Fix some bugs in MobileOrg support
[org-mode.git] / doc / org.texi
blob9edd9b8ba0eaba734aaddbc444f02bca973a5f7c
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 * MobileOrg::                   Viewing and capture on a mobile device
113 * History and Acknowledgments::  How Org came into being
114 * Main Index::                  An index of Org's concepts and features
115 * Key Index::                   Key bindings and where they are described
116 * Variable Index::              Variables mentioned in the manual
118 @detailmenu
119  --- The Detailed Node Listing ---
121 Introduction
123 * Summary::                     Brief summary of what Org does
124 * Installation::                How to install a downloaded version of Org
125 * Activation::                  How to activate Org for certain buffers
126 * Feedback::                    Bug reports, ideas, patches etc.
127 * Conventions::                 Type-setting conventions in the manual
129 Document Structure
131 * Outlines::                    Org is based on Outline mode
132 * Headlines::                   How to typeset Org tree headlines
133 * Visibility cycling::          Show and hide, much simplified
134 * Motion::                      Jumping to other headlines
135 * Structure editing::           Changing sequence and level of headlines
136 * Archiving::                   Move done task trees to a different place
137 * Sparse trees::                Matches embedded in context
138 * Plain lists::                 Additional structure within an entry
139 * Drawers::                     Tucking stuff away
140 * Blocks::                      Folding blocks
141 * Footnotes::                   How footnotes are defined in Org's syntax
142 * Orgstruct mode::              Structure editing outside Org
144 Archiving
146 * ARCHIVE tag::                 Marking a tree as inactive
147 * Moving subtrees::             Moving a tree to an archive file
149 Tables
151 * Built-in table editor::       Simple tables
152 * Column width and alignment::  Overrule the automatic settings
153 * Column groups::               Grouping to trigger vertical lines
154 * Orgtbl mode::                 The table editor as minor mode
155 * The spreadsheet::             The table editor has spreadsheet capabilities
156 * Org-Plot::                    Plotting from org tables
158 The spreadsheet
160 * References::                  How to refer to another field or range
161 * Formula syntax for Calc::     Using Calc to compute stuff
162 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
163 * Field formulas::              Formulas valid for a single field
164 * Column formulas::             Formulas valid for an entire column
165 * Editing and debugging formulas::  Fixing formulas
166 * Updating the table::          Recomputing all dependent fields
167 * Advanced features::           Field names, parameters and automatic recalc
169 Hyperlinks
171 * Link format::                 How links in Org are formatted
172 * Internal links::              Links to other places in the current file
173 * External links::              URL-like links to the world
174 * Handling links::              Creating, inserting and following
175 * Using links outside Org::     Linking from my C source code?
176 * Link abbreviations::          Shortcuts for writing complex links
177 * Search options::              Linking to a specific location
178 * Custom searches::             When the default search is not enough
180 Internal links
182 * Radio targets::               Make targets trigger links in plain text
184 TODO Items
186 * TODO basics::                 Marking and displaying TODO entries
187 * TODO extensions::             Workflow and assignments
188 * Progress logging::            Dates and notes for progress
189 * Priorities::                  Some things are more important than others
190 * Breaking down tasks::         Splitting a task into manageable pieces
191 * Checkboxes::                  Tick-off lists
193 Extended use of TODO keywords
195 * Workflow states::             From TODO to DONE in steps
196 * TODO types::                  I do this, Fred does the rest
197 * Multiple sets in one file::   Mixing it all, and still finding your way
198 * Fast access to TODO states::  Single letter selection of a state
199 * Per-file keywords::           Different files, different requirements
200 * Faces for TODO keywords::     Highlighting states
201 * TODO dependencies::           When one task needs to wait for others
203 Progress logging
205 * Closing items::               When was this entry marked DONE?
206 * Tracking TODO state changes::  When did the status change?
208 Tags
210 * Tag inheritance::             Tags use the tree structure of the outline
211 * Setting tags::                How to assign tags to a headline
212 * Tag searches::                Searching for combinations of tags
214 Properties and Columns
216 * Property syntax::             How properties are spelled out
217 * Special properties::          Access to other Org mode features
218 * Property searches::           Matching property values
219 * Property inheritance::        Passing values down the tree
220 * Column view::                 Tabular viewing and editing
221 * Property API::                Properties for Lisp programmers
223 Column view
225 * Defining columns::            The COLUMNS format property
226 * Using column view::           How to create and use column view
227 * Capturing column view::       A dynamic block for column view
229 Defining columns
231 * Scope of column definitions::  Where defined, where valid?
232 * Column attributes::           Appearance and content of a column
234 Dates and Times
236 * Timestamps::                  Assigning a time to a tree entry
237 * Creating timestamps::         Commands which insert timestamps
238 * Deadlines and scheduling::    Planning your work
239 * Clocking work time::          Tracking how long you spend on a task
240 * Effort estimates::            Planning work effort in advance
241 * Relative timer::              Notes with a running timer
243 Creating timestamps
245 * The date/time prompt::        How Org mode helps you entering date and time
246 * Custom time format::          Making dates look different
248 Deadlines and scheduling
250 * Inserting deadline/schedule::  Planning items
251 * Repeated tasks::              Items that show up again and again
253 Capture
255 * Remember::                    Capture new tasks/ideas with little interruption
256 * Attachments::                 Add files to tasks.
257 * RSS Feeds::                   Getting input from RSS feeds
258 * Protocols::                   External (@eg Browser) access to Emacs and Org
260 Remember
262 * Setting up Remember for Org::  Some code for .emacs to get things going
263 * Remember templates::          Define the outline of different note types
264 * Storing notes::               Directly get the note to where it belongs
265 * Refiling notes::              Moving a note or task to a project
267 Agenda Views
269 * Agenda files::                Files being searched for agenda information
270 * Agenda dispatcher::           Keyboard access to agenda views
271 * Built-in agenda views::       What is available out of the box?
272 * Presentation and sorting::    How agenda items are prepared for display
273 * Agenda commands::             Remote editing of Org trees
274 * Custom agenda views::         Defining special searches and views
275 * Exporting Agenda Views::      Writing a view to a file
276 * Agenda column view::          Using column view for collected entries
278 The built-in agenda views
280 * Weekly/daily agenda::         The calendar page with current tasks
281 * Global TODO list::            All unfinished action items
282 * Matching tags and properties::  Structured information with fine-tuned search
283 * Timeline::                    Time-sorted view for single file
284 * Keyword search::              Finding entries by keyword
285 * Stuck projects::              Find projects you need to review
287 Presentation and sorting
289 * Categories::                  Not all tasks are equal
290 * Time-of-day specifications::  How the agenda knows the time
291 * Sorting of agenda items::     The order of things
293 Custom agenda views
295 * Storing searches::            Type once, use often
296 * Block agenda::                All the stuff you need in a single buffer
297 * Setting Options::             Changing the rules
299 Embedded La@TeX{}
301 * Math symbols::                @TeX{} macros for symbols and Greek letters
302 * Subscripts and superscripts::  Simple syntax for raising/lowering text
303 * LaTeX fragments::             Complex formulas made easy
304 * Processing LaTeX fragments::  Previewing La@TeX{} processing
305 * CDLaTeX mode::                Speed up entering of formulas
307 Exporting
309 * Markup rules::                Which structures are recognized?
310 * Selective export::            Using tags to select and exclude trees
311 * Export options::              Per-file export settings
312 * The export dispatcher::       How to access exporter commands
313 * ASCII export::                Exporting to plain ASCII
314 * HTML export::                 Exporting to HTML
315 * LaTeX and PDF export::        Exporting to La@TeX{}, and processing to PDF
316 * DocBook export::              Exporting to DocBook
317 * XOXO export::                 Exporting to XOXO
318 * iCalendar export::            Exporting in iCalendar format
320 Markup rules
322 * Document title::              How the document title is determined
323 * Headings and sections::       The main structure of the exported document
324 * Table of contents::           If, where, how to create a table of contents
325 * Initial text::                Text before the first headline
326 * Lists::                       Plain lists are exported
327 * Paragraphs::                  What determines beginning and ending
328 * Literal examples::            Source code and other examples
329 * Include files::               Include the contents of a file during export
330 * Tables exported::             Tables are exported richly
331 * Inlined images::              How to inline images during export
332 * Footnote markup::             ASCII representation of footnotes
333 * Emphasis and monospace::      To bold or not to bold
334 * TeX macros and LaTeX fragments::  Create special, rich export.
335 * Horizontal rules::            A line across the page
336 * Comment lines::               Some lines will not be exported
337 * Macro replacement::           Global replacement of place holders
339 HTML export
341 * HTML Export commands::        How to invoke HTML export
342 * Quoting HTML tags::           Using direct HTML in Org mode
343 * Links::                       Transformation of links for HTML
344 * Tables in HTML export::       How to modify the formatting of tables
345 * Images in HTML export::       How to insert figures into HTML output
346 * Text areas in HTML export::   An alternative way to show an example
347 * CSS support::                 Changing the appearance of the output
348 * Javascript support::          Info and Folding in a web browser
350 La@TeX{} and PDF export
352 * LaTeX/PDF export commands::   Which key invokes which commands
353 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
354 * Sectioning structure::        Changing sectioning in La@TeX{} output
355 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
356 * Images in LaTeX export::      How to insert figures into La@TeX{} output
358 DocBook export
360 * DocBook export commands::     How to invoke DocBook export
361 * Quoting DocBook code::        Incorporating DocBook code in Org files
362 * Recursive sections::          Recursive sections in DocBook
363 * Tables in DocBook export::    Tables are exported as HTML tables
364 * Images in DocBook export::    How to insert figures into DocBook output
365 * Special characters::          How to handle special characters
367 Publishing
369 * Configuration::               Defining projects
370 * Uploading files::             How to get files up on the server
371 * Sample configuration::        Example projects
372 * Triggering publication::      Publication commands
374 Configuration
376 * Project alist::               The central configuration variable
377 * Sources and destinations::    From here to there
378 * Selecting files::             What files are part of the project?
379 * Publishing action::           Setting the function doing the publishing
380 * Publishing options::          Tweaking HTML export
381 * Publishing links::            Which links keep working after publishing?
382 * Project page index::          Publishing a list of project files
384 Sample configuration
386 * Simple example::              One-component publishing
387 * Complex example::             A multi-component publishing example
389 Miscellaneous
391 * Completion::                  M-TAB knows what you need
392 * Customization::               Adapting Org to your taste
393 * In-buffer settings::          Overview of the #+KEYWORDS
394 * The very busy C-c C-c key::   When in doubt, press C-c C-c
395 * Clean view::                  Getting rid of leading stars in the outline
396 * TTY keys::                    Using Org on a tty
397 * Interaction::                 Other Emacs packages
399 Interaction with other packages
401 * Cooperation::                 Packages Org cooperates with
402 * Conflicts::                   Packages that lead to conflicts
404 Hacking
406 * Hooks::                       Who to reach into Org's internals
407 * Add-on packages::             Available extensions
408 * Adding hyperlink types::      New custom link types
409 * Context-sensitive commands::  How to add functionality to such commands
410 * Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
411 * Dynamic blocks::              Automatically filled blocks
412 * Special agenda views::        Customized views
413 * Extracting agenda information::  Postprocessing of agenda information
414 * Using the property API::      Writing programs that use entry properties
415 * Using the mapping API::       Mapping over all or selected entries
417 Tables and lists in arbitrary syntax
419 * Radio tables::                Sending and receiving radio tables
420 * A LaTeX example::             Step by step, almost a tutorial
421 * Translator functions::        Copy and modify
422 * Radio lists::                 Doing the same for lists
424 MobileOrg
426 * Setting up the staging area::  Where to interact with the mobile device
427 * Pushing to MobileOrg::        Uploading Org files and agendas
428 * Pulling from MobileOrg::      Integrating captured and flagged items
430 @end detailmenu
431 @end menu
433 @node Introduction, Document Structure, Top, Top
434 @chapter Introduction
435 @cindex introduction
437 @menu
438 * Summary::                     Brief summary of what Org does
439 * Installation::                How to install a downloaded version of Org
440 * Activation::                  How to activate Org for certain buffers
441 * Feedback::                    Bug reports, ideas, patches etc.
442 * Conventions::                 Type-setting conventions in the manual
443 @end menu
445 @node Summary, Installation, Introduction, Introduction
446 @section Summary
447 @cindex summary
449 Org is a mode for keeping notes, maintaining TODO lists, and doing
450 project planning with a fast and effective plain-text system.
452 Org develops organizational tasks around NOTES files that contain
453 lists or information about projects as plain text.  Org is
454 implemented on top of Outline mode, which makes it possible to keep the
455 content of large files well structured.  Visibility cycling and
456 structure editing help to work with the tree.  Tables are easily created
457 with a built-in table editor.  Org supports TODO items, deadlines,
458 timestamps, and scheduling.  It dynamically compiles entries into an
459 agenda that utilizes and smoothly integrates much of the Emacs calendar
460 and diary.  Plain text URL-like links connect to websites, emails,
461 Usenet messages, BBDB entries, and any files related to the projects.
462 For printing and sharing of notes, an Org file can be exported as a
463 structured ASCII file, as HTML, or (TODO and agenda items only) as an
464 iCalendar file.  It can also serve as a publishing tool for a set of
465 linked web pages.
467 An important design aspect that distinguishes Org from, for example,
468 Planner/Muse is that it encourages you to store every piece of information
469 only once.  In Planner, you have project pages, day pages and possibly
470 other files, duplicating some information such as tasks.  In Org,
471 you only have notes files.  In your notes you mark entries as tasks, and
472 label them with tags and timestamps.  All necessary lists, like a
473 schedule for the day, the agenda for a meeting, tasks lists selected by
474 tags, etc., are created dynamically when you need them.
476 Org keeps simple things simple.  When first fired up, it should
477 feel like a straightforward, easy to use outliner.  Complexity is not
478 imposed, but a large amount of functionality is available when you need
479 it.  Org is a toolbox and can be used in different ways, for
480 example as:
482 @example
483 @r{@bullet{} an outline extension with visibility cycling and structure editing}
484 @r{@bullet{} an ASCII system and table editor for taking structured notes}
485 @r{@bullet{} an ASCII table editor with spreadsheet-like capabilities}
486 @r{@bullet{} a TODO list editor}
487 @r{@bullet{} a full agenda and planner with deadlines and work scheduling}
488 @pindex GTD, Getting Things Done
489 @r{@bullet{} an environment to implement David Allen's GTD system}
490 @r{@bullet{} a basic database application}
491 @r{@bullet{} a simple hypertext system, with HTML and La@TeX{} export}
492 @r{@bullet{} a publishing tool to create a set of interlinked webpages}
493 @end example
495 Org's automatic, context-sensitive table editor with spreadsheet
496 capabilities can be integrated into any major mode by activating the
497 minor Orgtbl mode.  Using a translation step, it can be used to maintain
498 tables in arbitrary file types, for example in La@TeX{}.  The structure
499 editing and list creation capabilities can be used outside Org with
500 the minor Orgstruct mode.
502 @cindex FAQ
503 There is a website for Org which provides links to the newest
504 version of Org, as well as additional information, frequently asked
505 questions (FAQ), links to tutorials, etc@.  This page is located at
506 @uref{http://orgmode.org}.
508 @page
511 @node Installation, Activation, Summary, Introduction
512 @section Installation
513 @cindex installation
514 @cindex XEmacs
516 @b{Important:} @i{If you are using a version of Org that is part of the Emacs
517 distribution or an XEmacs package, please skip this section and go directly
518 to @ref{Activation}.}
520 If you have downloaded Org from the Web, either as a distribution @file{.zip}
521 or @file{.tar} file, or as a Git archive, you must take the following steps
522 to install it: go into the unpacked Org distribution directory and edit the
523 top section of the file @file{Makefile}.  You must set the name of the Emacs
524 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
525 directories where local Lisp and Info files are kept.  If you don't have
526 access to the system-wide directories, you can simply run Org directly from
527 the distribution directory by adding the @file{lisp} subdirectory to the
528 Emacs load path.  To do this, add the following line to @file{.emacs}:
530 @example
531 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
532 @end example
534 @noindent
535 If you plan to use code from the @file{contrib} subdirectory, do a similar
536 step for this directory:
538 @example
539 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
540 @end example
542 @sp 2
543 @cartouche
544 XEmacs users now need to install the file @file{noutline.el} from
545 the @file{xemacs} sub-directory of the Org distribution.  Use the
546 command:
548 @example
549      make install-noutline
550 @end example
551 @end cartouche
552 @sp 2
554 @noindent Now byte-compile the Lisp files with the shell command:
556 @example
557 make
558 @end example
560 @noindent If you are running Org from the distribution directory, this is
561 all.  If you want to install Org into the system directories, use (as
562 administrator)
564 @example
565 make install
566 @end example
568 Installing Info files is system dependent, because of differences in the
569 @file{install-info} program.  In Debian it copies the info files into the
570 correct directory and modifies the info directory file.  In many other
571 systems, the files need to be copied to the correct directory separately, and
572 @file{install-info} then only modifies the directory file.  Check your system
573 documentation to find out which of the following commands you need:
575 @example
576 make install-info
577 make install-info-debian
578 @end example
580 Then add the following line to @file{.emacs}.  It is needed so that
581 Emacs can autoload functions that are located in files not immediately loaded
582 when Org-mode starts.
583 @lisp
584 (require 'org-install)
585 @end lisp
587 Do not forget to activate Org as described in the following section.
588 @page
590 @node Activation, Feedback, Installation, Introduction
591 @section Activation
592 @cindex activation
593 @cindex autoload
594 @cindex global key bindings
595 @cindex key bindings, global
597 @iftex
598 @b{Important:} @i{If you use copy-and-paste to copy Lisp code from the
599 PDF documentation as viewed by some PDF viewers to your @file{.emacs} file, the
600 single-quote character comes out incorrectly and the code will not work.
601 You need to fix the single-quotes by hand, or copy from Info
602 documentation.}
603 @end iftex
605 Add the following lines to your @file{.emacs} file.  The last three lines
606 define @emph{global} keys for the commands @command{org-store-link},
607 @command{org-agenda}, and @command{org-iswitchb}---please choose suitable
608 keys yourself.
610 @lisp
611 ;; The following lines are always needed.  Choose your own keys.
612 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
613 (global-set-key "\C-cl" 'org-store-link)
614 (global-set-key "\C-ca" 'org-agenda)
615 (global-set-key "\C-cb" 'org-iswitchb)
616 @end lisp
618 Furthermore, you must activate @code{font-lock-mode} in Org
619 buffers, because significant functionality depends on font-locking being
620 active.  You can do this with either one of the following two lines
621 (XEmacs users must use the second option):
622 @lisp
623 (global-font-lock-mode 1)                     ; for all buffers
624 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
625 @end lisp
627 @cindex Org mode, turning on
628 With this setup, all files with extension @samp{.org} will be put
629 into Org mode.  As an alternative, make the first line of a file look
630 like this:
632 @example
633 MY PROJECTS    -*- mode: org; -*-
634 @end example
636 @vindex org-insert-mode-line-in-empty-file
637 @noindent which will select Org mode for this buffer no matter what
638 the file's name is.  See also the variable
639 @code{org-insert-mode-line-in-empty-file}.
641 Many commands in Org work on the region if the region is @i{active}.  To make
642 use of this, you need to have @code{transient-mark-mode}
643 (@code{zmacs-regions} in XEmacs) turned on.  In Emacs 23 this is the default,
644 in Emacs 22 you need to do this yourself with
645 @lisp
646 (transient-mark-mode 1)
647 @end lisp
648 @noindent If you do not like @code{transient-mark-mode}, you can create an
649 active region by using the mouse to select a region, or pressing
650 @kbd{C-@key{SPC}} twice before moving the cursor.
652 @node Feedback, Conventions, Activation, Introduction
653 @section Feedback
654 @cindex feedback
655 @cindex bug reports
656 @cindex maintainer
657 @cindex author
659 If you find problems with Org, or if you have questions, remarks, or ideas
660 about it, please mail to the Org mailing list @email{emacs-orgmode@@gnu.org}.
661 If you are not a member of the mailing list, your mail will be passed to the
662 list after a moderator has approved it.
664 For bug reports, please provide as much information as possible, including
665 the version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
666 (@kbd{M-x org-version @key{RET}}), as well as the Org related setup in
667 @file{.emacs}.  The easiest way to do this is to use the command
668 @example
669 @kbd{M-x org-submit-bug-report}
670 @end example
671 @noindent which will put all this information into an Emacs mail buffer so
672 that you only need to add your description.  If you re not sending the Email
673 from within Emacs, please copy and paste the content into your Email program.
675 If an error occurs, a backtrace can be very useful (see below on how to
676 create one).  Often a small example file helps, along with clear information
677 about:
679 @enumerate
680 @item What exactly did you do?
681 @item What did you expect to happen?
682 @item What happened instead?
683 @end enumerate
684 @noindent Thank you for helping to improve this mode.
686 @subsubheading How to create a useful backtrace
688 @cindex backtrace of an error
689 If working with Org produces an error with a message you don't
690 understand, you may have hit a bug.  The best way to report this is by
691 providing, in addition to what was mentioned above, a @emph{backtrace}.
692 This is information from the built-in debugger about where and how the
693 error occurred.  Here is how to produce a useful backtrace:
695 @enumerate
696 @item
697 Reload uncompiled versions of all Org-mode Lisp files.  The backtrace
698 contains much more information if it is produced with uncompiled code.
699 To do this, use
700 @example
701 C-u M-x org-reload RET
702 @end example
703 @noindent
704 or select @code{Org -> Refresh/Reload -> Reload Org uncompiled} from the
705 menu.
706 @item
707 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
708 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
709 @item
710 Do whatever you have to do to hit the error.  Don't forget to
711 document the steps you take.
712 @item
713 When you hit the error, a @file{*Backtrace*} buffer will appear on the
714 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
715 attach it to your bug report.
716 @end enumerate
718 @node Conventions,  , Feedback, Introduction
719 @section Typesetting conventions used in this manual
721 Org uses three types of keywords: TODO keywords, tags, and property
722 names.  In this manual we use the following conventions:
724 @table @code
725 @item TODO
726 @itemx WAITING
727 TODO keywords are written with all capitals, even if they are
728 user-defined.
729 @item boss
730 @itemx ARCHIVE
731 User-defined tags are written in lowercase; built-in tags with special
732 meaning are written with all capitals.
733 @item Release
734 @itemx PRIORITY
735 User-defined properties are capitalized; built-in properties with
736 special meaning are written with all capitals.
737 @end table
739 @node Document Structure, Tables, Introduction, Top
740 @chapter Document Structure
741 @cindex document structure
742 @cindex structure of document
744 Org is based on Outline mode and provides flexible commands to
745 edit the structure of the document.
747 @menu
748 * Outlines::                    Org is based on Outline mode
749 * Headlines::                   How to typeset Org tree headlines
750 * Visibility cycling::          Show and hide, much simplified
751 * Motion::                      Jumping to other headlines
752 * Structure editing::           Changing sequence and level of headlines
753 * Archiving::                   Move done task trees to a different place
754 * Sparse trees::                Matches embedded in context
755 * Plain lists::                 Additional structure within an entry
756 * Drawers::                     Tucking stuff away
757 * Blocks::                      Folding blocks
758 * Footnotes::                   How footnotes are defined in Org's syntax
759 * Orgstruct mode::              Structure editing outside Org
760 @end menu
762 @node Outlines, Headlines, Document Structure, Document Structure
763 @section Outlines
764 @cindex outlines
765 @cindex Outline mode
767 Org is implemented on top of Outline mode.  Outlines allow a
768 document to be organized in a hierarchical structure, which (at least
769 for me) is the best representation of notes and thoughts.  An overview
770 of this structure is achieved by folding (hiding) large parts of the
771 document to show only the general document structure and the parts
772 currently being worked on.  Org greatly simplifies the use of
773 outlines by compressing the entire show/hide functionality into a single
774 command, @command{org-cycle}, which is bound to the @key{TAB} key.
776 @node Headlines, Visibility cycling, Outlines, Document Structure
777 @section Headlines
778 @cindex headlines
779 @cindex outline tree
780 @vindex org-special-ctrl-a/e
782 Headlines define the structure of an outline tree.  The headlines in
783 Org start with one or more stars, on the left margin@footnote{See
784 the variable @code{org-special-ctrl-a/e} to configure special behavior
785 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
787 @example
788 * Top level headline
789 ** Second level
790 *** 3rd level
791     some text
792 *** 3rd level
793     more text
795 * Another top level headline
796 @end example
798 @noindent Some people find the many stars too noisy and would prefer an
799 outline that has whitespace followed by a single star as headline
800 starters.  @ref{Clean view}, describes a setup to realize this.
802 @vindex org-cycle-separator-lines
803 An empty line after the end of a subtree is considered part of it and
804 will be hidden when the subtree is folded.  However, if you leave at
805 least two empty lines, one empty line will remain visible after folding
806 the subtree, in order to structure the collapsed view.  See the
807 variable @code{org-cycle-separator-lines} to modify this behavior.
809 @node Visibility cycling, Motion, Headlines, Document Structure
810 @section Visibility cycling
811 @cindex cycling, visibility
812 @cindex visibility cycling
813 @cindex trees, visibility
814 @cindex show hidden text
815 @cindex hide text
817 Outlines make it possible to hide parts of the text in the buffer.
818 Org uses just two commands, bound to @key{TAB} and
819 @kbd{S-@key{TAB}} to change the visibility in the buffer.
821 @cindex subtree visibility states
822 @cindex subtree cycling
823 @cindex folded, subtree visibility state
824 @cindex children, subtree visibility state
825 @cindex subtree, subtree visibility state
826 @table @kbd
827 @kindex @key{TAB}
828 @item @key{TAB}
829 @emph{Subtree cycling}: Rotate current subtree among the states
831 @example
832 ,-> FOLDED -> CHILDREN -> SUBTREE --.
833 '-----------------------------------'
834 @end example
836 @vindex org-cycle-emulate-tab
837 @vindex org-cycle-global-at-bob
838 The cursor must be on a headline for this to work@footnote{see, however,
839 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
840 beginning of the buffer and the first line is not a headline, then
841 @key{TAB} actually runs global cycling (see below)@footnote{see the
842 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
843 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
845 @cindex global visibility states
846 @cindex global cycling
847 @cindex overview, global visibility state
848 @cindex contents, global visibility state
849 @cindex show all, global visibility state
850 @kindex S-@key{TAB}
851 @item S-@key{TAB}
852 @itemx C-u @key{TAB}
853 @emph{Global cycling}: Rotate the entire buffer among the states
855 @example
856 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
857 '--------------------------------------'
858 @end example
860 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
861 CONTENTS view up to headlines of level N will be shown.  Note that inside
862 tables, @kbd{S-@key{TAB}} jumps to the previous field.
864 @cindex show all, command
865 @kindex C-u C-u C-u @key{TAB}
866 @item C-u C-u C-u @key{TAB}
867 Show all, including drawers.
868 @kindex C-c C-r
869 @item C-c C-r
870 Reveal context around point, showing the current entry, the following heading
871 and the hierarchy above.  Useful for working near a location that has been
872 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
873 (@pxref{Agenda commands}).  With a prefix argument show, on each
874 level, all sibling headings.
875 @kindex C-c C-x b
876 @item C-c C-x b
877 Show the current subtree in an indirect buffer@footnote{The indirect
878 buffer
879 @ifinfo
880 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
881 @end ifinfo
882 @ifnotinfo
883 (see the Emacs manual for more information about indirect buffers)
884 @end ifnotinfo
885 will contain the entire buffer, but will be narrowed to the current
886 tree.  Editing the indirect buffer will also change the original buffer,
887 but without affecting visibility in that buffer.}.  With a numeric
888 prefix argument N, go up to level N and then take that tree.  If N is
889 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
890 the previously used indirect buffer.
891 @end table
893 @vindex org-startup-folded
894 @cindex @code{overview}, STARTUP keyword
895 @cindex @code{content}, STARTUP keyword
896 @cindex @code{showall}, STARTUP keyword
898 When Emacs first visits an Org file, the global state is set to
899 OVERVIEW, @ie only the top level headlines are visible.  This can be
900 configured through the variable @code{org-startup-folded}, or on a
901 per-file basis by adding one of the following lines anywhere in the
902 buffer:
904 @example
905 #+STARTUP: overview
906 #+STARTUP: content
907 #+STARTUP: showall
908 @end example
910 @cindex property, VISIBILITY
911 @noindent
912 Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
913 and Columns}) will get their visibility adapted accordingly.  Allowed values
914 for this property are @code{folded}, @code{children}, @code{content}, and
915 @code{all}.
916 @table @kbd
917 @kindex C-u C-u @key{TAB}
918 @item C-u C-u @key{TAB}
919 Switch back to the startup visibility of the buffer, @ie whatever is
920 requested by startup options and @samp{VISIBILITY} properties in individual
921 entries.
922 @end table
924 @node Motion, Structure editing, Visibility cycling, Document Structure
925 @section Motion
926 @cindex motion, between headlines
927 @cindex jumping, to headlines
928 @cindex headline navigation
929 The following commands jump to other headlines in the buffer.
931 @table @kbd
932 @kindex C-c C-n
933 @item C-c C-n
934 Next heading.
935 @kindex C-c C-p
936 @item C-c C-p
937 Previous heading.
938 @kindex C-c C-f
939 @item C-c C-f
940 Next heading same level.
941 @kindex C-c C-b
942 @item C-c C-b
943 Previous heading same level.
944 @kindex C-c C-u
945 @item C-c C-u
946 Backward to higher level heading.
947 @kindex C-c C-j
948 @item C-c C-j
949 Jump to a different place without changing the current outline
950 visibility.  Shows the document structure in a temporary buffer, where
951 you can use the following keys to find your destination:
952 @vindex org-goto-auto-isearch
953 @example
954 @key{TAB}         @r{Cycle visibility.}
955 @key{down} / @key{up}   @r{Next/previous visible headline.}
956 @key{RET}         @r{Select this location.}
957 @kbd{/}           @r{Do a Sparse-tree search}
958 @r{The following keys work if you turn off @code{org-goto-auto-isearch}}
959 n / p        @r{Next/previous visible headline.}
960 f / b        @r{Next/previous headline same level.}
961 u            @r{One level up.}
962 0-9          @r{Digit argument.}
963 q            @r{Quit}
964 @end example
965 @vindex org-goto-interface
966 @noindent
967 See also the variable @code{org-goto-interface}.
968 @end table
970 @node Structure editing, Archiving, Motion, Document Structure
971 @section Structure editing
972 @cindex structure editing
973 @cindex headline, promotion and demotion
974 @cindex promotion, of subtrees
975 @cindex demotion, of subtrees
976 @cindex subtree, cut and paste
977 @cindex pasting, of subtrees
978 @cindex cutting, of subtrees
979 @cindex copying, of subtrees
980 @cindex sorting, of subtrees
981 @cindex subtrees, cut and paste
983 @table @kbd
984 @kindex M-@key{RET}
985 @item M-@key{RET}
986 @vindex org-M-RET-may-split-line
987 Insert new heading with same level as current.  If the cursor is in a
988 plain list item, a new item is created (@pxref{Plain lists}).  To force
989 creation of a new headline, use a prefix argument, or first press @key{RET}
990 to get to the beginning of the next line.  When this command is used in
991 the middle of a line, the line is split and the rest of the line becomes
992 the new headline@footnote{If you do not want the line to be split,
993 customize the variable @code{org-M-RET-may-split-line}.}.  If the
994 command is used at the beginning of a headline, the new headline is
995 created before the current line.  If at the beginning of any other line,
996 the content of that line is made the new heading.  If the command is
997 used at the end of a folded subtree (@ie behind the ellipses at the end
998 of a headline), then a headline like the current one will be inserted
999 after the end of the subtree.
1000 @kindex C-@key{RET}
1001 @item C-@key{RET}
1002 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
1003 current heading, the new heading is placed after the body instead of before
1004 it.  This command works from anywhere in the entry.
1005 @kindex M-S-@key{RET}
1006 @item M-S-@key{RET}
1007 @vindex org-treat-insert-todo-heading-as-state-change
1008 Insert new TODO entry with same level as current heading.  See also the
1009 variable @code{org-treat-insert-todo-heading-as-state-change}.
1010 @kindex C-S-@key{RET}
1011 @item C-S-@key{RET}
1012 Insert new TODO entry with same level as current heading.  Like
1013 @kbd{C-@key{RET}}, the new headline will be inserted after the current
1014 subtree.
1015 @kindex M-@key{left}
1016 @item M-@key{left}
1017 Promote current heading by one level.
1018 @kindex M-@key{right}
1019 @item M-@key{right}
1020 Demote current heading by one level.
1021 @kindex M-S-@key{left}
1022 @item M-S-@key{left}
1023 Promote the current subtree by one level.
1024 @kindex M-S-@key{right}
1025 @item M-S-@key{right}
1026 Demote the current subtree by one level.
1027 @kindex M-S-@key{up}
1028 @item M-S-@key{up}
1029 Move subtree up (swap with previous subtree of same
1030 level).
1031 @kindex M-S-@key{down}
1032 @item M-S-@key{down}
1033 Move subtree down (swap with next subtree of same level).
1034 @kindex C-c C-x C-w
1035 @item C-c C-x C-w
1036 Kill subtree, @ie remove it from buffer but save in kill ring.
1037 With a numeric prefix argument N, kill N sequential subtrees.
1038 @kindex C-c C-x M-w
1039 @item C-c C-x M-w
1040 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
1041 sequential subtrees.
1042 @kindex C-c C-x C-y
1043 @item C-c C-x C-y
1044 Yank subtree from kill ring.  This does modify the level of the subtree to
1045 make sure the tree fits in nicely at the yank position.  The yank level can
1046 also be specified with a numeric prefix argument, or by yanking after a
1047 headline marker like @samp{****}.
1048 @kindex C-y
1049 @item C-y
1050 @vindex org-yank-adjusted-subtrees
1051 @vindex org-yank-folded-subtrees
1052 Depending on the variables @code{org-yank-adjusted-subtrees} and
1053 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
1054 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
1055 C-x C-y}.  With the default settings, no level adjustment will take place,
1056 but the yanked tree will be folded unless doing so would swallow text
1057 previously visible.  Any prefix argument to this command will force a normal
1058 @code{yank} to be executed, with the prefix passed along.  A good way to
1059 force a normal yank is @kbd{C-u C-y}.  If you use @code{yank-pop} after a
1060 yank, it will yank previous kill items plainly, without adjustment and
1061 folding.
1062 @kindex C-c C-x c
1063 @item C-c C-x c
1064 Clone a subtree by making a number of sibling copies of it.  You will be
1065 prompted for the number of copies to make, and you can also specify if any
1066 timestamps in the entry should be shifted.  This can be useful, for example,
1067 to create a number of tasks related to a series of lectures to prepare.  For
1068 more details, see the docstring of the command
1069 @code{org-clone-subtree-with-time-shift}.
1070 @kindex C-c C-w
1071 @item C-c C-w
1072 Refile entry or region to a different location.  @xref{Refiling notes}.
1073 @kindex C-c ^
1074 @item C-c ^
1075 Sort same-level entries.  When there is an active region, all entries in the
1076 region will be sorted.  Otherwise the children of the current headline are
1077 sorted.  The command prompts for the sorting method, which can be
1078 alphabetically, numerically, by time (first timestamp with active preferred,
1079 creation time, scheduled time, deadline time), by priority, by TODO keyword
1080 (in the sequence the keywords have been defined in the setup) or by the value
1081 of a property.  Reverse sorting is possible as well.  You can also supply
1082 your own function to extract the sorting key.  With a @kbd{C-u} prefix,
1083 sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes, duplicate
1084 entries will also be removed.
1085 @kindex C-x n s
1086 @item C-x n s
1087 Narrow buffer to current subtree.
1088 @kindex C-x n w
1089 @item C-x n w
1090 Widen buffer to remove narrowing.
1091 @kindex C-c *
1092 @item C-c *
1093 Turn a normal line or plain list item into a headline (so that it becomes a
1094 subheading at its location).  Also turn a headline into a normal line by
1095 removing the stars.  If there is an active region, turn all lines in the
1096 region into headlines.  If the first line in the region was an item, turn
1097 only the item lines into headlines.  Finally, if the first line is a
1098 headline, remove the stars from all headlines in the region.
1099 @end table
1101 @cindex region, active
1102 @cindex active region
1103 @cindex transient mark mode
1104 When there is an active region (Transient Mark mode), promotion and
1105 demotion work on all headlines in the region.  To select a region of
1106 headlines, it is best to place both point and mark at the beginning of a
1107 line, mark at the beginning of the first headline, and point at the line
1108 just after the last headline to change.  Note that when the cursor is
1109 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
1110 functionality.
1112 @node Archiving, Sparse trees, Structure editing, Document Structure
1113 @section Archiving
1114 @cindex archiving
1116 When a project represented by a (sub)tree is finished, you may want
1117 to move the tree out of the way and to stop it from contributing to the
1118 agenda.  Org mode knows two ways of archiving.  You can mark a tree with
1119 the ARCHIVE tag, or you can move an entire (sub)tree to a different
1120 location.
1122 @menu
1123 * ARCHIVE tag::                 Marking a tree as inactive
1124 * Moving subtrees::             Moving a tree to an archive file
1125 @end menu
1127 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
1128 @subsection The ARCHIVE tag
1129 @cindex internal archiving
1131 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
1132 its location in the outline tree, but behaves in the following way:
1133 @itemize @minus
1134 @item
1135 @vindex org-cycle-open-archived-trees
1136 It does not open when you attempt to do so with a visibility cycling
1137 command (@pxref{Visibility cycling}).  You can force cycling archived
1138 subtrees with @kbd{C-@key{TAB}}, or by setting the option
1139 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
1140 @code{show-all} will open archived subtrees.
1141 @item
1142 @vindex org-sparse-tree-open-archived-trees
1143 During sparse tree construction (@pxref{Sparse trees}), matches in
1144 archived subtrees are not exposed, unless you configure the option
1145 @code{org-sparse-tree-open-archived-trees}.
1146 @item
1147 @vindex org-agenda-skip-archived-trees
1148 During agenda view construction (@pxref{Agenda Views}), the content of
1149 archived trees is ignored unless you configure the option
1150 @code{org-agenda-skip-archived-trees}, in which case these trees will always
1151 be included.  In the agenda you can press the @kbd{v} key to get archives
1152 temporarily included.
1153 @item
1154 @vindex org-export-with-archived-trees
1155 Archived trees are not exported (@pxref{Exporting}), only the headline
1156 is.  Configure the details using the variable
1157 @code{org-export-with-archived-trees}.
1158 @item
1159 @vindex org-columns-skip-arrchived-trees
1160 Archived trees are excluded from column view unless the variable
1161 @code{org-columns-skip-arrchived-trees} is configured to @code{nil}.
1162 @end itemize
1164 The following commands help managing the ARCHIVE tag:
1166 @table @kbd
1167 @kindex C-c C-x a
1168 @item C-c C-x a
1169 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
1170 the headline changes to a shadowed face, and the subtree below it is
1171 hidden.
1172 @kindex C-u C-c C-x a
1173 @item C-u C-c C-x a
1174 Check if any direct children of the current headline should be archived.
1175 To do this, each subtree is checked for open TODO entries.  If none are
1176 found, the command offers to set the ARCHIVE tag for the child.  If the
1177 cursor is @emph{not} on a headline when this command is invoked, the
1178 level 1 trees will be checked.
1179 @kindex C-@kbd{TAB}
1180 @item C-@kbd{TAB}
1181 Cycle a tree even if it is tagged with ARCHIVE.
1182 @end table
1184 @node Moving subtrees,  , ARCHIVE tag, Archiving
1185 @subsection Moving subtrees
1186 @cindex external archiving
1188 Once an entire project is finished, you may want to move it to a different
1189 location.  Org can move it to an @emph{Archive Sibling} in the same tree, to a
1190 different tree in the current file, or to a different file, the archive file.
1192 @table @kbd
1193 @kindex C-c C-x A
1194 @item C-c C-x A
1195 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
1196 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}
1197 (@pxref{ARCHIVE tag}).  The entry becomes a child of that sibling and in this
1198 way retains a lot of its original context, including inherited tags and
1199 approximate position in the outline.
1200 @kindex C-c $
1201 @kindex C-c C-x C-s
1202 @itemx C-c $
1203 @item C-c C-x C-s
1204 @vindex org-archive-location
1205 Archive the subtree starting at the cursor position to the location
1206 given by @code{org-archive-location}.  Context information that could be
1207 lost, like the file name, the category, inherited tags, and the TODO
1208 state will be stored as properties in the entry.
1209 @kindex C-u C-c C-x C-s
1210 @item C-u C-c C-x C-s
1211 Check if any direct children of the current headline could be moved to
1212 the archive.  To do this, each subtree is checked for open TODO entries.
1213 If none are found, the command offers to move it to the archive
1214 location.  If the cursor is @emph{not} on a headline when this command
1215 is invoked, the level 1 trees will be checked.
1216 @end table
1218 @cindex archive locations
1219 The default archive location is a file in the same directory as the
1220 current file, with the name derived by appending @file{_archive} to the
1221 current file name.  For information and examples on how to change this,
1222 see the documentation string of the variable
1223 @code{org-archive-location}.  There is also an in-buffer option for
1224 setting this variable, for example@footnote{For backward compatibility,
1225 the following also works: If there are several such lines in a file,
1226 each specifies the archive location for the text below it.  The first
1227 such line also applies to any text before its definition.  However,
1228 using this method is @emph{strongly} deprecated as it is incompatible
1229 with the outline structure of the document.  The correct method for
1230 setting multiple archive locations in a buffer is using properties.}:
1232 @cindex #+ARCHIVE
1233 @example
1234 #+ARCHIVE: %s_done::
1235 @end example
1237 @cindex property, ARCHIVE
1238 @noindent
1239 If you would like to have a special ARCHIVE location for a single entry
1240 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1241 location as the value (@pxref{Properties and Columns}).
1243 @vindex org-archive-save-context-info
1244 When a subtree is moved, it receives a number of special properties that
1245 record context information like the file from where the entry came, its
1246 outline path the archiving time etc.  Configure the variable
1247 @code{org-archive-save-context-info} to adjust the amount of information
1248 added.
1250 @node Sparse trees, Plain lists, Archiving, Document Structure
1251 @section Sparse trees
1252 @cindex sparse trees
1253 @cindex trees, sparse
1254 @cindex folding, sparse trees
1255 @cindex occur, command
1257 @vindex org-show-hierarchy-above
1258 @vindex org-show-following-heading
1259 @vindex org-show-siblings
1260 @vindex org-show-entry-below
1261 An important feature of Org mode is the ability to construct @emph{sparse
1262 trees} for selected information in an outline tree, so that the entire
1263 document is folded as much as possible, but the selected information is made
1264 visible along with the headline structure above it@footnote{See also the
1265 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1266 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1267 control on how much context is shown around each match.}.  Just try it out
1268 and you will see immediately how it works.
1270 Org mode contains several commands creating such trees, all these
1271 commands can be accessed through a dispatcher:
1273 @table @kbd
1274 @kindex C-c /
1275 @item C-c /
1276 This prompts for an extra key to select a sparse-tree creating command.
1277 @kindex C-c / r
1278 @item C-c / r
1279 @vindex org-remove-highlights-with-change
1280 Occur.  Prompts for a regexp and shows a sparse tree with all matches.  If
1281 the match is in a headline, the headline is made visible.  If the match is in
1282 the body of an entry, headline and body are made visible.  In order to
1283 provide minimal context, also the full hierarchy of headlines above the match
1284 is shown, as well as the headline following the match.  Each match is also
1285 highlighted; the highlights disappear when the buffer is changed by an
1286 editing command@footnote{This depends on the option
1287 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1288 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1289 so several calls to this command can be stacked.
1290 @end table
1292 @noindent
1293 @vindex org-agenda-custom-commands
1294 For frequently used sparse trees of specific search strings, you can
1295 use the variable @code{org-agenda-custom-commands} to define fast
1296 keyboard access to specific sparse trees.  These commands will then be
1297 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1298 For example:
1300 @lisp
1301 (setq org-agenda-custom-commands
1302       '(("f" occur-tree "FIXME")))
1303 @end lisp
1305 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1306 a sparse tree matching the string @samp{FIXME}.
1308 The other sparse tree commands select headings based on TODO keywords,
1309 tags, or properties and will be discussed later in this manual.
1311 @kindex C-c C-e v
1312 @cindex printing sparse trees
1313 @cindex visible text, printing
1314 To print a sparse tree, you can use the Emacs command
1315 @code{ps-print-buffer-with-faces} which does not print invisible parts
1316 of the document @footnote{This does not work under XEmacs, because
1317 XEmacs uses selective display for outlining, not text properties.}.
1318 Or you can use the command @kbd{C-c C-e v} to export only the visible
1319 part of the document and print the resulting file.
1321 @node Plain lists, Drawers, Sparse trees, Document Structure
1322 @section Plain lists
1323 @cindex plain lists
1324 @cindex lists, plain
1325 @cindex lists, ordered
1326 @cindex ordered lists
1328 Within an entry of the outline tree, hand-formatted lists can provide
1329 additional structure.  They also provide a way to create lists of
1330 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1331 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1333 Org knows ordered lists, unordered lists, and description lists.
1334 @itemize @bullet
1335 @item
1336 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1337 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1338 they will be seen as top-level headlines.  Also, when you are hiding leading
1339 stars to get a clean outline view, plain list items starting with a star are
1340 visually indistinguishable from true headlines.  In short: even though
1341 @samp{*} is supported, it may be better to not use it for plain list items.}
1342 as bullets.
1343 @item
1344 @emph{Ordered} list items start with a numeral followed by either a period or
1345 a right parenthesis, such as @samp{1.} or @samp{1)}.
1346 @item
1347 @emph{Description} list items are like unordered list items, but contain the
1348 separator @samp{ :: } to separate the description @emph{term} from the
1349 description.
1350 @end itemize
1352 @vindex org-empty-line-terminates-plain-lists
1353 Items belonging to the same list must have the same indentation on the first
1354 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1355 2--digit numbers must be written left-aligned with the other numbers in the
1356 list.  Indentation also determines the end of a list item.  It ends before
1357 the next line that is indented like the bullet/number, or less.  Empty lines
1358 are part of the previous item, so you can have several paragraphs in one
1359 item.  If you would like an empty line to terminate all currently open plain
1360 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1361 Here is an example:
1363 @example
1364 @group
1365 ** Lord of the Rings
1366    My favorite scenes are (in this order)
1367    1. The attack of the Rohirrim
1368    2. Eowyn's fight with the witch king
1369       + this was already my favorite scene in the book
1370       + I really like Miranda Otto.
1371    3. Peter Jackson being shot by Legolas
1372        - on DVD only
1373       He makes a really funny face when it happens.
1374    But in the end, no individual scenes matter but the film as a whole.
1375    Important actors in this film are:
1376    - @b{Elijah Wood} :: He plays Frodo
1377    - @b{Sean Austin} :: He plays Sam, Frodo's friend.  I still remember
1378      him very well from his role as Mikey Walsh in @i{The Goonies}.
1379 @end group
1380 @end example
1382 Org supports these lists by tuning filling and wrapping commands to deal with
1383 them correctly@footnote{Org only changes the filling settings for Emacs.  For
1384 XEmacs, you should use Kyle E. Jones' @file{filladapt.el}.  To turn this on,
1385 put into @file{.emacs}: @code{(require 'filladapt)}}, and by exporting them
1386 properly (@pxref{Exporting}).  Since indentation is what governs the
1387 structure of these lists, many structural constructs like @code{#+BEGIN_...}
1388 blocks can be indented to signal that they should be part of a list item.
1390 The following commands act on items when the cursor is in the first line
1391 of an item (the line with the bullet or number).
1393 @table @kbd
1394 @kindex @key{TAB}
1395 @item @key{TAB}
1396 @vindex org-cycle-include-plain-lists
1397 Items can be folded just like headline levels.  Normally this works only if
1398 the cursor is on a plain list item.  For more details, see the variable
1399 @code{org-cycle-include-plain-lists}. to @code{integrate}, plain list items
1400 will be treated like low-level.  The level of an item is then given by the
1401 indentation of the bullet/number.  Items are always subordinate to real
1402 headlines, however; the hierarchies remain completely separated.
1404 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1405 fixes the indentation of the current line in a heuristic way.
1406 @kindex M-@key{RET}
1407 @item M-@key{RET}
1408 @vindex org-M-RET-may-split-line
1409 Insert new item at current level.  With a prefix argument, force a new
1410 heading (@pxref{Structure editing}).  If this command is used in the middle
1411 of a line, the line is @emph{split} and the rest of the line becomes the new
1412 item@footnote{If you do not want the line to be split, customize the variable
1413 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1414 @emph{whitespace before a bullet or number}, the new item is created
1415 @emph{before} the current item.  If the command is executed in the white
1416 space before the text that is part of an item but does not contain the
1417 bullet, a bullet is added to the current line.
1418 @kindex M-S-@key{RET}
1419 @item M-S-@key{RET}
1420 Insert a new item with a checkbox (@pxref{Checkboxes}).
1421 @kindex S-@key{up}
1422 @kindex S-@key{down}
1423 @item S-@key{up}
1424 @itemx S-@key{down}
1425 @cindex shift-selection-mode
1426 @vindex org-support-shift-select
1427 Jump to the previous/next item in the current list, but only if
1428 @code{org-support-shift-select} is off.  If not, you can still use paragraph
1429 jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
1430 similar effect.
1431 @kindex M-S-@key{up}
1432 @kindex M-S-@key{down}
1433 @item M-S-@key{up}
1434 @itemx M-S-@key{down}
1435 Move the item including subitems up/down (swap with previous/next item
1436 of same indentation).  If the list is ordered, renumbering is
1437 automatic.
1438 @kindex M-S-@key{left}
1439 @kindex M-S-@key{right}
1440 @item M-S-@key{left}
1441 @itemx M-S-@key{right}
1442 Decrease/increase the indentation of the item, including subitems.
1443 Initially, the item tree is selected based on current indentation.
1444 When these commands are executed several times in direct succession,
1445 the initially selected region is used, even if the new indentation
1446 would imply a different hierarchy.  To use the new hierarchy, break
1447 the command chain with a cursor motion or so.
1448 @kindex C-c C-c
1449 @item C-c C-c
1450 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1451 state of the checkbox.  If not, this command makes sure that all the
1452 items on this list level use the same bullet.  Furthermore, if this is
1453 an ordered list, make sure the numbering is OK.
1454 @kindex C-c -
1455 @item C-c -
1456 Cycle the entire list level through the different itemize/enumerate bullets
1457 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1458 argument N, select the Nth bullet from this list.  If there is an active
1459 region when calling this, all lines will be converted to list items.  If the
1460 first line already was a list item, any item markers will be removed from the
1461 list.  Finally, even without an active region, a normal line will be
1462 converted into a list item.
1463 @kindex C-c *
1464 @item C-c *
1465 Turn a plain list item into a headline (so that it becomes a subheading at
1466 its location). @xref{Structure editing}, for a detailed explanation.
1467 @kindex S-@key{left}
1468 @kindex S-@key{right}
1469 @item S-@key{left}/@key{right}
1470 @vindex org-support-shift-select
1471 This command also cycles bullet styles when the cursor in on the bullet or
1472 anywhere in an item line, details depending on
1473 @code{org-support-shift-select}.
1474 @kindex C-c ^
1475 @item C-c ^
1476 Sort the plain list.  You will be prompted for the sorting method:
1477 numerically, alphabetically, by time, or by custom function.
1478 @end table
1480 @node Drawers, Blocks, Plain lists, Document Structure
1481 @section Drawers
1482 @cindex drawers
1483 @cindex #+DRAWERS
1484 @cindex visibility cycling, drawers
1486 @vindex org-drawers
1487 Sometimes you want to keep information associated with an entry, but you
1488 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1489 Drawers need to be configured with the variable
1490 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1491 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1492 look like this:
1494 @example
1495 ** This is a headline
1496    Still outside the drawer
1497    :DRAWERNAME:
1498       This is inside the drawer.
1499    :END:
1500    After the drawer.
1501 @end example
1503 Visibility cycling (@pxref{Visibility cycling}) on the headline will hide and
1504 show the entry, but keep the drawer collapsed to a single line.  In order to
1505 look inside the drawer, you need to move the cursor to the drawer line and
1506 press @key{TAB} there.  Org mode uses the @code{PROPERTIES} drawer for
1507 storing properties (@pxref{Properties and Columns}), and you can also arrange
1508 for state change notes (@pxref{Tracking TODO state changes}) and clock times
1509 (@pxref{Clocking work time}) to be stored in a drawer @code{LOGBOOK}.
1511 @node Blocks, Footnotes, Drawers, Document Structure
1512 @section Blocks
1514 @vindex org-hide-block-startup
1515 @cindex blocks, folding
1516 Org-mode uses begin...end blocks for various purposes from including source
1517 code examples (@pxref{Literal examples}) to capturing time logging
1518 information (@pxref{Clocking work time}).  These blocks can be folded and
1519 unfolded by pressing TAB in the begin line.  You can also get all blocks
1520 folded at startup by configuring the variable @code{org-hide-block-startup}
1521 or on a per-file basis by using
1523 @cindex @code{hideblocks}, STARTUP keyword
1524 @cindex @code{nohideblocks}, STARTUP keyword
1525 @example
1526 #+STARTUP: hideblocks
1527 #+STARTUP: nohideblocks
1528 @end example
1530 @node Footnotes, Orgstruct mode, Blocks, Document Structure
1531 @section Footnotes
1532 @cindex footnotes
1534 Org mode supports the creation of footnotes.  In contrast to the
1535 @file{footnote.el} package, Org mode's footnotes are designed for work on a
1536 larger document, not only for one-off documents like emails.  The basic
1537 syntax is similar to the one used by @file{footnote.el}, @ie a footnote is
1538 defined in a paragraph that is started by a footnote marker in square
1539 brackets in column 0, no indentation allowed.  If you need a paragraph break
1540 inside a footnote, use the La@TeX{} idiom @samp{\par}.  The footnote reference
1541 is simply the marker in square brackets, inside text.  For example:
1543 @example
1544 The Org homepage[fn:1] now looks a lot better than it used to.
1546 [fn:1] The link is: http://orgmode.org
1547 @end example
1549 Org mode extends the number-based syntax to @emph{named} footnotes and
1550 optional inline definition.  Using plain numbers as markers (as
1551 @file{footnote.el} does) is supported for backward compatibility, but not
1552 encouraged because of possible conflicts with La@TeX{} snippets (@pxref{Embedded
1553 LaTeX}).  Here are the valid references:
1555 @table @code
1556 @item [1]
1557 A plain numeric footnote marker.  Compatible with @file{footnote.el}, but not
1558 recommended because somthing like @samp{[1]} could easily be part of a code
1559 snippet.
1560 @item [fn:name]
1561 A named footnote reference, where @code{name} is a unique label word, or, for
1562 simplicity of automatic creation, a number.
1563 @item [fn:: This is the inline definition of this footnote]
1564 A La@TeX{}-like anonymous footnote where the definition is given directly at the
1565 reference point.
1566 @item [fn:name: a definition]
1567 An inline definition of a footnote, which also specifies a name for the note.
1568 Since Org allows multiple references to the same note, you can then use
1569 @code{[fn:name]} to create additional references.
1570 @end table
1572 @vindex org-footnote-auto-label
1573 Footnote labels can be created automatically, or you can create names yourself.
1574 This is handled by the variable @code{org-footnote-auto-label} and its
1575 corresponding @code{#+STARTUP} keywords, see the docstring of that variable
1576 for details.
1578 @noindent The following command handles footnotes:
1580 @table @kbd
1581 @kindex C-c C-x f
1582 @item C-c C-x f
1583 The footnote action command.
1585 When the cursor is on a footnote reference, jump to the definition.  When it
1586 is at a definition, jump to the (first) reference.
1588 @vindex org-footnote-define-inline
1589 @vindex org-footnote-section
1590 @vindex org-footnote-auto-adjust
1591 Otherwise, create a new footnote.  Depending on the variable
1592 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
1593 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
1594 definition will be placed right into the text as part of the reference, or
1595 separately into the location determined by the variable
1596 @code{org-footnote-section}.
1598 When this command is called with a prefix argument, a menu of additional
1599 options is offered:
1600 @example
1601 s   @r{Sort the footnote definitions by reference sequence.  During editing,}
1602     @r{Org makes no effort to sort footnote definitions into a particular}
1603     @r{sequence.  If you want them sorted, use this command, which will}
1604     @r{also move entries according to @code{org-footnote-section}.  Automatic}
1605     @r{sorting after each insertion/deletion can be configured using the}
1606     @r{variable @code{org-footnote-auto-adjust}.}
1607 r   @r{Renumber the simple @code{fn:N} footnotes.  Automatic renumbering}
1608     @r{after each insertion/deletion can be configured using the variable}
1609     @r{@code{org-footnote-auto-adjust}.}
1610 S   @r{Short for first @code{r}, then @code{s} action.}
1611 n   @r{Normalize the footnotes by collecting all definitions (including}
1612     @r{inline definitions) into a special section, and then numbering them}
1613     @r{in sequence.  The references will then also be numbers.  This is}
1614     @r{meant to be the final step before finishing a document (e.g. sending}
1615     @r{off an email).  The exporters do this automatically, and so could}
1616     @r{something like @code{message-send-hook}.}
1617 d   @r{Delete the footnote at point, and all definitions of and references}
1618     @r{to it.}
1619 @end example
1620 Depending on the variable @code{org-footnote-auto-adjust}@footnote{the
1621 corresponding in-buffer options are @code{fnadjust} and @code{nofnadjust}.},
1622 renumbering and sorting footnotes can be automatic after each insertion or
1623 deletion.
1625 @kindex C-c C-c
1626 @item C-c C-c
1627 If the cursor is on a footnote reference, jump to the definition.  If it is a
1628 the definition, jump back to the reference.  When called at a footnote
1629 location with a prefix argument, offer the same menu as @kbd{C-c C-x f}.
1630 @kindex C-c C-o
1631 @kindex mouse-1
1632 @kindex mouse-2
1633 @item C-c C-o  @r{or} mouse-1/2
1634 Footnote labels are also links to the corresponding definition/reference, and
1635 you can use the usual commands to follow these links.
1636 @end table
1638 @node Orgstruct mode,  , Footnotes, Document Structure
1639 @section The Orgstruct minor mode
1640 @cindex Orgstruct mode
1641 @cindex minor mode for structure editing
1643 If you like the intuitive way the Org mode structure editing and list
1644 formatting works, you might want to use these commands in other modes like
1645 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
1646 this possible.   Toggle the mode with @kbd{M-x orgstruct-mode}, or
1647 turn it on by default, for example in Mail mode, with one of:
1649 @lisp
1650 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1651 (add-hook 'mail-mode-hook 'turn-on-orgstruct++)
1652 @end lisp
1654 When this mode is active and the cursor is on a line that looks to Org like a
1655 headline or the first line of a list item, most structure editing commands
1656 will work, even if the same keys normally have different functionality in the
1657 major mode you are using.  If the cursor is not in one of those special
1658 lines, Orgstruct mode lurks silently in the shadow.  When you use
1659 @code{orgstruct++-mode}, Org will also export indentation and autofill
1660 settings into that mode, and detect item context after the first line of an
1661 item.
1663 @node Tables, Hyperlinks, Document Structure, Top
1664 @chapter Tables
1665 @cindex tables
1666 @cindex editing tables
1668 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1669 calculations are supported in connection with the Emacs @file{calc}
1670 package
1671 @ifinfo
1672 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1673 @end ifinfo
1674 @ifnotinfo
1675 (see the Emacs Calculator manual for more information about the Emacs
1676 calculator).
1677 @end ifnotinfo
1679 @menu
1680 * Built-in table editor::       Simple tables
1681 * Column width and alignment::  Overrule the automatic settings
1682 * Column groups::               Grouping to trigger vertical lines
1683 * Orgtbl mode::                 The table editor as minor mode
1684 * The spreadsheet::             The table editor has spreadsheet capabilities
1685 * Org-Plot::                    Plotting from org tables
1686 @end menu
1688 @node Built-in table editor, Column width and alignment, Tables, Tables
1689 @section The built-in table editor
1690 @cindex table editor, built-in
1692 Org makes it easy to format tables in plain ASCII.  Any line with
1693 @samp{|} as the first non-whitespace character is considered part of a
1694 table.  @samp{|} is also the column separator.  A table might look like
1695 this:
1697 @example
1698 | Name  | Phone | Age |
1699 |-------+-------+-----|
1700 | Peter |  1234 |  17 |
1701 | Anna  |  4321 |  25 |
1702 @end example
1704 A table is re-aligned automatically each time you press @key{TAB} or
1705 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1706 the next field (@key{RET} to the next row) and creates new table rows
1707 at the end of the table or before horizontal lines.  The indentation
1708 of the table is set by the first line.  Any line starting with
1709 @samp{|-} is considered as a horizontal separator line and will be
1710 expanded on the next re-align to span the whole table width.  So, to
1711 create the above table, you would only type
1713 @example
1714 |Name|Phone|Age|
1716 @end example
1718 @noindent and then press @key{TAB} to align the table and start filling in
1719 fields.  Even faster would be to type @code{|Name|Phone|Age} followed by
1720 @kbd{C-c @key{RET}}.
1722 @vindex org-enable-table-editor
1723 @vindex org-table-auto-blank-field
1724 When typing text into a field, Org treats @key{DEL},
1725 @key{Backspace}, and all character keys in a special way, so that
1726 inserting and deleting avoids shifting other fields.  Also, when
1727 typing @emph{immediately after the cursor was moved into a new field
1728 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1729 field is automatically made blank.  If this behavior is too
1730 unpredictable for you, configure the variables
1731 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1733 @table @kbd
1734 @tsubheading{Creation and conversion}
1735 @kindex C-c |
1736 @item C-c |
1737 Convert the active region to table. If every line contains at least one
1738 TAB character, the function assumes that the material is tab separated.
1739 If every line contains a comma, comma-separated values (CSV) are assumed.
1740 If not, lines are split at whitespace into fields.  You can use a prefix
1741 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1742 C-u} forces TAB, and a numeric argument N indicates that at least N
1743 consecutive spaces, or alternatively a TAB will be the separator.
1745 If there is no active region, this command creates an empty Org
1746 table.  But it's easier just to start typing, like
1747 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1749 @tsubheading{Re-aligning and field motion}
1750 @kindex C-c C-c
1751 @item C-c C-c
1752 Re-align the table without moving the cursor.
1754 @kindex @key{TAB}
1755 @item @key{TAB}
1756 Re-align the table, move to the next field.  Creates a new row if
1757 necessary.
1759 @kindex S-@key{TAB}
1760 @item S-@key{TAB}
1761 Re-align, move to previous field.
1763 @kindex @key{RET}
1764 @item @key{RET}
1765 Re-align the table and move down to next row.  Creates a new row if
1766 necessary.  At the beginning or end of a line, @key{RET} still does
1767 NEWLINE, so it can be used to split a table.
1769 @kindex M-a
1770 @item M-a
1771 Move to beginning of the current table field, or on to the previous field.
1772 @kindex M-e
1773 @item M-e
1774 Move to end of the current table field, or on to the next field.
1776 @tsubheading{Column and row editing}
1777 @kindex M-@key{left}
1778 @kindex M-@key{right}
1779 @item M-@key{left}
1780 @itemx M-@key{right}
1781 Move the current column left/right.
1783 @kindex M-S-@key{left}
1784 @item M-S-@key{left}
1785 Kill the current column.
1787 @kindex M-S-@key{right}
1788 @item M-S-@key{right}
1789 Insert a new column to the left of the cursor position.
1791 @kindex M-@key{up}
1792 @kindex M-@key{down}
1793 @item M-@key{up}
1794 @itemx M-@key{down}
1795 Move the current row up/down.
1797 @kindex M-S-@key{up}
1798 @item M-S-@key{up}
1799 Kill the current row or horizontal line.
1801 @kindex M-S-@key{down}
1802 @item M-S-@key{down}
1803 Insert a new row above the current row.  With a prefix argument, the line is
1804 created below the current one.
1806 @kindex C-c -
1807 @item C-c -
1808 Insert a horizontal line below current row.  With a prefix argument, the line
1809 is created above the current line.
1811 @kindex C-c @key{RET}
1812 @item C-c @key{RET}
1813 Insert a horizontal line below current row, and move the cursor into the row
1814 below that line.
1816 @kindex C-c ^
1817 @item C-c ^
1818 Sort the table lines in the region.  The position of point indicates the
1819 column to be used for sorting, and the range of lines is the range
1820 between the nearest horizontal separator lines, or the entire table.  If
1821 point is before the first column, you will be prompted for the sorting
1822 column.  If there is an active region, the mark specifies the first line
1823 and the sorting column, while point should be in the last line to be
1824 included into the sorting.  The command prompts for the sorting type
1825 (alphabetically, numerically, or by time).  When called with a prefix
1826 argument, alphabetic sorting will be case-sensitive.
1828 @tsubheading{Regions}
1829 @kindex C-c C-x M-w
1830 @item C-c C-x M-w
1831 Copy a rectangular region from a table to a special clipboard.  Point and
1832 mark determine edge fields of the rectangle.  If there is no active region,
1833 copy just the current field.  The process ignores horizontal separator lines.
1835 @kindex C-c C-x C-w
1836 @item C-c C-x C-w
1837 Copy a rectangular region from a table to a special clipboard, and
1838 blank all fields in the rectangle.  So this is the ``cut'' operation.
1840 @kindex C-c C-x C-y
1841 @item C-c C-x C-y
1842 Paste a rectangular region into a table.
1843 The upper left corner ends up in the current field.  All involved fields
1844 will be overwritten.  If the rectangle does not fit into the present table,
1845 the table is enlarged as needed.  The process ignores horizontal separator
1846 lines.
1848 @kindex M-@key{RET}
1849 @itemx M-@kbd{RET}
1850 Wrap several fields in a column like a paragraph.  If there is an active
1851 region, and both point and mark are in the same column, the text in the
1852 column is wrapped to minimum width for the given number of lines.  A numeric
1853 prefix argument may be used to change the number of desired lines.  If there
1854 is no region, the current field is split at the cursor position and the text
1855 fragment to the right of the cursor is prepended to the field one line
1856 down. If there is no region, but you specify a prefix argument, the current
1857 field is made blank, and the content is appended to the field above.
1859 @tsubheading{Calculations}
1860 @cindex formula, in tables
1861 @cindex calculations, in tables
1862 @cindex region, active
1863 @cindex active region
1864 @cindex transient mark mode
1865 @kindex C-c +
1866 @item C-c +
1867 Sum the numbers in the current column, or in the rectangle defined by
1868 the active region.  The result is shown in the echo area and can
1869 be inserted with @kbd{C-y}.
1871 @kindex S-@key{RET}
1872 @item S-@key{RET}
1873 @vindex org-table-copy-increment
1874 When current field is empty, copy from first non-empty field above.  When not
1875 empty, copy current field down to next row and move cursor along with it.
1876 Depending on the variable @code{org-table-copy-increment}, integer field
1877 values will be incremented during copy.  Integers that are too large will not
1878 be incremented.  Also, a @code{0} prefix argument temporarily disables the
1879 increment.  This key is also used by shift-selection and related modes
1880 (@pxref{Conflicts}).
1882 @tsubheading{Miscellaneous}
1883 @kindex C-c `
1884 @item C-c `
1885 Edit the current field in a separate window.  This is useful for fields that
1886 are not fully visible (@pxref{Column width and alignment}).  When called with
1887 a @kbd{C-u} prefix, just make the full field visible, so that it can be
1888 edited in place.
1890 @item M-x org-table-import
1891 Import a file as a table.  The table should be TAB or whitespace
1892 separated.  Use, for example, to import a spreadsheet table or data
1893 from a database, because these programs generally can write
1894 TAB-separated text files.  This command works by inserting the file into
1895 the buffer and then converting the region to a table.  Any prefix
1896 argument is passed on to the converter, which uses it to determine the
1897 separator.
1898 @item C-c |
1899 Tables can also be imported by pasting tabular text into the Org
1900 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1901 @kbd{C-c |} command (see above under @i{Creation and conversion}).
1903 @item M-x org-table-export
1904 @vindex org-table-export-default-format
1905 Export the table, by default as a TAB-separated file.  Use for data
1906 exchange with, for example, spreadsheet or database programs.  The format
1907 used to export the file can be configured in the variable
1908 @code{org-table-export-default-format}.  You may also use properties
1909 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1910 name and the format for table export in a subtree.  Org supports quite
1911 general formats for exported tables.  The exporter format is the same as the
1912 format used by Orgtbl radio tables, see @ref{Translator functions}, for a
1913 detailed description.
1914 @end table
1916 If you don't like the automatic table editor because it gets in your
1917 way on lines which you would like to start with @samp{|}, you can turn
1918 it off with
1920 @lisp
1921 (setq org-enable-table-editor nil)
1922 @end lisp
1924 @noindent Then the only table command that still works is
1925 @kbd{C-c C-c} to do a manual re-align.
1927 @node Column width and alignment, Column groups, Built-in table editor, Tables
1928 @section Column width and alignment
1929 @cindex narrow columns in tables
1930 @cindex alignment in tables
1932 The width of columns is automatically determined by the table editor.  And
1933 also the alignment of a column is determined automatically from the fraction
1934 of number-like versus non-number fields in the column.
1936 Sometimes a single field or a few fields need to carry more text,
1937 leading to inconveniently wide columns.  To limit@footnote{This feature
1938 does not work on XEmacs.} the width of a column, one field anywhere in
1939 the column may contain just the string @samp{<N>} where @samp{N} is an
1940 integer specifying the width of the column in characters.  The next
1941 re-align will then set the width of this column to no more than this
1942 value.
1944 @example
1945 @group
1946 |---+------------------------------|               |---+--------|
1947 |   |                              |               |   | <6>    |
1948 | 1 | one                          |               | 1 | one    |
1949 | 2 | two                          |     ----\     | 2 | two    |
1950 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1951 | 4 | four                         |               | 4 | four   |
1952 |---+------------------------------|               |---+--------|
1953 @end group
1954 @end example
1956 @noindent
1957 Fields that are wider become clipped and end in the string @samp{=>}.
1958 Note that the full text is still in the buffer, it is only invisible.
1959 To see the full text, hold the mouse over the field---a tool-tip window
1960 will show the full content.  To edit such a field, use the command
1961 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1962 open a new window with the full field.  Edit it and finish with @kbd{C-c
1963 C-c}.
1965 @vindex org-startup-align-all-tables
1966 When visiting a file containing a table with narrowed columns, the
1967 necessary character hiding has not yet happened, and the table needs to
1968 be aligned before it looks nice.  Setting the option
1969 @code{org-startup-align-all-tables} will realign all tables in a file
1970 upon visiting, but also slow down startup.  You can also set this option
1971 on a per-file basis with:
1973 @example
1974 #+STARTUP: align
1975 #+STARTUP: noalign
1976 @end example
1978 If you would like to overrule the automatic alignment of number-rich columns
1979 to the right and of string-rich column to the left, you and use @samp{<r>} or
1980 @samp{<l>} in a similar fashion.  You may also combine alignment and field
1981 width like this: @samp{<l10>}.
1983 @node Column groups, Orgtbl mode, Column width and alignment, Tables
1984 @section Column groups
1985 @cindex grouping columns in tables
1987 When Org exports tables, it does so by default without vertical
1988 lines because that is visually more satisfying in general.  Occasionally
1989 however, vertical lines can be useful to structure a table into groups
1990 of columns, much like horizontal lines can do for groups of rows.  In
1991 order to specify column groups, you can use a special row where the
1992 first field contains only @samp{/}.  The further fields can either
1993 contain @samp{<} to indicate that this column should start a group,
1994 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1995 a group of its own.  Boundaries between column groups will upon export be
1996 marked with vertical lines.  Here is an example:
1998 @example
1999 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2000 |---+----+-----+-----+-----+---------+------------|
2001 | / | <> |   < |     |   > |       < |          > |
2002 | # |  1 |   1 |   1 |   1 |       1 |          1 |
2003 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
2004 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
2005 |---+----+-----+-----+-----+---------+------------|
2006 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2)))
2007 @end example
2009 It is also sufficient to just insert the column group starters after
2010 every vertical line you'd like to have:
2012 @example
2013 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2014 |----+-----+-----+-----+---------+------------|
2015 | /  | <   |     |     | <       |            |
2016 @end example
2018 @node Orgtbl mode, The spreadsheet, Column groups, Tables
2019 @section The Orgtbl minor mode
2020 @cindex Orgtbl mode
2021 @cindex minor mode for tables
2023 If you like the intuitive way the Org table editor works, you
2024 might also want to use it in other modes like Text mode or Mail mode.
2025 The minor mode Orgtbl mode makes this possible.  You can always toggle
2026 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
2027 example in mail mode, use
2029 @lisp
2030 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
2031 @end lisp
2033 Furthermore, with some special setup, it is possible to maintain tables
2034 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
2035 construct La@TeX{} tables with the underlying ease and power of
2036 Orgtbl mode, including spreadsheet capabilities.  For details, see
2037 @ref{Tables in arbitrary syntax}.
2039 @node The spreadsheet, Org-Plot, Orgtbl mode, Tables
2040 @section The spreadsheet
2041 @cindex calculations, in tables
2042 @cindex spreadsheet capabilities
2043 @cindex @file{calc} package
2045 The table editor makes use of the Emacs @file{calc} package to implement
2046 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
2047 derive fields from other fields.  While fully featured, Org's
2048 implementation is not identical to other spreadsheets.  For example,
2049 Org knows the concept of a @emph{column formula} that will be
2050 applied to all non-header fields in a column without having to copy the
2051 formula to each relevant field.
2053 @menu
2054 * References::                  How to refer to another field or range
2055 * Formula syntax for Calc::     Using Calc to compute stuff
2056 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
2057 * Field formulas::              Formulas valid for a single field
2058 * Column formulas::             Formulas valid for an entire column
2059 * Editing and debugging formulas::  Fixing formulas
2060 * Updating the table::          Recomputing all dependent fields
2061 * Advanced features::           Field names, parameters and automatic recalc
2062 @end menu
2064 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
2065 @subsection References
2066 @cindex references
2068 To compute fields in the table from other fields, formulas must
2069 reference other fields or ranges.  In Org, fields can be referenced
2070 by name, by absolute coordinates, and by relative coordinates.  To find
2071 out what the coordinates of a field are, press @kbd{C-c ?} in that
2072 field, or press @kbd{C-c @}} to toggle the display of a grid.
2074 @subsubheading Field references
2075 @cindex field references
2076 @cindex references, to fields
2078 Formulas can reference the value of another field in two ways.  Like in
2079 any other spreadsheet, you may reference fields with a letter/number
2080 combination like @code{B3}, meaning the 2nd field in the 3rd row.
2081 @c Such references are always fixed to that field, they don't change
2082 @c when you copy and paste a formula to a different field.  So
2083 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
2085 @noindent
2086 Org also uses another, more general operator that looks like this:
2087 @example
2088 @@@var{row}$@var{column}
2089 @end example
2091 @noindent
2092 Column references can be absolute like @samp{1}, @samp{2},...@samp{@var{N}},
2093 or relative to the current column like @samp{+1} or @samp{-2}.
2095 The row specification only counts data lines and ignores horizontal
2096 separator lines (hlines).  You can use absolute row numbers
2097 @samp{1}...@samp{@var{N}}, and row numbers relative to the current row like
2098 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
2099 hlines: @samp{I} refers to the first hline@footnote{Note that only
2100 hlines are counted that @emph{separate} table lines.  If the table
2101 starts with a hline above the header, it does not count.}, @samp{II} to
2102 the second, etc@.  @samp{-I} refers to the first such line above the
2103 current line, @samp{+I} to the first such line below the current line.
2104 You can also write @samp{III+2} which is the second data line after the
2105 third hline in the table.
2107 @samp{0} refers to the current row and column.  Also, if you omit
2108 either the column or the row part of the reference, the current
2109 row/column is implied.
2111 Org's references with @emph{unsigned} numbers are fixed references
2112 in the sense that if you use the same reference in the formula for two
2113 different fields, the same field will be referenced each time.
2114 Org's references with @emph{signed} numbers are floating
2115 references because the same reference operator can reference different
2116 fields depending on the field being calculated by the formula.
2118 As a special case, references like @samp{$LR5} and @samp{$LR12} can be used
2119 to refer in a stable way to the 5th and 12th field in the last row of the
2120 table.
2122 Here are a few examples:
2124 @example
2125 @@2$3      @r{2nd row, 3rd column}
2126 C2        @r{same as previous}
2127 $5        @r{column 5 in the current row}
2128 E&        @r{same as previous}
2129 @@2        @r{current column, row 2}
2130 @@-1$-3    @r{the field one row up, three columns to the left}
2131 @@-I$2     @r{field just under hline above current row, column 2}
2132 @end example
2134 @subsubheading Range references
2135 @cindex range references
2136 @cindex references, to ranges
2138 You may reference a rectangular range of fields by specifying two field
2139 references connected by two dots @samp{..}.  If both fields are in the
2140 current row, you may simply use @samp{$2..$7}, but if at least one field
2141 is in a different row, you need to use the general @code{@@row$column}
2142 format at least for the first field (i.e the reference must start with
2143 @samp{@@} in order to be interpreted correctly).  Examples:
2145 @example
2146 $1..$3        @r{First three fields in the current row.}
2147 $P..$Q        @r{Range, using column names (see under Advanced)}
2148 @@2$1..@@4$3    @r{6 fields between these two fields.}
2149 A2..C4        @r{Same as above.}
2150 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
2151 @end example
2153 @noindent Range references return a vector of values that can be fed
2154 into Calc vector functions.  Empty fields in ranges are normally
2155 suppressed, so that the vector contains only the non-empty fields (but
2156 see the @samp{E} mode switch below).  If there are no non-empty fields,
2157 @samp{[0]} is returned to avoid syntax errors in formulas.
2159 @subsubheading Named references
2160 @cindex named references
2161 @cindex references, named
2162 @cindex name, of column or field
2163 @cindex constants, in calculations
2164 @cindex #+CONSTANTS
2166 @vindex org-table-formula-constants
2167 @samp{$name} is interpreted as the name of a column, parameter or
2168 constant.  Constants are defined globally through the variable
2169 @code{org-table-formula-constants}, and locally (for the file) through a
2170 line like
2172 @example
2173 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2174 @end example
2176 @noindent
2177 @vindex constants-unit-system
2178 @pindex constants.el
2179 Also properties (@pxref{Properties and Columns}) can be used as
2180 constants in table formulas: for a property @samp{:Xyz:} use the name
2181 @samp{$PROP_Xyz}, and the property will be searched in the current
2182 outline entry and in the hierarchy above it.  If you have the
2183 @file{constants.el} package, it will also be used to resolve constants,
2184 including natural constants like @samp{$h} for Planck's constant, and
2185 units like @samp{$km} for kilometers@footnote{@file{constants.el} can
2186 supply the values of constants in two different unit systems, @code{SI}
2187 and @code{cgs}.  Which one is used depends on the value of the variable
2188 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
2189 @code{constSI} and @code{constcgs} to set this value for the current
2190 buffer.}.  Column names and parameters can be specified in special table
2191 lines.  These are described below, see @ref{Advanced features}.  All
2192 names must start with a letter, and further consist of letters and
2193 numbers.
2195 @subsubheading Remote references
2196 @cindex remote references
2197 @cindex references, remote
2198 @cindex references, to a different table
2199 @cindex name, of column or field
2200 @cindex constants, in calculations
2201 @cindex #+TBLNAME
2203 You may also reference constants, fields and ranges from a different table,
2204 either in the current file or even in a different file.  The syntax is
2206 @example
2207 remote(NAME-OR-ID,REF)
2208 @end example
2210 @noindent
2211 where NAME can be the name of a table in the current file as set by a
2212 @code{#+TBLNAME: NAME} line before the table.  It can also be the ID of an
2213 entry, even in a different file, and the reference then refers to the first
2214 table in that entry.  REF is an absolute field or range reference as
2215 described above for example @code{@@3$3} or @code{$somename}, valid in the
2216 referenced table.
2218 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
2219 @subsection Formula syntax for Calc
2220 @cindex formula syntax, Calc
2221 @cindex syntax, of formulas
2223 A formula can be any algebraic expression understood by the Emacs
2224 @file{Calc} package.  @b{Note that @file{calc} has the
2225 non-standard convention that @samp{/} has lower precedence than
2226 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
2227 evaluation by @code{calc-eval} (@pxref{Calling Calc from
2228 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
2229 Emacs Calc Manual}),
2230 @c FIXME:  The link to the Calc manual in HTML does not work.
2231 variable substitution takes place according to the rules described above.
2232 @cindex vectors, in table calculations
2233 The range vectors can be directly fed into the Calc vector functions
2234 like @samp{vmean} and @samp{vsum}.
2236 @cindex format specifier
2237 @cindex mode, for @file{calc}
2238 @vindex org-calc-default-modes
2239 A formula can contain an optional mode string after a semicolon.  This
2240 string consists of flags to influence Calc and other modes during
2241 execution.  By default, Org uses the standard Calc modes (precision
2242 12, angular units degrees, fraction and symbolic modes off).  The display
2243 format, however, has been changed to @code{(float 8)} to keep tables
2244 compact.  The default settings can be configured using the variable
2245 @code{org-calc-default-modes}.
2247 @example
2248 p20           @r{switch the internal precision to 20 digits}
2249 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
2250 D R           @r{angle modes: degrees, radians}
2251 F S           @r{fraction and symbolic modes}
2252 N             @r{interpret all fields as numbers, use 0 for non-numbers}
2253 T             @r{force text interpretation}
2254 E             @r{keep empty fields in ranges}
2255 L             @r{literal}
2256 @end example
2258 @noindent
2259 In addition, you may provide a @code{printf} format specifier to
2260 reformat the final result.  A few examples:
2262 @example
2263 $1+$2                @r{Sum of first and second field}
2264 $1+$2;%.2f           @r{Same, format result to two decimals}
2265 exp($2)+exp($1)      @r{Math functions can be used}
2266 $0;%.1f              @r{Reformat current cell to 1 decimal}
2267 ($3-32)*5/9          @r{Degrees F -> C conversion}
2268 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
2269 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
2270 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
2271 vmean($2..$7)        @r{Compute column range mean, using vector function}
2272 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
2273 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
2274 @end example
2276 Calc also contains a complete set of logical operations.  For example
2278 @example
2279 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
2280 @end example
2282 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
2283 @subsection Emacs Lisp forms as formulas
2284 @cindex Lisp forms, as table formulas
2286 It is also possible to write a formula in Emacs Lisp; this can be useful
2287 for string manipulation and control structures, if Calc's
2288 functionality is not enough.  If a formula starts with a single-quote
2289 followed by an opening parenthesis, then it is evaluated as a Lisp form.
2290 The evaluation should return either a string or a number.  Just as with
2291 @file{calc} formulas, you can specify modes and a printf format after a
2292 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
2293 field references are interpolated into the form.  By default, a
2294 reference will be interpolated as a Lisp string (in double-quotes)
2295 containing the field.  If you provide the @samp{N} mode switch, all
2296 referenced elements will be numbers (non-number fields will be zero) and
2297 interpolated as Lisp numbers, without quotes.  If you provide the
2298 @samp{L} flag, all fields will be interpolated literally, without quotes.
2299 @Ie{}, if you want a reference to be interpreted as a string by the Lisp
2300 form, enclose the reference operator itself in double-quotes, like
2301 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
2302 embed them in list or vector syntax.  A few examples, note how the
2303 @samp{N} mode is used when we do computations in Lisp.
2305 @example
2306 @r{Swap the first two characters of the content of column 1}
2307   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
2308 @r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
2309   '(+ $1 $2);N
2310 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
2311   '(apply '+ '($1..$4));N
2312 @end example
2314 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
2315 @subsection Field formulas
2316 @cindex field formula
2317 @cindex formula, for individual table field
2319 To assign a formula to a particular field, type it directly into the
2320 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
2321 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
2322 the field, the formula will be stored as the formula for this field,
2323 evaluated, and the current field replaced with the result.
2325 @cindex #+TBLFM
2326 Formulas are stored in a special line starting with @samp{#+TBLFM:}
2327 directly below the table.  If you typed the equation in the 4th field of
2328 the 3rd data line in the table, the formula will look like
2329 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
2330 with the appropriate commands, @i{absolute references} (but not relative
2331 ones) in stored formulas are modified in order to still reference the
2332 same field.  Of course this is not true if you edit the table structure
2333 with normal editing commands---then you must fix the equations yourself.
2334 The left-hand side of a formula may also be a named field (@pxref{Advanced
2335 features}), or a last-row reference like @samp{$LR3}.
2337 Instead of typing an equation into the field, you may also use the
2338 following command
2340 @table @kbd
2341 @kindex C-u C-c =
2342 @item C-u C-c =
2343 Install a new formula for the current field.  The command prompts for a
2344 formula with default taken from the @samp{#+TBLFM:} line, applies
2345 it to the current field, and stores it.
2346 @end table
2348 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
2349 @subsection Column formulas
2350 @cindex column formula
2351 @cindex formula, for table column
2353 Often in a table, the same formula should be used for all fields in a
2354 particular column.  Instead of having to copy the formula to all fields
2355 in that column, Org allows you to assign a single formula to an entire
2356 column.  If the table contains horizontal separator hlines, everything
2357 before the first such line is considered part of the table @emph{header}
2358 and will not be modified by column formulas.
2360 To assign a formula to a column, type it directly into any field in the
2361 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2362 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2363 the formula will be stored as the formula for the current column, evaluated
2364 and the current field replaced with the result.  If the field contains only
2365 @samp{=}, the previously stored formula for this column is used.  For each
2366 column, Org will only remember the most recently used formula.  In the
2367 @samp{#+TBLFM:} line, column formulas will look like @samp{$4=$1+$2}.  The left-hand
2368 side of a column formula cannot currently be the name of column, it
2369 must be the numeric column reference.
2371 Instead of typing an equation into the field, you may also use the
2372 following command:
2374 @table @kbd
2375 @kindex C-c =
2376 @item C-c =
2377 Install a new formula for the current column and replace current field with
2378 the result of the formula.  The command prompts for a formula, with default
2379 taken from the @samp{#+TBLFM} line, applies it to the current field and
2380 stores it.  With a numeric prefix argument(@eg @kbd{C-5 C-c =}) the command
2381 will apply it to that many consecutive fields in the current column.
2382 @end table
2384 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
2385 @subsection Editing and debugging formulas
2386 @cindex formula editing
2387 @cindex editing, of table formulas
2389 @vindex org-table-use-standard-references
2390 You can edit individual formulas in the minibuffer or directly in the
2391 field.  Org can also prepare a special buffer with all active
2392 formulas of a table.  When offering a formula for editing, Org
2393 converts references to the standard format (like @code{B3} or @code{D&})
2394 if possible.  If you prefer to only work with the internal format (like
2395 @code{@@3$2} or @code{$4}), configure the variable
2396 @code{org-table-use-standard-references}.
2398 @table @kbd
2399 @kindex C-c =
2400 @kindex C-u C-c =
2401 @item C-c =
2402 @itemx C-u C-c =
2403 Edit the formula associated with the current column/field in the
2404 minibuffer.  See @ref{Column formulas}, and @ref{Field formulas}.
2405 @kindex C-u C-u C-c =
2406 @item C-u C-u C-c =
2407 Re-insert the active formula (either a
2408 field formula, or a column formula) into the current field, so that you
2409 can edit it directly in the field.  The advantage over editing in the
2410 minibuffer is that you can use the command @kbd{C-c ?}.
2411 @kindex C-c ?
2412 @item C-c ?
2413 While editing a formula in a table field, highlight the field(s)
2414 referenced by the reference at the cursor position in the formula.
2415 @kindex C-c @}
2416 @item C-c @}
2417 Toggle the display of row and column numbers for a table, using
2418 overlays.  These are updated each time the table is aligned; you can
2419 force it with @kbd{C-c C-c}.
2420 @kindex C-c @{
2421 @item C-c @{
2422 Toggle the formula debugger on and off.  See below.
2423 @kindex C-c '
2424 @item C-c '
2425 Edit all formulas for the current table in a special buffer, where the
2426 formulas will be displayed one per line.  If the current field has an
2427 active formula, the cursor in the formula editor will mark it.
2428 While inside the special buffer, Org will automatically highlight
2429 any field or range reference at the cursor position.  You may edit,
2430 remove and add formulas, and use the following commands:
2431 @table @kbd
2432 @kindex C-c C-c
2433 @kindex C-x C-s
2434 @item C-c C-c
2435 @itemx C-x C-s
2436 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2437 prefix, also apply the new formulas to the entire table.
2438 @kindex C-c C-q
2439 @item C-c C-q
2440 Exit the formula editor without installing changes.
2441 @kindex C-c C-r
2442 @item C-c C-r
2443 Toggle all references in the formula editor between standard (like
2444 @code{B3}) and internal (like @code{@@3$2}).
2445 @kindex @key{TAB}
2446 @item @key{TAB}
2447 Pretty-print or indent Lisp formula at point.  When in a line containing
2448 a Lisp formula, format the formula according to Emacs Lisp rules.
2449 Another @key{TAB} collapses the formula back again.  In the open
2450 formula, @key{TAB} re-indents just like in Emacs Lisp mode.
2451 @kindex M-@key{TAB}
2452 @item M-@key{TAB}
2453 Complete Lisp symbols, just like in Emacs Lisp mode.
2454 @kindex S-@key{up}
2455 @kindex S-@key{down}
2456 @kindex S-@key{left}
2457 @kindex S-@key{right}
2458 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2459 Shift the reference at point.  For example, if the reference is
2460 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2461 This also works for relative references and for hline references.
2462 @kindex M-S-@key{up}
2463 @kindex M-S-@key{down}
2464 @item M-S-@key{up}/@key{down}
2465 Move the test line for column formulas in the Org buffer up and
2466 down.
2467 @kindex M-@key{up}
2468 @kindex M-@key{down}
2469 @item M-@key{up}/@key{down}
2470 Scroll the window displaying the table.
2471 @kindex C-c @}
2472 @item C-c @}
2473 Turn the coordinate grid in the table on and off.
2474 @end table
2475 @end table
2477 Making a table field blank does not remove the formula associated with
2478 the field, because that is stored in a different line (the @samp{#+TBLFM}
2479 line)---during the next recalculation the field will be filled again.
2480 To remove a formula from a field, you have to give an empty reply when
2481 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2483 @kindex C-c C-c
2484 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2485 equations with @kbd{C-c C-c} in that line or with the normal
2486 recalculation commands in the table.
2488 @subsubheading Debugging formulas
2489 @cindex formula debugging
2490 @cindex debugging, of table formulas
2491 When the evaluation of a formula leads to an error, the field content
2492 becomes the string @samp{#ERROR}.  If you would like see what is going
2493 on during variable substitution and calculation in order to find a bug,
2494 turn on formula debugging in the @code{Tbl} menu and repeat the
2495 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2496 field.  Detailed information will be displayed.
2498 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2499 @subsection Updating the table
2500 @cindex recomputing table fields
2501 @cindex updating, table
2503 Recalculation of a table is normally not automatic, but needs to be
2504 triggered by a command.  See @ref{Advanced features}, for a way to make
2505 recalculation at least semi-automatic.
2507 In order to recalculate a line of a table or the entire table, use the
2508 following commands:
2510 @table @kbd
2511 @kindex C-c *
2512 @item C-c *
2513 Recalculate the current row by first applying the stored column formulas
2514 from left to right, and all field formulas in the current row.
2516 @kindex C-u C-c *
2517 @item C-u C-c *
2518 @kindex C-u C-c C-c
2519 @itemx C-u C-c C-c
2520 Recompute the entire table, line by line.  Any lines before the first
2521 hline are left alone, assuming that these are part of the table header.
2523 @kindex C-u C-u C-c *
2524 @kindex C-u C-u C-c C-c
2525 @item C-u C-u C-c *
2526 @itemx C-u C-u C-c C-c
2527 Iterate the table by recomputing it until no further changes occur.
2528 This may be necessary if some computed fields use the value of other
2529 fields that are computed @i{later} in the calculation sequence.
2530 @end table
2532 @node Advanced features,  , Updating the table, The spreadsheet
2533 @subsection Advanced features
2535 If you want the recalculation of fields to happen automatically, or if
2536 you want to be able to assign @i{names} to fields and columns, you need
2537 to reserve the first column of the table for special marking characters.
2538 @table @kbd
2539 @kindex C-#
2540 @item C-#
2541 Rotate the calculation mark in first column through the states @samp{},
2542 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
2543 change all marks in the region.
2544 @end table
2546 Here is an example of a table that collects exam results of students and
2547 makes use of these features:
2549 @example
2550 @group
2551 |---+---------+--------+--------+--------+-------+------|
2552 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2553 |---+---------+--------+--------+--------+-------+------|
2554 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2555 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2556 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2557 |---+---------+--------+--------+--------+-------+------|
2558 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2559 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2560 |---+---------+--------+--------+--------+-------+------|
2561 |   | Average |        |        |        |  29.7 |      |
2562 | ^ |         |        |        |        |    at |      |
2563 | $ | max=50  |        |        |        |       |      |
2564 |---+---------+--------+--------+--------+-------+------|
2565 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2566 @end group
2567 @end example
2569 @noindent @b{Important}: please note that for these special tables,
2570 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2571 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2572 to the field itself.  The column formulas are not applied in rows with
2573 empty first field.
2575 @cindex marking characters, tables
2576 The marking characters have the following meaning:
2577 @table @samp
2578 @item !
2579 The fields in this line define names for the columns, so that you may
2580 refer to a column as @samp{$Tot} instead of @samp{$6}.
2581 @item ^
2582 This row defines names for the fields @emph{above} the row.  With such
2583 a definition, any formula in the table may use @samp{$m1} to refer to
2584 the value @samp{10}.  Also, if you assign a formula to a names field, it
2585 will be stored as @samp{$name=...}.
2586 @item _
2587 Similar to @samp{^}, but defines names for the fields in the row
2588 @emph{below}.
2589 @item $
2590 Fields in this row can define @emph{parameters} for formulas.  For
2591 example, if a field in a @samp{$} row contains @samp{max=50}, then
2592 formulas in this table can refer to the value 50 using @samp{$max}.
2593 Parameters work exactly like constants, only that they can be defined on
2594 a per-table basis.
2595 @item #
2596 Fields in this row are automatically recalculated when pressing
2597 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2598 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2599 lines will be left alone by this command.
2600 @item *
2601 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2602 not for automatic recalculation.  Use this when automatic
2603 recalculation slows down editing too much.
2604 @item
2605 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2606 All lines that should be recalculated should be marked with @samp{#}
2607 or @samp{*}.
2608 @item /
2609 Do not export this line.  Useful for lines that contain the narrowing
2610 @samp{<N>} markers or column group markers.
2611 @end table
2613 Finally, just to whet your appetite for what can be done with the
2614 fantastic @file{calc.el} package, here is a table that computes the Taylor
2615 series of degree @code{n} at location @code{x} for a couple of
2616 functions.
2618 @example
2619 @group
2620 |---+-------------+---+-----+--------------------------------------|
2621 |   | Func        | n | x   | Result                               |
2622 |---+-------------+---+-----+--------------------------------------|
2623 | # | exp(x)      | 1 | x   | 1 + x                                |
2624 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2625 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2626 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2627 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2628 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2629 |---+-------------+---+-----+--------------------------------------|
2630 #+TBLFM: $5=taylor($2,$4,$3);n3
2631 @end group
2632 @end example
2634 @node Org-Plot,  , The spreadsheet, Tables
2635 @section Org-Plot
2636 @cindex graph, in tables
2637 @cindex plot tables using gnuplot
2638 @cindex #+PLOT
2640 Org-Plot can produce 2D and 3D graphs of information stored in org tables
2641 using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
2642 @uref{http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html}.  To see
2643 this in action, ensure that you have both Gnuplot and Gnuplot mode installed
2644 on your system, then call @code{org-plot/gnuplot} on the following table.
2646 @example
2647 @group
2648 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2649 | Sede      | Max cites | H-index |
2650 |-----------+-----------+---------|
2651 | Chile     |    257.72 |   21.39 |
2652 | Leeds     |    165.77 |   19.68 |
2653 | Sao Paolo |     71.00 |   11.50 |
2654 | Stockholm |    134.19 |   14.33 |
2655 | Morelia   |    257.56 |   17.67 |
2656 @end group
2657 @end example
2659 Notice that Org Plot is smart enough to apply the table's headers as labels.
2660 Further control over the labels, type, content, and appearance of plots can
2661 be exercised through the @code{#+PLOT:} lines preceding a table.  See below
2662 for a complete list of Org-plot options.  For more information and examples
2663 see the Org-plot tutorial at
2664 @uref{http://orgmode.org/worg/org-tutorials/org-plot.php}.
2666 @subsubheading Plot Options
2668 @table @code
2669 @item set
2670 Specify any @command{gnuplot} option to be set when graphing.
2672 @item title
2673 Specify the title of the plot.
2675 @item ind
2676 Specify which column of the table to use as the @code{x} axis.
2678 @item deps
2679 Specify the columns to graph as a Lisp style list, surrounded by parentheses
2680 and separated by spaces for example @code{dep:(3 4)} to graph the third and
2681 fourth columns (defaults to graphing all other columns aside from the @code{ind}
2682 column).
2684 @item type
2685 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
2687 @item with
2688 Specify a @code{with} option to be inserted for every col being plotted
2689 (@eg @code{lines}, @code{points}, @code{boxes}, @code{impulses}, etc...).
2690 Defaults to @code{lines}.
2692 @item file
2693 If you want to plot to a file, specify @code{"@var{path/to/desired/output-file}"}.
2695 @item labels
2696 List of labels to be used for the deps (defaults to the column headers if
2697 they exist).
2699 @item line
2700 Specify an entire line to be inserted in the Gnuplot script.
2702 @item map
2703 When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
2704 flat mapping rather than a @code{3d} slope.
2706 @item timefmt
2707 Specify format of Org-mode timestamps as they will be parsed by Gnuplot.
2708 Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
2710 @item script
2711 If you want total control, you can specify a script file (place the file name
2712 between double-quotes) which will be used to plot.  Before plotting, every
2713 instance of @code{$datafile} in the specified script will be replaced with
2714 the path to the generated data file.  Note: even if you set this option, you
2715 may still want to specify the plot type, as that can impact the content of
2716 the data file.
2717 @end table
2719 @node Hyperlinks, TODO Items, Tables, Top
2720 @chapter Hyperlinks
2721 @cindex hyperlinks
2723 Like HTML, Org provides links inside a file, external links to
2724 other files, Usenet articles, emails, and much more.
2726 @menu
2727 * Link format::                 How links in Org are formatted
2728 * Internal links::              Links to other places in the current file
2729 * External links::              URL-like links to the world
2730 * Handling links::              Creating, inserting and following
2731 * Using links outside Org::     Linking from my C source code?
2732 * Link abbreviations::          Shortcuts for writing complex links
2733 * Search options::              Linking to a specific location
2734 * Custom searches::             When the default search is not enough
2735 @end menu
2737 @node Link format, Internal links, Hyperlinks, Hyperlinks
2738 @section Link format
2739 @cindex link format
2740 @cindex format, of links
2742 Org will recognize plain URL-like links and activate them as
2743 clickable links.  The general link format, however, looks like this:
2745 @example
2746 [[link][description]]       @r{or alternatively}           [[link]]
2747 @end example
2749 @noindent
2750 Once a link in the buffer is complete (all brackets present), Org
2751 will change the display so that @samp{description} is displayed instead
2752 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2753 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2754 which by default is an underlined face.  You can directly edit the
2755 visible part of a link.  Note that this can be either the @samp{link}
2756 part (if there is no description) or the @samp{description} part.  To
2757 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2758 cursor on the link.
2760 If you place the cursor at the beginning or just behind the end of the
2761 displayed text and press @key{BACKSPACE}, you will remove the
2762 (invisible) bracket at that location.  This makes the link incomplete
2763 and the internals are again displayed as plain text.  Inserting the
2764 missing bracket hides the link internals again.  To show the
2765 internal structure of all links, use the menu entry
2766 @code{Org->Hyperlinks->Literal links}.
2768 @node Internal links, External links, Link format, Hyperlinks
2769 @section Internal links
2770 @cindex internal links
2771 @cindex links, internal
2772 @cindex targets, for links
2774 @cindex property, CUSTOM_ID
2775 If the link does not look like a URL, it is considered to be internal in the
2776 current file.  The most important case is a link like
2777 @samp{[[#my-custom-id]]} which will link to the entry with the
2778 @code{CUSTOM_ID} property @samp{my-custom-id}.  Such custom IDs are very good
2779 for HTML export (@pxref{HTML export}) where they produce pretty section
2780 links.  You are responsible yourself to make sure these custom IDs are unique
2781 in a file.
2783 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]}
2784 lead to a text search in the current file.
2786 The link can be followed with @kbd{C-c C-o} when the cursor is on the link,
2787 or with a mouse click (@pxref{Handling links}).  Links to custom IDs will
2788 point to the corresponding headline.  The preferred match for a text link is
2789 a @i{dedicated target}: the same string in double angular brackets.  Targets
2790 may be located anywhere; sometimes it is convenient to put them into a
2791 comment line. For example
2793 @example
2794 # <<My Target>>
2795 @end example
2797 @noindent In HTML export (@pxref{HTML export}), such targets will become
2798 named anchors for direct access through @samp{http} links@footnote{Note that
2799 text before the first headline is usually not exported, so the first such
2800 target should be after the first headline, or in the line directly before the
2801 first headline.}.
2803 If no dedicated target exists, Org will search for the words in the link.  In
2804 the above example the search would be for @samp{my target}.  Links starting
2805 with a star like @samp{*My Target} restrict the search to
2806 headlines@footnote{To insert a link targeting a headline, in-buffer
2807 completion can be used.  Just type a star followed by a few optional letters
2808 into the buffer and press @kbd{M-@key{TAB}}.  All headlines in the current
2809 buffer will be offered as completions.  @xref{Handling links}, for more
2810 commands creating links.}.  When searching, Org mode will first try an
2811 exact match, but then move on to more and more lenient searches.  For
2812 example, the link @samp{[[*My Targets]]} will find any of the following:
2814 @example
2815 ** My targets
2816 ** TODO my targets are bright
2817 ** my 20 targets are
2818 @end example
2821 Following a link pushes a mark onto Org's own mark ring.  You can
2822 return to the previous position with @kbd{C-c &}.  Using this command
2823 several times in direct succession goes back to positions recorded
2824 earlier.
2826 @menu
2827 * Radio targets::               Make targets trigger links in plain text
2828 @end menu
2830 @node Radio targets,  , Internal links, Internal links
2831 @subsection Radio targets
2832 @cindex radio targets
2833 @cindex targets, radio
2834 @cindex links, radio targets
2836 Org can automatically turn any occurrences of certain target names
2837 in normal text into a link.  So without explicitly creating a link, the
2838 text connects to the target radioing its position.  Radio targets are
2839 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2840 Target>>>} causes each occurrence of @samp{my target} in normal text to
2841 become activated as a link.  The Org file is scanned automatically
2842 for radio targets only when the file is first loaded into Emacs.  To
2843 update the target list during editing, press @kbd{C-c C-c} with the
2844 cursor on or at a target.
2846 @node External links, Handling links, Internal links, Hyperlinks
2847 @section External links
2848 @cindex links, external
2849 @cindex external links
2850 @cindex links, external
2851 @cindex Gnus links
2852 @cindex BBDB links
2853 @cindex IRC links
2854 @cindex URL links
2855 @cindex file links
2856 @cindex VM links
2857 @cindex RMAIL links
2858 @cindex WANDERLUST links
2859 @cindex MH-E links
2860 @cindex USENET links
2861 @cindex SHELL links
2862 @cindex Info links
2863 @cindex Elisp links
2865 Org supports links to files, websites, Usenet and email messages,
2866 BBDB database entries and links to both IRC conversations and their
2867 logs.  External links are URL-like locators.  They start with a short
2868 identifying string followed by a colon.  There can be no space after
2869 the colon.  The following list shows examples for each link type.
2871 @example
2872 http://www.astro.uva.nl/~dominik          @r{on the web}
2873 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2874 /home/dominik/images/jupiter.jpg          @r{same as above}
2875 file:papers/last.pdf                      @r{file, relative path}
2876 ./papers/last.pdf                         @r{same as above}
2877 file:projects.org                         @r{another Org file}
2878 file:projects.org::some words             @r{text search in Org file}
2879 file:projects.org::*task title            @r{heading search in Org file}
2880 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
2881 news:comp.emacs                           @r{Usenet link}
2882 mailto:adent@@galaxy.net                   @r{Mail link}
2883 vm:folder                                 @r{VM folder link}
2884 vm:folder#id                              @r{VM message link}
2885 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
2886 wl:folder                                 @r{WANDERLUST folder link}
2887 wl:folder#id                              @r{WANDERLUST message link}
2888 mhe:folder                                @r{MH-E folder link}
2889 mhe:folder#id                             @r{MH-E message link}
2890 rmail:folder                              @r{RMAIL folder link}
2891 rmail:folder#id                           @r{RMAIL message link}
2892 gnus:group                                @r{Gnus group link}
2893 gnus:group#id                             @r{Gnus article link}
2894 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
2895 irc:/irc.com/#emacs/bob                   @r{IRC link}
2896 shell:ls *.org                            @r{A shell command}
2897 elisp:org-agenda                          @r{Interactive Elisp command}
2898 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
2899 @end example
2901 A link should be enclosed in double brackets and may contain a
2902 descriptive text to be displayed instead of the URL (@pxref{Link
2903 format}), for example:
2905 @example
2906 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2907 @end example
2909 @noindent
2910 If the description is a file name or URL that points to an image, HTML
2911 export (@pxref{HTML export}) will inline the image as a clickable
2912 button.  If there is no description at all and the link points to an
2913 image,
2914 that image will be inlined into the exported HTML file.
2916 @cindex square brackets, around links
2917 @cindex plain text external links
2918 Org also finds external links in the normal text and activates them
2919 as links.  If spaces must be part of the link (for example in
2920 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2921 about the end of the link, enclose them in square brackets.
2923 @node Handling links, Using links outside Org, External links, Hyperlinks
2924 @section Handling links
2925 @cindex links, handling
2927 Org provides methods to create a link in the correct syntax, to
2928 insert it into an Org file, and to follow the link.
2930 @table @kbd
2931 @kindex C-c l
2932 @cindex storing links
2933 @item C-c l
2934 Store a link to the current location.  This is a @emph{global} command (you
2935 must create the key binding yourself) which can be used in any buffer to
2936 create a link.  The link will be stored for later insertion into an Org
2937 buffer (see below).  What kind of link will be created depends on the current
2938 buffer:
2940 @b{Org-mode buffers}@*
2941 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
2942 to the target.  Otherwise it points to the current headline, which will also
2943 be the description.
2945 @vindex org-link-to-org-use-id
2946 @cindex property, CUSTOM_ID
2947 @cindex property, ID
2948 If the headline has a @code{CUSTOM_ID} property, a link to this custom ID
2949 will be stored.  In addition or alternatively (depending on the value of
2950 @code{org-link-to-org-use-id}), a globally unique @code{ID} property will be
2951 created and/or used to construct a link.  So using this command in Org
2952 buffers will potentially create two links: a human-readable from the custom
2953 ID, and one that is globally unique and works even if the entry is moved from
2954 file to file.  Later, when inserting the link, you need to decide which one
2955 to use.
2957 @b{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}@*
2958 Pretty much all Emacs mail clients are supported.  The link will point to the
2959 current article, or, in some GNUS buffers, to the group.  The description is
2960 constructed from the author and the subject.
2962 @b{Web browsers: W3 and W3M}@*
2963 Here the link will be the current URL, with the page title as description.
2965 @b{Contacts: BBDB}@*
2966 Links created in a BBDB buffer will point to the current entry.
2968 @b{Chat: IRC}@*
2969 @vindex org-irc-link-to-logs
2970 For IRC links, if you set the variable @code{org-irc-link-to-logs} to
2971 @code{t}, a @samp{file:/} style link to the relevant point in the logs for
2972 the current conversation is created.  Otherwise an @samp{irc:/} style link to
2973 the user/channel/server under the point will be stored.
2975 @b{Other files}@*
2976 For any other files, the link will point to the file, with a search string
2977 (@pxref{Search options}) pointing to the contents of the current line.  If
2978 there is an active region, the selected words will form the basis of the
2979 search string.  If the automatically created link is not working correctly or
2980 accurately enough, you can write custom functions to select the search string
2981 and to do the search for particular file types---see @ref{Custom searches}.
2982 The key binding @kbd{C-c l} is only a suggestion---see @ref{Installation}.
2984 @b{Agenda view}@*
2985 When the cursor is in an agenda view, the created link points to the
2986 entry referenced by the current line.
2989 @kindex C-c C-l
2990 @cindex link completion
2991 @cindex completion, of links
2992 @cindex inserting links
2993 @item C-c C-l
2994 @vindex org-keep-stored-link-after-insertion
2995 Insert a link@footnote{ Note that you don't have to use this command to
2996 insert a link.  Links in Org are plain text, and you can type or paste them
2997 straight into the buffer.  By using this command, the links are automatically
2998 enclosed in double brackets, and you will be asked for the optional
2999 descriptive text.}.  This prompts for a link to be inserted into the buffer.
3000 You can just type a link, using text for an internal link, or one of the link
3001 type prefixes mentioned in the examples above.  The link will be inserted
3002 into the buffer@footnote{After insertion of a stored link, the link will be
3003 removed from the list of stored links.  To keep it in the list later use, use
3004 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
3005 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
3006 If some text was selected when this command is called, the selected text
3007 becomes the default description.
3009 @b{Inserting stored links}@*
3010 All links stored during the
3011 current session are part of the history for this prompt, so you can access
3012 them with @key{up} and @key{down} (or @kbd{M-p/n}).
3014 @b{Completion support}@* Completion with @key{TAB} will help you to insert
3015 valid link prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
3016 defined through link abbreviations (@pxref{Link abbreviations}).  If you
3017 press @key{RET} after inserting only the @var{prefix}, Org will offer
3018 specific completion support for some link types@footnote{This works by
3019 calling a special function @code{org-PREFIX-complete-link}.}  For
3020 example, if you type @kbd{file @key{RET}}, file name completion (alternative
3021 access: @kbd{C-u C-c C-l}, see below) will be offered, and after @kbd{bbdb
3022 @key{RET}} you can complete contact names.
3023 @kindex C-u C-c C-l
3024 @cindex file name completion
3025 @cindex completion, of file names
3026 @item C-u C-c C-l
3027 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
3028 a file will be inserted and you may use file name completion to select
3029 the name of the file.  The path to the file is inserted relative to the
3030 directory of the current Org file, if the linked file is in the current
3031 directory or in a sub-directory of it, or if the path is written relative
3032 to the current directory using @samp{../}.  Otherwise an absolute path
3033 is used, if possible with @samp{~/} for your home directory.  You can
3034 force an absolute path with two @kbd{C-u} prefixes.
3036 @item C-c C-l @r{(with cursor on existing link)}
3037 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
3038 link and description parts of the link.
3040 @cindex following links
3041 @kindex C-c C-o
3042 @kindex RET
3043 @item C-c C-o @r{or} @key{RET}
3044 @vindex org-file-apps
3045 Open link at point.  This will launch a web browser for URLs (using
3046 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
3047 the corresponding links, and execute the command in a shell link.  When the
3048 cursor is on an internal link, this commands runs the corresponding search.
3049 When the cursor is on a TAG list in a headline, it creates the corresponding
3050 TAGS view.  If the cursor is on a timestamp, it compiles the agenda for that
3051 date.  Furthermore, it will visit text and remote files in @samp{file:} links
3052 with Emacs and select a suitable application for local non-text files.
3053 Classification of files is based on file extension only.  See option
3054 @code{org-file-apps}.  If you want to override the default application and
3055 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
3056 opening in Emacs, use a @kbd{C-u C-u} prefix.@*
3057 If the cursor is on a headline, but not on a link, offer all links in the
3058 headline and entry text.
3060 @kindex mouse-2
3061 @kindex mouse-1
3062 @item mouse-2
3063 @itemx mouse-1
3064 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
3065 would.  Under Emacs 22, @kbd{mouse-1} will also follow a link.
3067 @kindex mouse-3
3068 @item mouse-3
3069 @vindex org-display-internal-link-with-indirect-buffer
3070 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
3071 internal links to be displayed in another window@footnote{See the
3072 variable @code{org-display-internal-link-with-indirect-buffer}}.
3074 @cindex mark ring
3075 @kindex C-c %
3076 @item C-c %
3077 Push the current position onto the mark ring, to be able to return
3078 easily. Commands following an internal link do this automatically.
3080 @cindex links, returning to
3081 @kindex C-c &
3082 @item C-c &
3083 Jump back to a recorded position.  A position is recorded by the
3084 commands following internal links, and by @kbd{C-c %}.  Using this
3085 command several times in direct succession moves through a ring of
3086 previously recorded positions.
3088 @kindex C-c C-x C-n
3089 @kindex C-c C-x C-p
3090 @cindex links, finding next/previous
3091 @item C-c C-x C-n
3092 @itemx C-c C-x C-p
3093 Move forward/backward to the next link in the buffer.  At the limit of
3094 the buffer, the search fails once, and then wraps around.  The key
3095 bindings for this are really too long, you might want to bind this also
3096 to @kbd{C-n} and @kbd{C-p}
3097 @lisp
3098 (add-hook 'org-load-hook
3099   (lambda ()
3100     (define-key 'org-mode-map "\C-n" 'org-next-link)
3101     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
3102 @end lisp
3103 @end table
3105 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
3106 @section Using links outside Org
3108 You can insert and follow links that have Org syntax not only in
3109 Org, but in any Emacs buffer.  For this, you should create two
3110 global commands, like this (please select suitable global keys
3111 yourself):
3113 @lisp
3114 (global-set-key "\C-c L" 'org-insert-link-global)
3115 (global-set-key "\C-c o" 'org-open-at-point-global)
3116 @end lisp
3118 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
3119 @section Link abbreviations
3120 @cindex link abbreviations
3121 @cindex abbreviation, links
3123 Long URLs can be cumbersome to type, and often many similar links are
3124 needed in a document.  For this you can use link abbreviations.  An
3125 abbreviated link looks like this
3127 @example
3128 [[linkword:tag][description]]
3129 @end example
3131 @noindent
3132 @vindex org-link-abbrev-alist
3133 where the tag is optional.  The @i{linkword} must be a word; letter, numbers,
3134 @samp{-}, and @samp{_} are allowed here.  Abbreviations are resolved
3135 according to the information in the variable @code{org-link-abbrev-alist}
3136 that relates the linkwords to replacement text.  Here is an example:
3138 @lisp
3139 @group
3140 (setq org-link-abbrev-alist
3141   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3142     ("google"   . "http://www.google.com/search?q=")
3143     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
3144                    nph-abs_connect?author=%s&db_key=AST")))
3145 @end group
3146 @end lisp
3148 If the replacement text contains the string @samp{%s}, it will be
3149 replaced with the tag.  Otherwise the tag will be appended to the string
3150 in order to create the link.  You may also specify a function that will
3151 be called with the tag as the only argument to create the link.
3153 With the above setting, you could link to a specific bug with
3154 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
3155 @code{[[google:OrgMode]]} and find out what the Org author is
3156 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
3158 If you need special abbreviations just for a single Org buffer, you
3159 can define them in the file with
3161 @cindex #+LINK
3162 @example
3163 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3164 #+LINK: google    http://www.google.com/search?q=%s
3165 @end example
3167 @noindent
3168 In-buffer completion (@pxref{Completion}) can be used after @samp{[} to
3169 complete link abbreviations.  You may also define a function
3170 @code{org-PREFIX-complete-link} that implements special (@eg completion)
3171 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
3172 not accept any arguments, and return the full link with prefix.
3174 @node Search options, Custom searches, Link abbreviations, Hyperlinks
3175 @section Search options in file links
3176 @cindex search option in file links
3177 @cindex file links, searching
3179 File links can contain additional information to make Emacs jump to a
3180 particular location in the file when following a link.  This can be a
3181 line number or a search option after a double@footnote{For backward
3182 compatibility, line numbers can also follow a single colon.} colon. For
3183 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
3184 links}) to a file, it encodes the words in the current line as a search
3185 string that can be used to find this line back later when following the
3186 link with @kbd{C-c C-o}.
3188 Here is the syntax of the different ways to attach a search to a file
3189 link, together with an explanation:
3191 @example
3192 [[file:~/code/main.c::255]]
3193 [[file:~/xx.org::My Target]]
3194 [[file:~/xx.org::*My Target]]
3195 [[file:~/xx.org::/regexp/]]
3196 @end example
3198 @table @code
3199 @item 255
3200 Jump to line 255.
3201 @item My Target
3202 Search for a link target @samp{<<My Target>>}, or do a text search for
3203 @samp{my target}, similar to the search in internal links, see
3204 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
3205 link will become an HTML reference to the corresponding named anchor in
3206 the linked file.
3207 @item *My Target
3208 In an Org file, restrict search to headlines.
3209 @item /regexp/
3210 Do a regular expression search for @code{regexp}.  This uses the Emacs
3211 command @code{occur} to list all matches in a separate window.  If the
3212 target file is in Org mode, @code{org-occur} is used to create a
3213 sparse tree with the matches.
3214 @c If the target file is a directory,
3215 @c @code{grep} will be used to search all files in the directory.
3216 @end table
3218 As a degenerate case, a file link with an empty file name can be used
3219 to search the current file.  For example, @code{[[file:::find me]]} does
3220 a search for @samp{find me} in the current file, just as
3221 @samp{[[find me]]} would.
3223 @node Custom searches,  , Search options, Hyperlinks
3224 @section Custom Searches
3225 @cindex custom search strings
3226 @cindex search strings, custom
3228 The default mechanism for creating search strings and for doing the
3229 actual search related to a file link may not work correctly in all
3230 cases.  For example, Bib@TeX{} database files have many entries like
3231 @samp{year="1993"} which would not result in good search strings,
3232 because the only unique identification for a Bib@TeX{} entry is the
3233 citation key.
3235 @vindex org-create-file-search-functions
3236 @vindex org-execute-file-search-functions
3237 If you come across such a problem, you can write custom functions to set
3238 the right search string for a particular file type, and to do the search
3239 for the string in the file.  Using @code{add-hook}, these functions need
3240 to be added to the hook variables
3241 @code{org-create-file-search-functions} and
3242 @code{org-execute-file-search-functions}.  See the docstring for these
3243 variables for more information.  Org actually uses this mechanism
3244 for Bib@TeX{} database files, and you can use the corresponding code as
3245 an implementation example.  See the file @file{org-bibtex.el}.
3247 @node TODO Items, Tags, Hyperlinks, Top
3248 @chapter TODO Items
3249 @cindex TODO items
3251 Org mode does not maintain TODO lists as separate documents@footnote{Of
3252 course, you can make a document that contains only long lists of TODO items,
3253 but this is not required.}.  Instead, TODO items are an integral part of the
3254 notes file, because TODO items usually come up while taking notes!  With Org
3255 mode, simply mark any entry in a tree as being a TODO item.  In this way,
3256 information is not duplicated, and the entire context from which the TODO
3257 item emerged is always present.
3259 Of course, this technique for managing TODO items scatters them
3260 throughout your notes file.  Org mode compensates for this by providing
3261 methods to give you an overview of all the things that you have to do.
3263 @menu
3264 * TODO basics::                 Marking and displaying TODO entries
3265 * TODO extensions::             Workflow and assignments
3266 * Progress logging::            Dates and notes for progress
3267 * Priorities::                  Some things are more important than others
3268 * Breaking down tasks::         Splitting a task into manageable pieces
3269 * Checkboxes::                  Tick-off lists
3270 @end menu
3272 @node TODO basics, TODO extensions, TODO Items, TODO Items
3273 @section Basic TODO functionality
3275 Any headline becomes a TODO item when it starts with the word
3276 @samp{TODO}, for example:
3278 @example
3279 *** TODO Write letter to Sam Fortune
3280 @end example
3282 @noindent
3283 The most important commands to work with TODO entries are:
3285 @table @kbd
3286 @kindex C-c C-t
3287 @cindex cycling, of TODO states
3288 @item C-c C-t
3289 Rotate the TODO state of the current item among
3291 @example
3292 ,-> (unmarked) -> TODO -> DONE --.
3293 '--------------------------------'
3294 @end example
3296 The same rotation can also be done ``remotely'' from the timeline and
3297 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
3299 @kindex C-u C-c C-t
3300 @item C-u C-c C-t
3301 Select a specific keyword using completion or (if it has been set up)
3302 the fast selection interface.  For the latter, you need to assign keys
3303 to TODO states, see @ref{Per-file keywords}, and @ref{Setting tags}, for
3304 more information.
3306 @kindex S-@key{right}
3307 @kindex S-@key{left}
3308 @vindex org-treat-S-cursor-todo-selection-as-state-change
3309 @item S-@key{right}
3310 @itemx S-@key{left}
3311 Select the following/preceding TODO state, similar to cycling.  Useful
3312 mostly if more than two TODO states are possible (@pxref{TODO
3313 extensions}).  See also @ref{Conflicts}, for a discussion of the interaction
3314 with @code{shift-selection-mode}.  See also the variable
3315 @code{org-treat-S-cursor-todo-selection-as-state-change}.
3316 @kindex C-c C-v
3317 @kindex C-c / t
3318 @cindex sparse tree, for TODO
3319 @item C-c C-v
3320 @itemx C-c / t
3321 @vindex org-todo-keywords
3322 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
3323 entire buffer, but shows all TODO items and the headings hierarchy above
3324 them.  With a prefix argument, search for a specific TODO.  You will be
3325 prompted for the keyword, and you can also give a list of keywords like
3326 @code{KWD1|KWD2|...} to list entries that match any one of these keywords.
3327 With numeric prefix argument N, show the tree for the Nth keyword in the
3328 variable @code{org-todo-keywords}.  With two prefix arguments, find all TODO
3329 and DONE entries.
3330 @kindex C-c a t
3331 @item C-c a t
3332 Show the global TODO list.  Collects the TODO items from all agenda
3333 files (@pxref{Agenda Views}) into a single buffer.  The new buffer will
3334 be in @code{agenda-mode}, which provides commands to examine and
3335 manipulate the TODO entries from the new buffer (@pxref{Agenda
3336 commands}).  @xref{Global TODO list}, for more information.
3337 @kindex S-M-@key{RET}
3338 @item S-M-@key{RET}
3339 Insert a new TODO entry below the current one.
3340 @end table
3342 @noindent
3343 @vindex org-todo-state-tags-triggers
3344 Changing a TODO state can also trigger tag changes.  See the docstring of the
3345 option @code{org-todo-state-tags-triggers} for details.
3347 @node TODO extensions, Progress logging, TODO basics, TODO Items
3348 @section Extended use of TODO keywords
3349 @cindex extended TODO keywords
3351 @vindex org-todo-keywords
3352 By default, marked TODO entries have one of only two states: TODO and
3353 DONE.  Org mode allows you to classify TODO items in more complex ways
3354 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
3355 special setup, the TODO keyword system can work differently in different
3356 files.
3358 Note that @i{tags} are another way to classify headlines in general and
3359 TODO items in particular (@pxref{Tags}).
3361 @menu
3362 * Workflow states::             From TODO to DONE in steps
3363 * TODO types::                  I do this, Fred does the rest
3364 * Multiple sets in one file::   Mixing it all, and still finding your way
3365 * Fast access to TODO states::  Single letter selection of a state
3366 * Per-file keywords::           Different files, different requirements
3367 * Faces for TODO keywords::     Highlighting states
3368 * TODO dependencies::           When one task needs to wait for others
3369 @end menu
3371 @node Workflow states, TODO types, TODO extensions, TODO extensions
3372 @subsection TODO keywords as workflow states
3373 @cindex TODO workflow
3374 @cindex workflow states as TODO keywords
3376 You can use TODO keywords to indicate different @emph{sequential} states
3377 in the process of working on an item, for example@footnote{Changing
3378 this variable only becomes effective after restarting Org mode in a
3379 buffer.}:
3381 @lisp
3382 (setq org-todo-keywords
3383   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3384 @end lisp
3386 The vertical bar separates the TODO keywords (states that @emph{need
3387 action}) from the DONE states (which need @emph{no further action}).  If
3388 you don't provide the separator bar, the last state is used as the DONE
3389 state.
3390 @cindex completion, of TODO keywords
3391 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
3392 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
3393 also use a numeric prefix argument to quickly select a specific state.  For
3394 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
3395 Or you can use @kbd{S-@key{left}} to go backward through the sequence.  If you
3396 define many keywords, you can use in-buffer completion
3397 (@pxref{Completion}) or even a special one-key selection scheme
3398 (@pxref{Fast access to TODO states}) to insert these words into the
3399 buffer.  Changing a TODO state can be logged with a timestamp, see
3400 @ref{Tracking TODO state changes}, for more information.
3402 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
3403 @subsection TODO keywords as types
3404 @cindex TODO types
3405 @cindex names as TODO keywords
3406 @cindex types as TODO keywords
3408 The second possibility is to use TODO keywords to indicate different
3409 @emph{types} of action items.  For example, you might want to indicate
3410 that items are for ``work'' or ``home''.  Or, when you work with several
3411 people on a single project, you might want to assign action items
3412 directly to persons, by using their names as TODO keywords.  This would
3413 be set up like this:
3415 @lisp
3416 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3417 @end lisp
3419 In this case, different keywords do not indicate a sequence, but rather
3420 different types.  So the normal work flow would be to assign a task to a
3421 person, and later to mark it DONE.  Org mode supports this style by adapting
3422 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
3423 @kbd{t} command in the timeline and agenda buffers.}.  When used several
3424 times in succession, it will still cycle through all names, in order to first
3425 select the right type for a task.  But when you return to the item after some
3426 time and execute @kbd{C-c C-t} again, it will switch from any name directly
3427 to DONE.  Use prefix arguments or completion to quickly select a specific
3428 name.  You can also review the items of a specific TODO type in a sparse tree
3429 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
3430 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
3431 from all agenda files into a single buffer, you would use the numeric prefix
3432 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
3434 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
3435 @subsection Multiple keyword sets in one file
3436 @cindex TODO keyword sets
3438 Sometimes you may want to use different sets of TODO keywords in
3439 parallel.  For example, you may want to have the basic
3440 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
3441 separate state indicating that an item has been canceled (so it is not
3442 DONE, but also does not require action).  Your setup would then look
3443 like this:
3445 @lisp
3446 (setq org-todo-keywords
3447       '((sequence "TODO" "|" "DONE")
3448         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3449         (sequence "|" "CANCELED")))
3450 @end lisp
3452 The keywords should all be different, this helps Org mode to keep track
3453 of which subsequence should be used for a given entry.  In this setup,
3454 @kbd{C-c C-t} only operates within a subsequence, so it switches from
3455 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
3456 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
3457 select the correct sequence.  Besides the obvious ways like typing a
3458 keyword or using completion, you may also apply the following commands:
3460 @table @kbd
3461 @kindex C-S-@key{right}
3462 @kindex C-S-@key{left}
3463 @kindex C-u C-u C-c C-t
3464 @item C-u C-u C-c C-t
3465 @itemx C-S-@key{right}
3466 @itemx C-S-@key{left}
3467 These keys jump from one TODO subset to the next.  In the above example,
3468 @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{right}} would jump from @code{TODO} or
3469 @code{DONE} to @code{REPORT}, and any of the words in the second row to
3470 @code{CANCELED}.  Note that the @kbd{C-S-} key binding conflict with
3471 @code{shift-selection-mode} (@pxref{Conflicts}).
3472 @kindex S-@key{right}
3473 @kindex S-@key{left}
3474 @item S-@key{right}
3475 @itemx S-@key{left}
3476 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through @emph{all}
3477 keywords from all sets, so for example @kbd{S-@key{<right>}} would switch
3478 from @code{DONE} to @code{REPORT} in the example above.  See also
3479 @ref{Conflicts}, for a discussion of the interaction with
3480 @code{shift-selection-mode}.
3481 @end table
3483 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
3484 @subsection Fast access to TODO states
3486 If you would like to quickly change an entry to an arbitrary TODO state
3487 instead of cycling through the states, you can set up keys for
3488 single-letter access to the states.  This is done by adding the section
3489 key after each keyword, in parentheses.  For example:
3491 @lisp
3492 (setq org-todo-keywords
3493       '((sequence "TODO(t)" "|" "DONE(d)")
3494         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3495         (sequence "|" "CANCELED(c)")))
3496 @end lisp
3498 @vindex org-fast-tag-selection-include-todo
3499 If you then press @code{C-c C-t} followed by the selection key, the entry
3500 will be switched to this state.  @key{SPC} can be used to remove any TODO
3501 keyword from an entry.@footnote{Check also the variable
3502 @code{org-fast-tag-selection-include-todo}, it allows you to change the TODO
3503 state through the tags interface (@pxref{Setting tags}), in case you like to
3504 mingle the two concepts.  Note that this means you need to come up with
3505 unique keys across both sets of keywords.}
3507 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
3508 @subsection Setting up keywords for individual files
3509 @cindex keyword options
3510 @cindex per-file keywords
3511 @cindex #+TODO
3512 @cindex #+TYP_TODO
3513 @cindex #+SEQ_TODO
3515 It can be very useful to use different aspects of the TODO mechanism in
3516 different files.  For file-local settings, you need to add special lines
3517 to the file which set the keywords and interpretation for that file
3518 only.  For example, to set one of the two examples discussed above, you
3519 need one of the following lines, starting in column zero anywhere in the
3520 file:
3522 @example
3523 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3524 @end example
3525 @noindent (you may also write @code{#+SEQ_TODO} to be explicit about the
3526 interpretation, but it means the same as @code{#+TODO}), or
3527 @example
3528 #+TYP_TODO: Fred Sara Lucy Mike | DONE
3529 @end example
3531 A setup for using several sets in parallel would be:
3533 @example
3534 #+TODO: TODO | DONE
3535 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
3536 #+TODO: | CANCELED
3537 @end example
3539 @cindex completion, of option keywords
3540 @kindex M-@key{TAB}
3541 @noindent To make sure you are using the correct keyword, type
3542 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
3544 @cindex DONE, final TODO keyword
3545 Remember that the keywords after the vertical bar (or the last keyword
3546 if no bar is there) must always mean that the item is DONE (although you
3547 may use a different word).  After changing one of these lines, use
3548 @kbd{C-c C-c} with the cursor still in the line to make the changes
3549 known to Org mode@footnote{Org mode parses these lines only when
3550 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
3551 cursor in a line starting with @samp{#+} is simply restarting Org mode
3552 for the current buffer.}.
3554 @node Faces for TODO keywords, TODO dependencies, Per-file keywords, TODO extensions
3555 @subsection Faces for TODO keywords
3556 @cindex faces, for TODO keywords
3558 @vindex org-todo @r{(face)}
3559 @vindex org-done @r{(face)}
3560 @vindex org-todo-keyword-faces
3561 Org mode highlights TODO keywords with special faces: @code{org-todo}
3562 for keywords indicating that an item still has to be acted upon, and
3563 @code{org-done} for keywords indicating that an item is finished.  If
3564 you are using more than 2 different states, you might want to use
3565 special faces for some of them.  This can be done using the variable
3566 @code{org-todo-keyword-faces}.  For example:
3568 @lisp
3569 @group
3570 (setq org-todo-keyword-faces
3571       '(("TODO"      . org-warning)
3572         ("DEFERRED"  . shadow)
3573         ("CANCELED"  . (:foreground "blue" :weight bold))))
3574 @end group
3575 @end lisp
3577 While using a list with face properties as shown for CANCELED
3578 @emph{should} work, this does not aways seem to be the case.  If
3579 necessary, define a special face and use that.
3581 @node TODO dependencies,  , Faces for TODO keywords, TODO extensions
3582 @subsection TODO dependencies
3583 @cindex TODO dependencies
3584 @cindex dependencies, of TODO states
3586 @vindex org-enforce-todo-dependencies
3587 @cindex property, ORDERED
3588 The structure of Org files (hierarchy and lists) makes it easy to define TODO
3589 dependencies.  Usually, a parent TODO task should not be marked DONE until
3590 all subtasks (defined as children tasks) are marked as DONE.  And sometimes
3591 there is a logical sequence to a number of (sub)tasks, so that one task
3592 cannot be acted upon before all siblings above it are done.  If you customize
3593 the variable @code{org-enforce-todo-dependencies}, Org will block entries
3594 from changing state to DONE while they have children that are not DONE.
3595 Furthermore, if an entry has a property @code{ORDERED}, each of its children
3596 will be blocked until all earlier siblings are marked DONE.  Here is an
3597 example:
3599 @example
3600 * TODO Blocked until (two) is done
3601 ** DONE one
3602 ** TODO two
3604 * Parent
3605   :PROPERTIES:
3606     :ORDERED: t
3607   :END:
3608 ** TODO a
3609 ** TODO b, needs to wait for (a)
3610 ** TODO c, needs to wait for (a) and (b)
3611 @end example
3613 @table @kbd
3614 @kindex C-c C-x o
3615 @item C-c C-x o
3616 @vindex org-track-ordered-property-with-tag
3617 @cindex property, ORDERED
3618 Toggle the @code{ORDERED} property of the current entry.  A property is used
3619 for this behavior because this should be local to the current entry, not
3620 inherited like a tag.  However, if you would like to @i{track} the value of
3621 this property with a tag for better visibility, customize the variable
3622 @code{org-track-ordered-property-with-tag}.
3623 @kindex C-u C-u C-u C-c C-t
3624 @item C-u C-u C-u C-c C-t
3625 Change TODO state, circumventing any state blocking.
3626 @end table
3628 @vindex org-agenda-dim-blocked-tasks
3629 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
3630 that cannot be closed because of such dependencies will be shown in a dimmed
3631 font or even made invisible in agenda views (@pxref{Agenda Views}).
3633 @cindex checkboxes and TODO dependencies
3634 @vindex org-enforce-todo-dependencies
3635 You can also block changes of TODO states by looking at checkboxes
3636 (@pxref{Checkboxes}).  If you set the variable
3637 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
3638 checkboxes will be blocked from switching to DONE.
3640 If you need more complex dependency structures, for example dependencies
3641 between entries in different trees or files, check out the contributed
3642 module @file{org-depend.el}.
3644 @page
3645 @node Progress logging, Priorities, TODO extensions, TODO Items
3646 @section Progress logging
3647 @cindex progress logging
3648 @cindex logging, of progress
3650 Org mode can automatically record a timestamp and possibly a note when
3651 you mark a TODO item as DONE, or even each time you change the state of
3652 a TODO item.  This system is highly configurable, settings can be on a
3653 per-keyword basis and can be localized to a file or even a subtree.  For
3654 information on how to clock working time for a task, see @ref{Clocking
3655 work time}.
3657 @menu
3658 * Closing items::               When was this entry marked DONE?
3659 * Tracking TODO state changes::  When did the status change?
3660 @end menu
3662 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3663 @subsection Closing items
3665 The most basic logging is to keep track of @emph{when} a certain TODO
3666 item was finished.  This is achieved with@footnote{The corresponding
3667 in-buffer setting is: @code{#+STARTUP: logdone}}.
3669 @lisp
3670 (setq org-log-done 'time)
3671 @end lisp
3673 @noindent
3674 Then each time you turn an entry from a TODO (not-done) state into any
3675 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3676 just after the headline.  If you turn the entry back into a TODO item
3677 through further state cycling, that line will be removed again.  If you
3678 want to record a note along with the timestamp, use@footnote{The
3679 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3681 @lisp
3682 (setq org-log-done 'note)
3683 @end lisp
3685 @noindent
3686 You will then be prompted for a note, and that note will be stored below
3687 the entry with a @samp{Closing Note} heading.
3689 In the timeline (@pxref{Timeline}) and in the agenda
3690 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3691 display the TODO items with a @samp{CLOSED} timestamp on each day,
3692 giving you an overview of what has been done.
3694 @node Tracking TODO state changes,  , Closing items, Progress logging
3695 @subsection Tracking TODO state changes
3696 @cindex drawer, for state change recording
3698 @vindex org-log-states-order-reversed
3699 @vindex org-log-into-drawer
3700 @cindex property, LOG_INTO_DRAWER
3701 When TODO keywords are used as workflow states (@pxref{Workflow states}), you
3702 might want to keep track of when a state change occurred and maybe take a
3703 note about this change.  You can either record just a timestamp, or a
3704 time-stamped note for a change.  These records will be inserted after the
3705 headline as an itemized list, newest first@footnote{See the variable
3706 @code{org-log-states-order-reversed}}.  When taking a lot of notes, you might
3707 want to get the notes out of the way into a drawer (@pxref{Drawers}).
3708 Customize the variable @code{org-log-into-drawer} to get this
3709 behavior---the recommended drawer for this is called @code{LOGBOOK}.  You can
3710 also overrule the setting of this variable for a subtree by setting a
3711 @code{LOG_INTO_DRAWER} property.
3713 Since it is normally too much to record a note for every state, Org mode
3714 expects configuration on a per-keyword basis for this.  This is achieved by
3715 adding special markers @samp{!} (for a timestamp) and @samp{@@} (for a note)
3716 in parentheses after each keyword.  For example, with the setting
3718 @lisp
3719 (setq org-todo-keywords
3720   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3721 @end lisp
3723 @noindent
3724 @vindex org-log-done
3725 you not only define global TODO keywords and fast access keys, but also
3726 request that a time is recorded when the entry is set to
3727 DONE@footnote{It is possible that Org mode will record two timestamps
3728 when you are using both @code{org-log-done} and state change logging.
3729 However, it will never prompt for two notes---if you have configured
3730 both, the state change recording note will take precedence and cancel
3731 the @samp{Closing Note}.}, and that a note is recorded when switching to
3732 WAIT or CANCELED.  The setting for WAIT is even more special: the
3733 @samp{!} after the slash means that in addition to the note taken when
3734 entering the state, a timestamp should be recorded when @i{leaving} the
3735 WAIT state, if and only if the @i{target} state does not configure
3736 logging for entering it.  So it has no effect when switching from WAIT
3737 to DONE, because DONE is configured to record a timestamp only.  But
3738 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3739 setting now triggers a timestamp even though TODO has no logging
3740 configured.
3742 You can use the exact same syntax for setting logging preferences local
3743 to a buffer:
3744 @example
3745 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3746 @end example
3748 @cindex property, LOGGING
3749 In order to define logging settings that are local to a subtree or a
3750 single item, define a LOGGING property in this entry.  Any non-empty
3751 LOGGING property resets all logging settings to nil.  You may then turn
3752 on logging for this specific tree using STARTUP keywords like
3753 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3754 settings like @code{TODO(!)}.  For example
3756 @example
3757 * TODO Log each state with only a time
3758   :PROPERTIES:
3759   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3760   :END:
3761 * TODO Only log when switching to WAIT, and when repeating
3762   :PROPERTIES:
3763   :LOGGING: WAIT(@@) logrepeat
3764   :END:
3765 * TODO No logging at all
3766   :PROPERTIES:
3767   :LOGGING: nil
3768   :END:
3769 @end example
3771 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3772 @section Priorities
3773 @cindex priorities
3775 If you use Org mode extensively, you may end up enough TODO items that
3776 it starts to make sense to prioritize them.  Prioritizing can be done by
3777 placing a @emph{priority cookie} into the headline of a TODO item, like
3778 this
3780 @example
3781 *** TODO [#A] Write letter to Sam Fortune
3782 @end example
3784 @noindent
3785 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
3786 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3787 is treated as priority @samp{B}.  Priorities make a difference only in
3788 the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have
3789 no inherent meaning to Org mode.
3791 Priorities can be attached to any outline tree entries; they do not need
3792 to be TODO items.
3794 @table @kbd
3795 @kindex @kbd{C-c ,}
3796 @item @kbd{C-c ,}
3797 Set the priority of the current headline.  The command prompts for a
3798 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3799 @key{SPC} instead, the priority cookie is removed from the headline.
3800 The priorities can also be changed ``remotely'' from the timeline and
3801 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3803 @kindex S-@key{up}
3804 @kindex S-@key{down}
3805 @item S-@key{up}
3806 @itemx S-@key{down}
3807 @vindex org-priority-start-cycle-with-default
3808 Increase/decrease priority of current headline@footnote{See also the option
3809 @code{org-priority-start-cycle-with-default}.}.  Note that these keys are
3810 also used to modify timestamps (@pxref{Creating timestamps}).  See also
3811 @ref{Conflicts}, for a discussion of the interaction with
3812 @code{shift-selection-mode}.
3813 @end table
3815 @vindex org-highest-priority
3816 @vindex org-lowest-priority
3817 @vindex org-default-priority
3818 You can change the range of allowed priorities by setting the variables
3819 @code{org-highest-priority}, @code{org-lowest-priority}, and
3820 @code{org-default-priority}.  For an individual buffer, you may set
3821 these values (highest, lowest, default) like this (please make sure that
3822 the highest priority is earlier in the alphabet than the lowest
3823 priority):
3825 @cindex #+PRIORITIES
3826 @example
3827 #+PRIORITIES: A C B
3828 @end example
3830 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3831 @section Breaking tasks down into subtasks
3832 @cindex tasks, breaking down
3833 @cindex statistics, for TODO items
3835 @vindex org-agenda-todo-list-sublevels
3836 It is often advisable to break down large tasks into smaller, manageable
3837 subtasks.  You can do this by creating an outline tree below a TODO item,
3838 with detailed subtasks on the tree@footnote{To keep subtasks out of the
3839 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
3840 the overview over the fraction of subtasks that are already completed, insert
3841 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
3842 be updates each time the todo status of a child changes, or when pressing
3843 @kbd{C-c C-c} on the cookie.  For example:
3845 @example
3846 * Organize Party [33%]
3847 ** TODO Call people [1/2]
3848 *** TODO Peter
3849 *** DONE Sarah
3850 ** TODO Buy food
3851 ** DONE Talk to neighbor
3852 @end example
3854 @cindex property, COOKIE_DATA
3855 If a heading has both checkboxes and TODO children below it, the meaning of
3856 the statistics cookie become ambiguous.  Set the property
3857 @code{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve
3858 this issue.
3860 @vindex org-hierarchical-todo-statistics
3861 If you would like to have the statistics cookie count any TODO entries in the
3862 subtree (not just direct children), confgure the variable
3863 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
3864 include the word @samp{recursive} into the value of the @code{COOKIE_DATA}
3865 property.
3867 @example
3868 * Parent capturing statistics [2/20]
3869   :PROPERTIES:
3870   :COOKIE_DATA: todo recursive
3871   :END:
3872 @end example
3874 If you would like a TODO entry to automatically change to DONE
3875 when all children are done, you can use the following setup:
3877 @example
3878 (defun org-summary-todo (n-done n-not-done)
3879   "Switch entry to DONE when all subentries are done, to TODO otherwise."
3880   (let (org-log-done org-log-states)   ; turn off logging
3881     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
3883 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
3884 @end example
3887 Another possibility is the use of checkboxes to identify (a hierarchy of) a
3888 large number of subtasks (@pxref{Checkboxes}).
3891 @node Checkboxes,  , Breaking down tasks, TODO Items
3892 @section Checkboxes
3893 @cindex checkboxes
3895 Every item in a plain list (@pxref{Plain lists}) can be made into a
3896 checkbox by starting it with the string @samp{[ ]}.  This feature is
3897 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3898 Checkboxes are not included into the global TODO list, so they are often
3899 great to split a task into a number of simple steps.  Or you can use
3900 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3901 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3903 Here is an example of a checkbox list.
3905 @example
3906 * TODO Organize party [2/4]
3907   - [-] call people [1/3]
3908     - [ ] Peter
3909     - [X] Sarah
3910     - [ ] Sam
3911   - [X] order food
3912   - [ ] think about what music to play
3913   - [X] talk to the neighbors
3914 @end example
3916 Checkboxes work hierarchically, so if a checkbox item has children that
3917 are checkboxes, toggling one of the children checkboxes will make the
3918 parent checkbox reflect if none, some, or all of the children are
3919 checked.
3921 @cindex statistics, for checkboxes
3922 @cindex checkbox statistics
3923 @cindex property, COOKIE_DATA
3924 @vindex org-hierarchical-checkbox-statistics
3925 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
3926 indicating how many checkboxes present in this entry have been checked off,
3927 and the total number of checkboxes present.  This can give you an idea on how
3928 many checkboxes remain, even without opening a folded entry.  The cookies can
3929 be placed into a headline or into (the first line of) a plain list item.
3930 Each cookie covers checkboxes of direct children structurally below the
3931 headline/item on which the cookie appears@footnote{Set the variable
3932 @code{org-hierarchical-checkbox-statistics} if you want such cookies to
3933 represent the all checkboxes below the cookie, not just the direct
3934 children.}.  You have to insert the cookie yourself by typing either
3935 @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m}
3936 result, as in the examples above.  With @samp{[%]} you get information about
3937 the percentage of checkboxes checked (in the above example, this would be
3938 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can
3939 count either checkboxes below the heading or TODO states of children, and it
3940 will display whatever was changed last.  Set the property @code{COOKIE_DATA}
3941 to either @samp{checkbox} or @samp{todo} to resolve this issue.
3943 @cindex blocking, of checkboxes
3944 @cindex checkbox blocking
3945 @cindex property, ORDERED
3946 If the current outline node has an @code{ORDERED} property, checkboxes must
3947 be checked off in sequence, and an error will be thrown if you try to check
3948 off a box while there are unchecked boxes above it.
3950 @noindent The following commands work with checkboxes:
3952 @table @kbd
3953 @kindex C-c C-c
3954 @item C-c C-c
3955 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
3956 double prefix argument, set it to @samp{[-]}, which is considered to be an
3957 intermediate state.
3958 @kindex C-c C-x C-b
3959 @item C-c C-x C-b
3960 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
3961 double prefix argument, set it to @samp{[-]}, which is considered to be an
3962 intermediate state.
3963 @itemize @minus
3964 @item
3965 If there is an active region, toggle the first checkbox in the region
3966 and set all remaining boxes to the same status as the first.  With a prefix
3967 arg, add or remove the checkbox for all items in the region.
3968 @item
3969 If the cursor is in a headline, toggle checkboxes in the region between
3970 this headline and the next (so @emph{not} the entire subtree).
3971 @item
3972 If there is no active region, just toggle the checkbox at point.
3973 @end itemize
3974 @kindex M-S-@key{RET}
3975 @item M-S-@key{RET}
3976 Insert a new item with a checkbox.
3977 This works only if the cursor is already in a plain list item
3978 (@pxref{Plain lists}).
3979 @kindex C-c C-x o
3980 @item C-c C-x o
3981 @vindex org-track-ordered-property-with-tag
3982 @cindex property, ORDERED
3983 Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
3984 be checked off in sequence.  A property is used for this behavior because
3985 this should be local to the current entry, not inherited like a tag.
3986 However, if you would like to @i{track} the value of this property with a tag
3987 for better visibility, customize the variable
3988 @code{org-track-ordered-property-with-tag}.
3989 @kindex C-c #
3990 @item C-c #
3991 Update the statistics cookie in the current outline entry.  When called with
3992 a @kbd{C-u} prefix, update the entire file.  Checkbox statistic cookies are
3993 updated automatically if you toggle checkboxes with @kbd{C-c C-c} and make
3994 new ones with @kbd{M-S-@key{RET}}.  TODO statistics cookies update when
3995 changing TODO states.  If you delete boxes/entries or add/change them by
3996 hand, use this command to get things back into sync.  Or simply toggle any
3997 entry twice (checkboxes with @kbd{C-c C-c}).
3998 @end table
4000 @node Tags, Properties and Columns, TODO Items, Top
4001 @chapter Tags
4002 @cindex tags
4003 @cindex headline tagging
4004 @cindex matching, tags
4005 @cindex sparse tree, tag based
4007 An excellent way to implement labels and contexts for cross-correlating
4008 information is to assign @i{tags} to headlines.  Org mode has extensive
4009 support for tags.
4011 @vindex org-tag-faces
4012 Every headline can contain a list of tags; they occur at the end of the
4013 headline.  Tags are normal words containing letters, numbers, @samp{_}, and
4014 @samp{@@}.  Tags must be preceded and followed by a single colon, @eg{},
4015 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
4016 Tags will by default be in bold face with the same color as the headline.
4017 You may specify special faces for specific tags using the variable
4018 @code{org-tag-faces}, in much the same way as you can for TODO keywords
4019 (@pxref{Faces for TODO keywords}).
4021 @menu
4022 * Tag inheritance::             Tags use the tree structure of the outline
4023 * Setting tags::                How to assign tags to a headline
4024 * Tag searches::                Searching for combinations of tags
4025 @end menu
4027 @node Tag inheritance, Setting tags, Tags, Tags
4028 @section Tag inheritance
4029 @cindex tag inheritance
4030 @cindex inheritance, of tags
4031 @cindex sublevels, inclusion into tags match
4033 @i{Tags} make use of the hierarchical structure of outline trees.  If a
4034 heading has a certain tag, all subheadings will inherit the tag as
4035 well.  For example, in the list
4037 @example
4038 * Meeting with the French group      :work:
4039 ** Summary by Frank                  :boss:notes:
4040 *** TODO Prepare slides for him      :action:
4041 @end example
4043 @noindent
4044 the final heading will have the tags @samp{:work:}, @samp{:boss:},
4045 @samp{:notes:}, and @samp{:action:} even though the final heading is not
4046 explicitly marked with those tags.  You can also set tags that all entries in
4047 a file should inherit just as if these tags were defined in a hypothetical
4048 level zero that surrounds the entire file.  Use a line like this@footnote{As
4049 with all these in-buffer settings, pressing @kbd{C-c C-c} activates any
4050 changes in the line.}:
4052 @cindex #+FILETAGS
4053 @example
4054 #+FILETAGS: :Peter:Boss:Secret:
4055 @end example
4057 @noindent
4058 @vindex org-use-tag-inheritance
4059 @vindex org-tags-exclude-from-inheritance
4060 To limit tag inheritance to specific tags, or to turn it off entirely, use
4061 the variables @code{org-use-tag-inheritance} and
4062 @code{org-tags-exclude-from-inheritance}.
4064 @vindex org-tags-match-list-sublevels
4065 When a headline matches during a tags search while tag inheritance is turned
4066 on, all the sublevels in the same tree will (for a simple match form) match
4067 as well@footnote{This is only true if the search does not involve more
4068 complex tests including properties (@pxref{Property searches}).}.  The list
4069 of matches may then become very long.  If you only want to see the first tags
4070 match in a subtree, configure the variable
4071 @code{org-tags-match-list-sublevels} (not recommended).
4073 @node Setting tags, Tag searches, Tag inheritance, Tags
4074 @section Setting tags
4075 @cindex setting tags
4076 @cindex tags, setting
4078 @kindex M-@key{TAB}
4079 Tags can simply be typed into the buffer at the end of a headline.
4080 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
4081 also a special command for inserting tags:
4083 @table @kbd
4084 @kindex C-c C-q
4085 @item C-c C-q
4086 @cindex completion, of tags
4087 @vindex org-tags-column
4088 Enter new tags for the current headline.  Org mode will either offer
4089 completion or a special single-key interface for setting tags, see
4090 below.  After pressing @key{RET}, the tags will be inserted and aligned
4091 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
4092 tags in the current buffer will be aligned to that column, just to make
4093 things look nice.  TAGS are automatically realigned after promotion,
4094 demotion, and TODO state changes (@pxref{TODO basics}).
4095 @kindex C-c C-c
4096 @item C-c C-c
4097 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
4098 @end table
4100 @vindex org-tag-alist
4101 Org will support tag insertion based on a @emph{list of tags}.  By
4102 default this list is constructed dynamically, containing all tags
4103 currently used in the buffer.  You may also globally specify a hard list
4104 of tags with the variable @code{org-tag-alist}.  Finally you can set
4105 the default tags for a given file with lines like
4107 @cindex #+TAGS
4108 @example
4109 #+TAGS: @@work @@home @@tennisclub
4110 #+TAGS: laptop car pc sailboat
4111 @end example
4113 If you have globally defined your preferred set of tags using the
4114 variable @code{org-tag-alist}, but would like to use a dynamic tag list
4115 in a specific file, add an empty TAGS option line to that file:
4117 @example
4118 #+TAGS:
4119 @end example
4121 @vindex org-tag-persistent-alist
4122 If you have a preferred set of tags that you would like to use in every file,
4123 in addition to those defined on a per-file basis by TAGS option lines, then
4124 you may specify a list of tags with the variable
4125 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
4126 by adding a STARTUP option line to that file:
4128 @example
4129 #+STARTUP: noptag
4130 @end example
4132 By default Org mode uses the standard minibuffer completion facilities for
4133 entering tags.  However, it also implements another, quicker, tag selection
4134 method called @emph{fast tag selection}.  This allows you to select and
4135 deselect tags with just a single key press.  For this to work well you should
4136 assign unique letters to most of your commonly used tags.  You can do this
4137 globally by configuring the variable @code{org-tag-alist} in your
4138 @file{.emacs} file.  For example, you may find the need to tag many items in
4139 different files with @samp{:@@home:}.  In this case you can set something
4140 like:
4142 @lisp
4143 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
4144 @end lisp
4146 @noindent If the tag is only relevant to the file you are working on, then you
4147 can instead set the TAGS option line as:
4149 @example
4150 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
4151 @end example
4153 @noindent The tags interface will show the available tags in a splash
4154 window.  If you want to start a new line after a specific tag, insert
4155 @samp{\n} into the tag list
4157 @example
4158 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t) \n laptop(l)  pc(p)
4159 @end example
4161 @noindent or write them in two lines:
4163 @example
4164 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
4165 #+TAGS: laptop(l)  pc(p)
4166 @end example
4168 @noindent
4169 You can also group together tags that are mutually exclusive by using
4170 braces, as in:
4172 @example
4173 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
4174 @end example
4176 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
4177 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
4179 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
4180 these lines to activate any changes.
4182 @noindent
4183 To set these mutually exclusive groups in the variable @code{org-tags-alist},
4184 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
4185 of the braces.  Similarly, you can use @code{:newline} to indicate a line
4186 break.  The previous example would be set globally by the following
4187 configuration:
4189 @lisp
4190 (setq org-tag-alist '((:startgroup . nil)
4191                       ("@@work" . ?w) ("@@home" . ?h)
4192                       ("@@tennisclub" . ?t)
4193                       (:endgroup . nil)
4194                       ("laptop" . ?l) ("pc" . ?p)))
4195 @end lisp
4197 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
4198 automatically present you with a special interface, listing inherited tags,
4199 the tags of the current headline, and a list of all valid tags with
4200 corresponding keys@footnote{Keys will automatically be assigned to tags which
4201 have no configured keys.}.  In this interface, you can use the following
4202 keys:
4204 @table @kbd
4205 @item a-z...
4206 Pressing keys assigned to tags will add or remove them from the list of
4207 tags in the current line.  Selecting a tag in a group of mutually
4208 exclusive tags will turn off any other tags from that group.
4209 @kindex @key{TAB}
4210 @item @key{TAB}
4211 Enter a tag in the minibuffer, even if the tag is not in the predefined
4212 list.  You will be able to complete on all tags present in the buffer.
4213 @kindex @key{SPC}
4214 @item @key{SPC}
4215 Clear all tags for this line.
4216 @kindex @key{RET}
4217 @item @key{RET}
4218 Accept the modified set.
4219 @item C-g
4220 Abort without installing changes.
4221 @item q
4222 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
4223 @item !
4224 Turn off groups of mutually exclusive tags.  Use this to (as an
4225 exception) assign several tags from such a group.
4226 @item C-c
4227 Toggle auto-exit after the next change (see below).
4228 If you are using expert mode, the first @kbd{C-c} will display the
4229 selection window.
4230 @end table
4232 @noindent
4233 This method lets you assign tags to a headline with very few keys.  With
4234 the above setup, you could clear the current tags and set @samp{@@home},
4235 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
4236 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
4237 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
4238 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
4239 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
4240 @key{RET} @key{RET}}.
4242 @vindex org-fast-tag-selection-single-key
4243 If you find that most of the time you need only a single key press to
4244 modify your list of tags, set the variable
4245 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
4246 press @key{RET} to exit fast tag selection---it will immediately exit
4247 after the first change.  If you then occasionally need more keys, press
4248 @kbd{C-c} to turn off auto-exit for the current tag selection process
4249 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
4250 C-c}).  If you set the variable to the value @code{expert}, the special
4251 window is not even shown for single-key tag selection, it comes up only
4252 when you press an extra @kbd{C-c}.
4254 @node Tag searches,  , Setting tags, Tags
4255 @section Tag searches
4256 @cindex tag searches
4257 @cindex searching for tags
4259 Once a system of tags has been set up, it can be used to collect related
4260 information into special lists.
4262 @table @kbd
4263 @kindex C-c \
4264 @kindex C-c / m
4265 @item C-c \
4266 @itemx C-c / m
4267 Create a sparse tree with all headlines matching a tags search.  With a
4268 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4269 @kindex C-c a m
4270 @item C-c a m
4271 Create a global list of tag matches from all agenda files.
4272 @xref{Matching tags and properties}.
4273 @kindex C-c a M
4274 @item C-c a M
4275 @vindex org-tags-match-list-sublevels
4276 Create a global list of tag matches from all agenda files, but check
4277 only TODO items and force checking subitems (see variable
4278 @code{org-tags-match-list-sublevels}).
4279 @end table
4281 These commands all prompt for a match string which allows basic Boolean logic
4282 like @samp{+boss+urgent-project1}, to find entries with tags @samp{boss} and
4283 @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find entries
4284 which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of the search
4285 string is rich and allows also matching against TODO keywords, entry levels
4286 and properties.  For a complete description with many examples, see
4287 @ref{Matching tags and properties}.
4290 @node Properties and Columns, Dates and Times, Tags, Top
4291 @chapter Properties and Columns
4292 @cindex properties
4294 Properties are a set of key-value pairs associated with an entry.  There
4295 are two main applications for properties in Org mode.  First, properties
4296 are like tags, but with a value.  Second, you can use properties to
4297 implement (very basic) database capabilities in an Org buffer.  For
4298 an example of the first application, imagine maintaining a file where
4299 you document bugs and plan releases for a piece of software.  Instead of
4300 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
4301 property, say @code{:Release:}, that in different subtrees has different
4302 values, such as @code{1.0} or @code{2.0}.  For an example of the second
4303 application of properties, imagine keeping track of your music CDs,
4304 where properties could be things such as the album, artist, date of
4305 release, number of tracks, and so on.
4307 Properties can be conveniently edited and viewed in column view
4308 (@pxref{Column view}).
4310 @menu
4311 * Property syntax::             How properties are spelled out
4312 * Special properties::          Access to other Org mode features
4313 * Property searches::           Matching property values
4314 * Property inheritance::        Passing values down the tree
4315 * Column view::                 Tabular viewing and editing
4316 * Property API::                Properties for Lisp programmers
4317 @end menu
4319 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
4320 @section Property syntax
4321 @cindex property syntax
4322 @cindex drawer, for properties
4324 Properties are key-value pairs.  They need to be inserted into a special
4325 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
4326 is specified on a single line, with the key (surrounded by colons)
4327 first, and the value after it.  Here is an example:
4329 @example
4330 * CD collection
4331 ** Classic
4332 *** Goldberg Variations
4333     :PROPERTIES:
4334     :Title:     Goldberg Variations
4335     :Composer:  J.S. Bach
4336     :Artist:    Glen Gould
4337     :Publisher: Deutsche Grammophon
4338     :NDisks:    1
4339     :END:
4340 @end example
4342 You may define the allowed values for a particular property @samp{:Xyz:}
4343 by setting a property @samp{:Xyz_ALL:}.  This special property is
4344 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
4345 the entire tree.  When allowed values are defined, setting the
4346 corresponding property becomes easier and is less prone to typing
4347 errors.  For the example with the CD collection, we can predefine
4348 publishers and the number of disks in a box like this:
4350 @example
4351 * CD collection
4352   :PROPERTIES:
4353   :NDisks_ALL:  1 2 3 4
4354   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
4355   :END:
4356 @end example
4358 If you want to set properties that can be inherited by any entry in a
4359 file, use a line like
4360 @cindex property, _ALL
4361 @cindex #+PROPERTY
4362 @example
4363 #+PROPERTY: NDisks_ALL 1 2 3 4
4364 @end example
4366 @vindex org-global-properties
4367 Property values set with the global variable
4368 @code{org-global-properties} can be inherited by all entries in all
4369 Org files.
4371 @noindent
4372 The following commands help to work with properties:
4374 @table @kbd
4375 @kindex M-@key{TAB}
4376 @item M-@key{TAB}
4377 After an initial colon in a line, complete property keys.  All keys used
4378 in the current file will be offered as possible completions.
4379 @kindex C-c C-x p
4380 @item C-c C-x p
4381 Set a property.  This prompts for a property name and a value.  If
4382 necessary, the property drawer is created as well.
4383 @item M-x org-insert-property-drawer
4384 Insert a property drawer into the current entry.  The drawer will be
4385 inserted early in the entry, but after the lines with planning
4386 information like deadlines.
4387 @kindex C-c C-c
4388 @item C-c C-c
4389 With the cursor in a property drawer, this executes property commands.
4390 @item C-c C-c s
4391 Set a property in the current entry.  Both the property and the value
4392 can be inserted using completion.
4393 @kindex S-@key{right}
4394 @kindex S-@key{left}
4395 @item S-@key{left}/@key{right}
4396 Switch property at point to the next/previous allowed value.
4397 @item C-c C-c d
4398 Remove a property from the current entry.
4399 @item C-c C-c D
4400 Globally remove a property, from all entries in the current file.
4401 @item C-c C-c c
4402 Compute the property at point, using the operator and scope from the
4403 nearest column format definition.
4404 @end table
4406 @node Special properties, Property searches, Property syntax, Properties and Columns
4407 @section Special properties
4408 @cindex properties, special
4410 Special properties provide an alternative access method to Org mode
4411 features, like the TODO state or the priority of an entry, discussed in the
4412 previous chapters.  This interface exists so that you can include
4413 these states in a column view (@pxref{Column view}), or to use them in
4414 queries.  The following property names are special and should not be
4415 used as keys in the properties drawer:
4417 @cindex property, special, TODO
4418 @cindex property, special, TAGS
4419 @cindex property, special, ALLTAGS
4420 @cindex property, special, CATEGORY
4421 @cindex property, special, PRIORITY
4422 @cindex property, special, DEADLINE
4423 @cindex property, special, SCHEDULED
4424 @cindex property, special, CLOSED
4425 @cindex property, special, TIMESTAMP
4426 @cindex property, special, TIMESTAMP_IA
4427 @cindex property, special, CLOCKSUM
4428 @c guessing that ITEM is needed in this area; also, should this list be sorted?
4429 @cindex property, special, ITEM
4430 @example
4431 TODO         @r{The TODO keyword of the entry.}
4432 TAGS         @r{The tags defined directly in the headline.}
4433 ALLTAGS      @r{All tags, including inherited ones.}
4434 CATEGORY     @r{The category of an entry.}
4435 PRIORITY     @r{The priority of the entry, a string with a single letter.}
4436 DEADLINE     @r{The deadline time string, without the angular brackets.}
4437 SCHEDULED    @r{The scheduling timestamp, without the angular brackets.}
4438 CLOSED       @r{When was this entry closed?}
4439 TIMESTAMP    @r{The first keyword-less timestamp in the entry.}
4440 TIMESTAMP_IA @r{The first inactive timestamp in the entry.}
4441 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
4442              @r{must be run first to compute the values.}
4443 ITEM         @r{The content of the entry.}
4444 @end example
4446 @node Property searches, Property inheritance, Special properties, Properties and Columns
4447 @section Property searches
4448 @cindex properties, searching
4449 @cindex searching, of properties
4451 To create sparse trees and special lists with selection based on properties,
4452 the same commands are used as for tag searches (@pxref{Tag searches}).
4453 @table @kbd
4454 @kindex C-c \
4455 @kindex C-c / m
4456 @item C-c \
4457 @itemx C-c / m
4458 Create a sparse tree with all matching entries.  With a
4459 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4460 @kindex C-c a m
4461 @item C-c a m
4462 Create a global list of tag/property  matches from all agenda files.
4463 @xref{Matching tags and properties}.
4464 @kindex C-c a M
4465 @item C-c a M
4466 @vindex org-tags-match-list-sublevels
4467 Create a global list of tag matches from all agenda files, but check
4468 only TODO items and force checking of subitems (see variable
4469 @code{org-tags-match-list-sublevels}).
4470 @end table
4472 The syntax for the search string is described in @ref{Matching tags and
4473 properties}.
4475 There is also a special command for creating sparse trees based on a
4476 single property:
4478 @table @kbd
4479 @kindex C-c / p
4480 @item C-c / p
4481 Create a sparse tree based on the value of a property.  This first
4482 prompts for the name of a property, and then for a value.  A sparse tree
4483 is created with all entries that define this property with the given
4484 value.  If you enclose the value into curly braces, it is interpreted as
4485 a regular expression and matched against the property values.
4486 @end table
4488 @node Property inheritance, Column view, Property searches, Properties and Columns
4489 @section Property Inheritance
4490 @cindex properties, inheritance
4491 @cindex inheritance, of properties
4493 @vindex org-use-property-inheritance
4494 The outline structure of Org-mode documents lends itself for an
4495 inheritance model of properties: if the parent in a tree has a certain
4496 property, the children can inherit this property.  Org mode does not
4497 turn this on by default, because it can slow down property searches
4498 significantly and is often not needed.  However, if you find inheritance
4499 useful, you can turn it on by setting the variable
4500 @code{org-use-property-inheritance}.  It may be set to @code{t} to make
4501 all properties inherited from the parent, to a list of properties
4502 that should be inherited, or to a regular expression that matches
4503 inherited properties.
4505 Org mode has a few properties for which inheritance is hard-coded, at
4506 least for the special applications for which they are used:
4508 @cindex property, COLUMNS
4509 @table @code
4510 @item COLUMNS
4511 The @code{:COLUMNS:} property defines the format of column view
4512 (@pxref{Column view}).  It is inherited in the sense that the level
4513 where a @code{:COLUMNS:} property is defined is used as the starting
4514 point for a column view table, independently of the location in the
4515 subtree from where columns view is turned on.
4516 @item CATEGORY
4517 @cindex property, CATEGORY
4518 For agenda view, a category set through a @code{:CATEGORY:} property
4519 applies to the entire subtree.
4520 @item ARCHIVE
4521 @cindex property, ARCHIVE
4522 For archiving, the @code{:ARCHIVE:} property may define the archive
4523 location for the entire subtree (@pxref{Moving subtrees}).
4524 @item LOGGING
4525 @cindex property, LOGGING
4526 The LOGGING property may define logging settings for an entry or a
4527 subtree (@pxref{Tracking TODO state changes}).
4528 @end table
4530 @node Column view, Property API, Property inheritance, Properties and Columns
4531 @section Column view
4533 A great way to view and edit properties in an outline tree is
4534 @emph{column view}.  In column view, each outline node is turned into a
4535 table row.  Columns in this table provide access to properties of the
4536 entries.  Org mode implements columns by overlaying a tabular structure
4537 over the headline of each item.  While the headlines have been turned
4538 into a table row, you can still change the visibility of the outline
4539 tree.  For example, you get a compact table by switching to CONTENTS
4540 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
4541 is active), but you can still open, read, and edit the entry below each
4542 headline.  Or, you can switch to column view after executing a sparse
4543 tree command and in this way get a table only for the selected items.
4544 Column view also works in agenda buffers (@pxref{Agenda Views}) where
4545 queries have collected selected items, possibly from a number of files.
4547 @menu
4548 * Defining columns::            The COLUMNS format property
4549 * Using column view::           How to create and use column view
4550 * Capturing column view::       A dynamic block for column view
4551 @end menu
4553 @node Defining columns, Using column view, Column view, Column view
4554 @subsection Defining columns
4555 @cindex column view, for properties
4556 @cindex properties, column view
4558 Setting up a column view first requires defining the columns.  This is
4559 done by defining a column format line.
4561 @menu
4562 * Scope of column definitions::  Where defined, where valid?
4563 * Column attributes::           Appearance and content of a column
4564 @end menu
4566 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
4567 @subsubsection Scope of column definitions
4569 To define a column format for an entire file, use a line like
4571 @cindex #+COLUMNS
4572 @example
4573 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4574 @end example
4576 To specify a format that only applies to a specific tree, add a
4577 @code{:COLUMNS:} property to the top node of that tree, for example:
4579 @example
4580 ** Top node for columns view
4581    :PROPERTIES:
4582    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4583    :END:
4584 @end example
4586 If a @code{:COLUMNS:} property is present in an entry, it defines columns
4587 for the entry itself, and for the entire subtree below it.  Since the
4588 column definition is part of the hierarchical structure of the document,
4589 you can define columns on level 1 that are general enough for all
4590 sublevels, and more specific columns further down, when you edit a
4591 deeper part of the tree.
4593 @node Column attributes,  , Scope of column definitions, Defining columns
4594 @subsubsection Column attributes
4595 A column definition sets the attributes of a column.  The general
4596 definition looks like this:
4598 @example
4599  %[@var{width}]@var{property}[(@var{title})][@{@var{summary-type}@}]
4600 @end example
4602 @noindent
4603 Except for the percent sign and the property name, all items are
4604 optional.  The individual parts have the following meaning:
4606 @example
4607 @var{width}           @r{An integer specifying the width of the column in characters.}
4608                 @r{If omitted, the width will be determined automatically.}
4609 @var{property}        @r{The property that should be edited in this column.}
4610 (title)         @r{The header text for the column. If omitted, the}
4611                 @r{property name is used.}
4612 @{@var{summary-type}@}  @r{The summary type.  If specified, the column values for}
4613                 @r{parent nodes are computed from the children.}
4614                 @r{Supported summary types are:}
4615                 @{+@}       @r{Sum numbers in this column.}
4616                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
4617                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
4618                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
4619                 @{X@}       @r{Checkbox status, @samp{[X]} if all children are @samp{[X]}.}
4620                 @{X/@}      @r{Checkbox status, @samp{[n/m]}.}
4621                 @{X%@}      @r{Checkbox status, @samp{[n%]}.}
4622                 @{min@}     @r{Smallest number in column.}
4623                 @{max@}     @r{Largest number.}
4624                 @{mean@}    @r{Arithmetic mean of numbers.}
4625                 @{:min@}    @r{Smallest time value in column.}
4626                 @{:max@}    @r{Largest time value.}
4627                 @{:mean@}   @r{Arithmetic mean of time values.}
4628 @end example
4630 @noindent
4631 Here is an example for a complete columns definition, along with allowed
4632 values.
4634 @example
4635 :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.}
4636                    %10Time_Estimate@{:@} %CLOCKSUM
4637 :Owner_ALL:    Tammy Mark Karl Lisa Don
4638 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
4639 :Approved_ALL: "[ ]" "[X]"
4640 @end example
4642 @noindent
4643 The first column, @samp{%25ITEM}, means the first 25 characters of the
4644 item itself, @ie of the headline.  You probably always should start the
4645 column definition with the @samp{ITEM} specifier.  The other specifiers
4646 create columns @samp{Owner} with a list of names as allowed values, for
4647 @samp{Status} with four different possible values, and for a checkbox
4648 field @samp{Approved}.  When no width is given after the @samp{%}
4649 character, the column will be exactly as wide as it needs to be in order
4650 to fully display all values.  The @samp{Approved} column does have a
4651 modified title (@samp{Approved?}, with a question mark).  Summaries will
4652 be created for the @samp{Time_Estimate} column by adding time duration
4653 expressions like HH:MM, and for the @samp{Approved} column, by providing
4654 an @samp{[X]} status if all children have been checked.  The
4655 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
4656 in the subtree.
4658 @node Using column view, Capturing column view, Defining columns, Column view
4659 @subsection Using column view
4661 @table @kbd
4662 @tsubheading{Turning column view on and off}
4663 @kindex C-c C-x C-c
4664 @item C-c C-x C-c
4665 @vindex org-columns-default-format
4666 Turn on column view.  If the cursor is before the first headline in the file,
4667 column view is turned on for the entire file, using the @code{#+COLUMNS}
4668 definition.  If the cusor is somewhere inside the outline, this command
4669 searches the hierarchy, up from point, for a @code{:COLUMNS:} property that
4670 defines a format.  When one is found, the column view table is established
4671 for the tree starting at the entry that contains the @code{:COLUMNS:}
4672 property.  If no such property is found, the format is taken from the
4673 @code{#+COLUMNS} line or from the variable @code{org-columns-default-format},
4674 and column view is established for the current entry and its subtree.
4675 @kindex r
4676 @item r
4677 Recreate the column view, to include recent changes made in the buffer.
4678 @kindex g
4679 @item g
4680 Same as @kbd{r}.
4681 @kindex q
4682 @item q
4683 Exit column view.
4684 @tsubheading{Editing values}
4685 @item @key{left} @key{right} @key{up} @key{down}
4686 Move through the column view from field to field.
4687 @kindex S-@key{left}
4688 @kindex S-@key{right}
4689 @item  S-@key{left}/@key{right}
4690 Switch to the next/previous allowed value of the field.  For this, you
4691 have to have specified allowed values for a property.
4692 @item 1..9,0
4693 Directly select the nth allowed value, @kbd{0} selects the 10th value.
4694 @kindex n
4695 @kindex p
4696 @itemx  n / p
4697 Same as @kbd{S-@key{left}/@key{right}}
4698 @kindex e
4699 @item e
4700 Edit the property at point.  For the special properties, this will
4701 invoke the same interface that you normally use to change that
4702 property.  For example, when editing a TAGS property, the tag completion
4703 or fast selection interface will pop up.
4704 @kindex C-c C-c
4705 @item C-c C-c
4706 When there is a checkbox at point, toggle it.
4707 @kindex v
4708 @item v
4709 View the full value of this property.  This is useful if the width of
4710 the column is smaller than that of the value.
4711 @kindex a
4712 @item a
4713 Edit the list of allowed values for this property.  If the list is found
4714 in the hierarchy, the modified values is stored there.  If no list is
4715 found, the new value is stored in the first entry that is part of the
4716 current column view.
4717 @tsubheading{Modifying the table structure}
4718 @kindex <
4719 @kindex >
4720 @item < / >
4721 Make the column narrower/wider by one character.
4722 @kindex S-M-@key{right}
4723 @item S-M-@key{right}
4724 Insert a new column, to the left of the current column.
4725 @kindex S-M-@key{left}
4726 @item S-M-@key{left}
4727 Delete the current column.
4728 @end table
4730 @node Capturing column view,  , Using column view, Column view
4731 @subsection Capturing column view
4733 Since column view is just an overlay over a buffer, it cannot be
4734 exported or printed directly.  If you want to capture a column view, use
4735 a @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
4736 of this block looks like this:
4738 @cindex #+BEGIN, columnview
4739 @example
4740 * The column view
4741 #+BEGIN: columnview :hlines 1 :id "label"
4743 #+END:
4744 @end example
4746 @noindent This dynamic block has the following parameters:
4748 @table @code
4749 @item :id
4750 This is the most important parameter.  Column view is a feature that is
4751 often localized to a certain (sub)tree, and the capture block might be
4752 at a different location in the file.  To identify the tree whose view to
4753 capture, you can use 4 values:
4754 @cindex property, ID
4755 @example
4756 local     @r{use the tree in which the capture block is located}
4757 global    @r{make a global view, including all headings in the file}
4758 "file:@var{path-to-file}"
4759           @r{run column view at the top of this file}
4760 "@var{ID}"      @r{call column view in the tree that has an @code{:ID:}}
4761           @r{property with the value @i{label}.  You can use}
4762           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
4763           @r{the current entry and copy it to the kill-ring.}
4764 @end example
4765 @item :hlines
4766 When @code{t}, insert an hline after every line.  When a number @var{N}, insert
4767 an hline before each headline with level @code{<= @var{N}}.
4768 @item :vlines
4769 When set to @code{t}, force column groups to get vertical lines.
4770 @item :maxlevel
4771 When set to a number, don't capture entries below this level.
4772 @item :skip-empty-rows
4773 When set to @code{t}, skip rows where the only non-empty specifier of the
4774 column view is @code{ITEM}.
4776 @end table
4778 @noindent
4779 The following commands insert or update the dynamic block:
4781 @table @kbd
4782 @kindex C-c C-x i
4783 @item C-c C-x i
4784 Insert a dynamic block capturing a column view.  You will be prompted
4785 for the scope or ID of the view.
4786 @kindex C-c C-c
4787 @item C-c C-c
4788 @kindex C-c C-x C-u
4789 @itemx C-c C-x C-u
4790 Update dynamic block at point.  The cursor needs to be in the
4791 @code{#+BEGIN} line of the dynamic block.
4792 @kindex C-u C-c C-x C-u
4793 @item C-u C-c C-x C-u
4794 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4795 you have several clock table blocks in a buffer.
4796 @end table
4798 You can add formulas to the column view table and you may add plotting
4799 instructions in front of the table---these will survive an update of the
4800 block.  If there is a @code{#+TBLFM:} after the table, the table will
4801 actually be recalculated automatically after an update.
4803 An alternative way to capture and process property values into a table is
4804 provided by Eric Schulte's @file{org-collector.el} which is a contributed
4805 package@footnote{Contributed packages are not part of Emacs, but are
4806 distributed with the main distribution of Org (visit
4807 @uref{http://orgmode.org}).}.  It provides a general API to collect
4808 properties from entries in a certain scope, and arbitrary Lisp expressions to
4809 process these values before inserting them into a table or a dynamic block.
4811 @node Property API,  , Column view, Properties and Columns
4812 @section The Property API
4813 @cindex properties, API
4814 @cindex API, for properties
4816 There is a full API for accessing and changing properties.  This API can
4817 be used by Emacs Lisp programs to work with properties and to implement
4818 features based on them.  For more information see @ref{Using the
4819 property API}.
4821 @node Dates and Times, Capture, Properties and Columns, Top
4822 @chapter Dates and Times
4823 @cindex dates
4824 @cindex times
4825 @cindex timestamp
4826 @cindex date stamp
4828 To assist project planning, TODO items can be labeled with a date and/or
4829 a time.  The specially formatted string carrying the date and time
4830 information is called a @emph{timestamp} in Org mode.  This may be a
4831 little confusing because timestamp is often used as indicating when
4832 something was created or last changed.  However, in Org mode this term
4833 is used in a much wider sense.
4835 @menu
4836 * Timestamps::                  Assigning a time to a tree entry
4837 * Creating timestamps::         Commands which insert timestamps
4838 * Deadlines and scheduling::    Planning your work
4839 * Clocking work time::          Tracking how long you spend on a task
4840 * Effort estimates::            Planning work effort in advance
4841 * Relative timer::              Notes with a running timer
4842 @end menu
4845 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4846 @section Timestamps, deadlines, and scheduling
4847 @cindex timestamps
4848 @cindex ranges, time
4849 @cindex date stamps
4850 @cindex deadlines
4851 @cindex scheduling
4853 A timestamp is a specification of a date (possibly with a time or a range
4854 of times) in a special format, either @samp{<2003-09-16 Tue>} or
4855 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4856 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
4857 use an alternative format, see @ref{Custom time format}.}.  A timestamp
4858 can appear anywhere in the headline or body of an Org tree entry.  Its
4859 presence causes entries to be shown on specific dates in the agenda
4860 (@pxref{Weekly/daily agenda}).  We distinguish:
4862 @table @var
4863 @item Plain timestamp; Event; Appointment
4864 @cindex timestamp
4865 A simple timestamp just assigns a date/time to an item.  This is just
4866 like writing down an appointment or event in a paper agenda.  In the
4867 timeline and agenda displays, the headline of an entry associated with a
4868 plain timestamp will be shown exactly on that date.
4870 @example
4871 * Meet Peter at the movies <2006-11-01 Wed 19:15>
4872 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
4873 @end example
4875 @item Timestamp with repeater interval
4876 @cindex timestamp, with repeater interval
4877 A timestamp may contain a @emph{repeater interval}, indicating that it
4878 applies not only on the given date, but again and again after a certain
4879 interval of N days (d), weeks (w), months (m), or years (y).  The
4880 following will show up in the agenda every Wednesday:
4882 @example
4883 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4884 @end example
4886 @item Diary-style sexp entries
4887 For more complex date specifications, Org mode supports using the
4888 special sexp diary entries implemented in the Emacs calendar/diary
4889 package.  For example
4891 @example
4892 * The nerd meeting on every 2nd Thursday of the month
4893   <%%(diary-float t 4 2)>
4894 @end example
4896 @item Time/Date range
4897 @cindex timerange
4898 @cindex date range
4899 Two timestamps connected by @samp{--} denote a range.  The headline
4900 will be shown on the first and last day of the range, and on any dates
4901 that are displayed and fall in the range.  Here is an example:
4903 @example
4904 ** Meeting in Amsterdam
4905    <2004-08-23 Mon>--<2004-08-26 Thu>
4906 @end example
4908 @item Inactive timestamp
4909 @cindex timestamp, inactive
4910 @cindex inactive timestamp
4911 Just like a plain timestamp, but with square brackets instead of
4912 angular ones.  These timestamps are inactive in the sense that they do
4913 @emph{not} trigger an entry to show up in the agenda.
4915 @example
4916 * Gillian comes late for the fifth time [2006-11-01 Wed]
4917 @end example
4919 @end table
4921 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
4922 @section Creating timestamps
4923 @cindex creating timestamps
4924 @cindex timestamps, creating
4926 For Org mode to recognize timestamps, they need to be in the specific
4927 format.  All commands listed below produce timestamps in the correct
4928 format.
4930 @table @kbd
4931 @kindex C-c .
4932 @item C-c .
4933 Prompt for a date and insert a corresponding timestamp.  When the cursor is
4934 at an existing timestamp in the buffer, the command is used to modify this
4935 timestamp instead of inserting a new one.  When this command is used twice in
4936 succession, a time range is inserted.
4938 @kindex C-c !
4939 @item C-c !
4940 Like @kbd{C-c .}, but insert an inactive timestamp that will not cause
4941 an agenda entry.
4943 @kindex C-u C-c .
4944 @kindex C-u C-c !
4945 @item C-u C-c .
4946 @itemx C-u C-c !
4947 @vindex org-time-stamp-rounding-minutes
4948 Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
4949 contains date and time.  The default time can be rounded to multiples of 5
4950 minutes, see the option @code{org-time-stamp-rounding-minutes}.
4952 @kindex C-c <
4953 @item C-c <
4954 Insert a timestamp corresponding to the cursor date in the Calendar.
4956 @kindex C-c >
4957 @item C-c >
4958 Access the Emacs calendar for the current date.  If there is a
4959 timestamp in the current line, go to the corresponding date
4960 instead.
4962 @kindex C-c C-o
4963 @item C-c C-o
4964 Access the agenda for the date given by the timestamp or -range at
4965 point (@pxref{Weekly/daily agenda}).
4967 @kindex S-@key{left}
4968 @kindex S-@key{right}
4969 @item S-@key{left}
4970 @itemx S-@key{right}
4971 Change date at cursor by one day.  These key bindings conflict with
4972 shift-selection and related modes (@pxref{Conflicts}).
4974 @kindex S-@key{up}
4975 @kindex S-@key{down}
4976 @item S-@key{up}
4977 @itemx S-@key{down}
4978 Change the item under the cursor in a timestamp.  The cursor can be on a
4979 year, month, day, hour or minute.  When the timestamp contains a time range
4980 like @samp{15:30-16:30}, modifying the first time will also shift the second,
4981 shifting the time block with constant length.  To change the length, modify
4982 the second time.  Note that if the cursor is in a headline and not at a
4983 timestamp, these same keys modify the priority of an item.
4984 (@pxref{Priorities}). The key bindings also conflict with shift-selection and
4985 related modes (@pxref{Conflicts}).
4987 @kindex C-c C-y
4988 @cindex evaluate time range
4989 @item C-c C-y
4990 Evaluate a time range by computing the difference between start and end.
4991 With a prefix argument, insert result after the time range (in a table: into
4992 the following column).
4993 @end table
4996 @menu
4997 * The date/time prompt::        How Org mode helps you entering date and time
4998 * Custom time format::          Making dates look different
4999 @end menu
5001 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
5002 @subsection The date/time prompt
5003 @cindex date, reading in minibuffer
5004 @cindex time, reading in minibuffer
5006 @vindex org-read-date-prefer-future
5007 When Org mode prompts for a date/time, the default is shown as an ISO
5008 date, and the prompt therefore seems to ask for an ISO date.  But it
5009 will in fact accept any string containing some date and/or time
5010 information, and it is really smart about interpreting your input.  You
5011 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
5012 copied from an email message.  Org mode will find whatever information
5013 is in there and derive anything you have not specified from the
5014 @emph{default date and time}.  The default is usually the current date
5015 and time, but when modifying an existing timestamp, or when entering
5016 the second stamp of a range, it is taken from the stamp in the buffer.
5017 When filling in information, Org mode assumes that most of the time you
5018 will want to enter a date in the future: if you omit the month/year and
5019 the given day/month is @i{before} today, it will assume that you mean a
5020 future date@footnote{See the variable
5021 @code{org-read-date-prefer-future}.}.
5023 For example, let's assume that today is @b{June 13, 2006}.  Here is how
5024 various inputs will be interpreted, the items filled in by Org mode are
5025 in @b{bold}.
5027 @example
5028 3-2-5         --> 2003-02-05
5029 14            --> @b{2006}-@b{06}-14
5030 12            --> @b{2006}-@b{07}-12
5031 Fri           --> nearest Friday (defaultdate or later)
5032 sep 15        --> @b{2006}-09-15
5033 feb 15        --> @b{2007}-02-15
5034 sep 12 9      --> 2009-09-12
5035 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
5036 22 sept 0:34  --> @b{2006}-09-22 0:34
5037 w4            --> ISO week for of the current year @b{2006}
5038 2012 w4 fri   --> Friday of ISO week 4 in 2012
5039 2012-w04-5    --> Same as above
5040 @end example
5042 Furthermore you can specify a relative date by giving, as the
5043 @emph{first} thing in the input: a plus/minus sign, a number and a
5044 letter ([dwmy]) to indicate change in days, weeks, months, or years.  With a
5045 single plus or minus, the date is always relative to today.  With a
5046 double plus or minus, it is relative to the default date.  If instead of
5047 a single letter, you use the abbreviation of day name, the date will be
5048 the nth such day.  @Eg
5050 @example
5051 +0            --> today
5052 .             --> today
5053 +4d           --> four days from today
5054 +4            --> same as above
5055 +2w           --> two weeks from today
5056 ++5           --> five days from default date
5057 +2tue         --> second Tuesday from now.
5058 @end example
5060 @vindex parse-time-months
5061 @vindex parse-time-weekdays
5062 The function understands English month and weekday abbreviations.  If
5063 you want to use unabbreviated names and/or other languages, configure
5064 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
5066 @cindex calendar, for selecting date
5067 @vindex org-popup-calendar-for-date-prompt
5068 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
5069 you don't need/want the calendar, configure the variable
5070 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
5071 prompt, either by clicking on a date in the calendar, or by pressing
5072 @key{RET}, the date selected in the calendar will be combined with the
5073 information entered at the prompt.  You can control the calendar fully
5074 from the minibuffer:
5076 @kindex <
5077 @kindex >
5078 @kindex mouse-1
5079 @kindex S-@key{right}
5080 @kindex S-@key{left}
5081 @kindex S-@key{down}
5082 @kindex S-@key{up}
5083 @kindex M-S-@key{right}
5084 @kindex M-S-@key{left}
5085 @kindex @key{RET}
5086 @example
5087 > / <          @r{Scroll calendar forward/backward by one month.}
5088 mouse-1        @r{Select date by clicking on it.}
5089 S-@key{right}/@key{left}     @r{One day forward/backward.}
5090 S-@key{down}/@key{up}     @r{One week forward/backward.}
5091 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
5092 @key{RET}           @r{Choose date in calendar.}
5093 @end example
5095 @vindex org-read-date-display-live
5096 The actions of the date/time prompt may seem complex, but I assure you they
5097 will grow on you, and you will start getting annoyed by pretty much any other
5098 way of entering a date/time out there.  To help you understand what is going
5099 on, the current interpretation of your input will be displayed live in the
5100 minibuffer@footnote{If you find this distracting, turn the display of with
5101 @code{org-read-date-display-live}.}.
5103 @node Custom time format,  , The date/time prompt, Creating timestamps
5104 @subsection Custom time format
5105 @cindex custom date/time format
5106 @cindex time format, custom
5107 @cindex date format, custom
5109 @vindex org-display-custom-times
5110 @vindex org-time-stamp-custom-formats
5111 Org mode uses the standard ISO notation for dates and times as it is
5112 defined in ISO 8601.  If you cannot get used to this and require another
5113 representation of date and time to keep you happy, you can get it by
5114 customizing the variables @code{org-display-custom-times} and
5115 @code{org-time-stamp-custom-formats}.
5117 @table @kbd
5118 @kindex C-c C-x C-t
5119 @item C-c C-x C-t
5120 Toggle the display of custom formats for dates and times.
5121 @end table
5123 @noindent
5124 Org mode needs the default format for scanning, so the custom date/time
5125 format does not @emph{replace} the default format---instead it is put
5126 @emph{over} the default format using text properties.  This has the
5127 following consequences:
5128 @itemize @bullet
5129 @item
5130 You cannot place the cursor onto a timestamp anymore, only before or
5131 after.
5132 @item
5133 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
5134 each component of a timestamp.  If the cursor is at the beginning of
5135 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
5136 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
5137 time will be changed by one minute.
5138 @item
5139 If the timestamp contains a range of clock times or a repeater, these
5140 will not be overlayed, but remain in the buffer as they were.
5141 @item
5142 When you delete a timestamp character-by-character, it will only
5143 disappear from the buffer after @emph{all} (invisible) characters
5144 belonging to the ISO timestamp have been removed.
5145 @item
5146 If the custom timestamp format is longer than the default and you are
5147 using dates in tables, table alignment will be messed up.  If the custom
5148 format is shorter, things do work as expected.
5149 @end itemize
5152 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
5153 @section Deadlines and scheduling
5155 A timestamp may be preceded by special keywords to facilitate planning:
5157 @table @var
5158 @item DEADLINE
5159 @cindex DEADLINE keyword
5161 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
5162 to be finished on that date.
5164 @vindex org-deadline-warning-days
5165 On the deadline date, the task will be listed in the agenda.  In
5166 addition, the agenda for @emph{today} will carry a warning about the
5167 approaching or missed deadline, starting
5168 @code{org-deadline-warning-days} before the due date, and continuing
5169 until the entry is marked DONE.  An example:
5171 @example
5172 *** TODO write article about the Earth for the Guide
5173     The editor in charge is [[bbdb:Ford Prefect]]
5174     DEADLINE: <2004-02-29 Sun>
5175 @end example
5177 You can specify a different lead time for warnings for a specific
5178 deadlines using the following syntax.  Here is an example with a warning
5179 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
5181 @item SCHEDULED
5182 @cindex SCHEDULED keyword
5184 Meaning: you are planning to start working on that task on the given
5185 date.
5187 @vindex org-agenda-skip-scheduled-if-done
5188 The headline will be listed under the given date@footnote{It will still
5189 be listed on that date after it has been marked DONE.  If you don't like
5190 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
5191 addition, a reminder that the scheduled date has passed will be present
5192 in the compilation for @emph{today}, until the entry is marked DONE.
5193 @Ie the task will automatically be forwarded until completed.
5195 @example
5196 *** TODO Call Trillian for a date on New Years Eve.
5197     SCHEDULED: <2004-12-25 Sat>
5198 @end example
5200 @noindent
5201 @b{Important:} Scheduling an item in Org mode should @i{not} be
5202 understood in the same way that we understand @i{scheduling a meeting}.
5203 Setting a date for a meeting is just a simple appointment, you should
5204 mark this entry with a simple plain timestamp, to get this item shown
5205 on the date where it applies.  This is a frequent misunderstanding by
5206 Org users.  In Org mode, @i{scheduling} means setting a date when you
5207 want to start working on an action item.
5208 @end table
5210 You may use timestamps with repeaters in scheduling and deadline
5211 entries.  Org mode will issue early and late warnings based on the
5212 assumption that the timestamp represents the @i{nearest instance} of
5213 the repeater.  However, the use of diary sexp entries like
5215 @code{<%%(diary-float t 42)>}
5217 in scheduling and deadline timestamps is limited.  Org mode does not
5218 know enough about the internals of each sexp function to issue early and
5219 late warnings.  However, it will show the item on each day where the
5220 sexp entry matches.
5222 @menu
5223 * Inserting deadline/schedule::  Planning items
5224 * Repeated tasks::              Items that show up again and again
5225 @end menu
5227 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
5228 @subsection Inserting deadlines or schedules
5230 The following commands allow you to quickly insert a deadline or to schedule
5231 an item:
5233 @table @kbd
5235 @kindex C-c C-d
5236 @item C-c C-d
5237 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
5238 happen in the line directly following the headline.  When called with a
5239 prefix arg, an existing deadline will be removed from the entry.
5240 @c FIXME Any CLOSED timestamp will be removed.????????
5242 @kindex C-c C-s
5243 @item C-c C-s
5244 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
5245 happen in the line directly following the headline.  Any CLOSED
5246 timestamp will be removed.  When called with a prefix argument, remove
5247 the scheduling date from the entry.
5249 @kindex C-c C-x C-k
5250 @kindex k a
5251 @kindex k s
5252 @item C-c C-x C-k
5253 Mark the current entry for agenda action.  After you have marked the entry
5254 like this, you can open the agenda or the calendar to find an appropriate
5255 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
5256 schedule the marked item.
5258 @kindex C-c / d
5259 @cindex sparse tree, for deadlines
5260 @item C-c / d
5261 @vindex org-deadline-warning-days
5262 Create a sparse tree with all deadlines that are either past-due, or
5263 which will become due within @code{org-deadline-warning-days}.
5264 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
5265 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
5266 all deadlines due tomorrow.
5268 @kindex C-c / b
5269 @item C-c / b
5270 Sparse tree for deadlines and scheduled items before a given date.
5272 @kindex C-c / a
5273 @item C-c / a
5274 Sparse tree for deadlines and scheduled items after a given date.
5275 @end table
5277 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
5278 @subsection Repeated tasks
5279 @cindex tasks, repeated
5280 @cindex repeated tasks
5282 Some tasks need to be repeated again and again.  Org mode helps to
5283 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
5284 or plain timestamp.  In the following example
5285 @example
5286 ** TODO Pay the rent
5287    DEADLINE: <2005-10-01 Sat +1m>
5288 @end example
5289 @noindent
5290 the @code{+1m} is a repeater; the intended interpretation is that the task
5291 has a deadline on <2005-10-01> and repeats itself every (one) month starting
5292 from that time.  If you need both a repeater and a special warning period in
5293 a deadline entry, the repeater should come first and the warning period last:
5294 @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
5296 Deadlines and scheduled items produce entries in the agenda when they
5297 are over-due, so it is important to be able to mark such an entry as
5298 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
5299 with the TODO keyword DONE, it will no longer produce entries in the
5300 agenda.  The problem with this is, however, that then also the
5301 @emph{next} instance of the repeated entry will not be active.  Org mode
5302 deals with this in the following way: When you try to mark such an entry
5303 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
5304 timestamp by the repeater interval, and immediately set the entry state
5305 back to TODO.  In the example above, setting the state to DONE would
5306 actually switch the date like this:
5308 @example
5309 ** TODO Pay the rent
5310    DEADLINE: <2005-11-01 Tue +1m>
5311 @end example
5313 @vindex org-log-repeat
5314 A timestamp@footnote{You can change this using the option
5315 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
5316 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
5317 will also be prompted for a note.} will be added under the deadline, to keep
5318 a record that you actually acted on the previous instance of this deadline.
5320 As a consequence of shifting the base date, this entry will no longer be
5321 visible in the agenda when checking past dates, but all future instances
5322 will be visible.
5324 With the @samp{+1m} cookie, the date shift will always be exactly one
5325 month.  So if you have not paid the rent for three months, marking this
5326 entry DONE will still keep it as an overdue deadline.  Depending on the
5327 task, this may not be the best way to handle it.  For example, if you
5328 forgot to call you father for 3 weeks, it does not make sense to call
5329 him 3 times in a single day to make up for it.  Finally, there are tasks
5330 like changing batteries which should always repeat a certain time
5331 @i{after} the last time you did it.  For these tasks, Org mode has
5332 special repeaters markers with @samp{++} and @samp{.+}.  For example:
5334 @example
5335 ** TODO Call Father
5336    DEADLINE: <2008-02-10 Sun ++1w>
5337    Marking this DONE will shift the date by at least one week,
5338    but also by as many weeks as it takes to get this date into
5339    the future.  However, it stays on a Sunday, even if you called
5340    and marked it done on Saturday.
5341 ** TODO Check the batteries in the smoke detectors
5342    DEADLINE: <2005-11-01 Tue .+1m>
5343    Marking this DONE will shift the date to one month after
5344    today.
5345 @end example
5347 You may have both scheduling and deadline information for a specific
5348 task---just make sure that the repeater intervals on both are the same.
5350 An alternative to using a repeater is to create a number of copies of a task
5351 subtree, with dates shifted in each copy.  The command @kbd{C-c C-x c} was
5352 created for this purpose, it is described in @ref{Structure editing}.
5355 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
5356 @section Clocking work time
5358 Org mode allows you to clock the time you spend on specific tasks in a
5359 project.  When you start working on an item, you can start the clock.
5360 When you stop working on that task, or when you mark the task done, the
5361 clock is stopped and the corresponding time interval is recorded.  It
5362 also computes the total time spent on each subtree of a project.
5364 Normally, the clock does not survive exiting and re-entering Emacs, but you
5365 can arrange for the clock information to persist across Emacs sessions with
5367 @lisp
5368 (setq org-clock-persist t)
5369 (org-clock-persistence-insinuate)
5370 @end lisp
5372 @table @kbd
5373 @kindex C-c C-x C-i
5374 @item C-c C-x C-i
5375 @vindex org-clock-into-drawer
5376 Start the clock on the current item (clock-in).  This inserts the CLOCK
5377 keyword together with a timestamp.  If this is not the first clocking of
5378 this item, the multiple CLOCK lines will be wrapped into a
5379 @code{:LOGBOOK:} drawer (see also the variable
5380 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
5381 select the task from a list of recently clocked tasks.  With two @kbd{C-u
5382 C-u} prefixes, clock into the task at point and mark it as the default task.
5383 The default task will always be available when selecting a clocking task,
5384 with letter @kbd{d}.@*
5385 @cindex property: CLOCK_MODELINE_TOTAL
5386 @cindex property: LAST_REPEAT
5387 @vindex org-clock-modeline-total
5388 While the clock is running, the current clocking time is shown in the mode
5389 line, along with the title of the task.  The clock time shown will be all
5390 time ever clocked for this task and its children.  If the task has an effort
5391 estimate (@pxref{Effort estimates}), the mode line displays the current
5392 clocking time against it@footnote{To add an effort estimate ``on the fly'',
5393 hook a function doing this to @code{org-clock-in-prepare-hook}.}  If the task
5394 is a repeating one (@pxref{Repeated tasks}), only the time since the last
5395 reset of the task @footnote{as recorded by the @code{LAST_REPEAT} property}
5396 will be shown.  More control over what time is shown can be exercised with
5397 the @code{CLOCK_MODELINE_TOTAL} property.  It may have the values
5398 @code{current} to show only the current clocking instance, @code{today} to
5399 show all time clocked on this tasks today (see also the variable
5400 @code{org-extend-today-until}), @code{all} to include all time, or
5401 @code{auto} which is the default@footnote{See also the variable
5402 @code{org-clock-modeline-total}.}.@* Clicking with @kbd{mouse-1} onto the
5403 mode line entry will pop up a menu with clocking options.
5404 @kindex C-c C-x C-o
5405 @item C-c C-x C-o
5406 @vindex org-log-note-clock-out
5407 Stop the clock (clock-out).  This inserts another timestamp at the same
5408 location where the clock was last started.  It also directly computes
5409 the resulting time in inserts it after the time range as @samp{=>
5410 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
5411 possibility to record an additional note together with the clock-out
5412 timestamp@footnote{The corresponding in-buffer setting is:
5413 @code{#+STARTUP: lognoteclock-out}}.
5414 @kindex C-c C-x C-e
5415 @item C-c C-x C-e
5416 Update the effort estimate for the current clock task.
5417 @kindex C-c C-y
5418 @kindex C-c C-c
5419 @item C-c C-y @ @ @r{or}@ @ C-c C-c
5420 Recompute the time interval after changing one of the timestamps.  This
5421 is only necessary if you edit the timestamps directly.  If you change
5422 them with @kbd{S-@key{cursor}} keys, the update is automatic.
5423 @kindex C-c C-t
5424 @item C-c C-t
5425 Changing the TODO state of an item to DONE automatically stops the clock
5426 if it is running in this same item.
5427 @kindex C-c C-x C-x
5428 @item C-c C-x C-x
5429 Cancel the current clock.  This is useful if a clock was started by
5430 mistake, or if you ended up working on something else.
5431 @kindex C-c C-x C-j
5432 @item C-c C-x C-j
5433 Jump to the entry that contains the currently running clock.  With a
5434 @kbd{C-u} prefix arg, select the target task from a list of recently clocked
5435 tasks.
5436 @kindex C-c C-x C-d
5437 @item C-c C-x C-d
5438 @vindex org-remove-highlights-with-change
5439 Display time summaries for each subtree in the current buffer.  This
5440 puts overlays at the end of each headline, showing the total time
5441 recorded under that heading, including the time of any subheadings. You
5442 can use visibility cycling to study the tree, but the overlays disappear
5443 when you change the buffer (see variable
5444 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
5445 @kindex C-c C-x C-r
5446 @item C-c C-x C-r
5447 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
5448 report as an Org-mode table into the current file.  When the cursor is
5449 at an existing clock table, just update it.  When called with a prefix
5450 argument, jump to the first clock report in the current document and
5451 update it.
5452 @cindex #+BEGIN, clocktable
5453 @example
5454 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
5455 #+END: clocktable
5456 @end example
5457 @noindent
5458 If such a block already exists at point, its content is replaced by the
5459 new table.  The @samp{BEGIN} line can specify options:
5460 @example
5461 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
5462 :emphasize   @r{When @code{t}, emphasize level one and level two items.}
5463 :scope       @r{The scope to consider.  This can be any of the following:}
5464              nil        @r{the current buffer or narrowed region}
5465              file       @r{the full current buffer}
5466              subtree    @r{the subtree where the clocktable is located}
5467              tree@var{N}      @r{the surrounding level @var{N} tree, for example @code{tree3}}
5468              tree       @r{the surrounding level 1 tree}
5469              agenda     @r{all agenda files}
5470              ("file"..) @r{scan these files}
5471              file-with-archives    @r{current file and its archives}
5472              agenda-with-archives  @r{all agenda files, including archives}
5473 :block       @r{The time block to consider.  This block is specified either}
5474              @r{absolute, or relative to the current time and may be any of}
5475              @r{these formats:}
5476              2007-12-31    @r{New year eve 2007}
5477              2007-12       @r{December 2007}
5478              2007-W50      @r{ISO-week 50 in 2007}
5479              2007          @r{the year 2007}
5480              today, yesterday, today-@var{N}          @r{a relative day}
5481              thisweek, lastweek, thisweek-@var{N}     @r{a relative week}
5482              thismonth, lastmonth, thismonth-@var{N}  @r{a relative month}
5483              thisyear, lastyear, thisyear-@var{N}     @r{a relative year}
5484              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
5485 :tstart      @r{A time string specifying when to start considering times.}
5486 :tend        @r{A time string specifying when to stop considering times.}
5487 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
5488              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
5489 :link        @r{Link the item headlines in the table to their origins.}
5490 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
5491              @r{As a special case, @samp{:formula %} adds a column with % time.}
5492              @r{If you do not specify a formula here, any existing formula.}
5493              @r{below the clock table will survive updates and be evaluated.}
5494 :timestamp   @r{A timestamp for the entry, when available.  Look for SCHEDULED,}
5495              @r{DEADLINE, TIMESTAMP and TIMESTAMP_IA, in this order.}
5496 @end example
5497 To get a clock summary of the current level 1 tree, for the current
5498 day, you could write
5499 @example
5500 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
5501 #+END: clocktable
5502 @end example
5503 @noindent
5504 and to use a specific time range you could write@footnote{Note that all
5505 parameters must be specified in a single line---the line is broken here
5506 only to fit it into the manual.}
5507 @example
5508 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
5509                     :tend "<2006-08-10 Thu 12:00>"
5510 #+END: clocktable
5511 @end example
5512 A summary of the current subtree with % times would be
5513 @example
5514 #+BEGIN: clocktable :scope subtree :link t :formula %
5515 #+END: clocktable
5516 @end example
5517 @kindex C-c C-c
5518 @item C-c C-c
5519 @kindex C-c C-x C-u
5520 @itemx C-c C-x C-u
5521 Update dynamic block at point.  The cursor needs to be in the
5522 @code{#+BEGIN} line of the dynamic block.
5523 @kindex C-u C-c C-x C-u
5524 @item C-u C-c C-x C-u
5525 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
5526 you have several clock table blocks in a buffer.
5527 @kindex S-@key{left}
5528 @kindex S-@key{right}
5529 @item S-@key{left}
5530 @itemx S-@key{right}
5531 Shift the current @code{:block} interval and update the table.  The cursor
5532 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
5533 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
5534 @end table
5536 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
5537 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
5538 worked on or closed during a day.
5540 @node Effort estimates, Relative timer, Clocking work time, Dates and Times
5541 @section Effort estimates
5542 @cindex effort estimates
5544 @cindex property, Effort
5545 @vindex org-effort-property
5546 If you want to plan your work in a very detailed way, or if you need to
5547 produce offers with quotations of the estimated work effort, you may want to
5548 assign effort estimates to entries.  If you are also clocking your work, you
5549 may later want to compare the planned effort with the actual working time, a
5550 great way to improve planning estimates.  Effort estimates are stored in a
5551 special property @samp{Effort}@footnote{You may change the property being
5552 used with the variable @code{org-effort-property}.}.  You can set the effort
5553 for an entry with the following commands:
5555 @table @kbd
5556 @kindex C-c C-x e
5557 @item C-c C-x e
5558 Set the effort estimate for the current entry.  With a numeric prefix
5559 argument, set it to the NTH allowed value (see below).  This command is also
5560 accessible from the agenda with the @kbd{e} key.
5561 @kindex C-c C-x C-e
5562 @item C-c C-x C-e
5563 Modify the effort estimate of the item currently being clocked.
5564 @end table
5566 Clearly the best way to work with effort estimates is through column view
5567 (@pxref{Column view}).  You should start by setting up discrete values for
5568 effort estimates, and a @code{COLUMNS} format that displays these values
5569 together with clock sums (if you want to clock your time).  For a specific
5570 buffer you can use
5572 @example
5573 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
5574 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
5575 @end example
5577 @noindent
5578 @vindex org-global-properties
5579 @vindex org-columns-default-format
5580 or, even better, you can set up these values globally by customizing the
5581 variables @code{org-global-properties} and @code{org-columns-default-format}.
5582 In particular if you want to use this setup also in the agenda, a global
5583 setup may be advised.
5585 The way to assign estimates to individual items is then to switch to column
5586 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
5587 value.  The values you enter will immediately be summed up in the hierarchy.
5588 In the column next to it, any clocked time will be displayed.
5590 @vindex org-agenda-columns-add-appointments-to-effort-sum
5591 If you switch to column view in the daily/weekly agenda, the effort column
5592 will summarize the estimated work effort for each day@footnote{Please note
5593 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
5594 column view}).}, and you can use this to find space in your schedule.  To get
5595 an overview of the entire part of the day that is committed, you can set the
5596 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
5597 appointments on a day that take place over a specified time interval will
5598 then also be added to the load estimate of the day.
5600 Effort estimates can be used in secondary agenda filtering that is triggered
5601 with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
5602 these estimates defined consistently, two or three key presses will narrow
5603 down the list to stuff that fits into an available time slot.
5605 @node Relative timer,  , Effort estimates, Dates and Times
5606 @section Taking notes with a relative timer
5607 @cindex relative timer
5609 When taking notes during, for example, a meeting or a video viewing, it can
5610 be useful to have access to times relative to a starting time.  Org provides
5611 such a relative timer and make it easy to create timed notes.
5613 @table @kbd
5614 @kindex C-c C-x .
5615 @item C-c C-x .
5616 Insert a relative time into the buffer.  The first time you use this, the
5617 timer will be started.  When called with a prefix argument, the timer is
5618 restarted.
5619 @kindex C-c C-x -
5620 @item C-c C-x -
5621 Insert a description list item with the current relative time.  With a prefix
5622 argument, first reset the timer to 0.
5623 @kindex M-@key{RET}
5624 @item M-@key{RET}
5625 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
5626 new timer items.
5627 @kindex C-c C-x ,
5628 @item C-c C-x ,
5629 Pause the timer, or continue it if it is already paused.
5630 @c removed the sentence because it is redundant to the following item
5631 @kindex C-u C-c C-x ,
5632 @item C-u C-c C-x ,
5633 Stop the timer.  After this, you can only start a new timer, not continue the
5634 old one.  This command also removes the timer from the mode line.
5635 @kindex C-c C-x 0
5636 @item C-c C-x 0
5637 Reset the timer without inserting anything into the buffer.  By default, the
5638 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
5639 specific starting offset.  The user is prompted for the offset, with a
5640 default taken from a timer string at point, if any, So this can be used to
5641 restart taking notes after a break in the process.  When called with a double
5642 prefix argument @kbd{C-c C-u}, change all timer strings in the active region
5643 by a certain amount.  This can be used to fix timer strings if the timer was
5644 not started at exactly the right moment.
5645 @end table
5647 @node Capture, Agenda Views, Dates and Times, Top
5648 @chapter Capture
5649 @cindex capture
5651 An important part of any organization system is the ability to quickly
5652 capture new ideas and tasks, and to associate reference material with them.
5653 Org uses the @file{remember.el} package to create tasks, and stores files
5654 related to a task (@i{attachments}) in a special directory.
5656 @menu
5657 * Remember::                    Capture new tasks/ideas with little interruption
5658 * Attachments::                 Add files to tasks.
5659 * RSS Feeds::                   Getting input from RSS feeds
5660 * Protocols::                   External (@eg Browser) access to Emacs and Org
5661 @end menu
5663 @node Remember, Attachments, Capture, Capture
5664 @section Remember
5665 @cindex @file{remember.el}
5667 The Remember package by John Wiegley lets you store quick notes with little
5668 interruption of your work flow.  It is an excellent way to add new notes and
5669 tasks to Org files.  The @code{remember.el} package is part of Emacs 23, not
5670 Emacs 22.  See @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for
5671 more information.
5673 Org significantly expands the possibilities of Remember: you may define
5674 templates for different note types, and associate target files and headlines
5675 with specific templates.  It also allows you to select the location where a
5676 note should be stored interactively, on the fly.
5678 @menu
5679 * Setting up Remember for Org::  Some code for .emacs to get things going
5680 * Remember templates::          Define the outline of different note types
5681 * Storing notes::               Directly get the note to where it belongs
5682 * Refiling notes::              Moving a note or task to a project
5683 @end menu
5685 @node Setting up Remember for Org, Remember templates, Remember, Remember
5686 @subsection Setting up Remember for Org
5688 The following customization will tell Remember to use Org files as
5689 target, and to create annotations compatible with Org links.
5691 @example
5692 (org-remember-insinuate)
5693 (setq org-directory "~/path/to/my/orgfiles/")
5694 (setq org-default-notes-file (concat org-directory "/notes.org"))
5695 (define-key global-map "\C-cr" 'org-remember)
5696 @end example
5698 @noindent
5699 The last line binds the command @code{org-remember} to a global
5700 key@footnote{Please select your own key, @kbd{C-c r} is only a
5701 suggestion.}.  @code{org-remember} basically just calls Remember,
5702 but it makes a few things easier: if there is an active region, it will
5703 automatically copy the region into the Remember buffer.  It also allows
5704 to jump to the buffer and location where Remember notes are being
5705 stored: just call @code{org-remember} with a prefix argument.  If you
5706 use two prefix arguments, Org jumps to the location where the last
5707 remember note was stored.
5709 The Remember buffer will actually use @code{org-mode} as its major mode, so
5710 that all editing features of Org mode are available.  In addition to this, a
5711 minor mode @code{org-remember-mode} is turned on, for the single purpose that
5712 you can use its keymap @code{org-remember-mode-map} to overwrite some of
5713 Org mode's key bindings.
5715 You can also call @code{org-remember} in a special way from the agenda,
5716 using the @kbd{k r} key combination.  With this access, any timestamps
5717 inserted by the selected Remember template (see below) will default to
5718 the cursor date in the agenda, rather than to the current date.
5720 @node Remember templates, Storing notes, Setting up Remember for Org, Remember
5721 @subsection Remember templates
5722 @cindex templates, for Remember
5724 In combination with Org, you can use templates to generate
5725 different types of Remember notes.  For example, if you would like
5726 to use one template to create general TODO entries, another one for
5727 journal entries, and a third one for collecting random ideas, you could
5728 use:
5730 @example
5731 (setq org-remember-templates
5732  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
5733    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
5734    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5735 @end example
5737 @vindex org-remember-default-headline
5738 @vindex org-directory
5739 @noindent In these entries, the first string is just a name, and the
5740 character specifies how to select the template.  It is useful if the
5741 character is also the first letter of the name.  The next string specifies
5742 the template.  Two more (optional) strings give the file in which, and the
5743 headline under which, the new note should be stored.  The file (if not present
5744 or @code{nil}) defaults to @code{org-default-notes-file}, the heading to
5745 @code{org-remember-default-headline}.  If the file name is not an absolute
5746 path, it will be interpreted relative to @code{org-directory}.  The heading
5747 can also be the symbols @code{top} or @code{bottom} to send notes as level 1
5748 entries to the beginning or end of the file, respectively.
5750 An optional sixth element specifies the contexts in which the user can select
5751 the template.  This element can be a list of major modes or a function.
5752 @code{org-remember} will first check whether the function returns @code{t} or
5753 if we are in any of the listed major modes, and exclude templates for which
5754 this condition is not fulfilled.  Templates that do not specify this element
5755 at all, or that use @code{nil} or @code{t} as a value will always be
5756 selectable.
5758 So for example:
5760 @example
5761 (setq org-remember-templates
5762  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
5763    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" "X" my-check)
5764    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5765 @end example
5767 @noindent
5768 The first template will only be available when invoking @code{org-remember}
5769 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
5770 available when the function @code{my-check} returns @code{t}.  The third
5771 template will be proposed in any context.
5773 When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
5774 something, Org will prompt for a key to select the template (if you have
5775 more than one template) and then prepare the buffer like
5776 @example
5777 * TODO
5778   [[file:@var{link to where you called remember}]]
5779 @end example
5781 @noindent
5782 During expansion of the template, special @kbd{%}-escapes@footnote{If you
5783 need one of these sequences literally, escape the @kbd{%} with a backslash.}
5784 allow dynamic insertion of content:
5785 @example
5786 %^@{@var{prompt}@}  @r{prompt the user for a string and replace this sequence with it.}
5787             @r{You may specify a default value and a completion table with}
5788             @r{%^@{prompt|default|completion2|completion3...@}}
5789             @r{The arrow keys access a prompt-specific history.}
5790 %a          @r{annotation, normally the link created with @code{org-store-link}}
5791 %A          @r{like @code{%a}, but prompt for the description part}
5792 %i          @r{initial content, the region when remember is called with C-u.}
5793             @r{The entire text will be indented like @code{%i} itself.}
5794 %t          @r{timestamp, date only}
5795 %T          @r{timestamp with date and time}
5796 %u, %U      @r{like the above, but inactive timestamps}
5797 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
5798             @r{You may define a prompt like @code{%^@{Birthday@}t}}
5799 %n          @r{user name (taken from @code{user-full-name})}
5800 %c          @r{Current kill ring head.}
5801 %x          @r{Content of the X clipboard.}
5802 %^C         @r{Interactive selection of which kill or clip to use.}
5803 %^L         @r{Like @code{%^C}, but insert as link.}
5804 %^g         @r{prompt for tags, with completion on tags in target file.}
5805 %k          @r{title of currently clocked task}
5806 %K          @r{link to currently clocked task}
5807 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
5808 %^@{@var{prop}@}p   @r{Prompt the user for a value for property @var{prop}}
5809 %:keyword   @r{specific information for certain link types, see below}
5810 %[@var{file}]     @r{insert the contents of the file given by @var{file}}
5811 %(@var{sexp})     @r{evaluate Elisp @var{sexp} and replace with the result}
5812 %!          @r{immediately store note after completing the template}
5813             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
5814 %&          @r{jump to target location immediately after storing note}
5815 @end example
5817 @noindent
5818 For specific link types, the following keywords will be
5819 defined@footnote{If you define your own link types (@pxref{Adding
5820 hyperlink types}), any property you store with
5821 @code{org-store-link-props} can be accessed in remember templates in a
5822 similar way.}:
5824 @vindex org-from-is-user-regexp
5825 @example
5826 Link type          |  Available keywords
5827 -------------------+----------------------------------------------
5828 bbdb               |  %:name %:company
5829 bbdb               |  %::server %:port %:nick
5830 vm, wl, mh, rmail  |  %:type %:subject %:message-id
5831                    |  %:from %:fromname %:fromaddress
5832                    |  %:to   %:toname   %:toaddress
5833                    |  %: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}.}}
5834 gnus               |  %:group, @r{for messages also all email fields}
5835 w3, w3m            |  %:url
5836 info               |  %:file %:node
5837 calendar           |  %:date"
5838 @end example
5840 @noindent
5841 To place the cursor after template expansion use:
5843 @example
5844 %?          @r{After completing the template, position cursor here.}
5845 @end example
5847 @noindent
5848 If you change your mind about which template to use, call
5849 @code{org-remember} in the remember buffer.  You may then select a new
5850 template that will be filled with the previous context information.
5852 @node Storing notes, Refiling notes, Remember templates, Remember
5853 @subsection Storing notes
5855 @vindex org-remember-clock-out-on-exit
5856 When you are finished preparing a note with Remember, you have to press
5857 @kbd{C-c C-c} to file the note away.  If you have started the clock in the
5858 Remember buffer, you will first be asked if you want to clock out
5859 now@footnote{To avoid this query, configure the variable
5860 @code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
5861 will continue to run after the note was filed away.
5863 The handler will then store the note in the file and under the headline
5864 specified in the template, or it will use the default file and headline.
5865 The window configuration will be restored, sending you back to the working
5866 context before the call to Remember.  To re-use the location found
5867 during the last call to Remember, exit the Remember buffer with
5868 @kbd{C-0 C-c C-c}, @ie specify a zero prefix argument to @kbd{C-c C-c}.
5869 Another special case is @kbd{C-2 C-c C-c} which files the note as a child of
5870 the currently clocked item.
5872 @vindex org-remember-store-without-prompt
5873 If you want to store the note directly to a different place, use
5874 @kbd{C-1 C-c C-c} instead to exit Remember@footnote{Configure the
5875 variable @code{org-remember-store-without-prompt} to make this behavior
5876 the default.}.  The handler will then first prompt for a target file---if
5877 you press @key{RET}, the value specified for the template is used.
5878 Then the command offers the headings tree of the selected file, with the
5879 cursor position at the default headline (if you specified one in the
5880 template).  You can either immediately press @key{RET} to get the note
5881 placed there.  Or you can use the following keys to find a different
5882 location:
5883 @example
5884 @key{TAB}         @r{Cycle visibility.}
5885 @key{down} / @key{up}   @r{Next/previous visible headline.}
5886 n / p        @r{Next/previous visible headline.}
5887 f / b        @r{Next/previous headline same level.}
5888 u            @r{One level up.}
5889 @c 0-9          @r{Digit argument.}
5890 @end example
5891 @noindent
5892 Pressing @key{RET} or @key{left} or @key{right}
5893 then leads to the following result.
5895 @vindex org-reverse-note-order
5896 @multitable @columnfractions 0.2 0.15 0.65
5897 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
5898 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
5899 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
5900 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
5901 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
5902 @item                 @tab @tab depending on @code{org-reverse-note-order}.
5903 @item not on headline @tab @key{RET}
5904       @tab at cursor position, level taken from context.
5905 @end multitable
5907 Before inserting the text into a tree, the function ensures that the text has
5908 a headline, @ie a first line that starts with a @samp{*}.  If not, a
5909 headline is constructed from the current date.  If you have indented the text
5910 of the note below the headline, the indentation will be adapted if inserting
5911 the note into the tree requires demotion from level 1.
5913 @node Refiling notes,  , Storing notes, Remember
5914 @subsection Refiling notes
5915 @cindex refiling notes
5917 Remember is usually used to quickly capture notes and tasks into one or
5918 a few capture lists.  When reviewing the captured data, you may want to
5919 refile some of the entries into a different list, for example into a
5920 project.  Cutting, finding the right location, and then pasting the note
5921 is cumbersome.  To simplify this process, you can use the following
5922 special command:
5924 @table @kbd
5925 @kindex C-c C-w
5926 @item C-c C-w
5927 @vindex org-reverse-note-order
5928 @vindex org-refile-targets
5929 @vindex org-refile-use-outline-path
5930 @vindex org-outline-path-complete-in-steps
5931 @vindex org-refile-allow-creating-parent-nodes
5932 Refile the entry or region at point.  This command offers possible locations
5933 for refiling the entry and lets you select one with completion.  The item (or
5934 all items in the region) is filed below the target heading as a subitem.
5935 Depending on @code{org-reverse-note-order}, it will be either the first or
5936 last subitem.@*
5937 By default, all level 1 headlines in the current buffer are considered to be
5938 targets, but you can have more complex definitions across a number of files.
5939 See the variable @code{org-refile-targets} for details.  If you would like to
5940 select a location via a file-path-like completion along the outline path, see
5941 the variables @code{org-refile-use-outline-path} and
5942 @code{org-outline-path-complete-in-steps}.  If you would like to be able to
5943 create new nodes as new parents for for refiling on the fly, check the
5944 variable @code{org-refile-allow-creating-parent-nodes}.
5945 @kindex C-u C-c C-w
5946 @item C-u C-c C-w
5947 Use the refile interface to jump to a heading.
5948 @kindex C-u C-u C-c C-w
5949 @item C-u C-u C-c C-w
5950 Jump to the location where @code{org-refile} last moved a tree to.
5951 @end table
5954 @node Attachments, RSS Feeds, Remember, Capture
5955 @section Attachments
5956 @cindex attachments
5958 @vindex org-attach-directory
5959 It is often useful to associate reference material with an outline node/task.
5960 Small chunks of plain text can simply be stored in the subtree of a project.
5961 Hyperlinks (@pxref{Hyperlinks}) can be used to establish associations with
5962 files that live elsewhere on your computer or in the cloud, like emails or
5963 source code files belonging to a project.  Another method is @i{attachments},
5964 which are files located in a directory belonging to an outline node.  Org
5965 uses directories named by the unique ID of each entry.  These directories are
5966 located in the @file{data} directory which lives in the same directory where
5967 your Org file lives@footnote{If you move entries or Org files from one
5968 directory to another, you may want to configure @code{org-attach-directory}
5969 to contain an absolute path.}.  If you initialize this directory with
5970 @code{git init}, Org will automatically commit changes when it sees them.
5971 The attachment system has been contributed to Org by John Wiegley.
5973 In cases where it seems better to do so, you can also attach a directory of your
5974 choice to an entry.  You can also make children inherit the attachment
5975 directory from a parent, so that an entire subtree uses the same attached
5976 directory.
5978 @noindent The following commands deal with attachments.
5980 @table @kbd
5982 @kindex C-c C-a
5983 @item C-c C-a
5984 The dispatcher for commands related to the attachment system.  After these
5985 keys, a list of commands is displayed and you need to press an additional key
5986 to select a command:
5988 @table @kbd
5989 @kindex C-c C-a a
5990 @item a
5991 @vindex org-attach-method
5992 Select a file and move it into the task's attachment directory.  The file
5993 will be copied, moved, or linked, depending on @code{org-attach-method}.
5994 Note that hard links are not supported on all systems.
5996 @kindex C-c C-a c
5997 @kindex C-c C-a m
5998 @kindex C-c C-a l
5999 @item c/m/l
6000 Attach a file using the copy/move/link method.
6001 Note that hard links are not supported on all systems.
6003 @kindex C-c C-a n
6004 @item n
6005 Create a new attachment as an Emacs buffer.
6007 @kindex C-c C-a z
6008 @item z
6009 Synchronize the current task with its attachment directory, in case you added
6010 attachments yourself.
6012 @kindex C-c C-a o
6013 @item o
6014 @vindex org-file-apps
6015 Open current task's attachment.  If there are more than one, prompt for a
6016 file name first.  Opening will follow the rules set by @code{org-file-apps}.
6017 For more details, see the information on following hyperlinks
6018 (@pxref{Handling links}).
6020 @kindex C-c C-a O
6021 @item O
6022 Also open the attachment, but force opening the file in Emacs.
6024 @kindex C-c C-a f
6025 @item f
6026 Open the current task's attachment directory.
6028 @kindex C-c C-a F
6029 @item F
6030 Also open the directory, but force using @command{dired} in Emacs.
6032 @kindex C-c C-a d
6033 @item d
6034 Select and delete a single attachment.
6036 @kindex C-c C-a D
6037 @item D
6038 Delete all of a task's attachments.  A safer way is to open the directory in
6039 @command{dired} and delete from there.
6041 @kindex C-c C-a s
6042 @item C-c C-a s
6043 @cindex property, ATTACH_DIR
6044 Set a specific directory as the entry's attachment directory.  This works by
6045 putting the directory path into the @code{ATTACH_DIR} property.
6047 @kindex C-c C-a i
6048 @item C-c C-a i
6049 @cindex property, ATTACH_DIR_INHERIT
6050 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
6051 same directory for attachments as the parent does.
6052 @end table
6053 @end table
6055 @node RSS Feeds, Protocols, Attachments, Capture
6056 @section RSS feeds
6057 @cindex RSS feeds
6059 Org has the capability to add and change entries based on information found in
6060 RSS feeds.  You could use this to make a task out of each new podcast in a
6061 podcast feed.  Or you could use a phone-based note-creating service on the
6062 web to import tasks into Org.  To access feeds, you need to configure the
6063 variable @code{org-feed-alist}.  The docstring of this variable has detailed
6064 information.  Here is just an example:
6066 @example
6067 (setq org-feed-alist
6068       '(("ReQall" "http://www.reqall.com/user/feeds/rss/a1b2c3....."
6069          "~/org/feeds.org" "ReQall Entries")
6070 @end example
6071 @noindent
6072 will configure that new items from the feed provided by @file{reqall.com}
6073 will result in new entries in the file @file{~/org/feeds.org} under the
6074 heading @samp{ReQall Entries}, whenever the following command is used:
6076 @table @kbd
6077 @kindex C-c C-x g
6078 @item C-c C-x g
6079 Collect items from the feeds configured in @code{org-feed-alist} and act upon
6080 them.
6081 @kindex C-c C-x G
6082 @item C-c C-x G
6083 Prompt for a feed name and go to the inbox configured for this feed.
6084 @end table
6086 Under the same headline, Org will create a drawer @samp{FEEDSTATUS} in which
6087 it will store information about the status of items in the feed, to avoid
6088 adding the same item several times.  You should add @samp{FEEDSTATUS} to the
6089 list of drawers in that file:
6091 @example
6092 #+DRAWERS: LOGBOOK PROPERTIES FEEDSTATUS
6093 @end example
6095 For more information, see @file{org-feed.el} and the docstring of
6096 @code{org-feed-alist}.
6098 @node Protocols,  , RSS Feeds, Capture
6099 @section Protocols for external access
6100 @cindex protocols, for external access
6101 @cindex emacsserver
6103 You can set up Org for handling protocol calls from outside applications that
6104 are passed to Emacs through the @file{emacsserver}.  For example, you can
6105 configure bookmarks in your web browser to send a link to the current page to
6106 Org and create a note from it using Remember (@pxref{Remember}).  Or you
6107 could create a bookmark that will tell Emacs to open the local source file of
6108 a remote website you are looking at with the browser.  See
6109 @uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed
6110 documentation and setup instructions.
6113 @node Agenda Views, Embedded LaTeX, Capture, Top
6114 @chapter Agenda Views
6115 @cindex agenda views
6117 Due to the way Org works, TODO items, time-stamped items, and
6118 tagged headlines can be scattered throughout a file or even a number of
6119 files.  To get an overview of open action items, or of events that are
6120 important for a particular date, this information must be collected,
6121 sorted and displayed in an organized way.
6123 Org can select items based on various criteria and display them
6124 in a separate buffer.  Seven different view types are provided:
6126 @itemize @bullet
6127 @item
6128 an @emph{agenda} that is like a calendar and shows information
6129 for specific dates,
6130 @item
6131 a @emph{TODO list} that covers all unfinished
6132 action items,
6133 @item
6134 a @emph{match view}, showings headlines based on the tags, properties, and
6135 TODO state associated with them,
6136 @item
6137 a @emph{timeline view} that shows all events in a single Org file,
6138 in time-sorted view,
6139 @item
6140 a @emph{keyword search view} that shows all entries from multiple files
6141 that contain specified keywords,
6142 @item
6143 a @emph{stuck projects view} showing projects that currently don't move
6144 along, and
6145 @item
6146 @emph{custom views} that are special tag/keyword searches and
6147 combinations of different views.
6148 @end itemize
6150 @noindent
6151 The extracted information is displayed in a special @emph{agenda
6152 buffer}.  This buffer is read-only, but provides commands to visit the
6153 corresponding locations in the original Org files, and even to
6154 edit these files remotely.
6156 @vindex org-agenda-window-setup
6157 @vindex org-agenda-restore-windows-after-quit
6158 Two variables control how the agenda buffer is displayed and whether the
6159 window configuration is restored when the agenda exits:
6160 @code{org-agenda-window-setup} and
6161 @code{org-agenda-restore-windows-after-quit}.
6163 @menu
6164 * Agenda files::                Files being searched for agenda information
6165 * Agenda dispatcher::           Keyboard access to agenda views
6166 * Built-in agenda views::       What is available out of the box?
6167 * Presentation and sorting::    How agenda items are prepared for display
6168 * Agenda commands::             Remote editing of Org trees
6169 * Custom agenda views::         Defining special searches and views
6170 * Exporting Agenda Views::      Writing a view to a file
6171 * Agenda column view::          Using column view for collected entries
6172 @end menu
6174 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
6175 @section Agenda files
6176 @cindex agenda files
6177 @cindex files for agenda
6179 @vindex org-agenda-files
6180 The information to be shown is normally collected from all @emph{agenda
6181 files}, the files listed in the variable
6182 @code{org-agenda-files}@footnote{If the value of that variable is not a
6183 list, but a single file name, then the list of agenda files will be
6184 maintained in that external file.}. If a directory is part of this list,
6185 all files with the extension @file{.org} in this directory will be part
6186 of the list.
6188 Thus, even if you only work with a single Org file, that file should
6189 be put into the list@footnote{When using the dispatcher, pressing
6190 @kbd{<} before selecting a command will actually limit the command to
6191 the current file, and ignore @code{org-agenda-files} until the next
6192 dispatcher command.}.  You can customize @code{org-agenda-files}, but
6193 the easiest way to maintain it is through the following commands
6195 @cindex files, adding to agenda list
6196 @table @kbd
6197 @kindex C-c [
6198 @item C-c [
6199 Add current file to the list of agenda files.  The file is added to
6200 the front of the list.  If it was already in the list, it is moved to
6201 the front.  With a prefix argument, file is added/moved to the end.
6202 @kindex C-c ]
6203 @item C-c ]
6204 Remove current file from the list of agenda files.
6205 @kindex C-,
6206 @kindex C-'
6207 @item C-,
6208 @itemx C-'
6209 Cycle through agenda file list, visiting one file after the other.
6210 @kindex M-x org-iswitchb
6211 @item M-x org-iswitchb
6212 Command to use an @code{iswitchb}-like interface to switch to and between Org
6213 buffers.
6214 @end table
6216 @noindent
6217 The Org menu contains the current list of files and can be used
6218 to visit any of them.
6220 If you would like to focus the agenda temporarily on a file not in
6221 this list, or on just one file in the list, or even on only a subtree in a
6222 file, then this can be done in different ways.  For a single agenda command,
6223 you may press @kbd{<} once or several times in the dispatcher
6224 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
6225 extended period, use the following commands:
6227 @table @kbd
6228 @kindex C-c C-x <
6229 @item C-c C-x <
6230 Permanently restrict the agenda to the current subtree.  When with a
6231 prefix argument, or with the cursor before the first headline in a file,
6232 the agenda scope is set to the entire file.  This restriction remains in
6233 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
6234 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
6235 agenda view, the new restriction takes effect immediately.
6236 @kindex C-c C-x >
6237 @item C-c C-x >
6238 Remove the permanent restriction created by @kbd{C-c C-x <}.
6239 @end table
6241 @noindent
6242 When working with @file{speedbar.el}, you can use the following commands in
6243 the Speedbar frame:
6244 @table @kbd
6245 @kindex <
6246 @item < @r{in the speedbar frame}
6247 Permanently restrict the agenda to the item---either an Org file or a subtree
6248 in such a file---at the cursor in the Speedbar frame.
6249 If there is a window displaying an agenda view, the new restriction takes
6250 effect immediately.
6251 @kindex >
6252 @item > @r{in the speedbar frame}
6253 Lift the restriction.
6254 @end table
6256 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
6257 @section The agenda dispatcher
6258 @cindex agenda dispatcher
6259 @cindex dispatching agenda commands
6260 The views are created through a dispatcher, which should be bound to a
6261 global key---for example @kbd{C-c a} (@pxref{Installation}).  In the
6262 following we will assume that @kbd{C-c a} is indeed how the dispatcher
6263 is accessed and list keyboard access to commands accordingly.  After
6264 pressing @kbd{C-c a}, an additional letter is required to execute a
6265 command.  The dispatcher offers the following default commands:
6266 @table @kbd
6267 @item a
6268 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
6269 @item t @r{/} T
6270 Create a list of all TODO items (@pxref{Global TODO list}).
6271 @item m @r{/} M
6272 Create a list of headlines matching a TAGS expression (@pxref{Matching
6273 tags and properties}).
6274 @item L
6275 Create the timeline view for the current buffer (@pxref{Timeline}).
6276 @item s
6277 Create a list of entries selected by a boolean expression of keywords
6278 and/or regular expressions that must or must not occur in the entry.
6279 @item /
6280 @vindex org-agenda-text-search-extra-files
6281 Search for a regular expression in all agenda files and additionally in
6282 the files listed in @code{org-agenda-text-search-extra-files}.  This
6283 uses the Emacs command @code{multi-occur}.  A prefix argument can be
6284 used to specify the number of context lines for each match, default is
6286 @item # @r{/} !
6287 Create a list of stuck projects (@pxref{Stuck projects}).
6288 @item <
6289 Restrict an agenda command to the current buffer@footnote{For backward
6290 compatibility, you can also press @kbd{1} to restrict to the current
6291 buffer.}.  After pressing @kbd{<}, you still need to press the character
6292 selecting the command.
6293 @item < <
6294 If there is an active region, restrict the following agenda command to
6295 the region.  Otherwise, restrict it to the current subtree@footnote{For
6296 backward compatibility, you can also press @kbd{0} to restrict to the
6297 current region/subtree.}.  After pressing @kbd{< <}, you still need to press the
6298 character selecting the command.
6299 @end table
6301 You can also define custom commands that will be accessible through the
6302 dispatcher, just like the default commands.  This includes the
6303 possibility to create extended agenda buffers that contain several
6304 blocks together, for example the weekly agenda, the global TODO list and
6305 a number of special tags matches.  @xref{Custom agenda views}.
6307 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
6308 @section The built-in agenda views
6310 In this section we describe the built-in views.
6312 @menu
6313 * Weekly/daily agenda::         The calendar page with current tasks
6314 * Global TODO list::            All unfinished action items
6315 * Matching tags and properties::  Structured information with fine-tuned search
6316 * Timeline::                    Time-sorted view for single file
6317 * Keyword search::              Finding entries by keyword
6318 * Stuck projects::              Find projects you need to review
6319 @end menu
6321 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
6322 @subsection The weekly/daily agenda
6323 @cindex agenda
6324 @cindex weekly agenda
6325 @cindex daily agenda
6327 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
6328 paper agenda, showing all the tasks for the current week or day.
6330 @table @kbd
6331 @cindex org-agenda, command
6332 @kindex C-c a a
6333 @item C-c a a
6334 @vindex org-agenda-ndays
6335 Compile an agenda for the current week from a list of Org files.  The agenda
6336 shows the entries for each day.  With a numeric prefix@footnote{For backward
6337 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
6338 listed before the agenda.  This feature is deprecated, use the dedicated TODO
6339 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
6340 C-c a a}) you may set the number of days to be displayed (see also the
6341 variable @code{org-agenda-ndays})
6342 @end table
6344 Remote editing from the agenda buffer means, for example, that you can
6345 change the dates of deadlines and appointments from the agenda buffer.
6346 The commands available in the Agenda buffer are listed in @ref{Agenda
6347 commands}.
6349 @subsubheading Calendar/Diary integration
6350 @cindex calendar integration
6351 @cindex diary integration
6353 Emacs contains the calendar and diary by Edward M. Reingold.  The
6354 calendar displays a three-month calendar with holidays from different
6355 countries and cultures.  The diary allows you to keep track of
6356 anniversaries, lunar phases, sunrise/set, recurrent appointments
6357 (weekly, monthly) and more.  In this way, it is quite complementary to
6358 Org.  It can be very useful to combine output from Org with
6359 the diary.
6361 In order to include entries from the Emacs diary into Org mode's
6362 agenda, you only need to customize the variable
6364 @lisp
6365 (setq org-agenda-include-diary t)
6366 @end lisp
6368 @noindent After that, everything will happen automatically.  All diary
6369 entries including holidays, anniversaries, etc., will be included in the
6370 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
6371 @key{RET} can be used from the agenda buffer to jump to the diary
6372 file in order to edit existing diary entries.  The @kbd{i} command to
6373 insert new entries for the current date works in the agenda buffer, as
6374 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
6375 Sunrise/Sunset times, show lunar phases and to convert to other
6376 calendars, respectively.  @kbd{c} can be used to switch back and forth
6377 between calendar and agenda.
6379 If you are using the diary only for sexp entries and holidays, it is
6380 faster to not use the above setting, but instead to copy or even move
6381 the entries into an Org file. Org mode evaluates diary-style sexp
6382 entries, and does it faster because there is no overhead for first
6383 creating the diary display.  Note that the sexp entries must start at
6384 the left margin, no whitespace is allowed before them.  For example,
6385 the following segment of an Org file will be processed and entries
6386 will be made in the agenda:
6388 @example
6389 * Birthdays and similar stuff
6390 #+CATEGORY: Holiday
6391 %%(org-calendar-holiday)   ; special function for holiday names
6392 #+CATEGORY: Ann
6393 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
6394 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
6395 @end example
6397 @subsubheading Anniversaries from BBDB
6398 @cindex BBDB, anniversaries
6399 @cindex anniversaries, from BBDB
6401 If you are using the Big Brothers Database to store your contacts, you will
6402 very likely prefer to store anniversaries in BBDB rather than in a
6403 separate Org or diary file.  Org supports this and will show BBDB
6404 anniversaries as part of the agenda.  All you need to do is to add the
6405 following to one your your agenda files:
6407 @example
6408 * Anniversaries
6409   :PROPERTIES:
6410   :CATEGORY: Anniv
6411   :END
6412 %%(org-bbdb-anniversaries)
6413 @end example
6415 You can then go ahead and define anniversaries for a BBDB record.  Basically,
6416 you need to press @kbd{C-o anniversary @key{RET}} with the cursor in a BBDB
6417 record and then add the date in the format @code{YYYY-MM-DD}, followed by a
6418 space and the class of the anniversary (@samp{birthday} or @samp{wedding}, or
6419 a format string).  If you omit the class, it will default to @samp{birthday}.
6420 Here are a few examples, the header for the file @file{org-bbdb.el} contains
6421 more detailed information.
6423 @example
6424 1973-06-22
6425 1955-08-02 wedding
6426 2008-04-14 %s released version 6.01 of org-mode, %d years ago
6427 @end example
6429 After a change to BBDB, or for the first agenda display during an Emacs
6430 session, the agenda display will suffer a short delay as Org updates its
6431 hash with anniversaries.  However, from then on things will be very fast---much
6432 faster in fact than a long list of @samp{%%(diary-anniversary)} entries
6433 in an Org or Diary file.
6435 @subsubheading Appointment reminders
6436 @cindex @file{appt.el}
6437 @cindex appointment reminders
6439 Org can interact with Emacs appointments notification facility.  To add all
6440 the appointments of your agenda files, use the command
6441 @code{org-agenda-to-appt}.  This command also lets you filter through the
6442 list of your appointments and add only those belonging to a specific category
6443 or matching a regular expression. See the docstring for details.
6445 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
6446 @subsection The global TODO list
6447 @cindex global TODO list
6448 @cindex TODO list, global
6450 The global TODO list contains all unfinished TODO items formatted and
6451 collected into a single place.
6453 @table @kbd
6454 @kindex C-c a t
6455 @item C-c a t
6456 Show the global TODO list.  This collects the TODO items from all
6457 agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
6458 @code{agenda-mode}, so there are commands to examine and manipulate
6459 the TODO entries directly from that buffer (@pxref{Agenda commands}).
6460 @kindex C-c a T
6461 @item C-c a T
6462 @cindex TODO keyword matching
6463 @vindex org-todo-keywords
6464 Like the above, but allows selection of a specific TODO keyword.  You
6465 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
6466 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
6467 specify several keywords by separating them with @samp{|} as the boolean OR
6468 operator.  With a numeric prefix, the nth keyword in
6469 @code{org-todo-keywords} is selected.
6470 @kindex r
6471 The @kbd{r} key in the agenda buffer regenerates it, and you can give
6472 a prefix argument to this command to change the selected TODO keyword,
6473 for example @kbd{3 r}.  If you often need a search for a specific
6474 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
6475 Matching specific TODO keywords can also be done as part of a tags
6476 search (@pxref{Tag searches}).
6477 @end table
6479 Remote editing of TODO items means that you can change the state of a
6480 TODO entry with a single key press.  The commands available in the
6481 TODO list are described in @ref{Agenda commands}.
6483 @cindex sublevels, inclusion into TODO list
6484 Normally the global TODO list simply shows all headlines with TODO
6485 keywords.  This list can become very long.  There are two ways to keep
6486 it more compact:
6487 @itemize @minus
6488 @item
6489 @vindex org-agenda-todo-ignore-scheduled
6490 @vindex org-agenda-todo-ignore-deadlines
6491 @vindex org-agenda-todo-ignore-with-date
6492 Some people view a TODO item that has been @emph{scheduled} for execution or
6493 have a @emph{deadline} (@pxref{Timestamps}) as no longer @emph{open}.
6494 Configure the variables @code{org-agenda-todo-ignore-scheduled},
6495 @code{org-agenda-todo-ignore-deadlines}, and/or
6496 @code{org-agenda-todo-ignore-with-date} to exclude such items from the
6497 global TODO list.
6498 @item
6499 @vindex org-agenda-todo-list-sublevels
6500 TODO items may have sublevels to break up the task into subtasks.  In
6501 such cases it may be enough to list only the highest level TODO headline
6502 and omit the sublevels from the global list.  Configure the variable
6503 @code{org-agenda-todo-list-sublevels} to get this behavior.
6504 @end itemize
6506 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
6507 @subsection Matching tags and properties
6508 @cindex matching, of tags
6509 @cindex matching, of properties
6510 @cindex tags view
6511 @cindex match view
6513 If headlines in the agenda files are marked with @emph{tags} (@pxref{Tags}),
6514 or have properties (@pxref{Properties and Columns}), you can select headlines
6515 based on this metadata and collect them into an agenda buffer.  The match
6516 syntax described here also applies when creating sparse trees with @kbd{C-c /
6519 @table @kbd
6520 @kindex C-c a m
6521 @item C-c a m
6522 Produce a list of all headlines that match a given set of tags.  The
6523 command prompts for a selection criterion, which is a boolean logic
6524 expression with tags, like @samp{+work+urgent-withboss} or
6525 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
6526 define a custom command for it (@pxref{Agenda dispatcher}).
6527 @kindex C-c a M
6528 @item C-c a M
6529 @vindex org-tags-match-list-sublevels
6530 @vindex org-agenda-tags-todo-honor-ignore-options
6531 Like @kbd{C-c a m}, but only select headlines that are also TODO items and
6532 force checking subitems (see variable @code{org-tags-match-list-sublevels}).
6533 To exclude scheduled/deadline items, see the variable
6534 @code{org-agenda-tags-todo-honor-ignore-options}.  Matching specific TODO
6535 keywords together with a tags match is also possible, see @ref{Tag searches}.
6536 @end table
6538 The commands available in the tags list are described in @ref{Agenda
6539 commands}.
6541 @subsubheading Match syntax
6543 @cindex Boolean logic, for tag/property searches
6544 A search string can use Boolean operators @samp{&} for AND and @samp{|} for
6545 OR.  @samp{&} binds more strongly than @samp{|}.  Parentheses are currently
6546 not implemented.  Each element in the search is either a tag, a regular
6547 expression matching tags, or an expression like @code{PROPERTY OPERATOR
6548 VALUE} with a comparison operator, accessing a property value.  Each element
6549 may be preceded by @samp{-}, to select against it, and @samp{+} is syntactic
6550 sugar for positive selection.  The AND operator @samp{&} is optional when
6551 @samp{+} or @samp{-} is present.  Here are some examples, using only tags.
6553 @table @samp
6554 @item +work-boss
6555 Select headlines tagged @samp{:work:}, but discard those also tagged
6556 @samp{:boss:}.
6557 @item work|laptop
6558 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
6559 @item work|laptop+night
6560 Like before, but require the @samp{:laptop:} lines to be tagged also
6561 @samp{:night:}.
6562 @end table
6564 @cindex regular expressions, with tags search
6565 Instead of a tag, you may also specify a regular expression enclosed in curly
6566 braces.  For example,
6567 @samp{work+@{^boss.*@}} matches headlines that contain the tag
6568 @samp{:work:} and any tag @i{starting} with @samp{boss}.
6570 @cindex TODO keyword matching, with tags search
6571 @cindex level, require for tags/property match
6572 @cindex category, require for tags/property match
6573 @vindex org-odd-levels-only
6574 You may also test for properties (@pxref{Properties and Columns}) at the same
6575 time as matching tags.  The properties may be real properties, or special
6576 properties that represent other metadata (@pxref{Special properties}).  For
6577 example, the ``property'' @code{TODO} represents the TODO keyword of the
6578 entry.  Or, the ``property'' @code{LEVEL} represents the level of an entry.
6579 So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
6580 that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
6581 DONE.  In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
6582 count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
6584 Here are more examples:
6585 @table @samp
6586 @item work+TODO="WAITING"
6587 Select @samp{:work:}-tagged TODO lines with the specific TODO
6588 keyword @samp{WAITING}.
6589 @item work+TODO="WAITING"|home+TODO="WAITING"
6590 Waiting tasks both at work and at home.
6591 @end table
6593 When matching properties, a number of different operators can be used to test
6594 the value of a property.  Here is a complex example:
6596 @example
6597 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
6598          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
6599 @end example
6601 @noindent
6602 The type of comparison will depend on how the comparison value is written:
6603 @itemize @minus
6604 @item
6605 If the comparison value is a plain number, a numerical comparison is done,
6606 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
6607 @samp{>=}, and @samp{<>}.
6608 @item
6609 If the comparison value is enclosed in double-quotes,
6610 a string comparison is done, and the same operators are allowed.
6611 @item
6612 If the comparison value is enclosed in double-quotes @emph{and} angular
6613 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
6614 assumed to be date/time specifications in the standard Org way, and the
6615 comparison will be done accordingly.  Special values that will be recognized
6616 are @code{"<now>"} for now (including time), and @code{"<today>"}, and
6617 @code{"<tomorrow>"} for these days at 0:00 hours, @ie without a time
6618 specification.  Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
6619 @code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
6620 respectively, can be used.
6621 @item
6622 If the comparison value is enclosed
6623 in curly braces, a regexp match is performed, with @samp{=} meaning that the
6624 regexp matches the property value, and @samp{<>} meaning that it does not
6625 match.
6626 @end itemize
6628 So the search string in the example finds entries tagged @samp{:work:} but
6629 not @samp{:boss:}, which also have a priority value @samp{A}, a
6630 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
6631 property that is numerically smaller than 2, a @samp{:With:} property that is
6632 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
6633 on or after October 11, 2008.
6635 Accessing TODO, LEVEL, and CATEGORY during a search is fast.  Accessing any
6636 other properties will slow down the search.  However, once you have paid the
6637 price by accessing one property, testing additional properties is cheap
6638 again.
6640 You can configure Org mode to use property inheritance during a search, but
6641 beware that this can slow down searches considerably.  See @ref{Property
6642 inheritance}, for details.
6644 For backward compatibility, and also for typing speed, there is also a
6645 different way to test TODO states in a search.  For this, terminate the
6646 tags/property part of the search string (which may include several terms
6647 connected with @samp{|}) with a @samp{/} and then specify a Boolean
6648 expression just for TODO keywords.  The syntax is then similar to that for
6649 tags, but should be applied with care: for example, a positive
6650 selection on several TODO keywords cannot meaningfully be combined with
6651 boolean AND.  However, @emph{negative selection} combined with AND can be
6652 meaningful.  To make sure that only lines are checked that actually have any
6653 TODO keyword (resulting in a speed-up), use @kbd{C-c a M}, or equivalently
6654 start the TODO part after the slash with @samp{!}.  Examples:
6656 @table @samp
6657 @item work/WAITING
6658 Same as @samp{work+TODO="WAITING"}
6659 @item work/!-WAITING-NEXT
6660 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
6661 nor @samp{NEXT}
6662 @item work/!+WAITING|+NEXT
6663 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
6664 @samp{NEXT}.
6665 @end table
6667 @node Timeline, Keyword search, Matching tags and properties, Built-in agenda views
6668 @subsection Timeline for a single file
6669 @cindex timeline, single file
6670 @cindex time-sorted view
6672 The timeline summarizes all time-stamped items from a single Org mode
6673 file in a @emph{time-sorted view}.  The main purpose of this command is
6674 to give an overview over events in a project.
6676 @table @kbd
6677 @kindex C-c a L
6678 @item C-c a L
6679 Show a time-sorted view of the Org file, with all time-stamped items.
6680 When called with a @kbd{C-u} prefix, all unfinished TODO entries
6681 (scheduled or not) are also listed under the current date.
6682 @end table
6684 @noindent
6685 The commands available in the timeline buffer are listed in
6686 @ref{Agenda commands}.
6688 @node Keyword search, Stuck projects, Timeline, Built-in agenda views
6689 @subsection Keyword search
6690 @cindex keyword search
6691 @cindex searching, for keywords
6693 This agenda view is a general text search facility for Org mode entries.
6694 It is particularly useful to find notes.
6696 @table @kbd
6697 @kindex C-c a s
6698 @item C-c a s
6699 This is a special search that lets you select entries by keywords or
6700 regular expression, using a boolean logic.  For example, the search
6701 string
6703 @example
6704 +computer +wifi -ethernet -@{8\.11[bg]@}
6705 @end example
6707 @noindent
6708 will search for note entries that contain the keywords @code{computer}
6709 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
6710 not matched by the regular expression @code{8\.11[bg]}, meaning to
6711 exclude both 8.11b and 8.11g.
6713 @vindex org-agenda-text-search-extra-files
6714 Note that in addition to the agenda files, this command will also search
6715 the files listed in @code{org-agenda-text-search-extra-files}.
6716 @end table
6718 @node Stuck projects,  , Keyword search, Built-in agenda views
6719 @subsection Stuck projects
6721 If you are following a system like David Allen's GTD to organize your
6722 work, one of the ``duties'' you have is a regular review to make sure
6723 that all projects move along.  A @emph{stuck} project is a project that
6724 has no defined next actions, so it will never show up in the TODO lists
6725 Org mode produces.  During the review, you need to identify such
6726 projects and define next actions for them.
6728 @table @kbd
6729 @kindex C-c a #
6730 @item C-c a #
6731 List projects that are stuck.
6732 @kindex C-c a !
6733 @item C-c a !
6734 @vindex org-stuck-projects
6735 Customize the variable @code{org-stuck-projects} to define what a stuck
6736 project is and how to find it.
6737 @end table
6739 You almost certainly will have to configure this view before it will
6740 work for you.  The built-in default assumes that all your projects are
6741 level-2 headlines, and that a project is not stuck if it has at least
6742 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
6744 Let's assume that you, in your own way of using Org mode, identify
6745 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
6746 indicate a project that should not be considered yet.  Let's further
6747 assume that the TODO keyword DONE marks finished projects, and that NEXT
6748 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
6749 is a next action even without the NEXT tag.  Finally, if the project
6750 contains the special word IGNORE anywhere, it should not be listed
6751 either.  In this case you would start by identifying eligible projects
6752 with a tags/todo match@footnote{@xref{Tag searches}.}
6753 @samp{+PROJECT/-MAYBE-DONE}, and then check for TODO, NEXT, @@SHOP, and
6754 IGNORE in the subtree to identify projects that are not stuck.  The
6755 correct customization for this is
6757 @lisp
6758 (setq org-stuck-projects
6759       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
6760                                "\\<IGNORE\\>"))
6761 @end lisp
6763 Note that if a project is identified as non-stuck, the subtree of this entry
6764 will still be searched for stuck projects.
6766 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
6767 @section Presentation and sorting
6768 @cindex presentation, of agenda items
6770 @vindex org-agenda-prefix-format
6771 Before displaying items in an agenda view, Org mode visually prepares
6772 the items and sorts them.  Each item occupies a single line.  The line
6773 starts with a @emph{prefix} that contains the @emph{category}
6774 (@pxref{Categories}) of the item and other important information.  You can
6775 customize the prefix using the option @code{org-agenda-prefix-format}.
6776 The prefix is followed by a cleaned-up version of the outline headline
6777 associated with the item.
6779 @menu
6780 * Categories::                  Not all tasks are equal
6781 * Time-of-day specifications::  How the agenda knows the time
6782 * Sorting of agenda items::     The order of things
6783 @end menu
6785 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
6786 @subsection Categories
6788 @cindex category
6789 The category is a broad label assigned to each agenda item.  By default,
6790 the category is simply derived from the file name, but you can also
6791 specify it with a special line in the buffer, like this@footnote{For
6792 backward compatibility, the following also works: if there are several
6793 such lines in a file, each specifies the category for the text below it.
6794 The first category also applies to any text before the first CATEGORY
6795 line.  However, using this method is @emph{strongly} deprecated as it is
6796 incompatible with the outline structure of the document.  The correct
6797 method for setting multiple categories in a buffer is using a
6798 property.}:
6800 @example
6801 #+CATEGORY: Thesis
6802 @end example
6804 @noindent
6805 @cindex property, CATEGORY
6806 If you would like to have a special CATEGORY for a single entry or a
6807 (sub)tree, give the entry a @code{:CATEGORY:} property with the
6808 special category you want to apply as the value.
6810 @noindent
6811 The display in the agenda buffer looks best if the category is not
6812 longer than 10 characters.
6814 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
6815 @subsection Time-of-day specifications
6816 @cindex time-of-day specification
6818 Org mode checks each agenda item for a time-of-day specification.  The
6819 time can be part of the timestamp that triggered inclusion into the
6820 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
6821 ranges can be specified with two timestamps, like
6823 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
6825 In the headline of the entry itself, a time(range) may also appear as
6826 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
6827 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
6828 specifications in diary entries are recognized as well.
6830 For agenda display, Org mode extracts the time and displays it in a
6831 standard 24 hour format as part of the prefix.  The example times in
6832 the previous paragraphs would end up in the agenda like this:
6834 @example
6835     8:30-13:00 Arthur Dent lies in front of the bulldozer
6836    12:45...... Ford Prefect arrives and takes Arthur to the pub
6837    19:00...... The Vogon reads his poem
6838    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
6839 @end example
6841 @cindex time grid
6842 If the agenda is in single-day mode, or for the display of today, the
6843 timed entries are embedded in a time grid, like
6845 @example
6846     8:00...... ------------------
6847     8:30-13:00 Arthur Dent lies in front of the bulldozer
6848    10:00...... ------------------
6849    12:00...... ------------------
6850    12:45...... Ford Prefect arrives and takes Arthur to the pub
6851    14:00...... ------------------
6852    16:00...... ------------------
6853    18:00...... ------------------
6854    19:00...... The Vogon reads his poem
6855    20:00...... ------------------
6856    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
6857 @end example
6859 @vindex org-agenda-use-time-grid
6860 @vindex org-agenda-time-grid
6861 The time grid can be turned on and off with the variable
6862 @code{org-agenda-use-time-grid}, and can be configured with
6863 @code{org-agenda-time-grid}.
6865 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
6866 @subsection Sorting of agenda items
6867 @cindex sorting, of agenda items
6868 @cindex priorities, of agenda items
6869 Before being inserted into a view, the items are sorted.  How this is
6870 done depends on the type of view.
6871 @itemize @bullet
6872 @item
6873 @vindex org-agenda-files
6874 For the daily/weekly agenda, the items for each day are sorted.  The
6875 default order is to first collect all items containing an explicit
6876 time-of-day specification.  These entries will be shown at the beginning
6877 of the list, as a @emph{schedule} for the day.  After that, items remain
6878 grouped in categories, in the sequence given by @code{org-agenda-files}.
6879 Within each category, items are sorted by priority (@pxref{Priorities}),
6880 which is composed of the base priority (2000 for priority @samp{A}, 1000
6881 for @samp{B}, and 0 for @samp{C}), plus additional increments for
6882 overdue scheduled or deadline items.
6883 @item
6884 For the TODO list, items remain in the order of categories, but within
6885 each category, sorting takes place according to priority
6886 (@pxref{Priorities}).  The priority used for sorting derives from the
6887 priority cookie, with additions depending on how close an item is to its due
6888 or scheduled date.
6889 @item
6890 For tags matches, items are not sorted at all, but just appear in the
6891 sequence in which they are found in the agenda files.
6892 @end itemize
6894 @vindex org-agenda-sorting-strategy
6895 Sorting can be customized using the variable
6896 @code{org-agenda-sorting-strategy}, and may also include criteria based on
6897 the estimated effort of an entry (@pxref{Effort estimates}).
6899 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
6900 @section Commands in the agenda buffer
6901 @cindex commands, in agenda buffer
6903 Entries in the agenda buffer are linked back to the Org file or diary
6904 file where they originate.  You are not allowed to edit the agenda
6905 buffer itself, but commands are provided to show and jump to the
6906 original entry location, and to edit the Org files ``remotely'' from
6907 the agenda buffer.  In this way, all information is stored only once,
6908 removing the risk that your agenda and note files may diverge.
6910 Some commands can be executed with mouse clicks on agenda lines.  For
6911 the other commands, the cursor needs to be in the desired line.
6913 @table @kbd
6914 @tsubheading{Motion}
6915 @cindex motion commands in agenda
6916 @kindex n
6917 @item n
6918 Next line (same as @key{up} and @kbd{C-p}).
6919 @kindex p
6920 @item p
6921 Previous line (same as @key{down} and @kbd{C-n}).
6922 @tsubheading{View/Go to Org file}
6923 @kindex mouse-3
6924 @kindex @key{SPC}
6925 @item mouse-3
6926 @itemx @key{SPC}
6927 Display the original location of the item in another window.
6928 With prefix arg, make sure that the entire entry is made visible in the
6929 outline, not only the heading.
6931 @kindex L
6932 @item L
6933 Display original location and recenter that window.
6935 @kindex mouse-2
6936 @kindex mouse-1
6937 @kindex @key{TAB}
6938 @item mouse-2
6939 @itemx mouse-1
6940 @itemx @key{TAB}
6941 Go to the original location of the item in another window.  Under Emacs
6942 22, @kbd{mouse-1} will also works for this.
6944 @kindex @key{RET}
6945 @itemx @key{RET}
6946 Go to the original location of the item and delete other windows.
6948 @kindex F
6949 @item F
6950 @vindex org-agenda-start-with-follow-mode
6951 Toggle Follow mode.  In Follow mode, as you move the cursor through
6952 the agenda buffer, the other window always shows the corresponding
6953 location in the Org file.  The initial setting for this mode in new
6954 agenda buffers can be set with the variable
6955 @code{org-agenda-start-with-follow-mode}.
6957 @kindex C-c C-x b
6958 @item C-c C-x b
6959 Display the entire subtree of the current item in an indirect buffer.  With a
6960 numeric prefix argument N, go up to level N and then take that tree.  If N is
6961 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
6962 previously used indirect buffer.
6964 @kindex C-c C-o
6965 @item C-c C-o
6966 Follow a link in the entry.  This will offer a selection of any links in the
6967 text belonging to the referenced Org node.  If there is only one link, it
6968 will be followed without a selection prompt.
6970 @tsubheading{Change display}
6971 @cindex display changing, in agenda
6972 @kindex o
6973 @item o
6974 Delete other windows.
6976 @kindex v d
6977 @kindex d
6978 @kindex v w
6979 @kindex w
6980 @kindex v m
6981 @kindex v y
6982 @item v d @ @r{or short} @ d
6983 @itemx v w @ @r{or short} @ w
6984 @itemx v m
6985 @itemx v y
6986 Switch to day/week/month/year view.  When switching to day or week view,
6987 this setting becomes the default for subsequent agenda commands.  Since
6988 month and year views are slow to create, they do not become the default.
6989 A numeric prefix argument may be used to jump directly to a specific day
6990 of the year, ISO week, month, or year, respectively.  For example,
6991 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
6992 setting day, week, or month view, a year may be encoded in the prefix
6993 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
6994 2007.  If such a year specification has only one or two digits, it will
6995 be mapped to the interval 1938-2037.
6997 @kindex f
6998 @item f
6999 @vindex org-agenda-ndays
7000 Go forward in time to display the following @code{org-agenda-ndays} days.
7001 For example, if the display covers a week, switch to the following week.
7002 With prefix arg, go forward that many times @code{org-agenda-ndays} days.
7004 @kindex b
7005 @item b
7006 Go backward in time to display earlier dates.
7008 @kindex .
7009 @item .
7010 Go to today.
7012 @kindex j
7013 @item j
7014 Prompt for a date and go there.
7016 @kindex D
7017 @item D
7018 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
7020 @kindex v l
7021 @kindex l
7022 @item v l @ @r{or short} @ l
7023 @vindex org-log-done
7024 @vindex org-agenda-log-mode-items
7025 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
7026 logging was on (variable @code{org-log-done}) are shown in the agenda, as are
7027 entries that have been clocked on that day.  You can configure the entry
7028 types that should be included in log mode using the variable
7029 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
7030 all possible logbook entries, including state changes.  When called with two
7031 prefix args @kbd{C-u C-u}, show only logging information, nothing else.
7033 @kindex v [
7034 @kindex [
7035 @item v [ @ @r{or short} @ [
7036 Include inactive timestamps into the current view.  Only for weekly/daily
7037 agenda and timeline views.
7039 @kindex v a
7040 @kindex v A
7041 @item v a
7042 @itemx v A
7043 Toggle Archives mode.  In Archives mode, trees that are marked
7044 @code{ARCHIVED} are also scanned when producing the agenda.  When you use the
7045 capital @kbd{A}, even all archive files are included.  To exit archives mode,
7046 press @kbd{v a} again.
7048 @kindex v R
7049 @kindex R
7050 @item v R @ @r{or short} @ R
7051 @vindex org-agenda-start-with-clockreport-mode
7052 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly agenda will
7053 always show a table with the clocked times for the timespan and file scope
7054 covered by the current agenda view.  The initial setting for this mode in new
7055 agenda buffers can be set with the variable
7056 @code{org-agenda-start-with-clockreport-mode}.
7058 @kindex v E
7059 @kindex E
7060 @item v E @ @r{or short} @ E
7061 @vindex org-agenda-start-with-entry-text-mode
7062 @vindex org-agenda-entry-text-maxlines
7063 Toggle entry text mode.  In entry text mode, a number of lines from the Org
7064 outline node referenced by an agenda line will be displayed below the line.
7065 The maximum number of lines is given by the variable
7066 @code{org-agenda-entry-text-maxlines}.  Calling this command with a numeric
7067 prefix argument will temporarily modify that number to the prefix value.
7069 @kindex G
7070 @item G
7071 @vindex org-agenda-use-time-grid
7072 @vindex org-agenda-time-grid
7073 Toggle the time grid on and off.  See also the variables
7074 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
7076 @kindex r
7077 @item r
7078 Recreate the agenda buffer, for example to reflect the changes after
7079 modification of the timestamps of items with @kbd{S-@key{left}} and
7080 @kbd{S-@key{right}}.  When the buffer is the global TODO list, a prefix
7081 argument is interpreted to create a selective list for a specific TODO
7082 keyword.
7083 @kindex g
7084 @item g
7085 Same as @kbd{r}.
7087 @kindex s
7088 @kindex C-x C-s
7089 @item s
7090 @itemx C-x C-s
7091 Save all Org buffers in the current Emacs session, and also the locations of
7092 IDs.
7094 @kindex C-c C-x C-c
7095 @item C-c C-x C-c
7096 @vindex org-columns-default-format
7097 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
7098 view format is taken from the entry at point, or (if there is no entry at
7099 point), from the first entry in the agenda view.  So whatever the format for
7100 that entry would be in the original buffer (taken from a property, from a
7101 @code{#+COLUMNS} line, or from the default variable
7102 @code{org-columns-default-format}), will be used in the agenda.
7104 @kindex C-c C-x >
7105 @item C-c C-x >
7106 Remove the restriction lock on the agenda, if it is currently restricted to a
7107 file or subtree (@pxref{Agenda files}).
7109 @tsubheading{Secondary filtering and query editing}
7110 @cindex filtering, by tag and effort, in agenda
7111 @cindex tag filtering, in agenda
7112 @cindex effort filtering, in agenda
7113 @cindex query editing, in agenda
7115 @kindex /
7116 @item /
7117 @vindex org-agenda-filter-preset
7118 Filter the current agenda view with respect to a tag and/or effort estimates.
7119 The difference between this and a custom agenda command is that filtering is
7120 very fast, so that you can switch quickly between different filters without
7121 having to recreate the agenda@footnote{Custom commands can preset a filter by
7122 binding the variable @code{org-agenda-filter-preset} as an option.  This
7123 filter will then be applied to the view and persist as a basic filter through
7124 refreshes and more secondary filtering.}
7126 You will be prompted for a tag selection letter.  Pressing @key{TAB} at that
7127 prompt will offer use completion to select a tag (including any tags that do
7128 not have a selection character).  The command then hides all entries that do
7129 not contain or inherit this tag.  When called with prefix arg, remove the
7130 entries that @emph{do} have the tag.  A second @kbd{/} at the prompt will
7131 turn off the filter and unhide any hidden entries.  If the first key you
7132 press is either @kbd{+} or @kbd{-}, the previous filter will be narrowed by
7133 requiring or forbidding the selected additional tag.  Instead of pressing
7134 @kbd{+} or @kbd{-} after @kbd{/}, you can also immediately use the @kbd{\}
7135 command.
7137 @vindex org-sort-agenda-noeffort-is-high
7138 In order to filter for effort estimates, you should set-up allowed
7139 efforts globally, for example
7140 @lisp
7141 (setq org-global-properties
7142     '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
7143 @end lisp
7144 You can then filter for an effort by first typing an operator, one of
7145 @kbd{<}, @kbd{>}, and @kbd{=}, and then the one-digit index of an effort
7146 estimate in your array of allowed values, where @kbd{0} means the 10th value.
7147 The filter will then restrict to entries with effort smaller-or-equal, equal,
7148 or larger-or-equal than the selected value.  If the digits 0-9 are not used
7149 as fast access keys to tags, you can also simply press the index digit
7150 directly without an operator.  In this case, @kbd{<} will be assumed.  For
7151 application of the operator, entries without a defined effort will be treated
7152 according to the value of @code{org-sort-agenda-noeffort-is-high}.  To filter
7153 for tasks without effort definition, press @kbd{?} as the operator.
7155 @kindex \
7156 @item \
7157 Narrow the current agenda filter by an additional condition.  When called with
7158 prefix arg, remove the entries that @emph{do} have the tag, or that do match
7159 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
7160 @kbd{-} as the first key after the @kbd{/} command.
7162 @kindex [
7163 @kindex ]
7164 @kindex @{
7165 @kindex @}
7166 @item [ ] @{ @}
7167 @table @i
7168 @item @r{in} search view
7169 add new search words (@kbd{[} and @kbd{]}) or new regular expressions
7170 (@kbd{@{} and @kbd{@}}) to the query string.  The opening bracket/brace will
7171 add a positive search term prefixed by @samp{+}, indicating that this search
7172 term @i{must} occur/match in the entry.  The closing bracket/brace will add a
7173 negative search term which @i{must not} occur/match in the entry for it to be
7174 selected.
7175 @end table
7177 @tsubheading{Remote editing}
7178 @cindex remote editing, from agenda
7180 @item 0-9
7181 Digit argument.
7183 @cindex undoing remote-editing events
7184 @cindex remote editing, undo
7185 @kindex C-_
7186 @item C-_
7187 Undo a change due to a remote editing command.  The change is undone
7188 both in the agenda buffer and in the remote buffer.
7190 @kindex t
7191 @item t
7192 Change the TODO state of the item, both in the agenda and in the
7193 original org file.
7195 @kindex C-k
7196 @item C-k
7197 @vindex org-agenda-confirm-kill
7198 Delete the current agenda item along with the entire subtree belonging
7199 to it in the original Org file.  If the text to be deleted remotely
7200 is longer than one line, the kill needs to be confirmed by the user.  See
7201 variable @code{org-agenda-confirm-kill}.
7203 @kindex C-c C-w
7204 @item C-c C-w
7205 Refile the entry at point.
7207 @kindex a
7208 @item a
7209 Toggle the ARCHIVE tag for the current headline.
7211 @kindex A
7212 @item A
7213 Move the subtree corresponding to the current entry to its @emph{archive
7214 sibling}.
7216 @kindex $
7217 @item $
7218 Archive the subtree corresponding to the current headline.  This means the
7219 entry will be moved to the configured archive location, most likely a
7220 different file.
7222 @kindex T
7223 @item T
7224 @vindex org-agenda-show-inherited-tags
7225 Show all tags associated with the current item.  This is useful if you have
7226 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
7227 tags of a headline occasionally.
7229 @kindex :
7230 @item :
7231 Set tags for the current headline.  If there is an active region in the
7232 agenda, change a tag for all headings in the region.
7234 @kindex ,
7235 @item ,
7236 Set the priority for the current item.  Org mode prompts for the
7237 priority character. If you reply with @key{SPC}, the priority cookie
7238 is removed from the entry.
7240 @kindex P
7241 @item P
7242 Display weighted priority of current item.
7244 @kindex +
7245 @kindex S-@key{up}
7246 @item +
7247 @itemx S-@key{up}
7248 Increase the priority of the current item.  The priority is changed in
7249 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
7250 key for this.
7252 @kindex -
7253 @kindex S-@key{down}
7254 @item -
7255 @itemx S-@key{down}
7256 Decrease the priority of the current item.
7258 @kindex z
7259 @item z
7260 @vindex org-log-into-drawer
7261 Add a note to the entry.  This note will be recorded, and then files to the
7262 same location where state change notes are put.  Depending on
7263 @code{org-log-into-drawer}, this maybe inside a drawer.
7265 @kindex C-c C-a
7266 @item C-c C-a
7267 Dispatcher for all command related to attachments.
7269 @kindex C-c C-s
7270 @item C-c C-s
7271 Schedule this item
7273 @kindex C-c C-d
7274 @item C-c C-d
7275 Set a deadline for this item.
7277 @kindex k
7278 @item k
7279 Agenda actions, to set dates for selected items to the cursor date.
7280 This command also works in the calendar!  The command prompts for an
7281 additional key:
7282 @example
7283 m   @r{Mark the entry at point for action.  You can also make entries}
7284     @r{in Org files with @kbd{C-c C-x C-k}.}
7285 d   @r{Set the deadline of the marked entry to the date at point.}
7286 s   @r{Schedule the marked entry at the date at point.}
7287 r   @r{Call @code{org-remember} with the cursor date as default date.}
7288 @end example
7289 @noindent
7290 Press @kbd{r} afterward to refresh the agenda and see the effect of the
7291 command.
7293 @kindex S-@key{right}
7294 @item S-@key{right}
7295 Change the timestamp associated with the current line by one day into the
7296 future.  With a numeric prefix argument, change it by that many days.  For
7297 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  With a
7298 @kbd{C-u} prefix, change the time by one hour.  If you immediately repeat the
7299 command, it will continue to change hours even without the prefix arg.  With
7300 a double @kbd{C-u C-u} prefix, do the same for changing minutes.  The stamp
7301 is changed in the original Org file, but the change is not directly reflected
7302 in the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
7304 @kindex S-@key{left}
7305 @item S-@key{left}
7306 Change the timestamp associated with the current line by one day
7307 into the past.
7309 @kindex >
7310 @item >
7311 Change the timestamp associated with the current line to today.
7312 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
7313 on my keyboard.
7315 @kindex I
7316 @item I
7317 Start the clock on the current item.  If a clock is running already, it
7318 is stopped first.
7320 @kindex O
7321 @item O
7322 Stop the previously started clock.
7324 @kindex X
7325 @item X
7326 Cancel the currently running clock.
7328 @kindex J
7329 @item J
7330 Jump to the running clock in another window.
7332 @tsubheading{Bulk remote editing selected entries}
7333 @cindex remote editing, bulk, from agenda
7335 @kindex m
7336 @item s
7337 Mark the entry at point for bulk action.
7339 @kindex u
7340 @item u
7341 Unmark entry for bulk action.
7343 @kindex U
7344 @item U
7345 Unmark all marked entries for bulk action.
7347 @kindex B
7348 @item B
7349 Bulk action: act on all marked entries in the agenda.  This will prompt for
7350 another key to select the action to be applied:
7351 @example
7352 r  @r{Prompt for a single refile target and move all entries.  The entries}
7353    @r{will no longer be in the agenda, refresh (@kbd{g}) to bring them back.}
7354 $  @r{Archive all selected entries.}
7355 A  @r{Archive entries by moving them to their respective archive siblings.}
7356 t  @r{Change TODO state.  This prompts for a single TODO keyword and}
7357    @r{changes the state of all selected entries, bypassing blocking and}
7358    @r{suppressing logging notes (but not time stamps).}
7359 +  @r{Add a tag to all selected entries.}
7360 -  @r{Remove a tag from all selected entries.}
7361 s  @r{Schedule all items to a new date.  To shift existing schedule dates}
7362    @r{by a fixed number of days, use something starting with double plus}
7363    @r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
7364 d  @r{Set deadline to a specific date.}
7365 @end example
7368 @tsubheading{Calendar commands}
7369 @cindex calendar commands, from agenda
7370 @kindex c
7371 @item c
7372 Open the Emacs calendar and move to the date at the agenda cursor.
7374 @item c
7375 When in the calendar, compute and show the Org mode agenda for the
7376 date at the cursor.
7378 @cindex diary entries, creating from agenda
7379 @kindex i
7380 @item i
7381 Insert a new entry into the diary.  Prompts for the type of entry
7382 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
7383 entry in the diary, just as @kbd{i d}, etc., would do in the calendar.
7384 The date is taken from the cursor position.
7386 @kindex M
7387 @item M
7388 Show the phases of the moon for the three months around current date.
7390 @kindex S
7391 @item S
7392 Show sunrise and sunset times.  The geographical location must be set
7393 with calendar variables, see the documentation for the Emacs calendar.
7395 @kindex C
7396 @item C
7397 Convert the date at cursor into many other cultural and historic
7398 calendars.
7400 @kindex H
7401 @item H
7402 Show holidays for three months around the cursor date.
7404 @item M-x org-export-icalendar-combine-agenda-files
7405 Export a single iCalendar file containing entries from all agenda files.
7406 This is a globally available command, and also available in the agenda menu.
7408 @tsubheading{Exporting to a file}
7409 @kindex C-x C-w
7410 @item C-x C-w
7411 @cindex exporting agenda views
7412 @cindex agenda views, exporting
7413 @vindex org-agenda-exporter-settings
7414 Write the agenda view to a file.  Depending on the extension of the selected
7415 file name, the view will be exported as HTML (extension @file{.html} or
7416 @file{.htm}), Postscript (extension @file{.ps}), PDF (extension @file{.pdf}),
7417 Org-mode (extension @file{.org}), and plain text (any other extension).  When
7418 called with a @kbd{C-u} prefix argument, immediately open the newly created
7419 file.  Use the variable @code{org-agenda-exporter-settings} to set options
7420 for @file{ps-print} and for @file{htmlize} to be used during export.
7422 @tsubheading{Quit and Exit}
7423 @kindex q
7424 @item q
7425 Quit agenda, remove the agenda buffer.
7427 @kindex x
7428 @cindex agenda files, removing buffers
7429 @item x
7430 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
7431 for the compilation of the agenda.  Buffers created by the user to
7432 visit Org files will not be removed.
7433 @end table
7436 @node Custom agenda views, Exporting Agenda Views, Agenda commands, Agenda Views
7437 @section Custom agenda views
7438 @cindex custom agenda views
7439 @cindex agenda views, custom
7441 Custom agenda commands serve two purposes: to store and quickly access
7442 frequently used TODO and tags searches, and to create special composite
7443 agenda buffers.  Custom agenda commands will be accessible through the
7444 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
7446 @menu
7447 * Storing searches::            Type once, use often
7448 * Block agenda::                All the stuff you need in a single buffer
7449 * Setting Options::             Changing the rules
7450 @end menu
7452 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
7453 @subsection Storing searches
7455 The first application of custom searches is the definition of keyboard
7456 shortcuts for frequently used searches, either creating an agenda
7457 buffer, or a sparse tree (the latter covering of course only the current
7458 buffer).
7459 @kindex C-c a C
7460 @vindex org-agenda-custom-commands
7461 Custom commands are configured in the variable
7462 @code{org-agenda-custom-commands}.  You can customize this variable, for
7463 example by pressing @kbd{C-c a C}.  You can also directly set it with
7464 Emacs Lisp in @file{.emacs}.  The following example contains all valid
7465 search types:
7467 @lisp
7468 @group
7469 (setq org-agenda-custom-commands
7470       '(("w" todo "WAITING")
7471         ("W" todo-tree "WAITING")
7472         ("u" tags "+boss-urgent")
7473         ("v" tags-todo "+boss-urgent")
7474         ("U" tags-tree "+boss-urgent")
7475         ("f" occur-tree "\\<FIXME\\>")
7476         ("h" . "HOME+Name tags searches") ; description for "h" prefix
7477         ("hl" tags "+home+Lisa")
7478         ("hp" tags "+home+Peter")
7479         ("hk" tags "+home+Kim")))
7480 @end group
7481 @end lisp
7483 @noindent
7484 The initial string in each entry defines the keys you have to press
7485 after the dispatcher command @kbd{C-c a} in order to access the command.
7486 Usually this will be just a single character, but if you have many
7487 similar commands, you can also define two-letter combinations where the
7488 first character is the same in several combinations and serves as a
7489 prefix key@footnote{You can provide a description for a prefix key by
7490 inserting a cons cell with the prefix and the description.}.  The second
7491 parameter is the search type, followed by the string or regular
7492 expression to be used for the matching.  The example above will
7493 therefore define:
7495 @table @kbd
7496 @item C-c a w
7497 as a global search for TODO entries with @samp{WAITING} as the TODO
7498 keyword
7499 @item C-c a W
7500 as the same search, but only in the current buffer and displaying the
7501 results as a sparse tree
7502 @item C-c a u
7503 as a global tags search for headlines marked @samp{:boss:} but not
7504 @samp{:urgent:}
7505 @item C-c a v
7506 as the same search as @kbd{C-c a u}, but limiting the search to
7507 headlines that are also TODO items
7508 @item C-c a U
7509 as the same search as @kbd{C-c a u}, but only in the current buffer and
7510 displaying the result as a sparse tree
7511 @item C-c a f
7512 to create a sparse tree (again: current buffer only) with all entries
7513 containing the word @samp{FIXME}
7514 @item C-c a h
7515 as a prefix command for a HOME tags search where you have to press an
7516 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
7517 Peter, or Kim) as additional tag to match.
7518 @end table
7520 @node Block agenda, Setting Options, Storing searches, Custom agenda views
7521 @subsection Block agenda
7522 @cindex block agenda
7523 @cindex agenda, with block views
7525 Another possibility is the construction of agenda views that comprise
7526 the results of @emph{several} commands, each of which creates a block in
7527 the agenda buffer.  The available commands include @code{agenda} for the
7528 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
7529 for the global TODO list (as constructed with @kbd{C-c a t}), and the
7530 matching commands discussed above: @code{todo}, @code{tags}, and
7531 @code{tags-todo}.  Here are two examples:
7533 @lisp
7534 @group
7535 (setq org-agenda-custom-commands
7536       '(("h" "Agenda and Home-related tasks"
7537          ((agenda "")
7538           (tags-todo "home")
7539           (tags "garden")))
7540         ("o" "Agenda and Office-related tasks"
7541          ((agenda "")
7542           (tags-todo "work")
7543           (tags "office")))))
7544 @end group
7545 @end lisp
7547 @noindent
7548 This will define @kbd{C-c a h} to create a multi-block view for stuff
7549 you need to attend to at home.  The resulting agenda buffer will contain
7550 your agenda for the current week, all TODO items that carry the tag
7551 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
7552 command @kbd{C-c a o} provides a similar view for office tasks.
7554 @node Setting Options,  , Block agenda, Custom agenda views
7555 @subsection Setting options for custom commands
7556 @cindex options, for custom agenda views
7558 @vindex org-agenda-custom-commands
7559 Org mode contains a number of variables regulating agenda construction
7560 and display.  The global variables define the behavior for all agenda
7561 commands, including the custom commands.  However, if you want to change
7562 some settings just for a single custom view, you can do so.  Setting
7563 options requires inserting a list of variable names and values at the
7564 right spot in @code{org-agenda-custom-commands}.  For example:
7566 @lisp
7567 @group
7568 (setq org-agenda-custom-commands
7569       '(("w" todo "WAITING"
7570          ((org-agenda-sorting-strategy '(priority-down))
7571           (org-agenda-prefix-format "  Mixed: ")))
7572         ("U" tags-tree "+boss-urgent"
7573          ((org-show-following-heading nil)
7574           (org-show-hierarchy-above nil)))
7575         ("N" search ""
7576          ((org-agenda-files '("~org/notes.org"))
7577           (org-agenda-text-search-extra-files nil)))))
7578 @end group
7579 @end lisp
7581 @noindent
7582 Now the @kbd{C-c a w} command will sort the collected entries only by
7583 priority, and the prefix format is modified to just say @samp{  Mixed: }
7584 instead of giving the category of the entry.  The sparse tags tree of
7585 @kbd{C-c a U} will now turn out ultra-compact, because neither the
7586 headline hierarchy above the match, nor the headline following the match
7587 will be shown.  The command @kbd{C-c a N} will do a text search limited
7588 to only a single file.
7590 @vindex org-agenda-custom-commands
7591 For command sets creating a block agenda,
7592 @code{org-agenda-custom-commands} has two separate spots for setting
7593 options.  You can add options that should be valid for just a single
7594 command in the set, and options that should be valid for all commands in
7595 the set.  The former are just added to the command entry, the latter
7596 must come after the list of command entries.  Going back to the block
7597 agenda example (@pxref{Block agenda}), let's change the sorting strategy
7598 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
7599 the results for GARDEN tags query in the opposite order,
7600 @code{priority-up}.  This would look like this:
7602 @lisp
7603 @group
7604 (setq org-agenda-custom-commands
7605       '(("h" "Agenda and Home-related tasks"
7606          ((agenda)
7607           (tags-todo "home")
7608           (tags "garden"
7609                 ((org-agenda-sorting-strategy '(priority-up)))))
7610          ((org-agenda-sorting-strategy '(priority-down))))
7611         ("o" "Agenda and Office-related tasks"
7612          ((agenda)
7613           (tags-todo "work")
7614           (tags "office")))))
7615 @end group
7616 @end lisp
7618 As you see, the values and parentheses setting is a little complex.
7619 When in doubt, use the customize interface to set this variable---it
7620 fully supports its structure.  Just one caveat: when setting options in
7621 this interface, the @emph{values} are just Lisp expressions.  So if the
7622 value is a string, you need to add the double-quotes around the value
7623 yourself.
7626 @node Exporting Agenda Views, Agenda column view, Custom agenda views, Agenda Views
7627 @section Exporting Agenda Views
7628 @cindex agenda views, exporting
7630 If you are away from your computer, it can be very useful to have a printed
7631 version of some agenda views to carry around.  Org mode can export custom
7632 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
7633 @file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
7634 ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
7635 a PDF file with also create the postscript file.}, and iCalendar files.  If
7636 you want to do this only occasionally, use the command
7638 @table @kbd
7639 @kindex C-x C-w
7640 @item C-x C-w
7641 @cindex exporting agenda views
7642 @cindex agenda views, exporting
7643 @vindex org-agenda-exporter-settings
7644 Write the agenda view to a file.  Depending on the extension of the selected
7645 file name, the view will be exported as HTML (extension @file{.html} or
7646 @file{.htm}), Postscript (extension @file{.ps}), iCalendar (extension
7647 @file{.ics}), Org-mode (extension @file{.org}), or plain text (any other
7648 extension).  Use the variable @code{org-agenda-exporter-settings} to set
7649 options for @file{ps-print} and for @file{htmlize} to be used during export,
7650 for example
7652 @vindex org-agenda-add-entry-text-maxlines
7653 @vindex htmlize-output-type
7654 @vindex ps-number-of-columns
7655 @vindex ps-landscape-mode
7656 @lisp
7657 (setq org-agenda-exporter-settings
7658       '((ps-number-of-columns 2)
7659         (ps-landscape-mode t)
7660         (org-agenda-add-entry-text-maxlines 5)
7661         (htmlize-output-type 'css)))
7662 @end lisp
7663 @end table
7665 If you need to export certain agenda views frequently, you can associate
7666 any custom agenda command with a list of output file names
7667 @footnote{If you want to store standard views like the weekly agenda
7668 or the global TODO list as well, you need to define custom commands for
7669 them in order to be able to specify file names.}.  Here is an example
7670 that first defines custom commands for the agenda and the global
7671 TODO list, together with a number of files to which to export them.
7672 Then we define two block agenda commands and specify file names for them
7673 as well.  File names can be relative to the current working directory,
7674 or absolute.
7676 @lisp
7677 @group
7678 (setq org-agenda-custom-commands
7679       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
7680         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
7681         ("h" "Agenda and Home-related tasks"
7682          ((agenda "")
7683           (tags-todo "home")
7684           (tags "garden"))
7685          nil
7686          ("~/views/home.html"))
7687         ("o" "Agenda and Office-related tasks"
7688          ((agenda)
7689           (tags-todo "work")
7690           (tags "office"))
7691          nil
7692          ("~/views/office.ps" "~/calendars/office.ics"))))
7693 @end group
7694 @end lisp
7696 The extension of the file name determines the type of export.  If it is
7697 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
7698 the buffer to HTML and save it to this file name.  If the extension is
7699 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
7700 Postscript output.  If the extension is @file{.ics}, iCalendar export is
7701 run export over all files that were used to construct the agenda, and
7702 limit the export to entries listed in the agenda.  Any other
7703 extension produces a plain ASCII file.
7705 The export files are @emph{not} created when you use one of those
7706 commands interactively because this might use too much overhead.
7707 Instead, there is a special command to produce @emph{all} specified
7708 files in one step:
7710 @table @kbd
7711 @kindex C-c a e
7712 @item C-c a e
7713 Export all agenda views that have export file names associated with
7714 them.
7715 @end table
7717 You can use the options section of the custom agenda commands to also
7718 set options for the export commands.  For example:
7720 @lisp
7721 (setq org-agenda-custom-commands
7722       '(("X" agenda ""
7723          ((ps-number-of-columns 2)
7724           (ps-landscape-mode t)
7725           (org-agenda-prefix-format " [ ] ")
7726           (org-agenda-with-colors nil)
7727           (org-agenda-remove-tags t))
7728          ("theagenda.ps"))))
7729 @end lisp
7731 @noindent
7732 This command sets two options for the Postscript exporter, to make it
7733 print in two columns in landscape format---the resulting page can be cut
7734 in two and then used in a paper agenda.  The remaining settings modify
7735 the agenda prefix to omit category and scheduling information, and
7736 instead include a checkbox to check off items.  We also remove the tags
7737 to make the lines compact, and we don't want to use colors for the
7738 black-and-white printer.  Settings specified in
7739 @code{org-agenda-exporter-settings} will also apply, but the settings
7740 in @code{org-agenda-custom-commands} take precedence.
7742 @noindent
7743 From the command line you may also use
7744 @example
7745 emacs -f org-batch-store-agenda-views -kill
7746 @end example
7747 @noindent
7748 or, if you need to modify some parameters@footnote{Quoting depends on the
7749 system you use, please check the FAQ for examples.}
7750 @example
7751 emacs -eval '(org-batch-store-agenda-views                      \
7752               org-agenda-ndays 30                               \
7753               org-agenda-start-day "2007-11-01"                 \
7754               org-agenda-include-diary nil                      \
7755               org-agenda-files (quote ("~/org/project.org")))'  \
7756       -kill
7757 @end example
7758 @noindent
7759 which will create the agenda views restricted to the file
7760 @file{~/org/project.org}, without diary entries and with a 30-day
7761 extent.
7763 You can also extract agenda information in a way that allows further
7764 processing by other programs.  See @ref{Extracting agenda information}, for
7765 more information.
7768 @node Agenda column view,  , Exporting Agenda Views, Agenda Views
7769 @section Using column view in the agenda
7770 @cindex column view, in agenda
7771 @cindex agenda, column view
7773 Column view (@pxref{Column view}) is normally used to view and edit
7774 properties embedded in the hierarchical structure of an Org file.  It can be
7775 quite useful to use column view also from the agenda, where entries are
7776 collected by certain criteria.
7778 @table @kbd
7779 @kindex C-c C-x C-c
7780 @item C-c C-x C-c
7781 Turn on column view in the agenda.
7782 @end table
7784 To understand how to use this properly, it is important to realize that the
7785 entries in the agenda are no longer in their proper outline environment.
7786 This causes the following issues:
7788 @enumerate
7789 @item
7790 @vindex org-columns-default-format
7791 @vindex org-overriding-columns-format
7792 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
7793 entries in the agenda are collected from different files, and different files
7794 may have different @code{COLUMNS} formats, this is a non-trivial problem.
7795 Org first checks if the variable @code{org-overriding-columns-format} is
7796 currently set, and if so, takes the format from there.  Otherwise it takes
7797 the format associated with the first item in the agenda, or, if that item
7798 does not have a specific format (defined in a property, or in its file), it
7799 uses @code{org-columns-default-format}.
7800 @item
7801 @cindex property, special, CLOCKSUM
7802 If any of the columns has a summary type defined (@pxref{Column attributes}),
7803 turning on column view in the agenda will visit all relevant agenda files and
7804 make sure that the computations of this property are up to date.  This is
7805 also true for the special @code{CLOCKSUM} property.  Org will then sum the
7806 values displayed in the agenda.  In the daily/weekly agenda, the sums will
7807 cover a single day, in all other views they cover the entire block.  It is
7808 vital to realize that the agenda may show the same entry @emph{twice} (for
7809 example as scheduled and as a deadline), and it may show two entries from the
7810 same hierarchy (for example a @emph{parent} and its @emph{child}).  In these
7811 cases, the summation in the agenda will lead to incorrect results because
7812 some values will count double.
7813 @item
7814 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
7815 the entire clocked time for this item.  So even in the daily/weekly agenda,
7816 the clocksum listed in column view may originate from times outside the
7817 current view.  This has the advantage that you can compare these values with
7818 a column listing the planned total effort for a task---one of the major
7819 applications for column view in the agenda.  If you want information about
7820 clocked time in the displayed period use clock table mode (press @kbd{R} in
7821 the agenda).
7822 @end enumerate
7825 @node Embedded LaTeX, Exporting, Agenda Views, Top
7826 @chapter Embedded La@TeX{}
7827 @cindex @TeX{} interpretation
7828 @cindex La@TeX{} interpretation
7830 Plain ASCII is normally sufficient for almost all note taking.  One
7831 exception, however, are scientific notes which need to be able to contain
7832 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
7833 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
7834 features described here as ``La@TeX{}'' are really from @TeX{}, but for
7835 simplicity I am blurring this distinction.}  is widely used to typeset
7836 scientific documents. Org mode supports embedding La@TeX{} code into its
7837 files, because many academics are used to reading La@TeX{} source code, and
7838 because it can be readily processed into images for HTML production.
7840 It is not necessary to mark La@TeX{} macros and code in any special way.
7841 If you observe a few conventions, Org mode knows how to find it and what
7842 to do with it.
7844 @menu
7845 * Math symbols::                @TeX{} macros for symbols and Greek letters
7846 * Subscripts and superscripts::  Simple syntax for raising/lowering text
7847 * LaTeX fragments::             Complex formulas made easy
7848 * Processing LaTeX fragments::  Previewing La@TeX{} processing
7849 * CDLaTeX mode::                Speed up entering of formulas
7850 @end menu
7852 @node Math symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
7853 @section Math symbols
7854 @cindex math symbols
7855 @cindex @TeX{} macros
7857 You can use La@TeX{} macros to insert special symbols like @samp{\alpha} to
7858 indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
7859 for these macros is available, just type @samp{\} and maybe a few letters,
7860 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike La@TeX{}
7861 code, Org mode allows these macros to be present without surrounding math
7862 delimiters, for example:
7864 @example
7865 Angles are written as Greek letters \alpha, \beta and \gamma.
7866 @end example
7867 @noindent
7868 During HTML export (@pxref{HTML export}), these symbols are translated
7869 into the proper syntax for HTML, for the above examples this is
7870 @samp{&alpha;} and @samp{&rarr;}, respectively.  If you need such a symbol
7871 inside a word, terminate it like this: @samp{\Aacute@{@}stor}.
7873 @node Subscripts and superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
7874 @section Subscripts and superscripts
7875 @cindex subscript
7876 @cindex superscript
7878 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
7879 and subscripts.  Again, these can be used without embedding them in
7880 math-mode delimiters.  To increase the readability of ASCII text, it is
7881 not necessary (but OK) to surround multi-character sub- and superscripts
7882 with curly braces.  For example
7884 @example
7885 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
7886 the sun is R_@{sun@} = 6.96 x 10^8 m.
7887 @end example
7889 To avoid interpretation as raised or lowered text, you can quote
7890 @samp{^} and @samp{_} with a backslash: @samp{\^} and @samp{\_}.
7892 During HTML export (@pxref{HTML export}), subscript and superscripts
7893 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
7895 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
7896 @section La@TeX{} fragments
7897 @cindex La@TeX{} fragments
7899 @vindex org-format-latex-header
7900 With symbols, sub- and superscripts, HTML is pretty much at its end when
7901 it comes to representing mathematical formulas@footnote{Yes, there is
7902 MathML, but that is not yet fully supported by many browsers, and there
7903 is no decent converter for turning La@TeX{} or ASCII representations of
7904 formulas into MathML. So for the time being, converting formulas into
7905 images seems the way to go.}. More complex expressions need a dedicated
7906 formula processor. To this end, Org mode can contain arbitrary La@TeX{}
7907 fragments. It provides commands to preview the typeset result of these
7908 fragments, and upon export to HTML, all fragments will be converted to
7909 images and inlined into the HTML document@footnote{The La@TeX{} export
7910 will not use images for displaying La@TeX{} fragments but include these
7911 fragments directly into the La@TeX{} code.}. For this to work you
7912 need to be on a system with a working La@TeX{} installation. You also
7913 need the @file{dvipng} program, available at
7914 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
7915 will be used when processing a fragment can be configured with the
7916 variable @code{org-format-latex-header}.
7918 La@TeX{} fragments don't need any special marking at all.  The following
7919 snippets will be identified as La@TeX{} source code:
7920 @itemize @bullet
7921 @item
7922 Environments of any kind.  The only requirement is that the
7923 @code{\begin} statement appears on a new line, preceded by only
7924 whitespace.
7925 @item
7926 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
7927 currency specifications, single @samp{$} characters are only recognized as
7928 math delimiters if the enclosed text contains at most two line breaks, is
7929 directly attached to the @samp{$} characters with no whitespace in between,
7930 and if the closing @samp{$} is followed by whitespace, punctuation or a dash.
7931 For the other delimiters, there is no such restriction, so when in doubt, use
7932 @samp{\(...\)} as inline math delimiters.
7933 @end itemize
7935 @noindent For example:
7937 @example
7938 \begin@{equation@}                          % arbitrary environments,
7939 x=\sqrt@{b@}                                % even tables, figures
7940 \end@{equation@}                            % etc
7942 If $a^2=b$ and \( b=2 \), then the solution must be
7943 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
7944 @end example
7946 @noindent
7947 @vindex org-format-latex-options
7948 If you need any of the delimiter ASCII sequences for other purposes, you
7949 can configure the option @code{org-format-latex-options} to deselect the
7950 ones you do not wish to have interpreted by the La@TeX{} converter.
7952 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
7953 @section Processing LaTeX fragments
7954 @cindex LaTeX fragments, preview
7956 La@TeX{} fragments can be processed to produce preview images of the
7957 typeset expressions:
7959 @table @kbd
7960 @kindex C-c C-x C-l
7961 @item C-c C-x C-l
7962 Produce a preview image of the La@TeX{} fragment at point and overlay it
7963 over the source code.  If there is no fragment at point, process all
7964 fragments in the current entry (between two headlines).  When called
7965 with a prefix argument, process the entire subtree.  When called with
7966 two prefix arguments, or when the cursor is before the first headline,
7967 process the entire buffer.
7968 @kindex C-c C-c
7969 @item C-c C-c
7970 Remove the overlay preview images.
7971 @end table
7973 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
7974 converted into images and inlined into the document if the following
7975 setting is active:
7977 @lisp
7978 (setq org-export-with-LaTeX-fragments t)
7979 @end lisp
7981 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
7982 @section Using CDLa@TeX{} to enter math
7983 @cindex CDLa@TeX{}
7985 CDLa@TeX{} mode is a minor mode that is normally used in combination with a
7986 major La@TeX{} mode like AUC@TeX{} in order to speed-up insertion of
7987 environments and math templates.  Inside Org mode, you can make use of
7988 some of the features of CDLa@TeX{} mode.  You need to install
7989 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
7990 AUC@TeX{}) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
7991 Don't use CDLa@TeX{} mode itself under Org mode, but use the light
7992 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
7993 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
7994 Org files with
7996 @lisp
7997 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
7998 @end lisp
8000 When this mode is enabled, the following features are present (for more
8001 details see the documentation of CDLa@TeX{} mode):
8002 @itemize @bullet
8003 @kindex C-c @{
8004 @item
8005 Environment templates can be inserted with @kbd{C-c @{}.
8006 @item
8007 @kindex @key{TAB}
8008 The @key{TAB} key will do template expansion if the cursor is inside a
8009 La@TeX{} fragment@footnote{Org mode has a method to test if the cursor is
8010 inside such a fragment, see the documentation of the function
8011 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
8012 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
8013 correctly inside the first brace.  Another @key{TAB} will get you into
8014 the second brace.  Even outside fragments, @key{TAB} will expand
8015 environment abbreviations at the beginning of a line.  For example, if
8016 you write @samp{equ} at the beginning of a line and press @key{TAB},
8017 this abbreviation will be expanded to an @code{equation} environment.
8018 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
8019 @item
8020 @kindex _
8021 @kindex ^
8022 @vindex cdlatex-simplify-sub-super-scripts
8023 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
8024 characters together with a pair of braces.  If you use @key{TAB} to move
8025 out of the braces, and if the braces surround only a single character or
8026 macro, they are removed again (depending on the variable
8027 @code{cdlatex-simplify-sub-super-scripts}).
8028 @item
8029 @kindex `
8030 Pressing the backquote @kbd{`} followed by a character inserts math
8031 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
8032 after the backquote, a help window will pop up.
8033 @item
8034 @kindex '
8035 Pressing the single-quote @kbd{'} followed by another character modifies
8036 the symbol before point with an accent or a font.  If you wait more than
8037 1.5 seconds after the backquote, a help window will pop up.  Character
8038 modification will work only inside La@TeX{} fragments, outside the quote
8039 is normal.
8040 @end itemize
8042 @node Exporting, Publishing, Embedded LaTeX, Top
8043 @chapter Exporting
8044 @cindex exporting
8046 Org-mode documents can be exported into a variety of other formats.  For
8047 printing and sharing of notes, ASCII export produces a readable and simple
8048 version of an Org file.  HTML export allows you to publish a notes file on
8049 the web, while the XOXO format provides a solid base for exchange with a
8050 broad range of other applications. La@TeX{} export lets you use Org mode and
8051 its structured editing functions to easily create La@TeX{} files.  DocBook
8052 export makes it possible to convert Org files to many other formats using
8053 DocBook tools.  To incorporate entries with associated times like deadlines
8054 or appointments into a desktop calendar program like iCal, Org mode can also
8055 produce extracts in the iCalendar format.  Currently Org mode only supports
8056 export, not import of these different formats.
8058 Org supports export of selected regions when @code{transient-mark-mode} is
8059 enabled (default in Emacs 23).
8061 @menu
8062 * Markup rules::                Which structures are recognized?
8063 * Selective export::            Using tags to select and exclude trees
8064 * Export options::              Per-file export settings
8065 * The export dispatcher::       How to access exporter commands
8066 * ASCII export::                Exporting to plain ASCII
8067 * HTML export::                 Exporting to HTML
8068 * LaTeX and PDF export::        Exporting to La@TeX{}, and processing to PDF
8069 * DocBook export::              Exporting to DocBook
8070 * XOXO export::                 Exporting to XOXO
8071 * iCalendar export::            Exporting in iCalendar format
8072 @end menu
8074 @node Markup rules, Selective export, Exporting, Exporting
8075 @section Markup rules
8077 When exporting Org-mode documents, the exporter tries to reflect the
8078 structure of the document as accurately as possible in the backend.  Since
8079 export targets like HTML, La@TeX{}, or DocBook allow much richer formatting,
8080 Org mode has rules on how to prepare text for rich export.  This section
8081 summarizes the markup rules used in an Org-mode buffer.
8083 @menu
8084 * Document title::              How the document title is determined
8085 * Headings and sections::       The main structure of the exported document
8086 * Table of contents::           If, where, how to create a table of contents
8087 * Initial text::                Text before the first headline
8088 * Lists::                       Plain lists are exported
8089 * Paragraphs::                  What determines beginning and ending
8090 * Literal examples::            Source code and other examples
8091 * Include files::               Include the contents of a file during export
8092 * Tables exported::             Tables are exported richly
8093 * Inlined images::              How to inline images during export
8094 * Footnote markup::             ASCII representation of footnotes
8095 * Emphasis and monospace::      To bold or not to bold
8096 * TeX macros and LaTeX fragments::  Create special, rich export.
8097 * Horizontal rules::            A line across the page
8098 * Comment lines::               Some lines will not be exported
8099 * Macro replacement::           Global replacement of place holders
8100 @end menu
8102 @node Document title, Headings and sections, Markup rules, Markup rules
8103 @subheading Document title
8104 @cindex document title, markup rules
8106 @noindent
8107 The title of the exported document is taken from the special line
8109 @cindex #+TITLE
8110 @example
8111 #+TITLE: This is the title of the document
8112 @end example
8114 @noindent
8115 If this line does not exist, the title is derived from the first non-empty,
8116 non-comment line in the buffer.  If no such line exists, or if you have
8117 turned off exporting of the text before the first headline (see below), the
8118 title will be the file name without extension.
8120 @cindex property, EXPORT_TITLE
8121 If you are exporting only a subtree by marking is as the region, the heading
8122 of the subtree will become the title of the document.  If the subtree has a
8123 property @code{EXPORT_TITLE}, that will take precedence.
8125 @node Headings and sections, Table of contents, Document title, Markup rules
8126 @subheading Headings and sections
8127 @cindex headings and sections, markup rules
8129 @vindex org-export-headline-levels
8130 The outline structure of the document as described in @ref{Document
8131 Structure}, forms the basis for defining sections of the exported document.
8132 However, since the outline structure is also used for (for example) lists of
8133 tasks, only the first three outline levels will be used as headings.  Deeper
8134 levels will become itemized lists.  You can change the location of this
8135 switch globally by setting the variable @code{org-export-headline-levels}, or on a
8136 per-file basis with a line
8138 @cindex #+OPTIONS
8139 @example
8140 #+OPTIONS: H:4
8141 @end example
8143 @node Table of contents, Initial text, Headings and sections, Markup rules
8144 @subheading Table of contents
8145 @cindex table of contents, markup rules
8147 @vindex org-export-with-toc
8148 The table of contents is normally inserted directly before the first headline
8149 of the file.  If you would like to get it to a different location, insert the
8150 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
8151 location.  The depth of the table of contents is by default the same as the
8152 number of headline levels, but you can choose a smaller number, or turn off
8153 the table of contents entirely, by configuring the variable
8154 @code{org-export-with-toc}, or on a per-file basis with a line like
8156 @example
8157 #+OPTIONS: toc:2          (only to two levels in TOC)
8158 #+OPTIONS: toc:nil        (no TOC at all)
8159 @end example
8161 @node Initial text, Lists, Table of contents, Markup rules
8162 @subheading Text before the first headline
8163 @cindex text before first headline, markup rules
8164 @cindex #+TEXT
8166 Org mode normally exports the text before the first headline, and even uses
8167 the first line as the document title.  The text will be fully marked up.  If
8168 you need to include literal HTML, La@TeX{}, or DocBook code, use the special
8169 constructs described below in the sections for the individual exporters.
8171 @vindex org-export-skip-text-before-1st-heading
8172 Some people like to use the space before the first headline for setup and
8173 internal links and therefore would like to control the exported text before
8174 the first headline in a different way.  You can do so by setting the variable
8175 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
8176 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
8178 @noindent
8179 If you still want to have some text before the first headline, use the
8180 @code{#+TEXT} construct:
8182 @example
8183 #+OPTIONS: skip:t
8184 #+TEXT: This text will go before the *first* headline.
8185 #+TEXT: [TABLE-OF-CONTENTS]
8186 #+TEXT: This goes between the table of contents and the first headline
8187 @end example
8189 @node Lists, Paragraphs, Initial text, Markup rules
8190 @subheading Lists
8191 @cindex lists, markup rules
8193 Plain lists as described in @ref{Plain lists}, are translated to the backend's
8194 syntax for such lists.  Most backends support unordered, ordered, and
8195 description lists.
8197 @node Paragraphs, Literal examples, Lists, Markup rules
8198 @subheading Paragraphs, line breaks, and quoting
8199 @cindex paragraphs, markup rules
8201 Paragraphs are separated by at least one empty line.  If you need to enforce
8202 a line break within a paragraph, use @samp{\\} at the end of a line.
8204 To keep the line breaks in a region, but otherwise use normal formatting, you
8205 can use this construct, which can also be used to format poetry.
8207 @cindex #+BEGIN_VERSE
8208 @example
8209 #+BEGIN_VERSE
8210  Great clouds overhead
8211  Tiny black birds rise and fall
8212  Snow covers Emacs
8214      -- AlexSchroeder
8215 #+END_VERSE
8216 @end example
8218 When quoting a passage from another document, it is customary to format this
8219 as a paragraph that is indented on both the left and the right margin.  You
8220 can include quotations in Org-mode documents like this:
8222 @cindex #+BEGIN_QUOTE
8223 @example
8224 #+BEGIN_QUOTE
8225 Everything should be made as simple as possible,
8226 but not any simpler -- Albert Einstein
8227 #+END_QUOTE
8228 @end example
8230 If you would like to center some text, do it like this:
8231 @cindex #+BEGIN_CENTER
8232 @example
8233 #+BEGIN_CENTER
8234 Everything should be made as simple as possible, \\
8235 but not any simpler
8236 #+END_CENTER
8237 @end example
8239 @node Literal examples, Include files, Paragraphs, Markup rules
8240 @subheading Literal examples
8241 @cindex literal examples, markup rules
8242 @cindex code line references, markup rules
8244 You can include literal examples that should not be subjected to
8245 markup.  Such examples will be typeset in monospace, so this is well suited
8246 for source code and similar examples.
8247 @cindex #+BEGIN_EXAMPLE
8249 @example
8250 #+BEGIN_EXAMPLE
8251 Some example from a text file.
8252 #+END_EXAMPLE
8253 @end example
8255 Note that such blocks may be @i{indented} in order to align nicely with
8256 indented text and in particular with plain list structure (@pxref{Plain
8257 lists}).  For simplicity when using small examples, you can also start the
8258 example lines with a colon followed by a space.  There may also be additional
8259 whitespace before the colon:
8261 @example
8262 Here is an example
8263    : Some example from a text file.
8264 @end example
8266 @cindex formatting source code, markup rules
8267 If the example is source code from a programming language, or any other text
8268 that can be marked up by font-lock in Emacs, you can ask for the example to
8269 look like the fontified Emacs buffer@footnote{Currently this works for the
8270 HTML backend, and requires the @file{htmlize.el} package version 1.34 or
8271 later.  It also works for LaTeX with the listings package, if you turn on the
8272 option @code{org-export-latex-listings} and make sure that the listings
8273 package is included by the LaTeX header.}.  This is done with the @samp{src}
8274 block, where you also need to specify the name of the major mode that should
8275 be used to fontify the example:
8276 @cindex #+BEGIN_SRC
8278 @example
8279 #+BEGIN_SRC emacs-lisp
8280 (defun org-xor (a b)
8281    "Exclusive or."
8282    (if a (not b) b))
8283 #+END_SRC
8284 @end example
8286 Both in @code{example} and in @code{src} snippets, you can add a @code{-n}
8287 switch to the end of the @code{BEGIN} line, to get the lines of the example
8288 numbered.  If you use a @code{+n} switch, the numbering from the previous
8289 numbered snippet will be continued in the current one.  In literal examples,
8290 Org will interpret strings like @samp{(ref:name)} as labels, and use them as
8291 targets for special hyperlinks like @code{[[(name)]]} (@ie the reference name
8292 enclosed in single parenthesis).  In HTML, hovering the mouse over such a
8293 link will remote-highlight the corresponding code line, which is kind of
8294 cool.
8296 You can also add a @code{-r} switch which @i{removes} the labels from the
8297 source code@footnote{Adding @code{-k} to @code{-n -r} will @i{keep} the
8298 labels in the source code while using line numbers for the links, which might
8299 be useful to explain those in an org-mode example code.}.  With the @code{-n}
8300 switch, links to these references will be labeled by the line numbers from
8301 the code listing, otherwise links will use the labels with no parentheses.
8302 Here is an example:
8304 @example
8305 #+BEGIN_SRC emacs-lisp -n -r
8306 (save-excursion                  (ref:sc)
8307    (goto-char (point-min))       (ref:jump)
8308 #+END_SRC
8309 In line [[(sc)]] we remember the current position.  [[(jump)][Line (jump)]]
8310 jumps to point-min.
8311 @end example
8313 @vindex org-coderef-label-format
8314 If the syntax for the label format conflicts with the language syntax, use a
8315 @code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
8316 -n -r -l "((%s))"}.  See also the variable @code{org-coderef-label-format}.
8318 HTML export also allows examples to be published as text areas, @xref{Text
8319 areas in HTML export}.
8321 @table @kbd
8322 @kindex C-c '
8323 @item C-c '
8324 Edit the source code example at point in its native mode.  This works by
8325 switching to a temporary buffer with the source code.  You need to exit by
8326 pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*}
8327 or @samp{#} will get a comma prepended, to keep them from being interpreted
8328 by Org as outline nodes or special comments.  These commas will be striped
8329 for editing with @kbd{C-c '}, and also for export.}, the edited version will
8330 then replace the old version in the Org buffer.  Fixed-width regions
8331 (where each line starts with a colon followed by a space) will be edited
8332 using @code{artist-mode}@footnote{You may select a different-mode with the
8333 variable @code{org-edit-fixed-width-region-mode}.} to allow creating ASCII
8334 drawings easily.  Using this command in an empty line will create a new
8335 fixed-width region.
8336 @kindex C-c l
8337 @item C-c l
8338 Calling @code{org-store-link} while editing a source code example in a
8339 temporary buffer created with @kbd{C-c '} will prompt for a label, make sure
8340 that it is unique in the current buffer, and insert it with the proper
8341 formatting like @samp{(ref:label)} at the end of the current line.  Then the
8342 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
8343 @end table
8346 @node Include files, Tables exported, Literal examples, Markup rules
8347 @subheading Include files
8348 @cindex include files, markup rules
8350 During export, you can include the content of another file.  For example, to
8351 include your @file{.emacs} file, you could use:
8352 @cindex #+INCLUDE
8354 @example
8355 #+INCLUDE: "~/.emacs" src emacs-lisp
8356 @end example
8357 @noindent
8358 The optional second and third parameter are the markup (e.g. @samp{quote},
8359 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
8360 language for formatting the contents.  The markup is optional, if it is not
8361 given, the text will be assumed to be in Org mode format and will be
8362 processed normally.  The include line will also allow additional keyword
8363 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
8364 first line and for each following line, as well as any options accepted by
8365 the selected markup.  For example, to include a file as an item, use
8367 @example
8368 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
8369 @end example
8371 @table @kbd
8372 @kindex C-c '
8373 @item C-c '
8374 Visit the include file at point.
8375 @end table
8377 @node Tables exported, Inlined images, Include files, Markup rules
8378 @subheading Tables
8379 @cindex tables, markup rules
8381 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
8382 the @file{table.el} package will be exported properly.  For Org mode tables,
8383 the lines before the first horizontal separator line will become table header
8384 lines.  You can use the following lines somewhere before the table to assign
8385 a caption and a label for cross references:
8387 @example
8388 #+CAPTION: This is the caption for the next table (or link)
8389 #+LABEL:   tbl:basic-data
8390 @end example
8392 @node Inlined images, Footnote markup, Tables exported, Markup rules
8393 @subheading Inlined Images
8394 @cindex inlined images, markup rules
8396 Some backends (HTML, La@TeX{}, and DocBook) allow you to directly include images
8397 into the exported document.  Org does this, if a link to an image files does
8398 not have a description part, for example @code{[[./img/a.jpg]]}.  If you wish
8399 to define a caption for the image and maybe a label for internal cross
8400 references, you can use (before, but close to the link)
8402 @example
8403 #+CAPTION: This is the caption for the next figure link (or table)
8404 #+LABEL:   fig:SED-HR4049
8405 @end example
8407 You may also define additional attributes for the figure.  As this is
8408 backend-specific, see the sections about the individual backends for more
8409 information.
8411 @node Footnote markup, Emphasis and monospace, Inlined images, Markup rules
8412 @subheading Footnote markup
8413 @cindex footnotes, markup rules
8414 @cindex @file{footnote.el}
8416 Footnotes defined in the way described in @ref{Footnotes}, will be exported by
8417 all backends.  Org allows multiple references to the same note, and
8418 different backends support this to varying degrees.
8420 @node Emphasis and monospace, TeX macros and LaTeX fragments, Footnote markup, Markup rules
8421 @subheading Emphasis and monospace
8423 @cindex underlined text, markup rules
8424 @cindex bold text, markup rules
8425 @cindex italic text, markup rules
8426 @cindex verbatim text, markup rules
8427 @cindex code text, markup rules
8428 @cindex strike-through text, markup rules
8429 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
8430 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
8431 in the code and verbatim string is not processed for Org-mode specific
8432 syntax, it is exported verbatim.
8434 @node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
8435 @subheading @TeX{} macros and La@TeX{} fragments
8436 @cindex La@TeX{} fragments, markup rules
8437 @cindex @TeX{} macros, markup rules
8438 @cindex HTML entities
8439 @cindex La@TeX{} entities
8441 @vindex org-html-entities
8442 A @TeX{}-like syntax is used to specify special characters.  Where possible,
8443 these will be transformed into the native format of the exporter backend.
8444 Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
8445 output, and as @code{$\alpha$} in the La@TeX{} output.  Similarly,
8446 @code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
8447 This applies for a large number of entities, with names taken from both HTML
8448 and La@TeX{}, see the variable @code{org-html-entities} for the complete
8449 list.  If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
8450 after having typed the backslash and optionally a few characters
8451 (@pxref{Completion}).
8453 La@TeX{} fragments are converted into images for HTML export, and they are
8454 written literally into the La@TeX{} export.  See also @ref{Embedded LaTeX}.
8456 Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
8457 @samp{...} are all converted into special commands creating hyphens of
8458 different lengths or a compact set of dots.
8460 @node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
8461 @subheading  Horizontal rules
8462 @cindex horizontal rules, markup rules
8463 A line consisting of only dashes, and at least 5 of them, will be
8464 exported as a horizontal line (@samp{<hr/>} in HTML).
8466 @node Comment lines, Macro replacement, Horizontal rules, Markup rules
8467 @subheading Comment lines
8468 @cindex comment lines
8469 @cindex exporting, not
8470 @cindex #+BEGIN_COMMENT
8472 Lines starting with @samp{#} in column zero are treated as comments and will
8473 never be exported.  Also entire subtrees starting with the word
8474 @samp{COMMENT} will never be exported.  Finally, regions surrounded by
8475 @samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
8477 @table @kbd
8478 @kindex C-c ;
8479 @item C-c ;
8480 Toggle the COMMENT keyword at the beginning of an entry.
8481 @end table
8483 @node Macro replacement,  , Comment lines, Markup rules
8484 @subheading Macro replacement
8485 @cindex macro replacement, during export
8486 @cindex #+MACRO
8488 You can define text snippets with
8490 @example
8491 #+MACRO: name   replacement text $1, $2 are arguments
8492 @end example
8494 @noindent which can be referenced anywhere in the document (even in
8495 code examples) with @code{@{@{@{name(arg1,arg2)@}@}@}}.  In addition to
8496 defined macros, @code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc.,
8497 will reference information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and
8498 similar lines.  Also, @code{@{@{@{date(@var{FORMAT})@}@}@}} and
8499 @code{@{@{@{modification-time(@var{FORMAT})@}@}@}} refer to current date time
8500 and to the modification time of the file being exported, respectively.
8501 @var{FORMAT} should be a format string understood by
8502 @code{format-time-string}.
8504 @node Selective export, Export options, Markup rules, Exporting
8505 @section Selective export
8506 @cindex export, selective by tags
8508 @vindex org-export-select-tags
8509 @vindex org-export-exclude-tags
8510 You may use tags to select the parts of a document that should be exported,
8511 or to exclude parts from export.  This behavior is governed by two variables:
8512 @code{org-export-select-tags} and @code{org-export-exclude-tags}.
8514 Org first checks if any of the @emph{select} tags is present in the buffer.
8515 If yes, all trees that do not carry one of these tags will be excluded.  If a
8516 selected tree is a subtree, the heading hierarchy above it will also be
8517 selected for export, but not the text below those headings.
8519 @noindent
8520 If none of the select tags is found, the whole buffer will be selected for
8521 export.
8523 @noindent
8524 Finally, all subtrees that are marked by any of the @emph{exclude} tags will
8525 be removed from the export buffer.
8527 @node Export options, The export dispatcher, Selective export, Exporting
8528 @section Export options
8529 @cindex options, for export
8531 @cindex completion, of option keywords
8532 The exporter recognizes special lines in the buffer which provide
8533 additional information.  These lines may be put anywhere in the file.
8534 The whole set of lines can be inserted into the buffer with @kbd{C-c
8535 C-e t}.  For individual lines, a good way to make sure the keyword is
8536 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
8537 (@pxref{Completion}).   For a summary of other in-buffer settings not
8538 specifically related to export, see @ref{In-buffer settings}.
8539 In particular, note that you can place commonly-used (export) options in
8540 a separate file which can be included using @code{#+SETUPFILE}.
8542 @table @kbd
8543 @kindex C-c C-e t
8544 @item C-c C-e t
8545 Insert template with export options, see example below.
8546 @end table
8548 @cindex #+TITLE
8549 @cindex #+AUTHOR
8550 @cindex #+DATE
8551 @cindex #+EMAIL
8552 @cindex #+DESCRIPTION
8553 @cindex #+KEYWORDS
8554 @cindex #+LANGUAGE
8555 @cindex #+TEXT
8556 @cindex #+OPTIONS
8557 @cindex #+BIND
8558 @cindex #+LINK_UP
8559 @cindex #+LINK_HOME
8560 @cindex #+EXPORT_SELECT_TAGS
8561 @cindex #+EXPORT_EXCLUDE_TAGS
8562 @cindex #+LATEX_HEADER
8563 @vindex user-full-name
8564 @vindex user-mail-address
8565 @vindex org-export-default-language
8566 @example
8567 #+TITLE:       the title to be shown (default is the buffer name)
8568 #+AUTHOR:      the author (default taken from @code{user-full-name})
8569 #+DATE:        a date, fixed, of a format string for @code{format-time-string}
8570 #+EMAIL:       his/her email address (default from @code{user-mail-address})
8571 #+DESCRIPTION: the page description, @eg for the XHTML meta tag
8572 #+KEYWORDS:    the page keywords, @eg for the XHTML meta tag
8573 #+LANGUAGE:    language for HTML, @eg @samp{en} (@code{org-export-default-language})
8574 #+TEXT:        Some descriptive text to be inserted at the beginning.
8575 #+TEXT:        Several lines may be given.
8576 #+OPTIONS:     H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
8577 #+BIND:        lisp-var lisp-val, e.g.: org-export-latex-low-levels itemize
8578                @r{You need to confirm using these, or configure @code{org-export-allow-BIND}}
8579 #+LINK_UP:     the ``up'' link of an exported page
8580 #+LINK_HOME:   the ``home'' link of an exported page
8581 #+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage@{xyz@}
8582 #+EXPORT_SELECT_TAGS:   Tags that select a tree for export
8583 #+EXPORT_EXCLUDE_TAGS:  Tags that exclude a tree from export
8584 @end example
8586 @noindent
8587 The OPTIONS line is a compact@footnote{If you want to configure many options
8588 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
8589 you can:
8590 @cindex headline levels
8591 @cindex section-numbers
8592 @cindex table of contents
8593 @cindex line-break preservation
8594 @cindex quoted HTML tags
8595 @cindex fixed-width sections
8596 @cindex tables
8597 @cindex @TeX{}-like syntax for sub- and superscripts
8598 @cindex footnotes
8599 @cindex special strings
8600 @cindex emphasized text
8601 @cindex @TeX{} macros
8602 @cindex La@TeX{} fragments
8603 @cindex author info, in export
8604 @cindex time info, in export
8605 @example
8606 H:         @r{set the number of headline levels for export}
8607 num:       @r{turn on/off section-numbers}
8608 toc:       @r{turn on/off table of contents, or set level limit (integer)}
8609 \n:        @r{turn on/off line-break-preservation}
8610 @@:         @r{turn on/off quoted HTML tags}
8611 ::         @r{turn on/off fixed-width sections}
8612 |:         @r{turn on/off tables}
8613 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
8614            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
8615            @r{the simple @code{a_b} will be left as it is.}
8616 -:         @r{turn on/off conversion of special strings.}
8617 f:         @r{turn on/off footnotes like this[1].}
8618 todo:      @r{turn on/off inclusion of TODO keywords into exported text}
8619 pri:       @r{turn on/off priority cookies}
8620 tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
8621 <:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
8622 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
8623 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
8624 LaTeX:     @r{turn on/off La@TeX{} fragments}
8625 skip:      @r{turn on/off skipping the text before the first heading}
8626 author:    @r{turn on/off inclusion of author name/email into exported file}
8627 creator:   @r{turn on/off inclusion of creator info into exported file}
8628 timestamp: @r{turn on/off inclusion creation time into exported file}
8629 d:         @r{turn on/off inclusion of drawers}
8630 @end example
8631 @noindent
8632 These options take effect in both the HTML and La@TeX{} export, except
8633 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
8634 @code{nil} for the La@TeX{} export.
8636 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
8637 calling an export command, the subtree can overrule some of the file's export
8638 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
8639 @code{EXPORT_TEXT}, @code{EXPORT_AUTHOR}, @code{EXPORT_DATE}, and
8640 @code{EXPORT_OPTIONS}.
8642 @node The export dispatcher, ASCII export, Export options, Exporting
8643 @section The export dispatcher
8644 @cindex dispatcher, for export commands
8646 All export commands can be reached using the export dispatcher, which is a
8647 prefix key that prompts for an additional key specifying the command.
8648 Normally the entire file is exported, but if there is an active region that
8649 contains one outline tree, the first heading is used as document title and
8650 the subtrees are exported.
8652 @table @kbd
8653 @kindex C-c C-e
8654 @item C-c C-e
8655 @vindex org-export-run-in-background
8656 Dispatcher for export and publishing commands.  Displays a help-window
8657 listing the additional key(s) needed to launch an export or publishing
8658 command.  The prefix arg is passed through to the exporter.  A double prefix
8659 @kbd{C-u C-u} causes most commands to be executed in the background, in a
8660 separate Emacs process@footnote{To make this behavior the default, customize
8661 the variable @code{org-export-run-in-background}.}.
8662 @kindex C-c C-e v
8663 @item C-c C-e v
8664 Like @kbd{C-c C-e}, but only export the text that is currently visible
8665 (@ie not hidden by outline visibility).
8666 @kindex C-u C-u C-c C-e
8667 @item C-u C-u C-c C-e
8668 @vindex org-export-run-in-background
8669 Call an the exporter, but reverse the setting of
8670 @code{org-export-run-in-background}, @ie request background processing if
8671 not set, or force processing in the current Emacs process if set.
8672 @end table
8674 @node ASCII export, HTML export, The export dispatcher, Exporting
8675 @section ASCII export
8676 @cindex ASCII export
8678 ASCII export produces a simple and very readable version of an Org-mode
8679 file.
8681 @cindex region, active
8682 @cindex active region
8683 @cindex transient-mark-mode
8684 @table @kbd
8685 @kindex C-c C-e a
8686 @item C-c C-e a
8687 @cindex property, EXPORT_FILE_NAME
8688 Export as ASCII file.  For an Org file, @file{myfile.org}, the ASCII file
8689 will be @file{myfile.txt}.  The file will be overwritten without
8690 warning.  If there is an active region@footnote{This requires
8691 @code{transient-mark-mode} be turned on.}, only the region will be
8692 exported. If the selected region is a single tree@footnote{To select the
8693 current subtree, use @kbd{C-c @@}.}, the tree head will
8694 become the document title.  If the tree head entry has or inherits an
8695 @code{EXPORT_FILE_NAME} property, that name will be used for the
8696 export.
8697 @kindex C-c C-e A
8698 @item C-c C-e A
8699 Export to a temporary buffer, do not create a file.
8700 @kindex C-c C-e v a
8701 @item C-c C-e v a
8702 Export only the visible part of the document.
8703 @end table
8705 @cindex headline levels, for exporting
8706 In the exported version, the first 3 outline levels will become
8707 headlines, defining a general document structure.  Additional levels
8708 will be exported as itemized lists.  If you want that transition to occur
8709 at a different level, specify it with a prefix argument.  For example,
8711 @example
8712 @kbd{C-1 C-c C-e a}
8713 @end example
8715 @noindent
8716 creates only top level headlines and does the rest as items.  When
8717 headlines are converted to items, the indentation of the text following
8718 the headline is changed to fit nicely under the item.  This is done with
8719 the assumption that the first body line indicates the base indentation of
8720 the body text.  Any indentation larger than this is adjusted to preserve
8721 the layout relative to the first line.  Should there be lines with less
8722 indentation than the first, these are left alone.
8724 @vindex org-export-ascii-links-to-notes
8725 Links will be exported in a footnote-like style, with the descriptive part in
8726 the text and the link in a note before the next heading.  See the variable
8727 @code{org-export-ascii-links-to-notes} for details and other options.
8729 @node HTML export, LaTeX and PDF export, ASCII export, Exporting
8730 @section HTML export
8731 @cindex HTML export
8733 Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
8734 HTML formatting, in ways similar to John Gruber's @emph{markdown}
8735 language, but with additional support for tables.
8737 @menu
8738 * HTML Export commands::        How to invoke HTML export
8739 * Quoting HTML tags::           Using direct HTML in Org mode
8740 * Links::                       Transformation of links for HTML
8741 * Tables in HTML export::       How to modify the formatting of tables
8742 * Images in HTML export::       How to insert figures into HTML output
8743 * Text areas in HTML export::   An alternative way to show an example
8744 * CSS support::                 Changing the appearance of the output
8745 * Javascript support::          Info and Folding in a web browser
8746 @end menu
8748 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
8749 @subsection HTML export commands
8751 @cindex region, active
8752 @cindex active region
8753 @cindex transient-mark-mode
8754 @table @kbd
8755 @kindex C-c C-e h
8756 @item C-c C-e h
8757 @cindex property, EXPORT_FILE_NAME
8758 Export as HTML file @file{myfile.html}.  For an Org file @file{myfile.org},
8759 the ASCII file will be @file{myfile.html}.  The file will be overwritten
8760 without warning.  If there is an active region@footnote{This requires
8761 @code{transient-mark-mode} be turned on.}, only the region will be
8762 exported. If the selected region is a single tree@footnote{To select the
8763 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
8764 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
8765 property, that name will be used for the export.
8766 @kindex C-c C-e b
8767 @item C-c C-e b
8768 Export as HTML file and immediately open it with a browser.
8769 @kindex C-c C-e H
8770 @item C-c C-e H
8771 Export to a temporary buffer, do not create a file.
8772 @kindex C-c C-e R
8773 @item C-c C-e R
8774 Export the active region to a temporary buffer.  With a prefix argument, do
8775 not produce the file header and footer, but just the plain HTML section for
8776 the region.  This is good for cut-and-paste operations.
8777 @kindex C-c C-e v h
8778 @kindex C-c C-e v b
8779 @kindex C-c C-e v H
8780 @kindex C-c C-e v R
8781 @item C-c C-e v h
8782 @item C-c C-e v b
8783 @item C-c C-e v H
8784 @item C-c C-e v R
8785 Export only the visible part of the document.
8786 @item M-x org-export-region-as-html
8787 Convert the region to HTML under the assumption that it was Org-mode
8788 syntax before.  This is a global command that can be invoked in any
8789 buffer.
8790 @item M-x org-replace-region-by-HTML
8791 Replace the active region (assumed to be in Org-mode syntax) by HTML
8792 code.
8793 @end table
8795 @cindex headline levels, for exporting
8796 In the exported version, the first 3 outline levels will become headlines,
8797 defining a general document structure.  Additional levels will be exported as
8798 itemized lists.  If you want that transition to occur at a different level,
8799 specify it with a numeric prefix argument.  For example,
8801 @example
8802 @kbd{C-2 C-c C-e b}
8803 @end example
8805 @noindent
8806 creates two levels of headings and does the rest as items.
8808 @node Quoting HTML tags, Links, HTML Export commands, HTML export
8809 @subsection Quoting HTML tags
8811 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
8812 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
8813 which should be interpreted as such, mark them with @samp{@@} as in
8814 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
8815 simple tags.  For more extensive HTML that should be copied verbatim to
8816 the exported file use either
8818 @cindex #+HTML
8819 @cindex #+BEGIN_HTML
8820 @example
8821 #+HTML: Literal HTML code for export
8822 @end example
8824 @noindent or
8825 @cindex #+BEGIN_HTML
8827 @example
8828 #+BEGIN_HTML
8829 All lines between these markers are exported literally
8830 #+END_HTML
8831 @end example
8834 @node Links, Tables in HTML export, Quoting HTML tags, HTML export
8835 @subsection Links
8837 @cindex links, in HTML export
8838 @cindex internal links, in HTML export
8839 @cindex external links, in HTML export
8840 Internal links (@pxref{Internal links}) will continue to work in HTML.  This
8841 includes automatic links created by radio targets (@pxref{Radio
8842 targets}).  Links to external files will still work if the target file is on
8843 the same @i{relative} path as the published Org file.  Links to other
8844 @file{.org} files will be translated into HTML links under the assumption
8845 that an HTML version also exists of the linked file, at the same relative
8846 path.  @samp{id:} links can then be used to jump to specific entries across
8847 files.  For information related to linking files while publishing them to a
8848 publishing directory see @ref{Publishing links}.
8850 If you want to specify attributes for links, you can do so using a special
8851 @code{#+ATTR_HTML} line to define attributes that will be added to the
8852 @code{<a>} or @code{<img>} tags.  Here is an example that sets @code{title}
8853 and @code{style} attributes for a link:
8855 @cindex #+ATTR_HTML
8856 @example
8857 #+ATTR_HTML: title="The Org-mode homepage" style="color:red;"
8858 [[http://orgmode.org]]
8859 @end example
8861 @node Tables in HTML export, Images in HTML export, Links, HTML export
8862 @subsection Tables
8863 @cindex tables, in HTML
8864 @vindex org-export-html-table-tag
8866 Org-mode tables are exported to HTML using the table tag defined in
8867 @code{org-export-html-table-tag}.  The default setting makes tables without
8868 cell borders and frame.  If you would like to change this for individual
8869 tables, place somthing like the following before the table:
8871 @cindex #+CAPTION
8872 @example
8873 #+CAPTION: This is a table with lines around and between cells
8874 #+ATTR_HTML: border="2" rules="all" frame="all"
8875 @end example
8877 @node Images in HTML export, Text areas in HTML export, Tables in HTML export, HTML export
8878 @subsection Images
8880 @cindex images, inline in HTML
8881 @cindex inlining images in HTML
8882 @vindex org-export-html-inline-images
8883 HTML export can inline images given as links in the Org file, and
8884 it can make an image the clickable part of a link.  By
8885 default@footnote{But see the variable
8886 @code{org-export-html-inline-images}.}, images are inlined if a link does
8887 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
8888 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
8889 @samp{the image} that points to the image.  If the description part
8890 itself is a @code{file:} link or a @code{http:} URL pointing to an
8891 image, this image will be inlined and activated so that clicking on the
8892 image will activate the link.  For example, to include a thumbnail that
8893 will link to a high resolution version of the image, you could use:
8895 @example
8896 [[file:highres.jpg][file:thumb.jpg]]
8897 @end example
8899 If you need to add attributes to an inlines image, use a @code{#+ATTR_HTML},
8900 for example:
8902 @cindex #+CAPTION
8903 @example
8904 #+CAPTION: A black cat stalking a spider
8905 #+ATTR_HTML: alt="cat/spider image" title="one second before action"
8906 [[./img/a.jpg]]
8907 @end example
8909 @noindent
8910 and you could use @code{http} addresses just as well.
8912 @node Text areas in HTML export, CSS support, Images in HTML export, HTML export
8913 @subsection Text areas
8915 @cindex text areas, in HTML
8916 An alternative way to publish literal code examples in HTML is to use text
8917 areas, where the example can even be edited before pasting it into an
8918 application.  It is triggered by a @code{-t} switch at an @code{example} or
8919 @code{src} block.  Using this switch disables any options for syntax and
8920 label highlighting, and line numbering, which may be present.  You may also
8921 use @code{-h} and @code{-w} switches to specify the height and width of the
8922 text area, which default to the number of lines in the example, and 80,
8923 respectively.  For example
8925 @example
8926 #+BEGIN_EXAMPLE -t -w 40
8927 (defun org-xor (a b)
8928    "Exclusive or."
8929    (if a (not b) b))
8930 #+END_EXAMPLE
8931 @end example
8934 @node CSS support, Javascript support, Text areas in HTML export, HTML export
8935 @subsection CSS support
8936 @cindex CSS, for HTML export
8937 @cindex HTML export, CSS
8939 @vindex org-export-html-todo-kwd-class-prefix
8940 @vindex org-export-html-tag-class-prefix
8941 You can also give style information for the exported file.  The HTML exporter
8942 assigns the following special CSS classes@footnote{If the classes on TODO
8943 keywords and tags lead to conflicts, use the variables
8944 @code{org-export-html-todo-kwd-class-prefix} and
8945 @code{org-export-html-tag-class-prefix} to make them unique.} to appropriate
8946 parts of the document---your style specifications may change these, in
8947 addition to any of the standard classes like for headlines, tables, etc.
8948 @example
8949 p.author            @r{author information, including email}
8950 p.date              @r{publishing date}
8951 p.creator           @r{creator info, about org-mode version}
8952 .title              @r{document title}
8953 .todo               @r{TODO keywords, all not-done states}
8954 .done               @r{the DONE keywords, all stated the count as done}
8955 .WAITING            @r{each TODO keyword also uses a class named after itself}
8956 .timestamp          @r{timestamp}
8957 .timestamp-kwd      @r{keyword associated with a timestamp, like SCHEDULED}
8958 .timestamp-wrapper  @r{span around keyword plus timestamp}
8959 .tag                @r{tag in a headline}
8960 ._HOME              @r{each tag uses itself as a class, "@@" replaced by "_"}
8961 .target             @r{target for links}
8962 .linenr             @r{the line number in a code example}
8963 .code-highlighted   @r{for highlighting referenced code lines}
8964 div.outline-N       @r{div for outline level N (headline plus text))}
8965 div.outline-text-N  @r{extra div for text at outline level N}
8966 .section-number-N   @r{section number in headlines, different for each level}
8967 div.figure          @r{how to format an inlined image}
8968 pre.src             @r{formatted source code}
8969 pre.example         @r{normal example}
8970 p.verse             @r{verse paragraph}
8971 div.footnotes       @r{footnote section headline}
8972 p.footnote          @r{footnote definition paragraph, containing a footnote}
8973 .footref            @r{a footnote reference number (always a <sup>)}
8974 .footnum            @r{footnote number in footnote definition (always <sup>)}
8975 @end example
8977 @vindex org-export-html-style-default
8978 @vindex org-export-html-style-include-default
8979 @vindex org-export-html-style
8980 @vindex org-export-html-extra
8981 @vindex org-export-html-style-default
8982 Each exported file contains a compact default style that defines these
8983 classes in a basic way@footnote{This style is defined in the constant
8984 @code{org-export-html-style-default}, which you should not modify.  To turn
8985 inclusion of these defaults off, customize
8986 @code{org-export-html-style-include-default}}.  You may overwrite these
8987 settings, or add to them by using the variables @code{org-export-html-style}
8988 (for Org-wide settings) and @code{org-export-html-style-extra} (for more
8989 granular settings, like file-local settings).  To set the latter variable
8990 individually for each file, you can use
8992 @cindex #+STYLE
8993 @example
8994 #+STYLE: <link rel="stylesheet" type="text/css" href="stylesheet.css" />
8995 @end example
8997 @noindent
8998 For longer style definitions, you can use several such lines.  You could also
8999 directly write a @code{<style>} @code{</style>} section in this way, without
9000 referring to an external file.
9002 @c FIXME: More about header and footer styles
9003 @c FIXME: Talk about links and targets.
9005 @node Javascript support,  , CSS support, HTML export
9006 @subsection Javascript supported display of web pages
9008 @cindex Rose, Sebastian
9009 Sebastian Rose has written a JavaScript program especially designed to
9010 enhance the web viewing experience of HTML files created with Org.  This
9011 program allows you to view large files in two different ways.  The first one
9012 is an @emph{Info}-like mode where each section is displayed separately and
9013 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
9014 as well, press @kbd{?} for an overview of the available keys).  The second
9015 view type is a @emph{folding} view much like Org provides inside Emacs.  The
9016 script is available at @url{http://orgmode.org/org-info.js} and you can find
9017 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
9018 We host the script at our site, but if you use it a lot, you might
9019 not want to be dependent on @url{orgmode.org} and prefer to install a local
9020 copy on your own web server.
9022 To use the script, you need to make sure that the @file{org-jsinfo.el} module
9023 gets loaded.  It should be loaded by default, but you can try @kbd{M-x
9024 customize-variable @key{RET} org-modules @key{RET}} to convince yourself that
9025 this is indeed the case.  All it then takes to make use of the program is
9026 adding a single line to the Org file:
9028 @cindex #+INFOJS_OPT
9029 @example
9030 #+INFOJS_OPT: view:info toc:nil
9031 @end example
9033 @noindent
9034 If this line is found, the HTML header will automatically contain the code
9035 needed to invoke the script.  Using the line above, you can set the following
9036 viewing options:
9038 @example
9039 path:    @r{The path to the script.  The default is to grab the script from}
9040          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
9041          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
9042 view:    @r{Initial view when website is first shown.  Possible values are:}
9043          info      @r{Info-like interface with one section per page.}
9044          overview  @r{Folding interface, initially showing only top-level.}
9045          content   @r{Folding interface, starting with all headlines visible.}
9046          showall   @r{Folding interface, all headlines and text visible.}
9047 sdepth:  @r{Maximum headline level that will still become an independent}
9048          @r{section for info and folding modes.  The default is taken from}
9049          @r{@code{org-export-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
9050          @r{If this is smaller than in @code{org-export-headline-levels}, each}
9051          @r{info/folding section can still contain child headlines.}
9052 toc:     @r{Should the table of content @emph{initially} be visible?}
9053          @r{Even when @code{nil}, you can always get to the "toc" with @kbd{i}.}
9054 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
9055          @r{the variables @code{org-export-headline-levels} and @code{org-export-with-toc}.}
9056 ftoc:    @r{Does the css of the page specify a fixed position for the "toc"?}
9057          @r{If yes, the toc will never be displayed as a section.}
9058 ltoc:    @r{Should there be short contents (children) in each section?}
9059          @r{Make this @code{above} if the section should be above initial text.}
9060 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
9061          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
9062 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
9063          @r{default), only one such button will be present.}
9064 @end example
9065 @noindent
9066 @vindex org-infojs-options
9067 @vindex org-export-html-use-infojs
9068 You can choose default values for these options by customizing the variable
9069 @code{org-infojs-options}.  If you always want to apply the script to your
9070 pages, configure the variable @code{org-export-html-use-infojs}.
9072 @node LaTeX and PDF export, DocBook export, HTML export, Exporting
9073 @section La@TeX{} and PDF export
9074 @cindex La@TeX{} export
9075 @cindex PDF export
9076 @cindex Guerry, Bastian
9078 Org mode contains a La@TeX{} exporter written by Bastien Guerry.  With
9079 further processing, this backend is also used to produce PDF output.  Since
9080 the La@TeX{} output uses @file{hyperref} to implement links and cross
9081 references, the PDF output file will be fully linked.
9083 @menu
9084 * LaTeX/PDF export commands::   Which key invokes which commands
9085 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
9086 * Sectioning structure::        Changing sectioning in La@TeX{} output
9087 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
9088 * Images in LaTeX export::      How to insert figures into La@TeX{} output
9089 @end menu
9091 @node LaTeX/PDF export commands, Quoting LaTeX code, LaTeX and PDF export, LaTeX and PDF export
9092 @subsection La@TeX{} export commands
9094 @cindex region, active
9095 @cindex active region
9096 @cindex transient-mark-mode
9097 @table @kbd
9098 @kindex C-c C-e l
9099 @item C-c C-e l
9100 @cindex property EXPORT_FILE_NAME
9101 Export as La@TeX{} file @file{myfile.tex}.  For an Org file
9102 @file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
9103 be overwritten without warning.  If there is an active region@footnote{This
9104 requires @code{transient-mark-mode} be turned on.}, only the region will be
9105 exported. If the selected region is a single tree@footnote{To select the
9106 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9107 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
9108 property, that name will be used for the export.
9109 @kindex C-c C-e L
9110 @item C-c C-e L
9111 Export to a temporary buffer, do not create a file.
9112 @kindex C-c C-e v l
9113 @kindex C-c C-e v L
9114 @item C-c C-e v l
9115 @item C-c C-e v L
9116 Export only the visible part of the document.
9117 @item M-x org-export-region-as-latex
9118 Convert the region to La@TeX{} under the assumption that it was Org mode
9119 syntax before.  This is a global command that can be invoked in any
9120 buffer.
9121 @item M-x org-replace-region-by-latex
9122 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
9123 code.
9124 @kindex C-c C-e p
9125 @item C-c C-e p
9126 Export as La@TeX{} and then process to PDF.
9127 @kindex C-c C-e d
9128 @item C-c C-e d
9129 Export as La@TeX{} and then process to PDF, then open the resulting PDF file.
9130 @end table
9132 @cindex headline levels, for exporting
9133 @vindex org-latex-low-levels
9134 In the exported version, the first 3 outline levels will become
9135 headlines, defining a general document structure.  Additional levels
9136 will be exported as description lists.  The exporter can ignore them or
9137 convert them to a custom string depending on
9138 @code{org-latex-low-levels}.
9140 If you want that transition to occur at a different level, specify it
9141 with a numeric prefix argument. For example,
9143 @example
9144 @kbd{C-2 C-c C-e l}
9145 @end example
9147 @noindent
9148 creates two levels of headings and does the rest as items.
9150 @node Quoting LaTeX code, Sectioning structure, LaTeX/PDF export commands, LaTeX and PDF export
9151 @subsection Quoting La@TeX{} code
9153 Embedded La@TeX{} as described in @ref{Embedded LaTeX}, will be correctly
9154 inserted into the La@TeX{} file.  This includes simple macros like
9155 @samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
9156 you can add special code that should only be present in La@TeX{} export with
9157 the following constructs:
9159 @cindex #+LaTeX
9160 @cindex #+BEGIN_LaTeX
9161 @example
9162 #+LaTeX: Literal LaTeX code for export
9163 @end example
9165 @noindent or
9166 @cindex #+BEGIN_LaTeX
9168 @example
9169 #+BEGIN_LaTeX
9170 All lines between these markers are exported literally
9171 #+END_LaTeX
9172 @end example
9174 @node  Sectioning structure, Tables in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
9175 @subsection Sectioning structure
9176 @cindex La@TeX{} class
9177 @cindex La@TeX{} sectioning structure
9179 By default, the La@TeX{} output uses the class @code{article}.
9181 @vindex org-export-latex-default-class
9182 @vindex org-export-latex-classes
9183 @cindex #+LATEX_HEADER
9184 @cindex #+LATEX_CLASS
9185 @cindex property, LATEX_CLASS
9186 You can change this globally by setting a different value for
9187 @code{org-export-latex-default-class} or locally by adding an option like
9188 @code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
9189 property that applies when exporting a region containing only this (sub)tree.
9190 The class should be listed in @code{org-export-latex-classes}, where you can
9191 also define the sectioning structure for each class, as well as defining
9192 additional classes.  You can also use @code{#+LATEX_HEADER:
9193 \usepackage@{xyz@}} to add lines to the header.
9195 @node Tables in LaTeX export, Images in LaTeX export, Sectioning structure, LaTeX and PDF export
9196 @subsection Tables in La@TeX{} export
9197 @cindex tables, in La@TeX{} export
9199 For La@TeX{} export of a table, you can specify a label and a caption
9200 (@pxref{Markup rules}).  You can also use the @code{ATTR_LaTeX} line to
9201 request a longtable environment for the table, so that it may span several
9202 pages.  Finally, you can set the alignment string:
9204 @cindex #+CAPTION
9205 @cindex #+LABEL
9206 @cindex #+ATTR_LaTeX
9207 @example
9208 #+CAPTION: A long table
9209 #+LABEL: tbl:long
9210 #+ATTR_LaTeX: longtable align=l|lp@{3cm@}r|l
9211 | ..... | ..... |
9212 | ..... | ..... |
9213 @end example
9216 @node Images in LaTeX export,  , Tables in LaTeX export, LaTeX and PDF export
9217 @subsection Images in La@TeX{} export
9218 @cindex images, inline in La@TeX{}
9219 @cindex inlining images in La@TeX{}
9221 Images that are linked to without a description part in the link, like
9222 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
9223 output files resulting from La@TeX{} output.  Org will use an
9224 @code{\includegraphics} macro to insert the image.  If you have specified a
9225 caption and/or a label as described in @ref{Markup rules}, the figure will
9226 be wrapped into a @code{figure} environment and thus become a floating
9227 element.  Finally, you can use an @code{#+ATTR_LaTeX:} line to specify the
9228 options that can be used in the optional argument of the
9229 @code{\includegraphics} macro.
9231 @cindex #+CAPTION
9232 @cindex #+LABEL
9233 @cindex #+ATTR_LaTeX
9234 @example
9235 #+CAPTION:    The black-body emission of the disk around HR 4049
9236 #+LABEL:      fig:SED-HR4049
9237 #+ATTR_LaTeX: width=5cm,angle=90
9238 [[./img/sed-hr4049.pdf]]
9239 @end example
9241 @vindex org-export-latex-inline-image-extensions
9242 If you need references to a label created in this way, write
9243 @samp{\ref@{fig:SED-HR4049@}} just like in La@TeX{}.  The default settings will
9244 recognize files types that can be included as images during processing by
9245 @command{pdflatex} (@file{png}, @file{jpg}, and @file{pdf} files).  If you process your
9246 files in a different way, you may need to customize the variable
9247 @code{org-export-latex-inline-image-extensions}.
9249 @node DocBook export, XOXO export, LaTeX and PDF export, Exporting
9250 @section DocBook export
9251 @cindex DocBook export
9252 @cindex PDF export
9253 @cindex Cui, Baoqui
9255 Org contains a DocBook exporter written by Baoqiu Cui.  Once an Org file is
9256 exported to DocBook format, it can be further processed to produce other
9257 formats, including PDF, HTML, man pages, etc., using many available DocBook
9258 tools and stylesheets.
9260 Currently DocBook exporter only supports DocBook V5.0.
9262 @menu
9263 * DocBook export commands::     How to invoke DocBook export
9264 * Quoting DocBook code::        Incorporating DocBook code in Org files
9265 * Recursive sections::          Recursive sections in DocBook
9266 * Tables in DocBook export::    Tables are exported as HTML tables
9267 * Images in DocBook export::    How to insert figures into DocBook output
9268 * Special characters::          How to handle special characters
9269 @end menu
9271 @node DocBook export commands, Quoting DocBook code, DocBook export, DocBook export
9272 @subsection DocBook export commands
9274 @cindex region, active
9275 @cindex active region
9276 @cindex transient-mark-mode
9277 @table @kbd
9278 @kindex C-c C-e D
9279 @item C-c C-e D
9280 @cindex property EXPORT_FILE_NAME
9281 Export as DocBook file.  For an Org file, @file{myfile.org}, the DocBook XML
9282 file will be @file{myfile.xml}.  The file will be overwritten without
9283 warning.  If there is an active region@footnote{This requires
9284 @code{transient-mark-mode} to be turned on}, only the region will be
9285 exported.  If the selected region is a single tree@footnote{To select the
9286 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9287 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
9288 property, that name will be used for the export.
9289 @kindex C-c C-e V
9290 @item C-c C-e V
9291 Export as DocBook file, process to PDF, then open the resulting PDF file.
9293 @vindex org-export-docbook-xslt-proc-command
9294 @vindex org-export-docbook-xsl-fo-proc-command
9295 Note that, in order to produce PDF output based on exported DocBook file, you
9296 need to have XSLT processor and XSL-FO processor software installed on your
9297 system.  Check variables @code{org-export-docbook-xslt-proc-command} and
9298 @code{org-export-docbook-xsl-fo-proc-command}.
9300 @kindex C-c C-e v D
9301 @item C-c C-e v D
9302 Export only the visible part of the document.
9303 @end table
9305 @node Quoting DocBook code, Recursive sections, DocBook export commands, DocBook export
9306 @subsection Quoting DocBook code
9308 You can quote DocBook code in Org files and copy it verbatim into exported
9309 DocBook file with the following constructs:
9311 @cindex #+DOCBOOK
9312 @cindex #+BEGIN_DOCBOOK
9313 @example
9314 #+DOCBOOK: Literal DocBook code for export
9315 @end example
9317 @noindent or
9318 @cindex #+BEGIN_DOCBOOK
9320 @example
9321 #+BEGIN_DOCBOOK
9322 All lines between these markers are exported by DocBook exporter
9323 literally.
9324 #+END_DOCBOOK
9325 @end example
9327 For example, you can use the following lines to include a DocBook warning
9328 admonition.  As to what this warning says, you should pay attention to the
9329 document context when quoting DocBook code in Org files.  You may make
9330 exported DocBook XML files invalid by not quoting DocBook code correctly.
9332 @example
9333 #+BEGIN_DOCBOOK
9334 <warning>
9335   <para>You should know what you are doing when quoting DocBook XML code
9336   in your Org file.  Invalid DocBook XML file may be generated by
9337   DocBook exporter if you are not careful!</para>
9338 </warning>
9339 #+END_DOCBOOK
9340 @end example
9342 @node Recursive sections, Tables in DocBook export, Quoting DocBook code, DocBook export
9343 @subsection Recursive sections
9344 @cindex DocBook recursive sections
9346 DocBook exporter exports Org files as articles using the @code{article}
9347 element in DocBook.  Recursive sections, @ie @code{section} elements, are
9348 used in exported articles.  Top level headlines in Org files are exported as
9349 top level sections, and lower level headlines are exported as nested
9350 sections.  The entire structure of Org files will be exported completely, no
9351 matter how many nested levels of headlines there are.
9353 Using recursive sections makes it easy to port and reuse exported DocBook
9354 code in other DocBook document types like @code{book} or @code{set}.
9356 @node Tables in DocBook export, Images in DocBook export, Recursive sections, DocBook export
9357 @subsection Tables in DocBook export
9358 @cindex tables, in DocBook export
9360 Tables in Org files are exported as HTML tables, which have been supported since
9361 DocBook V4.3.
9363 If a table does not have a caption, an informal table is generated using the
9364 @code{informaltable} element; otherwise, a formal table will be generated
9365 using the @code{table} element.
9367 @node Images in DocBook export, Special characters, Tables in DocBook export, DocBook export
9368 @subsection Images in DocBook export
9369 @cindex images, inline in DocBook
9370 @cindex inlining images in DocBook
9372 Images that are linked to without a description part in the link, like
9373 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]}, will be exported to DocBook
9374 using @code{mediaobject} elements.  Each @code{mediaobject} element contains
9375 an @code{imageobject} that wraps an @code{imagedata} element.  If you have
9376 specified a caption for an image as described in @ref{Markup rules}, a
9377 @code{caption} element will be added in @code{mediaobject}.  If a label is
9378 also specified, it will be exported as an @code{xml:id} attribute of the
9379 @code{mediaobject} element.
9381 @vindex org-export-docbook-default-image-attributes
9382 Image attributes supported by the @code{imagedata} element, like @code{align}
9383 or @code{width}, can be specified in two ways: you can either customize
9384 variable @code{org-export-docbook-default-image-attributes} or use the
9385 @code{#+ATTR_DOCBOOK:} line.  Attributes specified in variable
9386 @code{org-export-docbook-default-image-attributes} are applied to all inline
9387 images in the Org file to be exported (unless they are overwritten by image
9388 attributes specified in @code{#+ATTR_DOCBOOK:} lines).
9390 The @code{#+ATTR_DOCBOOK:} line can be used to specify additional image
9391 attributes or overwrite default image attributes for individual images.  If
9392 the same attribute appears in both the @code{#+ATTR_DOCBOOK:} line and
9393 variable @code{org-export-docbook-default-image-attributes}, the former
9394 overwrites the latter.  Here is an example about how image attributes can be
9395 set:
9397 @cindex #+CAPTION
9398 @cindex #+LABEL
9399 @cindex #+ATTR_DOCBOOK
9400 @example
9401 #+CAPTION:    The logo of Org mode
9402 #+LABEL:      unicorn-svg
9403 #+ATTR_DOCBOOK: scalefit="1" width="100%" depth="100%"
9404 [[./img/org-mode-unicorn.svg]]
9405 @end example
9407 @vindex org-export-docbook-inline-image-extensions
9408 By default, DocBook exporter recognizes the following image file types:
9409 @file{jpeg}, @file{jpg}, @file{png}, @file{gif}, and @file{svg}.  You can
9410 customize variable @code{org-export-docbook-inline-image-extensions} to add
9411 more types to this list as long as DocBook supports them.
9413 @node Special characters,  , Images in DocBook export, DocBook export
9414 @subsection Special characters in DocBook export
9415 @cindex Special characters in DocBook export
9417 @vindex org-export-docbook-doctype
9418 @vindex org-html-entities
9419 Special characters that are written in @TeX{}-like syntax, such as @code{\alpha},
9420 @code{\Gamma}, and @code{\Zeta}, are supported by DocBook exporter.  These
9421 characters are rewritten to XML entities, like @code{&alpha;},
9422 @code{&Gamma;}, and @code{&Zeta;}, based on the list saved in variable
9423 @code{org-html-entities}.  As long as the generated DocBook file includes the
9424 corresponding entities, these special characters are recognized.
9426 You can customize variable @code{org-export-docbook-doctype} to include the
9427 entities you need.  For example, you can set variable
9428 @code{org-export-docbook-doctype} to the following value to recognize all
9429 special characters included in XHTML entities:
9431 @example
9432 "<!DOCTYPE article [
9433 <!ENTITY % xhtml1-symbol PUBLIC
9434 \"-//W3C//ENTITIES Symbol for HTML//EN//XML\"
9435 \"http://www.w3.org/2003/entities/2007/xhtml1-symbol.ent\"
9437 %xhtml1-symbol;
9440 @end example
9442 @node XOXO export, iCalendar export, DocBook export, Exporting
9443 @section XOXO export
9444 @cindex XOXO export
9446 Org mode contains an exporter that produces XOXO-style output.
9447 Currently, this exporter only handles the general outline structure and
9448 does not interpret any additional Org-mode features.
9450 @table @kbd
9451 @kindex C-c C-e x
9452 @item C-c C-e x
9453 Export as XOXO file @file{myfile.html}.
9454 @kindex C-c C-e v
9455 @item C-c C-e v x
9456 Export only the visible part of the document.
9457 @end table
9459 @node iCalendar export,  , XOXO export, Exporting
9460 @section iCalendar export
9461 @cindex iCalendar export
9463 @vindex org-icalendar-include-todo
9464 @vindex org-icalendar-use-deadline
9465 @vindex org-icalendar-use-scheduled
9466 @vindex org-icalendar-categories
9467 Some people use Org mode for keeping track of projects, but still prefer a
9468 standard calendar application for anniversaries and appointments.  In this
9469 case it can be useful to show deadlines and other time-stamped items in Org
9470 files in the calendar application.  Org mode can export calendar information
9471 in the standard iCalendar format.  If you also want to have TODO entries
9472 included in the export, configure the variable
9473 @code{org-icalendar-include-todo}.  Plain timestamps are exported as VEVENT,
9474 and TODO items as VTODO.  It will also create events from deadlines that are
9475 in non-TODO items.  Deadlines and scheduling dates in TODO items will be used
9476 to set the start and due dates for the TODO entry@footnote{See the variables
9477 @code{org-icalendar-use-deadline} and @code{org-icalendar-use-scheduled}.}.
9478 As categories, it will use the tags locally defined in the heading, and the
9479 file/tree category@footnote{To add inherited tags or the TODO state,
9480 configure the variable @code{org-icalendar-categories}.}.
9482 @vindex org-icalendar-store-UID
9483 @cindex property, ID
9484 The iCalendar standard requires each entry to have a globally unique
9485 identifier (UID).  Org creates these identifiers during export.  If you set
9486 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
9487 @code{:ID:} property of the entry and re-used next time you report this
9488 entry.  Since a single entry can give rise to multiple iCalendar entries (as
9489 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
9490 prefixes to the UID, depending on what triggered the inclusion of the entry.
9491 In this way the UID remains unique, but a synchronization program can still
9492 figure out from which entry all the different instances originate.
9494 @table @kbd
9495 @kindex C-c C-e i
9496 @item C-c C-e i
9497 Create iCalendar entries for the current file and store them in the same
9498 directory, using a file extension @file{.ics}.
9499 @kindex C-c C-e I
9500 @item C-c C-e I
9501 @vindex org-agenda-files
9502 Like @kbd{C-c C-e i}, but do this for all files in
9503 @code{org-agenda-files}.  For each of these files, a separate iCalendar
9504 file will be written.
9505 @kindex C-c C-e c
9506 @item C-c C-e c
9507 @vindex org-combined-agenda-icalendar-file
9508 Create a single large iCalendar file from all files in
9509 @code{org-agenda-files} and write it to the file given by
9510 @code{org-combined-agenda-icalendar-file}.
9511 @end table
9513 @vindex org-use-property-inheritance
9514 @vindex org-icalendar-include-body
9515 @cindex property, SUMMARY
9516 @cindex property, DESCRIPTION
9517 @cindex property, LOCATION
9518 The export will honor SUMMARY, DESCRIPTION and LOCATION@footnote{The LOCATION
9519 property can be inherited from higher in the hierarchy if you configure
9520 @code{org-use-property-inheritance} accordingly.} properties if the selected
9521 entries have them.  If not, the summary will be derived from the headline,
9522 and the description from the body (limited to
9523 @code{org-icalendar-include-body} characters).
9525 How this calendar is best read and updated, depends on the application
9526 you are using.  The FAQ covers this issue.
9528 @node Publishing, Miscellaneous, Exporting, Top
9529 @chapter Publishing
9530 @cindex publishing
9531 @cindex O'Toole, David
9533 Org includes a publishing management system that allows you to configure
9534 automatic HTML conversion of @emph{projects} composed of interlinked org
9535 files.  You can also configure Org to automatically upload your exported HTML
9536 pages and related attachments, such as images and source code files, to a web
9537 server.
9539 You can also use Org to convert files into PDF, or even combine HTML and PDF
9540 conversion so that files are available in both formats on the server.
9542 Publishing has been contributed to Org by David O'Toole.
9544 @menu
9545 * Configuration::               Defining projects
9546 * Uploading files::             How to get files up on the server
9547 * Sample configuration::        Example projects
9548 * Triggering publication::      Publication commands
9549 @end menu
9551 @node Configuration, Uploading files, Publishing, Publishing
9552 @section Configuration
9554 Publishing needs significant configuration to specify files, destination
9555 and many other properties of a project.
9557 @menu
9558 * Project alist::               The central configuration variable
9559 * Sources and destinations::    From here to there
9560 * Selecting files::             What files are part of the project?
9561 * Publishing action::           Setting the function doing the publishing
9562 * Publishing options::          Tweaking HTML export
9563 * Publishing links::            Which links keep working after publishing?
9564 * Project page index::          Publishing a list of project files
9565 @end menu
9567 @node Project alist, Sources and destinations, Configuration, Configuration
9568 @subsection The variable @code{org-publish-project-alist}
9569 @cindex org-publish-project-alist
9570 @cindex projects, for publishing
9572 @vindex org-publish-project-alist
9573 Publishing is configured almost entirely through setting the value of one
9574 variable, called @code{org-publish-project-alist}.  Each element of the list
9575 configures one project, and may be in one of the two following forms:
9577 @lisp
9578    ("project-name" :property value :property value ...)
9579 @r{or}
9580    ("project-name" :components ("project-name" "project-name" ...))
9582 @end lisp
9584 In both cases, projects are configured by specifying property values.  A
9585 project defines the set of files that will be published, as well as the
9586 publishing configuration to use when publishing those files.  When a project
9587 takes the second form listed above, the individual members of the
9588 @code{:components} property are taken to be sub-projects, which group
9589 together files requiring different publishing options.  When you publish such
9590 a ``meta-project'', all the components will also be published, in the
9591 sequence given.
9593 @node Sources and destinations, Selecting files, Project alist, Configuration
9594 @subsection Sources and destinations for files
9595 @cindex directories, for publishing
9597 Most properties are optional, but some should always be set.  In
9598 particular, Org needs to know where to look for source files,
9599 and where to put published files.
9601 @multitable @columnfractions 0.3 0.7
9602 @item @code{:base-directory}
9603 @tab Directory containing publishing source files
9604 @item @code{:publishing-directory}
9605 @tab Directory where output files will be published.  You can directly
9606 publish to a webserver using a file name syntax appropriate for
9607 the Emacs @file{tramp} package.  Or you can publish to a local directory and
9608 use external tools to upload your website (@pxref{Uploading files}).
9609 @item @code{:preparation-function}
9610 @tab Function called before starting the publishing process, for example, to
9611 run @code{make} for updating files to be published.
9612 @item @code{:completion-function}
9613 @tab Function called after finishing the publishing process, for example, to
9614 change permissions of the resulting files.
9615 @end multitable
9616 @noindent
9618 @node Selecting files, Publishing action, Sources and destinations, Configuration
9619 @subsection Selecting files
9620 @cindex files, selecting for publishing
9622 By default, all files with extension @file{.org} in the base directory
9623 are considered part of the project.  This can be modified by setting the
9624 properties
9625 @multitable @columnfractions 0.25 0.75
9626 @item @code{:base-extension}
9627 @tab Extension (without the dot!) of source files.  This actually is a
9628 regular expression.  Set this to the symbol @code{any} if you want to get all
9629 files in @code{:base-directory}, even without extension.
9631 @item @code{:exclude}
9632 @tab Regular expression to match file names that should not be
9633 published, even though they have been selected on the basis of their
9634 extension.
9636 @item @code{:include}
9637 @tab List of files to be included regardless of @code{:base-extension}
9638 and @code{:exclude}.
9639 @end multitable
9641 @node Publishing action, Publishing options, Selecting files, Configuration
9642 @subsection Publishing action
9643 @cindex action, for publishing
9645 Publishing means that a file is copied to the destination directory and
9646 possibly transformed in the process.  The default transformation is to export
9647 Org files as HTML files, and this is done by the function
9648 @code{org-publish-org-to-html} which calls the HTML exporter (@pxref{HTML
9649 export}).  But you also can publish your content as PDF files using
9650 @code{org-publish-org-to-pdf}.  If you want to publish the Org file itself,
9651 but with @i{archived}, @i{commented}, and @i{tag-excluded} trees removed, use
9652 @code{org-publish-org-to-org} and set the parameters @code{:plain-source}
9653 and/or @code{:htmlized-source}.  This will produce @file{file.org} and
9654 @file{file.org.html} in the publishing
9655 directory@footnote{@file{file-source.org} and @file{file-source.org.html} if
9656 source and publishing directories are equal.  Note that with this kind of
9657 setup, you need to add @code{:exclude "-source\\.org"} to the project
9658 definition in @code{org-publish-project-alist} to avoid that the published
9659 source files will be considered as new org files the next time the project is
9660 published.}.  Other files like images only
9661 need to be copied to the publishing destination, for this you may use
9662 @code{org-publish-attachment}.  For non-Org files, you always need to
9663 specify the publishing function:
9665 @multitable @columnfractions 0.3 0.7
9666 @item @code{:publishing-function}
9667 @tab Function executing the publication of a file.  This may also be a
9668 list of functions, which will all be called in turn.
9669 @item @code{:plain-source}
9670 @tab Non-nil means, publish plain source.
9671 @item @code{:htmlized-source}
9672 @tab Non-nil means, publish htmlized source.
9673 @end multitable
9675 The function must accept two arguments: a property list containing at least a
9676 @code{:publishing-directory} property, and the name of the file to be
9677 published.  It should take the specified file, make the necessary
9678 transformation (if any) and place the result into the destination folder.
9680 @node Publishing options, Publishing links, Publishing action, Configuration
9681 @subsection Options for the HTML/La@TeX{} exporters
9682 @cindex options, for publishing
9684 The property list can be used to set many export options for the HTML
9685 and La@TeX{} exporters.  In most cases, these properties correspond to user
9686 variables in Org.  The table below lists these properties along
9687 with the variable they belong to.  See the documentation string for the
9688 respective variable for details.
9690 @vindex org-export-html-link-up
9691 @vindex org-export-html-link-home
9692 @vindex org-export-default-language
9693 @vindex org-display-custom-times
9694 @vindex org-export-headline-levels
9695 @vindex org-export-with-section-numbers
9696 @vindex org-export-section-number-format
9697 @vindex org-export-with-toc
9698 @vindex org-export-preserve-breaks
9699 @vindex org-export-with-archived-trees
9700 @vindex org-export-with-emphasize
9701 @vindex org-export-with-sub-superscripts
9702 @vindex org-export-with-special-strings
9703 @vindex org-export-with-footnotes
9704 @vindex org-export-with-drawers
9705 @vindex org-export-with-tags
9706 @vindex org-export-with-todo-keywords
9707 @vindex org-export-with-priority
9708 @vindex org-export-with-TeX-macros
9709 @vindex org-export-with-LaTeX-fragments
9710 @vindex org-export-skip-text-before-1st-heading
9711 @vindex org-export-with-fixed-width
9712 @vindex org-export-with-timestamps
9713 @vindex org-export-author-info
9714 @vindex org-export-creator-info
9715 @vindex org-export-with-tables
9716 @vindex org-export-highlight-first-table-line
9717 @vindex org-export-html-style-include-default
9718 @vindex org-export-html-style
9719 @vindex org-export-html-style-extra
9720 @vindex org-export-html-link-org-files-as-html
9721 @vindex org-export-html-inline-images
9722 @vindex org-export-html-extension
9723 @vindex org-export-html-table-tag
9724 @vindex org-export-html-expand
9725 @vindex org-export-html-with-timestamp
9726 @vindex org-export-publishing-directory
9727 @vindex org-export-html-preamble
9728 @vindex org-export-html-postamble
9729 @vindex org-export-html-auto-preamble
9730 @vindex org-export-html-auto-postamble
9731 @vindex user-full-name
9732 @vindex user-mail-address
9733 @vindex org-export-select-tags
9734 @vindex org-export-exclude-tags
9736 @multitable @columnfractions 0.32 0.68
9737 @item @code{:link-up}               @tab @code{org-export-html-link-up}
9738 @item @code{:link-home}             @tab @code{org-export-html-link-home}
9739 @item @code{:language}              @tab @code{org-export-default-language}
9740 @item @code{:customtime}            @tab @code{org-display-custom-times}
9741 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
9742 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
9743 @item @code{:section-number-format} @tab @code{org-export-section-number-format}
9744 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
9745 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
9746 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
9747 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
9748 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
9749 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
9750 @item @code{:footnotes}             @tab @code{org-export-with-footnotes}
9751 @item @code{:drawers}               @tab @code{org-export-with-drawers}
9752 @item @code{:tags}                  @tab @code{org-export-with-tags}
9753 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
9754 @item @code{:priority}              @tab @code{org-export-with-priority}
9755 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
9756 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
9757 @item @code{:latex-listings}        @tab @code{org-export-latex-listings}
9758 @item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
9759 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
9760 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
9761 @item @code{:author-info}           @tab @code{org-export-author-info}
9762 @item @code{:creator-info}          @tab @code{org-export-creator-info}
9763 @item @code{:tables}                @tab @code{org-export-with-tables}
9764 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
9765 @item @code{:style-include-default} @tab @code{org-export-html-style-include-default}
9766 @item @code{:style}                 @tab @code{org-export-html-style}
9767 @item @code{:style-extra}           @tab @code{org-export-html-style-extra}
9768 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
9769 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
9770 @item @code{:html-extension}        @tab @code{org-export-html-extension}
9771 @item @code{:xml-declaration}       @tab @code{org-export-html-xml-declaration}
9772 @item @code{:html-table-tag}        @tab @code{org-export-html-table-tag}
9773 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
9774 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
9775 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
9776 @item @code{:preamble}              @tab @code{org-export-html-preamble}
9777 @item @code{:postamble}             @tab @code{org-export-html-postamble}
9778 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
9779 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
9780 @item @code{:author}                @tab @code{user-full-name}
9781 @item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
9782 @item @code{:select-tags}           @tab @code{org-export-select-tags}
9783 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
9784 @item @code{:latex-image-options}   @tab @code{org-export-latex-image-default-option}
9785 @end multitable
9787 Most of the @code{org-export-with-*} variables have the same effect in
9788 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
9789 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
9790 La@TeX{} export.
9792 @vindex org-publish-project-alist
9793 When a property is given a value in @code{org-publish-project-alist},
9794 its setting overrides the value of the corresponding user variable (if
9795 any) during publishing.  Options set within a file (@pxref{Export
9796 options}), however, override everything.
9798 @node Publishing links, Project page index, Publishing options, Configuration
9799 @subsection Links between published files
9800 @cindex links, publishing
9802 To create a link from one Org file to another, you would use
9803 something like @samp{[[file:foo.org][The foo]]} or simply
9804 @samp{file:foo.org.} (@pxref{Hyperlinks}).  When published, this link
9805 becomes a link to @file{foo.html}.  In this way, you can interlink the
9806 pages of your "org web" project and the links will work as expected when
9807 you publish them to HTML.  If you also publish the Org source file and want
9808 to link to that, use an @code{http:} link instead of a @code{file:} link,
9809 because @code{file:} links are converted to link to the corresponding
9810 @file{html} file.
9812 You may also link to related files, such as images. Provided you are careful
9813 with relative file names, and provided you have also configured Org to upload
9814 the related files, these links will work too. See @ref{Complex example}, for
9815 an example of this usage.
9817 Sometimes an Org file to be published may contain links that are
9818 only valid in your production environment, but not in the publishing
9819 location.  In this case, use the property
9821 @multitable @columnfractions 0.4 0.6
9822 @item @code{:link-validation-function}
9823 @tab Function to validate links
9824 @end multitable
9826 @noindent
9827 to define a function for checking link validity.  This function must
9828 accept two arguments, the file name and a directory relative to which
9829 the file name is interpreted in the production environment.  If this
9830 function returns @code{nil}, then the HTML generator will only insert a
9831 description into the HTML file, but no link.  One option for this
9832 function is @code{org-publish-validate-link} which checks if the given
9833 file is part of any project in @code{org-publish-project-alist}.
9835 @node Project page index,  , Publishing links, Configuration
9836 @subsection Project page index
9837 @cindex index, of published pages
9839 The following properties may be used to control publishing of an
9840 index of files or a summary page for a given project.
9842 @multitable @columnfractions 0.25 0.75
9843 @item @code{:auto-index}
9844 @tab When non-nil, publish an index during @code{org-publish-current-project}
9845 or @code{org-publish-all}.
9847 @item @code{:index-filename}
9848 @tab Filename for output of index. Defaults to @file{sitemap.org} (which
9849 becomes @file{sitemap.html}).
9851 @item @code{:index-title}
9852 @tab Title of index page. Defaults to name of file.
9854 @item @code{:index-function}
9855 @tab Plug-in function to use for generation of index.
9856 Defaults to @code{org-publish-org-index}, which generates a plain list
9857 of links to all files in the project.
9858 @end multitable
9860 @node Uploading files, Sample configuration, Configuration, Publishing
9861 @section Uploading files
9862 @cindex rsync
9863 @cindex unison
9865 For those people already utilizing third party sync tools such as
9866 @command{rsync} or @command{unison}, it might be preferable not to use the built in
9867 @i{remote} publishing facilities of Org mode which rely heavily on
9868 Tramp.  Tramp, while very useful and powerful, tends not to be
9869 so efficient for multiple file transfer and has been known to cause problems
9870 under heavy usage.
9872 Specialized synchronization utilities offer several advantages.  In addition
9873 to timestamp comparison, they also do content and permissions/attribute
9874 checks.  For this reason you might prefer to publish your web to a local
9875 directory (possibly even @i{in place} with your Org files) and then use
9876 @file{unison} or @file{rsync} to do the synchronization with the remote host.
9878 Since Unison (for example) can be configured as to which files to transfer to
9879 a certain remote destination, it can greatly simplify the project publishing
9880 definition.  Simply keep all files in the correct location, process your Org
9881 files with @code{org-publish} and let the synchronization tool do the rest.
9882 You do not need, in this scenario, to include attachments such as @file{jpg},
9883 @file{css} or @file{gif} files in the project definition since the 3rd party
9884 tool syncs them.
9886 Publishing to a local directory is also much faster than to a remote one, so
9887 that you can afford more easily to republish entire projects.  If you set
9888 @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the main
9889 benefit of re-including any changed external files such as source example
9890 files you might include with @code{#+INCLUDE}.  The timestamp mechanism in
9891 Org is not smart enough to detect if included files have been modified.
9893 @node Sample configuration, Triggering publication, Uploading files, Publishing
9894 @section Sample configuration
9896 Below we provide two example configurations.  The first one is a simple
9897 project publishing only a set of Org files.  The second example is
9898 more complex, with a multi-component project.
9900 @menu
9901 * Simple example::              One-component publishing
9902 * Complex example::             A multi-component publishing example
9903 @end menu
9905 @node Simple example, Complex example, Sample configuration, Sample configuration
9906 @subsection Example: simple publishing configuration
9908 This example publishes a set of Org files to the @file{public_html}
9909 directory on the local machine.
9911 @lisp
9912 (setq org-publish-project-alist
9913       '(("org"
9914          :base-directory "~/org/"
9915          :publishing-directory "~/public_html"
9916          :section-numbers nil
9917          :table-of-contents nil
9918          :style "<link rel=\"stylesheet\"
9919                 href=\"../other/mystyle.css\"
9920                 type=\"text/css\"/>")))
9921 @end lisp
9923 @node Complex example,  , Simple example, Sample configuration
9924 @subsection Example: complex publishing configuration
9926 This more complicated example publishes an entire website, including
9927 Org files converted to HTML, image files, Emacs Lisp source code, and
9928 style sheets. The publishing directory is remote and private files are
9929 excluded.
9931 To ensure that links are preserved, care should be taken to replicate
9932 your directory structure on the web server, and to use relative file
9933 paths. For example, if your Org files are kept in @file{~/org} and your
9934 publishable images in @file{~/images}, you'd link to an image with
9936 @example
9937 file:../images/myimage.png
9938 @end example
9940 On the web server, the relative path to the image should be the
9941 same. You can accomplish this by setting up an "images" folder in the
9942 right place on the web server, and publishing images to it.
9944 @lisp
9945 (setq org-publish-project-alist
9946       '(("orgfiles"
9947           :base-directory "~/org/"
9948           :base-extension "org"
9949           :publishing-directory "/ssh:user@@host:~/html/notebook/"
9950           :publishing-function org-publish-org-to-html
9951           :exclude "PrivatePage.org"   ;; regexp
9952           :headline-levels 3
9953           :section-numbers nil
9954           :table-of-contents nil
9955           :style "<link rel=\"stylesheet\"
9956                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
9957           :auto-preamble t
9958           :auto-postamble nil)
9960          ("images"
9961           :base-directory "~/images/"
9962           :base-extension "jpg\\|gif\\|png"
9963           :publishing-directory "/ssh:user@@host:~/html/images/"
9964           :publishing-function org-publish-attachment)
9966          ("other"
9967           :base-directory "~/other/"
9968           :base-extension "css\\|el"
9969           :publishing-directory "/ssh:user@@host:~/html/other/"
9970           :publishing-function org-publish-attachment)
9971          ("website" :components ("orgfiles" "images" "other"))))
9972 @end lisp
9974 @node Triggering publication,  , Sample configuration, Publishing
9975 @section Triggering publication
9977 Once properly configured, Org can publish with the following commands:
9979 @table @kbd
9980 @kindex C-c C-e C
9981 @item C-c C-e C
9982 Prompt for a specific project and publish all files that belong to it.
9983 @kindex C-c C-e P
9984 @item C-c C-e P
9985 Publish the project containing the current file.
9986 @kindex C-c C-e F
9987 @item C-c C-e F
9988 Publish only the current file.
9989 @kindex C-c C-e E
9990 @item C-c C-e E
9991 Publish every project.
9992 @end table
9994 @vindex org-publish-use-timestamps-flag
9995 Org uses timestamps to track when a file has changed. The above functions
9996 normally only publish changed files. You can override this and force
9997 publishing of all files by giving a prefix argument to any of the commands
9998 above, or by customizing the variable @code{org-publish-use-timestamps-flag}.
9999 This may be necessary in particular if files include other files via
10000 @code{#+SETUPFILE:} or @code{#+INCLUDE:}.
10002 @node Miscellaneous, Hacking, Publishing, Top
10003 @chapter Miscellaneous
10005 @menu
10006 * Completion::                  M-TAB knows what you need
10007 * Customization::               Adapting Org to your taste
10008 * In-buffer settings::          Overview of the #+KEYWORDS
10009 * The very busy C-c C-c key::   When in doubt, press C-c C-c
10010 * Clean view::                  Getting rid of leading stars in the outline
10011 * TTY keys::                    Using Org on a tty
10012 * Interaction::                 Other Emacs packages
10013 @end menu
10016 @node Completion, Customization, Miscellaneous, Miscellaneous
10017 @section Completion
10018 @cindex completion, of @TeX{} symbols
10019 @cindex completion, of TODO keywords
10020 @cindex completion, of dictionary words
10021 @cindex completion, of option keywords
10022 @cindex completion, of tags
10023 @cindex completion, of property keys
10024 @cindex completion, of link abbreviations
10025 @cindex @TeX{} symbol completion
10026 @cindex TODO keywords completion
10027 @cindex dictionary word completion
10028 @cindex option keyword completion
10029 @cindex tag completion
10030 @cindex link abbreviations, completion of
10032 Emacs would not be Emacs without completion, and Org-mode uses it whenever it
10033 makes sense.  If you prefer an @i{iswitchb}- or @i{ido}-like interface for
10034 some of the completion prompts, you can specify your preferece by setting at
10035 most one of the variables @code{org-completion-use-iswitchb}
10036 @code{org-completion-use-ido}.
10038 Org supports in-buffer completion.  This type of completion does
10039 not make use of the minibuffer.  You simply type a few letters into
10040 the buffer and use the key to complete text right there.
10042 @table @kbd
10043 @kindex M-@key{TAB}
10044 @item M-@key{TAB}
10045 Complete word at point
10046 @itemize @bullet
10047 @item
10048 At the beginning of a headline, complete TODO keywords.
10049 @item
10050 After @samp{\}, complete @TeX{} symbols supported by the exporter.
10051 @item
10052 After @samp{*}, complete headlines in the current buffer so that they
10053 can be used in search links like @samp{[[*find this headline]]}.
10054 @item
10055 After @samp{:} in a headline, complete tags.  The list of tags is taken
10056 from the variable @code{org-tag-alist} (possibly set through the
10057 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
10058 dynamically from all tags used in the current buffer.
10059 @item
10060 After @samp{:} and not in a headline, complete property keys.  The list
10061 of keys is constructed dynamically from all keys used in the current
10062 buffer.
10063 @item
10064 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
10065 @item
10066 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
10067 @samp{OPTIONS} which set file-specific options for Org mode.  When the
10068 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
10069 will insert example settings for this keyword.
10070 @item
10071 In the line after @samp{#+STARTUP: }, complete startup keywords,
10072 @ie valid keys for this line.
10073 @item
10074 Elsewhere, complete dictionary words using Ispell.
10075 @end itemize
10076 @end table
10078 @node Customization, In-buffer settings, Completion, Miscellaneous
10079 @section Customization
10080 @cindex customization
10081 @cindex options, for customization
10082 @cindex variables, for customization
10084 There are more than 180 variables that can be used to customize
10085 Org.  For the sake of compactness of the manual, I am not
10086 describing the variables here.  A structured overview of customization
10087 variables is available with @kbd{M-x org-customize}.  Or select
10088 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
10089 settings can also be activated on a per-file basis, by putting special
10090 lines into the buffer (@pxref{In-buffer settings}).
10092 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
10093 @section Summary of in-buffer settings
10094 @cindex in-buffer settings
10095 @cindex special keywords
10097 Org mode uses special lines in the buffer to define settings on a
10098 per-file basis.  These lines start with a @samp{#+} followed by a
10099 keyword, a colon, and then individual words defining a setting.  Several
10100 setting words can be in the same line, but you can also have multiple
10101 lines for the keyword.  While these settings are described throughout
10102 the manual, here is a summary.  After changing any of those lines in the
10103 buffer, press @kbd{C-c C-c} with the cursor still in the line to
10104 activate the changes immediately.  Otherwise they become effective only
10105 when the file is visited again in a new Emacs session.
10107 @vindex org-archive-location
10108 @table @kbd
10109 @item #+ARCHIVE: %s_done::
10110 This line sets the archive location for the agenda file.  It applies for
10111 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
10112 of the file.  The first such line also applies to any entries before it.
10113 The corresponding variable is @code{org-archive-location}.
10114 @item #+CATEGORY:
10115 This line sets the category for the agenda file.  The category applies
10116 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
10117 end of the file.  The first such line also applies to any entries before it.
10118 @item #+COLUMNS: %25ITEM .....
10119 @cindex property, COLUMNS
10120 Set the default format for columns view.  This format applies when
10121 columns view is invoked in locations where no @code{COLUMNS} property
10122 applies.
10123 @item #+CONSTANTS: name1=value1 ...
10124 @vindex org-table-formula-constants
10125 @vindex org-table-formula
10126 Set file-local values for constants to be used in table formulas.  This
10127 line set the local variable @code{org-table-formula-constants-local}.
10128 The global version of this variable is
10129 @code{org-table-formula-constants}.
10130 @item #+FILETAGS: :tag1:tag2:tag3:
10131 Set tags that can be inherited by any entry in the file, including the
10132 top-level entries.
10133 @item #+DRAWERS: NAME1 .....
10134 @vindex org-drawers
10135 Set the file-local set of drawers.  The corresponding global variable is
10136 @code{org-drawers}.
10137 @item #+LINK:  linkword replace
10138 @vindex org-link-abbrev-alist
10139 These lines (several are allowed) specify link abbreviations.
10140 @xref{Link abbreviations}.  The corresponding variable is
10141 @code{org-link-abbrev-alist}.
10142 @item #+PRIORITIES: highest lowest default
10143 @vindex org-highest-priority
10144 @vindex org-lowest-priority
10145 @vindex org-default-priority
10146 This line sets the limits and the default for the priorities.  All three
10147 must be either letters A-Z or numbers 0-9.  The highest priority must
10148 have a lower ASCII number that the lowest priority.
10149 @item #+PROPERTY: Property_Name Value
10150 This line sets a default inheritance value for entries in the current
10151 buffer, most useful for specifying the allowed values of a property.
10152 @cindex #+SETUPFILE
10153 @item #+SETUPFILE: file
10154 This line defines a file that holds more in-buffer setup.  Normally this is
10155 entirely ignored.  Only when the buffer is parsed for option-setting lines
10156 (@ie when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
10157 settings line, or when exporting), then the contents of this file are parsed
10158 as if they had been included in the buffer.  In particular, the file can be
10159 any other Org mode file with internal setup.  You can visit the file the
10160 cursor is in the line with @kbd{C-c '}.
10161 @item #+STARTUP:
10162 @cindex #+STARTUP:
10163 This line sets options to be used at startup of Org mode, when an
10164 Org file is being visited.
10166 The first set of options deals with the initial visibility of the outline
10167 tree.  The corresponding variable for global default settings is
10168 @code{org-startup-folded}, with a default value @code{t}, which means
10169 @code{overview}.
10170 @vindex org-startup-folded
10171 @cindex @code{overview}, STARTUP keyword
10172 @cindex @code{content}, STARTUP keyword
10173 @cindex @code{showall}, STARTUP keyword
10174 @example
10175 overview   @r{top-level headlines only}
10176 content    @r{all headlines}
10177 showall    @r{no folding at all, show everything}
10178 @end example
10180 @vindex org-startup-indented
10181 @cindex @code{indent}, STARTUP keyword
10182 @cindex @code{noindent}, STARTUP keyword
10183 Dynamic virtual indentation is controlled by the variable
10184 @code{org-startup-indented}@footnote{Emacs 23 and Org-mode 6.29 are required}
10185 @example
10186 indent     @r{start with @code{org-indent-mode} turned on}
10187 noindent   @r{start with @code{org-indent-mode} turned off}
10188 @end example
10190 @vindex org-startup-align-all-tables
10191 Then there are options for aligning tables upon visiting a file.  This
10192 is useful in files containing narrowed table columns.  The corresponding
10193 variable is @code{org-startup-align-all-tables}, with a default value
10194 @code{nil}.
10195 @cindex @code{align}, STARTUP keyword
10196 @cindex @code{noalign}, STARTUP keyword
10197 @example
10198 align      @r{align all tables}
10199 noalign    @r{don't align tables on startup}
10200 @end example
10201 @vindex org-log-done
10202 @vindex org-log-note-clock-out
10203 @vindex org-log-repeat
10204 Logging the closing and reopening of TODO items and clock intervals can be
10205 configured using these options (see variables @code{org-log-done},
10206 @code{org-log-note-clock-out} and @code{org-log-repeat})
10207 @cindex @code{logdone}, STARTUP keyword
10208 @cindex @code{lognotedone}, STARTUP keyword
10209 @cindex @code{nologdone}, STARTUP keyword
10210 @cindex @code{lognoteclock-out}, STARTUP keyword
10211 @cindex @code{nolognoteclock-out}, STARTUP keyword
10212 @cindex @code{logrepeat}, STARTUP keyword
10213 @cindex @code{lognoterepeat}, STARTUP keyword
10214 @cindex @code{nologrepeat}, STARTUP keyword
10215 @example
10216 logdone            @r{record a timestamp when an item is marked DONE}
10217 lognotedone        @r{record timestamp and a note when DONE}
10218 nologdone          @r{don't record when items are marked DONE}
10219 logrepeat          @r{record a time when reinstating a repeating item}
10220 lognoterepeat      @r{record a note when reinstating a repeating item}
10221 nologrepeat        @r{do not record when reinstating repeating item}
10222 lognoteclock-out   @r{record a note when clocking out}
10223 nolognoteclock-out @r{don't record a note when clocking out}
10224 @end example
10225 @vindex org-hide-leading-stars
10226 @vindex org-odd-levels-only
10227 Here are the options for hiding leading stars in outline headings, and for
10228 indenting outlines.  The corresponding variables are
10229 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
10230 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
10231 @cindex @code{hidestars}, STARTUP keyword
10232 @cindex @code{showstars}, STARTUP keyword
10233 @cindex @code{odd}, STARTUP keyword
10234 @cindex @code{even}, STARTUP keyword
10235 @example
10236 hidestars  @r{make all but one of the stars starting a headline invisible.}
10237 showstars  @r{show all stars starting a headline}
10238 indent     @r{virtual indentation according to outline level}
10239 noindent   @r{no virtual indentation according to outline level}
10240 odd        @r{allow only odd outline levels (1,3,...)}
10241 oddeven    @r{allow all outline levels}
10242 @end example
10243 @vindex org-put-time-stamp-overlays
10244 @vindex org-time-stamp-overlay-formats
10245 To turn on custom format overlays over timestamps (variables
10246 @code{org-put-time-stamp-overlays} and
10247 @code{org-time-stamp-overlay-formats}), use
10248 @cindex @code{customtime}, STARTUP keyword
10249 @example
10250 customtime @r{overlay custom time format}
10251 @end example
10252 @vindex constants-unit-system
10253 The following options influence the table spreadsheet (variable
10254 @code{constants-unit-system}).
10255 @cindex @code{constcgs}, STARTUP keyword
10256 @cindex @code{constSI}, STARTUP keyword
10257 @example
10258 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
10259 constSI    @r{@file{constants.el} should use the SI unit system}
10260 @end example
10261 @vindex org-footnote-define-inline
10262 @vindex org-footnote-auto-label
10263 @vindex org-footnote-auto-adjust
10264 To influence footnote settings, use the following keywords.  The
10265 corresponding variables are @code{org-footnote-define-inline},
10266 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
10267 @cindex @code{fninline}, STARTUP keyword
10268 @cindex @code{nofninline}, STARTUP keyword
10269 @cindex @code{fnlocal}, STARTUP keyword
10270 @cindex @code{fnprompt}, STARTUP keyword
10271 @cindex @code{fnauto}, STARTUP keyword
10272 @cindex @code{fnconfirm}, STARTUP keyword
10273 @cindex @code{fnplain}, STARTUP keyword
10274 @cindex @code{fnadjust}, STARTUP keyword
10275 @cindex @code{nofnadjust}, STARTUP keyword
10276 @example
10277 fninline    @r{define footnotes inline}
10278 fnnoinline  @r{define footnotes in separate section}
10279 fnlocal     @r{define footnotes near first reference, but not inline}
10280 fnprompt    @r{prompt for footnote labels}
10281 fnauto      @r{create [fn:1]-like labels automatically (default)}
10282 fnconfirm   @r{offer automatic label for editing or confirmation}
10283 fnplain     @r{create [1]-like labels automatically}
10284 fnadjust    @r{automatically renumber and sort footnotes}
10285 nofnadjust  @r{do not renumber and sort automatically}
10286 @end example
10287 @cindex org-hide-block-startup
10288 To hide blocks on startup, use these keywords. The corresponding variable is
10289 @code{org-hide-block-startup}.
10290 @cindex @code{hideblocks}, STARTUP keyword
10291 @cindex @code{nohideblocks}, STARTUP keyword
10292 @example
10293 hideblocks   @r{Hide all begin/end blocks on startup}
10294 nohideblocks @r{Do not hide blocks on startup}
10295 @end example
10296 @item #+TAGS:  TAG1(c1) TAG2(c2)
10297 @vindex org-tag-alist
10298 These lines (several such lines are allowed) specify the valid tags in
10299 this file, and (potentially) the corresponding @emph{fast tag selection}
10300 keys.  The corresponding variable is @code{org-tag-alist}.
10301 @item #+TBLFM:
10302 This line contains the formulas for the table directly above the line.
10303 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+DATE:,
10304 @itemx #+OPTIONS:, #+BIND:
10305 @itemx #+DESCRIPTION:, #+KEYWORDS:
10306 @itemx #+LATEX_HEADER:, #+STYLE:, #+LINK_UP:, #+LINK_HOME:,
10307 @itemx #+EXPORT_SELECT_TAGS:, #+EXPORT_EXCLUDE_TAGS:
10308 These lines provide settings for exporting files.  For more details see
10309 @ref{Export options}.
10310 @item #+TODO:    #+SEQ_TODO:   #+TYP_TODO:
10311 @vindex org-todo-keywords
10312 These lines set the TODO keywords and their interpretation in the
10313 current file.  The corresponding variable is @code{org-todo-keywords}.
10314 @end table
10316 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
10317 @section The very busy C-c C-c key
10318 @kindex C-c C-c
10319 @cindex C-c C-c, overview
10321 The key @kbd{C-c C-c} has many purposes in Org, which are all
10322 mentioned scattered throughout this manual.  One specific function of
10323 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
10324 other circumstances it means something like @emph{``Hey Org, look
10325 here and update according to what you see here''}.  Here is a summary of
10326 what this means in different contexts.
10328 @itemize @minus
10329 @item
10330 If there are highlights in the buffer from the creation of a sparse
10331 tree, or from clock display, remove these highlights.
10332 @item
10333 If the cursor is in one of the special @code{#+KEYWORD} lines, this
10334 triggers scanning the buffer for these lines and updating the
10335 information.
10336 @item
10337 If the cursor is inside a table, realign the table.  This command
10338 works even if the automatic table editor has been turned off.
10339 @item
10340 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
10341 the entire table.
10342 @item
10343 If the cursor is inside a table created by the @file{table.el} package,
10344 activate that table.
10345 @item
10346 If the current buffer is a Remember buffer, close the note and file it.
10347 With a prefix argument, file it, without further interaction, to the
10348 default location.
10349 @item
10350 If the cursor is on a @code{<<<target>>>}, update radio targets and
10351 corresponding links in this buffer.
10352 @item
10353 If the cursor is in a property line or at the start or end of a property
10354 drawer, offer property commands.
10355 @item
10356 If the cursor is at a footnote reference, go to the corresponding
10357 definition, and vice versa.
10358 @item
10359 If the cursor is on a statistics cookie, update it.
10360 @item
10361 If the cursor is in a plain list item with a checkbox, toggle the status
10362 of the checkbox.
10363 @item
10364 If the cursor is on a numbered item in a plain list, renumber the
10365 ordered list.
10366 @item
10367 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
10368 block is updated.
10369 @end itemize
10371 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
10372 @section A cleaner outline view
10373 @cindex hiding leading stars
10374 @cindex dynamic indentation
10375 @cindex odd-levels-only outlines
10376 @cindex clean outline view
10378 Some people find it noisy and distracting that the Org headlines start with a
10379 potentially large number of stars, and that text below the headlines is not
10380 indented.  While this is no problem when writing a @emph{book-like} document
10381 where the outline headings are really section headings, in a more
10382 @emph{list-oriented} outline, indented structure is a lot cleaner:
10384 @example
10385 @group
10386 * Top level headline             |    * Top level headline
10387 ** Second level                  |      * Second level
10388 *** 3rd level                    |        * 3rd level
10389 some text                        |          some text
10390 *** 3rd level                    |        * 3rd level
10391 more text                        |          more text
10392 * Another top level headline     |    * Another top level headline
10393 @end group
10394 @end example
10396 @noindent
10397 If you are using at least Emacs 23.1.50.3 and version 6.29 of Org, this kind
10398 of view can be achieved dynamically at display time using
10399 @code{org-indent-mode}.  In this minor mode, all lines are prefixed for
10400 display with the necessary amount of space.  Also headlines are prefixed with
10401 additional stars, so that the amount of indentation shifts by
10402 two@footnote{See the variable @code{org-indent-indentation-per-level}.}
10403 spaces per level.  All headline stars but the last one are made invisible
10404 using the @code{org-hide} face@footnote{Turning on @code{org-indent-mode}
10405 sets @code{org-hide-leading-stars} to @code{t} and
10406 @code{org-adapt-indentation} to @code{nil}.} - see below under @samp{2.} for
10407 more information on how this works.  You can turn on @code{org-indent-mode}
10408 for all files by customizing the variable @code{org-startup-indented}, or you
10409 can turn it on for individual files using
10411 @example
10412 #+STARTUP: indent
10413 @end example
10415 If you want a similar effect in earlier version of Emacs and/or Org, or if
10416 you want the indentation to be hard space characters so that the plain text
10417 file looks as similar as possible to the Emacs display, Org supports you in
10418 the following way:
10420 @enumerate
10421 @item
10422 @emph{Indentation of text below headlines}@*
10423 You may indent text below each headline to make the left boundary line up
10424 with the headline, like
10426 @example
10427 *** 3rd level
10428     more text, now indented
10429 @end example
10431 @vindex org-adapt-indentation
10432 Org supports this with paragraph filling, line wrapping, and structure
10433 editing@footnote{See also the variable @code{org-adapt-indentation}.},
10434 preserving or adapting the indentation as appropriate.
10436 @item
10437 @vindex org-hide-leading-stars
10438 @emph{Hiding leading stars}@* You can modify the display in such a way that
10439 all leading stars become invisible.  To do this in a global way, configure
10440 the variable @code{org-hide-leading-stars} or change this on a per-file basis
10441 with
10443 @example
10444 #+STARTUP: hidestars
10445 #+STARTUP: showstars
10446 @end example
10448 With hidden stars, the tree becomes:
10450 @example
10451 @group
10452 * Top level headline
10453  * Second level
10454   * 3rd level
10455   ...
10456 @end group
10457 @end example
10459 @noindent
10460 @vindex org-hide @r{(face)}
10461 The leading stars are not truly replaced by whitespace, they are only
10462 fontified with the face @code{org-hide} that uses the background color as
10463 font color.  If you are not using either white or black background, you may
10464 have to customize this face to get the wanted effect.  Another possibility is
10465 to set this font such that the extra stars are @i{almost} invisible, for
10466 example using the color @code{grey90} on a white background.
10468 @item
10469 @vindex org-odd-levels-only
10470 Things become cleaner still if you skip all the even levels and use only odd
10471 levels 1, 3, 5..., effectively adding two stars to go from one outline level
10472 to the next@footnote{When you need to specify a level for a property search
10473 or refile targets, @samp{LEVEL=2} will correspond to 3 stars, etc@.}.  In this
10474 way we get the outline view shown at the beginning of this section.  In order
10475 to make the structure editing and export commands handle this convention
10476 correctly, configure the variable @code{org-odd-levels-only}, or set this on
10477 a per-file basis with one of the following lines:
10479 @example
10480 #+STARTUP: odd
10481 #+STARTUP: oddeven
10482 @end example
10484 You can convert an Org file from single-star-per-level to the
10485 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
10486 RET} in that file.  The reverse operation is @kbd{M-x
10487 org-convert-to-oddeven-levels}.
10488 @end enumerate
10490 @node TTY keys, Interaction, Clean view, Miscellaneous
10491 @section Using Org on a tty
10492 @cindex tty key bindings
10494 Because Org contains a large number of commands, by default many of
10495 Org's core commands are bound to keys that are generally not
10496 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
10497 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
10498 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
10499 these commands on a tty when special keys are unavailable, the following
10500 alternative bindings can be used.  The tty bindings below will likely be
10501 more cumbersome; you may find for some of the bindings below that a
10502 customized workaround suits you better.  For example, changing a timestamp
10503 is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
10504 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
10506 @multitable @columnfractions 0.15 0.2 0.2
10507 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
10508 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
10509 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
10510 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
10511 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
10512 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
10513 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
10514 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
10515 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
10516 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
10517 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
10518 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
10519 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
10520 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
10521 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
10522 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
10523 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
10524 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
10525 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
10526 @end multitable
10529 @node Interaction,  , TTY keys, Miscellaneous
10530 @section Interaction with other packages
10531 @cindex packages, interaction with other
10532 Org lives in the world of GNU Emacs and interacts in various ways
10533 with other code out there.
10535 @menu
10536 * Cooperation::                 Packages Org cooperates with
10537 * Conflicts::                   Packages that lead to conflicts
10538 @end menu
10540 @node Cooperation, Conflicts, Interaction, Interaction
10541 @subsection Packages that Org cooperates with
10543 @table @asis
10544 @cindex @file{calc.el}
10545 @cindex Gillespie, Dave
10546 @item @file{calc.el} by Dave Gillespie
10547 Org uses the Calc package for implementing spreadsheet
10548 functionality in its tables (@pxref{The spreadsheet}).  Org
10549 checks for the availability of Calc by looking for the function
10550 @code{calc-eval} which will have been autoloaded during setup if Calc has
10551 been installed properly.  As of Emacs 22, Calc is part of the Emacs
10552 distribution.  Another possibility for interaction between the two
10553 packages is using Calc for embedded calculations. @xref{Embedded Mode,
10554 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
10555 @item @file{constants.el} by Carsten Dominik
10556 @cindex @file{constants.el}
10557 @cindex Dominik, Carsten
10558 @vindex org-table-formula-constants
10559 In a table formula (@pxref{The spreadsheet}), it is possible to use
10560 names for natural constants or units.  Instead of defining your own
10561 constants in the variable @code{org-table-formula-constants}, install
10562 the @file{constants} package which defines a large number of constants
10563 and units, and lets you use unit prefixes like @samp{M} for
10564 @samp{Mega}, etc@.  You will need version 2.0 of this package, available
10565 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
10566 the function @code{constants-get}, which has to be autoloaded in your
10567 setup.  See the installation instructions in the file
10568 @file{constants.el}.
10569 @item @file{cdlatex.el} by Carsten Dominik
10570 @cindex @file{cdlatex.el}
10571 @cindex Dominik, Carsten
10572 Org mode can make use of the CDLa@TeX{} package to efficiently enter
10573 La@TeX{} fragments into Org files.  See @ref{CDLaTeX mode}.
10574 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
10575 @cindex @file{imenu.el}
10576 Imenu allows menu access to an index of items in a file.  Org mode
10577 supports Imenu---all you need to do to get the index is the following:
10578 @lisp
10579 (add-hook 'org-mode-hook
10580           (lambda () (imenu-add-to-menubar "Imenu")))
10581 @end lisp
10582 @vindex org-imenu-depth
10583 By default the index is two levels deep---you can modify the depth using
10584 the option @code{org-imenu-depth}.
10585 @item @file{remember.el} by John Wiegley
10586 @cindex @file{remember.el}
10587 @cindex Wiegley, John
10588 Org cooperates with remember, see @ref{Remember}.
10589 @file{Remember.el} is not part of Emacs, find it on the web.
10590 @item @file{speedbar.el} by Eric M. Ludlam
10591 @cindex @file{speedbar.el}
10592 @cindex Ludlam, Eric M.
10593 Speedbar is a package that creates a special frame displaying files and
10594 index items in files.  Org mode supports Speedbar and allows you to
10595 drill into Org files directly from the Speedbar.  It also allows you to
10596 restrict the scope of agenda commands to a file or a subtree by using
10597 the command @kbd{<} in the Speedbar frame.
10598 @cindex @file{table.el}
10599 @item @file{table.el} by Takaaki Ota
10600 @kindex C-c C-c
10601 @cindex table editor, @file{table.el}
10602 @cindex @file{table.el}
10603 @cindex Ota, Takaaki
10605 Complex ASCII tables with automatic line wrapping, column- and
10606 row-spanning, and alignment can be created using the Emacs table
10607 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
10608 and also part of Emacs 22).
10609 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
10610 will call @command{table-recognize-table} and move the cursor into the
10611 table.  Inside a table, the keymap of Org mode is inactive.  In order
10612 to execute Org mode-related commands, leave the table.
10614 @table @kbd
10615 @kindex C-c C-c
10616 @item C-c C-c
10617 Recognize @file{table.el} table.  Works when the cursor is in a
10618 table.el table.
10620 @kindex C-c ~
10621 @item C-c ~
10622 Insert a @file{table.el} table.  If there is already a table at point, this
10623 command converts it between the @file{table.el} format and the Org-mode
10624 format.  See the documentation string of the command
10625 @code{org-convert-table} for the restrictions under which this is
10626 possible.
10627 @end table
10628 @file{table.el} is part of Emacs 22.
10629 @item @file{footnote.el} by Steven L. Baur
10630 @cindex @file{footnote.el}
10631 @cindex Baur, Steven L.
10632 Org mode recognizes numerical footnotes as provided by this package.
10633 However, Org mode also has its own footnote support (@pxref{Footnotes}),
10634 which makes using @file{footnote.el} unnecessary.
10635 @end table
10637 @node Conflicts,  , Cooperation, Interaction
10638 @subsection Packages that lead to conflicts with Org mode
10640 @table @asis
10642 @cindex @code{shift-selection-mode}
10643 @vindex org-support-shift-select
10644 In Emacs 23, @code{shift-selection-mode} is on by default, meaning that
10645 cursor motions combined with the shift key should start or enlarge regions.
10646 This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
10647 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
10648 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
10649 special contexts don't do anything, but you can customize the variable
10650 @code{org-support-shift-select}.  Org mode then tries to accommodate shift
10651 selection by (i) using it outside of the special contexts where special
10652 commands apply, and by (ii) extending an existing active region even if the
10653 cursor moves across a special context.
10655 @item @file{CUA.el} by Kim. F. Storm
10656 @cindex @file{CUA.el}
10657 @cindex Storm, Kim. F.
10658 @vindex org-replace-disputed-keys
10659 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by CUA mode
10660 (as well as @code{pc-select-mode} and @code{s-region-mode}) to select and extend the
10661 region.  In fact, Emacs 23 has this built-in in the form of
10662 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
10663 23, you probably don't want to use another package for this purpose.  However,
10664 if you prefer to leave these keys to a different package while working in
10665 Org mode, configure the variable @code{org-replace-disputed-keys}.  When set,
10666 Org will move the following key bindings in Org files, and in the agenda
10667 buffer (but not during date selection).
10669 @example
10670 S-UP      ->  M-p             S-DOWN     ->  M-n
10671 S-LEFT    ->  M--             S-RIGHT    ->  M-+
10672 C-S-LEFT  ->  M-S--           C-S-RIGHT  ->  M-S-+
10673 @end example
10675 @vindex org-disputed-keys
10676 Yes, these are unfortunately more difficult to remember.  If you want
10677 to have other replacement keys, look at the variable
10678 @code{org-disputed-keys}.
10680 @item @file{yasnippet.el}
10681 @cindex @file{yasnippet.el}
10682 The way Org-mode binds the TAB key (binding to @code{[tab]} instead of
10683 @code{"\t"}) overrules yasnippets' access to this key.  The following code
10684 fixed this problem:
10686 @lisp
10687 (add-hook 'org-mode-hook
10688           (lambda ()
10689             (org-set-local 'yas/trigger-key [tab])
10690             (define-key yas/keymap [tab] 'yas/next-field-group)))
10691 @end lisp
10693 @item @file{windmove.el} by Hovav Shacham
10694 @cindex @file{windmove.el}
10695 This package also uses the @kbd{S-<cursor>} keys, so everything written
10696 in the paragraph above about CUA mode also applies here.
10698 @end table
10701 @node Hacking, MobileOrg, Miscellaneous, Top
10702 @appendix Hacking
10703 @cindex hacking
10705 This appendix covers some aspects where users can extend the functionality of
10706 Org.
10708 @menu
10709 * Hooks::                       Who to reach into Org's internals
10710 * Add-on packages::             Available extensions
10711 * Adding hyperlink types::      New custom link types
10712 * Context-sensitive commands::  How to add functionality to such commands
10713 * Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
10714 * Dynamic blocks::              Automatically filled blocks
10715 * Special agenda views::        Customized views
10716 * Extracting agenda information::  Postprocessing of agenda information
10717 * Using the property API::      Writing programs that use entry properties
10718 * Using the mapping API::       Mapping over all or selected entries
10719 @end menu
10721 @node Hooks, Add-on packages, Hacking, Hacking
10722 @section Hooks
10723 @cindex hooks
10725 Org has a large number of hook variables that can be used to add
10726 functionality.  This appendix about hacking is going to illustrate the
10727 use of some of them.  A complete list of all hooks with documentation is
10728 maintained by the Worg project and can be found at
10729 @uref{http://orgmode.org/worg/org-configs/org-hooks.php}.
10731 @node Add-on packages, Adding hyperlink types, Hooks, Hacking
10732 @section Add-on packages
10733 @cindex add-on packages
10735 A large number of add-on packages have been written by various authors.
10736 These packages are not part of Emacs, but they are distributed as contributed
10737 packages with the separate release available at the Org mode home page at
10738 @uref{http://orgmode.org}.  The list of contributed packages, along with
10739 documentation about each package, is maintained by the Worg project at
10740 @uref{http://orgmode.org/worg/org-contrib/}.
10744 @node Adding hyperlink types, Context-sensitive commands, Add-on packages, Hacking
10745 @section Adding hyperlink types
10746 @cindex hyperlinks, adding new types
10748 Org has a large number of hyperlink types built-in
10749 (@pxref{Hyperlinks}).  If you would like to add new link types, Org
10750 provides an interface for doing so.  Let's look at an example file,
10751 @file{org-man.el}, that will add support for creating links like
10752 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
10753 Emacs:
10755 @lisp
10756 ;;; org-man.el - Support for links to manpages in Org
10758 (require 'org)
10760 (org-add-link-type "man" 'org-man-open)
10761 (add-hook 'org-store-link-functions 'org-man-store-link)
10763 (defcustom org-man-command 'man
10764   "The Emacs command to be used to display a man page."
10765   :group 'org-link
10766   :type '(choice (const man) (const woman)))
10768 (defun org-man-open (path)
10769   "Visit the manpage on PATH.
10770 PATH should be a topic that can be thrown at the man command."
10771   (funcall org-man-command path))
10773 (defun org-man-store-link ()
10774   "Store a link to a manpage."
10775   (when (memq major-mode '(Man-mode woman-mode))
10776     ;; This is a man page, we do make this link
10777     (let* ((page (org-man-get-page-name))
10778            (link (concat "man:" page))
10779            (description (format "Manpage for %s" page)))
10780       (org-store-link-props
10781        :type "man"
10782        :link link
10783        :description description))))
10785 (defun org-man-get-page-name ()
10786   "Extract the page name from the buffer name."
10787   ;; This works for both `Man-mode' and `woman-mode'.
10788   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
10789       (match-string 1 (buffer-name))
10790     (error "Cannot create link to this man page")))
10792 (provide 'org-man)
10794 ;;; org-man.el ends here
10795 @end lisp
10797 @noindent
10798 You would activate this new link type in @file{.emacs} with
10800 @lisp
10801 (require 'org-man)
10802 @end lisp
10804 @noindent
10805 Let's go through the file and see what it does.
10806 @enumerate
10807 @item
10808 It does @code{(require 'org)} to make sure that @file{org.el} has been
10809 loaded.
10810 @item
10811 The next line calls @code{org-add-link-type} to define a new link type
10812 with prefix @samp{man}.  The call also contains the name of a function
10813 that will be called to follow such a link.
10814 @item
10815 @vindex org-store-link-functions
10816 The next line adds a function to @code{org-store-link-functions}, in
10817 order to allow the command @kbd{C-c l} to record a useful link in a
10818 buffer displaying a man page.
10819 @end enumerate
10821 The rest of the file defines the necessary variables and functions.
10822 First there is a customization variable that determines which Emacs
10823 command should be used to display man pages.  There are two options,
10824 @code{man} and @code{woman}.  Then the function to follow a link is
10825 defined.  It gets the link path as an argument---in this case the link
10826 path is just a topic for the manual command.  The function calls the
10827 value of @code{org-man-command} to display the man page.
10829 Finally the function @code{org-man-store-link} is defined.  When you try
10830 to store a link with @kbd{C-c l}, this function will be called to
10831 try to make a link.  The function must first decide if it is supposed to
10832 create the link for this buffer type; we do this by checking the value
10833 of the variable @code{major-mode}.  If not, the function must exit and
10834 return the value @code{nil}.  If yes, the link is created by getting the
10835 manual topic from the buffer name and prefixing it with the string
10836 @samp{man:}.  Then it must call the command @code{org-store-link-props}
10837 and set the @code{:type} and @code{:link} properties.  Optionally you
10838 can also set the @code{:description} property to provide a default for
10839 the link description when the link is later inserted into an Org
10840 buffer with @kbd{C-c C-l}.
10842 When is makes sense for your new link type, you may also define a function
10843 @code{org-PREFIX-complete-link} that implements special (@eg completion)
10844 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
10845 not accept any arguments, and return the full link with prefix.
10847 @node Context-sensitive commands, Tables in arbitrary syntax, Adding hyperlink types, Hacking
10848 @section Context-sensitive commands
10849 @cindex context-sensitive commands, hooks
10850 @cindex add-ons, context-sensitive commands
10851 @vindex org-ctrl-c-ctrl-c-hook
10853 Org has several commands that act differently depending on context.  The most
10854 important example it the @kbd{C-c C-c} (@pxref{The very busy C-c C-c key}).
10855 Also the @kbd{M-cursor} and @kbd{M-S-cursor} keys have this property.
10857 Add-ons can tap into this functionality by providing a function that detects
10858 special context for that add-on and executes functionality appropriate for
10859 the context.  Here is an example from Dan Davison's @file{org-R.el} which
10860 allows you to evaluate commands based on the @file{R} programming language.  For
10861 this package, special contexts are lines that start with @code{#+R:} or
10862 @code{#+RR:}.
10864 @lisp
10865 (defun org-R-apply-maybe ()
10866   "Detect if this is context for org-R and execute R commands."
10867   (if (save-excursion
10868         (beginning-of-line 1)
10869         (looking-at "#\\+RR?:"))
10870       (progn (call-interactively 'org-R-apply)
10871              t) ;; to signal that we took action
10872     nil)) ;; to signal that we did not
10874 (add-hook 'org-ctrl-c-ctrl-c-hook 'org-R-apply-maybe)
10875 @end lisp
10877 The function first checks if the cursor is in such a line.  If that is the
10878 case, @code{org-R-apply} is called and the function returns @code{t} to
10879 signal that action was taken, and @kbd{C-c C-c} will stop looking for other
10880 contexts.  If the function finds it should do nothing locally, it returns @code{nil} so that other, similar functions can have a try.
10883 @node Tables in arbitrary syntax, Dynamic blocks, Context-sensitive commands, Hacking
10884 @section Tables and lists in arbitrary syntax
10885 @cindex tables, in other modes
10886 @cindex lists, in other modes
10887 @cindex Orgtbl mode
10889 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
10890 frequent feature request has been to make it work with native tables in
10891 specific languages, for example La@TeX{}.  However, this is extremely
10892 hard to do in a general way, would lead to a customization nightmare,
10893 and would take away much of the simplicity of the Orgtbl-mode table
10894 editor.
10897 This appendix describes a different approach.  We keep the Orgtbl mode
10898 table in its native format (the @i{source table}), and use a custom
10899 function to @i{translate} the table to the correct syntax, and to
10900 @i{install} it in the right location (the @i{target table}).  This puts
10901 the burden of writing conversion functions on the user, but it allows
10902 for a very flexible system.
10904 Bastien added the ability to do the same with lists.  You can use Org's
10905 facilities to edit and structure lists by turning @code{orgstruct-mode}
10906 on, then locally exporting such lists in another format (HTML, La@TeX{}
10907 or Texinfo.)
10910 @menu
10911 * Radio tables::                Sending and receiving radio tables
10912 * A LaTeX example::             Step by step, almost a tutorial
10913 * Translator functions::        Copy and modify
10914 * Radio lists::                 Doing the same for lists
10915 @end menu
10917 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
10918 @subsection Radio tables
10919 @cindex radio tables
10921 To define the location of the target table, you first need to create two
10922 lines that are comments in the current mode, but contain magic words for
10923 Orgtbl mode to find.  Orgtbl mode will insert the translated table
10924 between these lines, replacing whatever was there before.  For example:
10926 @example
10927 /* BEGIN RECEIVE ORGTBL table_name */
10928 /* END RECEIVE ORGTBL table_name */
10929 @end example
10931 @noindent
10932 Just above the source table, we put a special line that tells
10933 Orgtbl mode how to translate this table and where to install it.  For
10934 example:
10935 @cindex #+ORGTBL
10936 @example
10937 #+ORGTBL: SEND table_name translation_function arguments....
10938 @end example
10940 @noindent
10941 @code{table_name} is the reference name for the table that is also used
10942 in the receiver lines. @code{translation_function} is the Lisp function
10943 that does the translation.  Furthermore, the line can contain a list of
10944 arguments (alternating key and value) at the end.  The arguments will be
10945 passed as a property list to the translation function for
10946 interpretation.  A few standard parameters are already recognized and
10947 acted upon before the translation function is called:
10949 @table @code
10950 @item :skip N
10951 Skip the first N lines of the table.  Hlines do count as separate lines for
10952 this parameter!
10954 @item :skipcols (n1 n2 ...)
10955 List of columns that should be skipped.  If the table has a column with
10956 calculation marks, that column is automatically discarded as well.
10957 Please note that the translator function sees the table @emph{after} the
10958 removal of these columns, the function never knows that there have been
10959 additional columns.
10960 @end table
10962 @noindent
10963 The one problem remaining is how to keep the source table in the buffer
10964 without disturbing the normal workings of the file, for example during
10965 compilation of a C file or processing of a La@TeX{} file.  There are a
10966 number of different solutions:
10968 @itemize @bullet
10969 @item
10970 The table could be placed in a block comment if that is supported by the
10971 language.  For example, in C mode you could wrap the table between
10972 @samp{/*} and @samp{*/} lines.
10973 @item
10974 Sometimes it is possible to put the table after some kind of @i{END}
10975 statement, for example @samp{\bye} in @TeX{} and @samp{\end@{document@}}
10976 in La@TeX{}.
10977 @item
10978 You can just comment the table line-by-line whenever you want to process
10979 the file, and uncomment it whenever you need to edit the table.  This
10980 only sounds tedious---the command @kbd{M-x orgtbl-toggle-comment}
10981 makes this comment-toggling very easy, in particular if you bind it to a
10982 key.
10983 @end itemize
10985 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
10986 @subsection A La@TeX{} example of radio tables
10987 @cindex La@TeX{}, and Orgtbl mode
10989 The best way to wrap the source table in La@TeX{} is to use the
10990 @code{comment} environment provided by @file{comment.sty}.  It has to be
10991 activated by placing @code{\usepackage@{comment@}} into the document
10992 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
10993 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
10994 variable @code{orgtbl-radio-tables} to install templates for other
10995 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
10996 be prompted for a table name, let's say we use @samp{salesfigures}.  You
10997 will then get the following template:
10999 @cindex #+ORGTBL, SEND
11000 @example
11001 % BEGIN RECEIVE ORGTBL salesfigures
11002 % END RECEIVE ORGTBL salesfigures
11003 \begin@{comment@}
11004 #+ORGTBL: SEND salesfigures orgtbl-to-latex
11005 | | |
11006 \end@{comment@}
11007 @end example
11009 @noindent
11010 @vindex La@TeX{}-verbatim-environments
11011 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
11012 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
11013 into the receiver location with name @code{salesfigures}.  You may now
11014 fill in the table, feel free to use the spreadsheet features@footnote{If
11015 the @samp{#+TBLFM} line contains an odd number of dollar characters,
11016 this may cause problems with font-lock in La@TeX{} mode.  As shown in the
11017 example you can fix this by adding an extra line inside the
11018 @code{comment} environment that is used to balance the dollar
11019 expressions.  If you are using AUC@TeX{} with the font-latex library, a
11020 much better solution is to add the @code{comment} environment to the
11021 variable @code{LaTeX-verbatim-environments}.}:
11023 @example
11024 % BEGIN RECEIVE ORGTBL salesfigures
11025 % END RECEIVE ORGTBL salesfigures
11026 \begin@{comment@}
11027 #+ORGTBL: SEND salesfigures orgtbl-to-latex
11028 | Month | Days | Nr sold | per day |
11029 |-------+------+---------+---------|
11030 | Jan   |   23 |      55 |     2.4 |
11031 | Feb   |   21 |      16 |     0.8 |
11032 | March |   22 |     278 |    12.6 |
11033 #+TBLFM: $4=$3/$2;%.1f
11034 % $ (optional extra dollar to keep font-lock happy, see footnote)
11035 \end@{comment@}
11036 @end example
11038 @noindent
11039 When you are done, press @kbd{C-c C-c} in the table to get the converted
11040 table inserted between the two marker lines.
11042 Now let's assume you want to make the table header by hand, because you
11043 want to control how columns are aligned, etc@.  In this case we make sure
11044 that the table translator skips the first 2 lines of the source
11045 table, and tell the command to work as a @i{splice}, @ie to not produce
11046 header and footer commands of the target table:
11048 @example
11049 \begin@{tabular@}@{lrrr@}
11050 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
11051 % BEGIN RECEIVE ORGTBL salesfigures
11052 % END RECEIVE ORGTBL salesfigures
11053 \end@{tabular@}
11055 \begin@{comment@}
11056 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
11057 | Month | Days | Nr sold | per day |
11058 |-------+------+---------+---------|
11059 | Jan   |   23 |      55 |     2.4 |
11060 | Feb   |   21 |      16 |     0.8 |
11061 | March |   22 |     278 |    12.6 |
11062 #+TBLFM: $4=$3/$2;%.1f
11063 \end@{comment@}
11064 @end example
11066 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
11067 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
11068 and marks horizontal lines with @code{\hline}.  Furthermore, it
11069 interprets the following parameters (see also @pxref{Translator functions}):
11071 @table @code
11072 @item :splice nil/t
11073 When set to t, return only table body lines, don't wrap them into a
11074 tabular environment.  Default is nil.
11076 @item :fmt fmt
11077 A format to be used to wrap each field, it should contain @code{%s} for the
11078 original field value.  For example, to wrap each field value in dollars,
11079 you could use @code{:fmt "$%s$"}.  This may also be a property list with
11080 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
11081 A function of one argument can be used in place of the strings; the
11082 function must return a formatted string.
11084 @item :efmt efmt
11085 Use this format to print numbers with exponentials.  The format should
11086 have @code{%s} twice for inserting mantissa and exponent, for example
11087 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
11088 may also be a property list with column numbers and formats, for example
11089 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
11090 @code{efmt} has been applied to a value, @code{fmt} will also be
11091 applied.  Similar to @code{fmt}, functions of two arguments can be
11092 supplied instead of strings.
11093 @end table
11095 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
11096 @subsection Translator functions
11097 @cindex HTML, and Orgtbl mode
11098 @cindex translator function
11100 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
11101 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
11102 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
11103 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
11104 code that produces tables during HTML export.}, these all use a generic
11105 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
11106 itself is a very short function that computes the column definitions for the
11107 @code{tabular} environment, defines a few field and line separators and then
11108 hands processing over to the generic translator.  Here is the entire code:
11110 @lisp
11111 @group
11112 (defun orgtbl-to-latex (table params)
11113   "Convert the Orgtbl mode TABLE to LaTeX."
11114   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
11115                                org-table-last-alignment ""))
11116          (params2
11117           (list
11118            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
11119            :tend "\\end@{tabular@}"
11120            :lstart "" :lend " \\\\" :sep " & "
11121            :efmt "%s\\,(%s)" :hline "\\hline")))
11122     (orgtbl-to-generic table (org-combine-plists params2 params))))
11123 @end group
11124 @end lisp
11126 As you can see, the properties passed into the function (variable
11127 @var{PARAMS}) are combined with the ones newly defined in the function
11128 (variable @var{PARAMS2}).  The ones passed into the function (@ie the
11129 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
11130 would like to use the La@TeX{} translator, but wanted the line endings to
11131 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
11132 overrule the default with
11134 @example
11135 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
11136 @end example
11138 For a new language, you can either write your own converter function in
11139 analogy with the La@TeX{} translator, or you can use the generic function
11140 directly.  For example, if you have a language where a table is started
11141 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
11142 started with @samp{!BL!}, ended with @samp{!EL!}, and where the field
11143 separator is a TAB, you could call the generic translator like this (on
11144 a single line!):
11146 @example
11147 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
11148                               :lstart "!BL! " :lend " !EL!" :sep "\t"
11149 @end example
11151 @noindent
11152 Please check the documentation string of the function
11153 @code{orgtbl-to-generic} for a full list of parameters understood by
11154 that function, and remember that you can pass each of them into
11155 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
11156 using the generic function.
11158 Of course you can also write a completely new function doing complicated
11159 things the generic translator cannot do.  A translator function takes
11160 two arguments.  The first argument is the table, a list of lines, each
11161 line either the symbol @code{hline} or a list of fields.  The second
11162 argument is the property list containing all parameters specified in the
11163 @samp{#+ORGTBL: SEND} line.  The function must return a single string
11164 containing the formatted table.  If you write a generally useful
11165 translator, please post it on @email{emacs-orgmode@@gnu.org} so that
11166 others can benefit from your work.
11168 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
11169 @subsection Radio lists
11170 @cindex radio lists
11171 @cindex org-list-insert-radio-list
11173 Sending and receiving radio lists works exactly the same way than sending and
11174 receiving radio tables (@pxref{Radio tables}).  As for radio tables, you can
11175 insert radio lists templates in HTML, La@TeX{} and Texinfo modes by calling
11176 @code{org-list-insert-radio-list}.
11178 Here are the differences with radio tables:
11180 @itemize @minus
11181 @item
11182 Use @code{ORGLST} instead of @code{ORGTBL}.
11183 @item
11184 The available translation functions for radio lists don't take
11185 parameters.
11186 @item
11187 @kbd{C-c C-c} will work when pressed on the first item of the list.
11188 @end itemize
11190 Here is a La@TeX{} example.  Let's say that you have this in your
11191 La@TeX{} file:
11193 @cindex #+ORGLIST
11194 @example
11195 % BEGIN RECEIVE ORGLST to-buy
11196 % END RECEIVE ORGLST to-buy
11197 \begin@{comment@}
11198 #+ORGLIST: SEND to-buy orgtbl-to-latex
11199 - a new house
11200 - a new computer
11201   + a new keyboard
11202   + a new mouse
11203 - a new life
11204 \end@{comment@}
11205 @end example
11207 Pressing `C-c C-c' on @code{a new house} and will insert the converted
11208 La@TeX{} list between the two marker lines.
11210 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
11211 @section Dynamic blocks
11212 @cindex dynamic blocks
11214 Org documents can contain @emph{dynamic blocks}.  These are
11215 specially marked regions that are updated by some user-written function.
11216 A good example for such a block is the clock table inserted by the
11217 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
11219 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
11220 to the block and can also specify parameters for the function producing
11221 the content of the block.
11223 #+BEGIN:dynamic block
11224 @example
11225 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
11227 #+END:
11228 @end example
11230 Dynamic blocks are updated with the following commands
11232 @table @kbd
11233 @kindex C-c C-x C-u
11234 @item C-c C-x C-u
11235 Update dynamic block at point.
11236 @kindex C-u C-c C-x C-u
11237 @item C-u C-c C-x C-u
11238 Update all dynamic blocks in the current file.
11239 @end table
11241 Updating a dynamic block means to remove all the text between BEGIN and
11242 END, parse the BEGIN line for parameters and then call the specific
11243 writer function for this block to insert the new content.  If you want
11244 to use the original content in the writer function, you can use the
11245 extra parameter @code{:content}.
11247 For a block with name @code{myblock}, the writer function is
11248 @code{org-dblock-write:myblock} with as only parameter a property list
11249 with the parameters given in the begin line.  Here is a trivial example
11250 of a block that keeps track of when the block update function was last
11251 run:
11253 @example
11254 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
11256 #+END:
11257 @end example
11259 @noindent
11260 The corresponding block writer function could look like this:
11262 @lisp
11263 (defun org-dblock-write:block-update-time (params)
11264    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
11265      (insert "Last block update at: "
11266              (format-time-string fmt (current-time)))))
11267 @end lisp
11269 If you want to make sure that all dynamic blocks are always up-to-date,
11270 you could add the function @code{org-update-all-dblocks} to a hook, for
11271 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
11272 written in a way such that it does nothing in buffers that are not in
11273 @code{org-mode}.
11275 @node Special agenda views, Extracting agenda information, Dynamic blocks, Hacking
11276 @section Special agenda views
11277 @cindex agenda views, user-defined
11279 Org provides a special hook that can be used to narrow down the
11280 selection made by any of the agenda views.  You may specify a function
11281 that is used at each match to verify if the match should indeed be part
11282 of the agenda view, and if not, how much should be skipped.
11284 Let's say you want to produce a list of projects that contain a WAITING
11285 tag anywhere in the project tree.  Let's further assume that you have
11286 marked all tree headings that define a project with the TODO keyword
11287 PROJECT.  In this case you would run a TODO search for the keyword
11288 PROJECT, but skip the match unless there is a WAITING tag anywhere in
11289 the subtree belonging to the project line.
11291 To achieve this, you must write a function that searches the subtree for
11292 the tag.  If the tag is found, the function must return @code{nil} to
11293 indicate that this match should not be skipped.  If there is no such
11294 tag, return the location of the end of the subtree, to indicate that
11295 search should continue from there.
11297 @lisp
11298 (defun my-skip-unless-waiting ()
11299   "Skip trees that are not waiting"
11300   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
11301     (if (re-search-forward ":waiting:" subtree-end t)
11302         nil          ; tag found, do not skip
11303       subtree-end))) ; tag not found, continue after end of subtree
11304 @end lisp
11306 Now you may use this function in an agenda custom command, for example
11307 like this:
11309 @lisp
11310 (org-add-agenda-custom-command
11311  '("b" todo "PROJECT"
11312    ((org-agenda-skip-function 'my-skip-unless-waiting)
11313     (org-agenda-overriding-header "Projects waiting for something: "))))
11314 @end lisp
11316 @vindex org-agenda-overriding-header
11317 Note that this also binds @code{org-agenda-overriding-header} to get a
11318 meaningful header in the agenda view.
11320 @vindex org-odd-levels-only
11321 @vindex org-agenda-skip-function
11322 A general way to create custom searches is to base them on a search for
11323 entries with a certain level limit.  If you want to study all entries with
11324 your custom search function, simply do a search for
11325 @samp{LEVEL>0}@footnote{Note that, when using @code{org-odd-levels-only}, a
11326 level number corresponds to order in the hierarchy, not to the number of
11327 stars.}, and then use @code{org-agenda-skip-function} to select the entries
11328 you really want to have.
11330 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
11331 particular, you may use the functions @code{org-agenda-skip-entry-if}
11332 and @code{org-agenda-skip-subtree-if} in this form, for example:
11334 @table @code
11335 @item '(org-agenda-skip-entry-if 'scheduled)
11336 Skip current entry if it has been scheduled.
11337 @item '(org-agenda-skip-entry-if 'notscheduled)
11338 Skip current entry if it has not been scheduled.
11339 @item '(org-agenda-skip-entry-if 'deadline)
11340 Skip current entry if it has a deadline.
11341 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
11342 Skip current entry if it has a deadline, or if it is scheduled.
11343 @item '(org-agenda-skip-entry-if 'timestamp)
11344 Skip current entry if it has any timestamp, may also be deadline or scheduled.
11345 @item '(org-agenda-skip-entry 'regexp "regular expression")
11346 Skip current entry if the regular expression matches in the entry.
11347 @item '(org-agenda-skip-entry 'notregexp "regular expression")
11348 Skip current entry unless the regular expression matches.
11349 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
11350 Same as above, but check and skip the entire subtree.
11351 @end table
11353 Therefore we could also have written the search for WAITING projects
11354 like this, even without defining a special function:
11356 @lisp
11357 (org-add-agenda-custom-command
11358  '("b" todo "PROJECT"
11359    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
11360                                 'regexp ":waiting:"))
11361     (org-agenda-overriding-header "Projects waiting for something: "))))
11362 @end lisp
11364 @node Extracting agenda information, Using the property API, Special agenda views, Hacking
11365 @section Extracting agenda information
11366 @cindex agenda, pipe
11367 @cindex Scripts, for agenda processing
11369 @vindex org-agenda-custom-commands
11370 Org provides commands to access agenda information for the command
11371 line in Emacs batch mode.  This extracted information can be sent
11372 directly to a printer, or it can be read by a program that does further
11373 processing of the data.  The first of these commands is the function
11374 @code{org-batch-agenda}, that produces an agenda view and sends it as
11375 ASCII text to STDOUT.  The command takes a single string as parameter.
11376 If the string has length 1, it is used as a key to one of the commands
11377 you have configured in @code{org-agenda-custom-commands}, basically any
11378 key you can use after @kbd{C-c a}.  For example, to directly print the
11379 current TODO list, you could use
11381 @example
11382 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
11383 @end example
11385 If the parameter is a string with 2 or more characters, it is used as a
11386 tags/TODO match string.  For example, to print your local shopping list
11387 (all items with the tag @samp{shop}, but excluding the tag
11388 @samp{NewYork}), you could use
11390 @example
11391 emacs -batch -l ~/.emacs                                      \
11392       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
11393 @end example
11395 @noindent
11396 You may also modify parameters on the fly like this:
11398 @example
11399 emacs -batch -l ~/.emacs                                      \
11400    -eval '(org-batch-agenda "a"                               \
11401             org-agenda-ndays 30                               \
11402             org-agenda-include-diary nil                      \
11403             org-agenda-files (quote ("~/org/project.org")))'  \
11404    | lpr
11405 @end example
11407 @noindent
11408 which will produce a 30-day agenda, fully restricted to the Org file
11409 @file{~/org/projects.org}, not even including the diary.
11411 If you want to process the agenda data in more sophisticated ways, you
11412 can use the command @code{org-batch-agenda-csv} to get a comma-separated
11413 list of values for each agenda item.  Each line in the output will
11414 contain a number of fields separated by commas.  The fields in a line
11415 are:
11417 @example
11418 category     @r{The category of the item}
11419 head         @r{The headline, without TODO keyword, TAGS and PRIORITY}
11420 type         @r{The type of the agenda entry, can be}
11421                 todo               @r{selected in TODO match}
11422                 tagsmatch          @r{selected in tags match}
11423                 diary              @r{imported from diary}
11424                 deadline           @r{a deadline}
11425                 scheduled          @r{scheduled}
11426                 timestamp          @r{appointment, selected by timestamp}
11427                 closed             @r{entry was closed on date}
11428                 upcoming-deadline  @r{warning about nearing deadline}
11429                 past-scheduled     @r{forwarded scheduled item}
11430                 block              @r{entry has date block including date}
11431 todo         @r{The TODO keyword, if any}
11432 tags         @r{All tags including inherited ones, separated by colons}
11433 date         @r{The relevant date, like 2007-2-14}
11434 time         @r{The time, like 15:00-16:50}
11435 extra        @r{String with extra planning info}
11436 priority-l   @r{The priority letter if any was given}
11437 priority-n   @r{The computed numerical priority}
11438 @end example
11440 @noindent
11441 Time and date will only be given if a timestamp (or deadline/scheduled)
11442 led to the selection of the item.
11444 A CSV list like this is very easy to use in a post-processing script.
11445 For example, here is a Perl program that gets the TODO list from
11446 Emacs/Org and prints all the items, preceded by a checkbox:
11448 @example
11449 #!/usr/bin/perl
11451 # define the Emacs command to run
11452 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
11454 # run it and capture the output
11455 $agenda = qx@{$cmd 2>/dev/null@};
11457 # loop over all lines
11458 foreach $line (split(/\n/,$agenda)) @{
11459   # get the individual values
11460   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
11461    $priority_l,$priority_n) = split(/,/,$line);
11462   # process and print
11463   print "[ ] $head\n";
11465 @end example
11467 @node Using the property API, Using the mapping API, Extracting agenda information, Hacking
11468 @section Using the property API
11469 @cindex API, for properties
11470 @cindex properties, API
11472 Here is a description of the functions that can be used to work with
11473 properties.
11475 @defun org-entry-properties &optional pom which
11476 Get all properties of the entry at point-or-marker POM.@*
11477 This includes the TODO keyword, the tags, time strings for deadline,
11478 scheduled, and clocking, and any additional properties defined in the
11479 entry.  The return value is an alist, keys may occur multiple times
11480 if the property key was used several times.@*
11481 POM may also be nil, in which case the current entry is used.
11482 If WHICH is nil or `all', get all properties.  If WHICH is
11483 `special' or `standard', only get that subclass.
11484 @end defun
11485 @vindex org-use-property-inheritance
11486 @defun org-entry-get pom property &optional inherit
11487 Get value of PROPERTY for entry at point-or-marker POM.  By default,
11488 this only looks at properties defined locally in the entry.  If INHERIT
11489 is non-nil and the entry does not have the property, then also check
11490 higher levels of the hierarchy.  If INHERIT is the symbol
11491 @code{selective}, use inheritance if and only if the setting of
11492 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
11493 @end defun
11495 @defun org-entry-delete pom property
11496 Delete the property PROPERTY from entry at point-or-marker POM.
11497 @end defun
11499 @defun org-entry-put pom property value
11500 Set PROPERTY to VALUE for entry at point-or-marker POM.
11501 @end defun
11503 @defun org-buffer-property-keys &optional include-specials
11504 Get all property keys in the current buffer.
11505 @end defun
11507 @defun org-insert-property-drawer
11508 Insert a property drawer at point.
11509 @end defun
11511 @defun org-entry-put-multivalued-property pom property &rest values
11512 Set PROPERTY at point-or-marker POM to VALUES.  VALUES should be a list of
11513 strings.  They will be concatenated, with spaces as separators.
11514 @end defun
11516 @defun org-entry-get-multivalued-property pom property
11517 Treat the value of the property PROPERTY as a whitespace-separated list of
11518 values and return the values as a list of strings.
11519 @end defun
11521 @defun org-entry-add-to-multivalued-property pom property value
11522 Treat the value of the property PROPERTY as a whitespace-separated list of
11523 values and make sure that VALUE is in this list.
11524 @end defun
11526 @defun org-entry-remove-from-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 @emph{not} in this list.
11529 @end defun
11531 @defun org-entry-member-in-multivalued-property pom property value
11532 Treat the value of the property PROPERTY as a whitespace-separated list of
11533 values and check if VALUE is in this list.
11534 @end defun
11536 @node Using the mapping API,  , Using the property API, Hacking
11537 @section Using the mapping API
11538 @cindex API, for mapping
11539 @cindex mapping entries, API
11541 Org has sophisticated mapping capabilities to find all entries satisfying
11542 certain criteria.  Internally, this functionality is used to produce agenda
11543 views, but there is also an API that can be used to execute arbitrary
11544 functions for each or selected entries.  The main entry point for this API
11547 @defun org-map-entries func &optional match scope &rest skip
11548 Call FUNC at each headline selected by MATCH in SCOPE.
11550 FUNC is a function or a Lisp form.  The function will be called without
11551 arguments, with the cursor positioned at the beginning of the headline.
11552 The return values of all calls to the function will be collected and
11553 returned as a list.
11555 The call to FUNC will be wrapped into a save-excursion form, so FUNC
11556 does not need to preserve point.  After evaluation, the cursor will be
11557 moved to the end of the line (presumably of the headline of the
11558 processed entry) and search continues from there.  Under some
11559 circumstances, this may not produce the wanted results.  For example,
11560 if you have removed (@eg archived) the current (sub)tree it could
11561 mean that the next entry will be skipped entirely.  In such cases, you
11562 can specify the position from where search should continue by making
11563 FUNC set the variable `org-map-continue-from' to the desired buffer
11564 position.
11566 MATCH is a tags/property/todo match as it is used in the agenda match view.
11567 Only headlines that are matched by this query will be considered during
11568 the iteration.  When MATCH is nil or t, all headlines will be
11569 visited by the iteration.
11571 SCOPE determines the scope of this command.  It can be any of:
11573 @example
11574 nil     @r{the current buffer, respecting the restriction if any}
11575 tree    @r{the subtree started with the entry at point}
11576 file    @r{the current buffer, without restriction}
11577 file-with-archives
11578         @r{the current buffer, and any archives associated with it}
11579 agenda  @r{all agenda files}
11580 agenda-with-archives
11581         @r{all agenda files with any archive files associated with them}
11582 (file1 file2 ...)
11583         @r{if this is a list, all files in the list will be scanned}
11584 @end example
11585 @noindent
11586 The remaining args are treated as settings for the skipping facilities of
11587 the scanner.  The following items can be given here:
11589 @vindex org-agenda-skip-function
11590 @example
11591 archive   @r{skip trees with the archive tag}
11592 comment   @r{skip trees with the COMMENT keyword}
11593 function or Lisp form
11594           @r{will be used as value for @code{org-agenda-skip-function},}
11595           @r{so whenever the function returns t, FUNC}
11596           @r{will not be called for that entry and search will}
11597           @r{continue from the point where the function leaves it}
11598 @end example
11599 @end defun
11601 The function given to that mapping routine can really do anything you like.
11602 It can use the property API (@pxref{Using the property API}) to gather more
11603 information about the entry, or in order to change metadata in the entry.
11604 Here are a couple of functions that might be handy:
11606 @defun org-todo &optional arg
11607 Change the TODO state of the entry, see the docstring of the functions for
11608 the many possible values for the argument ARG.
11609 @end defun
11611 @defun org-priority &optional action
11612 Change the priority of the entry, see the docstring of this function for the
11613 possible values for ACTION.
11614 @end defun
11616 @defun org-toggle-tag tag &optional onoff
11617 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
11618 or @code{off} will not toggle tag, but ensure that it is either on or off.
11619 @end defun
11621 @defun org-promote
11622 Promote the current entry.
11623 @end defun
11625 @defun org-demote
11626 Demote the current entry.
11627 @end defun
11629 Here is a simple example that will turn all entries in the current file with
11630 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
11631 Entries in comment trees and in archive trees will be ignored.
11633 @lisp
11634 (org-map-entries
11635    '(org-todo "UPCOMING")
11636    "+TOMORROW" 'file 'archive 'comment)
11637 @end lisp
11639 The following example counts the number of entries with TODO keyword
11640 @code{WAITING}, in all agenda files.
11642 @lisp
11643 (length (org-map-entries t "/+WAITING" 'agenda))
11644 @end lisp
11646 @node MobileOrg, History and Acknowledgments, Hacking, Top
11647 @appendix MobileOrg
11648 @cindex iPhone
11649 @cindex MobileOrg
11651 @i{MobileOrg} is an application for the @i{iPhone/iPod Touch} series of
11652 devices, developed by Richard Moreland.  Instead of trying to implement the
11653 full feature set of Org and fighting with synchronization issues, this
11654 application chooses a different path.  @i{MobileOrg} provides offline viewing
11655 and capture support for an Org-mode system rooted on a ``real'' computer.
11656 Synchronization issues are avoided by making @i{MobileOrg} only @i{write} to
11657 a special capture file, that is only @i{read} by the computer-based system.
11659 This appendix describes the support Org has for creating agenda views in a
11660 format that can be displayed by @i{MobileOrg}, and for integrating notes
11661 captured by @i{MobileOrg} into the main system.  It does not cover the
11662 operation of @i{MobileOrg} itself (see @uref{http://ncogni.to/mobileorg/}).
11664 @menu
11665 * Setting up the staging area::  Where to interact with the mobile device
11666 * Pushing to MobileOrg::        Uploading Org files and agendas
11667 * Pulling from MobileOrg::      Integrating captured and flagged items
11668 @end menu
11670 @node Setting up the staging area, Pushing to MobileOrg, MobileOrg, MobileOrg
11671 @section Setting up the staging area
11673 Org-mode has commands to prepare a directory with files for @i{MobileOrg}, and to
11674 read captured notes from there.  If Emacs can directly write to the WebDAV
11675 directory accessed by @i{MobileOrg}, all you need to do is to point to this
11676 directory using the variable @code{org-mobile-directory}.
11678 If Emacs cannot access the WebDAV directory directly, you can use a local
11679 directory for staging.  Other means must then be used to keep this directory
11680 in sync with the WebDAV directory.  In the following example, files are
11681 staged in @file{~/stage}, and Org-mode hooks take care of moving files to and
11682 from the WebDAV directory using @file{scp}.
11684 @example
11685 (setq org-mobile-directory "~/stage/")
11686 (add-hook 'org-mobile-post-push-hook
11687   (lambda ()
11688    (shell-command "scp ~/stage/* user@@webdavhost:mobile/")))
11689 (add-hook 'org-mobile-pre-pull-hook
11690   (lambda ()
11691    (shell-command "scp user@@webdavhost:mobile/mobile-capture.org ~/stage/ ")))
11692 (add-hook 'org-mobile-post-pull-hook
11693   (lambda ()
11694    (shell-command "scp ~/stage/mobile-capture.org user@@webdavhost:mobile/")))
11695 @end example
11697 @node Pushing to MobileOrg, Pulling from MobileOrg, Setting up the staging area, MobileOrg
11698 @section Pushing to MobileOrg
11701 This operation copies all files currently listed in @code{org-agenda-files}
11702 to the directory @code{org-mobile-directory}.  It also creates (in the same
11703 directory) a special Org file @file{agendas.org}.  This file is an Org-mode
11704 style outline, containing every custom agenda view defined by the user.
11705 While creating the agendas, Org-mode will force@footnote{See the variable
11706 @code{org-mobile-force-id-on-agenda-items}.} an ID property on all entries
11707 referenced by the agendas, so that these entries can be uniquely identified
11708 if @i{MobileOrg} flags them for further action.  Finally, Org writes the file
11709 @file{index.org}, containing links to all other files.  If @i{MobileOrg} is
11710 configured to request this file from the WebDAV server, all agendas and Org
11711 files will be downloaded to the iPhone.
11713 @node Pulling from MobileOrg,  , Pushing to MobileOrg, MobileOrg
11714 @section Pulling from MobileOrg
11716 When @i{MobileOrg} synchronizes with the WebDAV server, it not only pulls the
11717 Org files for viewing.  It also appends captured entries and pointers to
11718 flagged entries to the file @file{mobile-capture.org} on the server.  Org has
11719 a @emph{pull} operation that integrates this information into an inbox file
11720 and operates on the pointers to flagged entries.  Here is how it works:
11722 @enumerate
11723 @item
11724 Org moves all entries found in @file{mobile-capture.org} and appends them to
11725 the file pointed to by the variable @code{org-mobile-inbox-for-pull}.  Each
11726 captured entry will be a top-level entry in the inbox file.
11727 @item
11728 After moving the entries, Org will attempt to act on the flags.  Some flags
11729 specify simple operations that will be executed directly and without user
11730 interaction.  Examples are marking an entry as DONE and/or archiving
11731 it@footnote{as specified by the variable @code{org-archive-default-action}}.
11732 All other flagged entries will receive a tag @code{:FLAGGED:}, so that they
11733 can be easily found again.  When there is a problem finding the entry that
11734 should be flagged, the pointer entry will remain in the inbox and will be
11735 marked with an error message.
11736 @item
11737 Org will then generate an agenda view with all flagged entries.  The user
11738 should then go through these entries and do whatever actions are necessary.
11739 If a note has been stored while flagging an entry in @i{MobileOrg}, that note
11740 will be displayed in the echo area when the cursor is on the corresponding
11741 agenda line.
11742 @table @kbd
11743 @kindex ?
11744 @item ?
11745 Pressing @kbd{?} in that special agenda will display the full flagging note in
11746 another window and also push it onto the kill ring.  So you could use @kbd{?
11747 z C-y C-c C-c} to store that flagging note as a normal note in the entry.
11748 Pressing @kbd{?} twice in succession will offer to remove the
11749 @code{:FLAGGED:} tag along with the recorded flagging note (which is stored
11750 in a property).
11751 @end table
11752 @end enumerate
11754 @kindex C-c a ?
11755 If you are not able to process all flagged entries directly, you can always
11756 return to this agenda view using @kbd{C-c a ?}.  Note, however, that there is
11757 a subtle difference.  The view created automatically by @kbd{M-x
11758 org-mobile-pull RET} is guaranteed to search all files that have been
11759 addressed by the last pull.  This might include a file that is not currently
11760 in your list of agenda files.  If you later use @kbd{C-c a ?} to regenerate
11761 the view, only the current agenda files will be searched.
11763 @node History and Acknowledgments, Main Index, MobileOrg, Top
11764 @appendix History and Acknowledgments
11765 @cindex acknowledgments
11766 @cindex history
11767 @cindex thanks
11769 Org was born in 2003, out of frustration over the user interface
11770 of the Emacs Outline mode.  I was trying to organize my notes and
11771 projects, and using Emacs seemed to be the natural way to go.  However,
11772 having to remember eleven different commands with two or three keys per
11773 command, only to hide and show parts of the outline tree, that seemed
11774 entirely unacceptable to me.  Also, when using outlines to take notes, I
11775 constantly wanted to restructure the tree, organizing it parallel to my
11776 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
11777 editing} were originally implemented in the package
11778 @file{outline-magic.el}, but quickly moved to the more general
11779 @file{org.el}.  As this environment became comfortable for project
11780 planning, the next step was adding @emph{TODO entries}, basic
11781 @emph{timestamps}, and @emph{table support}.  These areas highlighted the two main
11782 goals that Org still has today: to be a new, outline-based,
11783 plain text mode with innovative and intuitive editing features, and to
11784 incorporate project planning functionality directly into a notes file.
11786 A special thanks goes to @i{Bastien Guerry} who has not only written a large
11787 number of extensions to Org (most of them integrated into the core by now),
11788 but who has also helped in the development and maintenance of Org so much that he
11789 should be considered the main co-contributor to this package.
11791 Since the first release, literally thousands of emails to me or to
11792 @email{emacs-orgmode@@gnu.org} have provided a constant stream of bug
11793 reports, feedback, new ideas, and sometimes patches and add-on code.
11794 Many thanks to everyone who has helped to improve this package.  I am
11795 trying to keep here a list of the people who had significant influence
11796 in shaping one or more aspects of Org.  The list may not be
11797 complete, if I have forgotten someone, please accept my apologies and
11798 let me know.
11800 @itemize @bullet
11802 @item
11803 @i{Russel Adams} came up with the idea for drawers.
11804 @item
11805 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
11806 @item
11807 @i{Christophe Bataillon} created the great unicorn logo that we use on the
11808 Org-mode website.
11809 @item
11810 @i{Alex Bochannek} provided a patch for rounding timestamps.
11811 @item
11812 @i{Brad Bozarth} showed how to pull RSS feed data into Org-mode files.
11813 @item
11814 @i{Tom Breton} wrote @file{org-choose.el}.
11815 @item
11816 @i{Charles Cave}'s suggestion sparked the implementation of templates
11817 for Remember.
11818 @item
11819 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
11820 specified time.
11821 @item
11822 @i{Gregory Chernov} patched support for Lisp forms into table
11823 calculations and improved XEmacs compatibility, in particular by porting
11824 @file{nouline.el} to XEmacs.
11825 @item
11826 @i{Sacha Chua} suggested copying some linking code from Planner.
11827 @item
11828 @i{Baoqiu Cui} contributed the DocBook exporter.
11829 @item
11830 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
11831 came up with the idea of properties, and that there should be an API for
11832 them.
11833 @item
11834 @i{Nick Dokos} tracked down several nasty bugs.
11835 @item
11836 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
11837 inspired some of the early development, including HTML export.  He also
11838 asked for a way to narrow wide table columns.
11839 @item
11840 @i{Christian Egli} converted the documentation into Texinfo format,
11841 patched CSS formatting into the HTML exporter, and inspired the agenda.
11842 @item
11843 @i{David Emery} provided a patch for custom CSS support in exported
11844 HTML agendas.
11845 @item
11846 @i{Nic Ferrier} contributed mailcap and XOXO support.
11847 @item
11848 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
11849 @item
11850 @i{John Foerch} figured out how to make incremental search show context
11851 around a match in a hidden outline tree.
11852 @item
11853 @i{Niels Giesen} had the idea to automatically archive DONE trees.
11854 @item
11855 @i{Bastien Guerry} wrote the La@TeX{} exporter and @file{org-bibtex.el}, and
11856 has been prolific with patches, ideas, and bug reports.
11857 @item
11858 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
11859 @item
11860 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
11861 task state change logging, and the clocktable.  His clear explanations have
11862 been critical when we started to adopt the Git version control system.
11863 @item
11864 @i{Manuel Hermenegildo} has contributed various ideas, small fixes and
11865 patches.
11866 @item
11867 @i{Phil Jackson} wrote @file{org-irc.el}.
11868 @item
11869 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
11870 folded entries, and column view for properties.
11871 @item
11872 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
11873 @item
11874 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
11875 provided frequent feedback and some patches.
11876 @item
11877 @i{Matt Lundin} has proposed last-row references for table formulas and named
11878 invisible anchors.  He has also worked a lot on the FAQ.
11879 @item
11880 @i{Jason F. McBrayer} suggested agenda export to CSV format.
11881 @item
11882 @i{Max Mikhanosha} came up with the idea of refiling.
11883 @item
11884 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
11885 basis.
11886 @item
11887 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
11888 happy.
11889 @item
11890 @i{Richard Moreland} wrote @i{MobileOrg} for the iPhone.
11891 @item
11892 @i{Rick Moynihan} proposed allowing multiple TODO sequences in a file
11893 and being able to quickly restrict the agenda to a subtree.
11894 @item
11895 @i{Todd Neal} provided patches for links to Info files and Elisp forms.
11896 @item
11897 @i{Greg Newman} refreshed the unicorn logo into its current form.
11898 @item
11899 @i{Tim O'Callaghan} suggested in-file links, search options for general
11900 file links, and TAGS.
11901 @item
11902 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
11903 into Japanese.
11904 @item
11905 @i{Oliver Oppitz} suggested multi-state TODO items.
11906 @item
11907 @i{Scott Otterson} sparked the introduction of descriptive text for
11908 links, among other things.
11909 @item
11910 @i{Pete Phillips} helped during the development of the TAGS feature, and
11911 provided frequent feedback.
11912 @item
11913 @i{Martin Pohlack} provided the code snippet to bundle character insertion
11914 into bundles of 20 for undo.
11915 @item
11916 @i{T.V. Raman} reported bugs and suggested improvements.
11917 @item
11918 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
11919 control.
11920 @item
11921 @i{Paul Rivier} provided the basic implementation of named footnotes.
11922 @item
11923 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
11924 @item
11925 @i{Sebastian Rose} wrote @file{org-info.js}, a Java script for displaying
11926 webpages derived from Org using an Info-like or a folding interface with
11927 single-key navigation.
11928 @item
11929 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
11930 conflict with @file{allout.el}.
11931 @item
11932 @i{Jason Riedy} generalized the send-receive mechanism for Orgtbl tables with
11933 extensive patches.
11934 @item
11935 @i{Philip Rooke} created the Org reference card, provided lots
11936 of feedback, developed and applied standards to the Org documentation.
11937 @item
11938 @i{Christian Schlauer} proposed angular brackets around links, among
11939 other things.
11940 @item
11941 @i{Eric Schulte} wrote @file{org-plot.el} and contributed various patches,
11942 small features and modules.
11943 @item
11944 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
11945 @file{organizer-mode.el}.
11946 @item
11947 @i{Ilya Shlyakhter} proposed the Archive Sibling, line numbering in literal
11948 examples, and remote highlighting for referenced code lines.
11949 @item
11950 @i{Stathis Sideris} wrote the @file{ditaa.jar} ASCII to PNG converter that is
11951 now packaged into Org's @file{contrib} directory.
11952 @item
11953 @i{Daniel Sinder} came up with the idea of internal archiving by locking
11954 subtrees.
11955 @item
11956 @i{Dale Smith} proposed link abbreviations.
11957 @item
11958 @i{James TD Smith} has contributed a large number of patches for useful
11959 tweaks and features.
11960 @item
11961 @i{Adam Spiers} asked for global linking commands, inspired the link
11962 extension system, added support for mairix, and proposed the mapping API.
11963 @item
11964 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
11965 with links transformation to Org syntax.
11966 @item
11967 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
11968 chapter about publishing.
11969 @item
11970 @i{J@"urgen Vollmer} contributed code generating the table of contents
11971 in HTML output.
11972 @item
11973 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
11974 keyword.
11975 @item
11976 @i{David Wainberg} suggested archiving, and improvements to the linking
11977 system.
11978 @item
11979 @i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
11980 @file{muse.el}, which have some overlap with Org.  Initially the development
11981 of Org was fully independent because I was not aware of the existence of
11982 these packages.  But with time I have occasionally looked at John's code and
11983 learned a lot from it.  John has also contributed a number of great ideas and
11984 patches directly to Org, including the attachment system
11985 (@file{org-attach.el}), integration with Apple Mail
11986 (@file{org-mac-message.el}), and hierarchical dependencies of TODO items.
11987 @item
11988 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
11989 linking to Gnus.
11990 @item
11991 @i{Roland Winkler} requested additional key bindings to make Org
11992 work on a tty.
11993 @item
11994 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
11995 and contributed various ideas and code snippets.
11996 @end itemize
11999 @node Main Index, Key Index, History and Acknowledgments, Top
12000 @unnumbered Concept Index
12002 @printindex cp
12004 @node Key Index, Variable Index, Main Index, Top
12005 @unnumbered Key Index
12007 @printindex ky
12009 @node Variable Index,  , Key Index, Top
12010 @unnumbered Variable Index
12012 This is not a complete index of variables and faces, only the ones that are
12013 mentioned in the manual.  For a more complete list, use @kbd{M-x
12014 org-customize @key{RET}} and then klick yourself through the tree.
12016 @printindex vr
12018 @bye
12020 @ignore
12021         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
12022 @end ignore
12024 @c Local variables:
12025 @c ispell-local-dictionary: "en_US-w_accents"
12026 @c ispell-local-pdict: "./.aspell.org.pws"
12027 @c fill-column: 77
12028 @c End:
12031 @c  LocalWords:  webdavhost pre