org-babel now explicitly requires org-table
[org-mode.git] / doc / org.texi
blobb042ed948b6f5ae07cde6fb6cf657ef5f70e790e
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @set VERSION 6.30trans
7 @set DATE September 2009
9 @c Version and Contact Info
10 @set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
11 @set AUTHOR Carsten Dominik
12 @set MAINTAINER Carsten Dominik
13 @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
14 @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
15 @c %**end of header
16 @finalout
18 @c Macro definitions
19 @iftex
20 @c @hyphenation{time-stamp time-stamps time-stamp-ing time-stamp-ed}
21 @end iftex
22 @macro Ie {}
23 I.e.,
24 @end macro
25 @macro ie {}
26 i.e.,
27 @end macro
28 @macro Eg {}
29 E.g.,
30 @end macro
31 @macro eg {}
32 e.g.,
33 @end macro
35 @c Subheadings inside a table.
36 @macro tsubheading{text}
37 @ifinfo
38 @subsubheading \text\
39 @end ifinfo
40 @ifnotinfo
41 @item @b{\text\}
42 @end ifnotinfo
43 @end macro
45 @copying
46 This manual is for Org version @value{VERSION}.
48 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation
50 @quotation
51 Permission is granted to copy, distribute and/or modify this document
52 under the terms of the GNU Free Documentation License, Version 1.3 or
53 any later version published by the Free Software Foundation; with no
54 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
55 and with the Back-Cover Texts as in (a) below.  A copy of the license
56 is included in the section entitled ``GNU Free Documentation License.''
58 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
59 modify this GNU manual.  Buying copies from the FSF supports it in
60 developing GNU and promoting software freedom.''
62 This document is part of a collection distributed under the GNU Free
63 Documentation License.  If you want to distribute this document
64 separately from the collection, you can do so by adding a copy of the
65 license to the document, as described in section 6 of the license.
66 @end quotation
67 @end copying
69 @dircategory Emacs
70 @direntry
71 * Org Mode: (org).      Outline-based notes management and organizer
72 @end direntry
74 @titlepage
75 @title The Org Manual
77 @subtitle Release @value{VERSION}
78 @author by Carsten Dominik
80 @c The following two commands start the copyright page.
81 @page
82 @vskip 0pt plus 1filll
83 @insertcopying
84 @end titlepage
86 @c Output the table of contents at the beginning.
87 @contents
89 @ifnottex
90 @node Top, Introduction, (dir), (dir)
91 @top Org Mode Manual
93 @insertcopying
94 @end ifnottex
96 @menu
97 * Introduction::                Getting started
98 * Document Structure::          A tree works like your brain
99 * Tables::                      Pure magic for quick formatting
100 * Hyperlinks::                  Notes in context
101 * TODO Items::                  Every tree branch can be a TODO item
102 * Tags::                        Tagging headlines and matching sets of tags
103 * Properties and Columns::      Storing information about an entry
104 * Dates and Times::             Making items useful for planning
105 * Capture::                     Creating tasks and attaching files
106 * Agenda Views::                Collecting information into views
107 * Embedded LaTeX::              LaTeX fragments and formulas
108 * Exporting::                   Sharing and publishing of notes
109 * Publishing::                  Create a web site of linked Org files
110 * Miscellaneous::               All the rest which did not fit elsewhere
111 * Hacking::                     How to hack your way around
112 * History and Acknowledgments::  How Org came into being
113 * Main Index::                  An index of Org's concepts and features
114 * Key Index::                   Key bindings and where they are described
115 * Variable Index::              Variables mentioned in the manual
117 @detailmenu
118  --- The Detailed Node Listing ---
120 Introduction
122 * Summary::                     Brief summary of what Org does
123 * Installation::                How to install a downloaded version of Org
124 * Activation::                  How to activate Org for certain buffers
125 * Feedback::                    Bug reports, ideas, patches etc.
126 * Conventions::                 Type-setting conventions in the manual
128 Document Structure
130 * Outlines::                    Org is based on Outline mode
131 * Headlines::                   How to typeset Org tree headlines
132 * Visibility cycling::          Show and hide, much simplified
133 * Motion::                      Jumping to other headlines
134 * Structure editing::           Changing sequence and level of headlines
135 * Archiving::                   Move done task trees to a different place
136 * Sparse trees::                Matches embedded in context
137 * Plain lists::                 Additional structure within an entry
138 * Drawers::                     Tucking stuff away
139 * Blocks::                      Folding blocks
140 * Footnotes::                   How footnotes are defined in Org's syntax
141 * Orgstruct mode::              Structure editing outside Org
143 Archiving
145 * ARCHIVE tag::                 Marking a tree as inactive
146 * Moving subtrees::             Moving a tree to an archive file
148 Tables
150 * Built-in table editor::       Simple tables
151 * Column width and alignment::  Overrule the automatic settings
152 * Column groups::               Grouping to trigger vertical lines
153 * Orgtbl mode::                 The table editor as minor mode
154 * The spreadsheet::             The table editor has spreadsheet capabilities
155 * Org-Plot::                    Plotting from org tables
157 The spreadsheet
159 * References::                  How to refer to another field or range
160 * Formula syntax for Calc::     Using Calc to compute stuff
161 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
162 * Field formulas::              Formulas valid for a single field
163 * Column formulas::             Formulas valid for an entire column
164 * Editing and debugging formulas::  Fixing formulas
165 * Updating the table::          Recomputing all dependent fields
166 * Advanced features::           Field names, parameters and automatic recalc
168 Hyperlinks
170 * Link format::                 How links in Org are formatted
171 * Internal links::              Links to other places in the current file
172 * External links::              URL-like links to the world
173 * Handling links::              Creating, inserting and following
174 * Using links outside Org::     Linking from my C source code?
175 * Link abbreviations::          Shortcuts for writing complex links
176 * Search options::              Linking to a specific location
177 * Custom searches::             When the default search is not enough
179 Internal links
181 * Radio targets::               Make targets trigger links in plain text
183 TODO Items
185 * TODO basics::                 Marking and displaying TODO entries
186 * TODO extensions::             Workflow and assignments
187 * Progress logging::            Dates and notes for progress
188 * Priorities::                  Some things are more important than others
189 * Breaking down tasks::         Splitting a task into manageable pieces
190 * Checkboxes::                  Tick-off lists
192 Extended use of TODO keywords
194 * Workflow states::             From TODO to DONE in steps
195 * TODO types::                  I do this, Fred does the rest
196 * Multiple sets in one file::   Mixing it all, and still finding your way
197 * Fast access to TODO states::  Single letter selection of a state
198 * Per-file keywords::           Different files, different requirements
199 * Faces for TODO keywords::     Highlighting states
200 * TODO dependencies::           When one task needs to wait for others
202 Progress logging
204 * Closing items::               When was this entry marked DONE?
205 * Tracking TODO state changes::  When did the status change?
207 Tags
209 * Tag inheritance::             Tags use the tree structure of the outline
210 * Setting tags::                How to assign tags to a headline
211 * Tag searches::                Searching for combinations of tags
213 Properties and Columns
215 * Property syntax::             How properties are spelled out
216 * Special properties::          Access to other Org mode features
217 * Property searches::           Matching property values
218 * Property inheritance::        Passing values down the tree
219 * Column view::                 Tabular viewing and editing
220 * Property API::                Properties for Lisp programmers
222 Column view
224 * Defining columns::            The COLUMNS format property
225 * Using column view::           How to create and use column view
226 * Capturing column view::       A dynamic block for column view
228 Defining columns
230 * Scope of column definitions::  Where defined, where valid?
231 * Column attributes::           Appearance and content of a column
233 Dates and Times
235 * Timestamps::                  Assigning a time to a tree entry
236 * Creating timestamps::         Commands which insert timestamps
237 * Deadlines and scheduling::    Planning your work
238 * Clocking work time::          Tracking how long you spend on a task
239 * Effort estimates::            Planning work effort in advance
240 * Relative timer::              Notes with a running timer
242 Creating timestamps
244 * The date/time prompt::        How Org mode helps you entering date and time
245 * Custom time format::          Making dates look different
247 Deadlines and scheduling
249 * Inserting deadline/schedule::  Planning items
250 * Repeated tasks::              Items that show up again and again
252 Capture
254 * Remember::                    Capture new tasks/ideas with little interruption
255 * Attachments::                 Add files to tasks.
256 * RSS Feeds::                   Getting input from RSS feeds
257 * Protocols::                   External (@eg Browser) access to Emacs and Org
259 Remember
261 * Setting up Remember for Org:: Some code for .emacs to get things going
262 * Remember templates::          Define the outline of different note types
263 * Storing notes::               Directly get the note to where it belongs
264 * Refiling notes::              Moving a note or task to a project
266 Agenda Views
268 * Agenda files::                Files being searched for agenda information
269 * Agenda dispatcher::           Keyboard access to agenda views
270 * Built-in agenda views::       What is available out of the box?
271 * Presentation and sorting::    How agenda items are prepared for display
272 * Agenda commands::             Remote editing of Org trees
273 * Custom agenda views::         Defining special searches and views
274 * Exporting Agenda Views::
275 * Agenda column view::          Using column view for collected entries
277 The built-in agenda views
279 * Weekly/daily agenda::         The calendar page with current tasks
280 * Global TODO list::            All unfinished action items
281 * Matching tags and properties::  Structured information with fine-tuned search
282 * Timeline::                    Time-sorted view for single file
283 * Keyword search::              Finding entries by keyword
284 * Stuck projects::              Find projects you need to review
286 Presentation and sorting
288 * Categories::                  Not all tasks are equal
289 * Time-of-day specifications::  How the agenda knows the time
290 * Sorting of agenda items::     The order of things
292 Custom agenda views
294 * Storing searches::            Type once, use often
295 * Block agenda::                All the stuff you need in a single buffer
296 * Setting Options::             Changing the rules
298 Embedded La@TeX{}
300 * Math symbols::                @TeX{} macros for symbols and Greek letters
301 * Subscripts and superscripts::  Simple syntax for raising/lowering text
302 * LaTeX fragments::             Complex formulas made easy
303 * Processing LaTeX fragments::  Previewing La@TeX{} processing
304 * CDLaTeX mode::                Speed up entering of formulas
306 Exporting
308 * Markup rules::                Which structures are recognized?
309 * Selective export::            Using tags to select and exclude trees
310 * Export options::              Per-file export settings
311 * The export dispatcher::       How to access exporter commands
312 * ASCII export::                Exporting to plain ASCII
313 * HTML export::                 Exporting to HTML
314 * LaTeX and PDF export::        Exporting to La@TeX{}, and processing to PDF
315 * DocBook export::              Exporting to DocBook
316 * XOXO export::                 Exporting to XOXO
317 * iCalendar export::            Exporting in iCalendar format
319 Markup rules
321 * Document title::              How the document title is determined
322 * Headings and sections::       The main structure of the exported document
323 * Table of contents::           If, where, how to create a table of contents
324 * Initial text::                Text before the first headline
325 * Lists::                       Plain lists are exported
326 * Paragraphs::                  What determines beginning and ending
327 * Literal examples::            Source code and other examples
328 * Include files::               Include the contents of a file during export
329 * Tables exported::             Tables are exported richly
330 * Inlined images::              How to inline images during export
331 * Footnote markup::             ASCII representation of footnotes
332 * Emphasis and monospace::      To bold or not to bold
333 * TeX macros and LaTeX fragments::  Create special, rich export.
334 * Horizontal rules::            A line across the page
335 * Comment lines::               Some lines will not be exported
336 * Macro replacement::           Global replacement of place holders
338 HTML export
340 * HTML Export commands::        How to invoke HTML export
341 * Quoting HTML tags::           Using direct HTML in Org mode
342 * Links::                       Transformation of links for HTML
343 * Tables in HTML export::       How to modify the formatting of tables
344 * Images in HTML export::       How to insert figures into HTML output
345 * Text areas in HTML export::   An alternative way to show an example
346 * CSS support::                 Changing the appearance of the output
347 * Javascript support::          Info and Folding in a web browser
349 La@TeX{} and PDF export
351 * LaTeX/PDF export commands::   Which key invokes which commands
352 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
353 * Sectioning structure::        Changing sectioning in La@TeX{} output
354 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
355 * Images in LaTeX export::      How to insert figures into La@TeX{} output
357 DocBook export
359 * DocBook export commands::     How to invoke DocBook export
360 * Quoting DocBook code::        Incorporating DocBook code in Org files
361 * Recursive sections::          Recursive sections in DocBook
362 * Tables in DocBook export::    Tables are exported as HTML tables
363 * Images in DocBook export::    How to insert figures into DocBook output
364 * Special characters::          How to handle special characters
366 Publishing
368 * Configuration::               Defining projects
369 * Uploading files::             How to get files up on the server
370 * Sample configuration::        Example projects
371 * Triggering publication::      Publication commands
373 Configuration
375 * Project alist::               The central configuration variable
376 * Sources and destinations::    From here to there
377 * Selecting files::             What files are part of the project?
378 * Publishing action::           Setting the function doing the publishing
379 * Publishing options::          Tweaking HTML export
380 * Publishing links::            Which links keep working after publishing?
381 * Project page index::          Publishing a list of project files
383 Sample configuration
385 * Simple example::              One-component publishing
386 * Complex example::             A multi-component publishing example
388 Miscellaneous
390 * Completion::                  M-TAB knows what you need
391 * Customization::               Adapting Org to your taste
392 * In-buffer settings::          Overview of the #+KEYWORDS
393 * The very busy C-c C-c key::   When in doubt, press C-c C-c
394 * Clean view::                  Getting rid of leading stars in the outline
395 * TTY keys::                    Using Org on a tty
396 * Interaction::                 Other Emacs packages
398 Interaction with other packages
400 * Cooperation::                 Packages Org cooperates with
401 * Conflicts::                   Packages that lead to conflicts
403 Hacking
405 * Hooks::                       Who to reach into Org's internals
406 * Add-on packages::             Available extensions
407 * Adding hyperlink types::      New custom link types
408 * Context-sensitive commands::  How to add functionality to such commands
409 * Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
410 * Dynamic blocks::              Automatically filled blocks
411 * Special agenda views::        Customized views
412 * Extracting agenda information::  Postprocessing of agenda information
413 * Using the property API::      Writing programs that use entry properties
414 * Using the mapping API::       Mapping over all or selected entries
416 Tables and lists in arbitrary syntax
418 * Radio tables::                Sending and receiving radio tables
419 * A LaTeX example::             Step by step, almost a tutorial
420 * Translator functions::        Copy and modify
421 * Radio lists::                 Doing the same for lists
423 @end detailmenu
424 @end menu
426 @node Introduction, Document Structure, Top, Top
427 @chapter Introduction
428 @cindex introduction
430 @menu
431 * Summary::                     Brief summary of what Org does
432 * Installation::                How to install a downloaded version of Org
433 * Activation::                  How to activate Org for certain buffers
434 * Feedback::                    Bug reports, ideas, patches etc.
435 * Conventions::                 Type-setting conventions in the manual
436 @end menu
438 @node Summary, Installation, Introduction, Introduction
439 @section Summary
440 @cindex summary
442 Org is a mode for keeping notes, maintaining TODO lists, and doing
443 project planning with a fast and effective plain-text system.
445 Org develops organizational tasks around NOTES files that contain
446 lists or information about projects as plain text.  Org is
447 implemented on top of Outline mode, which makes it possible to keep the
448 content of large files well structured.  Visibility cycling and
449 structure editing help to work with the tree.  Tables are easily created
450 with a built-in table editor.  Org supports TODO items, deadlines,
451 timestamps, and scheduling.  It dynamically compiles entries into an
452 agenda that utilizes and smoothly integrates much of the Emacs calendar
453 and diary.  Plain text URL-like links connect to websites, emails,
454 Usenet messages, BBDB entries, and any files related to the projects.
455 For printing and sharing of notes, an Org file can be exported as a
456 structured ASCII file, as HTML, or (TODO and agenda items only) as an
457 iCalendar file.  It can also serve as a publishing tool for a set of
458 linked web pages.
460 An important design aspect that distinguishes Org from, for example,
461 Planner/Muse is that it encourages you to store every piece of information
462 only once.  In Planner, you have project pages, day pages and possibly
463 other files, duplicating some information such as tasks.  In Org,
464 you only have notes files.  In your notes you mark entries as tasks, and
465 label them with tags and timestamps.  All necessary lists, like a
466 schedule for the day, the agenda for a meeting, tasks lists selected by
467 tags, etc., are created dynamically when you need them.
469 Org keeps simple things simple.  When first fired up, it should
470 feel like a straightforward, easy to use outliner.  Complexity is not
471 imposed, but a large amount of functionality is available when you need
472 it.  Org is a toolbox and can be used in different ways, for
473 example as:
475 @example
476 @r{@bullet{} an outline extension with visibility cycling and structure editing}
477 @r{@bullet{} an ASCII system and table editor for taking structured notes}
478 @r{@bullet{} an ASCII table editor with spreadsheet-like capabilities}
479 @r{@bullet{} a TODO list editor}
480 @r{@bullet{} a full agenda and planner with deadlines and work scheduling}
481 @pindex GTD, Getting Things Done
482 @r{@bullet{} an environment to implement David Allen's GTD system}
483 @r{@bullet{} a basic database application}
484 @r{@bullet{} a simple hypertext system, with HTML and La@TeX{} export}
485 @r{@bullet{} a publishing tool to create a set of interlinked webpages}
486 @end example
488 Org's automatic, context-sensitive table editor with spreadsheet
489 capabilities can be integrated into any major mode by activating the
490 minor Orgtbl mode.  Using a translation step, it can be used to maintain
491 tables in arbitrary file types, for example in La@TeX{}.  The structure
492 editing and list creation capabilities can be used outside Org with
493 the minor Orgstruct mode.
495 @cindex FAQ
496 There is a website for Org which provides links to the newest
497 version of Org, as well as additional information, frequently asked
498 questions (FAQ), links to tutorials, etc@.  This page is located at
499 @uref{http://orgmode.org}.
501 @page
504 @node Installation, Activation, Summary, Introduction
505 @section Installation
506 @cindex installation
507 @cindex XEmacs
509 @b{Important:} @i{If you are using a version of Org that is part of the Emacs
510 distribution or an XEmacs package, please skip this section and go directly
511 to @ref{Activation}.}
513 If you have downloaded Org from the Web, either as a distribution @file{.zip}
514 or @file{.tar} file, or as a Git archive, you must take the following steps
515 to install it: go into the unpacked Org distribution directory and edit the
516 top section of the file @file{Makefile}.  You must set the name of the Emacs
517 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
518 directories where local Lisp and Info files are kept.  If you don't have
519 access to the system-wide directories, you can simply run Org directly from
520 the distribution directory by adding the @file{lisp} subdirectory to the
521 Emacs load path.  To do this, add the following line to @file{.emacs}:
523 @example
524 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
525 @end example
527 @noindent
528 If you plan to use code from the @file{contrib} subdirectory, do a similar
529 step for this directory:
531 @example
532 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
533 @end example
535 @sp 2
536 @cartouche
537 XEmacs users now need to install the file @file{noutline.el} from
538 the @file{xemacs} sub-directory of the Org distribution.  Use the
539 command:
541 @example
542      make install-noutline
543 @end example
544 @end cartouche
545 @sp 2
547 @noindent Now byte-compile the Lisp files with the shell command:
549 @example
550 make
551 @end example
553 @noindent If you are running Org from the distribution directory, this is
554 all.  If you want to install Org into the system directories, use (as
555 administrator)
557 @example
558 make install
559 @end example
561 Installing Info files is system dependent, because of differences in the
562 @file{install-info} program.  In Debian it copies the info files into the
563 correct directory and modifies the info directory file.  In many other
564 systems, the files need to be copied to the correct directory separately, and
565 @file{install-info} then only modifies the directory file.  Check your system
566 documentation to find out which of the following commands you need:
568 @example
569 make install-info
570 make install-info-debian
571 @end example
573 Then add the following line to @file{.emacs}.  It is needed so that
574 Emacs can autoload functions that are located in files not immediately loaded
575 when Org-mode starts.
576 @lisp
577 (require 'org-install)
578 @end lisp
580 Do not forget to activate Org as described in the following section.
581 @page
583 @node Activation, Feedback, Installation, Introduction
584 @section Activation
585 @cindex activation
586 @cindex autoload
587 @cindex global key bindings
588 @cindex key bindings, global
590 @iftex
591 @b{Important:} @i{If you use copy-and-paste to copy Lisp code from the
592 PDF documentation as viewed by some PDF viewers to your @file{.emacs} file, the
593 single-quote character comes out incorrectly and the code will not work.
594 You need to fix the single-quotes by hand, or copy from Info
595 documentation.}
596 @end iftex
598 Add the following lines to your @file{.emacs} file.  The last three lines
599 define @emph{global} keys for the commands @command{org-store-link},
600 @command{org-agenda}, and @command{org-iswitchb}---please choose suitable
601 keys yourself.
603 @lisp
604 ;; The following lines are always needed.  Choose your own keys.
605 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
606 (global-set-key "\C-cl" 'org-store-link)
607 (global-set-key "\C-ca" 'org-agenda)
608 (global-set-key "\C-cb" 'org-iswitchb)
609 @end lisp
611 Furthermore, you must activate @code{font-lock-mode} in Org
612 buffers, because significant functionality depends on font-locking being
613 active.  You can do this with either one of the following two lines
614 (XEmacs users must use the second option):
615 @lisp
616 (global-font-lock-mode 1)                     ; for all buffers
617 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
618 @end lisp
620 @cindex Org mode, turning on
621 With this setup, all files with extension @samp{.org} will be put
622 into Org mode.  As an alternative, make the first line of a file look
623 like this:
625 @example
626 MY PROJECTS    -*- mode: org; -*-
627 @end example
629 @vindex org-insert-mode-line-in-empty-file
630 @noindent which will select Org mode for this buffer no matter what
631 the file's name is.  See also the variable
632 @code{org-insert-mode-line-in-empty-file}.
634 Many commands in Org work on the region if the region is @i{active}.  To make
635 use of this, you need to have @code{transient-mark-mode}
636 (@code{zmacs-regions} in XEmacs) turned on.  In Emacs 23 this is the default,
637 in Emacs 22 you need to do this yourself with
638 @lisp
639 (transient-mark-mode 1)
640 @end lisp
641 @noindent If you do not like @code{transient-mark-mode}, you can create an
642 active region by using the mouse to select a region, or pressing
643 @kbd{C-@key{SPC}} twice before moving the cursor.
645 @node Feedback, Conventions, Activation, Introduction
646 @section Feedback
647 @cindex feedback
648 @cindex bug reports
649 @cindex maintainer
650 @cindex author
652 If you find problems with Org, or if you have questions, remarks, or ideas
653 about it, please mail to the Org mailing list @email{emacs-orgmode@@gnu.org}.
654 If you are not a member of the mailing list, your mail will be passed to the
655 list after a moderator has approved it.
657 For bug reports, please provide as much information as possible, including
658 the version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
659 (@kbd{M-x org-version @key{RET}}), as well as the Org related setup in
660 @file{.emacs}.  The easiest way to do this is to use the command
661 @example
662 @kbd{M-x org-submit-bug-report}
663 @end example
664 @noindent which will put all this information into an Emacs mail buffer so
665 that you only need to add your description.  If you re not sending the Email
666 from within Emacs, please copy and paste the content into your Email program.
668 If an error occurs, a backtrace can be very useful (see below on how to
669 create one).  Often a small example file helps, along with clear information
670 about:
672 @enumerate
673 @item What exactly did you do?
674 @item What did you expect to happen?
675 @item What happened instead?
676 @end enumerate
677 @noindent Thank you for helping to improve this mode.
679 @subsubheading How to create a useful backtrace
681 @cindex backtrace of an error
682 If working with Org produces an error with a message you don't
683 understand, you may have hit a bug.  The best way to report this is by
684 providing, in addition to what was mentioned above, a @emph{backtrace}.
685 This is information from the built-in debugger about where and how the
686 error occurred.  Here is how to produce a useful backtrace:
688 @enumerate
689 @item
690 Reload uncompiled versions of all Org-mode Lisp files.  The backtrace
691 contains much more information if it is produced with uncompiled code.
692 To do this, use
693 @example
694 C-u M-x org-reload RET
695 @end example
696 @noindent
697 or select @code{Org -> Refresh/Reload -> Reload Org uncompiled} from the
698 menu.
699 @item
700 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
701 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
702 @item
703 Do whatever you have to do to hit the error.  Don't forget to
704 document the steps you take.
705 @item
706 When you hit the error, a @file{*Backtrace*} buffer will appear on the
707 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
708 attach it to your bug report.
709 @end enumerate
711 @node Conventions,  , Feedback, Introduction
712 @section Typesetting conventions used in this manual
714 Org uses three types of keywords: TODO keywords, tags, and property
715 names.  In this manual we use the following conventions:
717 @table @code
718 @item TODO
719 @itemx WAITING
720 TODO keywords are written with all capitals, even if they are
721 user-defined.
722 @item boss
723 @itemx ARCHIVE
724 User-defined tags are written in lowercase; built-in tags with special
725 meaning are written with all capitals.
726 @item Release
727 @itemx PRIORITY
728 User-defined properties are capitalized; built-in properties with
729 special meaning are written with all capitals.
730 @end table
732 @node Document Structure, Tables, Introduction, Top
733 @chapter Document Structure
734 @cindex document structure
735 @cindex structure of document
737 Org is based on Outline mode and provides flexible commands to
738 edit the structure of the document.
740 @menu
741 * Outlines::                    Org is based on Outline mode
742 * Headlines::                   How to typeset Org tree headlines
743 * Visibility cycling::          Show and hide, much simplified
744 * Motion::                      Jumping to other headlines
745 * Structure editing::           Changing sequence and level of headlines
746 * Archiving::                   Move done task trees to a different place
747 * Sparse trees::                Matches embedded in context
748 * Plain lists::                 Additional structure within an entry
749 * Drawers::                     Tucking stuff away
750 * Blocks::                      Folding blocks
751 * Footnotes::                   How footnotes are defined in Org's syntax
752 * Orgstruct mode::              Structure editing outside Org
753 @end menu
755 @node Outlines, Headlines, Document Structure, Document Structure
756 @section Outlines
757 @cindex outlines
758 @cindex Outline mode
760 Org is implemented on top of Outline mode.  Outlines allow a
761 document to be organized in a hierarchical structure, which (at least
762 for me) is the best representation of notes and thoughts.  An overview
763 of this structure is achieved by folding (hiding) large parts of the
764 document to show only the general document structure and the parts
765 currently being worked on.  Org greatly simplifies the use of
766 outlines by compressing the entire show/hide functionality into a single
767 command, @command{org-cycle}, which is bound to the @key{TAB} key.
769 @node Headlines, Visibility cycling, Outlines, Document Structure
770 @section Headlines
771 @cindex headlines
772 @cindex outline tree
773 @vindex org-special-ctrl-a/e
775 Headlines define the structure of an outline tree.  The headlines in
776 Org start with one or more stars, on the left margin@footnote{See
777 the variable @code{org-special-ctrl-a/e} to configure special behavior
778 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
780 @example
781 * Top level headline
782 ** Second level
783 *** 3rd level
784     some text
785 *** 3rd level
786     more text
788 * Another top level headline
789 @end example
791 @noindent Some people find the many stars too noisy and would prefer an
792 outline that has whitespace followed by a single star as headline
793 starters.  @ref{Clean view}, describes a setup to realize this.
795 @vindex org-cycle-separator-lines
796 An empty line after the end of a subtree is considered part of it and
797 will be hidden when the subtree is folded.  However, if you leave at
798 least two empty lines, one empty line will remain visible after folding
799 the subtree, in order to structure the collapsed view.  See the
800 variable @code{org-cycle-separator-lines} to modify this behavior.
802 @node Visibility cycling, Motion, Headlines, Document Structure
803 @section Visibility cycling
804 @cindex cycling, visibility
805 @cindex visibility cycling
806 @cindex trees, visibility
807 @cindex show hidden text
808 @cindex hide text
810 Outlines make it possible to hide parts of the text in the buffer.
811 Org uses just two commands, bound to @key{TAB} and
812 @kbd{S-@key{TAB}} to change the visibility in the buffer.
814 @cindex subtree visibility states
815 @cindex subtree cycling
816 @cindex folded, subtree visibility state
817 @cindex children, subtree visibility state
818 @cindex subtree, subtree visibility state
819 @table @kbd
820 @kindex @key{TAB}
821 @item @key{TAB}
822 @emph{Subtree cycling}: Rotate current subtree among the states
824 @example
825 ,-> FOLDED -> CHILDREN -> SUBTREE --.
826 '-----------------------------------'
827 @end example
829 @vindex org-cycle-emulate-tab
830 @vindex org-cycle-global-at-bob
831 The cursor must be on a headline for this to work@footnote{see, however,
832 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
833 beginning of the buffer and the first line is not a headline, then
834 @key{TAB} actually runs global cycling (see below)@footnote{see the
835 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
836 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
838 @cindex global visibility states
839 @cindex global cycling
840 @cindex overview, global visibility state
841 @cindex contents, global visibility state
842 @cindex show all, global visibility state
843 @kindex S-@key{TAB}
844 @item S-@key{TAB}
845 @itemx C-u @key{TAB}
846 @emph{Global cycling}: Rotate the entire buffer among the states
848 @example
849 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
850 '--------------------------------------'
851 @end example
853 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
854 CONTENTS view up to headlines of level N will be shown.  Note that inside
855 tables, @kbd{S-@key{TAB}} jumps to the previous field.
857 @cindex show all, command
858 @kindex C-u C-u C-u @key{TAB}
859 @item C-u C-u C-u @key{TAB}
860 Show all, including drawers.
861 @kindex C-c C-r
862 @item C-c C-r
863 Reveal context around point, showing the current entry, the following heading
864 and the hierarchy above.  Useful for working near a location that has been
865 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
866 (@pxref{Agenda commands}).  With a prefix argument show, on each
867 level, all sibling headings.
868 @kindex C-c C-x b
869 @item C-c C-x b
870 Show the current subtree in an indirect buffer@footnote{The indirect
871 buffer
872 @ifinfo
873 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
874 @end ifinfo
875 @ifnotinfo
876 (see the Emacs manual for more information about indirect buffers)
877 @end ifnotinfo
878 will contain the entire buffer, but will be narrowed to the current
879 tree.  Editing the indirect buffer will also change the original buffer,
880 but without affecting visibility in that buffer.}.  With a numeric
881 prefix argument N, go up to level N and then take that tree.  If N is
882 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
883 the previously used indirect buffer.
884 @end table
886 @vindex org-startup-folded
887 @cindex @code{overview}, STARTUP keyword
888 @cindex @code{content}, STARTUP keyword
889 @cindex @code{showall}, STARTUP keyword
891 When Emacs first visits an Org file, the global state is set to
892 OVERVIEW, @ie only the top level headlines are visible.  This can be
893 configured through the variable @code{org-startup-folded}, or on a
894 per-file basis by adding one of the following lines anywhere in the
895 buffer:
897 @example
898 #+STARTUP: overview
899 #+STARTUP: content
900 #+STARTUP: showall
901 @end example
903 @cindex property, VISIBILITY
904 @noindent
905 Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
906 and Columns}) will get their visibility adapted accordingly.  Allowed values
907 for this property are @code{folded}, @code{children}, @code{content}, and
908 @code{all}.
909 @table @kbd
910 @kindex C-u C-u @key{TAB}
911 @item C-u C-u @key{TAB}
912 Switch back to the startup visibility of the buffer, @ie whatever is
913 requested by startup options and @samp{VISIBILITY} properties in individual
914 entries.
915 @end table
917 @node Motion, Structure editing, Visibility cycling, Document Structure
918 @section Motion
919 @cindex motion, between headlines
920 @cindex jumping, to headlines
921 @cindex headline navigation
922 The following commands jump to other headlines in the buffer.
924 @table @kbd
925 @kindex C-c C-n
926 @item C-c C-n
927 Next heading.
928 @kindex C-c C-p
929 @item C-c C-p
930 Previous heading.
931 @kindex C-c C-f
932 @item C-c C-f
933 Next heading same level.
934 @kindex C-c C-b
935 @item C-c C-b
936 Previous heading same level.
937 @kindex C-c C-u
938 @item C-c C-u
939 Backward to higher level heading.
940 @kindex C-c C-j
941 @item C-c C-j
942 Jump to a different place without changing the current outline
943 visibility.  Shows the document structure in a temporary buffer, where
944 you can use the following keys to find your destination:
945 @vindex org-goto-auto-isearch
946 @example
947 @key{TAB}         @r{Cycle visibility.}
948 @key{down} / @key{up}   @r{Next/previous visible headline.}
949 @key{RET}         @r{Select this location.}
950 @kbd{/}           @r{Do a Sparse-tree search}
951 @r{The following keys work if you turn off @code{org-goto-auto-isearch}}
952 n / p        @r{Next/previous visible headline.}
953 f / b        @r{Next/previous headline same level.}
954 u            @r{One level up.}
955 0-9          @r{Digit argument.}
956 q            @r{Quit}
957 @end example
958 @vindex org-goto-interface
959 @noindent
960 See also the variable @code{org-goto-interface}.
961 @end table
963 @node Structure editing, Archiving, Motion, Document Structure
964 @section Structure editing
965 @cindex structure editing
966 @cindex headline, promotion and demotion
967 @cindex promotion, of subtrees
968 @cindex demotion, of subtrees
969 @cindex subtree, cut and paste
970 @cindex pasting, of subtrees
971 @cindex cutting, of subtrees
972 @cindex copying, of subtrees
973 @cindex sorting, of subtrees
974 @cindex subtrees, cut and paste
976 @table @kbd
977 @kindex M-@key{RET}
978 @item M-@key{RET}
979 @vindex org-M-RET-may-split-line
980 Insert new heading with same level as current.  If the cursor is in a
981 plain list item, a new item is created (@pxref{Plain lists}).  To force
982 creation of a new headline, use a prefix argument, or first press @key{RET}
983 to get to the beginning of the next line.  When this command is used in
984 the middle of a line, the line is split and the rest of the line becomes
985 the new headline@footnote{If you do not want the line to be split,
986 customize the variable @code{org-M-RET-may-split-line}.}.  If the
987 command is used at the beginning of a headline, the new headline is
988 created before the current line.  If at the beginning of any other line,
989 the content of that line is made the new heading.  If the command is
990 used at the end of a folded subtree (@ie behind the ellipses at the end
991 of a headline), then a headline like the current one will be inserted
992 after the end of the subtree.
993 @kindex C-@key{RET}
994 @item C-@key{RET}
995 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
996 current heading, the new heading is placed after the body instead of before
997 it.  This command works from anywhere in the entry.
998 @kindex M-S-@key{RET}
999 @item M-S-@key{RET}
1000 @vindex org-treat-insert-todo-heading-as-state-change
1001 Insert new TODO entry with same level as current heading.  See also the
1002 variable @code{org-treat-insert-todo-heading-as-state-change}.
1003 @kindex C-S-@key{RET}
1004 @item C-S-@key{RET}
1005 Insert new TODO entry with same level as current heading.  Like
1006 @kbd{C-@key{RET}}, the new headline will be inserted after the current
1007 subtree.
1008 @kindex M-@key{left}
1009 @item M-@key{left}
1010 Promote current heading by one level.
1011 @kindex M-@key{right}
1012 @item M-@key{right}
1013 Demote current heading by one level.
1014 @kindex M-S-@key{left}
1015 @item M-S-@key{left}
1016 Promote the current subtree by one level.
1017 @kindex M-S-@key{right}
1018 @item M-S-@key{right}
1019 Demote the current subtree by one level.
1020 @kindex M-S-@key{up}
1021 @item M-S-@key{up}
1022 Move subtree up (swap with previous subtree of same
1023 level).
1024 @kindex M-S-@key{down}
1025 @item M-S-@key{down}
1026 Move subtree down (swap with next subtree of same level).
1027 @kindex C-c C-x C-w
1028 @item C-c C-x C-w
1029 Kill subtree, @ie remove it from buffer but save in kill ring.
1030 With a numeric prefix argument N, kill N sequential subtrees.
1031 @kindex C-c C-x M-w
1032 @item C-c C-x M-w
1033 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
1034 sequential subtrees.
1035 @kindex C-c C-x C-y
1036 @item C-c C-x C-y
1037 Yank subtree from kill ring.  This does modify the level of the subtree to
1038 make sure the tree fits in nicely at the yank position.  The yank level can
1039 also be specified with a numeric prefix argument, or by yanking after a
1040 headline marker like @samp{****}.
1041 @kindex C-y
1042 @item C-y
1043 @vindex org-yank-adjusted-subtrees
1044 @vindex org-yank-folded-subtrees
1045 Depending on the variables @code{org-yank-adjusted-subtrees} and
1046 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
1047 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
1048 C-x C-y}.  With the default settings, no level adjustment will take place,
1049 but the yanked tree will be folded unless doing so would swallow text
1050 previously visible.  Any prefix argument to this command will force a normal
1051 @code{yank} to be executed, with the prefix passed along.  A good way to
1052 force a normal yank is @kbd{C-u C-y}.  If you use @code{yank-pop} after a
1053 yank, it will yank previous kill items plainly, without adjustment and
1054 folding.
1055 @kindex C-c C-x c
1056 @item C-c C-x c
1057 Clone a subtree by making a number of sibling copies of it.  You will be
1058 prompted for the number of copies to make, and you can also specify if any
1059 timestamps in the entry should be shifted.  This can be useful, for example,
1060 to create a number of tasks related to a series of lectures to prepare.  For
1061 more details, see the docstring of the command
1062 @code{org-clone-subtree-with-time-shift}.
1063 @kindex C-c C-w
1064 @item C-c C-w
1065 Refile entry or region to a different location.  @xref{Refiling notes}.
1066 @kindex C-c ^
1067 @item C-c ^
1068 Sort same-level entries.  When there is an active region, all entries in the
1069 region will be sorted.  Otherwise the children of the current headline are
1070 sorted.  The command prompts for the sorting method, which can be
1071 alphabetically, numerically, by time (first timestamp with active preferred,
1072 creation time, scheduled time, deadline time), by priority, by TODO keyword
1073 (in the sequence the keywords have been defined in the setup) or by the value
1074 of a property.  Reverse sorting is possible as well.  You can also supply
1075 your own function to extract the sorting key.  With a @kbd{C-u} prefix,
1076 sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes, duplicate
1077 entries will also be removed.
1078 @kindex C-x n s
1079 @item C-x n s
1080 Narrow buffer to current subtree.
1081 @kindex C-x n w
1082 @item C-x n w
1083 Widen buffer to remove narrowing.
1084 @kindex C-c *
1085 @item C-c *
1086 Turn a normal line or plain list item into a headline (so that it becomes a
1087 subheading at its location).  Also turn a headline into a normal line by
1088 removing the stars.  If there is an active region, turn all lines in the
1089 region into headlines.  If the first line in the region was an item, turn
1090 only the item lines into headlines.  Finally, if the first line is a
1091 headline, remove the stars from all headlines in the region.
1092 @end table
1094 @cindex region, active
1095 @cindex active region
1096 @cindex transient mark mode
1097 When there is an active region (Transient Mark mode), promotion and
1098 demotion work on all headlines in the region.  To select a region of
1099 headlines, it is best to place both point and mark at the beginning of a
1100 line, mark at the beginning of the first headline, and point at the line
1101 just after the last headline to change.  Note that when the cursor is
1102 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
1103 functionality.
1105 @node Archiving, Sparse trees, Structure editing, Document Structure
1106 @section Archiving
1107 @cindex archiving
1109 When a project represented by a (sub)tree is finished, you may want
1110 to move the tree out of the way and to stop it from contributing to the
1111 agenda.  Org mode knows two ways of archiving.  You can mark a tree with
1112 the ARCHIVE tag, or you can move an entire (sub)tree to a different
1113 location.
1115 @menu
1116 * ARCHIVE tag::                 Marking a tree as inactive
1117 * Moving subtrees::             Moving a tree to an archive file
1118 @end menu
1120 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
1121 @subsection The ARCHIVE tag
1122 @cindex internal archiving
1124 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
1125 its location in the outline tree, but behaves in the following way:
1126 @itemize @minus
1127 @item
1128 @vindex org-cycle-open-archived-trees
1129 It does not open when you attempt to do so with a visibility cycling
1130 command (@pxref{Visibility cycling}).  You can force cycling archived
1131 subtrees with @kbd{C-@key{TAB}}, or by setting the option
1132 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
1133 @code{show-all} will open archived subtrees.
1134 @item
1135 @vindex org-sparse-tree-open-archived-trees
1136 During sparse tree construction (@pxref{Sparse trees}), matches in
1137 archived subtrees are not exposed, unless you configure the option
1138 @code{org-sparse-tree-open-archived-trees}.
1139 @item
1140 @vindex org-agenda-skip-archived-trees
1141 During agenda view construction (@pxref{Agenda Views}), the content of
1142 archived trees is ignored unless you configure the option
1143 @code{org-agenda-skip-archived-trees}, in which case these trees will always
1144 be included.  In the agenda you can press the @kbd{v} key to get archives
1145 temporarily included.
1146 @item
1147 @vindex org-export-with-archived-trees
1148 Archived trees are not exported (@pxref{Exporting}), only the headline
1149 is.  Configure the details using the variable
1150 @code{org-export-with-archived-trees}.
1151 @item
1152 @vindex org-columns-skip-arrchived-trees
1153 Archived trees are excluded from column view unless the variable
1154 @code{org-columns-skip-arrchived-trees} is configured to @code{nil}.
1155 @end itemize
1157 The following commands help managing the ARCHIVE tag:
1159 @table @kbd
1160 @kindex C-c C-x a
1161 @item C-c C-x a
1162 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
1163 the headline changes to a shadowed face, and the subtree below it is
1164 hidden.
1165 @kindex C-u C-c C-x a
1166 @item C-u C-c C-x a
1167 Check if any direct children of the current headline should be archived.
1168 To do this, each subtree is checked for open TODO entries.  If none are
1169 found, the command offers to set the ARCHIVE tag for the child.  If the
1170 cursor is @emph{not} on a headline when this command is invoked, the
1171 level 1 trees will be checked.
1172 @kindex C-@kbd{TAB}
1173 @item C-@kbd{TAB}
1174 Cycle a tree even if it is tagged with ARCHIVE.
1175 @end table
1177 @node Moving subtrees,  , ARCHIVE tag, Archiving
1178 @subsection Moving subtrees
1179 @cindex external archiving
1181 Once an entire project is finished, you may want to move it to a different
1182 location.  Org can move it to an @emph{Archive Sibling} in the same tree, to a
1183 different tree in the current file, or to a different file, the archive file.
1185 @table @kbd
1186 @kindex C-c C-x A
1187 @item C-c C-x A
1188 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
1189 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}
1190 (@pxref{ARCHIVE tag}).  The entry becomes a child of that sibling and in this
1191 way retains a lot of its original context, including inherited tags and
1192 approximate position in the outline.
1193 @kindex C-c $
1194 @kindex C-c C-x C-s
1195 @itemx C-c $
1196 @item C-c C-x C-s
1197 @vindex org-archive-location
1198 Archive the subtree starting at the cursor position to the location
1199 given by @code{org-archive-location}.  Context information that could be
1200 lost, like the file name, the category, inherited tags, and the TODO
1201 state will be stored as properties in the entry.
1202 @kindex C-u C-c C-x C-s
1203 @item C-u C-c C-x C-s
1204 Check if any direct children of the current headline could be moved to
1205 the archive.  To do this, each subtree is checked for open TODO entries.
1206 If none are found, the command offers to move it to the archive
1207 location.  If the cursor is @emph{not} on a headline when this command
1208 is invoked, the level 1 trees will be checked.
1209 @end table
1211 @cindex archive locations
1212 The default archive location is a file in the same directory as the
1213 current file, with the name derived by appending @file{_archive} to the
1214 current file name.  For information and examples on how to change this,
1215 see the documentation string of the variable
1216 @code{org-archive-location}.  There is also an in-buffer option for
1217 setting this variable, for example@footnote{For backward compatibility,
1218 the following also works: If there are several such lines in a file,
1219 each specifies the archive location for the text below it.  The first
1220 such line also applies to any text before its definition.  However,
1221 using this method is @emph{strongly} deprecated as it is incompatible
1222 with the outline structure of the document.  The correct method for
1223 setting multiple archive locations in a buffer is using properties.}:
1225 @cindex #+ARCHIVE
1226 @example
1227 #+ARCHIVE: %s_done::
1228 @end example
1230 @cindex property, ARCHIVE
1231 @noindent
1232 If you would like to have a special ARCHIVE location for a single entry
1233 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1234 location as the value (@pxref{Properties and Columns}).
1236 @vindex org-archive-save-context-info
1237 When a subtree is moved, it receives a number of special properties that
1238 record context information like the file from where the entry came, its
1239 outline path the archiving time etc.  Configure the variable
1240 @code{org-archive-save-context-info} to adjust the amount of information
1241 added.
1243 @node Sparse trees, Plain lists, Archiving, Document Structure
1244 @section Sparse trees
1245 @cindex sparse trees
1246 @cindex trees, sparse
1247 @cindex folding, sparse trees
1248 @cindex occur, command
1250 @vindex org-show-hierarchy-above
1251 @vindex org-show-following-heading
1252 @vindex org-show-siblings
1253 @vindex org-show-entry-below
1254 An important feature of Org mode is the ability to construct @emph{sparse
1255 trees} for selected information in an outline tree, so that the entire
1256 document is folded as much as possible, but the selected information is made
1257 visible along with the headline structure above it@footnote{See also the
1258 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1259 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1260 control on how much context is shown around each match.}.  Just try it out
1261 and you will see immediately how it works.
1263 Org mode contains several commands creating such trees, all these
1264 commands can be accessed through a dispatcher:
1266 @table @kbd
1267 @kindex C-c /
1268 @item C-c /
1269 This prompts for an extra key to select a sparse-tree creating command.
1270 @kindex C-c / r
1271 @item C-c / r
1272 @vindex org-remove-highlights-with-change
1273 Occur.  Prompts for a regexp and shows a sparse tree with all matches.  If
1274 the match is in a headline, the headline is made visible.  If the match is in
1275 the body of an entry, headline and body are made visible.  In order to
1276 provide minimal context, also the full hierarchy of headlines above the match
1277 is shown, as well as the headline following the match.  Each match is also
1278 highlighted; the highlights disappear when the buffer is changed by an
1279 editing command@footnote{This depends on the option
1280 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1281 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1282 so several calls to this command can be stacked.
1283 @end table
1285 @noindent
1286 @vindex org-agenda-custom-commands
1287 For frequently used sparse trees of specific search strings, you can
1288 use the variable @code{org-agenda-custom-commands} to define fast
1289 keyboard access to specific sparse trees.  These commands will then be
1290 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1291 For example:
1293 @lisp
1294 (setq org-agenda-custom-commands
1295       '(("f" occur-tree "FIXME")))
1296 @end lisp
1298 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1299 a sparse tree matching the string @samp{FIXME}.
1301 The other sparse tree commands select headings based on TODO keywords,
1302 tags, or properties and will be discussed later in this manual.
1304 @kindex C-c C-e v
1305 @cindex printing sparse trees
1306 @cindex visible text, printing
1307 To print a sparse tree, you can use the Emacs command
1308 @code{ps-print-buffer-with-faces} which does not print invisible parts
1309 of the document @footnote{This does not work under XEmacs, because
1310 XEmacs uses selective display for outlining, not text properties.}.
1311 Or you can use the command @kbd{C-c C-e v} to export only the visible
1312 part of the document and print the resulting file.
1314 @node Plain lists, Drawers, Sparse trees, Document Structure
1315 @section Plain lists
1316 @cindex plain lists
1317 @cindex lists, plain
1318 @cindex lists, ordered
1319 @cindex ordered lists
1321 Within an entry of the outline tree, hand-formatted lists can provide
1322 additional structure.  They also provide a way to create lists of
1323 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1324 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1326 Org knows ordered lists, unordered lists, and description lists.
1327 @itemize @bullet
1328 @item
1329 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1330 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1331 they will be seen as top-level headlines.  Also, when you are hiding leading
1332 stars to get a clean outline view, plain list items starting with a star are
1333 visually indistinguishable from true headlines.  In short: even though
1334 @samp{*} is supported, it may be better to not use it for plain list items.}
1335 as bullets.
1336 @item
1337 @emph{Ordered} list items start with a numeral followed by either a period or
1338 a right parenthesis, such as @samp{1.} or @samp{1)}.
1339 @item
1340 @emph{Description} list items are like unordered list items, but contain the
1341 separator @samp{ :: } to separate the description @emph{term} from the
1342 description.
1343 @end itemize
1345 @vindex org-empty-line-terminates-plain-lists
1346 Items belonging to the same list must have the same indentation on the first
1347 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1348 2--digit numbers must be written left-aligned with the other numbers in the
1349 list.  Indentation also determines the end of a list item.  It ends before
1350 the next line that is indented like the bullet/number, or less.  Empty lines
1351 are part of the previous item, so you can have several paragraphs in one
1352 item.  If you would like an empty line to terminate all currently open plain
1353 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1354 Here is an example:
1356 @example
1357 @group
1358 ** Lord of the Rings
1359    My favorite scenes are (in this order)
1360    1. The attack of the Rohirrim
1361    2. Eowyn's fight with the witch king
1362       + this was already my favorite scene in the book
1363       + I really like Miranda Otto.
1364    3. Peter Jackson being shot by Legolas
1365        - on DVD only
1366       He makes a really funny face when it happens.
1367    But in the end, no individual scenes matter but the film as a whole.
1368    Important actors in this film are:
1369    - @b{Elijah Wood} :: He plays Frodo
1370    - @b{Sean Austin} :: He plays Sam, Frodo's friend.  I still remember
1371      him very well from his role as Mikey Walsh in @i{The Goonies}.
1372 @end group
1373 @end example
1375 Org supports these lists by tuning filling and wrapping commands to deal with
1376 them correctly@footnote{Org only changes the filling settings for Emacs.  For
1377 XEmacs, you should use Kyle E. Jones' @file{filladapt.el}.  To turn this on,
1378 put into @file{.emacs}: @code{(require 'filladapt)}}, and by exporting them
1379 properly (@pxref{Exporting}).  Since indentation is what governs the
1380 structure of these lists, many structural constructs like @code{#+BEGIN_...}
1381 blocks can be indented to signal that they should be part of a list item.
1383 The following commands act on items when the cursor is in the first line
1384 of an item (the line with the bullet or number).
1386 @table @kbd
1387 @kindex @key{TAB}
1388 @item @key{TAB}
1389 @vindex org-cycle-include-plain-lists
1390 Items can be folded just like headline levels.  Normally this works only if
1391 the cursor is on a plain list item.  For more details, see the variable
1392 @code{org-cycle-include-plain-lists}. to @code{integrate}, plain list items
1393 will be treated like low-level.  The level of an item is then given by the
1394 indentation of the bullet/number.  Items are always subordinate to real
1395 headlines, however; the hierarchies remain completely separated.
1397 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1398 fixes the indentation of the current line in a heuristic way.
1399 @kindex M-@key{RET}
1400 @item M-@key{RET}
1401 @vindex org-M-RET-may-split-line
1402 Insert new item at current level.  With a prefix argument, force a new
1403 heading (@pxref{Structure editing}).  If this command is used in the middle
1404 of a line, the line is @emph{split} and the rest of the line becomes the new
1405 item@footnote{If you do not want the line to be split, customize the variable
1406 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1407 @emph{whitespace before a bullet or number}, the new item is created
1408 @emph{before} the current item.  If the command is executed in the white
1409 space before the text that is part of an item but does not contain the
1410 bullet, a bullet is added to the current line.
1411 @kindex M-S-@key{RET}
1412 @item M-S-@key{RET}
1413 Insert a new item with a checkbox (@pxref{Checkboxes}).
1414 @kindex S-@key{up}
1415 @kindex S-@key{down}
1416 @item S-@key{up}
1417 @itemx S-@key{down}
1418 @cindex shift-selection-mode
1419 @vindex org-support-shift-select
1420 Jump to the previous/next item in the current list, but only if
1421 @code{org-support-shift-select} is off.  If not, you can still use paragraph
1422 jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
1423 similar effect.
1424 @kindex M-S-@key{up}
1425 @kindex M-S-@key{down}
1426 @item M-S-@key{up}
1427 @itemx M-S-@key{down}
1428 Move the item including subitems up/down (swap with previous/next item
1429 of same indentation).  If the list is ordered, renumbering is
1430 automatic.
1431 @kindex M-S-@key{left}
1432 @kindex M-S-@key{right}
1433 @item M-S-@key{left}
1434 @itemx M-S-@key{right}
1435 Decrease/increase the indentation of the item, including subitems.
1436 Initially, the item tree is selected based on current indentation.
1437 When these commands are executed several times in direct succession,
1438 the initially selected region is used, even if the new indentation
1439 would imply a different hierarchy.  To use the new hierarchy, break
1440 the command chain with a cursor motion or so.
1441 @kindex C-c C-c
1442 @item C-c C-c
1443 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1444 state of the checkbox.  If not, this command makes sure that all the
1445 items on this list level use the same bullet.  Furthermore, if this is
1446 an ordered list, make sure the numbering is OK.
1447 @kindex C-c -
1448 @item C-c -
1449 Cycle the entire list level through the different itemize/enumerate bullets
1450 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1451 argument N, select the Nth bullet from this list.  If there is an active
1452 region when calling this, all lines will be converted to list items.  If the
1453 first line already was a list item, any item markers will be removed from the
1454 list.  Finally, even without an active region, a normal line will be
1455 converted into a list item.
1456 @kindex C-c *
1457 @item C-c *
1458 Turn a plain list item into a headline (so that it becomes a subheading at
1459 its location). @xref{Structure editing}, for a detailed explanation.
1460 @kindex S-@key{left}
1461 @kindex S-@key{right}
1462 @item S-@key{left}/@key{right}
1463 @vindex org-support-shift-select
1464 This command also cycles bullet styles when the cursor in on the bullet or
1465 anywhere in an item line, details depending on
1466 @code{org-support-shift-select}.
1467 @kindex C-c ^
1468 @item C-c ^
1469 Sort the plain list.  You will be prompted for the sorting method:
1470 numerically, alphabetically, by time, or by custom function.
1471 @end table
1473 @node Drawers, Blocks, Plain lists, Document Structure
1474 @section Drawers
1475 @cindex drawers
1476 @cindex #+DRAWERS
1477 @cindex visibility cycling, drawers
1479 @vindex org-drawers
1480 Sometimes you want to keep information associated with an entry, but you
1481 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1482 Drawers need to be configured with the variable
1483 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1484 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1485 look like this:
1487 @example
1488 ** This is a headline
1489    Still outside the drawer
1490    :DRAWERNAME:
1491       This is inside the drawer.
1492    :END:
1493    After the drawer.
1494 @end example
1496 Visibility cycling (@pxref{Visibility cycling}) on the headline will hide and
1497 show the entry, but keep the drawer collapsed to a single line.  In order to
1498 look inside the drawer, you need to move the cursor to the drawer line and
1499 press @key{TAB} there.  Org mode uses the @code{PROPERTIES} drawer for
1500 storing properties (@pxref{Properties and Columns}), and you can also arrange
1501 for state change notes (@pxref{Tracking TODO state changes}) and clock times
1502 (@pxref{Clocking work time}) to be stored in a drawer @code{LOGBOOK}.
1504 @node Blocks, Footnotes, Drawers, Document Structure
1505 @section Blocks
1507 @vindex org-hide-block-startup
1508 @cindex blocks, folding
1509 Org-mode uses begin...end blocks for various purposes from including source
1510 code examples (@pxref{Literal examples}) to capturing time logging
1511 information (@pxref{Clocking work time}).  These blocks can be folded and
1512 unfolded by pressing TAB in the begin line.  You can also get all blocks
1513 folded at startup by configuring the variable @code{org-hide-block-startup}
1514 or on a per-file basis by using
1516 @cindex @code{hideblocks}, STARTUP keyword
1517 @cindex @code{nohideblocks}, STARTUP keyword
1518 @example
1519 #+STARTUP: hideblocks
1520 #+STARTUP: nohideblocks
1521 @end example
1523 @node Footnotes, Orgstruct mode, Blocks, Document Structure
1524 @section Footnotes
1525 @cindex footnotes
1527 Org mode supports the creation of footnotes.  In contrast to the
1528 @file{footnote.el} package, Org mode's footnotes are designed for work on a
1529 larger document, not only for one-off documents like emails.  The basic
1530 syntax is similar to the one used by @file{footnote.el}, @ie a footnote is
1531 defined in a paragraph that is started by a footnote marker in square
1532 brackets in column 0, no indentation allowed.  If you need a paragraph break
1533 inside a footnote, use the La@TeX{} idiom @samp{\par}.  The footnote reference
1534 is simply the marker in square brackets, inside text.  For example:
1536 @example
1537 The Org homepage[fn:1] now looks a lot better than it used to.
1539 [fn:1] The link is: http://orgmode.org
1540 @end example
1542 Org mode extends the number-based syntax to @emph{named} footnotes and
1543 optional inline definition.  Using plain numbers as markers (as
1544 @file{footnote.el} does) is supported for backward compatibility, but not
1545 encouraged because of possible conflicts with La@TeX{} snippets (@pxref{Embedded
1546 LaTeX}).  Here are the valid references:
1548 @table @code
1549 @item [1]
1550 A plain numeric footnote marker.  Compatible with @file{footnote.el}, but not
1551 recommended because somthing like @samp{[1]} could easily be part of a code
1552 snippet.
1553 @item [fn:name]
1554 A named footnote reference, where @code{name} is a unique label word, or, for
1555 simplicity of automatic creation, a number.
1556 @item [fn:: This is the inline definition of this footnote]
1557 A La@TeX{}-like anonymous footnote where the definition is given directly at the
1558 reference point.
1559 @item [fn:name: a definition]
1560 An inline definition of a footnote, which also specifies a name for the note.
1561 Since Org allows multiple references to the same note, you can then use
1562 @code{[fn:name]} to create additional references.
1563 @end table
1565 @vindex org-footnote-auto-label
1566 Footnote labels can be created automatically, or you can create names yourself.
1567 This is handled by the variable @code{org-footnote-auto-label} and its
1568 corresponding @code{#+STARTUP} keywords, see the docstring of that variable
1569 for details.
1571 @noindent The following command handles footnotes:
1573 @table @kbd
1574 @kindex C-c C-x f
1575 @item C-c C-x f
1576 The footnote action command.
1578 When the cursor is on a footnote reference, jump to the definition.  When it
1579 is at a definition, jump to the (first) reference.
1581 @vindex org-footnote-define-inline
1582 @vindex org-footnote-section
1583 @vindex org-footnote-auto-adjust
1584 Otherwise, create a new footnote.  Depending on the variable
1585 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
1586 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
1587 definition will be placed right into the text as part of the reference, or
1588 separately into the location determined by the variable
1589 @code{org-footnote-section}.
1591 When this command is called with a prefix argument, a menu of additional
1592 options is offered:
1593 @example
1594 s   @r{Sort the footnote definitions by reference sequence.  During editing,}
1595     @r{Org makes no effort to sort footnote definitions into a particular}
1596     @r{sequence.  If you want them sorted, use this command, which will}
1597     @r{also move entries according to @code{org-footnote-section}.  Automatic}
1598     @r{sorting after each insertion/deletion can be configured using the}
1599     @r{variable @code{org-footnote-auto-adjust}.}
1600 r   @r{Renumber the simple @code{fn:N} footnotes.  Automatic renumbering}
1601     @r{after each insertion/deletion can be configured using the variable}
1602     @r{@code{org-footnote-auto-adjust}.}
1603 S   @r{Short for first @code{r}, then @code{s} action.}
1604 n   @r{Normalize the footnotes by collecting all definitions (including}
1605     @r{inline definitions) into a special section, and then numbering them}
1606     @r{in sequence.  The references will then also be numbers.  This is}
1607     @r{meant to be the final step before finishing a document (e.g. sending}
1608     @r{off an email).  The exporters do this automatically, and so could}
1609     @r{something like @code{message-send-hook}.}
1610 d   @r{Delete the footnote at point, and all definitions of and references}
1611     @r{to it.}
1612 @end example
1613 Depending on the variable @code{org-footnote-auto-adjust}@footnote{the
1614 corresponding in-buffer options are @code{fnadjust} and @code{nofnadjust}.},
1615 renumbering and sorting footnotes can be automatic after each insertion or
1616 deletion.
1618 @kindex C-c C-c
1619 @item C-c C-c
1620 If the cursor is on a footnote reference, jump to the definition.  If it is a
1621 the definition, jump back to the reference.  When called at a footnote
1622 location with a prefix argument, offer the same menu as @kbd{C-c C-x f}.
1623 @kindex C-c C-o
1624 @kindex mouse-1
1625 @kindex mouse-2
1626 @item C-c C-o  @r{or} mouse-1/2
1627 Footnote labels are also links to the corresponding definition/reference, and
1628 you can use the usual commands to follow these links.
1629 @end table
1631 @node Orgstruct mode,  , Footnotes, Document Structure
1632 @section The Orgstruct minor mode
1633 @cindex Orgstruct mode
1634 @cindex minor mode for structure editing
1636 If you like the intuitive way the Org mode structure editing and list
1637 formatting works, you might want to use these commands in other modes like
1638 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
1639 this possible.   Toggle the mode with @kbd{M-x orgstruct-mode}, or
1640 turn it on by default, for example in Mail mode, with one of:
1642 @lisp
1643 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1644 (add-hook 'mail-mode-hook 'turn-on-orgstruct++)
1645 @end lisp
1647 When this mode is active and the cursor is on a line that looks to Org like a
1648 headline or the first line of a list item, most structure editing commands
1649 will work, even if the same keys normally have different functionality in the
1650 major mode you are using.  If the cursor is not in one of those special
1651 lines, Orgstruct mode lurks silently in the shadow.  When you use
1652 @code{orgstruct++-mode}, Org will also export indentation and autofill
1653 settings into that mode, and detect item context after the first line of an
1654 item.
1656 @node Tables, Hyperlinks, Document Structure, Top
1657 @chapter Tables
1658 @cindex tables
1659 @cindex editing tables
1661 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1662 calculations are supported in connection with the Emacs @file{calc}
1663 package
1664 @ifinfo
1665 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1666 @end ifinfo
1667 @ifnotinfo
1668 (see the Emacs Calculator manual for more information about the Emacs
1669 calculator).
1670 @end ifnotinfo
1672 @menu
1673 * Built-in table editor::       Simple tables
1674 * Column width and alignment::  Overrule the automatic settings
1675 * Column groups::               Grouping to trigger vertical lines
1676 * Orgtbl mode::                 The table editor as minor mode
1677 * The spreadsheet::             The table editor has spreadsheet capabilities
1678 * Org-Plot::                    Plotting from org tables
1679 @end menu
1681 @node Built-in table editor, Column width and alignment, Tables, Tables
1682 @section The built-in table editor
1683 @cindex table editor, built-in
1685 Org makes it easy to format tables in plain ASCII.  Any line with
1686 @samp{|} as the first non-whitespace character is considered part of a
1687 table.  @samp{|} is also the column separator.  A table might look like
1688 this:
1690 @example
1691 | Name  | Phone | Age |
1692 |-------+-------+-----|
1693 | Peter |  1234 |  17 |
1694 | Anna  |  4321 |  25 |
1695 @end example
1697 A table is re-aligned automatically each time you press @key{TAB} or
1698 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1699 the next field (@key{RET} to the next row) and creates new table rows
1700 at the end of the table or before horizontal lines.  The indentation
1701 of the table is set by the first line.  Any line starting with
1702 @samp{|-} is considered as a horizontal separator line and will be
1703 expanded on the next re-align to span the whole table width.  So, to
1704 create the above table, you would only type
1706 @example
1707 |Name|Phone|Age|
1709 @end example
1711 @noindent and then press @key{TAB} to align the table and start filling in
1712 fields.  Even faster would be to type @code{|Name|Phone|Age} followed by
1713 @kbd{C-c @key{RET}}.
1715 @vindex org-enable-table-editor
1716 @vindex org-table-auto-blank-field
1717 When typing text into a field, Org treats @key{DEL},
1718 @key{Backspace}, and all character keys in a special way, so that
1719 inserting and deleting avoids shifting other fields.  Also, when
1720 typing @emph{immediately after the cursor was moved into a new field
1721 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1722 field is automatically made blank.  If this behavior is too
1723 unpredictable for you, configure the variables
1724 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1726 @table @kbd
1727 @tsubheading{Creation and conversion}
1728 @kindex C-c |
1729 @item C-c |
1730 Convert the active region to table. If every line contains at least one
1731 TAB character, the function assumes that the material is tab separated.
1732 If every line contains a comma, comma-separated values (CSV) are assumed.
1733 If not, lines are split at whitespace into fields.  You can use a prefix
1734 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1735 C-u} forces TAB, and a numeric argument N indicates that at least N
1736 consecutive spaces, or alternatively a TAB will be the separator.
1738 If there is no active region, this command creates an empty Org
1739 table.  But it's easier just to start typing, like
1740 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1742 @tsubheading{Re-aligning and field motion}
1743 @kindex C-c C-c
1744 @item C-c C-c
1745 Re-align the table without moving the cursor.
1747 @kindex @key{TAB}
1748 @item @key{TAB}
1749 Re-align the table, move to the next field.  Creates a new row if
1750 necessary.
1752 @kindex S-@key{TAB}
1753 @item S-@key{TAB}
1754 Re-align, move to previous field.
1756 @kindex @key{RET}
1757 @item @key{RET}
1758 Re-align the table and move down to next row.  Creates a new row if
1759 necessary.  At the beginning or end of a line, @key{RET} still does
1760 NEWLINE, so it can be used to split a table.
1762 @kindex M-a
1763 @item M-a
1764 Move to beginning of the current table field, or on to the previous field.
1765 @kindex M-e
1766 @item M-e
1767 Move to end of the current table field, or on to the next field.
1769 @tsubheading{Column and row editing}
1770 @kindex M-@key{left}
1771 @kindex M-@key{right}
1772 @item M-@key{left}
1773 @itemx M-@key{right}
1774 Move the current column left/right.
1776 @kindex M-S-@key{left}
1777 @item M-S-@key{left}
1778 Kill the current column.
1780 @kindex M-S-@key{right}
1781 @item M-S-@key{right}
1782 Insert a new column to the left of the cursor position.
1784 @kindex M-@key{up}
1785 @kindex M-@key{down}
1786 @item M-@key{up}
1787 @itemx M-@key{down}
1788 Move the current row up/down.
1790 @kindex M-S-@key{up}
1791 @item M-S-@key{up}
1792 Kill the current row or horizontal line.
1794 @kindex M-S-@key{down}
1795 @item M-S-@key{down}
1796 Insert a new row above the current row.  With a prefix argument, the line is
1797 created below the current one.
1799 @kindex C-c -
1800 @item C-c -
1801 Insert a horizontal line below current row.  With a prefix argument, the line
1802 is created above the current line.
1804 @kindex C-c @key{RET}
1805 @item C-c @key{RET}
1806 Insert a horizontal line below current row, and move the cursor into the row
1807 below that line.
1809 @kindex C-c ^
1810 @item C-c ^
1811 Sort the table lines in the region.  The position of point indicates the
1812 column to be used for sorting, and the range of lines is the range
1813 between the nearest horizontal separator lines, or the entire table.  If
1814 point is before the first column, you will be prompted for the sorting
1815 column.  If there is an active region, the mark specifies the first line
1816 and the sorting column, while point should be in the last line to be
1817 included into the sorting.  The command prompts for the sorting type
1818 (alphabetically, numerically, or by time).  When called with a prefix
1819 argument, alphabetic sorting will be case-sensitive.
1821 @tsubheading{Regions}
1822 @kindex C-c C-x M-w
1823 @item C-c C-x M-w
1824 Copy a rectangular region from a table to a special clipboard.  Point and
1825 mark determine edge fields of the rectangle.  If there is no active region,
1826 copy just the current field.  The process ignores horizontal separator lines.
1828 @kindex C-c C-x C-w
1829 @item C-c C-x C-w
1830 Copy a rectangular region from a table to a special clipboard, and
1831 blank all fields in the rectangle.  So this is the ``cut'' operation.
1833 @kindex C-c C-x C-y
1834 @item C-c C-x C-y
1835 Paste a rectangular region into a table.
1836 The upper left corner ends up in the current field.  All involved fields
1837 will be overwritten.  If the rectangle does not fit into the present table,
1838 the table is enlarged as needed.  The process ignores horizontal separator
1839 lines.
1841 @kindex M-@key{RET}
1842 @itemx M-@kbd{RET}
1843 Wrap several fields in a column like a paragraph.  If there is an active
1844 region, and both point and mark are in the same column, the text in the
1845 column is wrapped to minimum width for the given number of lines.  A numeric
1846 prefix argument may be used to change the number of desired lines.  If there
1847 is no region, the current field is split at the cursor position and the text
1848 fragment to the right of the cursor is prepended to the field one line
1849 down. If there is no region, but you specify a prefix argument, the current
1850 field is made blank, and the content is appended to the field above.
1852 @tsubheading{Calculations}
1853 @cindex formula, in tables
1854 @cindex calculations, in tables
1855 @cindex region, active
1856 @cindex active region
1857 @cindex transient mark mode
1858 @kindex C-c +
1859 @item C-c +
1860 Sum the numbers in the current column, or in the rectangle defined by
1861 the active region.  The result is shown in the echo area and can
1862 be inserted with @kbd{C-y}.
1864 @kindex S-@key{RET}
1865 @item S-@key{RET}
1866 @vindex org-table-copy-increment
1867 When current field is empty, copy from first non-empty field above.  When not
1868 empty, copy current field down to next row and move cursor along with it.
1869 Depending on the variable @code{org-table-copy-increment}, integer field
1870 values will be incremented during copy.  Integers that are too large will not
1871 be incremented.  Also, a @code{0} prefix argument temporarily disables the
1872 increment.  This key is also used by shift-selection and related modes
1873 (@pxref{Conflicts}).
1875 @tsubheading{Miscellaneous}
1876 @kindex C-c `
1877 @item C-c `
1878 Edit the current field in a separate window.  This is useful for fields that
1879 are not fully visible (@pxref{Column width and alignment}).  When called with
1880 a @kbd{C-u} prefix, just make the full field visible, so that it can be
1881 edited in place.
1883 @item M-x org-table-import
1884 Import a file as a table.  The table should be TAB or whitespace
1885 separated.  Use, for example, to import a spreadsheet table or data
1886 from a database, because these programs generally can write
1887 TAB-separated text files.  This command works by inserting the file into
1888 the buffer and then converting the region to a table.  Any prefix
1889 argument is passed on to the converter, which uses it to determine the
1890 separator.
1891 @item C-c |
1892 Tables can also be imported by pasting tabular text into the Org
1893 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1894 @kbd{C-c |} command (see above under @i{Creation and conversion}).
1896 @item M-x org-table-export
1897 @vindex org-table-export-default-format
1898 Export the table, by default as a TAB-separated file.  Use for data
1899 exchange with, for example, spreadsheet or database programs.  The format
1900 used to export the file can be configured in the variable
1901 @code{org-table-export-default-format}.  You may also use properties
1902 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1903 name and the format for table export in a subtree.  Org supports quite
1904 general formats for exported tables.  The exporter format is the same as the
1905 format used by Orgtbl radio tables, see @ref{Translator functions}, for a
1906 detailed description.
1907 @end table
1909 If you don't like the automatic table editor because it gets in your
1910 way on lines which you would like to start with @samp{|}, you can turn
1911 it off with
1913 @lisp
1914 (setq org-enable-table-editor nil)
1915 @end lisp
1917 @noindent Then the only table command that still works is
1918 @kbd{C-c C-c} to do a manual re-align.
1920 @node Column width and alignment, Column groups, Built-in table editor, Tables
1921 @section Column width and alignment
1922 @cindex narrow columns in tables
1923 @cindex alignment in tables
1925 The width of columns is automatically determined by the table editor.  And
1926 also the alignment of a column is determined automatically from the fraction
1927 of number-like versus non-number fields in the column.
1929 Sometimes a single field or a few fields need to carry more text,
1930 leading to inconveniently wide columns.  To limit@footnote{This feature
1931 does not work on XEmacs.} the width of a column, one field anywhere in
1932 the column may contain just the string @samp{<N>} where @samp{N} is an
1933 integer specifying the width of the column in characters.  The next
1934 re-align will then set the width of this column to no more than this
1935 value.
1937 @example
1938 @group
1939 |---+------------------------------|               |---+--------|
1940 |   |                              |               |   | <6>    |
1941 | 1 | one                          |               | 1 | one    |
1942 | 2 | two                          |     ----\     | 2 | two    |
1943 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1944 | 4 | four                         |               | 4 | four   |
1945 |---+------------------------------|               |---+--------|
1946 @end group
1947 @end example
1949 @noindent
1950 Fields that are wider become clipped and end in the string @samp{=>}.
1951 Note that the full text is still in the buffer, it is only invisible.
1952 To see the full text, hold the mouse over the field---a tool-tip window
1953 will show the full content.  To edit such a field, use the command
1954 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1955 open a new window with the full field.  Edit it and finish with @kbd{C-c
1956 C-c}.
1958 @vindex org-startup-align-all-tables
1959 When visiting a file containing a table with narrowed columns, the
1960 necessary character hiding has not yet happened, and the table needs to
1961 be aligned before it looks nice.  Setting the option
1962 @code{org-startup-align-all-tables} will realign all tables in a file
1963 upon visiting, but also slow down startup.  You can also set this option
1964 on a per-file basis with:
1966 @example
1967 #+STARTUP: align
1968 #+STARTUP: noalign
1969 @end example
1971 If you would like to overrule the automatic alignment of number-rich columns
1972 to the right and of string-rich column to the left, you and use @samp{<r>} or
1973 @samp{<l>} in a similar fashion.  You may also combine alignment and field
1974 width like this: @samp{<l10>}.
1976 @node Column groups, Orgtbl mode, Column width and alignment, Tables
1977 @section Column groups
1978 @cindex grouping columns in tables
1980 When Org exports tables, it does so by default without vertical
1981 lines because that is visually more satisfying in general.  Occasionally
1982 however, vertical lines can be useful to structure a table into groups
1983 of columns, much like horizontal lines can do for groups of rows.  In
1984 order to specify column groups, you can use a special row where the
1985 first field contains only @samp{/}.  The further fields can either
1986 contain @samp{<} to indicate that this column should start a group,
1987 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1988 a group of its own.  Boundaries between column groups will upon export be
1989 marked with vertical lines.  Here is an example:
1991 @example
1992 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1993 |---+----+-----+-----+-----+---------+------------|
1994 | / | <> |   < |     |   > |       < |          > |
1995 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1996 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1997 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1998 |---+----+-----+-----+-----+---------+------------|
1999 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2)))
2000 @end example
2002 It is also sufficient to just insert the column group starters after
2003 every vertical line you'd like to have:
2005 @example
2006 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2007 |----+-----+-----+-----+---------+------------|
2008 | /  | <   |     |     | <       |            |
2009 @end example
2011 @node Orgtbl mode, The spreadsheet, Column groups, Tables
2012 @section The Orgtbl minor mode
2013 @cindex Orgtbl mode
2014 @cindex minor mode for tables
2016 If you like the intuitive way the Org table editor works, you
2017 might also want to use it in other modes like Text mode or Mail mode.
2018 The minor mode Orgtbl mode makes this possible.  You can always toggle
2019 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
2020 example in mail mode, use
2022 @lisp
2023 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
2024 @end lisp
2026 Furthermore, with some special setup, it is possible to maintain tables
2027 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
2028 construct La@TeX{} tables with the underlying ease and power of
2029 Orgtbl mode, including spreadsheet capabilities.  For details, see
2030 @ref{Tables in arbitrary syntax}.
2032 @node The spreadsheet, Org-Plot, Orgtbl mode, Tables
2033 @section The spreadsheet
2034 @cindex calculations, in tables
2035 @cindex spreadsheet capabilities
2036 @cindex @file{calc} package
2038 The table editor makes use of the Emacs @file{calc} package to implement
2039 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
2040 derive fields from other fields.  While fully featured, Org's
2041 implementation is not identical to other spreadsheets.  For example,
2042 Org knows the concept of a @emph{column formula} that will be
2043 applied to all non-header fields in a column without having to copy the
2044 formula to each relevant field.
2046 @menu
2047 * References::                  How to refer to another field or range
2048 * Formula syntax for Calc::     Using Calc to compute stuff
2049 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
2050 * Field formulas::              Formulas valid for a single field
2051 * Column formulas::             Formulas valid for an entire column
2052 * Editing and debugging formulas::  Fixing formulas
2053 * Updating the table::          Recomputing all dependent fields
2054 * Advanced features::           Field names, parameters and automatic recalc
2055 @end menu
2057 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
2058 @subsection References
2059 @cindex references
2061 To compute fields in the table from other fields, formulas must
2062 reference other fields or ranges.  In Org, fields can be referenced
2063 by name, by absolute coordinates, and by relative coordinates.  To find
2064 out what the coordinates of a field are, press @kbd{C-c ?} in that
2065 field, or press @kbd{C-c @}} to toggle the display of a grid.
2067 @subsubheading Field references
2068 @cindex field references
2069 @cindex references, to fields
2071 Formulas can reference the value of another field in two ways.  Like in
2072 any other spreadsheet, you may reference fields with a letter/number
2073 combination like @code{B3}, meaning the 2nd field in the 3rd row.
2074 @c Such references are always fixed to that field, they don't change
2075 @c when you copy and paste a formula to a different field.  So
2076 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
2078 @noindent
2079 Org also uses another, more general operator that looks like this:
2080 @example
2081 @@@var{row}$@var{column}
2082 @end example
2084 @noindent
2085 Column references can be absolute like @samp{1}, @samp{2},...@samp{@var{N}},
2086 or relative to the current column like @samp{+1} or @samp{-2}.
2088 The row specification only counts data lines and ignores horizontal
2089 separator lines (hlines).  You can use absolute row numbers
2090 @samp{1}...@samp{@var{N}}, and row numbers relative to the current row like
2091 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
2092 hlines: @samp{I} refers to the first hline@footnote{Note that only
2093 hlines are counted that @emph{separate} table lines.  If the table
2094 starts with a hline above the header, it does not count.}, @samp{II} to
2095 the second, etc@.  @samp{-I} refers to the first such line above the
2096 current line, @samp{+I} to the first such line below the current line.
2097 You can also write @samp{III+2} which is the second data line after the
2098 third hline in the table.
2100 @samp{0} refers to the current row and column.  Also, if you omit
2101 either the column or the row part of the reference, the current
2102 row/column is implied.
2104 Org's references with @emph{unsigned} numbers are fixed references
2105 in the sense that if you use the same reference in the formula for two
2106 different fields, the same field will be referenced each time.
2107 Org's references with @emph{signed} numbers are floating
2108 references because the same reference operator can reference different
2109 fields depending on the field being calculated by the formula.
2111 As a special case, references like @samp{$LR5} and @samp{$LR12} can be used
2112 to refer in a stable way to the 5th and 12th field in the last row of the
2113 table.
2115 Here are a few examples:
2117 @example
2118 @@2$3      @r{2nd row, 3rd column}
2119 C2        @r{same as previous}
2120 $5        @r{column 5 in the current row}
2121 E&        @r{same as previous}
2122 @@2        @r{current column, row 2}
2123 @@-1$-3    @r{the field one row up, three columns to the left}
2124 @@-I$2     @r{field just under hline above current row, column 2}
2125 @end example
2127 @subsubheading Range references
2128 @cindex range references
2129 @cindex references, to ranges
2131 You may reference a rectangular range of fields by specifying two field
2132 references connected by two dots @samp{..}.  If both fields are in the
2133 current row, you may simply use @samp{$2..$7}, but if at least one field
2134 is in a different row, you need to use the general @code{@@row$column}
2135 format at least for the first field (i.e the reference must start with
2136 @samp{@@} in order to be interpreted correctly).  Examples:
2138 @example
2139 $1..$3        @r{First three fields in the current row.}
2140 $P..$Q        @r{Range, using column names (see under Advanced)}
2141 @@2$1..@@4$3    @r{6 fields between these two fields.}
2142 A2..C4        @r{Same as above.}
2143 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
2144 @end example
2146 @noindent Range references return a vector of values that can be fed
2147 into Calc vector functions.  Empty fields in ranges are normally
2148 suppressed, so that the vector contains only the non-empty fields (but
2149 see the @samp{E} mode switch below).  If there are no non-empty fields,
2150 @samp{[0]} is returned to avoid syntax errors in formulas.
2152 @subsubheading Named references
2153 @cindex named references
2154 @cindex references, named
2155 @cindex name, of column or field
2156 @cindex constants, in calculations
2157 @cindex #+CONSTANTS
2159 @vindex org-table-formula-constants
2160 @samp{$name} is interpreted as the name of a column, parameter or
2161 constant.  Constants are defined globally through the variable
2162 @code{org-table-formula-constants}, and locally (for the file) through a
2163 line like
2165 @example
2166 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2167 @end example
2169 @noindent
2170 @vindex constants-unit-system
2171 @pindex constants.el
2172 Also properties (@pxref{Properties and Columns}) can be used as
2173 constants in table formulas: for a property @samp{:Xyz:} use the name
2174 @samp{$PROP_Xyz}, and the property will be searched in the current
2175 outline entry and in the hierarchy above it.  If you have the
2176 @file{constants.el} package, it will also be used to resolve constants,
2177 including natural constants like @samp{$h} for Planck's constant, and
2178 units like @samp{$km} for kilometers@footnote{@file{constants.el} can
2179 supply the values of constants in two different unit systems, @code{SI}
2180 and @code{cgs}.  Which one is used depends on the value of the variable
2181 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
2182 @code{constSI} and @code{constcgs} to set this value for the current
2183 buffer.}.  Column names and parameters can be specified in special table
2184 lines.  These are described below, see @ref{Advanced features}.  All
2185 names must start with a letter, and further consist of letters and
2186 numbers.
2188 @subsubheading Remote references
2189 @cindex remote references
2190 @cindex references, remote
2191 @cindex references, to a different table
2192 @cindex name, of column or field
2193 @cindex constants, in calculations
2194 @cindex #+TBLNAME
2196 You may also reference constants, fields and ranges from a different table,
2197 either in the current file or even in a different file.  The syntax is
2199 @example
2200 remote(NAME-OR-ID,REF)
2201 @end example
2203 @noindent
2204 where NAME can be the name of a table in the current file as set by a
2205 @code{#+TBLNAME: NAME} line before the table.  It can also be the ID of an
2206 entry, even in a different file, and the reference then refers to the first
2207 table in that entry.  REF is an absolute field or range reference as
2208 described above for example @code{@@3$3} or @code{$somename}, valid in the
2209 referenced table.
2211 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
2212 @subsection Formula syntax for Calc
2213 @cindex formula syntax, Calc
2214 @cindex syntax, of formulas
2216 A formula can be any algebraic expression understood by the Emacs
2217 @file{Calc} package.  @b{Note that @file{calc} has the
2218 non-standard convention that @samp{/} has lower precedence than
2219 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
2220 evaluation by @code{calc-eval} (@pxref{Calling Calc from
2221 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
2222 Emacs Calc Manual}),
2223 @c FIXME:  The link to the Calc manual in HTML does not work.
2224 variable substitution takes place according to the rules described above.
2225 @cindex vectors, in table calculations
2226 The range vectors can be directly fed into the Calc vector functions
2227 like @samp{vmean} and @samp{vsum}.
2229 @cindex format specifier
2230 @cindex mode, for @file{calc}
2231 @vindex org-calc-default-modes
2232 A formula can contain an optional mode string after a semicolon.  This
2233 string consists of flags to influence Calc and other modes during
2234 execution.  By default, Org uses the standard Calc modes (precision
2235 12, angular units degrees, fraction and symbolic modes off).  The display
2236 format, however, has been changed to @code{(float 8)} to keep tables
2237 compact.  The default settings can be configured using the variable
2238 @code{org-calc-default-modes}.
2240 @example
2241 p20           @r{switch the internal precision to 20 digits}
2242 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
2243 D R           @r{angle modes: degrees, radians}
2244 F S           @r{fraction and symbolic modes}
2245 N             @r{interpret all fields as numbers, use 0 for non-numbers}
2246 T             @r{force text interpretation}
2247 E             @r{keep empty fields in ranges}
2248 L             @r{literal}
2249 @end example
2251 @noindent
2252 In addition, you may provide a @code{printf} format specifier to
2253 reformat the final result.  A few examples:
2255 @example
2256 $1+$2                @r{Sum of first and second field}
2257 $1+$2;%.2f           @r{Same, format result to two decimals}
2258 exp($2)+exp($1)      @r{Math functions can be used}
2259 $0;%.1f              @r{Reformat current cell to 1 decimal}
2260 ($3-32)*5/9          @r{Degrees F -> C conversion}
2261 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
2262 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
2263 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
2264 vmean($2..$7)        @r{Compute column range mean, using vector function}
2265 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
2266 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
2267 @end example
2269 Calc also contains a complete set of logical operations.  For example
2271 @example
2272 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
2273 @end example
2275 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
2276 @subsection Emacs Lisp forms as formulas
2277 @cindex Lisp forms, as table formulas
2279 It is also possible to write a formula in Emacs Lisp; this can be useful
2280 for string manipulation and control structures, if Calc's
2281 functionality is not enough.  If a formula starts with a single-quote
2282 followed by an opening parenthesis, then it is evaluated as a Lisp form.
2283 The evaluation should return either a string or a number.  Just as with
2284 @file{calc} formulas, you can specify modes and a printf format after a
2285 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
2286 field references are interpolated into the form.  By default, a
2287 reference will be interpolated as a Lisp string (in double-quotes)
2288 containing the field.  If you provide the @samp{N} mode switch, all
2289 referenced elements will be numbers (non-number fields will be zero) and
2290 interpolated as Lisp numbers, without quotes.  If you provide the
2291 @samp{L} flag, all fields will be interpolated literally, without quotes.
2292 @Ie{}, if you want a reference to be interpreted as a string by the Lisp
2293 form, enclose the reference operator itself in double-quotes, like
2294 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
2295 embed them in list or vector syntax.  A few examples, note how the
2296 @samp{N} mode is used when we do computations in Lisp.
2298 @example
2299 @r{Swap the first two characters of the content of column 1}
2300   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
2301 @r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
2302   '(+ $1 $2);N
2303 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
2304   '(apply '+ '($1..$4));N
2305 @end example
2307 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
2308 @subsection Field formulas
2309 @cindex field formula
2310 @cindex formula, for individual table field
2312 To assign a formula to a particular field, type it directly into the
2313 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
2314 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
2315 the field, the formula will be stored as the formula for this field,
2316 evaluated, and the current field replaced with the result.
2318 @cindex #+TBLFM
2319 Formulas are stored in a special line starting with @samp{#+TBLFM:}
2320 directly below the table.  If you typed the equation in the 4th field of
2321 the 3rd data line in the table, the formula will look like
2322 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
2323 with the appropriate commands, @i{absolute references} (but not relative
2324 ones) in stored formulas are modified in order to still reference the
2325 same field.  Of course this is not true if you edit the table structure
2326 with normal editing commands---then you must fix the equations yourself.
2327 The left-hand side of a formula may also be a named field (@pxref{Advanced
2328 features}), or a last-row reference like @samp{$LR3}.
2330 Instead of typing an equation into the field, you may also use the
2331 following command
2333 @table @kbd
2334 @kindex C-u C-c =
2335 @item C-u C-c =
2336 Install a new formula for the current field.  The command prompts for a
2337 formula with default taken from the @samp{#+TBLFM:} line, applies
2338 it to the current field, and stores it.
2339 @end table
2341 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
2342 @subsection Column formulas
2343 @cindex column formula
2344 @cindex formula, for table column
2346 Often in a table, the same formula should be used for all fields in a
2347 particular column.  Instead of having to copy the formula to all fields
2348 in that column, Org allows you to assign a single formula to an entire
2349 column.  If the table contains horizontal separator hlines, everything
2350 before the first such line is considered part of the table @emph{header}
2351 and will not be modified by column formulas.
2353 To assign a formula to a column, type it directly into any field in the
2354 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2355 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2356 the formula will be stored as the formula for the current column, evaluated
2357 and the current field replaced with the result.  If the field contains only
2358 @samp{=}, the previously stored formula for this column is used.  For each
2359 column, Org will only remember the most recently used formula.  In the
2360 @samp{#+TBLFM:} line, column formulas will look like @samp{$4=$1+$2}.  The left-hand
2361 side of a column formula cannot currently be the name of column, it
2362 must be the numeric column reference.
2364 Instead of typing an equation into the field, you may also use the
2365 following command:
2367 @table @kbd
2368 @kindex C-c =
2369 @item C-c =
2370 Install a new formula for the current column and replace current field with
2371 the result of the formula.  The command prompts for a formula, with default
2372 taken from the @samp{#+TBLFM} line, applies it to the current field and
2373 stores it.  With a numeric prefix argument(@eg @kbd{C-5 C-c =}) the command
2374 will apply it to that many consecutive fields in the current column.
2375 @end table
2377 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
2378 @subsection Editing and debugging formulas
2379 @cindex formula editing
2380 @cindex editing, of table formulas
2382 @vindex org-table-use-standard-references
2383 You can edit individual formulas in the minibuffer or directly in the
2384 field.  Org can also prepare a special buffer with all active
2385 formulas of a table.  When offering a formula for editing, Org
2386 converts references to the standard format (like @code{B3} or @code{D&})
2387 if possible.  If you prefer to only work with the internal format (like
2388 @code{@@3$2} or @code{$4}), configure the variable
2389 @code{org-table-use-standard-references}.
2391 @table @kbd
2392 @kindex C-c =
2393 @kindex C-u C-c =
2394 @item C-c =
2395 @itemx C-u C-c =
2396 Edit the formula associated with the current column/field in the
2397 minibuffer.  See @ref{Column formulas}, and @ref{Field formulas}.
2398 @kindex C-u C-u C-c =
2399 @item C-u C-u C-c =
2400 Re-insert the active formula (either a
2401 field formula, or a column formula) into the current field, so that you
2402 can edit it directly in the field.  The advantage over editing in the
2403 minibuffer is that you can use the command @kbd{C-c ?}.
2404 @kindex C-c ?
2405 @item C-c ?
2406 While editing a formula in a table field, highlight the field(s)
2407 referenced by the reference at the cursor position in the formula.
2408 @kindex C-c @}
2409 @item C-c @}
2410 Toggle the display of row and column numbers for a table, using
2411 overlays.  These are updated each time the table is aligned; you can
2412 force it with @kbd{C-c C-c}.
2413 @kindex C-c @{
2414 @item C-c @{
2415 Toggle the formula debugger on and off.  See below.
2416 @kindex C-c '
2417 @item C-c '
2418 Edit all formulas for the current table in a special buffer, where the
2419 formulas will be displayed one per line.  If the current field has an
2420 active formula, the cursor in the formula editor will mark it.
2421 While inside the special buffer, Org will automatically highlight
2422 any field or range reference at the cursor position.  You may edit,
2423 remove and add formulas, and use the following commands:
2424 @table @kbd
2425 @kindex C-c C-c
2426 @kindex C-x C-s
2427 @item C-c C-c
2428 @itemx C-x C-s
2429 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2430 prefix, also apply the new formulas to the entire table.
2431 @kindex C-c C-q
2432 @item C-c C-q
2433 Exit the formula editor without installing changes.
2434 @kindex C-c C-r
2435 @item C-c C-r
2436 Toggle all references in the formula editor between standard (like
2437 @code{B3}) and internal (like @code{@@3$2}).
2438 @kindex @key{TAB}
2439 @item @key{TAB}
2440 Pretty-print or indent Lisp formula at point.  When in a line containing
2441 a Lisp formula, format the formula according to Emacs Lisp rules.
2442 Another @key{TAB} collapses the formula back again.  In the open
2443 formula, @key{TAB} re-indents just like in Emacs Lisp mode.
2444 @kindex M-@key{TAB}
2445 @item M-@key{TAB}
2446 Complete Lisp symbols, just like in Emacs Lisp mode.
2447 @kindex S-@key{up}
2448 @kindex S-@key{down}
2449 @kindex S-@key{left}
2450 @kindex S-@key{right}
2451 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2452 Shift the reference at point.  For example, if the reference is
2453 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2454 This also works for relative references and for hline references.
2455 @kindex M-S-@key{up}
2456 @kindex M-S-@key{down}
2457 @item M-S-@key{up}/@key{down}
2458 Move the test line for column formulas in the Org buffer up and
2459 down.
2460 @kindex M-@key{up}
2461 @kindex M-@key{down}
2462 @item M-@key{up}/@key{down}
2463 Scroll the window displaying the table.
2464 @kindex C-c @}
2465 @item C-c @}
2466 Turn the coordinate grid in the table on and off.
2467 @end table
2468 @end table
2470 Making a table field blank does not remove the formula associated with
2471 the field, because that is stored in a different line (the @samp{#+TBLFM}
2472 line)---during the next recalculation the field will be filled again.
2473 To remove a formula from a field, you have to give an empty reply when
2474 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2476 @kindex C-c C-c
2477 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2478 equations with @kbd{C-c C-c} in that line or with the normal
2479 recalculation commands in the table.
2481 @subsubheading Debugging formulas
2482 @cindex formula debugging
2483 @cindex debugging, of table formulas
2484 When the evaluation of a formula leads to an error, the field content
2485 becomes the string @samp{#ERROR}.  If you would like see what is going
2486 on during variable substitution and calculation in order to find a bug,
2487 turn on formula debugging in the @code{Tbl} menu and repeat the
2488 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2489 field.  Detailed information will be displayed.
2491 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2492 @subsection Updating the table
2493 @cindex recomputing table fields
2494 @cindex updating, table
2496 Recalculation of a table is normally not automatic, but needs to be
2497 triggered by a command.  See @ref{Advanced features}, for a way to make
2498 recalculation at least semi-automatic.
2500 In order to recalculate a line of a table or the entire table, use the
2501 following commands:
2503 @table @kbd
2504 @kindex C-c *
2505 @item C-c *
2506 Recalculate the current row by first applying the stored column formulas
2507 from left to right, and all field formulas in the current row.
2509 @kindex C-u C-c *
2510 @item C-u C-c *
2511 @kindex C-u C-c C-c
2512 @itemx C-u C-c C-c
2513 Recompute the entire table, line by line.  Any lines before the first
2514 hline are left alone, assuming that these are part of the table header.
2516 @kindex C-u C-u C-c *
2517 @kindex C-u C-u C-c C-c
2518 @item C-u C-u C-c *
2519 @itemx C-u C-u C-c C-c
2520 Iterate the table by recomputing it until no further changes occur.
2521 This may be necessary if some computed fields use the value of other
2522 fields that are computed @i{later} in the calculation sequence.
2523 @end table
2525 @node Advanced features,  , Updating the table, The spreadsheet
2526 @subsection Advanced features
2528 If you want the recalculation of fields to happen automatically, or if
2529 you want to be able to assign @i{names} to fields and columns, you need
2530 to reserve the first column of the table for special marking characters.
2531 @table @kbd
2532 @kindex C-#
2533 @item C-#
2534 Rotate the calculation mark in first column through the states @samp{},
2535 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
2536 change all marks in the region.
2537 @end table
2539 Here is an example of a table that collects exam results of students and
2540 makes use of these features:
2542 @example
2543 @group
2544 |---+---------+--------+--------+--------+-------+------|
2545 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2546 |---+---------+--------+--------+--------+-------+------|
2547 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2548 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2549 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2550 |---+---------+--------+--------+--------+-------+------|
2551 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2552 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2553 |---+---------+--------+--------+--------+-------+------|
2554 |   | Average |        |        |        |  29.7 |      |
2555 | ^ |         |        |        |        |    at |      |
2556 | $ | max=50  |        |        |        |       |      |
2557 |---+---------+--------+--------+--------+-------+------|
2558 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2559 @end group
2560 @end example
2562 @noindent @b{Important}: please note that for these special tables,
2563 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2564 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2565 to the field itself.  The column formulas are not applied in rows with
2566 empty first field.
2568 @cindex marking characters, tables
2569 The marking characters have the following meaning:
2570 @table @samp
2571 @item !
2572 The fields in this line define names for the columns, so that you may
2573 refer to a column as @samp{$Tot} instead of @samp{$6}.
2574 @item ^
2575 This row defines names for the fields @emph{above} the row.  With such
2576 a definition, any formula in the table may use @samp{$m1} to refer to
2577 the value @samp{10}.  Also, if you assign a formula to a names field, it
2578 will be stored as @samp{$name=...}.
2579 @item _
2580 Similar to @samp{^}, but defines names for the fields in the row
2581 @emph{below}.
2582 @item $
2583 Fields in this row can define @emph{parameters} for formulas.  For
2584 example, if a field in a @samp{$} row contains @samp{max=50}, then
2585 formulas in this table can refer to the value 50 using @samp{$max}.
2586 Parameters work exactly like constants, only that they can be defined on
2587 a per-table basis.
2588 @item #
2589 Fields in this row are automatically recalculated when pressing
2590 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2591 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2592 lines will be left alone by this command.
2593 @item *
2594 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2595 not for automatic recalculation.  Use this when automatic
2596 recalculation slows down editing too much.
2597 @item
2598 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2599 All lines that should be recalculated should be marked with @samp{#}
2600 or @samp{*}.
2601 @item /
2602 Do not export this line.  Useful for lines that contain the narrowing
2603 @samp{<N>} markers or column group markers.
2604 @end table
2606 Finally, just to whet your appetite for what can be done with the
2607 fantastic @file{calc.el} package, here is a table that computes the Taylor
2608 series of degree @code{n} at location @code{x} for a couple of
2609 functions.
2611 @example
2612 @group
2613 |---+-------------+---+-----+--------------------------------------|
2614 |   | Func        | n | x   | Result                               |
2615 |---+-------------+---+-----+--------------------------------------|
2616 | # | exp(x)      | 1 | x   | 1 + x                                |
2617 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2618 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2619 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2620 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2621 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2622 |---+-------------+---+-----+--------------------------------------|
2623 #+TBLFM: $5=taylor($2,$4,$3);n3
2624 @end group
2625 @end example
2627 @node Org-Plot,  , The spreadsheet, Tables
2628 @section Org-Plot
2629 @cindex graph, in tables
2630 @cindex plot tables using gnuplot
2631 @cindex #+PLOT
2633 Org-Plot can produce 2D and 3D graphs of information stored in org tables
2634 using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
2635 @uref{http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html}.  To see
2636 this in action, ensure that you have both Gnuplot and Gnuplot mode installed
2637 on your system, then call @code{org-plot/gnuplot} on the following table.
2639 @example
2640 @group
2641 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2642 | Sede      | Max cites | H-index |
2643 |-----------+-----------+---------|
2644 | Chile     |    257.72 |   21.39 |
2645 | Leeds     |    165.77 |   19.68 |
2646 | Sao Paolo |     71.00 |   11.50 |
2647 | Stockholm |    134.19 |   14.33 |
2648 | Morelia   |    257.56 |   17.67 |
2649 @end group
2650 @end example
2652 Notice that Org Plot is smart enough to apply the table's headers as labels.
2653 Further control over the labels, type, content, and appearance of plots can
2654 be exercised through the @code{#+PLOT:} lines preceding a table.  See below
2655 for a complete list of Org-plot options.  For more information and examples
2656 see the Org-plot tutorial at
2657 @uref{http://orgmode.org/worg/org-tutorials/org-plot.php}.
2659 @subsubheading Plot Options
2661 @table @code
2662 @item set
2663 Specify any @command{gnuplot} option to be set when graphing.
2665 @item title
2666 Specify the title of the plot.
2668 @item ind
2669 Specify which column of the table to use as the @code{x} axis.
2671 @item deps
2672 Specify the columns to graph as a Lisp style list, surrounded by parentheses
2673 and separated by spaces for example @code{dep:(3 4)} to graph the third and
2674 fourth columns (defaults to graphing all other columns aside from the @code{ind}
2675 column).
2677 @item type
2678 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
2680 @item with
2681 Specify a @code{with} option to be inserted for every col being plotted
2682 (@eg @code{lines}, @code{points}, @code{boxes}, @code{impulses}, etc...).
2683 Defaults to @code{lines}.
2685 @item file
2686 If you want to plot to a file, specify @code{"@var{path/to/desired/output-file}"}.
2688 @item labels
2689 List of labels to be used for the deps (defaults to the column headers if
2690 they exist).
2692 @item line
2693 Specify an entire line to be inserted in the Gnuplot script.
2695 @item map
2696 When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
2697 flat mapping rather than a @code{3d} slope.
2699 @item timefmt
2700 Specify format of Org-mode timestamps as they will be parsed by Gnuplot.
2701 Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
2703 @item script
2704 If you want total control, you can specify a script file (place the file name
2705 between double-quotes) which will be used to plot.  Before plotting, every
2706 instance of @code{$datafile} in the specified script will be replaced with
2707 the path to the generated data file.  Note: even if you set this option, you
2708 may still want to specify the plot type, as that can impact the content of
2709 the data file.
2710 @end table
2712 @node Hyperlinks, TODO Items, Tables, Top
2713 @chapter Hyperlinks
2714 @cindex hyperlinks
2716 Like HTML, Org provides links inside a file, external links to
2717 other files, Usenet articles, emails, and much more.
2719 @menu
2720 * Link format::                 How links in Org are formatted
2721 * Internal links::              Links to other places in the current file
2722 * External links::              URL-like links to the world
2723 * Handling links::              Creating, inserting and following
2724 * Using links outside Org::     Linking from my C source code?
2725 * Link abbreviations::          Shortcuts for writing complex links
2726 * Search options::              Linking to a specific location
2727 * Custom searches::             When the default search is not enough
2728 @end menu
2730 @node Link format, Internal links, Hyperlinks, Hyperlinks
2731 @section Link format
2732 @cindex link format
2733 @cindex format, of links
2735 Org will recognize plain URL-like links and activate them as
2736 clickable links.  The general link format, however, looks like this:
2738 @example
2739 [[link][description]]       @r{or alternatively}           [[link]]
2740 @end example
2742 @noindent
2743 Once a link in the buffer is complete (all brackets present), Org
2744 will change the display so that @samp{description} is displayed instead
2745 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2746 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2747 which by default is an underlined face.  You can directly edit the
2748 visible part of a link.  Note that this can be either the @samp{link}
2749 part (if there is no description) or the @samp{description} part.  To
2750 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2751 cursor on the link.
2753 If you place the cursor at the beginning or just behind the end of the
2754 displayed text and press @key{BACKSPACE}, you will remove the
2755 (invisible) bracket at that location.  This makes the link incomplete
2756 and the internals are again displayed as plain text.  Inserting the
2757 missing bracket hides the link internals again.  To show the
2758 internal structure of all links, use the menu entry
2759 @code{Org->Hyperlinks->Literal links}.
2761 @node Internal links, External links, Link format, Hyperlinks
2762 @section Internal links
2763 @cindex internal links
2764 @cindex links, internal
2765 @cindex targets, for links
2767 @cindex property, CUSTOM_ID
2768 If the link does not look like a URL, it is considered to be internal in the
2769 current file.  The most important case is a link like
2770 @samp{[[#my-custom-id]]} which will link to the entry with the
2771 @code{CUSTOM_ID} property @samp{my-custom-id}.  Such custom IDs are very good
2772 for HTML export (@pxref{HTML export}) where they produce pretty section
2773 links.  You are responsible yourself to make sure these custom IDs are unique
2774 in a file.
2776 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]}
2777 lead to a text search in the current file.
2779 The link can be followed with @kbd{C-c C-o} when the cursor is on the link,
2780 or with a mouse click (@pxref{Handling links}).  Links to custom IDs will
2781 point to the corresponding headline.  The preferred match for a text link is
2782 a @i{dedicated target}: the same string in double angular brackets.  Targets
2783 may be located anywhere; sometimes it is convenient to put them into a
2784 comment line. For example
2786 @example
2787 # <<My Target>>
2788 @end example
2790 @noindent In HTML export (@pxref{HTML export}), such targets will become
2791 named anchors for direct access through @samp{http} links@footnote{Note that
2792 text before the first headline is usually not exported, so the first such
2793 target should be after the first headline, or in the line directly before the
2794 first headline.}.
2796 If no dedicated target exists, Org will search for the words in the link.  In
2797 the above example the search would be for @samp{my target}.  Links starting
2798 with a star like @samp{*My Target} restrict the search to
2799 headlines@footnote{To insert a link targeting a headline, in-buffer
2800 completion can be used.  Just type a star followed by a few optional letters
2801 into the buffer and press @kbd{M-@key{TAB}}.  All headlines in the current
2802 buffer will be offered as completions.  @xref{Handling links}, for more
2803 commands creating links.}.  When searching, Org mode will first try an
2804 exact match, but then move on to more and more lenient searches.  For
2805 example, the link @samp{[[*My Targets]]} will find any of the following:
2807 @example
2808 ** My targets
2809 ** TODO my targets are bright
2810 ** my 20 targets are
2811 @end example
2814 Following a link pushes a mark onto Org's own mark ring.  You can
2815 return to the previous position with @kbd{C-c &}.  Using this command
2816 several times in direct succession goes back to positions recorded
2817 earlier.
2819 @menu
2820 * Radio targets::               Make targets trigger links in plain text
2821 @end menu
2823 @node Radio targets,  , Internal links, Internal links
2824 @subsection Radio targets
2825 @cindex radio targets
2826 @cindex targets, radio
2827 @cindex links, radio targets
2829 Org can automatically turn any occurrences of certain target names
2830 in normal text into a link.  So without explicitly creating a link, the
2831 text connects to the target radioing its position.  Radio targets are
2832 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2833 Target>>>} causes each occurrence of @samp{my target} in normal text to
2834 become activated as a link.  The Org file is scanned automatically
2835 for radio targets only when the file is first loaded into Emacs.  To
2836 update the target list during editing, press @kbd{C-c C-c} with the
2837 cursor on or at a target.
2839 @node External links, Handling links, Internal links, Hyperlinks
2840 @section External links
2841 @cindex links, external
2842 @cindex external links
2843 @cindex links, external
2844 @cindex Gnus links
2845 @cindex BBDB links
2846 @cindex IRC links
2847 @cindex URL links
2848 @cindex file links
2849 @cindex VM links
2850 @cindex RMAIL links
2851 @cindex WANDERLUST links
2852 @cindex MH-E links
2853 @cindex USENET links
2854 @cindex SHELL links
2855 @cindex Info links
2856 @cindex Elisp links
2858 Org supports links to files, websites, Usenet and email messages,
2859 BBDB database entries and links to both IRC conversations and their
2860 logs.  External links are URL-like locators.  They start with a short
2861 identifying string followed by a colon.  There can be no space after
2862 the colon.  The following list shows examples for each link type.
2864 @example
2865 http://www.astro.uva.nl/~dominik          @r{on the web}
2866 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2867 /home/dominik/images/jupiter.jpg          @r{same as above}
2868 file:papers/last.pdf                      @r{file, relative path}
2869 ./papers/last.pdf                         @r{same as above}
2870 file:projects.org                         @r{another Org file}
2871 file:projects.org::some words             @r{text search in Org file}
2872 file:projects.org::*task title            @r{heading search in Org file}
2873 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
2874 news:comp.emacs                           @r{Usenet link}
2875 mailto:adent@@galaxy.net                   @r{Mail link}
2876 vm:folder                                 @r{VM folder link}
2877 vm:folder#id                              @r{VM message link}
2878 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
2879 wl:folder                                 @r{WANDERLUST folder link}
2880 wl:folder#id                              @r{WANDERLUST message link}
2881 mhe:folder                                @r{MH-E folder link}
2882 mhe:folder#id                             @r{MH-E message link}
2883 rmail:folder                              @r{RMAIL folder link}
2884 rmail:folder#id                           @r{RMAIL message link}
2885 gnus:group                                @r{Gnus group link}
2886 gnus:group#id                             @r{Gnus article link}
2887 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
2888 irc:/irc.com/#emacs/bob                   @r{IRC link}
2889 shell:ls *.org                            @r{A shell command}
2890 elisp:org-agenda                          @r{Interactive Elisp command}
2891 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
2892 @end example
2894 A link should be enclosed in double brackets and may contain a
2895 descriptive text to be displayed instead of the URL (@pxref{Link
2896 format}), for example:
2898 @example
2899 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2900 @end example
2902 @noindent
2903 If the description is a file name or URL that points to an image, HTML
2904 export (@pxref{HTML export}) will inline the image as a clickable
2905 button.  If there is no description at all and the link points to an
2906 image,
2907 that image will be inlined into the exported HTML file.
2909 @cindex square brackets, around links
2910 @cindex plain text external links
2911 Org also finds external links in the normal text and activates them
2912 as links.  If spaces must be part of the link (for example in
2913 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2914 about the end of the link, enclose them in square brackets.
2916 @node Handling links, Using links outside Org, External links, Hyperlinks
2917 @section Handling links
2918 @cindex links, handling
2920 Org provides methods to create a link in the correct syntax, to
2921 insert it into an Org file, and to follow the link.
2923 @table @kbd
2924 @kindex C-c l
2925 @cindex storing links
2926 @item C-c l
2927 Store a link to the current location.  This is a @emph{global} command (you
2928 must create the key binding yourself) which can be used in any buffer to
2929 create a link.  The link will be stored for later insertion into an Org
2930 buffer (see below).  What kind of link will be created depends on the current
2931 buffer:
2933 @b{Org-mode buffers}@*
2934 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
2935 to the target.  Otherwise it points to the current headline, which will also
2936 be the description.
2938 @vindex org-link-to-org-use-id
2939 @cindex property, CUSTOM_ID
2940 @cindex property, ID
2941 If the headline has a @code{CUSTOM_ID} property, a link to this custom ID
2942 will be stored.  In addition or alternatively (depending on the value of
2943 @code{org-link-to-org-use-id}), a globally unique @code{ID} property will be
2944 created and/or used to construct a link.  So using this command in Org
2945 buffers will potentially create two links: a human-readable from the custom
2946 ID, and one that is globally unique and works even if the entry is moved from
2947 file to file.  Later, when inserting the link, you need to decide which one
2948 to use.
2950 @b{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}@*
2951 Pretty much all Emacs mail clients are supported.  The link will point to the
2952 current article, or, in some GNUS buffers, to the group.  The description is
2953 constructed from the author and the subject.
2955 @b{Web browsers: W3 and W3M}@*
2956 Here the link will be the current URL, with the page title as description.
2958 @b{Contacts: BBDB}@*
2959 Links created in a BBDB buffer will point to the current entry.
2961 @b{Chat: IRC}@*
2962 @vindex org-irc-link-to-logs
2963 For IRC links, if you set the variable @code{org-irc-link-to-logs} to
2964 @code{t}, a @samp{file:/} style link to the relevant point in the logs for
2965 the current conversation is created.  Otherwise an @samp{irc:/} style link to
2966 the user/channel/server under the point will be stored.
2968 @b{Other files}@*
2969 For any other files, the link will point to the file, with a search string
2970 (@pxref{Search options}) pointing to the contents of the current line.  If
2971 there is an active region, the selected words will form the basis of the
2972 search string.  If the automatically created link is not working correctly or
2973 accurately enough, you can write custom functions to select the search string
2974 and to do the search for particular file types---see @ref{Custom searches}.
2975 The key binding @kbd{C-c l} is only a suggestion---see @ref{Installation}.
2977 @b{Agenda view}@*
2978 When the cursor is in an agenda view, the created link points to the
2979 entry referenced by the current line.
2982 @kindex C-c C-l
2983 @cindex link completion
2984 @cindex completion, of links
2985 @cindex inserting links
2986 @item C-c C-l
2987 @vindex org-keep-stored-link-after-insertion
2988 Insert a link@footnote{ Note that you don't have to use this command to
2989 insert a link.  Links in Org are plain text, and you can type or paste them
2990 straight into the buffer.  By using this command, the links are automatically
2991 enclosed in double brackets, and you will be asked for the optional
2992 descriptive text.}.  This prompts for a link to be inserted into the buffer.
2993 You can just type a link, using text for an internal link, or one of the link
2994 type prefixes mentioned in the examples above.  The link will be inserted
2995 into the buffer@footnote{After insertion of a stored link, the link will be
2996 removed from the list of stored links.  To keep it in the list later use, use
2997 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2998 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2999 If some text was selected when this command is called, the selected text
3000 becomes the default description.
3002 @b{Inserting stored links}@*
3003 All links stored during the
3004 current session are part of the history for this prompt, so you can access
3005 them with @key{up} and @key{down} (or @kbd{M-p/n}).
3007 @b{Completion support}@* Completion with @key{TAB} will help you to insert
3008 valid link prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
3009 defined through link abbreviations (@pxref{Link abbreviations}).  If you
3010 press @key{RET} after inserting only the @var{prefix}, Org will offer
3011 specific completion support for some link types@footnote{This works by
3012 calling a special function @code{org-PREFIX-complete-link}.}  For
3013 example, if you type @kbd{file @key{RET}}, file name completion (alternative
3014 access: @kbd{C-u C-c C-l}, see below) will be offered, and after @kbd{bbdb
3015 @key{RET}} you can complete contact names.
3016 @kindex C-u C-c C-l
3017 @cindex file name completion
3018 @cindex completion, of file names
3019 @item C-u C-c C-l
3020 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
3021 a file will be inserted and you may use file name completion to select
3022 the name of the file.  The path to the file is inserted relative to the
3023 directory of the current Org file, if the linked file is in the current
3024 directory or in a sub-directory of it, or if the path is written relative
3025 to the current directory using @samp{../}.  Otherwise an absolute path
3026 is used, if possible with @samp{~/} for your home directory.  You can
3027 force an absolute path with two @kbd{C-u} prefixes.
3029 @item C-c C-l @r{(with cursor on existing link)}
3030 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
3031 link and description parts of the link.
3033 @cindex following links
3034 @kindex C-c C-o
3035 @kindex RET
3036 @item C-c C-o @r{or} @key{RET}
3037 @vindex org-file-apps
3038 Open link at point.  This will launch a web browser for URLs (using
3039 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
3040 the corresponding links, and execute the command in a shell link.  When the
3041 cursor is on an internal link, this commands runs the corresponding search.
3042 When the cursor is on a TAG list in a headline, it creates the corresponding
3043 TAGS view.  If the cursor is on a timestamp, it compiles the agenda for that
3044 date.  Furthermore, it will visit text and remote files in @samp{file:} links
3045 with Emacs and select a suitable application for local non-text files.
3046 Classification of files is based on file extension only.  See option
3047 @code{org-file-apps}.  If you want to override the default application and
3048 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
3049 opening in Emacs, use a @kbd{C-u C-u} prefix.@*
3050 If the cursor is on a headline, but not on a link, offer all links in the
3051 headline and entry text.
3053 @kindex mouse-2
3054 @kindex mouse-1
3055 @item mouse-2
3056 @itemx mouse-1
3057 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
3058 would.  Under Emacs 22, @kbd{mouse-1} will also follow a link.
3060 @kindex mouse-3
3061 @item mouse-3
3062 @vindex org-display-internal-link-with-indirect-buffer
3063 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
3064 internal links to be displayed in another window@footnote{See the
3065 variable @code{org-display-internal-link-with-indirect-buffer}}.
3067 @cindex mark ring
3068 @kindex C-c %
3069 @item C-c %
3070 Push the current position onto the mark ring, to be able to return
3071 easily. Commands following an internal link do this automatically.
3073 @cindex links, returning to
3074 @kindex C-c &
3075 @item C-c &
3076 Jump back to a recorded position.  A position is recorded by the
3077 commands following internal links, and by @kbd{C-c %}.  Using this
3078 command several times in direct succession moves through a ring of
3079 previously recorded positions.
3081 @kindex C-c C-x C-n
3082 @kindex C-c C-x C-p
3083 @cindex links, finding next/previous
3084 @item C-c C-x C-n
3085 @itemx C-c C-x C-p
3086 Move forward/backward to the next link in the buffer.  At the limit of
3087 the buffer, the search fails once, and then wraps around.  The key
3088 bindings for this are really too long, you might want to bind this also
3089 to @kbd{C-n} and @kbd{C-p}
3090 @lisp
3091 (add-hook 'org-load-hook
3092   (lambda ()
3093     (define-key 'org-mode-map "\C-n" 'org-next-link)
3094     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
3095 @end lisp
3096 @end table
3098 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
3099 @section Using links outside Org
3101 You can insert and follow links that have Org syntax not only in
3102 Org, but in any Emacs buffer.  For this, you should create two
3103 global commands, like this (please select suitable global keys
3104 yourself):
3106 @lisp
3107 (global-set-key "\C-c L" 'org-insert-link-global)
3108 (global-set-key "\C-c o" 'org-open-at-point-global)
3109 @end lisp
3111 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
3112 @section Link abbreviations
3113 @cindex link abbreviations
3114 @cindex abbreviation, links
3116 Long URLs can be cumbersome to type, and often many similar links are
3117 needed in a document.  For this you can use link abbreviations.  An
3118 abbreviated link looks like this
3120 @example
3121 [[linkword:tag][description]]
3122 @end example
3124 @noindent
3125 @vindex org-link-abbrev-alist
3126 where the tag is optional.  The @i{linkword} must be a word; letter, numbers,
3127 @samp{-}, and @samp{_} are allowed here.  Abbreviations are resolved
3128 according to the information in the variable @code{org-link-abbrev-alist}
3129 that relates the linkwords to replacement text.  Here is an example:
3131 @lisp
3132 @group
3133 (setq org-link-abbrev-alist
3134   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3135     ("google"   . "http://www.google.com/search?q=")
3136     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
3137                    nph-abs_connect?author=%s&db_key=AST")))
3138 @end group
3139 @end lisp
3141 If the replacement text contains the string @samp{%s}, it will be
3142 replaced with the tag.  Otherwise the tag will be appended to the string
3143 in order to create the link.  You may also specify a function that will
3144 be called with the tag as the only argument to create the link.
3146 With the above setting, you could link to a specific bug with
3147 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
3148 @code{[[google:OrgMode]]} and find out what the Org author is
3149 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
3151 If you need special abbreviations just for a single Org buffer, you
3152 can define them in the file with
3154 @cindex #+LINK
3155 @example
3156 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3157 #+LINK: google    http://www.google.com/search?q=%s
3158 @end example
3160 @noindent
3161 In-buffer completion (@pxref{Completion}) can be used after @samp{[} to
3162 complete link abbreviations.  You may also define a function
3163 @code{org-PREFIX-complete-link} that implements special (@eg completion)
3164 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
3165 not accept any arguments, and return the full link with prefix.
3167 @node Search options, Custom searches, Link abbreviations, Hyperlinks
3168 @section Search options in file links
3169 @cindex search option in file links
3170 @cindex file links, searching
3172 File links can contain additional information to make Emacs jump to a
3173 particular location in the file when following a link.  This can be a
3174 line number or a search option after a double@footnote{For backward
3175 compatibility, line numbers can also follow a single colon.} colon. For
3176 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
3177 links}) to a file, it encodes the words in the current line as a search
3178 string that can be used to find this line back later when following the
3179 link with @kbd{C-c C-o}.
3181 Here is the syntax of the different ways to attach a search to a file
3182 link, together with an explanation:
3184 @example
3185 [[file:~/code/main.c::255]]
3186 [[file:~/xx.org::My Target]]
3187 [[file:~/xx.org::*My Target]]
3188 [[file:~/xx.org::/regexp/]]
3189 @end example
3191 @table @code
3192 @item 255
3193 Jump to line 255.
3194 @item My Target
3195 Search for a link target @samp{<<My Target>>}, or do a text search for
3196 @samp{my target}, similar to the search in internal links, see
3197 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
3198 link will become an HTML reference to the corresponding named anchor in
3199 the linked file.
3200 @item *My Target
3201 In an Org file, restrict search to headlines.
3202 @item /regexp/
3203 Do a regular expression search for @code{regexp}.  This uses the Emacs
3204 command @code{occur} to list all matches in a separate window.  If the
3205 target file is in Org mode, @code{org-occur} is used to create a
3206 sparse tree with the matches.
3207 @c If the target file is a directory,
3208 @c @code{grep} will be used to search all files in the directory.
3209 @end table
3211 As a degenerate case, a file link with an empty file name can be used
3212 to search the current file.  For example, @code{[[file:::find me]]} does
3213 a search for @samp{find me} in the current file, just as
3214 @samp{[[find me]]} would.
3216 @node Custom searches,  , Search options, Hyperlinks
3217 @section Custom Searches
3218 @cindex custom search strings
3219 @cindex search strings, custom
3221 The default mechanism for creating search strings and for doing the
3222 actual search related to a file link may not work correctly in all
3223 cases.  For example, Bib@TeX{} database files have many entries like
3224 @samp{year="1993"} which would not result in good search strings,
3225 because the only unique identification for a Bib@TeX{} entry is the
3226 citation key.
3228 @vindex org-create-file-search-functions
3229 @vindex org-execute-file-search-functions
3230 If you come across such a problem, you can write custom functions to set
3231 the right search string for a particular file type, and to do the search
3232 for the string in the file.  Using @code{add-hook}, these functions need
3233 to be added to the hook variables
3234 @code{org-create-file-search-functions} and
3235 @code{org-execute-file-search-functions}.  See the docstring for these
3236 variables for more information.  Org actually uses this mechanism
3237 for Bib@TeX{} database files, and you can use the corresponding code as
3238 an implementation example.  See the file @file{org-bibtex.el}.
3240 @node TODO Items, Tags, Hyperlinks, Top
3241 @chapter TODO Items
3242 @cindex TODO items
3244 Org mode does not maintain TODO lists as separate documents@footnote{Of
3245 course, you can make a document that contains only long lists of TODO items,
3246 but this is not required.}.  Instead, TODO items are an integral part of the
3247 notes file, because TODO items usually come up while taking notes!  With Org
3248 mode, simply mark any entry in a tree as being a TODO item.  In this way,
3249 information is not duplicated, and the entire context from which the TODO
3250 item emerged is always present.
3252 Of course, this technique for managing TODO items scatters them
3253 throughout your notes file.  Org mode compensates for this by providing
3254 methods to give you an overview of all the things that you have to do.
3256 @menu
3257 * TODO basics::                 Marking and displaying TODO entries
3258 * TODO extensions::             Workflow and assignments
3259 * Progress logging::            Dates and notes for progress
3260 * Priorities::                  Some things are more important than others
3261 * Breaking down tasks::         Splitting a task into manageable pieces
3262 * Checkboxes::                  Tick-off lists
3263 @end menu
3265 @node TODO basics, TODO extensions, TODO Items, TODO Items
3266 @section Basic TODO functionality
3268 Any headline becomes a TODO item when it starts with the word
3269 @samp{TODO}, for example:
3271 @example
3272 *** TODO Write letter to Sam Fortune
3273 @end example
3275 @noindent
3276 The most important commands to work with TODO entries are:
3278 @table @kbd
3279 @kindex C-c C-t
3280 @cindex cycling, of TODO states
3281 @item C-c C-t
3282 Rotate the TODO state of the current item among
3284 @example
3285 ,-> (unmarked) -> TODO -> DONE --.
3286 '--------------------------------'
3287 @end example
3289 The same rotation can also be done ``remotely'' from the timeline and
3290 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
3292 @kindex C-u C-c C-t
3293 @item C-u C-c C-t
3294 Select a specific keyword using completion or (if it has been set up)
3295 the fast selection interface.  For the latter, you need to assign keys
3296 to TODO states, see @ref{Per-file keywords}, and @ref{Setting tags}, for
3297 more information.
3299 @kindex S-@key{right}
3300 @kindex S-@key{left}
3301 @vindex org-treat-S-cursor-todo-selection-as-state-change
3302 @item S-@key{right}
3303 @itemx S-@key{left}
3304 Select the following/preceding TODO state, similar to cycling.  Useful
3305 mostly if more than two TODO states are possible (@pxref{TODO
3306 extensions}).  See also @ref{Conflicts}, for a discussion of the interaction
3307 with @code{shift-selection-mode}.  See also the variable
3308 @code{org-treat-S-cursor-todo-selection-as-state-change}.
3309 @kindex C-c C-v
3310 @kindex C-c / t
3311 @cindex sparse tree, for TODO
3312 @item C-c C-v
3313 @itemx C-c / t
3314 @vindex org-todo-keywords
3315 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
3316 entire buffer, but shows all TODO items and the headings hierarchy above
3317 them.  With a prefix argument, search for a specific TODO.  You will be
3318 prompted for the keyword, and you can also give a list of keywords like
3319 @code{KWD1|KWD2|...} to list entries that match any one of these keywords.
3320 With numeric prefix argument N, show the tree for the Nth keyword in the
3321 variable @code{org-todo-keywords}.  With two prefix arguments, find all TODO
3322 and DONE entries.
3323 @kindex C-c a t
3324 @item C-c a t
3325 Show the global TODO list.  Collects the TODO items from all agenda
3326 files (@pxref{Agenda Views}) into a single buffer.  The new buffer will
3327 be in @code{agenda-mode}, which provides commands to examine and
3328 manipulate the TODO entries from the new buffer (@pxref{Agenda
3329 commands}).  @xref{Global TODO list}, for more information.
3330 @kindex S-M-@key{RET}
3331 @item S-M-@key{RET}
3332 Insert a new TODO entry below the current one.
3333 @end table
3335 @noindent
3336 @vindex org-todo-state-tags-triggers
3337 Changing a TODO state can also trigger tag changes.  See the docstring of the
3338 option @code{org-todo-state-tags-triggers} for details.
3340 @node TODO extensions, Progress logging, TODO basics, TODO Items
3341 @section Extended use of TODO keywords
3342 @cindex extended TODO keywords
3344 @vindex org-todo-keywords
3345 By default, marked TODO entries have one of only two states: TODO and
3346 DONE.  Org mode allows you to classify TODO items in more complex ways
3347 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
3348 special setup, the TODO keyword system can work differently in different
3349 files.
3351 Note that @i{tags} are another way to classify headlines in general and
3352 TODO items in particular (@pxref{Tags}).
3354 @menu
3355 * Workflow states::             From TODO to DONE in steps
3356 * TODO types::                  I do this, Fred does the rest
3357 * Multiple sets in one file::   Mixing it all, and still finding your way
3358 * Fast access to TODO states::  Single letter selection of a state
3359 * Per-file keywords::           Different files, different requirements
3360 * Faces for TODO keywords::     Highlighting states
3361 * TODO dependencies::           When one task needs to wait for others
3362 @end menu
3364 @node Workflow states, TODO types, TODO extensions, TODO extensions
3365 @subsection TODO keywords as workflow states
3366 @cindex TODO workflow
3367 @cindex workflow states as TODO keywords
3369 You can use TODO keywords to indicate different @emph{sequential} states
3370 in the process of working on an item, for example@footnote{Changing
3371 this variable only becomes effective after restarting Org mode in a
3372 buffer.}:
3374 @lisp
3375 (setq org-todo-keywords
3376   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3377 @end lisp
3379 The vertical bar separates the TODO keywords (states that @emph{need
3380 action}) from the DONE states (which need @emph{no further action}).  If
3381 you don't provide the separator bar, the last state is used as the DONE
3382 state.
3383 @cindex completion, of TODO keywords
3384 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
3385 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
3386 also use a numeric prefix argument to quickly select a specific state.  For
3387 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
3388 Or you can use @kbd{S-@key{left}} to go backward through the sequence.  If you
3389 define many keywords, you can use in-buffer completion
3390 (@pxref{Completion}) or even a special one-key selection scheme
3391 (@pxref{Fast access to TODO states}) to insert these words into the
3392 buffer.  Changing a TODO state can be logged with a timestamp, see
3393 @ref{Tracking TODO state changes}, for more information.
3395 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
3396 @subsection TODO keywords as types
3397 @cindex TODO types
3398 @cindex names as TODO keywords
3399 @cindex types as TODO keywords
3401 The second possibility is to use TODO keywords to indicate different
3402 @emph{types} of action items.  For example, you might want to indicate
3403 that items are for ``work'' or ``home''.  Or, when you work with several
3404 people on a single project, you might want to assign action items
3405 directly to persons, by using their names as TODO keywords.  This would
3406 be set up like this:
3408 @lisp
3409 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3410 @end lisp
3412 In this case, different keywords do not indicate a sequence, but rather
3413 different types.  So the normal work flow would be to assign a task to a
3414 person, and later to mark it DONE.  Org mode supports this style by adapting
3415 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
3416 @kbd{t} command in the timeline and agenda buffers.}.  When used several
3417 times in succession, it will still cycle through all names, in order to first
3418 select the right type for a task.  But when you return to the item after some
3419 time and execute @kbd{C-c C-t} again, it will switch from any name directly
3420 to DONE.  Use prefix arguments or completion to quickly select a specific
3421 name.  You can also review the items of a specific TODO type in a sparse tree
3422 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
3423 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
3424 from all agenda files into a single buffer, you would use the numeric prefix
3425 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
3427 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
3428 @subsection Multiple keyword sets in one file
3429 @cindex TODO keyword sets
3431 Sometimes you may want to use different sets of TODO keywords in
3432 parallel.  For example, you may want to have the basic
3433 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
3434 separate state indicating that an item has been canceled (so it is not
3435 DONE, but also does not require action).  Your setup would then look
3436 like this:
3438 @lisp
3439 (setq org-todo-keywords
3440       '((sequence "TODO" "|" "DONE")
3441         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3442         (sequence "|" "CANCELED")))
3443 @end lisp
3445 The keywords should all be different, this helps Org mode to keep track
3446 of which subsequence should be used for a given entry.  In this setup,
3447 @kbd{C-c C-t} only operates within a subsequence, so it switches from
3448 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
3449 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
3450 select the correct sequence.  Besides the obvious ways like typing a
3451 keyword or using completion, you may also apply the following commands:
3453 @table @kbd
3454 @kindex C-S-@key{right}
3455 @kindex C-S-@key{left}
3456 @kindex C-u C-u C-c C-t
3457 @item C-u C-u C-c C-t
3458 @itemx C-S-@key{right}
3459 @itemx C-S-@key{left}
3460 These keys jump from one TODO subset to the next.  In the above example,
3461 @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{right}} would jump from @code{TODO} or
3462 @code{DONE} to @code{REPORT}, and any of the words in the second row to
3463 @code{CANCELED}.  Note that the @kbd{C-S-} key binding conflict with
3464 @code{shift-selection-mode} (@pxref{Conflicts}).
3465 @kindex S-@key{right}
3466 @kindex S-@key{left}
3467 @item S-@key{right}
3468 @itemx S-@key{left}
3469 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through @emph{all}
3470 keywords from all sets, so for example @kbd{S-@key{<right>}} would switch
3471 from @code{DONE} to @code{REPORT} in the example above.  See also
3472 @ref{Conflicts}, for a discussion of the interaction with
3473 @code{shift-selection-mode}.
3474 @end table
3476 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
3477 @subsection Fast access to TODO states
3479 If you would like to quickly change an entry to an arbitrary TODO state
3480 instead of cycling through the states, you can set up keys for
3481 single-letter access to the states.  This is done by adding the section
3482 key after each keyword, in parentheses.  For example:
3484 @lisp
3485 (setq org-todo-keywords
3486       '((sequence "TODO(t)" "|" "DONE(d)")
3487         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3488         (sequence "|" "CANCELED(c)")))
3489 @end lisp
3491 @vindex org-fast-tag-selection-include-todo
3492 If you then press @code{C-c C-t} followed by the selection key, the entry
3493 will be switched to this state.  @key{SPC} can be used to remove any TODO
3494 keyword from an entry.@footnote{Check also the variable
3495 @code{org-fast-tag-selection-include-todo}, it allows you to change the TODO
3496 state through the tags interface (@pxref{Setting tags}), in case you like to
3497 mingle the two concepts.  Note that this means you need to come up with
3498 unique keys across both sets of keywords.}
3500 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
3501 @subsection Setting up keywords for individual files
3502 @cindex keyword options
3503 @cindex per-file keywords
3504 @cindex #+TODO
3505 @cindex #+TYP_TODO
3506 @cindex #+SEQ_TODO
3508 It can be very useful to use different aspects of the TODO mechanism in
3509 different files.  For file-local settings, you need to add special lines
3510 to the file which set the keywords and interpretation for that file
3511 only.  For example, to set one of the two examples discussed above, you
3512 need one of the following lines, starting in column zero anywhere in the
3513 file:
3515 @example
3516 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3517 @end example
3518 @noindent (you may also write @code{#+SEQ_TODO} to be explicit about the
3519 interpretation, but it means the same as @code{#+TODO}), or
3520 @example
3521 #+TYP_TODO: Fred Sara Lucy Mike | DONE
3522 @end example
3524 A setup for using several sets in parallel would be:
3526 @example
3527 #+TODO: TODO | DONE
3528 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
3529 #+TODO: | CANCELED
3530 @end example
3532 @cindex completion, of option keywords
3533 @kindex M-@key{TAB}
3534 @noindent To make sure you are using the correct keyword, type
3535 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
3537 @cindex DONE, final TODO keyword
3538 Remember that the keywords after the vertical bar (or the last keyword
3539 if no bar is there) must always mean that the item is DONE (although you
3540 may use a different word).  After changing one of these lines, use
3541 @kbd{C-c C-c} with the cursor still in the line to make the changes
3542 known to Org mode@footnote{Org mode parses these lines only when
3543 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
3544 cursor in a line starting with @samp{#+} is simply restarting Org mode
3545 for the current buffer.}.
3547 @node Faces for TODO keywords, TODO dependencies, Per-file keywords, TODO extensions
3548 @subsection Faces for TODO keywords
3549 @cindex faces, for TODO keywords
3551 @vindex org-todo @r{(face)}
3552 @vindex org-done @r{(face)}
3553 @vindex org-todo-keyword-faces
3554 Org mode highlights TODO keywords with special faces: @code{org-todo}
3555 for keywords indicating that an item still has to be acted upon, and
3556 @code{org-done} for keywords indicating that an item is finished.  If
3557 you are using more than 2 different states, you might want to use
3558 special faces for some of them.  This can be done using the variable
3559 @code{org-todo-keyword-faces}.  For example:
3561 @lisp
3562 @group
3563 (setq org-todo-keyword-faces
3564       '(("TODO"      . org-warning)
3565         ("DEFERRED"  . shadow)
3566         ("CANCELED"  . (:foreground "blue" :weight bold))))
3567 @end group
3568 @end lisp
3570 While using a list with face properties as shown for CANCELED
3571 @emph{should} work, this does not aways seem to be the case.  If
3572 necessary, define a special face and use that.
3574 @node TODO dependencies,  , Faces for TODO keywords, TODO extensions
3575 @subsection TODO dependencies
3576 @cindex TODO dependencies
3577 @cindex dependencies, of TODO states
3579 @vindex org-enforce-todo-dependencies
3580 @cindex property, ORDERED
3581 The structure of Org files (hierarchy and lists) makes it easy to define TODO
3582 dependencies.  Usually, a parent TODO task should not be marked DONE until
3583 all subtasks (defined as children tasks) are marked as DONE.  And sometimes
3584 there is a logical sequence to a number of (sub)tasks, so that one task
3585 cannot be acted upon before all siblings above it are done.  If you customize
3586 the variable @code{org-enforce-todo-dependencies}, Org will block entries
3587 from changing state to DONE while they have children that are not DONE.
3588 Furthermore, if an entry has a property @code{ORDERED}, each of its children
3589 will be blocked until all earlier siblings are marked DONE.  Here is an
3590 example:
3592 @example
3593 * TODO Blocked until (two) is done
3594 ** DONE one
3595 ** TODO two
3597 * Parent
3598   :PROPERTIES:
3599     :ORDERED: t
3600   :END:
3601 ** TODO a
3602 ** TODO b, needs to wait for (a)
3603 ** TODO c, needs to wait for (a) and (b)
3604 @end example
3606 @table @kbd
3607 @kindex C-c C-x o
3608 @item C-c C-x o
3609 @vindex org-track-ordered-property-with-tag
3610 @cindex property, ORDERED
3611 Toggle the @code{ORDERED} property of the current entry.  A property is used
3612 for this behavior because this should be local to the current entry, not
3613 inherited like a tag.  However, if you would like to @i{track} the value of
3614 this property with a tag for better visibility, customize the variable
3615 @code{org-track-ordered-property-with-tag}.
3616 @kindex C-u C-u C-u C-c C-t
3617 @item C-u C-u C-u C-c C-t
3618 Change TODO state, circumventing any state blocking.
3619 @end table
3621 @vindex org-agenda-dim-blocked-tasks
3622 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
3623 that cannot be closed because of such dependencies will be shown in a dimmed
3624 font or even made invisible in agenda views (@pxref{Agenda Views}).
3626 @cindex checkboxes and TODO dependencies
3627 @vindex org-enforce-todo-dependencies
3628 You can also block changes of TODO states by looking at checkboxes
3629 (@pxref{Checkboxes}).  If you set the variable
3630 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
3631 checkboxes will be blocked from switching to DONE.
3633 If you need more complex dependency structures, for example dependencies
3634 between entries in different trees or files, check out the contributed
3635 module @file{org-depend.el}.
3637 @page
3638 @node Progress logging, Priorities, TODO extensions, TODO Items
3639 @section Progress logging
3640 @cindex progress logging
3641 @cindex logging, of progress
3643 Org mode can automatically record a timestamp and possibly a note when
3644 you mark a TODO item as DONE, or even each time you change the state of
3645 a TODO item.  This system is highly configurable, settings can be on a
3646 per-keyword basis and can be localized to a file or even a subtree.  For
3647 information on how to clock working time for a task, see @ref{Clocking
3648 work time}.
3650 @menu
3651 * Closing items::               When was this entry marked DONE?
3652 * Tracking TODO state changes::  When did the status change?
3653 @end menu
3655 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3656 @subsection Closing items
3658 The most basic logging is to keep track of @emph{when} a certain TODO
3659 item was finished.  This is achieved with@footnote{The corresponding
3660 in-buffer setting is: @code{#+STARTUP: logdone}}.
3662 @lisp
3663 (setq org-log-done 'time)
3664 @end lisp
3666 @noindent
3667 Then each time you turn an entry from a TODO (not-done) state into any
3668 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3669 just after the headline.  If you turn the entry back into a TODO item
3670 through further state cycling, that line will be removed again.  If you
3671 want to record a note along with the timestamp, use@footnote{The
3672 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3674 @lisp
3675 (setq org-log-done 'note)
3676 @end lisp
3678 @noindent
3679 You will then be prompted for a note, and that note will be stored below
3680 the entry with a @samp{Closing Note} heading.
3682 In the timeline (@pxref{Timeline}) and in the agenda
3683 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3684 display the TODO items with a @samp{CLOSED} timestamp on each day,
3685 giving you an overview of what has been done.
3687 @node Tracking TODO state changes,  , Closing items, Progress logging
3688 @subsection Tracking TODO state changes
3689 @cindex drawer, for state change recording
3691 @vindex org-log-states-order-reversed
3692 @vindex org-log-into-drawer
3693 @cindex property, LOG_INTO_DRAWER
3694 When TODO keywords are used as workflow states (@pxref{Workflow states}), you
3695 might want to keep track of when a state change occurred and maybe take a
3696 note about this change.  You can either record just a timestamp, or a
3697 time-stamped note for a change.  These records will be inserted after the
3698 headline as an itemized list, newest first@footnote{See the variable
3699 @code{org-log-states-order-reversed}}.  When taking a lot of notes, you might
3700 want to get the notes out of the way into a drawer (@pxref{Drawers}).
3701 Customize the variable @code{org-log-into-drawer} to get this
3702 behavior---the recommended drawer for this is called @code{LOGBOOK}.  You can
3703 also overrule the setting of this variable for a subtree by setting a
3704 @code{LOG_INTO_DRAWER} property.
3706 Since it is normally too much to record a note for every state, Org mode
3707 expects configuration on a per-keyword basis for this.  This is achieved by
3708 adding special markers @samp{!} (for a timestamp) and @samp{@@} (for a note)
3709 in parentheses after each keyword.  For example, with the setting
3711 @lisp
3712 (setq org-todo-keywords
3713   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3714 @end lisp
3716 @noindent
3717 @vindex org-log-done
3718 you not only define global TODO keywords and fast access keys, but also
3719 request that a time is recorded when the entry is set to
3720 DONE@footnote{It is possible that Org mode will record two timestamps
3721 when you are using both @code{org-log-done} and state change logging.
3722 However, it will never prompt for two notes---if you have configured
3723 both, the state change recording note will take precedence and cancel
3724 the @samp{Closing Note}.}, and that a note is recorded when switching to
3725 WAIT or CANCELED.  The setting for WAIT is even more special: the
3726 @samp{!} after the slash means that in addition to the note taken when
3727 entering the state, a timestamp should be recorded when @i{leaving} the
3728 WAIT state, if and only if the @i{target} state does not configure
3729 logging for entering it.  So it has no effect when switching from WAIT
3730 to DONE, because DONE is configured to record a timestamp only.  But
3731 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3732 setting now triggers a timestamp even though TODO has no logging
3733 configured.
3735 You can use the exact same syntax for setting logging preferences local
3736 to a buffer:
3737 @example
3738 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3739 @end example
3741 @cindex property, LOGGING
3742 In order to define logging settings that are local to a subtree or a
3743 single item, define a LOGGING property in this entry.  Any non-empty
3744 LOGGING property resets all logging settings to nil.  You may then turn
3745 on logging for this specific tree using STARTUP keywords like
3746 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3747 settings like @code{TODO(!)}.  For example
3749 @example
3750 * TODO Log each state with only a time
3751   :PROPERTIES:
3752   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3753   :END:
3754 * TODO Only log when switching to WAIT, and when repeating
3755   :PROPERTIES:
3756   :LOGGING: WAIT(@@) logrepeat
3757   :END:
3758 * TODO No logging at all
3759   :PROPERTIES:
3760   :LOGGING: nil
3761   :END:
3762 @end example
3764 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3765 @section Priorities
3766 @cindex priorities
3768 If you use Org mode extensively, you may end up enough TODO items that
3769 it starts to make sense to prioritize them.  Prioritizing can be done by
3770 placing a @emph{priority cookie} into the headline of a TODO item, like
3771 this
3773 @example
3774 *** TODO [#A] Write letter to Sam Fortune
3775 @end example
3777 @noindent
3778 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
3779 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3780 is treated as priority @samp{B}.  Priorities make a difference only in
3781 the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have
3782 no inherent meaning to Org mode.
3784 Priorities can be attached to any outline tree entries; they do not need
3785 to be TODO items.
3787 @table @kbd
3788 @kindex @kbd{C-c ,}
3789 @item @kbd{C-c ,}
3790 Set the priority of the current headline.  The command prompts for a
3791 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3792 @key{SPC} instead, the priority cookie is removed from the headline.
3793 The priorities can also be changed ``remotely'' from the timeline and
3794 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3796 @kindex S-@key{up}
3797 @kindex S-@key{down}
3798 @item S-@key{up}
3799 @itemx S-@key{down}
3800 @vindex org-priority-start-cycle-with-default
3801 Increase/decrease priority of current headline@footnote{See also the option
3802 @code{org-priority-start-cycle-with-default}.}.  Note that these keys are
3803 also used to modify timestamps (@pxref{Creating timestamps}).  See also
3804 @ref{Conflicts}, for a discussion of the interaction with
3805 @code{shift-selection-mode}.
3806 @end table
3808 @vindex org-highest-priority
3809 @vindex org-lowest-priority
3810 @vindex org-default-priority
3811 You can change the range of allowed priorities by setting the variables
3812 @code{org-highest-priority}, @code{org-lowest-priority}, and
3813 @code{org-default-priority}.  For an individual buffer, you may set
3814 these values (highest, lowest, default) like this (please make sure that
3815 the highest priority is earlier in the alphabet than the lowest
3816 priority):
3818 @cindex #+PRIORITIES
3819 @example
3820 #+PRIORITIES: A C B
3821 @end example
3823 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3824 @section Breaking tasks down into subtasks
3825 @cindex tasks, breaking down
3826 @cindex statistics, for TODO items
3828 @vindex org-agenda-todo-list-sublevels
3829 It is often advisable to break down large tasks into smaller, manageable
3830 subtasks.  You can do this by creating an outline tree below a TODO item,
3831 with detailed subtasks on the tree@footnote{To keep subtasks out of the
3832 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
3833 the overview over the fraction of subtasks that are already completed, insert
3834 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
3835 be updates each time the todo status of a child changes, or when pressing
3836 @kbd{C-c C-c} on the cookie.  For example:
3838 @example
3839 * Organize Party [33%]
3840 ** TODO Call people [1/2]
3841 *** TODO Peter
3842 *** DONE Sarah
3843 ** TODO Buy food
3844 ** DONE Talk to neighbor
3845 @end example
3847 @cindex property, COOKIE_DATA
3848 If a heading has both checkboxes and TODO children below it, the meaning of
3849 the statistics cookie become ambiguous.  Set the property
3850 @code{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve
3851 this issue.
3853 @vindex org-hierarchical-todo-statistics
3854 If you would like to have the statistics cookie count any TODO entries in the
3855 subtree (not just direct children), confgure the variable
3856 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
3857 include the word @samp{recursive} into the value of the @code{COOKIE_DATA}
3858 property.
3860 @example
3861 * Parent capturing statistics [2/20]
3862   :PROPERTIES:
3863   :COOKIE_DATA: todo recursive
3864   :END:
3865 @end example
3867 If you would like a TODO entry to automatically change to DONE
3868 when all children are done, you can use the following setup:
3870 @example
3871 (defun org-summary-todo (n-done n-not-done)
3872   "Switch entry to DONE when all subentries are done, to TODO otherwise."
3873   (let (org-log-done org-log-states)   ; turn off logging
3874     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
3876 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
3877 @end example
3880 Another possibility is the use of checkboxes to identify (a hierarchy of) a
3881 large number of subtasks (@pxref{Checkboxes}).
3884 @node Checkboxes,  , Breaking down tasks, TODO Items
3885 @section Checkboxes
3886 @cindex checkboxes
3888 Every item in a plain list (@pxref{Plain lists}) can be made into a
3889 checkbox by starting it with the string @samp{[ ]}.  This feature is
3890 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3891 Checkboxes are not included into the global TODO list, so they are often
3892 great to split a task into a number of simple steps.  Or you can use
3893 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3894 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3896 Here is an example of a checkbox list.
3898 @example
3899 * TODO Organize party [2/4]
3900   - [-] call people [1/3]
3901     - [ ] Peter
3902     - [X] Sarah
3903     - [ ] Sam
3904   - [X] order food
3905   - [ ] think about what music to play
3906   - [X] talk to the neighbors
3907 @end example
3909 Checkboxes work hierarchically, so if a checkbox item has children that
3910 are checkboxes, toggling one of the children checkboxes will make the
3911 parent checkbox reflect if none, some, or all of the children are
3912 checked.
3914 @cindex statistics, for checkboxes
3915 @cindex checkbox statistics
3916 @cindex property, COOKIE_DATA
3917 @vindex org-hierarchical-checkbox-statistics
3918 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
3919 indicating how many checkboxes present in this entry have been checked off,
3920 and the total number of checkboxes present.  This can give you an idea on how
3921 many checkboxes remain, even without opening a folded entry.  The cookies can
3922 be placed into a headline or into (the first line of) a plain list item.
3923 Each cookie covers checkboxes of direct children structurally below the
3924 headline/item on which the cookie appears@footnote{Set the variable
3925 @code{org-hierarchical-checkbox-statistics} if you want such cookies to
3926 represent the all checkboxes below the cookie, not just the direct
3927 children.}.  You have to insert the cookie yourself by typing either
3928 @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m}
3929 result, as in the examples above.  With @samp{[%]} you get information about
3930 the percentage of checkboxes checked (in the above example, this would be
3931 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can
3932 count either checkboxes below the heading or TODO states of children, and it
3933 will display whatever was changed last.  Set the property @code{COOKIE_DATA}
3934 to either @samp{checkbox} or @samp{todo} to resolve this issue.
3936 @cindex blocking, of checkboxes
3937 @cindex checkbox blocking
3938 @cindex property, ORDERED
3939 If the current outline node has an @code{ORDERED} property, checkboxes must
3940 be checked off in sequence, and an error will be thrown if you try to check
3941 off a box while there are unchecked boxes above it.
3943 @noindent The following commands work with checkboxes:
3945 @table @kbd
3946 @kindex C-c C-c
3947 @item C-c C-c
3948 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
3949 double prefix argument, set it to @samp{[-]}, which is considered to be an
3950 intermediate state.
3951 @kindex C-c C-x C-b
3952 @item C-c C-x C-b
3953 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
3954 double prefix argument, set it to @samp{[-]}, which is considered to be an
3955 intermediate state.
3956 @itemize @minus
3957 @item
3958 If there is an active region, toggle the first checkbox in the region
3959 and set all remaining boxes to the same status as the first.  With a prefix
3960 arg, add or remove the checkbox for all items in the region.
3961 @item
3962 If the cursor is in a headline, toggle checkboxes in the region between
3963 this headline and the next (so @emph{not} the entire subtree).
3964 @item
3965 If there is no active region, just toggle the checkbox at point.
3966 @end itemize
3967 @kindex M-S-@key{RET}
3968 @item M-S-@key{RET}
3969 Insert a new item with a checkbox.
3970 This works only if the cursor is already in a plain list item
3971 (@pxref{Plain lists}).
3972 @kindex C-c C-x o
3973 @item C-c C-x o
3974 @vindex org-track-ordered-property-with-tag
3975 @cindex property, ORDERED
3976 Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
3977 be checked off in sequence.  A property is used for this behavior because
3978 this should be local to the current entry, not inherited like a tag.
3979 However, if you would like to @i{track} the value of this property with a tag
3980 for better visibility, customize the variable
3981 @code{org-track-ordered-property-with-tag}.
3982 @kindex C-c #
3983 @item C-c #
3984 Update the statistics cookie in the current outline entry.  When called with
3985 a @kbd{C-u} prefix, update the entire file.  Checkbox statistic cookies are
3986 updated automatically if you toggle checkboxes with @kbd{C-c C-c} and make
3987 new ones with @kbd{M-S-@key{RET}}.  TODO statistics cookies update when
3988 changing TODO states.  If you delete boxes/entries or add/change them by
3989 hand, use this command to get things back into sync.  Or simply toggle any
3990 entry twice (checkboxes with @kbd{C-c C-c}).
3991 @end table
3993 @node Tags, Properties and Columns, TODO Items, Top
3994 @chapter Tags
3995 @cindex tags
3996 @cindex headline tagging
3997 @cindex matching, tags
3998 @cindex sparse tree, tag based
4000 An excellent way to implement labels and contexts for cross-correlating
4001 information is to assign @i{tags} to headlines.  Org mode has extensive
4002 support for tags.
4004 @vindex org-tag-faces
4005 Every headline can contain a list of tags; they occur at the end of the
4006 headline.  Tags are normal words containing letters, numbers, @samp{_}, and
4007 @samp{@@}.  Tags must be preceded and followed by a single colon, @eg{},
4008 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
4009 Tags will by default be in bold face with the same color as the headline.
4010 You may specify special faces for specific tags using the variable
4011 @code{org-tag-faces}, in much the same way as you can for TODO keywords
4012 (@pxref{Faces for TODO keywords}).
4014 @menu
4015 * Tag inheritance::             Tags use the tree structure of the outline
4016 * Setting tags::                How to assign tags to a headline
4017 * Tag searches::                Searching for combinations of tags
4018 @end menu
4020 @node Tag inheritance, Setting tags, Tags, Tags
4021 @section Tag inheritance
4022 @cindex tag inheritance
4023 @cindex inheritance, of tags
4024 @cindex sublevels, inclusion into tags match
4026 @i{Tags} make use of the hierarchical structure of outline trees.  If a
4027 heading has a certain tag, all subheadings will inherit the tag as
4028 well.  For example, in the list
4030 @example
4031 * Meeting with the French group      :work:
4032 ** Summary by Frank                  :boss:notes:
4033 *** TODO Prepare slides for him      :action:
4034 @end example
4036 @noindent
4037 the final heading will have the tags @samp{:work:}, @samp{:boss:},
4038 @samp{:notes:}, and @samp{:action:} even though the final heading is not
4039 explicitly marked with those tags.  You can also set tags that all entries in
4040 a file should inherit just as if these tags were defined in a hypothetical
4041 level zero that surrounds the entire file.  Use a line like this@footnote{As
4042 with all these in-buffer settings, pressing @kbd{C-c C-c} activates any
4043 changes in the line.}:
4045 @cindex #+FILETAGS
4046 @example
4047 #+FILETAGS: :Peter:Boss:Secret:
4048 @end example
4050 @noindent
4051 @vindex org-use-tag-inheritance
4052 @vindex org-tags-exclude-from-inheritance
4053 To limit tag inheritance to specific tags, or to turn it off entirely, use
4054 the variables @code{org-use-tag-inheritance} and
4055 @code{org-tags-exclude-from-inheritance}.
4057 @vindex org-tags-match-list-sublevels
4058 When a headline matches during a tags search while tag inheritance is turned
4059 on, all the sublevels in the same tree will (for a simple match form) match
4060 as well@footnote{This is only true if the search does not involve more
4061 complex tests including properties (@pxref{Property searches}).}.  The list
4062 of matches may then become very long.  If you only want to see the first tags
4063 match in a subtree, configure the variable
4064 @code{org-tags-match-list-sublevels} (not recommended).
4066 @node Setting tags, Tag searches, Tag inheritance, Tags
4067 @section Setting tags
4068 @cindex setting tags
4069 @cindex tags, setting
4071 @kindex M-@key{TAB}
4072 Tags can simply be typed into the buffer at the end of a headline.
4073 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
4074 also a special command for inserting tags:
4076 @table @kbd
4077 @kindex C-c C-q
4078 @item C-c C-q
4079 @cindex completion, of tags
4080 @vindex org-tags-column
4081 Enter new tags for the current headline.  Org mode will either offer
4082 completion or a special single-key interface for setting tags, see
4083 below.  After pressing @key{RET}, the tags will be inserted and aligned
4084 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
4085 tags in the current buffer will be aligned to that column, just to make
4086 things look nice.  TAGS are automatically realigned after promotion,
4087 demotion, and TODO state changes (@pxref{TODO basics}).
4088 @kindex C-c C-c
4089 @item C-c C-c
4090 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
4091 @end table
4093 @vindex org-tag-alist
4094 Org will support tag insertion based on a @emph{list of tags}.  By
4095 default this list is constructed dynamically, containing all tags
4096 currently used in the buffer.  You may also globally specify a hard list
4097 of tags with the variable @code{org-tag-alist}.  Finally you can set
4098 the default tags for a given file with lines like
4100 @cindex #+TAGS
4101 @example
4102 #+TAGS: @@work @@home @@tennisclub
4103 #+TAGS: laptop car pc sailboat
4104 @end example
4106 If you have globally defined your preferred set of tags using the
4107 variable @code{org-tag-alist}, but would like to use a dynamic tag list
4108 in a specific file, add an empty TAGS option line to that file:
4110 @example
4111 #+TAGS:
4112 @end example
4114 @vindex org-tag-persistent-alist
4115 If you have a preferred set of tags that you would like to use in every file,
4116 in addition to those defined on a per-file basis by TAGS option lines, then
4117 you may specify a list of tags with the variable
4118 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
4119 by adding a STARTUP option line to that file:
4121 @example
4122 #+STARTUP: noptag
4123 @end example
4125 By default Org mode uses the standard minibuffer completion facilities for
4126 entering tags.  However, it also implements another, quicker, tag selection
4127 method called @emph{fast tag selection}.  This allows you to select and
4128 deselect tags with just a single key press.  For this to work well you should
4129 assign unique letters to most of your commonly used tags.  You can do this
4130 globally by configuring the variable @code{org-tag-alist} in your
4131 @file{.emacs} file.  For example, you may find the need to tag many items in
4132 different files with @samp{:@@home:}.  In this case you can set something
4133 like:
4135 @lisp
4136 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
4137 @end lisp
4139 @noindent If the tag is only relevant to the file you are working on, then you
4140 can instead set the TAGS option line as:
4142 @example
4143 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
4144 @end example
4146 @noindent The tags interface will show the available tags in a splash
4147 window.  If you want to start a new line after a specific tag, insert
4148 @samp{\n} into the tag list
4150 @example
4151 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t) \n laptop(l)  pc(p)
4152 @end example
4154 @noindent or write them in two lines:
4156 @example
4157 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
4158 #+TAGS: laptop(l)  pc(p)
4159 @end example
4161 @noindent
4162 You can also group together tags that are mutually exclusive by using
4163 braces, as in:
4165 @example
4166 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
4167 @end example
4169 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
4170 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
4172 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
4173 these lines to activate any changes.
4175 @noindent
4176 To set these mutually exclusive groups in the variable @code{org-tags-alist},
4177 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
4178 of the braces.  Similarly, you can use @code{:newline} to indicate a line
4179 break.  The previous example would be set globally by the following
4180 configuration:
4182 @lisp
4183 (setq org-tag-alist '((:startgroup . nil)
4184                       ("@@work" . ?w) ("@@home" . ?h)
4185                       ("@@tennisclub" . ?t)
4186                       (:endgroup . nil)
4187                       ("laptop" . ?l) ("pc" . ?p)))
4188 @end lisp
4190 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
4191 automatically present you with a special interface, listing inherited tags,
4192 the tags of the current headline, and a list of all valid tags with
4193 corresponding keys@footnote{Keys will automatically be assigned to tags which
4194 have no configured keys.}.  In this interface, you can use the following
4195 keys:
4197 @table @kbd
4198 @item a-z...
4199 Pressing keys assigned to tags will add or remove them from the list of
4200 tags in the current line.  Selecting a tag in a group of mutually
4201 exclusive tags will turn off any other tags from that group.
4202 @kindex @key{TAB}
4203 @item @key{TAB}
4204 Enter a tag in the minibuffer, even if the tag is not in the predefined
4205 list.  You will be able to complete on all tags present in the buffer.
4206 @kindex @key{SPC}
4207 @item @key{SPC}
4208 Clear all tags for this line.
4209 @kindex @key{RET}
4210 @item @key{RET}
4211 Accept the modified set.
4212 @item C-g
4213 Abort without installing changes.
4214 @item q
4215 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
4216 @item !
4217 Turn off groups of mutually exclusive tags.  Use this to (as an
4218 exception) assign several tags from such a group.
4219 @item C-c
4220 Toggle auto-exit after the next change (see below).
4221 If you are using expert mode, the first @kbd{C-c} will display the
4222 selection window.
4223 @end table
4225 @noindent
4226 This method lets you assign tags to a headline with very few keys.  With
4227 the above setup, you could clear the current tags and set @samp{@@home},
4228 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
4229 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
4230 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
4231 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
4232 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
4233 @key{RET} @key{RET}}.
4235 @vindex org-fast-tag-selection-single-key
4236 If you find that most of the time you need only a single key press to
4237 modify your list of tags, set the variable
4238 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
4239 press @key{RET} to exit fast tag selection---it will immediately exit
4240 after the first change.  If you then occasionally need more keys, press
4241 @kbd{C-c} to turn off auto-exit for the current tag selection process
4242 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
4243 C-c}).  If you set the variable to the value @code{expert}, the special
4244 window is not even shown for single-key tag selection, it comes up only
4245 when you press an extra @kbd{C-c}.
4247 @node Tag searches,  , Setting tags, Tags
4248 @section Tag searches
4249 @cindex tag searches
4250 @cindex searching for tags
4252 Once a system of tags has been set up, it can be used to collect related
4253 information into special lists.
4255 @table @kbd
4256 @kindex C-c \
4257 @kindex C-c / m
4258 @item C-c \
4259 @itemx C-c / m
4260 Create a sparse tree with all headlines matching a tags search.  With a
4261 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4262 @kindex C-c a m
4263 @item C-c a m
4264 Create a global list of tag matches from all agenda files.
4265 @xref{Matching tags and properties}.
4266 @kindex C-c a M
4267 @item C-c a M
4268 @vindex org-tags-match-list-sublevels
4269 Create a global list of tag matches from all agenda files, but check
4270 only TODO items and force checking subitems (see variable
4271 @code{org-tags-match-list-sublevels}).
4272 @end table
4274 These commands all prompt for a match string which allows basic Boolean logic
4275 like @samp{+boss+urgent-project1}, to find entries with tags @samp{boss} and
4276 @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find entries
4277 which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of the search
4278 string is rich and allows also matching against TODO keywords, entry levels
4279 and properties.  For a complete description with many examples, see
4280 @ref{Matching tags and properties}.
4283 @node Properties and Columns, Dates and Times, Tags, Top
4284 @chapter Properties and Columns
4285 @cindex properties
4287 Properties are a set of key-value pairs associated with an entry.  There
4288 are two main applications for properties in Org mode.  First, properties
4289 are like tags, but with a value.  Second, you can use properties to
4290 implement (very basic) database capabilities in an Org buffer.  For
4291 an example of the first application, imagine maintaining a file where
4292 you document bugs and plan releases for a piece of software.  Instead of
4293 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
4294 property, say @code{:Release:}, that in different subtrees has different
4295 values, such as @code{1.0} or @code{2.0}.  For an example of the second
4296 application of properties, imagine keeping track of your music CDs,
4297 where properties could be things such as the album, artist, date of
4298 release, number of tracks, and so on.
4300 Properties can be conveniently edited and viewed in column view
4301 (@pxref{Column view}).
4303 @menu
4304 * Property syntax::             How properties are spelled out
4305 * Special properties::          Access to other Org mode features
4306 * Property searches::           Matching property values
4307 * Property inheritance::        Passing values down the tree
4308 * Column view::                 Tabular viewing and editing
4309 * Property API::                Properties for Lisp programmers
4310 @end menu
4312 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
4313 @section Property syntax
4314 @cindex property syntax
4315 @cindex drawer, for properties
4317 Properties are key-value pairs.  They need to be inserted into a special
4318 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
4319 is specified on a single line, with the key (surrounded by colons)
4320 first, and the value after it.  Here is an example:
4322 @example
4323 * CD collection
4324 ** Classic
4325 *** Goldberg Variations
4326     :PROPERTIES:
4327     :Title:     Goldberg Variations
4328     :Composer:  J.S. Bach
4329     :Artist:    Glen Gould
4330     :Publisher: Deutsche Grammophon
4331     :NDisks:    1
4332     :END:
4333 @end example
4335 You may define the allowed values for a particular property @samp{:Xyz:}
4336 by setting a property @samp{:Xyz_ALL:}.  This special property is
4337 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
4338 the entire tree.  When allowed values are defined, setting the
4339 corresponding property becomes easier and is less prone to typing
4340 errors.  For the example with the CD collection, we can predefine
4341 publishers and the number of disks in a box like this:
4343 @example
4344 * CD collection
4345   :PROPERTIES:
4346   :NDisks_ALL:  1 2 3 4
4347   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
4348   :END:
4349 @end example
4351 If you want to set properties that can be inherited by any entry in a
4352 file, use a line like
4353 @cindex property, _ALL
4354 @cindex #+PROPERTY
4355 @example
4356 #+PROPERTY: NDisks_ALL 1 2 3 4
4357 @end example
4359 @vindex org-global-properties
4360 Property values set with the global variable
4361 @code{org-global-properties} can be inherited by all entries in all
4362 Org files.
4364 @noindent
4365 The following commands help to work with properties:
4367 @table @kbd
4368 @kindex M-@key{TAB}
4369 @item M-@key{TAB}
4370 After an initial colon in a line, complete property keys.  All keys used
4371 in the current file will be offered as possible completions.
4372 @kindex C-c C-x p
4373 @item C-c C-x p
4374 Set a property.  This prompts for a property name and a value.  If
4375 necessary, the property drawer is created as well.
4376 @item M-x org-insert-property-drawer
4377 Insert a property drawer into the current entry.  The drawer will be
4378 inserted early in the entry, but after the lines with planning
4379 information like deadlines.
4380 @kindex C-c C-c
4381 @item C-c C-c
4382 With the cursor in a property drawer, this executes property commands.
4383 @item C-c C-c s
4384 Set a property in the current entry.  Both the property and the value
4385 can be inserted using completion.
4386 @kindex S-@key{right}
4387 @kindex S-@key{left}
4388 @item S-@key{left}/@key{right}
4389 Switch property at point to the next/previous allowed value.
4390 @item C-c C-c d
4391 Remove a property from the current entry.
4392 @item C-c C-c D
4393 Globally remove a property, from all entries in the current file.
4394 @item C-c C-c c
4395 Compute the property at point, using the operator and scope from the
4396 nearest column format definition.
4397 @end table
4399 @node Special properties, Property searches, Property syntax, Properties and Columns
4400 @section Special properties
4401 @cindex properties, special
4403 Special properties provide an alternative access method to Org mode
4404 features, like the TODO state or the priority of an entry, discussed in the
4405 previous chapters.  This interface exists so that you can include
4406 these states in a column view (@pxref{Column view}), or to use them in
4407 queries.  The following property names are special and should not be
4408 used as keys in the properties drawer:
4410 @cindex property, special, TODO
4411 @cindex property, special, TAGS
4412 @cindex property, special, ALLTAGS
4413 @cindex property, special, CATEGORY
4414 @cindex property, special, PRIORITY
4415 @cindex property, special, DEADLINE
4416 @cindex property, special, SCHEDULED
4417 @cindex property, special, CLOSED
4418 @cindex property, special, TIMESTAMP
4419 @cindex property, special, TIMESTAMP_IA
4420 @cindex property, special, CLOCKSUM
4421 @c guessing that ITEM is needed in this area; also, should this list be sorted?
4422 @cindex property, special, ITEM
4423 @example
4424 TODO         @r{The TODO keyword of the entry.}
4425 TAGS         @r{The tags defined directly in the headline.}
4426 ALLTAGS      @r{All tags, including inherited ones.}
4427 CATEGORY     @r{The category of an entry.}
4428 PRIORITY     @r{The priority of the entry, a string with a single letter.}
4429 DEADLINE     @r{The deadline time string, without the angular brackets.}
4430 SCHEDULED    @r{The scheduling timestamp, without the angular brackets.}
4431 CLOSED       @r{When was this entry closed?}
4432 TIMESTAMP    @r{The first keyword-less timestamp in the entry.}
4433 TIMESTAMP_IA @r{The first inactive timestamp in the entry.}
4434 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
4435              @r{must be run first to compute the values.}
4436 ITEM         @r{The content of the entry.}
4437 @end example
4439 @node Property searches, Property inheritance, Special properties, Properties and Columns
4440 @section Property searches
4441 @cindex properties, searching
4442 @cindex searching, of properties
4444 To create sparse trees and special lists with selection based on properties,
4445 the same commands are used as for tag searches (@pxref{Tag searches}).
4446 @table @kbd
4447 @kindex C-c \
4448 @kindex C-c / m
4449 @item C-c \
4450 @itemx C-c / m
4451 Create a sparse tree with all matching entries.  With a
4452 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4453 @kindex C-c a m
4454 @item C-c a m
4455 Create a global list of tag/property  matches from all agenda files.
4456 @xref{Matching tags and properties}.
4457 @kindex C-c a M
4458 @item C-c a M
4459 @vindex org-tags-match-list-sublevels
4460 Create a global list of tag matches from all agenda files, but check
4461 only TODO items and force checking of subitems (see variable
4462 @code{org-tags-match-list-sublevels}).
4463 @end table
4465 The syntax for the search string is described in @ref{Matching tags and
4466 properties}.
4468 There is also a special command for creating sparse trees based on a
4469 single property:
4471 @table @kbd
4472 @kindex C-c / p
4473 @item C-c / p
4474 Create a sparse tree based on the value of a property.  This first
4475 prompts for the name of a property, and then for a value.  A sparse tree
4476 is created with all entries that define this property with the given
4477 value.  If you enclose the value into curly braces, it is interpreted as
4478 a regular expression and matched against the property values.
4479 @end table
4481 @node Property inheritance, Column view, Property searches, Properties and Columns
4482 @section Property Inheritance
4483 @cindex properties, inheritance
4484 @cindex inheritance, of properties
4486 @vindex org-use-property-inheritance
4487 The outline structure of Org-mode documents lends itself for an
4488 inheritance model of properties: if the parent in a tree has a certain
4489 property, the children can inherit this property.  Org mode does not
4490 turn this on by default, because it can slow down property searches
4491 significantly and is often not needed.  However, if you find inheritance
4492 useful, you can turn it on by setting the variable
4493 @code{org-use-property-inheritance}.  It may be set to @code{t} to make
4494 all properties inherited from the parent, to a list of properties
4495 that should be inherited, or to a regular expression that matches
4496 inherited properties.
4498 Org mode has a few properties for which inheritance is hard-coded, at
4499 least for the special applications for which they are used:
4501 @cindex property, COLUMNS
4502 @table @code
4503 @item COLUMNS
4504 The @code{:COLUMNS:} property defines the format of column view
4505 (@pxref{Column view}).  It is inherited in the sense that the level
4506 where a @code{:COLUMNS:} property is defined is used as the starting
4507 point for a column view table, independently of the location in the
4508 subtree from where columns view is turned on.
4509 @item CATEGORY
4510 @cindex property, CATEGORY
4511 For agenda view, a category set through a @code{:CATEGORY:} property
4512 applies to the entire subtree.
4513 @item ARCHIVE
4514 @cindex property, ARCHIVE
4515 For archiving, the @code{:ARCHIVE:} property may define the archive
4516 location for the entire subtree (@pxref{Moving subtrees}).
4517 @item LOGGING
4518 @cindex property, LOGGING
4519 The LOGGING property may define logging settings for an entry or a
4520 subtree (@pxref{Tracking TODO state changes}).
4521 @end table
4523 @node Column view, Property API, Property inheritance, Properties and Columns
4524 @section Column view
4526 A great way to view and edit properties in an outline tree is
4527 @emph{column view}.  In column view, each outline node is turned into a
4528 table row.  Columns in this table provide access to properties of the
4529 entries.  Org mode implements columns by overlaying a tabular structure
4530 over the headline of each item.  While the headlines have been turned
4531 into a table row, you can still change the visibility of the outline
4532 tree.  For example, you get a compact table by switching to CONTENTS
4533 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
4534 is active), but you can still open, read, and edit the entry below each
4535 headline.  Or, you can switch to column view after executing a sparse
4536 tree command and in this way get a table only for the selected items.
4537 Column view also works in agenda buffers (@pxref{Agenda Views}) where
4538 queries have collected selected items, possibly from a number of files.
4540 @menu
4541 * Defining columns::            The COLUMNS format property
4542 * Using column view::           How to create and use column view
4543 * Capturing column view::       A dynamic block for column view
4544 @end menu
4546 @node Defining columns, Using column view, Column view, Column view
4547 @subsection Defining columns
4548 @cindex column view, for properties
4549 @cindex properties, column view
4551 Setting up a column view first requires defining the columns.  This is
4552 done by defining a column format line.
4554 @menu
4555 * Scope of column definitions::  Where defined, where valid?
4556 * Column attributes::           Appearance and content of a column
4557 @end menu
4559 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
4560 @subsubsection Scope of column definitions
4562 To define a column format for an entire file, use a line like
4564 @cindex #+COLUMNS
4565 @example
4566 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4567 @end example
4569 To specify a format that only applies to a specific tree, add a
4570 @code{:COLUMNS:} property to the top node of that tree, for example:
4572 @example
4573 ** Top node for columns view
4574    :PROPERTIES:
4575    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4576    :END:
4577 @end example
4579 If a @code{:COLUMNS:} property is present in an entry, it defines columns
4580 for the entry itself, and for the entire subtree below it.  Since the
4581 column definition is part of the hierarchical structure of the document,
4582 you can define columns on level 1 that are general enough for all
4583 sublevels, and more specific columns further down, when you edit a
4584 deeper part of the tree.
4586 @node Column attributes,  , Scope of column definitions, Defining columns
4587 @subsubsection Column attributes
4588 A column definition sets the attributes of a column.  The general
4589 definition looks like this:
4591 @example
4592  %[@var{width}]@var{property}[(@var{title})][@{@var{summary-type}@}]
4593 @end example
4595 @noindent
4596 Except for the percent sign and the property name, all items are
4597 optional.  The individual parts have the following meaning:
4599 @example
4600 @var{width}           @r{An integer specifying the width of the column in characters.}
4601                 @r{If omitted, the width will be determined automatically.}
4602 @var{property}        @r{The property that should be edited in this column.}
4603 (title)         @r{The header text for the column. If omitted, the}
4604                 @r{property name is used.}
4605 @{@var{summary-type}@}  @r{The summary type.  If specified, the column values for}
4606                 @r{parent nodes are computed from the children.}
4607                 @r{Supported summary types are:}
4608                 @{+@}       @r{Sum numbers in this column.}
4609                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
4610                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
4611                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
4612                 @{X@}       @r{Checkbox status, @samp{[X]} if all children are @samp{[X]}.}
4613                 @{X/@}      @r{Checkbox status, @samp{[n/m]}.}
4614                 @{X%@}      @r{Checkbox status, @samp{[n%]}.}
4615                 @{min@}     @r{Smallest number in column.}
4616                 @{max@}     @r{Largest number.}
4617                 @{mean@}    @r{Arithmetic mean of numbers.}
4618                 @{:min@}    @r{Smallest time value in column.}
4619                 @{:max@}    @r{Largest time value.}
4620                 @{:mean@}   @r{Arithmetic mean of time values.}
4621 @end example
4623 @noindent
4624 Here is an example for a complete columns definition, along with allowed
4625 values.
4627 @example
4628 :COLUMNS:  %25ITEM %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.}
4629                    %10Time_Estimate@{:@} %CLOCKSUM
4630 :Owner_ALL:    Tammy Mark Karl Lisa Don
4631 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
4632 :Approved_ALL: "[ ]" "[X]"
4633 @end example
4635 @noindent
4636 The first column, @samp{%25ITEM}, means the first 25 characters of the
4637 item itself, @ie of the headline.  You probably always should start the
4638 column definition with the @samp{ITEM} specifier.  The other specifiers
4639 create columns @samp{Owner} with a list of names as allowed values, for
4640 @samp{Status} with four different possible values, and for a checkbox
4641 field @samp{Approved}.  When no width is given after the @samp{%}
4642 character, the column will be exactly as wide as it needs to be in order
4643 to fully display all values.  The @samp{Approved} column does have a
4644 modified title (@samp{Approved?}, with a question mark).  Summaries will
4645 be created for the @samp{Time_Estimate} column by adding time duration
4646 expressions like HH:MM, and for the @samp{Approved} column, by providing
4647 an @samp{[X]} status if all children have been checked.  The
4648 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
4649 in the subtree.
4651 @node Using column view, Capturing column view, Defining columns, Column view
4652 @subsection Using column view
4654 @table @kbd
4655 @tsubheading{Turning column view on and off}
4656 @kindex C-c C-x C-c
4657 @item C-c C-x C-c
4658 @vindex org-columns-default-format
4659 Turn on column view.  If the cursor is before the first headline in the file,
4660 column view is turned on for the entire file, using the @code{#+COLUMNS}
4661 definition.  If the cusor is somewhere inside the outline, this command
4662 searches the hierarchy, up from point, for a @code{:COLUMNS:} property that
4663 defines a format.  When one is found, the column view table is established
4664 for the tree starting at the entry that contains the @code{:COLUMNS:}
4665 property.  If no such property is found, the format is taken from the
4666 @code{#+COLUMNS} line or from the variable @code{org-columns-default-format},
4667 and column view is established for the current entry and its subtree.
4668 @kindex r
4669 @item r
4670 Recreate the column view, to include recent changes made in the buffer.
4671 @kindex g
4672 @item g
4673 Same as @kbd{r}.
4674 @kindex q
4675 @item q
4676 Exit column view.
4677 @tsubheading{Editing values}
4678 @item @key{left} @key{right} @key{up} @key{down}
4679 Move through the column view from field to field.
4680 @kindex S-@key{left}
4681 @kindex S-@key{right}
4682 @item  S-@key{left}/@key{right}
4683 Switch to the next/previous allowed value of the field.  For this, you
4684 have to have specified allowed values for a property.
4685 @item 1..9,0
4686 Directly select the nth allowed value, @kbd{0} selects the 10th value.
4687 @kindex n
4688 @kindex p
4689 @itemx  n / p
4690 Same as @kbd{S-@key{left}/@key{right}}
4691 @kindex e
4692 @item e
4693 Edit the property at point.  For the special properties, this will
4694 invoke the same interface that you normally use to change that
4695 property.  For example, when editing a TAGS property, the tag completion
4696 or fast selection interface will pop up.
4697 @kindex C-c C-c
4698 @item C-c C-c
4699 When there is a checkbox at point, toggle it.
4700 @kindex v
4701 @item v
4702 View the full value of this property.  This is useful if the width of
4703 the column is smaller than that of the value.
4704 @kindex a
4705 @item a
4706 Edit the list of allowed values for this property.  If the list is found
4707 in the hierarchy, the modified values is stored there.  If no list is
4708 found, the new value is stored in the first entry that is part of the
4709 current column view.
4710 @tsubheading{Modifying the table structure}
4711 @kindex <
4712 @kindex >
4713 @item < / >
4714 Make the column narrower/wider by one character.
4715 @kindex S-M-@key{right}
4716 @item S-M-@key{right}
4717 Insert a new column, to the left of the current column.
4718 @kindex S-M-@key{left}
4719 @item S-M-@key{left}
4720 Delete the current column.
4721 @end table
4723 @node Capturing column view,  , Using column view, Column view
4724 @subsection Capturing column view
4726 Since column view is just an overlay over a buffer, it cannot be
4727 exported or printed directly.  If you want to capture a column view, use
4728 a @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
4729 of this block looks like this:
4731 @cindex #+BEGIN, columnview
4732 @example
4733 * The column view
4734 #+BEGIN: columnview :hlines 1 :id "label"
4736 #+END:
4737 @end example
4739 @noindent This dynamic block has the following parameters:
4741 @table @code
4742 @item :id
4743 This is the most important parameter.  Column view is a feature that is
4744 often localized to a certain (sub)tree, and the capture block might be
4745 at a different location in the file.  To identify the tree whose view to
4746 capture, you can use 4 values:
4747 @cindex property, ID
4748 @example
4749 local     @r{use the tree in which the capture block is located}
4750 global    @r{make a global view, including all headings in the file}
4751 "file:@var{path-to-file}"
4752           @r{run column view at the top of this file}
4753 "@var{ID}"      @r{call column view in the tree that has an @code{:ID:}}
4754           @r{property with the value @i{label}.  You can use}
4755           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
4756           @r{the current entry and copy it to the kill-ring.}
4757 @end example
4758 @item :hlines
4759 When @code{t}, insert an hline after every line.  When a number @var{N}, insert
4760 an hline before each headline with level @code{<= @var{N}}.
4761 @item :vlines
4762 When set to @code{t}, force column groups to get vertical lines.
4763 @item :maxlevel
4764 When set to a number, don't capture entries below this level.
4765 @item :skip-empty-rows
4766 When set to @code{t}, skip rows where the only non-empty specifier of the
4767 column view is @code{ITEM}.
4769 @end table
4771 @noindent
4772 The following commands insert or update the dynamic block:
4774 @table @kbd
4775 @kindex C-c C-x i
4776 @item C-c C-x i
4777 Insert a dynamic block capturing a column view.  You will be prompted
4778 for the scope or ID of the view.
4779 @kindex C-c C-c
4780 @item C-c C-c
4781 @kindex C-c C-x C-u
4782 @itemx C-c C-x C-u
4783 Update dynamic block at point.  The cursor needs to be in the
4784 @code{#+BEGIN} line of the dynamic block.
4785 @kindex C-u C-c C-x C-u
4786 @item C-u C-c C-x C-u
4787 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4788 you have several clock table blocks in a buffer.
4789 @end table
4791 You can add formulas to the column view table and you may add plotting
4792 instructions in front of the table---these will survive an update of the
4793 block.  If there is a @code{#+TBLFM:} after the table, the table will
4794 actually be recalculated automatically after an update.
4796 An alternative way to capture and process property values into a table is
4797 provided by Eric Schulte's @file{org-collector.el} which is a contributed
4798 package@footnote{Contributed packages are not part of Emacs, but are
4799 distributed with the main distribution of Org (visit
4800 @uref{http://orgmode.org}).}.  It provides a general API to collect
4801 properties from entries in a certain scope, and arbitrary Lisp expressions to
4802 process these values before inserting them into a table or a dynamic block.
4804 @node Property API,  , Column view, Properties and Columns
4805 @section The Property API
4806 @cindex properties, API
4807 @cindex API, for properties
4809 There is a full API for accessing and changing properties.  This API can
4810 be used by Emacs Lisp programs to work with properties and to implement
4811 features based on them.  For more information see @ref{Using the
4812 property API}.
4814 @node Dates and Times, Capture, Properties and Columns, Top
4815 @chapter Dates and Times
4816 @cindex dates
4817 @cindex times
4818 @cindex timestamp
4819 @cindex date stamp
4821 To assist project planning, TODO items can be labeled with a date and/or
4822 a time.  The specially formatted string carrying the date and time
4823 information is called a @emph{timestamp} in Org mode.  This may be a
4824 little confusing because timestamp is often used as indicating when
4825 something was created or last changed.  However, in Org mode this term
4826 is used in a much wider sense.
4828 @menu
4829 * Timestamps::                  Assigning a time to a tree entry
4830 * Creating timestamps::         Commands which insert timestamps
4831 * Deadlines and scheduling::    Planning your work
4832 * Clocking work time::          Tracking how long you spend on a task
4833 * Effort estimates::            Planning work effort in advance
4834 * Relative timer::              Notes with a running timer
4835 @end menu
4838 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4839 @section Timestamps, deadlines, and scheduling
4840 @cindex timestamps
4841 @cindex ranges, time
4842 @cindex date stamps
4843 @cindex deadlines
4844 @cindex scheduling
4846 A timestamp is a specification of a date (possibly with a time or a range
4847 of times) in a special format, either @samp{<2003-09-16 Tue>} or
4848 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4849 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
4850 use an alternative format, see @ref{Custom time format}.}.  A timestamp
4851 can appear anywhere in the headline or body of an Org tree entry.  Its
4852 presence causes entries to be shown on specific dates in the agenda
4853 (@pxref{Weekly/daily agenda}).  We distinguish:
4855 @table @var
4856 @item Plain timestamp; Event; Appointment
4857 @cindex timestamp
4858 A simple timestamp just assigns a date/time to an item.  This is just
4859 like writing down an appointment or event in a paper agenda.  In the
4860 timeline and agenda displays, the headline of an entry associated with a
4861 plain timestamp will be shown exactly on that date.
4863 @example
4864 * Meet Peter at the movies <2006-11-01 Wed 19:15>
4865 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
4866 @end example
4868 @item Timestamp with repeater interval
4869 @cindex timestamp, with repeater interval
4870 A timestamp may contain a @emph{repeater interval}, indicating that it
4871 applies not only on the given date, but again and again after a certain
4872 interval of N days (d), weeks (w), months (m), or years (y).  The
4873 following will show up in the agenda every Wednesday:
4875 @example
4876 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4877 @end example
4879 @item Diary-style sexp entries
4880 For more complex date specifications, Org mode supports using the
4881 special sexp diary entries implemented in the Emacs calendar/diary
4882 package.  For example
4884 @example
4885 * The nerd meeting on every 2nd Thursday of the month
4886   <%%(diary-float t 4 2)>
4887 @end example
4889 @item Time/Date range
4890 @cindex timerange
4891 @cindex date range
4892 Two timestamps connected by @samp{--} denote a range.  The headline
4893 will be shown on the first and last day of the range, and on any dates
4894 that are displayed and fall in the range.  Here is an example:
4896 @example
4897 ** Meeting in Amsterdam
4898    <2004-08-23 Mon>--<2004-08-26 Thu>
4899 @end example
4901 @item Inactive timestamp
4902 @cindex timestamp, inactive
4903 @cindex inactive timestamp
4904 Just like a plain timestamp, but with square brackets instead of
4905 angular ones.  These timestamps are inactive in the sense that they do
4906 @emph{not} trigger an entry to show up in the agenda.
4908 @example
4909 * Gillian comes late for the fifth time [2006-11-01 Wed]
4910 @end example
4912 @end table
4914 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
4915 @section Creating timestamps
4916 @cindex creating timestamps
4917 @cindex timestamps, creating
4919 For Org mode to recognize timestamps, they need to be in the specific
4920 format.  All commands listed below produce timestamps in the correct
4921 format.
4923 @table @kbd
4924 @kindex C-c .
4925 @item C-c .
4926 Prompt for a date and insert a corresponding timestamp.  When the cursor is
4927 at an existing timestamp in the buffer, the command is used to modify this
4928 timestamp instead of inserting a new one.  When this command is used twice in
4929 succession, a time range is inserted.
4931 @kindex C-c !
4932 @item C-c !
4933 Like @kbd{C-c .}, but insert an inactive timestamp that will not cause
4934 an agenda entry.
4936 @kindex C-u C-c .
4937 @kindex C-u C-c !
4938 @item C-u C-c .
4939 @itemx C-u C-c !
4940 @vindex org-time-stamp-rounding-minutes
4941 Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
4942 contains date and time.  The default time can be rounded to multiples of 5
4943 minutes, see the option @code{org-time-stamp-rounding-minutes}.
4945 @kindex C-c <
4946 @item C-c <
4947 Insert a timestamp corresponding to the cursor date in the Calendar.
4949 @kindex C-c >
4950 @item C-c >
4951 Access the Emacs calendar for the current date.  If there is a
4952 timestamp in the current line, go to the corresponding date
4953 instead.
4955 @kindex C-c C-o
4956 @item C-c C-o
4957 Access the agenda for the date given by the timestamp or -range at
4958 point (@pxref{Weekly/daily agenda}).
4960 @kindex S-@key{left}
4961 @kindex S-@key{right}
4962 @item S-@key{left}
4963 @itemx S-@key{right}
4964 Change date at cursor by one day.  These key bindings conflict with
4965 shift-selection and related modes (@pxref{Conflicts}).
4967 @kindex S-@key{up}
4968 @kindex S-@key{down}
4969 @item S-@key{up}
4970 @itemx S-@key{down}
4971 Change the item under the cursor in a timestamp.  The cursor can be on a
4972 year, month, day, hour or minute.  When the timestamp contains a time range
4973 like @samp{15:30-16:30}, modifying the first time will also shift the second,
4974 shifting the time block with constant length.  To change the length, modify
4975 the second time.  Note that if the cursor is in a headline and not at a
4976 timestamp, these same keys modify the priority of an item.
4977 (@pxref{Priorities}). The key bindings also conflict with shift-selection and
4978 related modes (@pxref{Conflicts}).
4980 @kindex C-c C-y
4981 @cindex evaluate time range
4982 @item C-c C-y
4983 Evaluate a time range by computing the difference between start and end.
4984 With a prefix argument, insert result after the time range (in a table: into
4985 the following column).
4986 @end table
4989 @menu
4990 * The date/time prompt::        How Org mode helps you entering date and time
4991 * Custom time format::          Making dates look different
4992 @end menu
4994 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
4995 @subsection The date/time prompt
4996 @cindex date, reading in minibuffer
4997 @cindex time, reading in minibuffer
4999 @vindex org-read-date-prefer-future
5000 When Org mode prompts for a date/time, the default is shown as an ISO
5001 date, and the prompt therefore seems to ask for an ISO date.  But it
5002 will in fact accept any string containing some date and/or time
5003 information, and it is really smart about interpreting your input.  You
5004 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
5005 copied from an email message.  Org mode will find whatever information
5006 is in there and derive anything you have not specified from the
5007 @emph{default date and time}.  The default is usually the current date
5008 and time, but when modifying an existing timestamp, or when entering
5009 the second stamp of a range, it is taken from the stamp in the buffer.
5010 When filling in information, Org mode assumes that most of the time you
5011 will want to enter a date in the future: if you omit the month/year and
5012 the given day/month is @i{before} today, it will assume that you mean a
5013 future date@footnote{See the variable
5014 @code{org-read-date-prefer-future}.}.
5016 For example, let's assume that today is @b{June 13, 2006}.  Here is how
5017 various inputs will be interpreted, the items filled in by Org mode are
5018 in @b{bold}.
5020 @example
5021 3-2-5         --> 2003-02-05
5022 14            --> @b{2006}-@b{06}-14
5023 12            --> @b{2006}-@b{07}-12
5024 Fri           --> nearest Friday (defaultdate or later)
5025 sep 15        --> @b{2006}-09-15
5026 feb 15        --> @b{2007}-02-15
5027 sep 12 9      --> 2009-09-12
5028 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
5029 22 sept 0:34  --> @b{2006}-09-22 0:34
5030 w4            --> ISO week for of the current year @b{2006}
5031 2012 w4 fri   --> Friday of ISO week 4 in 2012
5032 2012-w04-5    --> Same as above
5033 @end example
5035 Furthermore you can specify a relative date by giving, as the
5036 @emph{first} thing in the input: a plus/minus sign, a number and a
5037 letter ([dwmy]) to indicate change in days, weeks, months, or years.  With a
5038 single plus or minus, the date is always relative to today.  With a
5039 double plus or minus, it is relative to the default date.  If instead of
5040 a single letter, you use the abbreviation of day name, the date will be
5041 the nth such day.  @Eg
5043 @example
5044 +0            --> today
5045 .             --> today
5046 +4d           --> four days from today
5047 +4            --> same as above
5048 +2w           --> two weeks from today
5049 ++5           --> five days from default date
5050 +2tue         --> second Tuesday from now.
5051 @end example
5053 @vindex parse-time-months
5054 @vindex parse-time-weekdays
5055 The function understands English month and weekday abbreviations.  If
5056 you want to use unabbreviated names and/or other languages, configure
5057 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
5059 @cindex calendar, for selecting date
5060 @vindex org-popup-calendar-for-date-prompt
5061 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
5062 you don't need/want the calendar, configure the variable
5063 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
5064 prompt, either by clicking on a date in the calendar, or by pressing
5065 @key{RET}, the date selected in the calendar will be combined with the
5066 information entered at the prompt.  You can control the calendar fully
5067 from the minibuffer:
5069 @kindex <
5070 @kindex >
5071 @kindex mouse-1
5072 @kindex S-@key{right}
5073 @kindex S-@key{left}
5074 @kindex S-@key{down}
5075 @kindex S-@key{up}
5076 @kindex M-S-@key{right}
5077 @kindex M-S-@key{left}
5078 @kindex @key{RET}
5079 @example
5080 > / <          @r{Scroll calendar forward/backward by one month.}
5081 mouse-1        @r{Select date by clicking on it.}
5082 S-@key{right}/@key{left}     @r{One day forward/backward.}
5083 S-@key{down}/@key{up}     @r{One week forward/backward.}
5084 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
5085 @key{RET}           @r{Choose date in calendar.}
5086 @end example
5088 @vindex org-read-date-display-live
5089 The actions of the date/time prompt may seem complex, but I assure you they
5090 will grow on you, and you will start getting annoyed by pretty much any other
5091 way of entering a date/time out there.  To help you understand what is going
5092 on, the current interpretation of your input will be displayed live in the
5093 minibuffer@footnote{If you find this distracting, turn the display of with
5094 @code{org-read-date-display-live}.}.
5096 @node Custom time format,  , The date/time prompt, Creating timestamps
5097 @subsection Custom time format
5098 @cindex custom date/time format
5099 @cindex time format, custom
5100 @cindex date format, custom
5102 @vindex org-display-custom-times
5103 @vindex org-time-stamp-custom-formats
5104 Org mode uses the standard ISO notation for dates and times as it is
5105 defined in ISO 8601.  If you cannot get used to this and require another
5106 representation of date and time to keep you happy, you can get it by
5107 customizing the variables @code{org-display-custom-times} and
5108 @code{org-time-stamp-custom-formats}.
5110 @table @kbd
5111 @kindex C-c C-x C-t
5112 @item C-c C-x C-t
5113 Toggle the display of custom formats for dates and times.
5114 @end table
5116 @noindent
5117 Org mode needs the default format for scanning, so the custom date/time
5118 format does not @emph{replace} the default format---instead it is put
5119 @emph{over} the default format using text properties.  This has the
5120 following consequences:
5121 @itemize @bullet
5122 @item
5123 You cannot place the cursor onto a timestamp anymore, only before or
5124 after.
5125 @item
5126 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
5127 each component of a timestamp.  If the cursor is at the beginning of
5128 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
5129 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
5130 time will be changed by one minute.
5131 @item
5132 If the timestamp contains a range of clock times or a repeater, these
5133 will not be overlayed, but remain in the buffer as they were.
5134 @item
5135 When you delete a timestamp character-by-character, it will only
5136 disappear from the buffer after @emph{all} (invisible) characters
5137 belonging to the ISO timestamp have been removed.
5138 @item
5139 If the custom timestamp format is longer than the default and you are
5140 using dates in tables, table alignment will be messed up.  If the custom
5141 format is shorter, things do work as expected.
5142 @end itemize
5145 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
5146 @section Deadlines and scheduling
5148 A timestamp may be preceded by special keywords to facilitate planning:
5150 @table @var
5151 @item DEADLINE
5152 @cindex DEADLINE keyword
5154 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
5155 to be finished on that date.
5157 @vindex org-deadline-warning-days
5158 On the deadline date, the task will be listed in the agenda.  In
5159 addition, the agenda for @emph{today} will carry a warning about the
5160 approaching or missed deadline, starting
5161 @code{org-deadline-warning-days} before the due date, and continuing
5162 until the entry is marked DONE.  An example:
5164 @example
5165 *** TODO write article about the Earth for the Guide
5166     The editor in charge is [[bbdb:Ford Prefect]]
5167     DEADLINE: <2004-02-29 Sun>
5168 @end example
5170 You can specify a different lead time for warnings for a specific
5171 deadlines using the following syntax.  Here is an example with a warning
5172 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
5174 @item SCHEDULED
5175 @cindex SCHEDULED keyword
5177 Meaning: you are planning to start working on that task on the given
5178 date.
5180 @vindex org-agenda-skip-scheduled-if-done
5181 The headline will be listed under the given date@footnote{It will still
5182 be listed on that date after it has been marked DONE.  If you don't like
5183 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
5184 addition, a reminder that the scheduled date has passed will be present
5185 in the compilation for @emph{today}, until the entry is marked DONE.
5186 @Ie the task will automatically be forwarded until completed.
5188 @example
5189 *** TODO Call Trillian for a date on New Years Eve.
5190     SCHEDULED: <2004-12-25 Sat>
5191 @end example
5193 @noindent
5194 @b{Important:} Scheduling an item in Org mode should @i{not} be
5195 understood in the same way that we understand @i{scheduling a meeting}.
5196 Setting a date for a meeting is just a simple appointment, you should
5197 mark this entry with a simple plain timestamp, to get this item shown
5198 on the date where it applies.  This is a frequent misunderstanding by
5199 Org users.  In Org mode, @i{scheduling} means setting a date when you
5200 want to start working on an action item.
5201 @end table
5203 You may use timestamps with repeaters in scheduling and deadline
5204 entries.  Org mode will issue early and late warnings based on the
5205 assumption that the timestamp represents the @i{nearest instance} of
5206 the repeater.  However, the use of diary sexp entries like
5208 @code{<%%(diary-float t 42)>}
5210 in scheduling and deadline timestamps is limited.  Org mode does not
5211 know enough about the internals of each sexp function to issue early and
5212 late warnings.  However, it will show the item on each day where the
5213 sexp entry matches.
5215 @menu
5216 * Inserting deadline/schedule::  Planning items
5217 * Repeated tasks::              Items that show up again and again
5218 @end menu
5220 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
5221 @subsection Inserting deadlines or schedules
5223 The following commands allow you to quickly insert a deadline or to schedule
5224 an item:
5226 @table @kbd
5228 @kindex C-c C-d
5229 @item C-c C-d
5230 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
5231 happen in the line directly following the headline.  When called with a
5232 prefix arg, an existing deadline will be removed from the entry.
5233 @c FIXME Any CLOSED timestamp will be removed.????????
5235 @kindex C-c C-s
5236 @item C-c C-s
5237 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
5238 happen in the line directly following the headline.  Any CLOSED
5239 timestamp will be removed.  When called with a prefix argument, remove
5240 the scheduling date from the entry.
5242 @kindex C-c C-x C-k
5243 @kindex k a
5244 @kindex k s
5245 @item C-c C-x C-k
5246 Mark the current entry for agenda action.  After you have marked the entry
5247 like this, you can open the agenda or the calendar to find an appropriate
5248 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
5249 schedule the marked item.
5251 @kindex C-c / d
5252 @cindex sparse tree, for deadlines
5253 @item C-c / d
5254 @vindex org-deadline-warning-days
5255 Create a sparse tree with all deadlines that are either past-due, or
5256 which will become due within @code{org-deadline-warning-days}.
5257 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
5258 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
5259 all deadlines due tomorrow.
5261 @kindex C-c / b
5262 @item C-c / b
5263 Sparse tree for deadlines and scheduled items before a given date.
5265 @kindex C-c / a
5266 @item C-c / a
5267 Sparse tree for deadlines and scheduled items after a given date.
5268 @end table
5270 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
5271 @subsection Repeated tasks
5272 @cindex tasks, repeated
5273 @cindex repeated tasks
5275 Some tasks need to be repeated again and again.  Org mode helps to
5276 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
5277 or plain timestamp.  In the following example
5278 @example
5279 ** TODO Pay the rent
5280    DEADLINE: <2005-10-01 Sat +1m>
5281 @end example
5282 @noindent
5283 the @code{+1m} is a repeater; the intended interpretation is that the task
5284 has a deadline on <2005-10-01> and repeats itself every (one) month starting
5285 from that time.  If you need both a repeater and a special warning period in
5286 a deadline entry, the repeater should come first and the warning period last:
5287 @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
5289 Deadlines and scheduled items produce entries in the agenda when they
5290 are over-due, so it is important to be able to mark such an entry as
5291 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
5292 with the TODO keyword DONE, it will no longer produce entries in the
5293 agenda.  The problem with this is, however, that then also the
5294 @emph{next} instance of the repeated entry will not be active.  Org mode
5295 deals with this in the following way: When you try to mark such an entry
5296 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
5297 timestamp by the repeater interval, and immediately set the entry state
5298 back to TODO.  In the example above, setting the state to DONE would
5299 actually switch the date like this:
5301 @example
5302 ** TODO Pay the rent
5303    DEADLINE: <2005-11-01 Tue +1m>
5304 @end example
5306 @vindex org-log-repeat
5307 A timestamp@footnote{You can change this using the option
5308 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
5309 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
5310 will also be prompted for a note.} will be added under the deadline, to keep
5311 a record that you actually acted on the previous instance of this deadline.
5313 As a consequence of shifting the base date, this entry will no longer be
5314 visible in the agenda when checking past dates, but all future instances
5315 will be visible.
5317 With the @samp{+1m} cookie, the date shift will always be exactly one
5318 month.  So if you have not paid the rent for three months, marking this
5319 entry DONE will still keep it as an overdue deadline.  Depending on the
5320 task, this may not be the best way to handle it.  For example, if you
5321 forgot to call you father for 3 weeks, it does not make sense to call
5322 him 3 times in a single day to make up for it.  Finally, there are tasks
5323 like changing batteries which should always repeat a certain time
5324 @i{after} the last time you did it.  For these tasks, Org mode has
5325 special repeaters markers with @samp{++} and @samp{.+}.  For example:
5327 @example
5328 ** TODO Call Father
5329    DEADLINE: <2008-02-10 Sun ++1w>
5330    Marking this DONE will shift the date by at least one week,
5331    but also by as many weeks as it takes to get this date into
5332    the future.  However, it stays on a Sunday, even if you called
5333    and marked it done on Saturday.
5334 ** TODO Check the batteries in the smoke detectors
5335    DEADLINE: <2005-11-01 Tue .+1m>
5336    Marking this DONE will shift the date to one month after
5337    today.
5338 @end example
5340 You may have both scheduling and deadline information for a specific
5341 task---just make sure that the repeater intervals on both are the same.
5343 An alternative to using a repeater is to create a number of copies of a task
5344 subtree, with dates shifted in each copy.  The command @kbd{C-c C-x c} was
5345 created for this purpose, it is described in @ref{Structure editing}.
5348 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
5349 @section Clocking work time
5351 Org mode allows you to clock the time you spend on specific tasks in a
5352 project.  When you start working on an item, you can start the clock.
5353 When you stop working on that task, or when you mark the task done, the
5354 clock is stopped and the corresponding time interval is recorded.  It
5355 also computes the total time spent on each subtree of a project.
5357 Normally, the clock does not survive exiting and re-entering Emacs, but you
5358 can arrange for the clock information to persist across Emacs sessions with
5360 @lisp
5361 (setq org-clock-persist t)
5362 (org-clock-persistence-insinuate)
5363 @end lisp
5365 @table @kbd
5366 @kindex C-c C-x C-i
5367 @item C-c C-x C-i
5368 @vindex org-clock-into-drawer
5369 Start the clock on the current item (clock-in).  This inserts the CLOCK
5370 keyword together with a timestamp.  If this is not the first clocking of
5371 this item, the multiple CLOCK lines will be wrapped into a
5372 @code{:LOGBOOK:} drawer (see also the variable
5373 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
5374 select the task from a list of recently clocked tasks.  With two @kbd{C-u
5375 C-u} prefixes, clock into the task at point and mark it as the default task.
5376 The default task will always be available when selecting a clocking task,
5377 with letter @kbd{d}.@*
5378 @cindex property: CLOCK_MODELINE_TOTAL
5379 @cindex property: LAST_REPEAT
5380 @vindex org-clock-modeline-total
5381 While the clock is running, the current clocking time is shown in the mode
5382 line, along with the title of the task.  The clock time shown will be all
5383 time ever clocked for this task and its children.  If the task has an effort
5384 estimate (@pxref{Effort estimates}), the mode line displays the current
5385 clocking time against it@footnote{To add an effort estimate ``on the fly'',
5386 hook a function doing this to @code{org-clock-in-prepare-hook}.}  If the task
5387 is a repeating one (@pxref{Repeated tasks}), only the time since the last
5388 reset of the task @footnote{as recorded by the @code{LAST_REPEAT} property}
5389 will be shown.  More control over what time is shown can be exercised with
5390 the @code{CLOCK_MODELINE_TOTAL} property.  It may have the values
5391 @code{current} to show only the current clocking instance, @code{today} to
5392 show all time clocked on this tasks today (see also the variable
5393 @code{org-extend-today-until}), @code{all} to include all time, or
5394 @code{auto} which is the default@footnote{See also the variable
5395 @code{org-clock-modeline-total}.}.@* Clicking with @kbd{mouse-1} onto the
5396 mode line entry will pop up a menu with clocking options.
5397 @kindex C-c C-x C-o
5398 @item C-c C-x C-o
5399 @vindex org-log-note-clock-out
5400 Stop the clock (clock-out).  This inserts another timestamp at the same
5401 location where the clock was last started.  It also directly computes
5402 the resulting time in inserts it after the time range as @samp{=>
5403 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
5404 possibility to record an additional note together with the clock-out
5405 timestamp@footnote{The corresponding in-buffer setting is:
5406 @code{#+STARTUP: lognoteclock-out}}.
5407 @kindex C-c C-x C-e
5408 @item C-c C-x C-e
5409 Update the effort estimate for the current clock task.
5410 @kindex C-c C-y
5411 @kindex C-c C-c
5412 @item C-c C-y @ @ @r{or}@ @ C-c C-c
5413 Recompute the time interval after changing one of the timestamps.  This
5414 is only necessary if you edit the timestamps directly.  If you change
5415 them with @kbd{S-@key{cursor}} keys, the update is automatic.
5416 @kindex C-c C-t
5417 @item C-c C-t
5418 Changing the TODO state of an item to DONE automatically stops the clock
5419 if it is running in this same item.
5420 @kindex C-c C-x C-x
5421 @item C-c C-x C-x
5422 Cancel the current clock.  This is useful if a clock was started by
5423 mistake, or if you ended up working on something else.
5424 @kindex C-c C-x C-j
5425 @item C-c C-x C-j
5426 Jump to the entry that contains the currently running clock.  With a
5427 @kbd{C-u} prefix arg, select the target task from a list of recently clocked
5428 tasks.
5429 @kindex C-c C-x C-d
5430 @item C-c C-x C-d
5431 @vindex org-remove-highlights-with-change
5432 Display time summaries for each subtree in the current buffer.  This
5433 puts overlays at the end of each headline, showing the total time
5434 recorded under that heading, including the time of any subheadings. You
5435 can use visibility cycling to study the tree, but the overlays disappear
5436 when you change the buffer (see variable
5437 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
5438 @kindex C-c C-x C-r
5439 @item C-c C-x C-r
5440 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
5441 report as an Org-mode table into the current file.  When the cursor is
5442 at an existing clock table, just update it.  When called with a prefix
5443 argument, jump to the first clock report in the current document and
5444 update it.
5445 @cindex #+BEGIN, clocktable
5446 @example
5447 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
5448 #+END: clocktable
5449 @end example
5450 @noindent
5451 If such a block already exists at point, its content is replaced by the
5452 new table.  The @samp{BEGIN} line can specify options:
5453 @example
5454 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
5455 :emphasize   @r{When @code{t}, emphasize level one and level two items.}
5456 :scope       @r{The scope to consider.  This can be any of the following:}
5457              nil        @r{the current buffer or narrowed region}
5458              file       @r{the full current buffer}
5459              subtree    @r{the subtree where the clocktable is located}
5460              tree@var{N}      @r{the surrounding level @var{N} tree, for example @code{tree3}}
5461              tree       @r{the surrounding level 1 tree}
5462              agenda     @r{all agenda files}
5463              ("file"..) @r{scan these files}
5464              file-with-archives    @r{current file and its archives}
5465              agenda-with-archives  @r{all agenda files, including archives}
5466 :block       @r{The time block to consider.  This block is specified either}
5467              @r{absolute, or relative to the current time and may be any of}
5468              @r{these formats:}
5469              2007-12-31    @r{New year eve 2007}
5470              2007-12       @r{December 2007}
5471              2007-W50      @r{ISO-week 50 in 2007}
5472              2007          @r{the year 2007}
5473              today, yesterday, today-@var{N}          @r{a relative day}
5474              thisweek, lastweek, thisweek-@var{N}     @r{a relative week}
5475              thismonth, lastmonth, thismonth-@var{N}  @r{a relative month}
5476              thisyear, lastyear, thisyear-@var{N}     @r{a relative year}
5477              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
5478 :tstart      @r{A time string specifying when to start considering times.}
5479 :tend        @r{A time string specifying when to stop considering times.}
5480 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
5481              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
5482 :link        @r{Link the item headlines in the table to their origins.}
5483 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
5484              @r{As a special case, @samp{:formula %} adds a column with % time.}
5485              @r{If you do not specify a formula here, any existing formula.}
5486              @r{below the clock table will survive updates and be evaluated.}
5487 :timestamp   @r{A timestamp for the entry, when available.  Look for SCHEDULED,}
5488              @r{DEADLINE, TIMESTAMP and TIMESTAMP_IA, in this order.}
5489 @end example
5490 To get a clock summary of the current level 1 tree, for the current
5491 day, you could write
5492 @example
5493 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
5494 #+END: clocktable
5495 @end example
5496 @noindent
5497 and to use a specific time range you could write@footnote{Note that all
5498 parameters must be specified in a single line---the line is broken here
5499 only to fit it into the manual.}
5500 @example
5501 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
5502                     :tend "<2006-08-10 Thu 12:00>"
5503 #+END: clocktable
5504 @end example
5505 A summary of the current subtree with % times would be
5506 @example
5507 #+BEGIN: clocktable :scope subtree :link t :formula %
5508 #+END: clocktable
5509 @end example
5510 @kindex C-c C-c
5511 @item C-c C-c
5512 @kindex C-c C-x C-u
5513 @itemx C-c C-x C-u
5514 Update dynamic block at point.  The cursor needs to be in the
5515 @code{#+BEGIN} line of the dynamic block.
5516 @kindex C-u C-c C-x C-u
5517 @item C-u C-c C-x C-u
5518 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
5519 you have several clock table blocks in a buffer.
5520 @kindex S-@key{left}
5521 @kindex S-@key{right}
5522 @item S-@key{left}
5523 @itemx S-@key{right}
5524 Shift the current @code{:block} interval and update the table.  The cursor
5525 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
5526 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
5527 @end table
5529 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
5530 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
5531 worked on or closed during a day.
5533 @node Effort estimates, Relative timer, Clocking work time, Dates and Times
5534 @section Effort estimates
5535 @cindex effort estimates
5537 @cindex property, Effort
5538 @vindex org-effort-property
5539 If you want to plan your work in a very detailed way, or if you need to
5540 produce offers with quotations of the estimated work effort, you may want to
5541 assign effort estimates to entries.  If you are also clocking your work, you
5542 may later want to compare the planned effort with the actual working time, a
5543 great way to improve planning estimates.  Effort estimates are stored in a
5544 special property @samp{Effort}@footnote{You may change the property being
5545 used with the variable @code{org-effort-property}.}.  You can set the effort
5546 for an entry with the following commands:
5548 @table @kbd
5549 @kindex C-c C-x e
5550 @item C-c C-x e
5551 Set the effort estimate for the current entry.  With a numeric prefix
5552 argument, set it to the NTH allowed value (see below).  This command is also
5553 accessible from the agenda with the @kbd{e} key.
5554 @kindex C-c C-x C-e
5555 @item C-c C-x C-e
5556 Modify the effort estimate of the item currently being clocked.
5557 @end table
5559 Clearly the best way to work with effort estimates is through column view
5560 (@pxref{Column view}).  You should start by setting up discrete values for
5561 effort estimates, and a @code{COLUMNS} format that displays these values
5562 together with clock sums (if you want to clock your time).  For a specific
5563 buffer you can use
5565 @example
5566 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
5567 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
5568 @end example
5570 @noindent
5571 @vindex org-global-properties
5572 @vindex org-columns-default-format
5573 or, even better, you can set up these values globally by customizing the
5574 variables @code{org-global-properties} and @code{org-columns-default-format}.
5575 In particular if you want to use this setup also in the agenda, a global
5576 setup may be advised.
5578 The way to assign estimates to individual items is then to switch to column
5579 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
5580 value.  The values you enter will immediately be summed up in the hierarchy.
5581 In the column next to it, any clocked time will be displayed.
5583 @vindex org-agenda-columns-add-appointments-to-effort-sum
5584 If you switch to column view in the daily/weekly agenda, the effort column
5585 will summarize the estimated work effort for each day@footnote{Please note
5586 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
5587 column view}).}, and you can use this to find space in your schedule.  To get
5588 an overview of the entire part of the day that is committed, you can set the
5589 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
5590 appointments on a day that take place over a specified time interval will
5591 then also be added to the load estimate of the day.
5593 Effort estimates can be used in secondary agenda filtering that is triggered
5594 with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
5595 these estimates defined consistently, two or three key presses will narrow
5596 down the list to stuff that fits into an available time slot.
5598 @node Relative timer,  , Effort estimates, Dates and Times
5599 @section Taking notes with a relative timer
5600 @cindex relative timer
5602 When taking notes during, for example, a meeting or a video viewing, it can
5603 be useful to have access to times relative to a starting time.  Org provides
5604 such a relative timer and make it easy to create timed notes.
5606 @table @kbd
5607 @kindex C-c C-x .
5608 @item C-c C-x .
5609 Insert a relative time into the buffer.  The first time you use this, the
5610 timer will be started.  When called with a prefix argument, the timer is
5611 restarted.
5612 @kindex C-c C-x -
5613 @item C-c C-x -
5614 Insert a description list item with the current relative time.  With a prefix
5615 argument, first reset the timer to 0.
5616 @kindex M-@key{RET}
5617 @item M-@key{RET}
5618 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
5619 new timer items.
5620 @kindex C-c C-x ,
5621 @item C-c C-x ,
5622 Pause the timer, or continue it if it is already paused.
5623 @c removed the sentence because it is redundant to the following item
5624 @kindex C-u C-c C-x ,
5625 @item C-u C-c C-x ,
5626 Stop the timer.  After this, you can only start a new timer, not continue the
5627 old one.  This command also removes the timer from the mode line.
5628 @kindex C-c C-x 0
5629 @item C-c C-x 0
5630 Reset the timer without inserting anything into the buffer.  By default, the
5631 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
5632 specific starting offset.  The user is prompted for the offset, with a
5633 default taken from a timer string at point, if any, So this can be used to
5634 restart taking notes after a break in the process.  When called with a double
5635 prefix argument @kbd{C-c C-u}, change all timer strings in the active region
5636 by a certain amount.  This can be used to fix timer strings if the timer was
5637 not started at exactly the right moment.
5638 @end table
5640 @node Capture, Agenda Views, Dates and Times, Top
5641 @chapter Capture
5642 @cindex capture
5644 An important part of any organization system is the ability to quickly
5645 capture new ideas and tasks, and to associate reference material with them.
5646 Org uses the @file{remember.el} package to create tasks, and stores files
5647 related to a task (@i{attachments}) in a special directory.
5649 @menu
5650 * Remember::                    Capture new tasks/ideas with little interruption
5651 * Attachments::                 Add files to tasks.
5652 * RSS Feeds::                   Getting input from RSS feeds
5653 * Protocols::                   External (@eg Browser) access to Emacs and Org
5654 @end menu
5656 @node Remember, Attachments, Capture, Capture
5657 @section Remember
5658 @cindex @file{remember.el}
5660 The Remember package by John Wiegley lets you store quick notes with little
5661 interruption of your work flow.  It is an excellent way to add new notes and
5662 tasks to Org files.  The @code{remember.el} package is part of Emacs 23, not
5663 Emacs 22.  See @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for
5664 more information.
5666 Org significantly expands the possibilities of Remember: you may define
5667 templates for different note types, and associate target files and headlines
5668 with specific templates.  It also allows you to select the location where a
5669 note should be stored interactively, on the fly.
5671 @menu
5672 * Setting up Remember for Org:: Some code for .emacs to get things going
5673 * Remember templates::          Define the outline of different note types
5674 * Storing notes::               Directly get the note to where it belongs
5675 * Refiling notes::              Moving a note or task to a project
5676 @end menu
5678 @node Setting up Remember for Org, Remember templates, Remember, Remember
5679 @subsection Setting up Remember for Org
5681 The following customization will tell Remember to use Org files as
5682 target, and to create annotations compatible with Org links.
5684 @example
5685 (org-remember-insinuate)
5686 (setq org-directory "~/path/to/my/orgfiles/")
5687 (setq org-default-notes-file (concat org-directory "/notes.org"))
5688 (define-key global-map "\C-cr" 'org-remember)
5689 @end example
5691 @noindent
5692 The last line binds the command @code{org-remember} to a global
5693 key@footnote{Please select your own key, @kbd{C-c r} is only a
5694 suggestion.}.  @code{org-remember} basically just calls Remember,
5695 but it makes a few things easier: if there is an active region, it will
5696 automatically copy the region into the Remember buffer.  It also allows
5697 to jump to the buffer and location where Remember notes are being
5698 stored: just call @code{org-remember} with a prefix argument.  If you
5699 use two prefix arguments, Org jumps to the location where the last
5700 remember note was stored.
5702 The Remember buffer will actually use @code{org-mode} as its major mode, so
5703 that all editing features of Org mode are available.  In addition to this, a
5704 minor mode @code{org-remember-mode} is turned on, for the single purpose that
5705 you can use its keymap @code{org-remember-mode-map} to overwrite some of
5706 Org mode's key bindings.
5708 You can also call @code{org-remember} in a special way from the agenda,
5709 using the @kbd{k r} key combination.  With this access, any timestamps
5710 inserted by the selected Remember template (see below) will default to
5711 the cursor date in the agenda, rather than to the current date.
5713 @node Remember templates, Storing notes, Setting up Remember for Org, Remember
5714 @subsection Remember templates
5715 @cindex templates, for Remember
5717 In combination with Org, you can use templates to generate
5718 different types of Remember notes.  For example, if you would like
5719 to use one template to create general TODO entries, another one for
5720 journal entries, and a third one for collecting random ideas, you could
5721 use:
5723 @example
5724 (setq org-remember-templates
5725  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
5726    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
5727    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5728 @end example
5730 @vindex org-remember-default-headline
5731 @vindex org-directory
5732 @noindent In these entries, the first string is just a name, and the
5733 character specifies how to select the template.  It is useful if the
5734 character is also the first letter of the name.  The next string specifies
5735 the template.  Two more (optional) strings give the file in which, and the
5736 headline under which, the new note should be stored.  The file (if not present
5737 or @code{nil}) defaults to @code{org-default-notes-file}, the heading to
5738 @code{org-remember-default-headline}.  If the file name is not an absolute
5739 path, it will be interpreted relative to @code{org-directory}.  The heading
5740 can also be the symbols @code{top} or @code{bottom} to send notes as level 1
5741 entries to the beginning or end of the file, respectively.
5743 An optional sixth element specifies the contexts in which the user can select
5744 the template.  This element can be a list of major modes or a function.
5745 @code{org-remember} will first check whether the function returns @code{t} or
5746 if we are in any of the listed major modes, and exclude templates for which
5747 this condition is not fulfilled.  Templates that do not specify this element
5748 at all, or that use @code{nil} or @code{t} as a value will always be
5749 selectable.
5751 So for example:
5753 @example
5754 (setq org-remember-templates
5755  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
5756    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" "X" my-check)
5757    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5758 @end example
5760 @noindent
5761 The first template will only be available when invoking @code{org-remember}
5762 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
5763 available when the function @code{my-check} returns @code{t}.  The third
5764 template will be proposed in any context.
5766 When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
5767 something, Org will prompt for a key to select the template (if you have
5768 more than one template) and then prepare the buffer like
5769 @example
5770 * TODO
5771   [[file:@var{link to where you called remember}]]
5772 @end example
5774 @noindent
5775 During expansion of the template, special @kbd{%}-escapes@footnote{If you
5776 need one of these sequences literally, escape the @kbd{%} with a backslash.}
5777 allow dynamic insertion of content:
5778 @example
5779 %^@{@var{prompt}@}  @r{prompt the user for a string and replace this sequence with it.}
5780             @r{You may specify a default value and a completion table with}
5781             @r{%^@{prompt|default|completion2|completion3...@}}
5782             @r{The arrow keys access a prompt-specific history.}
5783 %a          @r{annotation, normally the link created with @code{org-store-link}}
5784 %A          @r{like @code{%a}, but prompt for the description part}
5785 %i          @r{initial content, the region when remember is called with C-u.}
5786             @r{The entire text will be indented like @code{%i} itself.}
5787 %t          @r{timestamp, date only}
5788 %T          @r{timestamp with date and time}
5789 %u, %U      @r{like the above, but inactive timestamps}
5790 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
5791             @r{You may define a prompt like @code{%^@{Birthday@}t}}
5792 %n          @r{user name (taken from @code{user-full-name})}
5793 %c          @r{Current kill ring head.}
5794 %x          @r{Content of the X clipboard.}
5795 %^C         @r{Interactive selection of which kill or clip to use.}
5796 %^L         @r{Like @code{%^C}, but insert as link.}
5797 %^g         @r{prompt for tags, with completion on tags in target file.}
5798 %k          @r{title of currently clocked task}
5799 %K          @r{link to currently clocked task}
5800 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
5801 %^@{@var{prop}@}p   @r{Prompt the user for a value for property @var{prop}}
5802 %:keyword   @r{specific information for certain link types, see below}
5803 %[@var{file}]     @r{insert the contents of the file given by @var{file}}
5804 %(@var{sexp})     @r{evaluate Elisp @var{sexp} and replace with the result}
5805 %!          @r{immediately store note after completing the template}
5806             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
5807 %&          @r{jump to target location immediately after storing note}
5808 @end example
5810 @noindent
5811 For specific link types, the following keywords will be
5812 defined@footnote{If you define your own link types (@pxref{Adding
5813 hyperlink types}), any property you store with
5814 @code{org-store-link-props} can be accessed in remember templates in a
5815 similar way.}:
5817 @vindex org-from-is-user-regexp
5818 @example
5819 Link type          |  Available keywords
5820 -------------------+----------------------------------------------
5821 bbdb               |  %:name %:company
5822 bbdb               |  %::server %:port %:nick
5823 vm, wl, mh, rmail  |  %:type %:subject %:message-id
5824                    |  %:from %:fromname %:fromaddress
5825                    |  %:to   %:toname   %:toaddress
5826                    |  %: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}.}}
5827 gnus               |  %:group, @r{for messages also all email fields}
5828 w3, w3m            |  %:url
5829 info               |  %:file %:node
5830 calendar           |  %:date"
5831 @end example
5833 @noindent
5834 To place the cursor after template expansion use:
5836 @example
5837 %?          @r{After completing the template, position cursor here.}
5838 @end example
5840 @noindent
5841 If you change your mind about which template to use, call
5842 @code{org-remember} in the remember buffer.  You may then select a new
5843 template that will be filled with the previous context information.
5845 @node Storing notes, Refiling notes, Remember templates, Remember
5846 @subsection Storing notes
5848 @vindex org-remember-clock-out-on-exit
5849 When you are finished preparing a note with Remember, you have to press
5850 @kbd{C-c C-c} to file the note away.  If you have started the clock in the
5851 Remember buffer, you will first be asked if you want to clock out
5852 now@footnote{To avoid this query, configure the variable
5853 @code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
5854 will continue to run after the note was filed away.
5856 The handler will then store the note in the file and under the headline
5857 specified in the template, or it will use the default file and headline.
5858 The window configuration will be restored, sending you back to the working
5859 context before the call to Remember.  To re-use the location found
5860 during the last call to Remember, exit the Remember buffer with
5861 @kbd{C-0 C-c C-c}, @ie specify a zero prefix argument to @kbd{C-c C-c}.
5862 Another special case is @kbd{C-2 C-c C-c} which files the note as a child of
5863 the currently clocked item.
5865 @vindex org-remember-store-without-prompt
5866 If you want to store the note directly to a different place, use
5867 @kbd{C-1 C-c C-c} instead to exit Remember@footnote{Configure the
5868 variable @code{org-remember-store-without-prompt} to make this behavior
5869 the default.}.  The handler will then first prompt for a target file---if
5870 you press @key{RET}, the value specified for the template is used.
5871 Then the command offers the headings tree of the selected file, with the
5872 cursor position at the default headline (if you specified one in the
5873 template).  You can either immediately press @key{RET} to get the note
5874 placed there.  Or you can use the following keys to find a different
5875 location:
5876 @example
5877 @key{TAB}         @r{Cycle visibility.}
5878 @key{down} / @key{up}   @r{Next/previous visible headline.}
5879 n / p        @r{Next/previous visible headline.}
5880 f / b        @r{Next/previous headline same level.}
5881 u            @r{One level up.}
5882 @c 0-9          @r{Digit argument.}
5883 @end example
5884 @noindent
5885 Pressing @key{RET} or @key{left} or @key{right}
5886 then leads to the following result.
5888 @vindex org-reverse-note-order
5889 @multitable @columnfractions 0.2 0.15 0.65
5890 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
5891 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
5892 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
5893 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
5894 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
5895 @item                 @tab @tab depending on @code{org-reverse-note-order}.
5896 @item not on headline @tab @key{RET}
5897       @tab at cursor position, level taken from context.
5898 @end multitable
5900 Before inserting the text into a tree, the function ensures that the text has
5901 a headline, @ie a first line that starts with a @samp{*}.  If not, a
5902 headline is constructed from the current date.  If you have indented the text
5903 of the note below the headline, the indentation will be adapted if inserting
5904 the note into the tree requires demotion from level 1.
5906 @node Refiling notes,  , Storing notes, Remember
5907 @subsection Refiling notes
5908 @cindex refiling notes
5910 Remember is usually used to quickly capture notes and tasks into one or
5911 a few capture lists.  When reviewing the captured data, you may want to
5912 refile some of the entries into a different list, for example into a
5913 project.  Cutting, finding the right location, and then pasting the note
5914 is cumbersome.  To simplify this process, you can use the following
5915 special command:
5917 @table @kbd
5918 @kindex C-c C-w
5919 @item C-c C-w
5920 @vindex org-reverse-note-order
5921 @vindex org-refile-targets
5922 @vindex org-refile-use-outline-path
5923 @vindex org-outline-path-complete-in-steps
5924 @vindex org-refile-allow-creating-parent-nodes
5925 Refile the entry or region at point.  This command offers possible locations
5926 for refiling the entry and lets you select one with completion.  The item (or
5927 all items in the region) is filed below the target heading as a subitem.
5928 Depending on @code{org-reverse-note-order}, it will be either the first or
5929 last subitem.@*
5930 By default, all level 1 headlines in the current buffer are considered to be
5931 targets, but you can have more complex definitions across a number of files.
5932 See the variable @code{org-refile-targets} for details.  If you would like to
5933 select a location via a file-path-like completion along the outline path, see
5934 the variables @code{org-refile-use-outline-path} and
5935 @code{org-outline-path-complete-in-steps}.  If you would like to be able to
5936 create new nodes as new parents for for refiling on the fly, check the
5937 variable @code{org-refile-allow-creating-parent-nodes}.
5938 @kindex C-u C-c C-w
5939 @item C-u C-c C-w
5940 Use the refile interface to jump to a heading.
5941 @kindex C-u C-u C-c C-w
5942 @item C-u C-u C-c C-w
5943 Jump to the location where @code{org-refile} last moved a tree to.
5944 @end table
5947 @node Attachments, RSS Feeds, Remember, Capture
5948 @section Attachments
5949 @cindex attachments
5951 @vindex org-attach-directory
5952 It is often useful to associate reference material with an outline node/task.
5953 Small chunks of plain text can simply be stored in the subtree of a project.
5954 Hyperlinks (@pxref{Hyperlinks}) can be used to establish associations with
5955 files that live elsewhere on your computer or in the cloud, like emails or
5956 source code files belonging to a project.  Another method is @i{attachments},
5957 which are files located in a directory belonging to an outline node.  Org
5958 uses directories named by the unique ID of each entry.  These directories are
5959 located in the @file{data} directory which lives in the same directory where
5960 your Org file lives@footnote{If you move entries or Org files from one
5961 directory to another, you may want to configure @code{org-attach-directory}
5962 to contain an absolute path.}.  If you initialize this directory with
5963 @code{git init}, Org will automatically commit changes when it sees them.
5964 The attachment system has been contributed to Org by John Wiegley.
5966 In cases where it seems better to do so, you can also attach a directory of your
5967 choice to an entry.  You can also make children inherit the attachment
5968 directory from a parent, so that an entire subtree uses the same attached
5969 directory.
5971 @noindent The following commands deal with attachments.
5973 @table @kbd
5975 @kindex C-c C-a
5976 @item C-c C-a
5977 The dispatcher for commands related to the attachment system.  After these
5978 keys, a list of commands is displayed and you need to press an additional key
5979 to select a command:
5981 @table @kbd
5982 @kindex C-c C-a a
5983 @item a
5984 @vindex org-attach-method
5985 Select a file and move it into the task's attachment directory.  The file
5986 will be copied, moved, or linked, depending on @code{org-attach-method}.
5987 Note that hard links are not supported on all systems.
5989 @kindex C-c C-a c
5990 @kindex C-c C-a m
5991 @kindex C-c C-a l
5992 @item c/m/l
5993 Attach a file using the copy/move/link method.
5994 Note that hard links are not supported on all systems.
5996 @kindex C-c C-a n
5997 @item n
5998 Create a new attachment as an Emacs buffer.
6000 @kindex C-c C-a z
6001 @item z
6002 Synchronize the current task with its attachment directory, in case you added
6003 attachments yourself.
6005 @kindex C-c C-a o
6006 @item o
6007 @vindex org-file-apps
6008 Open current task's attachment.  If there are more than one, prompt for a
6009 file name first.  Opening will follow the rules set by @code{org-file-apps}.
6010 For more details, see the information on following hyperlinks
6011 (@pxref{Handling links}).
6013 @kindex C-c C-a O
6014 @item O
6015 Also open the attachment, but force opening the file in Emacs.
6017 @kindex C-c C-a f
6018 @item f
6019 Open the current task's attachment directory.
6021 @kindex C-c C-a F
6022 @item F
6023 Also open the directory, but force using @command{dired} in Emacs.
6025 @kindex C-c C-a d
6026 @item d
6027 Select and delete a single attachment.
6029 @kindex C-c C-a D
6030 @item D
6031 Delete all of a task's attachments.  A safer way is to open the directory in
6032 @command{dired} and delete from there.
6034 @kindex C-c C-a s
6035 @item C-c C-a s
6036 @cindex property, ATTACH_DIR
6037 Set a specific directory as the entry's attachment directory.  This works by
6038 putting the directory path into the @code{ATTACH_DIR} property.
6040 @kindex C-c C-a i
6041 @item C-c C-a i
6042 @cindex property, ATTACH_DIR_INHERIT
6043 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
6044 same directory for attachments as the parent does.
6045 @end table
6046 @end table
6048 @node RSS Feeds, Protocols, Attachments, Capture
6049 @section RSS feeds
6050 @cindex RSS feeds
6052 Org has the capability to add and change entries based on information found in
6053 RSS feeds.  You could use this to make a task out of each new podcast in a
6054 podcast feed.  Or you could use a phone-based note-creating service on the
6055 web to import tasks into Org.  To access feeds, you need to configure the
6056 variable @code{org-feed-alist}.  The docstring of this variable has detailed
6057 information.  Here is just an example:
6059 @example
6060 (setq org-feed-alist
6061       '(("ReQall" "http://www.reqall.com/user/feeds/rss/a1b2c3....."
6062          "~/org/feeds.org" "ReQall Entries")
6063 @end example
6064 @noindent
6065 will configure that new items from the feed provided by @file{reqall.com}
6066 will result in new entries in the file @file{~/org/feeds.org} under the
6067 heading @samp{ReQall Entries}, whenever the following command is used:
6069 @table @kbd
6070 @kindex C-c C-x g
6071 @item C-c C-x g
6072 Collect items from the feeds configured in @code{org-feed-alist} and act upon
6073 them.
6074 @kindex C-c C-x G
6075 @item C-c C-x G
6076 Prompt for a feed name and go to the inbox configured for this feed.
6077 @end table
6079 Under the same headline, Org will create a drawer @samp{FEEDSTATUS} in which
6080 it will store information about the status of items in the feed, to avoid
6081 adding the same item several times.  You should add @samp{FEEDSTATUS} to the
6082 list of drawers in that file:
6084 @example
6085 #+DRAWERS: LOGBOOK PROPERTIES FEEDSTATUS
6086 @end example
6088 For more information, see @file{org-feed.el} and the docstring of
6089 @code{org-feed-alist}.
6091 @node Protocols,  , RSS Feeds, Capture
6092 @section Protocols for external access
6093 @cindex protocols, for external access
6094 @cindex emacsserver
6096 You can set up Org for handling protocol calls from outside applications that
6097 are passed to Emacs through the @file{emacsserver}.  For example, you can
6098 configure bookmarks in your web browser to send a link to the current page to
6099 Org and create a note from it using Remember (@pxref{Remember}).  Or you
6100 could create a bookmark that will tell Emacs to open the local source file of
6101 a remote website you are looking at with the browser.  See
6102 @uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed
6103 documentation and setup instructions.
6106 @node Agenda Views, Embedded LaTeX, Capture, Top
6107 @chapter Agenda Views
6108 @cindex agenda views
6110 Due to the way Org works, TODO items, time-stamped items, and
6111 tagged headlines can be scattered throughout a file or even a number of
6112 files.  To get an overview of open action items, or of events that are
6113 important for a particular date, this information must be collected,
6114 sorted and displayed in an organized way.
6116 Org can select items based on various criteria and display them
6117 in a separate buffer.  Seven different view types are provided:
6119 @itemize @bullet
6120 @item
6121 an @emph{agenda} that is like a calendar and shows information
6122 for specific dates,
6123 @item
6124 a @emph{TODO list} that covers all unfinished
6125 action items,
6126 @item
6127 a @emph{match view}, showings headlines based on the tags, properties, and
6128 TODO state associated with them,
6129 @item
6130 a @emph{timeline view} that shows all events in a single Org file,
6131 in time-sorted view,
6132 @item
6133 a @emph{keyword search view} that shows all entries from multiple files
6134 that contain specified keywords,
6135 @item
6136 a @emph{stuck projects view} showing projects that currently don't move
6137 along, and
6138 @item
6139 @emph{custom views} that are special tag/keyword searches and
6140 combinations of different views.
6141 @end itemize
6143 @noindent
6144 The extracted information is displayed in a special @emph{agenda
6145 buffer}.  This buffer is read-only, but provides commands to visit the
6146 corresponding locations in the original Org files, and even to
6147 edit these files remotely.
6149 @vindex org-agenda-window-setup
6150 @vindex org-agenda-restore-windows-after-quit
6151 Two variables control how the agenda buffer is displayed and whether the
6152 window configuration is restored when the agenda exits:
6153 @code{org-agenda-window-setup} and
6154 @code{org-agenda-restore-windows-after-quit}.
6156 @menu
6157 * Agenda files::                Files being searched for agenda information
6158 * Agenda dispatcher::           Keyboard access to agenda views
6159 * Built-in agenda views::       What is available out of the box?
6160 * Presentation and sorting::    How agenda items are prepared for display
6161 * Agenda commands::             Remote editing of Org trees
6162 * Custom agenda views::         Defining special searches and views
6163 * Exporting Agenda Views::
6164 * Agenda column view::          Using column view for collected entries
6165 @end menu
6167 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
6168 @section Agenda files
6169 @cindex agenda files
6170 @cindex files for agenda
6172 @vindex org-agenda-files
6173 The information to be shown is normally collected from all @emph{agenda
6174 files}, the files listed in the variable
6175 @code{org-agenda-files}@footnote{If the value of that variable is not a
6176 list, but a single file name, then the list of agenda files will be
6177 maintained in that external file.}. If a directory is part of this list,
6178 all files with the extension @file{.org} in this directory will be part
6179 of the list.
6181 Thus, even if you only work with a single Org file, that file should
6182 be put into the list@footnote{When using the dispatcher, pressing
6183 @kbd{<} before selecting a command will actually limit the command to
6184 the current file, and ignore @code{org-agenda-files} until the next
6185 dispatcher command.}.  You can customize @code{org-agenda-files}, but
6186 the easiest way to maintain it is through the following commands
6188 @cindex files, adding to agenda list
6189 @table @kbd
6190 @kindex C-c [
6191 @item C-c [
6192 Add current file to the list of agenda files.  The file is added to
6193 the front of the list.  If it was already in the list, it is moved to
6194 the front.  With a prefix argument, file is added/moved to the end.
6195 @kindex C-c ]
6196 @item C-c ]
6197 Remove current file from the list of agenda files.
6198 @kindex C-,
6199 @kindex C-'
6200 @item C-,
6201 @itemx C-'
6202 Cycle through agenda file list, visiting one file after the other.
6203 @kindex M-x org-iswitchb
6204 @item M-x org-iswitchb
6205 Command to use an @code{iswitchb}-like interface to switch to and between Org
6206 buffers.
6207 @end table
6209 @noindent
6210 The Org menu contains the current list of files and can be used
6211 to visit any of them.
6213 If you would like to focus the agenda temporarily on a file not in
6214 this list, or on just one file in the list, or even on only a subtree in a
6215 file, then this can be done in different ways.  For a single agenda command,
6216 you may press @kbd{<} once or several times in the dispatcher
6217 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
6218 extended period, use the following commands:
6220 @table @kbd
6221 @kindex C-c C-x <
6222 @item C-c C-x <
6223 Permanently restrict the agenda to the current subtree.  When with a
6224 prefix argument, or with the cursor before the first headline in a file,
6225 the agenda scope is set to the entire file.  This restriction remains in
6226 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
6227 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
6228 agenda view, the new restriction takes effect immediately.
6229 @kindex C-c C-x >
6230 @item C-c C-x >
6231 Remove the permanent restriction created by @kbd{C-c C-x <}.
6232 @end table
6234 @noindent
6235 When working with @file{speedbar.el}, you can use the following commands in
6236 the Speedbar frame:
6237 @table @kbd
6238 @kindex <
6239 @item < @r{in the speedbar frame}
6240 Permanently restrict the agenda to the item---either an Org file or a subtree
6241 in such a file---at the cursor in the Speedbar frame.
6242 If there is a window displaying an agenda view, the new restriction takes
6243 effect immediately.
6244 @kindex >
6245 @item > @r{in the speedbar frame}
6246 Lift the restriction.
6247 @end table
6249 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
6250 @section The agenda dispatcher
6251 @cindex agenda dispatcher
6252 @cindex dispatching agenda commands
6253 The views are created through a dispatcher, which should be bound to a
6254 global key---for example @kbd{C-c a} (@pxref{Installation}).  In the
6255 following we will assume that @kbd{C-c a} is indeed how the dispatcher
6256 is accessed and list keyboard access to commands accordingly.  After
6257 pressing @kbd{C-c a}, an additional letter is required to execute a
6258 command.  The dispatcher offers the following default commands:
6259 @table @kbd
6260 @item a
6261 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
6262 @item t @r{/} T
6263 Create a list of all TODO items (@pxref{Global TODO list}).
6264 @item m @r{/} M
6265 Create a list of headlines matching a TAGS expression (@pxref{Matching
6266 tags and properties}).
6267 @item L
6268 Create the timeline view for the current buffer (@pxref{Timeline}).
6269 @item s
6270 Create a list of entries selected by a boolean expression of keywords
6271 and/or regular expressions that must or must not occur in the entry.
6272 @item /
6273 @vindex org-agenda-text-search-extra-files
6274 Search for a regular expression in all agenda files and additionally in
6275 the files listed in @code{org-agenda-text-search-extra-files}.  This
6276 uses the Emacs command @code{multi-occur}.  A prefix argument can be
6277 used to specify the number of context lines for each match, default is
6279 @item # @r{/} !
6280 Create a list of stuck projects (@pxref{Stuck projects}).
6281 @item <
6282 Restrict an agenda command to the current buffer@footnote{For backward
6283 compatibility, you can also press @kbd{1} to restrict to the current
6284 buffer.}.  After pressing @kbd{<}, you still need to press the character
6285 selecting the command.
6286 @item < <
6287 If there is an active region, restrict the following agenda command to
6288 the region.  Otherwise, restrict it to the current subtree@footnote{For
6289 backward compatibility, you can also press @kbd{0} to restrict to the
6290 current region/subtree.}.  After pressing @kbd{< <}, you still need to press the
6291 character selecting the command.
6292 @end table
6294 You can also define custom commands that will be accessible through the
6295 dispatcher, just like the default commands.  This includes the
6296 possibility to create extended agenda buffers that contain several
6297 blocks together, for example the weekly agenda, the global TODO list and
6298 a number of special tags matches.  @xref{Custom agenda views}.
6300 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
6301 @section The built-in agenda views
6303 In this section we describe the built-in views.
6305 @menu
6306 * Weekly/daily agenda::         The calendar page with current tasks
6307 * Global TODO list::            All unfinished action items
6308 * Matching tags and properties::  Structured information with fine-tuned search
6309 * Timeline::                    Time-sorted view for single file
6310 * Keyword search::              Finding entries by keyword
6311 * Stuck projects::              Find projects you need to review
6312 @end menu
6314 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
6315 @subsection The weekly/daily agenda
6316 @cindex agenda
6317 @cindex weekly agenda
6318 @cindex daily agenda
6320 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
6321 paper agenda, showing all the tasks for the current week or day.
6323 @table @kbd
6324 @cindex org-agenda, command
6325 @kindex C-c a a
6326 @item C-c a a
6327 @vindex org-agenda-ndays
6328 Compile an agenda for the current week from a list of Org files.  The agenda
6329 shows the entries for each day.  With a numeric prefix@footnote{For backward
6330 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
6331 listed before the agenda.  This feature is deprecated, use the dedicated TODO
6332 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
6333 C-c a a}) you may set the number of days to be displayed (see also the
6334 variable @code{org-agenda-ndays})
6335 @end table
6337 Remote editing from the agenda buffer means, for example, that you can
6338 change the dates of deadlines and appointments from the agenda buffer.
6339 The commands available in the Agenda buffer are listed in @ref{Agenda
6340 commands}.
6342 @subsubheading Calendar/Diary integration
6343 @cindex calendar integration
6344 @cindex diary integration
6346 Emacs contains the calendar and diary by Edward M. Reingold.  The
6347 calendar displays a three-month calendar with holidays from different
6348 countries and cultures.  The diary allows you to keep track of
6349 anniversaries, lunar phases, sunrise/set, recurrent appointments
6350 (weekly, monthly) and more.  In this way, it is quite complementary to
6351 Org.  It can be very useful to combine output from Org with
6352 the diary.
6354 In order to include entries from the Emacs diary into Org mode's
6355 agenda, you only need to customize the variable
6357 @lisp
6358 (setq org-agenda-include-diary t)
6359 @end lisp
6361 @noindent After that, everything will happen automatically.  All diary
6362 entries including holidays, anniversaries, etc., will be included in the
6363 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
6364 @key{RET} can be used from the agenda buffer to jump to the diary
6365 file in order to edit existing diary entries.  The @kbd{i} command to
6366 insert new entries for the current date works in the agenda buffer, as
6367 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
6368 Sunrise/Sunset times, show lunar phases and to convert to other
6369 calendars, respectively.  @kbd{c} can be used to switch back and forth
6370 between calendar and agenda.
6372 If you are using the diary only for sexp entries and holidays, it is
6373 faster to not use the above setting, but instead to copy or even move
6374 the entries into an Org file. Org mode evaluates diary-style sexp
6375 entries, and does it faster because there is no overhead for first
6376 creating the diary display.  Note that the sexp entries must start at
6377 the left margin, no whitespace is allowed before them.  For example,
6378 the following segment of an Org file will be processed and entries
6379 will be made in the agenda:
6381 @example
6382 * Birthdays and similar stuff
6383 #+CATEGORY: Holiday
6384 %%(org-calendar-holiday)   ; special function for holiday names
6385 #+CATEGORY: Ann
6386 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
6387 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
6388 @end example
6390 @subsubheading Anniversaries from BBDB
6391 @cindex BBDB, anniversaries
6392 @cindex anniversaries, from BBDB
6394 If you are using the Big Brothers Database to store your contacts, you will
6395 very likely prefer to store anniversaries in BBDB rather than in a
6396 separate Org or diary file.  Org supports this and will show BBDB
6397 anniversaries as part of the agenda.  All you need to do is to add the
6398 following to one your your agenda files:
6400 @example
6401 * Anniversaries
6402   :PROPERTIES:
6403   :CATEGORY: Anniv
6404   :END
6405 %%(org-bbdb-anniversaries)
6406 @end example
6408 You can then go ahead and define anniversaries for a BBDB record.  Basically,
6409 you need to press @kbd{C-o anniversary @key{RET}} with the cursor in a BBDB
6410 record and then add the date in the format @code{YYYY-MM-DD}, followed by a
6411 space and the class of the anniversary (@samp{birthday} or @samp{wedding}, or
6412 a format string).  If you omit the class, it will default to @samp{birthday}.
6413 Here are a few examples, the header for the file @file{org-bbdb.el} contains
6414 more detailed information.
6416 @example
6417 1973-06-22
6418 1955-08-02 wedding
6419 2008-04-14 %s released version 6.01 of org-mode, %d years ago
6420 @end example
6422 After a change to BBDB, or for the first agenda display during an Emacs
6423 session, the agenda display will suffer a short delay as Org updates its
6424 hash with anniversaries.  However, from then on things will be very fast---much
6425 faster in fact than a long list of @samp{%%(diary-anniversary)} entries
6426 in an Org or Diary file.
6428 @subsubheading Appointment reminders
6429 @cindex @file{appt.el}
6430 @cindex appointment reminders
6432 Org can interact with Emacs appointments notification facility.  To add all
6433 the appointments of your agenda files, use the command
6434 @code{org-agenda-to-appt}.  This command also lets you filter through the
6435 list of your appointments and add only those belonging to a specific category
6436 or matching a regular expression. See the docstring for details.
6438 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
6439 @subsection The global TODO list
6440 @cindex global TODO list
6441 @cindex TODO list, global
6443 The global TODO list contains all unfinished TODO items formatted and
6444 collected into a single place.
6446 @table @kbd
6447 @kindex C-c a t
6448 @item C-c a t
6449 Show the global TODO list.  This collects the TODO items from all
6450 agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
6451 @code{agenda-mode}, so there are commands to examine and manipulate
6452 the TODO entries directly from that buffer (@pxref{Agenda commands}).
6453 @kindex C-c a T
6454 @item C-c a T
6455 @cindex TODO keyword matching
6456 @vindex org-todo-keywords
6457 Like the above, but allows selection of a specific TODO keyword.  You
6458 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
6459 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
6460 specify several keywords by separating them with @samp{|} as the boolean OR
6461 operator.  With a numeric prefix, the nth keyword in
6462 @code{org-todo-keywords} is selected.
6463 @kindex r
6464 The @kbd{r} key in the agenda buffer regenerates it, and you can give
6465 a prefix argument to this command to change the selected TODO keyword,
6466 for example @kbd{3 r}.  If you often need a search for a specific
6467 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
6468 Matching specific TODO keywords can also be done as part of a tags
6469 search (@pxref{Tag searches}).
6470 @end table
6472 Remote editing of TODO items means that you can change the state of a
6473 TODO entry with a single key press.  The commands available in the
6474 TODO list are described in @ref{Agenda commands}.
6476 @cindex sublevels, inclusion into TODO list
6477 Normally the global TODO list simply shows all headlines with TODO
6478 keywords.  This list can become very long.  There are two ways to keep
6479 it more compact:
6480 @itemize @minus
6481 @item
6482 @vindex org-agenda-todo-ignore-scheduled
6483 @vindex org-agenda-todo-ignore-deadlines
6484 @vindex org-agenda-todo-ignore-with-date
6485 Some people view a TODO item that has been @emph{scheduled} for execution or
6486 have a @emph{deadline} (@pxref{Timestamps}) as no longer @emph{open}.
6487 Configure the variables @code{org-agenda-todo-ignore-scheduled},
6488 @code{org-agenda-todo-ignore-deadlines}, and/or
6489 @code{org-agenda-todo-ignore-with-date} to exclude such items from the
6490 global TODO list.
6491 @item
6492 @vindex org-agenda-todo-list-sublevels
6493 TODO items may have sublevels to break up the task into subtasks.  In
6494 such cases it may be enough to list only the highest level TODO headline
6495 and omit the sublevels from the global list.  Configure the variable
6496 @code{org-agenda-todo-list-sublevels} to get this behavior.
6497 @end itemize
6499 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
6500 @subsection Matching tags and properties
6501 @cindex matching, of tags
6502 @cindex matching, of properties
6503 @cindex tags view
6504 @cindex match view
6506 If headlines in the agenda files are marked with @emph{tags} (@pxref{Tags}),
6507 or have properties (@pxref{Properties and Columns}), you can select headlines
6508 based on this metadata and collect them into an agenda buffer.  The match
6509 syntax described here also applies when creating sparse trees with @kbd{C-c /
6512 @table @kbd
6513 @kindex C-c a m
6514 @item C-c a m
6515 Produce a list of all headlines that match a given set of tags.  The
6516 command prompts for a selection criterion, which is a boolean logic
6517 expression with tags, like @samp{+work+urgent-withboss} or
6518 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
6519 define a custom command for it (@pxref{Agenda dispatcher}).
6520 @kindex C-c a M
6521 @item C-c a M
6522 @vindex org-tags-match-list-sublevels
6523 @vindex org-agenda-tags-todo-honor-ignore-options
6524 Like @kbd{C-c a m}, but only select headlines that are also TODO items and
6525 force checking subitems (see variable @code{org-tags-match-list-sublevels}).
6526 To exclude scheduled/deadline items, see the variable
6527 @code{org-agenda-tags-todo-honor-ignore-options}.  Matching specific TODO
6528 keywords together with a tags match is also possible, see @ref{Tag searches}.
6529 @end table
6531 The commands available in the tags list are described in @ref{Agenda
6532 commands}.
6534 @subsubheading Match syntax
6536 @cindex Boolean logic, for tag/property searches
6537 A search string can use Boolean operators @samp{&} for AND and @samp{|} for
6538 OR.  @samp{&} binds more strongly than @samp{|}.  Parentheses are currently
6539 not implemented.  Each element in the search is either a tag, a regular
6540 expression matching tags, or an expression like @code{PROPERTY OPERATOR
6541 VALUE} with a comparison operator, accessing a property value.  Each element
6542 may be preceded by @samp{-}, to select against it, and @samp{+} is syntactic
6543 sugar for positive selection.  The AND operator @samp{&} is optional when
6544 @samp{+} or @samp{-} is present.  Here are some examples, using only tags.
6546 @table @samp
6547 @item +work-boss
6548 Select headlines tagged @samp{:work:}, but discard those also tagged
6549 @samp{:boss:}.
6550 @item work|laptop
6551 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
6552 @item work|laptop+night
6553 Like before, but require the @samp{:laptop:} lines to be tagged also
6554 @samp{:night:}.
6555 @end table
6557 @cindex regular expressions, with tags search
6558 Instead of a tag, you may also specify a regular expression enclosed in curly
6559 braces.  For example,
6560 @samp{work+@{^boss.*@}} matches headlines that contain the tag
6561 @samp{:work:} and any tag @i{starting} with @samp{boss}.
6563 @cindex TODO keyword matching, with tags search
6564 @cindex level, require for tags/property match
6565 @cindex category, require for tags/property match
6566 @vindex org-odd-levels-only
6567 You may also test for properties (@pxref{Properties and Columns}) at the same
6568 time as matching tags.  The properties may be real properties, or special
6569 properties that represent other metadata (@pxref{Special properties}).  For
6570 example, the ``property'' @code{TODO} represents the TODO keyword of the
6571 entry.  Or, the ``property'' @code{LEVEL} represents the level of an entry.
6572 So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
6573 that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
6574 DONE.  In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
6575 count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
6577 Here are more examples:
6578 @table @samp
6579 @item work+TODO="WAITING"
6580 Select @samp{:work:}-tagged TODO lines with the specific TODO
6581 keyword @samp{WAITING}.
6582 @item work+TODO="WAITING"|home+TODO="WAITING"
6583 Waiting tasks both at work and at home.
6584 @end table
6586 When matching properties, a number of different operators can be used to test
6587 the value of a property.  Here is a complex example:
6589 @example
6590 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
6591          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
6592 @end example
6594 @noindent
6595 The type of comparison will depend on how the comparison value is written:
6596 @itemize @minus
6597 @item
6598 If the comparison value is a plain number, a numerical comparison is done,
6599 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
6600 @samp{>=}, and @samp{<>}.
6601 @item
6602 If the comparison value is enclosed in double-quotes,
6603 a string comparison is done, and the same operators are allowed.
6604 @item
6605 If the comparison value is enclosed in double-quotes @emph{and} angular
6606 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
6607 assumed to be date/time specifications in the standard Org way, and the
6608 comparison will be done accordingly.  Special values that will be recognized
6609 are @code{"<now>"} for now (including time), and @code{"<today>"}, and
6610 @code{"<tomorrow>"} for these days at 0:00 hours, @ie without a time
6611 specification.  Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
6612 @code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
6613 respectively, can be used.
6614 @item
6615 If the comparison value is enclosed
6616 in curly braces, a regexp match is performed, with @samp{=} meaning that the
6617 regexp matches the property value, and @samp{<>} meaning that it does not
6618 match.
6619 @end itemize
6621 So the search string in the example finds entries tagged @samp{:work:} but
6622 not @samp{:boss:}, which also have a priority value @samp{A}, a
6623 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
6624 property that is numerically smaller than 2, a @samp{:With:} property that is
6625 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
6626 on or after October 11, 2008.
6628 Accessing TODO, LEVEL, and CATEGORY during a search is fast.  Accessing any
6629 other properties will slow down the search.  However, once you have paid the
6630 price by accessing one property, testing additional properties is cheap
6631 again.
6633 You can configure Org mode to use property inheritance during a search, but
6634 beware that this can slow down searches considerably.  See @ref{Property
6635 inheritance}, for details.
6637 For backward compatibility, and also for typing speed, there is also a
6638 different way to test TODO states in a search.  For this, terminate the
6639 tags/property part of the search string (which may include several terms
6640 connected with @samp{|}) with a @samp{/} and then specify a Boolean
6641 expression just for TODO keywords.  The syntax is then similar to that for
6642 tags, but should be applied with care: for example, a positive
6643 selection on several TODO keywords cannot meaningfully be combined with
6644 boolean AND.  However, @emph{negative selection} combined with AND can be
6645 meaningful.  To make sure that only lines are checked that actually have any
6646 TODO keyword (resulting in a speed-up), use @kbd{C-c a M}, or equivalently
6647 start the TODO part after the slash with @samp{!}.  Examples:
6649 @table @samp
6650 @item work/WAITING
6651 Same as @samp{work+TODO="WAITING"}
6652 @item work/!-WAITING-NEXT
6653 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
6654 nor @samp{NEXT}
6655 @item work/!+WAITING|+NEXT
6656 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
6657 @samp{NEXT}.
6658 @end table
6660 @node Timeline, Keyword search, Matching tags and properties, Built-in agenda views
6661 @subsection Timeline for a single file
6662 @cindex timeline, single file
6663 @cindex time-sorted view
6665 The timeline summarizes all time-stamped items from a single Org mode
6666 file in a @emph{time-sorted view}.  The main purpose of this command is
6667 to give an overview over events in a project.
6669 @table @kbd
6670 @kindex C-c a L
6671 @item C-c a L
6672 Show a time-sorted view of the Org file, with all time-stamped items.
6673 When called with a @kbd{C-u} prefix, all unfinished TODO entries
6674 (scheduled or not) are also listed under the current date.
6675 @end table
6677 @noindent
6678 The commands available in the timeline buffer are listed in
6679 @ref{Agenda commands}.
6681 @node Keyword search, Stuck projects, Timeline, Built-in agenda views
6682 @subsection Keyword search
6683 @cindex keyword search
6684 @cindex searching, for keywords
6686 This agenda view is a general text search facility for Org mode entries.
6687 It is particularly useful to find notes.
6689 @table @kbd
6690 @kindex C-c a s
6691 @item C-c a s
6692 This is a special search that lets you select entries by keywords or
6693 regular expression, using a boolean logic.  For example, the search
6694 string
6696 @example
6697 +computer +wifi -ethernet -@{8\.11[bg]@}
6698 @end example
6700 @noindent
6701 will search for note entries that contain the keywords @code{computer}
6702 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
6703 not matched by the regular expression @code{8\.11[bg]}, meaning to
6704 exclude both 8.11b and 8.11g.
6706 @vindex org-agenda-text-search-extra-files
6707 Note that in addition to the agenda files, this command will also search
6708 the files listed in @code{org-agenda-text-search-extra-files}.
6709 @end table
6711 @node Stuck projects,  , Keyword search, Built-in agenda views
6712 @subsection Stuck projects
6714 If you are following a system like David Allen's GTD to organize your
6715 work, one of the ``duties'' you have is a regular review to make sure
6716 that all projects move along.  A @emph{stuck} project is a project that
6717 has no defined next actions, so it will never show up in the TODO lists
6718 Org mode produces.  During the review, you need to identify such
6719 projects and define next actions for them.
6721 @table @kbd
6722 @kindex C-c a #
6723 @item C-c a #
6724 List projects that are stuck.
6725 @kindex C-c a !
6726 @item C-c a !
6727 @vindex org-stuck-projects
6728 Customize the variable @code{org-stuck-projects} to define what a stuck
6729 project is and how to find it.
6730 @end table
6732 You almost certainly will have to configure this view before it will
6733 work for you.  The built-in default assumes that all your projects are
6734 level-2 headlines, and that a project is not stuck if it has at least
6735 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
6737 Let's assume that you, in your own way of using Org mode, identify
6738 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
6739 indicate a project that should not be considered yet.  Let's further
6740 assume that the TODO keyword DONE marks finished projects, and that NEXT
6741 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
6742 is a next action even without the NEXT tag.  Finally, if the project
6743 contains the special word IGNORE anywhere, it should not be listed
6744 either.  In this case you would start by identifying eligible projects
6745 with a tags/todo match@footnote{@xref{Tag searches}.}
6746 @samp{+PROJECT/-MAYBE-DONE}, and then check for TODO, NEXT, @@SHOP, and
6747 IGNORE in the subtree to identify projects that are not stuck.  The
6748 correct customization for this is
6750 @lisp
6751 (setq org-stuck-projects
6752       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
6753                                "\\<IGNORE\\>"))
6754 @end lisp
6756 Note that if a project is identified as non-stuck, the subtree of this entry
6757 will still be searched for stuck projects.
6759 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
6760 @section Presentation and sorting
6761 @cindex presentation, of agenda items
6763 @vindex org-agenda-prefix-format
6764 Before displaying items in an agenda view, Org mode visually prepares
6765 the items and sorts them.  Each item occupies a single line.  The line
6766 starts with a @emph{prefix} that contains the @emph{category}
6767 (@pxref{Categories}) of the item and other important information.  You can
6768 customize the prefix using the option @code{org-agenda-prefix-format}.
6769 The prefix is followed by a cleaned-up version of the outline headline
6770 associated with the item.
6772 @menu
6773 * Categories::                  Not all tasks are equal
6774 * Time-of-day specifications::  How the agenda knows the time
6775 * Sorting of agenda items::     The order of things
6776 @end menu
6778 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
6779 @subsection Categories
6781 @cindex category
6782 The category is a broad label assigned to each agenda item.  By default,
6783 the category is simply derived from the file name, but you can also
6784 specify it with a special line in the buffer, like this@footnote{For
6785 backward compatibility, the following also works: if there are several
6786 such lines in a file, each specifies the category for the text below it.
6787 The first category also applies to any text before the first CATEGORY
6788 line.  However, using this method is @emph{strongly} deprecated as it is
6789 incompatible with the outline structure of the document.  The correct
6790 method for setting multiple categories in a buffer is using a
6791 property.}:
6793 @example
6794 #+CATEGORY: Thesis
6795 @end example
6797 @noindent
6798 @cindex property, CATEGORY
6799 If you would like to have a special CATEGORY for a single entry or a
6800 (sub)tree, give the entry a @code{:CATEGORY:} property with the
6801 special category you want to apply as the value.
6803 @noindent
6804 The display in the agenda buffer looks best if the category is not
6805 longer than 10 characters.
6807 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
6808 @subsection Time-of-day specifications
6809 @cindex time-of-day specification
6811 Org mode checks each agenda item for a time-of-day specification.  The
6812 time can be part of the timestamp that triggered inclusion into the
6813 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
6814 ranges can be specified with two timestamps, like
6816 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
6818 In the headline of the entry itself, a time(range) may also appear as
6819 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
6820 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
6821 specifications in diary entries are recognized as well.
6823 For agenda display, Org mode extracts the time and displays it in a
6824 standard 24 hour format as part of the prefix.  The example times in
6825 the previous paragraphs would end up in the agenda like this:
6827 @example
6828     8:30-13:00 Arthur Dent lies in front of the bulldozer
6829    12:45...... Ford Prefect arrives and takes Arthur to the pub
6830    19:00...... The Vogon reads his poem
6831    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
6832 @end example
6834 @cindex time grid
6835 If the agenda is in single-day mode, or for the display of today, the
6836 timed entries are embedded in a time grid, like
6838 @example
6839     8:00...... ------------------
6840     8:30-13:00 Arthur Dent lies in front of the bulldozer
6841    10:00...... ------------------
6842    12:00...... ------------------
6843    12:45...... Ford Prefect arrives and takes Arthur to the pub
6844    14:00...... ------------------
6845    16:00...... ------------------
6846    18:00...... ------------------
6847    19:00...... The Vogon reads his poem
6848    20:00...... ------------------
6849    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
6850 @end example
6852 @vindex org-agenda-use-time-grid
6853 @vindex org-agenda-time-grid
6854 The time grid can be turned on and off with the variable
6855 @code{org-agenda-use-time-grid}, and can be configured with
6856 @code{org-agenda-time-grid}.
6858 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
6859 @subsection Sorting of agenda items
6860 @cindex sorting, of agenda items
6861 @cindex priorities, of agenda items
6862 Before being inserted into a view, the items are sorted.  How this is
6863 done depends on the type of view.
6864 @itemize @bullet
6865 @item
6866 @vindex org-agenda-files
6867 For the daily/weekly agenda, the items for each day are sorted.  The
6868 default order is to first collect all items containing an explicit
6869 time-of-day specification.  These entries will be shown at the beginning
6870 of the list, as a @emph{schedule} for the day.  After that, items remain
6871 grouped in categories, in the sequence given by @code{org-agenda-files}.
6872 Within each category, items are sorted by priority (@pxref{Priorities}),
6873 which is composed of the base priority (2000 for priority @samp{A}, 1000
6874 for @samp{B}, and 0 for @samp{C}), plus additional increments for
6875 overdue scheduled or deadline items.
6876 @item
6877 For the TODO list, items remain in the order of categories, but within
6878 each category, sorting takes place according to priority
6879 (@pxref{Priorities}).  The priority used for sorting derives from the
6880 priority cookie, with additions depending on how close an item is to its due
6881 or scheduled date.
6882 @item
6883 For tags matches, items are not sorted at all, but just appear in the
6884 sequence in which they are found in the agenda files.
6885 @end itemize
6887 @vindex org-agenda-sorting-strategy
6888 Sorting can be customized using the variable
6889 @code{org-agenda-sorting-strategy}, and may also include criteria based on
6890 the estimated effort of an entry (@pxref{Effort estimates}).
6892 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
6893 @section Commands in the agenda buffer
6894 @cindex commands, in agenda buffer
6896 Entries in the agenda buffer are linked back to the Org file or diary
6897 file where they originate.  You are not allowed to edit the agenda
6898 buffer itself, but commands are provided to show and jump to the
6899 original entry location, and to edit the Org files ``remotely'' from
6900 the agenda buffer.  In this way, all information is stored only once,
6901 removing the risk that your agenda and note files may diverge.
6903 Some commands can be executed with mouse clicks on agenda lines.  For
6904 the other commands, the cursor needs to be in the desired line.
6906 @table @kbd
6907 @tsubheading{Motion}
6908 @cindex motion commands in agenda
6909 @kindex n
6910 @item n
6911 Next line (same as @key{up} and @kbd{C-p}).
6912 @kindex p
6913 @item p
6914 Previous line (same as @key{down} and @kbd{C-n}).
6915 @tsubheading{View/Go to Org file}
6916 @kindex mouse-3
6917 @kindex @key{SPC}
6918 @item mouse-3
6919 @itemx @key{SPC}
6920 Display the original location of the item in another window.
6921 With prefix arg, make sure that the entire entry is made visible in the
6922 outline, not only the heading.
6924 @kindex L
6925 @item L
6926 Display original location and recenter that window.
6928 @kindex mouse-2
6929 @kindex mouse-1
6930 @kindex @key{TAB}
6931 @item mouse-2
6932 @itemx mouse-1
6933 @itemx @key{TAB}
6934 Go to the original location of the item in another window.  Under Emacs
6935 22, @kbd{mouse-1} will also works for this.
6937 @kindex @key{RET}
6938 @itemx @key{RET}
6939 Go to the original location of the item and delete other windows.
6941 @kindex F
6942 @item F
6943 @vindex org-agenda-start-with-follow-mode
6944 Toggle Follow mode.  In Follow mode, as you move the cursor through
6945 the agenda buffer, the other window always shows the corresponding
6946 location in the Org file.  The initial setting for this mode in new
6947 agenda buffers can be set with the variable
6948 @code{org-agenda-start-with-follow-mode}.
6950 @kindex C-c C-x b
6951 @item C-c C-x b
6952 Display the entire subtree of the current item in an indirect buffer.  With a
6953 numeric prefix argument N, go up to level N and then take that tree.  If N is
6954 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
6955 previously used indirect buffer.
6957 @kindex C-c C-o
6958 @item C-c C-o
6959 Follow a link in the entry.  This will offer a selection of any links in the
6960 text belonging to the referenced Org node.  If there is only one link, it
6961 will be followed without a selection prompt.
6963 @tsubheading{Change display}
6964 @cindex display changing, in agenda
6965 @kindex o
6966 @item o
6967 Delete other windows.
6969 @kindex v d
6970 @kindex d
6971 @kindex v w
6972 @kindex w
6973 @kindex v m
6974 @kindex v y
6975 @item v d @ @r{or short} @ d
6976 @itemx v w @ @r{or short} @ w
6977 @itemx v m
6978 @itemx v y
6979 Switch to day/week/month/year view.  When switching to day or week view,
6980 this setting becomes the default for subsequent agenda commands.  Since
6981 month and year views are slow to create, they do not become the default.
6982 A numeric prefix argument may be used to jump directly to a specific day
6983 of the year, ISO week, month, or year, respectively.  For example,
6984 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
6985 setting day, week, or month view, a year may be encoded in the prefix
6986 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
6987 2007.  If such a year specification has only one or two digits, it will
6988 be mapped to the interval 1938-2037.
6990 @kindex f
6991 @item f
6992 @vindex org-agenda-ndays
6993 Go forward in time to display the following @code{org-agenda-ndays} days.
6994 For example, if the display covers a week, switch to the following week.
6995 With prefix arg, go forward that many times @code{org-agenda-ndays} days.
6997 @kindex b
6998 @item b
6999 Go backward in time to display earlier dates.
7001 @kindex .
7002 @item .
7003 Go to today.
7005 @kindex j
7006 @item j
7007 Prompt for a date and go there.
7009 @kindex D
7010 @item D
7011 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
7013 @kindex v l
7014 @kindex l
7015 @item v l @ @r{or short} @ l
7016 @vindex org-log-done
7017 @vindex org-agenda-log-mode-items
7018 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
7019 logging was on (variable @code{org-log-done}) are shown in the agenda, as are
7020 entries that have been clocked on that day.  You can configure the entry
7021 types that should be included in log mode using the variable
7022 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
7023 all possible logbook entries, including state changes.  When called with two
7024 prefix args @kbd{C-u C-u}, show only logging information, nothing else.
7026 @kindex v [
7027 @kindex [
7028 @item v [ @ @r{or short} @ [
7029 Include inactive timestamps into the current view.  Only for weekly/daily
7030 agenda and timeline views.
7032 @kindex v a
7033 @kindex v A
7034 @item v a
7035 @itemx v A
7036 Toggle Archives mode.  In Archives mode, trees that are marked
7037 @code{ARCHIVED} are also scanned when producing the agenda.  When you use the
7038 capital @kbd{A}, even all archive files are included.  To exit archives mode,
7039 press @kbd{v a} again.
7041 @kindex v R
7042 @kindex R
7043 @item v R @ @r{or short} @ R
7044 @vindex org-agenda-start-with-clockreport-mode
7045 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly agenda will
7046 always show a table with the clocked times for the timespan and file scope
7047 covered by the current agenda view.  The initial setting for this mode in new
7048 agenda buffers can be set with the variable
7049 @code{org-agenda-start-with-clockreport-mode}.
7051 @kindex v E
7052 @kindex E
7053 @item v E @ @r{or short} @ E
7054 @vindex org-agenda-start-with-entry-text-mode
7055 @vindex org-agenda-entry-text-maxlines
7056 Toggle entry text mode.  In entry text mode, a number of lines from the Org
7057 outline node referenced by an agenda line will be displayed below the line.
7058 The maximum number of lines is given by the variable
7059 @code{org-agenda-entry-text-maxlines}.  Calling this command with a numeric
7060 prefix argument will temporarily modify that number to the prefix value.
7062 @kindex G
7063 @item G
7064 @vindex org-agenda-use-time-grid
7065 @vindex org-agenda-time-grid
7066 Toggle the time grid on and off.  See also the variables
7067 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
7069 @kindex r
7070 @item r
7071 Recreate the agenda buffer, for example to reflect the changes after
7072 modification of the timestamps of items with @kbd{S-@key{left}} and
7073 @kbd{S-@key{right}}.  When the buffer is the global TODO list, a prefix
7074 argument is interpreted to create a selective list for a specific TODO
7075 keyword.
7076 @kindex g
7077 @item g
7078 Same as @kbd{r}.
7080 @kindex s
7081 @kindex C-x C-s
7082 @item s
7083 @itemx C-x C-s
7084 Save all Org buffers in the current Emacs session, and also the locations of
7085 IDs.
7087 @kindex C-c C-x C-c
7088 @item C-c C-x C-c
7089 @vindex org-columns-default-format
7090 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
7091 view format is taken from the entry at point, or (if there is no entry at
7092 point), from the first entry in the agenda view.  So whatever the format for
7093 that entry would be in the original buffer (taken from a property, from a
7094 @code{#+COLUMNS} line, or from the default variable
7095 @code{org-columns-default-format}), will be used in the agenda.
7097 @kindex C-c C-x >
7098 @item C-c C-x >
7099 Remove the restriction lock on the agenda, if it is currently restricted to a
7100 file or subtree (@pxref{Agenda files}).
7102 @tsubheading{Secondary filtering and query editing}
7103 @cindex filtering, by tag and effort, in agenda
7104 @cindex tag filtering, in agenda
7105 @cindex effort filtering, in agenda
7106 @cindex query editing, in agenda
7108 @kindex /
7109 @item /
7110 @vindex org-agenda-filter-preset
7111 Filter the current agenda view with respect to a tag and/or effort estimates.
7112 The difference between this and a custom agenda command is that filtering is
7113 very fast, so that you can switch quickly between different filters without
7114 having to recreate the agenda@footnote{Custom commands can preset a filter by
7115 binding the variable @code{org-agenda-filter-preset} as an option.  This
7116 filter will then be applied to the view and persist as a basic filter through
7117 refreshes and more secondary filtering.}
7119 You will be prompted for a tag selection letter.  Pressing @key{TAB} at that
7120 prompt will offer use completion to select a tag (including any tags that do
7121 not have a selection character).  The command then hides all entries that do
7122 not contain or inherit this tag.  When called with prefix arg, remove the
7123 entries that @emph{do} have the tag.  A second @kbd{/} at the prompt will
7124 turn off the filter and unhide any hidden entries.  If the first key you
7125 press is either @kbd{+} or @kbd{-}, the previous filter will be narrowed by
7126 requiring or forbidding the selected additional tag.  Instead of pressing
7127 @kbd{+} or @kbd{-} after @kbd{/}, you can also immediately use the @kbd{\}
7128 command.
7130 @vindex org-sort-agenda-noeffort-is-high
7131 In order to filter for effort estimates, you should set-up allowed
7132 efforts globally, for example
7133 @lisp
7134 (setq org-global-properties
7135     '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
7136 @end lisp
7137 You can then filter for an effort by first typing an operator, one of
7138 @kbd{<}, @kbd{>}, and @kbd{=}, and then the one-digit index of an effort
7139 estimate in your array of allowed values, where @kbd{0} means the 10th value.
7140 The filter will then restrict to entries with effort smaller-or-equal, equal,
7141 or larger-or-equal than the selected value.  If the digits 0-9 are not used
7142 as fast access keys to tags, you can also simply press the index digit
7143 directly without an operator.  In this case, @kbd{<} will be assumed.  For
7144 application of the operator, entries without a defined effort will be treated
7145 according to the value of @code{org-sort-agenda-noeffort-is-high}.  To filter
7146 for tasks without effort definition, press @kbd{?} as the operator.
7148 @kindex \
7149 @item \
7150 Narrow the current agenda filter by an additional condition.  When called with
7151 prefix arg, remove the entries that @emph{do} have the tag, or that do match
7152 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
7153 @kbd{-} as the first key after the @kbd{/} command.
7155 @kindex [
7156 @kindex ]
7157 @kindex @{
7158 @kindex @}
7159 @item [ ] @{ @}
7160 @table @i
7161 @item @r{in} search view
7162 add new search words (@kbd{[} and @kbd{]}) or new regular expressions
7163 (@kbd{@{} and @kbd{@}}) to the query string.  The opening bracket/brace will
7164 add a positive search term prefixed by @samp{+}, indicating that this search
7165 term @i{must} occur/match in the entry.  The closing bracket/brace will add a
7166 negative search term which @i{must not} occur/match in the entry for it to be
7167 selected.
7168 @end table
7170 @tsubheading{Remote editing}
7171 @cindex remote editing, from agenda
7173 @item 0-9
7174 Digit argument.
7176 @cindex undoing remote-editing events
7177 @cindex remote editing, undo
7178 @kindex C-_
7179 @item C-_
7180 Undo a change due to a remote editing command.  The change is undone
7181 both in the agenda buffer and in the remote buffer.
7183 @kindex t
7184 @item t
7185 Change the TODO state of the item, both in the agenda and in the
7186 original org file.
7188 @kindex C-k
7189 @item C-k
7190 @vindex org-agenda-confirm-kill
7191 Delete the current agenda item along with the entire subtree belonging
7192 to it in the original Org file.  If the text to be deleted remotely
7193 is longer than one line, the kill needs to be confirmed by the user.  See
7194 variable @code{org-agenda-confirm-kill}.
7196 @kindex C-c C-w
7197 @item C-c C-w
7198 Refile the entry at point.
7200 @kindex a
7201 @item a
7202 Toggle the ARCHIVE tag for the current headline.
7204 @kindex A
7205 @item A
7206 Move the subtree corresponding to the current entry to its @emph{archive
7207 sibling}.
7209 @kindex $
7210 @item $
7211 Archive the subtree corresponding to the current headline.  This means the
7212 entry will be moved to the configured archive location, most likely a
7213 different file.
7215 @kindex T
7216 @item T
7217 @vindex org-agenda-show-inherited-tags
7218 Show all tags associated with the current item.  This is useful if you have
7219 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
7220 tags of a headline occasionally.
7222 @kindex :
7223 @item :
7224 Set tags for the current headline.  If there is an active region in the
7225 agenda, change a tag for all headings in the region.
7227 @kindex ,
7228 @item ,
7229 Set the priority for the current item.  Org mode prompts for the
7230 priority character. If you reply with @key{SPC}, the priority cookie
7231 is removed from the entry.
7233 @kindex P
7234 @item P
7235 Display weighted priority of current item.
7237 @kindex +
7238 @kindex S-@key{up}
7239 @item +
7240 @itemx S-@key{up}
7241 Increase the priority of the current item.  The priority is changed in
7242 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
7243 key for this.
7245 @kindex -
7246 @kindex S-@key{down}
7247 @item -
7248 @itemx S-@key{down}
7249 Decrease the priority of the current item.
7251 @kindex z
7252 @item z
7253 @vindex org-log-into-drawer
7254 Add a note to the entry.  This note will be recorded, and then files to the
7255 same location where state change notes are put.  Depending on
7256 @code{org-log-into-drawer}, this maybe inside a drawer.
7258 @kindex C-c C-a
7259 @item C-c C-a
7260 Dispatcher for all command related to attachments.
7262 @kindex C-c C-s
7263 @item C-c C-s
7264 Schedule this item
7266 @kindex C-c C-d
7267 @item C-c C-d
7268 Set a deadline for this item.
7270 @kindex k
7271 @item k
7272 Agenda actions, to set dates for selected items to the cursor date.
7273 This command also works in the calendar!  The command prompts for an
7274 additional key:
7275 @example
7276 m   @r{Mark the entry at point for action.  You can also make entries}
7277     @r{in Org files with @kbd{C-c C-x C-k}.}
7278 d   @r{Set the deadline of the marked entry to the date at point.}
7279 s   @r{Schedule the marked entry at the date at point.}
7280 r   @r{Call @code{org-remember} with the cursor date as default date.}
7281 @end example
7282 @noindent
7283 Press @kbd{r} afterward to refresh the agenda and see the effect of the
7284 command.
7286 @kindex S-@key{right}
7287 @item S-@key{right}
7288 Change the timestamp associated with the current line by one day into the
7289 future.  With a numeric prefix argument, change it by that many days.  For
7290 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  With a
7291 @kbd{C-u} prefix, change the time by one hour.  If you immediately repeat the
7292 command, it will continue to change hours even without the prefix arg.  With
7293 a double @kbd{C-u C-u} prefix, do the same for changing minutes.  The stamp
7294 is changed in the original Org file, but the change is not directly reflected
7295 in the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
7297 @kindex S-@key{left}
7298 @item S-@key{left}
7299 Change the timestamp associated with the current line by one day
7300 into the past.
7302 @kindex >
7303 @item >
7304 Change the timestamp associated with the current line to today.
7305 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
7306 on my keyboard.
7308 @kindex I
7309 @item I
7310 Start the clock on the current item.  If a clock is running already, it
7311 is stopped first.
7313 @kindex O
7314 @item O
7315 Stop the previously started clock.
7317 @kindex X
7318 @item X
7319 Cancel the currently running clock.
7321 @kindex J
7322 @item J
7323 Jump to the running clock in another window.
7325 @tsubheading{Bulk remote editing selected entries}
7326 @cindex remote editing, bulk, from agenda
7328 @kindex m
7329 @item s
7330 Mark the entry at point for bulk action.
7332 @kindex u
7333 @item u
7334 Unmark entry for bulk action.
7336 @kindex U
7337 @item U
7338 Unmark all marked entries for bulk action.
7340 @kindex B
7341 @item B
7342 Bulk action: act on all marked entries in the agenda.  This will prompt for
7343 another key to select the action to be applied:
7344 @example
7345 r  @r{Prompt for a single refile target and move all entries.  The entries}
7346    @r{will no longer be in the agenda, refresh (@kbd{g}) to bring them back.}
7347 $  @r{Archive all selected entries.}
7348 A  @r{Archive entries by moving them to their respective archive siblings.}
7349 t  @r{Change TODO state.  This prompts for a single TODO keyword and}
7350    @r{changes the state of all selected entries, bypassing blocking and}
7351    @r{suppressing logging notes (but not time stamps).}
7352 +  @r{Add a tag to all selected entries.}
7353 -  @r{Remove a tag from all selected entries.}
7354 s  @r{Schedule all items to a new date.  To shift existing schedule dates}
7355    @r{by a fixed number of days, use something starting with double plus}
7356    @r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
7357 d  @r{Set deadline to a specific date.}
7358 @end example
7361 @tsubheading{Calendar commands}
7362 @cindex calendar commands, from agenda
7363 @kindex c
7364 @item c
7365 Open the Emacs calendar and move to the date at the agenda cursor.
7367 @item c
7368 When in the calendar, compute and show the Org mode agenda for the
7369 date at the cursor.
7371 @cindex diary entries, creating from agenda
7372 @kindex i
7373 @item i
7374 Insert a new entry into the diary.  Prompts for the type of entry
7375 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
7376 entry in the diary, just as @kbd{i d}, etc., would do in the calendar.
7377 The date is taken from the cursor position.
7379 @kindex M
7380 @item M
7381 Show the phases of the moon for the three months around current date.
7383 @kindex S
7384 @item S
7385 Show sunrise and sunset times.  The geographical location must be set
7386 with calendar variables, see the documentation for the Emacs calendar.
7388 @kindex C
7389 @item C
7390 Convert the date at cursor into many other cultural and historic
7391 calendars.
7393 @kindex H
7394 @item H
7395 Show holidays for three months around the cursor date.
7397 @item M-x org-export-icalendar-combine-agenda-files
7398 Export a single iCalendar file containing entries from all agenda files.
7399 This is a globally available command, and also available in the agenda menu.
7401 @tsubheading{Exporting to a file}
7402 @kindex C-x C-w
7403 @item C-x C-w
7404 @cindex exporting agenda views
7405 @cindex agenda views, exporting
7406 @vindex org-agenda-exporter-settings
7407 Write the agenda view to a file.  Depending on the extension of the selected
7408 file name, the view will be exported as HTML (extension @file{.html} or
7409 @file{.htm}), Postscript (extension @file{.ps}), PDF (extension @file{.pdf}),
7410 or plain text (any other extension).  When called with a @kbd{C-u} prefix
7411 argument, immediately open the newly created file.  Use the variable
7412 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
7413 for @file{htmlize} to be used during export.
7415 @tsubheading{Quit and Exit}
7416 @kindex q
7417 @item q
7418 Quit agenda, remove the agenda buffer.
7420 @kindex x
7421 @cindex agenda files, removing buffers
7422 @item x
7423 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
7424 for the compilation of the agenda.  Buffers created by the user to
7425 visit Org files will not be removed.
7426 @end table
7429 @node Custom agenda views, Exporting Agenda Views, Agenda commands, Agenda Views
7430 @section Custom agenda views
7431 @cindex custom agenda views
7432 @cindex agenda views, custom
7434 Custom agenda commands serve two purposes: to store and quickly access
7435 frequently used TODO and tags searches, and to create special composite
7436 agenda buffers.  Custom agenda commands will be accessible through the
7437 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
7439 @menu
7440 * Storing searches::            Type once, use often
7441 * Block agenda::                All the stuff you need in a single buffer
7442 * Setting Options::             Changing the rules
7443 @end menu
7445 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
7446 @subsection Storing searches
7448 The first application of custom searches is the definition of keyboard
7449 shortcuts for frequently used searches, either creating an agenda
7450 buffer, or a sparse tree (the latter covering of course only the current
7451 buffer).
7452 @kindex C-c a C
7453 @vindex org-agenda-custom-commands
7454 Custom commands are configured in the variable
7455 @code{org-agenda-custom-commands}.  You can customize this variable, for
7456 example by pressing @kbd{C-c a C}.  You can also directly set it with
7457 Emacs Lisp in @file{.emacs}.  The following example contains all valid
7458 search types:
7460 @lisp
7461 @group
7462 (setq org-agenda-custom-commands
7463       '(("w" todo "WAITING")
7464         ("W" todo-tree "WAITING")
7465         ("u" tags "+boss-urgent")
7466         ("v" tags-todo "+boss-urgent")
7467         ("U" tags-tree "+boss-urgent")
7468         ("f" occur-tree "\\<FIXME\\>")
7469         ("h" . "HOME+Name tags searches") ; description for "h" prefix
7470         ("hl" tags "+home+Lisa")
7471         ("hp" tags "+home+Peter")
7472         ("hk" tags "+home+Kim")))
7473 @end group
7474 @end lisp
7476 @noindent
7477 The initial string in each entry defines the keys you have to press
7478 after the dispatcher command @kbd{C-c a} in order to access the command.
7479 Usually this will be just a single character, but if you have many
7480 similar commands, you can also define two-letter combinations where the
7481 first character is the same in several combinations and serves as a
7482 prefix key@footnote{You can provide a description for a prefix key by
7483 inserting a cons cell with the prefix and the description.}.  The second
7484 parameter is the search type, followed by the string or regular
7485 expression to be used for the matching.  The example above will
7486 therefore define:
7488 @table @kbd
7489 @item C-c a w
7490 as a global search for TODO entries with @samp{WAITING} as the TODO
7491 keyword
7492 @item C-c a W
7493 as the same search, but only in the current buffer and displaying the
7494 results as a sparse tree
7495 @item C-c a u
7496 as a global tags search for headlines marked @samp{:boss:} but not
7497 @samp{:urgent:}
7498 @item C-c a v
7499 as the same search as @kbd{C-c a u}, but limiting the search to
7500 headlines that are also TODO items
7501 @item C-c a U
7502 as the same search as @kbd{C-c a u}, but only in the current buffer and
7503 displaying the result as a sparse tree
7504 @item C-c a f
7505 to create a sparse tree (again: current buffer only) with all entries
7506 containing the word @samp{FIXME}
7507 @item C-c a h
7508 as a prefix command for a HOME tags search where you have to press an
7509 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
7510 Peter, or Kim) as additional tag to match.
7511 @end table
7513 @node Block agenda, Setting Options, Storing searches, Custom agenda views
7514 @subsection Block agenda
7515 @cindex block agenda
7516 @cindex agenda, with block views
7518 Another possibility is the construction of agenda views that comprise
7519 the results of @emph{several} commands, each of which creates a block in
7520 the agenda buffer.  The available commands include @code{agenda} for the
7521 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
7522 for the global TODO list (as constructed with @kbd{C-c a t}), and the
7523 matching commands discussed above: @code{todo}, @code{tags}, and
7524 @code{tags-todo}.  Here are two examples:
7526 @lisp
7527 @group
7528 (setq org-agenda-custom-commands
7529       '(("h" "Agenda and Home-related tasks"
7530          ((agenda "")
7531           (tags-todo "home")
7532           (tags "garden")))
7533         ("o" "Agenda and Office-related tasks"
7534          ((agenda "")
7535           (tags-todo "work")
7536           (tags "office")))))
7537 @end group
7538 @end lisp
7540 @noindent
7541 This will define @kbd{C-c a h} to create a multi-block view for stuff
7542 you need to attend to at home.  The resulting agenda buffer will contain
7543 your agenda for the current week, all TODO items that carry the tag
7544 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
7545 command @kbd{C-c a o} provides a similar view for office tasks.
7547 @node Setting Options,  , Block agenda, Custom agenda views
7548 @subsection Setting options for custom commands
7549 @cindex options, for custom agenda views
7551 @vindex org-agenda-custom-commands
7552 Org mode contains a number of variables regulating agenda construction
7553 and display.  The global variables define the behavior for all agenda
7554 commands, including the custom commands.  However, if you want to change
7555 some settings just for a single custom view, you can do so.  Setting
7556 options requires inserting a list of variable names and values at the
7557 right spot in @code{org-agenda-custom-commands}.  For example:
7559 @lisp
7560 @group
7561 (setq org-agenda-custom-commands
7562       '(("w" todo "WAITING"
7563          ((org-agenda-sorting-strategy '(priority-down))
7564           (org-agenda-prefix-format "  Mixed: ")))
7565         ("U" tags-tree "+boss-urgent"
7566          ((org-show-following-heading nil)
7567           (org-show-hierarchy-above nil)))
7568         ("N" search ""
7569          ((org-agenda-files '("~org/notes.org"))
7570           (org-agenda-text-search-extra-files nil)))))
7571 @end group
7572 @end lisp
7574 @noindent
7575 Now the @kbd{C-c a w} command will sort the collected entries only by
7576 priority, and the prefix format is modified to just say @samp{  Mixed: }
7577 instead of giving the category of the entry.  The sparse tags tree of
7578 @kbd{C-c a U} will now turn out ultra-compact, because neither the
7579 headline hierarchy above the match, nor the headline following the match
7580 will be shown.  The command @kbd{C-c a N} will do a text search limited
7581 to only a single file.
7583 @vindex org-agenda-custom-commands
7584 For command sets creating a block agenda,
7585 @code{org-agenda-custom-commands} has two separate spots for setting
7586 options.  You can add options that should be valid for just a single
7587 command in the set, and options that should be valid for all commands in
7588 the set.  The former are just added to the command entry, the latter
7589 must come after the list of command entries.  Going back to the block
7590 agenda example (@pxref{Block agenda}), let's change the sorting strategy
7591 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
7592 the results for GARDEN tags query in the opposite order,
7593 @code{priority-up}.  This would look like this:
7595 @lisp
7596 @group
7597 (setq org-agenda-custom-commands
7598       '(("h" "Agenda and Home-related tasks"
7599          ((agenda)
7600           (tags-todo "home")
7601           (tags "garden"
7602                 ((org-agenda-sorting-strategy '(priority-up)))))
7603          ((org-agenda-sorting-strategy '(priority-down))))
7604         ("o" "Agenda and Office-related tasks"
7605          ((agenda)
7606           (tags-todo "work")
7607           (tags "office")))))
7608 @end group
7609 @end lisp
7611 As you see, the values and parentheses setting is a little complex.
7612 When in doubt, use the customize interface to set this variable---it
7613 fully supports its structure.  Just one caveat: when setting options in
7614 this interface, the @emph{values} are just Lisp expressions.  So if the
7615 value is a string, you need to add the double-quotes around the value
7616 yourself.
7619 @node Exporting Agenda Views, Agenda column view, Custom agenda views, Agenda Views
7620 @section Exporting Agenda Views
7621 @cindex agenda views, exporting
7623 If you are away from your computer, it can be very useful to have a printed
7624 version of some agenda views to carry around.  Org mode can export custom
7625 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
7626 @file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
7627 ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
7628 a PDF file with also create the postscript file.}, and iCalendar files.  If
7629 you want to do this only occasionally, use the command
7631 @table @kbd
7632 @kindex C-x C-w
7633 @item C-x C-w
7634 @cindex exporting agenda views
7635 @cindex agenda views, exporting
7636 @vindex org-agenda-exporter-settings
7637 Write the agenda view to a file.  Depending on the extension of the
7638 selected file name, the view will be exported as HTML (extension
7639 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}),
7640 iCalendar (extension @file{.ics}), or plain text (any other extension).
7641 Use the variable @code{org-agenda-exporter-settings} to
7642 set options for @file{ps-print} and for @file{htmlize} to be used during
7643 export, for example
7645 @vindex org-agenda-add-entry-text-maxlines
7646 @vindex htmlize-output-type
7647 @vindex ps-number-of-columns
7648 @vindex ps-landscape-mode
7649 @lisp
7650 (setq org-agenda-exporter-settings
7651       '((ps-number-of-columns 2)
7652         (ps-landscape-mode t)
7653         (org-agenda-add-entry-text-maxlines 5)
7654         (htmlize-output-type 'css)))
7655 @end lisp
7656 @end table
7658 If you need to export certain agenda views frequently, you can associate
7659 any custom agenda command with a list of output file names
7660 @footnote{If you want to store standard views like the weekly agenda
7661 or the global TODO list as well, you need to define custom commands for
7662 them in order to be able to specify file names.}.  Here is an example
7663 that first defines custom commands for the agenda and the global
7664 TODO list, together with a number of files to which to export them.
7665 Then we define two block agenda commands and specify file names for them
7666 as well.  File names can be relative to the current working directory,
7667 or absolute.
7669 @lisp
7670 @group
7671 (setq org-agenda-custom-commands
7672       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
7673         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
7674         ("h" "Agenda and Home-related tasks"
7675          ((agenda "")
7676           (tags-todo "home")
7677           (tags "garden"))
7678          nil
7679          ("~/views/home.html"))
7680         ("o" "Agenda and Office-related tasks"
7681          ((agenda)
7682           (tags-todo "work")
7683           (tags "office"))
7684          nil
7685          ("~/views/office.ps" "~/calendars/office.ics"))))
7686 @end group
7687 @end lisp
7689 The extension of the file name determines the type of export.  If it is
7690 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
7691 the buffer to HTML and save it to this file name.  If the extension is
7692 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
7693 Postscript output.  If the extension is @file{.ics}, iCalendar export is
7694 run export over all files that were used to construct the agenda, and
7695 limit the export to entries listed in the agenda.  Any other
7696 extension produces a plain ASCII file.
7698 The export files are @emph{not} created when you use one of those
7699 commands interactively because this might use too much overhead.
7700 Instead, there is a special command to produce @emph{all} specified
7701 files in one step:
7703 @table @kbd
7704 @kindex C-c a e
7705 @item C-c a e
7706 Export all agenda views that have export file names associated with
7707 them.
7708 @end table
7710 You can use the options section of the custom agenda commands to also
7711 set options for the export commands.  For example:
7713 @lisp
7714 (setq org-agenda-custom-commands
7715       '(("X" agenda ""
7716          ((ps-number-of-columns 2)
7717           (ps-landscape-mode t)
7718           (org-agenda-prefix-format " [ ] ")
7719           (org-agenda-with-colors nil)
7720           (org-agenda-remove-tags t))
7721          ("theagenda.ps"))))
7722 @end lisp
7724 @noindent
7725 This command sets two options for the Postscript exporter, to make it
7726 print in two columns in landscape format---the resulting page can be cut
7727 in two and then used in a paper agenda.  The remaining settings modify
7728 the agenda prefix to omit category and scheduling information, and
7729 instead include a checkbox to check off items.  We also remove the tags
7730 to make the lines compact, and we don't want to use colors for the
7731 black-and-white printer.  Settings specified in
7732 @code{org-agenda-exporter-settings} will also apply, but the settings
7733 in @code{org-agenda-custom-commands} take precedence.
7735 @noindent
7736 From the command line you may also use
7737 @example
7738 emacs -f org-batch-store-agenda-views -kill
7739 @end example
7740 @noindent
7741 or, if you need to modify some parameters@footnote{Quoting depends on the
7742 system you use, please check the FAQ for examples.}
7743 @example
7744 emacs -eval '(org-batch-store-agenda-views                      \
7745               org-agenda-ndays 30                               \
7746               org-agenda-start-day "2007-11-01"                 \
7747               org-agenda-include-diary nil                      \
7748               org-agenda-files (quote ("~/org/project.org")))'  \
7749       -kill
7750 @end example
7751 @noindent
7752 which will create the agenda views restricted to the file
7753 @file{~/org/project.org}, without diary entries and with a 30-day
7754 extent.
7756 You can also extract agenda information in a way that allows further
7757 processing by other programs.  See @ref{Extracting agenda information}, for
7758 more information.
7761 @node Agenda column view,  , Exporting Agenda Views, Agenda Views
7762 @section Using column view in the agenda
7763 @cindex column view, in agenda
7764 @cindex agenda, column view
7766 Column view (@pxref{Column view}) is normally used to view and edit
7767 properties embedded in the hierarchical structure of an Org file.  It can be
7768 quite useful to use column view also from the agenda, where entries are
7769 collected by certain criteria.
7771 @table @kbd
7772 @kindex C-c C-x C-c
7773 @item C-c C-x C-c
7774 Turn on column view in the agenda.
7775 @end table
7777 To understand how to use this properly, it is important to realize that the
7778 entries in the agenda are no longer in their proper outline environment.
7779 This causes the following issues:
7781 @enumerate
7782 @item
7783 @vindex org-columns-default-format
7784 @vindex org-overriding-columns-format
7785 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
7786 entries in the agenda are collected from different files, and different files
7787 may have different @code{COLUMNS} formats, this is a non-trivial problem.
7788 Org first checks if the variable @code{org-overriding-columns-format} is
7789 currently set, and if so, takes the format from there.  Otherwise it takes
7790 the format associated with the first item in the agenda, or, if that item
7791 does not have a specific format (defined in a property, or in its file), it
7792 uses @code{org-columns-default-format}.
7793 @item
7794 @cindex property, special, CLOCKSUM
7795 If any of the columns has a summary type defined (@pxref{Column attributes}),
7796 turning on column view in the agenda will visit all relevant agenda files and
7797 make sure that the computations of this property are up to date.  This is
7798 also true for the special @code{CLOCKSUM} property.  Org will then sum the
7799 values displayed in the agenda.  In the daily/weekly agenda, the sums will
7800 cover a single day, in all other views they cover the entire block.  It is
7801 vital to realize that the agenda may show the same entry @emph{twice} (for
7802 example as scheduled and as a deadline), and it may show two entries from the
7803 same hierarchy (for example a @emph{parent} and its @emph{child}).  In these
7804 cases, the summation in the agenda will lead to incorrect results because
7805 some values will count double.
7806 @item
7807 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
7808 the entire clocked time for this item.  So even in the daily/weekly agenda,
7809 the clocksum listed in column view may originate from times outside the
7810 current view.  This has the advantage that you can compare these values with
7811 a column listing the planned total effort for a task---one of the major
7812 applications for column view in the agenda.  If you want information about
7813 clocked time in the displayed period use clock table mode (press @kbd{R} in
7814 the agenda).
7815 @end enumerate
7818 @node Embedded LaTeX, Exporting, Agenda Views, Top
7819 @chapter Embedded La@TeX{}
7820 @cindex @TeX{} interpretation
7821 @cindex La@TeX{} interpretation
7823 Plain ASCII is normally sufficient for almost all note taking.  One
7824 exception, however, are scientific notes which need to be able to contain
7825 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
7826 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
7827 features described here as ``La@TeX{}'' are really from @TeX{}, but for
7828 simplicity I am blurring this distinction.}  is widely used to typeset
7829 scientific documents. Org mode supports embedding La@TeX{} code into its
7830 files, because many academics are used to reading La@TeX{} source code, and
7831 because it can be readily processed into images for HTML production.
7833 It is not necessary to mark La@TeX{} macros and code in any special way.
7834 If you observe a few conventions, Org mode knows how to find it and what
7835 to do with it.
7837 @menu
7838 * Math symbols::                @TeX{} macros for symbols and Greek letters
7839 * Subscripts and superscripts::  Simple syntax for raising/lowering text
7840 * LaTeX fragments::             Complex formulas made easy
7841 * Processing LaTeX fragments::  Previewing La@TeX{} processing
7842 * CDLaTeX mode::                Speed up entering of formulas
7843 @end menu
7845 @node Math symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
7846 @section Math symbols
7847 @cindex math symbols
7848 @cindex @TeX{} macros
7850 You can use La@TeX{} macros to insert special symbols like @samp{\alpha} to
7851 indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
7852 for these macros is available, just type @samp{\} and maybe a few letters,
7853 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike La@TeX{}
7854 code, Org mode allows these macros to be present without surrounding math
7855 delimiters, for example:
7857 @example
7858 Angles are written as Greek letters \alpha, \beta and \gamma.
7859 @end example
7860 @noindent
7861 During HTML export (@pxref{HTML export}), these symbols are translated
7862 into the proper syntax for HTML, for the above examples this is
7863 @samp{&alpha;} and @samp{&rarr;}, respectively.  If you need such a symbol
7864 inside a word, terminate it like this: @samp{\Aacute@{@}stor}.
7866 @node Subscripts and superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
7867 @section Subscripts and superscripts
7868 @cindex subscript
7869 @cindex superscript
7871 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
7872 and subscripts.  Again, these can be used without embedding them in
7873 math-mode delimiters.  To increase the readability of ASCII text, it is
7874 not necessary (but OK) to surround multi-character sub- and superscripts
7875 with curly braces.  For example
7877 @example
7878 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
7879 the sun is R_@{sun@} = 6.96 x 10^8 m.
7880 @end example
7882 To avoid interpretation as raised or lowered text, you can quote
7883 @samp{^} and @samp{_} with a backslash: @samp{\^} and @samp{\_}.
7885 During HTML export (@pxref{HTML export}), subscript and superscripts
7886 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
7888 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
7889 @section La@TeX{} fragments
7890 @cindex La@TeX{} fragments
7892 @vindex org-format-latex-header
7893 With symbols, sub- and superscripts, HTML is pretty much at its end when
7894 it comes to representing mathematical formulas@footnote{Yes, there is
7895 MathML, but that is not yet fully supported by many browsers, and there
7896 is no decent converter for turning La@TeX{} or ASCII representations of
7897 formulas into MathML. So for the time being, converting formulas into
7898 images seems the way to go.}. More complex expressions need a dedicated
7899 formula processor. To this end, Org mode can contain arbitrary La@TeX{}
7900 fragments. It provides commands to preview the typeset result of these
7901 fragments, and upon export to HTML, all fragments will be converted to
7902 images and inlined into the HTML document@footnote{The La@TeX{} export
7903 will not use images for displaying La@TeX{} fragments but include these
7904 fragments directly into the La@TeX{} code.}. For this to work you
7905 need to be on a system with a working La@TeX{} installation. You also
7906 need the @file{dvipng} program, available at
7907 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
7908 will be used when processing a fragment can be configured with the
7909 variable @code{org-format-latex-header}.
7911 La@TeX{} fragments don't need any special marking at all.  The following
7912 snippets will be identified as La@TeX{} source code:
7913 @itemize @bullet
7914 @item
7915 Environments of any kind.  The only requirement is that the
7916 @code{\begin} statement appears on a new line, preceded by only
7917 whitespace.
7918 @item
7919 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
7920 currency specifications, single @samp{$} characters are only recognized as
7921 math delimiters if the enclosed text contains at most two line breaks, is
7922 directly attached to the @samp{$} characters with no whitespace in between,
7923 and if the closing @samp{$} is followed by whitespace, punctuation or a dash.
7924 For the other delimiters, there is no such restriction, so when in doubt, use
7925 @samp{\(...\)} as inline math delimiters.
7926 @end itemize
7928 @noindent For example:
7930 @example
7931 \begin@{equation@}                          % arbitrary environments,
7932 x=\sqrt@{b@}                                % even tables, figures
7933 \end@{equation@}                            % etc
7935 If $a^2=b$ and \( b=2 \), then the solution must be
7936 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
7937 @end example
7939 @noindent
7940 @vindex org-format-latex-options
7941 If you need any of the delimiter ASCII sequences for other purposes, you
7942 can configure the option @code{org-format-latex-options} to deselect the
7943 ones you do not wish to have interpreted by the La@TeX{} converter.
7945 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
7946 @section Processing LaTeX fragments
7947 @cindex LaTeX fragments, preview
7949 La@TeX{} fragments can be processed to produce preview images of the
7950 typeset expressions:
7952 @table @kbd
7953 @kindex C-c C-x C-l
7954 @item C-c C-x C-l
7955 Produce a preview image of the La@TeX{} fragment at point and overlay it
7956 over the source code.  If there is no fragment at point, process all
7957 fragments in the current entry (between two headlines).  When called
7958 with a prefix argument, process the entire subtree.  When called with
7959 two prefix arguments, or when the cursor is before the first headline,
7960 process the entire buffer.
7961 @kindex C-c C-c
7962 @item C-c C-c
7963 Remove the overlay preview images.
7964 @end table
7966 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
7967 converted into images and inlined into the document if the following
7968 setting is active:
7970 @lisp
7971 (setq org-export-with-LaTeX-fragments t)
7972 @end lisp
7974 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
7975 @section Using CDLa@TeX{} to enter math
7976 @cindex CDLa@TeX{}
7978 CDLa@TeX{} mode is a minor mode that is normally used in combination with a
7979 major La@TeX{} mode like AUC@TeX{} in order to speed-up insertion of
7980 environments and math templates.  Inside Org mode, you can make use of
7981 some of the features of CDLa@TeX{} mode.  You need to install
7982 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
7983 AUC@TeX{}) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
7984 Don't use CDLa@TeX{} mode itself under Org mode, but use the light
7985 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
7986 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
7987 Org files with
7989 @lisp
7990 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
7991 @end lisp
7993 When this mode is enabled, the following features are present (for more
7994 details see the documentation of CDLa@TeX{} mode):
7995 @itemize @bullet
7996 @kindex C-c @{
7997 @item
7998 Environment templates can be inserted with @kbd{C-c @{}.
7999 @item
8000 @kindex @key{TAB}
8001 The @key{TAB} key will do template expansion if the cursor is inside a
8002 La@TeX{} fragment@footnote{Org mode has a method to test if the cursor is
8003 inside such a fragment, see the documentation of the function
8004 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
8005 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
8006 correctly inside the first brace.  Another @key{TAB} will get you into
8007 the second brace.  Even outside fragments, @key{TAB} will expand
8008 environment abbreviations at the beginning of a line.  For example, if
8009 you write @samp{equ} at the beginning of a line and press @key{TAB},
8010 this abbreviation will be expanded to an @code{equation} environment.
8011 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
8012 @item
8013 @kindex _
8014 @kindex ^
8015 @vindex cdlatex-simplify-sub-super-scripts
8016 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
8017 characters together with a pair of braces.  If you use @key{TAB} to move
8018 out of the braces, and if the braces surround only a single character or
8019 macro, they are removed again (depending on the variable
8020 @code{cdlatex-simplify-sub-super-scripts}).
8021 @item
8022 @kindex `
8023 Pressing the backquote @kbd{`} followed by a character inserts math
8024 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
8025 after the backquote, a help window will pop up.
8026 @item
8027 @kindex '
8028 Pressing the single-quote @kbd{'} followed by another character modifies
8029 the symbol before point with an accent or a font.  If you wait more than
8030 1.5 seconds after the backquote, a help window will pop up.  Character
8031 modification will work only inside La@TeX{} fragments, outside the quote
8032 is normal.
8033 @end itemize
8035 @node Exporting, Publishing, Embedded LaTeX, Top
8036 @chapter Exporting
8037 @cindex exporting
8039 Org-mode documents can be exported into a variety of other formats.  For
8040 printing and sharing of notes, ASCII export produces a readable and simple
8041 version of an Org file.  HTML export allows you to publish a notes file on
8042 the web, while the XOXO format provides a solid base for exchange with a
8043 broad range of other applications. La@TeX{} export lets you use Org mode and
8044 its structured editing functions to easily create La@TeX{} files.  DocBook
8045 export makes it possible to convert Org files to many other formats using
8046 DocBook tools.  To incorporate entries with associated times like deadlines
8047 or appointments into a desktop calendar program like iCal, Org mode can also
8048 produce extracts in the iCalendar format.  Currently Org mode only supports
8049 export, not import of these different formats.
8051 Org supports export of selected regions when @code{transient-mark-mode} is
8052 enabled (default in Emacs 23).
8054 @menu
8055 * Markup rules::                Which structures are recognized?
8056 * Selective export::            Using tags to select and exclude trees
8057 * Export options::              Per-file export settings
8058 * The export dispatcher::       How to access exporter commands
8059 * ASCII export::                Exporting to plain ASCII
8060 * HTML export::                 Exporting to HTML
8061 * LaTeX and PDF export::        Exporting to La@TeX{}, and processing to PDF
8062 * DocBook export::              Exporting to DocBook
8063 * XOXO export::                 Exporting to XOXO
8064 * iCalendar export::            Exporting in iCalendar format
8065 @end menu
8067 @node Markup rules, Selective export, Exporting, Exporting
8068 @section Markup rules
8070 When exporting Org-mode documents, the exporter tries to reflect the
8071 structure of the document as accurately as possible in the backend.  Since
8072 export targets like HTML, La@TeX{}, or DocBook allow much richer formatting,
8073 Org mode has rules on how to prepare text for rich export.  This section
8074 summarizes the markup rules used in an Org-mode buffer.
8076 @menu
8077 * Document title::              How the document title is determined
8078 * Headings and sections::       The main structure of the exported document
8079 * Table of contents::           If, where, how to create a table of contents
8080 * Initial text::                Text before the first headline
8081 * Lists::                       Plain lists are exported
8082 * Paragraphs::                  What determines beginning and ending
8083 * Literal examples::            Source code and other examples
8084 * Include files::               Include the contents of a file during export
8085 * Tables exported::             Tables are exported richly
8086 * Inlined images::              How to inline images during export
8087 * Footnote markup::             ASCII representation of footnotes
8088 * Emphasis and monospace::      To bold or not to bold
8089 * TeX macros and LaTeX fragments::  Create special, rich export.
8090 * Horizontal rules::            A line across the page
8091 * Comment lines::               Some lines will not be exported
8092 * Macro replacement::           Global replacement of place holders
8093 @end menu
8095 @node Document title, Headings and sections, Markup rules, Markup rules
8096 @subheading Document title
8097 @cindex document title, markup rules
8099 @noindent
8100 The title of the exported document is taken from the special line
8102 @cindex #+TITLE
8103 @example
8104 #+TITLE: This is the title of the document
8105 @end example
8107 @noindent
8108 If this line does not exist, the title is derived from the first non-empty,
8109 non-comment line in the buffer.  If no such line exists, or if you have
8110 turned off exporting of the text before the first headline (see below), the
8111 title will be the file name without extension.
8113 @cindex property, EXPORT_TITLE
8114 If you are exporting only a subtree by marking is as the region, the heading
8115 of the subtree will become the title of the document.  If the subtree has a
8116 property @code{EXPORT_TITLE}, that will take precedence.
8118 @node Headings and sections, Table of contents, Document title, Markup rules
8119 @subheading Headings and sections
8120 @cindex headings and sections, markup rules
8122 @vindex org-export-headline-levels
8123 The outline structure of the document as described in @ref{Document
8124 Structure}, forms the basis for defining sections of the exported document.
8125 However, since the outline structure is also used for (for example) lists of
8126 tasks, only the first three outline levels will be used as headings.  Deeper
8127 levels will become itemized lists.  You can change the location of this
8128 switch globally by setting the variable @code{org-export-headline-levels}, or on a
8129 per-file basis with a line
8131 @cindex #+OPTIONS
8132 @example
8133 #+OPTIONS: H:4
8134 @end example
8136 @node Table of contents, Initial text, Headings and sections, Markup rules
8137 @subheading Table of contents
8138 @cindex table of contents, markup rules
8140 @vindex org-export-with-toc
8141 The table of contents is normally inserted directly before the first headline
8142 of the file.  If you would like to get it to a different location, insert the
8143 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
8144 location.  The depth of the table of contents is by default the same as the
8145 number of headline levels, but you can choose a smaller number, or turn off
8146 the table of contents entirely, by configuring the variable
8147 @code{org-export-with-toc}, or on a per-file basis with a line like
8149 @example
8150 #+OPTIONS: toc:2          (only to two levels in TOC)
8151 #+OPTIONS: toc:nil        (no TOC at all)
8152 @end example
8154 @node Initial text, Lists, Table of contents, Markup rules
8155 @subheading Text before the first headline
8156 @cindex text before first headline, markup rules
8157 @cindex #+TEXT
8159 Org mode normally exports the text before the first headline, and even uses
8160 the first line as the document title.  The text will be fully marked up.  If
8161 you need to include literal HTML, La@TeX{}, or DocBook code, use the special
8162 constructs described below in the sections for the individual exporters.
8164 @vindex org-export-skip-text-before-1st-heading
8165 Some people like to use the space before the first headline for setup and
8166 internal links and therefore would like to control the exported text before
8167 the first headline in a different way.  You can do so by setting the variable
8168 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
8169 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
8171 @noindent
8172 If you still want to have some text before the first headline, use the
8173 @code{#+TEXT} construct:
8175 @example
8176 #+OPTIONS: skip:t
8177 #+TEXT: This text will go before the *first* headline.
8178 #+TEXT: [TABLE-OF-CONTENTS]
8179 #+TEXT: This goes between the table of contents and the first headline
8180 @end example
8182 @node Lists, Paragraphs, Initial text, Markup rules
8183 @subheading Lists
8184 @cindex lists, markup rules
8186 Plain lists as described in @ref{Plain lists}, are translated to the backend's
8187 syntax for such lists.  Most backends support unordered, ordered, and
8188 description lists.
8190 @node Paragraphs, Literal examples, Lists, Markup rules
8191 @subheading Paragraphs, line breaks, and quoting
8192 @cindex paragraphs, markup rules
8194 Paragraphs are separated by at least one empty line.  If you need to enforce
8195 a line break within a paragraph, use @samp{\\} at the end of a line.
8197 To keep the line breaks in a region, but otherwise use normal formatting, you
8198 can use this construct, which can also be used to format poetry.
8200 @cindex #+BEGIN_VERSE
8201 @example
8202 #+BEGIN_VERSE
8203  Great clouds overhead
8204  Tiny black birds rise and fall
8205  Snow covers Emacs
8207      -- AlexSchroeder
8208 #+END_VERSE
8209 @end example
8211 When quoting a passage from another document, it is customary to format this
8212 as a paragraph that is indented on both the left and the right margin.  You
8213 can include quotations in Org-mode documents like this:
8215 @cindex #+BEGIN_QUOTE
8216 @example
8217 #+BEGIN_QUOTE
8218 Everything should be made as simple as possible,
8219 but not any simpler -- Albert Einstein
8220 #+END_QUOTE
8221 @end example
8223 If you would like to center some text, do it like this:
8224 @cindex #+BEGIN_CENTER
8225 @example
8226 #+BEGIN_CENTER
8227 Everything should be made as simple as possible, \\
8228 but not any simpler
8229 #+END_CENTER
8230 @end example
8232 @node Literal examples, Include files, Paragraphs, Markup rules
8233 @subheading Literal examples
8234 @cindex literal examples, markup rules
8235 @cindex code line references, markup rules
8237 You can include literal examples that should not be subjected to
8238 markup.  Such examples will be typeset in monospace, so this is well suited
8239 for source code and similar examples.
8240 @cindex #+BEGIN_EXAMPLE
8242 @example
8243 #+BEGIN_EXAMPLE
8244 Some example from a text file.
8245 #+END_EXAMPLE
8246 @end example
8248 Note that such blocks may be @i{indented} in order to align nicely with
8249 indented text and in particular with plain list structure (@pxref{Plain
8250 lists}).  For simplicity when using small examples, you can also start the
8251 example lines with a colon followed by a space.  There may also be additional
8252 whitespace before the colon:
8254 @example
8255 Here is an example
8256    : Some example from a text file.
8257 @end example
8259 @cindex formatting source code, markup rules
8260 If the example is source code from a programming language, or any other text
8261 that can be marked up by font-lock in Emacs, you can ask for the example to
8262 look like the fontified Emacs buffer@footnote{Currently this works for the
8263 HTML backend, and requires the @file{htmlize.el} package version 1.34 or
8264 later.  It also works for LaTeX with the listings package, if you turn on the
8265 option @code{org-export-latex-listings} and make sure that the listings
8266 package is included by the LaTeX header.}.  This is done with the @samp{src}
8267 block, where you also need to specify the name of the major mode that should
8268 be used to fontify the example:
8269 @cindex #+BEGIN_SRC
8271 @example
8272 #+BEGIN_SRC emacs-lisp
8273 (defun org-xor (a b)
8274    "Exclusive or."
8275    (if a (not b) b))
8276 #+END_SRC
8277 @end example
8279 Both in @code{example} and in @code{src} snippets, you can add a @code{-n}
8280 switch to the end of the @code{BEGIN} line, to get the lines of the example
8281 numbered.  If you use a @code{+n} switch, the numbering from the previous
8282 numbered snippet will be continued in the current one.  In literal examples,
8283 Org will interpret strings like @samp{(ref:name)} as labels, and use them as
8284 targets for special hyperlinks like @code{[[(name)]]} (@ie the reference name
8285 enclosed in single parenthesis).  In HTML, hovering the mouse over such a
8286 link will remote-highlight the corresponding code line, which is kind of
8287 cool.
8289 You can also add a @code{-r} switch which @i{removes} the labels from the
8290 source code@footnote{Adding @code{-k} to @code{-n -r} will @i{keep} the
8291 labels in the source code while using line numbers for the links, which might
8292 be useful to explain those in an org-mode example code.}.  With the @code{-n}
8293 switch, links to these references will be labeled by the line numbers from
8294 the code listing, otherwise links will use the labels with no parentheses.
8295 Here is an example:
8297 @example
8298 #+BEGIN_SRC emacs-lisp -n -r
8299 (save-excursion                  (ref:sc)
8300    (goto-char (point-min))       (ref:jump)
8301 #+END_SRC
8302 In line [[(sc)]] we remember the current position.  [[(jump)][Line (jump)]]
8303 jumps to point-min.
8304 @end example
8306 @vindex org-coderef-label-format
8307 If the syntax for the label format conflicts with the language syntax, use a
8308 @code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
8309 -n -r -l "((%s))"}.  See also the variable @code{org-coderef-label-format}.
8311 HTML export also allows examples to be published as text areas, @xref{Text
8312 areas in HTML export}.
8314 @table @kbd
8315 @kindex C-c '
8316 @item C-c '
8317 Edit the source code example at point in its native mode.  This works by
8318 switching to a temporary buffer with the source code.  You need to exit by
8319 pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*}
8320 or @samp{#} will get a comma prepended, to keep them from being interpreted
8321 by Org as outline nodes or special comments.  These commas will be striped
8322 for editing with @kbd{C-c '}, and also for export.}, the edited version will
8323 then replace the old version in the Org buffer.  Fixed-width regions
8324 (where each line starts with a colon followed by a space) will be edited
8325 using @code{artist-mode}@footnote{You may select a different-mode with the
8326 variable @code{org-edit-fixed-width-region-mode}.} to allow creating ASCII
8327 drawings easily.  Using this command in an empty line will create a new
8328 fixed-width region.
8329 @kindex C-c l
8330 @item C-c l
8331 Calling @code{org-store-link} while editing a source code example in a
8332 temporary buffer created with @kbd{C-c '} will prompt for a label, make sure
8333 that it is unique in the current buffer, and insert it with the proper
8334 formatting like @samp{(ref:label)} at the end of the current line.  Then the
8335 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
8336 @end table
8339 @node Include files, Tables exported, Literal examples, Markup rules
8340 @subheading Include files
8341 @cindex include files, markup rules
8343 During export, you can include the content of another file.  For example, to
8344 include your @file{.emacs} file, you could use:
8345 @cindex #+INCLUDE
8347 @example
8348 #+INCLUDE: "~/.emacs" src emacs-lisp
8349 @end example
8350 @noindent
8351 The optional second and third parameter are the markup (e.g. @samp{quote},
8352 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
8353 language for formatting the contents.  The markup is optional, if it is not
8354 given, the text will be assumed to be in Org mode format and will be
8355 processed normally.  The include line will also allow additional keyword
8356 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
8357 first line and for each following line, as well as any options accepted by
8358 the selected markup.  For example, to include a file as an item, use
8360 @example
8361 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
8362 @end example
8364 @table @kbd
8365 @kindex C-c '
8366 @item C-c '
8367 Visit the include file at point.
8368 @end table
8370 @node Tables exported, Inlined images, Include files, Markup rules
8371 @subheading Tables
8372 @cindex tables, markup rules
8374 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
8375 the @file{table.el} package will be exported properly.  For Org mode tables,
8376 the lines before the first horizontal separator line will become table header
8377 lines.  You can use the following lines somewhere before the table to assign
8378 a caption and a label for cross references:
8380 @example
8381 #+CAPTION: This is the caption for the next table (or link)
8382 #+LABEL:   tbl:basic-data
8383 @end example
8385 @node Inlined images, Footnote markup, Tables exported, Markup rules
8386 @subheading Inlined Images
8387 @cindex inlined images, markup rules
8389 Some backends (HTML, La@TeX{}, and DocBook) allow you to directly include images
8390 into the exported document.  Org does this, if a link to an image files does
8391 not have a description part, for example @code{[[./img/a.jpg]]}.  If you wish
8392 to define a caption for the image and maybe a label for internal cross
8393 references, you can use (before, but close to the link)
8395 @example
8396 #+CAPTION: This is the caption for the next figure link (or table)
8397 #+LABEL:   fig:SED-HR4049
8398 @end example
8400 You may also define additional attributes for the figure.  As this is
8401 backend-specific, see the sections about the individual backends for more
8402 information.
8404 @node Footnote markup, Emphasis and monospace, Inlined images, Markup rules
8405 @subheading Footnote markup
8406 @cindex footnotes, markup rules
8407 @cindex @file{footnote.el}
8409 Footnotes defined in the way described in @ref{Footnotes}, will be exported by
8410 all backends.  Org allows multiple references to the same note, and
8411 different backends support this to varying degrees.
8413 @node Emphasis and monospace, TeX macros and LaTeX fragments, Footnote markup, Markup rules
8414 @subheading Emphasis and monospace
8416 @cindex underlined text, markup rules
8417 @cindex bold text, markup rules
8418 @cindex italic text, markup rules
8419 @cindex verbatim text, markup rules
8420 @cindex code text, markup rules
8421 @cindex strike-through text, markup rules
8422 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
8423 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
8424 in the code and verbatim string is not processed for Org-mode specific
8425 syntax, it is exported verbatim.
8427 @node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
8428 @subheading @TeX{} macros and La@TeX{} fragments
8429 @cindex La@TeX{} fragments, markup rules
8430 @cindex @TeX{} macros, markup rules
8431 @cindex HTML entities
8432 @cindex La@TeX{} entities
8434 @vindex org-html-entities
8435 A @TeX{}-like syntax is used to specify special characters.  Where possible,
8436 these will be transformed into the native format of the exporter backend.
8437 Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
8438 output, and as @code{$\alpha$} in the La@TeX{} output.  Similarly,
8439 @code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
8440 This applies for a large number of entities, with names taken from both HTML
8441 and La@TeX{}, see the variable @code{org-html-entities} for the complete
8442 list.  If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
8443 after having typed the backslash and optionally a few characters
8444 (@pxref{Completion}).
8446 La@TeX{} fragments are converted into images for HTML export, and they are
8447 written literally into the La@TeX{} export.  See also @ref{Embedded LaTeX}.
8449 Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
8450 @samp{...} are all converted into special commands creating hyphens of
8451 different lengths or a compact set of dots.
8453 @node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
8454 @subheading  Horizontal rules
8455 @cindex horizontal rules, markup rules
8456 A line consisting of only dashes, and at least 5 of them, will be
8457 exported as a horizontal line (@samp{<hr/>} in HTML).
8459 @node Comment lines, Macro replacement, Horizontal rules, Markup rules
8460 @subheading Comment lines
8461 @cindex comment lines
8462 @cindex exporting, not
8463 @cindex #+BEGIN_COMMENT
8465 Lines starting with @samp{#} in column zero are treated as comments and will
8466 never be exported.  Also entire subtrees starting with the word
8467 @samp{COMMENT} will never be exported.  Finally, regions surrounded by
8468 @samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
8470 @table @kbd
8471 @kindex C-c ;
8472 @item C-c ;
8473 Toggle the COMMENT keyword at the beginning of an entry.
8474 @end table
8476 @node Macro replacement,  , Comment lines, Markup rules
8477 @subheading Macro replacement
8478 @cindex macro replacement, during export
8479 @cindex #+MACRO
8481 You can define text snippets with
8483 @example
8484 #+MACRO: name   replacement text $1, $2 are arguments
8485 @end example
8487 @noindent which can be referenced anywhere in the document (even in
8488 code examples) with @code{@{@{@{name(arg1,arg2)@}@}@}}.  In addition to
8489 defined macros, @code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc.,
8490 will reference information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and
8491 similar lines.  Also, @code{@{@{@{date(@var{FORMAT})@}@}@}} and
8492 @code{@{@{@{modification-time(@var{FORMAT})@}@}@}} refer to current date time
8493 and to the modification time of the file being exported, respectively.
8494 @var{FORMAT} should be a format string understood by
8495 @code{format-time-string}.
8497 @node Selective export, Export options, Markup rules, Exporting
8498 @section Selective export
8499 @cindex export, selective by tags
8501 @vindex org-export-select-tags
8502 @vindex org-export-exclude-tags
8503 You may use tags to select the parts of a document that should be exported,
8504 or to exclude parts from export.  This behavior is governed by two variables:
8505 @code{org-export-select-tags} and @code{org-export-exclude-tags}.
8507 Org first checks if any of the @emph{select} tags is present in the buffer.
8508 If yes, all trees that do not carry one of these tags will be excluded.  If a
8509 selected tree is a subtree, the heading hierarchy above it will also be
8510 selected for export, but not the text below those headings.
8512 @noindent
8513 If none of the select tags is found, the whole buffer will be selected for
8514 export.
8516 @noindent
8517 Finally, all subtrees that are marked by any of the @emph{exclude} tags will
8518 be removed from the export buffer.
8520 @node Export options, The export dispatcher, Selective export, Exporting
8521 @section Export options
8522 @cindex options, for export
8524 @cindex completion, of option keywords
8525 The exporter recognizes special lines in the buffer which provide
8526 additional information.  These lines may be put anywhere in the file.
8527 The whole set of lines can be inserted into the buffer with @kbd{C-c
8528 C-e t}.  For individual lines, a good way to make sure the keyword is
8529 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
8530 (@pxref{Completion}).   For a summary of other in-buffer settings not
8531 specifically related to export, see @ref{In-buffer settings}.
8532 In particular, note that you can place commonly-used (export) options in
8533 a separate file which can be included using @code{#+SETUPFILE}.
8535 @table @kbd
8536 @kindex C-c C-e t
8537 @item C-c C-e t
8538 Insert template with export options, see example below.
8539 @end table
8541 @cindex #+TITLE
8542 @cindex #+AUTHOR
8543 @cindex #+DATE
8544 @cindex #+EMAIL
8545 @cindex #+DESCRIPTION
8546 @cindex #+KEYWORDS
8547 @cindex #+LANGUAGE
8548 @cindex #+TEXT
8549 @cindex #+OPTIONS
8550 @cindex #+BIND
8551 @cindex #+LINK_UP
8552 @cindex #+LINK_HOME
8553 @cindex #+EXPORT_SELECT_TAGS
8554 @cindex #+EXPORT_EXCLUDE_TAGS
8555 @cindex #+LATEX_HEADER
8556 @vindex user-full-name
8557 @vindex user-mail-address
8558 @vindex org-export-default-language
8559 @example
8560 #+TITLE:       the title to be shown (default is the buffer name)
8561 #+AUTHOR:      the author (default taken from @code{user-full-name})
8562 #+DATE:        a date, fixed, of a format string for @code{format-time-string}
8563 #+EMAIL:       his/her email address (default from @code{user-mail-address})
8564 #+DESCRIPTION: the page description, @eg for the XHTML meta tag
8565 #+KEYWORDS:    the page keywords, @eg for the XHTML meta tag
8566 #+LANGUAGE:    language for HTML, @eg @samp{en} (@code{org-export-default-language})
8567 #+TEXT:        Some descriptive text to be inserted at the beginning.
8568 #+TEXT:        Several lines may be given.
8569 #+OPTIONS:     H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
8570 #+BIND:        lisp-var lisp-val, e.g.: org-export-latex-low-levels itemize
8571                @r{You need to confirm using these, or configure @code{org-export-allow-BIND}}
8572 #+LINK_UP:     the ``up'' link of an exported page
8573 #+LINK_HOME:   the ``home'' link of an exported page
8574 #+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage@{xyz@}
8575 #+EXPORT_SELECT_TAGS:   Tags that select a tree for export
8576 #+EXPORT_EXCLUDE_TAGS:  Tags that exclude a tree from export
8577 @end example
8579 @noindent
8580 The OPTIONS line is a compact@footnote{If you want to configure many options
8581 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
8582 you can:
8583 @cindex headline levels
8584 @cindex section-numbers
8585 @cindex table of contents
8586 @cindex line-break preservation
8587 @cindex quoted HTML tags
8588 @cindex fixed-width sections
8589 @cindex tables
8590 @cindex @TeX{}-like syntax for sub- and superscripts
8591 @cindex footnotes
8592 @cindex special strings
8593 @cindex emphasized text
8594 @cindex @TeX{} macros
8595 @cindex La@TeX{} fragments
8596 @cindex author info, in export
8597 @cindex time info, in export
8598 @example
8599 H:         @r{set the number of headline levels for export}
8600 num:       @r{turn on/off section-numbers}
8601 toc:       @r{turn on/off table of contents, or set level limit (integer)}
8602 \n:        @r{turn on/off line-break-preservation}
8603 @@:         @r{turn on/off quoted HTML tags}
8604 ::         @r{turn on/off fixed-width sections}
8605 |:         @r{turn on/off tables}
8606 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
8607            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
8608            @r{the simple @code{a_b} will be left as it is.}
8609 -:         @r{turn on/off conversion of special strings.}
8610 f:         @r{turn on/off footnotes like this[1].}
8611 todo:      @r{turn on/off inclusion of TODO keywords into exported text}
8612 pri:       @r{turn on/off priority cookies}
8613 tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
8614 <:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
8615 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
8616 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
8617 LaTeX:     @r{turn on/off La@TeX{} fragments}
8618 skip:      @r{turn on/off skipping the text before the first heading}
8619 author:    @r{turn on/off inclusion of author name/email into exported file}
8620 creator:   @r{turn on/off inclusion of creator info into exported file}
8621 timestamp: @r{turn on/off inclusion creation time into exported file}
8622 d:         @r{turn on/off inclusion of drawers}
8623 @end example
8624 @noindent
8625 These options take effect in both the HTML and La@TeX{} export, except
8626 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
8627 @code{nil} for the La@TeX{} export.
8629 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
8630 calling an export command, the subtree can overrule some of the file's export
8631 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
8632 @code{EXPORT_TEXT}, @code{EXPORT_AUTHOR}, @code{EXPORT_DATE}, and
8633 @code{EXPORT_OPTIONS}.
8635 @node The export dispatcher, ASCII export, Export options, Exporting
8636 @section The export dispatcher
8637 @cindex dispatcher, for export commands
8639 All export commands can be reached using the export dispatcher, which is a
8640 prefix key that prompts for an additional key specifying the command.
8641 Normally the entire file is exported, but if there is an active region that
8642 contains one outline tree, the first heading is used as document title and
8643 the subtrees are exported.
8645 @table @kbd
8646 @kindex C-c C-e
8647 @item C-c C-e
8648 @vindex org-export-run-in-background
8649 Dispatcher for export and publishing commands.  Displays a help-window
8650 listing the additional key(s) needed to launch an export or publishing
8651 command.  The prefix arg is passed through to the exporter.  A double prefix
8652 @kbd{C-u C-u} causes most commands to be executed in the background, in a
8653 separate Emacs process@footnote{To make this behavior the default, customize
8654 the variable @code{org-export-run-in-background}.}.
8655 @kindex C-c C-e v
8656 @item C-c C-e v
8657 Like @kbd{C-c C-e}, but only export the text that is currently visible
8658 (@ie not hidden by outline visibility).
8659 @kindex C-u C-u C-c C-e
8660 @item C-u C-u C-c C-e
8661 @vindex org-export-run-in-background
8662 Call an the exporter, but reverse the setting of
8663 @code{org-export-run-in-background}, @ie request background processing if
8664 not set, or force processing in the current Emacs process if set.
8665 @end table
8667 @node ASCII export, HTML export, The export dispatcher, Exporting
8668 @section ASCII export
8669 @cindex ASCII export
8671 ASCII export produces a simple and very readable version of an Org-mode
8672 file.
8674 @cindex region, active
8675 @cindex active region
8676 @cindex transient-mark-mode
8677 @table @kbd
8678 @kindex C-c C-e a
8679 @item C-c C-e a
8680 @cindex property, EXPORT_FILE_NAME
8681 Export as ASCII file.  For an Org file, @file{myfile.org}, the ASCII file
8682 will be @file{myfile.txt}.  The file will be overwritten without
8683 warning.  If there is an active region@footnote{This requires
8684 @code{transient-mark-mode} be turned on.}, only the region will be
8685 exported. If the selected region is a single tree@footnote{To select the
8686 current subtree, use @kbd{C-c @@}.}, the tree head will
8687 become the document title.  If the tree head entry has or inherits an
8688 @code{EXPORT_FILE_NAME} property, that name will be used for the
8689 export.
8690 @kindex C-c C-e A
8691 @item C-c C-e A
8692 Export to a temporary buffer, do not create a file.
8693 @kindex C-c C-e v a
8694 @item C-c C-e v a
8695 Export only the visible part of the document.
8696 @end table
8698 @cindex headline levels, for exporting
8699 In the exported version, the first 3 outline levels will become
8700 headlines, defining a general document structure.  Additional levels
8701 will be exported as itemized lists.  If you want that transition to occur
8702 at a different level, specify it with a prefix argument.  For example,
8704 @example
8705 @kbd{C-1 C-c C-e a}
8706 @end example
8708 @noindent
8709 creates only top level headlines and does the rest as items.  When
8710 headlines are converted to items, the indentation of the text following
8711 the headline is changed to fit nicely under the item.  This is done with
8712 the assumption that the first body line indicates the base indentation of
8713 the body text.  Any indentation larger than this is adjusted to preserve
8714 the layout relative to the first line.  Should there be lines with less
8715 indentation than the first, these are left alone.
8717 @vindex org-export-ascii-links-to-notes
8718 Links will be exported in a footnote-like style, with the descriptive part in
8719 the text and the link in a note before the next heading.  See the variable
8720 @code{org-export-ascii-links-to-notes} for details and other options.
8722 @node HTML export, LaTeX and PDF export, ASCII export, Exporting
8723 @section HTML export
8724 @cindex HTML export
8726 Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
8727 HTML formatting, in ways similar to John Gruber's @emph{markdown}
8728 language, but with additional support for tables.
8730 @menu
8731 * HTML Export commands::        How to invoke HTML export
8732 * Quoting HTML tags::           Using direct HTML in Org mode
8733 * Links::                       Transformation of links for HTML
8734 * Tables in HTML export::       How to modify the formatting of tables
8735 * Images in HTML export::       How to insert figures into HTML output
8736 * Text areas in HTML export::   An alternative way to show an example
8737 * CSS support::                 Changing the appearance of the output
8738 * Javascript support::          Info and Folding in a web browser
8739 @end menu
8741 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
8742 @subsection HTML export commands
8744 @cindex region, active
8745 @cindex active region
8746 @cindex transient-mark-mode
8747 @table @kbd
8748 @kindex C-c C-e h
8749 @item C-c C-e h
8750 @cindex property, EXPORT_FILE_NAME
8751 Export as HTML file @file{myfile.html}.  For an Org file @file{myfile.org},
8752 the ASCII file will be @file{myfile.html}.  The file will be overwritten
8753 without warning.  If there is an active region@footnote{This requires
8754 @code{transient-mark-mode} be turned on.}, only the region will be
8755 exported. If the selected region is a single tree@footnote{To select the
8756 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
8757 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
8758 property, that name will be used for the export.
8759 @kindex C-c C-e b
8760 @item C-c C-e b
8761 Export as HTML file and immediately open it with a browser.
8762 @kindex C-c C-e H
8763 @item C-c C-e H
8764 Export to a temporary buffer, do not create a file.
8765 @kindex C-c C-e R
8766 @item C-c C-e R
8767 Export the active region to a temporary buffer.  With a prefix argument, do
8768 not produce the file header and footer, but just the plain HTML section for
8769 the region.  This is good for cut-and-paste operations.
8770 @kindex C-c C-e v h
8771 @kindex C-c C-e v b
8772 @kindex C-c C-e v H
8773 @kindex C-c C-e v R
8774 @item C-c C-e v h
8775 @item C-c C-e v b
8776 @item C-c C-e v H
8777 @item C-c C-e v R
8778 Export only the visible part of the document.
8779 @item M-x org-export-region-as-html
8780 Convert the region to HTML under the assumption that it was Org-mode
8781 syntax before.  This is a global command that can be invoked in any
8782 buffer.
8783 @item M-x org-replace-region-by-HTML
8784 Replace the active region (assumed to be in Org-mode syntax) by HTML
8785 code.
8786 @end table
8788 @cindex headline levels, for exporting
8789 In the exported version, the first 3 outline levels will become headlines,
8790 defining a general document structure.  Additional levels will be exported as
8791 itemized lists.  If you want that transition to occur at a different level,
8792 specify it with a numeric prefix argument.  For example,
8794 @example
8795 @kbd{C-2 C-c C-e b}
8796 @end example
8798 @noindent
8799 creates two levels of headings and does the rest as items.
8801 @node Quoting HTML tags, Links, HTML Export commands, HTML export
8802 @subsection Quoting HTML tags
8804 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
8805 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
8806 which should be interpreted as such, mark them with @samp{@@} as in
8807 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
8808 simple tags.  For more extensive HTML that should be copied verbatim to
8809 the exported file use either
8811 @cindex #+HTML
8812 @cindex #+BEGIN_HTML
8813 @example
8814 #+HTML: Literal HTML code for export
8815 @end example
8817 @noindent or
8818 @cindex #+BEGIN_HTML
8820 @example
8821 #+BEGIN_HTML
8822 All lines between these markers are exported literally
8823 #+END_HTML
8824 @end example
8827 @node Links, Tables in HTML export, Quoting HTML tags, HTML export
8828 @subsection Links
8830 @cindex links, in HTML export
8831 @cindex internal links, in HTML export
8832 @cindex external links, in HTML export
8833 Internal links (@pxref{Internal links}) will continue to work in HTML.  This
8834 includes automatic links created by radio targets (@pxref{Radio
8835 targets}).  Links to external files will still work if the target file is on
8836 the same @i{relative} path as the published Org file.  Links to other
8837 @file{.org} files will be translated into HTML links under the assumption
8838 that an HTML version also exists of the linked file, at the same relative
8839 path.  @samp{id:} links can then be used to jump to specific entries across
8840 files.  For information related to linking files while publishing them to a
8841 publishing directory see @ref{Publishing links}.
8843 If you want to specify attributes for links, you can do so using a special
8844 @code{#+ATTR_HTML} line to define attributes that will be added to the
8845 @code{<a>} or @code{<img>} tags.  Here is an example that sets @code{title}
8846 and @code{style} attributes for a link:
8848 @cindex #+ATTR_HTML
8849 @example
8850 #+ATTR_HTML: title="The Org-mode homepage" style="color:red;"
8851 [[http://orgmode.org]]
8852 @end example
8854 @node Tables in HTML export, Images in HTML export, Links, HTML export
8855 @subsection Tables
8856 @cindex tables, in HTML
8857 @vindex org-export-html-table-tag
8859 Org-mode tables are exported to HTML using the table tag defined in
8860 @code{org-export-html-table-tag}.  The default setting makes tables without
8861 cell borders and frame.  If you would like to change this for individual
8862 tables, place somthing like the following before the table:
8864 @cindex #+CAPTION
8865 @example
8866 #+CAPTION: This is a table with lines around and between cells
8867 #+ATTR_HTML: border="2" rules="all" frame="all"
8868 @end example
8870 @node Images in HTML export, Text areas in HTML export, Tables in HTML export, HTML export
8871 @subsection Images
8873 @cindex images, inline in HTML
8874 @cindex inlining images in HTML
8875 @vindex org-export-html-inline-images
8876 HTML export can inline images given as links in the Org file, and
8877 it can make an image the clickable part of a link.  By
8878 default@footnote{But see the variable
8879 @code{org-export-html-inline-images}.}, images are inlined if a link does
8880 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
8881 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
8882 @samp{the image} that points to the image.  If the description part
8883 itself is a @code{file:} link or a @code{http:} URL pointing to an
8884 image, this image will be inlined and activated so that clicking on the
8885 image will activate the link.  For example, to include a thumbnail that
8886 will link to a high resolution version of the image, you could use:
8888 @example
8889 [[file:highres.jpg][file:thumb.jpg]]
8890 @end example
8892 If you need to add attributes to an inlines image, use a @code{#+ATTR_HTML},
8893 for example:
8895 @cindex #+CAPTION
8896 @example
8897 #+CAPTION: A black cat stalking a spider
8898 #+ATTR_HTML: alt="cat/spider image" title="one second before action"
8899 [[./img/a.jpg]]
8900 @end example
8902 @noindent
8903 and you could use @code{http} addresses just as well.
8905 @node Text areas in HTML export, CSS support, Images in HTML export, HTML export
8906 @subsection Text areas
8908 @cindex text areas, in HTML
8909 An alternative way to publish literal code examples in HTML is to use text
8910 areas, where the example can even be edited before pasting it into an
8911 application.  It is triggered by a @code{-t} switch at an @code{example} or
8912 @code{src} block.  Using this switch disables any options for syntax and
8913 label highlighting, and line numbering, which may be present.  You may also
8914 use @code{-h} and @code{-w} switches to specify the height and width of the
8915 text area, which default to the number of lines in the example, and 80,
8916 respectively.  For example
8918 @example
8919 #+BEGIN_EXAMPLE -t -w 40
8920 (defun org-xor (a b)
8921    "Exclusive or."
8922    (if a (not b) b))
8923 #+END_EXAMPLE
8924 @end example
8927 @node CSS support, Javascript support, Text areas in HTML export, HTML export
8928 @subsection CSS support
8929 @cindex CSS, for HTML export
8930 @cindex HTML export, CSS
8932 @vindex org-export-html-todo-kwd-class-prefix
8933 @vindex org-export-html-tag-class-prefix
8934 You can also give style information for the exported file.  The HTML exporter
8935 assigns the following special CSS classes@footnote{If the classes on TODO
8936 keywords and tags lead to conflicts, use the variables
8937 @code{org-export-html-todo-kwd-class-prefix} and
8938 @code{org-export-html-tag-class-prefix} to make them unique.} to appropriate
8939 parts of the document---your style specifications may change these, in
8940 addition to any of the standard classes like for headlines, tables, etc.
8941 @example
8942 p.author            @r{author information, including email}
8943 p.date              @r{publishing date}
8944 p.creator           @r{creator info, about org-mode version}
8945 .title              @r{document title}
8946 .todo               @r{TODO keywords, all not-done states}
8947 .done               @r{the DONE keywords, all stated the count as done}
8948 .WAITING            @r{each TODO keyword also uses a class named after itself}
8949 .timestamp          @r{timestamp}
8950 .timestamp-kwd      @r{keyword associated with a timestamp, like SCHEDULED}
8951 .timestamp-wrapper  @r{span around keyword plus timestamp}
8952 .tag                @r{tag in a headline}
8953 ._HOME              @r{each tag uses itself as a class, "@@" replaced by "_"}
8954 .target             @r{target for links}
8955 .linenr             @r{the line number in a code example}
8956 .code-highlighted   @r{for highlighting referenced code lines}
8957 div.outline-N       @r{div for outline level N (headline plus text))}
8958 div.outline-text-N  @r{extra div for text at outline level N}
8959 .section-number-N   @r{section number in headlines, different for each level}
8960 div.figure          @r{how to format an inlined image}
8961 pre.src             @r{formatted source code}
8962 pre.example         @r{normal example}
8963 p.verse             @r{verse paragraph}
8964 div.footnotes       @r{footnote section headline}
8965 p.footnote          @r{footnote definition paragraph, containing a footnote}
8966 .footref            @r{a footnote reference number (always a <sup>)}
8967 .footnum            @r{footnote number in footnote definition (always <sup>)}
8968 @end example
8970 @vindex org-export-html-style-default
8971 @vindex org-export-html-style-include-default
8972 @vindex org-export-html-style
8973 @vindex org-export-html-extra
8974 @vindex org-export-html-style-default
8975 Each exported file contains a compact default style that defines these
8976 classes in a basic way@footnote{This style is defined in the constant
8977 @code{org-export-html-style-default}, which you should not modify.  To turn
8978 inclusion of these defaults off, customize
8979 @code{org-export-html-style-include-default}}.  You may overwrite these
8980 settings, or add to them by using the variables @code{org-export-html-style}
8981 (for Org-wide settings) and @code{org-export-html-style-extra} (for more
8982 granular settings, like file-local settings).  To set the latter variable
8983 individually for each file, you can use
8985 @cindex #+STYLE
8986 @example
8987 #+STYLE: <link rel="stylesheet" type="text/css" href="stylesheet.css" />
8988 @end example
8990 @noindent
8991 For longer style definitions, you can use several such lines.  You could also
8992 directly write a @code{<style>} @code{</style>} section in this way, without
8993 referring to an external file.
8995 @c FIXME: More about header and footer styles
8996 @c FIXME: Talk about links and targets.
8998 @node Javascript support,  , CSS support, HTML export
8999 @subsection Javascript supported display of web pages
9001 @cindex Rose, Sebastian
9002 Sebastian Rose has written a JavaScript program especially designed to
9003 enhance the web viewing experience of HTML files created with Org.  This
9004 program allows you to view large files in two different ways.  The first one
9005 is an @emph{Info}-like mode where each section is displayed separately and
9006 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
9007 as well, press @kbd{?} for an overview of the available keys).  The second
9008 view type is a @emph{folding} view much like Org provides inside Emacs.  The
9009 script is available at @url{http://orgmode.org/org-info.js} and you can find
9010 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
9011 We host the script at our site, but if you use it a lot, you might
9012 not want to be dependent on @url{orgmode.org} and prefer to install a local
9013 copy on your own web server.
9015 To use the script, you need to make sure that the @file{org-jsinfo.el} module
9016 gets loaded.  It should be loaded by default, but you can try @kbd{M-x
9017 customize-variable @key{RET} org-modules @key{RET}} to convince yourself that
9018 this is indeed the case.  All it then takes to make use of the program is
9019 adding a single line to the Org file:
9021 @cindex #+INFOJS_OPT
9022 @example
9023 #+INFOJS_OPT: view:info toc:nil
9024 @end example
9026 @noindent
9027 If this line is found, the HTML header will automatically contain the code
9028 needed to invoke the script.  Using the line above, you can set the following
9029 viewing options:
9031 @example
9032 path:    @r{The path to the script.  The default is to grab the script from}
9033          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
9034          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
9035 view:    @r{Initial view when website is first shown.  Possible values are:}
9036          info      @r{Info-like interface with one section per page.}
9037          overview  @r{Folding interface, initially showing only top-level.}
9038          content   @r{Folding interface, starting with all headlines visible.}
9039          showall   @r{Folding interface, all headlines and text visible.}
9040 sdepth:  @r{Maximum headline level that will still become an independent}
9041          @r{section for info and folding modes.  The default is taken from}
9042          @r{@code{org-export-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
9043          @r{If this is smaller than in @code{org-export-headline-levels}, each}
9044          @r{info/folding section can still contain child headlines.}
9045 toc:     @r{Should the table of content @emph{initially} be visible?}
9046          @r{Even when @code{nil}, you can always get to the "toc" with @kbd{i}.}
9047 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
9048          @r{the variables @code{org-export-headline-levels} and @code{org-export-with-toc}.}
9049 ftoc:    @r{Does the css of the page specify a fixed position for the "toc"?}
9050          @r{If yes, the toc will never be displayed as a section.}
9051 ltoc:    @r{Should there be short contents (children) in each section?}
9052          @r{Make this @code{above} if the section should be above initial text.}
9053 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
9054          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
9055 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
9056          @r{default), only one such button will be present.}
9057 @end example
9058 @noindent
9059 @vindex org-infojs-options
9060 @vindex org-export-html-use-infojs
9061 You can choose default values for these options by customizing the variable
9062 @code{org-infojs-options}.  If you always want to apply the script to your
9063 pages, configure the variable @code{org-export-html-use-infojs}.
9065 @node LaTeX and PDF export, DocBook export, HTML export, Exporting
9066 @section La@TeX{} and PDF export
9067 @cindex La@TeX{} export
9068 @cindex PDF export
9069 @cindex Guerry, Bastian
9071 Org mode contains a La@TeX{} exporter written by Bastien Guerry.  With
9072 further processing, this backend is also used to produce PDF output.  Since
9073 the La@TeX{} output uses @file{hyperref} to implement links and cross
9074 references, the PDF output file will be fully linked.
9076 @menu
9077 * LaTeX/PDF export commands::   Which key invokes which commands
9078 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
9079 * Sectioning structure::        Changing sectioning in La@TeX{} output
9080 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
9081 * Images in LaTeX export::      How to insert figures into La@TeX{} output
9082 @end menu
9084 @node LaTeX/PDF export commands, Quoting LaTeX code, LaTeX and PDF export, LaTeX and PDF export
9085 @subsection La@TeX{} export commands
9087 @cindex region, active
9088 @cindex active region
9089 @cindex transient-mark-mode
9090 @table @kbd
9091 @kindex C-c C-e l
9092 @item C-c C-e l
9093 @cindex property EXPORT_FILE_NAME
9094 Export as La@TeX{} file @file{myfile.tex}.  For an Org file
9095 @file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
9096 be overwritten without warning.  If there is an active region@footnote{This
9097 requires @code{transient-mark-mode} be turned on.}, only the region will be
9098 exported. If the selected region is a single tree@footnote{To select the
9099 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9100 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
9101 property, that name will be used for the export.
9102 @kindex C-c C-e L
9103 @item C-c C-e L
9104 Export to a temporary buffer, do not create a file.
9105 @kindex C-c C-e v l
9106 @kindex C-c C-e v L
9107 @item C-c C-e v l
9108 @item C-c C-e v L
9109 Export only the visible part of the document.
9110 @item M-x org-export-region-as-latex
9111 Convert the region to La@TeX{} under the assumption that it was Org mode
9112 syntax before.  This is a global command that can be invoked in any
9113 buffer.
9114 @item M-x org-replace-region-by-latex
9115 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
9116 code.
9117 @kindex C-c C-e p
9118 @item C-c C-e p
9119 Export as La@TeX{} and then process to PDF.
9120 @kindex C-c C-e d
9121 @item C-c C-e d
9122 Export as La@TeX{} and then process to PDF, then open the resulting PDF file.
9123 @end table
9125 @cindex headline levels, for exporting
9126 @vindex org-latex-low-levels
9127 In the exported version, the first 3 outline levels will become
9128 headlines, defining a general document structure.  Additional levels
9129 will be exported as description lists.  The exporter can ignore them or
9130 convert them to a custom string depending on
9131 @code{org-latex-low-levels}.
9133 If you want that transition to occur at a different level, specify it
9134 with a numeric prefix argument. For example,
9136 @example
9137 @kbd{C-2 C-c C-e l}
9138 @end example
9140 @noindent
9141 creates two levels of headings and does the rest as items.
9143 @node Quoting LaTeX code, Sectioning structure, LaTeX/PDF export commands, LaTeX and PDF export
9144 @subsection Quoting La@TeX{} code
9146 Embedded La@TeX{} as described in @ref{Embedded LaTeX}, will be correctly
9147 inserted into the La@TeX{} file.  This includes simple macros like
9148 @samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
9149 you can add special code that should only be present in La@TeX{} export with
9150 the following constructs:
9152 @cindex #+LaTeX
9153 @cindex #+BEGIN_LaTeX
9154 @example
9155 #+LaTeX: Literal LaTeX code for export
9156 @end example
9158 @noindent or
9159 @cindex #+BEGIN_LaTeX
9161 @example
9162 #+BEGIN_LaTeX
9163 All lines between these markers are exported literally
9164 #+END_LaTeX
9165 @end example
9167 @node  Sectioning structure, Tables in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
9168 @subsection Sectioning structure
9169 @cindex La@TeX{} class
9170 @cindex La@TeX{} sectioning structure
9172 By default, the La@TeX{} output uses the class @code{article}.
9174 @vindex org-export-latex-default-class
9175 @vindex org-export-latex-classes
9176 @cindex #+LATEX_HEADER
9177 @cindex #+LATEX_CLASS
9178 @cindex property, LATEX_CLASS
9179 You can change this globally by setting a different value for
9180 @code{org-export-latex-default-class} or locally by adding an option like
9181 @code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
9182 property that applies when exporting a region containing only this (sub)tree.
9183 The class should be listed in @code{org-export-latex-classes}, where you can
9184 also define the sectioning structure for each class, as well as defining
9185 additional classes.  You can also use @code{#+LATEX_HEADER:
9186 \usepackage@{xyz@}} to add lines to the header.
9188 @node Tables in LaTeX export, Images in LaTeX export, Sectioning structure, LaTeX and PDF export
9189 @subsection Tables in La@TeX{} export
9190 @cindex tables, in La@TeX{} export
9192 For La@TeX{} export of a table, you can specify a label and a caption
9193 (@pxref{Markup rules}).  You can also use the @code{ATTR_LaTeX} line to
9194 request a longtable environment for the table, so that it may span several
9195 pages.  Finally, you can set the alignment string:
9197 @cindex #+CAPTION
9198 @cindex #+LABEL
9199 @cindex #+ATTR_LaTeX
9200 @example
9201 #+CAPTION: A long table
9202 #+LABEL: tbl:long
9203 #+ATTR_LaTeX: longtable align=l|lp@{3cm@}r|l
9204 | ..... | ..... |
9205 | ..... | ..... |
9206 @end example
9209 @node Images in LaTeX export,  , Tables in LaTeX export, LaTeX and PDF export
9210 @subsection Images in La@TeX{} export
9211 @cindex images, inline in La@TeX{}
9212 @cindex inlining images in La@TeX{}
9214 Images that are linked to without a description part in the link, like
9215 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
9216 output files resulting from La@TeX{} output.  Org will use an
9217 @code{\includegraphics} macro to insert the image.  If you have specified a
9218 caption and/or a label as described in @ref{Markup rules}, the figure will
9219 be wrapped into a @code{figure} environment and thus become a floating
9220 element.  Finally, you can use an @code{#+ATTR_LaTeX:} line to specify the
9221 options that can be used in the optional argument of the
9222 @code{\includegraphics} macro.
9224 @cindex #+CAPTION
9225 @cindex #+LABEL
9226 @cindex #+ATTR_LaTeX
9227 @example
9228 #+CAPTION:    The black-body emission of the disk around HR 4049
9229 #+LABEL:      fig:SED-HR4049
9230 #+ATTR_LaTeX: width=5cm,angle=90
9231 [[./img/sed-hr4049.pdf]]
9232 @end example
9234 @vindex org-export-latex-inline-image-extensions
9235 If you need references to a label created in this way, write
9236 @samp{\ref@{fig:SED-HR4049@}} just like in La@TeX{}.  The default settings will
9237 recognize files types that can be included as images during processing by
9238 @command{pdflatex} (@file{png}, @file{jpg}, and @file{pdf} files).  If you process your
9239 files in a different way, you may need to customize the variable
9240 @code{org-export-latex-inline-image-extensions}.
9242 @node DocBook export, XOXO export, LaTeX and PDF export, Exporting
9243 @section DocBook export
9244 @cindex DocBook export
9245 @cindex PDF export
9246 @cindex Cui, Baoqui
9248 Org contains a DocBook exporter written by Baoqiu Cui.  Once an Org file is
9249 exported to DocBook format, it can be further processed to produce other
9250 formats, including PDF, HTML, man pages, etc., using many available DocBook
9251 tools and stylesheets.
9253 Currently DocBook exporter only supports DocBook V5.0.
9255 @menu
9256 * DocBook export commands::     How to invoke DocBook export
9257 * Quoting DocBook code::        Incorporating DocBook code in Org files
9258 * Recursive sections::          Recursive sections in DocBook
9259 * Tables in DocBook export::    Tables are exported as HTML tables
9260 * Images in DocBook export::    How to insert figures into DocBook output
9261 * Special characters::          How to handle special characters
9262 @end menu
9264 @node DocBook export commands, Quoting DocBook code, DocBook export, DocBook export
9265 @subsection DocBook export commands
9267 @cindex region, active
9268 @cindex active region
9269 @cindex transient-mark-mode
9270 @table @kbd
9271 @kindex C-c C-e D
9272 @item C-c C-e D
9273 @cindex property EXPORT_FILE_NAME
9274 Export as DocBook file.  For an Org file, @file{myfile.org}, the DocBook XML
9275 file will be @file{myfile.xml}.  The file will be overwritten without
9276 warning.  If there is an active region@footnote{This requires
9277 @code{transient-mark-mode} to be turned on}, only the region will be
9278 exported.  If the selected region is a single tree@footnote{To select the
9279 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9280 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
9281 property, that name will be used for the export.
9282 @kindex C-c C-e V
9283 @item C-c C-e V
9284 Export as DocBook file, process to PDF, then open the resulting PDF file.
9286 @vindex org-export-docbook-xslt-proc-command
9287 @vindex org-export-docbook-xsl-fo-proc-command
9288 Note that, in order to produce PDF output based on exported DocBook file, you
9289 need to have XSLT processor and XSL-FO processor software installed on your
9290 system.  Check variables @code{org-export-docbook-xslt-proc-command} and
9291 @code{org-export-docbook-xsl-fo-proc-command}.
9293 @kindex C-c C-e v D
9294 @item C-c C-e v D
9295 Export only the visible part of the document.
9296 @end table
9298 @node Quoting DocBook code, Recursive sections, DocBook export commands, DocBook export
9299 @subsection Quoting DocBook code
9301 You can quote DocBook code in Org files and copy it verbatim into exported
9302 DocBook file with the following constructs:
9304 @cindex #+DOCBOOK
9305 @cindex #+BEGIN_DOCBOOK
9306 @example
9307 #+DOCBOOK: Literal DocBook code for export
9308 @end example
9310 @noindent or
9311 @cindex #+BEGIN_DOCBOOK
9313 @example
9314 #+BEGIN_DOCBOOK
9315 All lines between these markers are exported by DocBook exporter
9316 literally.
9317 #+END_DOCBOOK
9318 @end example
9320 For example, you can use the following lines to include a DocBook warning
9321 admonition.  As to what this warning says, you should pay attention to the
9322 document context when quoting DocBook code in Org files.  You may make
9323 exported DocBook XML files invalid by not quoting DocBook code correctly.
9325 @example
9326 #+BEGIN_DOCBOOK
9327 <warning>
9328   <para>You should know what you are doing when quoting DocBook XML code
9329   in your Org file.  Invalid DocBook XML file may be generated by
9330   DocBook exporter if you are not careful!</para>
9331 </warning>
9332 #+END_DOCBOOK
9333 @end example
9335 @node Recursive sections, Tables in DocBook export, Quoting DocBook code, DocBook export
9336 @subsection Recursive sections
9337 @cindex DocBook recursive sections
9339 DocBook exporter exports Org files as articles using the @code{article}
9340 element in DocBook.  Recursive sections, @ie @code{section} elements, are
9341 used in exported articles.  Top level headlines in Org files are exported as
9342 top level sections, and lower level headlines are exported as nested
9343 sections.  The entire structure of Org files will be exported completely, no
9344 matter how many nested levels of headlines there are.
9346 Using recursive sections makes it easy to port and reuse exported DocBook
9347 code in other DocBook document types like @code{book} or @code{set}.
9349 @node Tables in DocBook export, Images in DocBook export, Recursive sections, DocBook export
9350 @subsection Tables in DocBook export
9351 @cindex tables, in DocBook export
9353 Tables in Org files are exported as HTML tables, which have been supported since
9354 DocBook V4.3.
9356 If a table does not have a caption, an informal table is generated using the
9357 @code{informaltable} element; otherwise, a formal table will be generated
9358 using the @code{table} element.
9360 @node Images in DocBook export, Special characters, Tables in DocBook export, DocBook export
9361 @subsection Images in DocBook export
9362 @cindex images, inline in DocBook
9363 @cindex inlining images in DocBook
9365 Images that are linked to without a description part in the link, like
9366 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]}, will be exported to DocBook
9367 using @code{mediaobject} elements.  Each @code{mediaobject} element contains
9368 an @code{imageobject} that wraps an @code{imagedata} element.  If you have
9369 specified a caption for an image as described in @ref{Markup rules}, a
9370 @code{caption} element will be added in @code{mediaobject}.  If a label is
9371 also specified, it will be exported as an @code{xml:id} attribute of the
9372 @code{mediaobject} element.
9374 @vindex org-export-docbook-default-image-attributes
9375 Image attributes supported by the @code{imagedata} element, like @code{align}
9376 or @code{width}, can be specified in two ways: you can either customize
9377 variable @code{org-export-docbook-default-image-attributes} or use the
9378 @code{#+ATTR_DOCBOOK:} line.  Attributes specified in variable
9379 @code{org-export-docbook-default-image-attributes} are applied to all inline
9380 images in the Org file to be exported (unless they are overwritten by image
9381 attributes specified in @code{#+ATTR_DOCBOOK:} lines).
9383 The @code{#+ATTR_DOCBOOK:} line can be used to specify additional image
9384 attributes or overwrite default image attributes for individual images.  If
9385 the same attribute appears in both the @code{#+ATTR_DOCBOOK:} line and
9386 variable @code{org-export-docbook-default-image-attributes}, the former
9387 overwrites the latter.  Here is an example about how image attributes can be
9388 set:
9390 @cindex #+CAPTION
9391 @cindex #+LABEL
9392 @cindex #+ATTR_DOCBOOK
9393 @example
9394 #+CAPTION:    The logo of Org mode
9395 #+LABEL:      unicorn-svg
9396 #+ATTR_DOCBOOK: scalefit="1" width="100%" depth="100%"
9397 [[./img/org-mode-unicorn.svg]]
9398 @end example
9400 @vindex org-export-docbook-inline-image-extensions
9401 By default, DocBook exporter recognizes the following image file types:
9402 @file{jpeg}, @file{jpg}, @file{png}, @file{gif}, and @file{svg}.  You can
9403 customize variable @code{org-export-docbook-inline-image-extensions} to add
9404 more types to this list as long as DocBook supports them.
9406 @node Special characters,  , Images in DocBook export, DocBook export
9407 @subsection Special characters in DocBook export
9408 @cindex Special characters in DocBook export
9410 @vindex org-export-docbook-doctype
9411 @vindex org-html-entities
9412 Special characters that are written in @TeX{}-like syntax, such as @code{\alpha},
9413 @code{\Gamma}, and @code{\Zeta}, are supported by DocBook exporter.  These
9414 characters are rewritten to XML entities, like @code{&alpha;},
9415 @code{&Gamma;}, and @code{&Zeta;}, based on the list saved in variable
9416 @code{org-html-entities}.  As long as the generated DocBook file includes the
9417 corresponding entities, these special characters are recognized.
9419 You can customize variable @code{org-export-docbook-doctype} to include the
9420 entities you need.  For example, you can set variable
9421 @code{org-export-docbook-doctype} to the following value to recognize all
9422 special characters included in XHTML entities:
9424 @example
9425 "<!DOCTYPE article [
9426 <!ENTITY % xhtml1-symbol PUBLIC
9427 \"-//W3C//ENTITIES Symbol for HTML//EN//XML\"
9428 \"http://www.w3.org/2003/entities/2007/xhtml1-symbol.ent\"
9430 %xhtml1-symbol;
9433 @end example
9435 @node XOXO export, iCalendar export, DocBook export, Exporting
9436 @section XOXO export
9437 @cindex XOXO export
9439 Org mode contains an exporter that produces XOXO-style output.
9440 Currently, this exporter only handles the general outline structure and
9441 does not interpret any additional Org-mode features.
9443 @table @kbd
9444 @kindex C-c C-e x
9445 @item C-c C-e x
9446 Export as XOXO file @file{myfile.html}.
9447 @kindex C-c C-e v
9448 @item C-c C-e v x
9449 Export only the visible part of the document.
9450 @end table
9452 @node iCalendar export,  , XOXO export, Exporting
9453 @section iCalendar export
9454 @cindex iCalendar export
9456 @vindex org-icalendar-include-todo
9457 @vindex org-icalendar-use-deadline
9458 @vindex org-icalendar-use-scheduled
9459 @vindex org-icalendar-categories
9460 Some people use Org mode for keeping track of projects, but still prefer a
9461 standard calendar application for anniversaries and appointments.  In this
9462 case it can be useful to show deadlines and other time-stamped items in Org
9463 files in the calendar application.  Org mode can export calendar information
9464 in the standard iCalendar format.  If you also want to have TODO entries
9465 included in the export, configure the variable
9466 @code{org-icalendar-include-todo}.  Plain timestamps are exported as VEVENT,
9467 and TODO items as VTODO.  It will also create events from deadlines that are
9468 in non-TODO items.  Deadlines and scheduling dates in TODO items will be used
9469 to set the start and due dates for the TODO entry@footnote{See the variables
9470 @code{org-icalendar-use-deadline} and @code{org-icalendar-use-scheduled}.}.
9471 As categories, it will use the tags locally defined in the heading, and the
9472 file/tree category@footnote{To add inherited tags or the TODO state,
9473 configure the variable @code{org-icalendar-categories}.}.
9475 @vindex org-icalendar-store-UID
9476 @cindex property, ID
9477 The iCalendar standard requires each entry to have a globally unique
9478 identifier (UID).  Org creates these identifiers during export.  If you set
9479 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
9480 @code{:ID:} property of the entry and re-used next time you report this
9481 entry.  Since a single entry can give rise to multiple iCalendar entries (as
9482 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
9483 prefixes to the UID, depending on what triggered the inclusion of the entry.
9484 In this way the UID remains unique, but a synchronization program can still
9485 figure out from which entry all the different instances originate.
9487 @table @kbd
9488 @kindex C-c C-e i
9489 @item C-c C-e i
9490 Create iCalendar entries for the current file and store them in the same
9491 directory, using a file extension @file{.ics}.
9492 @kindex C-c C-e I
9493 @item C-c C-e I
9494 @vindex org-agenda-files
9495 Like @kbd{C-c C-e i}, but do this for all files in
9496 @code{org-agenda-files}.  For each of these files, a separate iCalendar
9497 file will be written.
9498 @kindex C-c C-e c
9499 @item C-c C-e c
9500 @vindex org-combined-agenda-icalendar-file
9501 Create a single large iCalendar file from all files in
9502 @code{org-agenda-files} and write it to the file given by
9503 @code{org-combined-agenda-icalendar-file}.
9504 @end table
9506 @vindex org-use-property-inheritance
9507 @vindex org-icalendar-include-body
9508 @cindex property, SUMMARY
9509 @cindex property, DESCRIPTION
9510 @cindex property, LOCATION
9511 The export will honor SUMMARY, DESCRIPTION and LOCATION@footnote{The LOCATION
9512 property can be inherited from higher in the hierarchy if you configure
9513 @code{org-use-property-inheritance} accordingly.} properties if the selected
9514 entries have them.  If not, the summary will be derived from the headline,
9515 and the description from the body (limited to
9516 @code{org-icalendar-include-body} characters).
9518 How this calendar is best read and updated, depends on the application
9519 you are using.  The FAQ covers this issue.
9521 @node Publishing, Miscellaneous, Exporting, Top
9522 @chapter Publishing
9523 @cindex publishing
9524 @cindex O'Toole, David
9526 Org includes a publishing management system that allows you to configure
9527 automatic HTML conversion of @emph{projects} composed of interlinked org
9528 files.  You can also configure Org to automatically upload your exported HTML
9529 pages and related attachments, such as images and source code files, to a web
9530 server.
9532 You can also use Org to convert files into PDF, or even combine HTML and PDF
9533 conversion so that files are available in both formats on the server.
9535 Publishing has been contributed to Org by David O'Toole.
9537 @menu
9538 * Configuration::               Defining projects
9539 * Uploading files::             How to get files up on the server
9540 * Sample configuration::        Example projects
9541 * Triggering publication::      Publication commands
9542 @end menu
9544 @node Configuration, Uploading files, Publishing, Publishing
9545 @section Configuration
9547 Publishing needs significant configuration to specify files, destination
9548 and many other properties of a project.
9550 @menu
9551 * Project alist::               The central configuration variable
9552 * Sources and destinations::    From here to there
9553 * Selecting files::             What files are part of the project?
9554 * Publishing action::           Setting the function doing the publishing
9555 * Publishing options::          Tweaking HTML export
9556 * Publishing links::            Which links keep working after publishing?
9557 * Project page index::          Publishing a list of project files
9558 @end menu
9560 @node Project alist, Sources and destinations, Configuration, Configuration
9561 @subsection The variable @code{org-publish-project-alist}
9562 @cindex org-publish-project-alist
9563 @cindex projects, for publishing
9565 @vindex org-publish-project-alist
9566 Publishing is configured almost entirely through setting the value of one
9567 variable, called @code{org-publish-project-alist}.  Each element of the list
9568 configures one project, and may be in one of the two following forms:
9570 @lisp
9571    ("project-name" :property value :property value ...)
9572 @r{or}
9573    ("project-name" :components ("project-name" "project-name" ...))
9575 @end lisp
9577 In both cases, projects are configured by specifying property values.  A
9578 project defines the set of files that will be published, as well as the
9579 publishing configuration to use when publishing those files.  When a project
9580 takes the second form listed above, the individual members of the
9581 @code{:components} property are taken to be sub-projects, which group
9582 together files requiring different publishing options.  When you publish such
9583 a ``meta-project'', all the components will also be published, in the
9584 sequence given.
9586 @node Sources and destinations, Selecting files, Project alist, Configuration
9587 @subsection Sources and destinations for files
9588 @cindex directories, for publishing
9590 Most properties are optional, but some should always be set.  In
9591 particular, Org needs to know where to look for source files,
9592 and where to put published files.
9594 @multitable @columnfractions 0.3 0.7
9595 @item @code{:base-directory}
9596 @tab Directory containing publishing source files
9597 @item @code{:publishing-directory}
9598 @tab Directory where output files will be published.  You can directly
9599 publish to a webserver using a file name syntax appropriate for
9600 the Emacs @file{tramp} package.  Or you can publish to a local directory and
9601 use external tools to upload your website (@pxref{Uploading files}).
9602 @item @code{:preparation-function}
9603 @tab Function called before starting the publishing process, for example, to
9604 run @code{make} for updating files to be published.
9605 @item @code{:completion-function}
9606 @tab Function called after finishing the publishing process, for example, to
9607 change permissions of the resulting files.
9608 @end multitable
9609 @noindent
9611 @node Selecting files, Publishing action, Sources and destinations, Configuration
9612 @subsection Selecting files
9613 @cindex files, selecting for publishing
9615 By default, all files with extension @file{.org} in the base directory
9616 are considered part of the project.  This can be modified by setting the
9617 properties
9618 @multitable @columnfractions 0.25 0.75
9619 @item @code{:base-extension}
9620 @tab Extension (without the dot!) of source files.  This actually is a
9621 regular expression.  Set this to the symbol @code{any} if you want to get all
9622 files in @code{:base-directory}, even without extension.
9624 @item @code{:exclude}
9625 @tab Regular expression to match file names that should not be
9626 published, even though they have been selected on the basis of their
9627 extension.
9629 @item @code{:include}
9630 @tab List of files to be included regardless of @code{:base-extension}
9631 and @code{:exclude}.
9632 @end multitable
9634 @node Publishing action, Publishing options, Selecting files, Configuration
9635 @subsection Publishing action
9636 @cindex action, for publishing
9638 Publishing means that a file is copied to the destination directory and
9639 possibly transformed in the process.  The default transformation is to export
9640 Org files as HTML files, and this is done by the function
9641 @code{org-publish-org-to-html} which calls the HTML exporter (@pxref{HTML
9642 export}).  But you also can publish your content as PDF files using
9643 @code{org-publish-org-to-pdf}.  If you want to publish the Org file itself,
9644 but with @i{archived}, @i{commented}, and @i{tag-excluded} trees removed, use
9645 @code{org-publish-org-to-org} and set the parameters @code{:plain-source}
9646 and/or @code{:htmlized-source}.  This will produce @file{file.org} and
9647 @file{file.org.html} in the publishing
9648 directory@footnote{@file{file-source.org} and @file{file-source.org.html} if
9649 source and publishing directories are equal.  Note that with this kind of
9650 setup, you need to add @code{:exclude "-source\\.org"} to the project
9651 definition in @code{org-publish-project-alist} to avoid that the published
9652 source files will be considered as new org files the next time the project is
9653 published.}.  Other files like images only
9654 need to be copied to the publishing destination, for this you may use
9655 @code{org-publish-attachment}.  For non-Org files, you always need to
9656 specify the publishing function:
9658 @multitable @columnfractions 0.3 0.7
9659 @item @code{:publishing-function}
9660 @tab Function executing the publication of a file.  This may also be a
9661 list of functions, which will all be called in turn.
9662 @item @code{:plain-source}
9663 @tab Non-nil means, publish plain source.
9664 @item @code{:htmlized-source}
9665 @tab Non-nil means, publish htmlized source.
9666 @end multitable
9668 The function must accept two arguments: a property list containing at least a
9669 @code{:publishing-directory} property, and the name of the file to be
9670 published.  It should take the specified file, make the necessary
9671 transformation (if any) and place the result into the destination folder.
9673 @node Publishing options, Publishing links, Publishing action, Configuration
9674 @subsection Options for the HTML/La@TeX{} exporters
9675 @cindex options, for publishing
9677 The property list can be used to set many export options for the HTML
9678 and La@TeX{} exporters.  In most cases, these properties correspond to user
9679 variables in Org.  The table below lists these properties along
9680 with the variable they belong to.  See the documentation string for the
9681 respective variable for details.
9683 @vindex org-export-html-link-up
9684 @vindex org-export-html-link-home
9685 @vindex org-export-default-language
9686 @vindex org-display-custom-times
9687 @vindex org-export-headline-levels
9688 @vindex org-export-with-section-numbers
9689 @vindex org-export-section-number-format
9690 @vindex org-export-with-toc
9691 @vindex org-export-preserve-breaks
9692 @vindex org-export-with-archived-trees
9693 @vindex org-export-with-emphasize
9694 @vindex org-export-with-sub-superscripts
9695 @vindex org-export-with-special-strings
9696 @vindex org-export-with-footnotes
9697 @vindex org-export-with-drawers
9698 @vindex org-export-with-tags
9699 @vindex org-export-with-todo-keywords
9700 @vindex org-export-with-priority
9701 @vindex org-export-with-TeX-macros
9702 @vindex org-export-with-LaTeX-fragments
9703 @vindex org-export-skip-text-before-1st-heading
9704 @vindex org-export-with-fixed-width
9705 @vindex org-export-with-timestamps
9706 @vindex org-export-author-info
9707 @vindex org-export-creator-info
9708 @vindex org-export-with-tables
9709 @vindex org-export-highlight-first-table-line
9710 @vindex org-export-html-style-include-default
9711 @vindex org-export-html-style
9712 @vindex org-export-html-style-extra
9713 @vindex org-export-html-link-org-files-as-html
9714 @vindex org-export-html-inline-images
9715 @vindex org-export-html-extension
9716 @vindex org-export-html-table-tag
9717 @vindex org-export-html-expand
9718 @vindex org-export-html-with-timestamp
9719 @vindex org-export-publishing-directory
9720 @vindex org-export-html-preamble
9721 @vindex org-export-html-postamble
9722 @vindex org-export-html-auto-preamble
9723 @vindex org-export-html-auto-postamble
9724 @vindex user-full-name
9725 @vindex user-mail-address
9726 @vindex org-export-select-tags
9727 @vindex org-export-exclude-tags
9729 @multitable @columnfractions 0.32 0.68
9730 @item @code{:link-up}               @tab @code{org-export-html-link-up}
9731 @item @code{:link-home}             @tab @code{org-export-html-link-home}
9732 @item @code{:language}              @tab @code{org-export-default-language}
9733 @item @code{:customtime}            @tab @code{org-display-custom-times}
9734 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
9735 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
9736 @item @code{:section-number-format} @tab @code{org-export-section-number-format}
9737 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
9738 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
9739 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
9740 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
9741 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
9742 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
9743 @item @code{:footnotes}             @tab @code{org-export-with-footnotes}
9744 @item @code{:drawers}               @tab @code{org-export-with-drawers}
9745 @item @code{:tags}                  @tab @code{org-export-with-tags}
9746 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
9747 @item @code{:priority}              @tab @code{org-export-with-priority}
9748 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
9749 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
9750 @item @code{:latex-listings}        @tab @code{org-export-latex-listings}
9751 @item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
9752 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
9753 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
9754 @item @code{:author-info}           @tab @code{org-export-author-info}
9755 @item @code{:creator-info}          @tab @code{org-export-creator-info}
9756 @item @code{:tables}                @tab @code{org-export-with-tables}
9757 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
9758 @item @code{:style-include-default} @tab @code{org-export-html-style-include-default}
9759 @item @code{:style}                 @tab @code{org-export-html-style}
9760 @item @code{:style-extra}           @tab @code{org-export-html-style-extra}
9761 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
9762 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
9763 @item @code{:html-extension}        @tab @code{org-export-html-extension}
9764 @item @code{:xml-declaration}       @tab @code{org-export-html-xml-declaration}
9765 @item @code{:html-table-tag}        @tab @code{org-export-html-table-tag}
9766 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
9767 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
9768 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
9769 @item @code{:preamble}              @tab @code{org-export-html-preamble}
9770 @item @code{:postamble}             @tab @code{org-export-html-postamble}
9771 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
9772 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
9773 @item @code{:author}                @tab @code{user-full-name}
9774 @item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
9775 @item @code{:select-tags}           @tab @code{org-export-select-tags}
9776 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
9777 @item @code{:latex-image-options}   @tab @code{org-export-latex-image-default-option}
9778 @end multitable
9780 Most of the @code{org-export-with-*} variables have the same effect in
9781 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
9782 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
9783 La@TeX{} export.
9785 @vindex org-publish-project-alist
9786 When a property is given a value in @code{org-publish-project-alist},
9787 its setting overrides the value of the corresponding user variable (if
9788 any) during publishing.  Options set within a file (@pxref{Export
9789 options}), however, override everything.
9791 @node Publishing links, Project page index, Publishing options, Configuration
9792 @subsection Links between published files
9793 @cindex links, publishing
9795 To create a link from one Org file to another, you would use
9796 something like @samp{[[file:foo.org][The foo]]} or simply
9797 @samp{file:foo.org.} (@pxref{Hyperlinks}).  When published, this link
9798 becomes a link to @file{foo.html}.  In this way, you can interlink the
9799 pages of your "org web" project and the links will work as expected when
9800 you publish them to HTML.  If you also publish the Org source file and want
9801 to link to that, use an @code{http:} link instead of a @code{file:} link,
9802 because @code{file:} links are converted to link to the corresponding
9803 @file{html} file.
9805 You may also link to related files, such as images. Provided you are careful
9806 with relative file names, and provided you have also configured Org to upload
9807 the related files, these links will work too. See @ref{Complex example}, for
9808 an example of this usage.
9810 Sometimes an Org file to be published may contain links that are
9811 only valid in your production environment, but not in the publishing
9812 location.  In this case, use the property
9814 @multitable @columnfractions 0.4 0.6
9815 @item @code{:link-validation-function}
9816 @tab Function to validate links
9817 @end multitable
9819 @noindent
9820 to define a function for checking link validity.  This function must
9821 accept two arguments, the file name and a directory relative to which
9822 the file name is interpreted in the production environment.  If this
9823 function returns @code{nil}, then the HTML generator will only insert a
9824 description into the HTML file, but no link.  One option for this
9825 function is @code{org-publish-validate-link} which checks if the given
9826 file is part of any project in @code{org-publish-project-alist}.
9828 @node Project page index,  , Publishing links, Configuration
9829 @subsection Project page index
9830 @cindex index, of published pages
9832 The following properties may be used to control publishing of an
9833 index of files or a summary page for a given project.
9835 @multitable @columnfractions 0.25 0.75
9836 @item @code{:auto-index}
9837 @tab When non-nil, publish an index during @code{org-publish-current-project}
9838 or @code{org-publish-all}.
9840 @item @code{:index-filename}
9841 @tab Filename for output of index. Defaults to @file{sitemap.org} (which
9842 becomes @file{sitemap.html}).
9844 @item @code{:index-title}
9845 @tab Title of index page. Defaults to name of file.
9847 @item @code{:index-function}
9848 @tab Plug-in function to use for generation of index.
9849 Defaults to @code{org-publish-org-index}, which generates a plain list
9850 of links to all files in the project.
9851 @end multitable
9853 @node Uploading files, Sample configuration, Configuration, Publishing
9854 @section Uploading files
9855 @cindex rsync
9856 @cindex unison
9858 For those people already utilizing third party sync tools such as
9859 @command{rsync} or @command{unison}, it might be preferable not to use the built in
9860 @i{remote} publishing facilities of Org mode which rely heavily on
9861 Tramp.  Tramp, while very useful and powerful, tends not to be
9862 so efficient for multiple file transfer and has been known to cause problems
9863 under heavy usage.
9865 Specialized synchronization utilities offer several advantages.  In addition
9866 to timestamp comparison, they also do content and permissions/attribute
9867 checks.  For this reason you might prefer to publish your web to a local
9868 directory (possibly even @i{in place} with your Org files) and then use
9869 @file{unison} or @file{rsync} to do the synchronization with the remote host.
9871 Since Unison (for example) can be configured as to which files to transfer to
9872 a certain remote destination, it can greatly simplify the project publishing
9873 definition.  Simply keep all files in the correct location, process your Org
9874 files with @code{org-publish} and let the synchronization tool do the rest.
9875 You do not need, in this scenario, to include attachments such as @file{jpg},
9876 @file{css} or @file{gif} files in the project definition since the 3rd party
9877 tool syncs them.
9879 Publishing to a local directory is also much faster than to a remote one, so
9880 that you can afford more easily to republish entire projects.  If you set
9881 @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the main
9882 benefit of re-including any changed external files such as source example
9883 files you might include with @code{#+INCLUDE}.  The timestamp mechanism in
9884 Org is not smart enough to detect if included files have been modified.
9886 @node Sample configuration, Triggering publication, Uploading files, Publishing
9887 @section Sample configuration
9889 Below we provide two example configurations.  The first one is a simple
9890 project publishing only a set of Org files.  The second example is
9891 more complex, with a multi-component project.
9893 @menu
9894 * Simple example::              One-component publishing
9895 * Complex example::             A multi-component publishing example
9896 @end menu
9898 @node Simple example, Complex example, Sample configuration, Sample configuration
9899 @subsection Example: simple publishing configuration
9901 This example publishes a set of Org files to the @file{public_html}
9902 directory on the local machine.
9904 @lisp
9905 (setq org-publish-project-alist
9906       '(("org"
9907          :base-directory "~/org/"
9908          :publishing-directory "~/public_html"
9909          :section-numbers nil
9910          :table-of-contents nil
9911          :style "<link rel=\"stylesheet\"
9912                 href=\"../other/mystyle.css\"
9913                 type=\"text/css\"/>")))
9914 @end lisp
9916 @node Complex example,  , Simple example, Sample configuration
9917 @subsection Example: complex publishing configuration
9919 This more complicated example publishes an entire website, including
9920 Org files converted to HTML, image files, Emacs Lisp source code, and
9921 style sheets. The publishing directory is remote and private files are
9922 excluded.
9924 To ensure that links are preserved, care should be taken to replicate
9925 your directory structure on the web server, and to use relative file
9926 paths. For example, if your Org files are kept in @file{~/org} and your
9927 publishable images in @file{~/images}, you'd link to an image with
9929 @example
9930 file:../images/myimage.png
9931 @end example
9933 On the web server, the relative path to the image should be the
9934 same. You can accomplish this by setting up an "images" folder in the
9935 right place on the web server, and publishing images to it.
9937 @lisp
9938 (setq org-publish-project-alist
9939       '(("orgfiles"
9940           :base-directory "~/org/"
9941           :base-extension "org"
9942           :publishing-directory "/ssh:user@@host:~/html/notebook/"
9943           :publishing-function org-publish-org-to-html
9944           :exclude "PrivatePage.org"   ;; regexp
9945           :headline-levels 3
9946           :section-numbers nil
9947           :table-of-contents nil
9948           :style "<link rel=\"stylesheet\"
9949                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
9950           :auto-preamble t
9951           :auto-postamble nil)
9953          ("images"
9954           :base-directory "~/images/"
9955           :base-extension "jpg\\|gif\\|png"
9956           :publishing-directory "/ssh:user@@host:~/html/images/"
9957           :publishing-function org-publish-attachment)
9959          ("other"
9960           :base-directory "~/other/"
9961           :base-extension "css\\|el"
9962           :publishing-directory "/ssh:user@@host:~/html/other/"
9963           :publishing-function org-publish-attachment)
9964          ("website" :components ("orgfiles" "images" "other"))))
9965 @end lisp
9967 @node Triggering publication,  , Sample configuration, Publishing
9968 @section Triggering publication
9970 Once properly configured, Org can publish with the following commands:
9972 @table @kbd
9973 @kindex C-c C-e C
9974 @item C-c C-e C
9975 Prompt for a specific project and publish all files that belong to it.
9976 @kindex C-c C-e P
9977 @item C-c C-e P
9978 Publish the project containing the current file.
9979 @kindex C-c C-e F
9980 @item C-c C-e F
9981 Publish only the current file.
9982 @kindex C-c C-e E
9983 @item C-c C-e E
9984 Publish every project.
9985 @end table
9987 @vindex org-publish-use-timestamps-flag
9988 Org uses timestamps to track when a file has changed. The above functions
9989 normally only publish changed files. You can override this and force
9990 publishing of all files by giving a prefix argument to any of the commands
9991 above, or by customizing the variable @code{org-publish-use-timestamps-flag}.
9992 This may be necessary in particular if files include other files via
9993 @code{#+SETUPFILE:} or @code{#+INCLUDE:}.
9995 @node Miscellaneous, Hacking, Publishing, Top
9996 @chapter Miscellaneous
9998 @menu
9999 * Completion::                  M-TAB knows what you need
10000 * Customization::               Adapting Org to your taste
10001 * In-buffer settings::          Overview of the #+KEYWORDS
10002 * The very busy C-c C-c key::   When in doubt, press C-c C-c
10003 * Clean view::                  Getting rid of leading stars in the outline
10004 * TTY keys::                    Using Org on a tty
10005 * Interaction::                 Other Emacs packages
10006 @end menu
10009 @node Completion, Customization, Miscellaneous, Miscellaneous
10010 @section Completion
10011 @cindex completion, of @TeX{} symbols
10012 @cindex completion, of TODO keywords
10013 @cindex completion, of dictionary words
10014 @cindex completion, of option keywords
10015 @cindex completion, of tags
10016 @cindex completion, of property keys
10017 @cindex completion, of link abbreviations
10018 @cindex @TeX{} symbol completion
10019 @cindex TODO keywords completion
10020 @cindex dictionary word completion
10021 @cindex option keyword completion
10022 @cindex tag completion
10023 @cindex link abbreviations, completion of
10025 Emacs would not be Emacs without completion, and Org-mode uses it whenever it
10026 makes sense.  If you prefer an @i{iswitchb}- or @i{ido}-like interface for
10027 some of the completion prompts, you can specify your preferece by setting at
10028 most one of the variables @code{org-completion-use-iswitchb}
10029 @code{org-completion-use-ido}.
10031 Org supports in-buffer completion.  This type of completion does
10032 not make use of the minibuffer.  You simply type a few letters into
10033 the buffer and use the key to complete text right there.
10035 @table @kbd
10036 @kindex M-@key{TAB}
10037 @item M-@key{TAB}
10038 Complete word at point
10039 @itemize @bullet
10040 @item
10041 At the beginning of a headline, complete TODO keywords.
10042 @item
10043 After @samp{\}, complete @TeX{} symbols supported by the exporter.
10044 @item
10045 After @samp{*}, complete headlines in the current buffer so that they
10046 can be used in search links like @samp{[[*find this headline]]}.
10047 @item
10048 After @samp{:} in a headline, complete tags.  The list of tags is taken
10049 from the variable @code{org-tag-alist} (possibly set through the
10050 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
10051 dynamically from all tags used in the current buffer.
10052 @item
10053 After @samp{:} and not in a headline, complete property keys.  The list
10054 of keys is constructed dynamically from all keys used in the current
10055 buffer.
10056 @item
10057 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
10058 @item
10059 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
10060 @samp{OPTIONS} which set file-specific options for Org mode.  When the
10061 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
10062 will insert example settings for this keyword.
10063 @item
10064 In the line after @samp{#+STARTUP: }, complete startup keywords,
10065 @ie valid keys for this line.
10066 @item
10067 Elsewhere, complete dictionary words using Ispell.
10068 @end itemize
10069 @end table
10071 @node Customization, In-buffer settings, Completion, Miscellaneous
10072 @section Customization
10073 @cindex customization
10074 @cindex options, for customization
10075 @cindex variables, for customization
10077 There are more than 180 variables that can be used to customize
10078 Org.  For the sake of compactness of the manual, I am not
10079 describing the variables here.  A structured overview of customization
10080 variables is available with @kbd{M-x org-customize}.  Or select
10081 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
10082 settings can also be activated on a per-file basis, by putting special
10083 lines into the buffer (@pxref{In-buffer settings}).
10085 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
10086 @section Summary of in-buffer settings
10087 @cindex in-buffer settings
10088 @cindex special keywords
10090 Org mode uses special lines in the buffer to define settings on a
10091 per-file basis.  These lines start with a @samp{#+} followed by a
10092 keyword, a colon, and then individual words defining a setting.  Several
10093 setting words can be in the same line, but you can also have multiple
10094 lines for the keyword.  While these settings are described throughout
10095 the manual, here is a summary.  After changing any of those lines in the
10096 buffer, press @kbd{C-c C-c} with the cursor still in the line to
10097 activate the changes immediately.  Otherwise they become effective only
10098 when the file is visited again in a new Emacs session.
10100 @vindex org-archive-location
10101 @table @kbd
10102 @item #+ARCHIVE: %s_done::
10103 This line sets the archive location for the agenda file.  It applies for
10104 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
10105 of the file.  The first such line also applies to any entries before it.
10106 The corresponding variable is @code{org-archive-location}.
10107 @item #+CATEGORY:
10108 This line sets the category for the agenda file.  The category applies
10109 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
10110 end of the file.  The first such line also applies to any entries before it.
10111 @item #+COLUMNS: %25ITEM .....
10112 @cindex property, COLUMNS
10113 Set the default format for columns view.  This format applies when
10114 columns view is invoked in locations where no @code{COLUMNS} property
10115 applies.
10116 @item #+CONSTANTS: name1=value1 ...
10117 @vindex org-table-formula-constants
10118 @vindex org-table-formula
10119 Set file-local values for constants to be used in table formulas.  This
10120 line set the local variable @code{org-table-formula-constants-local}.
10121 The global version of this variable is
10122 @code{org-table-formula-constants}.
10123 @item #+FILETAGS: :tag1:tag2:tag3:
10124 Set tags that can be inherited by any entry in the file, including the
10125 top-level entries.
10126 @item #+DRAWERS: NAME1 .....
10127 @vindex org-drawers
10128 Set the file-local set of drawers.  The corresponding global variable is
10129 @code{org-drawers}.
10130 @item #+LINK:  linkword replace
10131 @vindex org-link-abbrev-alist
10132 These lines (several are allowed) specify link abbreviations.
10133 @xref{Link abbreviations}.  The corresponding variable is
10134 @code{org-link-abbrev-alist}.
10135 @item #+PRIORITIES: highest lowest default
10136 @vindex org-highest-priority
10137 @vindex org-lowest-priority
10138 @vindex org-default-priority
10139 This line sets the limits and the default for the priorities.  All three
10140 must be either letters A-Z or numbers 0-9.  The highest priority must
10141 have a lower ASCII number that the lowest priority.
10142 @item #+PROPERTY: Property_Name Value
10143 This line sets a default inheritance value for entries in the current
10144 buffer, most useful for specifying the allowed values of a property.
10145 @cindex #+SETUPFILE
10146 @item #+SETUPFILE: file
10147 This line defines a file that holds more in-buffer setup.  Normally this is
10148 entirely ignored.  Only when the buffer is parsed for option-setting lines
10149 (@ie when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
10150 settings line, or when exporting), then the contents of this file are parsed
10151 as if they had been included in the buffer.  In particular, the file can be
10152 any other Org mode file with internal setup.  You can visit the file the
10153 cursor is in the line with @kbd{C-c '}.
10154 @item #+STARTUP:
10155 @cindex #+STARTUP:
10156 This line sets options to be used at startup of Org mode, when an
10157 Org file is being visited.
10159 The first set of options deals with the initial visibility of the outline
10160 tree.  The corresponding variable for global default settings is
10161 @code{org-startup-folded}, with a default value @code{t}, which means
10162 @code{overview}.
10163 @vindex org-startup-folded
10164 @cindex @code{overview}, STARTUP keyword
10165 @cindex @code{content}, STARTUP keyword
10166 @cindex @code{showall}, STARTUP keyword
10167 @example
10168 overview   @r{top-level headlines only}
10169 content    @r{all headlines}
10170 showall    @r{no folding at all, show everything}
10171 @end example
10173 @vindex org-startup-indented
10174 @cindex @code{indent}, STARTUP keyword
10175 @cindex @code{noindent}, STARTUP keyword
10176 Dynamic virtual indentation is controlled by the variable
10177 @code{org-startup-indented}@footnote{Emacs 23 and Org-mode 6.29 are required}
10178 @example
10179 indent     @r{start with @code{org-indent-mode} turned on}
10180 noindent   @r{start with @code{org-indent-mode} turned off}
10181 @end example
10183 @vindex org-startup-align-all-tables
10184 Then there are options for aligning tables upon visiting a file.  This
10185 is useful in files containing narrowed table columns.  The corresponding
10186 variable is @code{org-startup-align-all-tables}, with a default value
10187 @code{nil}.
10188 @cindex @code{align}, STARTUP keyword
10189 @cindex @code{noalign}, STARTUP keyword
10190 @example
10191 align      @r{align all tables}
10192 noalign    @r{don't align tables on startup}
10193 @end example
10194 @vindex org-log-done
10195 @vindex org-log-note-clock-out
10196 @vindex org-log-repeat
10197 Logging the closing and reopening of TODO items and clock intervals can be
10198 configured using these options (see variables @code{org-log-done},
10199 @code{org-log-note-clock-out} and @code{org-log-repeat})
10200 @cindex @code{logdone}, STARTUP keyword
10201 @cindex @code{lognotedone}, STARTUP keyword
10202 @cindex @code{nologdone}, STARTUP keyword
10203 @cindex @code{lognoteclock-out}, STARTUP keyword
10204 @cindex @code{nolognoteclock-out}, STARTUP keyword
10205 @cindex @code{logrepeat}, STARTUP keyword
10206 @cindex @code{lognoterepeat}, STARTUP keyword
10207 @cindex @code{nologrepeat}, STARTUP keyword
10208 @example
10209 logdone            @r{record a timestamp when an item is marked DONE}
10210 lognotedone        @r{record timestamp and a note when DONE}
10211 nologdone          @r{don't record when items are marked DONE}
10212 logrepeat          @r{record a time when reinstating a repeating item}
10213 lognoterepeat      @r{record a note when reinstating a repeating item}
10214 nologrepeat        @r{do not record when reinstating repeating item}
10215 lognoteclock-out   @r{record a note when clocking out}
10216 nolognoteclock-out @r{don't record a note when clocking out}
10217 @end example
10218 @vindex org-hide-leading-stars
10219 @vindex org-odd-levels-only
10220 Here are the options for hiding leading stars in outline headings, and for
10221 indenting outlines.  The corresponding variables are
10222 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
10223 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
10224 @cindex @code{hidestars}, STARTUP keyword
10225 @cindex @code{showstars}, STARTUP keyword
10226 @cindex @code{odd}, STARTUP keyword
10227 @cindex @code{even}, STARTUP keyword
10228 @example
10229 hidestars  @r{make all but one of the stars starting a headline invisible.}
10230 showstars  @r{show all stars starting a headline}
10231 indent     @r{virtual indentation according to outline level}
10232 noindent   @r{no virtual indentation according to outline level}
10233 odd        @r{allow only odd outline levels (1,3,...)}
10234 oddeven    @r{allow all outline levels}
10235 @end example
10236 @vindex org-put-time-stamp-overlays
10237 @vindex org-time-stamp-overlay-formats
10238 To turn on custom format overlays over timestamps (variables
10239 @code{org-put-time-stamp-overlays} and
10240 @code{org-time-stamp-overlay-formats}), use
10241 @cindex @code{customtime}, STARTUP keyword
10242 @example
10243 customtime @r{overlay custom time format}
10244 @end example
10245 @vindex constants-unit-system
10246 The following options influence the table spreadsheet (variable
10247 @code{constants-unit-system}).
10248 @cindex @code{constcgs}, STARTUP keyword
10249 @cindex @code{constSI}, STARTUP keyword
10250 @example
10251 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
10252 constSI    @r{@file{constants.el} should use the SI unit system}
10253 @end example
10254 @vindex org-footnote-define-inline
10255 @vindex org-footnote-auto-label
10256 @vindex org-footnote-auto-adjust
10257 To influence footnote settings, use the following keywords.  The
10258 corresponding variables are @code{org-footnote-define-inline},
10259 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
10260 @cindex @code{fninline}, STARTUP keyword
10261 @cindex @code{nofninline}, STARTUP keyword
10262 @cindex @code{fnlocal}, STARTUP keyword
10263 @cindex @code{fnprompt}, STARTUP keyword
10264 @cindex @code{fnauto}, STARTUP keyword
10265 @cindex @code{fnconfirm}, STARTUP keyword
10266 @cindex @code{fnplain}, STARTUP keyword
10267 @cindex @code{fnadjust}, STARTUP keyword
10268 @cindex @code{nofnadjust}, STARTUP keyword
10269 @example
10270 fninline    @r{define footnotes inline}
10271 fnnoinline  @r{define footnotes in separate section}
10272 fnlocal     @r{define footnotes near first reference, but not inline}
10273 fnprompt    @r{prompt for footnote labels}
10274 fnauto      @r{create [fn:1]-like labels automatically (default)}
10275 fnconfirm   @r{offer automatic label for editing or confirmation}
10276 fnplain     @r{create [1]-like labels automatically}
10277 fnadjust    @r{automatically renumber and sort footnotes}
10278 nofnadjust  @r{do not renumber and sort automatically}
10279 @end example
10280 @cindex org-hide-block-startup
10281 To hide blocks on startup, use these keywords. The corresponding variable is
10282 @code{org-hide-block-startup}.
10283 @cindex @code{hideblocks}, STARTUP keyword
10284 @cindex @code{nohideblocks}, STARTUP keyword
10285 @example
10286 hideblocks   @r{Hide all begin/end blocks on startup}
10287 nohideblocks @r{Do not hide blocks on startup}
10288 @end example
10289 @item #+TAGS:  TAG1(c1) TAG2(c2)
10290 @vindex org-tag-alist
10291 These lines (several such lines are allowed) specify the valid tags in
10292 this file, and (potentially) the corresponding @emph{fast tag selection}
10293 keys.  The corresponding variable is @code{org-tag-alist}.
10294 @item #+TBLFM:
10295 This line contains the formulas for the table directly above the line.
10296 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+DATE:,
10297 @itemx #+OPTIONS:, #+BIND:
10298 @itemx #+DESCRIPTION:, #+KEYWORDS:
10299 @itemx #+LATEX_HEADER:, #+STYLE:, #+LINK_UP:, #+LINK_HOME:,
10300 @itemx #+EXPORT_SELECT_TAGS:, #+EXPORT_EXCLUDE_TAGS:
10301 These lines provide settings for exporting files.  For more details see
10302 @ref{Export options}.
10303 @item #+TODO:    #+SEQ_TODO:   #+TYP_TODO:
10304 @vindex org-todo-keywords
10305 These lines set the TODO keywords and their interpretation in the
10306 current file.  The corresponding variable is @code{org-todo-keywords}.
10307 @end table
10309 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
10310 @section The very busy C-c C-c key
10311 @kindex C-c C-c
10312 @cindex C-c C-c, overview
10314 The key @kbd{C-c C-c} has many purposes in Org, which are all
10315 mentioned scattered throughout this manual.  One specific function of
10316 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
10317 other circumstances it means something like @emph{``Hey Org, look
10318 here and update according to what you see here''}.  Here is a summary of
10319 what this means in different contexts.
10321 @itemize @minus
10322 @item
10323 If there are highlights in the buffer from the creation of a sparse
10324 tree, or from clock display, remove these highlights.
10325 @item
10326 If the cursor is in one of the special @code{#+KEYWORD} lines, this
10327 triggers scanning the buffer for these lines and updating the
10328 information.
10329 @item
10330 If the cursor is inside a table, realign the table.  This command
10331 works even if the automatic table editor has been turned off.
10332 @item
10333 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
10334 the entire table.
10335 @item
10336 If the cursor is inside a table created by the @file{table.el} package,
10337 activate that table.
10338 @item
10339 If the current buffer is a Remember buffer, close the note and file it.
10340 With a prefix argument, file it, without further interaction, to the
10341 default location.
10342 @item
10343 If the cursor is on a @code{<<<target>>>}, update radio targets and
10344 corresponding links in this buffer.
10345 @item
10346 If the cursor is in a property line or at the start or end of a property
10347 drawer, offer property commands.
10348 @item
10349 If the cursor is at a footnote reference, go to the corresponding
10350 definition, and vice versa.
10351 @item
10352 If the cursor is on a statistics cookie, update it.
10353 @item
10354 If the cursor is in a plain list item with a checkbox, toggle the status
10355 of the checkbox.
10356 @item
10357 If the cursor is on a numbered item in a plain list, renumber the
10358 ordered list.
10359 @item
10360 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
10361 block is updated.
10362 @end itemize
10364 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
10365 @section A cleaner outline view
10366 @cindex hiding leading stars
10367 @cindex dynamic indentation
10368 @cindex odd-levels-only outlines
10369 @cindex clean outline view
10371 Some people find it noisy and distracting that the Org headlines start with a
10372 potentially large number of stars, and that text below the headlines is not
10373 indented.  While this is no problem when writing a @emph{book-like} document
10374 where the outline headings are really section headings, in a more
10375 @emph{list-oriented} outline, indented structure is a lot cleaner:
10377 @example
10378 @group
10379 * Top level headline             |    * Top level headline
10380 ** Second level                  |      * Second level
10381 *** 3rd level                    |        * 3rd level
10382 some text                        |          some text
10383 *** 3rd level                    |        * 3rd level
10384 more text                        |          more text
10385 * Another top level headline     |    * Another top level headline
10386 @end group
10387 @end example
10389 @noindent
10390 If you are using at least Emacs 23.1.50.3 and version 6.29 of Org, this kind
10391 of view can be achieved dynamically at display time using
10392 @code{org-indent-mode}.  In this minor mode, all lines are prefixed for
10393 display with the necessary amount of space.  Also headlines are prefixed with
10394 additional stars, so that the amount of indentation shifts by
10395 two@footnote{See the variable @code{org-indent-indentation-per-level}.}
10396 spaces per level.  All headline stars but the last one are made invisible
10397 using the @code{org-hide} face@footnote{Turning on @code{org-indent-mode}
10398 sets @code{org-hide-leading-stars} to @code{t} and
10399 @code{org-adapt-indentation} to @code{nil}.} - see below under @samp{2.} for
10400 more information on how this works.  You can turn on @code{org-indent-mode}
10401 for all files by customizing the variable @code{org-startup-indented}, or you
10402 can turn it on for individual files using
10404 @example
10405 #+STARTUP: indent
10406 @end example
10408 If you want a similar effect in earlier version of Emacs and/or Org, or if
10409 you want the indentation to be hard space characters so that the plain text
10410 file looks as similar as possible to the Emacs display, Org supports you in
10411 the following way:
10413 @enumerate
10414 @item
10415 @emph{Indentation of text below headlines}@*
10416 You may indent text below each headline to make the left boundary line up
10417 with the headline, like
10419 @example
10420 *** 3rd level
10421     more text, now indented
10422 @end example
10424 @vindex org-adapt-indentation
10425 Org supports this with paragraph filling, line wrapping, and structure
10426 editing@footnote{See also the variable @code{org-adapt-indentation}.},
10427 preserving or adapting the indentation as appropriate.
10429 @item
10430 @vindex org-hide-leading-stars
10431 @emph{Hiding leading stars}@* You can modify the display in such a way that
10432 all leading stars become invisible.  To do this in a global way, configure
10433 the variable @code{org-hide-leading-stars} or change this on a per-file basis
10434 with
10436 @example
10437 #+STARTUP: hidestars
10438 #+STARTUP: showstars
10439 @end example
10441 With hidden stars, the tree becomes:
10443 @example
10444 @group
10445 * Top level headline
10446  * Second level
10447   * 3rd level
10448   ...
10449 @end group
10450 @end example
10452 @noindent
10453 @vindex org-hide @r{(face)}
10454 The leading stars are not truly replaced by whitespace, they are only
10455 fontified with the face @code{org-hide} that uses the background color as
10456 font color.  If you are not using either white or black background, you may
10457 have to customize this face to get the wanted effect.  Another possibility is
10458 to set this font such that the extra stars are @i{almost} invisible, for
10459 example using the color @code{grey90} on a white background.
10461 @item
10462 @vindex org-odd-levels-only
10463 Things become cleaner still if you skip all the even levels and use only odd
10464 levels 1, 3, 5..., effectively adding two stars to go from one outline level
10465 to the next@footnote{When you need to specify a level for a property search
10466 or refile targets, @samp{LEVEL=2} will correspond to 3 stars, etc@.}.  In this
10467 way we get the outline view shown at the beginning of this section.  In order
10468 to make the structure editing and export commands handle this convention
10469 correctly, configure the variable @code{org-odd-levels-only}, or set this on
10470 a per-file basis with one of the following lines:
10472 @example
10473 #+STARTUP: odd
10474 #+STARTUP: oddeven
10475 @end example
10477 You can convert an Org file from single-star-per-level to the
10478 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
10479 RET} in that file.  The reverse operation is @kbd{M-x
10480 org-convert-to-oddeven-levels}.
10481 @end enumerate
10483 @node TTY keys, Interaction, Clean view, Miscellaneous
10484 @section Using Org on a tty
10485 @cindex tty key bindings
10487 Because Org contains a large number of commands, by default many of
10488 Org's core commands are bound to keys that are generally not
10489 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
10490 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
10491 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
10492 these commands on a tty when special keys are unavailable, the following
10493 alternative bindings can be used.  The tty bindings below will likely be
10494 more cumbersome; you may find for some of the bindings below that a
10495 customized workaround suits you better.  For example, changing a timestamp
10496 is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
10497 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
10499 @multitable @columnfractions 0.15 0.2 0.2
10500 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
10501 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
10502 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
10503 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
10504 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
10505 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
10506 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
10507 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
10508 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
10509 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
10510 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
10511 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
10512 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
10513 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
10514 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
10515 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
10516 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
10517 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
10518 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
10519 @end multitable
10522 @node Interaction,  , TTY keys, Miscellaneous
10523 @section Interaction with other packages
10524 @cindex packages, interaction with other
10525 Org lives in the world of GNU Emacs and interacts in various ways
10526 with other code out there.
10528 @menu
10529 * Cooperation::                 Packages Org cooperates with
10530 * Conflicts::                   Packages that lead to conflicts
10531 @end menu
10533 @node Cooperation, Conflicts, Interaction, Interaction
10534 @subsection Packages that Org cooperates with
10536 @table @asis
10537 @cindex @file{calc.el}
10538 @cindex Gillespie, Dave
10539 @item @file{calc.el} by Dave Gillespie
10540 Org uses the Calc package for implementing spreadsheet
10541 functionality in its tables (@pxref{The spreadsheet}).  Org
10542 checks for the availability of Calc by looking for the function
10543 @code{calc-eval} which will have been autoloaded during setup if Calc has
10544 been installed properly.  As of Emacs 22, Calc is part of the Emacs
10545 distribution.  Another possibility for interaction between the two
10546 packages is using Calc for embedded calculations. @xref{Embedded Mode,
10547 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
10548 @item @file{constants.el} by Carsten Dominik
10549 @cindex @file{constants.el}
10550 @cindex Dominik, Carsten
10551 @vindex org-table-formula-constants
10552 In a table formula (@pxref{The spreadsheet}), it is possible to use
10553 names for natural constants or units.  Instead of defining your own
10554 constants in the variable @code{org-table-formula-constants}, install
10555 the @file{constants} package which defines a large number of constants
10556 and units, and lets you use unit prefixes like @samp{M} for
10557 @samp{Mega}, etc@.  You will need version 2.0 of this package, available
10558 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
10559 the function @code{constants-get}, which has to be autoloaded in your
10560 setup.  See the installation instructions in the file
10561 @file{constants.el}.
10562 @item @file{cdlatex.el} by Carsten Dominik
10563 @cindex @file{cdlatex.el}
10564 @cindex Dominik, Carsten
10565 Org mode can make use of the CDLa@TeX{} package to efficiently enter
10566 La@TeX{} fragments into Org files.  See @ref{CDLaTeX mode}.
10567 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
10568 @cindex @file{imenu.el}
10569 Imenu allows menu access to an index of items in a file.  Org mode
10570 supports Imenu---all you need to do to get the index is the following:
10571 @lisp
10572 (add-hook 'org-mode-hook
10573           (lambda () (imenu-add-to-menubar "Imenu")))
10574 @end lisp
10575 @vindex org-imenu-depth
10576 By default the index is two levels deep---you can modify the depth using
10577 the option @code{org-imenu-depth}.
10578 @item @file{remember.el} by John Wiegley
10579 @cindex @file{remember.el}
10580 @cindex Wiegley, John
10581 Org cooperates with remember, see @ref{Remember}.
10582 @file{Remember.el} is not part of Emacs, find it on the web.
10583 @item @file{speedbar.el} by Eric M. Ludlam
10584 @cindex @file{speedbar.el}
10585 @cindex Ludlam, Eric M.
10586 Speedbar is a package that creates a special frame displaying files and
10587 index items in files.  Org mode supports Speedbar and allows you to
10588 drill into Org files directly from the Speedbar.  It also allows you to
10589 restrict the scope of agenda commands to a file or a subtree by using
10590 the command @kbd{<} in the Speedbar frame.
10591 @cindex @file{table.el}
10592 @item @file{table.el} by Takaaki Ota
10593 @kindex C-c C-c
10594 @cindex table editor, @file{table.el}
10595 @cindex @file{table.el}
10596 @cindex Ota, Takaaki
10598 Complex ASCII tables with automatic line wrapping, column- and
10599 row-spanning, and alignment can be created using the Emacs table
10600 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
10601 and also part of Emacs 22).
10602 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
10603 will call @command{table-recognize-table} and move the cursor into the
10604 table.  Inside a table, the keymap of Org mode is inactive.  In order
10605 to execute Org mode-related commands, leave the table.
10607 @table @kbd
10608 @kindex C-c C-c
10609 @item C-c C-c
10610 Recognize @file{table.el} table.  Works when the cursor is in a
10611 table.el table.
10613 @kindex C-c ~
10614 @item C-c ~
10615 Insert a @file{table.el} table.  If there is already a table at point, this
10616 command converts it between the @file{table.el} format and the Org-mode
10617 format.  See the documentation string of the command
10618 @code{org-convert-table} for the restrictions under which this is
10619 possible.
10620 @end table
10621 @file{table.el} is part of Emacs 22.
10622 @item @file{footnote.el} by Steven L. Baur
10623 @cindex @file{footnote.el}
10624 @cindex Baur, Steven L.
10625 Org mode recognizes numerical footnotes as provided by this package.
10626 However, Org mode also has its own footnote support (@pxref{Footnotes}),
10627 which makes using @file{footnote.el} unnecessary.
10628 @end table
10630 @node Conflicts,  , Cooperation, Interaction
10631 @subsection Packages that lead to conflicts with Org mode
10633 @table @asis
10635 @cindex @code{shift-selection-mode}
10636 @vindex org-support-shift-select
10637 In Emacs 23, @code{shift-selection-mode} is on by default, meaning that
10638 cursor motions combined with the shift key should start or enlarge regions.
10639 This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
10640 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
10641 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
10642 special contexts don't do anything, but you can customize the variable
10643 @code{org-support-shift-select}.  Org mode then tries to accommodate shift
10644 selection by (i) using it outside of the special contexts where special
10645 commands apply, and by (ii) extending an existing active region even if the
10646 cursor moves across a special context.
10648 @item @file{CUA.el} by Kim. F. Storm
10649 @cindex @file{CUA.el}
10650 @cindex Storm, Kim. F.
10651 @vindex org-replace-disputed-keys
10652 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by CUA mode
10653 (as well as @code{pc-select-mode} and @code{s-region-mode}) to select and extend the
10654 region.  In fact, Emacs 23 has this built-in in the form of
10655 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
10656 23, you probably don't want to use another package for this purpose.  However,
10657 if you prefer to leave these keys to a different package while working in
10658 Org mode, configure the variable @code{org-replace-disputed-keys}.  When set,
10659 Org will move the following key bindings in Org files, and in the agenda
10660 buffer (but not during date selection).
10662 @example
10663 S-UP      ->  M-p             S-DOWN     ->  M-n
10664 S-LEFT    ->  M--             S-RIGHT    ->  M-+
10665 C-S-LEFT  ->  M-S--           C-S-RIGHT  ->  M-S-+
10666 @end example
10668 @vindex org-disputed-keys
10669 Yes, these are unfortunately more difficult to remember.  If you want
10670 to have other replacement keys, look at the variable
10671 @code{org-disputed-keys}.
10673 @item @file{yasnippet.el}
10674 @cindex @file{yasnippet.el}
10675 The way Org-mode binds the TAB key (binding to @code{[tab]} instead of
10676 @code{"\t"}) overrules yasnippets' access to this key.  The following code
10677 fixed this problem:
10679 @lisp
10680 (add-hook 'org-mode-hook
10681           (lambda ()
10682             (org-set-local 'yas/trigger-key [tab])
10683             (define-key yas/keymap [tab] 'yas/next-field-group)))
10684 @end lisp
10686 @item @file{windmove.el} by Hovav Shacham
10687 @cindex @file{windmove.el}
10688 This package also uses the @kbd{S-<cursor>} keys, so everything written
10689 in the paragraph above about CUA mode also applies here.
10691 @end table
10693 @node Hacking, History and Acknowledgments, Miscellaneous, Top
10694 @appendix Hacking
10695 @cindex hacking
10697 This appendix covers some aspects where users can extend the functionality of
10698 Org.
10700 @menu
10701 * Hooks::                       Who to reach into Org's internals
10702 * Add-on packages::             Available extensions
10703 * Adding hyperlink types::      New custom link types
10704 * Context-sensitive commands::  How to add functionality to such commands
10705 * Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
10706 * Dynamic blocks::              Automatically filled blocks
10707 * Special agenda views::        Customized views
10708 * Extracting agenda information::  Postprocessing of agenda information
10709 * Using the property API::      Writing programs that use entry properties
10710 * Using the mapping API::       Mapping over all or selected entries
10711 @end menu
10713 @node Hooks, Add-on packages, Hacking, Hacking
10714 @section Hooks
10715 @cindex hooks
10717 Org has a large number of hook variables that can be used to add
10718 functionality.  This appendix about hacking is going to illustrate the
10719 use of some of them.  A complete list of all hooks with documentation is
10720 maintained by the Worg project and can be found at
10721 @uref{http://orgmode.org/worg/org-configs/org-hooks.php}.
10723 @node Add-on packages, Adding hyperlink types, Hooks, Hacking
10724 @section Add-on packages
10725 @cindex add-on packages
10727 A large number of add-on packages have been written by various authors.
10728 These packages are not part of Emacs, but they are distributed as contributed
10729 packages with the separate release available at the Org mode home page at
10730 @uref{http://orgmode.org}.  The list of contributed packages, along with
10731 documentation about each package, is maintained by the Worg project at
10732 @uref{http://orgmode.org/worg/org-contrib/}.
10736 @node Adding hyperlink types, Context-sensitive commands, Add-on packages, Hacking
10737 @section Adding hyperlink types
10738 @cindex hyperlinks, adding new types
10740 Org has a large number of hyperlink types built-in
10741 (@pxref{Hyperlinks}).  If you would like to add new link types, Org
10742 provides an interface for doing so.  Let's look at an example file,
10743 @file{org-man.el}, that will add support for creating links like
10744 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
10745 Emacs:
10747 @lisp
10748 ;;; org-man.el - Support for links to manpages in Org
10750 (require 'org)
10752 (org-add-link-type "man" 'org-man-open)
10753 (add-hook 'org-store-link-functions 'org-man-store-link)
10755 (defcustom org-man-command 'man
10756   "The Emacs command to be used to display a man page."
10757   :group 'org-link
10758   :type '(choice (const man) (const woman)))
10760 (defun org-man-open (path)
10761   "Visit the manpage on PATH.
10762 PATH should be a topic that can be thrown at the man command."
10763   (funcall org-man-command path))
10765 (defun org-man-store-link ()
10766   "Store a link to a manpage."
10767   (when (memq major-mode '(Man-mode woman-mode))
10768     ;; This is a man page, we do make this link
10769     (let* ((page (org-man-get-page-name))
10770            (link (concat "man:" page))
10771            (description (format "Manpage for %s" page)))
10772       (org-store-link-props
10773        :type "man"
10774        :link link
10775        :description description))))
10777 (defun org-man-get-page-name ()
10778   "Extract the page name from the buffer name."
10779   ;; This works for both `Man-mode' and `woman-mode'.
10780   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
10781       (match-string 1 (buffer-name))
10782     (error "Cannot create link to this man page")))
10784 (provide 'org-man)
10786 ;;; org-man.el ends here
10787 @end lisp
10789 @noindent
10790 You would activate this new link type in @file{.emacs} with
10792 @lisp
10793 (require 'org-man)
10794 @end lisp
10796 @noindent
10797 Let's go through the file and see what it does.
10798 @enumerate
10799 @item
10800 It does @code{(require 'org)} to make sure that @file{org.el} has been
10801 loaded.
10802 @item
10803 The next line calls @code{org-add-link-type} to define a new link type
10804 with prefix @samp{man}.  The call also contains the name of a function
10805 that will be called to follow such a link.
10806 @item
10807 @vindex org-store-link-functions
10808 The next line adds a function to @code{org-store-link-functions}, in
10809 order to allow the command @kbd{C-c l} to record a useful link in a
10810 buffer displaying a man page.
10811 @end enumerate
10813 The rest of the file defines the necessary variables and functions.
10814 First there is a customization variable that determines which Emacs
10815 command should be used to display man pages.  There are two options,
10816 @code{man} and @code{woman}.  Then the function to follow a link is
10817 defined.  It gets the link path as an argument---in this case the link
10818 path is just a topic for the manual command.  The function calls the
10819 value of @code{org-man-command} to display the man page.
10821 Finally the function @code{org-man-store-link} is defined.  When you try
10822 to store a link with @kbd{C-c l}, this function will be called to
10823 try to make a link.  The function must first decide if it is supposed to
10824 create the link for this buffer type; we do this by checking the value
10825 of the variable @code{major-mode}.  If not, the function must exit and
10826 return the value @code{nil}.  If yes, the link is created by getting the
10827 manual topic from the buffer name and prefixing it with the string
10828 @samp{man:}.  Then it must call the command @code{org-store-link-props}
10829 and set the @code{:type} and @code{:link} properties.  Optionally you
10830 can also set the @code{:description} property to provide a default for
10831 the link description when the link is later inserted into an Org
10832 buffer with @kbd{C-c C-l}.
10834 When is makes sense for your new link type, you may also define a function
10835 @code{org-PREFIX-complete-link} that implements special (@eg completion)
10836 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
10837 not accept any arguments, and return the full link with prefix.
10839 @node Context-sensitive commands, Tables in arbitrary syntax, Adding hyperlink types, Hacking
10840 @section Context-sensitive commands
10841 @cindex context-sensitive commands, hooks
10842 @cindex add-ons, context-sensitive commands
10843 @vindex org-ctrl-c-ctrl-c-hook
10845 Org has several commands that act differently depending on context.  The most
10846 important example it the @kbd{C-c C-c} (@pxref{The very busy C-c C-c key}).
10847 Also the @kbd{M-cursor} and @kbd{M-S-cursor} keys have this property.
10849 Add-ons can tap into this functionality by providing a function that detects
10850 special context for that add-on and executes functionality appropriate for
10851 the context.  Here is an example from Dan Davison's @file{org-R.el} which
10852 allows you to evaluate commands based on the @file{R} programming language.  For
10853 this package, special contexts are lines that start with @code{#+R:} or
10854 @code{#+RR:}.
10856 @lisp
10857 (defun org-R-apply-maybe ()
10858   "Detect if this is context for org-R and execute R commands."
10859   (if (save-excursion
10860         (beginning-of-line 1)
10861         (looking-at "#\\+RR?:"))
10862       (progn (call-interactively 'org-R-apply)
10863              t) ;; to signal that we took action
10864     nil)) ;; to signal that we did not
10866 (add-hook 'org-ctrl-c-ctrl-c-hook 'org-R-apply-maybe)
10867 @end lisp
10869 The function first checks if the cursor is in such a line.  If that is the
10870 case, @code{org-R-apply} is called and the function returns @code{t} to
10871 signal that action was taken, and @kbd{C-c C-c} will stop looking for other
10872 contexts.  If the function finds it should do nothing locally, it returns @code{nil} so that other, similar functions can have a try.
10875 @node Tables in arbitrary syntax, Dynamic blocks, Context-sensitive commands, Hacking
10876 @section Tables and lists in arbitrary syntax
10877 @cindex tables, in other modes
10878 @cindex lists, in other modes
10879 @cindex Orgtbl mode
10881 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
10882 frequent feature request has been to make it work with native tables in
10883 specific languages, for example La@TeX{}.  However, this is extremely
10884 hard to do in a general way, would lead to a customization nightmare,
10885 and would take away much of the simplicity of the Orgtbl-mode table
10886 editor.
10889 This appendix describes a different approach.  We keep the Orgtbl mode
10890 table in its native format (the @i{source table}), and use a custom
10891 function to @i{translate} the table to the correct syntax, and to
10892 @i{install} it in the right location (the @i{target table}).  This puts
10893 the burden of writing conversion functions on the user, but it allows
10894 for a very flexible system.
10896 Bastien added the ability to do the same with lists.  You can use Org's
10897 facilities to edit and structure lists by turning @code{orgstruct-mode}
10898 on, then locally exporting such lists in another format (HTML, La@TeX{}
10899 or Texinfo.)
10902 @menu
10903 * Radio tables::                Sending and receiving radio tables
10904 * A LaTeX example::             Step by step, almost a tutorial
10905 * Translator functions::        Copy and modify
10906 * Radio lists::                 Doing the same for lists
10907 @end menu
10909 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
10910 @subsection Radio tables
10911 @cindex radio tables
10913 To define the location of the target table, you first need to create two
10914 lines that are comments in the current mode, but contain magic words for
10915 Orgtbl mode to find.  Orgtbl mode will insert the translated table
10916 between these lines, replacing whatever was there before.  For example:
10918 @example
10919 /* BEGIN RECEIVE ORGTBL table_name */
10920 /* END RECEIVE ORGTBL table_name */
10921 @end example
10923 @noindent
10924 Just above the source table, we put a special line that tells
10925 Orgtbl mode how to translate this table and where to install it.  For
10926 example:
10927 @cindex #+ORGTBL
10928 @example
10929 #+ORGTBL: SEND table_name translation_function arguments....
10930 @end example
10932 @noindent
10933 @code{table_name} is the reference name for the table that is also used
10934 in the receiver lines. @code{translation_function} is the Lisp function
10935 that does the translation.  Furthermore, the line can contain a list of
10936 arguments (alternating key and value) at the end.  The arguments will be
10937 passed as a property list to the translation function for
10938 interpretation.  A few standard parameters are already recognized and
10939 acted upon before the translation function is called:
10941 @table @code
10942 @item :skip N
10943 Skip the first N lines of the table.  Hlines do count as separate lines for
10944 this parameter!
10946 @item :skipcols (n1 n2 ...)
10947 List of columns that should be skipped.  If the table has a column with
10948 calculation marks, that column is automatically discarded as well.
10949 Please note that the translator function sees the table @emph{after} the
10950 removal of these columns, the function never knows that there have been
10951 additional columns.
10952 @end table
10954 @noindent
10955 The one problem remaining is how to keep the source table in the buffer
10956 without disturbing the normal workings of the file, for example during
10957 compilation of a C file or processing of a La@TeX{} file.  There are a
10958 number of different solutions:
10960 @itemize @bullet
10961 @item
10962 The table could be placed in a block comment if that is supported by the
10963 language.  For example, in C mode you could wrap the table between
10964 @samp{/*} and @samp{*/} lines.
10965 @item
10966 Sometimes it is possible to put the table after some kind of @i{END}
10967 statement, for example @samp{\bye} in @TeX{} and @samp{\end@{document@}}
10968 in La@TeX{}.
10969 @item
10970 You can just comment the table line-by-line whenever you want to process
10971 the file, and uncomment it whenever you need to edit the table.  This
10972 only sounds tedious---the command @kbd{M-x orgtbl-toggle-comment}
10973 makes this comment-toggling very easy, in particular if you bind it to a
10974 key.
10975 @end itemize
10977 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
10978 @subsection A La@TeX{} example of radio tables
10979 @cindex La@TeX{}, and Orgtbl mode
10981 The best way to wrap the source table in La@TeX{} is to use the
10982 @code{comment} environment provided by @file{comment.sty}.  It has to be
10983 activated by placing @code{\usepackage@{comment@}} into the document
10984 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
10985 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
10986 variable @code{orgtbl-radio-tables} to install templates for other
10987 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
10988 be prompted for a table name, let's say we use @samp{salesfigures}.  You
10989 will then get the following template:
10991 @cindex #+ORGTBL, SEND
10992 @example
10993 % BEGIN RECEIVE ORGTBL salesfigures
10994 % END RECEIVE ORGTBL salesfigures
10995 \begin@{comment@}
10996 #+ORGTBL: SEND salesfigures orgtbl-to-latex
10997 | | |
10998 \end@{comment@}
10999 @end example
11001 @noindent
11002 @vindex La@TeX{}-verbatim-environments
11003 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
11004 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
11005 into the receiver location with name @code{salesfigures}.  You may now
11006 fill in the table, feel free to use the spreadsheet features@footnote{If
11007 the @samp{#+TBLFM} line contains an odd number of dollar characters,
11008 this may cause problems with font-lock in La@TeX{} mode.  As shown in the
11009 example you can fix this by adding an extra line inside the
11010 @code{comment} environment that is used to balance the dollar
11011 expressions.  If you are using AUC@TeX{} with the font-latex library, a
11012 much better solution is to add the @code{comment} environment to the
11013 variable @code{LaTeX-verbatim-environments}.}:
11015 @example
11016 % BEGIN RECEIVE ORGTBL salesfigures
11017 % END RECEIVE ORGTBL salesfigures
11018 \begin@{comment@}
11019 #+ORGTBL: SEND salesfigures orgtbl-to-latex
11020 | Month | Days | Nr sold | per day |
11021 |-------+------+---------+---------|
11022 | Jan   |   23 |      55 |     2.4 |
11023 | Feb   |   21 |      16 |     0.8 |
11024 | March |   22 |     278 |    12.6 |
11025 #+TBLFM: $4=$3/$2;%.1f
11026 % $ (optional extra dollar to keep font-lock happy, see footnote)
11027 \end@{comment@}
11028 @end example
11030 @noindent
11031 When you are done, press @kbd{C-c C-c} in the table to get the converted
11032 table inserted between the two marker lines.
11034 Now let's assume you want to make the table header by hand, because you
11035 want to control how columns are aligned, etc@.  In this case we make sure
11036 that the table translator skips the first 2 lines of the source
11037 table, and tell the command to work as a @i{splice}, @ie to not produce
11038 header and footer commands of the target table:
11040 @example
11041 \begin@{tabular@}@{lrrr@}
11042 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
11043 % BEGIN RECEIVE ORGTBL salesfigures
11044 % END RECEIVE ORGTBL salesfigures
11045 \end@{tabular@}
11047 \begin@{comment@}
11048 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
11049 | Month | Days | Nr sold | per day |
11050 |-------+------+---------+---------|
11051 | Jan   |   23 |      55 |     2.4 |
11052 | Feb   |   21 |      16 |     0.8 |
11053 | March |   22 |     278 |    12.6 |
11054 #+TBLFM: $4=$3/$2;%.1f
11055 \end@{comment@}
11056 @end example
11058 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
11059 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
11060 and marks horizontal lines with @code{\hline}.  Furthermore, it
11061 interprets the following parameters (see also @pxref{Translator functions}):
11063 @table @code
11064 @item :splice nil/t
11065 When set to t, return only table body lines, don't wrap them into a
11066 tabular environment.  Default is nil.
11068 @item :fmt fmt
11069 A format to be used to wrap each field, it should contain @code{%s} for the
11070 original field value.  For example, to wrap each field value in dollars,
11071 you could use @code{:fmt "$%s$"}.  This may also be a property list with
11072 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
11073 A function of one argument can be used in place of the strings; the
11074 function must return a formatted string.
11076 @item :efmt efmt
11077 Use this format to print numbers with exponentials.  The format should
11078 have @code{%s} twice for inserting mantissa and exponent, for example
11079 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
11080 may also be a property list with column numbers and formats, for example
11081 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
11082 @code{efmt} has been applied to a value, @code{fmt} will also be
11083 applied.  Similar to @code{fmt}, functions of two arguments can be
11084 supplied instead of strings.
11085 @end table
11087 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
11088 @subsection Translator functions
11089 @cindex HTML, and Orgtbl mode
11090 @cindex translator function
11092 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
11093 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
11094 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
11095 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
11096 code that produces tables during HTML export.}, these all use a generic
11097 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
11098 itself is a very short function that computes the column definitions for the
11099 @code{tabular} environment, defines a few field and line separators and then
11100 hands processing over to the generic translator.  Here is the entire code:
11102 @lisp
11103 @group
11104 (defun orgtbl-to-latex (table params)
11105   "Convert the Orgtbl mode TABLE to LaTeX."
11106   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
11107                                org-table-last-alignment ""))
11108          (params2
11109           (list
11110            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
11111            :tend "\\end@{tabular@}"
11112            :lstart "" :lend " \\\\" :sep " & "
11113            :efmt "%s\\,(%s)" :hline "\\hline")))
11114     (orgtbl-to-generic table (org-combine-plists params2 params))))
11115 @end group
11116 @end lisp
11118 As you can see, the properties passed into the function (variable
11119 @var{PARAMS}) are combined with the ones newly defined in the function
11120 (variable @var{PARAMS2}).  The ones passed into the function (@ie the
11121 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
11122 would like to use the La@TeX{} translator, but wanted the line endings to
11123 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
11124 overrule the default with
11126 @example
11127 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
11128 @end example
11130 For a new language, you can either write your own converter function in
11131 analogy with the La@TeX{} translator, or you can use the generic function
11132 directly.  For example, if you have a language where a table is started
11133 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
11134 started with @samp{!BL!}, ended with @samp{!EL!}, and where the field
11135 separator is a TAB, you could call the generic translator like this (on
11136 a single line!):
11138 @example
11139 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
11140                               :lstart "!BL! " :lend " !EL!" :sep "\t"
11141 @end example
11143 @noindent
11144 Please check the documentation string of the function
11145 @code{orgtbl-to-generic} for a full list of parameters understood by
11146 that function, and remember that you can pass each of them into
11147 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
11148 using the generic function.
11150 Of course you can also write a completely new function doing complicated
11151 things the generic translator cannot do.  A translator function takes
11152 two arguments.  The first argument is the table, a list of lines, each
11153 line either the symbol @code{hline} or a list of fields.  The second
11154 argument is the property list containing all parameters specified in the
11155 @samp{#+ORGTBL: SEND} line.  The function must return a single string
11156 containing the formatted table.  If you write a generally useful
11157 translator, please post it on @email{emacs-orgmode@@gnu.org} so that
11158 others can benefit from your work.
11160 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
11161 @subsection Radio lists
11162 @cindex radio lists
11163 @cindex org-list-insert-radio-list
11165 Sending and receiving radio lists works exactly the same way than sending and
11166 receiving radio tables (@pxref{Radio tables}).  As for radio tables, you can
11167 insert radio lists templates in HTML, La@TeX{} and Texinfo modes by calling
11168 @code{org-list-insert-radio-list}.
11170 Here are the differences with radio tables:
11172 @itemize @minus
11173 @item
11174 Use @code{ORGLST} instead of @code{ORGTBL}.
11175 @item
11176 The available translation functions for radio lists don't take
11177 parameters.
11178 @item
11179 @kbd{C-c C-c} will work when pressed on the first item of the list.
11180 @end itemize
11182 Here is a La@TeX{} example.  Let's say that you have this in your
11183 La@TeX{} file:
11185 @cindex #+ORGLIST
11186 @example
11187 % BEGIN RECEIVE ORGLST to-buy
11188 % END RECEIVE ORGLST to-buy
11189 \begin@{comment@}
11190 #+ORGLIST: SEND to-buy orgtbl-to-latex
11191 - a new house
11192 - a new computer
11193   + a new keyboard
11194   + a new mouse
11195 - a new life
11196 \end@{comment@}
11197 @end example
11199 Pressing `C-c C-c' on @code{a new house} and will insert the converted
11200 La@TeX{} list between the two marker lines.
11202 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
11203 @section Dynamic blocks
11204 @cindex dynamic blocks
11206 Org documents can contain @emph{dynamic blocks}.  These are
11207 specially marked regions that are updated by some user-written function.
11208 A good example for such a block is the clock table inserted by the
11209 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
11211 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
11212 to the block and can also specify parameters for the function producing
11213 the content of the block.
11215 #+BEGIN:dynamic block
11216 @example
11217 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
11219 #+END:
11220 @end example
11222 Dynamic blocks are updated with the following commands
11224 @table @kbd
11225 @kindex C-c C-x C-u
11226 @item C-c C-x C-u
11227 Update dynamic block at point.
11228 @kindex C-u C-c C-x C-u
11229 @item C-u C-c C-x C-u
11230 Update all dynamic blocks in the current file.
11231 @end table
11233 Updating a dynamic block means to remove all the text between BEGIN and
11234 END, parse the BEGIN line for parameters and then call the specific
11235 writer function for this block to insert the new content.  If you want
11236 to use the original content in the writer function, you can use the
11237 extra parameter @code{:content}.
11239 For a block with name @code{myblock}, the writer function is
11240 @code{org-dblock-write:myblock} with as only parameter a property list
11241 with the parameters given in the begin line.  Here is a trivial example
11242 of a block that keeps track of when the block update function was last
11243 run:
11245 @example
11246 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
11248 #+END:
11249 @end example
11251 @noindent
11252 The corresponding block writer function could look like this:
11254 @lisp
11255 (defun org-dblock-write:block-update-time (params)
11256    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
11257      (insert "Last block update at: "
11258              (format-time-string fmt (current-time)))))
11259 @end lisp
11261 If you want to make sure that all dynamic blocks are always up-to-date,
11262 you could add the function @code{org-update-all-dblocks} to a hook, for
11263 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
11264 written in a way such that it does nothing in buffers that are not in
11265 @code{org-mode}.
11267 @node Special agenda views, Extracting agenda information, Dynamic blocks, Hacking
11268 @section Special agenda views
11269 @cindex agenda views, user-defined
11271 Org provides a special hook that can be used to narrow down the
11272 selection made by any of the agenda views.  You may specify a function
11273 that is used at each match to verify if the match should indeed be part
11274 of the agenda view, and if not, how much should be skipped.
11276 Let's say you want to produce a list of projects that contain a WAITING
11277 tag anywhere in the project tree.  Let's further assume that you have
11278 marked all tree headings that define a project with the TODO keyword
11279 PROJECT.  In this case you would run a TODO search for the keyword
11280 PROJECT, but skip the match unless there is a WAITING tag anywhere in
11281 the subtree belonging to the project line.
11283 To achieve this, you must write a function that searches the subtree for
11284 the tag.  If the tag is found, the function must return @code{nil} to
11285 indicate that this match should not be skipped.  If there is no such
11286 tag, return the location of the end of the subtree, to indicate that
11287 search should continue from there.
11289 @lisp
11290 (defun my-skip-unless-waiting ()
11291   "Skip trees that are not waiting"
11292   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
11293     (if (re-search-forward ":waiting:" subtree-end t)
11294         nil          ; tag found, do not skip
11295       subtree-end))) ; tag not found, continue after end of subtree
11296 @end lisp
11298 Now you may use this function in an agenda custom command, for example
11299 like this:
11301 @lisp
11302 (org-add-agenda-custom-command
11303  '("b" todo "PROJECT"
11304    ((org-agenda-skip-function 'my-skip-unless-waiting)
11305     (org-agenda-overriding-header "Projects waiting for something: "))))
11306 @end lisp
11308 @vindex org-agenda-overriding-header
11309 Note that this also binds @code{org-agenda-overriding-header} to get a
11310 meaningful header in the agenda view.
11312 @vindex org-odd-levels-only
11313 @vindex org-agenda-skip-function
11314 A general way to create custom searches is to base them on a search for
11315 entries with a certain level limit.  If you want to study all entries with
11316 your custom search function, simply do a search for
11317 @samp{LEVEL>0}@footnote{Note that, when using @code{org-odd-levels-only}, a
11318 level number corresponds to order in the hierarchy, not to the number of
11319 stars.}, and then use @code{org-agenda-skip-function} to select the entries
11320 you really want to have.
11322 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
11323 particular, you may use the functions @code{org-agenda-skip-entry-if}
11324 and @code{org-agenda-skip-subtree-if} in this form, for example:
11326 @table @code
11327 @item '(org-agenda-skip-entry-if 'scheduled)
11328 Skip current entry if it has been scheduled.
11329 @item '(org-agenda-skip-entry-if 'notscheduled)
11330 Skip current entry if it has not been scheduled.
11331 @item '(org-agenda-skip-entry-if 'deadline)
11332 Skip current entry if it has a deadline.
11333 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
11334 Skip current entry if it has a deadline, or if it is scheduled.
11335 @item '(org-agenda-skip-entry-if 'timestamp)
11336 Skip current entry if it has any timestamp, may also be deadline or scheduled.
11337 @item '(org-agenda-skip-entry 'regexp "regular expression")
11338 Skip current entry if the regular expression matches in the entry.
11339 @item '(org-agenda-skip-entry 'notregexp "regular expression")
11340 Skip current entry unless the regular expression matches.
11341 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
11342 Same as above, but check and skip the entire subtree.
11343 @end table
11345 Therefore we could also have written the search for WAITING projects
11346 like this, even without defining a special function:
11348 @lisp
11349 (org-add-agenda-custom-command
11350  '("b" todo "PROJECT"
11351    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
11352                                 'regexp ":waiting:"))
11353     (org-agenda-overriding-header "Projects waiting for something: "))))
11354 @end lisp
11356 @node Extracting agenda information, Using the property API, Special agenda views, Hacking
11357 @section Extracting agenda information
11358 @cindex agenda, pipe
11359 @cindex Scripts, for agenda processing
11361 @vindex org-agenda-custom-commands
11362 Org provides commands to access agenda information for the command
11363 line in Emacs batch mode.  This extracted information can be sent
11364 directly to a printer, or it can be read by a program that does further
11365 processing of the data.  The first of these commands is the function
11366 @code{org-batch-agenda}, that produces an agenda view and sends it as
11367 ASCII text to STDOUT.  The command takes a single string as parameter.
11368 If the string has length 1, it is used as a key to one of the commands
11369 you have configured in @code{org-agenda-custom-commands}, basically any
11370 key you can use after @kbd{C-c a}.  For example, to directly print the
11371 current TODO list, you could use
11373 @example
11374 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
11375 @end example
11377 If the parameter is a string with 2 or more characters, it is used as a
11378 tags/TODO match string.  For example, to print your local shopping list
11379 (all items with the tag @samp{shop}, but excluding the tag
11380 @samp{NewYork}), you could use
11382 @example
11383 emacs -batch -l ~/.emacs                                      \
11384       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
11385 @end example
11387 @noindent
11388 You may also modify parameters on the fly like this:
11390 @example
11391 emacs -batch -l ~/.emacs                                      \
11392    -eval '(org-batch-agenda "a"                               \
11393             org-agenda-ndays 30                               \
11394             org-agenda-include-diary nil                      \
11395             org-agenda-files (quote ("~/org/project.org")))'  \
11396    | lpr
11397 @end example
11399 @noindent
11400 which will produce a 30-day agenda, fully restricted to the Org file
11401 @file{~/org/projects.org}, not even including the diary.
11403 If you want to process the agenda data in more sophisticated ways, you
11404 can use the command @code{org-batch-agenda-csv} to get a comma-separated
11405 list of values for each agenda item.  Each line in the output will
11406 contain a number of fields separated by commas.  The fields in a line
11407 are:
11409 @example
11410 category     @r{The category of the item}
11411 head         @r{The headline, without TODO keyword, TAGS and PRIORITY}
11412 type         @r{The type of the agenda entry, can be}
11413                 todo               @r{selected in TODO match}
11414                 tagsmatch          @r{selected in tags match}
11415                 diary              @r{imported from diary}
11416                 deadline           @r{a deadline}
11417                 scheduled          @r{scheduled}
11418                 timestamp          @r{appointment, selected by timestamp}
11419                 closed             @r{entry was closed on date}
11420                 upcoming-deadline  @r{warning about nearing deadline}
11421                 past-scheduled     @r{forwarded scheduled item}
11422                 block              @r{entry has date block including date}
11423 todo         @r{The TODO keyword, if any}
11424 tags         @r{All tags including inherited ones, separated by colons}
11425 date         @r{The relevant date, like 2007-2-14}
11426 time         @r{The time, like 15:00-16:50}
11427 extra        @r{String with extra planning info}
11428 priority-l   @r{The priority letter if any was given}
11429 priority-n   @r{The computed numerical priority}
11430 @end example
11432 @noindent
11433 Time and date will only be given if a timestamp (or deadline/scheduled)
11434 led to the selection of the item.
11436 A CSV list like this is very easy to use in a post-processing script.
11437 For example, here is a Perl program that gets the TODO list from
11438 Emacs/Org and prints all the items, preceded by a checkbox:
11440 @example
11441 #!/usr/bin/perl
11443 # define the Emacs command to run
11444 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
11446 # run it and capture the output
11447 $agenda = qx@{$cmd 2>/dev/null@};
11449 # loop over all lines
11450 foreach $line (split(/\n/,$agenda)) @{
11451   # get the individual values
11452   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
11453    $priority_l,$priority_n) = split(/,/,$line);
11454   # process and print
11455   print "[ ] $head\n";
11457 @end example
11472 @node Using the property API, Using the mapping API, Extracting agenda information, Hacking
11473 @section Using the property API
11474 @cindex API, for properties
11475 @cindex properties, API
11477 Here is a description of the functions that can be used to work with
11478 properties.
11480 @defun org-entry-properties &optional pom which
11481 Get all properties of the entry at point-or-marker POM.@*
11482 This includes the TODO keyword, the tags, time strings for deadline,
11483 scheduled, and clocking, and any additional properties defined in the
11484 entry.  The return value is an alist, keys may occur multiple times
11485 if the property key was used several times.@*
11486 POM may also be nil, in which case the current entry is used.
11487 If WHICH is nil or `all', get all properties.  If WHICH is
11488 `special' or `standard', only get that subclass.
11489 @end defun
11490 @vindex org-use-property-inheritance
11491 @defun org-entry-get pom property &optional inherit
11492 Get value of PROPERTY for entry at point-or-marker POM.  By default,
11493 this only looks at properties defined locally in the entry.  If INHERIT
11494 is non-nil and the entry does not have the property, then also check
11495 higher levels of the hierarchy.  If INHERIT is the symbol
11496 @code{selective}, use inheritance if and only if the setting of
11497 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
11498 @end defun
11500 @defun org-entry-delete pom property
11501 Delete the property PROPERTY from entry at point-or-marker POM.
11502 @end defun
11504 @defun org-entry-put pom property value
11505 Set PROPERTY to VALUE for entry at point-or-marker POM.
11506 @end defun
11508 @defun org-buffer-property-keys &optional include-specials
11509 Get all property keys in the current buffer.
11510 @end defun
11512 @defun org-insert-property-drawer
11513 Insert a property drawer at point.
11514 @end defun
11516 @defun org-entry-put-multivalued-property pom property &rest values
11517 Set PROPERTY at point-or-marker POM to VALUES.  VALUES should be a list of
11518 strings.  They will be concatenated, with spaces as separators.
11519 @end defun
11521 @defun org-entry-get-multivalued-property pom property
11522 Treat the value of the property PROPERTY as a whitespace-separated list of
11523 values and return the values as a list of strings.
11524 @end defun
11526 @defun org-entry-add-to-multivalued-property pom property value
11527 Treat the value of the property PROPERTY as a whitespace-separated list of
11528 values and make sure that VALUE is in this list.
11529 @end defun
11531 @defun org-entry-remove-from-multivalued-property pom property value
11532 Treat the value of the property PROPERTY as a whitespace-separated list of
11533 values and make sure that VALUE is @emph{not} in this list.
11534 @end defun
11536 @defun org-entry-member-in-multivalued-property pom property value
11537 Treat the value of the property PROPERTY as a whitespace-separated list of
11538 values and check if VALUE is in this list.
11539 @end defun
11541 @node Using the mapping API,  , Using the property API, Hacking
11542 @section Using the mapping API
11543 @cindex API, for mapping
11544 @cindex mapping entries, API
11546 Org has sophisticated mapping capabilities to find all entries satisfying
11547 certain criteria.  Internally, this functionality is used to produce agenda
11548 views, but there is also an API that can be used to execute arbitrary
11549 functions for each or selected entries.  The main entry point for this API
11552 @defun org-map-entries func &optional match scope &rest skip
11553 Call FUNC at each headline selected by MATCH in SCOPE.
11555 FUNC is a function or a Lisp form.  The function will be called without
11556 arguments, with the cursor positioned at the beginning of the headline.
11557 The return values of all calls to the function will be collected and
11558 returned as a list.
11560 The call to FUNC will be wrapped into a save-excursion form, so FUNC
11561 does not need to preserve point.  After evaluation, the cursor will be
11562 moved to the end of the line (presumably of the headline of the
11563 processed entry) and search continues from there.  Under some
11564 circumstances, this may not produce the wanted results.  For example,
11565 if you have removed (@eg archived) the current (sub)tree it could
11566 mean that the next entry will be skipped entirely.  In such cases, you
11567 can specify the position from where search should continue by making
11568 FUNC set the variable `org-map-continue-from' to the desired buffer
11569 position.
11571 MATCH is a tags/property/todo match as it is used in the agenda match view.
11572 Only headlines that are matched by this query will be considered during
11573 the iteration.  When MATCH is nil or t, all headlines will be
11574 visited by the iteration.
11576 SCOPE determines the scope of this command.  It can be any of:
11578 @example
11579 nil     @r{the current buffer, respecting the restriction if any}
11580 tree    @r{the subtree started with the entry at point}
11581 file    @r{the current buffer, without restriction}
11582 file-with-archives
11583         @r{the current buffer, and any archives associated with it}
11584 agenda  @r{all agenda files}
11585 agenda-with-archives
11586         @r{all agenda files with any archive files associated with them}
11587 (file1 file2 ...)
11588         @r{if this is a list, all files in the list will be scanned}
11589 @end example
11590 @noindent
11591 The remaining args are treated as settings for the skipping facilities of
11592 the scanner.  The following items can be given here:
11594 @vindex org-agenda-skip-function
11595 @example
11596 archive   @r{skip trees with the archive tag}
11597 comment   @r{skip trees with the COMMENT keyword}
11598 function or Lisp form
11599           @r{will be used as value for @code{org-agenda-skip-function},}
11600           @r{so whenever the function returns t, FUNC}
11601           @r{will not be called for that entry and search will}
11602           @r{continue from the point where the function leaves it}
11603 @end example
11604 @end defun
11606 The function given to that mapping routine can really do anything you like.
11607 It can use the property API (@pxref{Using the property API}) to gather more
11608 information about the entry, or in order to change metadata in the entry.
11609 Here are a couple of functions that might be handy:
11611 @defun org-todo &optional arg
11612 Change the TODO state of the entry, see the docstring of the functions for
11613 the many possible values for the argument ARG.
11614 @end defun
11616 @defun org-priority &optional action
11617 Change the priority of the entry, see the docstring of this function for the
11618 possible values for ACTION.
11619 @end defun
11621 @defun org-toggle-tag tag &optional onoff
11622 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
11623 or @code{off} will not toggle tag, but ensure that it is either on or off.
11624 @end defun
11626 @defun org-promote
11627 Promote the current entry.
11628 @end defun
11630 @defun org-demote
11631 Demote the current entry.
11632 @end defun
11634 Here is a simple example that will turn all entries in the current file with
11635 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
11636 Entries in comment trees and in archive trees will be ignored.
11638 @lisp
11639 (org-map-entries
11640    '(org-todo "UPCOMING")
11641    "+TOMORROW" 'file 'archive 'comment)
11642 @end lisp
11644 The following example counts the number of entries with TODO keyword
11645 @code{WAITING}, in all agenda files.
11647 @lisp
11648 (length (org-map-entries t "/+WAITING" 'agenda))
11649 @end lisp
11651 @node History and Acknowledgments, Main Index, Hacking, Top
11652 @appendix History and Acknowledgments
11653 @cindex acknowledgments
11654 @cindex history
11655 @cindex thanks
11657 Org was born in 2003, out of frustration over the user interface
11658 of the Emacs Outline mode.  I was trying to organize my notes and
11659 projects, and using Emacs seemed to be the natural way to go.  However,
11660 having to remember eleven different commands with two or three keys per
11661 command, only to hide and show parts of the outline tree, that seemed
11662 entirely unacceptable to me.  Also, when using outlines to take notes, I
11663 constantly wanted to restructure the tree, organizing it parallel to my
11664 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
11665 editing} were originally implemented in the package
11666 @file{outline-magic.el}, but quickly moved to the more general
11667 @file{org.el}.  As this environment became comfortable for project
11668 planning, the next step was adding @emph{TODO entries}, basic
11669 @emph{timestamps}, and @emph{table support}.  These areas highlighted the two main
11670 goals that Org still has today: to be a new, outline-based,
11671 plain text mode with innovative and intuitive editing features, and to
11672 incorporate project planning functionality directly into a notes file.
11674 A special thanks goes to @i{Bastien Guerry} who has not only written a large
11675 number of extensions to Org (most of them integrated into the core by now),
11676 but who has also helped in the development and maintenance of Org so much that he
11677 should be considered the main co-contributor to this package.
11679 Since the first release, literally thousands of emails to me or to
11680 @email{emacs-orgmode@@gnu.org} have provided a constant stream of bug
11681 reports, feedback, new ideas, and sometimes patches and add-on code.
11682 Many thanks to everyone who has helped to improve this package.  I am
11683 trying to keep here a list of the people who had significant influence
11684 in shaping one or more aspects of Org.  The list may not be
11685 complete, if I have forgotten someone, please accept my apologies and
11686 let me know.
11688 @itemize @bullet
11690 @item
11691 @i{Russel Adams} came up with the idea for drawers.
11692 @item
11693 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
11694 @item
11695 @i{Christophe Bataillon} created the great unicorn logo that we use on the
11696 Org-mode website.
11697 @item
11698 @i{Alex Bochannek} provided a patch for rounding timestamps.
11699 @item
11700 @i{Brad Bozarth} showed how to pull RSS feed data into Org-mode files.
11701 @item
11702 @i{Tom Breton} wrote @file{org-choose.el}.
11703 @item
11704 @i{Charles Cave}'s suggestion sparked the implementation of templates
11705 for Remember.
11706 @item
11707 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
11708 specified time.
11709 @item
11710 @i{Gregory Chernov} patched support for Lisp forms into table
11711 calculations and improved XEmacs compatibility, in particular by porting
11712 @file{nouline.el} to XEmacs.
11713 @item
11714 @i{Sacha Chua} suggested copying some linking code from Planner.
11715 @item
11716 @i{Baoqiu Cui} contributed the DocBook exporter.
11717 @item
11718 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
11719 came up with the idea of properties, and that there should be an API for
11720 them.
11721 @item
11722 @i{Nick Dokos} tracked down several nasty bugs.
11723 @item
11724 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
11725 inspired some of the early development, including HTML export.  He also
11726 asked for a way to narrow wide table columns.
11727 @item
11728 @i{Christian Egli} converted the documentation into Texinfo format,
11729 patched CSS formatting into the HTML exporter, and inspired the agenda.
11730 @item
11731 @i{David Emery} provided a patch for custom CSS support in exported
11732 HTML agendas.
11733 @item
11734 @i{Nic Ferrier} contributed mailcap and XOXO support.
11735 @item
11736 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
11737 @item
11738 @i{John Foerch} figured out how to make incremental search show context
11739 around a match in a hidden outline tree.
11740 @item
11741 @i{Niels Giesen} had the idea to automatically archive DONE trees.
11742 @item
11743 @i{Bastien Guerry} wrote the La@TeX{} exporter and @file{org-bibtex.el}, and
11744 has been prolific with patches, ideas, and bug reports.
11745 @item
11746 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
11747 @item
11748 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
11749 task state change logging, and the clocktable.  His clear explanations have
11750 been critical when we started to adopt the Git version control system.
11751 @item
11752 @i{Manuel Hermenegildo} has contributed various ideas, small fixes and
11753 patches.
11754 @item
11755 @i{Phil Jackson} wrote @file{org-irc.el}.
11756 @item
11757 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
11758 folded entries, and column view for properties.
11759 @item
11760 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
11761 @item
11762 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
11763 provided frequent feedback and some patches.
11764 @item
11765 @i{Matt Lundin} has proposed last-row references for table formulas and named
11766 invisible anchors.  He has also worked a lot on the FAQ.
11767 @item
11768 @i{Jason F. McBrayer} suggested agenda export to CSV format.
11769 @item
11770 @i{Max Mikhanosha} came up with the idea of refiling.
11771 @item
11772 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
11773 basis.
11774 @item
11775 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
11776 happy.
11777 @item
11778 @i{Rick Moynihan} proposed allowing multiple TODO sequences in a file
11779 and being able to quickly restrict the agenda to a subtree.
11780 @item
11781 @i{Todd Neal} provided patches for links to Info files and Elisp forms.
11782 @item
11783 @i{Greg Newman} refreshed the unicorn logo into its current form.
11784 @item
11785 @i{Tim O'Callaghan} suggested in-file links, search options for general
11786 file links, and TAGS.
11787 @item
11788 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
11789 into Japanese.
11790 @item
11791 @i{Oliver Oppitz} suggested multi-state TODO items.
11792 @item
11793 @i{Scott Otterson} sparked the introduction of descriptive text for
11794 links, among other things.
11795 @item
11796 @i{Pete Phillips} helped during the development of the TAGS feature, and
11797 provided frequent feedback.
11798 @item
11799 @i{Martin Pohlack} provided the code snippet to bundle character insertion
11800 into bundles of 20 for undo.
11801 @item
11802 @i{T.V. Raman} reported bugs and suggested improvements.
11803 @item
11804 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
11805 control.
11806 @item
11807 @i{Paul Rivier} provided the basic implementation of named footnotes.
11808 @item
11809 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
11810 @item
11811 @i{Sebastian Rose} wrote @file{org-info.js}, a Java script for displaying
11812 webpages derived from Org using an Info-like or a folding interface with
11813 single-key navigation.
11814 @item
11815 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
11816 conflict with @file{allout.el}.
11817 @item
11818 @i{Jason Riedy} generalized the send-receive mechanism for Orgtbl tables with
11819 extensive patches.
11820 @item
11821 @i{Philip Rooke} created the Org reference card, provided lots
11822 of feedback, developed and applied standards to the Org documentation.
11823 @item
11824 @i{Christian Schlauer} proposed angular brackets around links, among
11825 other things.
11826 @item
11827 @i{Eric Schulte} wrote @file{org-plot.el} and contributed various patches,
11828 small features and modules.
11829 @item
11830 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
11831 @file{organizer-mode.el}.
11832 @item
11833 @i{Ilya Shlyakhter} proposed the Archive Sibling, line numbering in literal
11834 examples, and remote highlighting for referenced code lines.
11835 @item
11836 @i{Stathis Sideris} wrote the @file{ditaa.jar} ASCII to PNG converter that is
11837 now packaged into Org's @file{contrib} directory.
11838 @item
11839 @i{Daniel Sinder} came up with the idea of internal archiving by locking
11840 subtrees.
11841 @item
11842 @i{Dale Smith} proposed link abbreviations.
11843 @item
11844 @i{James TD Smith} has contributed a large number of patches for useful
11845 tweaks and features.
11846 @item
11847 @i{Adam Spiers} asked for global linking commands, inspired the link
11848 extension system, added support for mairix, and proposed the mapping API.
11849 @item
11850 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
11851 with links transformation to Org syntax.
11852 @item
11853 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
11854 chapter about publishing.
11855 @item
11856 @i{J@"urgen Vollmer} contributed code generating the table of contents
11857 in HTML output.
11858 @item
11859 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
11860 keyword.
11861 @item
11862 @i{David Wainberg} suggested archiving, and improvements to the linking
11863 system.
11864 @item
11865 @i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
11866 @file{muse.el}, which have some overlap with Org.  Initially the development
11867 of Org was fully independent because I was not aware of the existence of
11868 these packages.  But with time I have occasionally looked at John's code and
11869 learned a lot from it.  John has also contributed a number of great ideas and
11870 patches directly to Org, including the attachment system
11871 (@file{org-attach.el}), integration with Apple Mail
11872 (@file{org-mac-message.el}), and hierarchical dependencies of TODO items.
11873 @item
11874 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
11875 linking to Gnus.
11876 @item
11877 @i{Roland Winkler} requested additional key bindings to make Org
11878 work on a tty.
11879 @item
11880 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
11881 and contributed various ideas and code snippets.
11882 @end itemize
11885 @node Main Index, Key Index, History and Acknowledgments, Top
11886 @unnumbered Concept Index
11888 @printindex cp
11890 @node Key Index, Variable Index, Main Index, Top
11891 @unnumbered Key Index
11893 @printindex ky
11895 @node Variable Index,  , Key Index, Top
11896 @unnumbered Variable Index
11898 This is not a complete index of variables and faces, only the ones that are
11899 mentioned in the manual.  For a more complete list, use @kbd{M-x
11900 org-customize @key{RET}} and then klick yourself through the tree.
11902 @printindex vr
11904 @bye
11906 @ignore
11907         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
11908 @end ignore
11910 @c Local variables:
11911 @c ispell-local-dictionary: "en_US-w_accents"
11912 @c ispell-local-pdict: "./.aspell.org.pws"
11913 @c fill-column: 77
11914 @c End: