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