Implement include files for export.
[org-mode/org-tableheadings.git] / doc / org.texi
blob9400d86fcea8c89ba83409580bc5891e8267c322
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @set VERSION 6.02b
7 @set DATE April 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 @node Motion, Structure editing, Visibility cycling, Document Structure
801 @section Motion
802 @cindex motion, between headlines
803 @cindex jumping, to headlines
804 @cindex headline navigation
805 The following commands jump to other headlines in the buffer.
807 @table @kbd
808 @kindex C-c C-n
809 @item C-c C-n
810 Next heading.
811 @kindex C-c C-p
812 @item C-c C-p
813 Previous heading.
814 @kindex C-c C-f
815 @item C-c C-f
816 Next heading same level.
817 @kindex C-c C-b
818 @item C-c C-b
819 Previous heading same level.
820 @kindex C-c C-u
821 @item C-c C-u
822 Backward to higher level heading.
823 @kindex C-c C-j
824 @item C-c C-j
825 Jump to a different place without changing the current outline
826 visibility.  Shows the document structure in a temporary buffer, where
827 you can use the following keys to find your destination:
828 @example
829 @key{TAB}         @r{Cycle visibility.}
830 @key{down} / @key{up}   @r{Next/previous visible headline.}
831 n / p        @r{Next/previous visible headline.}
832 f / b        @r{Next/previous headline same level.}
833 u            @r{One level up.}
834 0-9          @r{Digit argument.}
835 @key{RET}         @r{Select this location.}
836 @end example
837 @end table
839 @node Structure editing, Archiving, Motion, Document Structure
840 @section Structure editing
841 @cindex structure editing
842 @cindex headline, promotion and demotion
843 @cindex promotion, of subtrees
844 @cindex demotion, of subtrees
845 @cindex subtree, cut and paste
846 @cindex pasting, of subtrees
847 @cindex cutting, of subtrees
848 @cindex copying, of subtrees
849 @cindex subtrees, cut and paste
851 @table @kbd
852 @kindex M-@key{RET}
853 @item M-@key{RET}
854 Insert new heading with same level as current.  If the cursor is in a
855 plain list item, a new item is created (@pxref{Plain lists}).  To force
856 creation of a new headline, use a prefix argument, or first press @key{RET}
857 to get to the beginning of the next line.  When this command is used in
858 the middle of a line, the line is split and the rest of the line becomes
859 the new headline@footnote{If you do not want the line to be split,
860 customize the variable @code{org-M-RET-may-split-line}.}.  If the
861 command is used at the beginning of a headline, the new headline is
862 created before the current line.  If at the beginning of any other line,
863 the content of that line is made the new heading.  If the command is
864 used at the end of a folded subtree (i.e. behind the ellipses at the end
865 of a headline), then a headline like the current one will be inserted
866 after the end of the subtree.
867 @kindex C-@key{RET}
868 @item C-@key{RET}
869 Insert a new heading after the current subtree, same level as the
870 current headline.  This command works from anywhere in the entry.
871 @kindex M-S-@key{RET}
872 @item M-S-@key{RET}
873 Insert new TODO entry with same level as current heading.
874 @kindex M-@key{left}
875 @item M-@key{left}
876 Promote current heading by one level.
877 @kindex M-@key{right}
878 @item M-@key{right}
879 Demote current heading by one level.
880 @kindex M-S-@key{left}
881 @item M-S-@key{left}
882 Promote the current subtree by one level.
883 @kindex M-S-@key{right}
884 @item M-S-@key{right}
885 Demote the current subtree by one level.
886 @kindex M-S-@key{up}
887 @item M-S-@key{up}
888 Move subtree up (swap with previous subtree of same
889 level).
890 @kindex M-S-@key{down}
891 @item M-S-@key{down}
892 Move subtree down (swap with next subtree of same level).
893 @kindex C-c C-x C-w
894 @kindex C-c C-x C-k
895 @item C-c C-x C-w
896 @itemx C-c C-x C-k
897 Kill subtree, i.e. remove it from buffer but save in kill ring.
898 With a numeric prefix argument N, kill N sequential subtrees.
899 @kindex C-c C-x M-w
900 @item C-c C-x M-w
901 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
902 sequential subtrees.
903 @kindex C-c C-x C-y
904 @item C-c C-x C-y
905 Yank subtree from kill ring.  This does modify the level of the subtree to
906 make sure the tree fits in nicely at the yank position.  The yank level can
907 also be specified with a numeric prefix argument, or by yanking after a
908 headline marker like @samp{****}.
909 @kindex C-c C-w
910 @item C-c C-w
911 Refile entry to a different location.  @xref{Refiling notes}.
912 @kindex C-c ^
913 @item C-c ^
914 Sort same-level entries.  When there is an active region, all entries in the
915 region will be sorted.  Otherwise the children of the current headline are
916 sorted.  The command prompts for the sorting method, which can be
917 alphabetically, numerically, by time (using the first time stamp in each
918 entry), by priority, or by TODO keyword (in the sequence the keywords have
919 been defined in the setup).  Reverse sorting is possible as well.  You can
920 also supply your own function to extract the sorting key.  With a @kbd{C-u}
921 prefix, sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes,
922 duplicate entries will also be removed.
923 @kindex C-c *
924 @item C-c *
925 Turn a normal line or plain list item into a headline (so that it
926 becomes a subheading at its location).  Also turn a headline into a
927 normal line by removing the stars.  If there is an active region, turn
928 all lines in the region into headlines.  Or, if the first line is a
929 headline, remove the stars from all headlines in the region.
930 @end table
932 @cindex region, active
933 @cindex active region
934 @cindex Transient mark mode
935 When there is an active region (Transient mark mode), promotion and
936 demotion work on all headlines in the region.  To select a region of
937 headlines, it is best to place both point and mark at the beginning of a
938 line, mark at the beginning of the first headline, and point at the line
939 just after the last headline to change.  Note that when the cursor is
940 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
941 functionality.
943 @node Archiving, Sparse trees, Structure editing, Document Structure
944 @section Archiving
945 @cindex archiving
947 When a project represented by a (sub)tree is finished, you may want
948 to move the tree out of the way and to stop it from contributing to the
949 agenda.  Org mode knows two ways of archiving.  You can mark a tree with
950 the ARCHIVE tag, or you can move an entire (sub)tree to a different
951 location.
953 @menu
954 * ARCHIVE tag::                 Marking a tree as inactive
955 * Moving subtrees::             Moving a tree to an archive file
956 @end menu
958 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
959 @subsection The ARCHIVE tag
960 @cindex internal archiving
962 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
963 its location in the outline tree, but behaves in the following way:
964 @itemize @minus
965 @item
966 It does not open when you attempt to do so with a visibility cycling
967 command (@pxref{Visibility cycling}).  You can force cycling archived
968 subtrees with @kbd{C-@key{TAB}}, or by setting the option
969 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
970 @code{show-all} will open archived subtrees.
971 @item
972 During sparse tree construction (@pxref{Sparse trees}), matches in
973 archived subtrees are not exposed, unless you configure the option
974 @code{org-sparse-tree-open-archived-trees}.
975 @item
976 During agenda view construction (@pxref{Agenda Views}), the content of
977 archived trees is ignored unless you configure the option
978 @code{org-agenda-skip-archived-trees}.
979 @item
980 Archived trees are not exported (@pxref{Exporting}), only the headline
981 is.  Configure the details using the variable
982 @code{org-export-with-archived-trees}.
983 @end itemize
985 The following commands help managing the ARCHIVE tag:
987 @table @kbd
988 @kindex C-c C-x a
989 @item C-c C-x a
990 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
991 the headline changes to a shadowed face, and the subtree below it is
992 hidden.
993 @kindex C-u C-c C-x a
994 @item C-u C-c C-x a
995 Check if any direct children of the current headline should be archived.
996 To do this, each subtree is checked for open TODO entries.  If none are
997 found, the command offers to set the ARCHIVE tag for the child.  If the
998 cursor is @emph{not} on a headline when this command is invoked, the
999 level 1 trees will be checked.
1000 @kindex C-@kbd{TAB}
1001 @item C-@kbd{TAB}
1002 Cycle a tree even if it is tagged with ARCHIVE.
1003 @end table
1005 @node Moving subtrees,  , ARCHIVE tag, Archiving
1006 @subsection Moving subtrees
1007 @cindex external archiving
1009 Once an entire project is finished, you may want to move it to a different
1010 location.  Org can move it to an @emph{Attic Sibling} in the same tree, to a
1011 different tree in the current file, or to a different file, the archive file.
1013 @table @kbd
1014 @kindex C-c C-x A
1015 @item C-c C-x A
1016 Move the current entry to the @emph{Attic Sibling}.  This is a sibling of the
1017 entry with the heading @samp{Attic} and the tag @samp{ARCHIVE}
1018 (@pxref{ARCHIVE tag}).  The entry becomes a child of that sibling and in this
1019 way retains a lot of its original context, including inherited tags and
1020 approximate position in the outline.
1021 @kindex C-c C-x C-s
1022 @item C-c C-x C-s
1023 Archive the subtree starting at the cursor position to the location
1024 given by @code{org-archive-location}.  Context information that could be
1025 lost like the file name, the category, inherited tags, and the TODO
1026 state will be store as properties in the entry.
1027 @kindex C-u C-c C-x C-s
1028 @item C-u C-c C-x C-s
1029 Check if any direct children of the current headline could be moved to
1030 the archive.  To do this, each subtree is checked for open TODO entries.
1031 If none are found, the command offers to move it to the archive
1032 location.  If the cursor is @emph{not} on a headline when this command
1033 is invoked, the level 1 trees will be checked.
1034 @end table
1036 @cindex archive locations
1037 The default archive location is a file in the same directory as the
1038 current file, with the name derived by appending @file{_archive} to the
1039 current file name.  For information and examples on how to change this,
1040 see the documentation string of the variable
1041 @code{org-archive-location}.  There is also an in-buffer option for
1042 setting this variable, for example@footnote{For backward compatibility,
1043 the following also works: If there are several such lines in a file,
1044 each specifies the archive location for the text below it.  The first
1045 such line also applies to any text before its definition.  However,
1046 using this method is @emph{strongly} deprecated as it is incompatible
1047 with the outline structure of the document.  The correct method for
1048 setting multiple archive locations in a buffer is using a property.}:
1050 @example
1051 #+ARCHIVE: %s_done::
1052 @end example
1054 @noindent
1055 If you would like to have a special ARCHIVE location for a single entry
1056 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1057 location as the value (@pxref{Properties and Columns}).
1059 When a subtree is moved, it receives a number of special properties that
1060 record context information like the file from where the entry came, it's
1061 outline path the archiving time etc.  Configure the variable
1062 @code{org-archive-save-context-info} to adjust the amount of information
1063 added.
1065 @node Sparse trees, Plain lists, Archiving, Document Structure
1066 @section Sparse trees
1067 @cindex sparse trees
1068 @cindex trees, sparse
1069 @cindex folding, sparse trees
1070 @cindex occur, command
1072 An important feature of Org mode is the ability to construct
1073 @emph{sparse trees} for selected information in an outline tree, so that
1074 the entire document is folded as much as possible, but the selected
1075 information is made visible along with the headline structure above
1076 it@footnote{See also the variables @code{org-show-hierarchy-above},
1077 @code{org-show-following-heading}, and @code{org-show-siblings} for
1078 detailed control on how much context is shown around each match.}.  Just
1079 try it out and you will see immediately how it works.
1081 Org mode contains several commands creating such trees, all these
1082 commands can be accessed through a dispatcher:
1084 @table @kbd
1085 @kindex C-c /
1086 @item C-c /
1087 This prompts for an extra key to select a sparse-tree creating command.
1088 @kindex C-c / r
1089 @item C-c / r
1090 Occur.  Prompts for a regexp and shows a sparse tree with all matches.
1091 If the match is in a headline, the headline is made visible.  If the
1092 match is in the body of an entry, headline and body are made visible.
1093 In order to provide minimal context, also the full hierarchy of
1094 headlines above the match is shown, as well as the headline following
1095 the match.  Each match is also highlighted; the highlights disappear
1096 when the buffer is changed by an editing command, or by pressing
1097 @kbd{C-c C-c}.  When called with a @kbd{C-u} prefix argument, previous
1098 highlights are kept, so several calls to this command can be stacked.
1099 @end table
1101 @noindent
1102 For frequently used sparse trees of specific search strings, you can
1103 use the variable @code{org-agenda-custom-commands} to define fast
1104 keyboard access to specific sparse trees.  These commands will then be
1105 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1106 For example:
1108 @lisp
1109 (setq org-agenda-custom-commands
1110       '(("f" occur-tree "FIXME")))
1111 @end lisp
1113 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1114 a sparse tree matching the string @samp{FIXME}.
1116 The other sparse tree commands select headings based on TODO keywords,
1117 tags, or properties and will be discussed later in this manual.
1119 @kindex C-c C-e v
1120 @cindex printing sparse trees
1121 @cindex visible text, printing
1122 To print a sparse tree, you can use the Emacs command
1123 @code{ps-print-buffer-with-faces} which does not print invisible parts
1124 of the document @footnote{This does not work under XEmacs, because
1125 XEmacs uses selective display for outlining, not text properties.}.
1126 Or you can use the command @kbd{C-c C-e v} to export only the visible
1127 part of the document and print the resulting file.
1129 @node Plain lists, Drawers, Sparse trees, Document Structure
1130 @section Plain lists
1131 @cindex plain lists
1132 @cindex lists, plain
1133 @cindex lists, ordered
1134 @cindex ordered lists
1136 Within an entry of the outline tree, hand-formatted lists can provide
1137 additional structure.  They also provide a way to create lists of
1138 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1139 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1141 Org knows ordered lists, unordered lists, and description lists.
1142 @itemize @bullet
1143 @item
1144 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1145 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1146 they will be seen as top-level headlines.  Also, when you are hiding leading
1147 stars to get a clean outline view, plain list items starting with a star are
1148 visually indistinguishable from true headlines.  In short: even though
1149 @samp{*} is supported, it may be better to not use it for plain list items.}
1150 as bullets.
1151 @item
1152 @emph{Ordered} list items start with a numeral followed by either a period or
1153 a right parenthesis, such as @samp{1.} or @samp{1)}.
1154 @item
1155 @emph{Description} list items are like unordered list items, but contain the
1156 separator @samp{ :: } to separate the description @emph{term} from the
1157 desciption.
1158 @end itemize
1160 Items belonging to the same list must have the same indentation on the first
1161 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1162 2--digit numbers must be written left-aligned with the other numbers in the
1163 list.  Indentation also determines the end of a list item.  It ends before
1164 the next line that is indented like the bullet/number, or less.  Empty lines
1165 are part of the previous item, so you can have several paragraphs in one
1166 item.  If you would like an empty line to terminate all currently open plain
1167 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1168 Here is an example:
1170 @example
1171 @group
1172 ** Lord of the Rings
1173    My favorite scenes are (in this order)
1174    1. The attack of the Rohirrim
1175    2. Eowyns fight with the witch king
1176       + this was already my favorite scene in the book
1177       + I really like Miranda Otto.
1178    3. Peter Jackson being shot by Legolas
1179        - on DVD only
1180       He makes a really funny face when it happens.
1181    But in the end, not individual scenes matter but the film as a whole.
1182    Important actors in this film are:
1183    - @b{Elijah Wood} :: He plays the Frodo
1184    - @b{Sean Austin} :: He plays the Sam, Frodos friend.  I still remember
1185      him very well from his role as Mikey Walsh a in the Goonies.
1186 @end group
1187 @end example
1189 Org supports these lists by tuning filling and wrapping commands to
1190 deal with them correctly@footnote{Org only changes the filling
1191 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1192 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1193 @code{(require 'filladapt)}}, and by exporting them properly
1194 (@pxref{Exporting}).
1196 The following commands act on items when the cursor is in the first line
1197 of an item (the line with the bullet or number).
1199 @table @kbd
1200 @kindex @key{TAB}
1201 @item @key{TAB}
1202 Items can be folded just like headline levels if you set the variable
1203 @code{org-cycle-include-plain-lists}.  The level of an item is then
1204 given by the indentation of the bullet/number.  Items are always
1205 subordinate to real headlines, however; the hierarchies remain
1206 completely separated.
1208 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1209 fixes the indentation of the current line in a heuristic way.
1210 @kindex M-@key{RET}
1211 @item M-@key{RET}
1212 Insert new item at current level.  With a prefix argument, force a new
1213 heading (@pxref{Structure editing}).  If this command is used in the middle
1214 of a line, the line is @emph{split} and the rest of the line becomes the new
1215 item@footnote{If you do not want the line to be split, customize the variable
1216 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1217 @emph{whitespace before a bullet or number}, the new item is created
1218 @emph{before} the current item.  If the command is executed in the white
1219 space before the text that is part of an item but does not contain the
1220 bullet, a bullet is added to the current line.
1221 @kindex M-S-@key{RET}
1222 @item M-S-@key{RET}
1223 Insert a new item with a checkbox (@pxref{Checkboxes}).
1224 @kindex S-@key{up}
1225 @kindex S-@key{down}
1226 @item S-@key{up}
1227 @itemx S-@key{down}
1228 Jump to the previous/next item in the current list.
1229 @kindex M-S-@key{up}
1230 @kindex M-S-@key{down}
1231 @item M-S-@key{up}
1232 @itemx M-S-@key{down}
1233 Move the item including subitems up/down (swap with previous/next item
1234 of same indentation).  If the list is ordered, renumbering is
1235 automatic.
1236 @kindex M-S-@key{left}
1237 @kindex M-S-@key{right}
1238 @item M-S-@key{left}
1239 @itemx M-S-@key{right}
1240 Decrease/increase the indentation of the item, including subitems.
1241 Initially, the item tree is selected based on current indentation.
1242 When these commands are executed several times in direct succession,
1243 the initially selected region is used, even if the new indentation
1244 would imply a different hierarchy.  To use the new hierarchy, break
1245 the command chain with a cursor motion or so.
1246 @kindex C-c C-c
1247 @item C-c C-c
1248 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1249 state of the checkbox.  If not, this command makes sure that all the
1250 items on this list level use the same bullet.  Furthermore, if this is
1251 an ordered list, make sure the numbering is OK.
1252 @kindex C-c -
1253 @item C-c -
1254 Cycle the entire list level through the different itemize/enumerate bullets
1255 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1256 argument N, select the Nth bullet from this list.  If there is an active
1257 region when calling this, all lines will be converted to list items.  If the
1258 first line already was a list item, any item markers will be removed from the
1259 list.  Finally, even without an active region, a normal line will be
1260 converted into a list item.
1261 @end table
1263 @node Drawers, Orgstruct mode, Plain lists, Document Structure
1264 @section Drawers
1265 @cindex drawers
1266 @cindex visibility cycling, drawers
1268 Sometimes you want to keep information associated with an entry, but you
1269 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1270 Drawers need to be configured with the variable
1271 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1272 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1273 look like this:
1275 @example
1276 ** This is a headline
1277    Still outside the drawer
1278    :DRAWERNAME:
1279       This is inside the drawer.
1280    :END:
1281    After the drawer.
1282 @end example
1284 Visibility cycling (@pxref{Visibility cycling}) on the headline will
1285 hide and show the entry, but keep the drawer collapsed to a single line.
1286 In order to look inside the drawer, you need to move the cursor to the
1287 drawer line and press @key{TAB} there.  Org mode uses a drawer for
1288 storing properties (@pxref{Properties and Columns}), and another one for
1289 storing clock times (@pxref{Clocking work time}).
1291 @node Orgstruct mode,  , Drawers, Document Structure
1292 @section The Orgstruct minor mode
1293 @cindex Orgstruct mode
1294 @cindex minor mode for structure editing
1296 If you like the intuitive way the Org mode structure editing and list
1297 formatting works, you might want to use these commands in other modes
1298 like Text mode or Mail mode as well.  The minor mode Orgstruct mode
1299 makes this possible.  You can always toggle the mode with @kbd{M-x
1300 orgstruct-mode}.  To turn it on by default, for example in Mail mode,
1303 @lisp
1304 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1305 @end lisp
1307 When this mode is active and the cursor is on a line that looks to
1308 Org like a headline of the first line of a list item, most
1309 structure editing commands will work, even if the same keys normally
1310 have different functionality in the major mode you are using.  If the
1311 cursor is not in one of those special lines, Orgstruct mode lurks
1312 silently in the shadow.
1314 @node Tables, Hyperlinks, Document Structure, Top
1315 @chapter Tables
1316 @cindex tables
1317 @cindex editing tables
1319 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1320 calculations are supported in connection with the Emacs @file{calc}
1321 package
1322 @ifinfo
1323 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1324 @end ifinfo
1325 @ifnotinfo
1326 (see the Emacs Calculator manual for more information about the Emacs
1327 calculator).
1328 @end ifnotinfo
1330 @menu
1331 * Built-in table editor::       Simple tables
1332 * Narrow columns::              Stop wasting space in tables
1333 * Column groups::               Grouping to trigger vertical lines
1334 * Orgtbl mode::                 The table editor as minor mode
1335 * The spreadsheet::             The table editor has spreadsheet capabilities
1336 @end menu
1338 @node Built-in table editor, Narrow columns, Tables, Tables
1339 @section The built-in table editor
1340 @cindex table editor, built-in
1342 Org makes it easy to format tables in plain ASCII.  Any line with
1343 @samp{|} as the first non-whitespace character is considered part of a
1344 table.  @samp{|} is also the column separator.  A table might look like
1345 this:
1347 @example
1348 | Name  | Phone | Age |
1349 |-------+-------+-----|
1350 | Peter |  1234 |  17 |
1351 | Anna  |  4321 |  25 |
1352 @end example
1354 A table is re-aligned automatically each time you press @key{TAB} or
1355 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1356 the next field (@key{RET} to the next row) and creates new table rows
1357 at the end of the table or before horizontal lines.  The indentation
1358 of the table is set by the first line.  Any line starting with
1359 @samp{|-} is considered as a horizontal separator line and will be
1360 expanded on the next re-align to span the whole table width.  So, to
1361 create the above table, you would only type
1363 @example
1364 |Name|Phone|Age|
1366 @end example
1368 @noindent and then press @key{TAB} to align the table and start filling in
1369 fields.
1371 When typing text into a field, Org treats @key{DEL},
1372 @key{Backspace}, and all character keys in a special way, so that
1373 inserting and deleting avoids shifting other fields.  Also, when
1374 typing @emph{immediately after the cursor was moved into a new field
1375 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1376 field is automatically made blank.  If this behavior is too
1377 unpredictable for you, configure the variables
1378 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1380 @table @kbd
1381 @tsubheading{Creation and conversion}
1382 @kindex C-c |
1383 @item C-c |
1384 Convert the active region to table. If every line contains at least one
1385 TAB character, the function assumes that the material is tab separated.
1386 If every line contains a comma, comma-separated values (CSV) are assumed.
1387 If not, lines are split at whitespace into fields.  You can use a prefix
1388 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1389 C-u} forces TAB, and a numeric argument N indicates that at least N
1390 consecutive spaces, or alternatively a TAB will be the separator.
1392 If there is no active region, this command creates an empty Org
1393 table.  But it's easier just to start typing, like
1394 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1396 @tsubheading{Re-aligning and field motion}
1397 @kindex C-c C-c
1398 @item C-c C-c
1399 Re-align the table without moving the cursor.
1401 @kindex @key{TAB}
1402 @item @key{TAB}
1403 Re-align the table, move to the next field.  Creates a new row if
1404 necessary.
1406 @kindex S-@key{TAB}
1407 @item S-@key{TAB}
1408 Re-align, move to previous field.
1410 @kindex @key{RET}
1411 @item @key{RET}
1412 Re-align the table and move down to next row.  Creates a new row if
1413 necessary.  At the beginning or end of a line, @key{RET} still does
1414 NEWLINE, so it can be used to split a table.
1416 @tsubheading{Column and row editing}
1417 @kindex M-@key{left}
1418 @kindex M-@key{right}
1419 @item M-@key{left}
1420 @itemx M-@key{right}
1421 Move the current column left/right.
1423 @kindex M-S-@key{left}
1424 @item M-S-@key{left}
1425 Kill the current column.
1427 @kindex M-S-@key{right}
1428 @item M-S-@key{right}
1429 Insert a new column to the left of the cursor position.
1431 @kindex M-@key{up}
1432 @kindex M-@key{down}
1433 @item M-@key{up}
1434 @itemx M-@key{down}
1435 Move the current row up/down.
1437 @kindex M-S-@key{up}
1438 @item M-S-@key{up}
1439 Kill the current row or horizontal line.
1441 @kindex M-S-@key{down}
1442 @item M-S-@key{down}
1443 Insert a new row above the current row.  With a prefix argument, the line is
1444 created below the current one.
1446 @kindex C-c -
1447 @item C-c -
1448 Insert a horizontal line below current row. With a prefix argument, the line
1449 is created above the current line.
1451 @kindex C-c ^
1452 @item C-c ^
1453 Sort the table lines in the region.  The position of point indicates the
1454 column to be used for sorting, and the range of lines is the range
1455 between the nearest horizontal separator lines, or the entire table.  If
1456 point is before the first column, you will be prompted for the sorting
1457 column.  If there is an active region, the mark specifies the first line
1458 and the sorting column, while point should be in the last line to be
1459 included into the sorting.  The command prompts for the sorting type
1460 (alphabetically, numerically, or by time).  When called with a prefix
1461 argument, alphabetic sorting will be case-sensitive.
1463 @tsubheading{Regions}
1464 @kindex C-c C-x M-w
1465 @item C-c C-x M-w
1466 Copy a rectangular region from a table to a special clipboard.  Point
1467 and mark determine edge fields of the rectangle.  The process ignores
1468 horizontal separator lines.
1470 @kindex C-c C-x C-w
1471 @item C-c C-x C-w
1472 Copy a rectangular region from a table to a special clipboard, and
1473 blank all fields in the rectangle.  So this is the ``cut'' operation.
1475 @kindex C-c C-x C-y
1476 @item C-c C-x C-y
1477 Paste a rectangular region into a table.
1478 The upper right corner ends up in the current field.  All involved fields
1479 will be overwritten.  If the rectangle does not fit into the present table,
1480 the table is enlarged as needed.  The process ignores horizontal separator
1481 lines.
1483 @kindex C-c C-q
1484 @kindex M-@key{RET}
1485 @item C-c C-q
1486 @itemx M-@kbd{RET}
1487 Wrap several fields in a column like a paragraph.  If there is an active
1488 region, and both point and mark are in the same column, the text in the
1489 column is wrapped to minimum width for the given number of lines.  A numeric
1490 prefix argument may be used to change the number of desired lines.  If there
1491 is no region, the current field is split at the cursor position and the text
1492 fragment to the right of the cursor is prepended to the field one line
1493 down. If there is no region, but you specify a prefix argument, the current
1494 field is made blank, and the content is appended to the field above.
1496 @tsubheading{Calculations}
1497 @cindex formula, in tables
1498 @cindex calculations, in tables
1499 @cindex region, active
1500 @cindex active region
1501 @cindex Transient mark mode
1502 @kindex C-c +
1503 @item C-c +
1504 Sum the numbers in the current column, or in the rectangle defined by
1505 the active region.  The result is shown in the echo area and can
1506 be inserted with @kbd{C-y}.
1508 @kindex S-@key{RET}
1509 @item S-@key{RET}
1510 When current field is empty, copy from first non-empty field above.
1511 When not empty, copy current field down to next row and move cursor
1512 along with it.  Depending on the variable
1513 @code{org-table-copy-increment}, integer field values will be
1514 incremented during copy.  This key is also used by CUA mode
1515 (@pxref{Cooperation}).
1517 @tsubheading{Miscellaneous}
1518 @kindex C-c `
1519 @item C-c `
1520 Edit the current field in a separate window.  This is useful for fields
1521 that are not fully visible (@pxref{Narrow columns}).  When called with a
1522 @kbd{C-u} prefix, just make the full field visible, so that it can be
1523 edited in place.
1525 @item M-x org-table-import
1526 Import a file as a table.  The table should be TAB- or whitespace
1527 separated.  Useful, for example, to import a spreadsheet table or data
1528 from a database, because these programs generally can write
1529 TAB-separated text files.  This command works by inserting the file into
1530 the buffer and then converting the region to a table.  Any prefix
1531 argument is passed on to the converter, which uses it to determine the
1532 separator.
1533 @item C-c |
1534 Tables can also be imported by pasting tabular text into the Org
1535 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1536 @kbd{C-c |} command (see above under @i{Creation and conversion}.
1538 @item M-x org-table-export
1539 Export the table, by default as a TAB-separated file.  Useful for data
1540 exchange with, for example, spreadsheet or database programs.  The format
1541 used to export the file can be configured in the variable
1542 @code{org-table-export-default-format}.  You may also use properties
1543 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1544 name and the format for table export in a subtree.
1545 @end table
1547 If you don't like the automatic table editor because it gets in your
1548 way on lines which you would like to start with @samp{|}, you can turn
1549 it off with
1551 @lisp
1552 (setq org-enable-table-editor nil)
1553 @end lisp
1555 @noindent Then the only table command that still works is
1556 @kbd{C-c C-c} to do a manual re-align.
1558 @node Narrow columns, Column groups, Built-in table editor, Tables
1559 @section Narrow columns
1560 @cindex narrow columns in tables
1562 The width of columns is automatically determined by the table editor.
1563 Sometimes a single field or a few fields need to carry more text,
1564 leading to inconveniently wide columns.  To limit@footnote{This feature
1565 does not work on XEmacs.} the width of a column, one field anywhere in
1566 the column may contain just the string @samp{<N>} where @samp{N} is an
1567 integer specifying the width of the column in characters.  The next
1568 re-align will then set the width of this column to no more than this
1569 value.
1571 @example
1572 @group
1573 |---+------------------------------|               |---+--------|
1574 |   |                              |               |   | <6>    |
1575 | 1 | one                          |               | 1 | one    |
1576 | 2 | two                          |     ----\     | 2 | two    |
1577 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1578 | 4 | four                         |               | 4 | four   |
1579 |---+------------------------------|               |---+--------|
1580 @end group
1581 @end example
1583 @noindent
1584 Fields that are wider become clipped and end in the string @samp{=>}.
1585 Note that the full text is still in the buffer, it is only invisible.
1586 To see the full text, hold the mouse over the field - a tool-tip window
1587 will show the full content.  To edit such a field, use the command
1588 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1589 open a new window with the full field.  Edit it and finish with @kbd{C-c
1590 C-c}.
1592 When visiting a file containing a table with narrowed columns, the
1593 necessary character hiding has not yet happened, and the table needs to
1594 be aligned before it looks nice.  Setting the option
1595 @code{org-startup-align-all-tables} will realign all tables in a file
1596 upon visiting, but also slow down startup.  You can also set this option
1597 on a per-file basis with:
1599 @example
1600 #+STARTUP: align
1601 #+STARTUP: noalign
1602 @end example
1604 @node Column groups, Orgtbl mode, Narrow columns, Tables
1605 @section Column groups
1606 @cindex grouping columns in tables
1608 When Org exports tables, it does so by default without vertical
1609 lines because that is visually more satisfying in general.  Occasionally
1610 however, vertical lines can be useful to structure a table into groups
1611 of columns, much like horizontal lines can do for groups of rows.  In
1612 order to specify column groups, you can use a special row where the
1613 first field contains only @samp{/}.  The further fields can either
1614 contain @samp{<} to indicate that this column should start a group,
1615 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1616 a group of its own.  Boundaries between column groups will upon export be
1617 marked with vertical lines.  Here is an example:
1619 @example
1620 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1621 |---+----+-----+-----+-----+---------+------------|
1622 | / | <> |   < |     |   > |       < |          > |
1623 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1624 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1625 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1626 |---+----+-----+-----+-----+---------+------------|
1627 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2))
1628 @end example
1630 It is also sufficient to just insert the column group starters after
1631 every vertical line you'd like to have:
1633 @example
1634 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1635 |----+-----+-----+-----+---------+------------|
1636 | /  | <   |     |     | <       |            |
1637 @end example
1639 @node Orgtbl mode, The spreadsheet, Column groups, Tables
1640 @section The Orgtbl minor mode
1641 @cindex Orgtbl mode
1642 @cindex minor mode for tables
1644 If you like the intuitive way the Org table editor works, you
1645 might also want to use it in other modes like Text mode or Mail mode.
1646 The minor mode Orgtbl mode makes this possible.  You can always toggle
1647 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1648 example in mail mode, use
1650 @lisp
1651 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1652 @end lisp
1654 Furthermore, with some special setup, it is possible to maintain tables
1655 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
1656 construct La@TeX{} tables with the underlying ease and power of
1657 Orgtbl mode, including spreadsheet capabilities.  For details, see
1658 @ref{Tables in arbitrary syntax}.
1660 @node The spreadsheet,  , Orgtbl mode, Tables
1661 @section The spreadsheet
1662 @cindex calculations, in tables
1663 @cindex spreadsheet capabilities
1664 @cindex @file{calc} package
1666 The table editor makes use of the Emacs @file{calc} package to implement
1667 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1668 derive fields from other fields.  While fully featured, Org's
1669 implementation is not identical to other spreadsheets.  For example,
1670 Org knows the concept of a @emph{column formula} that will be
1671 applied to all non-header fields in a column without having to copy the
1672 formula to each relevant field.
1674 @menu
1675 * References::                  How to refer to another field or range
1676 * Formula syntax for Calc::     Using Calc to compute stuff
1677 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1678 * Field formulas::              Formulas valid for a single field
1679 * Column formulas::             Formulas valid for an entire column
1680 * Editing and debugging formulas::  Fixing formulas
1681 * Updating the table::          Recomputing all dependent fields
1682 * Advanced features::           Field names, parameters and automatic recalc
1683 @end menu
1685 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1686 @subsection References
1687 @cindex references
1689 To compute fields in the table from other fields, formulas must
1690 reference other fields or ranges.  In Org, fields can be referenced
1691 by name, by absolute coordinates, and by relative coordinates.  To find
1692 out what the coordinates of a field are, press @kbd{C-c ?} in that
1693 field, or press @kbd{C-c @}} to toggle the display of a grid.
1695 @subsubheading Field references
1696 @cindex field references
1697 @cindex references, to fields
1699 Formulas can reference the value of another field in two ways.  Like in
1700 any other spreadsheet, you may reference fields with a letter/number
1701 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1702 @c Such references are always fixed to that field, they don't change
1703 @c when you copy and paste a formula to a different field.  So
1704 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1706 @noindent
1707 Org also uses another, more general operator that looks like this:
1708 @example
1709 @@row$column
1710 @end example
1712 @noindent
1713 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1714 or relative to the current column like @samp{+1} or @samp{-2}.
1716 The row specification only counts data lines and ignores horizontal
1717 separator lines (hlines).  You can use absolute row numbers
1718 @samp{1}...@samp{N}, and row numbers relative to the current row like
1719 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1720 hlines: @samp{I} refers to the first hline@footnote{Note that only
1721 hlines are counted that @emph{separate} table lines.  If the table
1722 starts with a hline above the header, it does not count.}, @samp{II} to
1723 the second etc.  @samp{-I} refers to the first such line above the
1724 current line, @samp{+I} to the first such line below the current line.
1725 You can also write @samp{III+2} which is the second data line after the
1726 third hline in the table.  Relative row numbers like @samp{-3} will not
1727 cross hlines if the current line is too close to the hline.  Instead,
1728 the value directly at the hline is used.
1730 @samp{0} refers to the current row and column.  Also, if you omit
1731 either the column or the row part of the reference, the current
1732 row/column is implied.
1734 Org's references with @emph{unsigned} numbers are fixed references
1735 in the sense that if you use the same reference in the formula for two
1736 different fields, the same field will be referenced each time.
1737 Org's references with @emph{signed} numbers are floating
1738 references because the same reference operator can reference different
1739 fields depending on the field being calculated by the formula.
1741 Here are a few examples:
1743 @example
1744 @@2$3      @r{2nd row, 3rd column}
1745 C2        @r{same as previous}
1746 $5        @r{column 5 in the current row}
1747 E&        @r{same as previous}
1748 @@2        @r{current column, row 2}
1749 @@-1$-3    @r{the field one row up, three columns to the left}
1750 @@-I$2     @r{field just under hline above current row, column 2}
1751 @end example
1753 @subsubheading Range references
1754 @cindex range references
1755 @cindex references, to ranges
1757 You may reference a rectangular range of fields by specifying two field
1758 references connected by two dots @samp{..}.  If both fields are in the
1759 current row, you may simply use @samp{$2..$7}, but if at least one field
1760 is in a different row, you need to use the general @code{@@row$column}
1761 format at least for the first field (i.e the reference must start with
1762 @samp{@@} in order to be interpreted correctly).  Examples:
1764 @example
1765 $1..$3        @r{First three fields in the current row.}
1766 $P..$Q        @r{Range, using column names (see under Advanced)}
1767 @@2$1..@@4$3    @r{6 fields between these two fields.}
1768 A2..C4        @r{Same as above.}
1769 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
1770 @end example
1772 @noindent Range references return a vector of values that can be fed
1773 into Calc vector functions.  Empty fields in ranges are normally
1774 suppressed, so that the vector contains only the non-empty fields (but
1775 see the @samp{E} mode switch below).  If there are no non-empty fields,
1776 @samp{[0]} is returned to avoid syntax errors in formulas.
1778 @subsubheading Named references
1779 @cindex named references
1780 @cindex references, named
1781 @cindex name, of column or field
1782 @cindex constants, in calculations
1784 @samp{$name} is interpreted as the name of a column, parameter or
1785 constant.  Constants are defined globally through the variable
1786 @code{org-table-formula-constants}, and locally (for the file) through a
1787 line like
1789 @example
1790 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
1791 @end example
1793 @noindent
1794 Also properties (@pxref{Properties and Columns}) can be used as
1795 constants in table formulas: For a property @samp{:Xyz:} use the name
1796 @samp{$PROP_Xyz}, and the property will be searched in the current
1797 outline entry and in the hierarchy above it.  If you have the
1798 @file{constants.el} package, it will also be used to resolve constants,
1799 including natural constants like @samp{$h} for Planck's constant, and
1800 units like @samp{$km} for kilometers@footnote{@file{Constant.el} can
1801 supply the values of constants in two different unit systems, @code{SI}
1802 and @code{cgs}.  Which one is used depends on the value of the variable
1803 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
1804 @code{constSI} and @code{constcgs} to set this value for the current
1805 buffer.}.  Column names and parameters can be specified in special table
1806 lines.  These are described below, see @ref{Advanced features}.  All
1807 names must start with a letter, and further consist of letters and
1808 numbers.
1810 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
1811 @subsection Formula syntax for Calc
1812 @cindex formula syntax, Calc
1813 @cindex syntax, of formulas
1815 A formula can be any algebraic expression understood by the Emacs
1816 @file{Calc} package.  @b{Note that @file{calc} has the
1817 non-standard convention that @samp{/} has lower precedence than
1818 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
1819 evaluation by @code{calc-eval} (@pxref{Calling Calc from
1820 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
1821 Emacs Calc Manual}),
1822 @c FIXME:  The link to the Calc manual in HTML does not work.
1823 variable substitution takes place according to the rules described above.
1824 @cindex vectors, in table calculations
1825 The range vectors can be directly fed into the Calc vector functions
1826 like @samp{vmean} and @samp{vsum}.
1828 @cindex format specifier
1829 @cindex mode, for @file{calc}
1830 A formula can contain an optional mode string after a semicolon.  This
1831 string consists of flags to influence Calc and other modes during
1832 execution.  By default, Org uses the standard Calc modes (precision
1833 12, angular units degrees, fraction and symbolic modes off.  The display
1834 format, however, has been changed to @code{(float 5)} to keep tables
1835 compact.  The default settings can be configured using the variable
1836 @code{org-calc-default-modes}.
1838 @example
1839 p20           @r{switch the internal precision to 20 digits}
1840 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
1841 D R           @r{angle modes: degrees, radians}
1842 F S           @r{fraction and symbolic modes}
1843 N             @r{interpret all fields as numbers, use 0 for non-numbers}
1844 T             @r{force text interpretation}
1845 E             @r{keep empty fields in ranges}
1846 @end example
1848 @noindent
1849 In addition, you may provide a @code{printf} format specifier to
1850 reformat the final result.  A few examples:
1852 @example
1853 $1+$2                @r{Sum of first and second field}
1854 $1+$2;%.2f           @r{Same, format result to two decimals}
1855 exp($2)+exp($1)      @r{Math functions can be used}
1856 $0;%.1f              @r{Reformat current cell to 1 decimal}
1857 ($3-32)*5/9          @r{Degrees F -> C conversion}
1858 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
1859 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
1860 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
1861 vmean($2..$7)        @r{Compute column range mean, using vector function}
1862 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
1863 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
1864 @end example
1866 Calc also contains a complete set of logical operations.  For example
1868 @example
1869 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
1870 @end example
1872 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
1873 @subsection Emacs Lisp forms as formulas
1874 @cindex Lisp forms, as table formulas
1876 It is also possible to write a formula in Emacs Lisp; this can be useful
1877 for string manipulation and control structures, if the Calc's
1878 functionality is not enough.  If a formula starts with a single quote
1879 followed by an opening parenthesis, then it is evaluated as a lisp form.
1880 The evaluation should return either a string or a number.  Just as with
1881 @file{calc} formulas, you can specify modes and a printf format after a
1882 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
1883 field references are interpolated into the form.  By default, a
1884 reference will be interpolated as a Lisp string (in double quotes)
1885 containing the field.  If you provide the @samp{N} mode switch, all
1886 referenced elements will be numbers (non-number fields will be zero) and
1887 interpolated as Lisp numbers, without quotes.  If you provide the
1888 @samp{L} flag, all fields will be interpolated literally, without quotes.
1889 I.e., if you want a reference to be interpreted as a string by the Lisp
1890 form, enclose the reference operator itself in double quotes, like
1891 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
1892 embed them in list or vector syntax.  A few examples, note how the
1893 @samp{N} mode is used when we do computations in lisp.
1895 @example
1896 @r{Swap the first two characters of the content of column 1}
1897   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
1898 @r{Add columns 1 and 2, equivalent to the Calc's @code{$1+$2}}
1899   '(+ $1 $2);N
1900 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
1901   '(apply '+ '($1..$4));N
1902 @end example
1904 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
1905 @subsection Field formulas
1906 @cindex field formula
1907 @cindex formula, for individual table field
1909 To assign a formula to a particular field, type it directly into the
1910 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
1911 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
1912 the field, the formula will be stored as the formula for this field,
1913 evaluated, and the current field replaced with the result.
1915 Formulas are stored in a special line starting with @samp{#+TBLFM:}
1916 directly below the table.  If you typed the equation in the 4th field of
1917 the 3rd data line in the table, the formula will look like
1918 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
1919 with the appropriate commands, @i{absolute references} (but not relative
1920 ones) in stored formulas are modified in order to still reference the
1921 same field.  Of cause this is not true if you edit the table structure
1922 with normal editing commands - then you must fix the equations yourself.
1924 Instead of typing an equation into the field, you may also use the
1925 following command
1927 @table @kbd
1928 @kindex C-u C-c =
1929 @item C-u C-c =
1930 Install a new formula for the current field.  The command prompts for a
1931 formula, with default taken from the @samp{#+TBLFM:} line, applies
1932 it to the current field and stores it.
1933 @end table
1935 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
1936 @subsection Column formulas
1937 @cindex column formula
1938 @cindex formula, for table column
1940 Often in a table, the same formula should be used for all fields in a
1941 particular column.  Instead of having to copy the formula to all fields
1942 in that column, Org allows to assign a single formula to an entire
1943 column.  If the table contains horizontal separator hlines, everything
1944 before the first such line is considered part of the table @emph{header}
1945 and will not be modified by column formulas.
1947 To assign a formula to a column, type it directly into any field in the
1948 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
1949 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
1950 field, the formula will be stored as the formula for the current column,
1951 evaluated and the current field replaced with the result.  If the field
1952 contains only @samp{=}, the previously stored formula for this column is
1953 used.  For each column, Org will only remember the most recently
1954 used formula.  In the @samp{TBLFM:} line, column formulas will look like
1955 @samp{$4=$1+$2}.
1957 Instead of typing an equation into the field, you may also use the
1958 following command:
1960 @table @kbd
1961 @kindex C-c =
1962 @item C-c =
1963 Install a new formula for the current column and replace current field with
1964 the result of the formula.  The command prompts for a formula, with default
1965 taken from the @samp{#+TBLFM} line, applies it to the current field and
1966 stores it.  With a numeric prefix argument(e.g. @kbd{C-5 C-c =}) the command
1967 will apply it to that many consecutive fields in the current column.
1968 @end table
1970 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
1971 @subsection Editing and debugging formulas
1972 @cindex formula editing
1973 @cindex editing, of table formulas
1975 You can edit individual formulas in the minibuffer or directly in the
1976 field.  Org can also prepare a special buffer with all active
1977 formulas of a table.  When offering a formula for editing, Org
1978 converts references to the standard format (like @code{B3} or @code{D&})
1979 if possible.  If you prefer to only work with the internal format (like
1980 @code{@@3$2} or @code{$4}), configure the variable
1981 @code{org-table-use-standard-references}.
1983 @table @kbd
1984 @kindex C-c =
1985 @kindex C-u C-c =
1986 @item C-c =
1987 @itemx C-u C-c =
1988 Edit the formula associated with the current column/field in the
1989 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
1990 @kindex C-u C-u C-c =
1991 @item C-u C-u C-c =
1992 Re-insert the active formula (either a
1993 field formula, or a column formula) into the current field, so that you
1994 can edit it directly in the field.  The advantage over editing in the
1995 minibuffer is that you can use the command @kbd{C-c ?}.
1996 @kindex C-c ?
1997 @item C-c ?
1998 While editing a formula in a table field, highlight the field(s)
1999 referenced by the reference at the cursor position in the formula.
2000 @kindex C-c @}
2001 @item C-c @}
2002 Toggle the display of row and column numbers for a table, using
2003 overlays.  These are updated each time the table is aligned, you can
2004 force it with @kbd{C-c C-c}.
2005 @kindex C-c @{
2006 @item C-c @{
2007 Toggle the formula debugger on and off.  See below.
2008 @kindex C-c '
2009 @item C-c '
2010 Edit all formulas for the current table in a special buffer, where the
2011 formulas will be displayed one per line.  If the current field has an
2012 active formula, the cursor in the formula editor will mark it.
2013 While inside the special buffer, Org will automatically highlight
2014 any field or range reference at the cursor position.  You may edit,
2015 remove and add formulas, and use the following commands:
2016 @table @kbd
2017 @kindex C-c C-c
2018 @kindex C-x C-s
2019 @item C-c C-c
2020 @itemx C-x C-s
2021 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2022 prefix, also apply the new formulas to the entire table.
2023 @kindex C-c C-q
2024 @item C-c C-q
2025 Exit the formula editor without installing changes.
2026 @kindex C-c C-r
2027 @item C-c C-r
2028 Toggle all references in the formula editor between standard (like
2029 @code{B3}) and internal (like @code{@@3$2}).
2030 @kindex @key{TAB}
2031 @item @key{TAB}
2032 Pretty-print or indent lisp formula at point.  When in a line containing
2033 a lisp formula, format the formula according to Emacs Lisp rules.
2034 Another @key{TAB} collapses the formula back again.  In the open
2035 formula, @key{TAB} re-indents just like in Emacs lisp mode.
2036 @kindex M-@key{TAB}
2037 @item M-@key{TAB}
2038 Complete Lisp symbols, just like in Emacs lisp mode.
2039 @kindex S-@key{up}
2040 @kindex S-@key{down}
2041 @kindex S-@key{left}
2042 @kindex S-@key{right}
2043 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2044 Shift the reference at point.  For example, if the reference is
2045 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2046 This also works for relative references, and for hline references.
2047 @kindex M-S-@key{up}
2048 @kindex M-S-@key{down}
2049 @item M-S-@key{up}/@key{down}
2050 Move the test line for column formulas in the Org buffer up and
2051 down.
2052 @kindex M-@key{up}
2053 @kindex M-@key{down}
2054 @item M-@key{up}/@key{down}
2055 Scroll the window displaying the table.
2056 @kindex C-c @}
2057 @item C-c @}
2058 Turn the coordinate grid in the table on and off.
2059 @end table
2060 @end table
2062 Making a table field blank does not remove the formula associated with
2063 the field, because that is stored in a different line (the @samp{TBLFM}
2064 line) - during the next recalculation the field will be filled again.
2065 To remove a formula from a field, you have to give an empty reply when
2066 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2068 @kindex C-c C-c
2069 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2070 equations with @kbd{C-c C-c} in that line, or with the normal
2071 recalculation commands in the table.
2073 @subsubheading Debugging formulas
2074 @cindex formula debugging
2075 @cindex debugging, of table formulas
2076 When the evaluation of a formula leads to an error, the field content
2077 becomes the string @samp{#ERROR}.  If you would like see what is going
2078 on during variable substitution and calculation in order to find a bug,
2079 turn on formula debugging in the @code{Tbl} menu and repeat the
2080 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2081 field.  Detailed information will be displayed.
2083 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2084 @subsection Updating the table
2085 @cindex recomputing table fields
2086 @cindex updating, table
2088 Recalculation of a table is normally not automatic, but needs to be
2089 triggered by a command.  See @ref{Advanced features} for a way to make
2090 recalculation at least semi-automatically.
2092 In order to recalculate a line of a table or the entire table, use the
2093 following commands:
2095 @table @kbd
2096 @kindex C-c *
2097 @item C-c *
2098 Recalculate the current row by first applying the stored column formulas
2099 from left to right, and all field formulas in the current row.
2101 @kindex C-u C-c *
2102 @item C-u C-c *
2103 @kindex C-u C-c C-c
2104 @itemx C-u C-c C-c
2105 Recompute the entire table, line by line.  Any lines before the first
2106 hline are left alone, assuming that these are part of the table header.
2108 @kindex C-u C-u C-c *
2109 @kindex C-u C-u C-c C-c
2110 @item C-u C-u C-c *
2111 @itemx C-u C-u C-c C-c
2112 Iterate the table by recomputing it until no further changes occur.
2113 This may be necessary if some computed fields use the value of other
2114 fields that are computed @i{later} in the calculation sequence.
2115 @end table
2117 @node Advanced features,  , Updating the table, The spreadsheet
2118 @subsection Advanced features
2120 If you want the recalculation of fields to happen automatically, or if
2121 you want to be able to assign @i{names} to fields and columns, you need
2122 to reserve the first column of the table for special marking characters.
2123 @table @kbd
2124 @kindex C-#
2125 @item C-#
2126 Rotate the calculation mark in first column through the states @samp{},
2127 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  The meaning of these characters
2128 is discussed below.  When there is an active region, change all marks in
2129 the region.
2130 @end table
2132 Here is an example of a table that collects exam results of students and
2133 makes use of these features:
2135 @example
2136 @group
2137 |---+---------+--------+--------+--------+-------+------|
2138 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2139 |---+---------+--------+--------+--------+-------+------|
2140 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2141 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2142 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2143 |---+---------+--------+--------+--------+-------+------|
2144 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2145 | # | Sara    |      6 |     14 |     19 |    39 |  7.8 |
2146 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2147 |---+---------+--------+--------+--------+-------+------|
2148 |   | Average |        |        |        |  29.7 |      |
2149 | ^ |         |        |        |        |    at |      |
2150 | $ | max=50  |        |        |        |       |      |
2151 |---+---------+--------+--------+--------+-------+------|
2152 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2153 @end group
2154 @end example
2156 @noindent @b{Important}: Please note that for these special tables,
2157 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2158 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2159 to the field itself.  The column formulas are not applied in rows with
2160 empty first field.
2162 @cindex marking characters, tables
2163 The marking characters have the following meaning:
2164 @table @samp
2165 @item !
2166 The fields in this line define names for the columns, so that you may
2167 refer to a column as @samp{$Tot} instead of @samp{$6}.
2168 @item ^
2169 This row defines names for the fields @emph{above} the row.  With such
2170 a definition, any formula in the table may use @samp{$m1} to refer to
2171 the value @samp{10}.  Also, if you assign a formula to a names field, it
2172 will be stored as @samp{$name=...}.
2173 @item _
2174 Similar to @samp{^}, but defines names for the fields in the row
2175 @emph{below}.
2176 @item $
2177 Fields in this row can define @emph{parameters} for formulas.  For
2178 example, if a field in a @samp{$} row contains @samp{max=50}, then
2179 formulas in this table can refer to the value 50 using @samp{$max}.
2180 Parameters work exactly like constants, only that they can be defined on
2181 a per-table basis.
2182 @item #
2183 Fields in this row are automatically recalculated when pressing
2184 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2185 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2186 lines will be left alone by this command.
2187 @item *
2188 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2189 not for automatic recalculation.  Use this when automatic
2190 recalculation slows down editing too much.
2191 @item
2192 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2193 All lines that should be recalculated should be marked with @samp{#}
2194 or @samp{*}.
2195 @item /
2196 Do not export this line.  Useful for lines that contain the narrowing
2197 @samp{<N>} markers.
2198 @end table
2200 Finally, just to whet your appetite on what can be done with the
2201 fantastic @file{calc} package, here is a table that computes the Taylor
2202 series of degree @code{n} at location @code{x} for a couple of
2203 functions.
2205 @example
2206 @group
2207 |---+-------------+---+-----+--------------------------------------|
2208 |   | Func        | n | x   | Result                               |
2209 |---+-------------+---+-----+--------------------------------------|
2210 | # | exp(x)      | 1 | x   | 1 + x                                |
2211 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2212 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2213 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2214 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2215 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2216 |---+-------------+---+-----+--------------------------------------|
2217 #+TBLFM: $5=taylor($2,$4,$3);n3
2218 @end group
2219 @end example
2221 @node Hyperlinks, TODO Items, Tables, Top
2222 @chapter Hyperlinks
2223 @cindex hyperlinks
2225 Like HTML, Org provides links inside a file, external links to
2226 other files, Usenet articles, emails, and much more.
2228 @menu
2229 * Link format::                 How links in Org are formatted
2230 * Internal links::              Links to other places in the current file
2231 * External links::              URL-like links to the world
2232 * Handling links::              Creating, inserting and following
2233 * Using links outside Org::     Linking from my C source code?
2234 * Link abbreviations::          Shortcuts for writing complex links
2235 * Search options::              Linking to a specific location
2236 * Custom searches::             When the default search is not enough
2237 @end menu
2239 @node Link format, Internal links, Hyperlinks, Hyperlinks
2240 @section Link format
2241 @cindex link format
2242 @cindex format, of links
2244 Org will recognize plain URL-like links and activate them as
2245 clickable links.  The general link format, however, looks like this:
2247 @example
2248 [[link][description]]       @r{or alternatively}           [[link]]
2249 @end example
2251 Once a link in the buffer is complete (all brackets present), Org
2252 will change the display so that @samp{description} is displayed instead
2253 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2254 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2255 which by default is an underlined face.  You can directly edit the
2256 visible part of a link.  Note that this can be either the @samp{link}
2257 part (if there is no description) or the @samp{description} part.  To
2258 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2259 cursor on the link.
2261 If you place the cursor at the beginning or just behind the end of the
2262 displayed text and press @key{BACKSPACE}, you will remove the
2263 (invisible) bracket at that location.  This makes the link incomplete
2264 and the internals are again displayed as plain text.  Inserting the
2265 missing bracket hides the link internals again.  To show the
2266 internal structure of all links, use the menu entry
2267 @code{Org->Hyperlinks->Literal links}.
2269 @node Internal links, External links, Link format, Hyperlinks
2270 @section Internal links
2271 @cindex internal links
2272 @cindex links, internal
2273 @cindex targets, for links
2275 If the link does not look like a URL, it is considered to be internal in
2276 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
2277 Target][Find my target]]} lead to a text search in the current file.
2278 The link can be followed with @kbd{C-c C-o} when the cursor is on the
2279 link, or with a mouse click (@pxref{Handling links}).  The preferred
2280 match for such a link is a dedicated target: the same string in double
2281 angular brackets.  Targets may be located anywhere; sometimes it is
2282 convenient to put them into a comment line. For example
2284 @example
2285 # <<My Target>>
2286 @end example
2288 @noindent In HTML export (@pxref{HTML export}), such targets will become
2289 named anchors for direct access through @samp{http} links@footnote{Note
2290 that text before the first headline is usually not exported, so the
2291 first such target should be after the first headline.}.
2293 If no dedicated target exists, Org will search for the words in the
2294 link.  In the above example the search would be for @samp{my target}.
2295 Links starting with a star like @samp{*My Target} restrict the search to
2296 headlines.  When searching, Org mode will first try an exact match, but
2297 then move on to more and more lenient searches.  For example, the link
2298 @samp{[[*My Targets]]} will find any of the following:
2300 @example
2301 ** My targets
2302 ** TODO my targets are bright
2303 ** my 20 targets are
2304 @end example
2306 To insert a link targeting a headline, in-buffer completion can be used.
2307 Just type a star followed by a few optional letters into the buffer and
2308 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2309 offered as completions.  @xref{Handling links}, for more commands
2310 creating links.
2312 Following a link pushes a mark onto Org's own mark ring.  You can
2313 return to the previous position with @kbd{C-c &}.  Using this command
2314 several times in direct succession goes back to positions recorded
2315 earlier.
2317 @menu
2318 * Radio targets::               Make targets trigger links in plain text
2319 @end menu
2321 @node Radio targets,  , Internal links, Internal links
2322 @subsection Radio targets
2323 @cindex radio targets
2324 @cindex targets, radio
2325 @cindex links, radio targets
2327 Org can automatically turn any occurrences of certain target names
2328 in normal text into a link.  So without explicitly creating a link, the
2329 text connects to the target radioing its position.  Radio targets are
2330 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2331 Target>>>} causes each occurrence of @samp{my target} in normal text to
2332 become activated as a link.  The Org file is scanned automatically
2333 for radio targets only when the file is first loaded into Emacs.  To
2334 update the target list during editing, press @kbd{C-c C-c} with the
2335 cursor on or at a target.
2337 @node External links, Handling links, Internal links, Hyperlinks
2338 @section External links
2339 @cindex links, external
2340 @cindex external links
2341 @cindex links, external
2342 @cindex Gnus links
2343 @cindex BBDB links
2344 @cindex IRC links
2345 @cindex URL links
2346 @cindex file links
2347 @cindex VM links
2348 @cindex RMAIL links
2349 @cindex WANDERLUST links
2350 @cindex MH-E links
2351 @cindex USENET links
2352 @cindex SHELL links
2353 @cindex Info links
2354 @cindex elisp links
2356 Org supports links to files, websites, Usenet and email messages,
2357 BBDB database entries and links to both IRC conversations and their
2358 logs.  External links are URL-like locators.  They start with a short
2359 identifying string followed by a colon.  There can be no space after
2360 the colon.  The following list shows examples for each link type.
2362 @example
2363 http://www.astro.uva.nl/~dominik          @r{on the web}
2364 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2365 file:papers/last.pdf                      @r{file, relative path}
2366 news:comp.emacs                           @r{Usenet link}
2367 mailto:adent@@galaxy.net                  @r{Mail link}
2368 vm:folder                                 @r{VM folder link}
2369 vm:folder#id                              @r{VM message link}
2370 vm://myself@@some.where.org/folder#id     @r{VM on remote machine}
2371 wl:folder                                 @r{WANDERLUST folder link}
2372 wl:folder#id                              @r{WANDERLUST message link}
2373 mhe:folder                                @r{MH-E folder link}
2374 mhe:folder#id                             @r{MH-E message link}
2375 rmail:folder                              @r{RMAIL folder link}
2376 rmail:folder#id                           @r{RMAIL message link}
2377 gnus:group                                @r{Gnus group link}
2378 gnus:group#id                             @r{Gnus article link}
2379 bbdb:Richard Stallman                     @r{BBDB link}
2380 irc:/irc.com/#emacs/bob                   @r{IRC link}
2381 shell:ls *.org                            @r{A shell command}
2382 elisp:(find-file-other-frame "Elisp.org") @r{An elisp form to evaluate}
2383 @end example
2385 A link should be enclosed in double brackets and may contain a
2386 descriptive text to be displayed instead of the URL (@pxref{Link
2387 format}), for example:
2389 @example
2390 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2391 @end example
2393 @noindent
2394 If the description is a file name or URL that points to an image, HTML
2395 export (@pxref{HTML export}) will inline the image as a clickable
2396 button.  If there is no description at all and the link points to an
2397 image,
2398 that image will be inlined into the exported HTML file.
2400 @cindex angular brackets, around links
2401 @cindex plain text external links
2402 Org also finds external links in the normal text and activates them
2403 as links.  If spaces must be part of the link (for example in
2404 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2405 about the end of the link, enclose them in angular brackets.
2407 @node Handling links, Using links outside Org, External links, Hyperlinks
2408 @section Handling links
2409 @cindex links, handling
2411 Org provides methods to create a link in the correct syntax, to
2412 insert it into an Org file, and to follow the link.
2414 @table @kbd
2415 @kindex C-c l
2416 @cindex storing links
2417 @item C-c l
2418 Store a link to the current location.  This is a @emph{global} command
2419 which can be used in any buffer to create a link.  The link will be
2420 stored for later insertion into an Org buffer (see below).  For
2421 Org files, if there is a @samp{<<target>>} at the cursor, the
2422 link points to the target.  Otherwise it points to the current
2423 headline.  For VM, Rmail, Wanderlust, MH-E, Gnus and BBDB buffers, the
2424 link will indicate the current article/entry.  For W3 and W3M buffers,
2425 the link goes to the current URL.  For IRC links, if you set the
2426 variable @code{org-irc-link-to-logs} to non-nil then @kbd{C-c l} will
2427 store a @samp{file:/} style link to the relevant point in the logs for
2428 the current conversation. Otherwise an @samp{irc:/} style link to the
2429 user/channel/server under the point will be stored.  For any other
2430 files, the link will point to the file, with a search string
2431 (@pxref{Search options}) pointing to the contents of the current line.
2432 If there is an active region, the selected words will form the basis
2433 of the search string.  If the automatically created link is not
2434 working correctly or accurately enough, you can write custom functions
2435 to select the search string and to do the search for particular file
2436 types - see @ref{Custom searches}.  The key binding @kbd{C-c l} is
2437 only a suggestion - see @ref{Installation}.
2439 @kindex C-c C-l
2440 @cindex link completion
2441 @cindex completion, of links
2442 @cindex inserting links
2443 @item C-c C-l
2444 Insert a link.  This prompts for a link to be inserted into the buffer.  You
2445 can just type a link, using text for an internal link, or one of the link
2446 type prefixes mentioned in the examples above.  All links stored during the
2447 current session are part of the history for this prompt, so you can access
2448 them with @key{up} and @key{down} (or @kbd{M-p/n}).  Completion, on the other
2449 hand, will help you to insert valid link prefixes like @samp{http:} or
2450 @samp{ftp:}, including the prefixes defined through link abbreviations
2451 (@pxref{Link abbreviations}).  The link will be inserted into the
2452 buffer@footnote{After insertion of a stored link, the link will be removed
2453 from the list of stored links.  To keep it in the list later use, use a
2454 triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2455 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2456 If some text was selected when this command is called, the selected text
2457 becomes the default description.@* Note that you don't have to use this
2458 command to insert a link.  Links in Org are plain text, and you can type
2459 or paste them straight into the buffer.  By using this command, the links are
2460 automatically enclosed in double brackets, and you will be asked for the
2461 optional descriptive text.
2463 @c  If the link is a @samp{file:} link and
2464 @c the linked file is located in the same directory as the current file or
2465 @c a subdirectory of it, the path of the file will be inserted relative to
2466 @c the current directory.
2468 @kindex C-u C-c C-l
2469 @cindex file name completion
2470 @cindex completion, of file names
2471 @item C-u C-c C-l
2472 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2473 a file will be inserted and you may use file name completion to select
2474 the name of the file.  The path to the file is inserted relative to the
2475 directory of the current org file, if the linked file is in the current
2476 directory or in a sub-directory of it, or if the path is written relative
2477 to the current directory using @samp{../}.  Otherwise an absolute path
2478 is used, if possible with @samp{~/} for your home directory.  You can
2479 force an absolute path with two @kbd{C-u} prefixes.
2481 @item C-c C-l @r{(with cursor on existing link)}
2482 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2483 link and description parts of the link.
2485 @cindex following links
2486 @kindex C-c C-o
2487 @item C-c C-o
2488 Open link at point.  This will launch a web browser for URLs (using
2489 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB
2490 for the corresponding links, and execute the command in a shell link.
2491 When the cursor is on an internal link, this commands runs the
2492 corresponding search.  When the cursor is on a TAG list in a headline,
2493 it creates the corresponding TAGS view.  If the cursor is on a time
2494 stamp, it compiles the agenda for that date.  Furthermore, it will visit
2495 text and remote files in @samp{file:} links with Emacs and select a
2496 suitable application for local non-text files.  Classification of files
2497 is based on file extension only.  See option @code{org-file-apps}.  If
2498 you want to override the default application and visit the file with
2499 Emacs, use a @kbd{C-u} prefix.
2501 @kindex mouse-2
2502 @kindex mouse-1
2503 @item mouse-2
2504 @itemx mouse-1
2505 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2506 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2508 @kindex mouse-3
2509 @item mouse-3
2510 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2511 internal links to be displayed in another window@footnote{See the
2512 variable @code{org-display-internal-link-with-indirect-buffer}}.
2514 @cindex mark ring
2515 @kindex C-c %
2516 @item C-c %
2517 Push the current position onto the mark ring, to be able to return
2518 easily. Commands following an internal link do this automatically.
2520 @cindex links, returning to
2521 @kindex C-c &
2522 @item C-c &
2523 Jump back to a recorded position.  A position is recorded by the
2524 commands following internal links, and by @kbd{C-c %}.  Using this
2525 command several times in direct succession moves through a ring of
2526 previously recorded positions.
2528 @kindex C-c C-x C-n
2529 @kindex C-c C-x C-p
2530 @cindex links, finding next/previous
2531 @item C-c C-x C-n
2532 @itemx C-c C-x C-p
2533 Move forward/backward to the next link in the buffer.  At the limit of
2534 the buffer, the search fails once, and then wraps around.  The key
2535 bindings for this are really too long, you might want to bind this also
2536 to @kbd{C-n} and @kbd{C-p}
2537 @lisp
2538 (add-hook 'org-load-hook
2539   (lambda ()
2540     (define-key 'org-mode-map "\C-n" 'org-next-link)
2541     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2542 @end lisp
2543 @end table
2545 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
2546 @section Using links outside Org
2548 You can insert and follow links that have Org syntax not only in
2549 Org, but in any Emacs buffer.  For this, you should create two
2550 global commands, like this (please select suitable global keys
2551 yourself):
2553 @lisp
2554 (global-set-key "\C-c L" 'org-insert-link-global)
2555 (global-set-key "\C-c o" 'org-open-at-point-global)
2556 @end lisp
2558 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
2559 @section Link abbreviations
2560 @cindex link abbreviations
2561 @cindex abbreviation, links
2563 Long URLs can be cumbersome to type, and often many similar links are
2564 needed in a document.  For this you can use link abbreviations.  An
2565 abbreviated link looks like this
2567 @example
2568 [[linkword:tag][description]]
2569 @end example
2571 @noindent
2572 where the tag is optional.  Such abbreviations are resolved according to
2573 the information in the variable @code{org-link-abbrev-alist} that
2574 relates the linkwords to replacement text.  Here is an example:
2576 @lisp
2577 @group
2578 (setq org-link-abbrev-alist
2579   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2580     ("google"   . "http://www.google.com/search?q=")
2581     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2582                    nph-abs_connect?author=%s&db_key=AST")))
2583 @end group
2584 @end lisp
2586 If the replacement text contains the string @samp{%s}, it will be
2587 replaced with the tag.  Otherwise the tag will be appended to the string
2588 in order to create the link.  You may also specify a function that will
2589 be called with the tag as the only argument to create the link.
2591 With the above setting, you could link to a specific bug with
2592 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2593 @code{[[google:OrgMode]]} and find out what the Org author is
2594 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2596 If you need special abbreviations just for a single Org buffer, you
2597 can define them in the file with
2599 @example
2600 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2601 #+LINK: google    http://www.google.com/search?q=%s
2602 @end example
2604 @noindent
2605 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2606 complete link abbreviations.
2608 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2609 @section Search options in file links
2610 @cindex search option in file links
2611 @cindex file links, searching
2613 File links can contain additional information to make Emacs jump to a
2614 particular location in the file when following a link.  This can be a
2615 line number or a search option after a double@footnote{For backward
2616 compatibility, line numbers can also follow a single colon.} colon. For
2617 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2618 links}) to a file, it encodes the words in the current line as a search
2619 string that can be used to find this line back later when following the
2620 link with @kbd{C-c C-o}.
2622 Here is the syntax of the different ways to attach a search to a file
2623 link, together with an explanation:
2625 @example
2626 [[file:~/code/main.c::255]]
2627 [[file:~/xx.org::My Target]]
2628 [[file:~/xx.org::*My Target]]
2629 [[file:~/xx.org::/regexp/]]
2630 @end example
2632 @table @code
2633 @item 255
2634 Jump to line 255.
2635 @item My Target
2636 Search for a link target @samp{<<My Target>>}, or do a text search for
2637 @samp{my target}, similar to the search in internal links, see
2638 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
2639 link will become an HTML reference to the corresponding named anchor in
2640 the linked file.
2641 @item *My Target
2642 In an Org file, restrict search to headlines.
2643 @item /regexp/
2644 Do a regular expression search for @code{regexp}.  This uses the Emacs
2645 command @code{occur} to list all matches in a separate window.  If the
2646 target file is in Org mode, @code{org-occur} is used to create a
2647 sparse tree with the matches.
2648 @c If the target file is a directory,
2649 @c @code{grep} will be used to search all files in the directory.
2650 @end table
2652 As a degenerate case, a file link with an empty file name can be used
2653 to search the current file.  For example, @code{[[file:::find me]]} does
2654 a search for @samp{find me} in the current file, just as
2655 @samp{[[find me]]} would.
2657 @node Custom searches,  , Search options, Hyperlinks
2658 @section Custom Searches
2659 @cindex custom search strings
2660 @cindex search strings, custom
2662 The default mechanism for creating search strings and for doing the
2663 actual search related to a file link may not work correctly in all
2664 cases.  For example, BibTeX database files have many entries like
2665 @samp{year="1993"} which would not result in good search strings,
2666 because the only unique identification for a BibTeX entry is the
2667 citation key.
2669 If you come across such a problem, you can write custom functions to set
2670 the right search string for a particular file type, and to do the search
2671 for the string in the file.  Using @code{add-hook}, these functions need
2672 to be added to the hook variables
2673 @code{org-create-file-search-functions} and
2674 @code{org-execute-file-search-functions}.  See the docstring for these
2675 variables for more information.  Org actually uses this mechanism
2676 for Bib@TeX{} database files, and you can use the corresponding code as
2677 an implementation example.  Search for @samp{BibTeX links} in the source
2678 file.
2680 @node TODO Items, Tags, Hyperlinks, Top
2681 @chapter TODO Items
2682 @cindex TODO items
2684 Org mode does not maintain TODO lists as separate documents.  Instead,
2685 TODO items are an integral part of the notes file, because TODO items
2686 usually come up while taking notes!  With Org mode, simply mark any
2687 entry in a tree as being a TODO item.  In this way, information is not
2688 duplicated, and the entire context from which the TODO item emerged is
2689 always present.
2691 Of course, this technique for managing TODO items scatters them
2692 throughout your notes file.  Org mode compensates for this by providing
2693 methods to give you an overview of all the things that you have to do.
2695 @menu
2696 * TODO basics::                 Marking and displaying TODO entries
2697 * TODO extensions::             Workflow and assignments
2698 * Progress logging::            Dates and notes for progress
2699 * Priorities::                  Some things are more important than others
2700 * Breaking down tasks::         Splitting a task into manageable pieces
2701 * Checkboxes::                  Tick-off lists
2702 @end menu
2704 @node TODO basics, TODO extensions, TODO Items, TODO Items
2705 @section Basic TODO functionality
2707 Any headline becomes a TODO item when it starts with the word
2708 @samp{TODO}, for example:
2710 @example
2711 *** TODO Write letter to Sam Fortune
2712 @end example
2714 @noindent
2715 The most important commands to work with TODO entries are:
2717 @table @kbd
2718 @kindex C-c C-t
2719 @cindex cycling, of TODO states
2720 @item C-c C-t
2721 Rotate the TODO state of the current item among
2723 @example
2724 ,-> (unmarked) -> TODO -> DONE --.
2725 '--------------------------------'
2726 @end example
2728 The same rotation can also be done ``remotely'' from the timeline and
2729 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
2731 @kindex C-u C-c C-t
2732 @item C-u C-c C-t
2733 Select a specific keyword using completion or (if it has been set up)
2734 the fast selection interface.  For the latter, you need to assign keys
2735 to TODO states, see @ref{Per-file keywords} and @ref{Setting tags} for
2736 more information.
2738 @kindex S-@key{right}
2739 @kindex S-@key{left}
2740 @item S-@key{right}
2741 @itemx S-@key{left}
2742 Select the following/preceding TODO state, similar to cycling.  Useful
2743 mostly if more than two TODO states are possible (@pxref{TODO
2744 extensions}).
2745 @kindex C-c C-v
2746 @kindex C-c / t
2747 @cindex sparse tree, for TODO
2748 @item C-c C-v
2749 @itemx C-c / t
2750 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
2751 the entire buffer, but shows all TODO items and the headings hierarchy
2752 above them.  With a prefix argument, search for a specific TODO.  You will be
2753 prompted for the keyword, and you can also give a list of keywords like
2754 @code{KWD1|KWD2|...}.  With numeric prefix argument N, show the tree for the
2755 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
2756 arguments, find all TODO and DONE entries.
2757 @kindex C-c a t
2758 @item C-c a t
2759 Show the global TODO list.  Collects the TODO items from all agenda
2760 files (@pxref{Agenda Views}) into a single buffer.  The new buffer will
2761 be in @code{agenda-mode}, which provides commands to examine and
2762 manipulate the TODO entries from the new buffer (@pxref{Agenda
2763 commands}).  @xref{Global TODO list}, for more information.
2764 @kindex S-M-@key{RET}
2765 @item S-M-@key{RET}
2766 Insert a new TODO entry below the current one.
2767 @end table
2769 @node TODO extensions, Progress logging, TODO basics, TODO Items
2770 @section Extended use of TODO keywords
2771 @cindex extended TODO keywords
2773 By default, marked TODO entries have one of only two states: TODO and
2774 DONE.  Org mode allows you to classify TODO items in more complex ways
2775 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
2776 special setup, the TODO keyword system can work differently in different
2777 files.
2779 Note that @i{tags} are another way to classify headlines in general and
2780 TODO items in particular (@pxref{Tags}).
2782 @menu
2783 * Workflow states::             From TODO to DONE in steps
2784 * TODO types::                  I do this, Fred does the rest
2785 * Multiple sets in one file::   Mixing it all, and still finding your way
2786 * Fast access to TODO states::  Single letter selection of a state
2787 * Per-file keywords::           Different files, different requirements
2788 * Faces for TODO keywords::     Highlighting states
2789 @end menu
2791 @node Workflow states, TODO types, TODO extensions, TODO extensions
2792 @subsection TODO keywords as workflow states
2793 @cindex TODO workflow
2794 @cindex workflow states as TODO keywords
2796 You can use TODO keywords to indicate different @emph{sequential} states
2797 in the process of working on an item, for example@footnote{Changing
2798 this variable only becomes effective after restarting Org mode in a
2799 buffer.}:
2801 @lisp
2802 (setq org-todo-keywords
2803   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
2804 @end lisp
2806 The vertical bar separates the TODO keywords (states that @emph{need
2807 action}) from the DONE states (which need @emph{no further action}.  If
2808 you don't provide the separator bar, the last state is used as the DONE
2809 state.
2810 @cindex completion, of TODO keywords
2811 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
2812 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
2813 also use a numeric prefix argument to quickly select a specific state.  For
2814 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
2815 Or you can use @kbd{S-left} to go backward through the sequence.  If you
2816 define many keywords, you can use in-buffer completion
2817 (@pxref{Completion}) or even a special one-key selection scheme
2818 (@pxref{Fast access to TODO states}) to insert these words into the
2819 buffer.  Changing a TODO state can be logged with a timestamp, see
2820 @ref{Tracking TODO state changes} for more information.
2822 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
2823 @subsection TODO keywords as types
2824 @cindex TODO types
2825 @cindex names as TODO keywords
2826 @cindex types as TODO keywords
2828 The second possibility is to use TODO keywords to indicate different
2829 @emph{types} of action items.  For example, you might want to indicate
2830 that items are for ``work'' or ``home''.  Or, when you work with several
2831 people on a single project, you might want to assign action items
2832 directly to persons, by using their names as TODO keywords.  This would
2833 be set up like this:
2835 @lisp
2836 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
2837 @end lisp
2839 In this case, different keywords do not indicate a sequence, but rather
2840 different types.  So the normal work flow would be to assign a task to a
2841 person, and later to mark it DONE.  Org mode supports this style by adapting
2842 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
2843 @kbd{t} command in the timeline and agenda buffers.}.  When used several
2844 times in succession, it will still cycle through all names, in order to first
2845 select the right type for a task.  But when you return to the item after some
2846 time and execute @kbd{C-c C-t} again, it will switch from any name directly
2847 to DONE.  Use prefix arguments or completion to quickly select a specific
2848 name.  You can also review the items of a specific TODO type in a sparse tree
2849 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
2850 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
2851 from all agenda files into a single buffer, you would use the numeric prefix
2852 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
2854 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
2855 @subsection Multiple keyword sets in one file
2856 @cindex TODO keyword sets
2858 Sometimes you may want to use different sets of TODO keywords in
2859 parallel.  For example, you may want to have the basic
2860 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
2861 separate state indicating that an item has been canceled (so it is not
2862 DONE, but also does not require action).  Your setup would then look
2863 like this:
2865 @lisp
2866 (setq org-todo-keywords
2867       '((sequence "TODO" "|" "DONE")
2868         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
2869         (sequence "|" "CANCELED")))
2870 @end lisp
2872 The keywords should all be different, this helps Org mode to keep track
2873 of which subsequence should be used for a given entry.  In this setup,
2874 @kbd{C-c C-t} only operates within a subsequence, so it switches from
2875 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
2876 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
2877 select the correct sequence.  Besides the obvious ways like typing a
2878 keyword or using completion, you may also apply the following commands:
2880 @table @kbd
2881 @kindex C-S-@key{right}
2882 @kindex C-S-@key{left}
2883 @item C-S-@key{right}
2884 @itemx C-S-@key{left}
2885 These keys jump from one TODO subset to the next.  In the above example,
2886 @kbd{C-S-@key{right}} would jump from @code{TODO} or @code{DONE} to
2887 @code{REPORT}, and any of the words in the second row to @code{CANCELED}.
2888 @kindex S-@key{right}
2889 @kindex S-@key{left}
2890 @item S-@key{right}
2891 @itemx S-@key{left}
2892 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through
2893 @emph{all} keywords from all sets, so for example @kbd{S-@key{<right>}}
2894 would switch from @code{DONE} to @code{REPORT} in the example above.
2895 @end table
2897 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
2898 @subsection Fast access to TODO states
2900 If you would like to quickly change an entry to an arbitrary TODO state
2901 instead of cycling through the states, you can set up keys for
2902 single-letter access to the states.  This is done by adding the section
2903 key after each keyword, in parenthesis.  For example:
2905 @lisp
2906 (setq org-todo-keywords
2907       '((sequence "TODO(t)" "|" "DONE(d)")
2908         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
2909         (sequence "|" "CANCELED(c)")))
2910 @end lisp
2912 If you then press @code{C-u C-c C-t} followed by the selection key, the
2913 entry will be switched to this state.  @key{SPC} can be used to remove
2914 any TODO keyword from an entry.  Should you like this way of selecting
2915 TODO states a lot, you might want to set the variable
2916 @code{org-use-fast-todo-selection} to @code{t} and make this behavior
2917 the default.  Check also the variable
2918 @code{org-fast-tag-selection-include-todo}, it allows to change the TODO
2919 state through the tags interface (@pxref{Setting tags}), in case you
2920 like to mingle the two concepts.
2922 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
2923 @subsection Setting up keywords for individual files
2924 @cindex keyword options
2925 @cindex per-file keywords
2927 It can be very useful to use different aspects of the TODO mechanism in
2928 different files.  For file-local settings, you need to add special lines
2929 to the file which set the keywords and interpretation for that file
2930 only.  For example, to set one of the two examples discussed above, you
2931 need one of the following lines, starting in column zero anywhere in the
2932 file:
2934 @example
2935 #+SEQ_TODO: TODO FEEDBACK VERIFY | DONE CANCELED
2936 @end example
2938 @example
2939 #+TYP_TODO: Fred Sara Lucy Mike | DONE
2940 @end example
2942 A setup for using several sets in parallel would be:
2944 @example
2945 #+SEQ_TODO: TODO | DONE
2946 #+SEQ_TODO: REPORT BUG KNOWNCAUSE | FIXED
2947 #+SEQ_TODO: | CANCELED
2948 @end example
2950 @cindex completion, of option keywords
2951 @kindex M-@key{TAB}
2952 @noindent To make sure you are using the correct keyword, type
2953 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
2955 @cindex DONE, final TODO keyword
2956 Remember that the keywords after the vertical bar (or the last keyword
2957 if no bar is there) must always mean that the item is DONE (although you
2958 may use a different word).  After changing one of these lines, use
2959 @kbd{C-c C-c} with the cursor still in the line to make the changes
2960 known to Org mode@footnote{Org mode parses these lines only when
2961 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
2962 cursor in a line starting with @samp{#+} is simply restarting Org mode
2963 for the current buffer.}.
2965 @node Faces for TODO keywords,  , Per-file keywords, TODO extensions
2966 @subsection Faces for TODO keywords
2967 @cindex faces, for TODO keywords
2969 Org mode highlights TODO keywords with special faces: @code{org-todo}
2970 for keywords indicating that an item still has to be acted upon, and
2971 @code{org-done} for keywords indicating that an item is finished.  If
2972 you are using more than 2 different states, you might want to use
2973 special faces for some of them.  This can be done using the variable
2974 @code{org-todo-keyword-faces}.  For example:
2976 @lisp
2977 (setq org-todo-keyword-faces
2978       '(("TODO"      . org-warning)
2979         ("DEFERRED"  . shadow)
2980         ("CANCELED"  . (:foreground "blue" :weight bold))))
2981 @end lisp
2983 While using a list with face properties as shown for CANCELED
2984 @emph{should} work, this does not aways seem to be the case.  If
2985 necessary, define a special face and use that.
2987 @page
2988 @node Progress logging, Priorities, TODO extensions, TODO Items
2989 @section Progress logging
2990 @cindex progress logging
2991 @cindex logging, of progress
2993 Org mode can automatically record a time stamp and possibly a note when
2994 you mark a TODO item as DONE, or even each time you change the state of
2995 a TODO item.  This system is highly configurable, settings can be on a
2996 per-keyword basis and can be localized to a file or even a subtree.  For
2997 information on how to clock working time for a task, see @ref{Clocking
2998 work time}.
3000 @menu
3001 * Closing items::               When was this entry marked DONE?
3002 * Tracking TODO state changes::  When did the status change?
3003 @end menu
3005 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3006 @subsection Closing items
3008 The most basic logging is to keep track of @emph{when} a certain TODO
3009 item was finished.  This is achieved with@footnote{The corresponding
3010 in-buffer setting is: @code{#+STARTUP: logdone}}.
3012 @lisp
3013 (setq org-log-done 'time)
3014 @end lisp
3016 @noindent
3017 Then each time you turn an entry from a TODO (not-done) state into any
3018 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3019 just after the headline.  If you turn the entry back into a TODO item
3020 through further state cycling, that line will be removed again.  If you
3021 want to record a note along with the timestamp, use@footnote{The
3022 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3024 @lisp
3025 (setq org-log-done 'note)
3026 @end lisp
3028 @noindent
3029 You will then be prompted for a note, and that note will be stored below
3030 the entry with a @samp{Closing Note} heading.
3032 In the timeline (@pxref{Timeline}) and in the agenda
3033 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3034 display the TODO items with a @samp{CLOSED} timestamp on each day,
3035 giving you an overview of what has been done.
3037 @node Tracking TODO state changes,  , Closing items, Progress logging
3038 @subsection Tracking TODO state changes
3040 When TODO keywords are used as workflow states (@pxref{Workflow
3041 states}), you might want to keep track of when a state change occurred
3042 and maybe take a note about this change.  Since it is normally too much
3043 to record a note for every state, Org mode expects configuration on a
3044 per-keyword basis for this.  This is achieved by adding special markers
3045 @samp{!} (for a time stamp) and @samp{@@} (for a note) in parenthesis
3046 after each keyword.  For example, with the setting
3048 @lisp
3049 (setq org-todo-keywords
3050   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3051 @end lisp
3053 @noindent
3054 you not only define global TODO keywords and fast access keys, but also
3055 request that a time is recorded when the entry is turned into
3056 DONE@footnote{It is possible that Org mode will record two time stamps
3057 when you are using both @code{org-log-done} and state change logging.
3058 However, it will never prompt for two notes - if you have configured
3059 both, the state change recording note will take precedence and cancel
3060 the @samp{Closing Note}.}, and that a note is recorded when switching to
3061 WAIT or CANCELED.  The setting for WAIT is even more special: The
3062 @samp{!} after the slash means that in addition to the note taken when
3063 entering the state, a time stamp should be recorded when @i{leaving} the
3064 WAIT state, if and only if the @i{target} state does not configure
3065 logging for entering it.  So it has no effect when switching from WAIT
3066 to DONE, because DONE is configured to record a timestamp only.  But
3067 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3068 setting now triggers a timestamp even though TODO has no logging
3069 configured.
3071 You can use the exact same syntax for setting logging preferences local
3072 to a buffer:
3073 @example
3074 #+SEQ_TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3075 @end example
3077 In order to define logging settings that are local to a subtree or a
3078 single item, define a LOGGING property in this entry.  Any non-empty
3079 LOGGING property resets all logging settings to nil.  You may then turn
3080 on logging for this specific tree using STARTUP keywords like
3081 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3082 settings like @code{TODO(!)}.  For example
3084 @example
3085 * TODO Log each state with only a time
3086   :PROPERTIES:
3087   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3088   :END:
3089 * TODO Only log when switching to WAIT, and when repeating
3090   :PROPERTIES:
3091   :LOGGING: WAIT(@@) logrepeat
3092   :END:
3093 * TODO No logging at all
3094   :PROPERTIES:
3095   :LOGGING: nil
3096   :END:
3097 @end example
3100 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3101 @section Priorities
3102 @cindex priorities
3104 If you use Org mode extensively, you may end up enough TODO items that
3105 it starts to make sense to prioritize them.  Prioritizing can be done by
3106 placing a @emph{priority cookie} into the headline of a TODO item, like
3107 this
3109 @example
3110 *** TODO [#A] Write letter to Sam Fortune
3111 @end example
3113 @noindent
3114 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
3115 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3116 is treated as priority @samp{B}.  Priorities make a difference only in
3117 the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have
3118 no inherent meaning to Org mode.
3120 Priorities can be attached to any outline tree entries; they do not need
3121 to be TODO items.
3123 @table @kbd
3124 @kindex @kbd{C-c ,}
3125 @item @kbd{C-c ,}
3126 Set the priority of the current headline.  The command prompts for a
3127 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3128 @key{SPC} instead, the priority cookie is removed from the headline.
3129 The priorities can also be changed ``remotely'' from the timeline and
3130 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3132 @kindex S-@key{up}
3133 @kindex S-@key{down}
3134 @item S-@key{up}
3135 @itemx S-@key{down}
3136 Increase/decrease priority of current headline@footnote{See also the
3137 option @code{org-priority-start-cycle-with-default'}.}.  Note that these
3138 keys are also used to modify time stamps (@pxref{Creating timestamps}).
3139 Furthermore, these keys are also used by CUA mode (@pxref{Conflicts}).
3140 @end table
3142 You can change the range of allowed priorities by setting the variables
3143 @code{org-highest-priority}, @code{org-lowest-priority}, and
3144 @code{org-default-priority}.  For an individual buffer, you may set
3145 these values (highest, lowest, default) like this (please make sure that
3146 the highest priority is earlier in the alphabet than the lowest
3147 priority):
3149 @example
3150 #+PRIORITIES: A C B
3151 @end example
3153 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3154 @section Breaking tasks down into subtasks
3155 @cindex tasks, breaking down
3157 It is often advisable to break down large tasks into smaller, manageable
3158 subtasks.  You can do this by creating an outline tree below a TODO
3159 item, with detailed subtasks on the tree@footnote{To keep subtasks out
3160 of the global TODO list, see the
3161 @code{org-agenda-todo-list-sublevels}.}.  Another possibility is the use
3162 of checkboxes to identify (a hierarchy of) a large number of subtasks
3163 (@pxref{Checkboxes}).
3166 @node Checkboxes,  , Breaking down tasks, TODO Items
3167 @section Checkboxes
3168 @cindex checkboxes
3170 Every item in a plain list (@pxref{Plain lists}) can be made into a
3171 checkbox by starting it with the string @samp{[ ]}.  This feature is
3172 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3173 Checkboxes are not included into the global TODO list, so they are often
3174 great to split a task into a number of simple steps.  Or you can use
3175 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3176 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3178 Here is an example of a checkbox list.
3180 @example
3181 * TODO Organize party [2/4]
3182   - [-] call people [1/3]
3183     - [ ] Peter
3184     - [X] Sarah
3185     - [ ] Sam
3186   - [X] order food
3187   - [ ] think about what music to play
3188   - [X] talk to the neighbors
3189 @end example
3191 Checkboxes work hierarchically, so if a checkbox item has children that
3192 are checkboxes, toggling one of the children checkboxes will make the
3193 parent checkbox reflect if none, some, or all of the children are
3194 checked.
3196 @cindex statistics, for checkboxes
3197 @cindex checkbox statistics
3198 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are
3199 cookies indicating how many checkboxes present in this entry have been
3200 checked off, and the total number of checkboxes are present.  This can
3201 give you an idea on how many checkboxes remain, even without opening a
3202 folded entry.  The cookies can be placed into a headline or into (the
3203 first line of) a plain list item. Each cookie covers all checkboxes
3204 structurally below the headline/item on which the cookie appear.  You
3205 have to insert the cookie yourself by typing either @samp{[/]} or
3206 @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as in
3207 the examples above.  With @samp{[%]} you get information about the
3208 percentage of checkboxes checked (in the above example, this would be
3209 @samp{[50%]} and @samp{[33%]}, respectively).
3211 @noindent The following commands work with checkboxes:
3213 @table @kbd
3214 @kindex C-c C-c
3215 @item C-c C-c
3216 Toggle checkbox at point.  With a prefix argument, set it to @samp{[-]},
3217 which is considered to be an intermediate state.
3218 @kindex C-c C-x C-b
3219 @item C-c C-x C-b
3220 Toggle checkbox at point.
3221 @itemize @minus
3222 @item
3223 If there is an active region, toggle the first checkbox in the region
3224 and set all remaining boxes to the same status as the first.  If you
3225 want to toggle all boxes in the region independently, use a prefix
3226 argument.
3227 @item
3228 If the cursor is in a headline, toggle checkboxes in the region between
3229 this headline and the next (so @emph{not} the entire subtree).
3230 @item
3231 If there is no active region, just toggle the checkbox at point.
3232 @end itemize
3233 @kindex M-S-@key{RET}
3234 @item M-S-@key{RET}
3235 Insert a new item with a checkbox.
3236 This works only if the cursor is already in a plain list item
3237 (@pxref{Plain lists}).
3238 @kindex C-c #
3239 @item C-c #
3240 Update the checkbox statistics in the current outline entry.  When
3241 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
3242 statistic cookies are updated automatically if you toggle checkboxes
3243 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
3244 delete boxes or add/change them by hand, use this command to get things
3245 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
3246 @end table
3248 @node Tags, Properties and Columns, TODO Items, Top
3249 @chapter Tags
3250 @cindex tags
3251 @cindex headline tagging
3252 @cindex matching, tags
3253 @cindex sparse tree, tag based
3255 An excellent way to implement labels and contexts for cross-correlating
3256 information is to assign @i{tags} to headlines.  Org mode has extensive
3257 support for tags.
3259 Every headline can contain a list of tags; they occur at the end of the
3260 headline.  Tags are normal words containing letters, numbers, @samp{_},
3261 and @samp{@@}.  Tags must be preceded and followed by a single colon,
3262 e.g., @samp{:WORK:}.  Several tags can be specified, as in
3263 @samp{:work:URGENT:}.
3265 @menu
3266 * Tag inheritance::             Tags use the tree structure of the outline
3267 * Setting tags::                How to assign tags to a headline
3268 * Tag searches::                Searching for combinations of tags
3269 @end menu
3271 @node Tag inheritance, Setting tags, Tags, Tags
3272 @section Tag inheritance
3273 @cindex tag inheritance
3274 @cindex inheritance, of tags
3275 @cindex sublevels, inclusion into tags match
3277 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3278 heading has a certain tag, all subheadings will inherit the tag as
3279 well.  For example, in the list
3281 @example
3282 * Meeting with the French group      :work:
3283 ** Summary by Frank                  :boss:notes:
3284 *** TODO Prepare slides for him      :action:
3285 @end example
3287 @noindent
3288 the final heading will have the tags @samp{:work:}, @samp{:boss:},
3289 @samp{:notes:}, and @samp{:action:} even though the final heading is not
3290 explicitly marked with those tags.  When executing tag searches and
3291 Org mode finds that a certain headline matches the search criterion, it
3292 will not check any sublevel headline, assuming that these also match and
3293 that the list of matches could become very long because of that.  If you
3294 do want the sublevels be tested and listed as well, you may set the
3295 variable @code{org-tags-match-list-sublevels}.  To limit tag inheritance
3296 to specific tags, or to turn it off entirely, use the variable
3297 @code{org-use-tag-inheritance}.
3299 @node Setting tags, Tag searches, Tag inheritance, Tags
3300 @section Setting tags
3301 @cindex setting tags
3302 @cindex tags, setting
3304 @kindex M-@key{TAB}
3305 Tags can simply be typed into the buffer at the end of a headline.
3306 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3307 also a special command for inserting tags:
3309 @table @kbd
3310 @kindex C-c C-c
3311 @item C-c C-c
3312 @cindex completion, of tags
3313 Enter new tags for the current headline.  Org mode will either offer
3314 completion or a special single-key interface for setting tags, see
3315 below.  After pressing @key{RET}, the tags will be inserted and aligned
3316 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3317 tags in the current buffer will be aligned to that column, just to make
3318 things look nice.  TAGS are automatically realigned after promotion,
3319 demotion, and TODO state changes (@pxref{TODO basics}).
3320 @end table
3322 Org will support tag insertion based on a @emph{list of tags}.  By
3323 default this list is constructed dynamically, containing all tags
3324 currently used in the buffer.  You may also globally specify a hard list
3325 of tags with the variable @code{org-tag-alist}.  Finally you can set
3326 the default tags for a given file with lines like
3328 @example
3329 #+TAGS: @@work @@home @@tennisclub
3330 #+TAGS: laptop car pc sailboat
3331 @end example
3333 If you have globally defined your preferred set of tags using the
3334 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3335 in a specific file, add an empty TAGS option line to that file:
3337 @example
3338 #+TAGS:
3339 @end example
3341 By default Org mode uses the standard minibuffer completion facilities for
3342 entering tags.  However, it also implements another, quicker, tag selection
3343 method called @emph{fast tag selection}.  This allows you to select and
3344 deselect tags with just a single key press.  For this to work well you should
3345 assign unique letters to most of your commonly used tags.  You can do this
3346 globally by configuring the variable @code{org-tag-alist} in your
3347 @file{.emacs} file.  For example, you may find the need to tag many items in
3348 different files with @samp{:@@home:}.  In this case you can set something
3349 like:
3351 @lisp
3352 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
3353 @end lisp
3355 @noindent If the tag is only relevant to the file you are working on then you
3356 can, instead, set the TAGS option line as:
3358 @example
3359 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
3360 @end example
3362 @noindent
3363 You can also group together tags that are mutually exclusive.  By using
3364 braces, as in:
3366 @example
3367 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
3368 @end example
3370 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
3371 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
3373 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3374 these lines to activate any changes.
3376 @noindent
3377 To set these mutually exclusive groups in the variable @code{org-mode-alist}
3378 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
3379 of the braces.  The previous example would be set globally by the following
3380 configuration:
3382 @lisp
3383 (setq org-tag-alist '((:startgroup . nil)
3384                       ("@@work" . ?w) ("@@home" . ?h)
3385                       ("@@tennisclub" . ?t)
3386                       (:endgroup . nil)
3387                       ("laptop" . ?l) ("pc" . ?p)))
3388 @end lisp
3390 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
3391 automatically present you with a special interface, listing inherited tags,
3392 the tags of the current headline, and a list of all valid tags with
3393 corresponding keys@footnote{Keys will automatically be assigned to tags which
3394 have no configured keys.}.  In this interface, you can use the following
3395 keys:
3397 @table @kbd
3398 @item a-z...
3399 Pressing keys assigned to tags will add or remove them from the list of
3400 tags in the current line.  Selecting a tag in a group of mutually
3401 exclusive tags will turn off any other tags from that group.
3402 @kindex @key{TAB}
3403 @item @key{TAB}
3404 Enter a tag in the minibuffer, even if the tag is not in the predefined
3405 list.  You will be able to complete on all tags present in the buffer.
3406 @kindex @key{SPC}
3407 @item @key{SPC}
3408 Clear all tags for this line.
3409 @kindex @key{RET}
3410 @item @key{RET}
3411 Accept the modified set.
3412 @item C-g
3413 Abort without installing changes.
3414 @item q
3415 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3416 @item !
3417 Turn off groups of mutually exclusive tags.  Use this to (as an
3418 exception) assign several tags from such a group.
3419 @item C-c
3420 Toggle auto-exit after the next change (see below).
3421 If you are using expert mode, the first @kbd{C-c} will display the
3422 selection window.
3423 @end table
3425 @noindent
3426 This method lets you assign tags to a headline with very few keys.  With
3427 the above setup, you could clear the current tags and set @samp{@@home},
3428 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
3429 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
3430 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
3431 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3432 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3433 @key{RET} @key{RET}}.
3435 If you find that most of the time, you need only a single key press to
3436 modify your list of tags, set the variable
3437 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3438 press @key{RET} to exit fast tag selection - it will immediately exit
3439 after the first change.  If you then occasionally need more keys, press
3440 @kbd{C-c} to turn off auto-exit for the current tag selection process
3441 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
3442 C-c}).  If you set the variable to the value @code{expert}, the special
3443 window is not even shown for single-key tag selection, it comes up only
3444 when you press an extra @kbd{C-c}.
3446 @node Tag searches,  , Setting tags, Tags
3447 @section Tag searches
3448 @cindex tag searches
3449 @cindex searching for tags
3451 Once a system of tags has been set up, it can be used to collect related
3452 information into special lists.
3454 @table @kbd
3455 @kindex C-c \
3456 @kindex C-c / T
3457 @item C-c \
3458 @itemx C-c / T
3459 Create a sparse tree with all headlines matching a tags search.  With a
3460 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
3461 @kindex C-c a m
3462 @item C-c a m
3463 Create a global list of tag matches from all agenda files.
3464 @xref{Matching tags and properties}.
3465 @kindex C-c a M
3466 @item C-c a M
3467 Create a global list of tag matches from all agenda files, but check
3468 only TODO items and force checking subitems (see variable
3469 @code{org-tags-match-list-sublevels}).
3470 @end table
3472 @cindex Boolean logic, for tag searches
3473 A @i{tags} search string can use Boolean operators @samp{&} for AND and
3474 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
3475 Parenthesis are currently not implemented.  A tag may also be preceded
3476 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
3477 positive selection.  The AND operator @samp{&} is optional when @samp{+}
3478 or @samp{-} is present.  Examples:
3480 @table @samp
3481 @item +work-boss
3482 Select headlines tagged @samp{:work:}, but discard those also tagged
3483 @samp{:boss:}.
3484 @item work|laptop
3485 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
3486 @item work|laptop&night
3487 Like before, but require the @samp{:laptop:} lines to be tagged also
3488 @samp{:night:}.
3489 @end table
3491 @cindex TODO keyword matching, with tags search
3492 If you are using multi-state TODO keywords (@pxref{TODO extensions}), it
3493 can be useful to also match on the TODO keyword.  This can be done by
3494 adding a condition after a slash to a tags match.  The syntax is similar
3495 to the tag matches, but should be applied with consideration: For
3496 example, a positive selection on several TODO keywords can not
3497 meaningfully be combined with boolean AND.  However, @emph{negative
3498 selection} combined with AND can be meaningful.  To make sure that only
3499 lines are checked that actually have any TODO keyword, use @kbd{C-c a
3500 M}, or equivalently start the TODO part after the slash with @samp{!}.
3501 Examples:
3503 @table @samp
3504 @item work/WAITING
3505 Select @samp{:work:}-tagged TODO lines with the specific TODO
3506 keyword @samp{WAITING}.
3507 @item work/!-WAITING-NEXT
3508 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
3509 nor @samp{NEXT}
3510 @item work/+WAITING|+NEXT
3511 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
3512 @samp{NEXT}.
3513 @end table
3515 @cindex regular expressions, with tags search
3516 Any element of the tag/todo match can be a regular expression - in this
3517 case it must be enclosed in curly braces.  For example,
3518 @samp{work+@{^boss.*@}} matches headlines that contain the tag
3519 @samp{:work:} and any tag @i{starting} with @samp{boss}.
3521 @cindex level, require for tags/property match
3522 @cindex category, require for tags/property match
3523 You can also require a headline to be of a certain level or category, by
3524 writing instead of any TAG an expression like @samp{LEVEL=3} or
3525 @samp{CATEGORY="work"}, respectively.  For example, a search
3526 @samp{+LEVEL=3+boss/-DONE} lists all level three headlines that have the
3527 tag @samp{boss} and are @emph{not} marked with the TODO keyword DONE.
3529 @node Properties and Columns, Dates and Times, Tags, Top
3530 @chapter Properties and Columns
3531 @cindex properties
3533 Properties are a set of key-value pairs associated with an entry.  There
3534 are two main applications for properties in Org mode.  First, properties
3535 are like tags, but with a value.  Second, you can use properties to
3536 implement (very basic) database capabilities in an Org buffer.  For
3537 an example of the first application, imagine maintaining a file where
3538 you document bugs and plan releases of a piece of software.  Instead of
3539 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
3540 property, say @code{:Release:}, that in different subtrees has different
3541 values, such as @code{1.0} or @code{2.0}.  For an example of the second
3542 application of properties, imagine keeping track of your music CD's,
3543 where properties could be things such as the album artist, date of
3544 release, number of tracks, and so on.
3546 Properties can be conveniently edited and viewed in column view
3547 (@pxref{Column view}).
3549 Properties are like tags, but with a value.  For example, in a file
3550 where you document bugs and plan releases of a piece of software,
3551 instead of using tags like @code{:release_1:}, @code{:release_2:}, it
3552 can be more efficient to use a property @code{:Release:} with a value
3553 @code{1.0} or @code{2.0}.  Second, you can use properties to implement
3554 (very basic) database capabilities in an Org buffer, for example to
3555 create a list of Music CD's you own.  You can edit and view properties
3556 conveniently in column view (@pxref{Column view}).
3558 @menu
3559 * Property syntax::             How properties are spelled out
3560 * Special properties::          Access to other Org mode features
3561 * Property searches::           Matching property values
3562 * Property inheritance::        Passing values down the tree
3563 * Column view::                 Tabular viewing and editing
3564 * Property API::                Properties for Lisp programmers
3565 @end menu
3567 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
3568 @section Property syntax
3569 @cindex property syntax
3570 @cindex drawer, for properties
3572 Properties are key-value pairs.  They need to be inserted into a special
3573 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
3574 is specified on a single line, with the key (surrounded by colons)
3575 first, and the value after it.  Here is an example:
3577 @example
3578 * CD collection
3579 ** Classic
3580 *** Goldberg Variations
3581     :PROPERTIES:
3582     :Title:     Goldberg Variations
3583     :Composer:  J.S. Bach
3584     :Artist:    Glen Gould
3585     :Publisher: Deutsche Grammphon
3586     :NDisks:    1
3587     :END:
3588 @end example
3590 You may define the allowed values for a particular property @samp{:Xyz:}
3591 by setting a property @samp{:Xyz_ALL:}.  This special property is
3592 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
3593 the entire tree.  When allowed values are defined, setting the
3594 corresponding property becomes easier and is less prone to typing
3595 errors.  For the example with the CD collection, we can predefine
3596 publishers and the number of disks in a box like this:
3598 @example
3599 * CD collection
3600   :PROPERTIES:
3601   :NDisks_ALL:  1 2 3 4
3602   :Publisher_ALL: "Deutsche Grammophon" Phillips EMI
3603   :END:
3604 @end example
3606 If you want to set properties that can be inherited by any entry in a
3607 file, use a line like
3609 @example
3610 #+PROPERTY: NDisks_ALL 1 2 3 4
3611 @end example
3613 Property values set with the global variable
3614 @code{org-global-properties} can be inherited by all entries in all
3615 Org files.
3617 @noindent
3618 The following commands help to work with properties:
3620 @table @kbd
3621 @kindex M-@key{TAB}
3622 @item M-@key{TAB}
3623 After an initial colon in a line, complete property keys.  All keys used
3624 in the current file will be offered as possible completions.
3625 @kindex C-c C-x p
3626 @item C-c C-x p
3627 Set a property.  This prompts for a property name and a value.  If
3628 necessary, the property drawer is created as well.
3629 @item M-x org-insert-property-drawer
3630 Insert a property drawer into the current entry.  The drawer will be
3631 inserted early in the entry, but after the lines with planning
3632 information like deadlines.
3633 @kindex C-c C-c
3634 @item C-c C-c
3635 With the cursor in a property drawer, this executes property commands.
3636 @item C-c C-c s
3637 Set a property in the current entry.  Both the property and the value
3638 can be inserted using completion.
3639 @kindex S-@key{right}
3640 @kindex S-@key{left}
3641 @item S-@key{left}/@key{right}
3642 Switch property at point to the next/previous allowed value.
3643 @item C-c C-c d
3644 Remove a property from the current entry.
3645 @item C-c C-c D
3646 Globally remove a property, from all entries in the current file.
3647 @item C-c C-c c
3648 Compute the property at point, using the operator and scope from the
3649 nearest column format definition.
3650 @end table
3652 @node Special properties, Property searches, Property syntax, Properties and Columns
3653 @section Special properties
3654 @cindex properties, special
3656 Special properties provide alternative access method to Org mode
3657 features discussed in the previous chapters, like the TODO state or the
3658 priority of an entry.  This interface exists so that you can include
3659 these states into columns view (@pxref{Column view}), or to use them in
3660 queries.  The following property names are special and should not be
3661 used as keys in the properties drawer:
3663 @example
3664 TODO         @r{The TODO keyword of the entry.}
3665 TAGS         @r{The tags defined directly in the headline.}
3666 ALLTAGS      @r{All tags, including inherited ones.}
3667 PRIORITY     @r{The priority of the entry, a string with a single letter.}
3668 DEADLINE     @r{The deadline time string, without the angular brackets.}
3669 SCHEDULED    @r{The scheduling time stamp, without the angular brackets.}
3670 TIMESTAMP    @r{The first keyword-less time stamp in the entry.}
3671 TIMESTAMP_IA @r{The first inactive time stamp in the entry.}
3672 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
3673              @r{must be run first to compute the values.}
3674 @end example
3676 @node Property searches, Property inheritance, Special properties, Properties and Columns
3677 @section Property searches
3678 @cindex properties, searching
3679 @cindex searching, of properties
3681 To create sparse trees and special lists with selection based on properties,
3682 the same commands are used as for tag searches (@pxref{Tag searches}), and
3683 the same logic applies.  For example, here is a search string:
3685 @example
3686 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2+With=@{Sarah\|Denny@}
3687 @end example
3689 @noindent
3690 If the comparison value is a plain number, a numerical comparison is done,
3691 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
3692 @samp{>=}, and @samp{<>}.  If the comparison value is enclosed in double
3693 quotes, a string comparison is done, and the same operators are allowed.  If
3694 the comparison value is enclosed in curly braces, a regexp match is
3695 performed, with @samp{=} meaning that the regexp matches the property value,
3696 and @samp{<>} meaning that it does not match.  So the search string in the
3697 example finds entries tagged @samp{:work:} but not @samp{:boss:}, which also
3698 have a priority value @samp{A}, a @samp{:Coffee:} property with the value
3699 @samp{unlimited}, an @samp{Effort} property that is numerically smaller than
3700 2, and a @samp{:With:} property that is matched by the regular expression
3701 @samp{Sarah\|Denny}.
3703 You can configure Org mode to use property inheritance during a search, but
3704 beware that this can slow down searches considerably.  See @ref{Property
3705 inheritance} for details.
3707 There is also a special command for creating sparse trees based on a
3708 single property:
3710 @table @kbd
3711 @kindex C-c / p
3712 @item C-c / p
3713 Create a sparse tree based on the value of a property.  This first
3714 prompts for the name of a property, and then for a value.  A sparse tree
3715 is created with all entries that define this property with the given
3716 value.  If you enclose the value into curly braces, it is interpreted as
3717 a regular expression and matched against the property values.
3718 @end table
3720 @node Property inheritance, Column view, Property searches, Properties and Columns
3721 @section Property Inheritance
3722 @cindex properties, inheritance
3723 @cindex inheritance, of properties
3725 The outline structure of Org mode documents lends itself for an
3726 inheritance model of properties: If the parent in a tree has a certain
3727 property, the children can inherit this property.  Org mode does not
3728 turn this on by default, because it can slow down property searches
3729 significantly and is often not needed.  However, if you find inheritance
3730 useful, you can turn it on by setting the variable
3731 @code{org-use-property-inheritance}.  It may be set to @code{t}, to make
3732 all properties inherited from the parent, to a list of properties
3733 that should be inherited, or to a regular expression that matches
3734 inherited properties.
3736 Org mode has a few properties for which inheritance is hard-coded, at
3737 least for the special applications for which they are used:
3739 @table @code
3740 @item COLUMNS
3741 The @code{:COLUMNS:} property defines the format of column view
3742 (@pxref{Column view}).  It is inherited in the sense that the level
3743 where a @code{:COLUMNS:} property is defined is used as the starting
3744 point for a column view table, independently of the location in the
3745 subtree from where columns view is turned on.
3746 @item CATEGORY
3747 For agenda view, a category set through a @code{:CATEGORY:} property
3748 applies to the entire subtree.
3749 @item ARCHIVE
3750 For archiving, the @code{:ARCHIVE:} property may define the archive
3751 location for the entire subtree (@pxref{Moving subtrees}).
3752 @item LOGGING
3753 The LOGGING property may define logging settings for an entry or a
3754 subtree (@pxref{Tracking TODO state changes}).
3755 @end table
3757 @node Column view, Property API, Property inheritance, Properties and Columns
3758 @section Column view
3760 A great way to view and edit properties in an outline tree is
3761 @emph{column view}.  In column view, each outline item is turned into a
3762 table row.  Columns in this table provide access to properties of the
3763 entries.  Org mode implements columns by overlaying a tabular structure
3764 over the headline of each item.  While the headlines have been turned
3765 into a table row, you can still change the visibility of the outline
3766 tree.  For example, you get a compact table by switching to CONTENTS
3767 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
3768 is active), but you can still open, read, and edit the entry below each
3769 headline.  Or, you can switch to column view after executing a sparse
3770 tree command and in this way get a table only for the selected items.
3771 Column view also works in agenda buffers (@pxref{Agenda Views}) where
3772 queries have collected selected items, possibly from a number of files.
3774 @menu
3775 * Defining columns::            The COLUMNS format property
3776 * Using column view::           How to create and use column view
3777 * Capturing column view::       A dynamic block for column view
3778 @end menu
3780 @node Defining columns, Using column view, Column view, Column view
3781 @subsection Defining columns
3782 @cindex column view, for properties
3783 @cindex properties, column view
3785 Setting up a column view first requires defining the columns.  This is
3786 done by defining a column format line.
3788 @menu
3789 * Scope of column definitions::  Where defined, where valid?
3790 * Column attributes::           Appearance and content of a column
3791 @end menu
3793 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
3794 @subsubsection Scope of column definitions
3796 To define a column format for an entire file, use a line like
3798 @example
3799 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3800 @end example
3802 To specify a format that only applies to a specific tree, add a
3803 @code{:COLUMNS:} property to the top node of that tree, for example:
3805 @example
3806 ** Top node for columns view
3807    :PROPERTIES:
3808    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3809    :END:
3810 @end example
3812 If a @code{:COLUMNS:} property is present in an entry, it defines columns
3813 for the entry itself, and for the entire subtree below it.  Since the
3814 column definition is part of the hierarchical structure of the document,
3815 you can define columns on level 1 that are general enough for all
3816 sublevels, and more specific columns further down, when you edit a
3817 deeper part of the tree.
3819 @node Column attributes,  , Scope of column definitions, Defining columns
3820 @subsubsection Column attributes
3821 A column definition sets the attributes of a column.  The general
3822 definition looks like this:
3824 @example
3825  %[width]property[(title)][@{summary-type@}]
3826 @end example
3828 @noindent
3829 Except for the percent sign and the property name, all items are
3830 optional.  The individual parts have the following meaning:
3832 @example
3833 width           @r{An integer specifying the width of the column in characters.}
3834                 @r{If omitted, the width will be determined automatically.}
3835 property        @r{The property that should be edited in this column.}
3836 (title)         @r{The header text for the column. If omitted, the}
3837                 @r{property name is used.}
3838 @{summary-type@}  @r{The summary type.  If specified, the column values for}
3839                 @r{parent nodes are computed from the children.}
3840                 @r{Supported summary types are:}
3841                 @{+@}       @r{Sum numbers in this column.}
3842                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
3843                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
3844                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
3845                 @{X@}       @r{Checkbox status, [X] if all children are [X].}
3846                 @{X/@}      @r{Checkbox status, [n/m].}
3847                 @{X%@}      @r{Checkbox status, [n%].}
3848 @end example
3850 @noindent
3851 Here is an example for a complete columns definition, along with allowed
3852 values.
3854 @example
3855 :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.}
3856                    %10Time_Estimate@{:@} %CLOCKSUM
3857 :Owner_ALL:    Tammy Mark Karl Lisa Don
3858 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
3859 :Approved_ALL: "[ ]" "[X]"
3860 @end example
3862 The first column, @samp{%25ITEM}, means the first 25 characters of the
3863 item itself, i.e. of the headline.  You probably always should start the
3864 column definition with the @samp{ITEM} specifier.  The other specifiers
3865 create columns @samp{Owner} with a list of names as allowed values, for
3866 @samp{Status} with four different possible values, and for a checkbox
3867 field @samp{Approved}.  When no width is given after the @samp{%}
3868 character, the column will be exactly as wide as it needs to be in order
3869 to fully display all values.  The @samp{Approved} column does have a
3870 modified title (@samp{Approved?}, with a question mark).  Summaries will
3871 be created for the @samp{Time_Estimate} column by adding time duration
3872 expressions like HH:MM, and for the @samp{Approved} column, by providing
3873 an @samp{[X]} status if all children have been checked.  The
3874 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
3875 in the subtree.
3877 @node Using column view, Capturing column view, Defining columns, Column view
3878 @subsection Using column view
3880 @table @kbd
3881 @tsubheading{Turning column view on and off}
3882 @kindex C-c C-x C-c
3883 @item C-c C-x C-c
3884 Create the column view for the local environment.  This command searches
3885 the hierarchy, up from point, for a @code{:COLUMNS:} property that defines
3886 a format.  When one is found, the column view table is established for
3887 the entire tree, starting from the entry that contains the @code{:COLUMNS:}
3888 property.  If none is found, the format is taken from the @code{#+COLUMNS}
3889 line or from the variable @code{org-columns-default-format}, and column
3890 view is established for the current entry and its subtree.
3891 @kindex r
3892 @item r
3893 Recreate the column view, to include recent changes made in the buffer.
3894 @kindex g
3895 @item g
3896 Same as @kbd{r}.
3897 @kindex q
3898 @item q
3899 Exit column view.
3900 @tsubheading{Editing values}
3901 @item @key{left} @key{right} @key{up} @key{down}
3902 Move through the column view from field to field.
3903 @kindex S-@key{left}
3904 @kindex S-@key{right}
3905 @item  S-@key{left}/@key{right}
3906 Switch to the next/previous allowed value of the field.  For this, you
3907 have to have specified allowed values for a property.
3908 @kindex n
3909 @kindex p
3910 @itemx  n / p
3911 Same as @kbd{S-@key{left}/@key{right}}
3912 @kindex e
3913 @item e
3914 Edit the property at point.  For the special properties, this will
3915 invoke the same interface that you normally use to change that
3916 property.  For example, when editing a TAGS property, the tag completion
3917 or fast selection interface will pop up.
3918 @kindex C-c C-c
3919 @item C-c C-c
3920 When there is a checkbox at point, toggle it.
3921 @kindex v
3922 @item v
3923 View the full value of this property.  This is useful if the width of
3924 the column is smaller than that of the value.
3925 @kindex a
3926 @item a
3927 Edit the list of allowed values for this property.  If the list is found
3928 in the hierarchy, the modified values is stored there.  If no list is
3929 found, the new value is stored in the first entry that is part of the
3930 current column view.
3931 @tsubheading{Modifying the table structure}
3932 @kindex <
3933 @kindex >
3934 @item < / >
3935 Make the column narrower/wider by one character.
3936 @kindex S-M-@key{right}
3937 @item S-M-@key{right}
3938 Insert a new column, to the right of the current column.
3939 @kindex S-M-@key{left}
3940 @item S-M-@key{left}
3941 Delete the current column.
3942 @end table
3944 @node Capturing column view,  , Using column view, Column view
3945 @subsection Capturing column view
3947 Since column view is just an overlay over a buffer, it cannot be
3948 exported or printed directly.  If you want to capture a column view, use
3949 this @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
3950 of this block looks like this:
3952 @example
3953 * The column view
3954 #+BEGIN: columnview :hlines 1 :id "label"
3956 #+END:
3957 @end example
3959 @noindent This dynamic block has the following parameters:
3961 @table @code
3962 @item :id
3963 This is most important parameter.  Column view is a feature that is
3964 often localized to a certain (sub)tree, and the capture block might be
3965 in a different location in the file.  To identify the tree whose view to
3966 capture, you can use 3 values:
3967 @example
3968 local     @r{use the tree in which the capture block is located}
3969 global    @r{make a global view, including all headings in the file}
3970 "label"   @r{call column view in the tree that has and @code{:ID:}}
3971           @r{property with the value @i{label}}
3972 @end example
3973 @item :hlines
3974 When @code{t}, insert a hline after every line.  When a number N, insert
3975 a hline before each headline with level @code{<= N}.
3976 @item :vlines
3977 When set to @code{t}, enforce column groups to get vertical lines.
3978 @item :maxlevel
3979 When set to a number, don't capture entries below this level.
3980 @item :skip-empty-rows
3981 When set to @code{t}, skip row where the only non-empty specifier of the
3982 column view is @code{ITEM}.
3984 @end table
3986 @noindent
3987 The following commands insert or update the dynamic block:
3989 @table @kbd
3990 @kindex C-c C-x r
3991 @item C-c C-x r
3992 Insert a dynamic block capturing a column view.  You will be prompted
3993 for the scope or id of the view.
3994 @kindex C-c C-c
3995 @item C-c C-c
3996 @kindex C-c C-x C-u
3997 @itemx C-c C-x C-u
3998 Update dynamical block at point.  The cursor needs to be in the
3999 @code{#+BEGIN} line of the dynamic block.
4000 @kindex C-u C-c C-x C-u
4001 @item C-u C-c C-x C-u
4002 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4003 you have several clock table blocks in a buffer.
4004 @end table
4006 @node Property API,  , Column view, Properties and Columns
4007 @section The Property API
4008 @cindex properties, API
4009 @cindex API, for properties
4011 There is a full API for accessing and changing properties.  This API can
4012 be used by Emacs Lisp programs to work with properties and to implement
4013 features based on them.  For more information see @ref{Using the
4014 property API}.
4016 @node Dates and Times, Remember, Properties and Columns, Top
4017 @chapter Dates and Times
4018 @cindex dates
4019 @cindex times
4020 @cindex time stamps
4021 @cindex date stamps
4023 To assist project planning, TODO items can be labeled with a date and/or
4024 a time.  The specially formatted string carrying the date and time
4025 information is called a @emph{timestamp} in Org mode.  This may be a
4026 little confusing because timestamp is often used as indicating when
4027 something was created or last changed.  However, in Org mode this term
4028 is used in a much wider sense.
4030 @menu
4031 * Timestamps::                  Assigning a time to a tree entry
4032 * Creating timestamps::         Commands which insert timestamps
4033 * Deadlines and scheduling::    Planning your work
4034 * Clocking work time::          Tracking how long you spend on a task
4035 * Effort estimates::            Planning work effort in advance
4036 @end menu
4039 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4040 @section Timestamps, deadlines and scheduling
4041 @cindex time stamps
4042 @cindex ranges, time
4043 @cindex date stamps
4044 @cindex deadlines
4045 @cindex scheduling
4047 A time stamp is a specification of a date (possibly with time or a range
4048 of times) in a special format, either @samp{<2003-09-16 Tue>} or
4049 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4050 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
4051 use an alternative format, see @ref{Custom time format}.}.  A time stamp
4052 can appear anywhere in the headline or body of an Org tree entry.  Its
4053 presence causes entries to be shown on specific dates in the agenda
4054 (@pxref{Weekly/daily agenda}).  We distinguish:
4056 @table @var
4057 @item Plain time stamp; Event; Appointment
4058 @cindex timestamp
4059 A simple time stamp just assigns a date/time to an item.  This is just
4060 like writing down an appointment or event in a paper agenda.  In the
4061 timeline and agenda displays, the headline of an entry associated with a
4062 plain time stamp will be shown exactly on that date.
4064 @example
4065 * Meet Peter at the movies <2006-11-01 Wed 19:15>
4066 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
4067 @end example
4069 @item Time stamp with repeater interval
4070 @cindex timestamp, with repeater interval
4071 A time stamp may contain a @emph{repeater interval}, indicating that it
4072 applies not only on the given date, but again and again after a certain
4073 interval of N days (d), weeks (w), months(m), or years(y).  The
4074 following will show up in the agenda every Wednesday:
4076 @example
4077 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4078 @end example
4080 @item Diary-style sexp entries
4081 For more complex date specifications, Org mode supports using the
4082 special sexp diary entries implemented in the Emacs calendar/diary
4083 package.  For example
4085 @example
4086 * The nerd meeting on every 2nd Thursday of the month
4087   <%%(diary-float t 4 2)>
4088 @end example
4090 @item Time/Date range
4091 @cindex timerange
4092 @cindex date range
4093 Two time stamps connected by @samp{--} denote a range.  The headline
4094 will be shown on the first and last day of the range, and on any dates
4095 that are displayed and fall in the range.  Here is an example:
4097 @example
4098 ** Meeting in Amsterdam
4099    <2004-08-23 Mon>--<2004-08-26 Thu>
4100 @end example
4102 @item Inactive time stamp
4103 @cindex timestamp, inactive
4104 @cindex inactive timestamp
4105 Just like a plain time stamp, but with square brackets instead of
4106 angular ones.  These time stamps are inactive in the sense that they do
4107 @emph{not} trigger an entry to show up in the agenda.
4109 @example
4110 * Gillian comes late for the fifth time [2006-11-01 Wed]
4111 @end example
4113 @end table
4115 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
4116 @section Creating timestamps
4117 @cindex creating timestamps
4118 @cindex timestamps, creating
4120 For Org mode to recognize time stamps, they need to be in the specific
4121 format.  All commands listed below produce time stamps in the correct
4122 format.
4124 @table @kbd
4125 @kindex C-c .
4126 @item C-c .
4127 Prompt for a date and insert a corresponding time stamp.  When the
4128 cursor is at a previously used time stamp, it is updated to NOW.  When
4129 this command is used twice in succession, a time range is inserted.
4131 @kindex C-u C-c .
4132 @item C-u C-c .
4133 Like @kbd{C-c .}, but use the alternative format which contains date
4134 and time.  The default time can be rounded to multiples of 5 minutes,
4135 see the option @code{org-time-stamp-rounding-minutes}.
4137 @kindex C-c !
4138 @item C-c !
4139 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
4140 an agenda entry.
4142 @kindex C-c <
4143 @item C-c <
4144 Insert a time stamp corresponding to the cursor date in the Calendar.
4146 @kindex C-c >
4147 @item C-c >
4148 Access the Emacs calendar for the current date.  If there is a
4149 timestamp in the current line, go to the corresponding date
4150 instead.
4152 @kindex C-c C-o
4153 @item C-c C-o
4154 Access the agenda for the date given by the time stamp or -range at
4155 point (@pxref{Weekly/daily agenda}).
4157 @kindex S-@key{left}
4158 @kindex S-@key{right}
4159 @item S-@key{left}
4160 @itemx S-@key{right}
4161 Change date at cursor by one day.  These key bindings conflict with
4162 CUA mode (@pxref{Conflicts}).
4164 @kindex S-@key{up}
4165 @kindex S-@key{down}
4166 @item S-@key{up}
4167 @itemx S-@key{down}
4168 Change the item under the cursor in a timestamp.  The cursor can be on a
4169 year, month, day, hour or minute.  Note that if the cursor is in a
4170 headline and not at a time stamp, these same keys modify the priority of
4171 an item.  (@pxref{Priorities}). The key bindings also conflict with
4172 CUA mode (@pxref{Conflicts}).
4174 @kindex C-c C-y
4175 @cindex evaluate time range
4176 @item C-c C-y
4177 Evaluate a time range by computing the difference between start and end.
4178 With a prefix argument, insert result after the time range (in a table: into
4179 the following column).
4180 @end table
4183 @menu
4184 * The date/time prompt::        How Org mode helps you entering date and time
4185 * Custom time format::          Making dates look different
4186 @end menu
4188 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
4189 @subsection The date/time prompt
4190 @cindex date, reading in minibuffer
4191 @cindex time, reading in minibuffer
4193 When Org mode prompts for a date/time, the default is shown as an ISO
4194 date, and the prompt therefore seems to ask for an ISO date.  But it
4195 will in fact accept any string containing some date and/or time
4196 information, and it is really smart about interpreting your input.  You
4197 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
4198 copied from an email message.  Org mode will find whatever information
4199 is in there and derive anything you have not specified from the
4200 @emph{default date and time}.  The default is usually the current date
4201 and time, but when modifying an existing time stamp, or when entering
4202 the second stamp of a range, it is taken from the stamp in the buffer.
4203 When filling in information, Org mode assumes that most of the time you
4204 will want to enter a date in the future: If you omit the month/year and
4205 the given day/month is @i{before} today, it will assume that you mean a
4206 future date@footnote{See the variable
4207 @code{org-read-date-prefer-future}.}.
4209 For example, lets assume that today is @b{June 13, 2006}.  Here is how
4210 various inputs will be interpreted, the items filled in by Org mode are
4211 in @b{bold}.
4213 @example
4214 3-2-5         --> 2003-02-05
4215 14            --> @b{2006}-@b{06}-14
4216 12            --> @b{2006}-@b{07}-12
4217 Fri           --> nearest Friday (defaultdate or later)
4218 sep 15        --> @b{2006}-11-15
4219 feb 15        --> @b{2007}-02-15
4220 sep 12 9      --> 2009-09-12
4221 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
4222 22 sept 0:34  --> @b{2006}-09-22 0:34
4223 w4            --> ISO week for of the current year @b{2006}
4224 2012 w4 fri   --> Friday of ISO week 4 in 2012
4225 2012-w04-5    --> Same as above
4226 @end example
4228 Furthermore you can specify a relative date by giving, as the
4229 @emph{first} thing in the input: a plus/minus sign, a number and a
4230 letter [dwmy] to indicate change in days weeks, months, years.  With a
4231 single plus or minus, the date is always relative to today.  With a
4232 double plus or minus, it is relative to the default date.  If instead of
4233 a single letter, you use the abbreviation of day name, the date will be
4234 the nth such day.  E.g.
4236 @example
4237 +0            --> today
4238 .             --> today
4239 +4d           --> four days from today
4240 +4            --> same as above
4241 +2w           --> two weeks from today
4242 ++5           --> five days from default date
4243 +2tue         --> second tuesday from now.
4244 @end example
4246 The function understands English month and weekday abbreviations.  If
4247 you want to use unabbreviated names and/or other languages, configure
4248 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
4250 @cindex calendar, for selecting date
4251 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
4252 you don't need/want the calendar, configure the variable
4253 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
4254 prompt, either by clicking on a date in the calendar, or by pressing
4255 @key{RET}, the date selected in the calendar will be combined with the
4256 information entered at the prompt.  You can control the calendar fully
4257 from the minibuffer:
4259 @kindex <
4260 @kindex >
4261 @kindex mouse-1
4262 @kindex S-@key{right}
4263 @kindex S-@key{left}
4264 @kindex S-@key{down}
4265 @kindex S-@key{up}
4266 @kindex M-S-@key{right}
4267 @kindex M-S-@key{left}
4268 @kindex @key{RET}
4269 @example
4270 > / <          @r{Scroll calendar forward/backward by one month.}
4271 mouse-1        @r{Select date by clicking on it.}
4272 S-@key{right}/@key{left}     @r{One day forward/backward.}
4273 S-@key{down}/@key{up}     @r{One week forward/backward.}
4274 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
4275 @key{RET}           @r{Choose date in calendar.}
4276 @end example
4278 The actions of the date/time prompt may seem complex, but I assure you they
4279 will grow on you, and you will start getting annoyed by pretty much any other
4280 way of entering a date/time out there.  To help you understand what is going
4281 on, the current interpretation of your input will be displayed live in the
4282 minibuffer@footnote{If you find this distracting, turn the display of with
4283 @code{org-read-date-display-live}.}.
4285 @node Custom time format,  , The date/time prompt, Creating timestamps
4286 @subsection Custom time format
4287 @cindex custom date/time format
4288 @cindex time format, custom
4289 @cindex date format, custom
4291 Org mode uses the standard ISO notation for dates and times as it is
4292 defined in ISO 8601.  If you cannot get used to this and require another
4293 representation of date and time to keep you happy, you can get it by
4294 customizing the variables @code{org-display-custom-times} and
4295 @code{org-time-stamp-custom-formats}.
4297 @table @kbd
4298 @kindex C-c C-x C-t
4299 @item C-c C-x C-t
4300 Toggle the display of custom formats for dates and times.
4301 @end table
4303 @noindent
4304 Org mode needs the default format for scanning, so the custom date/time
4305 format does not @emph{replace} the default format - instead it is put
4306 @emph{over} the default format using text properties.  This has the
4307 following consequences:
4308 @itemize @bullet
4309 @item
4310 You cannot place the cursor onto a time stamp anymore, only before or
4311 after.
4312 @item
4313 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
4314 each component of a time stamp.  If the cursor is at the beginning of
4315 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
4316 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
4317 time will be changed by one minute.
4318 @item
4319 If the time stamp contains a range of clock times or a repeater, these
4320 will not be overlayed, but remain in the buffer as they were.
4321 @item
4322 When you delete a time stamp character-by-character, it will only
4323 disappear from the buffer after @emph{all} (invisible) characters
4324 belonging to the ISO timestamp have been removed.
4325 @item
4326 If the custom time stamp format is longer than the default and you are
4327 using dates in tables, table alignment will be messed up.  If the custom
4328 format is shorter, things do work as expected.
4329 @end itemize
4332 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
4333 @section Deadlines and scheduling
4335 A time stamp may be preceded by special keywords to facilitate planning:
4337 @table @var
4338 @item DEADLINE
4339 @cindex DEADLINE keyword
4341 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
4342 to be finished on that date.
4344 On the deadline date, the task will be listed in the agenda.  In
4345 addition, the agenda for @emph{today} will carry a warning about the
4346 approaching or missed deadline, starting
4347 @code{org-deadline-warning-days} before the due date, and continuing
4348 until the entry is marked DONE.  An example:
4350 @example
4351 *** TODO write article about the Earth for the Guide
4352     The editor in charge is [[bbdb:Ford Prefect]]
4353     DEADLINE: <2004-02-29 Sun>
4354 @end example
4356 You can specify a different lead time for warnings for a specific
4357 deadlines using the following syntax.  Here is an example with a warning
4358 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
4360 @item SCHEDULED
4361 @cindex SCHEDULED keyword
4363 Meaning: you are planning to start working on that task on the given
4364 date.
4366 The headline will be listed under the given date@footnote{It will still
4367 be listed on that date after it has been marked DONE.  If you don't like
4368 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
4369 addition, a reminder that the scheduled date has passed will be present
4370 in the compilation for @emph{today}, until the entry is marked DONE.
4371 I.e., the task will automatically be forwarded until completed.
4373 @example
4374 *** TODO Call Trillian for a date on New Years Eve.
4375     SCHEDULED: <2004-12-25 Sat>
4376 @end example
4378 @noindent
4379 @b{Important:} Scheduling an item in Org mode should @i{not} be
4380 understood in the same way that we understand @i{scheduling a meeting}.
4381 Setting a date for a meeting is just a simple appointment, you should
4382 mark this entry with a simple plain time stamp, to get this item shown
4383 on the date where it applies.  This is a frequent mis-understanding from
4384 Org-users.  In Org mode, @i{scheduling} means setting a date when you
4385 want to start working on an action item.
4386 @end table
4388 You may use time stamps with repeaters in scheduling and deadline
4389 entries.  Org mode will issue early and late warnings based on the
4390 assumption that the time stamp represents the @i{nearest instance} of
4391 the repeater.  However, the use of diary sexp entries like
4393 @code{<%%(diary-float t 42)>}
4395 in scheduling and deadline timestamps is limited.  Org mode does not
4396 know enough about the internals of each sexp function to issue early and
4397 late warnings.  However, it will show the item on each day where the
4398 sexp entry matches.
4400 @menu
4401 * Inserting deadline/schedule::  Planning items
4402 * Repeated tasks::              Items that show up again and again
4403 @end menu
4405 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
4406 @subsection Inserting deadlines or schedules
4408 The following commands allow to quickly insert a deadline or to schedule
4409 an item:
4411 @table @kbd
4413 @kindex C-c C-d
4414 @item C-c C-d
4415 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
4416 happen in the line directly following the headline.  When called with a
4417 prefix arg, an existing deadline will be removed from the entry.
4418 @c FIXME Any CLOSED timestamp will be removed.????????
4420 @kindex C-c / d
4421 @cindex sparse tree, for deadlines
4422 @item C-c / d
4423 Create a sparse tree with all deadlines that are either past-due, or
4424 which will become due within @code{org-deadline-warning-days}.
4425 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
4426 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
4427 all deadlines due tomorrow.
4429 @kindex C-c C-s
4430 @item C-c C-s
4431 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
4432 happen in the line directly following the headline.  Any CLOSED
4433 timestamp will be removed.  When called with a prefix argument, remove
4434 the scheduling date from the entry.
4435 @end table
4437 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
4438 @subsection Repeated tasks
4440 Some tasks need to be repeated again and again.  Org mode helps to
4441 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
4442 or plain time stamp.  In the following example
4443 @example
4444 ** TODO Pay the rent
4445    DEADLINE: <2005-10-01 Sat +1m>
4446 @end example
4447 the @code{+1m} is a repeater; the intended interpretation is that the
4448 task has a deadline on <2005-10-01> and repeats itself every (one) month
4449 starting from that time.  If you need both a repeater and a special
4450 warning period in a deadline entry, the repeater comes first and the
4451 warning period last: @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
4453 Deadlines and scheduled items produce entries in the agenda when they
4454 are over-due, so it is important to be able to mark such an entry as
4455 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
4456 with the TODO keyword DONE, it will no longer produce entries in the
4457 agenda.  The problem with this is, however, that then also the
4458 @emph{next} instance of the repeated entry will not be active.  Org mode
4459 deals with this in the following way: When you try to mark such an entry
4460 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
4461 time stamp by the repeater interval, and immediately set the entry state
4462 back to TODO.  In the example above, setting the state to DONE would
4463 actually switch the date like this:
4465 @example
4466 ** TODO Pay the rent
4467    DEADLINE: <2005-11-01 Tue +1m>
4468 @end example
4470 A timestamp@footnote{You can change this using the option
4471 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
4472 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
4473 will aslo be prompted for a note.} will be added under the deadline, to keep
4474 a record that you actually acted on the previous instance of this deadline.
4476 As a consequence of shifting the base date, this entry will no longer be
4477 visible in the agenda when checking past dates, but all future instances
4478 will be visible.
4480 With the @samp{+1m} cookie, the date shift will always be exactly one
4481 month.  So if you have not payed the rent for three months, marking this
4482 entry DONE will still keep it as an overdue deadline.  Depending on the
4483 task, this may not be the best way to handle it.  For example, if you
4484 forgot to call you father for 3 weeks, it does not make sense to call
4485 him 3 times in a single day to make up for it.  Finally, there are tasks
4486 like changing batteries which should always repeat a certain time
4487 @i{after} the last time you did it.  For these tasks, Org mode has
4488 special repeaters markers with @samp{++} and @samp{.+}.  For example:
4490 @example
4491 ** TODO Call Father
4492    DEADLINE: <2008-02-10 Sun ++1w>
4493    Marking this DONE will shift the date by at least one week,
4494    but also by as many weeks as it takes to get this date into
4495    the future.  However, it stays on a Sunday, even if you called
4496    and marked it done on Saturday.
4497 ** TODO Check the batteries in the smoke detectors
4498    DEADLINE: <2005-11-01 Tue .+1m>
4499    Marking this DONE will shift the date to one month after
4500    today.
4501 @end example
4503 You may have both scheduling and deadline information for a specific
4504 task - just make sure that the repeater intervals on both are the same.
4506 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
4507 @section Clocking work time
4509 Org mode allows you to clock the time you spent on specific tasks in a
4510 project.  When you start working on an item, you can start the clock.
4511 When you stop working on that task, or when you mark the task done, the
4512 clock is stopped and the corresponding time interval is recorded.  It
4513 also computes the total time spent on each subtree of a project.
4515 @table @kbd
4516 @kindex C-c C-x C-i
4517 @item C-c C-x C-i
4518 Start the clock on the current item (clock-in).  This inserts the CLOCK
4519 keyword together with a timestamp.  If this is not the first clocking of
4520 this item, the multiple CLOCK lines will be wrapped into a
4521 @code{:CLOCK:} drawer (see also the variable
4522 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
4523 select the task from a list of recently clocked tasks.  With two @kbd{C-u
4524 C-u} prefixes, clock into the task at point and mark it as the default task.
4525 The default task will always be available when selecting a clocking task,
4526 with letter @kbd{d}.
4527 @kindex C-c C-x C-o
4528 @item C-c C-x C-o
4529 Stop the clock (clock-out).  The inserts another timestamp at the same
4530 location where the clock was last started.  It also directly computes
4531 the resulting time in inserts it after the time range as @samp{=>
4532 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
4533 possibility to record an additional note together with the clock-out
4534 time stamp@footnote{The corresponding in-buffer setting is:
4535 @code{#+STARTUP: lognoteclock-out}}.
4536 @kindex C-c C-y
4537 @item C-c C-y
4538 Recompute the time interval after changing one of the time stamps.  This
4539 is only necessary if you edit the time stamps directly.  If you change
4540 them with @kbd{S-@key{cursor}} keys, the update is automatic.
4541 @kindex C-c C-t
4542 @item C-c C-t
4543 Changing the TODO state of an item to DONE automatically stops the clock
4544 if it is running in this same item.
4545 @kindex C-c C-x C-x
4546 @item C-c C-x C-x
4547 Cancel the current clock.  This is useful if a clock was started by
4548 mistake, or if you ended up working on something else.
4549 @kindex C-c C-x C-j
4550 @item C-c C-x C-j
4551 Jump to the entry that contains the currently running clock.  With a
4552 @kbd{C-u} prefix arg, select the target task from a list of recently clocked
4553 tasks.
4554 @kindex C-c C-x C-d
4555 @item C-c C-x C-d
4556 Display time summaries for each subtree in the current buffer.  This
4557 puts overlays at the end of each headline, showing the total time
4558 recorded under that heading, including the time of any subheadings. You
4559 can use visibility cycling to study the tree, but the overlays disappear
4560 when you change the buffer (see variable
4561 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
4562 @kindex C-c C-x C-r
4563 @item C-c C-x C-r
4564 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
4565 report as an Org mode table into the current file.  When the cursor is
4566 at an existing clock table, just update it.  When called with a prefix
4567 argument, jump to the first clock report in the current document and
4568 update it.
4569 @example
4570 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
4571 #+END: clocktable
4572 @end example
4573 @noindent
4574 If such a block already exists at point, its content is replaced by the
4575 new table.  The @samp{BEGIN} line can specify options:
4576 @example
4577 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
4578 :emphasize   @r{When @code{t}, emphasize level one and level two items}
4579 :scope       @r{The scope to consider.  This can be any of the following:}
4580              nil        @r{the current buffer or narrowed region}
4581              file       @r{the full current buffer}
4582              subtree    @r{the subtree where the clocktable is located}
4583              treeN      @r{the surrounding level N tree, for example @code{tree3}}
4584              tree       @r{the surrounding level 1 tree}
4585              agenda     @r{all agenda files}
4586              ("file"..) @r{scan these files}
4587              file-with-archives    @r{current file and its archives}
4588              agenda-with-archives  @r{all agenda files, including archives}
4589 :block       @r{The time block to consider.  This block is specified either}
4590              @r{absolute, or relative to the current time and may be any of}
4591              @r{these formats:}
4592              2007-12-31    @r{New year eve 2007}
4593              2007-12       @r{December 2007}
4594              2007-W50      @r{ISO-week 50 in 2007}
4595              2007          @r{the year 2007}
4596              today, yesterday, today-N          @r{a relative day}
4597              thisweek, lastweek, thisweek-N     @r{a relative week}
4598              thismonth, lastmonth, thismonth-N  @r{a relative month}
4599              thisyear, lastyear, thisyear-N     @r{a relative year}
4600              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
4601 :tstart      @r{A time string specifying when to start considering times}
4602 :tend        @r{A time string specifying when to stop considering times}
4603 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
4604              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
4605 :link        @r{Link the item headlines in the table to their origins}
4606 @end example
4607 So to get a clock summary of the current level 1 tree, for the current
4608 day, you could write
4609 @example
4610 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
4611 #+END: clocktable
4612 @end example
4613 and to use a specific time range you could write@footnote{Note that all
4614 parameters must be specified in a single line - the line is broken here
4615 only to fit it onto the manual.}
4616 @example
4617 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
4618                     :tend "<2006-08-10 Thu 12:00>"
4619 #+END: clocktable
4620 @end example
4621 @kindex C-c C-c
4622 @item C-c C-c
4623 @kindex C-c C-x C-u
4624 @itemx C-c C-x C-u
4625 Update dynamical block at point.  The cursor needs to be in the
4626 @code{#+BEGIN} line of the dynamic block.
4627 @kindex C-u C-c C-x C-u
4628 @item C-u C-c C-x C-u
4629 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4630 you have several clock table blocks in a buffer.
4631 @kindex S-@key{left}
4632 @kindex S-@key{right}
4633 @item S-@key{left}
4634 @itemx S-@key{right}
4635 Shift the current @code{:block} interval and update the table.  The cursor
4636 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
4637 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
4638 @end table
4640 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
4641 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
4642 worked on or closed during a day.
4644 @node Effort estimates,  , Clocking work time, Dates and Times
4645 @section Effort estimates
4646 @cindex Effort estimates
4648 If you want to plan your work in a very detailed way, or if you need to
4649 produce offers with quotations of the estimated work effort, you may want to
4650 assign effort estimates to entries.  If you are also clocking your work, you
4651 may later want to compare the planned effort with the actual working time, a
4652 great way to improve planning estimates.  Effort estimates are stored in a
4653 special property @samp{Effort}@footnote{You may change the property being
4654 used with the variable @code{org-effort-property}.}.  Clearly the best way to
4655 work with effort estimates is through column view (@pxref{Column view}).  You
4656 should start by setting up discrete values for effort estimates, and a
4657 @code{COLUMNS} format that displays these values together with clock sums (if
4658 you want to clock your time).  For a specific buffer you can use
4660 @example
4661 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
4662 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
4663 @end example
4665 @noindent
4666 or you can set up these values globally by customizing the variables
4667 @code{org-global-properties} and @code{org-columns-default-format}.  In
4668 particular if you want to use this setup also in the agenda, a global setup
4669 may be advised.
4671 The way to assign estimates to individual items is then to switch to column
4672 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
4673 value.  The values you enter will immediately be summed up in the hierarchy.
4674 In the column next to it, any clocked time will be displayed.
4676 If you switch to column view in the daily/weekly agenda, the effort column
4677 will summarize the estimated work effort for each day@footnote{Please note
4678 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
4679 column view}.}, and you can use this to find space in your schedule.  To get
4680 an overview of the entire part of the day that is committed, you can set the
4681 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
4682 appointments on a day that take place over a specified time interval will
4683 then also be added to the load estimate of the day.
4685 @node Remember, Agenda Views, Dates and Times, Top
4686 @chapter Remember
4687 @cindex @file{remember.el}
4689 The @i{Remember} package by John Wiegley lets you store quick notes with
4690 little interruption of your work flow.  See
4691 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
4692 information.  It is an excellent way to add new notes and tasks to
4693 Org files.  Org significantly expands the possibilities of
4694 @i{remember}: You may define templates for different note types, and
4695 associate target files and headlines with specific templates.  It also
4696 allows you to select the location where a note should be stored
4697 interactively, on the fly.
4699 @menu
4700 * Setting up Remember::         Some code for .emacs to get things going
4701 * Remember templates::          Define the outline of different note types
4702 * Storing notes::               Directly get the note to where it belongs
4703 * Refiling notes::              Moving a note or task to a project
4704 @end menu
4706 @node Setting up Remember, Remember templates, Remember, Remember
4707 @section Setting up Remember
4709 The following customization will tell @i{remember} to use org files as
4710 target, and to create annotations compatible with Org links.
4712 @example
4713 (org-remember-insinuate)
4714 (setq org-directory "~/path/to/my/orgfiles/")
4715 (setq org-default-notes-file (concat org-directory "/notes.org"))
4716 (define-key global-map "\C-cr" 'org-remember)
4717 @end example
4719 The last line binds the command @code{org-remember} to a global
4720 key@footnote{Please select your own key, @kbd{C-c r} is only a
4721 suggestion.}.  @code{org-remember} basically just calls @code{remember},
4722 but it makes a few things easier: If there is an active region, it will
4723 automatically copy the region into the remember buffer.  It also allows
4724 to jump to the buffer and location where remember notes are being
4725 stored: Just call @code{org-remember} with a prefix argument.  If you
4726 use two prefix arguments, Org jumps to the location where the last
4727 remember note was stored.
4729 @node Remember templates, Storing notes, Setting up Remember, Remember
4730 @section Remember templates
4731 @cindex templates, for remember
4733 In combination with Org, you can use templates to generate
4734 different types of @i{remember} notes.  For example, if you would like
4735 to use one template to create general TODO entries, another one for
4736 journal entries, and a third one for collecting random ideas, you could
4737 use:
4739 @example
4740 (setq org-remember-templates
4741  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
4742    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
4743    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4744 @end example
4746 @noindent In these entries, the first string is just a name, and the
4747 character specifies how to select the template.  It is useful if the
4748 character is also the first letter of the name.  The next string
4749 specifies the template.  Two more (optional) strings give the file in
4750 which, and the headline under which the new note should be stored.  The
4751 file (if not present or @code{nil}) defaults to
4752 @code{org-default-notes-file}, the heading to
4753 @code{org-remember-default-headline}.  If the file name is not an
4754 absolute path, it will be interpreted relative to @code{org-directory}.
4756 An optional sixth element specifies the contexts in which the user can
4757 select the template.  This element can be either a list of major modes
4758 or a function.  @code{org-remember} will first check whether the function
4759 returns @code{t} or if we are in any of the listed major mode, and select
4760 the template accordingly.
4762 So for example:
4764 @example
4765 (setq org-remember-templates
4766  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
4767    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" my-check)
4768    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4769 @end example
4771 The first template will only be available when invoking @code{org-remember}
4772 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
4773 available when the function @code{my-check} returns @code{t}.  The third
4774 template will be proposed in any context.
4776 When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
4777 something, Org will prompt for a key to select the template (if you have
4778 more than one template) and then prepare the buffer like
4779 @example
4780 * TODO
4781   [[file:link to where you called remember]]
4782 @end example
4784 @noindent
4785 During expansion of the template, special @kbd{%}-escapes allow dynamic
4786 insertion of content:
4787 @example
4788 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
4789             @r{You may specify a default value and a completion table with}
4790             @r{%^@{prompt|default|completion2|completion3...@}}
4791             @r{The arrow keys access a prompt-specific history.}
4792 %t          @r{time stamp, date only}
4793 %T          @r{time stamp with date and time}
4794 %u, %U      @r{like the above, but inactive time stamps}
4795 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
4796             @r{You may define a prompt like @code{%^@{Birthday@}t}}
4797 %n          @r{user name (taken from @code{user-full-name})}
4798 %a          @r{annotation, normally the link created with @code{org-store-link}}
4799 %A          @r{like @code{%a}, but prompt for the description part}
4800 %i          @r{initial content, the region when remember is called with C-u.}
4801             @r{The entire text will be indented like @code{%i} itself.}
4802 %c          @r{Current kill ring head.}
4803 %x          @r{Content of the X clipboard.}
4804 %^C         @r{Interactive selection of which kill or clip to use.}
4805 %^L         @r{Like @code{%^C}, but insert as link.}
4806 %^g         @r{prompt for tags, with completion on tags in target file.}
4807 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
4808 %:keyword   @r{specific information for certain link types, see below}
4809 %[pathname] @r{insert the contents of the file given by @code{pathname}}
4810 %(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
4811 %!          @r{immediately store note after completing the template}
4812             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
4813 @end example
4815 @noindent
4816 For specific link types, the following keywords will be
4817 defined@footnote{If you define your own link types (@pxref{Adding
4818 hyperlink types}), any property you store with
4819 @code{org-store-link-props} can be accessed in remember templates in a
4820 similar way.}:
4822 @example
4823 Link type          |  Available keywords
4824 -------------------+----------------------------------------------
4825 bbdb               |  %:name %:company
4826 bbdb               |  %::server %:port %:nick
4827 vm, wl, mh, rmail  |  %:type %:subject %:message-id
4828                    |  %:from %:fromname %:fromaddress
4829                    |  %:to   %:toname   %:toaddress
4830                    |  %: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}.}}
4831 gnus               |  %:group, @r{for messages also all email fields}
4832 w3, w3m            |  %:url
4833 info               |  %:file %:node
4834 calendar           |  %:date"
4835 @end example
4837 @noindent
4838 To place the cursor after template expansion use:
4840 @example
4841 %?          @r{After completing the template, position cursor here.}
4842 @end example
4844 @noindent
4845 If you change your mind about which template to use, call
4846 @code{org-remember} in the remember buffer.  You may then select a new
4847 template that will be filled with the previous context information.
4849 @node Storing notes, Refiling notes, Remember templates, Remember
4850 @section Storing notes
4852 When you are finished preparing a note with @i{remember}, you have to press
4853 @kbd{C-c C-c} to file the note away.  If you have started the clock in the
4854 remember buffer, you will first be asked if you want to clock out
4855 now@footnote{To avoid this query, configure the variable
4856 @code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
4857 will continue to run after the note is filed away.
4859 The handler will then store the note in the file and under the headline
4860 specified in the template, or it will use the default file and headlines.
4861 The window configuration will be restored, sending you back to the working
4862 context before the call to @code{remember}.  To re-use the location found
4863 during the last call to @code{remember}, exit the remember buffer with
4864 @kbd{C-u C-u C-c C-c}, i.e. specify a double prefix argument to @kbd{C-c
4865 C-c}.
4867 If you want to store the note directly to a different place, use
4868 @kbd{C-u C-c C-c} instead to exit remember@footnote{Configure the
4869 variable @code{org-remember-store-without-prompt} to make this behavior
4870 the default.}.  The handler will then first prompt for a target file -
4871 if you press @key{RET}, the value specified for the template is used.
4872 Then the command offers the headings tree of the selected file, with the
4873 cursor position at the default headline (if you had specified one in the
4874 template).  You can either immediately press @key{RET} to get the note
4875 placed there.  Or you can use the following keys to find a different
4876 location:
4877 @example
4878 @key{TAB}         @r{Cycle visibility.}
4879 @key{down} / @key{up}   @r{Next/previous visible headline.}
4880 n / p        @r{Next/previous visible headline.}
4881 f / b        @r{Next/previous headline same level.}
4882 u            @r{One level up.}
4883 @c 0-9          @r{Digit argument.}
4884 @end example
4885 @noindent
4886 Pressing @key{RET} or @key{left} or @key{right}
4887 then leads to the following result.
4889 @multitable @columnfractions 0.2 0.15 0.65
4890 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
4891 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
4892 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
4893 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
4894 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
4895 @item                 @tab @tab depending on @code{org-reverse-note-order}.
4896 @item not on headline @tab @key{RET}
4897       @tab at cursor position, level taken from context.
4898 @end multitable
4900 Before inserting the text into a tree, the function ensures that the
4901 text has a headline, i.e. a first line that starts with a @samp{*}.  If
4902 not, a headline is constructed from the current date and some additional
4903 data.  If you have indented the text of the note below the headline, the
4904 indentation will be adapted if inserting the note into the tree requires
4905 demotion from level 1.
4907 @node Refiling notes,  , Storing notes, Remember
4908 @section Refiling notes
4909 @cindex refiling notes
4911 Remember is usually used to quickly capture notes and tasks into one or
4912 a few capture lists.  When reviewing the captured data, you may want to
4913 refile some of the entries into a different list, for example into a
4914 project.  Cutting, finding the right location and then pasting the note
4915 is cumbersome.  To simplify this process, you can use the following
4916 special command:
4918 @table @kbd
4919 @kindex C-c C-w
4920 @item C-c C-w
4921 Refile the entry at point.  This command offers possible locations for
4922 refiling the entry and lets you select one with completion.  The item is
4923 filed below the target heading as a subitem.  Depending on
4924 @code{org-reverse-note-order}, it will be either the first of last
4925 subitem.@* By default, all level 1 headlines in the current buffer are
4926 considered to be targets, but you can have more complex definitions
4927 across a number of files.  See the variable @code{org-refile-targets}
4928 for details.
4929 @kindex C-u C-c C-w
4930 @item C-u C-c C-w
4931 Use the refile interface to jump to a heading.
4932 @kindex C-u C-u C-c C-w
4933 @item C-u C-u C-c C-w
4934 Jump to the location where @code{org-refile} last moved a tree to.
4935 @end table
4937 @node Agenda Views, Embedded LaTeX, Remember, Top
4938 @chapter Agenda Views
4939 @cindex agenda views
4941 Due to the way Org works, TODO items, time-stamped items, and
4942 tagged headlines can be scattered throughout a file or even a number of
4943 files.  To get an overview of open action items, or of events that are
4944 important for a particular date, this information must be collected,
4945 sorted and displayed in an organized way.
4947 Org can select items based on various criteria, and display them
4948 in a separate buffer.  Seven different view types are provided:
4950 @itemize @bullet
4951 @item
4952 an @emph{agenda} that is like a calendar and shows information
4953 for specific dates,
4954 @item
4955 a @emph{TODO list} that covers all unfinished
4956 action items,
4957 @item
4958 a @emph{tags view}, showings headlines based on
4959 the tags associated with them,
4960 @item
4961 a @emph{timeline view} that shows all events in a single Org file,
4962 in time-sorted view,
4963 @item
4964 a @emph{keyword search view} that shows all entries from multiple files
4965 that contain specified keywords.
4966 @item
4967 a @emph{stuck projects view} showing projects that currently don't move
4968 along, and
4969 @item
4970 @emph{custom views} that are special tag/keyword searches and
4971 combinations of different views.
4972 @end itemize
4974 @noindent
4975 The extracted information is displayed in a special @emph{agenda
4976 buffer}.  This buffer is read-only, but provides commands to visit the
4977 corresponding locations in the original Org files, and even to
4978 edit these files remotely.
4980 Two variables control how the agenda buffer is displayed and whether the
4981 window configuration is restored when the agenda exits:
4982 @code{org-agenda-window-setup} and
4983 @code{org-agenda-restore-windows-after-quit}.
4985 @menu
4986 * Agenda files::                Files being searched for agenda information
4987 * Agenda dispatcher::           Keyboard access to agenda views
4988 * Built-in agenda views::       What is available out of the box?
4989 * Presentation and sorting::    How agenda items are prepared for display
4990 * Agenda commands::             Remote editing of Org trees
4991 * Custom agenda views::         Defining special searches and views
4992 * Agenda column view::          Using column view for collected entries
4993 @end menu
4995 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
4996 @section Agenda files
4997 @cindex agenda files
4998 @cindex files for agenda
5000 The information to be shown is normally collected from all @emph{agenda
5001 files}, the files listed in the variable
5002 @code{org-agenda-files}@footnote{If the value of that variable is not a
5003 list, but a single file name, then the list of agenda files will be
5004 maintained in that external file.}. If a directory is part of this list,
5005 all files with the extension @file{.org} in this directory will be part
5006 of the list.
5008 Thus even if you only work with a single Org file, this file should
5009 be put into that list@footnote{When using the dispatcher, pressing
5010 @kbd{<} before selecting a command will actually limit the command to
5011 the current file, and ignore @code{org-agenda-files} until the next
5012 dispatcher command.}.  You can customize @code{org-agenda-files}, but
5013 the easiest way to maintain it is through the following commands
5015 @cindex files, adding to agenda list
5016 @table @kbd
5017 @kindex C-c [
5018 @item C-c [
5019 Add current file to the list of agenda files.  The file is added to
5020 the front of the list.  If it was already in the list, it is moved to
5021 the front.  With a prefix argument, file is added/moved to the end.
5022 @kindex C-c ]
5023 @item C-c ]
5024 Remove current file from the list of agenda files.
5025 @kindex C-,
5026 @kindex C-'
5027 @item C-,
5028 @itemx C-'
5029 Cycle through agenda file list, visiting one file after the other.
5030 @kindex M-x org-iswitchb
5031 @item M-x org-iswitchb
5032 Command to use an @code{iswitchb}-like interface to switch to and between Org
5033 buffers.
5034 @end table
5036 @noindent
5037 The Org menu contains the current list of files and can be used
5038 to visit any of them.
5040 If you would like to focus the agenda temporarily onto a file not in
5041 this list, or onto just one file in the list or even only a subtree in a
5042 file, this can be done in different ways.  For a single agenda command,
5043 you may press @kbd{<} once or several times in the dispatcher
5044 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
5045 extended period, use the following commands:
5047 @table @kbd
5048 @kindex C-c C-x <
5049 @item C-c C-x <
5050 Permanently restrict the agenda to the current subtree.  When with a
5051 prefix argument, or with the cursor before the first headline in a file,
5052 the agenda scope is set to the entire file.  This restriction remains in
5053 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
5054 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
5055 agenda view, the new restriction takes effect immediately.
5056 @kindex C-c C-x <
5057 @item C-c C-x <
5058 Remove the permanent restriction created by @kbd{C-c C-x <}.
5059 @end table
5061 @noindent
5062 When working with @file{Speedbar}, you can use the following commands in
5063 the Speedbar frame:
5064 @table @kbd
5065 @kindex <
5066 @item < @r{in the speedbar frame}
5067 Permanently restrict the agenda to the item at the cursor in the
5068 Speedbar frame, either an Org file or a subtree in such a file.
5069 If there is a window displaying an agenda view, the new restriction takes
5070 effect immediately.
5071 @kindex <
5072 @item > @r{in the speedbar frame}
5073 Lift the restriction again.
5074 @end table
5076 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
5077 @section The agenda dispatcher
5078 @cindex agenda dispatcher
5079 @cindex dispatching agenda commands
5080 The views are created through a dispatcher that should be bound to a
5081 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
5082 following we will assume that @kbd{C-c a} is indeed how the dispatcher
5083 is accessed and list keyboard access to commands accordingly.  After
5084 pressing @kbd{C-c a}, an additional letter is required to execute a
5085 command.  The dispatcher offers the following default commands:
5086 @table @kbd
5087 @item a
5088 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
5089 @item t @r{/} T
5090 Create a list of all TODO items (@pxref{Global TODO list}).
5091 @item m @r{/} M
5092 Create a list of headlines matching a TAGS expression (@pxref{Matching
5093 tags and properties}).
5094 @item L
5095 Create the timeline view for the current buffer (@pxref{Timeline}).
5096 @item s
5097 Create a list of entries selected by a boolean expression of keywords
5098 and/or regular expressions that must or must not occur in the entry.
5099 @item /
5100 Search for a regular expression in all agenda files and additionally in
5101 the files listed in @code{org-agenda-multi-occur-extra-files}.  This
5102 uses the Emacs command @code{multi-occur}.  A prefix argument can be
5103 used to specify the number of context lines for each match, default is
5105 @item # @r{/} !
5106 Create a list of stuck projects (@pxref{Stuck projects}).
5107 @item <
5108 Restrict an agenda command to the current buffer@footnote{For backward
5109 compatibility, you can also press @kbd{1} to restrict to the current
5110 buffer.}.  After pressing @kbd{<}, you still need to press the character
5111 selecting the command.
5112 @item < <
5113 If there is an active region, restrict the following agenda command to
5114 the region.  Otherwise, restrict it to the current subtree@footnote{For
5115 backward compatibility, you can also press @kbd{0} to restrict to the
5116 current buffer.}.  After pressing @kbd{< <}, you still need to press the
5117 character selecting the command.
5118 @end table
5120 You can also define custom commands that will be accessible through the
5121 dispatcher, just like the default commands.  This includes the
5122 possibility to create extended agenda buffers that contain several
5123 blocks together, for example the weekly agenda, the global TODO list and
5124 a number of special tags matches.  @xref{Custom agenda views}.
5126 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
5127 @section The built-in agenda views
5129 In this section we describe the built-in views.
5131 @menu
5132 * Weekly/daily agenda::         The calendar page with current tasks
5133 * Global TODO list::            All unfinished action items
5134 * Matching tags and properties::  Structured information with fine-tuned search
5135 * Timeline::                    Time-sorted view for single file
5136 * Keyword search::              Finding entries by keyword
5137 * Stuck projects::              Find projects you need to review
5138 @end menu
5140 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
5141 @subsection The weekly/daily agenda
5142 @cindex agenda
5143 @cindex weekly agenda
5144 @cindex daily agenda
5146 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
5147 paper agenda, showing all the tasks for the current week or day.
5149 @table @kbd
5150 @cindex org-agenda, command
5151 @kindex C-c a a
5152 @item C-c a a
5153 Compile an agenda for the current week from a list of org files.  The
5154 agenda shows the entries for each day.  With a numeric
5155 prefix@footnote{For backward compatibility, the universal prefix
5156 @kbd{C-u} causes all TODO entries to be listed before the agenda.  This
5157 feature is deprecated, use the dedicated TODO list, or a block agenda
5158 instead.}  (like @kbd{C-u 2 1 C-c a a}) you may set the number of days
5159 to be displayed (see also the variable @code{org-agenda-ndays})
5160 @end table
5162 Remote editing from the agenda buffer means, for example, that you can
5163 change the dates of deadlines and appointments from the agenda buffer.
5164 The commands available in the Agenda buffer are listed in @ref{Agenda
5165 commands}.
5167 @subsubheading Calendar/Diary integration
5168 @cindex calendar integration
5169 @cindex diary integration
5171 Emacs contains the calendar and diary by Edward M. Reingold.  The
5172 calendar displays a three-month calendar with holidays from different
5173 countries and cultures.  The diary allows you to keep track of
5174 anniversaries, lunar phases, sunrise/set, recurrent appointments
5175 (weekly, monthly) and more.  In this way, it is quite complementary to
5176 Org.  It can be very useful to combine output from Org with
5177 the diary.
5179 In order to include entries from the Emacs diary into Org mode's
5180 agenda, you only need to customize the variable
5182 @lisp
5183 (setq org-agenda-include-diary t)
5184 @end lisp
5186 @noindent After that, everything will happen automatically.  All diary
5187 entries including holidays, anniversaries etc will be included in the
5188 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
5189 @key{RET} can be used from the agenda buffer to jump to the diary
5190 file in order to edit existing diary entries.  The @kbd{i} command to
5191 insert new entries for the current date works in the agenda buffer, as
5192 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
5193 Sunrise/Sunset times, show lunar phases and to convert to other
5194 calendars, respectively.  @kbd{c} can be used to switch back and forth
5195 between calendar and agenda.
5197 If you are using the diary only for sexp entries and holidays, it is
5198 faster to not use the above setting, but instead to copy or even move
5199 the entries into an Org file. Org mode evaluates diary-style sexp
5200 entries, and does it faster because there is no overhead for first
5201 creating the diary display.  Note that the sexp entries must start at
5202 the left margin, no white space is allowed before them.  For example,
5203 the following segment of an Org file will be processed and entries
5204 will be made in the agenda:
5206 @example
5207 * Birthdays and similar stuff
5208 #+CATEGORY: Holiday
5209 %%(org-calendar-holiday)   ; special function for holiday names
5210 #+CATEGORY: Ann
5211 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
5212 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
5213 @end example
5215 @subsubheading Appointment reminders
5216 @cindex @file{appt.el}
5217 @cindex appointment reminders
5219 Org can interact with Emacs appointments notification facility.
5221 To add all the appointments of your agenda files, use the command
5222 @code{org-agenda-to-appt}.  This commands also lets you filter through
5223 the list of your appointments and add only those belonging to a specific
5224 category or matching a regular expression. See the docstring for
5225 details.
5227 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
5228 @subsection The global TODO list
5229 @cindex global TODO list
5230 @cindex TODO list, global
5232 The global TODO list contains all unfinished TODO items, formatted and
5233 collected into a single place.
5235 @table @kbd
5236 @kindex C-c a t
5237 @item C-c a t
5238 Show the global TODO list.  This collects the TODO items from all
5239 agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
5240 @code{agenda-mode}, so there are commands to examine and manipulate
5241 the TODO entries directly from that buffer (@pxref{Agenda commands}).
5242 @kindex C-c a T
5243 @item C-c a T
5244 @cindex TODO keyword matching
5245 Like the above, but allows selection of a specific TODO keyword.  You
5246 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
5247 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
5248 specify several keywords by separating them with @samp{|} as boolean OR
5249 operator.  With a numeric prefix, the Nth keyword in
5250 @code{org-todo-keywords} is selected.
5251 @kindex r
5252 The @kbd{r} key in the agenda buffer regenerates it, and you can give
5253 a prefix argument to this command to change the selected TODO keyword,
5254 for example @kbd{3 r}.  If you often need a search for a specific
5255 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
5256 Matching specific TODO keywords can also be done as part of a tags
5257 search (@pxref{Tag searches}).
5258 @end table
5260 Remote editing of TODO items means that you can change the state of a
5261 TODO entry with a single key press.  The commands available in the
5262 TODO list are described in @ref{Agenda commands}.
5264 @cindex sublevels, inclusion into TODO list
5265 Normally the global TODO list simply shows all headlines with TODO
5266 keywords.  This list can become very long.  There are two ways to keep
5267 it more compact:
5268 @itemize @minus
5269 @item
5270 Some people view a TODO item that has been @emph{scheduled} for
5271 execution (@pxref{Timestamps}) as no longer @emph{open}.  Configure the
5272 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
5273 items from the global TODO list.
5274 @item
5275 TODO items may have sublevels to break up the task into subtasks.  In
5276 such cases it may be enough to list only the highest level TODO headline
5277 and omit the sublevels from the global list.  Configure the variable
5278 @code{org-agenda-todo-list-sublevels} to get this behavior.
5279 @end itemize
5281 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
5282 @subsection Matching tags and properties
5283 @cindex matching, of tags
5284 @cindex matching, of properties
5285 @cindex tags view
5287 If headlines in the agenda files are marked with @emph{tags}
5288 (@pxref{Tags}), you can select headlines based on the tags that apply
5289 to them and collect them into an agenda buffer.
5291 @table @kbd
5292 @kindex C-c a m
5293 @item C-c a m
5294 Produce a list of all headlines that match a given set of tags.  The
5295 command prompts for a selection criterion, which is a boolean logic
5296 expression with tags, like @samp{+work+urgent-withboss} or
5297 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
5298 define a custom command for it (@pxref{Agenda dispatcher}).
5299 @kindex C-c a M
5300 @item C-c a M
5301 Like @kbd{C-c a m}, but only select headlines that are also TODO items
5302 and force checking subitems (see variable
5303 @code{org-tags-match-list-sublevels}).  Matching specific TODO keywords
5304 together with a tags match is also possible, see @ref{Tag searches}.
5305 @end table
5307 The commands available in the tags list are described in @ref{Agenda
5308 commands}.
5310 @node Timeline, Keyword search, Matching tags and properties, Built-in agenda views
5311 @subsection Timeline for a single file
5312 @cindex timeline, single file
5313 @cindex time-sorted view
5315 The timeline summarizes all time-stamped items from a single Org mode
5316 file in a @emph{time-sorted view}.  The main purpose of this command is
5317 to give an overview over events in a project.
5319 @table @kbd
5320 @kindex C-c a L
5321 @item C-c a L
5322 Show a time-sorted view of the org file, with all time-stamped items.
5323 When called with a @kbd{C-u} prefix, all unfinished TODO entries
5324 (scheduled or not) are also listed under the current date.
5325 @end table
5327 @noindent
5328 The commands available in the timeline buffer are listed in
5329 @ref{Agenda commands}.
5331 @node Keyword search, Stuck projects, Timeline, Built-in agenda views
5332 @subsection Keyword search
5333 @cindex keyword search
5334 @cindex searching, for keywords
5336 This agenda view is a general text search facility for Org mode entries.
5337 It is particularly useful to find notes.
5339 @table @kbd
5340 @kindex C-c a s
5341 @item C-c a s
5342 This is a special search that lets you select entries by keywords or
5343 regular expression, using a boolean logic.  For example, the search
5344 string
5346 @example
5347 +computer +wifi -ethernet -@{8\.11[bg]@}
5348 @end example
5350 @noindent
5351 will search for note entries that contain the keywords @code{computer}
5352 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
5353 not matched by the regular expression @code{8\.11[bg]}, meaning to
5354 exclude both 8.11b and 8.11g.
5356 Note that in addition to the agenda files, this command will also search
5357 the files listed in @code{org-agenda-text-search-extra-files}.
5358 @end table
5360 @node Stuck projects,  , Keyword search, Built-in agenda views
5361 @subsection Stuck projects
5363 If you are following a system like David Allen's GTD to organize your
5364 work, one of the ``duties'' you have is a regular review to make sure
5365 that all projects move along.  A @emph{stuck} project is a project that
5366 has no defined next actions, so it will never show up in the TODO lists
5367 Org mode produces.  During the review, you need to identify such
5368 projects and define next actions for them.
5370 @table @kbd
5371 @kindex C-c a #
5372 @item C-c a #
5373 List projects that are stuck.
5374 @kindex C-c a !
5375 @item C-c a !
5376 Customize the variable @code{org-stuck-projects} to define what a stuck
5377 project is and how to find it.
5378 @end table
5380 You almost certainly will have to configure this view before it will
5381 work for you.  The built-in default assumes that all your projects are
5382 level-2 headlines, and that a project is not stuck if it has at least
5383 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
5385 Lets assume that you, in your own way of using Org mode, identify
5386 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
5387 indicate a project that should not be considered yet.  Lets further
5388 assume that the TODO keyword DONE marks finished projects, and that NEXT
5389 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
5390 is a next action even without the NEXT tag.  Finally, if the project
5391 contains the special word IGNORE anywhere, it should not be listed
5392 either.  In this case you would start by identifying eligible projects
5393 with a tags/todo match @samp{+PROJECT/-MAYBE-DONE}, and then check for
5394 TODO, NEXT, @@SHOP, and IGNORE in the subtree to identify projects that
5395 are not stuck.  The correct customization for this is
5397 @lisp
5398 (setq org-stuck-projects
5399       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
5400                                "\\<IGNORE\\>"))
5401 @end lisp
5404 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
5405 @section Presentation and sorting
5406 @cindex presentation, of agenda items
5408 Before displaying items in an agenda view, Org mode visually prepares
5409 the items and sorts them.  Each item occupies a single line.  The line
5410 starts with a @emph{prefix} that contains the @emph{category}
5411 (@pxref{Categories}) of the item and other important information.  You can
5412 customize the prefix using the option @code{org-agenda-prefix-format}.
5413 The prefix is followed by a cleaned-up version of the outline headline
5414 associated with the item.
5416 @menu
5417 * Categories::                  Not all tasks are equal
5418 * Time-of-day specifications::  How the agenda knows the time
5419 * Sorting of agenda items::     The order of things
5420 @end menu
5422 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
5423 @subsection Categories
5425 @cindex category
5426 The category is a broad label assigned to each agenda item.  By default,
5427 the category is simply derived from the file name, but you can also
5428 specify it with a special line in the buffer, like this@footnote{For
5429 backward compatibility, the following also works: If there are several
5430 such lines in a file, each specifies the category for the text below it.
5431 The first category also applies to any text before the first CATEGORY
5432 line.  However, using this method is @emph{strongly} deprecated as it is
5433 incompatible with the outline structure of the document.  The correct
5434 method for setting multiple categories in a buffer is using a
5435 property.}:
5437 @example
5438 #+CATEGORY: Thesis
5439 @end example
5441 @noindent
5442 If you would like to have a special CATEGORY for a single entry or a
5443 (sub)tree, give the entry a @code{:CATEGORY:} property with the location
5444 as the value (@pxref{Properties and Columns}).
5446 @noindent
5447 The display in the agenda buffer looks best if the category is not
5448 longer than 10 characters.
5450 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
5451 @subsection Time-of-day specifications
5452 @cindex time-of-day specification
5454 Org mode checks each agenda item for a time-of-day specification.  The
5455 time can be part of the time stamp that triggered inclusion into the
5456 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
5457 ranges can be specified with two time stamps, like
5459 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
5461 In the headline of the entry itself, a time(range) may also appear as
5462 plain text (like @samp{12:45} or a @samp{8:30-1pm}.  If the agenda
5463 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
5464 specifications in diary entries are recognized as well.
5466 For agenda display, Org mode extracts the time and displays it in a
5467 standard 24 hour format as part of the prefix.  The example times in
5468 the previous paragraphs would end up in the agenda like this:
5470 @example
5471     8:30-13:00 Arthur Dent lies in front of the bulldozer
5472    12:45...... Ford Prefect arrives and takes Arthur to the pub
5473    19:00...... The Vogon reads his poem
5474    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5475 @end example
5477 @cindex time grid
5478 If the agenda is in single-day mode, or for the display of today, the
5479 timed entries are embedded in a time grid, like
5481 @example
5482     8:00...... ------------------
5483     8:30-13:00 Arthur Dent lies in front of the bulldozer
5484    10:00...... ------------------
5485    12:00...... ------------------
5486    12:45...... Ford Prefect arrives and takes Arthur to the pub
5487    14:00...... ------------------
5488    16:00...... ------------------
5489    18:00...... ------------------
5490    19:00...... The Vogon reads his poem
5491    20:00...... ------------------
5492    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5493 @end example
5495 The time grid can be turned on and off with the variable
5496 @code{org-agenda-use-time-grid}, and can be configured with
5497 @code{org-agenda-time-grid}.
5499 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
5500 @subsection Sorting of agenda items
5501 @cindex sorting, of agenda items
5502 @cindex priorities, of agenda items
5503 Before being inserted into a view, the items are sorted.  How this is
5504 done depends on the type of view.
5505 @itemize @bullet
5506 @item
5507 For the daily/weekly agenda, the items for each day are sorted.  The
5508 default order is to first collect all items containing an explicit
5509 time-of-day specification.  These entries will be shown at the beginning
5510 of the list, as a @emph{schedule} for the day.  After that, items remain
5511 grouped in categories, in the sequence given by @code{org-agenda-files}.
5512 Within each category, items are sorted by priority (@pxref{Priorities}),
5513 which is composed of the base priority (2000 for priority @samp{A}, 1000
5514 for @samp{B}, and 0 for @samp{C}), plus additional increments for
5515 overdue scheduled or deadline items.
5516 @item
5517 For the TODO list, items remain in the order of categories, but within
5518 each category, sorting takes place according to priority
5519 (@pxref{Priorities}).
5520 @item
5521 For tags matches, items are not sorted at all, but just appear in the
5522 sequence in which they are found in the agenda files.
5523 @end itemize
5525 Sorting can be customized using the variable
5526 @code{org-agenda-sorting-strategy}, and may also include criteria based on
5527 the estimated effort of an entry.
5528 @c FIXME: link!!!!!!!!
5531 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
5532 @section Commands in the agenda buffer
5533 @cindex commands, in agenda buffer
5535 Entries in the agenda buffer are linked back to the org file or diary
5536 file where they originate.  You are not allowed to edit the agenda
5537 buffer itself, but commands are provided to show and jump to the
5538 original entry location, and to edit the org-files ``remotely'' from
5539 the agenda buffer.  In this way, all information is stored only once,
5540 removing the risk that your agenda and note files may diverge.
5542 Some commands can be executed with mouse clicks on agenda lines.  For
5543 the other commands, the cursor needs to be in the desired line.
5545 @table @kbd
5546 @tsubheading{Motion}
5547 @cindex motion commands in agenda
5548 @kindex n
5549 @item n
5550 Next line (same as @key{up} and @kbd{C-p}).
5551 @kindex p
5552 @item p
5553 Previous line (same as @key{down} and @kbd{C-n}).
5554 @tsubheading{View/Go to org file}
5555 @kindex mouse-3
5556 @kindex @key{SPC}
5557 @item mouse-3
5558 @itemx @key{SPC}
5559 Display the original location of the item in another window.
5561 @kindex L
5562 @item L
5563 Display original location and recenter that window.
5565 @kindex mouse-2
5566 @kindex mouse-1
5567 @kindex @key{TAB}
5568 @item mouse-2
5569 @itemx mouse-1
5570 @itemx @key{TAB}
5571 Go to the original location of the item in another window.  Under Emacs
5572 22, @kbd{mouse-1} will also works for this.
5574 @kindex @key{RET}
5575 @itemx @key{RET}
5576 Go to the original location of the item and delete other windows.
5578 @kindex f
5579 @item f
5580 Toggle Follow mode.  In Follow mode, as you move the cursor through
5581 the agenda buffer, the other window always shows the corresponding
5582 location in the org file.  The initial setting for this mode in new
5583 agenda buffers can be set with the variable
5584 @code{org-agenda-start-with-follow-mode}.
5586 @kindex b
5587 @item b
5588 Display the entire subtree of the current item in an indirect buffer.  With a
5589 numeric prefix argument N, go up to level N and then take that tree.  If N is
5590 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
5591 previously used indirect buffer.
5593 @kindex l
5594 @item l
5595 Toggle Logbook mode.  In Logbook mode, entries that where marked DONE while
5596 logging was on (variable @code{org-log-done}) are shown in the agenda,
5597 as are entries that have been clocked on that day.
5599 @kindex R
5600 @item R
5601 Toggle Clockreport mode.  In clockreport mode, the daily/weekly agenda will
5602 always show a table with the clocked times for the timespan and file scope
5603 covered by the current agenda view.  The initial setting for this mode in new
5604 agenda buffers can be set with the variable
5605 @code{org-agenda-start-with-clockreport-mode}.
5607 @tsubheading{Change display}
5608 @cindex display changing, in agenda
5609 @kindex o
5610 @item o
5611 Delete other windows.
5613 @kindex d
5614 @kindex w
5615 @kindex m
5616 @kindex y
5617 @item d w m y
5618 Switch to day/week/month/year view.  When switching to day or week view,
5619 this setting becomes the default for subsequent agenda commands.  Since
5620 month and year views are slow to create, they do not become the default.
5621 A numeric prefix argument may be used to jump directly to a specific day
5622 of the year, ISO week, month, or year, respectively.  For example,
5623 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
5624 setting day, week, or month view, a year may be encoded in the prefix
5625 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
5626 2007.  If such a year specification has only one or two digits, it will
5627 be mapped to the interval 1938-2037.
5629 @kindex D
5630 @item D
5631 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
5633 @kindex G
5634 @item G
5635 Toggle the time grid on and off.  See also the variables
5636 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
5638 @kindex r
5639 @item r
5640 Recreate the agenda buffer, for example to reflect the changes
5641 after modification of the time stamps of items with S-@key{left} and
5642 S-@key{right}.  When the buffer is the global TODO list, a prefix
5643 argument is interpreted to create a selective list for a specific TODO
5644 keyword.
5645 @kindex g
5646 @item g
5647 Same as @kbd{r}.
5649 @kindex s
5650 @kindex C-x C-s
5651 @item s
5652 @itemx C-x C-s
5653 Save all Org buffers in the current Emacs session.
5655 @kindex @key{right}
5656 @item @key{right}
5657 Display the following @code{org-agenda-ndays} days.  For example, if
5658 the display covers a week, switch to the following week.  With prefix
5659 arg, go forward that many times @code{org-agenda-ndays} days.
5661 @kindex @key{left}
5662 @item @key{left}
5663 Display the previous dates.
5665 @kindex .
5666 @item .
5667 Go to today.
5669 @kindex C-c C-x C-c
5670 @item C-c C-x C-c
5671 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
5672 view format is taken from the entry at point, or (if there is no entry at
5673 point), from the first entry in the agenda view.  So whatever the format for
5674 that entry would be in the original buffer (taken from a property, from a
5675 @code{#+COLUMNS} line, or from the default variable
5676 @code{org-columns-default-format}), will be used in the agenda.
5678 @tsubheading{Query editing}
5679 @cindex query editing, in agenda
5681 @kindex [
5682 @kindex ]
5683 @kindex @{
5684 @kindex @}
5685 @item [ ] @{ @}
5686 In the @i{search view} (@pxref{Keyword search}), these keys add new
5687 search words (@kbd{[} and @kbd{]}) or new regular expressions (@kbd{@{}
5688 and @kbd{@}}) to the query string.  The opening bracket/brace will add a
5689 positive search term prefixed by @samp{+}, indicating that this search
5690 term @i{must} occur/match in the entry.  Closing bracket/brace add a
5691 negative search term which @i{must not} occur/match in the entry for it
5692 to be selected.
5695 @tsubheading{Remote editing}
5696 @cindex remote editing, from agenda
5698 @item 0-9
5699 Digit argument.
5701 @cindex undoing remote-editing events
5702 @cindex remote editing, undo
5703 @kindex C-_
5704 @item C-_
5705 Undo a change due to a remote editing command.  The change is undone
5706 both in the agenda buffer and in the remote buffer.
5708 @kindex t
5709 @item t
5710 Change the TODO state of the item, both in the agenda and in the
5711 original org file.
5713 @kindex C-k
5714 @item C-k
5715 Delete the current agenda item along with the entire subtree belonging
5716 to it in the original Org file.  If the text to be deleted remotely
5717 is longer than one line, the kill needs to be confirmed by the user.  See
5718 variable @code{org-agenda-confirm-kill}.
5720 @kindex a
5721 @item a
5722 Toggle the ARCHIVE tag for the current headline.
5724 @kindex A
5725 @item A
5726 Move the subtree corresponding to the current entry to its @emph{Archive
5727 Sibling}.
5729 @kindex $
5730 @item $
5731 Archive the subtree corresponding to the current headline.  This means the
5732 entry will be moved to the configured archive location, most likely a
5733 different file.
5735 @kindex T
5736 @item T
5737 Show all tags associated with the current item.  Because of
5738 inheritance, this may be more than the tags listed in the line itself.
5740 @kindex :
5741 @item :
5742 Set tags for the current headline.  If there is an active region in the
5743 agenda, change a tag for all headings in the region.
5745 @kindex ,
5746 @item ,
5747 Set the priority for the current item.  Org mode prompts for the
5748 priority character. If you reply with @key{SPC}, the priority cookie
5749 is removed from the entry.
5751 @kindex P
5752 @item P
5753 Display weighted priority of current item.
5755 @kindex +
5756 @kindex S-@key{up}
5757 @item +
5758 @itemx S-@key{up}
5759 Increase the priority of the current item.  The priority is changed in
5760 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
5761 key for this.
5763 @kindex -
5764 @kindex S-@key{down}
5765 @item -
5766 @itemx S-@key{down}
5767 Decrease the priority of the current item.
5769 @kindex C-c C-s
5770 @item C-c C-s
5771 Schedule this item
5773 @kindex C-c C-d
5774 @item C-c C-d
5775 Set a deadline for this item.
5777 @kindex S-@key{right}
5778 @item S-@key{right}
5779 Change the time stamp associated with the current line by one day into the
5780 future.  With a numeric prefix argument, change it by that many days.  For
5781 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The stamp is
5782 changed in the original org file, but the change is not directly reflected in
5783 the agenda buffer.  Use the @kbd{r} key to update the buffer.
5785 @kindex S-@key{left}
5786 @item S-@key{left}
5787 Change the time stamp associated with the current line by one day
5788 into the past.
5790 @kindex >
5791 @item >
5792 Change the time stamp associated with the current line to today.
5793 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
5794 on my keyboard.
5796 @kindex I
5797 @item I
5798 Start the clock on the current item.  If a clock is running already, it
5799 is stopped first.
5801 @kindex O
5802 @item O
5803 Stop the previously started clock.
5805 @kindex X
5806 @item X
5807 Cancel the currently running clock.
5809 @kindex J
5810 @item J
5811 Jump to the running clock in another window.
5813 @tsubheading{Calendar commands}
5814 @cindex calendar commands, from agenda
5815 @kindex c
5816 @item c
5817 Open the Emacs calendar and move to the date at the agenda cursor.
5819 @item c
5820 When in the calendar, compute and show the Org mode agenda for the
5821 date at the cursor.
5823 @cindex diary entries, creating from agenda
5824 @kindex i
5825 @item i
5826 Insert a new entry into the diary.  Prompts for the type of entry
5827 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
5828 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
5829 The date is taken from the cursor position.
5831 @kindex M
5832 @item M
5833 Show the phases of the moon for the three months around current date.
5835 @kindex S
5836 @item S
5837 Show sunrise and sunset times.  The geographical location must be set
5838 with calendar variables, see documentation of the Emacs calendar.
5840 @kindex C
5841 @item C
5842 Convert the date at cursor into many other cultural and historic
5843 calendars.
5845 @kindex H
5846 @item H
5847 Show holidays for three month around the cursor date.
5849 @item M-x org-export-icalendar-combine-agenda-files
5850 Export a single iCalendar file containing entries from all agenda files.
5851 This is a globally available command, and also available in the agenda menu.
5853 @tsubheading{Exporting to a file}
5854 @kindex C-x C-w
5855 @item C-x C-w
5856 @cindex exporting agenda views
5857 @cindex agenda views, exporting
5858 Write the agenda view to a file.  Depending on the extension of the
5859 selected file name, the view will be exported as HTML (extension
5860 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
5861 plain text (any other extension).  Use the variable
5862 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
5863 and for @file{htmlize} to be used during export.
5865 @tsubheading{Quit and Exit}
5866 @kindex q
5867 @item q
5868 Quit agenda, remove the agenda buffer.
5870 @kindex x
5871 @cindex agenda files, removing buffers
5872 @item x
5873 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
5874 for the compilation of the agenda.  Buffers created by the user to
5875 visit org files will not be removed.
5876 @end table
5879 @node Custom agenda views, Agenda column view, Agenda commands, Agenda Views
5880 @section Custom agenda views
5881 @cindex custom agenda views
5882 @cindex agenda views, custom
5884 Custom agenda commands serve two purposes: to store and quickly access
5885 frequently used TODO and tags searches, and to create special composite
5886 agenda buffers.  Custom agenda commands will be accessible through the
5887 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
5889 @menu
5890 * Storing searches::            Type once, use often
5891 * Block agenda::                All the stuff you need in a single buffer
5892 * Setting Options::             Changing the rules
5893 * Exporting Agenda Views::      Writing agendas to files
5894 * Using the agenda elsewhere::  Using agenda information in other programs
5895 @end menu
5897 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
5898 @subsection Storing searches
5900 The first application of custom searches is the definition of keyboard
5901 shortcuts for frequently used searches, either creating an agenda
5902 buffer, or a sparse tree (the latter covering of course only the current
5903 buffer).
5904 @kindex C-c a C
5905 Custom commands are configured in the variable
5906 @code{org-agenda-custom-commands}.  You can customize this variable, for
5907 example by pressing @kbd{C-c a C}.  You can also directly set it with
5908 Emacs Lisp in @file{.emacs}.  The following example contains all valid
5909 search types:
5911 @lisp
5912 @group
5913 (setq org-agenda-custom-commands
5914       '(("w" todo "WAITING")
5915         ("W" todo-tree "WAITING")
5916         ("u" tags "+boss-urgent")
5917         ("v" tags-todo "+boss-urgent")
5918         ("U" tags-tree "+boss-urgent")
5919         ("f" occur-tree "\\<FIXME\\>")
5920         ("h" . "HOME+Name tags searches") ; description for "h" prefix
5921         ("hl" tags "+home+Lisa")
5922         ("hp" tags "+home+Peter")
5923         ("hk" tags "+home+Kim")))
5924 @end group
5925 @end lisp
5927 @noindent
5928 The initial string in each entry defines the keys you have to press
5929 after the dispatcher command @kbd{C-c a} in order to access the command.
5930 Usually this will be just a single character, but if you have many
5931 similar commands, you can also define two-letter combinations where the
5932 first character is the same in several combinations and serves as a
5933 prefix key@footnote{You can provide a description for a prefix key by
5934 inserting a cons cell with the prefix and the description.}.  The second
5935 parameter is the search type, followed by the string or regular
5936 expression to be used for the matching.  The example above will
5937 therefore define:
5939 @table @kbd
5940 @item C-c a w
5941 as a global search for TODO entries with @samp{WAITING} as the TODO
5942 keyword
5943 @item C-c a W
5944 as the same search, but only in the current buffer and displaying the
5945 results as a sparse tree
5946 @item C-c a u
5947 as a global tags search for headlines marked @samp{:boss:} but not
5948 @samp{:urgent:}
5949 @item C-c a v
5950 as the same search as @kbd{C-c a u}, but limiting the search to
5951 headlines that are also TODO items
5952 @item C-c a U
5953 as the same search as @kbd{C-c a u}, but only in the current buffer and
5954 displaying the result as a sparse tree
5955 @item C-c a f
5956 to create a sparse tree (again: current buffer only) with all entries
5957 containing the word @samp{FIXME}
5958 @item C-c a h
5959 as a prefix command for a HOME tags search where you have to press an
5960 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
5961 Peter, or Kim) as additional tag to match.
5962 @end table
5964 @node Block agenda, Setting Options, Storing searches, Custom agenda views
5965 @subsection Block agenda
5966 @cindex block agenda
5967 @cindex agenda, with block views
5969 Another possibility is the construction of agenda views that comprise
5970 the results of @emph{several} commands, each of which creates a block in
5971 the agenda buffer.  The available commands include @code{agenda} for the
5972 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
5973 for the global TODO list (as constructed with @kbd{C-c a t}), and the
5974 matching commands discussed above: @code{todo}, @code{tags}, and
5975 @code{tags-todo}.  Here are two examples:
5977 @lisp
5978 @group
5979 (setq org-agenda-custom-commands
5980       '(("h" "Agenda and Home-related tasks"
5981          ((agenda "")
5982           (tags-todo "home")
5983           (tags "garden")))
5984         ("o" "Agenda and Office-related tasks"
5985          ((agenda "")
5986           (tags-todo "work")
5987           (tags "office")))))
5988 @end group
5989 @end lisp
5991 @noindent
5992 This will define @kbd{C-c a h} to create a multi-block view for stuff
5993 you need to attend to at home.  The resulting agenda buffer will contain
5994 your agenda for the current week, all TODO items that carry the tag
5995 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
5996 command @kbd{C-c a o} provides a similar view for office tasks.
5998 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
5999 @subsection Setting options for custom commands
6000 @cindex options, for custom agenda views
6002 Org mode contains a number of variables regulating agenda construction
6003 and display.  The global variables define the behavior for all agenda
6004 commands, including the custom commands.  However, if you want to change
6005 some settings just for a single custom view, you can do so.  Setting
6006 options requires inserting a list of variable names and values at the
6007 right spot in @code{org-agenda-custom-commands}.  For example:
6009 @lisp
6010 @group
6011 (setq org-agenda-custom-commands
6012       '(("w" todo "WAITING"
6013          ((org-agenda-sorting-strategy '(priority-down))
6014           (org-agenda-prefix-format "  Mixed: ")))
6015         ("U" tags-tree "+boss-urgent"
6016          ((org-show-following-heading nil)
6017           (org-show-hierarchy-above nil)))
6018         ("N" search ""
6019          ((org-agenda-files '("~org/notes.org"))
6020           (org-agenda-text-search-extra-files nil)))))
6021 @end group
6022 @end lisp
6024 @noindent
6025 Now the @kbd{C-c a w} command will sort the collected entries only by
6026 priority, and the prefix format is modified to just say @samp{  Mixed: }
6027 instead of giving the category of the entry.  The sparse tags tree of
6028 @kbd{C-c a U} will now turn out ultra-compact, because neither the
6029 headline hierarchy above the match, nor the headline following the match
6030 will be shown.  The command @kbd{C-c a N} will do a text search limited
6031 to only a single file.
6033 For command sets creating a block agenda,
6034 @code{org-agenda-custom-commands} has two separate spots for setting
6035 options.  You can add options that should be valid for just a single
6036 command in the set, and options that should be valid for all commands in
6037 the set.  The former are just added to the command entry, the latter
6038 must come after the list of command entries.  Going back to the block
6039 agenda example (@pxref{Block agenda}), let's change the sorting strategy
6040 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
6041 the results for GARDEN tags query in the opposite order,
6042 @code{priority-up}.  This would look like this:
6044 @lisp
6045 @group
6046 (setq org-agenda-custom-commands
6047       '(("h" "Agenda and Home-related tasks"
6048          ((agenda)
6049           (tags-todo "home")
6050           (tags "garden"
6051                 ((org-agenda-sorting-strategy '(priority-up)))))
6052          ((org-agenda-sorting-strategy '(priority-down))))
6053         ("o" "Agenda and Office-related tasks"
6054          ((agenda)
6055           (tags-todo "work")
6056           (tags "office")))))
6057 @end group
6058 @end lisp
6060 As you see, the values and parenthesis setting is a little complex.
6061 When in doubt, use the customize interface to set this variable - it
6062 fully supports its structure.  Just one caveat: When setting options in
6063 this interface, the @emph{values} are just lisp expressions.  So if the
6064 value is a string, you need to add the double quotes around the value
6065 yourself.
6068 @node Exporting Agenda Views, Using the agenda elsewhere, Setting Options, Custom agenda views
6069 @subsection Exporting Agenda Views
6070 @cindex agenda views, exporting
6072 If you are away from your computer, it can be very useful to have a
6073 printed version of some agenda views to carry around.  Org mode can
6074 export custom agenda views as plain text, HTML@footnote{You need to
6075 install Hrvoje Niksic' @file{htmlize.el}.} postscript, and iCalendar
6076 files.  If you want to do this only occasionally, use the command
6078 @table @kbd
6079 @kindex C-x C-w
6080 @item C-x C-w
6081 @cindex exporting agenda views
6082 @cindex agenda views, exporting
6083 Write the agenda view to a file.  Depending on the extension of the
6084 selected file name, the view will be exported as HTML (extension
6085 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}),
6086 iCalendar (extension @file{.ics}), or plain text (any other extension).
6087 Use the variable @code{org-agenda-exporter-settings} to
6088 set options for @file{ps-print} and for @file{htmlize} to be used during
6089 export, for example
6091 @lisp
6092 (setq org-agenda-exporter-settings
6093       '((ps-number-of-columns 2)
6094         (ps-landscape-mode t)
6095         (htmlize-output-type 'css)))
6096 @end lisp
6097 @end table
6099 If you need to export certain agenda views frequently, you can associate
6100 any custom agenda command with a list of output file names
6101 @footnote{If you want to store standard views like the weekly agenda
6102 or the global TODO list as well, you need to define custom commands for
6103 them in order to be able to specify file names.}.  Here is an example
6104 that first does define custom commands for the agenda and the global
6105 todo list, together with a number of files to which to export them.
6106 Then we define two block agenda commands and specify file names for them
6107 as well.  File names can be relative to the current working directory,
6108 or absolute.
6110 @lisp
6111 @group
6112 (setq org-agenda-custom-commands
6113       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
6114         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
6115         ("h" "Agenda and Home-related tasks"
6116          ((agenda "")
6117           (tags-todo "home")
6118           (tags "garden"))
6119          nil
6120          ("~/views/home.html"))
6121         ("o" "Agenda and Office-related tasks"
6122          ((agenda)
6123           (tags-todo "work")
6124           (tags "office"))
6125          nil
6126          ("~/views/office.ps" "~/calendars/office.ics"))))
6127 @end group
6128 @end lisp
6130 The extension of the file name determines the type of export.  If it is
6131 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
6132 the buffer to HTML and save it to this file name.  If the extension is
6133 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
6134 postscript output.  If the extension is @file{.ics}, iCalendar export is
6135 run export over all files that were used to construct the agenda, and
6136 limit the export to entries listed in the agenda now.  Any other
6137 extension produces a plain ASCII file.
6139 The export files are @emph{not} created when you use one of those
6140 commands interactively because this might use too much overhead.
6141 Instead, there is a special command to produce @emph{all} specified
6142 files in one step:
6144 @table @kbd
6145 @kindex C-c a e
6146 @item C-c a e
6147 Export all agenda views that have export file names associated with
6148 them.
6149 @end table
6151 You can use the options section of the custom agenda commands to also
6152 set options for the export commands.  For example:
6154 @lisp
6155 (setq org-agenda-custom-commands
6156       '(("X" agenda ""
6157          ((ps-number-of-columns 2)
6158           (ps-landscape-mode t)
6159           (org-agenda-prefix-format " [ ] ")
6160           (org-agenda-with-colors nil)
6161           (org-agenda-remove-tags t))
6162          ("theagenda.ps"))))
6163 @end lisp
6165 @noindent
6166 This command sets two options for the postscript exporter, to make it
6167 print in two columns in landscape format - the resulting page can be cut
6168 in two and then used in a paper agenda.  The remaining settings modify
6169 the agenda prefix to omit category and scheduling information, and
6170 instead include a checkbox to check off items.  We also remove the tags
6171 to make the lines compact, and we don't want to use colors for the
6172 black-and-white printer.  Settings specified in
6173 @code{org-agenda-exporter-settings} will also apply, but the settings
6174 in @code{org-agenda-custom-commands} take precedence.
6176 @noindent
6177 From the command line you may also use
6178 @example
6179 emacs -f org-batch-store-agenda-views -kill
6180 @end example
6181 @noindent
6182 or, if you need to modify some parameters
6183 @example
6184 emacs -eval '(org-batch-store-agenda-views                      \
6185               org-agenda-ndays 30                               \
6186               org-agenda-start-day "2007-11-01"                 \
6187               org-agenda-include-diary nil                      \
6188               org-agenda-files (quote ("~/org/project.org")))'  \
6189       -kill
6190 @end example
6191 @noindent
6192 which will create the agenda views restricted to the file
6193 @file{~/org/project.org}, without diary entries and with 30 days
6194 extent.
6196 @node Using the agenda elsewhere,  , Exporting Agenda Views, Custom agenda views
6197 @subsection Using agenda information outside of Org
6198 @cindex agenda, pipe
6199 @cindex Scripts, for agenda processing
6201 Org provides commands to access agenda information for the command
6202 line in emacs batch mode.  This extracted information can be sent
6203 directly to a printer, or it can be read by a program that does further
6204 processing of the data.  The first of these commands is the function
6205 @code{org-batch-agenda}, that produces an agenda view and sends it as
6206 ASCII text to STDOUT.  The command takes a single string as parameter.
6207 If the string has length 1, it is used as a key to one of the commands
6208 you have configured in @code{org-agenda-custom-commands}, basically any
6209 key you can use after @kbd{C-c a}.  For example, to directly print the
6210 current TODO list, you could use
6212 @example
6213 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
6214 @end example
6216 If the parameter is a string with 2 or more characters, it is used as a
6217 tags/todo match string.  For example, to print your local shopping list
6218 (all items with the tag @samp{shop}, but excluding the tag
6219 @samp{NewYork}), you could use
6221 @example
6222 emacs -batch -l ~/.emacs                                      \
6223       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
6224 @end example
6226 @noindent
6227 You may also modify parameters on the fly like this:
6229 @example
6230 emacs -batch -l ~/.emacs                                      \
6231    -eval '(org-batch-agenda "a"                               \
6232             org-agenda-ndays 30                               \
6233             org-agenda-include-diary nil                      \
6234             org-agenda-files (quote ("~/org/project.org")))'  \
6235    | lpr
6236 @end example
6238 @noindent
6239 which will produce a 30 day agenda, fully restricted to the Org file
6240 @file{~/org/projects.org}, not even including the diary.
6242 If you want to process the agenda data in more sophisticated ways, you
6243 can use the command @code{org-batch-agenda-csv} to get a comma-separated
6244 list of values for each agenda item.  Each line in the output will
6245 contain a number of fields separated by commas.  The fields in a line
6246 are:
6248 @example
6249 category     @r{The category of the item}
6250 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
6251 type         @r{The type of the agenda entry, can be}
6252                 todo               @r{selected in TODO match}
6253                 tagsmatch          @r{selected in tags match}
6254                 diary              @r{imported from diary}
6255                 deadline           @r{a deadline}
6256                 scheduled          @r{scheduled}
6257                 timestamp          @r{appointment, selected by timestamp}
6258                 closed             @r{entry was closed on date}
6259                 upcoming-deadline  @r{warning about nearing deadline}
6260                 past-scheduled     @r{forwarded scheduled item}
6261                 block              @r{entry has date block including date}
6262 todo         @r{The TODO keyword, if any}
6263 tags         @r{All tags including inherited ones, separated by colons}
6264 date         @r{The relevant date, like 2007-2-14}
6265 time         @r{The time, like 15:00-16:50}
6266 extra        @r{String with extra planning info}
6267 priority-l   @r{The priority letter if any was given}
6268 priority-n   @r{The computed numerical priority}
6269 @end example
6271 @noindent
6272 Time and date will only be given if a timestamp (or deadline/scheduled)
6273 lead to the selection of the item.
6275 A CSV list like this is very easy to use in a post processing script.
6276 For example, here is a Perl program that gets the TODO list from
6277 Emacs/Org and prints all the items, preceded by a checkbox:
6279 @example
6280 @group
6281 #!/usr/bin/perl
6283 # define the Emacs command to run
6284 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
6286 # run it and capture the output
6287 $agenda = qx@{$cmd 2>/dev/null@};
6289 # loop over all lines
6290 foreach $line (split(/\n/,$agenda)) @{
6292   # get the individual values
6293   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
6294    $priority_l,$priority_n) = split(/,/,$line);
6296   # proccess and print
6297   print "[ ] $head\n";
6299 @end group
6300 @end example
6302 @node Agenda column view,  , Custom agenda views, Agenda Views
6303 @section Using column view in the agenda
6304 @cindex column view, in agenda
6305 @cindex agenda, column view
6307 Column view (@pxref{Column view}) is normally used to view and edit
6308 properties embedded in the hierarchical structure of an Org file.  It can be
6309 quite useful to use column view also from the agenda, where entries are
6310 collected by certain criteria.
6312 @table @kbd
6313 @kindex C-c C-x C-c
6314 @item C-c C-x C-c
6315 Turn on column view in the agenda.
6316 @end table
6318 To understand how to use this properly, it is important to realize that the
6319 entries in the agenda are no longer in their proper outline environment.
6320 This causes the following issues:
6322 @enumerate
6323 @item
6324 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
6325 entries in the agenda are collected from different files, and different files
6326 may have different @code{COLUMNS} formats, this is a non-trivial problem.
6327 Org first checks if the variable @code{org-overriding-columns-format} is
6328 currently set, and if yes takes the format from there.  Otherwise it takes
6329 the format associated with the first item in the agenda, or, if that item
6330 does not have a specific format (defined in a property, or in it's file), it
6331 uses @code{org-columns-default-format}.
6332 @item
6333 If any of the columns has a summary type defined (@pxref{Column attributes}),
6334 turning on column view in the agenda will visit all relevant agenda files and
6335 make sure that the computations of this property are up to date.  This is
6336 also true for the special @code{CLOCKSUM} property.  Org will then sum the
6337 values displayed in the agenda.  In the daily/weekly agenda, the sums will
6338 cover a single day, in all other views they cover the entire block.  It is
6339 vital to realize that the agenda may show the same entry @emph{twice} (for
6340 example as scheduled and as a deadline), and it may show two entries from the
6341 same hierarchy (for example a @emph{parent} and it's @emph{child}).  In these
6342 cases, the summation in the agenda will lead to incorrect results because
6343 some values will count double.
6344 @item
6345 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
6346 the entire clocked time for this item.  So even in the daily/weekly agenda,
6347 the clocksum listed in column view may originate from times outside the
6348 current view.  This has the advantage that you can compare these values with
6349 a column listing the planned total effort for a task - one of the major
6350 applications for column view in the agenda.  If you want information about
6351 clocked time in the displayed period use clock table mode (press @kbd{R} in
6352 the agenda).
6353 @end enumerate
6356 @node Embedded LaTeX, Exporting, Agenda Views, Top
6357 @chapter Embedded LaTeX
6358 @cindex @TeX{} interpretation
6359 @cindex La@TeX{} interpretation
6361 Plain ASCII is normally sufficient for almost all note taking.  One
6362 exception, however, are scientific notes which need to be able to contain
6363 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
6364 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
6365 features described here as ``La@TeX{}'' are really from @TeX{}, but for
6366 simplicity I am blurring this distinction.}  is widely used to typeset
6367 scientific documents. Org mode supports embedding La@TeX{} code into its
6368 files, because many academics are used to reading La@TeX{} source code, and
6369 because it can be readily processed into images for HTML production.
6371 It is not necessary to mark La@TeX{} macros and code in any special way.
6372 If you observe a few conventions, Org mode knows how to find it and what
6373 to do with it.
6375 @menu
6376 * Math symbols::                TeX macros for symbols and Greek letters
6377 * Subscripts and superscripts::  Simple syntax for raising/lowering text
6378 * LaTeX fragments::             Complex formulas made easy
6379 * Processing LaTeX fragments::  Previewing LaTeX processing
6380 * CDLaTeX mode::                Speed up entering of formulas
6381 @end menu
6383 @node Math symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
6384 @section Math symbols
6385 @cindex math symbols
6386 @cindex TeX macros
6388 You can use La@TeX{} macros to insert special symbols like @samp{\alpha}
6389 to indicate the Greek letter, or @samp{\to} to indicate an arrow.
6390 Completion for these macros is available, just type @samp{\} and maybe a
6391 few letters, and press @kbd{M-@key{TAB}} to see possible completions.
6392 Unlike La@TeX{} code, Org mode allows these macros to be present
6393 without surrounding math delimiters, for example:
6395 @example
6396 Angles are written as Greek letters \alpha, \beta and \gamma.
6397 @end example
6399 During HTML export (@pxref{HTML export}), these symbols are translated
6400 into the proper syntax for HTML, for the above examples this is
6401 @samp{&alpha;} and @samp{&rarr;}, respectively.
6403 @node Subscripts and superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
6404 @section Subscripts and superscripts
6405 @cindex subscript
6406 @cindex superscript
6408 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
6409 and subscripts.  Again, these can be used without embedding them in
6410 math-mode delimiters.  To increase the readability of ASCII text, it is
6411 not necessary (but OK) to surround multi-character sub- and superscripts
6412 with curly braces.  For example
6414 @example
6415 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
6416 the sun is R_@{sun@} = 6.96 x 10^8 m.
6417 @end example
6419 To avoid interpretation as raised or lowered text, you can quote
6420 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
6422 During HTML export (@pxref{HTML export}), subscript and superscripts
6423 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
6425 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
6426 @section LaTeX fragments
6427 @cindex LaTeX fragments
6429 With symbols, sub- and superscripts, HTML is pretty much at its end when
6430 it comes to representing mathematical formulas@footnote{Yes, there is
6431 MathML, but that is not yet fully supported by many browsers, and there
6432 is no decent converter for turning La@TeX{} or ASCII representations of
6433 formulas into MathML. So for the time being, converting formulas into
6434 images seems the way to go.}. More complex expressions need a dedicated
6435 formula processor. To this end, Org mode can contain arbitrary La@TeX{}
6436 fragments. It provides commands to preview the typeset result of these
6437 fragments, and upon export to HTML, all fragments will be converted to
6438 images and inlined into the HTML document@footnote{The La@TeX{} export
6439 will not use images for displaying La@TeX{} fragments but include these
6440 fragments directly into the La@TeX{} code.}. For this to work you
6441 need to be on a system with a working La@TeX{} installation. You also
6442 need the @file{dvipng} program, available at
6443 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
6444 will be used when processing a fragment can be configured with the
6445 variable @code{org-format-latex-header}.
6447 La@TeX{} fragments don't need any special marking at all.  The following
6448 snippets will be identified as La@TeX{} source code:
6449 @itemize @bullet
6450 @item
6451 Environments of any kind.  The only requirement is that the
6452 @code{\begin} statement appears on a new line, preceded by only
6453 whitespace.
6454 @item
6455 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
6456 currency specifications, single @samp{$} characters are only recognized
6457 as math delimiters if the enclosed text contains at most two line breaks,
6458 is directly attached to the @samp{$} characters with no whitespace in
6459 between, and if the closing @samp{$} is followed by whitespace or
6460 punctuation.  For the other delimiters, there is no such restriction, so
6461 when in doubt, use @samp{\(...\)} as inline math delimiters.
6462 @end itemize
6464 @noindent For example:
6466 @example
6467 \begin@{equation@}                          % arbitrary environments,
6468 x=\sqrt@{b@}                                % even tables, figures
6469 \end@{equation@}                            % etc
6471 If $a^2=b$ and \( b=2 \), then the solution must be
6472 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
6473 @end example
6475 @noindent
6476 If you need any of the delimiter ASCII sequences for other purposes, you
6477 can configure the option @code{org-format-latex-options} to deselect the
6478 ones you do not wish to have interpreted by the La@TeX{} converter.
6480 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
6481 @section Processing LaTeX fragments
6482 @cindex LaTeX fragments, preview
6484 La@TeX{} fragments can be processed to produce a preview images of the
6485 typeset expressions:
6487 @table @kbd
6488 @kindex C-c C-x C-l
6489 @item C-c C-x C-l
6490 Produce a preview image of the La@TeX{} fragment at point and overlay it
6491 over the source code.  If there is no fragment at point, process all
6492 fragments in the current entry (between two headlines).  When called
6493 with a prefix argument, process the entire subtree.  When called with
6494 two prefix arguments, or when the cursor is before the first headline,
6495 process the entire buffer.
6496 @kindex C-c C-c
6497 @item C-c C-c
6498 Remove the overlay preview images.
6499 @end table
6501 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
6502 converted into images and inlined into the document if the following
6503 setting is active:
6505 @lisp
6506 (setq org-export-with-LaTeX-fragments t)
6507 @end lisp
6509 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
6510 @section Using CDLaTeX to enter math
6511 @cindex CDLaTeX
6513 CDLaTeX mode is a minor mode that is normally used in combination with a
6514 major La@TeX{} mode like AUCTeX in order to speed-up insertion of
6515 environments and math templates.  Inside Org mode, you can make use of
6516 some of the features of CDLaTeX mode.  You need to install
6517 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
6518 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
6519 Don't use CDLaTeX mode itself under Org mode, but use the light
6520 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
6521 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
6522 Org files with
6524 @lisp
6525 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
6526 @end lisp
6528 When this mode is enabled, the following features are present (for more
6529 details see the documentation of CDLaTeX mode):
6530 @itemize @bullet
6531 @kindex C-c @{
6532 @item
6533 Environment templates can be inserted with @kbd{C-c @{}.
6534 @item
6535 @kindex @key{TAB}
6536 The @key{TAB} key will do template expansion if the cursor is inside a
6537 La@TeX{} fragment@footnote{Org mode has a method to test if the cursor is
6538 inside such a fragment, see the documentation of the function
6539 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
6540 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
6541 correctly inside the first brace.  Another @key{TAB} will get you into
6542 the second brace.  Even outside fragments, @key{TAB} will expand
6543 environment abbreviations at the beginning of a line.  For example, if
6544 you write @samp{equ} at the beginning of a line and press @key{TAB},
6545 this abbreviation will be expanded to an @code{equation} environment.
6546 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
6547 @item
6548 @kindex _
6549 @kindex ^
6550 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
6551 characters together with a pair of braces.  If you use @key{TAB} to move
6552 out of the braces, and if the braces surround only a single character or
6553 macro, they are removed again (depending on the variable
6554 @code{cdlatex-simplify-sub-super-scripts}).
6555 @item
6556 @kindex `
6557 Pressing the backquote @kbd{`} followed by a character inserts math
6558 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
6559 after the backquote, a help window will pop up.
6560 @item
6561 @kindex '
6562 Pressing the normal quote @kbd{'} followed by another character modifies
6563 the symbol before point with an accent or a font.  If you wait more than
6564 1.5 seconds after the backquote, a help window will pop up.  Character
6565 modification will work only inside La@TeX{} fragments, outside the quote
6566 is normal.
6567 @end itemize
6569 @node Exporting, Publishing, Embedded LaTeX, Top
6570 @chapter Exporting
6571 @cindex exporting
6573 Org mode documents can be exported into a variety of other formats.  For
6574 printing and sharing of notes, ASCII export produces a readable and
6575 simple version of an Org file.  HTML export allows you to publish a
6576 notes file on the web, while the XOXO format provides a solid base for
6577 exchange with a broad range of other applications. La@TeX{} export lets
6578 you use Org mode and its structured editing functions to easily create
6579 La@TeX{} files.  To incorporate entries with associated times like
6580 deadlines or appointments into a desktop calendar program like iCal,
6581 Org mode can also produce extracts in the iCalendar format.  Currently
6582 Org mode only supports export, not import of these different formats.
6584 @menu
6585 * Markup rules::                Which structures are recognized?
6586 * Export options::              Per-file export settings
6587 * The export dispatcher::       How to access exporter commands
6588 * ASCII export::                Exporting to plain ASCII
6589 * HTML export::                 Exporting to HTML
6590 * LaTeX export::                Exporting to LaTeX
6591 * XOXO export::                 Exporting to XOXO
6592 * iCalendar export::            Exporting in iCalendar format
6593 @end menu
6595 @node Markup rules, Export options, Exporting, Exporting
6596 @section Markup rules
6598 When exporting Org mode documents,  the exporter tries to reflect the
6599 structure of the document as accurately as possible in the back-end.  Since
6600 export targets like HTML or La@TeX{} allow much richer formatting, Org mode
6601 has rules how to prepare text for rich export.  This section summarizes the
6602 markup rule used in an Org mode buffer.
6604 @menu
6605 * Document title::              How the document title is determined
6606 * Headings and sections::       The main structure of the exported document
6607 * Table of contents::           If, where, how to create a table of contents
6608 * Initial text::                Text before the first headline
6609 * Lists::                       Plain lists are exported
6610 * Paragraphs::                  What determines beginning and ending
6611 * Literal examples::            Source code and other examples
6612 * Include files::               Include the contents of a file during export
6613 * Tables exported::             Tables are exported richly
6614 * Footnotes::                   Numbers like [1]
6615 * Emphasis and monospace::      To bold or not to bold
6616 * TeX macros and LaTeX fragments::  Create special, rich export.
6617 * Horizontal rules::            A line across the page
6618 * Comment lines::               Some lines will not be exported
6619 @end menu
6621 @node Document title, Headings and sections, Markup rules, Markup rules
6622 @subheading Document title
6624 @noindent
6625 The title of the exported document is taken from the special line
6627 @example
6628 #+TITLE: This is the title of the document
6629 @end example
6631 @noindent
6632 If this line does not exist, the title is derived from the first non-empty,
6633 non-comment line in the buffer.  If no such line exists, or if you have
6634 turned off exporting of the text before the first headline (see below), the
6635 title will be the file name without extension.
6637 If you are exporting only a subtree by marking is as the region, the heading
6638 of the subtree will become the title of the document.
6640 @node Headings and sections, Table of contents, Document title, Markup rules
6641 @subheading Headings and sections
6643 The outline structure of the document as described in @ref{Document
6644 Structure} forms the basis for defining sections of the exported document.
6645 However, since the outline structure is also used for (for example) lists of
6646 tasks, only the first three outline levels will be used as headings.  Deeper
6647 levels will become itemized lists.  You can change the location of this
6648 switch, globally by setting the variable @code{org-headline-levels}, or on a
6649 per file basis with a line
6651 @example
6652 #+OPTIONS: H:4
6653 @end example
6655 @node Table of contents, Initial text, Headings and sections, Markup rules
6656 @subheading Table of contents
6658 The table of contents is normally inserted directly before the first headline
6659 of the file.  If you would like to get it to a different location, insert the
6660 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
6661 location.  The depth of the table of contents is by default the same as the
6662 number of headline levels, but you can choose a smaller number or turn off
6663 the table of contents entirely by configuring the variable
6664 @code{org-export-with-toc}, or on a per-file basis with a line like
6666 @example
6667 #+OPTIONS: toc:2          (only to two levels in TOC)
6668 #+OPTIONS: toc:nil        (no TOC at all)
6669 @end example
6671 @node Initial text, Lists, Table of contents, Markup rules
6672 @subheading Text before the first headline
6674 Org mode normally exports the text before the first headline, and even uses
6675 the first line as the document title.  The text will be fully marked up.  If
6676 you need to include literal HTML or La@TeX{} code, use the special constructs
6677 described below in the sections for the individual exporters.
6679 Some people like to use the space before the first headline for setup and
6680 internal links and therefore would like to control the exported text before
6681 the first headline in a different way.  You can do so by setting the variable
6682 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
6683 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
6685 @noindent
6686 If you still want to have some text before the first headline, use the
6687 @code{#+TEXT} construct:
6689 @example
6690 #+OPTIONS: skip:t
6691 #+TEXT: This text will go before the *first* headline.
6692 #+TEXT: [TABLE-OF-CONTENTS]
6693 #+TEXT: This goes between the table of contents and the first headline
6694 @end example
6696 @node Lists, Paragraphs, Initial text, Markup rules
6697 @subheading Lists
6699 Plain lists as described in @ref{Plain lists} are translated to the back-ends
6700 syntax for such lists.  Most back-ends support unordered, ordered, and
6701 description lists.
6703 @node Paragraphs, Literal examples, Lists, Markup rules
6704 @subheading Paragraphs, line breaks, and quoting
6706 Paragraphs are separated by at least one empty line.  If you need to enforce
6707 a line break within a paragraph, use @samp{\\} at the end of a line.
6709 When quoting a passage from another document, it is customary to format this
6710 as a paragraph that is indented on both the left and the right margin.  You
6711 can include quotations in Org mode documents like this:
6713 @example
6714 #+begin_quote
6715 Everything should be made as simple as possible,
6716 but not any simpler -- Albert Einstein
6717 #+end_quote
6718 @end example
6720 @node Literal examples, Include files, Paragraphs, Markup rules
6721 @subheading Literal examples
6723 You can include literal examples that should not be subjected to
6724 markup.  Such examples will be typeset in monospace, so this is well suited
6725 for source code and similar examples.
6727 @example
6728 #+begin_example
6729 Some example from a text file.
6730 #+end_example
6731 @end example
6733 For simplicity when using small examples, you can also start the example
6734 lines with a colon:
6736 @example
6737 : Some example from a text file.
6738 @end example
6740 If the example is source code from a programming language, or any other text
6741 that can be marked up by font-lock in Emacs, you can ask for the example to
6742 look like the fontified Emacs buffer@footnote{Currently this works only for
6743 the HTML back-end, and requires the @file{htmlize.el} package version 1.34 or
6744 later.}.  This is done with the @samp{src} block, where you also need to
6745 specify the name of the major mode that should be used to fontify the
6746 example:
6748 @example
6749 #+begin_src emacs-lisp
6750 (defun org-xor (a b)
6751    "Exclusive or."
6752    (if a (not b) b))
6753 #+end_src
6754 @end example
6756 @node Include files, Tables exported, Literal examples, Markup rules
6757 @subheading Include files
6759 During export, you can include the content of another file.  For example, to
6760 include your .emacs file, you could use:
6762 @example
6763 #+include "~/.emacs" src emacs-lisp
6764 @end example
6766 The optional second and third parameter are the markup (@samp{quote},
6767 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
6768 language for formatting the contents.  The markup is optional, if it is not
6769 given, the text will be assumed to be in Org mode format and will be
6770 processed normally.
6772 @node Tables exported, Footnotes, Include files, Markup rules
6773 @subheading Tables
6775 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
6776 the @file{table.el} package will be exported properly.  For Org mode tables,
6777 the lines before the first horizontal separator line will become table header
6778 lines.
6780 @node Footnotes, Emphasis and monospace, Tables exported, Markup rules
6781 @subheading Footnotes
6782 @cindex footnotes
6783 @cindex @file{footnote.el}
6785 @kindex C-c !
6786 Numbers in square brackets are treated as footnote markers, and lines
6787 starting with such a marker are interpreted as the footnote itself.  You can
6788 use the Emacs package @file{footnote.el} to create footnotes@footnote{The
6789 @file{footnote} package uses @kbd{C-c !} to invoke its commands.  This
6790 binding conflicts with the Org mode command for inserting inactive time
6791 stamps.  You could use the variable @code{footnote-prefix} to switch
6792 footnotes commands to another key.  Or, if you are too used to this binding,
6793 you could use @code{org-replace-disputed-keys} and @code{org-disputed-keys}
6794 to change the settings in Org.}.  For example:
6796 @example
6797 The Org homepage[1] now looks a lot better than it used to.
6799 [1] The link is: http://orgmode.org
6800 @end example
6802 @node Emphasis and monospace, TeX macros and LaTeX fragments, Footnotes, Markup rules
6803 @subheading Emphasis and monospace
6805 @cindex underlined text
6806 @cindex bold text
6807 @cindex italic text
6808 @cindex verbatim text
6809 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
6810 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
6811 in the code and verbatim string is not processed for Org mode specific
6812 syntax, it is exported verbatim.
6814 @node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
6815 @subheading @TeX{} macros and La@TeX{} fragments
6816 @cindex LaTeX fragments, export
6817 @cindex TeX macros, export
6818 @cindex HTML entities
6819 @cindex LaTeX entities
6821 A @TeX{}-like syntax is used to specify special characters.  Where possible,
6822 these will be transformed into the native format of the exporter back-end.
6823 Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
6824 output, and as @code{$\alpha$} in the La@TeX{} output.  Similarly,
6825 @code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
6826 This applies for a large number of entities, with names taken from both HTML
6827 and La@TeX{}, see the variable @code{org-html-entities} for the complete
6828 list.  If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
6829 after having types the backslash and maybe a few characters
6830 (@pxref{Completion}).
6832 La@TeX{} fragments are converted into images for HTML export, and they are
6833 written literally into the La@TeX{} export.  See also @ref{Embedded LaTeX}.
6835 Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
6836 @samp{...} are all converted into special commands creating hyphens of
6837 different lengths or a compact set of dots.
6839 @node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
6840 @subheading  Horizontal rules
6841 @cindex horizontal rules, in exported files
6842 A line consisting of only dashes, and at least 5 of them, will be
6843 exported as a horizontal line (@samp{<hr/>} in HTML).
6845 @node Comment lines,  , Horizontal rules, Markup rules
6846 @subheading Comment lines
6847 @cindex comment lines
6848 @cindex exporting, not
6850 Lines starting with @samp{#} in column zero are treated as comments
6851 and will never be exported.  Also entire subtrees starting with the
6852 word @samp{COMMENT} will never be exported.
6854 @table @kbd
6855 @kindex C-c ;
6856 @item C-c ;
6857 Toggle the COMMENT keyword at the beginning of an entry.
6858 @end table
6860 @node Export options, The export dispatcher, Markup rules, Exporting
6861 @section Export options
6862 @cindex options, for export
6864 @cindex completion, of option keywords
6865 The exporter recognizes special lines in the buffer which provide
6866 additional information.  These lines may be put anywhere in the file.
6867 The whole set of lines can be inserted into the buffer with @kbd{C-c
6868 C-e t}.  For individual lines, a good way to make sure the keyword is
6869 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
6870 (@pxref{Completion}).
6872 @table @kbd
6873 @kindex C-c C-e t
6874 @item C-c C-e t
6875 Insert template with export options, see example below.
6876 @end table
6878 @example
6879 #+TITLE:     the title to be shown (default is the buffer name)
6880 #+AUTHOR:    the author (default taken from @code{user-full-name})
6881 #+DATE:      A date, fixed, of a format string for @code{format-time-string}
6882 #+EMAIL:     his/her email address (default from @code{user-mail-address})
6883 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
6884 #+TEXT:      Some descriptive text to be inserted at the beginning.
6885 #+TEXT:      Several lines may be given.
6886 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
6887 @end example
6889 @noindent
6890 The OPTIONS line is a compact@footnote{If you want to configure many options
6891 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
6892 you can:
6893 @cindex headline levels
6894 @cindex section-numbers
6895 @cindex table of contents
6896 @cindex line-break preservation
6897 @cindex quoted HTML tags
6898 @cindex fixed-width sections
6899 @cindex tables
6900 @cindex @TeX{}-like syntax for sub- and superscripts
6901 @cindex footnotes
6902 @cindex special strings
6903 @cindex emphasized text
6904 @cindex @TeX{} macros
6905 @cindex La@TeX{} fragments
6906 @cindex author info, in export
6907 @cindex time info, in export
6908 @example
6909 H:         @r{set the number of headline levels for export}
6910 num:       @r{turn on/off section-numbers}
6911 toc:       @r{turn on/off table of contents, or set level limit (integer)}
6912 \n:        @r{turn on/off line-break-preservation}
6913 @@:         @r{turn on/off quoted HTML tags}
6914 ::         @r{turn on/off fixed-width sections}
6915 |:         @r{turn on/off tables}
6916 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
6917            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
6918            @r{the simple @code{a_b} will be left as it is.}
6919 -:         @r{turn on/off conversion of special strings.}
6920 f:         @r{turn on/off footnotes like this[1].}
6921 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
6922 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
6923 LaTeX:     @r{turn on/off La@TeX{} fragments}
6924 skip:      @r{turn on/off skipping the text before the first heading}
6925 author:    @r{turn on/off inclusion of author name/email into exported file}
6926 timestamp: @r{turn on/off inclusion creation time into exported file}
6927 d:         @r{turn on/off inclusion of drawers}
6928 @end example
6930 These options take effect in both the HTML and La@TeX{} export, except
6931 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
6932 @code{nil} for the La@TeX{} export.
6935 @node The export dispatcher, ASCII export, Export options, Exporting
6936 @section The export dispatcher
6938 All export commands can be reached using the export dispatcher, which is a
6939 prefix key that prompts for an additional key specifying the command.
6940 Normally the entire file is exported, but if there is an active region that
6941 contains one outline tree, the first heading is used as document title and
6942 the subtrees are exported.
6944 @table @kbd
6945 @kindex C-c C-e
6946 @item C-c C-e
6947 Dispatcher for export and publishing commands.  Displays a help-window
6948 listing the additional key(s) needed to launch an export or publishing
6949 command.  The prefix arg is passed through to the exporter.  If the option
6950 @code{org-export-run-in-background} is set, Org will run the command in the
6951 background if that seems useful for the specific command (i.e. commands that
6952 write to a file).
6953 @kindex C-c C-e v
6954 @item C-c C-e v
6955 Like @kbd{C-c C-e}, but only export the text that is currently visible
6956 (i.e. not hidden by outline visibility).
6957 @kindex C-u C-u C-c C-e
6958 @item C-u C-u C-c C-e
6959 Call an the exporter, but reverse the setting of
6960 @code{org-export-run-in-background}, i.e. request background processing if
6961 not set, or force processing in the current Emacs process if st.
6962 @end table
6964 @node ASCII export, HTML export, The export dispatcher, Exporting
6965 @section ASCII export
6966 @cindex ASCII export
6968 ASCII export produces a simple and very readable version of an Org mode
6969 file.
6971 @cindex region, active
6972 @cindex active region
6973 @cindex Transient mark mode
6974 @table @kbd
6975 @kindex C-c C-e a
6976 @item C-c C-e a
6977 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
6978 will be @file{myfile.txt}.  The file will be overwritten without
6979 warning.  If there is an active region, only the region will be
6980 exported. If the selected region is a single tree, the tree head will
6981 become the document title.  If the tree head entry has or inherits an
6982 @code{:EXPORT_FILE_NAME:} property, that name will be used for the
6983 export.
6984 @kindex C-c C-e v a
6985 @item C-c C-e v a
6986 Export only the visible part of the document.
6987 @end table
6989 @cindex headline levels, for exporting
6990 In the exported version, the first 3 outline levels will become
6991 headlines, defining a general document structure.  Additional levels
6992 will be exported as itemized lists.  If you want that transition to occur
6993 at a different level, specify it with a prefix argument.  For example,
6995 @example
6996 @kbd{C-1 C-c C-e a}
6997 @end example
6999 @noindent
7000 creates only top level headlines and does the rest as items.  When
7001 headlines are converted to items, the indentation of the text following
7002 the headline is changed to fit nicely under the item.  This is done with
7003 the assumption that the first body line indicates the base indentation of
7004 the body text.  Any indentation larger than this is adjusted to preserve
7005 the layout relative to the first line.  Should there be lines with less
7006 indentation than the first, these are left alone.
7008 @node HTML export, LaTeX export, ASCII export, Exporting
7009 @section HTML export
7010 @cindex HTML export
7012 Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
7013 HTML formatting, in ways similar to John Grubers @emph{markdown}
7014 language, but with additional support for tables.
7016 @menu
7017 * HTML Export commands::        How to invoke HTML export
7018 * Quoting HTML tags::           Using direct HTML in Org mode
7019 * Links::                       Transformation of links for HTML
7020 * Images::                      How to include images
7021 * CSS support::                 Changing the appearance of the output
7022 * Javascript support::          Info and Folding in a web browser
7023 @end menu
7025 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
7026 @subsection HTML export commands
7028 @cindex region, active
7029 @cindex active region
7030 @cindex Transient mark mode
7031 @table @kbd
7032 @kindex C-c C-e h
7033 @item C-c C-e h
7034 Export as HTML file @file{myfile.html}.  For an org file
7035 @file{myfile.org}, the ASCII file will be @file{myfile.html}.  The file
7036 will be overwritten without warning.  If there is an active region, only
7037 the region will be exported. If the selected region is a single tree,
7038 the tree head will become the document title.  If the tree head entry
7039 has or inherits an @code{:EXPORT_FILE_NAME:} property, that name will be
7040 used for the export.
7041 @kindex C-c C-e b
7042 @item C-c C-e b
7043 Export as HTML file and immediately open it with a browser.
7044 @kindex C-c C-e H
7045 @item C-c C-e H
7046 Export to a temporary buffer, do not create a file.
7047 @kindex C-c C-e R
7048 @item C-c C-e R
7049 Export the active region to a temporary buffer.  With a prefix argument, do
7050 not produce the file header and footer, but just the plain HTML section for
7051 the region.  This is good for cut-and-paste operations.
7052 @kindex C-c C-e v h
7053 @kindex C-c C-e v b
7054 @kindex C-c C-e v H
7055 @kindex C-c C-e v R
7056 @item C-c C-e v h
7057 @item C-c C-e v b
7058 @item C-c C-e v H
7059 @item C-c C-e v R
7060 Export only the visible part of the document.
7061 @item M-x org-export-region-as-html
7062 Convert the region to HTML under the assumption that it was Org mode
7063 syntax before.  This is a global command that can be invoked in any
7064 buffer.
7065 @item M-x org-replace-region-by-HTML
7066 Replace the active region (assumed to be in Org mode syntax) by HTML
7067 code.
7068 @end table
7070 @cindex headline levels, for exporting
7071 In the exported version, the first 3 outline levels will become headlines,
7072 defining a general document structure.  Additional levels will be exported as
7073 itemized lists.  If you want that transition to occur at a different level,
7074 specify it with a numeric prefix argument.  For example,
7076 @example
7077 @kbd{C-2 C-c C-e b}
7078 @end example
7080 @noindent
7081 creates two levels of headings and does the rest as items.
7083 @node Quoting HTML tags, Links, HTML Export commands, HTML export
7084 @subsection Quoting HTML tags
7086 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
7087 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
7088 which should be interpreted as such, mark them with @samp{@@} as in
7089 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
7090 simple tags.  For more extensive HTML that should be copied verbatim to
7091 the exported file use either
7093 @example
7094 #+HTML: Literal HTML code for export
7095 @end example
7097 @noindent or
7099 @example
7100 #+BEGIN_HTML
7101 All lines between these markers are exported literally
7102 #+END_HTML
7103 @end example
7106 @node Links, Images, Quoting HTML tags, HTML export
7107 @subsection Links
7109 @cindex links, in HTML export
7110 @cindex internal links, in HTML export
7111 @cindex external links, in HTML export
7112 Internal links (@pxref{Internal links}) will continue to work in HTML
7113 files only if they match a dedicated @samp{<<target>>}.  Automatic links
7114 created by radio targets (@pxref{Radio targets}) will also work in the
7115 HTML file.  Links to external files will still work if the HTML file is
7116 in the same directory as the Org file.  Links to other @file{.org}
7117 files will be translated into HTML links under the assumption that an
7118 HTML version also exists of the linked file.  For information related to
7119 linking files while publishing them to a publishing directory see
7120 @ref{Publishing links}.
7122 @node Images, CSS support, Links, HTML export
7123 @subsection Images
7125 @cindex images, inline in HTML
7126 @cindex inlining images in HTML
7127 HTML export can inline images given as links in the Org file, and
7128 it can make an image the clickable part of a link.  By
7129 default@footnote{but see the variable
7130 @code{org-export-html-inline-images}}, images are inlined if a link does
7131 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
7132 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
7133 @samp{the image} that points to the image.  If the description part
7134 itself is a @code{file:} link or a @code{http:} URL pointing to an
7135 image, this image will be inlined and activated so that clicking on the
7136 image will activate the link.  For example, to include a thumbnail that
7137 will link to a high resolution version of the image, you could use:
7139 @example
7140 [[file:highres.jpg][file:thumb.jpg]]
7141 @end example
7143 @noindent
7144 and you could use @code{http} addresses just as well.
7146 @node CSS support, Javascript support, Images, HTML export
7147 @subsection CSS support
7148 @cindex CSS, for HTML export
7149 @cindex HTML export, CSS
7151 You can also give style information for the exported file.  The HTML
7152 exporter assigns the following CSS classes to appropriate parts of the
7153 document - your style specifications may change these:
7154 @example
7155 .todo           @r{TODO keywords}
7156 .done           @r{the DONE keyword}
7157 .timestamp      @r{time stamp}
7158 .timestamp-kwd  @r{keyword associated with a time stamp, like SCHEDULED}
7159 .tag            @r{tag in a headline}
7160 .target         @r{target for links}
7161 @end example
7163 The default style specification can be configured through the option
7164 @code{org-export-html-style}.  If you want to use a file-local style,
7165 you may use file variables, best wrapped into a COMMENT section at the
7166 end of the outline tree.  For example@footnote{Under Emacs 21, the
7167 continuation lines for a variable value should have no @samp{#} at the
7168 start of the line.}:
7170 @example
7171 * COMMENT html style specifications
7173 # Local Variables:
7174 # org-export-html-style: "   <style type=\"text/css\">
7175 #       p @{font-weight: normal; color: gray; @}
7176 #       h1 @{color: black; @}
7177 #   </style>"
7178 # End:
7179 @end example
7181 Remember to execute @kbd{M-x normal-mode} after changing this to make
7182 the new style visible to Emacs.  This command restarts Org mode for the
7183 current buffer and forces Emacs to re-evaluate the local variables
7184 section in the buffer.
7186 @c FIXME: More about header and footer styles
7187 @c FIXME: Talk about links and targets.
7189 @node Javascript support,  , CSS support, HTML export
7190 @subsection Javascript supported display of web pages
7192 @emph{Sebastian Rose} has written a JavaScript program especially designed to
7193 enhance the web viewing experience of HTML files created with Org.  This
7194 program allows to view large files in two different ways.  The first one is
7195 an @emph{Info}-like mode where each section is displayed separately and
7196 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
7197 as well, press @kbd{?} for an overview of the available keys).  The second
7198 view type is a @emph{folding} view much like Org provides it inside Emacs.
7199 The script is available at @url{http://orgmode.org/org-info.js} and you can
7200 find the documentation for it at @url{http://orgmode.org/org-infojs.html}.
7201 We are serving the script from our site, but if you use it a lot, you might
7202 not want to be dependent on @url{orgmode.org} and prefer to install a local
7203 copy on your own web server.
7205 To use the script, you need to make sure that the @file{org-infojs.el} module
7206 gets loaded.  It should be loaded by default, try @kbd{M-x customize-variable
7207 @key{RET} org-modules @key{RET}} to convince yourself that this is indeed the
7208 case.  All it then takes to make use of the program is adding a single line
7209 to the Org file:
7211 @example
7212 #+INFOSJ_OPT: view:info toc:nil
7213 @end example
7215 @noindent
7216 If this line is found, the HTML header will automatically contain the code
7217 needed to invoke the script.  Using the line above, you can set the following
7218 viewing options:
7220 @example
7221 path:    @r{The path to the script.  The default is to grab the script from}
7222          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
7223          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
7224 view:    @r{Initial view when website is first shown.  Possible values are}
7225          info      @r{Info-like interface with one section per page.}
7226          overview  @r{Folding interface, initially showing only top-level.}
7227          content   @r{Folding interface, starting with all headlines visible.}
7228          showall   @r{Folding interface, all headlines and text visible.}
7229 sdepth:  @r{Maximum headline level that will still become an independent}
7230          @r{section for info and folding modes.  The default is taken from}
7231          @r{@code{org-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
7232          @r{If this is smaller than in @code{org-headline-levels}, each}
7233          @r{info/folding section can still contain children headlines.}
7234 toc:     @r{Should the table of content @emph{initially} be visible?}
7235          @r{Even when @code{nil}, you can always get to the toc with @kbd{i}.}
7236 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
7237          @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.}
7238 ltoc:    @r{Should there be short contents (children) in each section?}
7239 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
7240          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
7241 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
7242          @r{default), only one such button will be present.}
7243 @end example
7245 You can choose default values for these options by customizing the variable
7246 @code{org-infojs-options}.  If you always want to apply the script to your
7247 pages, configure the variable @code{org-export-html-use-infojs}.
7249 @node LaTeX export, XOXO export, HTML export, Exporting
7250 @section LaTeX export
7251 @cindex LaTeX export
7253 Org mode contains a La@TeX{} exporter written by Bastien Guerry.
7255 @menu
7256 * LaTeX export commands::       How to invoke LaTeX export
7257 * Quoting LaTeX code::          Incorporating literal LaTeX code
7258 * Sectioning structure::        Changing sectioning in LaTeX output
7259 @end menu
7261 @node LaTeX export commands, Quoting LaTeX code, LaTeX export, LaTeX export
7262 @subsection LaTeX export commands
7264 @table @kbd
7265 @kindex C-c C-e l
7266 @item C-c C-e l
7267 Export as La@TeX{} file @file{myfile.tex}.
7268 @kindex C-c C-e L
7269 @item C-c C-e L
7270 Export to a temporary buffer, do not create a file.
7271 @kindex C-c C-e v l
7272 @kindex C-c C-e v L
7273 @item C-c C-e v l
7274 @item C-c C-e v L
7275 Export only the visible part of the document.
7276 @item M-x org-export-region-as-latex
7277 Convert the region to La@TeX{} under the assumption that it was Org mode
7278 syntax before.  This is a global command that can be invoked in any
7279 buffer.
7280 @item M-x org-replace-region-by-latex
7281 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
7282 code.
7283 @end table
7285 @cindex headline levels, for exporting
7286 In the exported version, the first 3 outline levels will become
7287 headlines, defining a general document structure.  Additional levels
7288 will be exported as description lists.  The exporter can ignore them or
7289 convert them to a custom string depending on
7290 @code{org-latex-low-levels}.
7292 If you want that transition to occur at a different level, specify it
7293 with a numeric prefix argument. For example,
7295 @example
7296 @kbd{C-2 C-c C-e l}
7297 @end example
7299 @noindent
7300 creates two levels of headings and does the rest as items.
7302 @node Quoting LaTeX code, Sectioning structure, LaTeX export commands, LaTeX export
7303 @subsection Quoting LaTeX code
7305 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
7306 inserted into the La@TeX{} file.  Furthermore, you can add special code
7307 that should only be present in La@TeX{} export with the following
7308 constructs:
7310 @example
7311 #+LaTeX: Literal LaTeX code for export
7312 @end example
7314 @noindent or
7316 @example
7317 #+BEGIN_LaTeX
7318 All lines between these markers are exported literally
7319 #+END_LaTeX
7320 @end example
7324 @node   Sectioning structure,  , Quoting LaTeX code, LaTeX export
7325 @subsection Sectioning structure
7326 @cindex LaTeX class
7327 @cindex LaTeX sectioning structure
7329 By default, the La@TeX{} output uses the class @code{article}.
7331 You can change this globally by setting a different value for
7332 @code{org-export-latex-default-class} or locally by adding an option
7333 like @code{#+LaTeX_CLASS: myclass} in your file.  The class should be
7334 listed in @code{org-export-latex-classes}, where you can also define the
7335 sectioning structure for each class.
7338 @node XOXO export, iCalendar export, LaTeX export, Exporting
7339 @section XOXO export
7340 @cindex XOXO export
7342 Org mode contains an exporter that produces XOXO-style output.
7343 Currently, this exporter only handles the general outline structure and
7344 does not interpret any additional Org mode features.
7346 @table @kbd
7347 @kindex C-c C-e x
7348 @item C-c C-e x
7349 Export as XOXO file @file{myfile.html}.
7350 @kindex C-c C-e v
7351 @item C-c C-e v x
7352 Export only the visible part of the document.
7353 @end table
7355 @node iCalendar export,  , XOXO export, Exporting
7356 @section iCalendar export
7357 @cindex iCalendar export
7359 Some people like to use Org mode for keeping track of projects, but
7360 still prefer a standard calendar application for anniversaries and
7361 appointments.  In this case it can be useful to have deadlines and
7362 other time-stamped items in Org files show up in the calendar
7363 application.  Org mode can export calendar information in the standard
7364 iCalendar format.  If you also want to have TODO entries included in the
7365 export, configure the variable @code{org-icalendar-include-todo}.
7367 @table @kbd
7368 @kindex C-c C-e i
7369 @item C-c C-e i
7370 Create iCalendar entries for the current file and store them in the same
7371 directory, using a file extension @file{.ics}.
7372 @kindex C-c C-e I
7373 @item C-c C-e I
7374 Like @kbd{C-c C-e i}, but do this for all files in
7375 @code{org-agenda-files}.  For each of these files, a separate iCalendar
7376 file will be written.
7377 @kindex C-c C-e c
7378 @item C-c C-e c
7379 Create a single large iCalendar file from all files in
7380 @code{org-agenda-files} and write it to the file given by
7381 @code{org-combined-agenda-icalendar-file}.
7382 @end table
7384 The export will honor SUMMARY, DESCRIPTION and LOCATION properties if
7385 the selected entries have them.  If not, the summary will be derived
7386 from the headline, and the description from the body (limited to
7387 @code{org-icalendar-include-body} characters).
7389 How this calendar is best read and updated, depends on the application
7390 you are using.  The FAQ covers this issue.
7392 @node Publishing, Miscellaneous, Exporting, Top
7393 @chapter Publishing
7394 @cindex publishing
7396 Org includes@footnote{@file{org-publish.el} is not distributed with
7397 Emacs 21, if you are still using Emacs 21, you need you need to download
7398 this file separately.} a publishing management system that allows you to
7399 configure automatic HTML conversion of @emph{projects} composed of
7400 interlinked org files.  This system is called @emph{org-publish}.  You can
7401 also configure org-publish to automatically upload your exported HTML
7402 pages and related attachments, such as images and source code files, to
7403 a web server. Org-publish turns Org into a web-site authoring tool.
7405 You can also use Org-publish to convert files into La@TeX{}, or even
7406 combine HTML and La@TeX{} conversion so that files are available in both
7407 formats on the server@footnote{Since La@TeX{} files on a server are not
7408 that helpful, you surely want to perform further conversion on them --
7409 e.g. convert them to @code{PDF} format.}.
7411 Org-publish has been contributed to Org by David O'Toole.
7413 @menu
7414 * Configuration::               Defining projects
7415 * Sample configuration::        Example projects
7416 * Triggering publication::      Publication commands
7417 @end menu
7419 @node Configuration, Sample configuration, Publishing, Publishing
7420 @section Configuration
7422 Publishing needs significant configuration to specify files, destination
7423 and many other properties of a project.
7425 @menu
7426 * Project alist::               The central configuration variable
7427 * Sources and destinations::    From here to there
7428 * Selecting files::             What files are part of the project?
7429 * Publishing action::           Setting the function doing the publishing
7430 * Publishing options::          Tweaking HTML export
7431 * Publishing links::            Which links keep working after publishing?
7432 * Project page index::          Publishing a list of project files
7433 @end menu
7435 @node Project alist, Sources and destinations, Configuration, Configuration
7436 @subsection The variable @code{org-publish-project-alist}
7437 @cindex org-publish-project-alist
7438 @cindex projects, for publishing
7440 Org-publish is configured almost entirely through setting the value of
7441 one variable, called @code{org-publish-project-alist}.
7442 Each element of the list configures one project, and may be in one of
7443 the two following forms:
7445 @lisp
7446 ("project-name" :property value :property value ...)
7448 @r{or}
7450 ("project-name" :components ("project-name" "project-name" ...))
7452 @end lisp
7454 In both cases, projects are configured by specifying property values.
7455 A project defines the set of files that will be published, as well as
7456 the publishing configuration to use when publishing those files.  When
7457 a project takes the second form listed above, the individual members
7458 of the ``components'' property are taken to be components of the
7459 project, which group together files requiring different publishing
7460 options. When you publish such a ``meta-project'' all the components
7461 will also publish.
7463 @node Sources and destinations, Selecting files, Project alist, Configuration
7464 @subsection Sources and destinations for files
7465 @cindex directories, for publishing
7467 Most properties are optional, but some should always be set. In
7468 particular, org-publish needs to know where to look for source files,
7469 and where to put published files.
7471 @multitable @columnfractions 0.3 0.7
7472 @item @code{:base-directory}
7473 @tab Directory containing publishing source files
7474 @item @code{:publishing-directory}
7475 @tab Directory (possibly remote) where output files will be published.
7476 @item @code{:preparation-function}
7477 @tab Function called before starting publishing process, for example to
7478 run @code{make} for updating files to be published.
7479 @end multitable
7480 @noindent
7482 @node Selecting files, Publishing action, Sources and destinations, Configuration
7483 @subsection Selecting files
7484 @cindex files, selecting for publishing
7486 By default, all files with extension @file{.org} in the base directory
7487 are considered part of the project.  This can be modified by setting the
7488 properties
7489 @multitable @columnfractions 0.25 0.75
7490 @item @code{:base-extension}
7491 @tab Extension (without the dot!) of source files.  This actually is a
7492 regular expression.
7494 @item @code{:exclude}
7495 @tab Regular expression to match file names that should not be
7496 published, even though they have been selected on the basis of their
7497 extension.
7499 @item @code{:include}
7500 @tab List of files to be included regardless of @code{:base-extension}
7501 and @code{:exclude}.
7502 @end multitable
7504 @node Publishing action, Publishing options, Selecting files, Configuration
7505 @subsection Publishing action
7506 @cindex action, for publishing
7508 Publishing means that a file is copied to the destination directory and
7509 possibly transformed in the process.  The default transformation is to
7510 export Org files as HTML files, and this is done by the function
7511 @code{org-publish-org-to-html} which calls the HTML exporter
7512 (@pxref{HTML export}). But you also can publish your files in La@TeX{} by
7513 using the function @code{org-publish-org-to-latex} instead. Other files
7514 like images only need to be copied to the publishing destination. For
7515 non-Org files, you need to specify the publishing function.
7518 @multitable @columnfractions 0.3 0.7
7519 @item @code{:publishing-function}
7520 @tab Function executing the publication of a file.  This may also be a
7521 list of functions, which will all be called in turn.
7522 @end multitable
7524 The function must accept two arguments: a property list containing at
7525 least a @code{:publishing-directory} property, and the name of the file
7526 to be published.  It should take the specified file, make the necessary
7527 transformation (if any) and place the result into the destination folder.
7528 You can write your own publishing function, but @code{org-publish}
7529 provides one for attachments (files that only need to be copied):
7530 @code{org-publish-attachment}.
7532 @node Publishing options, Publishing links, Publishing action, Configuration
7533 @subsection Options for the HTML/LaTeX exporters
7534 @cindex options, for publishing
7536 The property list can be used to set many export options for the HTML
7537 and La@TeX{} exporters.  In most cases, these properties correspond to user
7538 variables in Org.  The table below lists these properties along
7539 with the variable they belong to.  See the documentation string for the
7540 respective variable for details.
7542 @multitable @columnfractions 0.3 0.7
7543 @item @code{:language}              @tab @code{org-export-default-language}
7544 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
7545 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
7546 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
7547 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
7548 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
7549 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
7550 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
7551 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
7552 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
7553 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
7554 @item @code{:timestamps}           .@tab @code{org-export-with-timestamps}
7555 @item @code{:tags}                 .@tab @code{org-export-with-tags}
7556 @item @code{:tables}                @tab @code{org-export-with-tables}
7557 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
7558 @item @code{:style}                 @tab @code{org-export-html-style}
7559 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
7560 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
7561 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
7562 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
7563 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
7564 @item @code{:preamble}              @tab @code{org-export-html-preamble}
7565 @item @code{:postamble}             @tab @code{org-export-html-postamble}
7566 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
7567 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
7568 @item @code{:author}                @tab @code{user-full-name}
7569 @item @code{:email}                 @tab @code{user-mail-address}
7570 @end multitable
7572 If you use several email addresses, separate them by a semi-column.
7574 Most of the @code{org-export-with-*} variables have the same effect in
7575 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
7576 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
7577 La@TeX{} export.
7579 When a property is given a value in @code{org-publish-project-alist},
7580 its setting overrides the value of the corresponding user variable (if
7581 any) during publishing.  Options set within a file (@pxref{Export
7582 options}), however, override everything.
7584 @node Publishing links, Project page index, Publishing options, Configuration
7585 @subsection Links between published files
7586 @cindex links, publishing
7588 To create a link from one Org file to another, you would use
7589 something like @samp{[[file:foo.org][The foo]]} or simply
7590 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
7591 becomes a link to @file{foo.html}.  In this way, you can interlink the
7592 pages of your "org web" project and the links will work as expected when
7593 you publish them to HTML.
7595 You may also link to related files, such as images. Provided you are
7596 careful with relative pathnames, and provided you have also configured
7597 @code{org-publish} to upload the related files, these links will work
7598 too. @ref{Complex example} for an example of this usage.
7600 Sometime an Org file to be published may contain links that are
7601 only valid in your production environment, but not in the publishing
7602 location.  In this case, use the property
7604 @multitable @columnfractions 0.4 0.6
7605 @item @code{:link-validation-function}
7606 @tab Function to validate links
7607 @end multitable
7609 @noindent
7610 to define a function for checking link validity.  This function must
7611 accept two arguments, the file name and a directory relative to which
7612 the file name is interpreted in the production environment.  If this
7613 function returns @code{nil}, then the HTML generator will only insert a
7614 description into the HTML file, but no link.  One option for this
7615 function is @code{org-publish-validate-link} which checks if the given
7616 file is part of any project in @code{org-publish-project-alist}.
7618 @node Project page index,  , Publishing links, Configuration
7619 @subsection Project page index
7620 @cindex index, of published pages
7622 The following properties may be used to control publishing of an
7623 index of files or summary page for a given project.
7625 @multitable @columnfractions 0.25 0.75
7626 @item @code{:auto-index}
7627 @tab When non-nil, publish an index during org-publish-current-project or
7628 org-publish-all.
7630 @item @code{:index-filename}
7631 @tab Filename for output of index. Defaults to @file{index.org} (which
7632 becomes @file{index.html}).
7634 @item @code{:index-title}
7635 @tab Title of index page. Defaults to name of file.
7637 @item @code{:index-function}
7638 @tab Plug-in function to use for generation of index.
7639 Defaults to @code{org-publish-org-index}, which generates a plain list
7640 of links to all files in the project.
7641 @end multitable
7643 @node Sample configuration, Triggering publication, Configuration, Publishing
7644 @section Sample configuration
7646 Below we provide two example configurations.  The first one is a simple
7647 project publishing only a set of Org files.  The second example is
7648 more complex, with a multi-component project.
7650 @menu
7651 * Simple example::              One-component publishing
7652 * Complex example::             A multi-component publishing example
7653 @end menu
7655 @node Simple example, Complex example, Sample configuration, Sample configuration
7656 @subsection Example: simple publishing configuration
7658 This example publishes a set of Org files to the @file{public_html}
7659 directory on the local machine.
7661 @lisp
7662 (setq org-publish-project-alist
7663       '(("org"
7664          :base-directory "~/org/"
7665          :publishing-directory "~/public_html"
7666          :section-numbers nil
7667          :table-of-contents nil
7668          :style "<link rel=stylesheet
7669                 href=\"../other/mystyle.css\"
7670                 type=\"text/css\">")))
7671 @end lisp
7673 @node Complex example,  , Simple example, Sample configuration
7674 @subsection Example: complex publishing configuration
7676 This more complicated example publishes an entire website, including
7677 org files converted to HTML, image files, emacs lisp source code, and
7678 style sheets. The publishing-directory is remote and private files are
7679 excluded.
7681 To ensure that links are preserved, care should be taken to replicate
7682 your directory structure on the web server, and to use relative file
7683 paths. For example, if your org files are kept in @file{~/org} and your
7684 publishable images in @file{~/images}, you'd link to an image with
7686 @example
7687 file:../images/myimage.png
7688 @end example
7690 On the web server, the relative path to the image should be the
7691 same. You can accomplish this by setting up an "images" folder in the
7692 right place on the web server, and publishing images to it.
7694 @lisp
7695 (setq org-publish-project-alist
7696       '(("orgfiles"
7697           :base-directory "~/org/"
7698           :base-extension "org"
7699           :publishing-directory "/ssh:user@@host:~/html/notebook/"
7700           :publishing-function org-publish-org-to-html
7701           :exclude "PrivatePage.org"   ;; regexp
7702           :headline-levels 3
7703           :section-numbers nil
7704           :table-of-contents nil
7705           :style "<link rel=stylesheet
7706                   href=\"../other/mystyle.css\" type=\"text/css\">"
7707           :auto-preamble t
7708           :auto-postamble nil)
7710          ("images"
7711           :base-directory "~/images/"
7712           :base-extension "jpg\\|gif\\|png"
7713           :publishing-directory "/ssh:user@@host:~/html/images/"
7714           :publishing-function org-publish-attachment)
7716          ("other"
7717           :base-directory "~/other/"
7718           :base-extension "css\\|el"
7719           :publishing-directory "/ssh:user@@host:~/html/other/"
7720           :publishing-function org-publish-attachment)
7721          ("website" :components ("orgfiles" "images" "other"))))
7722 @end lisp
7724 @node Triggering publication,  , Sample configuration, Publishing
7725 @section Triggering publication
7727 Once org-publish is properly configured, you can publish with the
7728 following functions:
7730 @table @kbd
7731 @item C-c C-e C
7732 Prompt for a specific project and publish all files that belong to it.
7733 @item C-c C-e P
7734 Publish the project containing the current file.
7735 @item C-c C-e F
7736 Publish only the current file.
7737 @item C-c C-e A
7738 Publish all projects.
7739 @end table
7741 Org uses timestamps to track when a file has changed. The above
7742 functions normally only publish changed files. You can override this and
7743 force publishing of all files by giving a prefix argument.
7745 @node Miscellaneous, Extensions and Hacking, Publishing, Top
7746 @chapter Miscellaneous
7748 @menu
7749 * Completion::                  M-TAB knows what you need
7750 * Customization::               Adapting Org to your taste
7751 * In-buffer settings::          Overview of the #+KEYWORDS
7752 * The very busy C-c C-c key::   When in doubt, press C-c C-c
7753 * Clean view::                  Getting rid of leading stars in the outline
7754 * TTY keys::                    Using Org on a tty
7755 * Interaction::                 Other Emacs packages
7756 * Bugs::                        Things which do not work perfectly
7757 @end menu
7759 @node Completion, Customization, Miscellaneous, Miscellaneous
7760 @section Completion
7761 @cindex completion, of @TeX{} symbols
7762 @cindex completion, of TODO keywords
7763 @cindex completion, of dictionary words
7764 @cindex completion, of option keywords
7765 @cindex completion, of tags
7766 @cindex completion, of property keys
7767 @cindex completion, of link abbreviations
7768 @cindex @TeX{} symbol completion
7769 @cindex TODO keywords completion
7770 @cindex dictionary word completion
7771 @cindex option keyword completion
7772 @cindex tag completion
7773 @cindex link abbreviations, completion of
7775 Org supports in-buffer completion.  This type of completion does
7776 not make use of the minibuffer.  You simply type a few letters into
7777 the buffer and use the key to complete text right there.
7779 @table @kbd
7780 @kindex M-@key{TAB}
7781 @item M-@key{TAB}
7782 Complete word at point
7783 @itemize @bullet
7784 @item
7785 At the beginning of a headline, complete TODO keywords.
7786 @item
7787 After @samp{\}, complete @TeX{} symbols supported by the exporter.
7788 @item
7789 After @samp{*}, complete headlines in the current buffer so that they
7790 can be used in search links like @samp{[[*find this headline]]}.
7791 @item
7792 After @samp{:} in a headline, complete tags.  The list of tags is taken
7793 from the variable @code{org-tag-alist} (possibly set through the
7794 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
7795 dynamically from all tags used in the current buffer.
7796 @item
7797 After @samp{:} and not in a headline, complete property keys.  The list
7798 of keys is constructed dynamically from all keys used in the current
7799 buffer.
7800 @item
7801 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
7802 @item
7803 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
7804 @samp{OPTIONS} which set file-specific options for Org mode.  When the
7805 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
7806 will insert example settings for this keyword.
7807 @item
7808 In the line after @samp{#+STARTUP: }, complete startup keywords,
7809 i.e. valid keys for this line.
7810 @item
7811 Elsewhere, complete dictionary words using Ispell.
7812 @end itemize
7813 @end table
7815 @node Customization, In-buffer settings, Completion, Miscellaneous
7816 @section Customization
7817 @cindex customization
7818 @cindex options, for customization
7819 @cindex variables, for customization
7821 There are more than 180 variables that can be used to customize
7822 Org.  For the sake of compactness of the manual, I am not
7823 describing the variables here.  A structured overview of customization
7824 variables is available with @kbd{M-x org-customize}.  Or select
7825 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
7826 settings can also be activated on a per-file basis, by putting special
7827 lines into the buffer (@pxref{In-buffer settings}).
7829 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
7830 @section Summary of in-buffer settings
7831 @cindex in-buffer settings
7832 @cindex special keywords
7834 Org mode uses special lines in the buffer to define settings on a
7835 per-file basis.  These lines start with a @samp{#+} followed by a
7836 keyword, a colon, and then individual words defining a setting.  Several
7837 setting words can be in the same line, but you can also have multiple
7838 lines for the keyword.  While these settings are described throughout
7839 the manual, here is a summary.  After changing any of those lines in the
7840 buffer, press @kbd{C-c C-c} with the cursor still in the line to
7841 activate the changes immediately.  Otherwise they become effective only
7842 when the file is visited again in a new Emacs session.
7844 @table @kbd
7845 @item #+ARCHIVE: %s_done::
7846 This line sets the archive location for the agenda file.  It applies for
7847 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
7848 of the file.  The first such line also applies to any entries before it.
7849 The corresponding variable is @code{org-archive-location}.
7850 @item #+CATEGORY:
7851 This line sets the category for the agenda file.  The category applies
7852 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
7853 end of the file.  The first such line also applies to any entries before it.
7854 @item #+COLUMNS: %25ITEM .....
7855 Set the default format for columns view.  This format applies when
7856 columns view is invoked in location where no @code{COLUMNS} property
7857 applies.
7858 @item #+CONSTANTS: name1=value1 ...
7859 Set file-local values for constants to be used in table formulas.  This
7860 line set the local variable @code{org-table-formula-constants-local}.
7861 The global version of this variable is
7862 @code{org-table-formula-constants}.
7863 @item #+DRAWERS: NAME1 .....
7864 Set the file-local set of drawers.  The corresponding global variable is
7865 @code{org-drawers}.
7866 @item #+LINK:  linkword replace
7867 These lines (several are allowed) specify link abbreviations.
7868 @xref{Link abbreviations}.  The corresponding variable is
7869 @code{org-link-abbrev-alist}.
7870 @item #+PRIORITIES: highest lowest default
7871 This line sets the limits and the default for the priorities.  All three
7872 must be either letters A-Z or numbers 0-9.  The highest priority must
7873 have a lower ASCII number that the lowest priority.
7874 @item #+PROPERTY: Property_Name Value
7875 This line sets a default inheritance value for entries in the current
7876 buffer, most useful for specifying the allowed values of a property.
7877 @item #+STARTUP:
7878 This line sets options to be used at startup of Org mode, when an
7879 Org file is being visited.  The first set of options deals with the
7880 initial visibility of the outline tree.  The corresponding variable for
7881 global default settings is @code{org-startup-folded}, with a default
7882 value @code{t}, which means @code{overview}.
7883 @cindex @code{overview}, STARTUP keyword
7884 @cindex @code{content}, STARTUP keyword
7885 @cindex @code{showall}, STARTUP keyword
7886 @example
7887 overview   @r{top-level headlines only}
7888 content    @r{all headlines}
7889 showall    @r{no folding at all, show everything}
7890 @end example
7891 Then there are options for aligning tables upon visiting a file.  This
7892 is useful in files containing narrowed table columns.  The corresponding
7893 variable is @code{org-startup-align-all-tables}, with a default value
7894 @code{nil}.
7895 @cindex @code{align}, STARTUP keyword
7896 @cindex @code{noalign}, STARTUP keyword
7897 @example
7898 align      @r{align all tables}
7899 noalign    @r{don't align tables on startup}
7900 @end example
7901 Logging closing and reinstating TODO items, and clock intervals
7902 (variables @code{org-log-done}, @code{org-log-note-clock-out}, and
7903 @code{org-log-repeat}) can be configured using these options.
7904 @cindex @code{logdone}, STARTUP keyword
7905 @cindex @code{lognotedone}, STARTUP keyword
7906 @cindex @code{nologdone}, STARTUP keyword
7907 @cindex @code{lognoteclock-out}, STARTUP keyword
7908 @cindex @code{nolognoteclock-out}, STARTUP keyword
7909 @cindex @code{logrepeat}, STARTUP keyword
7910 @cindex @code{lognoterepeat}, STARTUP keyword
7911 @cindex @code{nologrepeat}, STARTUP keyword
7912 @example
7913 logdone            @r{record a timestamp when an item is marked DONE}
7914 lognotedone        @r{record timestamp and a note when DONE}
7915 nologdone          @r{don't record when items are marked DONE}
7916 logrepeat          @r{record a time when reinstating a repeating item}
7917 lognoterepeat      @r{record a note when reinstating a repeating item}
7918 nologrepeat        @r{do not record when reinstating repeating item}
7919 lognoteclock-out   @r{record a note when clocking out}
7920 nolognoteclock-out @r{don't record a note when clocking out}
7921 @end example
7922 Here are the options for hiding leading stars in outline headings.  The
7923 corresponding variables are @code{org-hide-leading-stars} and
7924 @code{org-odd-levels-only}, both with a default setting @code{nil}
7925 (meaning @code{showstars} and @code{oddeven}).
7926 @cindex @code{hidestars}, STARTUP keyword
7927 @cindex @code{showstars}, STARTUP keyword
7928 @cindex @code{odd}, STARTUP keyword
7929 @cindex @code{even}, STARTUP keyword
7930 @example
7931 hidestars  @r{make all but one of the stars starting a headline invisible.}
7932 showstars  @r{show all stars starting a headline}
7933 odd        @r{allow only odd outline levels (1,3,...)}
7934 oddeven    @r{allow all outline levels}
7935 @end example
7936 To turn on custom format overlays over time stamps (variables
7937 @code{org-put-time-stamp-overlays} and
7938 @code{org-time-stamp-overlay-formats}), use
7939 @cindex @code{customtime}, STARTUP keyword
7940 @example
7941 customtime @r{overlay custom time format}
7942 @end example
7943 The following options influence the table spreadsheet (variable
7944 @code{constants-unit-system}).
7945 @cindex @code{constcgs}, STARTUP keyword
7946 @cindex @code{constSI}, STARTUP keyword
7947 @example
7948 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
7949 constSI    @r{@file{constants.el} should use the SI unit system}
7950 @end example
7951 @item #+TAGS:  TAG1(c1) TAG2(c2)
7952 These lines (several such lines are allowed) specify the valid tags in
7953 this file, and (potentially) the corresponding @emph{fast tag selection}
7954 keys.  The corresponding variable is @code{org-tag-alist}.
7955 @item #+TBLFM:
7956 This line contains the formulas for the table directly above the line.
7957 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:
7958 These lines provide settings for exporting files.  For more details see
7959 @ref{Export options}.
7960 @item #+SEQ_TODO:   #+TYP_TODO:
7961 These lines set the TODO keywords and their interpretation in the
7962 current file.  The corresponding variables are @code{org-todo-keywords}
7963 and @code{org-todo-interpretation}.
7964 @end table
7966 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
7967 @section The very busy C-c C-c key
7968 @kindex C-c C-c
7969 @cindex C-c C-c, overview
7971 The key @kbd{C-c C-c} has many purposes in Org, which are all
7972 mentioned scattered throughout this manual.  One specific function of
7973 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
7974 other circumstances it means something like @emph{Hey Org, look
7975 here and update according to what you see here}.  Here is a summary of
7976 what this means in different contexts.
7978 @itemize @minus
7979 @item
7980 If there are highlights in the buffer from the creation of a sparse
7981 tree, or from clock display, remove these highlights.
7982 @item
7983 If the cursor is in one of the special @code{#+KEYWORD} lines, this
7984 triggers scanning the buffer for these lines and updating the
7985 information.
7986 @item
7987 If the cursor is inside a table, realign the table.  This command
7988 works even if the automatic table editor has been turned off.
7989 @item
7990 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
7991 the entire table.
7992 @item
7993 If the cursor is inside a table created by the @file{table.el} package,
7994 activate that table.
7995 @item
7996 If the current buffer is a remember buffer, close the note and file it.
7997 With a prefix argument, file it, without further interaction, to the
7998 default location.
7999 @item
8000 If the cursor is on a @code{<<<target>>>}, update radio targets and
8001 corresponding links in this buffer.
8002 @item
8003 If the cursor is in a property line or at the start or end of a property
8004 drawer, offer property commands.
8005 @item
8006 If the cursor is in a plain list item with a checkbox, toggle the status
8007 of the checkbox.
8008 @item
8009 If the cursor is on a numbered item in a plain list, renumber the
8010 ordered list.
8011 @item
8012 If the cursor is on the @code{#+BEGIN} line of a dynamical block, the
8013 block is updated.
8014 @end itemize
8016 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
8017 @section A cleaner outline view
8018 @cindex hiding leading stars
8019 @cindex clean outline view
8021 Some people find it noisy and distracting that the Org headlines
8022 are starting with a potentially large number of stars.  For example
8023 the tree from @ref{Headlines}:
8025 @example
8026 * Top level headline
8027 ** Second level
8028 *** 3rd level
8029     some text
8030 *** 3rd level
8031     more text
8032 * Another top level headline
8033 @end example
8035 @noindent
8036 Unfortunately this is deeply ingrained into the code of Org and
8037 cannot be easily changed.  You can, however, modify the display in such
8038 a way that all leading stars become invisible and the outline more easy
8039 to read.  To do this, customize the variable
8040 @code{org-hide-leading-stars} like this:
8042 @lisp
8043 (setq org-hide-leading-stars t)
8044 @end lisp
8046 @noindent
8047 or change this on a per-file basis with one of the lines (anywhere in
8048 the buffer)
8050 @example
8051 #+STARTUP: showstars
8052 #+STARTUP: hidestars
8053 @end example
8055 @noindent
8056 Press @kbd{C-c C-c} with the cursor in a @samp{STARTUP} line to activate
8057 the modifications.
8059 With stars hidden, the tree becomes:
8061 @example
8062 * Top level headline
8063  * Second level
8064   * 3rd level
8065     some text
8066   * 3rd level
8067     more text
8068 * Another top level headline
8069 @end example
8071 @noindent
8072 Note that the leading stars are not truly replaced by whitespace, they
8073 are only fontified with the face @code{org-hide} that uses the
8074 background color as font color.  If you are not using either white or
8075 black background, you may have to customize this face to get the wanted
8076 effect.  Another possibility is to set this font such that the extra
8077 stars are @i{almost} invisible, for example using the color
8078 @code{grey90} on a white background.
8080 Things become cleaner still if you skip all the even levels and use only
8081 odd levels 1, 3, 5..., effectively adding two stars to go from one
8082 outline level to the next:
8084 @example
8085 * Top level headline
8086   * Second level
8087     * 3rd level
8088       some text
8089     * 3rd level
8090       more text
8091 * Another top level headline
8092 @end example
8094 @noindent
8095 In order to make the structure editing and export commands handle this
8096 convention correctly, use
8098 @lisp
8099 (setq org-odd-levels-only t)
8100 @end lisp
8102 @noindent
8103 or set this on a per-file basis with one of the following lines (don't
8104 forget to press @kbd{C-c C-c} with the cursor in the startup line to
8105 activate changes immediately).
8107 @example
8108 #+STARTUP: odd
8109 #+STARTUP: oddeven
8110 @end example
8112 You can convert an Org file from single-star-per-level to the
8113 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
8114 RET} in that file.  The reverse operation is @kbd{M-x
8115 org-convert-to-oddeven-levels}.
8117 @node TTY keys, Interaction, Clean view, Miscellaneous
8118 @section Using Org on a tty
8119 @cindex tty key bindings
8121 Because Org contains a large number of commands, by default much of
8122 Org's core commands are bound to keys that are generally not
8123 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
8124 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
8125 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
8126 these commands on a tty when special keys are unavailable, the following
8127 alternative bindings can be used.  The tty bindings below will likely be
8128 more cumbersome; you may find for some of the bindings below that a
8129 customized work-around suits you better.  For example, changing a time
8130 stamp is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
8131 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
8133 @multitable @columnfractions 0.15 0.2 0.2
8134 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
8135 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
8136 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
8137 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
8138 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
8139 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
8140 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
8141 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
8142 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
8143 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
8144 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
8145 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
8146 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
8147 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
8148 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
8149 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
8150 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
8151 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
8152 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
8153 @end multitable
8155 @node Interaction, Bugs, TTY keys, Miscellaneous
8156 @section Interaction with other packages
8157 @cindex packages, interaction with other
8158 Org lives in the world of GNU Emacs and interacts in various ways
8159 with other code out there.
8161 @menu
8162 * Cooperation::                 Packages Org cooperates with
8163 * Conflicts::                   Packages that lead to conflicts
8164 @end menu
8166 @node Cooperation, Conflicts, Interaction, Interaction
8167 @subsection Packages that Org cooperates with
8169 @table @asis
8170 @cindex @file{calc.el}
8171 @item @file{calc.el} by Dave Gillespie
8172 Org uses the Calc package for implementing spreadsheet
8173 functionality in its tables (@pxref{The spreadsheet}).  Org
8174 checks for the availability of Calc by looking for the function
8175 @code{calc-eval} which should be autoloaded in your setup if Calc has
8176 been installed properly.  As of Emacs 22, Calc is part of the Emacs
8177 distribution.  Another possibility for interaction between the two
8178 packages is using Calc for embedded calculations. @xref{Embedded Mode,
8179 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
8180 @cindex @file{constants.el}
8181 @item @file{constants.el} by Carsten Dominik
8182 In a table formula (@pxref{The spreadsheet}), it is possible to use
8183 names for natural constants or units.  Instead of defining your own
8184 constants in the variable @code{org-table-formula-constants}, install
8185 the @file{constants} package which defines a large number of constants
8186 and units, and lets you use unit prefixes like @samp{M} for
8187 @samp{Mega} etc.  You will need version 2.0 of this package, available
8188 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
8189 the function @code{constants-get}, which has to be autoloaded in your
8190 setup.  See the installation instructions in the file
8191 @file{constants.el}.
8192 @item @file{cdlatex.el} by Carsten Dominik
8193 @cindex @file{cdlatex.el}
8194 Org mode can make use of the CDLaTeX package to efficiently enter
8195 La@TeX{} fragments into Org files. See @ref{CDLaTeX mode}.
8196 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
8197 @cindex @file{imenu.el}
8198 Imenu allows menu access to an index of items in a file.  Org mode
8199 supports Imenu - all you need to do to get the index is the following:
8200 @lisp
8201 (add-hook 'org-mode-hook
8202           (lambda () (imenu-add-to-menubar "Imenu")))
8203 @end lisp
8204 By default the index is two levels deep - you can modify the depth using
8205 the option @code{org-imenu-depth}.
8206 @item @file{remember.el} by John Wiegley
8207 @cindex @file{remember.el}
8208 Org cooperates with remember, see @ref{Remember}.
8209 @file{Remember.el} is not part of Emacs, find it on the web.
8210 @item @file{speedbar.el} by Eric M. Ludlam
8211 @cindex @file{speedbar.el}
8212 Speedbar is a package that creates a special frame displaying files and
8213 index items in files.  Org mode supports Speedbar and allows you to
8214 drill into Org files directly from the Speedbar.  It also allows to
8215 restrict the scope of agenda commands to a file or a subtree by using
8216 the command @kbd{<} in the Speedbar frame.
8217 @cindex @file{table.el}
8218 @item @file{table.el} by Takaaki Ota
8219 @kindex C-c C-c
8220 @cindex table editor, @file{table.el}
8221 @cindex @file{table.el}
8223 Complex ASCII tables with automatic line wrapping, column- and
8224 row-spanning, and alignment can be created using the Emacs table
8225 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
8226 and also part of Emacs 22).
8227 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
8228 will call @command{table-recognize-table} and move the cursor into the
8229 table.  Inside a table, the keymap of Org mode is inactive.  In order
8230 to execute Org mode-related commands, leave the table.
8232 @table @kbd
8233 @kindex C-c C-c
8234 @item C-c C-c
8235 Recognize @file{table.el} table.  Works when the cursor is in a
8236 table.el table.
8238 @kindex C-c ~
8239 @item C-c ~
8240 Insert a table.el table.  If there is already a table at point, this
8241 command converts it between the table.el format and the Org mode
8242 format.  See the documentation string of the command
8243 @code{org-convert-table} for the restrictions under which this is
8244 possible.
8245 @end table
8246 @file{table.el} is part of Emacs 22.
8247 @cindex @file{footnote.el}
8248 @item @file{footnote.el} by Steven L. Baur
8249 Org mode recognizes numerical footnotes as provided by this package
8250 (@pxref{Footnotes}).
8251 @end table
8253 @node Conflicts,  , Cooperation, Interaction
8254 @subsection Packages that lead to conflicts with Org mode
8256 @table @asis
8258 @cindex @file{allout.el}
8259 @item @file{allout.el} by Ken Manheimer
8260 Startup of Org may fail with the error message
8261 @code{(wrong-type-argument keymapp nil)} when there is an outdated
8262 version @file{allout.el} on the load path, for example the version
8263 distributed with Emacs 21.x.  Upgrade to Emacs 22 and this problem will
8264 disappear.  If for some reason you cannot do this, make sure that org.el
8265 is loaded @emph{before} @file{allout.el}, for example by putting
8266 @code{(require 'org)} early enough into your @file{.emacs} file.
8268 @cindex @file{CUA.el}
8269 @item @file{CUA.el} by Kim. F. Storm
8270 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by
8271 CUA mode (as well as pc-select-mode and s-region-mode) to select and
8272 extend the region.  If you want to use one of these packages along with
8273 Org, configure the variable @code{org-replace-disputed-keys}.  When
8274 set, Org will move the following key bindings in Org files, and
8275 in the agenda buffer (but not during date selection).
8277 @example
8278 S-UP    -> M-p             S-DOWN  -> M-n
8279 S-LEFT  -> M--             S-RIGHT -> M-+
8280 @end example
8282 Yes, these are unfortunately more difficult to remember.  If you want
8283 to have other replacement keys, look at the variable
8284 @code{org-disputed-keys}.
8285 @item @file{windmove.el} by Hovav Shacham
8286 @cindex @file{windmove.el}
8287 Also this package uses the @kbd{S-<cursor>} keys, so everything written
8288 in the paragraph above about CUA mode also applies here.
8290 @cindex @file{footnote.el}
8291 @item @file{footnote.el} by Steven L. Baur
8292 Org supports the syntax of the footnote package, but only the
8293 numerical footnote markers.  Also, the default key for footnote
8294 commands, @kbd{C-c !} is already used by Org.  You could use the
8295 variable @code{footnote-prefix} to switch footnotes commands to another
8296 key.  Or, you could use @code{org-replace-disputed-keys} and
8297 @code{org-disputed-keys} to change the settings in Org.
8299 @end table
8302 @node Bugs,  , Interaction, Miscellaneous
8303 @section Bugs
8304 @cindex bugs
8306 Here is a list of things that should work differently, but which I
8307 have found too hard to fix.
8309 @itemize @bullet
8310 @item
8311 If a table field starts with a link, and if the corresponding table
8312 column is narrowed (@pxref{Narrow columns}) to a width too small to
8313 display the link, the field would look entirely empty even though it is
8314 not.  To prevent this, Org throws an error.  The work-around is to
8315 make the column wide enough to fit the link, or to add some text (at
8316 least 2 characters) before the link in the same field.
8317 @item
8318 Narrowing table columns does not work on XEmacs, because the
8319 @code{format} function does not transport text properties.
8320 @item
8321 Text in an entry protected with the @samp{QUOTE} keyword should not
8322 autowrap.
8323 @item
8324 When the application called by @kbd{C-c C-o} to open a file link fails
8325 (for example because the application does not exist or refuses to open
8326 the file), it does so silently.  No error message is displayed.
8327 @item
8328 Recalculating a table line applies the formulas from left to right.
8329 If a formula uses @emph{calculated} fields further down the row,
8330 multiple recalculation may be needed to get all fields consistent.  You
8331 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
8332 recalculate until convergence.
8333 @item
8334 A single letter cannot be made bold, for example @samp{*a*}.
8335 @item
8336 The exporters work well, but could be made more efficient.
8337 @end itemize
8340 @node Extensions and Hacking, History and Acknowledgments, Miscellaneous, Top
8341 @appendix Extensions, Hooks and Hacking
8343 This appendix lists extensions for Org written by other authors.
8344 It also covers some aspects where users can extend the functionality of
8345 Org.
8347 @menu
8348 * Extensions::                  Existing 3rd-party extensions
8349 * Adding hyperlink types::      New custom link types
8350 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
8351 * Dynamic blocks::              Automatically filled blocks
8352 * Special agenda views::        Customized views
8353 * Using the property API::      Writing programs that use entry properties
8354 @end menu
8356 @node Extensions, Adding hyperlink types, Extensions and Hacking, Extensions and Hacking
8357 @section Third-party extensions for Org
8358 @cindex extension, third-party
8360 There are lots of extensions that have been written by other people.  Most of
8361 them have either been integrated into Org by now, or they can be found in the
8362 Org distribution, in the @file{contrib} directory.  The list has gotten too
8363 long to cover in any detail here, but there is a seaparate manual for these
8364 extensions.
8366 @node Adding hyperlink types, Tables in arbitrary syntax, Extensions, Extensions and Hacking
8367 @section Adding hyperlink types
8368 @cindex hyperlinks, adding new types
8370 Org has a large number of hyperlink types built-in
8371 (@pxref{Hyperlinks}).  If you would like to add new link types, it
8372 provides an interface for doing so.  Lets look at an example file
8373 @file{org-man.el} that will add support for creating links like
8374 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
8375 emacs:
8377 @lisp
8378 ;;; org-man.el - Support for links to manpages in Org
8380 (require 'org)
8382 (org-add-link-type "man" 'org-man-open)
8383 (add-hook 'org-store-link-functions 'org-man-store-link)
8385 (defcustom org-man-command 'man
8386   "The Emacs command to be used to display a man page."
8387   :group 'org-link
8388   :type '(choice (const man) (const woman)))
8390 (defun org-man-open (path)
8391   "Visit the manpage on PATH.
8392 PATH should be a topic that can be thrown at the man command."
8393   (funcall org-man-command path))
8395 (defun org-man-store-link ()
8396   "Store a link to a manpage."
8397   (when (memq major-mode '(Man-mode woman-mode))
8398     ;; This is a man page, we do make this link
8399     (let* ((page (org-man-get-page-name))
8400            (link (concat "man:" page))
8401            (description (format "Manpage for %s" page)))
8402       (org-store-link-props
8403        :type "man"
8404        :link link
8405        :description description))))
8407 (defun org-man-get-page-name ()
8408   "Extract the page name from the buffer name."
8409   ;; This works for both `Man-mode' and `woman-mode'.
8410   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
8411       (match-string 1 (buffer-name))
8412     (error "Cannot create link to this man page")))
8414 (provide 'org-man)
8416 ;;; org-man.el ends here
8417 @end lisp
8419 @noindent
8420 You would activate this new link type in @file{.emacs} with
8422 @lisp
8423 (require 'org-man)
8424 @end lisp
8426 @noindent
8427 Lets go through the file and see what it does.
8428 @enumerate
8429 @item
8430 It does @code{(require 'org)} to make sure that @file{org.el} has been
8431 loaded.
8432 @item
8433 The next line calls @code{org-add-link-type} to define a new link type
8434 with prefix @samp{man}.  The call also contains the name of a function
8435 that will be called to follow such a link.
8436 @item
8437 The next line adds a function to @code{org-store-link-functions}, in
8438 order to allow the command @kbd{C-c l} to record a useful link in a
8439 buffer displaying a man page.
8440 @end enumerate
8442 The rest of the file defines the necessary variables and functions.
8443 First there is a customization variable that determines which emacs
8444 command should be used to display man pages.  There are two options,
8445 @code{man} and @code{woman}.  Then the function to follow a link is
8446 defined.  It gets the link path as an argument - in this case the link
8447 path is just a topic for the manual command.  The function calls the
8448 value of @code{org-man-command} to display the man page.
8450 Finally the function @code{org-man-store-link} is defined.  When you try
8451 to store a link with @kbd{C-c l}, also this function will be called to
8452 try to make a link.  The function must first decide if it is supposed to
8453 create the link for this buffer type, we do this by checking the value
8454 of the variable @code{major-mode}.  If not, the function must exit and
8455 return the value @code{nil}.  If yes, the link is created by getting the
8456 manual topic from the buffer name and prefixing it with the string
8457 @samp{man:}.  Then it must call the command @code{org-store-link-props}
8458 and set the @code{:type} and @code{:link} properties.  Optionally you
8459 can also set the @code{:description} property to provide a default for
8460 the link description when the link is later inserted into an Org
8461 buffer with @kbd{C-c C-l}.
8463 @node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Extensions and Hacking
8464 @section Tables and lists in arbitrary syntax
8465 @cindex tables, in other modes
8466 @cindex lists, in other modes
8467 @cindex Orgtbl mode
8469 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
8470 frequent feature request has been to make it work with native tables in
8471 specific languages, for example La@TeX{}.  However, this is extremely
8472 hard to do in a general way, would lead to a customization nightmare,
8473 and would take away much of the simplicity of the Orgtbl mode table
8474 editor.
8477 This appendix describes a different approach.  We keep the Orgtbl mode
8478 table in its native format (the @i{source table}), and use a custom
8479 function to @i{translate} the table to the correct syntax, and to
8480 @i{install} it in the right location (the @i{target table}).  This puts
8481 the burden of writing conversion functions on the user, but it allows
8482 for a very flexible system.
8484 Bastien added the ability to do the same with lists.  You can use Org's
8485 facilities to edit and structure lists by turning @code{orgstruct-mode}
8486 on, then locally exporting such lists in another format (HTML, La@TeX{}
8487 or Texinfo.)
8490 @menu
8491 * Radio tables::                Sending and receiving
8492 * A LaTeX example::             Step by step, almost a tutorial
8493 * Translator functions::        Copy and modify
8494 * Radio lists::                 Doing the same for lists
8495 @end menu
8497 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
8498 @subsection Radio tables
8499 @cindex radio tables
8501 To define the location of the target table, you first need to create two
8502 lines that are comments in the current mode, but contain magic words for
8503 Orgtbl mode to find.  Orgtbl mode will insert the translated table
8504 between these lines, replacing whatever was there before.  For example:
8506 @example
8507 /* BEGIN RECEIVE ORGTBL table_name */
8508 /* END RECEIVE ORGTBL table_name */
8509 @end example
8511 @noindent
8512 Just above the source table, we put a special line that tells
8513 Orgtbl mode how to translate this table and where to install it.  For
8514 example:
8515 @example
8516 #+ORGTBL: SEND table_name translation_function arguments....
8517 @end example
8519 @noindent
8520 @code{table_name} is the reference name for the table that is also used
8521 in the receiver lines. @code{translation_function} is the Lisp function
8522 that does the translation.  Furthermore, the line can contain a list of
8523 arguments (alternating key and value) at the end.  The arguments will be
8524 passed as a property list to the translation function for
8525 interpretation.  A few standard parameters are already recognized and
8526 acted upon before the translation function is called:
8528 @table @code
8529 @item :skip N
8530 Skip the first N lines of the table. Hlines do count!
8531 @item :skipcols (n1 n2 ...)
8532 List of columns that should be skipped.  If the table has a column with
8533 calculation marks, that column is automatically discarded as well.
8534 Please note that the translator function sees the table @emph{after} the
8535 removal of these columns, the function never knows that there have been
8536 additional columns.
8537 @end table
8539 @noindent
8540 The one problem remaining is how to keep the source table in the buffer
8541 without disturbing the normal workings of the file, for example during
8542 compilation of a C file or processing of a La@TeX{} file.  There are a
8543 number of different solutions:
8545 @itemize @bullet
8546 @item
8547 The table could be placed in a block comment if that is supported by the
8548 language.  For example, in C mode you could wrap the table between
8549 @samp{/*} and @samp{*/} lines.
8550 @item
8551 Sometimes it is possible to put the table after some kind of @i{END}
8552 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
8553 in La@TeX{}.
8554 @item
8555 You can just comment the table line by line whenever you want to process
8556 the file, and uncomment it whenever you need to edit the table.  This
8557 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
8558 make this comment-toggling very easy, in particular if you bind it to a
8559 key.
8560 @end itemize
8562 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
8563 @subsection A LaTeX example of radio tables
8564 @cindex LaTeX, and Orgtbl mode
8566 The best way to wrap the source table in La@TeX{} is to use the
8567 @code{comment} environment provided by @file{comment.sty}.  It has to be
8568 activated by placing @code{\usepackage@{comment@}} into the document
8569 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
8570 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
8571 variable @code{orgtbl-radio-tables} to install templates for other
8572 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
8573 be prompted for a table name, lets say we use @samp{salesfigures}.  You
8574 will then get the following template:
8576 @example
8577 % BEGIN RECEIVE ORGTBL salesfigures
8578 % END RECEIVE ORGTBL salesfigures
8579 \begin@{comment@}
8580 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8581 | | |
8582 \end@{comment@}
8583 @end example
8585 @noindent
8586 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
8587 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
8588 into the receiver location with name @code{salesfigures}.  You may now
8589 fill in the table, feel free to use the spreadsheet features@footnote{If
8590 the @samp{#+TBLFM} line contains an odd number of dollar characters,
8591 this may cause problems with font-lock in LaTeX mode.  As shown in the
8592 example you can fix this by adding an extra line inside the
8593 @code{comment} environment that is used to balance the dollar
8594 expressions.  If you are using AUCTeX with the font-latex library, a
8595 much better solution is to add the @code{comment} environment to the
8596 variable @code{LaTeX-verbatim-environments}.}:
8598 @example
8599 % BEGIN RECEIVE ORGTBL salesfigures
8600 % END RECEIVE ORGTBL salesfigures
8601 \begin@{comment@}
8602 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8603 | Month | Days | Nr sold | per day |
8604 |-------+------+---------+---------|
8605 | Jan   |   23 |      55 |     2.4 |
8606 | Feb   |   21 |      16 |     0.8 |
8607 | March |   22 |     278 |    12.6 |
8608 #+TBLFM: $4=$3/$2;%.1f
8609 % $ (optional extra dollar to keep font-lock happy, see footnote)
8610 \end@{comment@}
8611 @end example
8613 @noindent
8614 When you are done, press @kbd{C-c C-c} in the table to get the converted
8615 table inserted between the two marker lines.
8617 Now lets assume you want to make the table header by hand, because you
8618 want to control how columns are aligned etc.  In this case we make sure
8619 that the table translator does skip the first 2 lines of the source
8620 table, and tell the command to work as a @i{splice}, i.e. to not produce
8621 header and footer commands of the target table:
8623 @example
8624 \begin@{tabular@}@{lrrr@}
8625 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
8626 % BEGIN RECEIVE ORGTBL salesfigures
8627 % END RECEIVE ORGTBL salesfigures
8628 \end@{tabular@}
8630 \begin@{comment@}
8631 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
8632 | Month | Days | Nr sold | per day |
8633 |-------+------+---------+---------|
8634 | Jan   |   23 |      55 |     2.4 |
8635 | Feb   |   21 |      16 |     0.8 |
8636 | March |   22 |     278 |    12.6 |
8637 #+TBLFM: $4=$3/$2;%.1f
8638 \end@{comment@}
8639 @end example
8641 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
8642 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
8643 and marks horizontal lines with @code{\hline}.  Furthermore, it
8644 interprets the following parameters:
8646 @table @code
8647 @item :splice nil/t
8648 When set to t, return only table body lines, don't wrap them into a
8649 tabular environment.  Default is nil.
8651 @item :fmt fmt
8652 A format to be used to wrap each field, should contain @code{%s} for the
8653 original field value.  For example, to wrap each field value in dollars,
8654 you could use @code{:fmt "$%s$"}.  This may also be a property list with
8655 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
8656 A function of one argument can be used in place of the strings; the
8657 function must return a formatted string.
8659 @item :efmt efmt
8660 Use this format to print numbers with exponentials.  The format should
8661 have @code{%s} twice for inserting mantissa and exponent, for example
8662 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
8663 may also be a property list with column numbers and formats, for example
8664 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
8665 @code{efmt} has been applied to a value, @code{fmt} will also be
8666 applied.  Similar to @code{fmt}, functions of two arguments can be
8667 supplied instead of strings.
8668 @end table
8670 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
8671 @subsection Translator functions
8672 @cindex HTML, and Orgtbl mode
8673 @cindex translator function
8675 Orgtbl mode has several translator functions built-in:
8676 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and
8677 @code{orgtbl-to-texinfo}.  Except for @code{orgtbl-to-html}@footnote{The
8678 HTML translator uses the same code that produces tables during HTML
8679 export.}, these all use a generic translator, @code{orgtbl-to-generic}.
8680 For example, @code{orgtbl-to-latex} itself is a very short function that
8681 computes the column definitions for the @code{tabular} environment,
8682 defines a few field and line separators and then hands over to the
8683 generic translator.  Here is the entire code:
8685 @lisp
8686 @group
8687 (defun orgtbl-to-latex (table params)
8688   "Convert the Orgtbl mode TABLE to LaTeX."
8689   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
8690                                org-table-last-alignment ""))
8691          (params2
8692           (list
8693            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
8694            :tend "\\end@{tabular@}"
8695            :lstart "" :lend " \\\\" :sep " & "
8696            :efmt "%s\\,(%s)" :hline "\\hline")))
8697     (orgtbl-to-generic table (org-combine-plists params2 params))))
8698 @end group
8699 @end lisp
8701 As you can see, the properties passed into the function (variable
8702 @var{PARAMS}) are combined with the ones newly defined in the function
8703 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
8704 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
8705 would like to use the La@TeX{} translator, but wanted the line endings to
8706 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
8707 overrule the default with
8709 @example
8710 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
8711 @end example
8713 For a new language, you can either write your own converter function in
8714 analogy with the La@TeX{} translator, or you can use the generic function
8715 directly.  For example, if you have a language where a table is started
8716 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
8717 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
8718 separator is a TAB, you could call the generic translator like this (on
8719 a single line!):
8721 @example
8722 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
8723                               :lstart "!BL! " :lend " !EL!" :sep "\t"
8724 @end example
8726 @noindent
8727 Please check the documentation string of the function
8728 @code{orgtbl-to-generic} for a full list of parameters understood by
8729 that function and remember that you can pass each of them into
8730 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
8731 using the generic function.
8733 Of course you can also write a completely new function doing complicated
8734 things the generic translator cannot do.  A translator function takes
8735 two arguments.  The first argument is the table, a list of lines, each
8736 line either the symbol @code{hline} or a list of fields.  The second
8737 argument is the property list containing all parameters specified in the
8738 @samp{#+ORGTBL: SEND} line.  The function must return a single string
8739 containing the formatted table.  If you write a generally useful
8740 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
8741 others can benefit from your work.
8743 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
8744 @subsection Radio lists
8745 @cindex radio lists
8746 @cindex org-list-insert-radio-list
8748 Sending and receiving radio lists works exactly the same way than
8749 sending and receiving radio tables (@pxref{Radio tables}) @footnote{You
8750 need to load the @code{org-export-latex.el} package to use radio lists
8751 since the relevant code is there for now.}.  As for radio tables, you
8752 can insert radio lists templates in HTML, La@TeX{} and Texinfo modes by
8753 calling @code{org-list-insert-radio-list}.
8755 Here are the differences with radio tables:
8757 @itemize @minus
8758 @item
8759 Use @code{ORGLST} instead of @code{ORGTBL}.
8760 @item
8761 The available translation functions for radio lists don't take
8762 parameters.
8763 @item
8764 `C-c C-c' will work when pressed on the first item of the list.
8765 @end itemize
8767 Here is a La@TeX{} example.  Let's say that you have this in your
8768 La@TeX{} file:
8770 @example
8771 % BEGIN RECEIVE ORGLST to-buy
8772 % END RECEIVE ORGLST to-buy
8773 \begin@{comment@}
8774 #+ORGLIST: SEND to-buy orgtbl-to-latex
8775 - a new house
8776 - a new computer
8777   + a new keyboard
8778   + a new mouse
8779 - a new life
8780 \end@{comment@}
8781 @end example
8783 Pressing `C-c C-c' on @code{a new house} and will insert the converted
8784 La@TeX{} list between the two marker lines.
8786 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Extensions and Hacking
8787 @section Dynamic blocks
8788 @cindex dynamic blocks
8790 Org documents can contain @emph{dynamic blocks}.  These are
8791 specially marked regions that are updated by some user-written function.
8792 A good example for such a block is the clock table inserted by the
8793 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
8795 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
8796 to the block and can also specify parameters for the function producing
8797 the content of the block.
8799 @example
8800 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
8802 #+END:
8803 @end example
8805 Dynamic blocks are updated with the following commands
8807 @table @kbd
8808 @kindex C-c C-x C-u
8809 @item C-c C-x C-u
8810 Update dynamic block at point.
8811 @kindex C-u C-c C-x C-u
8812 @item C-u C-c C-x C-u
8813 Update all dynamic blocks in the current file.
8814 @end table
8816 Updating a dynamic block means to remove all the text between BEGIN and
8817 END, parse the BEGIN line for parameters and then call the specific
8818 writer function for this block to insert the new content.  If you want
8819 to use the original content in the writer function, you can use the
8820 extra parameter @code{:content}.
8822 For a block with name @code{myblock}, the writer function is
8823 @code{org-dblock-write:myblock} with as only parameter a property list
8824 with the parameters given in the begin line.  Here is a trivial example
8825 of a block that keeps track of when the block update function was last
8826 run:
8828 @example
8829 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
8831 #+END:
8832 @end example
8834 @noindent
8835 The corresponding block writer function could look like this:
8837 @lisp
8838 (defun org-dblock-write:block-update-time (params)
8839    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
8840      (insert "Last block update at: "
8841              (format-time-string fmt (current-time)))))
8842 @end lisp
8844 If you want to make sure that all dynamic blocks are always up-to-date,
8845 you could add the function @code{org-update-all-dblocks} to a hook, for
8846 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
8847 written in a way that is does nothing in buffers that are not in
8848 @code{org-mode}.
8850 @node Special agenda views, Using the property API, Dynamic blocks, Extensions and Hacking
8851 @section Special agenda views
8852 @cindex agenda views, user-defined
8854 Org provides a special hook that can be used to narrow down the
8855 selection made by any of the agenda views.  You may specify a function
8856 that is used at each match to verify if the match should indeed be part
8857 of the agenda view, and if not, how much should be skipped.
8859 Let's say you want to produce a list of projects that contain a WAITING
8860 tag anywhere in the project tree.  Let's further assume that you have
8861 marked all tree headings that define a project with the TODO keyword
8862 PROJECT.  In this case you would run a TODO search for the keyword
8863 PROJECT, but skip the match unless there is a WAITING tag anywhere in
8864 the subtree belonging to the project line.
8866 To achieve this, you must write a function that searches the subtree for
8867 the tag.  If the tag is found, the function must return @code{nil} to
8868 indicate that this match should not be skipped.  If there is no such
8869 tag, return the location of the end of the subtree, to indicate that
8870 search should continue from there.
8872 @lisp
8873 (defun my-skip-unless-waiting ()
8874   "Skip trees that are not waiting"
8875   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
8876     (if (re-search-forward ":waiting:" subtree-end t)
8877         nil          ; tag found, do not skip
8878       subtree-end))) ; tag not found, continue after end of subtree
8879 @end lisp
8881 Now you may use this function in an agenda custom command, for example
8882 like this:
8884 @lisp
8885 (org-add-agenda-custom-command
8886  '("b" todo "PROJECT"
8887    ((org-agenda-skip-function 'my-org-waiting-projects)
8888     (org-agenda-overriding-header "Projects waiting for something: "))))
8889 @end lisp
8891 Note that this also binds @code{org-agenda-overriding-header} to get a
8892 meaningful header in the agenda view.
8894 A general way to create custom searches is to base them on a search for
8895 entries with a certain level limit.  If you want to study all entries with
8896 your custom search function, simply do a search for @samp{LEVEL>0}, and then
8897 use @code{org-agenda-skip-function} to select the entries you really want to
8898 have.
8900 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
8901 particular, you may use the functions @code{org-agenda-skip-entry-if}
8902 and @code{org-agenda-skip-subtree-if} in this form, for example:
8904 @table @code
8905 @item '(org-agenda-skip-entry-if 'scheduled)
8906 Skip current entry if it has been scheduled.
8907 @item '(org-agenda-skip-entry-if 'notscheduled)
8908 Skip current entry if it has not been scheduled.
8909 @item '(org-agenda-skip-entry-if 'deadline)
8910 Skip current entry if it has a deadline.
8911 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
8912 Skip current entry if it has a deadline, or if it is scheduled.
8913 @item '(org-agenda-skip-entry 'regexp "regular expression")
8914 Skip current entry if the regular expression matches in the entry.
8915 @item '(org-agenda-skip-entry 'notregexp "regular expression")
8916 Skip current entry unless the regular expression matches.
8917 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
8918 Same as above, but check and skip the entire subtree.
8919 @end table
8921 Therefore we could also have written the search for WAITING projects
8922 like this, even without defining a special function:
8924 @lisp
8925 (org-add-agenda-custom-command
8926  '("b" todo "PROJECT"
8927    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
8928                                 'regexp ":waiting:"))
8929     (org-agenda-overriding-header "Projects waiting for something: "))))
8930 @end lisp
8932 @node Using the property API,  , Special agenda views, Extensions and Hacking
8933 @section Using the property API
8934 @cindex API, for properties
8935 @cindex properties, API
8937 Here is a description of the functions that can be used to work with
8938 properties.
8940 @defun org-entry-properties &optional pom which
8941 Get all properties of the entry at point-or-marker POM.
8942 This includes the TODO keyword, the tags, time strings for deadline,
8943 scheduled, and clocking, and any additional properties defined in the
8944 entry.  The return value is an alist, keys may occur multiple times
8945 if the property key was used several times.
8946 POM may also be nil, in which case the current entry is used.
8947 If WHICH is nil or `all', get all properties.  If WHICH is
8948 `special' or `standard', only get that subclass.
8949 @end defun
8950 @defun org-entry-get pom property &optional inherit
8951 Get value of PROPERTY for entry at point-or-marker POM.  By default,
8952 this only looks at properties defined locally in the entry.  If INHERIT
8953 is non-nil and the entry does not have the property, then also check
8954 higher levels of the hierarchy.  If INHERIT is the symbol
8955 @code{selective}, use inheritance if and only if the setting of
8956 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
8957 @end defun
8959 @defun org-entry-delete pom property
8960 Delete the property PROPERTY from entry at point-or-marker POM.
8961 @end defun
8963 @defun org-entry-put pom property value
8964 Set PROPERTY to VALUE for entry at point-or-marker POM.
8965 @end defun
8967 @defun org-buffer-property-keys &optional include-specials
8968 Get all property keys in the current buffer.
8969 @end defun
8971 @defun org-insert-property-drawer
8972 Insert a property drawer at point.
8973 @end defun
8975 @defun org-entry-add-to-multivalued-property pom property value
8976 Treat the value of the property PROPERTY as a whitespace-separated list of
8977 values and make sure that VALUE is in this list.
8978 @end defun
8980 @defun org-entry-remove-from-multivalued-property pom property value
8981 Treat the value of the property PROPERTY as a whitespace-separated list of
8982 values and make sure that VALUE is @emph{not} in this list.
8983 @end defun
8985 @defun org-entry-member-in-multivalued-property pom property value
8986 Treat the value of the property PROPERTY as a whitespace-separated list of
8987 values and check if VALUE is in this list.
8988 @end defun
8990 @node History and Acknowledgments, Main Index, Extensions and Hacking, Top
8991 @appendix History and Acknowledgments
8992 @cindex acknowledgments
8993 @cindex history
8994 @cindex thanks
8996 Org was borne in 2003, out of frustration over the user interface
8997 of the Emacs Outline mode.  I was trying to organize my notes and
8998 projects, and using Emacs seemed to be the natural way to go.  However,
8999 having to remember eleven different commands with two or three keys per
9000 command, only to hide and show parts of the outline tree, that seemed
9001 entirely unacceptable to me.  Also, when using outlines to take notes, I
9002 constantly want to restructure the tree, organizing it parallel to my
9003 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
9004 editing} were originally implemented in the package
9005 @file{outline-magic.el}, but quickly moved to the more general
9006 @file{org.el}.  As this environment became comfortable for project
9007 planning, the next step was adding @emph{TODO entries}, basic @emph{time
9008 stamps}, and @emph{table support}.  These areas highlight the two main
9009 goals that Org still has today: To create a new, outline-based,
9010 plain text mode with innovative and intuitive editing features, and to
9011 incorporate project planning functionality directly into a notes file.
9013 A special thanks goes to @i{Bastien Guerry} who has not only writen a large
9014 number of extensions to Org (most of them integrated into the core by now),
9015 but has also helped the development and maintenance of Org so much that he
9016 should be considered co-author of this package.
9018 Since the first release, literally thousands of emails to me or on
9019 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
9020 reports, feedback, new ideas, and sometimes patches and add-on code.
9021 Many thanks to everyone who has helped to improve this package.  I am
9022 trying to keep here a list of the people who had significant influence
9023 in shaping one or more aspects of Org.  The list may not be
9024 complete, if I have forgotten someone, please accept my apologies and
9025 let me know.
9027 @itemize @bullet
9029 @item
9030 @i{Russel Adams} came up with the idea for drawers.
9031 @item
9032 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
9033 @item
9034 @i{Alex Bochannek} provided a patch for rounding time stamps.
9035 @item
9036 @i{Charles Cave}'s suggestion sparked the implementation of templates
9037 for Remember.
9038 @item
9039 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
9040 specified time.
9041 @item
9042 @i{Gregory Chernov} patched support for lisp forms into table
9043 calculations and improved XEmacs compatibility, in particular by porting
9044 @file{nouline.el} to XEmacs.
9045 @item
9046 @i{Sacha Chua} suggested to copy some linking code from Planner.
9047 @item
9048 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
9049 came up with the idea of properties, and that there should be an API for
9050 them.
9051 @item
9052 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
9053 inspired some of the early development, including HTML export.  He also
9054 asked for a way to narrow wide table columns.
9055 @item
9056 @i{Christian Egli} converted the documentation into Texinfo format,
9057 patched CSS formatting into the HTML exporter, and inspired the agenda.
9058 @item
9059 @i{David Emery} provided a patch for custom CSS support in exported
9060 HTML agendas.
9061 @item
9062 @i{Nic Ferrier} contributed mailcap and XOXO support.
9063 @item
9064 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
9065 @item
9066 @i{John Foerch} figured out how to make incremental search show context
9067 around a match in a hidden outline tree.
9068 @item
9069 @i{Niels Giesen} had the idea to automatically archive DONE trees.
9070 @item
9071 @i{Bastien Guerry} wrote the La@TeX{} exporter and @file{org-bibtex.el}, and
9072 has been prolific with patches, ideas, and bug reports.
9073 @item
9074 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
9075 @item
9076 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
9077 task state change logging, and the clocktable.  His clear explanations have
9078 been critical when we started to adopt the GIT version control system.
9079 @item
9080 @i{Phil Jackson} wrote @file{org-irc.el}.
9081 @item
9082 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
9083 folded entries, and column view for properties.
9084 @item
9085 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
9086 @item
9087 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
9088 provided frequent feedback and some patches.
9089 @item
9090 @i{Jason F. McBrayer} suggested agenda export to CSV format.
9091 @item
9092 @i{Max Mikhanosha} came up with the idea of refiling.
9093 @item
9094 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
9095 basis.
9096 @item
9097 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
9098 happy.
9099 @item
9100 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file
9101 and to be able to quickly restrict the agenda to a subtree.
9102 @item
9103 @i{Todd Neal} provided patches for links to Info files and elisp forms.
9104 @item
9105 @i{Tim O'Callaghan} suggested in-file links, search options for general
9106 file links, and TAGS.
9107 @item
9108 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
9109 into Japanese.
9110 @item
9111 @i{Oliver Oppitz} suggested multi-state TODO items.
9112 @item
9113 @i{Scott Otterson} sparked the introduction of descriptive text for
9114 links, among other things.
9115 @item
9116 @i{Pete Phillips} helped during the development of the TAGS feature, and
9117 provided frequent feedback.
9118 @item
9119 @i{T.V. Raman} reported bugs and suggested improvements.
9120 @item
9121 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
9122 control.
9123 @item
9124 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
9125 @item
9126 @i{Sebastian Rose} wrote @file{org-info.js}, a Java script for displaying
9127 webpages derived from Org using an Info-like, or a folding interface with
9128 single key navigation.
9129 @item
9130 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
9131 conflict with @file{allout.el}.
9132 @item
9133 @i{Jason Riedy} generalized the send-receive mechanism for orgtbl tables with
9134 extensive patches.
9135 @item
9136 @i{Philip Rooke} created the Org reference card, provided lots
9137 of feedback, developed and applied standards to the Org documentation and
9138 wrote the manual for the contributed packages.
9139 @item
9140 @i{Christian Schlauer} proposed angular brackets around links, among
9141 other things.
9142 @item
9143 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
9144 @file{organizer-mode.el}.
9145 @item
9146 @i{Ilya Shlyakhter} proposed the Archive Sibling.
9147 @item
9148 @i{Daniel Sinder} came up with the idea of internal archiving by locking
9149 subtrees.
9150 @item
9151 @i{Dale Smith} proposed link abbreviations.
9152 @item
9153 @i{Adam Spiers} asked for global linking commands and inspired the link
9154 extension system.  support mairix.
9155 @item
9156 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
9157 chapter about publishing.
9158 @item
9159 @i{J@"urgen Vollmer} contributed code generating the table of contents
9160 in HTML output.
9161 @item
9162 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
9163 keyword.
9164 @item
9165 @i{David Wainberg} suggested archiving, and improvements to the linking
9166 system.
9167 @item
9168 @i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
9169 @file{muse.el}, which have similar goals as Org.  Initially the development
9170 of Org was fully independent because I was not aware of the existence of
9171 these packages.  But with time I have accasionally looked at John's code and
9172 learned a lot from it.  John has also contributed a number of great ideas and
9173 patches directly to Org, including the file @code{org-mac-message.el}'
9174 @item
9175 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
9176 linking to Gnus.
9177 @item
9178 @i{Roland Winkler} requested additional key bindings to make Org
9179 work on a tty.
9180 @item
9181 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
9182 and contributed various ideas and code snippets.
9183 @end itemize
9186 @node Main Index, Key Index, History and Acknowledgments, Top
9187 @unnumbered The Main Index
9189 @printindex cp
9191 @node Key Index,  , Main Index, Top
9192 @unnumbered Key Index
9194 @printindex ky
9196 @bye
9198 @ignore
9199         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
9200 @end ignore
9202 @c Local variables:
9203 @c ispell-local-dictionary: "en_US-w_accents"
9204 @c ispell-local-pdict: "./.aspell.org.pws"
9205 @c fill-column: 77
9206 @c End: