Release 6.03.
[org-mode/org-tableheadings.git] / doc / org.texi
blob73180d5f79028bb3005195513e98046f45560fe2
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @set VERSION 6.03
7 @set DATE May 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 (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 The Org 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 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 came into being
94 * Main Index::                  An index of Org's concepts and features
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 does
103 * Installation::                How to install a downloaded version of Org
104 * Activation::                  How to activate Org for certain buffers
105 * Feedback::                    Bug reports, ideas, patches etc.
106 * Conventions::                 Type-setting conventions in the manual
108 Document Structure
110 * Outlines::                    Org 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
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 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::     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 * Timestamps::                  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::          Tracking how long you spend on a task
215 * Effort estimates::            Planning work effort in advance
217 Creating timestamps
219 * The date/time prompt::        How Org mode helps you entering date and time
220 * Custom time format::          Making dates look different
222 Deadlines and scheduling
224 * Inserting deadline/schedule::  Planning items
225 * Repeated tasks::              Items that show up again and again
227 Remember
229 * Setting up Remember::         Some code for .emacs to get things going
230 * Remember templates::          Define the outline of different note types
231 * Storing notes::               Directly get the note to where it belongs
232 * Refiling notes::              Moving a note or task to a project
234 Agenda Views
236 * Agenda files::                Files being searched for agenda information
237 * Agenda dispatcher::           Keyboard access to agenda views
238 * Built-in agenda views::       What is available out of the box?
239 * Presentation and sorting::    How agenda items are prepared for display
240 * Agenda commands::             Remote editing of Org trees
241 * Custom agenda views::         Defining special searches and views
242 * Agenda column view::          Using column view for collected entries
244 The built-in agenda views
246 * Weekly/daily agenda::         The calendar page with current tasks
247 * Global TODO list::            All unfinished action items
248 * Matching tags and properties::  Structured information with fine-tuned search
249 * Timeline::                    Time-sorted view for single file
250 * Keyword search::              Finding entries by keyword
251 * Stuck projects::              Find projects you need to review
253 Presentation and sorting
255 * Categories::                  Not all tasks are equal
256 * Time-of-day specifications::  How the agenda knows the time
257 * Sorting of agenda items::     The order of things
259 Custom agenda views
261 * Storing searches::            Type once, use often
262 * Block agenda::                All the stuff you need in a single buffer
263 * Setting Options::             Changing the rules
264 * Exporting Agenda Views::      Writing agendas to files
265 * Using the agenda elsewhere::  Using agenda information in other programs
267 Embedded LaTeX
269 * Math symbols::                TeX macros for symbols and Greek letters
270 * Subscripts and superscripts::  Simple syntax for raising/lowering text
271 * LaTeX fragments::             Complex formulas made easy
272 * Processing LaTeX fragments::  Previewing LaTeX processing
273 * CDLaTeX mode::                Speed up entering of formulas
275 Exporting
277 * Markup rules::                Which structures are recognized?
278 * Export options::              Per-file export settings
279 * The export dispatcher::       How to access exporter commands
280 * ASCII export::                Exporting to plain ASCII
281 * HTML export::                 Exporting to HTML
282 * LaTeX export::                Exporting to LaTeX
283 * XOXO export::                 Exporting to XOXO
284 * iCalendar export::            Exporting in iCalendar format
286 Markup rules
288 * Document title::              How the document title is determined
289 * Headings and sections::       The main structure of the exported document
290 * Table of contents::           If, where, how to create a table of contents
291 * Initial text::                Text before the first headline
292 * Lists::                       Plain lists are exported
293 * Paragraphs::                  What determines beginning and ending
294 * Literal examples::            Source code and other examples
295 * Include files::               Include the contents of a file during export
296 * Tables exported::             Tables are exported richly
297 * Footnotes::                   Numbers like [1]
298 * Emphasis and monospace::      To bold or not to bold
299 * TeX macros and LaTeX fragments::  Create special, rich export.
300 * Horizontal rules::            A line across the page
301 * Comment lines::               Some lines will not be exported
303 HTML export
305 * HTML Export commands::        How to invoke HTML export
306 * Quoting HTML tags::           Using direct HTML in Org mode
307 * Links::                       Transformation of links for HTML
308 * Images::                      How to include images
309 * CSS support::                 Changing the appearance of the output
310 * Javascript support::          Info and Folding in a web browser
312 LaTeX export
314 * LaTeX export commands::       How to invoke LaTeX export
315 * Quoting LaTeX code::          Incorporating literal LaTeX code
316 * Sectioning structure::        Changing sectioning in LaTeX output
318 Publishing
320 * Configuration::               Defining projects
321 * Sample configuration::        Example projects
322 * Triggering publication::      Publication commands
324 Configuration
326 * Project alist::               The central configuration variable
327 * Sources and destinations::    From here to there
328 * Selecting files::             What files are part of the project?
329 * Publishing action::           Setting the function doing the publishing
330 * Publishing options::          Tweaking HTML export
331 * Publishing links::            Which links keep working after publishing?
332 * Project page index::          Publishing a list of project files
334 Sample configuration
336 * Simple example::              One-component publishing
337 * Complex example::             A multi-component publishing example
339 Miscellaneous
341 * Completion::                  M-TAB knows what you need
342 * Customization::               Adapting Org to your taste
343 * In-buffer settings::          Overview of the #+KEYWORDS
344 * The very busy C-c C-c key::   When in doubt, press C-c C-c
345 * Clean view::                  Getting rid of leading stars in the outline
346 * TTY keys::                    Using Org on a tty
347 * Interaction::                 Other Emacs packages
348 * Bugs::                        Things which do not work perfectly
350 Interaction with other packages
352 * Cooperation::                 Packages Org cooperates with
353 * Conflicts::                   Packages that lead to conflicts
355 Extensions, Hooks and Hacking
357 * Extensions::                  Existing 3rd-party extensions
358 * Adding hyperlink types::      New custom link types
359 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
360 * Dynamic blocks::              Automatically filled blocks
361 * Special agenda views::        Customized views
362 * Using the property API::      Writing programs that use entry properties
364 Tables and lists in arbitrary syntax
366 * Radio tables::                Sending and receiving
367 * A LaTeX example::             Step by step, almost a tutorial
368 * Translator functions::        Copy and modify
369 * Radio lists::                 Doing the same for lists
371 @end detailmenu
372 @end menu
374 @node Introduction, Document Structure, Top, Top
375 @chapter Introduction
376 @cindex introduction
378 @menu
379 * Summary::                     Brief summary of what Org does
380 * Installation::                How to install a downloaded version of Org
381 * Activation::                  How to activate Org for certain buffers
382 * Feedback::                    Bug reports, ideas, patches etc.
383 * Conventions::                 Type-setting conventions in the manual
384 @end menu
386 @node Summary, Installation, Introduction, Introduction
387 @section Summary
388 @cindex summary
390 Org is a mode for keeping notes, maintaining TODO lists, and doing
391 project planning with a fast and effective plain-text system.
393 Org develops organizational tasks around NOTES files that contain
394 lists or information about projects as plain text.  Org is
395 implemented on top of Outline mode, which makes it possible to keep the
396 content of large files well structured.  Visibility cycling and
397 structure editing help to work with the tree.  Tables are easily created
398 with a built-in table editor.  Org supports TODO items, deadlines,
399 time stamps, and scheduling.  It dynamically compiles entries into an
400 agenda that utilizes and smoothly integrates much of the Emacs calendar
401 and diary.  Plain text URL-like links connect to websites, emails,
402 Usenet messages, BBDB entries, and any files related to the projects.
403 For printing and sharing of notes, an Org file can be exported as a
404 structured ASCII file, as HTML, or (TODO and agenda items only) as an
405 iCalendar file.  It can also serve as a publishing tool for a set of
406 linked web pages.
408 An important design aspect that distinguishes Org from for example
409 Planner/Muse is that it encourages to store every piece of information
410 only once.  In Planner, you have project pages, day pages and possibly
411 other files, duplicating some information such as tasks.  In Org,
412 you only have notes files.  In your notes you mark entries as tasks,
413 label them with tags and timestamps.  All necessary lists like a
414 schedule for the day, the agenda for a meeting, tasks lists selected by
415 tags etc are created dynamically when you need them.
417 Org keeps simple things simple.  When first fired up, it should
418 feel like a straightforward, easy to use outliner.  Complexity is not
419 imposed, but a large amount of functionality is available when you need
420 it.  Org is a toolbox and can be used in different ways, for
421 example as:
423 @example
424 @r{@bullet{} outline extension with visibility cycling and structure editing}
425 @r{@bullet{} ASCII system and table editor for taking structured notes}
426 @r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
427 @r{@bullet{} TODO list editor}
428 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
429 @r{@bullet{} environment to implement David Allen's GTD system}
430 @r{@bullet{} a basic database application}
431 @r{@bullet{} simple hypertext system, with HTML and LaTeX export}
432 @r{@bullet{} publishing tool to create a set of interlinked webpages}
433 @end example
435 Org's automatic, context sensitive table editor with spreadsheet
436 capabilities can be integrated into any major mode by activating the
437 minor Orgtbl mode.  Using a translation step, it can be used to maintain
438 tables in arbitrary file types, for example in La@TeX{}.  The structure
439 editing and list creation capabilities can be used outside Org with
440 the minor Orgstruct mode.
442 @cindex FAQ
443 There is a website for Org which provides links to the newest
444 version of Org, as well as additional information, frequently asked
445 questions (FAQ), links to tutorials etc.  This page is located at
446 @uref{http://orgmode.org}.
448 @page
451 @node Installation, Activation, Summary, Introduction
452 @section Installation
453 @cindex installation
454 @cindex XEmacs
456 @b{Important:} @i{If Org is part of the Emacs distribution or an
457 XEmacs package, please skip this section and go directly to
458 @ref{Activation}.}
460 If you have downloaded Org from the Web, either as a distribution @file{.zip}
461 or @file{.tar} file, or as a GIT archive, you must take the following steps
462 to install it: Go into the unpacked Org distribution directory and edit the
463 top section of the file @file{Makefile}.  You must set the name of the Emacs
464 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
465 directories where local Lisp and Info files are kept.  If you don't have
466 access to the system-wide directories, you can simply run Org directly from
467 the distribution directory by adding the @file{lisp} subdirectory to the
468 Emacs load path.  To do this, add the following line to @file{.emacs}:
470 @example
471 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
472 @end example
474 @noindent
475 If you plan to use code from the @file{contrib} subdirectory, do a similar
476 step for this directory:
478 @example
479 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
480 @end example
482 @b{XEmacs users now need to install the file @file{noutline.el} from
483 the @file{xemacs} sub-directory of the Org distribution.  Use the
484 command:}
486 @example
487 @b{make install-noutline}
488 @end example
490 @noindent Now byte-compile the Lisp files with the shell command:
492 @example
493 make
494 @end example
496 @noindent If you are running Org from the distribution directory, this is
497 all.  If you want to install into the system directories, use
499 @example
500 make install
501 make install-info
502 @end example
504 @noindent Then add to @file{.emacs}:
506 @lisp
507 ;; This line only if Org is not part of the X/Emacs distribution.
508 (require 'org-install)
509 @end lisp
512 @node Activation, Feedback, Installation, Introduction
513 @section Activation
514 @cindex activation
515 @cindex autoload
516 @cindex global key bindings
517 @cindex key bindings, global
519 @iftex
520 @b{Important:} @i{If you use copy-and-paste to copy lisp code from the
521 PDF documentation as viewed by Acrobat reader to your .emacs file, the
522 single quote character comes out incorrectly and the code will not work.
523 You need to fix the single quotes by hand, or copy from Info
524 documentation.}
525 @end iftex
527 Add the following lines to your @file{.emacs} file.  The last two lines
528 define @emph{global} keys for the commands @command{org-store-link},
529 @command{org-agenda}, and @command{org-iswitchb} - please choose suitable
530 keys yourself.
532 @lisp
533 ;; The following lines are always needed.  Choose your own keys.
534 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
535 (global-set-key "\C-cl" 'org-store-link)
536 (global-set-key "\C-ca" 'org-agenda)
537 (global-set-key "\C-cb" 'org-iswitchb)
538 @end lisp
540 Furthermore, you must activate @code{font-lock-mode} in Org
541 buffers, because significant functionality depends on font-locking being
542 active.  You can do this with either one of the following two lines
543 (XEmacs user must use the second option):
544 @lisp
545 (global-font-lock-mode 1)                     ; for all buffers
546 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
547 @end lisp
549 @cindex Org mode, turning on
550 With this setup, all files with extension @samp{.org} will be put
551 into Org mode.  As an alternative, make the first line of a file look
552 like this:
554 @example
555 MY PROJECTS    -*- mode: org; -*-
556 @end example
558 @noindent which will select Org mode for this buffer no matter what
559 the file's name is.  See also the variable
560 @code{org-insert-mode-line-in-empty-file}.
562 @node Feedback, Conventions, Activation, Introduction
563 @section Feedback
564 @cindex feedback
565 @cindex bug reports
566 @cindex maintainer
567 @cindex author
569 If you find problems with Org, or if you have questions, remarks,
570 or ideas about it, please contact the maintainer @value{MAINTAINER} at
571 @value{MAINTAINEREMAIL}.
573 For bug reports, please provide as much information as possible,
574 including the version information of Emacs (@kbd{C-h v emacs-version
575 @key{RET}}) and Org (@kbd{C-h v org-version @key{RET}}), as well as
576 the Org related setup in @file{.emacs}.  If an error occurs, a
577 backtrace can be very useful (see below on how to create one).  Often a
578 small example file helps, along with clear information about:
580 @enumerate
581 @item What exactly did you do?
582 @item What did you expect to happen?
583 @item What happened instead?
584 @end enumerate
585 @noindent Thank you for helping to improve this mode.
587 @subsubheading How to create a useful backtrace
589 @cindex backtrace of an error
590 If working with Org produces an error with a message you don't
591 understand, you may have hit a bug.  The best way to report this is by
592 providing, in addition to what was mentioned above, a @emph{Backtrace}.
593 This is information from the built-in debugger about where and how the
594 error occurred.  Here is how to produce a useful backtrace:
596 @enumerate
597 @item
598 Start a fresh Emacs or XEmacs, and make sure that it will load the
599 original Lisp code in @file{org.el} instead of the compiled version in
600 @file{org.elc}.  The backtrace contains much more information if it is
601 produced with uncompiled code.  To do this, either rename @file{org.elc}
602 to something else before starting Emacs, or ask Emacs explicitly to load
603 @file{org.el} by using the command line
604 @example
605 emacs -l /path/to/org.el
606 @end example
607 @item
608 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
609 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
610 @item
611 Do whatever you have to do to hit the error.  Don't forget to
612 document the steps you take.
613 @item
614 When you hit the error, a @file{*Backtrace*} buffer will appear on the
615 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
616 attach it to your bug report.
617 @end enumerate
619 @node Conventions,  , Feedback, Introduction
620 @section Typesetting conventions used in this manual
622 Org uses three types of keywords: TODO keywords, tags, and property
623 names.  In this manual we use the following conventions:
625 @table @code
626 @item TODO
627 @itemx WAITING
628 TODO keywords are written with all capitals, even if they are
629 user-defined.
630 @item boss
631 @itemx ARCHIVE
632 User-defined tags are written in lowercase; built-in tags with special
633 meaning are written with all capitals.
634 @item Release
635 @itemx PRIORITY
636 User-defined properties are capitalized; built-in properties with
637 special meaning are written with all capitals.
638 @end table
640 @node Document Structure, Tables, Introduction, Top
641 @chapter Document Structure
642 @cindex document structure
643 @cindex structure of document
645 Org is based on outline mode and provides flexible commands to
646 edit the structure of the document.
648 @menu
649 * Outlines::                    Org is based on Outline mode
650 * Headlines::                   How to typeset Org tree headlines
651 * Visibility cycling::          Show and hide, much simplified
652 * Motion::                      Jumping to other headlines
653 * Structure editing::           Changing sequence and level of headlines
654 * Archiving::                   Move done task trees to a different place
655 * Sparse trees::                Matches embedded in context
656 * Plain lists::                 Additional structure within an entry
657 * Drawers::                     Tucking stuff away
658 * Orgstruct mode::              Structure editing outside Org
659 @end menu
661 @node Outlines, Headlines, Document Structure, Document Structure
662 @section Outlines
663 @cindex outlines
664 @cindex Outline mode
666 Org is implemented on top of Outline mode.  Outlines allow a
667 document to be organized in a hierarchical structure, which (at least
668 for me) is the best representation of notes and thoughts.  An overview
669 of this structure is achieved by folding (hiding) large parts of the
670 document to show only the general document structure and the parts
671 currently being worked on.  Org greatly simplifies the use of
672 outlines by compressing the entire show/hide functionality into a single
673 command @command{org-cycle}, which is bound to the @key{TAB} key.
675 @node Headlines, Visibility cycling, Outlines, Document Structure
676 @section Headlines
677 @cindex headlines
678 @cindex outline tree
680 Headlines define the structure of an outline tree.  The headlines in
681 Org start with one or more stars, on the left margin@footnote{See
682 the variable @code{org-special-ctrl-a/e} to configure special behavior
683 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
685 @example
686 * Top level headline
687 ** Second level
688 *** 3rd level
689     some text
690 *** 3rd level
691     more text
693 * Another top level headline
694 @end example
696 @noindent Some people find the many stars too noisy and would prefer an
697 outline that has whitespace followed by a single star as headline
698 starters.  @ref{Clean view} describes a setup to realize this.
700 An empty line after the end of a subtree is considered part of it and
701 will be hidden when the subtree is folded.  However, if you leave at
702 least two empty lines, one empty line will remain visible after folding
703 the subtree, in order to structure the collapsed view.  See the
704 variable @code{org-cycle-separator-lines} to modify this behavior.
706 @node Visibility cycling, Motion, Headlines, Document Structure
707 @section Visibility cycling
708 @cindex cycling, visibility
709 @cindex visibility cycling
710 @cindex trees, visibility
711 @cindex show hidden text
712 @cindex hide text
714 Outlines make it possible to hide parts of the text in the buffer.
715 Org uses just two commands, bound to @key{TAB} and
716 @kbd{S-@key{TAB}} to change the visibility in the buffer.
718 @cindex subtree visibility states
719 @cindex subtree cycling
720 @cindex folded, subtree visibility state
721 @cindex children, subtree visibility state
722 @cindex subtree, subtree visibility state
723 @table @kbd
724 @kindex @key{TAB}
725 @item @key{TAB}
726 @emph{Subtree cycling}: Rotate current subtree among the states
728 @example
729 ,-> FOLDED -> CHILDREN -> SUBTREE --.
730 '-----------------------------------'
731 @end example
733 The cursor must be on a headline for this to work@footnote{see, however,
734 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
735 beginning of the buffer and the first line is not a headline, then
736 @key{TAB} actually runs global cycling (see below)@footnote{see the
737 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
738 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
740 @cindex global visibility states
741 @cindex global cycling
742 @cindex overview, global visibility state
743 @cindex contents, global visibility state
744 @cindex show all, global visibility state
745 @kindex S-@key{TAB}
746 @item S-@key{TAB}
747 @itemx C-u @key{TAB}
748 @emph{Global cycling}: Rotate the entire buffer among the states
750 @example
751 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
752 '--------------------------------------'
753 @end example
755 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
756 CONTENTS view up to headlines of level N will be shown.  Note that inside
757 tables, @kbd{S-@key{TAB}} jumps to the previous field.
759 @cindex show all, command
760 @kindex C-c C-a
761 @item C-c C-a
762 Show all.
763 @kindex C-c C-r
764 @item C-c C-r
765 Reveal context around point, showing the current entry, the following heading
766 and the hierarchy above.  Useful for working near a location that has been
767 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
768 (@pxref{Agenda commands}).  With a prefix argument show, on each
769 level, all sibling headings.
770 @kindex C-c C-x b
771 @item C-c C-x b
772 Show the current subtree in an indirect buffer@footnote{The indirect
773 buffer
774 @ifinfo
775 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
776 @end ifinfo
777 @ifnotinfo
778 (see the Emacs manual for more information about indirect buffers)
779 @end ifnotinfo
780 will contain the entire buffer, but will be narrowed to the current
781 tree.  Editing the indirect buffer will also change the original buffer,
782 but without affecting visibility in that buffer.}.  With a numeric
783 prefix argument N, go up to level N and then take that tree.  If N is
784 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
785 the previously used indirect buffer.
786 @end table
788 When Emacs first visits an Org file, the global state is set to
789 OVERVIEW, i.e. only the top level headlines are visible.  This can be
790 configured through the variable @code{org-startup-folded}, or on a
791 per-file basis by adding one of the following lines anywhere in the
792 buffer:
794 @example
795 #+STARTUP: overview
796 #+STARTUP: content
797 #+STARTUP: showall
798 @end example
800 @noindent
801 Forthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
802 and Columns}) will get their visibility adapted accordingly.  Allowed values
803 for this property are @code{folded}, @code{children}, @code{content}, and
804 @code{all}.
805 @table @kbd
806 @kindex C-u C-u @key{TAB}
807 @item C-u C-u @key{TAB}
808 Switch back to the startup visibility of the buffer, i.e. whatever is
809 requested by startup options and @samp{VISIBILITY} properties in individual
810 entries.
811 @end table
813 @node Motion, Structure editing, Visibility cycling, Document Structure
814 @section Motion
815 @cindex motion, between headlines
816 @cindex jumping, to headlines
817 @cindex headline navigation
818 The following commands jump to other headlines in the buffer.
820 @table @kbd
821 @kindex C-c C-n
822 @item C-c C-n
823 Next heading.
824 @kindex C-c C-p
825 @item C-c C-p
826 Previous heading.
827 @kindex C-c C-f
828 @item C-c C-f
829 Next heading same level.
830 @kindex C-c C-b
831 @item C-c C-b
832 Previous heading same level.
833 @kindex C-c C-u
834 @item C-c C-u
835 Backward to higher level heading.
836 @kindex C-c C-j
837 @item C-c C-j
838 Jump to a different place without changing the current outline
839 visibility.  Shows the document structure in a temporary buffer, where
840 you can use the following keys to find your destination:
841 @example
842 @key{TAB}         @r{Cycle visibility.}
843 @key{down} / @key{up}   @r{Next/previous visible headline.}
844 n / p        @r{Next/previous visible headline.}
845 f / b        @r{Next/previous headline same level.}
846 u            @r{One level up.}
847 0-9          @r{Digit argument.}
848 @key{RET}         @r{Select this location.}
849 @end example
850 @end table
852 @node Structure editing, Archiving, Motion, Document Structure
853 @section Structure editing
854 @cindex structure editing
855 @cindex headline, promotion and demotion
856 @cindex promotion, of subtrees
857 @cindex demotion, of subtrees
858 @cindex subtree, cut and paste
859 @cindex pasting, of subtrees
860 @cindex cutting, of subtrees
861 @cindex copying, of subtrees
862 @cindex subtrees, cut and paste
864 @table @kbd
865 @kindex M-@key{RET}
866 @item M-@key{RET}
867 Insert new heading with same level as current.  If the cursor is in a
868 plain list item, a new item is created (@pxref{Plain lists}).  To force
869 creation of a new headline, use a prefix argument, or first press @key{RET}
870 to get to the beginning of the next line.  When this command is used in
871 the middle of a line, the line is split and the rest of the line becomes
872 the new headline@footnote{If you do not want the line to be split,
873 customize the variable @code{org-M-RET-may-split-line}.}.  If the
874 command is used at the beginning of a headline, the new headline is
875 created before the current line.  If at the beginning of any other line,
876 the content of that line is made the new heading.  If the command is
877 used at the end of a folded subtree (i.e. behind the ellipses at the end
878 of a headline), then a headline like the current one will be inserted
879 after the end of the subtree.
880 @kindex C-@key{RET}
881 @item C-@key{RET}
882 Insert a new heading after the current subtree, same level as the
883 current headline.  This command works from anywhere in the entry.
884 @kindex M-S-@key{RET}
885 @item M-S-@key{RET}
886 Insert new TODO entry with same level as current heading.
887 @kindex M-@key{left}
888 @item M-@key{left}
889 Promote current heading by one level.
890 @kindex M-@key{right}
891 @item M-@key{right}
892 Demote current heading by one level.
893 @kindex M-S-@key{left}
894 @item M-S-@key{left}
895 Promote the current subtree by one level.
896 @kindex M-S-@key{right}
897 @item M-S-@key{right}
898 Demote the current subtree by one level.
899 @kindex M-S-@key{up}
900 @item M-S-@key{up}
901 Move subtree up (swap with previous subtree of same
902 level).
903 @kindex M-S-@key{down}
904 @item M-S-@key{down}
905 Move subtree down (swap with next subtree of same level).
906 @kindex C-c C-x C-w
907 @kindex C-c C-x C-k
908 @item C-c C-x C-w
909 @itemx C-c C-x C-k
910 Kill subtree, i.e. remove it from buffer but save in kill ring.
911 With a numeric prefix argument N, kill N sequential subtrees.
912 @kindex C-c C-x M-w
913 @item C-c C-x M-w
914 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
915 sequential subtrees.
916 @kindex C-c C-x C-y
917 @item C-c C-x C-y
918 Yank subtree from kill ring.  This does modify the level of the subtree to
919 make sure the tree fits in nicely at the yank position.  The yank level can
920 also be specified with a numeric prefix argument, or by yanking after a
921 headline marker like @samp{****}.
922 @kindex C-c C-w
923 @item C-c C-w
924 Refile entry to a different location.  @xref{Refiling notes}.
925 @kindex C-c ^
926 @item C-c ^
927 Sort same-level entries.  When there is an active region, all entries in the
928 region will be sorted.  Otherwise the children of the current headline are
929 sorted.  The command prompts for the sorting method, which can be
930 alphabetically, numerically, by time (using the first time stamp in each
931 entry), by priority, or by TODO keyword (in the sequence the keywords have
932 been defined in the setup).  Reverse sorting is possible as well.  You can
933 also supply your own function to extract the sorting key.  With a @kbd{C-u}
934 prefix, sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes,
935 duplicate entries will also be removed.
936 @kindex C-c *
937 @item C-c *
938 Turn a normal line or plain list item into a headline (so that it
939 becomes a subheading at its location).  Also turn a headline into a
940 normal line by removing the stars.  If there is an active region, turn
941 all lines in the region into headlines.  Or, if the first line is a
942 headline, remove the stars from all headlines in the region.
943 @end table
945 @cindex region, active
946 @cindex active region
947 @cindex Transient mark mode
948 When there is an active region (Transient mark mode), promotion and
949 demotion work on all headlines in the region.  To select a region of
950 headlines, it is best to place both point and mark at the beginning of a
951 line, mark at the beginning of the first headline, and point at the line
952 just after the last headline to change.  Note that when the cursor is
953 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
954 functionality.
956 @node Archiving, Sparse trees, Structure editing, Document Structure
957 @section Archiving
958 @cindex archiving
960 When a project represented by a (sub)tree is finished, you may want
961 to move the tree out of the way and to stop it from contributing to the
962 agenda.  Org mode knows two ways of archiving.  You can mark a tree with
963 the ARCHIVE tag, or you can move an entire (sub)tree to a different
964 location.
966 @menu
967 * ARCHIVE tag::                 Marking a tree as inactive
968 * Moving subtrees::             Moving a tree to an archive file
969 @end menu
971 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
972 @subsection The ARCHIVE tag
973 @cindex internal archiving
975 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
976 its location in the outline tree, but behaves in the following way:
977 @itemize @minus
978 @item
979 It does not open when you attempt to do so with a visibility cycling
980 command (@pxref{Visibility cycling}).  You can force cycling archived
981 subtrees with @kbd{C-@key{TAB}}, or by setting the option
982 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
983 @code{show-all} will open archived subtrees.
984 @item
985 During sparse tree construction (@pxref{Sparse trees}), matches in
986 archived subtrees are not exposed, unless you configure the option
987 @code{org-sparse-tree-open-archived-trees}.
988 @item
989 During agenda view construction (@pxref{Agenda Views}), the content of
990 archived trees is ignored unless you configure the option
991 @code{org-agenda-skip-archived-trees}.
992 @item
993 Archived trees are not exported (@pxref{Exporting}), only the headline
994 is.  Configure the details using the variable
995 @code{org-export-with-archived-trees}.
996 @end itemize
998 The following commands help managing the ARCHIVE tag:
1000 @table @kbd
1001 @kindex C-c C-x a
1002 @item C-c C-x a
1003 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
1004 the headline changes to a shadowed face, and the subtree below it is
1005 hidden.
1006 @kindex C-u C-c C-x a
1007 @item C-u C-c C-x a
1008 Check if any direct children of the current headline should be archived.
1009 To do this, each subtree is checked for open TODO entries.  If none are
1010 found, the command offers to set the ARCHIVE tag for the child.  If the
1011 cursor is @emph{not} on a headline when this command is invoked, the
1012 level 1 trees will be checked.
1013 @kindex C-@kbd{TAB}
1014 @item C-@kbd{TAB}
1015 Cycle a tree even if it is tagged with ARCHIVE.
1016 @end table
1018 @node Moving subtrees,  , ARCHIVE tag, Archiving
1019 @subsection Moving subtrees
1020 @cindex external archiving
1022 Once an entire project is finished, you may want to move it to a different
1023 location.  Org can move it to an @emph{Attic Sibling} in the same tree, to a
1024 different tree in the current file, or to a different file, the archive file.
1026 @table @kbd
1027 @kindex C-c C-x A
1028 @item C-c C-x A
1029 Move the current entry to the @emph{Attic Sibling}.  This is a sibling of the
1030 entry with the heading @samp{Attic} and the tag @samp{ARCHIVE}
1031 (@pxref{ARCHIVE tag}).  The entry becomes a child of that sibling and in this
1032 way retains a lot of its original context, including inherited tags and
1033 approximate position in the outline.
1034 @kindex C-c C-x C-s
1035 @item C-c C-x C-s
1036 Archive the subtree starting at the cursor position to the location
1037 given by @code{org-archive-location}.  Context information that could be
1038 lost like the file name, the category, inherited tags, and the TODO
1039 state will be store as properties in the entry.
1040 @kindex C-u C-c C-x C-s
1041 @item C-u C-c C-x C-s
1042 Check if any direct children of the current headline could be moved to
1043 the archive.  To do this, each subtree is checked for open TODO entries.
1044 If none are found, the command offers to move it to the archive
1045 location.  If the cursor is @emph{not} on a headline when this command
1046 is invoked, the level 1 trees will be checked.
1047 @end table
1049 @cindex archive locations
1050 The default archive location is a file in the same directory as the
1051 current file, with the name derived by appending @file{_archive} to the
1052 current file name.  For information and examples on how to change this,
1053 see the documentation string of the variable
1054 @code{org-archive-location}.  There is also an in-buffer option for
1055 setting this variable, for example@footnote{For backward compatibility,
1056 the following also works: If there are several such lines in a file,
1057 each specifies the archive location for the text below it.  The first
1058 such line also applies to any text before its definition.  However,
1059 using this method is @emph{strongly} deprecated as it is incompatible
1060 with the outline structure of the document.  The correct method for
1061 setting multiple archive locations in a buffer is using a property.}:
1063 @example
1064 #+ARCHIVE: %s_done::
1065 @end example
1067 @noindent
1068 If you would like to have a special ARCHIVE location for a single entry
1069 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1070 location as the value (@pxref{Properties and Columns}).
1072 When a subtree is moved, it receives a number of special properties that
1073 record context information like the file from where the entry came, it's
1074 outline path the archiving time etc.  Configure the variable
1075 @code{org-archive-save-context-info} to adjust the amount of information
1076 added.
1078 @node Sparse trees, Plain lists, Archiving, Document Structure
1079 @section Sparse trees
1080 @cindex sparse trees
1081 @cindex trees, sparse
1082 @cindex folding, sparse trees
1083 @cindex occur, command
1085 An important feature of Org mode is the ability to construct
1086 @emph{sparse trees} for selected information in an outline tree, so that
1087 the entire document is folded as much as possible, but the selected
1088 information is made visible along with the headline structure above
1089 it@footnote{See also the variables @code{org-show-hierarchy-above},
1090 @code{org-show-following-heading}, and @code{org-show-siblings} for
1091 detailed control on how much context is shown around each match.}.  Just
1092 try it out and you will see immediately how it works.
1094 Org mode contains several commands creating such trees, all these
1095 commands can be accessed through a dispatcher:
1097 @table @kbd
1098 @kindex C-c /
1099 @item C-c /
1100 This prompts for an extra key to select a sparse-tree creating command.
1101 @kindex C-c / r
1102 @item C-c / r
1103 Occur.  Prompts for a regexp and shows a sparse tree with all matches.
1104 If the match is in a headline, the headline is made visible.  If the
1105 match is in the body of an entry, headline and body are made visible.
1106 In order to provide minimal context, also the full hierarchy of
1107 headlines above the match is shown, as well as the headline following
1108 the match.  Each match is also highlighted; the highlights disappear
1109 when the buffer is changed by an editing command, or by pressing
1110 @kbd{C-c C-c}.  When called with a @kbd{C-u} prefix argument, previous
1111 highlights are kept, so several calls to this command can be stacked.
1112 @end table
1114 @noindent
1115 For frequently used sparse trees of specific search strings, you can
1116 use the variable @code{org-agenda-custom-commands} to define fast
1117 keyboard access to specific sparse trees.  These commands will then be
1118 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1119 For example:
1121 @lisp
1122 (setq org-agenda-custom-commands
1123       '(("f" occur-tree "FIXME")))
1124 @end lisp
1126 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1127 a sparse tree matching the string @samp{FIXME}.
1129 The other sparse tree commands select headings based on TODO keywords,
1130 tags, or properties and will be discussed later in this manual.
1132 @kindex C-c C-e v
1133 @cindex printing sparse trees
1134 @cindex visible text, printing
1135 To print a sparse tree, you can use the Emacs command
1136 @code{ps-print-buffer-with-faces} which does not print invisible parts
1137 of the document @footnote{This does not work under XEmacs, because
1138 XEmacs uses selective display for outlining, not text properties.}.
1139 Or you can use the command @kbd{C-c C-e v} to export only the visible
1140 part of the document and print the resulting file.
1142 @node Plain lists, Drawers, Sparse trees, Document Structure
1143 @section Plain lists
1144 @cindex plain lists
1145 @cindex lists, plain
1146 @cindex lists, ordered
1147 @cindex ordered lists
1149 Within an entry of the outline tree, hand-formatted lists can provide
1150 additional structure.  They also provide a way to create lists of
1151 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1152 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1154 Org knows ordered lists, unordered lists, and description lists.
1155 @itemize @bullet
1156 @item
1157 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1158 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1159 they will be seen as top-level headlines.  Also, when you are hiding leading
1160 stars to get a clean outline view, plain list items starting with a star are
1161 visually indistinguishable from true headlines.  In short: even though
1162 @samp{*} is supported, it may be better to not use it for plain list items.}
1163 as bullets.
1164 @item
1165 @emph{Ordered} list items start with a numeral followed by either a period or
1166 a right parenthesis, such as @samp{1.} or @samp{1)}.
1167 @item
1168 @emph{Description} list items are like unordered list items, but contain the
1169 separator @samp{ :: } to separate the description @emph{term} from the
1170 desciption.
1171 @end itemize
1173 Items belonging to the same list must have the same indentation on the first
1174 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1175 2--digit numbers must be written left-aligned with the other numbers in the
1176 list.  Indentation also determines the end of a list item.  It ends before
1177 the next line that is indented like the bullet/number, or less.  Empty lines
1178 are part of the previous item, so you can have several paragraphs in one
1179 item.  If you would like an empty line to terminate all currently open plain
1180 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1181 Here is an example:
1183 @example
1184 @group
1185 ** Lord of the Rings
1186    My favorite scenes are (in this order)
1187    1. The attack of the Rohirrim
1188    2. Eowyns fight with the witch king
1189       + this was already my favorite scene in the book
1190       + I really like Miranda Otto.
1191    3. Peter Jackson being shot by Legolas
1192        - on DVD only
1193       He makes a really funny face when it happens.
1194    But in the end, not individual scenes matter but the film as a whole.
1195    Important actors in this film are:
1196    - @b{Elijah Wood} :: He plays the Frodo
1197    - @b{Sean Austin} :: He plays the Sam, Frodos friend.  I still remember
1198      him very well from his role as Mikey Walsh a in the Goonies.
1199 @end group
1200 @end example
1202 Org supports these lists by tuning filling and wrapping commands to
1203 deal with them correctly@footnote{Org only changes the filling
1204 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1205 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1206 @code{(require 'filladapt)}}, and by exporting them properly
1207 (@pxref{Exporting}).
1209 The following commands act on items when the cursor is in the first line
1210 of an item (the line with the bullet or number).
1212 @table @kbd
1213 @kindex @key{TAB}
1214 @item @key{TAB}
1215 Items can be folded just like headline levels if you set the variable
1216 @code{org-cycle-include-plain-lists}.  The level of an item is then
1217 given by the indentation of the bullet/number.  Items are always
1218 subordinate to real headlines, however; the hierarchies remain
1219 completely separated.
1221 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1222 fixes the indentation of the current line in a heuristic way.
1223 @kindex M-@key{RET}
1224 @item M-@key{RET}
1225 Insert new item at current level.  With a prefix argument, force a new
1226 heading (@pxref{Structure editing}).  If this command is used in the middle
1227 of a line, the line is @emph{split} and the rest of the line becomes the new
1228 item@footnote{If you do not want the line to be split, customize the variable
1229 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1230 @emph{whitespace before a bullet or number}, the new item is created
1231 @emph{before} the current item.  If the command is executed in the white
1232 space before the text that is part of an item but does not contain the
1233 bullet, a bullet is added to the current line.
1234 @kindex M-S-@key{RET}
1235 @item M-S-@key{RET}
1236 Insert a new item with a checkbox (@pxref{Checkboxes}).
1237 @kindex S-@key{up}
1238 @kindex S-@key{down}
1239 @item S-@key{up}
1240 @itemx S-@key{down}
1241 Jump to the previous/next item in the current list.
1242 @kindex M-S-@key{up}
1243 @kindex M-S-@key{down}
1244 @item M-S-@key{up}
1245 @itemx M-S-@key{down}
1246 Move the item including subitems up/down (swap with previous/next item
1247 of same indentation).  If the list is ordered, renumbering is
1248 automatic.
1249 @kindex M-S-@key{left}
1250 @kindex M-S-@key{right}
1251 @item M-S-@key{left}
1252 @itemx M-S-@key{right}
1253 Decrease/increase the indentation of the item, including subitems.
1254 Initially, the item tree is selected based on current indentation.
1255 When these commands are executed several times in direct succession,
1256 the initially selected region is used, even if the new indentation
1257 would imply a different hierarchy.  To use the new hierarchy, break
1258 the command chain with a cursor motion or so.
1259 @kindex C-c C-c
1260 @item C-c C-c
1261 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1262 state of the checkbox.  If not, this command makes sure that all the
1263 items on this list level use the same bullet.  Furthermore, if this is
1264 an ordered list, make sure the numbering is OK.
1265 @kindex C-c -
1266 @item C-c -
1267 Cycle the entire list level through the different itemize/enumerate bullets
1268 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1269 argument N, select the Nth bullet from this list.  If there is an active
1270 region when calling this, all lines will be converted to list items.  If the
1271 first line already was a list item, any item markers will be removed from the
1272 list.  Finally, even without an active region, a normal line will be
1273 converted into a list item.
1274 @end table
1276 @node Drawers, Orgstruct mode, Plain lists, Document Structure
1277 @section Drawers
1278 @cindex drawers
1279 @cindex visibility cycling, drawers
1281 Sometimes you want to keep information associated with an entry, but you
1282 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1283 Drawers need to be configured with the variable
1284 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1285 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1286 look like this:
1288 @example
1289 ** This is a headline
1290    Still outside the drawer
1291    :DRAWERNAME:
1292       This is inside the drawer.
1293    :END:
1294    After the drawer.
1295 @end example
1297 Visibility cycling (@pxref{Visibility cycling}) on the headline will
1298 hide and show the entry, but keep the drawer collapsed to a single line.
1299 In order to look inside the drawer, you need to move the cursor to the
1300 drawer line and press @key{TAB} there.  Org mode uses a drawer for
1301 storing properties (@pxref{Properties and Columns}), and another one for
1302 storing clock times (@pxref{Clocking work time}).
1304 @node Orgstruct mode,  , Drawers, Document Structure
1305 @section The Orgstruct minor mode
1306 @cindex Orgstruct mode
1307 @cindex minor mode for structure editing
1309 If you like the intuitive way the Org mode structure editing and list
1310 formatting works, you might want to use these commands in other modes
1311 like Text mode or Mail mode as well.  The minor mode Orgstruct mode
1312 makes this possible.  You can always toggle the mode with @kbd{M-x
1313 orgstruct-mode}.  To turn it on by default, for example in Mail mode,
1316 @lisp
1317 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1318 @end lisp
1320 When this mode is active and the cursor is on a line that looks to
1321 Org like a headline of the first line of a list item, most
1322 structure editing commands will work, even if the same keys normally
1323 have different functionality in the major mode you are using.  If the
1324 cursor is not in one of those special lines, Orgstruct mode lurks
1325 silently in the shadow.
1327 @node Tables, Hyperlinks, Document Structure, Top
1328 @chapter Tables
1329 @cindex tables
1330 @cindex editing tables
1332 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1333 calculations are supported in connection with the Emacs @file{calc}
1334 package
1335 @ifinfo
1336 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1337 @end ifinfo
1338 @ifnotinfo
1339 (see the Emacs Calculator manual for more information about the Emacs
1340 calculator).
1341 @end ifnotinfo
1343 @menu
1344 * Built-in table editor::       Simple tables
1345 * Narrow columns::              Stop wasting space in tables
1346 * Column groups::               Grouping to trigger vertical lines
1347 * Orgtbl mode::                 The table editor as minor mode
1348 * The spreadsheet::             The table editor has spreadsheet capabilities
1349 @end menu
1351 @node Built-in table editor, Narrow columns, Tables, Tables
1352 @section The built-in table editor
1353 @cindex table editor, built-in
1355 Org makes it easy to format tables in plain ASCII.  Any line with
1356 @samp{|} as the first non-whitespace character is considered part of a
1357 table.  @samp{|} is also the column separator.  A table might look like
1358 this:
1360 @example
1361 | Name  | Phone | Age |
1362 |-------+-------+-----|
1363 | Peter |  1234 |  17 |
1364 | Anna  |  4321 |  25 |
1365 @end example
1367 A table is re-aligned automatically each time you press @key{TAB} or
1368 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1369 the next field (@key{RET} to the next row) and creates new table rows
1370 at the end of the table or before horizontal lines.  The indentation
1371 of the table is set by the first line.  Any line starting with
1372 @samp{|-} is considered as a horizontal separator line and will be
1373 expanded on the next re-align to span the whole table width.  So, to
1374 create the above table, you would only type
1376 @example
1377 |Name|Phone|Age|
1379 @end example
1381 @noindent and then press @key{TAB} to align the table and start filling in
1382 fields.
1384 When typing text into a field, Org treats @key{DEL},
1385 @key{Backspace}, and all character keys in a special way, so that
1386 inserting and deleting avoids shifting other fields.  Also, when
1387 typing @emph{immediately after the cursor was moved into a new field
1388 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1389 field is automatically made blank.  If this behavior is too
1390 unpredictable for you, configure the variables
1391 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1393 @table @kbd
1394 @tsubheading{Creation and conversion}
1395 @kindex C-c |
1396 @item C-c |
1397 Convert the active region to table. If every line contains at least one
1398 TAB character, the function assumes that the material is tab separated.
1399 If every line contains a comma, comma-separated values (CSV) are assumed.
1400 If not, lines are split at whitespace into fields.  You can use a prefix
1401 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1402 C-u} forces TAB, and a numeric argument N indicates that at least N
1403 consecutive spaces, or alternatively a TAB will be the separator.
1405 If there is no active region, this command creates an empty Org
1406 table.  But it's easier just to start typing, like
1407 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1409 @tsubheading{Re-aligning and field motion}
1410 @kindex C-c C-c
1411 @item C-c C-c
1412 Re-align the table without moving the cursor.
1414 @kindex @key{TAB}
1415 @item @key{TAB}
1416 Re-align the table, move to the next field.  Creates a new row if
1417 necessary.
1419 @kindex S-@key{TAB}
1420 @item S-@key{TAB}
1421 Re-align, move to previous field.
1423 @kindex @key{RET}
1424 @item @key{RET}
1425 Re-align the table and move down to next row.  Creates a new row if
1426 necessary.  At the beginning or end of a line, @key{RET} still does
1427 NEWLINE, so it can be used to split a table.
1429 @tsubheading{Column and row editing}
1430 @kindex M-@key{left}
1431 @kindex M-@key{right}
1432 @item M-@key{left}
1433 @itemx M-@key{right}
1434 Move the current column left/right.
1436 @kindex M-S-@key{left}
1437 @item M-S-@key{left}
1438 Kill the current column.
1440 @kindex M-S-@key{right}
1441 @item M-S-@key{right}
1442 Insert a new column to the left of the cursor position.
1444 @kindex M-@key{up}
1445 @kindex M-@key{down}
1446 @item M-@key{up}
1447 @itemx M-@key{down}
1448 Move the current row up/down.
1450 @kindex M-S-@key{up}
1451 @item M-S-@key{up}
1452 Kill the current row or horizontal line.
1454 @kindex M-S-@key{down}
1455 @item M-S-@key{down}
1456 Insert a new row above the current row.  With a prefix argument, the line is
1457 created below the current one.
1459 @kindex C-c -
1460 @item C-c -
1461 Insert a horizontal line below current row. With a prefix argument, the line
1462 is created above the current line.
1464 @kindex C-c ^
1465 @item C-c ^
1466 Sort the table lines in the region.  The position of point indicates the
1467 column to be used for sorting, and the range of lines is the range
1468 between the nearest horizontal separator lines, or the entire table.  If
1469 point is before the first column, you will be prompted for the sorting
1470 column.  If there is an active region, the mark specifies the first line
1471 and the sorting column, while point should be in the last line to be
1472 included into the sorting.  The command prompts for the sorting type
1473 (alphabetically, numerically, or by time).  When called with a prefix
1474 argument, alphabetic sorting will be case-sensitive.
1476 @tsubheading{Regions}
1477 @kindex C-c C-x M-w
1478 @item C-c C-x M-w
1479 Copy a rectangular region from a table to a special clipboard.  Point
1480 and mark determine edge fields of the rectangle.  The process ignores
1481 horizontal separator lines.
1483 @kindex C-c C-x C-w
1484 @item C-c C-x C-w
1485 Copy a rectangular region from a table to a special clipboard, and
1486 blank all fields in the rectangle.  So this is the ``cut'' operation.
1488 @kindex C-c C-x C-y
1489 @item C-c C-x C-y
1490 Paste a rectangular region into a table.
1491 The upper right corner ends up in the current field.  All involved fields
1492 will be overwritten.  If the rectangle does not fit into the present table,
1493 the table is enlarged as needed.  The process ignores horizontal separator
1494 lines.
1496 @kindex C-c C-q
1497 @kindex M-@key{RET}
1498 @item C-c C-q
1499 @itemx M-@kbd{RET}
1500 Wrap several fields in a column like a paragraph.  If there is an active
1501 region, and both point and mark are in the same column, the text in the
1502 column is wrapped to minimum width for the given number of lines.  A numeric
1503 prefix argument may be used to change the number of desired lines.  If there
1504 is no region, the current field is split at the cursor position and the text
1505 fragment to the right of the cursor is prepended to the field one line
1506 down. If there is no region, but you specify a prefix argument, the current
1507 field is made blank, and the content is appended to the field above.
1509 @tsubheading{Calculations}
1510 @cindex formula, in tables
1511 @cindex calculations, in tables
1512 @cindex region, active
1513 @cindex active region
1514 @cindex Transient mark mode
1515 @kindex C-c +
1516 @item C-c +
1517 Sum the numbers in the current column, or in the rectangle defined by
1518 the active region.  The result is shown in the echo area and can
1519 be inserted with @kbd{C-y}.
1521 @kindex S-@key{RET}
1522 @item S-@key{RET}
1523 When current field is empty, copy from first non-empty field above.
1524 When not empty, copy current field down to next row and move cursor
1525 along with it.  Depending on the variable
1526 @code{org-table-copy-increment}, integer field values will be
1527 incremented during copy.  This key is also used by CUA mode
1528 (@pxref{Cooperation}).
1530 @tsubheading{Miscellaneous}
1531 @kindex C-c `
1532 @item C-c `
1533 Edit the current field in a separate window.  This is useful for fields
1534 that are not fully visible (@pxref{Narrow columns}).  When called with a
1535 @kbd{C-u} prefix, just make the full field visible, so that it can be
1536 edited in place.
1538 @item M-x org-table-import
1539 Import a file as a table.  The table should be TAB- or whitespace
1540 separated.  Useful, for example, to import a spreadsheet table or data
1541 from a database, because these programs generally can write
1542 TAB-separated text files.  This command works by inserting the file into
1543 the buffer and then converting the region to a table.  Any prefix
1544 argument is passed on to the converter, which uses it to determine the
1545 separator.
1546 @item C-c |
1547 Tables can also be imported by pasting tabular text into the Org
1548 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1549 @kbd{C-c |} command (see above under @i{Creation and conversion}.
1551 @item M-x org-table-export
1552 Export the table, by default as a TAB-separated file.  Useful for data
1553 exchange with, for example, spreadsheet or database programs.  The format
1554 used to export the file can be configured in the variable
1555 @code{org-table-export-default-format}.  You may also use properties
1556 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1557 name and the format for table export in a subtree.  Org supports quite
1558 general formats for exported tables.  The exporter format is the same as the
1559 format used by Orgtbl radio tables, see @ref{Translator functions} for a
1560 detailed description.
1561 @end table
1563 If you don't like the automatic table editor because it gets in your
1564 way on lines which you would like to start with @samp{|}, you can turn
1565 it off with
1567 @lisp
1568 (setq org-enable-table-editor nil)
1569 @end lisp
1571 @noindent Then the only table command that still works is
1572 @kbd{C-c C-c} to do a manual re-align.
1574 @node Narrow columns, Column groups, Built-in table editor, Tables
1575 @section Narrow columns
1576 @cindex narrow columns in tables
1578 The width of columns is automatically determined by the table editor.
1579 Sometimes a single field or a few fields need to carry more text,
1580 leading to inconveniently wide columns.  To limit@footnote{This feature
1581 does not work on XEmacs.} the width of a column, one field anywhere in
1582 the column may contain just the string @samp{<N>} where @samp{N} is an
1583 integer specifying the width of the column in characters.  The next
1584 re-align will then set the width of this column to no more than this
1585 value.
1587 @example
1588 @group
1589 |---+------------------------------|               |---+--------|
1590 |   |                              |               |   | <6>    |
1591 | 1 | one                          |               | 1 | one    |
1592 | 2 | two                          |     ----\     | 2 | two    |
1593 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1594 | 4 | four                         |               | 4 | four   |
1595 |---+------------------------------|               |---+--------|
1596 @end group
1597 @end example
1599 @noindent
1600 Fields that are wider become clipped and end in the string @samp{=>}.
1601 Note that the full text is still in the buffer, it is only invisible.
1602 To see the full text, hold the mouse over the field - a tool-tip window
1603 will show the full content.  To edit such a field, use the command
1604 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1605 open a new window with the full field.  Edit it and finish with @kbd{C-c
1606 C-c}.
1608 When visiting a file containing a table with narrowed columns, the
1609 necessary character hiding has not yet happened, and the table needs to
1610 be aligned before it looks nice.  Setting the option
1611 @code{org-startup-align-all-tables} will realign all tables in a file
1612 upon visiting, but also slow down startup.  You can also set this option
1613 on a per-file basis with:
1615 @example
1616 #+STARTUP: align
1617 #+STARTUP: noalign
1618 @end example
1620 @node Column groups, Orgtbl mode, Narrow columns, Tables
1621 @section Column groups
1622 @cindex grouping columns in tables
1624 When Org exports tables, it does so by default without vertical
1625 lines because that is visually more satisfying in general.  Occasionally
1626 however, vertical lines can be useful to structure a table into groups
1627 of columns, much like horizontal lines can do for groups of rows.  In
1628 order to specify column groups, you can use a special row where the
1629 first field contains only @samp{/}.  The further fields can either
1630 contain @samp{<} to indicate that this column should start a group,
1631 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1632 a group of its own.  Boundaries between column groups will upon export be
1633 marked with vertical lines.  Here is an example:
1635 @example
1636 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1637 |---+----+-----+-----+-----+---------+------------|
1638 | / | <> |   < |     |   > |       < |          > |
1639 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1640 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1641 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1642 |---+----+-----+-----+-----+---------+------------|
1643 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2))
1644 @end example
1646 It is also sufficient to just insert the column group starters after
1647 every vertical line you'd like to have:
1649 @example
1650 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1651 |----+-----+-----+-----+---------+------------|
1652 | /  | <   |     |     | <       |            |
1653 @end example
1655 @node Orgtbl mode, The spreadsheet, Column groups, Tables
1656 @section The Orgtbl minor mode
1657 @cindex Orgtbl mode
1658 @cindex minor mode for tables
1660 If you like the intuitive way the Org table editor works, you
1661 might also want to use it in other modes like Text mode or Mail mode.
1662 The minor mode Orgtbl mode makes this possible.  You can always toggle
1663 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1664 example in mail mode, use
1666 @lisp
1667 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1668 @end lisp
1670 Furthermore, with some special setup, it is possible to maintain tables
1671 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
1672 construct La@TeX{} tables with the underlying ease and power of
1673 Orgtbl mode, including spreadsheet capabilities.  For details, see
1674 @ref{Tables in arbitrary syntax}.
1676 @node The spreadsheet,  , Orgtbl mode, Tables
1677 @section The spreadsheet
1678 @cindex calculations, in tables
1679 @cindex spreadsheet capabilities
1680 @cindex @file{calc} package
1682 The table editor makes use of the Emacs @file{calc} package to implement
1683 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1684 derive fields from other fields.  While fully featured, Org's
1685 implementation is not identical to other spreadsheets.  For example,
1686 Org knows the concept of a @emph{column formula} that will be
1687 applied to all non-header fields in a column without having to copy the
1688 formula to each relevant field.
1690 @menu
1691 * References::                  How to refer to another field or range
1692 * Formula syntax for Calc::     Using Calc to compute stuff
1693 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1694 * Field formulas::              Formulas valid for a single field
1695 * Column formulas::             Formulas valid for an entire column
1696 * Editing and debugging formulas::  Fixing formulas
1697 * Updating the table::          Recomputing all dependent fields
1698 * Advanced features::           Field names, parameters and automatic recalc
1699 @end menu
1701 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1702 @subsection References
1703 @cindex references
1705 To compute fields in the table from other fields, formulas must
1706 reference other fields or ranges.  In Org, fields can be referenced
1707 by name, by absolute coordinates, and by relative coordinates.  To find
1708 out what the coordinates of a field are, press @kbd{C-c ?} in that
1709 field, or press @kbd{C-c @}} to toggle the display of a grid.
1711 @subsubheading Field references
1712 @cindex field references
1713 @cindex references, to fields
1715 Formulas can reference the value of another field in two ways.  Like in
1716 any other spreadsheet, you may reference fields with a letter/number
1717 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1718 @c Such references are always fixed to that field, they don't change
1719 @c when you copy and paste a formula to a different field.  So
1720 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1722 @noindent
1723 Org also uses another, more general operator that looks like this:
1724 @example
1725 @@row$column
1726 @end example
1728 @noindent
1729 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1730 or relative to the current column like @samp{+1} or @samp{-2}.
1732 The row specification only counts data lines and ignores horizontal
1733 separator lines (hlines).  You can use absolute row numbers
1734 @samp{1}...@samp{N}, and row numbers relative to the current row like
1735 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1736 hlines: @samp{I} refers to the first hline@footnote{Note that only
1737 hlines are counted that @emph{separate} table lines.  If the table
1738 starts with a hline above the header, it does not count.}, @samp{II} to
1739 the second etc.  @samp{-I} refers to the first such line above the
1740 current line, @samp{+I} to the first such line below the current line.
1741 You can also write @samp{III+2} which is the second data line after the
1742 third hline in the table.  Relative row numbers like @samp{-3} will not
1743 cross hlines if the current line is too close to the hline.  Instead,
1744 the value directly at the hline is used.
1746 @samp{0} refers to the current row and column.  Also, if you omit
1747 either the column or the row part of the reference, the current
1748 row/column is implied.
1750 Org's references with @emph{unsigned} numbers are fixed references
1751 in the sense that if you use the same reference in the formula for two
1752 different fields, the same field will be referenced each time.
1753 Org's references with @emph{signed} numbers are floating
1754 references because the same reference operator can reference different
1755 fields depending on the field being calculated by the formula.
1757 Here are a few examples:
1759 @example
1760 @@2$3      @r{2nd row, 3rd column}
1761 C2        @r{same as previous}
1762 $5        @r{column 5 in the current row}
1763 E&        @r{same as previous}
1764 @@2        @r{current column, row 2}
1765 @@-1$-3    @r{the field one row up, three columns to the left}
1766 @@-I$2     @r{field just under hline above current row, column 2}
1767 @end example
1769 @subsubheading Range references
1770 @cindex range references
1771 @cindex references, to ranges
1773 You may reference a rectangular range of fields by specifying two field
1774 references connected by two dots @samp{..}.  If both fields are in the
1775 current row, you may simply use @samp{$2..$7}, but if at least one field
1776 is in a different row, you need to use the general @code{@@row$column}
1777 format at least for the first field (i.e the reference must start with
1778 @samp{@@} in order to be interpreted correctly).  Examples:
1780 @example
1781 $1..$3        @r{First three fields in the current row.}
1782 $P..$Q        @r{Range, using column names (see under Advanced)}
1783 @@2$1..@@4$3    @r{6 fields between these two fields.}
1784 A2..C4        @r{Same as above.}
1785 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
1786 @end example
1788 @noindent Range references return a vector of values that can be fed
1789 into Calc vector functions.  Empty fields in ranges are normally
1790 suppressed, so that the vector contains only the non-empty fields (but
1791 see the @samp{E} mode switch below).  If there are no non-empty fields,
1792 @samp{[0]} is returned to avoid syntax errors in formulas.
1794 @subsubheading Named references
1795 @cindex named references
1796 @cindex references, named
1797 @cindex name, of column or field
1798 @cindex constants, in calculations
1800 @samp{$name} is interpreted as the name of a column, parameter or
1801 constant.  Constants are defined globally through the variable
1802 @code{org-table-formula-constants}, and locally (for the file) through a
1803 line like
1805 @example
1806 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
1807 @end example
1809 @noindent
1810 Also properties (@pxref{Properties and Columns}) can be used as
1811 constants in table formulas: For a property @samp{:Xyz:} use the name
1812 @samp{$PROP_Xyz}, and the property will be searched in the current
1813 outline entry and in the hierarchy above it.  If you have the
1814 @file{constants.el} package, it will also be used to resolve constants,
1815 including natural constants like @samp{$h} for Planck's constant, and
1816 units like @samp{$km} for kilometers@footnote{@file{Constant.el} can
1817 supply the values of constants in two different unit systems, @code{SI}
1818 and @code{cgs}.  Which one is used depends on the value of the variable
1819 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
1820 @code{constSI} and @code{constcgs} to set this value for the current
1821 buffer.}.  Column names and parameters can be specified in special table
1822 lines.  These are described below, see @ref{Advanced features}.  All
1823 names must start with a letter, and further consist of letters and
1824 numbers.
1826 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
1827 @subsection Formula syntax for Calc
1828 @cindex formula syntax, Calc
1829 @cindex syntax, of formulas
1831 A formula can be any algebraic expression understood by the Emacs
1832 @file{Calc} package.  @b{Note that @file{calc} has the
1833 non-standard convention that @samp{/} has lower precedence than
1834 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
1835 evaluation by @code{calc-eval} (@pxref{Calling Calc from
1836 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
1837 Emacs Calc Manual}),
1838 @c FIXME:  The link to the Calc manual in HTML does not work.
1839 variable substitution takes place according to the rules described above.
1840 @cindex vectors, in table calculations
1841 The range vectors can be directly fed into the Calc vector functions
1842 like @samp{vmean} and @samp{vsum}.
1844 @cindex format specifier
1845 @cindex mode, for @file{calc}
1846 A formula can contain an optional mode string after a semicolon.  This
1847 string consists of flags to influence Calc and other modes during
1848 execution.  By default, Org uses the standard Calc modes (precision
1849 12, angular units degrees, fraction and symbolic modes off.  The display
1850 format, however, has been changed to @code{(float 5)} to keep tables
1851 compact.  The default settings can be configured using the variable
1852 @code{org-calc-default-modes}.
1854 @example
1855 p20           @r{switch the internal precision to 20 digits}
1856 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
1857 D R           @r{angle modes: degrees, radians}
1858 F S           @r{fraction and symbolic modes}
1859 N             @r{interpret all fields as numbers, use 0 for non-numbers}
1860 T             @r{force text interpretation}
1861 E             @r{keep empty fields in ranges}
1862 @end example
1864 @noindent
1865 In addition, you may provide a @code{printf} format specifier to
1866 reformat the final result.  A few examples:
1868 @example
1869 $1+$2                @r{Sum of first and second field}
1870 $1+$2;%.2f           @r{Same, format result to two decimals}
1871 exp($2)+exp($1)      @r{Math functions can be used}
1872 $0;%.1f              @r{Reformat current cell to 1 decimal}
1873 ($3-32)*5/9          @r{Degrees F -> C conversion}
1874 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
1875 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
1876 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
1877 vmean($2..$7)        @r{Compute column range mean, using vector function}
1878 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
1879 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
1880 @end example
1882 Calc also contains a complete set of logical operations.  For example
1884 @example
1885 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
1886 @end example
1888 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
1889 @subsection Emacs Lisp forms as formulas
1890 @cindex Lisp forms, as table formulas
1892 It is also possible to write a formula in Emacs Lisp; this can be useful
1893 for string manipulation and control structures, if the Calc's
1894 functionality is not enough.  If a formula starts with a single quote
1895 followed by an opening parenthesis, then it is evaluated as a lisp form.
1896 The evaluation should return either a string or a number.  Just as with
1897 @file{calc} formulas, you can specify modes and a printf format after a
1898 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
1899 field references are interpolated into the form.  By default, a
1900 reference will be interpolated as a Lisp string (in double quotes)
1901 containing the field.  If you provide the @samp{N} mode switch, all
1902 referenced elements will be numbers (non-number fields will be zero) and
1903 interpolated as Lisp numbers, without quotes.  If you provide the
1904 @samp{L} flag, all fields will be interpolated literally, without quotes.
1905 I.e., if you want a reference to be interpreted as a string by the Lisp
1906 form, enclose the reference operator itself in double quotes, like
1907 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
1908 embed them in list or vector syntax.  A few examples, note how the
1909 @samp{N} mode is used when we do computations in lisp.
1911 @example
1912 @r{Swap the first two characters of the content of column 1}
1913   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
1914 @r{Add columns 1 and 2, equivalent to the Calc's @code{$1+$2}}
1915   '(+ $1 $2);N
1916 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
1917   '(apply '+ '($1..$4));N
1918 @end example
1920 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
1921 @subsection Field formulas
1922 @cindex field formula
1923 @cindex formula, for individual table field
1925 To assign a formula to a particular field, type it directly into the
1926 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
1927 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
1928 the field, the formula will be stored as the formula for this field,
1929 evaluated, and the current field replaced with the result.
1931 Formulas are stored in a special line starting with @samp{#+TBLFM:}
1932 directly below the table.  If you typed the equation in the 4th field of
1933 the 3rd data line in the table, the formula will look like
1934 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
1935 with the appropriate commands, @i{absolute references} (but not relative
1936 ones) in stored formulas are modified in order to still reference the
1937 same field.  Of cause this is not true if you edit the table structure
1938 with normal editing commands - then you must fix the equations yourself.
1940 Instead of typing an equation into the field, you may also use the
1941 following command
1943 @table @kbd
1944 @kindex C-u C-c =
1945 @item C-u C-c =
1946 Install a new formula for the current field.  The command prompts for a
1947 formula, with default taken from the @samp{#+TBLFM:} line, applies
1948 it to the current field and stores it.
1949 @end table
1951 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
1952 @subsection Column formulas
1953 @cindex column formula
1954 @cindex formula, for table column
1956 Often in a table, the same formula should be used for all fields in a
1957 particular column.  Instead of having to copy the formula to all fields
1958 in that column, Org allows to assign a single formula to an entire
1959 column.  If the table contains horizontal separator hlines, everything
1960 before the first such line is considered part of the table @emph{header}
1961 and will not be modified by column formulas.
1963 To assign a formula to a column, type it directly into any field in the
1964 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
1965 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
1966 field, the formula will be stored as the formula for the current column,
1967 evaluated and the current field replaced with the result.  If the field
1968 contains only @samp{=}, the previously stored formula for this column is
1969 used.  For each column, Org will only remember the most recently
1970 used formula.  In the @samp{TBLFM:} line, column formulas will look like
1971 @samp{$4=$1+$2}.
1973 Instead of typing an equation into the field, you may also use the
1974 following command:
1976 @table @kbd
1977 @kindex C-c =
1978 @item C-c =
1979 Install a new formula for the current column and replace current field with
1980 the result of the formula.  The command prompts for a formula, with default
1981 taken from the @samp{#+TBLFM} line, applies it to the current field and
1982 stores it.  With a numeric prefix argument(e.g. @kbd{C-5 C-c =}) the command
1983 will apply it to that many consecutive fields in the current column.
1984 @end table
1986 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
1987 @subsection Editing and debugging formulas
1988 @cindex formula editing
1989 @cindex editing, of table formulas
1991 You can edit individual formulas in the minibuffer or directly in the
1992 field.  Org can also prepare a special buffer with all active
1993 formulas of a table.  When offering a formula for editing, Org
1994 converts references to the standard format (like @code{B3} or @code{D&})
1995 if possible.  If you prefer to only work with the internal format (like
1996 @code{@@3$2} or @code{$4}), configure the variable
1997 @code{org-table-use-standard-references}.
1999 @table @kbd
2000 @kindex C-c =
2001 @kindex C-u C-c =
2002 @item C-c =
2003 @itemx C-u C-c =
2004 Edit the formula associated with the current column/field in the
2005 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
2006 @kindex C-u C-u C-c =
2007 @item C-u C-u C-c =
2008 Re-insert the active formula (either a
2009 field formula, or a column formula) into the current field, so that you
2010 can edit it directly in the field.  The advantage over editing in the
2011 minibuffer is that you can use the command @kbd{C-c ?}.
2012 @kindex C-c ?
2013 @item C-c ?
2014 While editing a formula in a table field, highlight the field(s)
2015 referenced by the reference at the cursor position in the formula.
2016 @kindex C-c @}
2017 @item C-c @}
2018 Toggle the display of row and column numbers for a table, using
2019 overlays.  These are updated each time the table is aligned, you can
2020 force it with @kbd{C-c C-c}.
2021 @kindex C-c @{
2022 @item C-c @{
2023 Toggle the formula debugger on and off.  See below.
2024 @kindex C-c '
2025 @item C-c '
2026 Edit all formulas for the current table in a special buffer, where the
2027 formulas will be displayed one per line.  If the current field has an
2028 active formula, the cursor in the formula editor will mark it.
2029 While inside the special buffer, Org will automatically highlight
2030 any field or range reference at the cursor position.  You may edit,
2031 remove and add formulas, and use the following commands:
2032 @table @kbd
2033 @kindex C-c C-c
2034 @kindex C-x C-s
2035 @item C-c C-c
2036 @itemx C-x C-s
2037 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2038 prefix, also apply the new formulas to the entire table.
2039 @kindex C-c C-q
2040 @item C-c C-q
2041 Exit the formula editor without installing changes.
2042 @kindex C-c C-r
2043 @item C-c C-r
2044 Toggle all references in the formula editor between standard (like
2045 @code{B3}) and internal (like @code{@@3$2}).
2046 @kindex @key{TAB}
2047 @item @key{TAB}
2048 Pretty-print or indent lisp formula at point.  When in a line containing
2049 a lisp formula, format the formula according to Emacs Lisp rules.
2050 Another @key{TAB} collapses the formula back again.  In the open
2051 formula, @key{TAB} re-indents just like in Emacs lisp mode.
2052 @kindex M-@key{TAB}
2053 @item M-@key{TAB}
2054 Complete Lisp symbols, just like in Emacs lisp mode.
2055 @kindex S-@key{up}
2056 @kindex S-@key{down}
2057 @kindex S-@key{left}
2058 @kindex S-@key{right}
2059 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2060 Shift the reference at point.  For example, if the reference is
2061 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2062 This also works for relative references, and for hline references.
2063 @kindex M-S-@key{up}
2064 @kindex M-S-@key{down}
2065 @item M-S-@key{up}/@key{down}
2066 Move the test line for column formulas in the Org buffer up and
2067 down.
2068 @kindex M-@key{up}
2069 @kindex M-@key{down}
2070 @item M-@key{up}/@key{down}
2071 Scroll the window displaying the table.
2072 @kindex C-c @}
2073 @item C-c @}
2074 Turn the coordinate grid in the table on and off.
2075 @end table
2076 @end table
2078 Making a table field blank does not remove the formula associated with
2079 the field, because that is stored in a different line (the @samp{TBLFM}
2080 line) - during the next recalculation the field will be filled again.
2081 To remove a formula from a field, you have to give an empty reply when
2082 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2084 @kindex C-c C-c
2085 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2086 equations with @kbd{C-c C-c} in that line, or with the normal
2087 recalculation commands in the table.
2089 @subsubheading Debugging formulas
2090 @cindex formula debugging
2091 @cindex debugging, of table formulas
2092 When the evaluation of a formula leads to an error, the field content
2093 becomes the string @samp{#ERROR}.  If you would like see what is going
2094 on during variable substitution and calculation in order to find a bug,
2095 turn on formula debugging in the @code{Tbl} menu and repeat the
2096 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2097 field.  Detailed information will be displayed.
2099 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2100 @subsection Updating the table
2101 @cindex recomputing table fields
2102 @cindex updating, table
2104 Recalculation of a table is normally not automatic, but needs to be
2105 triggered by a command.  See @ref{Advanced features} for a way to make
2106 recalculation at least semi-automatically.
2108 In order to recalculate a line of a table or the entire table, use the
2109 following commands:
2111 @table @kbd
2112 @kindex C-c *
2113 @item C-c *
2114 Recalculate the current row by first applying the stored column formulas
2115 from left to right, and all field formulas in the current row.
2117 @kindex C-u C-c *
2118 @item C-u C-c *
2119 @kindex C-u C-c C-c
2120 @itemx C-u C-c C-c
2121 Recompute the entire table, line by line.  Any lines before the first
2122 hline are left alone, assuming that these are part of the table header.
2124 @kindex C-u C-u C-c *
2125 @kindex C-u C-u C-c C-c
2126 @item C-u C-u C-c *
2127 @itemx C-u C-u C-c C-c
2128 Iterate the table by recomputing it until no further changes occur.
2129 This may be necessary if some computed fields use the value of other
2130 fields that are computed @i{later} in the calculation sequence.
2131 @end table
2133 @node Advanced features,  , Updating the table, The spreadsheet
2134 @subsection Advanced features
2136 If you want the recalculation of fields to happen automatically, or if
2137 you want to be able to assign @i{names} to fields and columns, you need
2138 to reserve the first column of the table for special marking characters.
2139 @table @kbd
2140 @kindex C-#
2141 @item C-#
2142 Rotate the calculation mark in first column through the states @samp{},
2143 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  The meaning of these characters
2144 is discussed below.  When there is an active region, change all marks in
2145 the region.
2146 @end table
2148 Here is an example of a table that collects exam results of students and
2149 makes use of these features:
2151 @example
2152 @group
2153 |---+---------+--------+--------+--------+-------+------|
2154 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2155 |---+---------+--------+--------+--------+-------+------|
2156 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2157 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2158 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2159 |---+---------+--------+--------+--------+-------+------|
2160 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2161 | # | Sara    |      6 |     14 |     19 |    39 |  7.8 |
2162 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2163 |---+---------+--------+--------+--------+-------+------|
2164 |   | Average |        |        |        |  29.7 |      |
2165 | ^ |         |        |        |        |    at |      |
2166 | $ | max=50  |        |        |        |       |      |
2167 |---+---------+--------+--------+--------+-------+------|
2168 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2169 @end group
2170 @end example
2172 @noindent @b{Important}: Please note that for these special tables,
2173 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2174 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2175 to the field itself.  The column formulas are not applied in rows with
2176 empty first field.
2178 @cindex marking characters, tables
2179 The marking characters have the following meaning:
2180 @table @samp
2181 @item !
2182 The fields in this line define names for the columns, so that you may
2183 refer to a column as @samp{$Tot} instead of @samp{$6}.
2184 @item ^
2185 This row defines names for the fields @emph{above} the row.  With such
2186 a definition, any formula in the table may use @samp{$m1} to refer to
2187 the value @samp{10}.  Also, if you assign a formula to a names field, it
2188 will be stored as @samp{$name=...}.
2189 @item _
2190 Similar to @samp{^}, but defines names for the fields in the row
2191 @emph{below}.
2192 @item $
2193 Fields in this row can define @emph{parameters} for formulas.  For
2194 example, if a field in a @samp{$} row contains @samp{max=50}, then
2195 formulas in this table can refer to the value 50 using @samp{$max}.
2196 Parameters work exactly like constants, only that they can be defined on
2197 a per-table basis.
2198 @item #
2199 Fields in this row are automatically recalculated when pressing
2200 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2201 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2202 lines will be left alone by this command.
2203 @item *
2204 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2205 not for automatic recalculation.  Use this when automatic
2206 recalculation slows down editing too much.
2207 @item
2208 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2209 All lines that should be recalculated should be marked with @samp{#}
2210 or @samp{*}.
2211 @item /
2212 Do not export this line.  Useful for lines that contain the narrowing
2213 @samp{<N>} markers.
2214 @end table
2216 Finally, just to whet your appetite on what can be done with the
2217 fantastic @file{calc} package, here is a table that computes the Taylor
2218 series of degree @code{n} at location @code{x} for a couple of
2219 functions.
2221 @example
2222 @group
2223 |---+-------------+---+-----+--------------------------------------|
2224 |   | Func        | n | x   | Result                               |
2225 |---+-------------+---+-----+--------------------------------------|
2226 | # | exp(x)      | 1 | x   | 1 + x                                |
2227 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2228 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2229 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2230 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2231 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2232 |---+-------------+---+-----+--------------------------------------|
2233 #+TBLFM: $5=taylor($2,$4,$3);n3
2234 @end group
2235 @end example
2237 @node Hyperlinks, TODO Items, Tables, Top
2238 @chapter Hyperlinks
2239 @cindex hyperlinks
2241 Like HTML, Org provides links inside a file, external links to
2242 other files, Usenet articles, emails, and much more.
2244 @menu
2245 * Link format::                 How links in Org are formatted
2246 * Internal links::              Links to other places in the current file
2247 * External links::              URL-like links to the world
2248 * Handling links::              Creating, inserting and following
2249 * Using links outside Org::     Linking from my C source code?
2250 * Link abbreviations::          Shortcuts for writing complex links
2251 * Search options::              Linking to a specific location
2252 * Custom searches::             When the default search is not enough
2253 @end menu
2255 @node Link format, Internal links, Hyperlinks, Hyperlinks
2256 @section Link format
2257 @cindex link format
2258 @cindex format, of links
2260 Org will recognize plain URL-like links and activate them as
2261 clickable links.  The general link format, however, looks like this:
2263 @example
2264 [[link][description]]       @r{or alternatively}           [[link]]
2265 @end example
2267 Once a link in the buffer is complete (all brackets present), Org
2268 will change the display so that @samp{description} is displayed instead
2269 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2270 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2271 which by default is an underlined face.  You can directly edit the
2272 visible part of a link.  Note that this can be either the @samp{link}
2273 part (if there is no description) or the @samp{description} part.  To
2274 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2275 cursor on the link.
2277 If you place the cursor at the beginning or just behind the end of the
2278 displayed text and press @key{BACKSPACE}, you will remove the
2279 (invisible) bracket at that location.  This makes the link incomplete
2280 and the internals are again displayed as plain text.  Inserting the
2281 missing bracket hides the link internals again.  To show the
2282 internal structure of all links, use the menu entry
2283 @code{Org->Hyperlinks->Literal links}.
2285 @node Internal links, External links, Link format, Hyperlinks
2286 @section Internal links
2287 @cindex internal links
2288 @cindex links, internal
2289 @cindex targets, for links
2291 If the link does not look like a URL, it is considered to be internal in
2292 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
2293 Target][Find my target]]} lead to a text search in the current file.
2294 The link can be followed with @kbd{C-c C-o} when the cursor is on the
2295 link, or with a mouse click (@pxref{Handling links}).  The preferred
2296 match for such a link is a dedicated target: the same string in double
2297 angular brackets.  Targets may be located anywhere; sometimes it is
2298 convenient to put them into a comment line. For example
2300 @example
2301 # <<My Target>>
2302 @end example
2304 @noindent In HTML export (@pxref{HTML export}), such targets will become
2305 named anchors for direct access through @samp{http} links@footnote{Note
2306 that text before the first headline is usually not exported, so the
2307 first such target should be after the first headline.}.
2309 If no dedicated target exists, Org will search for the words in the
2310 link.  In the above example the search would be for @samp{my target}.
2311 Links starting with a star like @samp{*My Target} restrict the search to
2312 headlines.  When searching, Org mode will first try an exact match, but
2313 then move on to more and more lenient searches.  For example, the link
2314 @samp{[[*My Targets]]} will find any of the following:
2316 @example
2317 ** My targets
2318 ** TODO my targets are bright
2319 ** my 20 targets are
2320 @end example
2322 To insert a link targeting a headline, in-buffer completion can be used.
2323 Just type a star followed by a few optional letters into the buffer and
2324 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2325 offered as completions.  @xref{Handling links}, for more commands
2326 creating links.
2328 Following a link pushes a mark onto Org's own mark ring.  You can
2329 return to the previous position with @kbd{C-c &}.  Using this command
2330 several times in direct succession goes back to positions recorded
2331 earlier.
2333 @menu
2334 * Radio targets::               Make targets trigger links in plain text
2335 @end menu
2337 @node Radio targets,  , Internal links, Internal links
2338 @subsection Radio targets
2339 @cindex radio targets
2340 @cindex targets, radio
2341 @cindex links, radio targets
2343 Org can automatically turn any occurrences of certain target names
2344 in normal text into a link.  So without explicitly creating a link, the
2345 text connects to the target radioing its position.  Radio targets are
2346 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2347 Target>>>} causes each occurrence of @samp{my target} in normal text to
2348 become activated as a link.  The Org file is scanned automatically
2349 for radio targets only when the file is first loaded into Emacs.  To
2350 update the target list during editing, press @kbd{C-c C-c} with the
2351 cursor on or at a target.
2353 @node External links, Handling links, Internal links, Hyperlinks
2354 @section External links
2355 @cindex links, external
2356 @cindex external links
2357 @cindex links, external
2358 @cindex Gnus links
2359 @cindex BBDB links
2360 @cindex IRC links
2361 @cindex URL links
2362 @cindex file links
2363 @cindex VM links
2364 @cindex RMAIL links
2365 @cindex WANDERLUST links
2366 @cindex MH-E links
2367 @cindex USENET links
2368 @cindex SHELL links
2369 @cindex Info links
2370 @cindex elisp links
2372 Org supports links to files, websites, Usenet and email messages,
2373 BBDB database entries and links to both IRC conversations and their
2374 logs.  External links are URL-like locators.  They start with a short
2375 identifying string followed by a colon.  There can be no space after
2376 the colon.  The following list shows examples for each link type.
2378 @example
2379 http://www.astro.uva.nl/~dominik          @r{on the web}
2380 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2381 file:papers/last.pdf                      @r{file, relative path}
2382 news:comp.emacs                           @r{Usenet link}
2383 mailto:adent@@galaxy.net                  @r{Mail link}
2384 vm:folder                                 @r{VM folder link}
2385 vm:folder#id                              @r{VM message link}
2386 vm://myself@@some.where.org/folder#id     @r{VM on remote machine}
2387 wl:folder                                 @r{WANDERLUST folder link}
2388 wl:folder#id                              @r{WANDERLUST message link}
2389 mhe:folder                                @r{MH-E folder link}
2390 mhe:folder#id                             @r{MH-E message link}
2391 rmail:folder                              @r{RMAIL folder link}
2392 rmail:folder#id                           @r{RMAIL message link}
2393 gnus:group                                @r{Gnus group link}
2394 gnus:group#id                             @r{Gnus article link}
2395 bbdb:Richard Stallman                     @r{BBDB link}
2396 irc:/irc.com/#emacs/bob                   @r{IRC link}
2397 shell:ls *.org                            @r{A shell command}
2398 elisp:(find-file-other-frame "Elisp.org") @r{An elisp form to evaluate}
2399 @end example
2401 A link should be enclosed in double brackets and may contain a
2402 descriptive text to be displayed instead of the URL (@pxref{Link
2403 format}), for example:
2405 @example
2406 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2407 @end example
2409 @noindent
2410 If the description is a file name or URL that points to an image, HTML
2411 export (@pxref{HTML export}) will inline the image as a clickable
2412 button.  If there is no description at all and the link points to an
2413 image,
2414 that image will be inlined into the exported HTML file.
2416 @cindex angular brackets, around links
2417 @cindex plain text external links
2418 Org also finds external links in the normal text and activates them
2419 as links.  If spaces must be part of the link (for example in
2420 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2421 about the end of the link, enclose them in angular brackets.
2423 @node Handling links, Using links outside Org, External links, Hyperlinks
2424 @section Handling links
2425 @cindex links, handling
2427 Org provides methods to create a link in the correct syntax, to
2428 insert it into an Org file, and to follow the link.
2430 @table @kbd
2431 @kindex C-c l
2432 @cindex storing links
2433 @item C-c l
2434 Store a link to the current location.  This is a @emph{global} command
2435 which can be used in any buffer to create a link.  The link will be
2436 stored for later insertion into an Org buffer (see below).  For
2437 Org files, if there is a @samp{<<target>>} at the cursor, the
2438 link points to the target.  Otherwise it points to the current
2439 headline.  For VM, Rmail, Wanderlust, MH-E, Gnus and BBDB buffers, the
2440 link will indicate the current article/entry.  For W3 and W3M buffers,
2441 the link goes to the current URL.  For IRC links, if you set the
2442 variable @code{org-irc-link-to-logs} to non-nil then @kbd{C-c l} will
2443 store a @samp{file:/} style link to the relevant point in the logs for
2444 the current conversation. Otherwise an @samp{irc:/} style link to the
2445 user/channel/server under the point will be stored.  For any other
2446 files, the link will point to the file, with a search string
2447 (@pxref{Search options}) pointing to the contents of the current line.
2448 If there is an active region, the selected words will form the basis
2449 of the search string.  If the automatically created link is not
2450 working correctly or accurately enough, you can write custom functions
2451 to select the search string and to do the search for particular file
2452 types - see @ref{Custom searches}.  The key binding @kbd{C-c l} is
2453 only a suggestion - see @ref{Installation}.
2455 @kindex C-c C-l
2456 @cindex link completion
2457 @cindex completion, of links
2458 @cindex inserting links
2459 @item C-c C-l
2460 Insert a link.  This prompts for a link to be inserted into the buffer.  You
2461 can just type a link, using text for an internal link, or one of the link
2462 type prefixes mentioned in the examples above.  All links stored during the
2463 current session are part of the history for this prompt, so you can access
2464 them with @key{up} and @key{down} (or @kbd{M-p/n}).  Completion, on the other
2465 hand, will help you to insert valid link prefixes like @samp{http:} or
2466 @samp{ftp:}, including the prefixes defined through link abbreviations
2467 (@pxref{Link abbreviations}).  The link will be inserted into the
2468 buffer@footnote{After insertion of a stored link, the link will be removed
2469 from the list of stored links.  To keep it in the list later use, use a
2470 triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2471 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2472 If some text was selected when this command is called, the selected text
2473 becomes the default description.@* Note that you don't have to use this
2474 command to insert a link.  Links in Org are plain text, and you can type
2475 or paste them straight into the buffer.  By using this command, the links are
2476 automatically enclosed in double brackets, and you will be asked for the
2477 optional descriptive text.
2479 @c  If the link is a @samp{file:} link and
2480 @c the linked file is located in the same directory as the current file or
2481 @c a subdirectory of it, the path of the file will be inserted relative to
2482 @c the current directory.
2484 @kindex C-u C-c C-l
2485 @cindex file name completion
2486 @cindex completion, of file names
2487 @item C-u C-c C-l
2488 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2489 a file will be inserted and you may use file name completion to select
2490 the name of the file.  The path to the file is inserted relative to the
2491 directory of the current org file, if the linked file is in the current
2492 directory or in a sub-directory of it, or if the path is written relative
2493 to the current directory using @samp{../}.  Otherwise an absolute path
2494 is used, if possible with @samp{~/} for your home directory.  You can
2495 force an absolute path with two @kbd{C-u} prefixes.
2497 @item C-c C-l @r{(with cursor on existing link)}
2498 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2499 link and description parts of the link.
2501 @cindex following links
2502 @kindex C-c C-o
2503 @item C-c C-o
2504 Open link at point.  This will launch a web browser for URLs (using
2505 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB
2506 for the corresponding links, and execute the command in a shell link.
2507 When the cursor is on an internal link, this commands runs the
2508 corresponding search.  When the cursor is on a TAG list in a headline,
2509 it creates the corresponding TAGS view.  If the cursor is on a time
2510 stamp, it compiles the agenda for that date.  Furthermore, it will visit
2511 text and remote files in @samp{file:} links with Emacs and select a
2512 suitable application for local non-text files.  Classification of files
2513 is based on file extension only.  See option @code{org-file-apps}.  If
2514 you want to override the default application and visit the file with
2515 Emacs, use a @kbd{C-u} prefix.
2517 @kindex mouse-2
2518 @kindex mouse-1
2519 @item mouse-2
2520 @itemx mouse-1
2521 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2522 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2524 @kindex mouse-3
2525 @item mouse-3
2526 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2527 internal links to be displayed in another window@footnote{See the
2528 variable @code{org-display-internal-link-with-indirect-buffer}}.
2530 @cindex mark ring
2531 @kindex C-c %
2532 @item C-c %
2533 Push the current position onto the mark ring, to be able to return
2534 easily. Commands following an internal link do this automatically.
2536 @cindex links, returning to
2537 @kindex C-c &
2538 @item C-c &
2539 Jump back to a recorded position.  A position is recorded by the
2540 commands following internal links, and by @kbd{C-c %}.  Using this
2541 command several times in direct succession moves through a ring of
2542 previously recorded positions.
2544 @kindex C-c C-x C-n
2545 @kindex C-c C-x C-p
2546 @cindex links, finding next/previous
2547 @item C-c C-x C-n
2548 @itemx C-c C-x C-p
2549 Move forward/backward to the next link in the buffer.  At the limit of
2550 the buffer, the search fails once, and then wraps around.  The key
2551 bindings for this are really too long, you might want to bind this also
2552 to @kbd{C-n} and @kbd{C-p}
2553 @lisp
2554 (add-hook 'org-load-hook
2555   (lambda ()
2556     (define-key 'org-mode-map "\C-n" 'org-next-link)
2557     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2558 @end lisp
2559 @end table
2561 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
2562 @section Using links outside Org
2564 You can insert and follow links that have Org syntax not only in
2565 Org, but in any Emacs buffer.  For this, you should create two
2566 global commands, like this (please select suitable global keys
2567 yourself):
2569 @lisp
2570 (global-set-key "\C-c L" 'org-insert-link-global)
2571 (global-set-key "\C-c o" 'org-open-at-point-global)
2572 @end lisp
2574 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
2575 @section Link abbreviations
2576 @cindex link abbreviations
2577 @cindex abbreviation, links
2579 Long URLs can be cumbersome to type, and often many similar links are
2580 needed in a document.  For this you can use link abbreviations.  An
2581 abbreviated link looks like this
2583 @example
2584 [[linkword:tag][description]]
2585 @end example
2587 @noindent
2588 where the tag is optional.  Such abbreviations are resolved according to
2589 the information in the variable @code{org-link-abbrev-alist} that
2590 relates the linkwords to replacement text.  Here is an example:
2592 @lisp
2593 @group
2594 (setq org-link-abbrev-alist
2595   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2596     ("google"   . "http://www.google.com/search?q=")
2597     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2598                    nph-abs_connect?author=%s&db_key=AST")))
2599 @end group
2600 @end lisp
2602 If the replacement text contains the string @samp{%s}, it will be
2603 replaced with the tag.  Otherwise the tag will be appended to the string
2604 in order to create the link.  You may also specify a function that will
2605 be called with the tag as the only argument to create the link.
2607 With the above setting, you could link to a specific bug with
2608 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2609 @code{[[google:OrgMode]]} and find out what the Org author is
2610 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2612 If you need special abbreviations just for a single Org buffer, you
2613 can define them in the file with
2615 @example
2616 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2617 #+LINK: google    http://www.google.com/search?q=%s
2618 @end example
2620 @noindent
2621 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2622 complete link abbreviations.
2624 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2625 @section Search options in file links
2626 @cindex search option in file links
2627 @cindex file links, searching
2629 File links can contain additional information to make Emacs jump to a
2630 particular location in the file when following a link.  This can be a
2631 line number or a search option after a double@footnote{For backward
2632 compatibility, line numbers can also follow a single colon.} colon. For
2633 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2634 links}) to a file, it encodes the words in the current line as a search
2635 string that can be used to find this line back later when following the
2636 link with @kbd{C-c C-o}.
2638 Here is the syntax of the different ways to attach a search to a file
2639 link, together with an explanation:
2641 @example
2642 [[file:~/code/main.c::255]]
2643 [[file:~/xx.org::My Target]]
2644 [[file:~/xx.org::*My Target]]
2645 [[file:~/xx.org::/regexp/]]
2646 @end example
2648 @table @code
2649 @item 255
2650 Jump to line 255.
2651 @item My Target
2652 Search for a link target @samp{<<My Target>>}, or do a text search for
2653 @samp{my target}, similar to the search in internal links, see
2654 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
2655 link will become an HTML reference to the corresponding named anchor in
2656 the linked file.
2657 @item *My Target
2658 In an Org file, restrict search to headlines.
2659 @item /regexp/
2660 Do a regular expression search for @code{regexp}.  This uses the Emacs
2661 command @code{occur} to list all matches in a separate window.  If the
2662 target file is in Org mode, @code{org-occur} is used to create a
2663 sparse tree with the matches.
2664 @c If the target file is a directory,
2665 @c @code{grep} will be used to search all files in the directory.
2666 @end table
2668 As a degenerate case, a file link with an empty file name can be used
2669 to search the current file.  For example, @code{[[file:::find me]]} does
2670 a search for @samp{find me} in the current file, just as
2671 @samp{[[find me]]} would.
2673 @node Custom searches,  , Search options, Hyperlinks
2674 @section Custom Searches
2675 @cindex custom search strings
2676 @cindex search strings, custom
2678 The default mechanism for creating search strings and for doing the
2679 actual search related to a file link may not work correctly in all
2680 cases.  For example, BibTeX database files have many entries like
2681 @samp{year="1993"} which would not result in good search strings,
2682 because the only unique identification for a BibTeX entry is the
2683 citation key.
2685 If you come across such a problem, you can write custom functions to set
2686 the right search string for a particular file type, and to do the search
2687 for the string in the file.  Using @code{add-hook}, these functions need
2688 to be added to the hook variables
2689 @code{org-create-file-search-functions} and
2690 @code{org-execute-file-search-functions}.  See the docstring for these
2691 variables for more information.  Org actually uses this mechanism
2692 for Bib@TeX{} database files, and you can use the corresponding code as
2693 an implementation example.  Search for @samp{BibTeX links} in the source
2694 file.
2696 @node TODO Items, Tags, Hyperlinks, Top
2697 @chapter TODO Items
2698 @cindex TODO items
2700 Org mode does not maintain TODO lists as separate documents.  Instead,
2701 TODO items are an integral part of the notes file, because TODO items
2702 usually come up while taking notes!  With Org mode, simply mark any
2703 entry in a tree as being a TODO item.  In this way, information is not
2704 duplicated, and the entire context from which the TODO item emerged is
2705 always present.
2707 Of course, this technique for managing TODO items scatters them
2708 throughout your notes file.  Org mode compensates for this by providing
2709 methods to give you an overview of all the things that you have to do.
2711 @menu
2712 * TODO basics::                 Marking and displaying TODO entries
2713 * TODO extensions::             Workflow and assignments
2714 * Progress logging::            Dates and notes for progress
2715 * Priorities::                  Some things are more important than others
2716 * Breaking down tasks::         Splitting a task into manageable pieces
2717 * Checkboxes::                  Tick-off lists
2718 @end menu
2720 @node TODO basics, TODO extensions, TODO Items, TODO Items
2721 @section Basic TODO functionality
2723 Any headline becomes a TODO item when it starts with the word
2724 @samp{TODO}, for example:
2726 @example
2727 *** TODO Write letter to Sam Fortune
2728 @end example
2730 @noindent
2731 The most important commands to work with TODO entries are:
2733 @table @kbd
2734 @kindex C-c C-t
2735 @cindex cycling, of TODO states
2736 @item C-c C-t
2737 Rotate the TODO state of the current item among
2739 @example
2740 ,-> (unmarked) -> TODO -> DONE --.
2741 '--------------------------------'
2742 @end example
2744 The same rotation can also be done ``remotely'' from the timeline and
2745 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
2747 @kindex C-u C-c C-t
2748 @item C-u C-c C-t
2749 Select a specific keyword using completion or (if it has been set up)
2750 the fast selection interface.  For the latter, you need to assign keys
2751 to TODO states, see @ref{Per-file keywords} and @ref{Setting tags} for
2752 more information.
2754 @kindex S-@key{right}
2755 @kindex S-@key{left}
2756 @item S-@key{right}
2757 @itemx S-@key{left}
2758 Select the following/preceding TODO state, similar to cycling.  Useful
2759 mostly if more than two TODO states are possible (@pxref{TODO
2760 extensions}).
2761 @kindex C-c C-v
2762 @kindex C-c / t
2763 @cindex sparse tree, for TODO
2764 @item C-c C-v
2765 @itemx C-c / t
2766 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
2767 the entire buffer, but shows all TODO items and the headings hierarchy
2768 above them.  With a prefix argument, search for a specific TODO.  You will be
2769 prompted for the keyword, and you can also give a list of keywords like
2770 @code{KWD1|KWD2|...}.  With numeric prefix argument N, show the tree for the
2771 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
2772 arguments, find all TODO and DONE entries.
2773 @kindex C-c a t
2774 @item C-c a t
2775 Show the global TODO list.  Collects the TODO items from all agenda
2776 files (@pxref{Agenda Views}) into a single buffer.  The new buffer will
2777 be in @code{agenda-mode}, which provides commands to examine and
2778 manipulate the TODO entries from the new buffer (@pxref{Agenda
2779 commands}).  @xref{Global TODO list}, for more information.
2780 @kindex S-M-@key{RET}
2781 @item S-M-@key{RET}
2782 Insert a new TODO entry below the current one.
2783 @end table
2785 @node TODO extensions, Progress logging, TODO basics, TODO Items
2786 @section Extended use of TODO keywords
2787 @cindex extended TODO keywords
2789 By default, marked TODO entries have one of only two states: TODO and
2790 DONE.  Org mode allows you to classify TODO items in more complex ways
2791 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
2792 special setup, the TODO keyword system can work differently in different
2793 files.
2795 Note that @i{tags} are another way to classify headlines in general and
2796 TODO items in particular (@pxref{Tags}).
2798 @menu
2799 * Workflow states::             From TODO to DONE in steps
2800 * TODO types::                  I do this, Fred does the rest
2801 * Multiple sets in one file::   Mixing it all, and still finding your way
2802 * Fast access to TODO states::  Single letter selection of a state
2803 * Per-file keywords::           Different files, different requirements
2804 * Faces for TODO keywords::     Highlighting states
2805 @end menu
2807 @node Workflow states, TODO types, TODO extensions, TODO extensions
2808 @subsection TODO keywords as workflow states
2809 @cindex TODO workflow
2810 @cindex workflow states as TODO keywords
2812 You can use TODO keywords to indicate different @emph{sequential} states
2813 in the process of working on an item, for example@footnote{Changing
2814 this variable only becomes effective after restarting Org mode in a
2815 buffer.}:
2817 @lisp
2818 (setq org-todo-keywords
2819   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
2820 @end lisp
2822 The vertical bar separates the TODO keywords (states that @emph{need
2823 action}) from the DONE states (which need @emph{no further action}.  If
2824 you don't provide the separator bar, the last state is used as the DONE
2825 state.
2826 @cindex completion, of TODO keywords
2827 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
2828 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
2829 also use a numeric prefix argument to quickly select a specific state.  For
2830 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
2831 Or you can use @kbd{S-left} to go backward through the sequence.  If you
2832 define many keywords, you can use in-buffer completion
2833 (@pxref{Completion}) or even a special one-key selection scheme
2834 (@pxref{Fast access to TODO states}) to insert these words into the
2835 buffer.  Changing a TODO state can be logged with a timestamp, see
2836 @ref{Tracking TODO state changes} for more information.
2838 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
2839 @subsection TODO keywords as types
2840 @cindex TODO types
2841 @cindex names as TODO keywords
2842 @cindex types as TODO keywords
2844 The second possibility is to use TODO keywords to indicate different
2845 @emph{types} of action items.  For example, you might want to indicate
2846 that items are for ``work'' or ``home''.  Or, when you work with several
2847 people on a single project, you might want to assign action items
2848 directly to persons, by using their names as TODO keywords.  This would
2849 be set up like this:
2851 @lisp
2852 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
2853 @end lisp
2855 In this case, different keywords do not indicate a sequence, but rather
2856 different types.  So the normal work flow would be to assign a task to a
2857 person, and later to mark it DONE.  Org mode supports this style by adapting
2858 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
2859 @kbd{t} command in the timeline and agenda buffers.}.  When used several
2860 times in succession, it will still cycle through all names, in order to first
2861 select the right type for a task.  But when you return to the item after some
2862 time and execute @kbd{C-c C-t} again, it will switch from any name directly
2863 to DONE.  Use prefix arguments or completion to quickly select a specific
2864 name.  You can also review the items of a specific TODO type in a sparse tree
2865 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
2866 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
2867 from all agenda files into a single buffer, you would use the numeric prefix
2868 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
2870 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
2871 @subsection Multiple keyword sets in one file
2872 @cindex TODO keyword sets
2874 Sometimes you may want to use different sets of TODO keywords in
2875 parallel.  For example, you may want to have the basic
2876 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
2877 separate state indicating that an item has been canceled (so it is not
2878 DONE, but also does not require action).  Your setup would then look
2879 like this:
2881 @lisp
2882 (setq org-todo-keywords
2883       '((sequence "TODO" "|" "DONE")
2884         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
2885         (sequence "|" "CANCELED")))
2886 @end lisp
2888 The keywords should all be different, this helps Org mode to keep track
2889 of which subsequence should be used for a given entry.  In this setup,
2890 @kbd{C-c C-t} only operates within a subsequence, so it switches from
2891 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
2892 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
2893 select the correct sequence.  Besides the obvious ways like typing a
2894 keyword or using completion, you may also apply the following commands:
2896 @table @kbd
2897 @kindex C-S-@key{right}
2898 @kindex C-S-@key{left}
2899 @item C-S-@key{right}
2900 @itemx C-S-@key{left}
2901 These keys jump from one TODO subset to the next.  In the above example,
2902 @kbd{C-S-@key{right}} would jump from @code{TODO} or @code{DONE} to
2903 @code{REPORT}, and any of the words in the second row to @code{CANCELED}.
2904 @kindex S-@key{right}
2905 @kindex S-@key{left}
2906 @item S-@key{right}
2907 @itemx S-@key{left}
2908 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through
2909 @emph{all} keywords from all sets, so for example @kbd{S-@key{<right>}}
2910 would switch from @code{DONE} to @code{REPORT} in the example above.
2911 @end table
2913 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
2914 @subsection Fast access to TODO states
2916 If you would like to quickly change an entry to an arbitrary TODO state
2917 instead of cycling through the states, you can set up keys for
2918 single-letter access to the states.  This is done by adding the section
2919 key after each keyword, in parenthesis.  For example:
2921 @lisp
2922 (setq org-todo-keywords
2923       '((sequence "TODO(t)" "|" "DONE(d)")
2924         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
2925         (sequence "|" "CANCELED(c)")))
2926 @end lisp
2928 If you then press @code{C-u C-c C-t} followed by the selection key, the
2929 entry will be switched to this state.  @key{SPC} can be used to remove
2930 any TODO keyword from an entry.  Should you like this way of selecting
2931 TODO states a lot, you might want to set the variable
2932 @code{org-use-fast-todo-selection} to @code{t} and make this behavior
2933 the default.  Check also the variable
2934 @code{org-fast-tag-selection-include-todo}, it allows to change the TODO
2935 state through the tags interface (@pxref{Setting tags}), in case you
2936 like to mingle the two concepts.
2938 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
2939 @subsection Setting up keywords for individual files
2940 @cindex keyword options
2941 @cindex per-file keywords
2943 It can be very useful to use different aspects of the TODO mechanism in
2944 different files.  For file-local settings, you need to add special lines
2945 to the file which set the keywords and interpretation for that file
2946 only.  For example, to set one of the two examples discussed above, you
2947 need one of the following lines, starting in column zero anywhere in the
2948 file:
2950 @example
2951 #+SEQ_TODO: TODO FEEDBACK VERIFY | DONE CANCELED
2952 @end example
2954 @example
2955 #+TYP_TODO: Fred Sara Lucy Mike | DONE
2956 @end example
2958 A setup for using several sets in parallel would be:
2960 @example
2961 #+SEQ_TODO: TODO | DONE
2962 #+SEQ_TODO: REPORT BUG KNOWNCAUSE | FIXED
2963 #+SEQ_TODO: | CANCELED
2964 @end example
2966 @cindex completion, of option keywords
2967 @kindex M-@key{TAB}
2968 @noindent To make sure you are using the correct keyword, type
2969 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
2971 @cindex DONE, final TODO keyword
2972 Remember that the keywords after the vertical bar (or the last keyword
2973 if no bar is there) must always mean that the item is DONE (although you
2974 may use a different word).  After changing one of these lines, use
2975 @kbd{C-c C-c} with the cursor still in the line to make the changes
2976 known to Org mode@footnote{Org mode parses these lines only when
2977 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
2978 cursor in a line starting with @samp{#+} is simply restarting Org mode
2979 for the current buffer.}.
2981 @node Faces for TODO keywords,  , Per-file keywords, TODO extensions
2982 @subsection Faces for TODO keywords
2983 @cindex faces, for TODO keywords
2985 Org mode highlights TODO keywords with special faces: @code{org-todo}
2986 for keywords indicating that an item still has to be acted upon, and
2987 @code{org-done} for keywords indicating that an item is finished.  If
2988 you are using more than 2 different states, you might want to use
2989 special faces for some of them.  This can be done using the variable
2990 @code{org-todo-keyword-faces}.  For example:
2992 @lisp
2993 (setq org-todo-keyword-faces
2994       '(("TODO"      . org-warning)
2995         ("DEFERRED"  . shadow)
2996         ("CANCELED"  . (:foreground "blue" :weight bold))))
2997 @end lisp
2999 While using a list with face properties as shown for CANCELED
3000 @emph{should} work, this does not aways seem to be the case.  If
3001 necessary, define a special face and use that.
3003 @page
3004 @node Progress logging, Priorities, TODO extensions, TODO Items
3005 @section Progress logging
3006 @cindex progress logging
3007 @cindex logging, of progress
3009 Org mode can automatically record a time stamp and possibly a note when
3010 you mark a TODO item as DONE, or even each time you change the state of
3011 a TODO item.  This system is highly configurable, settings can be on a
3012 per-keyword basis and can be localized to a file or even a subtree.  For
3013 information on how to clock working time for a task, see @ref{Clocking
3014 work time}.
3016 @menu
3017 * Closing items::               When was this entry marked DONE?
3018 * Tracking TODO state changes::  When did the status change?
3019 @end menu
3021 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3022 @subsection Closing items
3024 The most basic logging is to keep track of @emph{when} a certain TODO
3025 item was finished.  This is achieved with@footnote{The corresponding
3026 in-buffer setting is: @code{#+STARTUP: logdone}}.
3028 @lisp
3029 (setq org-log-done 'time)
3030 @end lisp
3032 @noindent
3033 Then each time you turn an entry from a TODO (not-done) state into any
3034 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3035 just after the headline.  If you turn the entry back into a TODO item
3036 through further state cycling, that line will be removed again.  If you
3037 want to record a note along with the timestamp, use@footnote{The
3038 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3040 @lisp
3041 (setq org-log-done 'note)
3042 @end lisp
3044 @noindent
3045 You will then be prompted for a note, and that note will be stored below
3046 the entry with a @samp{Closing Note} heading.
3048 In the timeline (@pxref{Timeline}) and in the agenda
3049 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3050 display the TODO items with a @samp{CLOSED} timestamp on each day,
3051 giving you an overview of what has been done.
3053 @node Tracking TODO state changes,  , Closing items, Progress logging
3054 @subsection Tracking TODO state changes
3056 When TODO keywords are used as workflow states (@pxref{Workflow
3057 states}), you might want to keep track of when a state change occurred
3058 and maybe take a note about this change.  Since it is normally too much
3059 to record a note for every state, Org mode expects configuration on a
3060 per-keyword basis for this.  This is achieved by adding special markers
3061 @samp{!} (for a time stamp) and @samp{@@} (for a note) in parenthesis
3062 after each keyword.  For example, with the setting
3064 @lisp
3065 (setq org-todo-keywords
3066   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3067 @end lisp
3069 @noindent
3070 you not only define global TODO keywords and fast access keys, but also
3071 request that a time is recorded when the entry is turned into
3072 DONE@footnote{It is possible that Org mode will record two time stamps
3073 when you are using both @code{org-log-done} and state change logging.
3074 However, it will never prompt for two notes - if you have configured
3075 both, the state change recording note will take precedence and cancel
3076 the @samp{Closing Note}.}, and that a note is recorded when switching to
3077 WAIT or CANCELED.  The setting for WAIT is even more special: The
3078 @samp{!} after the slash means that in addition to the note taken when
3079 entering the state, a time stamp should be recorded when @i{leaving} the
3080 WAIT state, if and only if the @i{target} state does not configure
3081 logging for entering it.  So it has no effect when switching from WAIT
3082 to DONE, because DONE is configured to record a timestamp only.  But
3083 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3084 setting now triggers a timestamp even though TODO has no logging
3085 configured.
3087 You can use the exact same syntax for setting logging preferences local
3088 to a buffer:
3089 @example
3090 #+SEQ_TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3091 @end example
3093 In order to define logging settings that are local to a subtree or a
3094 single item, define a LOGGING property in this entry.  Any non-empty
3095 LOGGING property resets all logging settings to nil.  You may then turn
3096 on logging for this specific tree using STARTUP keywords like
3097 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3098 settings like @code{TODO(!)}.  For example
3100 @example
3101 * TODO Log each state with only a time
3102   :PROPERTIES:
3103   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3104   :END:
3105 * TODO Only log when switching to WAIT, and when repeating
3106   :PROPERTIES:
3107   :LOGGING: WAIT(@@) logrepeat
3108   :END:
3109 * TODO No logging at all
3110   :PROPERTIES:
3111   :LOGGING: nil
3112   :END:
3113 @end example
3116 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3117 @section Priorities
3118 @cindex priorities
3120 If you use Org mode extensively, you may end up enough TODO items that
3121 it starts to make sense to prioritize them.  Prioritizing can be done by
3122 placing a @emph{priority cookie} into the headline of a TODO item, like
3123 this
3125 @example
3126 *** TODO [#A] Write letter to Sam Fortune
3127 @end example
3129 @noindent
3130 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
3131 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3132 is treated as priority @samp{B}.  Priorities make a difference only in
3133 the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have
3134 no inherent meaning to Org mode.
3136 Priorities can be attached to any outline tree entries; they do not need
3137 to be TODO items.
3139 @table @kbd
3140 @kindex @kbd{C-c ,}
3141 @item @kbd{C-c ,}
3142 Set the priority of the current headline.  The command prompts for a
3143 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3144 @key{SPC} instead, the priority cookie is removed from the headline.
3145 The priorities can also be changed ``remotely'' from the timeline and
3146 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3148 @kindex S-@key{up}
3149 @kindex S-@key{down}
3150 @item S-@key{up}
3151 @itemx S-@key{down}
3152 Increase/decrease priority of current headline@footnote{See also the
3153 option @code{org-priority-start-cycle-with-default'}.}.  Note that these
3154 keys are also used to modify time stamps (@pxref{Creating timestamps}).
3155 Furthermore, these keys are also used by CUA mode (@pxref{Conflicts}).
3156 @end table
3158 You can change the range of allowed priorities by setting the variables
3159 @code{org-highest-priority}, @code{org-lowest-priority}, and
3160 @code{org-default-priority}.  For an individual buffer, you may set
3161 these values (highest, lowest, default) like this (please make sure that
3162 the highest priority is earlier in the alphabet than the lowest
3163 priority):
3165 @example
3166 #+PRIORITIES: A C B
3167 @end example
3169 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3170 @section Breaking tasks down into subtasks
3171 @cindex tasks, breaking down
3173 It is often advisable to break down large tasks into smaller, manageable
3174 subtasks.  You can do this by creating an outline tree below a TODO
3175 item, with detailed subtasks on the tree@footnote{To keep subtasks out
3176 of the global TODO list, see the
3177 @code{org-agenda-todo-list-sublevels}.}.  Another possibility is the use
3178 of checkboxes to identify (a hierarchy of) a large number of subtasks
3179 (@pxref{Checkboxes}).
3182 @node Checkboxes,  , Breaking down tasks, TODO Items
3183 @section Checkboxes
3184 @cindex checkboxes
3186 Every item in a plain list (@pxref{Plain lists}) can be made into a
3187 checkbox by starting it with the string @samp{[ ]}.  This feature is
3188 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3189 Checkboxes are not included into the global TODO list, so they are often
3190 great to split a task into a number of simple steps.  Or you can use
3191 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3192 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3194 Here is an example of a checkbox list.
3196 @example
3197 * TODO Organize party [2/4]
3198   - [-] call people [1/3]
3199     - [ ] Peter
3200     - [X] Sarah
3201     - [ ] Sam
3202   - [X] order food
3203   - [ ] think about what music to play
3204   - [X] talk to the neighbors
3205 @end example
3207 Checkboxes work hierarchically, so if a checkbox item has children that
3208 are checkboxes, toggling one of the children checkboxes will make the
3209 parent checkbox reflect if none, some, or all of the children are
3210 checked.
3212 @cindex statistics, for checkboxes
3213 @cindex checkbox statistics
3214 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are
3215 cookies indicating how many checkboxes present in this entry have been
3216 checked off, and the total number of checkboxes are present.  This can
3217 give you an idea on how many checkboxes remain, even without opening a
3218 folded entry.  The cookies can be placed into a headline or into (the
3219 first line of) a plain list item. Each cookie covers all checkboxes
3220 structurally below the headline/item on which the cookie appear.  You
3221 have to insert the cookie yourself by typing either @samp{[/]} or
3222 @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as in
3223 the examples above.  With @samp{[%]} you get information about the
3224 percentage of checkboxes checked (in the above example, this would be
3225 @samp{[50%]} and @samp{[33%]}, respectively).
3227 @noindent The following commands work with checkboxes:
3229 @table @kbd
3230 @kindex C-c C-c
3231 @item C-c C-c
3232 Toggle checkbox at point.  With a prefix argument, set it to @samp{[-]},
3233 which is considered to be an intermediate state.
3234 @kindex C-c C-x C-b
3235 @item C-c C-x C-b
3236 Toggle checkbox at point.
3237 @itemize @minus
3238 @item
3239 If there is an active region, toggle the first checkbox in the region
3240 and set all remaining boxes to the same status as the first.  If you
3241 want to toggle all boxes in the region independently, use a prefix
3242 argument.
3243 @item
3244 If the cursor is in a headline, toggle checkboxes in the region between
3245 this headline and the next (so @emph{not} the entire subtree).
3246 @item
3247 If there is no active region, just toggle the checkbox at point.
3248 @end itemize
3249 @kindex M-S-@key{RET}
3250 @item M-S-@key{RET}
3251 Insert a new item with a checkbox.
3252 This works only if the cursor is already in a plain list item
3253 (@pxref{Plain lists}).
3254 @kindex C-c #
3255 @item C-c #
3256 Update the checkbox statistics in the current outline entry.  When
3257 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
3258 statistic cookies are updated automatically if you toggle checkboxes
3259 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
3260 delete boxes or add/change them by hand, use this command to get things
3261 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
3262 @end table
3264 @node Tags, Properties and Columns, TODO Items, Top
3265 @chapter Tags
3266 @cindex tags
3267 @cindex headline tagging
3268 @cindex matching, tags
3269 @cindex sparse tree, tag based
3271 An excellent way to implement labels and contexts for cross-correlating
3272 information is to assign @i{tags} to headlines.  Org mode has extensive
3273 support for tags.
3275 Every headline can contain a list of tags; they occur at the end of the
3276 headline.  Tags are normal words containing letters, numbers, @samp{_},
3277 and @samp{@@}.  Tags must be preceded and followed by a single colon,
3278 e.g., @samp{:WORK:}.  Several tags can be specified, as in
3279 @samp{:work:URGENT:}.
3281 @menu
3282 * Tag inheritance::             Tags use the tree structure of the outline
3283 * Setting tags::                How to assign tags to a headline
3284 * Tag searches::                Searching for combinations of tags
3285 @end menu
3287 @node Tag inheritance, Setting tags, Tags, Tags
3288 @section Tag inheritance
3289 @cindex tag inheritance
3290 @cindex inheritance, of tags
3291 @cindex sublevels, inclusion into tags match
3293 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3294 heading has a certain tag, all subheadings will inherit the tag as
3295 well.  For example, in the list
3297 @example
3298 * Meeting with the French group      :work:
3299 ** Summary by Frank                  :boss:notes:
3300 *** TODO Prepare slides for him      :action:
3301 @end example
3303 @noindent
3304 the final heading will have the tags @samp{:work:}, @samp{:boss:},
3305 @samp{:notes:}, and @samp{:action:} even though the final heading is not
3306 explicitly marked with those tags.  When executing tag searches and
3307 Org mode finds that a certain headline matches the search criterion, it
3308 will not check any sublevel headline, assuming that these also match and
3309 that the list of matches could become very long because of that.  If you
3310 do want the sublevels be tested and listed as well, you may set the
3311 variable @code{org-tags-match-list-sublevels}.  To limit tag inheritance
3312 to specific tags, or to turn it off entirely, use the variable
3313 @code{org-use-tag-inheritance}.
3315 @node Setting tags, Tag searches, Tag inheritance, Tags
3316 @section Setting tags
3317 @cindex setting tags
3318 @cindex tags, setting
3320 @kindex M-@key{TAB}
3321 Tags can simply be typed into the buffer at the end of a headline.
3322 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3323 also a special command for inserting tags:
3325 @table @kbd
3326 @kindex C-c C-c
3327 @item C-c C-c
3328 @cindex completion, of tags
3329 Enter new tags for the current headline.  Org mode will either offer
3330 completion or a special single-key interface for setting tags, see
3331 below.  After pressing @key{RET}, the tags will be inserted and aligned
3332 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3333 tags in the current buffer will be aligned to that column, just to make
3334 things look nice.  TAGS are automatically realigned after promotion,
3335 demotion, and TODO state changes (@pxref{TODO basics}).
3336 @end table
3338 Org will support tag insertion based on a @emph{list of tags}.  By
3339 default this list is constructed dynamically, containing all tags
3340 currently used in the buffer.  You may also globally specify a hard list
3341 of tags with the variable @code{org-tag-alist}.  Finally you can set
3342 the default tags for a given file with lines like
3344 @example
3345 #+TAGS: @@work @@home @@tennisclub
3346 #+TAGS: laptop car pc sailboat
3347 @end example
3349 If you have globally defined your preferred set of tags using the
3350 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3351 in a specific file, add an empty TAGS option line to that file:
3353 @example
3354 #+TAGS:
3355 @end example
3357 By default Org mode uses the standard minibuffer completion facilities for
3358 entering tags.  However, it also implements another, quicker, tag selection
3359 method called @emph{fast tag selection}.  This allows you to select and
3360 deselect tags with just a single key press.  For this to work well you should
3361 assign unique letters to most of your commonly used tags.  You can do this
3362 globally by configuring the variable @code{org-tag-alist} in your
3363 @file{.emacs} file.  For example, you may find the need to tag many items in
3364 different files with @samp{:@@home:}.  In this case you can set something
3365 like:
3367 @lisp
3368 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
3369 @end lisp
3371 @noindent If the tag is only relevant to the file you are working on then you
3372 can, instead, set the TAGS option line as:
3374 @example
3375 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
3376 @end example
3378 @noindent
3379 You can also group together tags that are mutually exclusive.  By using
3380 braces, as in:
3382 @example
3383 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
3384 @end example
3386 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
3387 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
3389 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3390 these lines to activate any changes.
3392 @noindent
3393 To set these mutually exclusive groups in the variable @code{org-mode-alist}
3394 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
3395 of the braces.  The previous example would be set globally by the following
3396 configuration:
3398 @lisp
3399 (setq org-tag-alist '((:startgroup . nil)
3400                       ("@@work" . ?w) ("@@home" . ?h)
3401                       ("@@tennisclub" . ?t)
3402                       (:endgroup . nil)
3403                       ("laptop" . ?l) ("pc" . ?p)))
3404 @end lisp
3406 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
3407 automatically present you with a special interface, listing inherited tags,
3408 the tags of the current headline, and a list of all valid tags with
3409 corresponding keys@footnote{Keys will automatically be assigned to tags which
3410 have no configured keys.}.  In this interface, you can use the following
3411 keys:
3413 @table @kbd
3414 @item a-z...
3415 Pressing keys assigned to tags will add or remove them from the list of
3416 tags in the current line.  Selecting a tag in a group of mutually
3417 exclusive tags will turn off any other tags from that group.
3418 @kindex @key{TAB}
3419 @item @key{TAB}
3420 Enter a tag in the minibuffer, even if the tag is not in the predefined
3421 list.  You will be able to complete on all tags present in the buffer.
3422 @kindex @key{SPC}
3423 @item @key{SPC}
3424 Clear all tags for this line.
3425 @kindex @key{RET}
3426 @item @key{RET}
3427 Accept the modified set.
3428 @item C-g
3429 Abort without installing changes.
3430 @item q
3431 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3432 @item !
3433 Turn off groups of mutually exclusive tags.  Use this to (as an
3434 exception) assign several tags from such a group.
3435 @item C-c
3436 Toggle auto-exit after the next change (see below).
3437 If you are using expert mode, the first @kbd{C-c} will display the
3438 selection window.
3439 @end table
3441 @noindent
3442 This method lets you assign tags to a headline with very few keys.  With
3443 the above setup, you could clear the current tags and set @samp{@@home},
3444 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
3445 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
3446 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
3447 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3448 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3449 @key{RET} @key{RET}}.
3451 If you find that most of the time, you need only a single key press to
3452 modify your list of tags, set the variable
3453 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3454 press @key{RET} to exit fast tag selection - it will immediately exit
3455 after the first change.  If you then occasionally need more keys, press
3456 @kbd{C-c} to turn off auto-exit for the current tag selection process
3457 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
3458 C-c}).  If you set the variable to the value @code{expert}, the special
3459 window is not even shown for single-key tag selection, it comes up only
3460 when you press an extra @kbd{C-c}.
3462 @node Tag searches,  , Setting tags, Tags
3463 @section Tag searches
3464 @cindex tag searches
3465 @cindex searching for tags
3467 Once a system of tags has been set up, it can be used to collect related
3468 information into special lists.
3470 @table @kbd
3471 @kindex C-c \
3472 @kindex C-c / T
3473 @item C-c \
3474 @itemx C-c / T
3475 Create a sparse tree with all headlines matching a tags search.  With a
3476 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
3477 @kindex C-c a m
3478 @item C-c a m
3479 Create a global list of tag matches from all agenda files.
3480 @xref{Matching tags and properties}.
3481 @kindex C-c a M
3482 @item C-c a M
3483 Create a global list of tag matches from all agenda files, but check
3484 only TODO items and force checking subitems (see variable
3485 @code{org-tags-match-list-sublevels}).
3486 @end table
3488 @cindex Boolean logic, for tag searches
3489 A @i{tags} search string can use Boolean operators @samp{&} for AND and
3490 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
3491 Parenthesis are currently not implemented.  A tag may also be preceded
3492 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
3493 positive selection.  The AND operator @samp{&} is optional when @samp{+}
3494 or @samp{-} is present.  Examples:
3496 @table @samp
3497 @item +work-boss
3498 Select headlines tagged @samp{:work:}, but discard those also tagged
3499 @samp{:boss:}.
3500 @item work|laptop
3501 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
3502 @item work|laptop&night
3503 Like before, but require the @samp{:laptop:} lines to be tagged also
3504 @samp{:night:}.
3505 @end table
3507 @cindex TODO keyword matching, with tags search
3508 If you are using multi-state TODO keywords (@pxref{TODO extensions}), it
3509 can be useful to also match on the TODO keyword.  This can be done by
3510 adding a condition after a slash to a tags match.  The syntax is similar
3511 to the tag matches, but should be applied with consideration: For
3512 example, a positive selection on several TODO keywords can not
3513 meaningfully be combined with boolean AND.  However, @emph{negative
3514 selection} combined with AND can be meaningful.  To make sure that only
3515 lines are checked that actually have any TODO keyword, use @kbd{C-c a
3516 M}, or equivalently start the TODO part after the slash with @samp{!}.
3517 Examples:
3519 @table @samp
3520 @item work/WAITING
3521 Select @samp{:work:}-tagged TODO lines with the specific TODO
3522 keyword @samp{WAITING}.
3523 @item work/!-WAITING-NEXT
3524 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
3525 nor @samp{NEXT}
3526 @item work/+WAITING|+NEXT
3527 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
3528 @samp{NEXT}.
3529 @end table
3531 @cindex regular expressions, with tags search
3532 Any element of the tag/todo match can be a regular expression - in this
3533 case it must be enclosed in curly braces.  For example,
3534 @samp{work+@{^boss.*@}} matches headlines that contain the tag
3535 @samp{:work:} and any tag @i{starting} with @samp{boss}.
3537 @cindex level, require for tags/property match
3538 @cindex category, require for tags/property match
3539 You can also require a headline to be of a certain level or category, by
3540 writing instead of any TAG an expression like @samp{LEVEL=3} or
3541 @samp{CATEGORY="work"}, respectively.  For example, a search
3542 @samp{+LEVEL=3+boss/-DONE} lists all level three headlines that have the
3543 tag @samp{boss} and are @emph{not} marked with the TODO keyword DONE.
3545 @node Properties and Columns, Dates and Times, Tags, Top
3546 @chapter Properties and Columns
3547 @cindex properties
3549 Properties are a set of key-value pairs associated with an entry.  There
3550 are two main applications for properties in Org mode.  First, properties
3551 are like tags, but with a value.  Second, you can use properties to
3552 implement (very basic) database capabilities in an Org buffer.  For
3553 an example of the first application, imagine maintaining a file where
3554 you document bugs and plan releases of a piece of software.  Instead of
3555 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
3556 property, say @code{:Release:}, that in different subtrees has different
3557 values, such as @code{1.0} or @code{2.0}.  For an example of the second
3558 application of properties, imagine keeping track of your music CD's,
3559 where properties could be things such as the album artist, date of
3560 release, number of tracks, and so on.
3562 Properties can be conveniently edited and viewed in column view
3563 (@pxref{Column view}).
3565 Properties are like tags, but with a value.  For example, in a file
3566 where you document bugs and plan releases of a piece of software,
3567 instead of using tags like @code{:release_1:}, @code{:release_2:}, it
3568 can be more efficient to use a property @code{:Release:} with a value
3569 @code{1.0} or @code{2.0}.  Second, you can use properties to implement
3570 (very basic) database capabilities in an Org buffer, for example to
3571 create a list of Music CD's you own.  You can edit and view properties
3572 conveniently in column view (@pxref{Column view}).
3574 @menu
3575 * Property syntax::             How properties are spelled out
3576 * Special properties::          Access to other Org mode features
3577 * Property searches::           Matching property values
3578 * Property inheritance::        Passing values down the tree
3579 * Column view::                 Tabular viewing and editing
3580 * Property API::                Properties for Lisp programmers
3581 @end menu
3583 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
3584 @section Property syntax
3585 @cindex property syntax
3586 @cindex drawer, for properties
3588 Properties are key-value pairs.  They need to be inserted into a special
3589 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
3590 is specified on a single line, with the key (surrounded by colons)
3591 first, and the value after it.  Here is an example:
3593 @example
3594 * CD collection
3595 ** Classic
3596 *** Goldberg Variations
3597     :PROPERTIES:
3598     :Title:     Goldberg Variations
3599     :Composer:  J.S. Bach
3600     :Artist:    Glen Gould
3601     :Publisher: Deutsche Grammphon
3602     :NDisks:    1
3603     :END:
3604 @end example
3606 You may define the allowed values for a particular property @samp{:Xyz:}
3607 by setting a property @samp{:Xyz_ALL:}.  This special property is
3608 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
3609 the entire tree.  When allowed values are defined, setting the
3610 corresponding property becomes easier and is less prone to typing
3611 errors.  For the example with the CD collection, we can predefine
3612 publishers and the number of disks in a box like this:
3614 @example
3615 * CD collection
3616   :PROPERTIES:
3617   :NDisks_ALL:  1 2 3 4
3618   :Publisher_ALL: "Deutsche Grammophon" Phillips EMI
3619   :END:
3620 @end example
3622 If you want to set properties that can be inherited by any entry in a
3623 file, use a line like
3625 @example
3626 #+PROPERTY: NDisks_ALL 1 2 3 4
3627 @end example
3629 Property values set with the global variable
3630 @code{org-global-properties} can be inherited by all entries in all
3631 Org files.
3633 @noindent
3634 The following commands help to work with properties:
3636 @table @kbd
3637 @kindex M-@key{TAB}
3638 @item M-@key{TAB}
3639 After an initial colon in a line, complete property keys.  All keys used
3640 in the current file will be offered as possible completions.
3641 @kindex C-c C-x p
3642 @item C-c C-x p
3643 Set a property.  This prompts for a property name and a value.  If
3644 necessary, the property drawer is created as well.
3645 @item M-x org-insert-property-drawer
3646 Insert a property drawer into the current entry.  The drawer will be
3647 inserted early in the entry, but after the lines with planning
3648 information like deadlines.
3649 @kindex C-c C-c
3650 @item C-c C-c
3651 With the cursor in a property drawer, this executes property commands.
3652 @item C-c C-c s
3653 Set a property in the current entry.  Both the property and the value
3654 can be inserted using completion.
3655 @kindex S-@key{right}
3656 @kindex S-@key{left}
3657 @item S-@key{left}/@key{right}
3658 Switch property at point to the next/previous allowed value.
3659 @item C-c C-c d
3660 Remove a property from the current entry.
3661 @item C-c C-c D
3662 Globally remove a property, from all entries in the current file.
3663 @item C-c C-c c
3664 Compute the property at point, using the operator and scope from the
3665 nearest column format definition.
3666 @end table
3668 @node Special properties, Property searches, Property syntax, Properties and Columns
3669 @section Special properties
3670 @cindex properties, special
3672 Special properties provide alternative access method to Org mode
3673 features discussed in the previous chapters, like the TODO state or the
3674 priority of an entry.  This interface exists so that you can include
3675 these states into columns view (@pxref{Column view}), or to use them in
3676 queries.  The following property names are special and should not be
3677 used as keys in the properties drawer:
3679 @example
3680 TODO         @r{The TODO keyword of the entry.}
3681 TAGS         @r{The tags defined directly in the headline.}
3682 ALLTAGS      @r{All tags, including inherited ones.}
3683 PRIORITY     @r{The priority of the entry, a string with a single letter.}
3684 DEADLINE     @r{The deadline time string, without the angular brackets.}
3685 SCHEDULED    @r{The scheduling time stamp, without the angular brackets.}
3686 TIMESTAMP    @r{The first keyword-less time stamp in the entry.}
3687 TIMESTAMP_IA @r{The first inactive time stamp in the entry.}
3688 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
3689              @r{must be run first to compute the values.}
3690 @end example
3692 @node Property searches, Property inheritance, Special properties, Properties and Columns
3693 @section Property searches
3694 @cindex properties, searching
3695 @cindex searching, of properties
3697 To create sparse trees and special lists with selection based on properties,
3698 the same commands are used as for tag searches (@pxref{Tag searches}), and
3699 the same logic applies.  For example, here is a search string:
3701 @example
3702 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2+With=@{Sarah\|Denny@}
3703 @end example
3705 @noindent
3706 If the comparison value is a plain number, a numerical comparison is done,
3707 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
3708 @samp{>=}, and @samp{<>}.  If the comparison value is enclosed in double
3709 quotes, a string comparison is done, and the same operators are allowed.  If
3710 the comparison value is enclosed in curly braces, a regexp match is
3711 performed, with @samp{=} meaning that the regexp matches the property value,
3712 and @samp{<>} meaning that it does not match.  So the search string in the
3713 example finds entries tagged @samp{:work:} but not @samp{:boss:}, which also
3714 have a priority value @samp{A}, a @samp{:Coffee:} property with the value
3715 @samp{unlimited}, an @samp{Effort} property that is numerically smaller than
3716 2, and a @samp{:With:} property that is matched by the regular expression
3717 @samp{Sarah\|Denny}.
3719 You can configure Org mode to use property inheritance during a search, but
3720 beware that this can slow down searches considerably.  See @ref{Property
3721 inheritance} for details.
3723 There is also a special command for creating sparse trees based on a
3724 single property:
3726 @table @kbd
3727 @kindex C-c / p
3728 @item C-c / p
3729 Create a sparse tree based on the value of a property.  This first
3730 prompts for the name of a property, and then for a value.  A sparse tree
3731 is created with all entries that define this property with the given
3732 value.  If you enclose the value into curly braces, it is interpreted as
3733 a regular expression and matched against the property values.
3734 @end table
3736 @node Property inheritance, Column view, Property searches, Properties and Columns
3737 @section Property Inheritance
3738 @cindex properties, inheritance
3739 @cindex inheritance, of properties
3741 The outline structure of Org mode documents lends itself for an
3742 inheritance model of properties: If the parent in a tree has a certain
3743 property, the children can inherit this property.  Org mode does not
3744 turn this on by default, because it can slow down property searches
3745 significantly and is often not needed.  However, if you find inheritance
3746 useful, you can turn it on by setting the variable
3747 @code{org-use-property-inheritance}.  It may be set to @code{t}, to make
3748 all properties inherited from the parent, to a list of properties
3749 that should be inherited, or to a regular expression that matches
3750 inherited properties.
3752 Org mode has a few properties for which inheritance is hard-coded, at
3753 least for the special applications for which they are used:
3755 @table @code
3756 @item COLUMNS
3757 The @code{:COLUMNS:} property defines the format of column view
3758 (@pxref{Column view}).  It is inherited in the sense that the level
3759 where a @code{:COLUMNS:} property is defined is used as the starting
3760 point for a column view table, independently of the location in the
3761 subtree from where columns view is turned on.
3762 @item CATEGORY
3763 For agenda view, a category set through a @code{:CATEGORY:} property
3764 applies to the entire subtree.
3765 @item ARCHIVE
3766 For archiving, the @code{:ARCHIVE:} property may define the archive
3767 location for the entire subtree (@pxref{Moving subtrees}).
3768 @item LOGGING
3769 The LOGGING property may define logging settings for an entry or a
3770 subtree (@pxref{Tracking TODO state changes}).
3771 @end table
3773 @node Column view, Property API, Property inheritance, Properties and Columns
3774 @section Column view
3776 A great way to view and edit properties in an outline tree is
3777 @emph{column view}.  In column view, each outline item is turned into a
3778 table row.  Columns in this table provide access to properties of the
3779 entries.  Org mode implements columns by overlaying a tabular structure
3780 over the headline of each item.  While the headlines have been turned
3781 into a table row, you can still change the visibility of the outline
3782 tree.  For example, you get a compact table by switching to CONTENTS
3783 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
3784 is active), but you can still open, read, and edit the entry below each
3785 headline.  Or, you can switch to column view after executing a sparse
3786 tree command and in this way get a table only for the selected items.
3787 Column view also works in agenda buffers (@pxref{Agenda Views}) where
3788 queries have collected selected items, possibly from a number of files.
3790 @menu
3791 * Defining columns::            The COLUMNS format property
3792 * Using column view::           How to create and use column view
3793 * Capturing column view::       A dynamic block for column view
3794 @end menu
3796 @node Defining columns, Using column view, Column view, Column view
3797 @subsection Defining columns
3798 @cindex column view, for properties
3799 @cindex properties, column view
3801 Setting up a column view first requires defining the columns.  This is
3802 done by defining a column format line.
3804 @menu
3805 * Scope of column definitions::  Where defined, where valid?
3806 * Column attributes::           Appearance and content of a column
3807 @end menu
3809 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
3810 @subsubsection Scope of column definitions
3812 To define a column format for an entire file, use a line like
3814 @example
3815 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3816 @end example
3818 To specify a format that only applies to a specific tree, add a
3819 @code{:COLUMNS:} property to the top node of that tree, for example:
3821 @example
3822 ** Top node for columns view
3823    :PROPERTIES:
3824    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3825    :END:
3826 @end example
3828 If a @code{:COLUMNS:} property is present in an entry, it defines columns
3829 for the entry itself, and for the entire subtree below it.  Since the
3830 column definition is part of the hierarchical structure of the document,
3831 you can define columns on level 1 that are general enough for all
3832 sublevels, and more specific columns further down, when you edit a
3833 deeper part of the tree.
3835 @node Column attributes,  , Scope of column definitions, Defining columns
3836 @subsubsection Column attributes
3837 A column definition sets the attributes of a column.  The general
3838 definition looks like this:
3840 @example
3841  %[width]property[(title)][@{summary-type@}]
3842 @end example
3844 @noindent
3845 Except for the percent sign and the property name, all items are
3846 optional.  The individual parts have the following meaning:
3848 @example
3849 width           @r{An integer specifying the width of the column in characters.}
3850                 @r{If omitted, the width will be determined automatically.}
3851 property        @r{The property that should be edited in this column.}
3852 (title)         @r{The header text for the column. If omitted, the}
3853                 @r{property name is used.}
3854 @{summary-type@}  @r{The summary type.  If specified, the column values for}
3855                 @r{parent nodes are computed from the children.}
3856                 @r{Supported summary types are:}
3857                 @{+@}       @r{Sum numbers in this column.}
3858                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
3859                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
3860                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
3861                 @{X@}       @r{Checkbox status, [X] if all children are [X].}
3862                 @{X/@}      @r{Checkbox status, [n/m].}
3863                 @{X%@}      @r{Checkbox status, [n%].}
3864 @end example
3866 @noindent
3867 Here is an example for a complete columns definition, along with allowed
3868 values.
3870 @example
3871 :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.}
3872                    %10Time_Estimate@{:@} %CLOCKSUM
3873 :Owner_ALL:    Tammy Mark Karl Lisa Don
3874 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
3875 :Approved_ALL: "[ ]" "[X]"
3876 @end example
3878 The first column, @samp{%25ITEM}, means the first 25 characters of the
3879 item itself, i.e. of the headline.  You probably always should start the
3880 column definition with the @samp{ITEM} specifier.  The other specifiers
3881 create columns @samp{Owner} with a list of names as allowed values, for
3882 @samp{Status} with four different possible values, and for a checkbox
3883 field @samp{Approved}.  When no width is given after the @samp{%}
3884 character, the column will be exactly as wide as it needs to be in order
3885 to fully display all values.  The @samp{Approved} column does have a
3886 modified title (@samp{Approved?}, with a question mark).  Summaries will
3887 be created for the @samp{Time_Estimate} column by adding time duration
3888 expressions like HH:MM, and for the @samp{Approved} column, by providing
3889 an @samp{[X]} status if all children have been checked.  The
3890 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
3891 in the subtree.
3893 @node Using column view, Capturing column view, Defining columns, Column view
3894 @subsection Using column view
3896 @table @kbd
3897 @tsubheading{Turning column view on and off}
3898 @kindex C-c C-x C-c
3899 @item C-c C-x C-c
3900 Create the column view for the local environment.  This command searches
3901 the hierarchy, up from point, for a @code{:COLUMNS:} property that defines
3902 a format.  When one is found, the column view table is established for
3903 the entire tree, starting from the entry that contains the @code{:COLUMNS:}
3904 property.  If none is found, the format is taken from the @code{#+COLUMNS}
3905 line or from the variable @code{org-columns-default-format}, and column
3906 view is established for the current entry and its subtree.
3907 @kindex r
3908 @item r
3909 Recreate the column view, to include recent changes made in the buffer.
3910 @kindex g
3911 @item g
3912 Same as @kbd{r}.
3913 @kindex q
3914 @item q
3915 Exit column view.
3916 @tsubheading{Editing values}
3917 @item @key{left} @key{right} @key{up} @key{down}
3918 Move through the column view from field to field.
3919 @kindex S-@key{left}
3920 @kindex S-@key{right}
3921 @item  S-@key{left}/@key{right}
3922 Switch to the next/previous allowed value of the field.  For this, you
3923 have to have specified allowed values for a property.
3924 @kindex n
3925 @kindex p
3926 @itemx  n / p
3927 Same as @kbd{S-@key{left}/@key{right}}
3928 @kindex e
3929 @item e
3930 Edit the property at point.  For the special properties, this will
3931 invoke the same interface that you normally use to change that
3932 property.  For example, when editing a TAGS property, the tag completion
3933 or fast selection interface will pop up.
3934 @kindex C-c C-c
3935 @item C-c C-c
3936 When there is a checkbox at point, toggle it.
3937 @kindex v
3938 @item v
3939 View the full value of this property.  This is useful if the width of
3940 the column is smaller than that of the value.
3941 @kindex a
3942 @item a
3943 Edit the list of allowed values for this property.  If the list is found
3944 in the hierarchy, the modified values is stored there.  If no list is
3945 found, the new value is stored in the first entry that is part of the
3946 current column view.
3947 @tsubheading{Modifying the table structure}
3948 @kindex <
3949 @kindex >
3950 @item < / >
3951 Make the column narrower/wider by one character.
3952 @kindex S-M-@key{right}
3953 @item S-M-@key{right}
3954 Insert a new column, to the right of the current column.
3955 @kindex S-M-@key{left}
3956 @item S-M-@key{left}
3957 Delete the current column.
3958 @end table
3960 @node Capturing column view,  , Using column view, Column view
3961 @subsection Capturing column view
3963 Since column view is just an overlay over a buffer, it cannot be
3964 exported or printed directly.  If you want to capture a column view, use
3965 this @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
3966 of this block looks like this:
3968 @cindex #+BEGIN: columnview
3969 @example
3970 * The column view
3971 #+BEGIN: columnview :hlines 1 :id "label"
3973 #+END:
3974 @end example
3976 @noindent This dynamic block has the following parameters:
3978 @table @code
3979 @item :id
3980 This is most important parameter.  Column view is a feature that is
3981 often localized to a certain (sub)tree, and the capture block might be
3982 in a different location in the file.  To identify the tree whose view to
3983 capture, you can use 3 values:
3984 @example
3985 local     @r{use the tree in which the capture block is located}
3986 global    @r{make a global view, including all headings in the file}
3987 "label"   @r{call column view in the tree that has and @code{:ID:}}
3988           @r{property with the value @i{label}}
3989 @end example
3990 @item :hlines
3991 When @code{t}, insert a hline after every line.  When a number N, insert
3992 a hline before each headline with level @code{<= N}.
3993 @item :vlines
3994 When set to @code{t}, enforce column groups to get vertical lines.
3995 @item :maxlevel
3996 When set to a number, don't capture entries below this level.
3997 @item :skip-empty-rows
3998 When set to @code{t}, skip row where the only non-empty specifier of the
3999 column view is @code{ITEM}.
4001 @end table
4003 @noindent
4004 The following commands insert or update the dynamic block:
4006 @table @kbd
4007 @kindex C-c C-x r
4008 @item C-c C-x r
4009 Insert a dynamic block capturing a column view.  You will be prompted
4010 for the scope or id of the view.
4011 @kindex C-c C-c
4012 @item C-c C-c
4013 @kindex C-c C-x C-u
4014 @itemx C-c C-x C-u
4015 Update dynamical block at point.  The cursor needs to be in the
4016 @code{#+BEGIN} line of the dynamic block.
4017 @kindex C-u C-c C-x C-u
4018 @item C-u C-c C-x C-u
4019 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4020 you have several clock table blocks in a buffer.
4021 @end table
4023 @node Property API,  , Column view, Properties and Columns
4024 @section The Property API
4025 @cindex properties, API
4026 @cindex API, for properties
4028 There is a full API for accessing and changing properties.  This API can
4029 be used by Emacs Lisp programs to work with properties and to implement
4030 features based on them.  For more information see @ref{Using the
4031 property API}.
4033 @node Dates and Times, Remember, Properties and Columns, Top
4034 @chapter Dates and Times
4035 @cindex dates
4036 @cindex times
4037 @cindex time stamps
4038 @cindex date stamps
4040 To assist project planning, TODO items can be labeled with a date and/or
4041 a time.  The specially formatted string carrying the date and time
4042 information is called a @emph{timestamp} in Org mode.  This may be a
4043 little confusing because timestamp is often used as indicating when
4044 something was created or last changed.  However, in Org mode this term
4045 is used in a much wider sense.
4047 @menu
4048 * Timestamps::                  Assigning a time to a tree entry
4049 * Creating timestamps::         Commands which insert timestamps
4050 * Deadlines and scheduling::    Planning your work
4051 * Clocking work time::          Tracking how long you spend on a task
4052 * Effort estimates::            Planning work effort in advance
4053 @end menu
4056 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4057 @section Timestamps, deadlines and scheduling
4058 @cindex time stamps
4059 @cindex ranges, time
4060 @cindex date stamps
4061 @cindex deadlines
4062 @cindex scheduling
4064 A time stamp is a specification of a date (possibly with time or a range
4065 of times) in a special format, either @samp{<2003-09-16 Tue>} or
4066 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4067 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
4068 use an alternative format, see @ref{Custom time format}.}.  A time stamp
4069 can appear anywhere in the headline or body of an Org tree entry.  Its
4070 presence causes entries to be shown on specific dates in the agenda
4071 (@pxref{Weekly/daily agenda}).  We distinguish:
4073 @table @var
4074 @item Plain time stamp; Event; Appointment
4075 @cindex timestamp
4076 A simple time stamp just assigns a date/time to an item.  This is just
4077 like writing down an appointment or event in a paper agenda.  In the
4078 timeline and agenda displays, the headline of an entry associated with a
4079 plain time stamp will be shown exactly on that date.
4081 @example
4082 * Meet Peter at the movies <2006-11-01 Wed 19:15>
4083 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
4084 @end example
4086 @item Time stamp with repeater interval
4087 @cindex timestamp, with repeater interval
4088 A time stamp may contain a @emph{repeater interval}, indicating that it
4089 applies not only on the given date, but again and again after a certain
4090 interval of N days (d), weeks (w), months(m), or years(y).  The
4091 following will show up in the agenda every Wednesday:
4093 @example
4094 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4095 @end example
4097 @item Diary-style sexp entries
4098 For more complex date specifications, Org mode supports using the
4099 special sexp diary entries implemented in the Emacs calendar/diary
4100 package.  For example
4102 @example
4103 * The nerd meeting on every 2nd Thursday of the month
4104   <%%(diary-float t 4 2)>
4105 @end example
4107 @item Time/Date range
4108 @cindex timerange
4109 @cindex date range
4110 Two time stamps connected by @samp{--} denote a range.  The headline
4111 will be shown on the first and last day of the range, and on any dates
4112 that are displayed and fall in the range.  Here is an example:
4114 @example
4115 ** Meeting in Amsterdam
4116    <2004-08-23 Mon>--<2004-08-26 Thu>
4117 @end example
4119 @item Inactive time stamp
4120 @cindex timestamp, inactive
4121 @cindex inactive timestamp
4122 Just like a plain time stamp, but with square brackets instead of
4123 angular ones.  These time stamps are inactive in the sense that they do
4124 @emph{not} trigger an entry to show up in the agenda.
4126 @example
4127 * Gillian comes late for the fifth time [2006-11-01 Wed]
4128 @end example
4130 @end table
4132 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
4133 @section Creating timestamps
4134 @cindex creating timestamps
4135 @cindex timestamps, creating
4137 For Org mode to recognize time stamps, they need to be in the specific
4138 format.  All commands listed below produce time stamps in the correct
4139 format.
4141 @table @kbd
4142 @kindex C-c .
4143 @item C-c .
4144 Prompt for a date and insert a corresponding time stamp.  When the
4145 cursor is at a previously used time stamp, it is updated to NOW.  When
4146 this command is used twice in succession, a time range is inserted.
4148 @kindex C-u C-c .
4149 @item C-u C-c .
4150 Like @kbd{C-c .}, but use the alternative format which contains date
4151 and time.  The default time can be rounded to multiples of 5 minutes,
4152 see the option @code{org-time-stamp-rounding-minutes}.
4154 @kindex C-c !
4155 @item C-c !
4156 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
4157 an agenda entry.
4159 @kindex C-c <
4160 @item C-c <
4161 Insert a time stamp corresponding to the cursor date in the Calendar.
4163 @kindex C-c >
4164 @item C-c >
4165 Access the Emacs calendar for the current date.  If there is a
4166 timestamp in the current line, go to the corresponding date
4167 instead.
4169 @kindex C-c C-o
4170 @item C-c C-o
4171 Access the agenda for the date given by the time stamp or -range at
4172 point (@pxref{Weekly/daily agenda}).
4174 @kindex S-@key{left}
4175 @kindex S-@key{right}
4176 @item S-@key{left}
4177 @itemx S-@key{right}
4178 Change date at cursor by one day.  These key bindings conflict with
4179 CUA mode (@pxref{Conflicts}).
4181 @kindex S-@key{up}
4182 @kindex S-@key{down}
4183 @item S-@key{up}
4184 @itemx S-@key{down}
4185 Change the item under the cursor in a timestamp.  The cursor can be on a
4186 year, month, day, hour or minute.  Note that if the cursor is in a
4187 headline and not at a time stamp, these same keys modify the priority of
4188 an item.  (@pxref{Priorities}). The key bindings also conflict with
4189 CUA mode (@pxref{Conflicts}).
4191 @kindex C-c C-y
4192 @cindex evaluate time range
4193 @item C-c C-y
4194 Evaluate a time range by computing the difference between start and end.
4195 With a prefix argument, insert result after the time range (in a table: into
4196 the following column).
4197 @end table
4200 @menu
4201 * The date/time prompt::        How Org mode helps you entering date and time
4202 * Custom time format::          Making dates look different
4203 @end menu
4205 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
4206 @subsection The date/time prompt
4207 @cindex date, reading in minibuffer
4208 @cindex time, reading in minibuffer
4210 When Org mode prompts for a date/time, the default is shown as an ISO
4211 date, and the prompt therefore seems to ask for an ISO date.  But it
4212 will in fact accept any string containing some date and/or time
4213 information, and it is really smart about interpreting your input.  You
4214 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
4215 copied from an email message.  Org mode will find whatever information
4216 is in there and derive anything you have not specified from the
4217 @emph{default date and time}.  The default is usually the current date
4218 and time, but when modifying an existing time stamp, or when entering
4219 the second stamp of a range, it is taken from the stamp in the buffer.
4220 When filling in information, Org mode assumes that most of the time you
4221 will want to enter a date in the future: If you omit the month/year and
4222 the given day/month is @i{before} today, it will assume that you mean a
4223 future date@footnote{See the variable
4224 @code{org-read-date-prefer-future}.}.
4226 For example, lets assume that today is @b{June 13, 2006}.  Here is how
4227 various inputs will be interpreted, the items filled in by Org mode are
4228 in @b{bold}.
4230 @example
4231 3-2-5         --> 2003-02-05
4232 14            --> @b{2006}-@b{06}-14
4233 12            --> @b{2006}-@b{07}-12
4234 Fri           --> nearest Friday (defaultdate or later)
4235 sep 15        --> @b{2006}-11-15
4236 feb 15        --> @b{2007}-02-15
4237 sep 12 9      --> 2009-09-12
4238 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
4239 22 sept 0:34  --> @b{2006}-09-22 0:34
4240 w4            --> ISO week for of the current year @b{2006}
4241 2012 w4 fri   --> Friday of ISO week 4 in 2012
4242 2012-w04-5    --> Same as above
4243 @end example
4245 Furthermore you can specify a relative date by giving, as the
4246 @emph{first} thing in the input: a plus/minus sign, a number and a
4247 letter [dwmy] to indicate change in days weeks, months, years.  With a
4248 single plus or minus, the date is always relative to today.  With a
4249 double plus or minus, it is relative to the default date.  If instead of
4250 a single letter, you use the abbreviation of day name, the date will be
4251 the nth such day.  E.g.
4253 @example
4254 +0            --> today
4255 .             --> today
4256 +4d           --> four days from today
4257 +4            --> same as above
4258 +2w           --> two weeks from today
4259 ++5           --> five days from default date
4260 +2tue         --> second tuesday from now.
4261 @end example
4263 The function understands English month and weekday abbreviations.  If
4264 you want to use unabbreviated names and/or other languages, configure
4265 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
4267 @cindex calendar, for selecting date
4268 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
4269 you don't need/want the calendar, configure the variable
4270 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
4271 prompt, either by clicking on a date in the calendar, or by pressing
4272 @key{RET}, the date selected in the calendar will be combined with the
4273 information entered at the prompt.  You can control the calendar fully
4274 from the minibuffer:
4276 @kindex <
4277 @kindex >
4278 @kindex mouse-1
4279 @kindex S-@key{right}
4280 @kindex S-@key{left}
4281 @kindex S-@key{down}
4282 @kindex S-@key{up}
4283 @kindex M-S-@key{right}
4284 @kindex M-S-@key{left}
4285 @kindex @key{RET}
4286 @example
4287 > / <          @r{Scroll calendar forward/backward by one month.}
4288 mouse-1        @r{Select date by clicking on it.}
4289 S-@key{right}/@key{left}     @r{One day forward/backward.}
4290 S-@key{down}/@key{up}     @r{One week forward/backward.}
4291 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
4292 @key{RET}           @r{Choose date in calendar.}
4293 @end example
4295 The actions of the date/time prompt may seem complex, but I assure you they
4296 will grow on you, and you will start getting annoyed by pretty much any other
4297 way of entering a date/time out there.  To help you understand what is going
4298 on, the current interpretation of your input will be displayed live in the
4299 minibuffer@footnote{If you find this distracting, turn the display of with
4300 @code{org-read-date-display-live}.}.
4302 @node Custom time format,  , The date/time prompt, Creating timestamps
4303 @subsection Custom time format
4304 @cindex custom date/time format
4305 @cindex time format, custom
4306 @cindex date format, custom
4308 Org mode uses the standard ISO notation for dates and times as it is
4309 defined in ISO 8601.  If you cannot get used to this and require another
4310 representation of date and time to keep you happy, you can get it by
4311 customizing the variables @code{org-display-custom-times} and
4312 @code{org-time-stamp-custom-formats}.
4314 @table @kbd
4315 @kindex C-c C-x C-t
4316 @item C-c C-x C-t
4317 Toggle the display of custom formats for dates and times.
4318 @end table
4320 @noindent
4321 Org mode needs the default format for scanning, so the custom date/time
4322 format does not @emph{replace} the default format - instead it is put
4323 @emph{over} the default format using text properties.  This has the
4324 following consequences:
4325 @itemize @bullet
4326 @item
4327 You cannot place the cursor onto a time stamp anymore, only before or
4328 after.
4329 @item
4330 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
4331 each component of a time stamp.  If the cursor is at the beginning of
4332 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
4333 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
4334 time will be changed by one minute.
4335 @item
4336 If the time stamp contains a range of clock times or a repeater, these
4337 will not be overlayed, but remain in the buffer as they were.
4338 @item
4339 When you delete a time stamp character-by-character, it will only
4340 disappear from the buffer after @emph{all} (invisible) characters
4341 belonging to the ISO timestamp have been removed.
4342 @item
4343 If the custom time stamp format is longer than the default and you are
4344 using dates in tables, table alignment will be messed up.  If the custom
4345 format is shorter, things do work as expected.
4346 @end itemize
4349 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
4350 @section Deadlines and scheduling
4352 A time stamp may be preceded by special keywords to facilitate planning:
4354 @table @var
4355 @item DEADLINE
4356 @cindex DEADLINE keyword
4358 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
4359 to be finished on that date.
4361 On the deadline date, the task will be listed in the agenda.  In
4362 addition, the agenda for @emph{today} will carry a warning about the
4363 approaching or missed deadline, starting
4364 @code{org-deadline-warning-days} before the due date, and continuing
4365 until the entry is marked DONE.  An example:
4367 @example
4368 *** TODO write article about the Earth for the Guide
4369     The editor in charge is [[bbdb:Ford Prefect]]
4370     DEADLINE: <2004-02-29 Sun>
4371 @end example
4373 You can specify a different lead time for warnings for a specific
4374 deadlines using the following syntax.  Here is an example with a warning
4375 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
4377 @item SCHEDULED
4378 @cindex SCHEDULED keyword
4380 Meaning: you are planning to start working on that task on the given
4381 date.
4383 The headline will be listed under the given date@footnote{It will still
4384 be listed on that date after it has been marked DONE.  If you don't like
4385 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
4386 addition, a reminder that the scheduled date has passed will be present
4387 in the compilation for @emph{today}, until the entry is marked DONE.
4388 I.e., the task will automatically be forwarded until completed.
4390 @example
4391 *** TODO Call Trillian for a date on New Years Eve.
4392     SCHEDULED: <2004-12-25 Sat>
4393 @end example
4395 @noindent
4396 @b{Important:} Scheduling an item in Org mode should @i{not} be
4397 understood in the same way that we understand @i{scheduling a meeting}.
4398 Setting a date for a meeting is just a simple appointment, you should
4399 mark this entry with a simple plain time stamp, to get this item shown
4400 on the date where it applies.  This is a frequent mis-understanding from
4401 Org-users.  In Org mode, @i{scheduling} means setting a date when you
4402 want to start working on an action item.
4403 @end table
4405 You may use time stamps with repeaters in scheduling and deadline
4406 entries.  Org mode will issue early and late warnings based on the
4407 assumption that the time stamp represents the @i{nearest instance} of
4408 the repeater.  However, the use of diary sexp entries like
4410 @code{<%%(diary-float t 42)>}
4412 in scheduling and deadline timestamps is limited.  Org mode does not
4413 know enough about the internals of each sexp function to issue early and
4414 late warnings.  However, it will show the item on each day where the
4415 sexp entry matches.
4417 @menu
4418 * Inserting deadline/schedule::  Planning items
4419 * Repeated tasks::              Items that show up again and again
4420 @end menu
4422 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
4423 @subsection Inserting deadlines or schedules
4425 The following commands allow to quickly insert a deadline or to schedule
4426 an item:
4428 @table @kbd
4430 @kindex C-c C-d
4431 @item C-c C-d
4432 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
4433 happen in the line directly following the headline.  When called with a
4434 prefix arg, an existing deadline will be removed from the entry.
4435 @c FIXME Any CLOSED timestamp will be removed.????????
4437 @kindex C-c / d
4438 @cindex sparse tree, for deadlines
4439 @item C-c / d
4440 Create a sparse tree with all deadlines that are either past-due, or
4441 which will become due within @code{org-deadline-warning-days}.
4442 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
4443 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
4444 all deadlines due tomorrow.
4446 @kindex C-c C-s
4447 @item C-c C-s
4448 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
4449 happen in the line directly following the headline.  Any CLOSED
4450 timestamp will be removed.  When called with a prefix argument, remove
4451 the scheduling date from the entry.
4452 @end table
4454 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
4455 @subsection Repeated tasks
4457 Some tasks need to be repeated again and again.  Org mode helps to
4458 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
4459 or plain time stamp.  In the following example
4460 @example
4461 ** TODO Pay the rent
4462    DEADLINE: <2005-10-01 Sat +1m>
4463 @end example
4464 the @code{+1m} is a repeater; the intended interpretation is that the
4465 task has a deadline on <2005-10-01> and repeats itself every (one) month
4466 starting from that time.  If you need both a repeater and a special
4467 warning period in a deadline entry, the repeater comes first and the
4468 warning period last: @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
4470 Deadlines and scheduled items produce entries in the agenda when they
4471 are over-due, so it is important to be able to mark such an entry as
4472 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
4473 with the TODO keyword DONE, it will no longer produce entries in the
4474 agenda.  The problem with this is, however, that then also the
4475 @emph{next} instance of the repeated entry will not be active.  Org mode
4476 deals with this in the following way: When you try to mark such an entry
4477 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
4478 time stamp by the repeater interval, and immediately set the entry state
4479 back to TODO.  In the example above, setting the state to DONE would
4480 actually switch the date like this:
4482 @example
4483 ** TODO Pay the rent
4484    DEADLINE: <2005-11-01 Tue +1m>
4485 @end example
4487 A timestamp@footnote{You can change this using the option
4488 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
4489 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
4490 will aslo be prompted for a note.} will be added under the deadline, to keep
4491 a record that you actually acted on the previous instance of this deadline.
4493 As a consequence of shifting the base date, this entry will no longer be
4494 visible in the agenda when checking past dates, but all future instances
4495 will be visible.
4497 With the @samp{+1m} cookie, the date shift will always be exactly one
4498 month.  So if you have not payed the rent for three months, marking this
4499 entry DONE will still keep it as an overdue deadline.  Depending on the
4500 task, this may not be the best way to handle it.  For example, if you
4501 forgot to call you father for 3 weeks, it does not make sense to call
4502 him 3 times in a single day to make up for it.  Finally, there are tasks
4503 like changing batteries which should always repeat a certain time
4504 @i{after} the last time you did it.  For these tasks, Org mode has
4505 special repeaters markers with @samp{++} and @samp{.+}.  For example:
4507 @example
4508 ** TODO Call Father
4509    DEADLINE: <2008-02-10 Sun ++1w>
4510    Marking this DONE will shift the date by at least one week,
4511    but also by as many weeks as it takes to get this date into
4512    the future.  However, it stays on a Sunday, even if you called
4513    and marked it done on Saturday.
4514 ** TODO Check the batteries in the smoke detectors
4515    DEADLINE: <2005-11-01 Tue .+1m>
4516    Marking this DONE will shift the date to one month after
4517    today.
4518 @end example
4520 You may have both scheduling and deadline information for a specific
4521 task - just make sure that the repeater intervals on both are the same.
4523 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
4524 @section Clocking work time
4526 Org mode allows you to clock the time you spent on specific tasks in a
4527 project.  When you start working on an item, you can start the clock.
4528 When you stop working on that task, or when you mark the task done, the
4529 clock is stopped and the corresponding time interval is recorded.  It
4530 also computes the total time spent on each subtree of a project.
4532 @table @kbd
4533 @kindex C-c C-x C-i
4534 @item C-c C-x C-i
4535 Start the clock on the current item (clock-in).  This inserts the CLOCK
4536 keyword together with a timestamp.  If this is not the first clocking of
4537 this item, the multiple CLOCK lines will be wrapped into a
4538 @code{:CLOCK:} drawer (see also the variable
4539 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
4540 select the task from a list of recently clocked tasks.  With two @kbd{C-u
4541 C-u} prefixes, clock into the task at point and mark it as the default task.
4542 The default task will always be available when selecting a clocking task,
4543 with letter @kbd{d}.
4544 @kindex C-c C-x C-o
4545 @item C-c C-x C-o
4546 Stop the clock (clock-out).  The inserts another timestamp at the same
4547 location where the clock was last started.  It also directly computes
4548 the resulting time in inserts it after the time range as @samp{=>
4549 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
4550 possibility to record an additional note together with the clock-out
4551 time stamp@footnote{The corresponding in-buffer setting is:
4552 @code{#+STARTUP: lognoteclock-out}}.
4553 @kindex C-c C-y
4554 @item C-c C-y
4555 Recompute the time interval after changing one of the time stamps.  This
4556 is only necessary if you edit the time stamps directly.  If you change
4557 them with @kbd{S-@key{cursor}} keys, the update is automatic.
4558 @kindex C-c C-t
4559 @item C-c C-t
4560 Changing the TODO state of an item to DONE automatically stops the clock
4561 if it is running in this same item.
4562 @kindex C-c C-x C-x
4563 @item C-c C-x C-x
4564 Cancel the current clock.  This is useful if a clock was started by
4565 mistake, or if you ended up working on something else.
4566 @kindex C-c C-x C-j
4567 @item C-c C-x C-j
4568 Jump to the entry that contains the currently running clock.  With a
4569 @kbd{C-u} prefix arg, select the target task from a list of recently clocked
4570 tasks.
4571 @kindex C-c C-x C-d
4572 @item C-c C-x C-d
4573 Display time summaries for each subtree in the current buffer.  This
4574 puts overlays at the end of each headline, showing the total time
4575 recorded under that heading, including the time of any subheadings. You
4576 can use visibility cycling to study the tree, but the overlays disappear
4577 when you change the buffer (see variable
4578 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
4579 @kindex C-c C-x C-r
4580 @item C-c C-x C-r
4581 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
4582 report as an Org mode table into the current file.  When the cursor is
4583 at an existing clock table, just update it.  When called with a prefix
4584 argument, jump to the first clock report in the current document and
4585 update it.
4586 @cindex #+BEGIN: clocktable
4587 @example
4588 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
4589 #+END: clocktable
4590 @end example
4591 @noindent
4592 If such a block already exists at point, its content is replaced by the
4593 new table.  The @samp{BEGIN} line can specify options:
4594 @example
4595 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
4596 :emphasize   @r{When @code{t}, emphasize level one and level two items}
4597 :scope       @r{The scope to consider.  This can be any of the following:}
4598              nil        @r{the current buffer or narrowed region}
4599              file       @r{the full current buffer}
4600              subtree    @r{the subtree where the clocktable is located}
4601              treeN      @r{the surrounding level N tree, for example @code{tree3}}
4602              tree       @r{the surrounding level 1 tree}
4603              agenda     @r{all agenda files}
4604              ("file"..) @r{scan these files}
4605              file-with-archives    @r{current file and its archives}
4606              agenda-with-archives  @r{all agenda files, including archives}
4607 :block       @r{The time block to consider.  This block is specified either}
4608              @r{absolute, or relative to the current time and may be any of}
4609              @r{these formats:}
4610              2007-12-31    @r{New year eve 2007}
4611              2007-12       @r{December 2007}
4612              2007-W50      @r{ISO-week 50 in 2007}
4613              2007          @r{the year 2007}
4614              today, yesterday, today-N          @r{a relative day}
4615              thisweek, lastweek, thisweek-N     @r{a relative week}
4616              thismonth, lastmonth, thismonth-N  @r{a relative month}
4617              thisyear, lastyear, thisyear-N     @r{a relative year}
4618              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
4619 :tstart      @r{A time string specifying when to start considering times}
4620 :tend        @r{A time string specifying when to stop considering times}
4621 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
4622              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
4623 :link        @r{Link the item headlines in the table to their origins}
4624 @end example
4625 So to get a clock summary of the current level 1 tree, for the current
4626 day, you could write
4627 @example
4628 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
4629 #+END: clocktable
4630 @end example
4631 and to use a specific time range you could write@footnote{Note that all
4632 parameters must be specified in a single line - the line is broken here
4633 only to fit it onto the manual.}
4634 @example
4635 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
4636                     :tend "<2006-08-10 Thu 12:00>"
4637 #+END: clocktable
4638 @end example
4639 @kindex C-c C-c
4640 @item C-c C-c
4641 @kindex C-c C-x C-u
4642 @itemx C-c C-x C-u
4643 Update dynamical block at point.  The cursor needs to be in the
4644 @code{#+BEGIN} line of the dynamic block.
4645 @kindex C-u C-c C-x C-u
4646 @item C-u C-c C-x C-u
4647 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4648 you have several clock table blocks in a buffer.
4649 @kindex S-@key{left}
4650 @kindex S-@key{right}
4651 @item S-@key{left}
4652 @itemx S-@key{right}
4653 Shift the current @code{:block} interval and update the table.  The cursor
4654 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
4655 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
4656 @end table
4658 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
4659 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
4660 worked on or closed during a day.
4662 @node Effort estimates,  , Clocking work time, Dates and Times
4663 @section Effort estimates
4664 @cindex Effort estimates
4666 If you want to plan your work in a very detailed way, or if you need to
4667 produce offers with quotations of the estimated work effort, you may want to
4668 assign effort estimates to entries.  If you are also clocking your work, you
4669 may later want to compare the planned effort with the actual working time, a
4670 great way to improve planning estimates.  Effort estimates are stored in a
4671 special property @samp{Effort}@footnote{You may change the property being
4672 used with the variable @code{org-effort-property}.}.  Clearly the best way to
4673 work with effort estimates is through column view (@pxref{Column view}).  You
4674 should start by setting up discrete values for effort estimates, and a
4675 @code{COLUMNS} format that displays these values together with clock sums (if
4676 you want to clock your time).  For a specific buffer you can use
4678 @example
4679 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
4680 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
4681 @end example
4683 @noindent
4684 or you can set up these values globally by customizing the variables
4685 @code{org-global-properties} and @code{org-columns-default-format}.  In
4686 particular if you want to use this setup also in the agenda, a global setup
4687 may be advised.
4689 The way to assign estimates to individual items is then to switch to column
4690 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
4691 value.  The values you enter will immediately be summed up in the hierarchy.
4692 In the column next to it, any clocked time will be displayed.
4694 If you switch to column view in the daily/weekly agenda, the effort column
4695 will summarize the estimated work effort for each day@footnote{Please note
4696 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
4697 column view}.}, and you can use this to find space in your schedule.  To get
4698 an overview of the entire part of the day that is committed, you can set the
4699 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
4700 appointments on a day that take place over a specified time interval will
4701 then also be added to the load estimate of the day.
4703 @node Remember, Agenda Views, Dates and Times, Top
4704 @chapter Remember
4705 @cindex @file{remember.el}
4707 The @i{Remember} package by John Wiegley lets you store quick notes with
4708 little interruption of your work flow.  See
4709 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
4710 information.  It is an excellent way to add new notes and tasks to
4711 Org files.  Org significantly expands the possibilities of
4712 @i{remember}: You may define templates for different note types, and
4713 associate target files and headlines with specific templates.  It also
4714 allows you to select the location where a note should be stored
4715 interactively, on the fly.
4717 @menu
4718 * Setting up Remember::         Some code for .emacs to get things going
4719 * Remember templates::          Define the outline of different note types
4720 * Storing notes::               Directly get the note to where it belongs
4721 * Refiling notes::              Moving a note or task to a project
4722 @end menu
4724 @node Setting up Remember, Remember templates, Remember, Remember
4725 @section Setting up Remember
4727 The following customization will tell @i{remember} to use org files as
4728 target, and to create annotations compatible with Org links.
4730 @example
4731 (org-remember-insinuate)
4732 (setq org-directory "~/path/to/my/orgfiles/")
4733 (setq org-default-notes-file (concat org-directory "/notes.org"))
4734 (define-key global-map "\C-cr" 'org-remember)
4735 @end example
4737 The last line binds the command @code{org-remember} to a global
4738 key@footnote{Please select your own key, @kbd{C-c r} is only a
4739 suggestion.}.  @code{org-remember} basically just calls @code{remember},
4740 but it makes a few things easier: If there is an active region, it will
4741 automatically copy the region into the remember buffer.  It also allows
4742 to jump to the buffer and location where remember notes are being
4743 stored: Just call @code{org-remember} with a prefix argument.  If you
4744 use two prefix arguments, Org jumps to the location where the last
4745 remember note was stored.
4747 @node Remember templates, Storing notes, Setting up Remember, Remember
4748 @section Remember templates
4749 @cindex templates, for remember
4751 In combination with Org, you can use templates to generate
4752 different types of @i{remember} notes.  For example, if you would like
4753 to use one template to create general TODO entries, another one for
4754 journal entries, and a third one for collecting random ideas, you could
4755 use:
4757 @example
4758 (setq org-remember-templates
4759  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
4760    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
4761    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4762 @end example
4764 @noindent In these entries, the first string is just a name, and the
4765 character specifies how to select the template.  It is useful if the
4766 character is also the first letter of the name.  The next string
4767 specifies the template.  Two more (optional) strings give the file in
4768 which, and the headline under which the new note should be stored.  The
4769 file (if not present or @code{nil}) defaults to
4770 @code{org-default-notes-file}, the heading to
4771 @code{org-remember-default-headline}.  If the file name is not an
4772 absolute path, it will be interpreted relative to @code{org-directory}.
4774 An optional sixth element specifies the contexts in which the user can
4775 select the template.  This element can be either a list of major modes
4776 or a function.  @code{org-remember} will first check whether the function
4777 returns @code{t} or if we are in any of the listed major mode, and select
4778 the template accordingly.
4780 So for example:
4782 @example
4783 (setq org-remember-templates
4784  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
4785    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" my-check)
4786    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4787 @end example
4789 The first template will only be available when invoking @code{org-remember}
4790 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
4791 available when the function @code{my-check} returns @code{t}.  The third
4792 template will be proposed in any context.
4794 When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
4795 something, Org will prompt for a key to select the template (if you have
4796 more than one template) and then prepare the buffer like
4797 @example
4798 * TODO
4799   [[file:link to where you called remember]]
4800 @end example
4802 @noindent
4803 During expansion of the template, special @kbd{%}-escapes allow dynamic
4804 insertion of content:
4805 @example
4806 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
4807             @r{You may specify a default value and a completion table with}
4808             @r{%^@{prompt|default|completion2|completion3...@}}
4809             @r{The arrow keys access a prompt-specific history.}
4810 %t          @r{time stamp, date only}
4811 %T          @r{time stamp with date and time}
4812 %u, %U      @r{like the above, but inactive time stamps}
4813 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
4814             @r{You may define a prompt like @code{%^@{Birthday@}t}}
4815 %n          @r{user name (taken from @code{user-full-name})}
4816 %a          @r{annotation, normally the link created with @code{org-store-link}}
4817 %A          @r{like @code{%a}, but prompt for the description part}
4818 %i          @r{initial content, the region when remember is called with C-u.}
4819             @r{The entire text will be indented like @code{%i} itself.}
4820 %c          @r{Current kill ring head.}
4821 %x          @r{Content of the X clipboard.}
4822 %^C         @r{Interactive selection of which kill or clip to use.}
4823 %^L         @r{Like @code{%^C}, but insert as link.}
4824 %^g         @r{prompt for tags, with completion on tags in target file.}
4825 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
4826 %:keyword   @r{specific information for certain link types, see below}
4827 %[pathname] @r{insert the contents of the file given by @code{pathname}}
4828 %(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
4829 %!          @r{immediately store note after completing the template}
4830             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
4831 @end example
4833 @noindent
4834 For specific link types, the following keywords will be
4835 defined@footnote{If you define your own link types (@pxref{Adding
4836 hyperlink types}), any property you store with
4837 @code{org-store-link-props} can be accessed in remember templates in a
4838 similar way.}:
4840 @example
4841 Link type          |  Available keywords
4842 -------------------+----------------------------------------------
4843 bbdb               |  %:name %:company
4844 bbdb               |  %::server %:port %:nick
4845 vm, wl, mh, rmail  |  %:type %:subject %:message-id
4846                    |  %:from %:fromname %:fromaddress
4847                    |  %:to   %:toname   %:toaddress
4848                    |  %: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}.}}
4849 gnus               |  %:group, @r{for messages also all email fields}
4850 w3, w3m            |  %:url
4851 info               |  %:file %:node
4852 calendar           |  %:date"
4853 @end example
4855 @noindent
4856 To place the cursor after template expansion use:
4858 @example
4859 %?          @r{After completing the template, position cursor here.}
4860 @end example
4862 @noindent
4863 If you change your mind about which template to use, call
4864 @code{org-remember} in the remember buffer.  You may then select a new
4865 template that will be filled with the previous context information.
4867 @node Storing notes, Refiling notes, Remember templates, Remember
4868 @section Storing notes
4870 When you are finished preparing a note with @i{remember}, you have to press
4871 @kbd{C-c C-c} to file the note away.  If you have started the clock in the
4872 remember buffer, you will first be asked if you want to clock out
4873 now@footnote{To avoid this query, configure the variable
4874 @code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
4875 will continue to run after the note is filed away.
4877 The handler will then store the note in the file and under the headline
4878 specified in the template, or it will use the default file and headlines.
4879 The window configuration will be restored, sending you back to the working
4880 context before the call to @code{remember}.  To re-use the location found
4881 during the last call to @code{remember}, exit the remember buffer with
4882 @kbd{C-u C-u C-c C-c}, i.e. specify a double prefix argument to @kbd{C-c
4883 C-c}.
4885 If you want to store the note directly to a different place, use
4886 @kbd{C-u C-c C-c} instead to exit remember@footnote{Configure the
4887 variable @code{org-remember-store-without-prompt} to make this behavior
4888 the default.}.  The handler will then first prompt for a target file -
4889 if you press @key{RET}, the value specified for the template is used.
4890 Then the command offers the headings tree of the selected file, with the
4891 cursor position at the default headline (if you had specified one in the
4892 template).  You can either immediately press @key{RET} to get the note
4893 placed there.  Or you can use the following keys to find a different
4894 location:
4895 @example
4896 @key{TAB}         @r{Cycle visibility.}
4897 @key{down} / @key{up}   @r{Next/previous visible headline.}
4898 n / p        @r{Next/previous visible headline.}
4899 f / b        @r{Next/previous headline same level.}
4900 u            @r{One level up.}
4901 @c 0-9          @r{Digit argument.}
4902 @end example
4903 @noindent
4904 Pressing @key{RET} or @key{left} or @key{right}
4905 then leads to the following result.
4907 @multitable @columnfractions 0.2 0.15 0.65
4908 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
4909 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
4910 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
4911 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
4912 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
4913 @item                 @tab @tab depending on @code{org-reverse-note-order}.
4914 @item not on headline @tab @key{RET}
4915       @tab at cursor position, level taken from context.
4916 @end multitable
4918 Before inserting the text into a tree, the function ensures that the
4919 text has a headline, i.e. a first line that starts with a @samp{*}.  If
4920 not, a headline is constructed from the current date and some additional
4921 data.  If you have indented the text of the note below the headline, the
4922 indentation will be adapted if inserting the note into the tree requires
4923 demotion from level 1.
4925 @node Refiling notes,  , Storing notes, Remember
4926 @section Refiling notes
4927 @cindex refiling notes
4929 Remember is usually used to quickly capture notes and tasks into one or
4930 a few capture lists.  When reviewing the captured data, you may want to
4931 refile some of the entries into a different list, for example into a
4932 project.  Cutting, finding the right location and then pasting the note
4933 is cumbersome.  To simplify this process, you can use the following
4934 special command:
4936 @table @kbd
4937 @kindex C-c C-w
4938 @item C-c C-w
4939 Refile the entry at point.  This command offers possible locations for
4940 refiling the entry and lets you select one with completion.  The item is
4941 filed below the target heading as a subitem.  Depending on
4942 @code{org-reverse-note-order}, it will be either the first of last
4943 subitem.@* By default, all level 1 headlines in the current buffer are
4944 considered to be targets, but you can have more complex definitions
4945 across a number of files.  See the variable @code{org-refile-targets}
4946 for details.
4947 @kindex C-u C-c C-w
4948 @item C-u C-c C-w
4949 Use the refile interface to jump to a heading.
4950 @kindex C-u C-u C-c C-w
4951 @item C-u C-u C-c C-w
4952 Jump to the location where @code{org-refile} last moved a tree to.
4953 @end table
4955 @node Agenda Views, Embedded LaTeX, Remember, Top
4956 @chapter Agenda Views
4957 @cindex agenda views
4959 Due to the way Org works, TODO items, time-stamped items, and
4960 tagged headlines can be scattered throughout a file or even a number of
4961 files.  To get an overview of open action items, or of events that are
4962 important for a particular date, this information must be collected,
4963 sorted and displayed in an organized way.
4965 Org can select items based on various criteria, and display them
4966 in a separate buffer.  Seven different view types are provided:
4968 @itemize @bullet
4969 @item
4970 an @emph{agenda} that is like a calendar and shows information
4971 for specific dates,
4972 @item
4973 a @emph{TODO list} that covers all unfinished
4974 action items,
4975 @item
4976 a @emph{tags view}, showings headlines based on
4977 the tags associated with them,
4978 @item
4979 a @emph{timeline view} that shows all events in a single Org file,
4980 in time-sorted view,
4981 @item
4982 a @emph{keyword search view} that shows all entries from multiple files
4983 that contain specified keywords.
4984 @item
4985 a @emph{stuck projects view} showing projects that currently don't move
4986 along, and
4987 @item
4988 @emph{custom views} that are special tag/keyword searches and
4989 combinations of different views.
4990 @end itemize
4992 @noindent
4993 The extracted information is displayed in a special @emph{agenda
4994 buffer}.  This buffer is read-only, but provides commands to visit the
4995 corresponding locations in the original Org files, and even to
4996 edit these files remotely.
4998 Two variables control how the agenda buffer is displayed and whether the
4999 window configuration is restored when the agenda exits:
5000 @code{org-agenda-window-setup} and
5001 @code{org-agenda-restore-windows-after-quit}.
5003 @menu
5004 * Agenda files::                Files being searched for agenda information
5005 * Agenda dispatcher::           Keyboard access to agenda views
5006 * Built-in agenda views::       What is available out of the box?
5007 * Presentation and sorting::    How agenda items are prepared for display
5008 * Agenda commands::             Remote editing of Org trees
5009 * Custom agenda views::         Defining special searches and views
5010 * Agenda column view::          Using column view for collected entries
5011 @end menu
5013 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
5014 @section Agenda files
5015 @cindex agenda files
5016 @cindex files for agenda
5018 The information to be shown is normally collected from all @emph{agenda
5019 files}, the files listed in the variable
5020 @code{org-agenda-files}@footnote{If the value of that variable is not a
5021 list, but a single file name, then the list of agenda files will be
5022 maintained in that external file.}. If a directory is part of this list,
5023 all files with the extension @file{.org} in this directory will be part
5024 of the list.
5026 Thus even if you only work with a single Org file, this file should
5027 be put into that list@footnote{When using the dispatcher, pressing
5028 @kbd{<} before selecting a command will actually limit the command to
5029 the current file, and ignore @code{org-agenda-files} until the next
5030 dispatcher command.}.  You can customize @code{org-agenda-files}, but
5031 the easiest way to maintain it is through the following commands
5033 @cindex files, adding to agenda list
5034 @table @kbd
5035 @kindex C-c [
5036 @item C-c [
5037 Add current file to the list of agenda files.  The file is added to
5038 the front of the list.  If it was already in the list, it is moved to
5039 the front.  With a prefix argument, file is added/moved to the end.
5040 @kindex C-c ]
5041 @item C-c ]
5042 Remove current file from the list of agenda files.
5043 @kindex C-,
5044 @kindex C-'
5045 @item C-,
5046 @itemx C-'
5047 Cycle through agenda file list, visiting one file after the other.
5048 @kindex M-x org-iswitchb
5049 @item M-x org-iswitchb
5050 Command to use an @code{iswitchb}-like interface to switch to and between Org
5051 buffers.
5052 @end table
5054 @noindent
5055 The Org menu contains the current list of files and can be used
5056 to visit any of them.
5058 If you would like to focus the agenda temporarily onto a file not in
5059 this list, or onto just one file in the list or even only a subtree in a
5060 file, this can be done in different ways.  For a single agenda command,
5061 you may press @kbd{<} once or several times in the dispatcher
5062 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
5063 extended period, use the following commands:
5065 @table @kbd
5066 @kindex C-c C-x <
5067 @item C-c C-x <
5068 Permanently restrict the agenda to the current subtree.  When with a
5069 prefix argument, or with the cursor before the first headline in a file,
5070 the agenda scope is set to the entire file.  This restriction remains in
5071 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
5072 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
5073 agenda view, the new restriction takes effect immediately.
5074 @kindex C-c C-x <
5075 @item C-c C-x <
5076 Remove the permanent restriction created by @kbd{C-c C-x <}.
5077 @end table
5079 @noindent
5080 When working with @file{Speedbar}, you can use the following commands in
5081 the Speedbar frame:
5082 @table @kbd
5083 @kindex <
5084 @item < @r{in the speedbar frame}
5085 Permanently restrict the agenda to the item at the cursor in the
5086 Speedbar frame, either an Org file or a subtree in such a file.
5087 If there is a window displaying an agenda view, the new restriction takes
5088 effect immediately.
5089 @kindex <
5090 @item > @r{in the speedbar frame}
5091 Lift the restriction again.
5092 @end table
5094 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
5095 @section The agenda dispatcher
5096 @cindex agenda dispatcher
5097 @cindex dispatching agenda commands
5098 The views are created through a dispatcher that should be bound to a
5099 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
5100 following we will assume that @kbd{C-c a} is indeed how the dispatcher
5101 is accessed and list keyboard access to commands accordingly.  After
5102 pressing @kbd{C-c a}, an additional letter is required to execute a
5103 command.  The dispatcher offers the following default commands:
5104 @table @kbd
5105 @item a
5106 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
5107 @item t @r{/} T
5108 Create a list of all TODO items (@pxref{Global TODO list}).
5109 @item m @r{/} M
5110 Create a list of headlines matching a TAGS expression (@pxref{Matching
5111 tags and properties}).
5112 @item L
5113 Create the timeline view for the current buffer (@pxref{Timeline}).
5114 @item s
5115 Create a list of entries selected by a boolean expression of keywords
5116 and/or regular expressions that must or must not occur in the entry.
5117 @item /
5118 Search for a regular expression in all agenda files and additionally in
5119 the files listed in @code{org-agenda-multi-occur-extra-files}.  This
5120 uses the Emacs command @code{multi-occur}.  A prefix argument can be
5121 used to specify the number of context lines for each match, default is
5123 @item # @r{/} !
5124 Create a list of stuck projects (@pxref{Stuck projects}).
5125 @item <
5126 Restrict an agenda command to the current buffer@footnote{For backward
5127 compatibility, you can also press @kbd{1} to restrict to the current
5128 buffer.}.  After pressing @kbd{<}, you still need to press the character
5129 selecting the command.
5130 @item < <
5131 If there is an active region, restrict the following agenda command to
5132 the region.  Otherwise, restrict it to the current subtree@footnote{For
5133 backward compatibility, you can also press @kbd{0} to restrict to the
5134 current buffer.}.  After pressing @kbd{< <}, you still need to press the
5135 character selecting the command.
5136 @end table
5138 You can also define custom commands that will be accessible through the
5139 dispatcher, just like the default commands.  This includes the
5140 possibility to create extended agenda buffers that contain several
5141 blocks together, for example the weekly agenda, the global TODO list and
5142 a number of special tags matches.  @xref{Custom agenda views}.
5144 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
5145 @section The built-in agenda views
5147 In this section we describe the built-in views.
5149 @menu
5150 * Weekly/daily agenda::         The calendar page with current tasks
5151 * Global TODO list::            All unfinished action items
5152 * Matching tags and properties::  Structured information with fine-tuned search
5153 * Timeline::                    Time-sorted view for single file
5154 * Keyword search::              Finding entries by keyword
5155 * Stuck projects::              Find projects you need to review
5156 @end menu
5158 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
5159 @subsection The weekly/daily agenda
5160 @cindex agenda
5161 @cindex weekly agenda
5162 @cindex daily agenda
5164 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
5165 paper agenda, showing all the tasks for the current week or day.
5167 @table @kbd
5168 @cindex org-agenda, command
5169 @kindex C-c a a
5170 @item C-c a a
5171 Compile an agenda for the current week from a list of org files.  The
5172 agenda shows the entries for each day.  With a numeric
5173 prefix@footnote{For backward compatibility, the universal prefix
5174 @kbd{C-u} causes all TODO entries to be listed before the agenda.  This
5175 feature is deprecated, use the dedicated TODO list, or a block agenda
5176 instead.}  (like @kbd{C-u 2 1 C-c a a}) you may set the number of days
5177 to be displayed (see also the variable @code{org-agenda-ndays})
5178 @end table
5180 Remote editing from the agenda buffer means, for example, that you can
5181 change the dates of deadlines and appointments from the agenda buffer.
5182 The commands available in the Agenda buffer are listed in @ref{Agenda
5183 commands}.
5185 @subsubheading Calendar/Diary integration
5186 @cindex calendar integration
5187 @cindex diary integration
5189 Emacs contains the calendar and diary by Edward M. Reingold.  The
5190 calendar displays a three-month calendar with holidays from different
5191 countries and cultures.  The diary allows you to keep track of
5192 anniversaries, lunar phases, sunrise/set, recurrent appointments
5193 (weekly, monthly) and more.  In this way, it is quite complementary to
5194 Org.  It can be very useful to combine output from Org with
5195 the diary.
5197 In order to include entries from the Emacs diary into Org mode's
5198 agenda, you only need to customize the variable
5200 @lisp
5201 (setq org-agenda-include-diary t)
5202 @end lisp
5204 @noindent After that, everything will happen automatically.  All diary
5205 entries including holidays, anniversaries etc will be included in the
5206 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
5207 @key{RET} can be used from the agenda buffer to jump to the diary
5208 file in order to edit existing diary entries.  The @kbd{i} command to
5209 insert new entries for the current date works in the agenda buffer, as
5210 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
5211 Sunrise/Sunset times, show lunar phases and to convert to other
5212 calendars, respectively.  @kbd{c} can be used to switch back and forth
5213 between calendar and agenda.
5215 If you are using the diary only for sexp entries and holidays, it is
5216 faster to not use the above setting, but instead to copy or even move
5217 the entries into an Org file. Org mode evaluates diary-style sexp
5218 entries, and does it faster because there is no overhead for first
5219 creating the diary display.  Note that the sexp entries must start at
5220 the left margin, no white space is allowed before them.  For example,
5221 the following segment of an Org file will be processed and entries
5222 will be made in the agenda:
5224 @example
5225 * Birthdays and similar stuff
5226 #+CATEGORY: Holiday
5227 %%(org-calendar-holiday)   ; special function for holiday names
5228 #+CATEGORY: Ann
5229 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
5230 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
5231 @end example
5233 @subsubheading Appointment reminders
5234 @cindex @file{appt.el}
5235 @cindex appointment reminders
5237 Org can interact with Emacs appointments notification facility.
5239 To add all the appointments of your agenda files, use the command
5240 @code{org-agenda-to-appt}.  This commands also lets you filter through
5241 the list of your appointments and add only those belonging to a specific
5242 category or matching a regular expression. See the docstring for
5243 details.
5245 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
5246 @subsection The global TODO list
5247 @cindex global TODO list
5248 @cindex TODO list, global
5250 The global TODO list contains all unfinished TODO items, formatted and
5251 collected into a single place.
5253 @table @kbd
5254 @kindex C-c a t
5255 @item C-c a t
5256 Show the global TODO list.  This collects the TODO items from all
5257 agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
5258 @code{agenda-mode}, so there are commands to examine and manipulate
5259 the TODO entries directly from that buffer (@pxref{Agenda commands}).
5260 @kindex C-c a T
5261 @item C-c a T
5262 @cindex TODO keyword matching
5263 Like the above, but allows selection of a specific TODO keyword.  You
5264 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
5265 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
5266 specify several keywords by separating them with @samp{|} as boolean OR
5267 operator.  With a numeric prefix, the Nth keyword in
5268 @code{org-todo-keywords} is selected.
5269 @kindex r
5270 The @kbd{r} key in the agenda buffer regenerates it, and you can give
5271 a prefix argument to this command to change the selected TODO keyword,
5272 for example @kbd{3 r}.  If you often need a search for a specific
5273 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
5274 Matching specific TODO keywords can also be done as part of a tags
5275 search (@pxref{Tag searches}).
5276 @end table
5278 Remote editing of TODO items means that you can change the state of a
5279 TODO entry with a single key press.  The commands available in the
5280 TODO list are described in @ref{Agenda commands}.
5282 @cindex sublevels, inclusion into TODO list
5283 Normally the global TODO list simply shows all headlines with TODO
5284 keywords.  This list can become very long.  There are two ways to keep
5285 it more compact:
5286 @itemize @minus
5287 @item
5288 Some people view a TODO item that has been @emph{scheduled} for
5289 execution (@pxref{Timestamps}) as no longer @emph{open}.  Configure the
5290 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
5291 items from the global TODO list.
5292 @item
5293 TODO items may have sublevels to break up the task into subtasks.  In
5294 such cases it may be enough to list only the highest level TODO headline
5295 and omit the sublevels from the global list.  Configure the variable
5296 @code{org-agenda-todo-list-sublevels} to get this behavior.
5297 @end itemize
5299 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
5300 @subsection Matching tags and properties
5301 @cindex matching, of tags
5302 @cindex matching, of properties
5303 @cindex tags view
5305 If headlines in the agenda files are marked with @emph{tags}
5306 (@pxref{Tags}), you can select headlines based on the tags that apply
5307 to them and collect them into an agenda buffer.
5309 @table @kbd
5310 @kindex C-c a m
5311 @item C-c a m
5312 Produce a list of all headlines that match a given set of tags.  The
5313 command prompts for a selection criterion, which is a boolean logic
5314 expression with tags, like @samp{+work+urgent-withboss} or
5315 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
5316 define a custom command for it (@pxref{Agenda dispatcher}).
5317 @kindex C-c a M
5318 @item C-c a M
5319 Like @kbd{C-c a m}, but only select headlines that are also TODO items
5320 and force checking subitems (see variable
5321 @code{org-tags-match-list-sublevels}).  Matching specific TODO keywords
5322 together with a tags match is also possible, see @ref{Tag searches}.
5323 @end table
5325 The commands available in the tags list are described in @ref{Agenda
5326 commands}.
5328 @node Timeline, Keyword search, Matching tags and properties, Built-in agenda views
5329 @subsection Timeline for a single file
5330 @cindex timeline, single file
5331 @cindex time-sorted view
5333 The timeline summarizes all time-stamped items from a single Org mode
5334 file in a @emph{time-sorted view}.  The main purpose of this command is
5335 to give an overview over events in a project.
5337 @table @kbd
5338 @kindex C-c a L
5339 @item C-c a L
5340 Show a time-sorted view of the org file, with all time-stamped items.
5341 When called with a @kbd{C-u} prefix, all unfinished TODO entries
5342 (scheduled or not) are also listed under the current date.
5343 @end table
5345 @noindent
5346 The commands available in the timeline buffer are listed in
5347 @ref{Agenda commands}.
5349 @node Keyword search, Stuck projects, Timeline, Built-in agenda views
5350 @subsection Keyword search
5351 @cindex keyword search
5352 @cindex searching, for keywords
5354 This agenda view is a general text search facility for Org mode entries.
5355 It is particularly useful to find notes.
5357 @table @kbd
5358 @kindex C-c a s
5359 @item C-c a s
5360 This is a special search that lets you select entries by keywords or
5361 regular expression, using a boolean logic.  For example, the search
5362 string
5364 @example
5365 +computer +wifi -ethernet -@{8\.11[bg]@}
5366 @end example
5368 @noindent
5369 will search for note entries that contain the keywords @code{computer}
5370 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
5371 not matched by the regular expression @code{8\.11[bg]}, meaning to
5372 exclude both 8.11b and 8.11g.
5374 Note that in addition to the agenda files, this command will also search
5375 the files listed in @code{org-agenda-text-search-extra-files}.
5376 @end table
5378 @node Stuck projects,  , Keyword search, Built-in agenda views
5379 @subsection Stuck projects
5381 If you are following a system like David Allen's GTD to organize your
5382 work, one of the ``duties'' you have is a regular review to make sure
5383 that all projects move along.  A @emph{stuck} project is a project that
5384 has no defined next actions, so it will never show up in the TODO lists
5385 Org mode produces.  During the review, you need to identify such
5386 projects and define next actions for them.
5388 @table @kbd
5389 @kindex C-c a #
5390 @item C-c a #
5391 List projects that are stuck.
5392 @kindex C-c a !
5393 @item C-c a !
5394 Customize the variable @code{org-stuck-projects} to define what a stuck
5395 project is and how to find it.
5396 @end table
5398 You almost certainly will have to configure this view before it will
5399 work for you.  The built-in default assumes that all your projects are
5400 level-2 headlines, and that a project is not stuck if it has at least
5401 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
5403 Lets assume that you, in your own way of using Org mode, identify
5404 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
5405 indicate a project that should not be considered yet.  Lets further
5406 assume that the TODO keyword DONE marks finished projects, and that NEXT
5407 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
5408 is a next action even without the NEXT tag.  Finally, if the project
5409 contains the special word IGNORE anywhere, it should not be listed
5410 either.  In this case you would start by identifying eligible projects
5411 with a tags/todo match @samp{+PROJECT/-MAYBE-DONE}, and then check for
5412 TODO, NEXT, @@SHOP, and IGNORE in the subtree to identify projects that
5413 are not stuck.  The correct customization for this is
5415 @lisp
5416 (setq org-stuck-projects
5417       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
5418                                "\\<IGNORE\\>"))
5419 @end lisp
5422 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
5423 @section Presentation and sorting
5424 @cindex presentation, of agenda items
5426 Before displaying items in an agenda view, Org mode visually prepares
5427 the items and sorts them.  Each item occupies a single line.  The line
5428 starts with a @emph{prefix} that contains the @emph{category}
5429 (@pxref{Categories}) of the item and other important information.  You can
5430 customize the prefix using the option @code{org-agenda-prefix-format}.
5431 The prefix is followed by a cleaned-up version of the outline headline
5432 associated with the item.
5434 @menu
5435 * Categories::                  Not all tasks are equal
5436 * Time-of-day specifications::  How the agenda knows the time
5437 * Sorting of agenda items::     The order of things
5438 @end menu
5440 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
5441 @subsection Categories
5443 @cindex category
5444 The category is a broad label assigned to each agenda item.  By default,
5445 the category is simply derived from the file name, but you can also
5446 specify it with a special line in the buffer, like this@footnote{For
5447 backward compatibility, the following also works: If there are several
5448 such lines in a file, each specifies the category for the text below it.
5449 The first category also applies to any text before the first CATEGORY
5450 line.  However, using this method is @emph{strongly} deprecated as it is
5451 incompatible with the outline structure of the document.  The correct
5452 method for setting multiple categories in a buffer is using a
5453 property.}:
5455 @example
5456 #+CATEGORY: Thesis
5457 @end example
5459 @noindent
5460 If you would like to have a special CATEGORY for a single entry or a
5461 (sub)tree, give the entry a @code{:CATEGORY:} property with the location
5462 as the value (@pxref{Properties and Columns}).
5464 @noindent
5465 The display in the agenda buffer looks best if the category is not
5466 longer than 10 characters.
5468 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
5469 @subsection Time-of-day specifications
5470 @cindex time-of-day specification
5472 Org mode checks each agenda item for a time-of-day specification.  The
5473 time can be part of the time stamp that triggered inclusion into the
5474 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
5475 ranges can be specified with two time stamps, like
5477 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
5479 In the headline of the entry itself, a time(range) may also appear as
5480 plain text (like @samp{12:45} or a @samp{8:30-1pm}.  If the agenda
5481 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
5482 specifications in diary entries are recognized as well.
5484 For agenda display, Org mode extracts the time and displays it in a
5485 standard 24 hour format as part of the prefix.  The example times in
5486 the previous paragraphs would end up in the agenda like this:
5488 @example
5489     8:30-13:00 Arthur Dent lies in front of the bulldozer
5490    12:45...... Ford Prefect arrives and takes Arthur to the pub
5491    19:00...... The Vogon reads his poem
5492    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5493 @end example
5495 @cindex time grid
5496 If the agenda is in single-day mode, or for the display of today, the
5497 timed entries are embedded in a time grid, like
5499 @example
5500     8:00...... ------------------
5501     8:30-13:00 Arthur Dent lies in front of the bulldozer
5502    10:00...... ------------------
5503    12:00...... ------------------
5504    12:45...... Ford Prefect arrives and takes Arthur to the pub
5505    14:00...... ------------------
5506    16:00...... ------------------
5507    18:00...... ------------------
5508    19:00...... The Vogon reads his poem
5509    20:00...... ------------------
5510    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5511 @end example
5513 The time grid can be turned on and off with the variable
5514 @code{org-agenda-use-time-grid}, and can be configured with
5515 @code{org-agenda-time-grid}.
5517 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
5518 @subsection Sorting of agenda items
5519 @cindex sorting, of agenda items
5520 @cindex priorities, of agenda items
5521 Before being inserted into a view, the items are sorted.  How this is
5522 done depends on the type of view.
5523 @itemize @bullet
5524 @item
5525 For the daily/weekly agenda, the items for each day are sorted.  The
5526 default order is to first collect all items containing an explicit
5527 time-of-day specification.  These entries will be shown at the beginning
5528 of the list, as a @emph{schedule} for the day.  After that, items remain
5529 grouped in categories, in the sequence given by @code{org-agenda-files}.
5530 Within each category, items are sorted by priority (@pxref{Priorities}),
5531 which is composed of the base priority (2000 for priority @samp{A}, 1000
5532 for @samp{B}, and 0 for @samp{C}), plus additional increments for
5533 overdue scheduled or deadline items.
5534 @item
5535 For the TODO list, items remain in the order of categories, but within
5536 each category, sorting takes place according to priority
5537 (@pxref{Priorities}).
5538 @item
5539 For tags matches, items are not sorted at all, but just appear in the
5540 sequence in which they are found in the agenda files.
5541 @end itemize
5543 Sorting can be customized using the variable
5544 @code{org-agenda-sorting-strategy}, and may also include criteria based on
5545 the estimated effort of an entry.
5546 @c FIXME: link!!!!!!!!
5549 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
5550 @section Commands in the agenda buffer
5551 @cindex commands, in agenda buffer
5553 Entries in the agenda buffer are linked back to the org file or diary
5554 file where they originate.  You are not allowed to edit the agenda
5555 buffer itself, but commands are provided to show and jump to the
5556 original entry location, and to edit the org-files ``remotely'' from
5557 the agenda buffer.  In this way, all information is stored only once,
5558 removing the risk that your agenda and note files may diverge.
5560 Some commands can be executed with mouse clicks on agenda lines.  For
5561 the other commands, the cursor needs to be in the desired line.
5563 @table @kbd
5564 @tsubheading{Motion}
5565 @cindex motion commands in agenda
5566 @kindex n
5567 @item n
5568 Next line (same as @key{up} and @kbd{C-p}).
5569 @kindex p
5570 @item p
5571 Previous line (same as @key{down} and @kbd{C-n}).
5572 @tsubheading{View/Go to org file}
5573 @kindex mouse-3
5574 @kindex @key{SPC}
5575 @item mouse-3
5576 @itemx @key{SPC}
5577 Display the original location of the item in another window.
5579 @kindex L
5580 @item L
5581 Display original location and recenter that window.
5583 @kindex mouse-2
5584 @kindex mouse-1
5585 @kindex @key{TAB}
5586 @item mouse-2
5587 @itemx mouse-1
5588 @itemx @key{TAB}
5589 Go to the original location of the item in another window.  Under Emacs
5590 22, @kbd{mouse-1} will also works for this.
5592 @kindex @key{RET}
5593 @itemx @key{RET}
5594 Go to the original location of the item and delete other windows.
5596 @kindex f
5597 @item f
5598 Toggle Follow mode.  In Follow mode, as you move the cursor through
5599 the agenda buffer, the other window always shows the corresponding
5600 location in the org file.  The initial setting for this mode in new
5601 agenda buffers can be set with the variable
5602 @code{org-agenda-start-with-follow-mode}.
5604 @kindex b
5605 @item b
5606 Display the entire subtree of the current item in an indirect buffer.  With a
5607 numeric prefix argument N, go up to level N and then take that tree.  If N is
5608 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
5609 previously used indirect buffer.
5611 @kindex l
5612 @item l
5613 Toggle Logbook mode.  In Logbook mode, entries that where marked DONE while
5614 logging was on (variable @code{org-log-done}) are shown in the agenda,
5615 as are entries that have been clocked on that day.
5617 @kindex R
5618 @item R
5619 Toggle Clockreport mode.  In clockreport mode, the daily/weekly agenda will
5620 always show a table with the clocked times for the timespan and file scope
5621 covered by the current agenda view.  The initial setting for this mode in new
5622 agenda buffers can be set with the variable
5623 @code{org-agenda-start-with-clockreport-mode}.
5625 @tsubheading{Change display}
5626 @cindex display changing, in agenda
5627 @kindex o
5628 @item o
5629 Delete other windows.
5631 @kindex d
5632 @kindex w
5633 @kindex m
5634 @kindex y
5635 @item d w m y
5636 Switch to day/week/month/year view.  When switching to day or week view,
5637 this setting becomes the default for subsequent agenda commands.  Since
5638 month and year views are slow to create, they do not become the default.
5639 A numeric prefix argument may be used to jump directly to a specific day
5640 of the year, ISO week, month, or year, respectively.  For example,
5641 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
5642 setting day, week, or month view, a year may be encoded in the prefix
5643 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
5644 2007.  If such a year specification has only one or two digits, it will
5645 be mapped to the interval 1938-2037.
5647 @kindex D
5648 @item D
5649 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
5651 @kindex G
5652 @item G
5653 Toggle the time grid on and off.  See also the variables
5654 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
5656 @kindex r
5657 @item r
5658 Recreate the agenda buffer, for example to reflect the changes
5659 after modification of the time stamps of items with S-@key{left} and
5660 S-@key{right}.  When the buffer is the global TODO list, a prefix
5661 argument is interpreted to create a selective list for a specific TODO
5662 keyword.
5663 @kindex g
5664 @item g
5665 Same as @kbd{r}.
5667 @kindex s
5668 @kindex C-x C-s
5669 @item s
5670 @itemx C-x C-s
5671 Save all Org buffers in the current Emacs session.
5673 @kindex @key{right}
5674 @item @key{right}
5675 Display the following @code{org-agenda-ndays} days.  For example, if
5676 the display covers a week, switch to the following week.  With prefix
5677 arg, go forward that many times @code{org-agenda-ndays} days.
5679 @kindex @key{left}
5680 @item @key{left}
5681 Display the previous dates.
5683 @kindex .
5684 @item .
5685 Go to today.
5687 @kindex C-c C-x C-c
5688 @item C-c C-x C-c
5689 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
5690 view format is taken from the entry at point, or (if there is no entry at
5691 point), from the first entry in the agenda view.  So whatever the format for
5692 that entry would be in the original buffer (taken from a property, from a
5693 @code{#+COLUMNS} line, or from the default variable
5694 @code{org-columns-default-format}), will be used in the agenda.
5696 @tsubheading{Query editing}
5697 @cindex query editing, in agenda
5699 @kindex [
5700 @kindex ]
5701 @kindex @{
5702 @kindex @}
5703 @item [ ] @{ @}
5704 In the @i{search view} (@pxref{Keyword search}), these keys add new
5705 search words (@kbd{[} and @kbd{]}) or new regular expressions (@kbd{@{}
5706 and @kbd{@}}) to the query string.  The opening bracket/brace will add a
5707 positive search term prefixed by @samp{+}, indicating that this search
5708 term @i{must} occur/match in the entry.  Closing bracket/brace add a
5709 negative search term which @i{must not} occur/match in the entry for it
5710 to be selected.
5713 @tsubheading{Remote editing}
5714 @cindex remote editing, from agenda
5716 @item 0-9
5717 Digit argument.
5719 @cindex undoing remote-editing events
5720 @cindex remote editing, undo
5721 @kindex C-_
5722 @item C-_
5723 Undo a change due to a remote editing command.  The change is undone
5724 both in the agenda buffer and in the remote buffer.
5726 @kindex t
5727 @item t
5728 Change the TODO state of the item, both in the agenda and in the
5729 original org file.
5731 @kindex C-k
5732 @item C-k
5733 Delete the current agenda item along with the entire subtree belonging
5734 to it in the original Org file.  If the text to be deleted remotely
5735 is longer than one line, the kill needs to be confirmed by the user.  See
5736 variable @code{org-agenda-confirm-kill}.
5738 @kindex a
5739 @item a
5740 Toggle the ARCHIVE tag for the current headline.
5742 @kindex A
5743 @item A
5744 Move the subtree corresponding to the current entry to its @emph{Archive
5745 Sibling}.
5747 @kindex $
5748 @item $
5749 Archive the subtree corresponding to the current headline.  This means the
5750 entry will be moved to the configured archive location, most likely a
5751 different file.
5753 @kindex T
5754 @item T
5755 Show all tags associated with the current item.  Because of
5756 inheritance, this may be more than the tags listed in the line itself.
5758 @kindex :
5759 @item :
5760 Set tags for the current headline.  If there is an active region in the
5761 agenda, change a tag for all headings in the region.
5763 @kindex ,
5764 @item ,
5765 Set the priority for the current item.  Org mode prompts for the
5766 priority character. If you reply with @key{SPC}, the priority cookie
5767 is removed from the entry.
5769 @kindex P
5770 @item P
5771 Display weighted priority of current item.
5773 @kindex +
5774 @kindex S-@key{up}
5775 @item +
5776 @itemx S-@key{up}
5777 Increase the priority of the current item.  The priority is changed in
5778 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
5779 key for this.
5781 @kindex -
5782 @kindex S-@key{down}
5783 @item -
5784 @itemx S-@key{down}
5785 Decrease the priority of the current item.
5787 @kindex C-c C-s
5788 @item C-c C-s
5789 Schedule this item
5791 @kindex C-c C-d
5792 @item C-c C-d
5793 Set a deadline for this item.
5795 @kindex S-@key{right}
5796 @item S-@key{right}
5797 Change the time stamp associated with the current line by one day into the
5798 future.  With a numeric prefix argument, change it by that many days.  For
5799 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The stamp is
5800 changed in the original org file, but the change is not directly reflected in
5801 the agenda buffer.  Use the @kbd{r} key to update the buffer.
5803 @kindex S-@key{left}
5804 @item S-@key{left}
5805 Change the time stamp associated with the current line by one day
5806 into the past.
5808 @kindex >
5809 @item >
5810 Change the time stamp associated with the current line to today.
5811 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
5812 on my keyboard.
5814 @kindex I
5815 @item I
5816 Start the clock on the current item.  If a clock is running already, it
5817 is stopped first.
5819 @kindex O
5820 @item O
5821 Stop the previously started clock.
5823 @kindex X
5824 @item X
5825 Cancel the currently running clock.
5827 @kindex J
5828 @item J
5829 Jump to the running clock in another window.
5831 @tsubheading{Calendar commands}
5832 @cindex calendar commands, from agenda
5833 @kindex c
5834 @item c
5835 Open the Emacs calendar and move to the date at the agenda cursor.
5837 @item c
5838 When in the calendar, compute and show the Org mode agenda for the
5839 date at the cursor.
5841 @cindex diary entries, creating from agenda
5842 @kindex i
5843 @item i
5844 Insert a new entry into the diary.  Prompts for the type of entry
5845 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
5846 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
5847 The date is taken from the cursor position.
5849 @kindex M
5850 @item M
5851 Show the phases of the moon for the three months around current date.
5853 @kindex S
5854 @item S
5855 Show sunrise and sunset times.  The geographical location must be set
5856 with calendar variables, see documentation of the Emacs calendar.
5858 @kindex C
5859 @item C
5860 Convert the date at cursor into many other cultural and historic
5861 calendars.
5863 @kindex H
5864 @item H
5865 Show holidays for three month around the cursor date.
5867 @item M-x org-export-icalendar-combine-agenda-files
5868 Export a single iCalendar file containing entries from all agenda files.
5869 This is a globally available command, and also available in the agenda menu.
5871 @tsubheading{Exporting to a file}
5872 @kindex C-x C-w
5873 @item C-x C-w
5874 @cindex exporting agenda views
5875 @cindex agenda views, exporting
5876 Write the agenda view to a file.  Depending on the extension of the
5877 selected file name, the view will be exported as HTML (extension
5878 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
5879 plain text (any other extension).  Use the variable
5880 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
5881 and for @file{htmlize} to be used during export.
5883 @tsubheading{Quit and Exit}
5884 @kindex q
5885 @item q
5886 Quit agenda, remove the agenda buffer.
5888 @kindex x
5889 @cindex agenda files, removing buffers
5890 @item x
5891 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
5892 for the compilation of the agenda.  Buffers created by the user to
5893 visit org files will not be removed.
5894 @end table
5897 @node Custom agenda views, Agenda column view, Agenda commands, Agenda Views
5898 @section Custom agenda views
5899 @cindex custom agenda views
5900 @cindex agenda views, custom
5902 Custom agenda commands serve two purposes: to store and quickly access
5903 frequently used TODO and tags searches, and to create special composite
5904 agenda buffers.  Custom agenda commands will be accessible through the
5905 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
5907 @menu
5908 * Storing searches::            Type once, use often
5909 * Block agenda::                All the stuff you need in a single buffer
5910 * Setting Options::             Changing the rules
5911 * Exporting Agenda Views::      Writing agendas to files
5912 * Using the agenda elsewhere::  Using agenda information in other programs
5913 @end menu
5915 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
5916 @subsection Storing searches
5918 The first application of custom searches is the definition of keyboard
5919 shortcuts for frequently used searches, either creating an agenda
5920 buffer, or a sparse tree (the latter covering of course only the current
5921 buffer).
5922 @kindex C-c a C
5923 Custom commands are configured in the variable
5924 @code{org-agenda-custom-commands}.  You can customize this variable, for
5925 example by pressing @kbd{C-c a C}.  You can also directly set it with
5926 Emacs Lisp in @file{.emacs}.  The following example contains all valid
5927 search types:
5929 @lisp
5930 @group
5931 (setq org-agenda-custom-commands
5932       '(("w" todo "WAITING")
5933         ("W" todo-tree "WAITING")
5934         ("u" tags "+boss-urgent")
5935         ("v" tags-todo "+boss-urgent")
5936         ("U" tags-tree "+boss-urgent")
5937         ("f" occur-tree "\\<FIXME\\>")
5938         ("h" . "HOME+Name tags searches") ; description for "h" prefix
5939         ("hl" tags "+home+Lisa")
5940         ("hp" tags "+home+Peter")
5941         ("hk" tags "+home+Kim")))
5942 @end group
5943 @end lisp
5945 @noindent
5946 The initial string in each entry defines the keys you have to press
5947 after the dispatcher command @kbd{C-c a} in order to access the command.
5948 Usually this will be just a single character, but if you have many
5949 similar commands, you can also define two-letter combinations where the
5950 first character is the same in several combinations and serves as a
5951 prefix key@footnote{You can provide a description for a prefix key by
5952 inserting a cons cell with the prefix and the description.}.  The second
5953 parameter is the search type, followed by the string or regular
5954 expression to be used for the matching.  The example above will
5955 therefore define:
5957 @table @kbd
5958 @item C-c a w
5959 as a global search for TODO entries with @samp{WAITING} as the TODO
5960 keyword
5961 @item C-c a W
5962 as the same search, but only in the current buffer and displaying the
5963 results as a sparse tree
5964 @item C-c a u
5965 as a global tags search for headlines marked @samp{:boss:} but not
5966 @samp{:urgent:}
5967 @item C-c a v
5968 as the same search as @kbd{C-c a u}, but limiting the search to
5969 headlines that are also TODO items
5970 @item C-c a U
5971 as the same search as @kbd{C-c a u}, but only in the current buffer and
5972 displaying the result as a sparse tree
5973 @item C-c a f
5974 to create a sparse tree (again: current buffer only) with all entries
5975 containing the word @samp{FIXME}
5976 @item C-c a h
5977 as a prefix command for a HOME tags search where you have to press an
5978 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
5979 Peter, or Kim) as additional tag to match.
5980 @end table
5982 @node Block agenda, Setting Options, Storing searches, Custom agenda views
5983 @subsection Block agenda
5984 @cindex block agenda
5985 @cindex agenda, with block views
5987 Another possibility is the construction of agenda views that comprise
5988 the results of @emph{several} commands, each of which creates a block in
5989 the agenda buffer.  The available commands include @code{agenda} for the
5990 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
5991 for the global TODO list (as constructed with @kbd{C-c a t}), and the
5992 matching commands discussed above: @code{todo}, @code{tags}, and
5993 @code{tags-todo}.  Here are two examples:
5995 @lisp
5996 @group
5997 (setq org-agenda-custom-commands
5998       '(("h" "Agenda and Home-related tasks"
5999          ((agenda "")
6000           (tags-todo "home")
6001           (tags "garden")))
6002         ("o" "Agenda and Office-related tasks"
6003          ((agenda "")
6004           (tags-todo "work")
6005           (tags "office")))))
6006 @end group
6007 @end lisp
6009 @noindent
6010 This will define @kbd{C-c a h} to create a multi-block view for stuff
6011 you need to attend to at home.  The resulting agenda buffer will contain
6012 your agenda for the current week, all TODO items that carry the tag
6013 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
6014 command @kbd{C-c a o} provides a similar view for office tasks.
6016 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
6017 @subsection Setting options for custom commands
6018 @cindex options, for custom agenda views
6020 Org mode contains a number of variables regulating agenda construction
6021 and display.  The global variables define the behavior for all agenda
6022 commands, including the custom commands.  However, if you want to change
6023 some settings just for a single custom view, you can do so.  Setting
6024 options requires inserting a list of variable names and values at the
6025 right spot in @code{org-agenda-custom-commands}.  For example:
6027 @lisp
6028 @group
6029 (setq org-agenda-custom-commands
6030       '(("w" todo "WAITING"
6031          ((org-agenda-sorting-strategy '(priority-down))
6032           (org-agenda-prefix-format "  Mixed: ")))
6033         ("U" tags-tree "+boss-urgent"
6034          ((org-show-following-heading nil)
6035           (org-show-hierarchy-above nil)))
6036         ("N" search ""
6037          ((org-agenda-files '("~org/notes.org"))
6038           (org-agenda-text-search-extra-files nil)))))
6039 @end group
6040 @end lisp
6042 @noindent
6043 Now the @kbd{C-c a w} command will sort the collected entries only by
6044 priority, and the prefix format is modified to just say @samp{  Mixed: }
6045 instead of giving the category of the entry.  The sparse tags tree of
6046 @kbd{C-c a U} will now turn out ultra-compact, because neither the
6047 headline hierarchy above the match, nor the headline following the match
6048 will be shown.  The command @kbd{C-c a N} will do a text search limited
6049 to only a single file.
6051 For command sets creating a block agenda,
6052 @code{org-agenda-custom-commands} has two separate spots for setting
6053 options.  You can add options that should be valid for just a single
6054 command in the set, and options that should be valid for all commands in
6055 the set.  The former are just added to the command entry, the latter
6056 must come after the list of command entries.  Going back to the block
6057 agenda example (@pxref{Block agenda}), let's change the sorting strategy
6058 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
6059 the results for GARDEN tags query in the opposite order,
6060 @code{priority-up}.  This would look like this:
6062 @lisp
6063 @group
6064 (setq org-agenda-custom-commands
6065       '(("h" "Agenda and Home-related tasks"
6066          ((agenda)
6067           (tags-todo "home")
6068           (tags "garden"
6069                 ((org-agenda-sorting-strategy '(priority-up)))))
6070          ((org-agenda-sorting-strategy '(priority-down))))
6071         ("o" "Agenda and Office-related tasks"
6072          ((agenda)
6073           (tags-todo "work")
6074           (tags "office")))))
6075 @end group
6076 @end lisp
6078 As you see, the values and parenthesis setting is a little complex.
6079 When in doubt, use the customize interface to set this variable - it
6080 fully supports its structure.  Just one caveat: When setting options in
6081 this interface, the @emph{values} are just lisp expressions.  So if the
6082 value is a string, you need to add the double quotes around the value
6083 yourself.
6086 @node Exporting Agenda Views, Using the agenda elsewhere, Setting Options, Custom agenda views
6087 @subsection Exporting Agenda Views
6088 @cindex agenda views, exporting
6090 If you are away from your computer, it can be very useful to have a
6091 printed version of some agenda views to carry around.  Org mode can
6092 export custom agenda views as plain text, HTML@footnote{You need to
6093 install Hrvoje Niksic' @file{htmlize.el}.} postscript, and iCalendar
6094 files.  If you want to do this only occasionally, use the command
6096 @table @kbd
6097 @kindex C-x C-w
6098 @item C-x C-w
6099 @cindex exporting agenda views
6100 @cindex agenda views, exporting
6101 Write the agenda view to a file.  Depending on the extension of the
6102 selected file name, the view will be exported as HTML (extension
6103 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}),
6104 iCalendar (extension @file{.ics}), or plain text (any other extension).
6105 Use the variable @code{org-agenda-exporter-settings} to
6106 set options for @file{ps-print} and for @file{htmlize} to be used during
6107 export, for example
6109 @lisp
6110 (setq org-agenda-exporter-settings
6111       '((ps-number-of-columns 2)
6112         (ps-landscape-mode t)
6113         (htmlize-output-type 'css)))
6114 @end lisp
6115 @end table
6117 If you need to export certain agenda views frequently, you can associate
6118 any custom agenda command with a list of output file names
6119 @footnote{If you want to store standard views like the weekly agenda
6120 or the global TODO list as well, you need to define custom commands for
6121 them in order to be able to specify file names.}.  Here is an example
6122 that first does define custom commands for the agenda and the global
6123 todo list, together with a number of files to which to export them.
6124 Then we define two block agenda commands and specify file names for them
6125 as well.  File names can be relative to the current working directory,
6126 or absolute.
6128 @lisp
6129 @group
6130 (setq org-agenda-custom-commands
6131       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
6132         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
6133         ("h" "Agenda and Home-related tasks"
6134          ((agenda "")
6135           (tags-todo "home")
6136           (tags "garden"))
6137          nil
6138          ("~/views/home.html"))
6139         ("o" "Agenda and Office-related tasks"
6140          ((agenda)
6141           (tags-todo "work")
6142           (tags "office"))
6143          nil
6144          ("~/views/office.ps" "~/calendars/office.ics"))))
6145 @end group
6146 @end lisp
6148 The extension of the file name determines the type of export.  If it is
6149 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
6150 the buffer to HTML and save it to this file name.  If the extension is
6151 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
6152 postscript output.  If the extension is @file{.ics}, iCalendar export is
6153 run export over all files that were used to construct the agenda, and
6154 limit the export to entries listed in the agenda now.  Any other
6155 extension produces a plain ASCII file.
6157 The export files are @emph{not} created when you use one of those
6158 commands interactively because this might use too much overhead.
6159 Instead, there is a special command to produce @emph{all} specified
6160 files in one step:
6162 @table @kbd
6163 @kindex C-c a e
6164 @item C-c a e
6165 Export all agenda views that have export file names associated with
6166 them.
6167 @end table
6169 You can use the options section of the custom agenda commands to also
6170 set options for the export commands.  For example:
6172 @lisp
6173 (setq org-agenda-custom-commands
6174       '(("X" agenda ""
6175          ((ps-number-of-columns 2)
6176           (ps-landscape-mode t)
6177           (org-agenda-prefix-format " [ ] ")
6178           (org-agenda-with-colors nil)
6179           (org-agenda-remove-tags t))
6180          ("theagenda.ps"))))
6181 @end lisp
6183 @noindent
6184 This command sets two options for the postscript exporter, to make it
6185 print in two columns in landscape format - the resulting page can be cut
6186 in two and then used in a paper agenda.  The remaining settings modify
6187 the agenda prefix to omit category and scheduling information, and
6188 instead include a checkbox to check off items.  We also remove the tags
6189 to make the lines compact, and we don't want to use colors for the
6190 black-and-white printer.  Settings specified in
6191 @code{org-agenda-exporter-settings} will also apply, but the settings
6192 in @code{org-agenda-custom-commands} take precedence.
6194 @noindent
6195 From the command line you may also use
6196 @example
6197 emacs -f org-batch-store-agenda-views -kill
6198 @end example
6199 @noindent
6200 or, if you need to modify some parameters
6201 @example
6202 emacs -eval '(org-batch-store-agenda-views                      \
6203               org-agenda-ndays 30                               \
6204               org-agenda-start-day "2007-11-01"                 \
6205               org-agenda-include-diary nil                      \
6206               org-agenda-files (quote ("~/org/project.org")))'  \
6207       -kill
6208 @end example
6209 @noindent
6210 which will create the agenda views restricted to the file
6211 @file{~/org/project.org}, without diary entries and with 30 days
6212 extent.
6214 @node Using the agenda elsewhere,  , Exporting Agenda Views, Custom agenda views
6215 @subsection Using agenda information outside of Org
6216 @cindex agenda, pipe
6217 @cindex Scripts, for agenda processing
6219 Org provides commands to access agenda information for the command
6220 line in emacs batch mode.  This extracted information can be sent
6221 directly to a printer, or it can be read by a program that does further
6222 processing of the data.  The first of these commands is the function
6223 @code{org-batch-agenda}, that produces an agenda view and sends it as
6224 ASCII text to STDOUT.  The command takes a single string as parameter.
6225 If the string has length 1, it is used as a key to one of the commands
6226 you have configured in @code{org-agenda-custom-commands}, basically any
6227 key you can use after @kbd{C-c a}.  For example, to directly print the
6228 current TODO list, you could use
6230 @example
6231 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
6232 @end example
6234 If the parameter is a string with 2 or more characters, it is used as a
6235 tags/todo match string.  For example, to print your local shopping list
6236 (all items with the tag @samp{shop}, but excluding the tag
6237 @samp{NewYork}), you could use
6239 @example
6240 emacs -batch -l ~/.emacs                                      \
6241       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
6242 @end example
6244 @noindent
6245 You may also modify parameters on the fly like this:
6247 @example
6248 emacs -batch -l ~/.emacs                                      \
6249    -eval '(org-batch-agenda "a"                               \
6250             org-agenda-ndays 30                               \
6251             org-agenda-include-diary nil                      \
6252             org-agenda-files (quote ("~/org/project.org")))'  \
6253    | lpr
6254 @end example
6256 @noindent
6257 which will produce a 30 day agenda, fully restricted to the Org file
6258 @file{~/org/projects.org}, not even including the diary.
6260 If you want to process the agenda data in more sophisticated ways, you
6261 can use the command @code{org-batch-agenda-csv} to get a comma-separated
6262 list of values for each agenda item.  Each line in the output will
6263 contain a number of fields separated by commas.  The fields in a line
6264 are:
6266 @example
6267 category     @r{The category of the item}
6268 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
6269 type         @r{The type of the agenda entry, can be}
6270                 todo               @r{selected in TODO match}
6271                 tagsmatch          @r{selected in tags match}
6272                 diary              @r{imported from diary}
6273                 deadline           @r{a deadline}
6274                 scheduled          @r{scheduled}
6275                 timestamp          @r{appointment, selected by timestamp}
6276                 closed             @r{entry was closed on date}
6277                 upcoming-deadline  @r{warning about nearing deadline}
6278                 past-scheduled     @r{forwarded scheduled item}
6279                 block              @r{entry has date block including date}
6280 todo         @r{The TODO keyword, if any}
6281 tags         @r{All tags including inherited ones, separated by colons}
6282 date         @r{The relevant date, like 2007-2-14}
6283 time         @r{The time, like 15:00-16:50}
6284 extra        @r{String with extra planning info}
6285 priority-l   @r{The priority letter if any was given}
6286 priority-n   @r{The computed numerical priority}
6287 @end example
6289 @noindent
6290 Time and date will only be given if a timestamp (or deadline/scheduled)
6291 lead to the selection of the item.
6293 A CSV list like this is very easy to use in a post processing script.
6294 For example, here is a Perl program that gets the TODO list from
6295 Emacs/Org and prints all the items, preceded by a checkbox:
6297 @example
6298 @group
6299 #!/usr/bin/perl
6301 # define the Emacs command to run
6302 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
6304 # run it and capture the output
6305 $agenda = qx@{$cmd 2>/dev/null@};
6307 # loop over all lines
6308 foreach $line (split(/\n/,$agenda)) @{
6310   # get the individual values
6311   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
6312    $priority_l,$priority_n) = split(/,/,$line);
6314   # proccess and print
6315   print "[ ] $head\n";
6317 @end group
6318 @end example
6320 @node Agenda column view,  , Custom agenda views, Agenda Views
6321 @section Using column view in the agenda
6322 @cindex column view, in agenda
6323 @cindex agenda, column view
6325 Column view (@pxref{Column view}) is normally used to view and edit
6326 properties embedded in the hierarchical structure of an Org file.  It can be
6327 quite useful to use column view also from the agenda, where entries are
6328 collected by certain criteria.
6330 @table @kbd
6331 @kindex C-c C-x C-c
6332 @item C-c C-x C-c
6333 Turn on column view in the agenda.
6334 @end table
6336 To understand how to use this properly, it is important to realize that the
6337 entries in the agenda are no longer in their proper outline environment.
6338 This causes the following issues:
6340 @enumerate
6341 @item
6342 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
6343 entries in the agenda are collected from different files, and different files
6344 may have different @code{COLUMNS} formats, this is a non-trivial problem.
6345 Org first checks if the variable @code{org-overriding-columns-format} is
6346 currently set, and if yes takes the format from there.  Otherwise it takes
6347 the format associated with the first item in the agenda, or, if that item
6348 does not have a specific format (defined in a property, or in it's file), it
6349 uses @code{org-columns-default-format}.
6350 @item
6351 If any of the columns has a summary type defined (@pxref{Column attributes}),
6352 turning on column view in the agenda will visit all relevant agenda files and
6353 make sure that the computations of this property are up to date.  This is
6354 also true for the special @code{CLOCKSUM} property.  Org will then sum the
6355 values displayed in the agenda.  In the daily/weekly agenda, the sums will
6356 cover a single day, in all other views they cover the entire block.  It is
6357 vital to realize that the agenda may show the same entry @emph{twice} (for
6358 example as scheduled and as a deadline), and it may show two entries from the
6359 same hierarchy (for example a @emph{parent} and it's @emph{child}).  In these
6360 cases, the summation in the agenda will lead to incorrect results because
6361 some values will count double.
6362 @item
6363 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
6364 the entire clocked time for this item.  So even in the daily/weekly agenda,
6365 the clocksum listed in column view may originate from times outside the
6366 current view.  This has the advantage that you can compare these values with
6367 a column listing the planned total effort for a task - one of the major
6368 applications for column view in the agenda.  If you want information about
6369 clocked time in the displayed period use clock table mode (press @kbd{R} in
6370 the agenda).
6371 @end enumerate
6374 @node Embedded LaTeX, Exporting, Agenda Views, Top
6375 @chapter Embedded LaTeX
6376 @cindex @TeX{} interpretation
6377 @cindex La@TeX{} interpretation
6379 Plain ASCII is normally sufficient for almost all note taking.  One
6380 exception, however, are scientific notes which need to be able to contain
6381 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
6382 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
6383 features described here as ``La@TeX{}'' are really from @TeX{}, but for
6384 simplicity I am blurring this distinction.}  is widely used to typeset
6385 scientific documents. Org mode supports embedding La@TeX{} code into its
6386 files, because many academics are used to reading La@TeX{} source code, and
6387 because it can be readily processed into images for HTML production.
6389 It is not necessary to mark La@TeX{} macros and code in any special way.
6390 If you observe a few conventions, Org mode knows how to find it and what
6391 to do with it.
6393 @menu
6394 * Math symbols::                TeX macros for symbols and Greek letters
6395 * Subscripts and superscripts::  Simple syntax for raising/lowering text
6396 * LaTeX fragments::             Complex formulas made easy
6397 * Processing LaTeX fragments::  Previewing LaTeX processing
6398 * CDLaTeX mode::                Speed up entering of formulas
6399 @end menu
6401 @node Math symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
6402 @section Math symbols
6403 @cindex math symbols
6404 @cindex TeX macros
6406 You can use La@TeX{} macros to insert special symbols like @samp{\alpha}
6407 to indicate the Greek letter, or @samp{\to} to indicate an arrow.
6408 Completion for these macros is available, just type @samp{\} and maybe a
6409 few letters, and press @kbd{M-@key{TAB}} to see possible completions.
6410 Unlike La@TeX{} code, Org mode allows these macros to be present
6411 without surrounding math delimiters, for example:
6413 @example
6414 Angles are written as Greek letters \alpha, \beta and \gamma.
6415 @end example
6417 During HTML export (@pxref{HTML export}), these symbols are translated
6418 into the proper syntax for HTML, for the above examples this is
6419 @samp{&alpha;} and @samp{&rarr;}, respectively.
6421 @node Subscripts and superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
6422 @section Subscripts and superscripts
6423 @cindex subscript
6424 @cindex superscript
6426 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
6427 and subscripts.  Again, these can be used without embedding them in
6428 math-mode delimiters.  To increase the readability of ASCII text, it is
6429 not necessary (but OK) to surround multi-character sub- and superscripts
6430 with curly braces.  For example
6432 @example
6433 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
6434 the sun is R_@{sun@} = 6.96 x 10^8 m.
6435 @end example
6437 To avoid interpretation as raised or lowered text, you can quote
6438 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
6440 During HTML export (@pxref{HTML export}), subscript and superscripts
6441 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
6443 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
6444 @section LaTeX fragments
6445 @cindex LaTeX fragments
6447 With symbols, sub- and superscripts, HTML is pretty much at its end when
6448 it comes to representing mathematical formulas@footnote{Yes, there is
6449 MathML, but that is not yet fully supported by many browsers, and there
6450 is no decent converter for turning La@TeX{} or ASCII representations of
6451 formulas into MathML. So for the time being, converting formulas into
6452 images seems the way to go.}. More complex expressions need a dedicated
6453 formula processor. To this end, Org mode can contain arbitrary La@TeX{}
6454 fragments. It provides commands to preview the typeset result of these
6455 fragments, and upon export to HTML, all fragments will be converted to
6456 images and inlined into the HTML document@footnote{The La@TeX{} export
6457 will not use images for displaying La@TeX{} fragments but include these
6458 fragments directly into the La@TeX{} code.}. For this to work you
6459 need to be on a system with a working La@TeX{} installation. You also
6460 need the @file{dvipng} program, available at
6461 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
6462 will be used when processing a fragment can be configured with the
6463 variable @code{org-format-latex-header}.
6465 La@TeX{} fragments don't need any special marking at all.  The following
6466 snippets will be identified as La@TeX{} source code:
6467 @itemize @bullet
6468 @item
6469 Environments of any kind.  The only requirement is that the
6470 @code{\begin} statement appears on a new line, preceded by only
6471 whitespace.
6472 @item
6473 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
6474 currency specifications, single @samp{$} characters are only recognized
6475 as math delimiters if the enclosed text contains at most two line breaks,
6476 is directly attached to the @samp{$} characters with no whitespace in
6477 between, and if the closing @samp{$} is followed by whitespace or
6478 punctuation.  For the other delimiters, there is no such restriction, so
6479 when in doubt, use @samp{\(...\)} as inline math delimiters.
6480 @end itemize
6482 @noindent For example:
6484 @example
6485 \begin@{equation@}                          % arbitrary environments,
6486 x=\sqrt@{b@}                                % even tables, figures
6487 \end@{equation@}                            % etc
6489 If $a^2=b$ and \( b=2 \), then the solution must be
6490 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
6491 @end example
6493 @noindent
6494 If you need any of the delimiter ASCII sequences for other purposes, you
6495 can configure the option @code{org-format-latex-options} to deselect the
6496 ones you do not wish to have interpreted by the La@TeX{} converter.
6498 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
6499 @section Processing LaTeX fragments
6500 @cindex LaTeX fragments, preview
6502 La@TeX{} fragments can be processed to produce a preview images of the
6503 typeset expressions:
6505 @table @kbd
6506 @kindex C-c C-x C-l
6507 @item C-c C-x C-l
6508 Produce a preview image of the La@TeX{} fragment at point and overlay it
6509 over the source code.  If there is no fragment at point, process all
6510 fragments in the current entry (between two headlines).  When called
6511 with a prefix argument, process the entire subtree.  When called with
6512 two prefix arguments, or when the cursor is before the first headline,
6513 process the entire buffer.
6514 @kindex C-c C-c
6515 @item C-c C-c
6516 Remove the overlay preview images.
6517 @end table
6519 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
6520 converted into images and inlined into the document if the following
6521 setting is active:
6523 @lisp
6524 (setq org-export-with-LaTeX-fragments t)
6525 @end lisp
6527 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
6528 @section Using CDLaTeX to enter math
6529 @cindex CDLaTeX
6531 CDLaTeX mode is a minor mode that is normally used in combination with a
6532 major La@TeX{} mode like AUCTeX in order to speed-up insertion of
6533 environments and math templates.  Inside Org mode, you can make use of
6534 some of the features of CDLaTeX mode.  You need to install
6535 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
6536 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
6537 Don't use CDLaTeX mode itself under Org mode, but use the light
6538 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
6539 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
6540 Org files with
6542 @lisp
6543 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
6544 @end lisp
6546 When this mode is enabled, the following features are present (for more
6547 details see the documentation of CDLaTeX mode):
6548 @itemize @bullet
6549 @kindex C-c @{
6550 @item
6551 Environment templates can be inserted with @kbd{C-c @{}.
6552 @item
6553 @kindex @key{TAB}
6554 The @key{TAB} key will do template expansion if the cursor is inside a
6555 La@TeX{} fragment@footnote{Org mode has a method to test if the cursor is
6556 inside such a fragment, see the documentation of the function
6557 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
6558 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
6559 correctly inside the first brace.  Another @key{TAB} will get you into
6560 the second brace.  Even outside fragments, @key{TAB} will expand
6561 environment abbreviations at the beginning of a line.  For example, if
6562 you write @samp{equ} at the beginning of a line and press @key{TAB},
6563 this abbreviation will be expanded to an @code{equation} environment.
6564 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
6565 @item
6566 @kindex _
6567 @kindex ^
6568 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
6569 characters together with a pair of braces.  If you use @key{TAB} to move
6570 out of the braces, and if the braces surround only a single character or
6571 macro, they are removed again (depending on the variable
6572 @code{cdlatex-simplify-sub-super-scripts}).
6573 @item
6574 @kindex `
6575 Pressing the backquote @kbd{`} followed by a character inserts math
6576 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
6577 after the backquote, a help window will pop up.
6578 @item
6579 @kindex '
6580 Pressing the normal quote @kbd{'} followed by another character modifies
6581 the symbol before point with an accent or a font.  If you wait more than
6582 1.5 seconds after the backquote, a help window will pop up.  Character
6583 modification will work only inside La@TeX{} fragments, outside the quote
6584 is normal.
6585 @end itemize
6587 @node Exporting, Publishing, Embedded LaTeX, Top
6588 @chapter Exporting
6589 @cindex exporting
6591 Org mode documents can be exported into a variety of other formats.  For
6592 printing and sharing of notes, ASCII export produces a readable and
6593 simple version of an Org file.  HTML export allows you to publish a
6594 notes file on the web, while the XOXO format provides a solid base for
6595 exchange with a broad range of other applications. La@TeX{} export lets
6596 you use Org mode and its structured editing functions to easily create
6597 La@TeX{} files.  To incorporate entries with associated times like
6598 deadlines or appointments into a desktop calendar program like iCal,
6599 Org mode can also produce extracts in the iCalendar format.  Currently
6600 Org mode only supports export, not import of these different formats.
6602 @menu
6603 * Markup rules::                Which structures are recognized?
6604 * Export options::              Per-file export settings
6605 * The export dispatcher::       How to access exporter commands
6606 * ASCII export::                Exporting to plain ASCII
6607 * HTML export::                 Exporting to HTML
6608 * LaTeX export::                Exporting to LaTeX
6609 * XOXO export::                 Exporting to XOXO
6610 * iCalendar export::            Exporting in iCalendar format
6611 @end menu
6613 @node Markup rules, Export options, Exporting, Exporting
6614 @section Markup rules
6616 When exporting Org mode documents,  the exporter tries to reflect the
6617 structure of the document as accurately as possible in the back-end.  Since
6618 export targets like HTML or La@TeX{} allow much richer formatting, Org mode
6619 has rules how to prepare text for rich export.  This section summarizes the
6620 markup rule used in an Org mode buffer.
6622 @menu
6623 * Document title::              How the document title is determined
6624 * Headings and sections::       The main structure of the exported document
6625 * Table of contents::           If, where, how to create a table of contents
6626 * Initial text::                Text before the first headline
6627 * Lists::                       Plain lists are exported
6628 * Paragraphs::                  What determines beginning and ending
6629 * Literal examples::            Source code and other examples
6630 * Include files::               Include the contents of a file during export
6631 * Tables exported::             Tables are exported richly
6632 * Footnotes::                   Numbers like [1]
6633 * Emphasis and monospace::      To bold or not to bold
6634 * TeX macros and LaTeX fragments::  Create special, rich export.
6635 * Horizontal rules::            A line across the page
6636 * Comment lines::               Some lines will not be exported
6637 @end menu
6639 @node Document title, Headings and sections, Markup rules, Markup rules
6640 @subheading Document title
6641 @cindex document title, markup rules
6643 @noindent
6644 The title of the exported document is taken from the special line
6646 @example
6647 #+TITLE: This is the title of the document
6648 @end example
6650 @noindent
6651 If this line does not exist, the title is derived from the first non-empty,
6652 non-comment line in the buffer.  If no such line exists, or if you have
6653 turned off exporting of the text before the first headline (see below), the
6654 title will be the file name without extension.
6656 If you are exporting only a subtree by marking is as the region, the heading
6657 of the subtree will become the title of the document.
6659 @node Headings and sections, Table of contents, Document title, Markup rules
6660 @subheading Headings and sections
6661 @cindex headings and sections, markup rules
6663 The outline structure of the document as described in @ref{Document
6664 Structure} forms the basis for defining sections of the exported document.
6665 However, since the outline structure is also used for (for example) lists of
6666 tasks, only the first three outline levels will be used as headings.  Deeper
6667 levels will become itemized lists.  You can change the location of this
6668 switch, globally by setting the variable @code{org-headline-levels}, or on a
6669 per file basis with a line
6671 @example
6672 #+OPTIONS: H:4
6673 @end example
6675 @node Table of contents, Initial text, Headings and sections, Markup rules
6676 @subheading Table of contents
6677 @cindex table of contents, markup rules
6679 The table of contents is normally inserted directly before the first headline
6680 of the file.  If you would like to get it to a different location, insert the
6681 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
6682 location.  The depth of the table of contents is by default the same as the
6683 number of headline levels, but you can choose a smaller number or turn off
6684 the table of contents entirely by configuring the variable
6685 @code{org-export-with-toc}, or on a per-file basis with a line like
6687 @example
6688 #+OPTIONS: toc:2          (only to two levels in TOC)
6689 #+OPTIONS: toc:nil        (no TOC at all)
6690 @end example
6692 @node Initial text, Lists, Table of contents, Markup rules
6693 @subheading Text before the first headline
6694 @cindex text before first headline, markup rules
6695 @cindex #+TEXT
6697 Org mode normally exports the text before the first headline, and even uses
6698 the first line as the document title.  The text will be fully marked up.  If
6699 you need to include literal HTML or La@TeX{} code, use the special constructs
6700 described below in the sections for the individual exporters.
6702 Some people like to use the space before the first headline for setup and
6703 internal links and therefore would like to control the exported text before
6704 the first headline in a different way.  You can do so by setting the variable
6705 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
6706 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
6708 @noindent
6709 If you still want to have some text before the first headline, use the
6710 @code{#+TEXT} construct:
6712 @example
6713 #+OPTIONS: skip:t
6714 #+TEXT: This text will go before the *first* headline.
6715 #+TEXT: [TABLE-OF-CONTENTS]
6716 #+TEXT: This goes between the table of contents and the first headline
6717 @end example
6719 @node Lists, Paragraphs, Initial text, Markup rules
6720 @subheading Lists
6721 @cindex lists, markup rules
6723 Plain lists as described in @ref{Plain lists} are translated to the back-ends
6724 syntax for such lists.  Most back-ends support unordered, ordered, and
6725 description lists.
6727 @node Paragraphs, Literal examples, Lists, Markup rules
6728 @subheading Paragraphs, line breaks, and quoting
6729 @cindex paragraphs, markup rules
6731 Paragraphs are separated by at least one empty line.  If you need to enforce
6732 a line break within a paragraph, use @samp{\\} at the end of a line.
6734 To keep the line breaks in a region, but otherwise use normal formatting, you
6735 can use this construct, which can also be used to format poetry.
6737 @example
6738 #+BEGIN_VERSE
6739 Everything should be made as simple as possible,
6740 but not any simpler -- Albert Einstein
6741 #+END_VERSE
6742 @end example
6744 When quoting a passage from another document, it is customary to format this
6745 as a paragraph that is indented on both the left and the right margin.  You
6746 can include quotations in Org mode documents like this:
6748 @example
6749 #+BEGIN_QUOTE
6750 Everything should be made as simple as possible,
6751 but not any simpler -- Albert Einstein
6752 #+END_QUOTE
6753 @end example
6756 @node Literal examples, Include files, Paragraphs, Markup rules
6757 @subheading Literal examples
6758 @cindex literal examples, markup rules
6760 You can include literal examples that should not be subjected to
6761 markup.  Such examples will be typeset in monospace, so this is well suited
6762 for source code and similar examples.
6763 @cindex #+BEGIN_EXAMPLE
6765 @example
6766 #+BEGIN_EXAMPLE
6767 Some example from a text file.
6768 #+END_EXAMPLE
6769 @end example
6771 For simplicity when using small examples, you can also start the example
6772 lines with a colon:
6774 @example
6775 : Some example from a text file.
6776 @end example
6778 @cindex formatting source code, markup rules
6779 If the example is source code from a programming language, or any other text
6780 that can be marked up by font-lock in Emacs, you can ask for the example to
6781 look like the fontified Emacs buffer@footnote{Currently this works only for
6782 the HTML back-end, and requires the @file{htmlize.el} package version 1.34 or
6783 later.}.  This is done with the @samp{src} block, where you also need to
6784 specify the name of the major mode that should be used to fontify the
6785 example:
6786 @cindex #+BEGIN_SRC
6788 @example
6789 #+BEGIN_SRC emacs-lisp
6790 (defun org-xor (a b)
6791    "Exclusive or."
6792    (if a (not b) b))
6793 #+END_SRC
6794 @end example
6796 @node Include files, Tables exported, Literal examples, Markup rules
6797 @subheading Include files
6798 @cindex include files, markup rules
6800 During export, you can include the content of another file.  For example, to
6801 include your .emacs file, you could use:
6802 @cindex #+INCLUDE
6804 @example
6805 #+INCLUDE: "~/.emacs" src emacs-lisp
6806 @end example
6808 The optional second and third parameter are the markup (@samp{quote},
6809 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
6810 language for formatting the contents.  The markup is optional, if it is not
6811 given, the text will be assumed to be in Org mode format and will be
6812 processed normally.
6814 @node Tables exported, Footnotes, Include files, Markup rules
6815 @subheading Tables
6816 @cindex tables, markup rules
6818 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
6819 the @file{table.el} package will be exported properly.  For Org mode tables,
6820 the lines before the first horizontal separator line will become table header
6821 lines.
6823 @node Footnotes, Emphasis and monospace, Tables exported, Markup rules
6824 @subheading Footnotes
6825 @cindex footnotes, markup rules
6826 @cindex @file{footnote.el}
6828 @kindex C-c !
6829 Numbers in square brackets are treated as footnote markers, and lines
6830 starting with such a marker are interpreted as the footnote itself.  You can
6831 use the Emacs package @file{footnote.el} to create footnotes@footnote{The
6832 @file{footnote} package uses @kbd{C-c !} to invoke its commands.  This
6833 binding conflicts with the Org mode command for inserting inactive time
6834 stamps.  You could use the variable @code{footnote-prefix} to switch
6835 footnotes commands to another key.  Or, if you are too used to this binding,
6836 you could use @code{org-replace-disputed-keys} and @code{org-disputed-keys}
6837 to change the settings in Org.}.  For example:
6839 @example
6840 The Org homepage[1] now looks a lot better than it used to.
6842 [1] The link is: http://orgmode.org
6843 @end example
6845 @node Emphasis and monospace, TeX macros and LaTeX fragments, Footnotes, Markup rules
6846 @subheading Emphasis and monospace
6848 @cindex underlined text, markup rules
6849 @cindex bold text, markup rules
6850 @cindex italic text, markup rules
6851 @cindex verbatim text, markup rules
6852 @cindex code text, markup rules
6853 @cindex strike-through text, markup rules
6854 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
6855 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
6856 in the code and verbatim string is not processed for Org mode specific
6857 syntax, it is exported verbatim.
6859 @node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
6860 @subheading @TeX{} macros and La@TeX{} fragments
6861 @cindex LaTeX fragments, markup rules
6862 @cindex TeX macros, markup rules
6863 @cindex HTML entities
6864 @cindex LaTeX entities
6866 A @TeX{}-like syntax is used to specify special characters.  Where possible,
6867 these will be transformed into the native format of the exporter back-end.
6868 Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
6869 output, and as @code{$\alpha$} in the La@TeX{} output.  Similarly,
6870 @code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
6871 This applies for a large number of entities, with names taken from both HTML
6872 and La@TeX{}, see the variable @code{org-html-entities} for the complete
6873 list.  If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
6874 after having types the backslash and maybe a few characters
6875 (@pxref{Completion}).
6877 La@TeX{} fragments are converted into images for HTML export, and they are
6878 written literally into the La@TeX{} export.  See also @ref{Embedded LaTeX}.
6880 Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
6881 @samp{...} are all converted into special commands creating hyphens of
6882 different lengths or a compact set of dots.
6884 @node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
6885 @subheading  Horizontal rules
6886 @cindex horizontal rules, markup rules
6887 A line consisting of only dashes, and at least 5 of them, will be
6888 exported as a horizontal line (@samp{<hr/>} in HTML).
6890 @node Comment lines,  , Horizontal rules, Markup rules
6891 @subheading Comment lines
6892 @cindex comment lines
6893 @cindex exporting, not
6895 Lines starting with @samp{#} in column zero are treated as comments and will
6896 never be exported.  Also entire subtrees starting with the word
6897 @samp{COMMENT} will never be exported.  Finally, regions surrounded by
6898 @samp{#+BEGIN_COMMENT} ... @samp{END_COMMENT} will not be exported.
6900 @table @kbd
6901 @kindex C-c ;
6902 @item C-c ;
6903 Toggle the COMMENT keyword at the beginning of an entry.
6904 @end table
6906 @node Export options, The export dispatcher, Markup rules, Exporting
6907 @section Export options
6908 @cindex options, for export
6910 @cindex completion, of option keywords
6911 The exporter recognizes special lines in the buffer which provide
6912 additional information.  These lines may be put anywhere in the file.
6913 The whole set of lines can be inserted into the buffer with @kbd{C-c
6914 C-e t}.  For individual lines, a good way to make sure the keyword is
6915 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
6916 (@pxref{Completion}).
6918 @table @kbd
6919 @kindex C-c C-e t
6920 @item C-c C-e t
6921 Insert template with export options, see example below.
6922 @end table
6924 @cindex #+TITLE:
6925 @cindex #+AUTHOR:
6926 @cindex #+DATE:
6927 @cindex #+EMAIL:
6928 @cindex #+LANGUAGE:
6929 @cindex #+TEXT:
6930 @cindex #+OPTIONS:
6931 @cindex #+LINK_UP:
6932 @cindex #+LINK_HOME:
6933 @example
6934 #+TITLE:     the title to be shown (default is the buffer name)
6935 #+AUTHOR:    the author (default taken from @code{user-full-name})
6936 #+DATE:      A date, fixed, of a format string for @code{format-time-string}
6937 #+EMAIL:     his/her email address (default from @code{user-mail-address})
6938 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
6939 #+TEXT:      Some descriptive text to be inserted at the beginning.
6940 #+TEXT:      Several lines may be given.
6941 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
6942 #+LINK_UP:   the ``up'' link of an exported page
6943 #+LINK_HOME: the ``home'' link of an exported page
6944 @end example
6946 @noindent
6947 The OPTIONS line is a compact@footnote{If you want to configure many options
6948 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
6949 you can:
6950 @cindex headline levels
6951 @cindex section-numbers
6952 @cindex table of contents
6953 @cindex line-break preservation
6954 @cindex quoted HTML tags
6955 @cindex fixed-width sections
6956 @cindex tables
6957 @cindex @TeX{}-like syntax for sub- and superscripts
6958 @cindex footnotes
6959 @cindex special strings
6960 @cindex emphasized text
6961 @cindex @TeX{} macros
6962 @cindex La@TeX{} fragments
6963 @cindex author info, in export
6964 @cindex time info, in export
6965 @example
6966 H:         @r{set the number of headline levels for export}
6967 num:       @r{turn on/off section-numbers}
6968 toc:       @r{turn on/off table of contents, or set level limit (integer)}
6969 \n:        @r{turn on/off line-break-preservation}
6970 @@:         @r{turn on/off quoted HTML tags}
6971 ::         @r{turn on/off fixed-width sections}
6972 |:         @r{turn on/off tables}
6973 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
6974            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
6975            @r{the simple @code{a_b} will be left as it is.}
6976 -:         @r{turn on/off conversion of special strings.}
6977 f:         @r{turn on/off footnotes like this[1].}
6978 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
6979 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
6980 LaTeX:     @r{turn on/off La@TeX{} fragments}
6981 skip:      @r{turn on/off skipping the text before the first heading}
6982 author:    @r{turn on/off inclusion of author name/email into exported file}
6983 timestamp: @r{turn on/off inclusion creation time into exported file}
6984 d:         @r{turn on/off inclusion of drawers}
6985 @end example
6987 These options take effect in both the HTML and La@TeX{} export, except
6988 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
6989 @code{nil} for the La@TeX{} export.
6991 @node The export dispatcher, ASCII export, Export options, Exporting
6992 @section The export dispatcher
6993 @cindex dispatcher, for export commands
6995 All export commands can be reached using the export dispatcher, which is a
6996 prefix key that prompts for an additional key specifying the command.
6997 Normally the entire file is exported, but if there is an active region that
6998 contains one outline tree, the first heading is used as document title and
6999 the subtrees are exported.
7001 @table @kbd
7002 @kindex C-c C-e
7003 @item C-c C-e
7004 Dispatcher for export and publishing commands.  Displays a help-window
7005 listing the additional key(s) needed to launch an export or publishing
7006 command.  The prefix arg is passed through to the exporter.  If the option
7007 @code{org-export-run-in-background} is set, Org will run the command in the
7008 background if that seems useful for the specific command (i.e. commands that
7009 write to a file).
7010 @kindex C-c C-e v
7011 @item C-c C-e v
7012 Like @kbd{C-c C-e}, but only export the text that is currently visible
7013 (i.e. not hidden by outline visibility).
7014 @kindex C-u C-u C-c C-e
7015 @item C-u C-u C-c C-e
7016 Call an the exporter, but reverse the setting of
7017 @code{org-export-run-in-background}, i.e. request background processing if
7018 not set, or force processing in the current Emacs process if st.
7019 @end table
7021 @node ASCII export, HTML export, The export dispatcher, Exporting
7022 @section ASCII export
7023 @cindex ASCII export
7025 ASCII export produces a simple and very readable version of an Org mode
7026 file.
7028 @cindex region, active
7029 @cindex active region
7030 @cindex Transient mark mode
7031 @table @kbd
7032 @kindex C-c C-e a
7033 @item C-c C-e a
7034 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
7035 will be @file{myfile.txt}.  The file will be overwritten without
7036 warning.  If there is an active region, only the region will be
7037 exported. If the selected region is a single tree, the tree head will
7038 become the document title.  If the tree head entry has or inherits an
7039 @code{:EXPORT_FILE_NAME:} property, that name will be used for the
7040 export.
7041 @kindex C-c C-e v a
7042 @item C-c C-e v a
7043 Export only the visible part of the document.
7044 @end table
7046 @cindex headline levels, for exporting
7047 In the exported version, the first 3 outline levels will become
7048 headlines, defining a general document structure.  Additional levels
7049 will be exported as itemized lists.  If you want that transition to occur
7050 at a different level, specify it with a prefix argument.  For example,
7052 @example
7053 @kbd{C-1 C-c C-e a}
7054 @end example
7056 @noindent
7057 creates only top level headlines and does the rest as items.  When
7058 headlines are converted to items, the indentation of the text following
7059 the headline is changed to fit nicely under the item.  This is done with
7060 the assumption that the first body line indicates the base indentation of
7061 the body text.  Any indentation larger than this is adjusted to preserve
7062 the layout relative to the first line.  Should there be lines with less
7063 indentation than the first, these are left alone.
7065 @node HTML export, LaTeX export, ASCII export, Exporting
7066 @section HTML export
7067 @cindex HTML export
7069 Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
7070 HTML formatting, in ways similar to John Grubers @emph{markdown}
7071 language, but with additional support for tables.
7073 @menu
7074 * HTML Export commands::        How to invoke HTML export
7075 * Quoting HTML tags::           Using direct HTML in Org mode
7076 * Links::                       Transformation of links for HTML
7077 * Images::                      How to include images
7078 * CSS support::                 Changing the appearance of the output
7079 * Javascript support::          Info and Folding in a web browser
7080 @end menu
7082 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
7083 @subsection HTML export commands
7085 @cindex region, active
7086 @cindex active region
7087 @cindex Transient mark mode
7088 @table @kbd
7089 @kindex C-c C-e h
7090 @item C-c C-e h
7091 Export as HTML file @file{myfile.html}.  For an org file
7092 @file{myfile.org}, the ASCII file will be @file{myfile.html}.  The file
7093 will be overwritten without warning.  If there is an active region, only
7094 the region will be exported. If the selected region is a single tree,
7095 the tree head will become the document title.  If the tree head entry
7096 has or inherits an @code{:EXPORT_FILE_NAME:} property, that name will be
7097 used for the export.
7098 @kindex C-c C-e b
7099 @item C-c C-e b
7100 Export as HTML file and immediately open it with a browser.
7101 @kindex C-c C-e H
7102 @item C-c C-e H
7103 Export to a temporary buffer, do not create a file.
7104 @kindex C-c C-e R
7105 @item C-c C-e R
7106 Export the active region to a temporary buffer.  With a prefix argument, do
7107 not produce the file header and footer, but just the plain HTML section for
7108 the region.  This is good for cut-and-paste operations.
7109 @kindex C-c C-e v h
7110 @kindex C-c C-e v b
7111 @kindex C-c C-e v H
7112 @kindex C-c C-e v R
7113 @item C-c C-e v h
7114 @item C-c C-e v b
7115 @item C-c C-e v H
7116 @item C-c C-e v R
7117 Export only the visible part of the document.
7118 @item M-x org-export-region-as-html
7119 Convert the region to HTML under the assumption that it was Org mode
7120 syntax before.  This is a global command that can be invoked in any
7121 buffer.
7122 @item M-x org-replace-region-by-HTML
7123 Replace the active region (assumed to be in Org mode syntax) by HTML
7124 code.
7125 @end table
7127 @cindex headline levels, for exporting
7128 In the exported version, the first 3 outline levels will become headlines,
7129 defining a general document structure.  Additional levels will be exported as
7130 itemized lists.  If you want that transition to occur at a different level,
7131 specify it with a numeric prefix argument.  For example,
7133 @example
7134 @kbd{C-2 C-c C-e b}
7135 @end example
7137 @noindent
7138 creates two levels of headings and does the rest as items.
7140 @node Quoting HTML tags, Links, HTML Export commands, HTML export
7141 @subsection Quoting HTML tags
7143 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
7144 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
7145 which should be interpreted as such, mark them with @samp{@@} as in
7146 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
7147 simple tags.  For more extensive HTML that should be copied verbatim to
7148 the exported file use either
7150 @example
7151 #+HTML: Literal HTML code for export
7152 @end example
7154 @noindent or
7155 @cindex #+BEGIN_HTML
7157 @example
7158 #+BEGIN_HTML
7159 All lines between these markers are exported literally
7160 #+END_HTML
7161 @end example
7164 @node Links, Images, Quoting HTML tags, HTML export
7165 @subsection Links
7167 @cindex links, in HTML export
7168 @cindex internal links, in HTML export
7169 @cindex external links, in HTML export
7170 Internal links (@pxref{Internal links}) will continue to work in HTML
7171 files only if they match a dedicated @samp{<<target>>}.  Automatic links
7172 created by radio targets (@pxref{Radio targets}) will also work in the
7173 HTML file.  Links to external files will still work if the HTML file is
7174 in the same directory as the Org file.  Links to other @file{.org}
7175 files will be translated into HTML links under the assumption that an
7176 HTML version also exists of the linked file.  For information related to
7177 linking files while publishing them to a publishing directory see
7178 @ref{Publishing links}.
7180 @node Images, CSS support, Links, HTML export
7181 @subsection Images
7183 @cindex images, inline in HTML
7184 @cindex inlining images in HTML
7185 HTML export can inline images given as links in the Org file, and
7186 it can make an image the clickable part of a link.  By
7187 default@footnote{but see the variable
7188 @code{org-export-html-inline-images}}, images are inlined if a link does
7189 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
7190 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
7191 @samp{the image} that points to the image.  If the description part
7192 itself is a @code{file:} link or a @code{http:} URL pointing to an
7193 image, this image will be inlined and activated so that clicking on the
7194 image will activate the link.  For example, to include a thumbnail that
7195 will link to a high resolution version of the image, you could use:
7197 @example
7198 [[file:highres.jpg][file:thumb.jpg]]
7199 @end example
7201 @noindent
7202 and you could use @code{http} addresses just as well.
7204 @node CSS support, Javascript support, Images, HTML export
7205 @subsection CSS support
7206 @cindex CSS, for HTML export
7207 @cindex HTML export, CSS
7209 You can also give style information for the exported file.  The HTML
7210 exporter assigns the following CSS classes to appropriate parts of the
7211 document - your style specifications may change these:
7212 @example
7213 .todo           @r{TODO keywords}
7214 .done           @r{the DONE keyword}
7215 .timestamp      @r{time stamp}
7216 .timestamp-kwd  @r{keyword associated with a time stamp, like SCHEDULED}
7217 .tag            @r{tag in a headline}
7218 .target         @r{target for links}
7219 @end example
7221 The default style specification can be configured through the option
7222 @code{org-export-html-style}.  If you want to use a file-local style,
7223 you may use file variables, best wrapped into a COMMENT section at the
7224 end of the outline tree.  For example@footnote{Under Emacs 21, the
7225 continuation lines for a variable value should have no @samp{#} at the
7226 start of the line.}:
7228 @example
7229 * COMMENT html style specifications
7231 # Local Variables:
7232 # org-export-html-style: "   <style type=\"text/css\">
7233 #       p @{font-weight: normal; color: gray; @}
7234 #       h1 @{color: black; @}
7235 #   </style>"
7236 # End:
7237 @end example
7239 Remember to execute @kbd{M-x normal-mode} after changing this to make
7240 the new style visible to Emacs.  This command restarts Org mode for the
7241 current buffer and forces Emacs to re-evaluate the local variables
7242 section in the buffer.
7244 @c FIXME: More about header and footer styles
7245 @c FIXME: Talk about links and targets.
7247 @node Javascript support,  , CSS support, HTML export
7248 @subsection Javascript supported display of web pages
7250 @emph{Sebastian Rose} has written a JavaScript program especially designed to
7251 enhance the web viewing experience of HTML files created with Org.  This
7252 program allows to view large files in two different ways.  The first one is
7253 an @emph{Info}-like mode where each section is displayed separately and
7254 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
7255 as well, press @kbd{?} for an overview of the available keys).  The second
7256 view type is a @emph{folding} view much like Org provides it inside Emacs.
7257 The script is available at @url{http://orgmode.org/org-info.js} and you can
7258 find the documentation for it at
7259 @url{http://orgmode.org/worg/code/org-info-js/org-info.js.html}.  We are
7260 serving the script from our site, but if you use it a lot, you might not want
7261 to be dependent on @url{orgmode.org} and prefer to install a local copy on
7262 your own web server.
7264 To use the script, you need to make sure that the @file{org-infojs.el} module
7265 gets loaded.  It should be loaded by default, try @kbd{M-x customize-variable
7266 @key{RET} org-modules @key{RET}} to convince yourself that this is indeed the
7267 case.  All it then takes to make use of the program is adding a single line
7268 to the Org file:
7270 @example
7271 #+INFOJS_OPT: view:info toc:nil
7272 @end example
7274 @noindent
7275 If this line is found, the HTML header will automatically contain the code
7276 needed to invoke the script.  Using the line above, you can set the following
7277 viewing options:
7279 @example
7280 path:    @r{The path to the script.  The default is to grab the script from}
7281          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
7282          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
7283 view:    @r{Initial view when website is first shown.  Possible values are:}
7284          info      @r{Info-like interface with one section per page.}
7285          overview  @r{Folding interface, initially showing only top-level.}
7286          content   @r{Folding interface, starting with all headlines visible.}
7287          showall   @r{Folding interface, all headlines and text visible.}
7288 sdepth:  @r{Maximum headline level that will still become an independent}
7289          @r{section for info and folding modes.  The default is taken from}
7290          @r{@code{org-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
7291          @r{If this is smaller than in @code{org-headline-levels}, each}
7292          @r{info/folding section can still contain children headlines.}
7293 toc:     @r{Should the table of content @emph{initially} be visible?}
7294          @r{Even when @code{nil}, you can always get to the toc with @kbd{i}.}
7295 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
7296          @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.}
7297 ftoc:    @r{Does the css of the page specify a fixed position for the toc?}
7298          @r{If yes, the toc will never be displayed as a section.}
7299 ltoc:    @r{Should there be short contents (children) in each section?}
7300 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
7301          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
7302 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
7303          @r{default), only one such button will be present.}
7304 @end example
7306 You can choose default values for these options by customizing the variable
7307 @code{org-infojs-options}.  If you always want to apply the script to your
7308 pages, configure the variable @code{org-export-html-use-infojs}.
7310 @node LaTeX export, XOXO export, HTML export, Exporting
7311 @section LaTeX export
7312 @cindex LaTeX export
7314 Org mode contains a La@TeX{} exporter written by Bastien Guerry.
7316 @menu
7317 * LaTeX export commands::       How to invoke LaTeX export
7318 * Quoting LaTeX code::          Incorporating literal LaTeX code
7319 * Sectioning structure::        Changing sectioning in LaTeX output
7320 @end menu
7322 @node LaTeX export commands, Quoting LaTeX code, LaTeX export, LaTeX export
7323 @subsection LaTeX export commands
7325 @table @kbd
7326 @kindex C-c C-e l
7327 @item C-c C-e l
7328 Export as La@TeX{} file @file{myfile.tex}.
7329 @kindex C-c C-e L
7330 @item C-c C-e L
7331 Export to a temporary buffer, do not create a file.
7332 @kindex C-c C-e v l
7333 @kindex C-c C-e v L
7334 @item C-c C-e v l
7335 @item C-c C-e v L
7336 Export only the visible part of the document.
7337 @item M-x org-export-region-as-latex
7338 Convert the region to La@TeX{} under the assumption that it was Org mode
7339 syntax before.  This is a global command that can be invoked in any
7340 buffer.
7341 @item M-x org-replace-region-by-latex
7342 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
7343 code.
7344 @end table
7346 @cindex headline levels, for exporting
7347 In the exported version, the first 3 outline levels will become
7348 headlines, defining a general document structure.  Additional levels
7349 will be exported as description lists.  The exporter can ignore them or
7350 convert them to a custom string depending on
7351 @code{org-latex-low-levels}.
7353 If you want that transition to occur at a different level, specify it
7354 with a numeric prefix argument. For example,
7356 @example
7357 @kbd{C-2 C-c C-e l}
7358 @end example
7360 @noindent
7361 creates two levels of headings and does the rest as items.
7363 @node Quoting LaTeX code, Sectioning structure, LaTeX export commands, LaTeX export
7364 @subsection Quoting LaTeX code
7366 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
7367 inserted into the La@TeX{} file.  Furthermore, you can add special code
7368 that should only be present in La@TeX{} export with the following
7369 constructs:
7371 @example
7372 #+LaTeX: Literal LaTeX code for export
7373 @end example
7375 @noindent or
7376 @cindex #+BEGIN_LaTeX
7378 @example
7379 #+BEGIN_LaTeX
7380 All lines between these markers are exported literally
7381 #+END_LaTeX
7382 @end example
7384 @node   Sectioning structure,  , Quoting LaTeX code, LaTeX export
7385 @subsection Sectioning structure
7386 @cindex LaTeX class
7387 @cindex LaTeX sectioning structure
7389 By default, the La@TeX{} output uses the class @code{article}.
7391 You can change this globally by setting a different value for
7392 @code{org-export-latex-default-class} or locally by adding an option
7393 like @code{#+LaTeX_CLASS: myclass} in your file.  The class should be
7394 listed in @code{org-export-latex-classes}, where you can also define the
7395 sectioning structure for each class.
7398 @node XOXO export, iCalendar export, LaTeX export, Exporting
7399 @section XOXO export
7400 @cindex XOXO export
7402 Org mode contains an exporter that produces XOXO-style output.
7403 Currently, this exporter only handles the general outline structure and
7404 does not interpret any additional Org mode features.
7406 @table @kbd
7407 @kindex C-c C-e x
7408 @item C-c C-e x
7409 Export as XOXO file @file{myfile.html}.
7410 @kindex C-c C-e v
7411 @item C-c C-e v x
7412 Export only the visible part of the document.
7413 @end table
7415 @node iCalendar export,  , XOXO export, Exporting
7416 @section iCalendar export
7417 @cindex iCalendar export
7419 Some people like to use Org mode for keeping track of projects, but
7420 still prefer a standard calendar application for anniversaries and
7421 appointments.  In this case it can be useful to have deadlines and
7422 other time-stamped items in Org files show up in the calendar
7423 application.  Org mode can export calendar information in the standard
7424 iCalendar format.  If you also want to have TODO entries included in the
7425 export, configure the variable @code{org-icalendar-include-todo}.
7427 @table @kbd
7428 @kindex C-c C-e i
7429 @item C-c C-e i
7430 Create iCalendar entries for the current file and store them in the same
7431 directory, using a file extension @file{.ics}.
7432 @kindex C-c C-e I
7433 @item C-c C-e I
7434 Like @kbd{C-c C-e i}, but do this for all files in
7435 @code{org-agenda-files}.  For each of these files, a separate iCalendar
7436 file will be written.
7437 @kindex C-c C-e c
7438 @item C-c C-e c
7439 Create a single large iCalendar file from all files in
7440 @code{org-agenda-files} and write it to the file given by
7441 @code{org-combined-agenda-icalendar-file}.
7442 @end table
7444 The export will honor SUMMARY, DESCRIPTION and LOCATION properties if
7445 the selected entries have them.  If not, the summary will be derived
7446 from the headline, and the description from the body (limited to
7447 @code{org-icalendar-include-body} characters).
7449 How this calendar is best read and updated, depends on the application
7450 you are using.  The FAQ covers this issue.
7452 @node Publishing, Miscellaneous, Exporting, Top
7453 @chapter Publishing
7454 @cindex publishing
7456 Org includes@footnote{@file{org-publish.el} is not distributed with
7457 Emacs 21, if you are still using Emacs 21, you need you need to download
7458 this file separately.} a publishing management system that allows you to
7459 configure automatic HTML conversion of @emph{projects} composed of
7460 interlinked org files.  This system is called @emph{org-publish}.  You can
7461 also configure org-publish to automatically upload your exported HTML
7462 pages and related attachments, such as images and source code files, to
7463 a web server. Org-publish turns Org into a web-site authoring tool.
7465 You can also use Org-publish to convert files into La@TeX{}, or even
7466 combine HTML and La@TeX{} conversion so that files are available in both
7467 formats on the server@footnote{Since La@TeX{} files on a server are not
7468 that helpful, you surely want to perform further conversion on them --
7469 e.g. convert them to @code{PDF} format.}.
7471 Org-publish has been contributed to Org by David O'Toole.
7473 @menu
7474 * Configuration::               Defining projects
7475 * Sample configuration::        Example projects
7476 * Triggering publication::      Publication commands
7477 @end menu
7479 @node Configuration, Sample configuration, Publishing, Publishing
7480 @section Configuration
7482 Publishing needs significant configuration to specify files, destination
7483 and many other properties of a project.
7485 @menu
7486 * Project alist::               The central configuration variable
7487 * Sources and destinations::    From here to there
7488 * Selecting files::             What files are part of the project?
7489 * Publishing action::           Setting the function doing the publishing
7490 * Publishing options::          Tweaking HTML export
7491 * Publishing links::            Which links keep working after publishing?
7492 * Project page index::          Publishing a list of project files
7493 @end menu
7495 @node Project alist, Sources and destinations, Configuration, Configuration
7496 @subsection The variable @code{org-publish-project-alist}
7497 @cindex org-publish-project-alist
7498 @cindex projects, for publishing
7500 Org-publish is configured almost entirely through setting the value of
7501 one variable, called @code{org-publish-project-alist}.
7502 Each element of the list configures one project, and may be in one of
7503 the two following forms:
7505 @lisp
7506 ("project-name" :property value :property value ...)
7508 @r{or}
7510 ("project-name" :components ("project-name" "project-name" ...))
7512 @end lisp
7514 In both cases, projects are configured by specifying property values.
7515 A project defines the set of files that will be published, as well as
7516 the publishing configuration to use when publishing those files.  When
7517 a project takes the second form listed above, the individual members
7518 of the ``components'' property are taken to be components of the
7519 project, which group together files requiring different publishing
7520 options. When you publish such a ``meta-project'' all the components
7521 will also publish.
7523 @node Sources and destinations, Selecting files, Project alist, Configuration
7524 @subsection Sources and destinations for files
7525 @cindex directories, for publishing
7527 Most properties are optional, but some should always be set. In
7528 particular, org-publish needs to know where to look for source files,
7529 and where to put published files.
7531 @multitable @columnfractions 0.3 0.7
7532 @item @code{:base-directory}
7533 @tab Directory containing publishing source files
7534 @item @code{:publishing-directory}
7535 @tab Directory (possibly remote) where output files will be published.
7536 @item @code{:preparation-function}
7537 @tab Function called before starting publishing process, for example to
7538 run @code{make} for updating files to be published.
7539 @end multitable
7540 @noindent
7542 @node Selecting files, Publishing action, Sources and destinations, Configuration
7543 @subsection Selecting files
7544 @cindex files, selecting for publishing
7546 By default, all files with extension @file{.org} in the base directory
7547 are considered part of the project.  This can be modified by setting the
7548 properties
7549 @multitable @columnfractions 0.25 0.75
7550 @item @code{:base-extension}
7551 @tab Extension (without the dot!) of source files.  This actually is a
7552 regular expression.
7554 @item @code{:exclude}
7555 @tab Regular expression to match file names that should not be
7556 published, even though they have been selected on the basis of their
7557 extension.
7559 @item @code{:include}
7560 @tab List of files to be included regardless of @code{:base-extension}
7561 and @code{:exclude}.
7562 @end multitable
7564 @node Publishing action, Publishing options, Selecting files, Configuration
7565 @subsection Publishing action
7566 @cindex action, for publishing
7568 Publishing means that a file is copied to the destination directory and
7569 possibly transformed in the process.  The default transformation is to
7570 export Org files as HTML files, and this is done by the function
7571 @code{org-publish-org-to-html} which calls the HTML exporter
7572 (@pxref{HTML export}). But you also can publish your files in La@TeX{} by
7573 using the function @code{org-publish-org-to-latex} instead. Other files
7574 like images only need to be copied to the publishing destination. For
7575 non-Org files, you need to specify the publishing function.
7578 @multitable @columnfractions 0.3 0.7
7579 @item @code{:publishing-function}
7580 @tab Function executing the publication of a file.  This may also be a
7581 list of functions, which will all be called in turn.
7582 @end multitable
7584 The function must accept two arguments: a property list containing at
7585 least a @code{:publishing-directory} property, and the name of the file
7586 to be published.  It should take the specified file, make the necessary
7587 transformation (if any) and place the result into the destination folder.
7588 You can write your own publishing function, but @code{org-publish}
7589 provides one for attachments (files that only need to be copied):
7590 @code{org-publish-attachment}.
7592 @node Publishing options, Publishing links, Publishing action, Configuration
7593 @subsection Options for the HTML/LaTeX exporters
7594 @cindex options, for publishing
7596 The property list can be used to set many export options for the HTML
7597 and La@TeX{} exporters.  In most cases, these properties correspond to user
7598 variables in Org.  The table below lists these properties along
7599 with the variable they belong to.  See the documentation string for the
7600 respective variable for details.
7602 @multitable @columnfractions 0.3 0.7
7603 @item @code{:language}              @tab @code{org-export-default-language}
7604 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
7605 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
7606 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
7607 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
7608 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
7609 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
7610 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
7611 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
7612 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
7613 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
7614 @item @code{:timestamps}           .@tab @code{org-export-with-timestamps}
7615 @item @code{:tags}                 .@tab @code{org-export-with-tags}
7616 @item @code{:tables}                @tab @code{org-export-with-tables}
7617 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
7618 @item @code{:style}                 @tab @code{org-export-html-style}
7619 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
7620 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
7621 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
7622 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
7623 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
7624 @item @code{:preamble}              @tab @code{org-export-html-preamble}
7625 @item @code{:postamble}             @tab @code{org-export-html-postamble}
7626 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
7627 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
7628 @item @code{:author}                @tab @code{user-full-name}
7629 @item @code{:email}                 @tab @code{user-mail-address}
7630 @end multitable
7632 If you use several email addresses, separate them by a semi-column.
7634 Most of the @code{org-export-with-*} variables have the same effect in
7635 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
7636 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
7637 La@TeX{} export.
7639 When a property is given a value in @code{org-publish-project-alist},
7640 its setting overrides the value of the corresponding user variable (if
7641 any) during publishing.  Options set within a file (@pxref{Export
7642 options}), however, override everything.
7644 @node Publishing links, Project page index, Publishing options, Configuration
7645 @subsection Links between published files
7646 @cindex links, publishing
7648 To create a link from one Org file to another, you would use
7649 something like @samp{[[file:foo.org][The foo]]} or simply
7650 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
7651 becomes a link to @file{foo.html}.  In this way, you can interlink the
7652 pages of your "org web" project and the links will work as expected when
7653 you publish them to HTML.
7655 You may also link to related files, such as images. Provided you are
7656 careful with relative pathnames, and provided you have also configured
7657 @code{org-publish} to upload the related files, these links will work
7658 too. @ref{Complex example} for an example of this usage.
7660 Sometime an Org file to be published may contain links that are
7661 only valid in your production environment, but not in the publishing
7662 location.  In this case, use the property
7664 @multitable @columnfractions 0.4 0.6
7665 @item @code{:link-validation-function}
7666 @tab Function to validate links
7667 @end multitable
7669 @noindent
7670 to define a function for checking link validity.  This function must
7671 accept two arguments, the file name and a directory relative to which
7672 the file name is interpreted in the production environment.  If this
7673 function returns @code{nil}, then the HTML generator will only insert a
7674 description into the HTML file, but no link.  One option for this
7675 function is @code{org-publish-validate-link} which checks if the given
7676 file is part of any project in @code{org-publish-project-alist}.
7678 @node Project page index,  , Publishing links, Configuration
7679 @subsection Project page index
7680 @cindex index, of published pages
7682 The following properties may be used to control publishing of an
7683 index of files or summary page for a given project.
7685 @multitable @columnfractions 0.25 0.75
7686 @item @code{:auto-index}
7687 @tab When non-nil, publish an index during org-publish-current-project or
7688 org-publish-all.
7690 @item @code{:index-filename}
7691 @tab Filename for output of index. Defaults to @file{index.org} (which
7692 becomes @file{index.html}).
7694 @item @code{:index-title}
7695 @tab Title of index page. Defaults to name of file.
7697 @item @code{:index-function}
7698 @tab Plug-in function to use for generation of index.
7699 Defaults to @code{org-publish-org-index}, which generates a plain list
7700 of links to all files in the project.
7701 @end multitable
7703 @node Sample configuration, Triggering publication, Configuration, Publishing
7704 @section Sample configuration
7706 Below we provide two example configurations.  The first one is a simple
7707 project publishing only a set of Org files.  The second example is
7708 more complex, with a multi-component project.
7710 @menu
7711 * Simple example::              One-component publishing
7712 * Complex example::             A multi-component publishing example
7713 @end menu
7715 @node Simple example, Complex example, Sample configuration, Sample configuration
7716 @subsection Example: simple publishing configuration
7718 This example publishes a set of Org files to the @file{public_html}
7719 directory on the local machine.
7721 @lisp
7722 (setq org-publish-project-alist
7723       '(("org"
7724          :base-directory "~/org/"
7725          :publishing-directory "~/public_html"
7726          :section-numbers nil
7727          :table-of-contents nil
7728          :style "<link rel=stylesheet
7729                 href=\"../other/mystyle.css\"
7730                 type=\"text/css\">")))
7731 @end lisp
7733 @node Complex example,  , Simple example, Sample configuration
7734 @subsection Example: complex publishing configuration
7736 This more complicated example publishes an entire website, including
7737 org files converted to HTML, image files, emacs lisp source code, and
7738 style sheets. The publishing-directory is remote and private files are
7739 excluded.
7741 To ensure that links are preserved, care should be taken to replicate
7742 your directory structure on the web server, and to use relative file
7743 paths. For example, if your org files are kept in @file{~/org} and your
7744 publishable images in @file{~/images}, you'd link to an image with
7746 @example
7747 file:../images/myimage.png
7748 @end example
7750 On the web server, the relative path to the image should be the
7751 same. You can accomplish this by setting up an "images" folder in the
7752 right place on the web server, and publishing images to it.
7754 @lisp
7755 (setq org-publish-project-alist
7756       '(("orgfiles"
7757           :base-directory "~/org/"
7758           :base-extension "org"
7759           :publishing-directory "/ssh:user@@host:~/html/notebook/"
7760           :publishing-function org-publish-org-to-html
7761           :exclude "PrivatePage.org"   ;; regexp
7762           :headline-levels 3
7763           :section-numbers nil
7764           :table-of-contents nil
7765           :style "<link rel=stylesheet
7766                   href=\"../other/mystyle.css\" type=\"text/css\">"
7767           :auto-preamble t
7768           :auto-postamble nil)
7770          ("images"
7771           :base-directory "~/images/"
7772           :base-extension "jpg\\|gif\\|png"
7773           :publishing-directory "/ssh:user@@host:~/html/images/"
7774           :publishing-function org-publish-attachment)
7776          ("other"
7777           :base-directory "~/other/"
7778           :base-extension "css\\|el"
7779           :publishing-directory "/ssh:user@@host:~/html/other/"
7780           :publishing-function org-publish-attachment)
7781          ("website" :components ("orgfiles" "images" "other"))))
7782 @end lisp
7784 @node Triggering publication,  , Sample configuration, Publishing
7785 @section Triggering publication
7787 Once org-publish is properly configured, you can publish with the
7788 following functions:
7790 @table @kbd
7791 @item C-c C-e C
7792 Prompt for a specific project and publish all files that belong to it.
7793 @item C-c C-e P
7794 Publish the project containing the current file.
7795 @item C-c C-e F
7796 Publish only the current file.
7797 @item C-c C-e A
7798 Publish all projects.
7799 @end table
7801 Org uses timestamps to track when a file has changed. The above
7802 functions normally only publish changed files. You can override this and
7803 force publishing of all files by giving a prefix argument.
7805 @node Miscellaneous, Extensions and Hacking, Publishing, Top
7806 @chapter Miscellaneous
7808 @menu
7809 * Completion::                  M-TAB knows what you need
7810 * Customization::               Adapting Org to your taste
7811 * In-buffer settings::          Overview of the #+KEYWORDS
7812 * The very busy C-c C-c key::   When in doubt, press C-c C-c
7813 * Clean view::                  Getting rid of leading stars in the outline
7814 * TTY keys::                    Using Org on a tty
7815 * Interaction::                 Other Emacs packages
7816 * Bugs::                        Things which do not work perfectly
7817 @end menu
7819 @node Completion, Customization, Miscellaneous, Miscellaneous
7820 @section Completion
7821 @cindex completion, of @TeX{} symbols
7822 @cindex completion, of TODO keywords
7823 @cindex completion, of dictionary words
7824 @cindex completion, of option keywords
7825 @cindex completion, of tags
7826 @cindex completion, of property keys
7827 @cindex completion, of link abbreviations
7828 @cindex @TeX{} symbol completion
7829 @cindex TODO keywords completion
7830 @cindex dictionary word completion
7831 @cindex option keyword completion
7832 @cindex tag completion
7833 @cindex link abbreviations, completion of
7835 Org supports in-buffer completion.  This type of completion does
7836 not make use of the minibuffer.  You simply type a few letters into
7837 the buffer and use the key to complete text right there.
7839 @table @kbd
7840 @kindex M-@key{TAB}
7841 @item M-@key{TAB}
7842 Complete word at point
7843 @itemize @bullet
7844 @item
7845 At the beginning of a headline, complete TODO keywords.
7846 @item
7847 After @samp{\}, complete @TeX{} symbols supported by the exporter.
7848 @item
7849 After @samp{*}, complete headlines in the current buffer so that they
7850 can be used in search links like @samp{[[*find this headline]]}.
7851 @item
7852 After @samp{:} in a headline, complete tags.  The list of tags is taken
7853 from the variable @code{org-tag-alist} (possibly set through the
7854 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
7855 dynamically from all tags used in the current buffer.
7856 @item
7857 After @samp{:} and not in a headline, complete property keys.  The list
7858 of keys is constructed dynamically from all keys used in the current
7859 buffer.
7860 @item
7861 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
7862 @item
7863 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
7864 @samp{OPTIONS} which set file-specific options for Org mode.  When the
7865 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
7866 will insert example settings for this keyword.
7867 @item
7868 In the line after @samp{#+STARTUP: }, complete startup keywords,
7869 i.e. valid keys for this line.
7870 @item
7871 Elsewhere, complete dictionary words using Ispell.
7872 @end itemize
7873 @end table
7875 @node Customization, In-buffer settings, Completion, Miscellaneous
7876 @section Customization
7877 @cindex customization
7878 @cindex options, for customization
7879 @cindex variables, for customization
7881 There are more than 180 variables that can be used to customize
7882 Org.  For the sake of compactness of the manual, I am not
7883 describing the variables here.  A structured overview of customization
7884 variables is available with @kbd{M-x org-customize}.  Or select
7885 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
7886 settings can also be activated on a per-file basis, by putting special
7887 lines into the buffer (@pxref{In-buffer settings}).
7889 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
7890 @section Summary of in-buffer settings
7891 @cindex in-buffer settings
7892 @cindex special keywords
7894 Org mode uses special lines in the buffer to define settings on a
7895 per-file basis.  These lines start with a @samp{#+} followed by a
7896 keyword, a colon, and then individual words defining a setting.  Several
7897 setting words can be in the same line, but you can also have multiple
7898 lines for the keyword.  While these settings are described throughout
7899 the manual, here is a summary.  After changing any of those lines in the
7900 buffer, press @kbd{C-c C-c} with the cursor still in the line to
7901 activate the changes immediately.  Otherwise they become effective only
7902 when the file is visited again in a new Emacs session.
7904 @table @kbd
7905 @item #+ARCHIVE: %s_done::
7906 This line sets the archive location for the agenda file.  It applies for
7907 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
7908 of the file.  The first such line also applies to any entries before it.
7909 The corresponding variable is @code{org-archive-location}.
7910 @item #+CATEGORY:
7911 This line sets the category for the agenda file.  The category applies
7912 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
7913 end of the file.  The first such line also applies to any entries before it.
7914 @item #+COLUMNS: %25ITEM .....
7915 Set the default format for columns view.  This format applies when
7916 columns view is invoked in location where no @code{COLUMNS} property
7917 applies.
7918 @item #+CONSTANTS: name1=value1 ...
7919 Set file-local values for constants to be used in table formulas.  This
7920 line set the local variable @code{org-table-formula-constants-local}.
7921 The global version of this variable is
7922 @code{org-table-formula-constants}.
7923 @item #+DRAWERS: NAME1 .....
7924 Set the file-local set of drawers.  The corresponding global variable is
7925 @code{org-drawers}.
7926 @item #+LINK:  linkword replace
7927 These lines (several are allowed) specify link abbreviations.
7928 @xref{Link abbreviations}.  The corresponding variable is
7929 @code{org-link-abbrev-alist}.
7930 @item #+PRIORITIES: highest lowest default
7931 This line sets the limits and the default for the priorities.  All three
7932 must be either letters A-Z or numbers 0-9.  The highest priority must
7933 have a lower ASCII number that the lowest priority.
7934 @item #+PROPERTY: Property_Name Value
7935 This line sets a default inheritance value for entries in the current
7936 buffer, most useful for specifying the allowed values of a property.
7937 @item #+SETUPFILE: file
7938 This line defines a file that holds more in-buffer setup.  Normally this is
7939 entirely ignored.  Only when the buffer is parsed for option-setting lines
7940 (i.e. when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
7941 settings line, or when exporting), then the contents of this file are parsed
7942 as if they had been included in the buffer.  In particlar, the file can be
7943 any other Org mode file with internal setup.
7944 @item #+STARTUP:
7945 This line sets options to be used at startup of Org mode, when an
7946 Org file is being visited.  The first set of options deals with the
7947 initial visibility of the outline tree.  The corresponding variable for
7948 global default settings is @code{org-startup-folded}, with a default
7949 value @code{t}, which means @code{overview}.
7950 @cindex @code{overview}, STARTUP keyword
7951 @cindex @code{content}, STARTUP keyword
7952 @cindex @code{showall}, STARTUP keyword
7953 @example
7954 overview   @r{top-level headlines only}
7955 content    @r{all headlines}
7956 showall    @r{no folding at all, show everything}
7957 @end example
7958 Then there are options for aligning tables upon visiting a file.  This
7959 is useful in files containing narrowed table columns.  The corresponding
7960 variable is @code{org-startup-align-all-tables}, with a default value
7961 @code{nil}.
7962 @cindex @code{align}, STARTUP keyword
7963 @cindex @code{noalign}, STARTUP keyword
7964 @example
7965 align      @r{align all tables}
7966 noalign    @r{don't align tables on startup}
7967 @end example
7968 Logging closing and reinstating TODO items, and clock intervals
7969 (variables @code{org-log-done}, @code{org-log-note-clock-out}, and
7970 @code{org-log-repeat}) can be configured using these options.
7971 @cindex @code{logdone}, STARTUP keyword
7972 @cindex @code{lognotedone}, STARTUP keyword
7973 @cindex @code{nologdone}, STARTUP keyword
7974 @cindex @code{lognoteclock-out}, STARTUP keyword
7975 @cindex @code{nolognoteclock-out}, STARTUP keyword
7976 @cindex @code{logrepeat}, STARTUP keyword
7977 @cindex @code{lognoterepeat}, STARTUP keyword
7978 @cindex @code{nologrepeat}, STARTUP keyword
7979 @example
7980 logdone            @r{record a timestamp when an item is marked DONE}
7981 lognotedone        @r{record timestamp and a note when DONE}
7982 nologdone          @r{don't record when items are marked DONE}
7983 logrepeat          @r{record a time when reinstating a repeating item}
7984 lognoterepeat      @r{record a note when reinstating a repeating item}
7985 nologrepeat        @r{do not record when reinstating repeating item}
7986 lognoteclock-out   @r{record a note when clocking out}
7987 nolognoteclock-out @r{don't record a note when clocking out}
7988 @end example
7989 Here are the options for hiding leading stars in outline headings.  The
7990 corresponding variables are @code{org-hide-leading-stars} and
7991 @code{org-odd-levels-only}, both with a default setting @code{nil}
7992 (meaning @code{showstars} and @code{oddeven}).
7993 @cindex @code{hidestars}, STARTUP keyword
7994 @cindex @code{showstars}, STARTUP keyword
7995 @cindex @code{odd}, STARTUP keyword
7996 @cindex @code{even}, STARTUP keyword
7997 @example
7998 hidestars  @r{make all but one of the stars starting a headline invisible.}
7999 showstars  @r{show all stars starting a headline}
8000 odd        @r{allow only odd outline levels (1,3,...)}
8001 oddeven    @r{allow all outline levels}
8002 @end example
8003 To turn on custom format overlays over time stamps (variables
8004 @code{org-put-time-stamp-overlays} and
8005 @code{org-time-stamp-overlay-formats}), use
8006 @cindex @code{customtime}, STARTUP keyword
8007 @example
8008 customtime @r{overlay custom time format}
8009 @end example
8010 The following options influence the table spreadsheet (variable
8011 @code{constants-unit-system}).
8012 @cindex @code{constcgs}, STARTUP keyword
8013 @cindex @code{constSI}, STARTUP keyword
8014 @example
8015 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
8016 constSI    @r{@file{constants.el} should use the SI unit system}
8017 @end example
8018 @item #+TAGS:  TAG1(c1) TAG2(c2)
8019 These lines (several such lines are allowed) specify the valid tags in
8020 this file, and (potentially) the corresponding @emph{fast tag selection}
8021 keys.  The corresponding variable is @code{org-tag-alist}.
8022 @item #+TBLFM:
8023 This line contains the formulas for the table directly above the line.
8024 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:
8025 These lines provide settings for exporting files.  For more details see
8026 @ref{Export options}.
8027 @item #+SEQ_TODO:   #+TYP_TODO:
8028 These lines set the TODO keywords and their interpretation in the
8029 current file.  The corresponding variables are @code{org-todo-keywords}
8030 and @code{org-todo-interpretation}.
8031 @end table
8033 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
8034 @section The very busy C-c C-c key
8035 @kindex C-c C-c
8036 @cindex C-c C-c, overview
8038 The key @kbd{C-c C-c} has many purposes in Org, which are all
8039 mentioned scattered throughout this manual.  One specific function of
8040 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
8041 other circumstances it means something like @emph{Hey Org, look
8042 here and update according to what you see here}.  Here is a summary of
8043 what this means in different contexts.
8045 @itemize @minus
8046 @item
8047 If there are highlights in the buffer from the creation of a sparse
8048 tree, or from clock display, remove these highlights.
8049 @item
8050 If the cursor is in one of the special @code{#+KEYWORD} lines, this
8051 triggers scanning the buffer for these lines and updating the
8052 information.
8053 @item
8054 If the cursor is inside a table, realign the table.  This command
8055 works even if the automatic table editor has been turned off.
8056 @item
8057 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
8058 the entire table.
8059 @item
8060 If the cursor is inside a table created by the @file{table.el} package,
8061 activate that table.
8062 @item
8063 If the current buffer is a remember buffer, close the note and file it.
8064 With a prefix argument, file it, without further interaction, to the
8065 default location.
8066 @item
8067 If the cursor is on a @code{<<<target>>>}, update radio targets and
8068 corresponding links in this buffer.
8069 @item
8070 If the cursor is in a property line or at the start or end of a property
8071 drawer, offer property commands.
8072 @item
8073 If the cursor is in a plain list item with a checkbox, toggle the status
8074 of the checkbox.
8075 @item
8076 If the cursor is on a numbered item in a plain list, renumber the
8077 ordered list.
8078 @item
8079 If the cursor is on the @code{#+BEGIN} line of a dynamical block, the
8080 block is updated.
8081 @end itemize
8083 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
8084 @section A cleaner outline view
8085 @cindex hiding leading stars
8086 @cindex clean outline view
8088 Some people find it noisy and distracting that the Org headlines
8089 are starting with a potentially large number of stars.  For example
8090 the tree from @ref{Headlines}:
8092 @example
8093 * Top level headline
8094 ** Second level
8095 *** 3rd level
8096     some text
8097 *** 3rd level
8098     more text
8099 * Another top level headline
8100 @end example
8102 @noindent
8103 Unfortunately this is deeply ingrained into the code of Org and
8104 cannot be easily changed.  You can, however, modify the display in such
8105 a way that all leading stars become invisible and the outline more easy
8106 to read.  To do this, customize the variable
8107 @code{org-hide-leading-stars} like this:
8109 @lisp
8110 (setq org-hide-leading-stars t)
8111 @end lisp
8113 @noindent
8114 or change this on a per-file basis with one of the lines (anywhere in
8115 the buffer)
8117 @example
8118 #+STARTUP: showstars
8119 #+STARTUP: hidestars
8120 @end example
8122 @noindent
8123 Press @kbd{C-c C-c} with the cursor in a @samp{STARTUP} line to activate
8124 the modifications.
8126 With stars hidden, the tree becomes:
8128 @example
8129 * Top level headline
8130  * Second level
8131   * 3rd level
8132     some text
8133   * 3rd level
8134     more text
8135 * Another top level headline
8136 @end example
8138 @noindent
8139 Note that the leading stars are not truly replaced by whitespace, they
8140 are only fontified with the face @code{org-hide} that uses the
8141 background color as font color.  If you are not using either white or
8142 black background, you may have to customize this face to get the wanted
8143 effect.  Another possibility is to set this font such that the extra
8144 stars are @i{almost} invisible, for example using the color
8145 @code{grey90} on a white background.
8147 Things become cleaner still if you skip all the even levels and use only
8148 odd levels 1, 3, 5..., effectively adding two stars to go from one
8149 outline level to the next:
8151 @example
8152 * Top level headline
8153   * Second level
8154     * 3rd level
8155       some text
8156     * 3rd level
8157       more text
8158 * Another top level headline
8159 @end example
8161 @noindent
8162 In order to make the structure editing and export commands handle this
8163 convention correctly, use
8165 @lisp
8166 (setq org-odd-levels-only t)
8167 @end lisp
8169 @noindent
8170 or set this on a per-file basis with one of the following lines (don't
8171 forget to press @kbd{C-c C-c} with the cursor in the startup line to
8172 activate changes immediately).
8174 @example
8175 #+STARTUP: odd
8176 #+STARTUP: oddeven
8177 @end example
8179 You can convert an Org file from single-star-per-level to the
8180 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
8181 RET} in that file.  The reverse operation is @kbd{M-x
8182 org-convert-to-oddeven-levels}.
8184 @node TTY keys, Interaction, Clean view, Miscellaneous
8185 @section Using Org on a tty
8186 @cindex tty key bindings
8188 Because Org contains a large number of commands, by default much of
8189 Org's core commands are bound to keys that are generally not
8190 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
8191 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
8192 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
8193 these commands on a tty when special keys are unavailable, the following
8194 alternative bindings can be used.  The tty bindings below will likely be
8195 more cumbersome; you may find for some of the bindings below that a
8196 customized work-around suits you better.  For example, changing a time
8197 stamp is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
8198 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
8200 @multitable @columnfractions 0.15 0.2 0.2
8201 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
8202 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
8203 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
8204 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
8205 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
8206 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
8207 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
8208 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
8209 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
8210 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
8211 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
8212 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
8213 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
8214 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
8215 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
8216 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
8217 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
8218 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
8219 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
8220 @end multitable
8222 @node Interaction, Bugs, TTY keys, Miscellaneous
8223 @section Interaction with other packages
8224 @cindex packages, interaction with other
8225 Org lives in the world of GNU Emacs and interacts in various ways
8226 with other code out there.
8228 @menu
8229 * Cooperation::                 Packages Org cooperates with
8230 * Conflicts::                   Packages that lead to conflicts
8231 @end menu
8233 @node Cooperation, Conflicts, Interaction, Interaction
8234 @subsection Packages that Org cooperates with
8236 @table @asis
8237 @cindex @file{calc.el}
8238 @item @file{calc.el} by Dave Gillespie
8239 Org uses the Calc package for implementing spreadsheet
8240 functionality in its tables (@pxref{The spreadsheet}).  Org
8241 checks for the availability of Calc by looking for the function
8242 @code{calc-eval} which should be autoloaded in your setup if Calc has
8243 been installed properly.  As of Emacs 22, Calc is part of the Emacs
8244 distribution.  Another possibility for interaction between the two
8245 packages is using Calc for embedded calculations. @xref{Embedded Mode,
8246 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
8247 @cindex @file{constants.el}
8248 @item @file{constants.el} by Carsten Dominik
8249 In a table formula (@pxref{The spreadsheet}), it is possible to use
8250 names for natural constants or units.  Instead of defining your own
8251 constants in the variable @code{org-table-formula-constants}, install
8252 the @file{constants} package which defines a large number of constants
8253 and units, and lets you use unit prefixes like @samp{M} for
8254 @samp{Mega} etc.  You will need version 2.0 of this package, available
8255 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
8256 the function @code{constants-get}, which has to be autoloaded in your
8257 setup.  See the installation instructions in the file
8258 @file{constants.el}.
8259 @item @file{cdlatex.el} by Carsten Dominik
8260 @cindex @file{cdlatex.el}
8261 Org mode can make use of the CDLaTeX package to efficiently enter
8262 La@TeX{} fragments into Org files. See @ref{CDLaTeX mode}.
8263 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
8264 @cindex @file{imenu.el}
8265 Imenu allows menu access to an index of items in a file.  Org mode
8266 supports Imenu - all you need to do to get the index is the following:
8267 @lisp
8268 (add-hook 'org-mode-hook
8269           (lambda () (imenu-add-to-menubar "Imenu")))
8270 @end lisp
8271 By default the index is two levels deep - you can modify the depth using
8272 the option @code{org-imenu-depth}.
8273 @item @file{remember.el} by John Wiegley
8274 @cindex @file{remember.el}
8275 Org cooperates with remember, see @ref{Remember}.
8276 @file{Remember.el} is not part of Emacs, find it on the web.
8277 @item @file{speedbar.el} by Eric M. Ludlam
8278 @cindex @file{speedbar.el}
8279 Speedbar is a package that creates a special frame displaying files and
8280 index items in files.  Org mode supports Speedbar and allows you to
8281 drill into Org files directly from the Speedbar.  It also allows to
8282 restrict the scope of agenda commands to a file or a subtree by using
8283 the command @kbd{<} in the Speedbar frame.
8284 @cindex @file{table.el}
8285 @item @file{table.el} by Takaaki Ota
8286 @kindex C-c C-c
8287 @cindex table editor, @file{table.el}
8288 @cindex @file{table.el}
8290 Complex ASCII tables with automatic line wrapping, column- and
8291 row-spanning, and alignment can be created using the Emacs table
8292 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
8293 and also part of Emacs 22).
8294 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
8295 will call @command{table-recognize-table} and move the cursor into the
8296 table.  Inside a table, the keymap of Org mode is inactive.  In order
8297 to execute Org mode-related commands, leave the table.
8299 @table @kbd
8300 @kindex C-c C-c
8301 @item C-c C-c
8302 Recognize @file{table.el} table.  Works when the cursor is in a
8303 table.el table.
8305 @kindex C-c ~
8306 @item C-c ~
8307 Insert a table.el table.  If there is already a table at point, this
8308 command converts it between the table.el format and the Org mode
8309 format.  See the documentation string of the command
8310 @code{org-convert-table} for the restrictions under which this is
8311 possible.
8312 @end table
8313 @file{table.el} is part of Emacs 22.
8314 @cindex @file{footnote.el}
8315 @item @file{footnote.el} by Steven L. Baur
8316 Org mode recognizes numerical footnotes as provided by this package
8317 (@pxref{Footnotes}).
8318 @end table
8320 @node Conflicts,  , Cooperation, Interaction
8321 @subsection Packages that lead to conflicts with Org mode
8323 @table @asis
8325 @cindex @file{allout.el}
8326 @item @file{allout.el} by Ken Manheimer
8327 Startup of Org may fail with the error message
8328 @code{(wrong-type-argument keymapp nil)} when there is an outdated
8329 version @file{allout.el} on the load path, for example the version
8330 distributed with Emacs 21.x.  Upgrade to Emacs 22 and this problem will
8331 disappear.  If for some reason you cannot do this, make sure that org.el
8332 is loaded @emph{before} @file{allout.el}, for example by putting
8333 @code{(require 'org)} early enough into your @file{.emacs} file.
8335 @cindex @file{CUA.el}
8336 @item @file{CUA.el} by Kim. F. Storm
8337 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by
8338 CUA mode (as well as pc-select-mode and s-region-mode) to select and
8339 extend the region.  If you want to use one of these packages along with
8340 Org, configure the variable @code{org-replace-disputed-keys}.  When
8341 set, Org will move the following key bindings in Org files, and
8342 in the agenda buffer (but not during date selection).
8344 @example
8345 S-UP    -> M-p             S-DOWN  -> M-n
8346 S-LEFT  -> M--             S-RIGHT -> M-+
8347 @end example
8349 Yes, these are unfortunately more difficult to remember.  If you want
8350 to have other replacement keys, look at the variable
8351 @code{org-disputed-keys}.
8352 @item @file{windmove.el} by Hovav Shacham
8353 @cindex @file{windmove.el}
8354 Also this package uses the @kbd{S-<cursor>} keys, so everything written
8355 in the paragraph above about CUA mode also applies here.
8357 @cindex @file{footnote.el}
8358 @item @file{footnote.el} by Steven L. Baur
8359 Org supports the syntax of the footnote package, but only the
8360 numerical footnote markers.  Also, the default key for footnote
8361 commands, @kbd{C-c !} is already used by Org.  You could use the
8362 variable @code{footnote-prefix} to switch footnotes commands to another
8363 key.  Or, you could use @code{org-replace-disputed-keys} and
8364 @code{org-disputed-keys} to change the settings in Org.
8366 @end table
8369 @node Bugs,  , Interaction, Miscellaneous
8370 @section Bugs
8371 @cindex bugs
8373 Here is a list of things that should work differently, but which I
8374 have found too hard to fix.
8376 @itemize @bullet
8377 @item
8378 If a table field starts with a link, and if the corresponding table
8379 column is narrowed (@pxref{Narrow columns}) to a width too small to
8380 display the link, the field would look entirely empty even though it is
8381 not.  To prevent this, Org throws an error.  The work-around is to
8382 make the column wide enough to fit the link, or to add some text (at
8383 least 2 characters) before the link in the same field.
8384 @item
8385 Narrowing table columns does not work on XEmacs, because the
8386 @code{format} function does not transport text properties.
8387 @item
8388 Text in an entry protected with the @samp{QUOTE} keyword should not
8389 autowrap.
8390 @item
8391 When the application called by @kbd{C-c C-o} to open a file link fails
8392 (for example because the application does not exist or refuses to open
8393 the file), it does so silently.  No error message is displayed.
8394 @item
8395 Recalculating a table line applies the formulas from left to right.
8396 If a formula uses @emph{calculated} fields further down the row,
8397 multiple recalculation may be needed to get all fields consistent.  You
8398 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
8399 recalculate until convergence.
8400 @item
8401 A single letter cannot be made bold, for example @samp{*a*}.
8402 @item
8403 The exporters work well, but could be made more efficient.
8404 @end itemize
8407 @node Extensions and Hacking, History and Acknowledgments, Miscellaneous, Top
8408 @appendix Extensions, Hooks and Hacking
8410 This appendix lists extensions for Org written by other authors.
8411 It also covers some aspects where users can extend the functionality of
8412 Org.
8414 @menu
8415 * Extensions::                  Existing 3rd-party extensions
8416 * Adding hyperlink types::      New custom link types
8417 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
8418 * Dynamic blocks::              Automatically filled blocks
8419 * Special agenda views::        Customized views
8420 * Using the property API::      Writing programs that use entry properties
8421 @end menu
8423 @node Extensions, Adding hyperlink types, Extensions and Hacking, Extensions and Hacking
8424 @section Third-party extensions for Org
8425 @cindex extension, third-party
8427 There are lots of extensions that have been written by other people.  Most of
8428 them have either been integrated into Org by now, or they can be found in the
8429 Org distribution, in the @file{contrib} directory.  The list has gotten too
8430 long to cover in any detail here, but there is a seaparate manual for these
8431 extensions.
8433 @node Adding hyperlink types, Tables in arbitrary syntax, Extensions, Extensions and Hacking
8434 @section Adding hyperlink types
8435 @cindex hyperlinks, adding new types
8437 Org has a large number of hyperlink types built-in
8438 (@pxref{Hyperlinks}).  If you would like to add new link types, it
8439 provides an interface for doing so.  Lets look at an example file
8440 @file{org-man.el} that will add support for creating links like
8441 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
8442 emacs:
8444 @lisp
8445 ;;; org-man.el - Support for links to manpages in Org
8447 (require 'org)
8449 (org-add-link-type "man" 'org-man-open)
8450 (add-hook 'org-store-link-functions 'org-man-store-link)
8452 (defcustom org-man-command 'man
8453   "The Emacs command to be used to display a man page."
8454   :group 'org-link
8455   :type '(choice (const man) (const woman)))
8457 (defun org-man-open (path)
8458   "Visit the manpage on PATH.
8459 PATH should be a topic that can be thrown at the man command."
8460   (funcall org-man-command path))
8462 (defun org-man-store-link ()
8463   "Store a link to a manpage."
8464   (when (memq major-mode '(Man-mode woman-mode))
8465     ;; This is a man page, we do make this link
8466     (let* ((page (org-man-get-page-name))
8467            (link (concat "man:" page))
8468            (description (format "Manpage for %s" page)))
8469       (org-store-link-props
8470        :type "man"
8471        :link link
8472        :description description))))
8474 (defun org-man-get-page-name ()
8475   "Extract the page name from the buffer name."
8476   ;; This works for both `Man-mode' and `woman-mode'.
8477   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
8478       (match-string 1 (buffer-name))
8479     (error "Cannot create link to this man page")))
8481 (provide 'org-man)
8483 ;;; org-man.el ends here
8484 @end lisp
8486 @noindent
8487 You would activate this new link type in @file{.emacs} with
8489 @lisp
8490 (require 'org-man)
8491 @end lisp
8493 @noindent
8494 Lets go through the file and see what it does.
8495 @enumerate
8496 @item
8497 It does @code{(require 'org)} to make sure that @file{org.el} has been
8498 loaded.
8499 @item
8500 The next line calls @code{org-add-link-type} to define a new link type
8501 with prefix @samp{man}.  The call also contains the name of a function
8502 that will be called to follow such a link.
8503 @item
8504 The next line adds a function to @code{org-store-link-functions}, in
8505 order to allow the command @kbd{C-c l} to record a useful link in a
8506 buffer displaying a man page.
8507 @end enumerate
8509 The rest of the file defines the necessary variables and functions.
8510 First there is a customization variable that determines which emacs
8511 command should be used to display man pages.  There are two options,
8512 @code{man} and @code{woman}.  Then the function to follow a link is
8513 defined.  It gets the link path as an argument - in this case the link
8514 path is just a topic for the manual command.  The function calls the
8515 value of @code{org-man-command} to display the man page.
8517 Finally the function @code{org-man-store-link} is defined.  When you try
8518 to store a link with @kbd{C-c l}, also this function will be called to
8519 try to make a link.  The function must first decide if it is supposed to
8520 create the link for this buffer type, we do this by checking the value
8521 of the variable @code{major-mode}.  If not, the function must exit and
8522 return the value @code{nil}.  If yes, the link is created by getting the
8523 manual topic from the buffer name and prefixing it with the string
8524 @samp{man:}.  Then it must call the command @code{org-store-link-props}
8525 and set the @code{:type} and @code{:link} properties.  Optionally you
8526 can also set the @code{:description} property to provide a default for
8527 the link description when the link is later inserted into an Org
8528 buffer with @kbd{C-c C-l}.
8530 @node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Extensions and Hacking
8531 @section Tables and lists in arbitrary syntax
8532 @cindex tables, in other modes
8533 @cindex lists, in other modes
8534 @cindex Orgtbl mode
8536 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
8537 frequent feature request has been to make it work with native tables in
8538 specific languages, for example La@TeX{}.  However, this is extremely
8539 hard to do in a general way, would lead to a customization nightmare,
8540 and would take away much of the simplicity of the Orgtbl mode table
8541 editor.
8544 This appendix describes a different approach.  We keep the Orgtbl mode
8545 table in its native format (the @i{source table}), and use a custom
8546 function to @i{translate} the table to the correct syntax, and to
8547 @i{install} it in the right location (the @i{target table}).  This puts
8548 the burden of writing conversion functions on the user, but it allows
8549 for a very flexible system.
8551 Bastien added the ability to do the same with lists.  You can use Org's
8552 facilities to edit and structure lists by turning @code{orgstruct-mode}
8553 on, then locally exporting such lists in another format (HTML, La@TeX{}
8554 or Texinfo.)
8557 @menu
8558 * Radio tables::                Sending and receiving
8559 * A LaTeX example::             Step by step, almost a tutorial
8560 * Translator functions::        Copy and modify
8561 * Radio lists::                 Doing the same for lists
8562 @end menu
8564 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
8565 @subsection Radio tables
8566 @cindex radio tables
8568 To define the location of the target table, you first need to create two
8569 lines that are comments in the current mode, but contain magic words for
8570 Orgtbl mode to find.  Orgtbl mode will insert the translated table
8571 between these lines, replacing whatever was there before.  For example:
8573 @example
8574 /* BEGIN RECEIVE ORGTBL table_name */
8575 /* END RECEIVE ORGTBL table_name */
8576 @end example
8578 @noindent
8579 Just above the source table, we put a special line that tells
8580 Orgtbl mode how to translate this table and where to install it.  For
8581 example:
8582 @example
8583 #+ORGTBL: SEND table_name translation_function arguments....
8584 @end example
8586 @noindent
8587 @code{table_name} is the reference name for the table that is also used
8588 in the receiver lines. @code{translation_function} is the Lisp function
8589 that does the translation.  Furthermore, the line can contain a list of
8590 arguments (alternating key and value) at the end.  The arguments will be
8591 passed as a property list to the translation function for
8592 interpretation.  A few standard parameters are already recognized and
8593 acted upon before the translation function is called:
8595 @table @code
8596 @item :skip N
8597 Skip the first N lines of the table.  Hlines do count as separate lines for
8598 this parameter!
8600 @item :skipcols (n1 n2 ...)
8601 List of columns that should be skipped.  If the table has a column with
8602 calculation marks, that column is automatically discarded as well.
8603 Please note that the translator function sees the table @emph{after} the
8604 removal of these columns, the function never knows that there have been
8605 additional columns.
8606 @end table
8608 @noindent
8609 The one problem remaining is how to keep the source table in the buffer
8610 without disturbing the normal workings of the file, for example during
8611 compilation of a C file or processing of a La@TeX{} file.  There are a
8612 number of different solutions:
8614 @itemize @bullet
8615 @item
8616 The table could be placed in a block comment if that is supported by the
8617 language.  For example, in C mode you could wrap the table between
8618 @samp{/*} and @samp{*/} lines.
8619 @item
8620 Sometimes it is possible to put the table after some kind of @i{END}
8621 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
8622 in La@TeX{}.
8623 @item
8624 You can just comment the table line by line whenever you want to process
8625 the file, and uncomment it whenever you need to edit the table.  This
8626 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
8627 make this comment-toggling very easy, in particular if you bind it to a
8628 key.
8629 @end itemize
8631 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
8632 @subsection A LaTeX example of radio tables
8633 @cindex LaTeX, and Orgtbl mode
8635 The best way to wrap the source table in La@TeX{} is to use the
8636 @code{comment} environment provided by @file{comment.sty}.  It has to be
8637 activated by placing @code{\usepackage@{comment@}} into the document
8638 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
8639 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
8640 variable @code{orgtbl-radio-tables} to install templates for other
8641 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
8642 be prompted for a table name, lets say we use @samp{salesfigures}.  You
8643 will then get the following template:
8645 @cindex #+ORGTBL: SEND
8646 @example
8647 % BEGIN RECEIVE ORGTBL salesfigures
8648 % END RECEIVE ORGTBL salesfigures
8649 \begin@{comment@}
8650 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8651 | | |
8652 \end@{comment@}
8653 @end example
8655 @noindent
8656 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
8657 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
8658 into the receiver location with name @code{salesfigures}.  You may now
8659 fill in the table, feel free to use the spreadsheet features@footnote{If
8660 the @samp{#+TBLFM} line contains an odd number of dollar characters,
8661 this may cause problems with font-lock in LaTeX mode.  As shown in the
8662 example you can fix this by adding an extra line inside the
8663 @code{comment} environment that is used to balance the dollar
8664 expressions.  If you are using AUCTeX with the font-latex library, a
8665 much better solution is to add the @code{comment} environment to the
8666 variable @code{LaTeX-verbatim-environments}.}:
8668 @example
8669 % BEGIN RECEIVE ORGTBL salesfigures
8670 % END RECEIVE ORGTBL salesfigures
8671 \begin@{comment@}
8672 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8673 | Month | Days | Nr sold | per day |
8674 |-------+------+---------+---------|
8675 | Jan   |   23 |      55 |     2.4 |
8676 | Feb   |   21 |      16 |     0.8 |
8677 | March |   22 |     278 |    12.6 |
8678 #+TBLFM: $4=$3/$2;%.1f
8679 % $ (optional extra dollar to keep font-lock happy, see footnote)
8680 \end@{comment@}
8681 @end example
8683 @noindent
8684 When you are done, press @kbd{C-c C-c} in the table to get the converted
8685 table inserted between the two marker lines.
8687 Now lets assume you want to make the table header by hand, because you
8688 want to control how columns are aligned etc.  In this case we make sure
8689 that the table translator does skip the first 2 lines of the source
8690 table, and tell the command to work as a @i{splice}, i.e. to not produce
8691 header and footer commands of the target table:
8693 @example
8694 \begin@{tabular@}@{lrrr@}
8695 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
8696 % BEGIN RECEIVE ORGTBL salesfigures
8697 % END RECEIVE ORGTBL salesfigures
8698 \end@{tabular@}
8700 \begin@{comment@}
8701 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
8702 | Month | Days | Nr sold | per day |
8703 |-------+------+---------+---------|
8704 | Jan   |   23 |      55 |     2.4 |
8705 | Feb   |   21 |      16 |     0.8 |
8706 | March |   22 |     278 |    12.6 |
8707 #+TBLFM: $4=$3/$2;%.1f
8708 \end@{comment@}
8709 @end example
8711 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
8712 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
8713 and marks horizontal lines with @code{\hline}.  Furthermore, it
8714 interprets the following parameters (see also @ref{Translator functions}):
8716 @table @code
8717 @item :splice nil/t
8718 When set to t, return only table body lines, don't wrap them into a
8719 tabular environment.  Default is nil.
8721 @item :fmt fmt
8722 A format to be used to wrap each field, should contain @code{%s} for the
8723 original field value.  For example, to wrap each field value in dollars,
8724 you could use @code{:fmt "$%s$"}.  This may also be a property list with
8725 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
8726 A function of one argument can be used in place of the strings; the
8727 function must return a formatted string.
8729 @item :efmt efmt
8730 Use this format to print numbers with exponentials.  The format should
8731 have @code{%s} twice for inserting mantissa and exponent, for example
8732 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
8733 may also be a property list with column numbers and formats, for example
8734 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
8735 @code{efmt} has been applied to a value, @code{fmt} will also be
8736 applied.  Similar to @code{fmt}, functions of two arguments can be
8737 supplied instead of strings.
8738 @end table
8740 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
8741 @subsection Translator functions
8742 @cindex HTML, and Orgtbl mode
8743 @cindex translator function
8745 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
8746 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
8747 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
8748 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
8749 code that produces tables during HTML export.}, these all use a generic
8750 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
8751 itself is a very short function that computes the column definitions for the
8752 @code{tabular} environment, defines a few field and line separators and then
8753 hands over to the generic translator.  Here is the entire code:
8755 @lisp
8756 @group
8757 (defun orgtbl-to-latex (table params)
8758   "Convert the Orgtbl mode TABLE to LaTeX."
8759   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
8760                                org-table-last-alignment ""))
8761          (params2
8762           (list
8763            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
8764            :tend "\\end@{tabular@}"
8765            :lstart "" :lend " \\\\" :sep " & "
8766            :efmt "%s\\,(%s)" :hline "\\hline")))
8767     (orgtbl-to-generic table (org-combine-plists params2 params))))
8768 @end group
8769 @end lisp
8771 As you can see, the properties passed into the function (variable
8772 @var{PARAMS}) are combined with the ones newly defined in the function
8773 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
8774 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
8775 would like to use the La@TeX{} translator, but wanted the line endings to
8776 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
8777 overrule the default with
8779 @example
8780 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
8781 @end example
8783 For a new language, you can either write your own converter function in
8784 analogy with the La@TeX{} translator, or you can use the generic function
8785 directly.  For example, if you have a language where a table is started
8786 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
8787 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
8788 separator is a TAB, you could call the generic translator like this (on
8789 a single line!):
8791 @example
8792 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
8793                               :lstart "!BL! " :lend " !EL!" :sep "\t"
8794 @end example
8796 @noindent
8797 Please check the documentation string of the function
8798 @code{orgtbl-to-generic} for a full list of parameters understood by
8799 that function and remember that you can pass each of them into
8800 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
8801 using the generic function.
8803 Of course you can also write a completely new function doing complicated
8804 things the generic translator cannot do.  A translator function takes
8805 two arguments.  The first argument is the table, a list of lines, each
8806 line either the symbol @code{hline} or a list of fields.  The second
8807 argument is the property list containing all parameters specified in the
8808 @samp{#+ORGTBL: SEND} line.  The function must return a single string
8809 containing the formatted table.  If you write a generally useful
8810 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
8811 others can benefit from your work.
8813 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
8814 @subsection Radio lists
8815 @cindex radio lists
8816 @cindex org-list-insert-radio-list
8818 Sending and receiving radio lists works exactly the same way than
8819 sending and receiving radio tables (@pxref{Radio tables}) @footnote{You
8820 need to load the @code{org-export-latex.el} package to use radio lists
8821 since the relevant code is there for now.}.  As for radio tables, you
8822 can insert radio lists templates in HTML, La@TeX{} and Texinfo modes by
8823 calling @code{org-list-insert-radio-list}.
8825 Here are the differences with radio tables:
8827 @itemize @minus
8828 @item
8829 Use @code{ORGLST} instead of @code{ORGTBL}.
8830 @item
8831 The available translation functions for radio lists don't take
8832 parameters.
8833 @item
8834 `C-c C-c' will work when pressed on the first item of the list.
8835 @end itemize
8837 Here is a La@TeX{} example.  Let's say that you have this in your
8838 La@TeX{} file:
8840 @example
8841 % BEGIN RECEIVE ORGLST to-buy
8842 % END RECEIVE ORGLST to-buy
8843 \begin@{comment@}
8844 #+ORGLIST: SEND to-buy orgtbl-to-latex
8845 - a new house
8846 - a new computer
8847   + a new keyboard
8848   + a new mouse
8849 - a new life
8850 \end@{comment@}
8851 @end example
8853 Pressing `C-c C-c' on @code{a new house} and will insert the converted
8854 La@TeX{} list between the two marker lines.
8856 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Extensions and Hacking
8857 @section Dynamic blocks
8858 @cindex dynamic blocks
8860 Org documents can contain @emph{dynamic blocks}.  These are
8861 specially marked regions that are updated by some user-written function.
8862 A good example for such a block is the clock table inserted by the
8863 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
8865 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
8866 to the block and can also specify parameters for the function producing
8867 the content of the block.
8869 #+BEGIN:dynamic block
8870 @example
8871 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
8873 #+END:
8874 @end example
8876 Dynamic blocks are updated with the following commands
8878 @table @kbd
8879 @kindex C-c C-x C-u
8880 @item C-c C-x C-u
8881 Update dynamic block at point.
8882 @kindex C-u C-c C-x C-u
8883 @item C-u C-c C-x C-u
8884 Update all dynamic blocks in the current file.
8885 @end table
8887 Updating a dynamic block means to remove all the text between BEGIN and
8888 END, parse the BEGIN line for parameters and then call the specific
8889 writer function for this block to insert the new content.  If you want
8890 to use the original content in the writer function, you can use the
8891 extra parameter @code{:content}.
8893 For a block with name @code{myblock}, the writer function is
8894 @code{org-dblock-write:myblock} with as only parameter a property list
8895 with the parameters given in the begin line.  Here is a trivial example
8896 of a block that keeps track of when the block update function was last
8897 run:
8899 @example
8900 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
8902 #+END:
8903 @end example
8905 @noindent
8906 The corresponding block writer function could look like this:
8908 @lisp
8909 (defun org-dblock-write:block-update-time (params)
8910    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
8911      (insert "Last block update at: "
8912              (format-time-string fmt (current-time)))))
8913 @end lisp
8915 If you want to make sure that all dynamic blocks are always up-to-date,
8916 you could add the function @code{org-update-all-dblocks} to a hook, for
8917 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
8918 written in a way that is does nothing in buffers that are not in
8919 @code{org-mode}.
8921 @node Special agenda views, Using the property API, Dynamic blocks, Extensions and Hacking
8922 @section Special agenda views
8923 @cindex agenda views, user-defined
8925 Org provides a special hook that can be used to narrow down the
8926 selection made by any of the agenda views.  You may specify a function
8927 that is used at each match to verify if the match should indeed be part
8928 of the agenda view, and if not, how much should be skipped.
8930 Let's say you want to produce a list of projects that contain a WAITING
8931 tag anywhere in the project tree.  Let's further assume that you have
8932 marked all tree headings that define a project with the TODO keyword
8933 PROJECT.  In this case you would run a TODO search for the keyword
8934 PROJECT, but skip the match unless there is a WAITING tag anywhere in
8935 the subtree belonging to the project line.
8937 To achieve this, you must write a function that searches the subtree for
8938 the tag.  If the tag is found, the function must return @code{nil} to
8939 indicate that this match should not be skipped.  If there is no such
8940 tag, return the location of the end of the subtree, to indicate that
8941 search should continue from there.
8943 @lisp
8944 (defun my-skip-unless-waiting ()
8945   "Skip trees that are not waiting"
8946   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
8947     (if (re-search-forward ":waiting:" subtree-end t)
8948         nil          ; tag found, do not skip
8949       subtree-end))) ; tag not found, continue after end of subtree
8950 @end lisp
8952 Now you may use this function in an agenda custom command, for example
8953 like this:
8955 @lisp
8956 (org-add-agenda-custom-command
8957  '("b" todo "PROJECT"
8958    ((org-agenda-skip-function 'my-org-waiting-projects)
8959     (org-agenda-overriding-header "Projects waiting for something: "))))
8960 @end lisp
8962 Note that this also binds @code{org-agenda-overriding-header} to get a
8963 meaningful header in the agenda view.
8965 A general way to create custom searches is to base them on a search for
8966 entries with a certain level limit.  If you want to study all entries with
8967 your custom search function, simply do a search for @samp{LEVEL>0}, and then
8968 use @code{org-agenda-skip-function} to select the entries you really want to
8969 have.
8971 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
8972 particular, you may use the functions @code{org-agenda-skip-entry-if}
8973 and @code{org-agenda-skip-subtree-if} in this form, for example:
8975 @table @code
8976 @item '(org-agenda-skip-entry-if 'scheduled)
8977 Skip current entry if it has been scheduled.
8978 @item '(org-agenda-skip-entry-if 'notscheduled)
8979 Skip current entry if it has not been scheduled.
8980 @item '(org-agenda-skip-entry-if 'deadline)
8981 Skip current entry if it has a deadline.
8982 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
8983 Skip current entry if it has a deadline, or if it is scheduled.
8984 @item '(org-agenda-skip-entry 'regexp "regular expression")
8985 Skip current entry if the regular expression matches in the entry.
8986 @item '(org-agenda-skip-entry 'notregexp "regular expression")
8987 Skip current entry unless the regular expression matches.
8988 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
8989 Same as above, but check and skip the entire subtree.
8990 @end table
8992 Therefore we could also have written the search for WAITING projects
8993 like this, even without defining a special function:
8995 @lisp
8996 (org-add-agenda-custom-command
8997  '("b" todo "PROJECT"
8998    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
8999                                 'regexp ":waiting:"))
9000     (org-agenda-overriding-header "Projects waiting for something: "))))
9001 @end lisp
9003 @node Using the property API,  , Special agenda views, Extensions and Hacking
9004 @section Using the property API
9005 @cindex API, for properties
9006 @cindex properties, API
9008 Here is a description of the functions that can be used to work with
9009 properties.
9011 @defun org-entry-properties &optional pom which
9012 Get all properties of the entry at point-or-marker POM.
9013 This includes the TODO keyword, the tags, time strings for deadline,
9014 scheduled, and clocking, and any additional properties defined in the
9015 entry.  The return value is an alist, keys may occur multiple times
9016 if the property key was used several times.
9017 POM may also be nil, in which case the current entry is used.
9018 If WHICH is nil or `all', get all properties.  If WHICH is
9019 `special' or `standard', only get that subclass.
9020 @end defun
9021 @defun org-entry-get pom property &optional inherit
9022 Get value of PROPERTY for entry at point-or-marker POM.  By default,
9023 this only looks at properties defined locally in the entry.  If INHERIT
9024 is non-nil and the entry does not have the property, then also check
9025 higher levels of the hierarchy.  If INHERIT is the symbol
9026 @code{selective}, use inheritance if and only if the setting of
9027 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
9028 @end defun
9030 @defun org-entry-delete pom property
9031 Delete the property PROPERTY from entry at point-or-marker POM.
9032 @end defun
9034 @defun org-entry-put pom property value
9035 Set PROPERTY to VALUE for entry at point-or-marker POM.
9036 @end defun
9038 @defun org-buffer-property-keys &optional include-specials
9039 Get all property keys in the current buffer.
9040 @end defun
9042 @defun org-insert-property-drawer
9043 Insert a property drawer at point.
9044 @end defun
9046 @defun org-entry-add-to-multivalued-property pom property value
9047 Treat the value of the property PROPERTY as a whitespace-separated list of
9048 values and make sure that VALUE is in this list.
9049 @end defun
9051 @defun org-entry-remove-from-multivalued-property pom property value
9052 Treat the value of the property PROPERTY as a whitespace-separated list of
9053 values and make sure that VALUE is @emph{not} in this list.
9054 @end defun
9056 @defun org-entry-member-in-multivalued-property pom property value
9057 Treat the value of the property PROPERTY as a whitespace-separated list of
9058 values and check if VALUE is in this list.
9059 @end defun
9061 @node History and Acknowledgments, Main Index, Extensions and Hacking, Top
9062 @appendix History and Acknowledgments
9063 @cindex acknowledgments
9064 @cindex history
9065 @cindex thanks
9067 Org was borne in 2003, out of frustration over the user interface
9068 of the Emacs Outline mode.  I was trying to organize my notes and
9069 projects, and using Emacs seemed to be the natural way to go.  However,
9070 having to remember eleven different commands with two or three keys per
9071 command, only to hide and show parts of the outline tree, that seemed
9072 entirely unacceptable to me.  Also, when using outlines to take notes, I
9073 constantly want to restructure the tree, organizing it parallel to my
9074 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
9075 editing} were originally implemented in the package
9076 @file{outline-magic.el}, but quickly moved to the more general
9077 @file{org.el}.  As this environment became comfortable for project
9078 planning, the next step was adding @emph{TODO entries}, basic @emph{time
9079 stamps}, and @emph{table support}.  These areas highlight the two main
9080 goals that Org still has today: To create a new, outline-based,
9081 plain text mode with innovative and intuitive editing features, and to
9082 incorporate project planning functionality directly into a notes file.
9084 A special thanks goes to @i{Bastien Guerry} who has not only writen a large
9085 number of extensions to Org (most of them integrated into the core by now),
9086 but has also helped the development and maintenance of Org so much that he
9087 should be considered co-author of this package.
9089 Since the first release, literally thousands of emails to me or on
9090 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
9091 reports, feedback, new ideas, and sometimes patches and add-on code.
9092 Many thanks to everyone who has helped to improve this package.  I am
9093 trying to keep here a list of the people who had significant influence
9094 in shaping one or more aspects of Org.  The list may not be
9095 complete, if I have forgotten someone, please accept my apologies and
9096 let me know.
9098 @itemize @bullet
9100 @item
9101 @i{Russel Adams} came up with the idea for drawers.
9102 @item
9103 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
9104 @item
9105 @i{Alex Bochannek} provided a patch for rounding time stamps.
9106 @item
9107 @i{Charles Cave}'s suggestion sparked the implementation of templates
9108 for Remember.
9109 @item
9110 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
9111 specified time.
9112 @item
9113 @i{Gregory Chernov} patched support for lisp forms into table
9114 calculations and improved XEmacs compatibility, in particular by porting
9115 @file{nouline.el} to XEmacs.
9116 @item
9117 @i{Sacha Chua} suggested to copy some linking code from Planner.
9118 @item
9119 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
9120 came up with the idea of properties, and that there should be an API for
9121 them.
9122 @item
9123 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
9124 inspired some of the early development, including HTML export.  He also
9125 asked for a way to narrow wide table columns.
9126 @item
9127 @i{Christian Egli} converted the documentation into Texinfo format,
9128 patched CSS formatting into the HTML exporter, and inspired the agenda.
9129 @item
9130 @i{David Emery} provided a patch for custom CSS support in exported
9131 HTML agendas.
9132 @item
9133 @i{Nic Ferrier} contributed mailcap and XOXO support.
9134 @item
9135 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
9136 @item
9137 @i{John Foerch} figured out how to make incremental search show context
9138 around a match in a hidden outline tree.
9139 @item
9140 @i{Niels Giesen} had the idea to automatically archive DONE trees.
9141 @item
9142 @i{Bastien Guerry} wrote the La@TeX{} exporter and @file{org-bibtex.el}, and
9143 has been prolific with patches, ideas, and bug reports.
9144 @item
9145 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
9146 @item
9147 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
9148 task state change logging, and the clocktable.  His clear explanations have
9149 been critical when we started to adopt the GIT version control system.
9150 @item
9151 @i{Phil Jackson} wrote @file{org-irc.el}.
9152 @item
9153 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
9154 folded entries, and column view for properties.
9155 @item
9156 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
9157 @item
9158 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
9159 provided frequent feedback and some patches.
9160 @item
9161 @i{Jason F. McBrayer} suggested agenda export to CSV format.
9162 @item
9163 @i{Max Mikhanosha} came up with the idea of refiling.
9164 @item
9165 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
9166 basis.
9167 @item
9168 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
9169 happy.
9170 @item
9171 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file
9172 and to be able to quickly restrict the agenda to a subtree.
9173 @item
9174 @i{Todd Neal} provided patches for links to Info files and elisp forms.
9175 @item
9176 @i{Tim O'Callaghan} suggested in-file links, search options for general
9177 file links, and TAGS.
9178 @item
9179 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
9180 into Japanese.
9181 @item
9182 @i{Oliver Oppitz} suggested multi-state TODO items.
9183 @item
9184 @i{Scott Otterson} sparked the introduction of descriptive text for
9185 links, among other things.
9186 @item
9187 @i{Pete Phillips} helped during the development of the TAGS feature, and
9188 provided frequent feedback.
9189 @item
9190 @i{T.V. Raman} reported bugs and suggested improvements.
9191 @item
9192 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
9193 control.
9194 @item
9195 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
9196 @item
9197 @i{Sebastian Rose} wrote @file{org-info.js}, a Java script for displaying
9198 webpages derived from Org using an Info-like, or a folding interface with
9199 single key navigation.
9200 @item
9201 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
9202 conflict with @file{allout.el}.
9203 @item
9204 @i{Jason Riedy} generalized the send-receive mechanism for orgtbl tables with
9205 extensive patches.
9206 @item
9207 @i{Philip Rooke} created the Org reference card, provided lots
9208 of feedback, developed and applied standards to the Org documentation and
9209 wrote the manual for the contributed packages.
9210 @item
9211 @i{Christian Schlauer} proposed angular brackets around links, among
9212 other things.
9213 @item
9214 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
9215 @file{organizer-mode.el}.
9216 @item
9217 @i{Ilya Shlyakhter} proposed the Archive Sibling.
9218 @item
9219 @i{Daniel Sinder} came up with the idea of internal archiving by locking
9220 subtrees.
9221 @item
9222 @i{Dale Smith} proposed link abbreviations.
9223 @item
9224 @i{Adam Spiers} asked for global linking commands and inspired the link
9225 extension system.  support mairix.
9226 @item
9227 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
9228 chapter about publishing.
9229 @item
9230 @i{J@"urgen Vollmer} contributed code generating the table of contents
9231 in HTML output.
9232 @item
9233 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
9234 keyword.
9235 @item
9236 @i{David Wainberg} suggested archiving, and improvements to the linking
9237 system.
9238 @item
9239 @i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
9240 @file{muse.el}, which have similar goals as Org.  Initially the development
9241 of Org was fully independent because I was not aware of the existence of
9242 these packages.  But with time I have accasionally looked at John's code and
9243 learned a lot from it.  John has also contributed a number of great ideas and
9244 patches directly to Org, including the file @code{org-mac-message.el}'
9245 @item
9246 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
9247 linking to Gnus.
9248 @item
9249 @i{Roland Winkler} requested additional key bindings to make Org
9250 work on a tty.
9251 @item
9252 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
9253 and contributed various ideas and code snippets.
9254 @end itemize
9257 @node Main Index, Key Index, History and Acknowledgments, Top
9258 @unnumbered The Main Index
9260 @printindex cp
9262 @node Key Index,  , Main Index, Top
9263 @unnumbered Key Index
9265 @printindex ky
9267 @bye
9269 @ignore
9270         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
9271 @end ignore
9273 @c Local variables:
9274 @c ispell-local-dictionary: "en_US-w_accents"
9275 @c ispell-local-pdict: "./.aspell.org.pws"
9276 @c fill-column: 77
9277 @c End: