Release 4.76
[org-mode/org-mode-NeilSmithlineMods.git] / org.texi
blob27d928c93ba3db40a74c0f699ffac57bf5600682
1 \input texinfo
2 @c %**start of header
3 @setfilename ../info/org
4 @settitle Org Mode Manual
6 @set VERSION 4.76
7 @set DATE May 2007
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://www.astro.uva.nl/~dominik/Tools/org/,maintainers webpage}
16 @set AUTHOR Carsten Dominik
17 @set MAINTAINER Carsten Dominik
18 @set MAINTAINEREMAIL @email{dominik at science dot uva dot nl}
19 @set MAINTAINERCONTACT @uref{mailto:dominik at science dot uva dot nl,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-mode (version @value{VERSION}).
38 Copyright @copyright{} 2004, 2005, 2006, 2007 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 Org Mode 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 * Timestamps::                  Assign date and time to items
84 * Tags::                        Tagging headlines and matching sets of tags
85 * Agenda views::                Collecting information into views
86 * Embedded LaTeX::              LaTeX fragments and formulas
87 * Exporting::                   Sharing and publishing of notes
88 * Publishing::                  Create a web site of linked Org-mode files
89 * Miscellaneous::               All the rest which did not fit elsewhere
90 * Extensions and Hacking::      It is possible to write add-on code
91 * History and Acknowledgments::  How Org-mode came into being 
92 * Index::                       The fast road to specific information
93 * Key Index::                   Key bindings and where they are described
95 @detailmenu
96  --- The Detailed Node Listing ---
98 Introduction
100 * Summary::                     Brief summary of what Org-mode does
101 * Installation::                How to install a downloaded version of Org-mode
102 * Activation::                  How to activate Org-mode for certain buffers.
103 * Feedback::                    Bug reports, ideas, patches etc.
105 Document Structure
107 * Outlines::                    Org-mode is based on outline-mode
108 * Headlines::                   How to typeset org-tree headlines
109 * Visibility cycling::          Show and hide, much simplified
110 * Motion::                      Jumping to other headlines
111 * Structure editing::           Changing sequence and level of headlines
112 * Archiving::                   Move done task trees to a different place
113 * Sparse trees::                Matches embedded in context
114 * Plain lists::                 Additional structure within an entry
116 Archiving
118 * ARCHIVE tag::                 Marking a tree as inactive
119 * Moving subtrees::             Moving a tree to an archive file
121 Tables
123 * Built-in table editor::       Simple tables
124 * Narrow columns::              Stop wasting space in tables   
125 * orgtbl-mode::                 The table editor as minor mode
126 * The spreadsheet::             The table editor has spreadsheet capabilities.
128 The spreadsheet
130 * References::                  How to refer to another field or range
131 * Formula syntax for Calc::     Using Calc to compute stuff
132 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
133 * Field formulas::              Formulas valid for a single field
134 * Column formulas::             Formulas valid for an entire column
135 * Editing and debugging formulas::  Fixing formulas
136 * Updating the table::          Recomputing all dependent fields
137 * Advanced features::           Field names, parameters and automatic recalc
139 Hyperlinks
141 * Link format::                 How links in Org-mode are formatted
142 * Internal links::              Links to other places in the current file
143 * External links::              URL-like links to the world
144 * Handling links::              Creating, inserting and following
145 * Link abbreviations::          Shortcuts for writing complex links
146 * Search options::              Linking to a specific location
147 * Custom searches::             When the default search is not enough
148 * Remember::                    Org-trees store quick notes
150 Internal links
152 * Radio targets::               Make targets trigger links in plain text.
154 Remember
156 * Setting up remember::         Some code for .emacs to get things going
157 * Remember templates::          Define the outline of different note types
158 * Storing notes::               Directly get the note to where it belongs
160 TODO items
162 * TODO basics::                 Marking and displaying TODO entries
163 * TODO extensions::             Workflow and assignments
164 * Priorities::                  Some things are more important than others
165 * Breaking down tasks::         Splitting a task into manageable pieces
166 * Checkboxes::                  Tick-off lists
168 Extended use of TODO keywords
170 * Workflow states::             From TODO to DONE in steps
171 * TODO types::                  I do this, Fred the rest
172 * Multiple sets in one file::   Mixing it all, and still finding your way
173 * Per file keywords::           Different files, different requirements
175 Timestamps
177 * Time stamps::                 Assigning a time to a tree entry
178 * Creating timestamps::         Commands which insert timestamps
179 * Deadlines and scheduling::    Planning your work
180 * Progress logging::            Documenting when what work was done.
182 Creating timestamps
184 * The date/time prompt::        How org-mode helps you entering date and time
185 * Custom time format::          Making dates look differently
187 Deadlines and Scheduling
189 * Inserting deadline/schedule::  
190 * Repeated tasks::              
192 Progress Logging
194 * Closing items::               When was this entry marked DONE?
195 * Tracking TODO state changes::  When did the status change?
196 * Clocking work time::          When exactly did you work on this item?
198 Tags
200 * Tag inheritance::             Tags use the tree structure of the outline
201 * Setting tags::                How to assign tags to a headline
202 * Tag searches::                Searching for combinations of tags
204 Agenda Views
206 * Agenda files::                Files being searched for agenda information
207 * Agenda dispatcher::           Keyboard access to agenda views
208 * Built-in agenda views::       What is available out of the box?
209 * Presentation and sorting::    How agenda items are prepared for display
210 * Agenda commands::             Remote editing of org trees
211 * Custom agenda views::         Defining special searches and views
213 The built-in agenda views
215 * Weekly/Daily agenda::         The calendar page with current tasks
216 * Global TODO list::            All unfinished action items
217 * Matching headline tags::      Structured information with fine-tuned search
218 * Timeline::                    Time-sorted view for single file
219 * Stuck projects::              Find projects you need to review
221 Presentation and sorting
223 * Categories::                  Not all tasks are equal
224 * Time-of-day specifications::  How the agenda knows the time
225 * Sorting of agenda items::     The order of things
227 Custom agenda views
229 * Storing searches::            Type once, use often
230 * Block agenda::                All the stuff you need in a single buffer
231 * Setting Options::             Changing the rules
232 * Exporting Agenda Views::      Writing agendas to files.
233 * Extracting Agenda Information for other programs::  
235 Embedded LaTeX
237 * Math symbols::                TeX macros for symbols and Greek letters
238 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
239 * LaTeX fragments::             Complex formulas made easy
240 * Processing LaTeX fragments::  Previewing LaTeX processing
241 * CDLaTeX mode::                Speed up entering of formulas
243 Exporting
245 * ASCII export::                Exporting to plain ASCII
246 * HTML export::                 Exporting to HTML
247 * XOXO export::                 Exporting to XOXO
248 * iCalendar export::            Exporting in iCalendar format
249 * Text interpretation::         How the exporter looks at the file
251 HTML export
253 * Export commands::             How to invoke HTML export
254 * Quoting HTML tags::           Using direct HTML in Org-mode
255 * Links::                       How hyperlinks get transferred to HTML
256 * Images::                      To inline or not to inline?
257 * CSS support::                 Style specifications
259 Text interpretation by the exporter
261 * Comment lines::               Some lines will not be exported
262 * Initial text::                Text before the first headline
263 * Footnotes::                   Numbers like [1]
264 * Enhancing text::              Subscripts, symbols and more
265 * Export options::              How to influence the export settings
267 Publishing
269 * Configuration::               Defining projects
270 * Sample configuration::        Example projects
271 * Triggering publication::      Publication commands
273 Configuration
275 * Project alist::               The central configuration variable
276 * Sources and destinations::    From here to there
277 * Selecting files::             What files are part of the project?
278 * Publishing action::           Setting the function doing the publishing
279 * Publishing options::          Tweaking HTML export
280 * Publishing links::            Which links keep working after publishing?
281 * Project page index::          Publishing a list of project files
283 Sample configuration
285 * Simple example::              One-component publishing
286 * Complex example::             A multi-component publishing example
288 Miscellaneous
290 * Completion::                  M-TAB knows what you need
291 * Customization::               Adapting Org-mode to your taste
292 * In-buffer settings::          Overview of the #+KEYWORDS
293 * The very busy C-c C-c key::   When in doubt, press C-c C-c
294 * Clean view::                  Getting rid of leading stars in the outline
295 * TTY keys::                    Using Org-mode on a tty
296 * Interaction::                 Other Emacs packages
297 * Bugs::                        Things which do not work perfectly
299 Interaction with other packages
301 * Cooperation::                 Packages Org-mode cooperates with
302 * Conflicts::                   Packages that lead to conflicts
304 Extensions, Hooks and Hacking
306 * Extensions::                  Existing 3rd-part extensions
307 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
308 * Dynamic blocks::              Automatically filled blocks
309 * Special agenda views::        Customized views
311 Tables in arbitrary syntax
313 * Radio tables::                Sending and receiving
314 * A LaTeX example::             Step by step, almost a tutorial
315 * Translator functions::        Copy and modify
317 @end detailmenu
318 @end menu
320 @node Introduction, Document structure, Top, Top
321 @chapter Introduction
322 @cindex introduction
324 @menu
325 * Summary::                     Brief summary of what Org-mode does
326 * Installation::                How to install a downloaded version of Org-mode
327 * Activation::                  How to activate Org-mode for certain buffers.
328 * Feedback::                    Bug reports, ideas, patches etc.
329 @end menu
331 @node Summary, Installation, Introduction, Introduction
332 @section Summary
333 @cindex summary
335 Org-mode is a mode for keeping notes, maintaining ToDo lists, and doing
336 project planning with a fast and effective plain-text system.
338 Org-mode develops organizational tasks around NOTES files that contain
339 lists or information about projects as plain text.  Org-mode is
340 implemented on top of outline-mode, which makes it possible to keep the
341 content of large files well structured.  Visibility cycling and
342 structure editing help to work with the tree.  Tables are easily created
343 with a built-in table editor.  Org-mode supports ToDo items, deadlines,
344 time stamps, and scheduling.  It dynamically compiles entries into an
345 agenda that utilizes and smoothly integrates much of the Emacs calendar
346 and diary.  Plain text URL-like links connect to websites, emails,
347 Usenet messages, BBDB entries, and any files related to the projects.
348 For printing and sharing of notes, an Org-mode file can be exported as a
349 structured ASCII file, as HTML, or (todo and agenda items only) as an
350 iCalendar file.  It can also serve as a publishing tool for a set of
351 linked webpages.
353 An important design aspect that distinguishes Org-mode from for example
354 Planner/Muse is that it encourages to store every piece of information
355 only once.  In Planner, you have project pages, day pages and possibly
356 other files, duplicating some information such as tasks.  In Org-mode,
357 you only have notes files.  In your notes you mark entries as tasks,
358 label them with tags and timestamps.  All necessary lists like a
359 schedule for the day, the agenda for a meeting, tasks lists selected by
360 tags etc are created dynamically when you need them.
362 Org-mode keeps simple things simple.  When first fired up, it should
363 feel like a straightforward, easy to use outliner.  Complexity is not
364 imposed, but a large amount of functionality is available when you need
365 it.  Org-mode can be used on different levels and in different ways, for
366 example as:
368 @example
369 @r{@bullet{} outline extension with visibility cycling and structure editing}
370 @r{@bullet{} ASCII system and table editor for taking structured notes}
371 @r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
372 @r{@bullet{} TODO list editor}
373 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
374 @r{@bullet{} environment to implement David Allen's GTD system}
375 @r{@bullet{} simple hypertext system, with HTML export}
376 @r{@bullet{} publishing tool to create a set of interlinked webpages}
377 @end example
379 Org-mode's automatic, context sensitive table editor with spreadsheet
380 capabilities can be integrated into any major mode by activating the
381 minor Orgtbl-mode.  Using a translation step, it can be used to maintain
382 tables in arbitrary file types, for example in LaTeX.
384 @cindex FAQ
385 There is a website for Org-mode which provides links to the newest
386 version of Org-mode, as well as additional information, frequently asked
387 questions (FAQ), links to tutorials etc.  This page is located at
388 @uref{http://www.astro.uva.nl/~dominik/Tools/org/}.
390 @page
393 @node Installation, Activation, Summary, Introduction
394 @section Installation
395 @cindex installation
396 @cindex XEmacs
398 @b{Important:} @i{If Org-mode is part of the Emacs distribution or an
399 XEmacs package, please skip this section and go directly to
400 @ref{Activation}.}
402 If you have downloaded Org-mode from the Web, you must take the
403 following steps to install it: Go into the Org-mode distribution
404 directory and edit the top section of the file @file{Makefile}.  You
405 must set the name of the Emacs binary (likely either @file{emacs} or
406 @file{xemacs}), and the paths to the directories where local Lisp and
407 Info files are kept.  If you don't have access to the system-wide
408 directories, create your own two directories for these files, enter them
409 into the Makefile, and make sure Emacs finds the Lisp files by adding
410 the following line to @file{.emacs}:
412 @example
413 (setq load-path (cons "~/path/to/lispdir" load-path))
414 @end example
416 @b{XEmacs users now need to install the file @file{noutline.el} from
417 the @file{xemacs} subdirectory of the Org-mode distribution.  Use the
418 command:}
420 @example
421 @b{make install-noutline}
422 @end example
424 @noindent Now byte-compile and install the Lisp files with the shell
425 commands:
427 @example
428 make
429 make install
430 @end example
432 @noindent If you want to install the info documentation, use this command:
434 @example
435 make install-info
436 @end example
438 @noindent Then add to @file{.emacs}:
440 @lisp
441 ;; This line only if org-mode is not part of the X/Emacs distribution.
442 (require 'org-install)
443 @end lisp
445 @node Activation, Feedback, Installation, Introduction
446 @section Activation
447 @cindex activation
448 @cindex autoload
449 @cindex global keybindings
450 @cindex keybindings, global
452 @iftex
453 @b{Important:} @i{If you use copy-and-paste to copy lisp code from the
454 PDF documentation to your .emacs file, the single quote character comes
455 out incorrectly and the code will not work.  You need to fix the single
456 quotes by hand, or copy from Info documentation.}
457 @end iftex
459 Add the following lines to your @file{.emacs} file.  The last two lines
460 define @emph{global} keys for the commands @command{org-store-link} and
461 @command{org-agenda} - please choose suitable keys yourself.
463 @lisp
464 ;; The following lines are always needed.  Choose your own keys.
465 (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
466 (define-key global-map "\C-cl" 'org-store-link)
467 (define-key global-map "\C-ca" 'org-agenda)
468 @end lisp
470 Furthermore, you must activate @code{font-lock-mode} in org-mode
471 buffers, because significant functionality depends on font-locking being
472 active.  You can do this with either one of the following two lines
473 (XEmacs user must use the second option):
474 @lisp
475 (global-font-lock-mode 1)                     ; for all buffers
476 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; org-mode buffers only
477 @end lisp
479 @cindex org-mode, turning on
480 With this setup, all files with extension @samp{.org} will be put
481 into Org-mode.  As an alternative, make the first line of a file look
482 like this:
484 @example
485 MY PROJECTS    -*- mode: org; -*-
486 @end example
488 @noindent which will select Org-mode for this buffer no matter what
489 the file's name is.  See also the variable
490 @code{org-insert-mode-line-in-empty-file}.
492 @node Feedback,  , Activation, Introduction
493 @section Feedback
494 @cindex feedback
495 @cindex bug reports
496 @cindex maintainer
497 @cindex author
499 If you find problems with Org-mode, or if you have questions, remarks,
500 or ideas about it, please contact the maintainer @value{MAINTAINER} at
501 @value{MAINTAINEREMAIL}.
503 For bug reports, please provide as much information as possible,
504 including the version information of Emacs (@kbd{C-h v emacs-version
505 @key{RET}}) and Org-mode (@kbd{C-h v org-version @key{RET}}), as well as
506 the Org-mode related setup in @file{.emacs}.  If an error occurs, a
507 backtrace can be very useful (see below on how to create one).  Often a
508 small example file helps, along with clear information about:
510 @enumerate
511 @item What exactly did you do?
512 @item What did you expect to happen?
513 @item What happened instead?
514 @end enumerate
515 @noindent Thank you for helping to improve this mode.
517 @subsubheading How to create a useful backtrace
519 @cindex backtrace of an error
520 If working with Org-mode produces an error with a message you don't
521 understand, you may have hit a bug.  The best way to report this is by
522 providing, in addition to what was mentioned above, a @emph{Backtrace}.
523 This is information from the built-in debugger about where and how the
524 error occurred.  Here is how to produce a useful backtrace:
526 @enumerate
527 @item
528 Start a fresh Emacs or XEmacs, and make sure that it will load the
529 original Lisp code in @file{org.el} instead of the compiled version in
530 @file{org.elc}.  The backtrace contains much more information if it is
531 produced with uncompiled code.  To do this, either rename @file{org.elc}
532 to something else before starting Emacs, or ask Emacs explicitly to load
533 @file{org.el} by using the command line
534 @example
535 emacs -l /path/to/org.el
536 @end example
537 @item
538 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
539 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
540 @item
541 Do whatever you have to do to hit the error.  Don't forget to
542 document the steps you take.
543 @item
544 When you hit the error, a @file{*Backtrace*} buffer will appear on the
545 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
546 attach it to your bug report.
547 @end enumerate
549 @node Document structure, Tables, Introduction, Top
550 @chapter Document Structure
551 @cindex document structure
552 @cindex structure of document
554 Org-mode is based on outline mode and provides flexible commands to
555 edit the structure of the document.
557 @menu
558 * Outlines::                    Org-mode is based on outline-mode
559 * Headlines::                   How to typeset org-tree headlines
560 * Visibility cycling::          Show and hide, much simplified
561 * Motion::                      Jumping to other headlines
562 * Structure editing::           Changing sequence and level of headlines
563 * Archiving::                   Move done task trees to a different place
564 * Sparse trees::                Matches embedded in context
565 * Plain lists::                 Additional structure within an entry
566 @end menu
568 @node Outlines, Headlines, Document structure, Document structure
569 @section Outlines
570 @cindex outlines
571 @cindex outline-mode
573 Org-mode is implemented on top of outline-mode.  Outlines allow to
574 organize a document in a hierarchical structure, which (at least for
575 me) is the best representation of notes and thoughts.  Overview over
576 this structure is achieved by folding (hiding) large parts of the
577 document to show only the general document structure and the parts
578 currently being worked on.  Org-mode greatly simplifies the use of
579 outlines by compressing the entire show/hide functionality into a
580 single command @command{org-cycle}, which is bound to the @key{TAB}
581 key.
583 @node Headlines, Visibility cycling, Outlines, Document structure
584 @section Headlines
585 @cindex headlines
586 @cindex outline tree
588 Headlines define the structure of an outline tree.  The headlines in
589 Org-mode start with one or more stars, on the left margin@footnote{See
590 the variable @code{org-special-ctrl-a} to configure special behavior of
591 @kbd{C-a} in headlines.}.  For example:
593 @example
594 * Top level headline
595 ** Second level
596 *** 3rd level
597     some text
598 *** 3rd level
599     more text
601 * Another top level headline
602 @end example
604 @noindent Some people find the many stars too noisy and would prefer an
605 outline that has whitespace followed by a single star as headline
606 starters.  @ref{Clean view} describes a setup to realize this.
608 An empty line after the end of a subtree is considered part of it and
609 will be hidden when the subtree is folded.  However, if you leave at
610 least two empty lines, one empty line will remain visible after folding
611 the subtree, in order to structure the collapsed view.  See the
612 variable @code{org-cycle-separator-lines} for modifying this behavior.
614 @node Visibility cycling, Motion, Headlines, Document structure
615 @section Visibility cycling
616 @cindex cycling, visibility
617 @cindex visibility cycling
618 @cindex trees, visibility
619 @cindex show hidden text
620 @cindex hide text
622 Outlines make it possible to hide parts of the text in the buffer.
623 Org-mode uses just two commands, bound to @key{TAB} and
624 @kbd{S-@key{TAB}} to change the visibility in the buffer.
626 @cindex subtree visibility states
627 @cindex subtree cycling
628 @cindex folded, subtree visibility state
629 @cindex children, subtree visibility state
630 @cindex subtree, subtree visibility state
631 @table @kbd
632 @kindex @key{TAB}
633 @item @key{TAB}
634 @emph{Subtree cycling}: Rotate current subtree among the states
636 @example
637 ,-> FOLDED -> CHILDREN -> SUBTREE --.
638 '-----------------------------------'
639 @end example
641 The cursor must be on a headline for this to work@footnote{see, however,
642 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
643 beginning of the buffer and the first line is not a headline, then
644 @key{TAB} actually runs global cycling (see below)@footnote{see the
645 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
646 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
648 @cindex global visibility states
649 @cindex global cycling
650 @cindex overview, global visibility state
651 @cindex contents, global visibility state
652 @cindex show all, global visibility state
653 @kindex S-@key{TAB}
654 @item S-@key{TAB}
655 @itemx C-u @key{TAB}
656 @emph{Global cycling}: Rotate the entire buffer among the states
658 @example
659 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
660 '--------------------------------------'
661 @end example
663 When @kbd{S-@key{TAB}} is called with a numerical prefix N, the CONTENTS
664 view up to headlines of level N will be shown.
665 Note that inside tables, @kbd{S-@key{TAB}} jumps to the previous field.
667 @cindex show all, command
668 @kindex C-c C-a
669 @item C-c C-a
670 Show all.
671 @kindex C-c C-r
672 @item C-c C-r
673 Reveal context around point, showing the current entry, the following
674 heading and the hierarchy above.  Useful for working near a location
675 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda
676 command (@pxref{Agenda commands}).  With prefix arg show, on each
677 level, all sibling headings.
678 @kindex C-c C-x b
679 @item C-c C-x b
680 Show the current subtree in an indirect buffer@footnote{The indirect
681 buffer
682 @ifinfo
683 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
684 @end ifinfo
685 @ifnotinfo
686 (see the Emacs manual for more information about indirect buffers)
687 @end ifnotinfo
688 will contain the entire buffer, but will be narrowed to the current
689 tree.  Editing the indirect buffer will also change the original buffer,
690 but without affecting visibility in that buffer.}.  With numerical
691 prefix ARG, go up to this level and then take that tree.  If ARG is
692 negative, go up that many levels.  With @kbd{C-u} prefix, do not remove
693 the previously used indirect buffer.
694 @end table
696 When Emacs first visits an Org-mode file, the global state is set to
697 OVERVIEW, i.e. only the top level headlines are visible.  This can be
698 configured through the variable @code{org-startup-folded}, or on a
699 per-file basis by adding one of the following lines anywhere in the
700 buffer:
702 @example
703 #+STARTUP: overview
704 #+STARTUP: content
705 #+STARTUP: showall
706 @end example
708 @node Motion, Structure editing, Visibility cycling, Document structure
709 @section Motion
710 @cindex motion, between headlines
711 @cindex jumping, to headlines
712 @cindex headline navigation
713 The following commands jump to other headlines in the buffer.
715 @table @kbd
716 @kindex C-c C-n
717 @item C-c C-n
718 Next heading.
719 @kindex C-c C-p
720 @item C-c C-p
721 Previous heading.
722 @kindex C-c C-f
723 @item C-c C-f
724 Next heading same level.
725 @kindex C-c C-b
726 @item C-c C-b
727 Previous heading same level.
728 @kindex C-c C-u
729 @item C-c C-u
730 Backward to higher level heading.
731 @kindex C-c C-j
732 @item C-c C-j
733 Jump to a different place without changing the current outline
734 visibility.  Shows the document structure in a temporary buffer, where
735 you can use the following keys to find your destination:
736 @example
737 @key{TAB}         @r{Cycle visibility.}
738 @key{down} / @key{up}   @r{Next/previous visible headline.}
739 n / p        @r{Next/previous visible headline.}
740 f / b        @r{Next/previous headline same level.}
741 u            @r{One level up.}
742 0-9          @r{Digit argument.}
743 @key{RET}         @r{Select this location.}
744 @end example
745 @end table
747 @node Structure editing, Archiving, Motion, Document structure
748 @section Structure editing
749 @cindex structure editing
750 @cindex headline, promotion and demotion
751 @cindex promotion, of subtrees
752 @cindex demotion, of subtrees
753 @cindex subtree, cut and paste
754 @cindex pasting, of subtrees
755 @cindex cutting, of subtrees
756 @cindex copying, of subtrees
757 @cindex subtrees, cut and paste
759 @table @kbd
760 @kindex M-@key{RET}
761 @item M-@key{RET}
762 Insert new heading with same level as current.  If the cursor is in a
763 plain list item, a new item is created (@pxref{Plain lists}).  To force
764 creation of a new headline, use a prefix arg, or first press @key{RET}
765 to get to the beginning of the next line.  When this command is used in
766 the middle of a line, the line is split and the rest of the line becomes
767 the new headline.  If the command is used at the beginning of a
768 headline, the new headline is created before the current line.  If at
769 the beginning of any other line, the content of that line is made the
770 new heading.  If the command is used at the end of a folded subtree
771 (i.e. behind the ellipses at the end of a headline), then a headline
772 like the current one will be inserted after the end of the subtree.
773 @kindex M-S-@key{RET}
774 @item M-S-@key{RET}
775 Insert new TODO entry with same level as current heading.
776 @kindex M-@key{left}
777 @item M-@key{left}
778 Promote current heading by one level.
779 @kindex M-@key{right}
780 @item M-@key{right}
781 Demote current heading by one level.
782 @kindex M-S-@key{left}
783 @item M-S-@key{left}
784 Promote the current subtree by one level.
785 @kindex M-S-@key{right}
786 @item M-S-@key{right}
787 Demote the current subtree by one level.
788 @kindex M-S-@key{up}
789 @item M-S-@key{up}
790 Move subtree up (swap with previous subtree of same
791 level).
792 @kindex M-S-@key{down}
793 @item M-S-@key{down}
794 Move subtree down (swap with next subtree of same level).
795 @kindex C-c C-x C-w
796 @kindex C-c C-x C-k
797 @item C-c C-x C-w
798 @itemx C-c C-x C-k
799 Kill subtree, i.e. remove it from buffer but save in kill ring.
800 @kindex C-c C-x M-w
801 @item C-c C-x M-w
802 Copy subtree to kill ring.
803 @kindex C-c C-x C-y
804 @item C-c C-x C-y
805 Yank subtree from kill ring.  This does modify the level of the subtree to
806 make sure the tree fits in nicely at the yank position.  The yank
807 level can also be specified with a prefix arg, or by yanking after a
808 headline marker like @samp{****}.
809 @kindex C-c ^
810 @item C-c ^
811 Sort same-level entries.  When there is an active region, all entries in
812 the region will be sorted.  Otherwise the children of the current
813 headline are sorted.  The command prompts for the sorting method, which
814 can be alphabetically, numerically, by time (using the first time stamp
815 in each entry), and each of these in reverse order.  With a @kbd{C-u}
816 prefix, sorting will be case-sensitive.  With two @kbd{C-u C-u}
817 prefixes, duplicate entries will also be removed.
818 @end table
820 @cindex region, active
821 @cindex active region
822 @cindex transient-mark-mode
823 When there is an active region (transient-mark-mode), promotion and
824 demotion work on all headlines in the region.  To select a region of
825 headlines, it is best to place both point and mark at the beginning of a
826 line, mark at the beginning of the first headline, and point at the line
827 just after the last headline to change.  Note that when the cursor is
828 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
829 functionality.
831 @node Archiving, Sparse trees, Structure editing, Document structure
832 @section Archiving
833 @cindex archiving
835 When a project represented by a (sub)tree is finished, you may want
836 to move the tree out of the way and to stop it from contributing to the
837 agenda.  Org-mode knows two ways of archiving.  You can mark a tree with
838 the ARCHIVE tag, or you can move an entire (sub)tree to a different
839 location.
841 @menu
842 * ARCHIVE tag::                 Marking a tree as inactive
843 * Moving subtrees::             Moving a tree to an archive file
844 @end menu
846 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
847 @subsection The ARCHIVE tag
848 @cindex internal archiving
850 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
851 its location in the outline tree, but behaves in the following way:
852 @itemize @minus
853 @item
854 It does not open when you attempt to do so with a visibility cycling
855 command (@pxref{Visibility cycling}).  You can force cycling archived
856 subtrees with @kbd{C-@key{TAB}}, or by setting the option
857 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
858 @code{show-all} will open archived subtrees.
859 @item
860 During sparse tree construction (@pxref{Sparse trees}), matches in
861 archived subtrees are not exposed, unless you configure the option
862 @code{org-sparse-tree-open-archived-trees}.
863 @item
864 During agenda view construction (@pxref{Agenda views}), the content of
865 archived trees is ignored unless you configure the option
866 @code{org-agenda-skip-archived-trees}.
867 @item
868 Archived trees are not exported (@pxref{Exporting}), only the headline
869 is.  Configure the details using the variable
870 @code{org-export-with-archived-trees}.
871 @end itemize
873 The following commands help managing the ARCHIVE tag:
875 @table @kbd
876 @kindex C-c C-x C-a
877 @item C-c C-x C-a
878 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
879 the headline changes to a shadowish face, and the subtree below it is
880 hidden.
881 @kindex C-u C-c C-x C-a
882 @item C-u C-c C-x C-a
883 Check if any direct children of the current headline should be archived.
884 To do this, each subtree is checked for open TODO entries.  If none are
885 found, the command offers to set the ARCHIVE tag for the child.  If the
886 cursor is @emph{not} on a headline when this command is invoked, the
887 level 1 trees will be checked.
888 @kindex C-@kbd{TAB}
889 @item C-@kbd{TAB}
890 Cycle a tree even if it is tagged with ARCHIVE.
891 @end table
893 @node Moving subtrees,  , ARCHIVE tag, Archiving
894 @subsection Moving subtrees
895 @cindex external archiving
897 Once an entire project is finished, you may want to move it to a
898 different location, either in the current file, or even in a different
899 file, the archive file.
901 @table @kbd
902 @kindex C-c C-x C-s
903 @item C-c C-x C-s
904 Archive the subtree starting at the cursor position to the location
905 given by @code{org-archive-location}.
906 @kindex C-u C-c C-x C-s
907 @item C-u C-c C-x C-s
908 Check if any direct children of the current headline could be moved to
909 the archive.  To do this, each subtree is checked for open TODO entries.
910 If none are found, the command offers to move it to the archive
911 location.  If the cursor is @emph{not} on a headline when this command
912 is invoked, the level 1 trees will be checked.
913 @end table
915 @cindex archive locations
916 The default archive location is a file in the same directory as the
917 current file, with the name derived by appending @file{_archive} to the
918 current file name.  For information and examples on how to change this,
919 see the documentation string of the variable
920 @code{org-archive-location}.  There is also an in-buffer option for
921 setting this variable, for example
923 @example
924 #+ARCHIVE: %s_done::
925 @end example
927 @noindent
928 You may have several such lines in the buffer, they will then be valid
929 for the entries following the line (the first will also apply to any
930 text before it).
932 @node Sparse trees, Plain lists, Archiving, Document structure
933 @section Sparse trees
934 @cindex sparse trees
935 @cindex trees, sparse
936 @cindex folding, sparse trees
937 @cindex occur, command
939 An important feature of Org-mode is the ability to construct
940 @emph{sparse trees} for selected information in an outline tree.  A
941 sparse tree means that the entire document is folded as much as
942 possible, but the selected information is made visible along with the
943 headline structure above it@footnote{See also the variables
944 @code{org-show-hierarchy-above}, @code{org-show-following-heading}, and
945 @code{org-show-siblings} for detailed control on how much context is
946 shown around each match.}.  Just try it out and you will see immediately
947 how it works.
949 Org-mode contains several commands creating such trees.  The most
950 basic one is @command{org-occur}:
952 @table @kbd
953 @kindex C-c /
954 @item C-c /
955 Occur.  Prompts for a regexp and shows a sparse tree with all matches.
956 If the match is in a headline, the headline is made visible.  If the
957 match is in the body of an entry, headline and body are made visible.
958 In order to provide minimal context, also the full hierarchy of
959 headlines above the match is shown, as well as the headline following
960 the match.  Each match is also highlighted; the highlights disappear
961 when the buffer is changes an editing command, or by pressing @kbd{C-c
962 C-c}.  When called with a @kbd{C-u} prefix argument, previous highlights
963 are kept, so several calls to this command can be stacked.
964 @end table
965 @noindent
966 For frequently used sparse trees of specific search strings, you can
967 use the variable @code{org-agenda-custom-commands} to define fast
968 keyboard access to specific sparse trees.  These commands will then be
969 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
970 For example:
972 @lisp
973 (setq org-agenda-custom-commands
974       '(("f" occur-tree "FIXME")))
975 @end lisp
977 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
978 a sparse tree matching the string @samp{FIXME}.
980 Other commands use sparse trees as well.  For example @kbd{C-c
981 C-v} creates a sparse TODO tree (@pxref{TODO basics}).
983 @kindex C-c C-e v
984 @cindex printing sparse trees
985 @cindex visible text, printing
986 To print a sparse tree, you can use the Emacs command
987 @code{ps-print-buffer-with-faces} which does not print invisible parts
988 of the document @footnote{This does not work under XEmacs, because
989 XEmacs uses selective display for outlining, not text properties.}.
990 Or you can use the command @kbd{C-c C-e v} to export only the visible
991 part of the document and print the resulting file.
993 @node Plain lists,  , Sparse trees, Document structure
994 @section Plain lists
995 @cindex plain lists
996 @cindex lists, plain
997 @cindex lists, ordered
998 @cindex ordered lists
1000 Within an entry of the outline tree, hand-formatted lists can provide
1001 additional structure.  They also provide a way to create lists of
1002 checkboxes (@pxref{Checkboxes}).  Org-mode supports editing such lists,
1003 and the HTML exporter (@pxref{Exporting}) does parse and format them.
1005 Org-mode knows ordered and unordered lists.  Unordered list items start
1006 with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a
1007 bullet, lines must be indented or they will be seen as top-level
1008 headlines.  Also, when you are hiding leading stars to get a clean
1009 outline view, plain list items starting with a star are visually
1010 indistinguishable from true headlines.  In short: even though @samp{*}
1011 is supported, it may be better not to use it for plain list items.} as
1012 bullets.  Ordered list items start with @samp{1.} or @samp{1)}.  Items
1013 belonging to the same list must have the same indentation on the first
1014 line.  In particular, if an ordered list reaches number @samp{10.}, then
1015 the 2--digit numbers must be written left-aligned with the other numbers
1016 in the list.  Indentation also determines the end of a list item.  It
1017 ends before the next line that is indented like the bullet/number, or
1018 less.  Empty lines are part of the previous item, so you can have
1019 several paragraphs in one item.  If you would like an emtpy line to
1020 terminate all currently open plain lists, configure the variable
1021 @code{org-empty-line-terminates-plain-lists}.  Here is an for example:
1023 @example
1024 @group
1025 ** Lord of the Rings
1026    My favorite scenes are (in this order)
1027    1. The attack of the Rohirrim
1028    2. Eowyns fight with the witch king
1029       + this was already my favorite scene in the book
1030       + I really like Miranda Otto.
1031    3. Peter Jackson being shot by Legolas
1032        - on DVD only
1033       He makes a really funny face when it happens.
1034    But in the end, not individual scenes matter but the film as a whole.
1035 @end group
1036 @end example
1038 Org-mode supports these lists by tuning filling and wrapping commands to
1039 deal with them correctly@footnote{Org-mode only changes the filling
1040 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1041 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1042 @example
1043 (require 'filladapt)
1044 @end example
1047 The following commands act on items when the cursor is in the first line
1048 of an item (the line with the bullet or number).
1050 @table @kbd
1051 @kindex @key{TAB}
1052 @item @key{TAB}
1053 Items can be folded just like headline levels if you set the variable
1054 @code{org-cycle-include-plain-lists}.  The level of an item is then
1055 given by the indentation of the bullet/number.  Items are always
1056 subordinate to real headlines, however; the hierarchies remain
1057 completely separated.
1058 @kindex M-@key{RET}
1059 @item M-@key{RET}
1060 Insert new item at current level.  With prefix arg, force a new heading
1061 (@pxref{Structure editing}).  If this command is used in the middle of a
1062 line, the line is @emph{split} and the rest of the line becomes the new
1063 item.  If this command is executed in the @emph{whitespace before a bullet or
1064 number}, the new item is created @emph{before} the current item.  If the
1065 command is executed in the white space before the text that is part of
1066 an item but does not contain the bullet, a bullet is added to the
1067 current line.
1068 @kindex M-S-@key{RET}
1069 @item M-S-@key{RET}
1070 Insert a new item with a checkbox (@pxref{Checkboxes}).
1071 @kindex S-@key{up}
1072 @kindex S-@key{down}
1073 @item S-@key{up}
1074 @itemx S-@key{down}
1075 Jump to the previous/next item in the current list.
1076 @kindex M-S-@key{up}
1077 @kindex M-S-@key{down}
1078 @item M-S-@key{up}
1079 @itemx M-S-@key{down}
1080 Move the item including subitems up/down (swap with previous/next item
1081 of same indentation).  If the list is ordered, renumbering is
1082 automatic.
1083 @kindex M-S-@key{left}
1084 @kindex M-S-@key{right}
1085 @item M-S-@key{left}
1086 @itemx M-S-@key{right}
1087 Decrease/increase the indentation of the item, including subitems.
1088 Initially, the item tree is selected based on current indentation.
1089 When these commands are executed several times in direct succession,
1090 the initially selected region is used, even if the new indentation
1091 would imply a different hierarchy.  To use the new hierarchy, break
1092 the command chain with a cursor motion or so.
1093 @kindex C-c C-c
1094 @item C-c C-c
1095 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1096 state of the checkbox.  Otherwise, if this is an ordered list, renumber
1097 the ordered list at the cursor.
1098 @end table
1100 @node Tables, Hyperlinks, Document structure, Top
1101 @chapter Tables
1102 @cindex tables
1103 @cindex editing tables
1105 Org-mode has a very fast and intuitive table editor built-in.
1106 Spreadsheet-like calculations are supported in connection with the
1107 Emacs @file{calc} package.
1109 @menu
1110 * Built-in table editor::       Simple tables
1111 * Narrow columns::              Stop wasting space in tables   
1112 * orgtbl-mode::                 The table editor as minor mode
1113 * The spreadsheet::             The table editor has spreadsheet capabilities.
1114 @end menu
1116 @node Built-in table editor, Narrow columns, Tables, Tables
1117 @section The built-in table editor
1118 @cindex table editor, built-in
1120 Org-mode makes it easy to format tables in plain ASCII.  Any line with
1121 @samp{|} as the first non-white character is considered part of a
1122 table.  @samp{|} is also the column separator.  A table might look
1123 like this:
1125 @example
1126 | Name  | Phone | Age |
1127 |-------+-------+-----|
1128 | Peter |  1234 |  17 |
1129 | Anna  |  4321 |  25 |
1130 @end example
1132 A table is re-aligned automatically each time you press @key{TAB} or
1133 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1134 the next field (@key{RET} to the next row) and creates new table rows
1135 at the end of the table or before horizontal lines.  The indentation
1136 of the table is set by the first line.  Any line starting with
1137 @samp{|-} is considered as a horizontal separator line and will be
1138 expanded on the next re-align to span the whole table width.  So, to
1139 create the above table, you would only type
1141 @example
1142 |Name|Phone|Age|
1144 @end example
1146 @noindent and then press @key{TAB} to align the table and start filling in
1147 fields.
1149 When typing text into a field, Org-mode treats @key{DEL},
1150 @key{Backspace}, and all character keys in a special way, so that
1151 inserting and deleting avoids shifting other fields.  Also, when
1152 typing @emph{immediately after the cursor was moved into a new field
1153 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1154 field is automatically made blank.  If this behavior is too
1155 unpredictable for you, configure the variables
1156 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1158 @table @kbd
1159 @tsubheading{Creation and conversion}
1160 @kindex C-c |
1161 @item C-c |
1162 Convert the active region to table. If every line contains at least one
1163 TAB character, the function assumes that the material is tab separated.
1164 If not, lines are split at whitespace into fields.  You can use a prefix
1165 argument to indicate the minimum number of consecutive spaces required
1166 to identify a field separator (default: just one).@* 
1167 If there is no active region, this command creates an empty Org-mode
1168 table.  But it's easier just to start typing, like
1169 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1171 @tsubheading{Re-aligning and field motion}
1172 @kindex C-c C-c
1173 @item C-c C-c
1174 Re-align the table without moving the cursor.
1176 @kindex @key{TAB}
1177 @item @key{TAB}
1178 Re-align the table, move to the next field.  Creates a new row if
1179 necessary.
1181 @kindex S-@key{TAB}
1182 @item S-@key{TAB}
1183 Re-align, move to previous field.
1185 @kindex @key{RET}
1186 @item @key{RET}
1187 Re-align the table and move down to next row.  Creates a new row if
1188 necessary.  At the beginning or end of a line, @key{RET} still does
1189 NEWLINE, so it can be used to split a table.
1191 @tsubheading{Column and row editing}
1192 @kindex M-@key{left}
1193 @kindex M-@key{right}
1194 @item M-@key{left}
1195 @itemx M-@key{right}
1196 Move the current column left/right.
1198 @kindex M-S-@key{left}
1199 @item M-S-@key{left}
1200 Kill the current column.
1202 @kindex M-S-@key{right}
1203 @item M-S-@key{right}
1204 Insert a new column to the left of the cursor position.
1206 @kindex M-@key{up}
1207 @kindex M-@key{down}
1208 @item M-@key{up}
1209 @itemx M-@key{down}
1210 Move the current row up/down.
1212 @kindex M-S-@key{up}
1213 @item M-S-@key{up}
1214 Kill the current row or horizontal line.
1216 @kindex M-S-@key{down}
1217 @item M-S-@key{down}
1218 Insert a new row above (with arg: below) the current row.
1220 @kindex C-c -
1221 @item C-c -
1222 Insert a horizontal line below current row. With prefix arg, the line
1223 is created above the current line.
1225 @kindex C-c ^
1226 @item C-c ^
1227 Sort the table lines in the region.  The position of point indicates the
1228 column to be used for sorting, and the range of lines is the range
1229 between the nearest horizontal separator lines, or the entire table.  If
1230 point is before the first column, you will be prompted for the sorting
1231 column.  If there is an active region, the mark specifies the first line
1232 and the sorting column, while point should be in the last line to be
1233 included into the sorting.  The command prompts for the sorting type
1234 (alphabetically, numerically, or by time).  When called with a prefix
1235 argument, alphabetic sorting will be case-sensitive.
1237 @tsubheading{Regions}
1238 @kindex C-c C-x M-w
1239 @item C-c C-x M-w
1240 Copy a rectangular region from a table to a special clipboard.  Point
1241 and mark determine edge fields of the rectangle.  The process ignores
1242 horizontal separator lines.
1244 @kindex C-c C-x C-w
1245 @item C-c C-x C-w
1246 Copy a rectangular region from a table to a special clipboard, and
1247 blank all fields in the rectangle.  So this is the ``cut'' operation.
1249 @kindex C-c C-x C-y
1250 @item C-c C-x C-y
1251 Paste a rectangular region into a table.
1252 The upper right corner ends up in the current field.  All involved fields
1253 will be overwritten.  If the rectangle does not fit into the present table,
1254 the table is enlarged as needed.  The process ignores horizontal separator
1255 lines.
1257 @kindex C-c C-q
1258 @item C-c C-q
1259 Wrap several fields in a column like a paragraph.  If there is an active
1260 region, and both point and mark are in the same column, the text in the
1261 column is wrapped to minimum width for the given number of lines.  A
1262 prefix ARG may be used to change the number of desired lines.  If there
1263 is no region, the current field is split at the cursor position and the
1264 text fragment to the right of the cursor is prepended to the field one
1265 line down. If there is no region, but you specify a prefix ARG, the
1266 current field is made blank, and the content is appended to the field
1267 above.
1269 @tsubheading{Calculations}
1270 @cindex formula, in tables
1271 @cindex calculations, in tables
1272 @cindex region, active
1273 @cindex active region
1274 @cindex transient-mark-mode
1275 @kindex C-c +
1276 @item C-c +
1277 Sum the numbers in the current column, or in the rectangle defined by
1278 the active region.  The result is shown in the echo area and can
1279 be inserted with @kbd{C-y}.
1281 @kindex S-@key{RET}
1282 @item S-@key{RET}
1283 When current field is empty, copy from first non-empty field above.
1284 When not empty, copy current field down to next row and move cursor
1285 along with it.  Depending on the variable
1286 @code{org-table-copy-increment}, integer field values will be
1287 incremented during copy.  This key is also used by CUA-mode
1288 (@pxref{Cooperation}).
1290 @tsubheading{Miscellaneous}
1291 @kindex C-c `
1292 @item C-c `
1293 Edit the current field in a separate window.  This is useful for fields
1294 that are not fully visible (@pxref{Narrow columns}).  When called with a
1295 @kbd{C-u} prefix, just make the full field visible, so that it can be
1296 edited in place.
1298 @kindex C-c @key{TAB}
1299 @item C-c @key{TAB}
1300 This is an alias for @kbd{C-u C-c `} to make the current field fully
1301 visible.
1303 @item M-x org-table-import
1304 Import a file as a table.  The table should be TAB- or whitespace
1305 separated.  Useful, for example, to import an Excel table or data from a
1306 database, because these programs generally can write TAB-separated text
1307 files.  This command works by inserting the file into the buffer and
1308 then converting the region to a table.  Any prefix argument is passed on
1309 to the converter, which uses it to determine the separator.
1310 @item C-c |
1311 Tables can also be imported by pasting tabular text into the org-mode
1312 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1313 @kbd{C-c |} command (see above under @i{Creation and conversion}.
1315 @item M-x org-table-export
1316 Export the table as a TAB-separated file.  Useful for data exchange with,
1317 for example, Excel or database programs.
1318 @end table
1320 If you don't like the automatic table editor because it gets in your
1321 way on lines which you would like to start with @samp{|}, you can turn
1322 it off with
1324 @lisp
1325 (setq org-enable-table-editor nil)
1326 @end lisp
1328 @noindent Then the only table command that still works is
1329 @kbd{C-c C-c} to do a manual re-align.
1331 @node Narrow columns, orgtbl-mode, Built-in table editor, Tables
1332 @section Narrow columns
1333 @cindex narrow columns in tables
1335 The width of columns is automatically determined by the table editor.
1336 Sometimes a single field or a few fields need to carry more text,
1337 leading to inconveniently wide columns.  To limit@footnote{This feature
1338 does not work on XEmacs.} the width of a column, one field anywhere in
1339 the column may contain just the string @samp{<N>} where @samp{N} is an
1340 integer specifying the width of the column in characters.  The next
1341 re-align will then set the width of this column to no more than this
1342 value.
1344 @example
1345 @group
1346 |---+------------------------------|               |---+--------|
1347 |   |                              |               |   | <6>    |
1348 | 1 | one                          |               | 1 | one    |
1349 | 2 | two                          |     ----\     | 2 | two    |
1350 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1351 | 4 | four                         |               | 4 | four   |
1352 |---+------------------------------|               |---+--------|
1353 @end group
1354 @end example
1356 @noindent
1357 Fields that are wider become clipped and end in the string @samp{=>}.
1358 Note that the full text is still in the buffer, it is only invisible.
1359 To see the full text, hold the mouse over the field - a tool-tip window
1360 will show the full content.  To edit such a field, use the command
1361 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1362 open a new window with the full field.  Edit it and finish with @kbd{C-c
1363 C-c}.
1365 When visiting a file containing a table with narrowed columns, the
1366 necessary character hiding has not yet happened, and the table needs to
1367 be aligned before it looks nice.  Setting the option
1368 @code{org-startup-align-all-tables} will realign all tables in a file
1369 upon visiting, but also slow down startup.  You can also set this option
1370 on a per-file basis with:
1372 @example
1373 #+STARTUP: align
1374 #+STARTUP: noalign
1375 @end example
1377 @node orgtbl-mode, The spreadsheet, Narrow columns, Tables
1378 @section The Orgtbl minor mode
1379 @cindex orgtbl-mode
1380 @cindex minor mode for tables
1382 If you like the intuitive way the Org-mode table editor works, you
1383 might also want to use it in other modes like text-mode or mail-mode.
1384 The minor mode Orgtbl-mode makes this possible.  You can always toggle
1385 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1386 example in mail mode, use
1388 @lisp
1389 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1390 @end lisp
1392 Furthermore, with some special setup, it is possible to maintain tables
1393 in arbitrary syntax with Orgtbl-mode.  For example, it is possible to
1394 construct LaTeX tables with the underlying ease and power of
1395 Orgtbl-mode, including spreadsheet capabilities.  For details, see
1396 @ref{Tables in arbitrary syntax}.
1398 @node The spreadsheet,  , orgtbl-mode, Tables
1399 @section The spreadsheet
1400 @cindex calculations, in tables
1401 @cindex spreadsheet capabilities
1402 @cindex @file{calc} package
1404 The table editor makes use of the Emacs @file{calc} package to implement
1405 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1406 derive fields from other fields.  While fully featured, Org-mode's
1407 implementation is not identical to other spreadsheets.  For example,
1408 Org-mode knows the concept of a @emph{column formula} that will be
1409 applied to all non-header fields in a column without having to copy the
1410 formula to each relevant field.
1412 @menu
1413 * References::                  How to refer to another field or range
1414 * Formula syntax for Calc::     Using Calc to compute stuff
1415 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1416 * Field formulas::              Formulas valid for a single field
1417 * Column formulas::             Formulas valid for an entire column
1418 * Editing and debugging formulas::  Fixing formulas
1419 * Updating the table::          Recomputing all dependent fields
1420 * Advanced features::           Field names, parameters and automatic recalc
1421 @end menu
1423 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1424 @subsection References
1425 @cindex references
1427 To compute fields in the table from other fields, formulas must
1428 reference other fields or ranges.  In Org-mode, fields can be referenced
1429 by name, by absolute coordinates, and by relative coordinates.  To find
1430 out what the coordinates of a field are, press @kbd{C-c ?} in that
1431 field, or press @kbd{C-c @}} to toggle the display of a grid.
1433 @subsubheading Field references
1434 @cindex field references
1435 @cindex references, to fields
1437 Formulas can reference the value of another field in two ways.  Like in
1438 any other spreadsheet, you may reference fields with a letter/number
1439 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1440 @c Such references are always fixed to that field, they don't change
1441 @c when you copy and paste a formula to a different field.  So
1442 @c Org-mode's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1444 @noindent
1445 Org-mode also uses another, more general operator that looks like this:
1446 @example
1447 @@row$column
1448 @end example
1450 @noindent
1451 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1452 or relative to the current column like @samp{+1} or @samp{-2}.
1454 The row specification only counts data lines and ignores horizontal
1455 separator lines (hlines).  You can use absolute row numbers
1456 @samp{1}...@samp{N}, and row numbers relative to the current row like
1457 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1458 hlines: @samp{I} refers to the first hline, @samp{II} to the second etc.
1459 @samp{-I} refers to the first such line above the current line,
1460 @samp{+I} to the first such line below the current line.  You can also
1461 write @samp{III+2} which is the second data line after the third hline
1462 in the table.  Relative row numbers like @samp{-3} will not cross hlines
1463 if the current line is too close to the hline.  Instead, the value
1464 directly at the hline is used.
1466 @samp{0} refers to the current row and column.  Also, if you omit
1467 either the column or the row part of the reference, the current
1468 row/column is implied. 
1470 Org-mode's references with @emph{unsigned} numbers are fixed references
1471 in the sense that if you use the same reference in the formula for two
1472 different fields, the same field will be referenced each time.
1473 Org-mode's references with @emph{signed} numbers are floating
1474 references because the same reference operator can reference different
1475 fields depending on the field being calculated by the formula.
1477 Here are a few examples:
1479 @example
1480 @@2$3      @r{2nd row, 3rd column}
1481 C2        @r{same as previous}
1482 $5        @r{column 5 in the current row}
1483 E&        @r{same as previous}
1484 @@2        @r{current column, row 2}
1485 @@-1$-3    @r{the field one row up, three columns to the left}
1486 @@-I$2     @r{field just under hline above current row, column 2}
1487 @end example
1489 @subsubheading Range references
1490 @cindex range references
1491 @cindex references, to ranges
1493 You may reference a rectangular range of fields by specifying two field
1494 references connected by two dots @samp{..}.  If both fields are in the
1495 current row, you may simply use @samp{$2..$7}, but if at least one field
1496 is in a different row, you need to use the general @code{@@row$column}
1497 format at least for the first field (i.e the reference must start with
1498 @samp{@@} in order to be interpreted correctly).  Examples:
1500 @example
1501 $1..$3        @r{First three fields in the current row.}
1502 $P..$Q        @r{Range, using column names (see under Advanced)}
1503 @@2$1..@@4$3    @r{6 fields between these two fields.}
1504 A2..C4        @r{Same as above.}
1505 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
1506 @end example
1508 @noindent Range references return a vector of values that can be fed
1509 into Calc vector functions.  Empty fields in ranges are normally
1510 suppressed, so that the vector contains only the non-empty fields (but
1511 see the @samp{E} mode switch below).  If there are no non-empty fields,
1512 @samp{[0]} is returned to avoid syntax errors in formulas.
1514 @subsubheading Named references
1515 @cindex named references
1516 @cindex references, named
1517 @cindex name, of column or field
1518 @cindex constants, in calculations
1520 @samp{$name} is interpreted as the name of a column, parameter or
1521 constant.  Constants are defined globally through the variable
1522 @code{org-table-formula-constants}.  If you have the @file{constants.el}
1523 package, it will also be used to resolve constants, including natural
1524 constants like @samp{$h} for Planck's constant, and units like
1525 @samp{$km} for kilometers@footnote{@file{Constant.el} can supply the
1526 values of constants in two different unit systems, @code{SI} and
1527 @code{cgs}.  Which one is used depends on the value of the variable
1528 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
1529 @code{constSI} and @code{constcgs} to set this value for the current
1530 buffer.}.  Column names and parameters can be specified in special table
1531 lines.  These are described below, see @ref{Advanced features}.  All
1532 names must start with a letter, and further consist of letters and
1533 numbers.
1535 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
1536 @subsection Formula syntax for Calc
1537 @cindex formula syntax, Calc
1538 @cindex syntax, of formulas
1540 A formula can be any algebraic expression understood by the Emacs
1541 @file{Calc} package.  @b{Note that @file{calc} has the
1542 non-standard convention that @samp{/} has lower precedence than
1543 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
1544 evaluation by @code{calc-eval} (@pxref{Calling Calc from
1545 Your Programs,calc-eval,Calling calc from Your Lisp Programs,calc,GNU
1546 Emacs Calc Manual}),
1547 @c FIXME:  The link to the calc manual in HTML does not work.
1548 variable substitution takes place according to the rules described above.
1549 @cindex vectors, in table calculations
1550 The range vectors can be directly fed into the calc vector functions
1551 like @samp{vmean} and @samp{vsum}.
1553 @cindex format specifier
1554 @cindex mode, for @file{calc}
1555 A formula can contain an optional mode string after a semicolon.  This
1556 string consists of flags to influence Calc and other modes during
1557 execution.  By default, Org-mode uses the standard calc modes (precision
1558 12, angular units degrees, fraction and symbolic modes off.  The display
1559 format, however, has been changed to @code{(float 5)} to keep tables
1560 compact.  The default settings can be configured using the variable
1561 @code{org-calc-default-modes}.
1563 @example
1564 p20           @r{switch the internal precision to 20 digits}
1565 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
1566 D R           @r{angle modes: degrees, radians}
1567 F S           @r{fraction and symbolic modes}
1568 N             @r{interpret all fields as numbers, use 0 for non-numbers}
1569 T             @r{force text interpretation}
1570 E             @r{keep empty fields in ranges}
1571 @end example
1573 @noindent
1574 In addition, you may provide a @code{printf} format specifier to
1575 reformat the final result.  A few examples:
1577 @example
1578 $1+$2                @r{Sum of first and second field}
1579 $1+$2;%.2f           @r{Same, format result to two decimals}
1580 exp($2)+exp($1)      @r{Math functions can be used}
1581 $0;%.1f              @r{Reformat current cell to 1 decimal}
1582 ($3-32)*5/9          @r{Degrees F -> C conversion}
1583 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
1584 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
1585 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
1586 vmean($2..$7)        @r{Compute column range mean, using vector function}
1587 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
1588 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
1589 @end example
1591 Calc also contains a complete set of logical operations.  For example
1593 @example
1594 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
1595 @end example
1597 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
1598 @subsection Emacs Lisp forms as formulas
1599 @cindex Lisp forms, as table formulas
1601 It is also possible to write a formula in Emacs Lisp; this can be useful
1602 for string manipulation and control structures, if the Calc's
1603 functionality is not enough.  If a formula starts with a single quote
1604 followed by an opening parenthesis, then it is evaluated as a lisp form.
1605 The evaluation should return either a string or a number.  Just as with
1606 @file{calc} formulas, you can specify modes and a printf format after a
1607 semicolon.  A reference will be replaced with a string (in double
1608 quotes) containing the field.  If you provide the @samp{N} mode switch,
1609 all referenced elements will be numbers.  Ranges are inserted as
1610 space-separated fields, so you can embed them in list or vector syntax.
1611 A few examples, note how the @samp{N} mode is used when we do
1612 computations in lisp.
1614 @example
1615 @r{Swap the first two characters of the content of column 1}
1616   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
1617 @r{Add columns 1 and 2, equivalent to the Calc's @code{$1+$2}}
1618   '(+ $1 $2);N
1619 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
1620   '(apply '+ '($1..$4));N
1621 @end example
1623 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
1624 @subsection Field formulas
1625 @cindex field formula
1626 @cindex formula, for individual table field
1628 To assign a formula to a particular field, type it directly into the
1629 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
1630 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
1631 the field, the formula will be stored as the formula for this field,
1632 evaluated, and the current field replaced with the result.
1634 Formulas are stored in a special line starting with @samp{#+TBLFM:}
1635 directly below the table.  If you typed the equation in the 4th field of
1636 the 3rd data line in the table, the formula will look like
1637 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
1638 with the appropriate commands, @i{absolute references} (but not relative
1639 ones) in stored formulas are modified in order to still reference the
1640 same field.  Of cause this is not true if you edit the table structure
1641 with normal editing commands - then you must fix the equations yourself.
1643 Instead of typing an equation into the field, you may also use the
1644 following command
1646 @table @kbd
1647 @kindex C-u C-c =
1648 @item C-u C-c =
1649 Install a new formula for the current field.  The command prompts for a
1650 formula, with default taken from the @samp{#+TBLFM:} line, applies
1651 it to the current field and stores it.
1652 @end table
1654 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
1655 @subsection Column formulas
1656 @cindex column formula
1657 @cindex formula, for table column
1659 Often in a table, the same formula should be used for all fields in a
1660 particular column.  Instead of having to copy the formula to all fields
1661 in that column, org-mode allows to assign a single formula to an entire
1662 column.  If the table contains horizontal separator hlines, everything
1663 before the first such line is considered part of the table @emph{header}
1664 and will not be modified by column formulas.
1666 To assign a formula to a column, type it directly into any field in the
1667 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
1668 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
1669 field, the formula will be stored as the formula for the current column,
1670 evaluated and the current field replaced with the result.  If the field
1671 contains only @samp{=}, the previously stored formula for this column is
1672 used.  For each column, Org-mode will only remember the most recently
1673 used formula.  In the @samp{TBLFM:} line, column formulas will look like
1674 @samp{$4=$1+$2}.
1676 Instead of typing an equation into the field, you may also use the
1677 following command:
1679 @table @kbd
1680 @kindex C-c =
1681 @item C-c =
1682 Install a new formula for the current column and replace current field
1683 with the result of the formula.  The command prompts for a formula, with
1684 default taken from the @samp{#+TBLFM} line, applies it to the current
1685 field and stores it.  With a numerical prefix (e.g. @kbd{C-5 C-c =})
1686 will apply it to that many consecutive fields in the current column.
1687 @end table
1690 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
1691 @subsection Editing and Debugging formulas
1692 @cindex formula editing
1693 @cindex editing, of table formulas
1695 You can edit individual formulas in the minibuffer or directly in the
1696 field.  Org-mode can also prepare a special buffer with all active
1697 formulas of a table.  When offering a formula for editing, Org-mode
1698 converts references to the standard format (like @code{B3} or @code{D&})
1699 if possible.  If you prefer to only work with the internal format (like
1700 @code{@@3$2} or @code{$4}), configure the variable
1701 @code{org-table-use-standard-references}.
1703 @table @kbd
1704 @kindex C-c =
1705 @kindex C-u C-c =
1706 @item C-c =
1707 @itemx C-u C-c =
1708 Edit the formula associated with the current column/field in the
1709 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
1710 @kindex C-u C-u C-c =
1711 @item C-u C-u C-c =
1712 Re-insert the active formula (either a
1713 field formula, or a column formula) into the current field, so that you
1714 can edit it directly in the field.  The advantage over editing in the
1715 minibuffer is that you can use the command @kbd{C-c ?}.
1716 @kindex C-c ?
1717 @item C-c ?
1718 While editing a formula in a table field, highlight the field(s)
1719 referenced by the reference at the cursor position in the formula.
1720 @kindex C-c @}
1721 @item C-c @}
1722 Toggle the display of row and column numbers for a table, using
1723 overlays.  These are updated each time the table is aligned, you can
1724 force it with @kbd{C-c C-c}.
1725 @kindex C-c @{
1726 @item C-c @{
1727 Toggle the formula debugger on and off.  See below.
1728 @kindex C-c '
1729 @item C-c '
1730 Edit all formulas for the current table in a special buffer, where the
1731 formulas will be displayed one per line.  If the current field has an
1732 active formula, the cursor in the formula editor will mark it.
1733 While inside the special buffer, Org-mode will automatically highlight
1734 any field or range reference at the cursor position.  You may edit,
1735 remove and add formulas, and use the following commands:
1736 @table @kbd
1737 @kindex C-c C-c
1738 @kindex C-x C-s
1739 @item C-c C-c
1740 @itemx C-x C-s
1741 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
1742 prefix, also apply the new formulas to the entire table.
1743 @kindex C-c C-q
1744 @item C-c C-q
1745 Exit the formula editor without installing changes.
1746 @kindex C-c C-r
1747 @item C-c C-r
1748 Toggle all references in the formula editor between standard (like
1749 @code{B3}) and internal (like @code{@@3$2}).
1750 @kindex @key{TAB}
1751 @item @key{TAB}
1752 Pretty-print or indent lisp formula at point.  When in a line containing
1753 a lisp formula, format the formula according to Emacs Lisp rules.
1754 Another @key{TAB} collapses the formula back again.  In the open
1755 formula, @key{TAB} re-indents just like in Emacs-lisp-mode.
1756 @kindex M-@key{TAB}
1757 @item M-@key{TAB}
1758 Complete Lisp symbols, just like in Emacs-lisp-mode.
1759 @kindex S-@key{up}
1760 @kindex S-@key{down}
1761 @kindex S-@key{left}
1762 @kindex S-@key{right}
1763 @item S-@key{up}/@key{down}/@key{left}/@key{right}
1764 Shift the reference at point.  For example, if the reference is
1765 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
1766 This also works for relative references, and for hline references.
1767 @kindex M-S-@key{up}
1768 @kindex M-S-@key{down}
1769 @item M-S-@key{up}/@key{down}
1770 Move the test line for column formulas in the Org-mode buffer up and
1771 down.
1772 @kindex M-@key{up}
1773 @kindex M-@key{down}
1774 @item M-@key{up}/@key{down}
1775 Scroll the window displaying the table.
1776 @kindex C-c @}
1777 @item C-c @}
1778 Turn the coordinate grid in the table on and off.
1779 @end table
1780 @end table
1782 Making a table field blank does not remove the formula associated with
1783 the field, because that is stored in a different line (the @samp{TBLFM}
1784 line) - during the next recalculation the field will be filled again.
1785 To remove a formula from a field, you have to give an empty reply when
1786 prompted for the formula, or to edit the @samp{#+TBLFM} line.
1788 @kindex C-c C-c
1789 You may edit the @samp{#+TBLFM} directly and re-apply the changed
1790 equations with @kbd{C-c C-c} in that line, or with the normal
1791 recalculation commands in the table.
1793 @subsubheading Debugging formulas
1794 @cindex formula debugging
1795 @cindex debugging, of table formulas
1796 When the evaluation of a formula leads to an error, the field content
1797 becomes the string @samp{#ERROR}.  If you would like see what is going
1798 on during variable substitution and calculation in order to find a bug,
1799 turn on formula debugging in the @code{Tbl} menu and repeat the
1800 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
1801 field.  Detailed information will be displayed.
1803 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
1804 @subsection Updating the Table
1805 @cindex recomputing table fields
1806 @cindex updating, table
1808 Recalculation of a table is normally not automatic, but needs to be
1809 triggered by a command.  See @ref{Advanced features} for a way to make
1810 recalculation at least semi-automatically.
1812 In order to recalculate a line of a table or the entire table, use the
1813 following commands:
1815 @table @kbd
1816 @kindex C-c *
1817 @item C-c *
1818 Recalculate the current row by first applying the stored column formulas
1819 from left to right, and all field formulas in the current row.
1821 @kindex C-u C-c *
1822 @item C-u C-c *
1823 @kindex C-u C-c C-c
1824 @itemx C-u C-c C-c
1825 Recompute the entire table, line by line.  Any lines before the first
1826 hline are left alone, assuming that these are part of the table header.
1828 @kindex C-u C-u C-c *
1829 @item C-u C-u C-c *
1830 Iterate the table by recomputing it until no further changes occur.
1831 This may be necessary if some computed fields use the value of other
1832 fields that are computed @i{later} in the calculation sequence.
1833 @end table
1835 @node Advanced features,  , Updating the table, The spreadsheet
1836 @subsection Advanced features
1838 If you want the recalculation of fields to happen automatically, or if
1839 you want to be able to assign @i{names} to fields and columns, you need
1840 to reserve the first column of the table for special marking characters.
1841 @table @kbd
1842 @kindex C-#
1843 @item C-#
1844 Rotate the calculation mark in first column through the states @samp{},
1845 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  The meaning of these characters
1846 is discussed below.  When there is an active region, change all marks in
1847 the region.
1848 @end table
1850 Here is an example of a table that collects exam results of students and
1851 makes use of these features:
1853 @example
1854 @group
1855 |---+---------+--------+--------+--------+-------+------|
1856 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
1857 |---+---------+--------+--------+--------+-------+------|
1858 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
1859 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
1860 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
1861 |---+---------+--------+--------+--------+-------+------|
1862 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
1863 | # | Sara    |      6 |     14 |     19 |    39 |  7.8 |
1864 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
1865 |---+---------+--------+--------+--------+-------+------|
1866 |   | Average |        |        |        |  29.7 |      |
1867 | ^ |         |        |        |        |    at |      |
1868 | $ | max=50  |        |        |        |       |      |
1869 |---+---------+--------+--------+--------+-------+------|
1870 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
1871 @end group
1872 @end example
1874 @noindent @b{Important}: Please note that for these special tables,
1875 recalculating the table with @kbd{C-u C-c *} will only affect rows that
1876 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
1877 to the field itself.  The column formulas are not applied in rows with
1878 empty first field.
1880 @cindex marking characters, tables
1881 The marking characters have the following meaning:
1882 @table @samp
1883 @item !
1884 The fields in this line define names for the columns, so that you may
1885 refer to a column as @samp{$Tot} instead of @samp{$6}.
1886 @item ^
1887 This row defines names for the fields @emph{above} the row.  With such
1888 a definition, any formula in the table may use @samp{$m1} to refer to
1889 the value @samp{10}.  Also, if you assign a formula to a names field, it
1890 will be stored as @samp{$name=...}.
1891 @item _
1892 Similar to @samp{^}, but defines names for the fields in the row
1893 @emph{below}.
1894 @item $
1895 Fields in this row can define @emph{parameters} for formulas.  For
1896 example, if a field in a @samp{$} row contains @samp{max=50}, then
1897 formulas in this table can refer to the value 50 using @samp{$max}.
1898 Parameters work exactly like constants, only that they can be defined on
1899 a per-table basis.
1900 @item #
1901 Fields in this row are automatically recalculated when pressing
1902 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
1903 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
1904 lines will be left alone by this command.
1905 @item *
1906 Selects this line for global recalculation with @kbd{C-u C-c *}, but
1907 not for automatic recalculation.  Use this when automatic
1908 recalculation slows down editing too much.
1909 @item
1910 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
1911 All lines that should be recalculated should be marked with @samp{#}
1912 or @samp{*}.
1913 @item /
1914 Do not export this line.  Useful for lines that contain the narrowing
1915 @samp{<N>} markers.
1916 @end table
1918 Finally, just to whet your appetite on what can be done with the
1919 fantastic @file{calc} package, here is a table that computes the Taylor
1920 series of degree @code{n} at location @code{x} for a couple of functions
1921 (homework: try that with Excel :-)
1923 @example
1924 @group
1925 |---+-------------+---+-----+--------------------------------------|
1926 |   | Func        | n | x   | Result                               |
1927 |---+-------------+---+-----+--------------------------------------|
1928 | # | exp(x)      | 1 | x   | 1 + x                                |
1929 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
1930 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
1931 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
1932 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
1933 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
1934 |---+-------------+---+-----+--------------------------------------|
1935 #+TBLFM: $5=taylor($2,$4,$3);n3
1936 @end group
1937 @end example
1939 @node Hyperlinks, TODO items, Tables, Top
1940 @chapter Hyperlinks
1941 @cindex hyperlinks
1943 Just like HTML, Org-mode provides links inside a file, and external
1944 links to other files, Usenet articles, emails, and much more.
1946 @menu
1947 * Link format::                 How links in Org-mode are formatted
1948 * Internal links::              Links to other places in the current file
1949 * External links::              URL-like links to the world
1950 * Handling links::              Creating, inserting and following
1951 * Link abbreviations::          Shortcuts for writing complex links
1952 * Search options::              Linking to a specific location
1953 * Custom searches::             When the default search is not enough
1954 * Remember::                    Org-trees store quick notes
1955 @end menu
1957 @node Link format, Internal links, Hyperlinks, Hyperlinks
1958 @section Link format
1959 @cindex link format
1960 @cindex format, of links
1962 Org-mode will recognize plain URL-like links and activate them as
1963 clickable links.  The general link format, however, looks like this:
1965 @example
1966 [[link][description]]       @r{or alternatively}           [[link]]  
1967 @end example
1969 Once a link in the buffer is complete (all brackets present), Org-mode
1970 will change the display so that @samp{description} is displayed instead
1971 of @samp{[[link][description]]} and @samp{link} is displayed instead of
1972 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
1973 which by default is an underlined face.  You can directly edit the
1974 visible part of a link.  Note that this can be either the @samp{link}
1975 part (if there is no description) or the @samp{description} part.  To
1976 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
1977 cursor on the link.
1979 If you place the cursor at the beginning or just behind the end of the
1980 displayed text and press @key{BACKSPACE}, you will remove the
1981 (invisible) bracket at that location.  This makes the link incomplete
1982 and the internals are again displayed as plain text.  Inserting the
1983 missing bracket hides the link internals again.  To show the
1984 internal structure of all links, use the menu entry
1985 @code{Org->Hyperlinks->Literal links}.
1987 @node Internal links, External links, Link format, Hyperlinks
1988 @section Internal links
1989 @cindex internal links
1990 @cindex links, internal
1991 @cindex targets, for links
1993 If the link does not look like a URL, it is considered to be internal in
1994 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
1995 Target][Find my target]]} lead to a text search in the current file.
1996 The link can be followed with @kbd{C-c C-o} when the cursor is on the
1997 link, or with a mouse click (@pxref{Handling links}).  The preferred
1998 match for such a link is a dedicated target: the same string in double
1999 angular brackets.  Targets may be located anywhere; sometimes it is
2000 convenient to put them into a comment line. For example
2002 @example
2003 # <<My Target>>
2004 @end example
2006 @noindent In HTML export (@pxref{HTML export}), such targets will become
2007 named anchors for direct access through @samp{http} links@footnote{Note
2008 that text before the first headline will never be exported, so the first
2009 such target must be after the first headline.}.
2011 If no dedicated target exists, Org-mode will search for the words in the
2012 link.  In the above example the search would be for @samp{my target}.
2013 Links starting with a star like @samp{*My Target} restrict the search to
2014 headlines.  When searching, Org-mode will first try an exact match, but
2015 then move on to more and more lenient searches.  For example, the link
2016 @samp{[[*My Targets]]} will find any of the following:
2018 @example
2019 ** My targets
2020 ** TODO my targets are bright
2021 ** my 20 targets are
2022 @end example
2024 To insert a link targeting a headline, in-buffer completion can be used.
2025 Just type a star followed by a few optional letters into the buffer and
2026 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2027 offered as completions.  @xref{Handling links}, for more commands
2028 creating links.
2030 Following a link pushes a mark onto Org-mode's own mark ring.  You can
2031 return to the previous position with @kbd{C-c &}.  Using this command
2032 several times in direct succession goes back to positions recorded
2033 earlier.
2035 @menu
2036 * Radio targets::               Make targets trigger links in plain text.
2037 @end menu
2039 @node Radio targets,  , Internal links, Internal links
2040 @subsection Radio targets
2041 @cindex radio targets
2042 @cindex targets, radio
2043 @cindex links, radio targets
2045 You can configure Org-mode to link any occurrences of certain target
2046 names in normal text.  So without explicitly creating a link, the text
2047 connects to the target radioing its position.  Radio targets are
2048 enclosed by triple angular brackets.  For example, a target
2049 @samp{<<<My Target>>>} causes each occurrence of @samp{my target} in
2050 normal text to become activated as a link.  The Org-mode file is
2051 scanned automatically for radio targets only when the file is first
2052 loaded into Emacs.  To update the target list during editing, press
2053 @kbd{C-c C-c} with the cursor on or at a target.
2055 @node External links, Handling links, Internal links, Hyperlinks
2056 @section External links
2057 @cindex links, external
2058 @cindex external links
2059 @cindex links, external
2060 @cindex GNUS links
2061 @cindex BBDB links
2062 @cindex URL links
2063 @cindex file links
2064 @cindex VM links
2065 @cindex RMAIL links
2066 @cindex WANDERLUST links
2067 @cindex MH-E links
2068 @cindex USENET links
2069 @cindex SHELL links
2070 @cindex Info links
2071 @cindex elisp links
2073 Org-mode supports links to files, websites, Usenet and email messages,
2074 and BBDB database entries.  External links are URL-like locators.  They
2075 start with a short identifying string followed by a colon.  There can be
2076 no space after the colon.  The following list shows examples for each
2077 link type.
2079 @example
2080 http://www.astro.uva.nl/~dominik          @r{on the web}
2081 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2082 file:papers/last.pdf                      @r{file, relative path}
2083 news:comp.emacs                           @r{Usenet link}
2084 mailto:adent@@galaxy.net                   @r{Mail link}
2085 vm:folder                                 @r{VM folder link}
2086 vm:folder#id                              @r{VM message link}
2087 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
2088 wl:folder                                 @r{WANDERLUST folder link}
2089 wl:folder#id                              @r{WANDERLUST message link}
2090 mhe:folder                                @r{MH-E folder link}
2091 mhe:folder#id                             @r{MH-E message link}
2092 rmail:folder                              @r{RMAIL folder link}
2093 rmail:folder#id                           @r{RMAIL message link}
2094 gnus:group                                @r{GNUS group link}
2095 gnus:group#id                             @r{GNUS article link}
2096 bbdb:Richard Stallman                     @r{BBDB link}
2097 shell:ls *.org                            @r{A shell command}
2098 elisp:(find-file-other-frame "Elisp.org") @r{An elisp form to evaluate}
2099 @end example
2101 A link should be enclosed in double brackets and may contain a
2102 descriptive text to be displayed instead of the url (@pxref{Link
2103 format}), for example:
2105 @example
2106 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2107 @end example
2109 @noindent
2110 If the description is a file name or URL that points to an image, HTML
2111 export (@pxref{HTML export}) will inline the image as a clickable
2112 button.  If there is no description at all and the link points to an
2113 image,
2114 that image will be inlined into the exported HTML file.
2116 @cindex angular brackets, around links
2117 @cindex plain text external links
2118 Org-mode also finds external links in the normal text and activates them
2119 as links.  If spaces must be part of the link (for example in
2120 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2121 about the end of the link, enclose them in angular brackets.
2123 @node Handling links, Link abbreviations, External links, Hyperlinks
2124 @section Handling links
2125 @cindex links, handling
2127 Org-mode provides methods to create a link in the correct syntax, to
2128 insert it into an org-mode file, and to follow the link.
2130 @table @kbd
2131 @kindex C-c l
2132 @cindex storing links
2133 @item C-c l
2134 Store a link to the current location.  This is a @emph{global} command
2135 which can be used in any buffer to create a link.  The link will be
2136 stored for later insertion into an Org-mode buffer (see below).  For
2137 Org-mode files, if there is a @samp{<<target>>} at the cursor, the link
2138 points to the target.  Otherwise it points to the current headline.  For
2139 VM, RMAIL, WANDERLUST, MH-E, GNUS and BBDB buffers, the link will
2140 indicate the current article/entry.  For W3 and W3M buffers, the link
2141 goes to the current URL.  For any other files, the link will point to
2142 the file, with a search string (@pxref{Search options}) pointing to the
2143 contents of the current line.  If there is an active region, the
2144 selected words will form the basis of the search string.  If the
2145 automatically created link is not working correctly or accurately
2146 enough, you can write custom functions to select the search string and
2147 to do the search for particular file types - see @ref{Custom searches}.
2148 The key binding @kbd{C-c l} is only a suggestion - see @ref{Installation}.
2150 @kindex C-c C-l
2151 @cindex link completion
2152 @cindex completion, of links
2153 @cindex inserting links
2154 @item C-c C-l
2155 Insert a link.  This prompts for a link to be inserted into the buffer.
2156 You can just type a link, using text for an internal link, or one of the
2157 link type prefixes mentioned in the examples above.  All links stored
2158 during the current session are part of the history for this prompt, so
2159 you can access them with @key{up} and @key{down}.  Completion, on the
2160 other hand, will help you to insert valid link prefixes like
2161 @samp{http:} or @samp{ftp:}, including the prefixes defined through link
2162 abbreviations (@pxref{Link abbreviations}).  The link will be inserted
2163 into the buffer@footnote{After insertion of a stored link, the link will
2164 be removed from the list of stored links.  To keep it in the list later
2165 use, use a triple @kbd{C-u} prefix to @kbd{C-c C-l}, or configure the
2166 option @code{org-keep-stored-link-after-insertion}.}, along with a
2167 descriptive text.  If some text was selected when this command is
2168 called, the selected text becomes the default description.@* Note that
2169 you don't have to use this command to insert a link.  Links in Org-mode
2170 are plain text, and you can type or paste them straight into the buffer.
2171 By using this command, the links are automatically enclosed in double
2172 brackets, and you will be asked for the optional descriptive text.
2174 @c  If the link is a @samp{file:} link and
2175 @c the linked file is located in the same directory as the current file or
2176 @c a subdirectory of it, the path of the file will be inserted relative to
2177 @c the current directory.
2179 @kindex C-u C-c C-l
2180 @cindex file name completion
2181 @cindex completion, of file names
2182 @item C-u C-c C-l
2183 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2184 a file will be inserted and you may use file name completion to select
2185 the name of the file.  The path to the file is inserted relative to the
2186 directory of the current org file, if the linked file is in the current
2187 directory or in a subdirectory of it, or if the path is written relative
2188 to the current directory using @samp{../}.  Otherwise an absolute path
2189 is used, if possible with @samp{~/} for your home directory.  You can
2190 force an absolute path with two @kbd{C-u} prefixes.
2192 @item C-c C-l @r{(with cursor on existing link)}
2193 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2194 link and description parts of the link.
2196 @cindex following links
2197 @kindex C-c C-o
2198 @item C-c C-o
2199 Open link at point.  This will launch a web browser for URLs (using
2200 @command{browse-url-at-point}), run vm/mh-e/wanderlust/rmail/gnus/bbdb
2201 for the corresponding links, and execute the command in a shell link.
2202 When the cursor is on an internal link, this commands runs the
2203 corresponding search.  When the cursor is on a TAG list in a headline,
2204 it creates the corresponding TAGS view.  If the cursor is on a time
2205 stamp, it compiles the agenda for that date.  Furthermore, it will visit
2206 text and remote files in @samp{file:} links with Emacs and select a
2207 suitable application for local non-text files.  Classification of files
2208 is based on file extension only.  See option @code{org-file-apps}.  If
2209 you want to override the default application and visit the file with
2210 Emacs, use a @kbd{C-u} prefix.
2212 @kindex mouse-2
2213 @kindex mouse-1
2214 @item mouse-2
2215 @itemx mouse-1
2216 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2217 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2219 @kindex mouse-3
2220 @item mouse-3
2221 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2222 internal links to be displayed in another window@footnote{See the
2223 variable @code{org-display-internal-link-with-indirect-buffer}}.
2225 @cindex mark ring
2226 @kindex C-c %
2227 @item C-c %
2228 Push the current position onto the mark ring, to be able to return
2229 easily. Commands following an internal link do this automatically.
2231 @cindex links, returning to
2232 @kindex C-c &
2233 @item C-c &
2234 Jump back to a recorded position.  A position is recorded by the
2235 commands following internal links, and by @kbd{C-c %}.  Using this
2236 command several times in direct succession moves through a ring of
2237 previously recorded positions.
2239 @kindex C-c C-x C-n
2240 @kindex C-c C-x C-p
2241 @cindex links, finding next/previous
2242 @item C-c C-x C-n
2243 @itemx C-c C-x C-p
2244 Move forward/backward to the next link in the buffer.  At the limit of
2245 the buffer, the search fails once, and then wraps around.  The key
2246 bindings for this are really too long, you might want to bind this also
2247 to @kbd{C-n} and @kbd{C-p}
2248 @lisp
2249 (add-hook 'org-load-hook
2250   (lambda ()
2251     (define-key 'org-mode-map "\C-n" 'org-next-link)
2252     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2253 @end lisp
2254 @end table
2256 @node Link abbreviations, Search options, Handling links, Hyperlinks
2257 @section Link abbreviations
2258 @cindex link abbreviations
2259 @cindex abbreviation, links
2261 Long URLs can be cumbersome to type, and often many similar links are
2262 needed in a document.  For this you can use link abbreviations.  An
2263 abbreviated link looks like this
2265 @example
2266 [[linkword:tag][description]]
2267 @end example
2269 @noindent
2270 where the tag is optional.  Such abbreviations are resolved according to
2271 the information in the variable @code{org-link-abbrev-alist} that
2272 relates the linkwords to replacement text.  Here is an example:
2274 @lisp
2275 @group
2276 (setq org-link-abbrev-alist
2277   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2278     ("google"   . "http://www.google.com/search?q=")
2279     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2280                    nph-abs_connect?author=%s&db_key=AST")))
2281 @end group
2282 @end lisp
2284 If the replacement text contains the string @samp{%s}, it will be
2285 replaced with the tag.  Otherwise the tag will be appended to the string
2286 in order to create the link.  You may also specify a function that will
2287 be called with the tag as the only argument to create the link.
2289 With the above setting, you could link to a specific bug with
2290 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2291 @code{[[google:OrgMode]]} and find out what the Org-mode author is
2292 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2294 If you need special abbreviations just for a single Org-mode buffer, you
2295 can define them in the file with
2297 @example
2298 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2299 #+LINK: google    http://www.google.com/search?q=%s
2300 @end example
2302 @noindent
2303 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2304 complete link abbreviations.
2306 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2307 @section Search options in file links
2308 @cindex search option in file links
2309 @cindex file links, searching
2311 File links can contain additional information to make Emacs jump to a
2312 particular location in the file when following a link.  This can be a
2313 line number or a search option after a double@footnote{For backward
2314 compatibility, line numbers can also follow a single colon.} colon. For
2315 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2316 links}) to a file, it encodes the words in the current line as a search
2317 string that can be used to find this line back later when following the
2318 link with @kbd{C-c C-o}. 
2320 Here is the syntax of the different ways to attach a search to a file
2321 link, together with an explanation:
2323 @example
2324 [[file:~/code/main.c::255]]
2325 [[file:~/xx.org::My Target]]
2326 [[file:~/xx.org::*My Target]]
2327 [[file:~/xx.org::/regexp/]]
2328 @end example
2330 @table @code
2331 @item 255
2332 Jump to line 255.
2333 @item My Target
2334 Search for a link target @samp{<<My Target>>}, or do a text search for
2335 @samp{my target}, similar to the search in internal links, see
2336 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
2337 link will become an HTML reference to the corresponding named anchor in
2338 the linked file.
2339 @item *My Target
2340 In an Org-mode file, restrict search to headlines.
2341 @item /regexp/
2342 Do a regular expression search for @code{regexp}.  This uses the Emacs
2343 command @code{occur} to list all matches in a separate window.  If the
2344 target file is in Org-mode, @code{org-occur} is used to create a
2345 sparse tree with the matches.
2346 @c If the target file is a directory,
2347 @c @code{grep} will be used to search all files in the directory.
2348 @end table
2350 As a degenerate case, a file link with an empty file name can be used
2351 to search the current file.  For example, @code{[[file:::find me]]} does
2352 a search for @samp{find me} in the current file, just as
2353 @samp{[[find me]]} would.
2355 @node Custom searches, Remember, Search options, Hyperlinks
2356 @section Custom Searches
2357 @cindex custom search strings
2358 @cindex search strings, custom
2360 The default mechanism for creating search strings and for doing the
2361 actual search related to a file link may not work correctly in all
2362 cases.  For example, BibTeX database files have many entries like
2363 @samp{year="1993"} which would not result in good search strings,
2364 because the only unique identification for a BibTeX entry is the
2365 citation key.
2367 If you come across such a problem, you can write custom functions to set
2368 the right search string for a particular file type, and to do the search
2369 for the string in the file.  Using @code{add-hook}, these functions need
2370 to be added to the hook variables
2371 @code{org-create-file-search-functions} and
2372 @code{org-execute-file-search-functions}.  See the docstring for these
2373 variables for more information.  Org-mode actually uses this mechanism
2374 for Bib@TeX{} database files, and you can use the corresponding code as
2375 an implementation example.  Search for @samp{BibTeX links} in the source
2376 file.
2379 @node Remember,  , Custom searches, Hyperlinks
2380 @section Remember
2381 @cindex @file{remember.el}
2383 Another way to create org entries with links to other files is through
2384 the @i{remember} package by John Wiegley.  @i{Remember} lets you store
2385 quick notes with little interruption of your work flow.  See
2386 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
2387 information.  The notes produced by @i{Remember} can be stored in
2388 different ways, and Org-mode files are a good target.  Org-mode
2389 significantly expands the possibilities of @i{remember}: You may define
2390 templates for different note types, and to associate target files and
2391 headlines with specific templates.  It also allows you to select the
2392 location where a note should be stored interactively, on the fly.
2394 @menu
2395 * Setting up remember::         Some code for .emacs to get things going
2396 * Remember templates::          Define the outline of different note types
2397 * Storing notes::               Directly get the note to where it belongs
2398 @end menu
2400 @node Setting up remember, Remember templates, Remember, Remember
2401 @subsection Setting up remember
2403 The following customization will tell @i{remember} to use org files as
2404 target, and to create annotations compatible with Org-mode links.
2406 @example
2407 (setq org-directory "~/path/to/my/orgfiles/")
2408 (setq org-default-notes-file "~/.notes")
2409 (setq remember-annotation-functions '(org-remember-annotation))
2410 (setq remember-handler-functions '(org-remember-handler))
2411 (add-hook 'remember-mode-hook 'org-remember-apply-template)
2412 @end example
2414 @node Remember templates, Storing notes, Setting up remember, Remember
2415 @subsection Remember templates
2416 @cindex templates, for remember
2418 In combination with Org-mode, you can use templates to generate
2419 different types of @i{remember} notes.  For example, if you would like
2420 to use one template to create general TODO entries, another one for
2421 journal entries, and a third one for collecting random ideas, you could
2422 use:
2424 @example
2425 (setq org-remember-templates
2426  '((?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org")
2427    (?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
2428    (?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
2429 @end example
2431 @noindent In these entries, the character specifies how to select the
2432 template.  The first string specifies the template.  Two more (optional)
2433 strings give the file in which, and the headline under which the new
2434 note should be stored.  The file defaults (if not present or @code{nil})
2435 to @code{org-default-notes-file}, the heading to
2436 @code{org-remember-default-headline}.  Both defaults help to get to the
2437 storing location quickly, but you can change the location interactively
2438 while storing the note.
2440 When you call @kbd{M-x remember} (or @kbd{M-x org-remember}) to remember
2441 something, org will prompt for a key to select the template (if you have
2442 more than one template) and then prepare the buffer like
2443 @example
2444 * TODO
2445   [[file:link to where you called remember]]
2446 @end example
2448 @noindent or
2450 @example
2451 * [2006-03-21 Tue 15:37]
2453   [[file:link to where you called remember]]
2454 @end example
2456 @noindent
2457 During expansion of the template, special @kbd{%}-escapes allow dynamic
2458 insertion of content:
2459 @example
2460 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
2461 %t          @r{time stamp, date only}
2462 %T          @r{time stamp with date and time}
2463 %u, %U      @r{like the above, but inactive time stamps}
2464 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
2465             @r{You may define a prompt like @code{%^@{Birthday@}t}}
2466 %n          @r{user name (taken from @code{user-full-name})}
2467 %a          @r{annotation, normally the link created with @code{org-store-link}}
2468 %i          @r{initial content, the region when remember is called with C-u.}
2469             @r{The entire text will be indented like @code{%i} itself.}
2470 %:keyword   @r{specific information for certain link types, see below}
2471 @end example
2473 @noindent
2474 For specific link types, the following keywords will be defined:
2476 @example
2477 Link type          |  Available keywords
2478 -------------------+----------------------------------------------
2479 bbdb               |  %:name %:company
2480 vm, wl, mh, rmail  |  %:type %:subject %:message-id
2481                    |  %:from %:fromname %:fromaddress
2482                    |  %:to   %:toname   %:toaddress
2483                    |  %: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}.}}       
2484 gnus               |  %:group, @r{for messages also all email fields}
2485 w3, w3m            |  %:url
2486 info               |  %:file %:node
2487 calendar           |  %:date"
2488 @end example
2490 @noindent
2491 To place the cursor after template expansion use:
2493 @example
2494 %?          @r{After completing the template, position cursor here.}
2495 @end example
2497 @noindent
2498 If you change you mind about which template to use, call
2499 @code{org-remember} in the remember buffer.  You may then select a new
2500 template that will be filled with the previous context information.
2502 @node Storing notes,  , Remember templates, Remember
2503 @subsection Storing notes
2505 When you are finished preparing a note with @i{remember}, you have to press
2506 @kbd{C-c C-c} to file the note away.  The handler first prompts for a
2507 target file - if you press @key{RET}, the value specified for the
2508 template is used.  Then the command offers the headings tree of the
2509 selected file, with the cursor position at the default headline (if you
2510 had specified one in the template).  You can either immediately press
2511 @key{RET} to get the note placed there.  Or you can use the following
2512 keys to find a better location:
2513 @example
2514 @key{TAB}         @r{Cycle visibility.}
2515 @key{down} / @key{up}   @r{Next/previous visible headline.}
2516 n / p        @r{Next/previous visible headline.}
2517 f / b        @r{Next/previous headline same level.}
2518 u            @r{One level up.}
2519 @c 0-9          @r{Digit argument.}
2520 @end example
2521 @noindent
2522 Pressing @key{RET} or @key{left} or @key{right}
2523 then leads to the following result.
2525 @multitable @columnfractions 0.2 0.15 0.65
2526 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
2527 @item buffer-start @tab @key{RET} @tab as level 2 heading at end of file
2528 @item on headline @tab @key{RET} @tab as sublevel of the heading at cursor
2529 @item             @tab @key{left}/@key{right} @tab as same level, before/after current heading
2530 @item not on headline @tab @key{RET}
2531       @tab at cursor position, level taken from context.
2532 @end multitable
2534 So a fast way to store the note to its default location is to press
2535 @kbd{C-c C-c @key{RET} @key{RET}}.  Even shorter would be @kbd{C-u C-c
2536 C-c}, which does the same without even asking for a file or showing the
2537 tree.
2539 Before inserting the text into a tree, the function ensures that the
2540 text has a headline, i.e. a first line that starts with a @samp{*}.
2541 If not, a headline is constructed from the current date and some
2542 additional data.  If the variable @code{org-adapt-indentation} is
2543 non-nil, the entire text is also indented so that it starts in the
2544 same column as the headline (after the asterisks).
2547 @node TODO items, Timestamps, Hyperlinks, Top
2548 @chapter TODO items
2549 @cindex TODO items
2551 Org-mode does not maintain TODO lists as a separate document.  TODO
2552 items are an integral part of the notes file, because TODO items
2553 usually come up while taking notes!  With Org-mode, you simply mark
2554 any entry in a tree as being a TODO item.  In this way, the
2555 information is not duplicated, and the entire context from which the
2556 item emerged is always present when you check.
2558 Of course, this technique causes TODO items to be scattered throughout
2559 your file.  Org-mode provides methods to give you an overview over all
2560 things you have to do.
2562 @menu
2563 * TODO basics::                 Marking and displaying TODO entries
2564 * TODO extensions::             Workflow and assignments
2565 * Priorities::                  Some things are more important than others
2566 * Breaking down tasks::         Splitting a task into manageable pieces
2567 * Checkboxes::                  Tick-off lists
2568 @end menu
2570 @node TODO basics, TODO extensions, TODO items, TODO items
2571 @section Basic TODO functionality
2573 Any headline can become a TODO item by starting it with the word TODO,
2574 for example:
2576 @example
2577 *** TODO Write letter to Sam Fortune
2578 @end example
2580 @noindent
2581 The most important commands to work with TODO entries are:
2583 @table @kbd
2584 @kindex C-c C-t
2585 @cindex cycling, of TODO states
2586 @item C-c C-t
2587 Rotate the TODO state of the current item among
2589 @example
2590 ,-> (unmarked) -> TODO -> DONE --.
2591 '--------------------------------'
2592 @end example
2594 The same rotation can also be done ``remotely'' from the timeline and
2595 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
2596 @kindex S-@key{right}
2597 @kindex S-@key{left}
2598 @item S-@key{right}
2599 @itemx S-@key{left}
2600 Select the following/preceding TODO state, similar to cycling.  Mostly
2601 useful if more than two TODO states are possible (@pxref{TODO extensions}).
2602 @kindex C-c C-v
2603 @cindex sparse tree, for TODO
2604 @item C-c C-v
2605 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
2606 the entire buffer, but shows all TODO items and the headings hierarchy
2607 above them.  With prefix arg, search for a specific TODO.  You will be
2608 prompted for the keyword, and you can also give a list of keywords like
2609 @code{kwd1|kwd2|...}.  With numerical prefix N, show the tree for the
2610 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
2611 args, find all TODO and DONE entries.
2612 @kindex C-c a t
2613 @item C-c a t
2614 Show the global TODO list.  This collects the TODO items from all
2615 agenda files (@pxref{Agenda views}) into a single buffer.  The buffer is in
2616 @code{agenda-mode}, so there are commands to examine and manipulate
2617 the TODO entries directly from that buffer (@pxref{Agenda commands}).
2618 @xref{Global TODO list}, for more information.
2619 @c @item @code{org-agenda-include-all-todo}
2620 @c If you would like to have all your TODO items listed as part of your
2621 @c agenda, customize the variable @code{org-agenda-include-all-todo}.
2622 @end table
2624 @node TODO extensions, Priorities, TODO basics, TODO items
2625 @section Extended use of TODO keywords
2626 @cindex extended TODO keywords
2628 The default implementation of TODO entries is just two states: TODO and
2629 DONE.  You can use the TODO feature for more complicated things by
2630 configuring the variable @code{org-todo-keywords}.  With special setup,
2631 the TODO keyword system can work differently in different files.
2633 Note that @i{tags} are another way to classify headlines in general and
2634 TODO items in particular (@pxref{Tags}).
2636 @menu
2637 * Workflow states::             From TODO to DONE in steps
2638 * TODO types::                  I do this, Fred the rest
2639 * Multiple sets in one file::   Mixing it all, and still finding your way
2640 * Per file keywords::           Different files, different requirements
2641 @end menu
2643 @node Workflow states, TODO types, TODO extensions, TODO extensions
2644 @subsection TODO keywords as workflow states
2645 @cindex TODO workflow
2646 @cindex workflow states as TODO keywords
2648 You can use TODO keywords to indicate different @emph{sequential} states
2649 in the process of working on an item, for example@footnote{Changing
2650 this variable only becomes effective after restarting Org-mode in a
2651 buffer.}:
2653 @lisp
2654 (setq org-todo-keywords
2655   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
2656 @end lisp
2658 The vertical bar separates the TODO keywords (states that @emph{need
2659 action}) from the DONE states (which need @emph{no further action}.  If
2660 you don't provide the separator bar, the last state is used as the DONE
2661 state.
2662 @cindex completion, of TODO keywords
2663 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
2664 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
2665 also use a prefix argument to quickly select a specific state.  For
2666 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
2667 If you define many keywords, you can use in-buffer completion (see
2668 @ref{Completion}) to insert these words into the buffer.  Changing a
2669 todo state can be logged with a timestamp, see @ref{Tracking TODO state
2670 changes} for more information.
2672 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
2673 @subsection TODO keywords as types
2674 @cindex TODO types
2675 @cindex names as TODO keywords
2676 @cindex types as TODO keywords
2678 The second possibility is to use TODO keywords to indicate different
2679 @emph{types} of action items.  For example, you might want to indicate
2680 that items are for ``work'' or ``home''.  Or, when you work with several
2681 people on a single project, you might want to assign action items
2682 directly to persons, by using their names as TODO keywords.  This would
2683 be set up like this:
2685 @lisp
2686 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
2687 @end lisp
2689 In this case, different keywords do not indicate a sequence, but rather
2690 different types.  So the normal work flow would be to assign a task to a
2691 person, and later to mark it DONE.  Org-mode supports this style by
2692 adapting the workings of the command @kbd{C-c C-t}@footnote{This is also
2693 true for the @kbd{t} command in the timeline and agenda buffers.}.  When
2694 used several times in succession, it will still cycle through all names,
2695 in order to first select the right type for a task.  But when you return
2696 to the item after some time and execute @kbd{C-c C-t} again, it will
2697 switch from any name directly to DONE.  Use prefix arguments or
2698 completion to quickly select a specific name.  You can also review the
2699 items of a specific TODO type in a sparse tree by using a numeric prefix
2700 to @kbd{C-c C-v}.  For example, to see all things Lucy has to do, you
2701 would use @kbd{C-3 C-c C-v}.  To collect Lucy's items from all agenda
2702 files into a single buffer, you would use the prefix arg as well when
2703 creating the global todo list: @kbd{C-3 C-c t}.
2705 @node Multiple sets in one file, Per file keywords, TODO types, TODO extensions
2706 @subsection Multiple keyword sets in one file
2707 @cindex todo keyword sets
2709 Sometimes you may want to use different sets of TODO keywords in
2710 parallel.  For example, you may want to have the basic
2711 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
2712 separate state indicating that an item has been canceled (so it is not
2713 DONE, but also does not require action).  Your setup would then look
2714 like this:
2716 @lisp
2717 (setq org-todo-keywords
2718       '((sequence "TODO" "|" "DONE")
2719         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
2720         (sequence "|" "CANCELED")))
2721 @end lisp
2723 The keywords should all be different, this helps Org-mode to keep track
2724 of which subsequence should be used for a given entry.  In this setup,
2725 @kbd{C-c C-t} only operates within a subsequence, so it switches from
2726 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
2727 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
2728 select the correct sequence.  Besides the obvious ways like typing a
2729 keyword or using completion, you may also apply the following commands:
2731 @table @kbd
2732 @kindex C-S-@key{right}
2733 @kindex C-S-@key{left}
2734 @item C-S-@key{right}
2735 @itemx C-S-@key{left}
2736 These keys jump from one TODO subset to the next.  In the above example,
2737 @kbd{C-S-@key{right}} would jump from @code{TODO} or @code{DONE} to
2738 @code{REPORT}, and any of the words in the second row to @code{CANCELED}.
2739 @kindex S-@key{right}
2740 @kindex S-@key{left}
2741 @item S-@key{right}
2742 @itemx S-@key{left}
2743 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through
2744 @emph{all} keywords from all sets, so for example @kbd{S-@key{<right>}}
2745 would switch from @code{DONE} to @code{REPORT} in the example above.
2746 @end table
2748 @node Per file keywords,  , Multiple sets in one file, TODO extensions
2749 @subsection Setting up keywords for individual files
2750 @cindex keyword options
2751 @cindex per file keywords
2753 It can be very useful to use different aspects of the TODO mechanism in
2754 different files.  For file-local settings, you need to add special lines
2755 to the file which set the keywords and interpretation for that file
2756 only.  For example, to set one of the two examples discussed above, you
2757 need one of the following lines, starting in column zero anywhere in the
2758 file:
2760 @example
2761 #+SEQ_TODO: TODO FEEDBACK VERIFY | DONE CANCELED
2762 @end example
2764 @example
2765 #+TYP_TODO: Fred Sara Lucy Mike | DONE
2766 @end example
2768 A setup for using several sets in parallel would be:
2770 @example
2771 #+SEQ_TODO: "TODO" "|" "DONE"
2772 #+SEQ_TODO: "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED"
2773 #+SEQ_TODO: "|" "CANCELED"
2774 @end example
2777 @cindex completion, of option keywords
2778 @kindex M-@key{TAB}
2779 @noindent To make sure you are using the correct keyword, type
2780 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
2782 @cindex DONE, final TODO keyword
2783 Remember that the keywords after the vertical bar (or the last keyword
2784 if no bar is there) must always mean that the item is DONE (although you
2785 may use a different word).  After changing one of these lines, use
2786 @kbd{C-c C-c} with the cursor still in the line to make the changes
2787 known to Org-mode@footnote{Org-mode parses these lines only when
2788 Org-mode is activated after visiting a file.  @kbd{C-c C-c} with the
2789 cursor in a line starting with @samp{#+} is simply restarting Org-mode
2790 for the current buffer.}.
2792 @node Priorities, Breaking down tasks, TODO extensions, TODO items
2793 @section Priorities
2794 @cindex priorities
2796 If you use Org-mode extensively to organize your work, you may end up
2797 with a number of TODO entries so large that you'd like to prioritize
2798 them.  This can be done by placing a @emph{priority cookie} into the
2799 headline, like this
2801 @example
2802 *** TODO [#A] Write letter to Sam Fortune
2803 @end example
2805 @noindent
2806 With its standard setup, Org-mode supports priorities @samp{A},
2807 @samp{B}, and @samp{C}.  @samp{A} is the highest priority.  An entry
2808 without a cookie is treated as priority @samp{B}.  Priorities make a
2809 difference only in the agenda (@pxref{Weekly/Daily agenda}).
2811 @table @kbd
2812 @kindex @kbd{C-c ,}
2813 @item @kbd{C-c ,}
2814 Set the priority of the current headline.  The command prompts for a
2815 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
2816 @key{SPC} instead, the priority cookie is removed from the headline.
2817 The priorities can also be changed ``remotely'' from the timeline and
2818 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
2820 @kindex S-@key{up}
2821 @kindex S-@key{down}
2822 @item S-@key{up}
2823 @itemx S-@key{down}
2824 Increase/decrease priority of current headline.  Note that these keys
2825 are also used to modify time stamps (@pxref{Creating timestamps}).
2826 Furthermore, these keys are also used by CUA-mode (@pxref{Conflicts}).
2827 @end table
2829 You can change the range of allowed priorities by setting the variables
2830 @code{org-highest-priority}, @code{org-lowest-priority}, and
2831 @code{org-default-priority}.  For an individual buffer, you may set
2832 these values (highest, lowest, default) like this (please make sure that
2833 the highest priority is earlier in the alphabet than the lowest
2834 priority):
2836 @example
2837 #+PRIORITIES: A C B
2838 @end example
2840 @node Breaking down tasks, Checkboxes, Priorities, TODO items
2841 @section Breaking tasks down into subtasks
2842 @cindex tasks, breaking down
2844 It is often advisable to break down large tasks into smaller, manageable
2845 subtasks.  You can do this by creating an outline tree below a TODO
2846 item, with detailed subtasks on the tree@footnote{To keep subtasks out
2847 of the global TODO list, see the
2848 @code{org-agenda-todo-list-sublevels}.}.  Another possibility is the use
2849 of checkboxes to identify (a hierarchy of) a large number of subtasks
2850 (@pxref{Checkboxes}).
2853 @node Checkboxes,  , Breaking down tasks, TODO items
2854 @section Checkboxes
2855 @cindex checkboxes
2857 Every item in a plain list (@pxref{Plain lists}) can be made a checkbox
2858 by starting it with the string @samp{[ ]}.  This feature is similar to
2859 TODO items (@pxref{TODO items}), but more lightweight.  Checkboxes are
2860 not included into the global TODO list, so they are often great to split
2861 a task into a number of simple steps.  Or you can use them in a shopping
2862 list.  To toggle a checkbox, use @kbd{C-c C-c}, or try Piotr Zielinski's
2863 @file{org-mouse.el}.  Here is an example of a checkbox list.
2865 @example
2866 * TODO Organize party [3/6]
2867   - call people [1/3]
2868     - [ ] Peter
2869     - [X] Sarah
2870     - [ ] Sam
2871   - [X] order food
2872   - [ ] think about what music to play
2873   - [X] talk to the neighbors
2874 @end example
2876 @cindex statistics, for checkboxes
2877 @cindex checkbox statistics
2878 The @samp{[3/6]} and @samp{[1/3]} in the first and second line are
2879 cookies indicating how many checkboxes are present in this entry, and
2880 how many of them have been checked off.  This can give you an idea on
2881 how many checkboxes remain, even without opening a folded entry.  The
2882 cookies can be placed into a headline or into (the first line of) a
2883 plain list item. Each cookie covers all checkboxes structurally below
2884 that headline/item.  You have to insert the cookie yourself by typing
2885 either @samp{[/]} or @samp{[%]}.  In the first case you get an @samp{n
2886 out of m} result, in the second case you get information about the
2887 percentage of checkboxes checked (in the above example, this would be
2888 @samp{[50%]} and @samp{[33%], respectively}).
2890 @noindent The following commands work with checkboxes:
2892 @table @kbd
2893 @kindex C-c C-c
2894 @item C-c C-c
2895 Toggle checkbox at point.
2896 @kindex C-c C-x C-b
2897 @item C-c C-x C-b
2898 Toggle checkbox at point.
2899 @itemize @minus
2900 @item
2901 If there is an active region, toggle the first checkbox in the region
2902 and set all remaining boxes to the same status as the first.  If you
2903 want to toggle all boxes in the region independently, use a prefix
2904 argument.
2905 @item
2906 If the cursor is in a headline, toggle checkboxes in the region between
2907 this headline and the next (so @emph{not} the entire subtree).
2908 @item
2909 If there is no active region, just toggle the checkbox at point.
2910 @end itemize
2911 @kindex M-S-@key{RET}
2912 @item M-S-@key{RET}
2913 Insert a new item with a checkbox.
2914 This works only if the cursor is already in a plain list item
2915 (@pxref{Plain lists}).
2916 @kindex C-c #
2917 @item C-c #
2918 Update the checkbox statistics in the current outline entry.  When
2919 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
2920 statistic cookies are updated automatically if you toggle checkboxes
2921 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
2922 delete boxes or add/change them by hand, use this command to get things
2923 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
2924 @end table
2926 @node Timestamps, Tags, TODO items, Top
2927 @chapter Timestamps
2928 @cindex time stamps
2929 @cindex date stamps
2931 Items can be labeled with timestamps to make them useful for project
2932 planning.
2934 @menu
2935 * Time stamps::                 Assigning a time to a tree entry
2936 * Creating timestamps::         Commands which insert timestamps
2937 * Deadlines and scheduling::    Planning your work
2938 * Progress logging::            Documenting when what work was done.
2939 @end menu
2942 @node Time stamps, Creating timestamps, Timestamps, Timestamps
2943 @section Time stamps, deadlines and scheduling
2944 @cindex time stamps
2945 @cindex ranges, time
2946 @cindex date stamps
2947 @cindex deadlines
2948 @cindex scheduling
2950 A time stamp is a specification of a date (possibly with time) in a
2951 special format, either @samp{<2003-09-16 Tue>} or @samp{<2003-09-16 Tue
2952 09:39>}@footnote{This is the standard ISO date/time format.  If you
2953 cannot get used to these, see @ref{Custom time format}}.  A time stamp
2954 can appear anywhere in the headline or body of an org-tree entry.  Its
2955 presence causes entries to be shown on specific dates in the agenda
2956 (@pxref{Weekly/Daily agenda}).  We distinguish:
2958 @table @var
2959 @item Plain time stamp
2960 @cindex timestamp
2961 A simple time stamp just assigns a date/time to an item.  This is just
2962 like writing down an appointment in a paper agenda, or like writing down
2963 an event in a diary, when you want to take note of when something
2964 happened.  In the timeline and agenda displays, the headline of an entry
2965 associated with a plain time stamp will be shown exactly on that date.
2967 @example
2968 * Meet Peter at the movies <2006-11-01 Wed 19:15>
2969 @end example
2971 @item Time stamp with repeater interval
2972 @cindex timestamp, with repeater interval
2973 A time stamp may contain a @emph{repeater interval}, indicating that it
2974 applies not only on the given date, but again and again after a certain
2975 interval of N days (d), weeks (w), months(m), or years(y).  The
2976 following will show up in the agenda every Wednesday:
2978 @example
2979 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
2980 @end example
2982 @item Diary-style sexp entries
2983 For more complex date specifications, Org-mode supports using the
2984 special sexp diary entries implemented in the Emacs calendar/diary
2985 package.  For example
2987 @example
2988 * The nerd meeting on every 2nd Thursday of the month
2989   <%%(diary-float t 4 2)>
2990 @end example
2992 @item Time/Date range
2993 @cindex timerange
2994 @cindex date range
2995 Two time stamps connected by @samp{--} denote a range.  The headline
2996 will be shown on the first and last day of the range, and on any dates
2997 that are displayed and fall in the range.  Here is an example:
2999 @example
3000 ** Meeting in Amsterdam
3001    <2004-08-23 Mon>--<2004-08-26 Thu>
3002 @end example
3004 @item Inactive time stamp
3005 @cindex timestamp, inactive
3006 @cindex inactive timestamp
3007 Just like a plain time stamp, but with square brackets instead of
3008 angular ones.  These time stamps are inactive in the sense that they do
3009 @emph{not} trigger an entry to show up in the agenda.
3011 @example
3012 * Gillian comes late for the fifth time [2006-11-01 Wed]
3013 @end example
3015 @end table
3017 @node Creating timestamps, Deadlines and scheduling, Time stamps, Timestamps
3018 @section Creating timestamps
3019 @cindex creating timestamps
3020 @cindex timestamps, creating
3022 For Org-mode to recognize time stamps, they need to be in the specific
3023 format.  All commands listed below produce time stamps in the correct
3024 format.
3026 @table @kbd
3027 @kindex C-c .
3028 @item C-c .
3029 Prompt for a date and insert a corresponding time stamp.  When the
3030 cursor is at a previously used time stamp, it is updated to NOW.  When
3031 this command is used twice in succession, a time range is inserted.
3033 @kindex C-u C-c .
3034 @item C-u C-c .
3035 Like @kbd{C-c .}, but use the alternative format which contains date
3036 and time.  The default time can be rounded to multiples of 5 minutes,
3037 see the option @code{org-time-stamp-rounding-minutes}.
3039 @kindex C-c !
3040 @item C-c !
3041 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
3042 an agenda entry.
3044 @kindex C-c <
3045 @item C-c <
3046 Insert a time stamp corresponding to the cursor date in the Calendar.
3048 @kindex C-c >
3049 @item C-c >
3050 Access the Emacs calendar for the current date.  If there is a
3051 timestamp in the current line, goto the corresponding date
3052 instead.
3054 @kindex C-c C-o
3055 @item C-c C-o
3056 Access the agenda for the date given by the time stamp or -range at
3057 point (@pxref{Weekly/Daily agenda}).
3059 @kindex S-@key{left}
3060 @kindex S-@key{right}
3061 @item S-@key{left}
3062 @itemx S-@key{right}
3063 Change date at cursor by one day.  These key bindings conflict with
3064 CUA-mode (@pxref{Conflicts}).
3066 @kindex S-@key{up}
3067 @kindex S-@key{down}
3068 @item S-@key{up}
3069 @itemx S-@key{down}
3070 Change the item under the cursor in a timestamp.  The cursor can be on a
3071 year, month, day, hour or minute.  Note that if the cursor is in a
3072 headline and not at a time stamp, these same keys modify the priority of
3073 an item.  (@pxref{Priorities}). The key bindings also conflict with
3074 CUA-mode (@pxref{Conflicts}).
3076 @kindex C-c C-y
3077 @cindex evaluate time range
3078 @item C-c C-y
3079 Evaluate a time range by computing the difference between start and
3080 end.  With prefix arg, insert result after the time range (in a table:
3081 into the following column).
3082 @end table
3085 @menu
3086 * The date/time prompt::        How org-mode helps you entering date and time
3087 * Custom time format::          Making dates look differently
3088 @end menu
3090 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
3091 @subsection The date/time prompt
3092 @cindex date, reading in minibuffer
3093 @cindex time, reading in minibuffer
3095 When Org-mode prompts for a date/time, the prompt suggests to enter an
3096 ISO date.  But it will in fact accept any string containing some date
3097 and/or time information.  You can, for example, use @kbd{C-y} to paste a
3098 (possibly multi-line) string copied from an email message.  Org-mode
3099 will find whatever information is in there and will replace anything not
3100 specified with the current date and time.  For example:
3102 @example
3103   3-2-5         --> 2003-02-05
3104   feb 15        --> currentyear-02-15
3105   sep 12 9      --> 2009-09-12
3106   12:45         --> today 12:45
3107   22 sept 0:34  --> currentyear-09-22 0:34
3108   12            --> currentyear-currentmonth-12
3109   Fri           --> nearest Friday (today or later)
3110   +4            --> 4 days from now (if +N is the only thing given)
3111 @end example
3113 The function understands English month and weekday abbreviations.  If
3114 you want to use unabbreviated names and/or other languages, configure
3115 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
3117 @cindex calendar, for selecting date
3118 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
3119 you don't need/want the calendar, configure the variable
3120 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
3121 prompt, either by clicking on a date in the calendar, or by pressing
3122 @key{RET}, the date selected in the calendar will be combined with the
3123 information entered at the prompt.  You can control the calendar fully
3124 from the minibuffer:
3126 @table @kbd
3127 @kindex <
3128 @item <
3129 Scroll calendar backwards by one month.
3130 @kindex >
3131 @item >
3132 Scroll calendar forwards by one month.
3133 @kindex mouse-1
3134 @item mouse-1
3135 Select date by clicking on it.
3136 @kindex S-@key{right}
3137 @item S-@key{right}
3138 One day forward.
3139 @kindex S-@key{left}
3140 @item S-@key{left}
3141 One day back.
3142 @kindex S-@key{down}
3143 @item S-@key{down}
3144 One week forward.
3145 @kindex S-@key{up}
3146 @item S-@key{up}
3147 One week back.
3148 @kindex M-S-@key{right}
3149 @item M-S-@key{right}
3150 One month forward.
3151 @kindex M-S-@key{left}
3152 @item M-S-@key{left}
3153 One month back.
3154 @kindex @key{RET}
3155 @item @key{RET}
3156 Choose date in calendar (only if nothing was typed into minibuffer).
3157 @end table
3159 @node Custom time format,  , The date/time prompt, Creating timestamps
3160 @subsection Custom time format
3161 @cindex custom date/time format
3162 @cindex time format, custom
3163 @cindex date format, custom
3165 Org-mode uses the standard ISO notation for dates and times as it is
3166 defined in ISO 8601.  If you cannot get used to this and require another
3167 representation of date and time to keep you happy, you can get it by
3168 customizing the variables @code{org-display-custom-times} and
3169 @code{org-time-stamp-custom-formats}.
3171 @table @kbd
3172 @kindex C-c C-x C-t
3173 @item C-c C-x C-t
3174 Toggle the display of custom formats for dates and times.
3175 @end table
3177 @noindent
3178 Org-mode needs the default format for scanning, so the custom date/time
3179 format does not @emph{replace} the default format - instead it is put
3180 @emph{over} the default format using text properties.  This has the
3181 following consequences:
3182 @itemize @bullet
3183 @item 
3184 You cannot place the cursor onto a time stamp anymore, only before or
3185 after.
3186 @item
3187 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
3188 each component of a time stamp.  If the cursor is at the beginning of
3189 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
3190 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
3191 time will be changed by one minute.
3192 @item
3193 When you delete a time stamp character-by-character, it will only
3194 disappear from the buffer after @emph{all} (invisible) characters
3195 belonging to the ISO timestamp have been removed.
3196 @item
3197 If the custom time stamp format is longer than the default and you are
3198 using dates in tables, table alignment will be messed up.  If the custom
3199 format is shorter, things do work as expected.
3200 @end itemize
3203 @node Deadlines and scheduling, Progress logging, Creating timestamps, Timestamps
3204 @section Deadlines and Scheduling
3206 A time stamp may be preceded by special keywords to facilitate planning
3207 of work:
3209 @table @var
3210 @item DEADLINE
3211 @cindex DEADLINE keyword
3212 The task (most likely a TODO item) is supposed to be finished on that
3213 date, and it will be listed then.  In addition, the compilation for
3214 @emph{today} will carry a warning about the approaching or missed
3215 deadline, starting @code{org-deadline-warning-days} before the due date,
3216 and continuing until the entry is marked DONE.  An example:
3218 @example
3219 *** TODO write article about the Earth for the Guide
3220     The editor in charge is [[bbdb:Ford Prefect]]
3221     DEADLINE: <2004-02-29 Sun>
3222 @end example
3224 @item SCHEDULED
3225 @cindex SCHEDULED keyword
3226 You are planning to start working on that task on the given date. The
3227 headline will be listed under the given date@footnote{It will still be
3228 listed on that date after it has been marked DONE.  If you don't like
3229 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
3230 addition, a reminder that the scheduled date has passed will be present
3231 in the compilation for @emph{today}, until the entry is marked DONE.
3232 I.e., the task will automatically be forwarded until completed.
3234 @example
3235 *** TODO Call Trillian for a date on New Years Eve.
3236     SCHEDULED: <2004-12-25 Sat>
3237 @end example
3238 @end table
3240 @menu
3241 * Inserting deadline/schedule::  
3242 * Repeated tasks::              
3243 @end menu
3245 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
3246 @subsection Inserting deadline/schedule
3248 The following commands allow to quickly insert a deadline or to schedule
3249 an item:
3251 @table @kbd
3253 @kindex C-c C-d
3254 @item C-c C-d
3255 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
3256 happen in the line directly following the headline.
3257 @c FIXME Any CLOSED timestamp will be removed.????????
3259 @kindex C-c C-w
3260 @cindex sparse tree, for deadlines
3261 @item C-c C-w
3262 Create a sparse tree with all deadlines that are either past-due, or
3263 which will become due within @code{org-deadline-warning-days}.
3264 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
3265 prefix, check that many days.  For example, @kbd{C-1 C-c C-w} shows
3266 all deadlines due tomorrow.
3268 @kindex C-c C-s
3269 @item C-c C-s
3270 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
3271 happen in the line directly following the headline.  Any CLOSED
3272 timestamp will be removed.
3273 @end table
3275 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
3276 @subsection Repeated Tasks
3278 Some tasks need to be repeated again and again, and Org-mode therefore
3279 allows to use a repeater in a DEADLINE or SCHEDULED time stamp, for
3280 example:
3281 @example
3282 ** TODO Pay the rent
3283    DEADLINE: <2005-10-01 Sat +1m>
3284 @end example
3286 Deadlines and scheduled items produce entries in the agenda when they
3287 are over-due, so it is important to be able to mark such an entry as
3288 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
3289 with the todo keyword DONE, it will no longer produce entries in the
3290 agenda. The problem with this is, however, that then also the
3291 @emph{next} instance of the repeated entry will not be active.  Org-mode
3292 deals with this in the following way: When you try to mark such an entry
3293 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
3294 time stamp by the repeater interval, and immediately set the entry state
3295 back to TODO.  In the example above, setting the state to DONE would
3296 actually switch the date like this:
3298 @example
3299 ** TODO Pay the rent
3300    DEADLINE: <2005-11-01 Tue +1m>
3301 @end example
3303 You will also be prompted for a note that will be put under the DEADLINE
3304 line to keep a record that you actually acted on the previous instance
3305 of this deadline.
3307 As a consequence of shifting the base date, this entry will no longer be
3308 visible in the agenda when checking past dates, but all future instances
3309 will be visible.
3311 You may have both scheduling and deadline information for a specific
3312 task - just make sure that the repeater intervals on both are the same.
3314 @node Progress logging,  , Deadlines and scheduling, Timestamps
3315 @section Progress Logging
3316 @cindex progress logging
3317 @cindex logging, of progress
3319 Org-mode can automatically record a time stamp when you mark a TODO item
3320 as DONE, or even each time when you change the state of a TODO item.
3321 You can also measure precisely the time you spent on specific items in a
3322 project by starting and stopping a clock when you start and stop working
3323 on an aspect of a project.
3325 @menu
3326 * Closing items::               When was this entry marked DONE?
3327 * Tracking TODO state changes::  When did the status change?
3328 * Clocking work time::          When exactly did you work on this item?
3329 @end menu
3331 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3332 @subsection Closing items
3334 If you want to keep track of @emph{when} a certain TODO item was
3335 finished, turn on logging with@footnote{The corresponding in-buffer
3336 setting is: @code{#+STARTUP: logdone}}
3338 @lisp
3339 (setq org-log-done t)
3340 @end lisp
3342 @noindent
3343 Then each time you turn a TODO entry into DONE using either @kbd{C-c
3344 C-t} in the Org-mode buffer or @kbd{t} in the agenda buffer, a line
3345 @samp{CLOSED: [timestamp]} will be inserted just after the headline.  If
3346 you turn the entry back into a TODO item through further state cycling,
3347 that line will be removed again.  In the timeline (@pxref{Timeline}) and
3348 in the agenda (@pxref{Weekly/Daily agenda}), you can then use the
3349 @kbd{l} key to display the TODO items closed on each day, giving you an
3350 overview of what has been done on a day.  If you want to record a note
3351 along with the timestamp, use@footnote{The corresponding in-buffer
3352 setting is: @code{#+STARTUP: lognotedone}}
3354 @lisp
3355 (setq org-log-done '(done))
3356 @end lisp
3358 @node Tracking TODO state changes, Clocking work time, Closing items, Progress logging
3359 @subsection Tracking TODO state changes
3361 When TODO keywords are used as workflow states (@pxref{Workflow
3362 states}), you might want to keep track of when a state change occurred,
3363 and you may even want to attach notes to that state change.  With the
3364 setting
3366 @lisp
3367 (setq org-log-done '(state))
3368 @end lisp
3370 @noindent
3371 each state change will prompt you for a note that will be attached to
3372 the current headline.  Very likely you do not want this verbose tracking
3373 all the time, so it is probably better to configure this behavior with
3374 in-buffer options.  For example, if you are tracking purchases, put
3375 these into a separate file that starts with:
3377 @example
3378 #+SEQ_TODO: TODO ORDERED INVOICE PAYED RECEIVED SENT
3379 #+STARTUP: lognotestate
3380 @end example
3383 @node Clocking work time,  , Tracking TODO state changes, Progress logging
3384 @subsection Clocking work time
3386 Org-mode allows you to clock the time you spent on specific tasks in a
3387 project.  When you start working on an item, you can start the clock.
3388 When you stop working on that task, or when you mark the task done, the
3389 clock is stopped and the corresponding time interval is recorded.  It
3390 also computes the total time spent on each subtree of a project.
3392 @table @kbd
3393 @kindex C-c C-x C-i
3394 @item C-c C-x C-i
3395 Start the clock on the current item (clock-in).  This inserts the CLOCK
3396 keyword together with a timestamp.
3397 @kindex C-c C-x C-o
3398 @item C-c C-x C-o
3399 Stop the clock (clock-out).  The inserts another timestamp at the same
3400 location where the clock was last started.  It also directly computes
3401 the resulting time in inserts it after the time range as @samp{=>
3402 HH:MM}.  See the variable @code{org-log-done} for the possibility to
3403 record an additional note together with the clock-out time
3404 stamp@footnote{The corresponding in-buffer setting is: @code{#+STARTUP:
3405 lognoteclock-out}}.
3406 @kindex C-c C-y
3407 @item C-c C-y
3408 Recompute the time interval after changing one of the time stamps.  This
3409 is only necessary if you edit the time stamps directly.  If you change
3410 them with @kbd{S-@key{cursor}} keys, the update is automatic.
3411 @kindex C-c C-t
3412 @item C-c C-t
3413 Changing the TODO state of an item to DONE automatically stops the clock
3414 if it is running in this same item.
3415 @kindex C-c C-x C-x
3416 @item C-c C-x C-x
3417 Cancel the current clock.  This is useful if a clock was started by
3418 mistake, or if you ended up working on something else.
3419 @kindex C-c C-x C-d
3420 @item C-c C-x C-d
3421 Display time summaries for each subtree in the current buffer.  This
3422 puts overlays at the end of each headline, showing the total time
3423 recorded under that heading, including the time of any subheadings. You
3424 can use visibility cycling to study the tree, but the overlays disappear
3425 when you change the buffer (see variable
3426 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
3427 @kindex C-c C-x C-r
3428 @item C-c C-x C-r
3429 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
3430 report as an org-mode table into the current file.
3431 @example
3432 #+BEGIN: clocktable :maxlevel 2 :emphasize nil
3434 #+END: clocktable
3435 @end example
3436 @noindent
3437 If such a block already exists, its content is replaced by the new
3438 table.  The @samp{BEGIN} line can specify options:
3439 @example
3440 :maxlevels   @r{Maximum level depth to which times are listed in the table.}
3441 :emphasize   @r{When @code{t}, emphasize level one and level two items}
3442 :block       @r{The time block to consider.  This block is specified relative}
3443              @r{to the current time and may be any of these keywords:}
3444              @r{@code{today}, @code{yesterday}, @code{thisweek}, @code{lastweek},}
3445              @r{@code{thismonth}, @code{lastmonth}, @code{thisyear}, or @code{lastyear}}.
3446 :tstart      @r{A time string specifying when to start considering times}
3447 :tend        @r{A time string specifying when to stop considering times}
3448 @end example
3449 So to get a clock summary for the current day, you could write
3450 @example
3451 #+BEGIN: clocktable :maxlevel 2 :block today
3453 #+END: clocktable
3454 @end example
3455 and to use a specific time range you could write@footnote{Note that all
3456 parameters must be specified in a single line - the line is broken here
3457 only to fit it onto the manual.}
3458 @example
3459 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>" 
3460                     :tend "<2006-08-10 Thu 12:00>"
3462 #+END: clocktable
3463 @end example
3464 @kindex C-u C-c C-x C-u
3465 @item C-u C-c C-x C-u
3466 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
3467 you have several clocktable blocks in a buffer.
3468 @end table
3470 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
3471 the agenda (@pxref{Weekly/Daily agenda}) to show which tasks have been
3472 worked on or closed during a day.
3474 @node Tags, Agenda views, Timestamps, Top
3475 @chapter Tags
3476 @cindex tags
3477 @cindex headline tagging
3478 @cindex matching, tags
3479 @cindex sparse tree, tag based
3481 If you wish to implement a system of labels and contexts for
3482 cross-correlating information, an excellent way is to assign @i{tags} to
3483 headlines.  Org-mode has extensive support for using tags.
3485 Every headline can contain a list of tags, at the end of the headline.
3486 Tags are normal words containing letters, numbers, @samp{_}, and
3487 @samp{@@}.  Tags must be preceded and followed by a single colon; like
3488 @samp{:WORK:}.  Several tags can be specified like @samp{:WORK:URGENT:}.
3490 @menu
3491 * Tag inheritance::             Tags use the tree structure of the outline
3492 * Setting tags::                How to assign tags to a headline
3493 * Tag searches::                Searching for combinations of tags
3494 @end menu
3496 @node Tag inheritance, Setting tags, Tags, Tags
3497 @section Tag inheritance
3498 @cindex inheritance, of tags
3499 @cindex sublevels, inclusion into tags match
3501 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3502 heading has a certain tag, all subheadings will inherit the tag as
3503 well.  For example, in the list
3505 @example
3506 * Meeting with the French group      :WORK:
3507 ** Summary by Frank                  :BOSS:NOTES:
3508 *** TODO Prepare slides for him      :ACTION:
3509 @end example
3511 @noindent
3512 the final heading will have the tags @samp{:WORK:}, @samp{:BOSS:},
3513 @samp{:NOTES:}, and @samp{:ACTION:}.  When executing tag searches and
3514 Org-mode finds that a certain headline matches the search criterion, it
3515 will not check any sublevel headline, assuming that these likely also
3516 match, and that the list of matches can become very long.  This may
3517 not be what you want, however, and you can influence inheritance and
3518 searching using the variables @code{org-use-tag-inheritance} and
3519 @code{org-tags-match-list-sublevels}.
3521 @node Setting tags, Tag searches, Tag inheritance, Tags
3522 @section Setting tags
3523 @cindex setting tags
3524 @cindex tags, setting
3526 @kindex M-@key{TAB}
3527 Tags can simply be typed into the buffer at the end of a headline.
3528 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3529 also a special command for inserting tags:
3531 @table @kbd
3532 @kindex C-c C-c
3533 @item C-c C-c
3534 @cindex completion, of tags
3535 Enter new tags for the current headline.  Org-mode will either offer
3536 completion or a special single-key interface for setting tags, see
3537 below.  After pressing @key{RET}, the tags will be inserted and aligned
3538 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3539 tags in the current buffer will be aligned to that column, just to make
3540 things look nice.  TAGS are automatically realigned after promotion,
3541 demotion, and TODO state changes (@pxref{TODO basics}).
3542 @end table
3544 Org will support tag insertion based on a @emph{list of tags}.  By
3545 default this list is constructed dynamically, containing all tags
3546 currently used in the buffer.  You may also globally specify a hard list
3547 of tags with the variable @code{org-tag-alist}.  Finally you can set
3548 the default tags for a given file with lines like
3550 @example
3551 #+TAGS: @@WORK @@HOME @@TENNISCLUB
3552 #+TAGS: Laptop Car PC Sailboat
3553 @end example
3555 If you have globally defined your preferred set of tags using the
3556 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3557 in a specific file: Just add an empty TAGS option line to that file:
3559 @example
3560 #+TAGS:
3561 @end example
3563 The default support method for entering tags is minibuffer completion.
3564 However, Org-mode also implements a much better method: @emph{fast tag
3565 selection}.  This method allows to select and deselect tags with a
3566 single key per tag.  To function efficiently, you should assign unique
3567 keys to most tags.  This can be done globally with
3569 @lisp
3570 (setq org-tag-alist '(("@@WORK" . ?w) ("@@HOME" . ?h) ("Laptop" . ?l)))
3571 @end lisp
3573 @noindent or on a per-file basis with
3575 @example
3576 #+TAGS: @@WORK(w)  @@HOME(h)  @@TENNISCLUB(t)  Laptop(l)  PC(p)
3577 @end example
3579 @noindent
3580 You can also group together tags that are mutually exclusive.  With
3581 curly braces@footnote{In @code{org-mode-alist} use
3582 @code{'(:startgroup)} and @code{'(:endgroup)}, respectively.  Several
3583 groups are allowed.}
3585 @example
3586 #+TAGS: @{ @@WORK(w)  @@HOME(h)  @@TENNISCLUB(t) @}  Laptop(l)  PC(p)
3587 @end example
3589 @noindent you indicate that at most one of @samp{@@WORK}, @samp{@@HOME},
3590 and @samp{@@TENNISCLUB} should be selected.
3592 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3593 these lines to activate any changes.
3595 If at least one tag has a selection key, pressing @kbd{C-c C-c} will
3596 automatically present you with a special interface, listing inherited
3597 tags, the tags of the current headline, and a list of all legal tags
3598 with corresponding keys@footnote{Keys will automatically be assigned to
3599 tags which have no configured keys.}.  In this interface, you can use
3600 the following keys:
3602 @table @kbd
3603 @item a-z...
3604 Pressing keys assigned to tags will add or remove them from the list of
3605 tags in the current line.  Selecting a tag in a group of mutually
3606 exclusive tags will turn off any other tags from that group.
3607 @kindex @key{TAB}
3608 @item @key{TAB}
3609 Enter a tag in the minibuffer, even if the tag is not in the predefined
3610 list.  You will be able to complete on all tags present in the buffer.
3611 @kindex @key{SPC}
3612 @item @key{SPC}
3613 Clear all tags for this line.
3614 @kindex @key{RET}
3615 @item @key{RET}
3616 Accept the modified set.
3617 @item C-g
3618 Abort without installing changes.
3619 @item q
3620 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3621 @item !
3622 Turn off groups of mutually exclusive tags.  Use this to (as an
3623 exception) assign several tags from such a group.
3624 @item C-c
3625 Toggle auto-exit after the next change (see below).
3626 If you are using expert mode, the first @kbd{C-c} will display the
3627 selection window.
3628 @end table
3630 @noindent
3631 This method lets you assign tags to a headline with very few keys.  With
3632 the above setup, you could clear the current tags and set @samp{@@HOME},
3633 @samp{Laptop} and @samp{PC} tags with just the following keys: @kbd{C-c
3634 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@HOME} to
3635 @samp{@@WORK} would be done with @kbd{C-c C-c w @key{RET}} or
3636 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3637 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3638 @key{RET} @key{RET}}.
3640 If you find that most of the time, you need only a single keypress to
3641 modify your list of tags, set the variable
3642 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3643 press @key{RET} to exit fast tag selection - it will immediately exit
3644 after the first change.  If you then occasionally need more keys, press
3645 @kbd{C-c} to turn off auto-exit for the current tag selection process
3646 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
3647 C-c}).  If you set the variable to the value @code{expert}, the special
3648 window is not even shown for single-key tag selection, it comes up only
3649 when you press an extra @kbd{C-c}.
3651 @node Tag searches,  , Setting tags, Tags
3652 @section Tag searches
3653 @cindex tag searches
3654 @cindex searching for tags
3656 Once a tags system has been set up, it can be used to collect related
3657 information into special lists.
3659 @table @kbd
3660 @kindex C-c \
3661 @item C-c \
3662 Create a sparse tree with all headlines matching a tags search.  With a
3663 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
3664 @kindex C-c a m
3665 @item C-c a m
3666 Create a global list of tag matches from all agenda files.
3667 @xref{Matching headline tags}.
3668 @kindex C-c a M
3669 @item C-c a M
3670 Create a global list of tag matches from all agenda files, but check
3671 only TODO items and force checking subitems (see variable
3672 @code{org-tags-match-list-sublevels}).
3673 @end table
3675 @cindex Boolean logic, for tag searches
3676 A @i{tags} search string can use Boolean operators @samp{&} for AND and
3677 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
3678 Parenthesis are currently not implemented.  A tag may also be preceded
3679 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
3680 positive selection.  The AND operator @samp{&} is optional when @samp{+}
3681 or @samp{-} is present.  Examples:
3683 @table @samp
3684 @item +WORK-BOSS
3685 Select headlines tagged @samp{:WORK:}, but discard those also tagged
3686 @samp{:BOSS:}.
3687 @item WORK|LAPTOP
3688 Selects lines tagged @samp{:WORK:} or @samp{:LAPTOP:}.
3689 @item WORK|LAPTOP&NIGHT
3690 Like before, but require the @samp{:LAPTOP:} lines to be tagged also
3691 @samp{NIGHT}.
3692 @end table
3694 @cindex TODO keyword matching, with tags search
3695 If you are using multi-state TODO keywords (@pxref{TODO extensions}), it
3696 can be useful to also match on the TODO keyword.  This can be done by
3697 adding a condition after a slash to a tags match.  The syntax is similar
3698 to the tag matches, but should be applied with consideration: For
3699 example, a positive selection on several TODO keywords can not
3700 meaningfully be combined with boolean AND.  However, @emph{negative
3701 selection} combined with AND can be meaningful.  To make sure that only
3702 lines are checked that actually have any TODO keyword, use @kbd{C-c a
3703 M}, or equivalently start the todo part after the slash with @samp{!}.
3704 Examples:
3706 @table @samp
3707 @item WORK/WAITING
3708 Select @samp{:WORK:}-tagged TODO lines with the specific TODO
3709 keyword @samp{WAITING}.
3710 @item WORK/!-WAITING-NEXT
3711 Select @samp{:WORK:}-tagged TODO lines that are neither @samp{WAITING}
3712 nor @samp{NEXT}
3713 @item WORK/+WAITING|+NEXT
3714 Select @samp{:WORK:}-tagged TODO lines that are either @samp{WAITING} or
3715 @samp{NEXT}.
3716 @end table
3718 @cindex regular expressions, with tags search
3719 Any element of the tag/todo match can be a regular expression - in this
3720 case it must be enclosed in curly braces.  For example,
3721 @samp{WORK+@{^BOSS.*@}} matches headlines that contain the tag
3722 @samp{WORK} and any tag @i{starting} with @samp{BOSS}.
3724 @cindex level, require for tags match
3725 You can also require a headline to be of a certain level, by writing
3726 instead of any TAG an expression like @samp{LEVEL=3}.  For example, a
3727 search @samp{+LEVEL=3+BOSS/-DONE} lists all level three headlines that
3728 have the tag BOSS and are @emph{not} marked with the todo keyword DONE.
3730 @node Agenda views, Embedded LaTeX, Tags, Top
3731 @chapter Agenda Views
3732 @cindex agenda views
3734 Due to the way Org-mode works, TODO items, time-stamped items, and
3735 tagged headlines can be scattered throughout a file or even a number of
3736 files.  To get an overview over open action items, or over events that
3737 are important for a particular date, this information must be collected,
3738 sorted and displayed in an organized way.
3740 Org-mode can select items based on various criteria, and display them
3741 in a separate buffer.  Six different view types are provided:
3743 @itemize @bullet
3744 @item
3745 an @emph{agenda} that is like a calendar and shows information
3746 for specific dates,
3747 @item
3748 a @emph{TODO list} that covers all unfinished
3749 action items,
3750 @item
3751 a @emph{tags view}, showings headlines based on
3752 the tags associated with them,
3753 @item
3754 a @emph{timeline view} that shows all events in a single Org-mode file,
3755 in time-sorted view,
3756 @item
3757 a @emph{stuck projects view} showing projects that currently don't move
3758 along, and
3759 @item
3760 @emph{custom views} that are special tag/keyword searches and
3761 combinations of different views.
3762 @end itemize
3764 @noindent
3765 The extracted information is displayed in a special @emph{agenda
3766 buffer}.  This buffer is read-only, but provides commands to visit the
3767 corresponding locations in the original Org-mode files, and even to
3768 edit these files remotely.  
3770 Two variables control how the agenda buffer is displayed and whether the
3771 window configuration is restored when the agenda exits:
3772 @code{org-agenda-window-setup} and
3773 @code{org-agenda-restore-windows-after-quit}.
3775 @menu
3776 * Agenda files::                Files being searched for agenda information
3777 * Agenda dispatcher::           Keyboard access to agenda views
3778 * Built-in agenda views::       What is available out of the box?
3779 * Presentation and sorting::    How agenda items are prepared for display
3780 * Agenda commands::             Remote editing of org trees
3781 * Custom agenda views::         Defining special searches and views
3782 @end menu
3784 @node Agenda files, Agenda dispatcher, Agenda views, Agenda views
3785 @section Agenda files
3786 @cindex agenda files
3787 @cindex files for agenda
3789 The information to be shown is collected from all @emph{agenda files},
3790 the files listed in the variable @code{org-agenda-files}@footnote{If the
3791 value of that variable is not a list, but a single file name, then the
3792 list of agenda files will be maintained in that external file.}.  Thus even
3793 if you only work with a single Org-mode file, this file should be put
3794 into that list@footnote{When using the dispatcher, pressing @kbd{1}
3795 before selecting a command will actually limit the command to the
3796 current file, and ignore @code{org-agenda-files} until the next
3797 dispatcher command.}.  You can customize @code{org-agenda-files}, but
3798 the easiest way to maintain it is through the following commands
3800 @cindex files, adding to agenda list
3801 @table @kbd
3802 @kindex C-c [
3803 @item C-c [
3804 Add current file to the list of agenda files.  The file is added to
3805 the front of the list.  If it was already in the list, it is moved to
3806 the front.  With prefix arg, file is added/moved to the end.
3807 @kindex C-c ]
3808 @item C-c ]
3809 Remove current file from the list of agenda files.
3810 @kindex C-,
3811 @kindex C-'
3812 @item C-,
3813 @itemx C-'
3814 Cycle through agenda file list, visiting one file after the other.
3815 @end table
3817 @noindent
3818 The Org menu contains the current list of files and can be used
3819 to visit any of them.
3821 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda views
3822 @section The agenda dispatcher
3823 @cindex agenda dispatcher
3824 @cindex dispatching agenda commands
3825 The views are created through a dispatcher that should be bound to a
3826 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
3827 following we will assume that @kbd{C-c a} is indeed how the dispatcher
3828 is accessed and list keyboard access to commands accordingly.  After
3829 pressing @kbd{C-c a}, an additional letter is required to execute a
3830 command.  The dispatcher offers the following default commands:
3831 @table @kbd
3832 @item a
3833 Create the calendar-like agenda (@pxref{Weekly/Daily agenda}).
3834 @item t @r{/} T
3835 Create a list of all TODO items (@pxref{Global TODO list}).
3836 @item m @r{/} M
3837 Create a list of headlines matching a TAGS expression (@pxref{Matching
3838 headline tags}).
3839 @item L
3840 Create the timeline view for the current buffer (@pxref{Timeline}).
3841 @item # @r{/} !
3842 Create a list of stuck projects (@pxref{Stuck projects}).
3843 @item 1
3844 Restrict an agenda command to the current buffer.  After pressing
3845 @kbd{1}, you still need to press the character selecting the command.
3846 @item 0
3847 If there is an active region, restrict the following agenda command to
3848 the region.  Otherwise, restrict it to the current subtree.  After
3849 pressing @kbd{0}, you still need to press the character selecting the
3850 command.
3851 @end table
3853 You can also define custom commands that will be accessible through the
3854 dispatcher, just like the default commands.  This includes the
3855 possibility to create extended agenda buffers that contain several
3856 blocks together, for example the weekly agenda, the global TODO list and
3857 a number of special tags matches.  @xref{Custom agenda views}.
3859 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda views
3860 @section The built-in agenda views
3862 In this section we describe the built-in views.
3864 @menu
3865 * Weekly/Daily agenda::         The calendar page with current tasks
3866 * Global TODO list::            All unfinished action items
3867 * Matching headline tags::      Structured information with fine-tuned search
3868 * Timeline::                    Time-sorted view for single file
3869 * Stuck projects::              Find projects you need to review
3870 @end menu
3872 @node Weekly/Daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
3873 @subsection The weekly/daily agenda
3874 @cindex agenda
3875 @cindex weekly agenda
3876 @cindex daily agenda
3878 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
3879 paper agenda, showing all the tasks for the current week or day.
3881 @table @kbd
3882 @cindex org-agenda, command
3883 @kindex C-c a a
3884 @item C-c a a
3885 Compile an agenda for the current week from a list of org files.  The
3886 agenda shows the entries for each day.  With a @kbd{C-u} prefix (or
3887 when the variable @code{org-agenda-include-all-todo} is @code{t}), all
3888 unfinished TODO items (including those without a date) are also listed at
3889 the beginning of the buffer, before the first date.@*
3890 @end table
3892 Remote editing from the agenda buffer means, for example, that you can
3893 change the dates of deadlines and appointments from the agenda buffer.
3894 The commands available in the Agenda buffer are listed in @ref{Agenda
3895 commands}.
3897 @subsubheading Calendar/Diary integration
3898 @cindex calendar integration
3899 @cindex diary integration
3901 Emacs contains the calendar and diary by Edward M. Reingold.  The
3902 calendar displays a three-month calendar with holidays from different
3903 countries and cultures.  The diary allows you to keep track of
3904 anniversaries, lunar phases, sunrise/set, recurrent appointments
3905 (weekly, monthly) and more.  In this way, it is quite complementary to
3906 Org-mode.  It can be very useful to combine output from Org-mode with
3907 the diary.
3909 In order to include entries from the Emacs diary into Org-mode's
3910 agenda, you only need to customize the variable
3912 @lisp
3913 (setq org-agenda-include-diary t)
3914 @end lisp
3916 @noindent After that, everything will happen automatically.  All diary
3917 entries including holidays, anniversaries etc will be included in the
3918 agenda buffer created by Org-mode.  @key{SPC}, @key{TAB}, and
3919 @key{RET} can be used from the agenda buffer to jump to the diary
3920 file in order to edit existing diary entries.  The @kbd{i} command to
3921 insert new entries for the current date works in the agenda buffer, as
3922 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
3923 Sunrise/Sunset times, show lunar phases and to convert to other
3924 calendars, respectively.  @kbd{c} can be used to switch back and forth
3925 between calendar and agenda.
3927 If you are using the diary only for sexp entries and holidays, it is
3928 faster to not use the above setting, but instead to copy or even move
3929 the entries into an Org-mode file. Org-mode evaluates diary-style sexp
3930 entries, and does it faster because there is no overhead for first
3931 creating the diary display.  Note that the sexp entries must start at
3932 the left margin, no white space is allowed before them.  For example,
3933 the following segment of an Org-mode file will be processed and entries
3934 will be made in the agenda:
3936 @example
3937 * Birthdays and similar stuff
3938 #+CATEGORY: Holiday
3939 %%(org-calendar-holiday)   ; special function for holiday names
3940 #+CATEGORY: Ann
3941 %%(diary-anniversary 14  5 1956) Artur Dent %d is years old
3942 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
3943 @end example
3945 @node Global TODO list, Matching headline tags, Weekly/Daily agenda, Built-in agenda views
3946 @subsection The global TODO list
3947 @cindex global TODO list
3948 @cindex TODO list, global
3950 The global TODO list contains all unfinished TODO items, formatted and
3951 collected into a single place.
3953 @table @kbd
3954 @kindex C-c a t
3955 @item C-c a t
3956 Show the global TODO list.  This collects the TODO items from all
3957 agenda files (@pxref{Agenda views}) into a single buffer.  The buffer is in
3958 @code{agenda-mode}, so there are commands to examine and manipulate
3959 the TODO entries directly from that buffer (@pxref{Agenda commands}).
3960 @kindex C-c a T
3961 @item C-c a T
3962 @cindex TODO keyword matching
3963 Like the above, but allows selection of a specific TODO keyword.  You
3964 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
3965 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
3966 specify several keywords by separating them with @samp{|} as boolean OR
3967 operator.  With a numeric prefix, the Nth keyword in
3968 @code{org-todo-keywords} is selected.
3969 @kindex r
3970 The @kbd{r} key in the agenda buffer regenerates it, and you can give
3971 a prefix argument to this command to change the selected TODO keyword,
3972 for example @kbd{3 r}.  If you often need a search for a specific
3973 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
3974 Matching specific TODO keywords can also be done as part of a tags
3975 search (@pxref{Tag searches}).
3976 @end table
3978 Remote editing of TODO items means that you can change the state of a
3979 TODO entry with a single key press.  The commands available in the
3980 TODO list are described in @ref{Agenda commands}.
3982 @cindex sublevels, inclusion into todo list
3983 Normally the global todo list simply shows all headlines with TODO
3984 keywords.  This list can become very long.  There are two ways to keep
3985 it more compact:
3986 @itemize @minus
3987 @item
3988 Some people view a TODO item that has been @emph{scheduled} for
3989 execution (@pxref{Time stamps}) as no longer @emph{open}.  Configure the
3990 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
3991 items from the global TODO list.
3992 @item
3993 TODO items may have sublevels to break up the task into subtasks.  In
3994 such cases it may be enough to list only the highest level TODO headline
3995 and omit the sublevels from the global list.  Configure the variable
3996 @code{org-agenda-todo-list-sublevels} to get this behavior.
3997 @end itemize
3999 @node Matching headline tags, Timeline, Global TODO list, Built-in agenda views
4000 @subsection Matching headline tags
4001 @cindex matching, of tags
4002 @cindex tags view
4004 If headlines in the agenda files are marked with @emph{tags}
4005 (@pxref{Tags}), you can select headlines based on the tags that apply
4006 to them and collect them into an agenda buffer.
4008 @table @kbd
4009 @kindex C-c a m
4010 @item C-c a m
4011 Produce a list of all headlines that match a given set of tags.  The
4012 command prompts for a selection criterion, which is a boolean logic
4013 expression with tags, like @samp{+WORK+URGENT-WITHBOSS} or
4014 @samp{WORK|HOME} (@pxref{Tags}).  If you often need a specific search,
4015 define a custom command for it (@pxref{Agenda dispatcher}).
4016 @kindex C-c a M
4017 @item C-c a M
4018 Like @kbd{C-c a m}, but only select headlines that are also TODO items
4019 and force checking subitems (see variable
4020 @code{org-tags-match-list-sublevels}).  Matching specific todo keywords
4021 together with a tags match is also possible, see @ref{Tag searches}.
4022 @end table
4024 The commands available in the tags list are described in @ref{Agenda
4025 commands}.
4027 @node Timeline, Stuck projects, Matching headline tags, Built-in agenda views
4028 @subsection Timeline for a single file
4029 @cindex timeline, single file
4030 @cindex time-sorted view
4032 The timeline summarizes all time-stamped items from a single Org-mode
4033 file in a @emph{time-sorted view}.  The main purpose of this command is
4034 to give an overview over events in a project.
4036 @table @kbd
4037 @kindex C-a a L
4038 @item C-c a L
4039 Show a time-sorted view of the org file, with all time-stamped items.
4040 When called with a @kbd{C-u} prefix, all unfinished TODO entries
4041 (scheduled or not) are also listed under the current date.
4042 @end table
4044 @noindent
4045 The commands available in the timeline buffer are listed in
4046 @ref{Agenda commands}.
4049 @node Stuck projects,  , Timeline, Built-in agenda views
4050 @subsection Stuck projects
4052 If you are following a system like David Allen's GTD to organize your
4053 work, one of the ``duties'' you have is a regular review to make sure
4054 that all projects move along.  A @emph{stuck} project is a project that
4055 has no defined next actions, so it will never show up in the TODO lists
4056 Org-mode produces.  During the review, you need to identify such
4057 projects and define next actions for them.
4059 @table @kbd
4060 @kindex C-c a #
4061 @item C-c a #
4062 List projects that are stuck.
4063 @kindex C-c a !
4064 @item C-c a !
4065 Customize the variable @code{org-stuck-projects} to define what a stuck
4066 project is and how to find it.
4067 @end table
4069 You almost certainly will have to configure this view before it will
4070 work for you.  The built-in default assumes that all your projects are
4071 level-2 headlines, and that a project is not stuck if it has at least
4072 one entry marked with a todo keyword TODO or NEXT or NEXTACTION.
4074 Lets assume that you, in your own way of using Org-mode, identify
4075 projects with a tag PROJECT, and that you use a todo keyword MAYBE to
4076 indicate a project that should not be considered yet.  Lets further
4077 assume that the todo keyword DONE marks finished projects, and that NEXT
4078 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
4079 is a next action even without the NEXT tag.  Finally, if the project
4080 contains the special word IGNORE anywhere, it should not be listed
4081 either.  In this case you would start by identifying eligible projects
4082 with a tags/todo match @samp{+PROJECT/-MAYBE-DONE}, and then check for
4083 TODO, NEXT, @@SHOP, and IGNORE in the subtree to identify projects that
4084 are not stuck.  The correct customization for this is
4086 @lisp
4087 (setq org-stuck-projects
4088       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
4089                                "\\<IGNORE\\>"))
4090 @end lisp
4093 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda views
4094 @section Presentation and sorting
4095 @cindex presentation, of agenda items
4097 Before displaying items in an agenda view, Org-mode visually prepares
4098 the items and sorts them.  Each item occupies a single line.  The line
4099 starts with a @emph{prefix} that contains the @emph{category}
4100 (@pxref{Categories}) of the item and other important information.  You can
4101 customize the prefix using the option @code{org-agenda-prefix-format}.
4102 The prefix is followed by a cleaned-up version of the outline headline
4103 associated with the item.
4105 @menu
4106 * Categories::                  Not all tasks are equal
4107 * Time-of-day specifications::  How the agenda knows the time
4108 * Sorting of agenda items::     The order of things
4109 @end menu
4111 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
4112 @subsection Categories
4114 @cindex category
4115 The category is a broad label assigned to each agenda item.  By default,
4116 the category is simply derived from the file name, but you can also
4117 specify it with a special line in the buffer, like this:
4119 @example
4120 #+CATEGORY: Thesis
4121 @end example
4123 If there are several such lines in a file, each specifies the category
4124 for the text below it (but the first category also applies to any text
4125 before the first CATEGORY line).  The display in the agenda buffer looks
4126 best if the category is not longer than 10 characters.
4128 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
4129 @subsection Time-of-Day Specifications
4130 @cindex time-of-day specification
4132 Org-mode checks each agenda item for a time-of-day specification.  The
4133 time can be part of the time stamp that triggered inclusion into the
4134 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
4135 ranges can be specified with two time stamps, like
4137 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
4139 In the headline of the entry itself, a time(range) may also appear as
4140 plain text (like @samp{12:45} or a @samp{8:30-1pm}.  If the agenda
4141 integrates the Emacs diary (@pxref{Weekly/Daily agenda}), time
4142 specifications in diary entries are recognized as well.
4144 For agenda display, Org-mode extracts the time and displays it in a
4145 standard 24 hour format as part of the prefix.  The example times in
4146 the previous paragraphs would end up in the agenda like this:
4148 @example
4149     8:30-13:00 Arthur Dent lies in front of the bulldozer
4150    12:45...... Ford Prefect arrives and takes Arthur to the pub
4151    19:00...... The Vogon reads his poem
4152    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
4153 @end example
4155 @cindex time grid
4156 If the agenda is in single-day mode, or for the display of today, the
4157 timed entries are embedded in a time grid, like
4159 @example
4160     8:00...... ------------------
4161     8:30-13:00 Arthur Dent lies in front of the bulldozer
4162    10:00...... ------------------
4163    12:00...... ------------------
4164    12:45...... Ford Prefect arrives and takes Arthur to the pub
4165    14:00...... ------------------
4166    16:00...... ------------------
4167    18:00...... ------------------
4168    19:00...... The Vogon reads his poem
4169    20:00...... ------------------
4170    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
4171 @end example
4173 The time grid can be turned on and off with the variable
4174 @code{org-agenda-use-time-grid}, and can be configured with
4175 @code{org-agenda-time-grid}.
4177 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
4178 @subsection Sorting of agenda items
4179 @cindex sorting, of agenda items
4180 @cindex priorities, of agenda items
4181 Before being inserted into a view, the items are sorted.  How this is
4182 done depends on the type of view.
4183 @itemize @bullet
4184 @item
4185 For the daily/weekly agenda, the items for each day are sorted.  The
4186 default order is to first collect all items containing an explicit
4187 time-of-day specification.  These entries will be shown at the beginning
4188 of the list, as a @emph{schedule} for the day.  After that, items remain
4189 grouped in categories, in the sequence given by @code{org-agenda-files}.
4190 Within each category, items are sorted by priority (@pxref{Priorities}),
4191 which is composed of the base priority (2000 for priority @samp{A}, 1000
4192 for @samp{B}, and 0 for @samp{C}), plus additional increments for
4193 overdue scheduled or deadline items.
4194 @item 
4195 For the TODO list, items remain in the order of categories, but within
4196 each category, sorting takes place according to priority
4197 (@pxref{Priorities}).
4198 @item
4199 For tags matches, items are not sorted at all, but just appear in the
4200 sequence in which they are found in the agenda files.
4201 @end itemize
4203 Sorting can be customized using the variable
4204 @code{org-agenda-sorting-strategy}.
4207 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda views
4208 @section Commands in the agenda buffer
4209 @cindex commands, in agenda buffer
4211 Entries in the agenda buffer are linked back to the org file or diary
4212 file where they originate.  You are not allowed to edit the agenda
4213 buffer itself, but commands are provided to show and jump to the
4214 original entry location, and to edit the org-files ``remotely'' from
4215 the agenda buffer.  In this way, all information is stored only once,
4216 removing the risk that your agenda and note files may diverge.
4218 Some commands can be executed with mouse clicks on agenda lines.  For
4219 the other commands, the cursor needs to be in the desired line.
4221 @table @kbd
4222 @tsubheading{Motion}
4223 @cindex motion commands in agenda
4224 @kindex n
4225 @item n
4226 Next line (same as @key{up}).
4227 @kindex p
4228 @item p
4229 Previous line (same as @key{down}).
4230 @tsubheading{View/GoTo org file}
4231 @kindex mouse-3
4232 @kindex @key{SPC}
4233 @item mouse-3
4234 @itemx @key{SPC}
4235 Display the original location of the item in another window.
4237 @kindex L
4238 @item L
4239 Display original location and recenter that window.
4241 @kindex mouse-2
4242 @kindex mouse-1
4243 @kindex @key{TAB}
4244 @item mouse-2
4245 @itemx mouse-1
4246 @itemx @key{TAB}
4247 Go to the original location of the item in another window.  Under Emacs
4248 22, @kbd{mouse-1} will also works for this.
4250 @kindex @key{RET}
4251 @itemx @key{RET}
4252 Go to the original location of the item and delete other windows.
4254 @kindex f
4255 @item f
4256 Toggle Follow mode.  In Follow mode, as you move the cursor through
4257 the agenda buffer, the other window always shows the corresponding
4258 location in the org file.  The initial setting for this mode in new
4259 agenda buffers can be set with the variable
4260 @code{org-agenda-start-with-follow-mode}.
4262 @kindex b
4263 @item b
4264 Display the entire subtree of the current item in an indirect buffer.
4265 With numerical prefix ARG, go up to this level and then take that tree.
4266 If ARG is negative, go up that many levels.  With @kbd{C-u} prefix, do
4267 not remove the previously used indirect buffer.
4269 @kindex l
4270 @item l
4271 Toggle Logbook mode.  In Logbook mode, entries that where marked DONE while
4272 logging was on (variable @code{org-log-done}) are shown in the agenda,
4273 as are entries that have been clocked on that day.
4275 @tsubheading{Change display}
4276 @cindex display changing, in agenda
4277 @kindex o
4278 @item o
4279 Delete other windows.
4281 @kindex w
4282 @item w
4283 Switch to weekly view (7 days displayed together).
4285 @kindex d
4286 @item d
4287 Switch to daily view (just one day displayed).
4289 @kindex D
4290 @item D
4291 Toggle the inclusion of diary entries.  See @ref{Weekly/Daily agenda}.
4293 @kindex g
4294 @item g
4295 Toggle the time grid on and off.  See also the variables
4296 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
4298 @kindex r
4299 @item r
4300 Recreate the agenda buffer, for example to reflect the changes
4301 after modification of the time stamps of items with S-@key{left} and
4302 S-@key{right}.  When the buffer is the global todo list, a prefix
4303 argument is interpreted to create a selective list for a specific TODO
4304 keyword.
4306 @kindex s
4307 @item s
4308 Save all Org-mode buffers in the current Emacs session.
4310 @kindex @key{right}
4311 @item @key{right}
4312 Display the following @code{org-agenda-ndays} days.  For example, if
4313 the display covers a week, switch to the following week.  With prefix
4314 arg, go forward that many times @code{org-agenda-ndays} days.
4316 @kindex @key{left}
4317 @item @key{left}
4318 Display the previous dates.
4320 @kindex .
4321 @item .
4322 Goto today.
4324 @tsubheading{Remote editing}
4325 @cindex remote editing, from agenda
4327 @item 0-9
4328 Digit argument.
4330 @cindex undoing remote-editing events
4331 @cindex remote editing, undo
4332 @kindex C-_
4333 @item C-_
4334 Undo a change due to a remote editing command.  The change is undone
4335 both in the agenda buffer and in the remote buffer.
4337 @kindex t
4338 @item t
4339 Change the TODO state of the item, both in the agenda and in the
4340 original org file.
4342 @kindex C-k
4343 @item C-k
4344 Delete the current agenda item along with the entire subtree belonging
4345 to it in the original Org-mode file.  If the text to be deleted remotely
4346 is longer than one line, the kill needs to be confirmed by the user.  See
4347 variable @code{org-agenda-confirm-kill}.
4349 @kindex $
4350 @item $
4351 Archive the subtree corresponding to the current headline.
4353 @kindex T
4354 @item T
4355 Show all tags associated with the current item.  Because of
4356 inheritance, this may be more than the tags listed in the line itself.
4358 @kindex :
4359 @item :
4360 Set tags for the current headline.
4362 @kindex a
4363 @item a
4364 Toggle the ARCHIVE tag for the current headline.
4366 @kindex ,
4367 @item ,
4368 Set the priority for the current item.  Org-mode prompts for the
4369 priority character. If you reply with @key{SPC}, the priority cookie
4370 is removed from the entry.
4372 @kindex P
4373 @item P
4374 Display weighted priority of current item.
4376 @kindex +
4377 @kindex S-@key{up}
4378 @item +
4379 @itemx S-@key{up}
4380 Increase the priority of the current item.  The priority is changed in
4381 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
4382 key for this.
4384 @kindex -
4385 @kindex S-@key{down}
4386 @item -
4387 @itemx S-@key{down}
4388 Decrease the priority of the current item.
4390 @kindex C-c C-s
4391 @item C-c C-s
4392 Schedule this item
4394 @kindex C-c C-d
4395 @item C-c C-d
4396 Set a deadline for this item.
4398 @kindex S-@key{right}
4399 @item S-@key{right}
4400 Change the time stamp associated with the current line by one day into
4401 the future.  With prefix argument, change it by that many days.  For
4402 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The
4403 stamp is changed in the original org file, but the change is not
4404 directly reflected in the agenda buffer.  Use the
4405 @kbd{r} key to update the buffer.
4407 @kindex S-@key{left}
4408 @item S-@key{left}
4409 Change the time stamp associated with the current line by one day
4410 into the past.
4412 @kindex >
4413 @item >
4414 Change the time stamp associated with the current line to today.
4415 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
4416 on my keyboard.
4418 @kindex I
4419 @item I
4420 Start the clock on the current item.  If a clock is running already, it
4421 is stopped first.
4423 @kindex O
4424 @item O
4425 Stop the previously started clock.
4427 @kindex X
4428 @item X
4429 Cancel the currently running clock.
4431 @tsubheading{Calendar commands}
4432 @cindex calendar commands, from agenda
4433 @kindex c
4434 @item c
4435 Open the Emacs calendar and move to the date at the agenda cursor.
4437 @item c
4438 When in the calendar, compute and show the Org-mode agenda for the
4439 date at the cursor.
4441 @cindex diary entries, creating from agenda
4442 @kindex i
4443 @item i
4444 Insert a new entry into the diary.  Prompts for the type of entry
4445 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
4446 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
4447 The date is taken from the cursor position.
4449 @kindex M
4450 @item M
4451 Show the phases of the moon for the three months around current date.
4453 @kindex S
4454 @item S
4455 Show sunrise and sunset times.  The geographical location must be set
4456 with calendar variables, see documentation of the Emacs calendar.
4458 @kindex C
4459 @item C
4460 Convert the date at cursor into many other cultural and historic
4461 calendars.
4463 @kindex H
4464 @item H
4465 Show holidays for three month around the cursor date.
4467 @c FIXME:  This should be a different key.
4468 @kindex C-c C-x C-c
4469 @item C-c C-x C-c
4470 Export a single iCalendar file containing entries from all agenda files.
4472 @tsubheading{Exporting to a file}
4473 @kindex C-x C-w
4474 @item C-x C-w
4475 @cindex exporting agenda views
4476 @cindex agenda views, exporting
4477 Write the agenda view to a file.  Depending on the extension of the
4478 selected file name, the view will be exported as HTML (extension
4479 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
4480 plain text (any other extension).  Use the variable
4481 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
4482 and for @file{htmlize} to be used during export.
4484 @tsubheading{Quit and Exit}
4485 @kindex q
4486 @item q
4487 Quit agenda, remove the agenda buffer.
4489 @kindex x
4490 @cindex agenda files, removing buffers
4491 @item x
4492 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
4493 for the compilation of the agenda.  Buffers created by the user to
4494 visit org files will not be removed.
4495 @end table
4498 @node Custom agenda views,  , Agenda commands, Agenda views
4499 @section Custom agenda views
4500 @cindex custom agenda views
4501 @cindex agenda views, custom
4503 Custom agenda commands serve two purposes: to store and quickly access
4504 frequently used TODO and tags searches, and to create special composite
4505 agenda buffers.  Custom agenda commands will be accessible through the
4506 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
4508 @menu
4509 * Storing searches::            Type once, use often
4510 * Block agenda::                All the stuff you need in a single buffer
4511 * Setting Options::             Changing the rules
4512 * Exporting Agenda Views::      Writing agendas to files.
4513 * Extracting Agenda Information for other programs::  
4514 @end menu
4516 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
4517 @subsection Storing searches
4519 The first application of custom searches is the definition of keyboard
4520 shortcuts for frequently used searches, either creating an agenda
4521 buffer, or a sparse tree (the latter covering of course only the current
4522 buffer).
4523 @kindex C-c a C
4524 Custom commands are configured in the variable
4525 @code{org-agenda-custom-commands}.  You can customize this variable, for
4526 example by pressing @kbd{C-c a C}.  You can also directly set it with
4527 Emacs Lisp in @file{.emacs}.  The following example contains all valid
4528 search types:
4530 @lisp
4531 @group
4532 (setq org-agenda-custom-commands
4533       '(("w" todo "WAITING")
4534         ("W" todo-tree "WAITING")
4535         ("u" tags "+BOSS-URGENT")
4536         ("v" tags-todo "+BOSS-URGENT")
4537         ("U" tags-tree "+BOSS-URGENT")
4538         ("f" occur-tree "\\<FIXME\\>")))
4539 @end group
4540 @end lisp
4542 @noindent
4543 The initial single-character string in each entry defines the character
4544 you have to press after the dispatcher command @kbd{C-c a} in order to
4545 access the command.   The second parameter is the search type, followed
4546 by the string or regular expression to be used for the matching.  The
4547 example above will therefore define:
4549 @table @kbd
4550 @item C-c a w
4551 as a global search for TODO entries with @samp{WAITING} as the TODO
4552 keyword
4553 @item C-c a W
4554 as the same search, but only in the current buffer and displaying the
4555 results as a sparse tree
4556 @item C-c a u
4557 as a global tags search for headlines marked @samp{:BOSS:} but not
4558 @samp{:URGENT:}
4559 @item C-c a v
4560 as the same search as @kbd{C-c a u}, but limiting the search to
4561 headlines that are also TODO items
4562 @item C-c a U
4563 as the same search as @kbd{C-c a u}, but only in the current buffer and
4564 displaying the result as a sparse tree
4565 @item C-c a f
4566 to create a sparse tree (again: current buffer only) with all entries
4567 containing the word @samp{FIXME}.
4568 @end table
4570 @node Block agenda, Setting Options, Storing searches, Custom agenda views
4571 @subsection Block agenda
4572 @cindex block agenda
4573 @cindex agenda, with block views
4575 Another possibility is the construction of agenda views that comprise
4576 the results of @emph{several} commands, each of which creates a block in
4577 the agenda buffer.  The available commands include @code{agenda} for the
4578 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
4579 for the global todo list (as constructed with @kbd{C-c a t}), and the
4580 matching commands discussed above: @code{todo}, @code{tags}, and
4581 @code{tags-todo}.  Here are two examples:
4583 @lisp
4584 @group
4585 (setq org-agenda-custom-commands
4586       '(("h" "Agenda and Home-related tasks"
4587          ((agenda)
4588           (tags-todo "HOME")
4589           (tags "GARDEN")))
4590         ("o" "Agenda and Office-related tasks"
4591          ((agenda)
4592           (tags-todo "WORK")
4593           (tags "OFFICE")))))
4594 @end group
4595 @end lisp
4597 @noindent
4598 This will define @kbd{C-c a h} to create a multi-block view for stuff
4599 you need to attend to at home.  The resulting agenda buffer will contain
4600 your agenda for the current week, all TODO items that carry the tag
4601 @samp{HOME}, and also all lines tagged with @samp{GARDEN}.  Finally the
4602 command @kbd{C-c a o} provides a similar view for office tasks.
4605 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
4606 @subsection Setting Options for custom commands
4607 @cindex options, for custom agenda views
4609 Org-mode contains a number of variables regulating agenda construction
4610 and display.  The global variables define the behavior for all agenda
4611 commands, including the custom commands.  However, if you want to change
4612 some settings just for a single custom view, you can do so.  Setting
4613 options requires inserting a list of variable names and values at the
4614 right spot in @code{org-agenda-custom-commands}.  For example:
4616 @lisp
4617 @group
4618 (setq org-agenda-custom-commands
4619       '(("w" todo "WAITING"
4620          ((org-agenda-sorting-strategy '(priority-down))
4621           (org-agenda-prefix-format "  Mixed: ")))
4622         ("U" tags-tree "+BOSS-URGENT"
4623          ((org-show-following-heading nil)
4624           (org-show-hierarchy-above nil)))))
4625 @end group
4626 @end lisp
4628 @noindent
4629 Now the @kbd{C-c a w} command will sort the collected entries only by
4630 priority, and the prefix format is modified to just say @samp{  Mixed:}
4631 instead of giving the category of the entry.  The sparse tags tree of
4632 @kbd{C-c a U} will now turn out ultra-compact, because neither the
4633 headline hierarchy above the match, nor the headline following the match
4634 will be shown.
4636 For command sets creating a block agenda,
4637 @code{org-agenda-custom-commands} has two separate spots for setting
4638 options.  You can add options that should be valid for just a single
4639 command in the set, and options that should be valid for all commands in
4640 the set.  The former are just added to the command entry, the latter
4641 must come after the list of command entries.  Going back to the block
4642 agenda example (@pxref{Block agenda}), let's change the sorting strategy
4643 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
4644 the results for GARDEN tags query in the opposite order,
4645 @code{priority-up}.  This would look like this:
4647 @lisp
4648 @group
4649 (setq org-agenda-custom-commands
4650       '(("h" "Agenda and Home-related tasks"
4651          ((agenda)
4652           (tags-todo "HOME")
4653           (tags "GARDEN"
4654                 ((org-agenda-sorting-strategy '(priority-up)))))
4655          ((org-agenda-sorting-strategy '(priority-down))))
4656         ("o" "Agenda and Office-related tasks"
4657          ((agenda)
4658           (tags-todo "WORK")
4659           (tags "OFFICE")))))
4660 @end group
4661 @end lisp
4663 As you see, the values and parenthesis setting is a little complex.
4664 When in doubt, use the customize interface to set this variable - it
4665 fully supports its structure.  Just one caveat: When setting options in
4666 this interface, the @emph{values} are just lisp expressions.  So if the
4667 value is a string, you need to add the double quotes around the value
4668 yourself.
4671 @node Exporting Agenda Views, Extracting Agenda Information for other programs, Setting Options, Custom agenda views
4672 @subsection Exporting Agenda Views
4673 @cindex agenda views, exporting
4675 If you are away from your computer, it can be very useful to have a
4676 printed version of some agenda views to carry around.  Org-mode can
4677 export custom agenda views as plain text, HTML@footnote{You need to
4678 install Hrvoje Niksic' @file{htmlize.el}.} and postscript.  If you want
4679 to do this only occasionally, use the commend
4681 @table @kbd
4682 @kindex C-x C-w
4683 @item C-x C-w
4684 @cindex exporting agenda views
4685 @cindex agenda views, exporting
4686 Write the agenda view to a file.  Depending on the extension of the
4687 selected file name, the view will be exported as HTML (extension
4688 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
4689 plain text (any other extension).  Use the variable
4690 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
4691 and for @file{htmlize} to be used during export, for example
4692 @lisp
4693 (setq org-agenda-exporter-settings
4694       '((ps-number-of-columns 2)
4695         (ps-landscape-mode t)
4696         (htmlize-output-type 'css)))
4697 @end lisp
4698 @end table
4700 If you need to export certain agenda views frequently, you can associate
4701 any custom agenda command with a list of output file names
4702 @footnote{If you want to store standard views like the weekly agenda
4703 or the global TODO list as well, you need to define custom commands for
4704 them in order to be able to specify filenames.}.  Here is an example
4705 that first does define custom commands for the agenda and the global
4706 todo list, together with a number of files to which to export them.
4707 Then we define two block agenda commands and specify filenames for them
4708 as well.  File names can be relative to the current working directory,
4709 or absolute.
4711 @lisp
4712 @group
4713 (setq org-agenda-custom-commands
4714       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
4715         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
4716         ("h" "Agenda and Home-related tasks"
4717          ((agenda)
4718           (tags-todo "HOME")
4719           (tags "GARDEN"))
4720          nil
4721          ("~/views/home.html"))
4722         ("o" "Agenda and Office-related tasks"
4723          ((agenda)
4724           (tags-todo "WORK")
4725           (tags "OFFICE"))
4726          nil
4727          ("~/views/office.ps"))))
4728 @end group
4729 @end lisp
4731 The extension of the file name determines the type of export.  If it is
4732 @file{.html}, Org-mode will use the @file{htmlize.el} package to convert
4733 the buffer to HTML and save it to this file name.  If the extension is
4734 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
4735 postscript output.  Any other extension produces a plain ASCII file.
4737 The export files are @emph{not} created when you use one of those
4738 commands interactively.  Instead, there is a special command to produce
4739 @emph{all} specified files in one step:
4741 @table @kbd
4742 @kindex C-c a e
4743 @item C-c a e
4744 Export all agenda views that have export filenames associated with
4745 them.
4746 @end table
4748 You can use the options section of the custom agenda commands to also
4749 set options for the export commands.  For example:
4751 @lisp
4752 (setq org-agenda-custom-commands
4753       '(("X" agenda ""
4754          ((ps-number-of-columns 2)
4755           (ps-landscape-mode t)
4756           (org-agenda-prefix-format " [ ] ")
4757           (org-agenda-with-colors nil)
4758           (org-agenda-remove-tags t))
4759          ("theagenda.ps"))))
4760 @end lisp
4762 @noindent
4763 This command sets two options for the postscript exporter, to make it
4764 print in two columns in landscape format - the resulting page can be cut
4765 in two and then used in a paper agenda.  The remaining settings modify
4766 the agenda prefix to omit category and scheduling information, and
4767 instead include a checkbox to check off items.  We also remove the tags
4768 to make the lines compact, and we don't want to use colors for the
4769 black-and-white printer.  Settings specified in
4770 @code{org-agenda-exporter-settings} will also apply, but the settings
4771 in @code{org-agenda-custom-commands} take precedence.
4773 @noindent
4774 From the command line you may also use
4775 @example
4776 emacs -f org-batch-store-agenda-views -kill
4777 @end example
4778 @noindent
4779 or, if you need to modify some parameters
4780 @example
4781 emacs -eval '(org-batch-store-agenda-views                      \
4782               org-agenda-ndays 30                               \
4783               org-agenda-include-diary nil                      \
4784               org-agenda-files (quote ("~/org/project.org")))'  \
4785       -kill
4786 @end example
4787 @noindent
4788 which will create the agenda views restricted to the file
4789 @file{~/org/project.org}, without diary entries and with 30 days
4790 extent. 
4792 @node Extracting Agenda Information for other programs,  , Exporting Agenda Views, Custom agenda views
4793 @subsection Extracting Agenda Information for other programs
4794 @cindex agenda, pipe
4795 @cindex Scripts, for agenda processing
4797 Org-mode provides commands to access agenda information for the command
4798 line in emacs batch mode.  This extracted information can be sent
4799 directly to a printer, or it can be read by a program that does further
4800 processing of the data.  The first of these commands is the function
4801 @code{org-batch-agenda}, that produces an agenda view and sends it as
4802 ASCII text to STDOUT.  The command takes a single string as parameter.
4803 If the string has length 1, it is used as a key to one of the commands
4804 you have configured in @code{org-agenda-custom-commands}, basically any
4805 key you can use after @kbd{C-c a}.  For example, to directly print the
4806 current TODO list, you could use
4808 @example
4809 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
4810 @end example
4812 If the parameter is a string with 2 or more characters, it is used as a
4813 tags/todo match string.  For example, to print your local shopping list
4814 (all items with the tag @samp{shop}, but excluding the tag
4815 @samp{NewYork}), you could use
4817 @example
4818 emacs -batch -l ~/.emacs                                      \       
4819       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
4820 @end example
4822 @noindent
4823 You may also modify parameters on the fly like this:
4825 @example
4826 emacs -batch -l ~/.emacs                                      \
4827    -eval '(org-batch-agenda "a"                               \
4828             org-agenda-ndays 30                               \
4829             org-agenda-include-diary nil                      \
4830             org-agenda-files (quote ("~/org/project.org")))'  \
4831    | lpr
4832 @end example
4834 @noindent
4835 which will produce a 30 day agenda, fully restricted to the Org file
4836 @file{~/org/projects.org}, not even including the diary.
4838 If you want to process the agenda data in more sophisticated ways, you
4839 can use the command @code{org-batch-agenda-csv} to get a comma-separated
4840 list of values for each agenda item.  Each line in the output will
4841 contain a number of fields separated by commas.  The fields in a line
4842 are:
4844 @example
4845 category     @r{The category of the item}
4846 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
4847 type         @r{The type of the agenda entry, can be}
4848                 todo               @r{selected in TODO match}
4849                 tagsmatch          @r{selected in tags match}
4850                 diary              @r{imported from diary}
4851                 deadline           @r{a deadline}
4852                 scheduled          @r{scheduled}
4853                 timestamp          @r{appointment, selected by timestamp}
4854                 closed             @r{entry was closed on date}
4855                 upcoming-deadline  @r{warning about nearing deadline}
4856                 past-scheduled     @r{forwarded scheduled item}
4857                 block              @r{entry has date block including date}
4858 todo         @r{The todo keyword, if any}
4859 tags         @r{All tags including inherited ones, separated by colons}
4860 date         @r{The relevant date, like 2007-2-14}
4861 time         @r{The time, like 15:00-16:50}
4862 extra        @r{String with extra planning info}
4863 priority-l   @r{The priority letter if any was given}
4864 priority-n   @r{The computed numerical priority}
4865 @end example
4867 @noindent
4868 Time and date will only be given if a timestamp (or deadline/scheduled)
4869 lead to the selection of the item.
4871 A CSV list like this is very easy to use in a post processing script.
4872 For example, here is a Perl program that gets the TODO list from
4873 Emacs/org-mode and prints all the items, preceded by a checkbox:
4875 @example
4876 @group
4877 #!/usr/bin/perl
4879 # define the Emacs command to run
4880 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
4882 # run it and capture the output
4883 $agenda = qx@{$cmd 2>/dev/null@};
4885 # loop over all lines
4886 foreach $line (split(/\n/,$agenda)) @{
4888   # get the individual values
4889   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
4890    $priority_l,$priority_n) = split(/,/,$line);
4892   # proccess and print
4893   print "[ ] $head\n";
4895 @end group
4896 @end example
4898 @node Embedded LaTeX, Exporting, Agenda views, Top
4899 @chapter Embedded LaTeX
4900 @cindex @TeX{} interpretation
4901 @cindex La@TeX{} interpretation
4903 Plain ASCII is normally sufficient for almost all note taking.  One
4904 exception, however, are scientific notes which need to be able to
4905 contain mathematical symbols and the occasional formula.
4906 La@TeX{}@footnote{La@TeX{} is a macro system based on Donald E. Knuth's
4907 @TeX{} system.  Many of the features described here as ``La@TeX{}'' are
4908 really from @TeX{}, but for simplicity I am blurring this distinction.}
4909 is widely used to typeset scientific documents. Org-mode supports
4910 embedding La@TeX{} code into its files, because many academics are used
4911 to read La@TeX{} source code, and because it can be readily processed
4912 into images for HTML production.
4914 It is not necessary to mark La@TeX{} macros and code in any special way.
4915 If you observe a few conventions, Org-mode knows how to find it and what
4916 to do with it.
4918 @menu
4919 * Math symbols::                TeX macros for symbols and Greek letters
4920 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
4921 * LaTeX fragments::             Complex formulas made easy
4922 * Processing LaTeX fragments::  Previewing LaTeX processing
4923 * CDLaTeX mode::                Speed up entering of formulas
4924 @end menu
4926 @node Math symbols, Subscripts and Superscripts, Embedded LaTeX, Embedded LaTeX
4927 @section Math symbols
4928 @cindex math symbols
4929 @cindex TeX macros
4931 You can use La@TeX{} macros to insert special symbols like @samp{\alpha}
4932 to indicate the Greek letter, or @samp{\to} to indicate an arrow.
4933 Completion for these macros is available, just type @samp{\} and maybe a
4934 few letters, and press @kbd{M-@key{TAB}} to see possible completions.
4935 Unlike La@TeX{} code, Org-mode allows these macros to be present
4936 without surrounding math delimiters, for example:
4938 @example
4939 Angles are written as Greek letters \alpha, \beta and \gamma.
4940 @end example
4942 During HTML export (@pxref{HTML export}), these symbols are translated
4943 into the proper syntax for HTML, for the above examples this is
4944 @samp{&alpha;} and @samp{&rarr;}, respectively.
4946 @node Subscripts and Superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
4947 @section Subscripts and Superscripts
4948 @cindex subscript
4949 @cindex superscript
4951 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
4952 and subscripts.  Again, these can be used without embedding them in
4953 math-mode delimiters.  To increase the readability of ASCII text, it is
4954 not necessary (but OK) to surround multi-character sub- and superscripts
4955 with curly braces.  For example
4957 @example
4958 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
4959 the sun is R_@{sun@} = 6.96 x 10^8 m.
4960 @end example
4962 To avoid interpretation as raised or lowered text, you can quote
4963 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
4965 During HTML export (@pxref{HTML export}), subscript and superscripts
4966 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
4968 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and Superscripts, Embedded LaTeX
4969 @section LaTeX fragments
4970 @cindex LaTeX fragments
4972 With symbols, sub- and superscripts, HTML is pretty much at its end when
4973 it comes to representing mathematical formulas@footnote{Yes, there is
4974 MathML, but that is not yet fully supported by many browsers, and there
4975 is no decent converter for turning LaTeX of ASCII representations of
4976 formulas into MathML.  So for the time being, converting formulas into
4977 images seems the way to go.}.  More complex
4978 expressions need a dedicated formula processor.  To this end, Org-mode
4979 can contain arbitrary La@TeX{} fragments.  It provides commands to
4980 preview the typeset result of these fragments, and upon export to HTML,
4981 all fragments will be converted to images and inlined into the HTML
4982 document.  For this to work you need to be on a system with a working
4983 La@TeX{} installation.  You also need the @file{dvipng} program,
4984 available at @url{http://sourceforge.net/projects/dvipng/}.  The LaTeX
4985 header that will be used when processing a fragment can be configured
4986 with the variable @code{org-format-latex-header}.
4988 La@TeX{} fragments don't need any special marking at all.  The following
4989 snippets will be identified as LaTeX source code:
4990 @itemize @bullet
4991 @item
4992 Environments of any kind.  The only requirement is that the
4993 @code{\begin} statement appears on a new line, preceded by only
4994 whitespace.
4995 @item
4996 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
4997 currency specifications, single @samp{$} characters are only recognized
4998 as math delimiters if the enclosed text contains at most two line breaks,
4999 is directly attached to the @samp{$} characters with no whitespace in
5000 between, and if the closing @samp{$} is followed by whitespace or
5001 punctuation.  For the other delimiters, there is no such restriction, so
5002 when in doubt, use @samp{\(...\)} as inline math delimiters.
5003 @end itemize
5005 @noindent For example:
5007 @example
5008 \begin@{equation@}                          % arbitrary environments,
5009 x=\sqrt@{b@}                                % even tables, figures
5010 \end@{equation@}                            % etc
5012 If $a^2=b$ and \( b=2 \), then the solution must be
5013 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
5014 @end example
5016 @noindent
5017 If you need any of the delimiter ASCII sequences for other purposes, you
5018 can configure the option @code{org-format-latex-options} to deselect the
5019 ones you do not wish to have interpreted by the La@TeX{} converter.
5021 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
5022 @section Processing LaTeX fragments
5023 @cindex LaTeX fragments, preview
5025 La@TeX{} fragments can be processed to produce a preview images of the
5026 typeset expressions:
5028 @table @kbd
5029 @kindex C-c C-x C-l
5030 @item C-c C-x C-l
5031 Produce a preview image of the La@TeX{} fragment at point and overlay it
5032 over the source code.  If there is no fragment at point, process all
5033 fragments in the current entry (between two headlines).  When called
5034 with a prefix argument, process the entire subtree.  When called with
5035 two prefix arguments, or when the cursor is before the first headline,
5036 process the entire buffer.
5037 @kindex C-c C-c
5038 @item C-c C-c
5039 Remove the overlay preview images.
5040 @end table
5042 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
5043 converted into images and inlined into the document if the following
5044 setting is active:
5046 @lisp
5047 (setq org-export-with-LaTeX-fragments t)
5048 @end lisp
5050 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
5051 @section Using CDLaTeX to enter math
5052 @cindex CDLaTeX
5054 CDLaTeX-mode is a minor mode that is normally used in combination with a
5055 major LaTeX mode like AUCTeX in order to speed-up insertion of
5056 environments and math templates.  Inside Org-mode, you can make use of
5057 some of the features of cdlatex-mode.  You need to install
5058 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
5059 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
5060 Don't turn cdlatex-mode itself under Org-mode, but use the light
5061 version @code{org-cdlatex-mode} that comes as part of Org-mode.  Turn it
5062 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
5063 Org-mode files with
5065 @lisp
5066 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
5067 @end lisp
5069 When this mode is enabled, the following features are present (for more
5070 details see the documentation of cdlatex-mode):
5071 @itemize @bullet
5072 @kindex C-c @{
5073 @item
5074 Environment templates can be inserted with @kbd{C-c @{}.
5075 @item
5076 @kindex @key{TAB}
5077 The @key{TAB} key will do template expansion if the cursor is inside a
5078 LaTeX fragment@footnote{Org-mode has a method to test if the cursor is
5079 inside such a fragment, see the documentation of the function
5080 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
5081 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
5082 correctly inside the first brace.  Another @key{TAB} will get you into
5083 the second brace.  Even outside fragments, @key{TAB} will expand
5084 environment abbreviations at the beginning of a line.  For example, if
5085 you write @samp{equ} at the beginning of a line and press @key{TAB},
5086 this abbreviation will be expanded to an @code{equation} environment.
5087 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
5088 @item
5089 @kindex _
5090 @kindex ^
5091 Pressing @kbd{_} and @kbd{^} inside a LaTeX fragment will insert these
5092 characters together with a pair of braces.  If you use @key{TAB} to move
5093 out of the braces, and if the braces surround only a single character or
5094 macro, they are removed again (depending on the variable
5095 @code{cdlatex-simplify-sub-super-scripts}).
5096 @item
5097 @kindex `
5098 Pressing the backquote @kbd{`} followed by a character inserts math
5099 macros, also outside LaTeX fragments.  If you wait more than 1.5 seconds
5100 after the backquote, a help window will pop up.
5101 @item
5102 @kindex '
5103 Pressing the normal quote @kbd{'} followed by another character modifies
5104 the symbol before point with an accent or a font.  If you wait more than
5105 1.5 seconds after the backquote, a help window will pop up.  Character
5106 modification will work only inside La@TeX{} fragments, outside the quote
5107 is normal.
5108 @end itemize
5110 @node Exporting, Publishing, Embedded LaTeX, Top
5111 @chapter Exporting
5112 @cindex exporting
5114 Org-mode documents can be exported into a variety of other formats.  For
5115 printing and sharing of notes, ASCII export produces a readable and
5116 simple version of an Org-mode file.  HTML export allows you to publish a
5117 notes file on the web, while the XOXO format provides a solid base for
5118 exchange with a broad range of other applications.  To incorporate
5119 entries with associated times like deadlines or appointments into a
5120 desktop calendar program like iCal, Org-mode can also produce extracts
5121 in the iCalendar format.  Currently Org-mode only supports export, not
5122 import of these different formats.
5124 When exporting, Org-mode uses special conventions to enrich the output
5125 produced.  @xref{Text interpretation}, for more details.
5127 @table @kbd
5128 @kindex C-c C-e
5129 @item C-c C-e
5130 Dispatcher for export and publishing commands.  Displays a help-window
5131 listing the additional key(s) needed to launch an export or publishing
5132 command.
5133 @end table
5135 @menu
5136 * ASCII export::                Exporting to plain ASCII
5137 * HTML export::                 Exporting to HTML
5138 * XOXO export::                 Exporting to XOXO
5139 * iCalendar export::            Exporting in iCalendar format
5140 * Text interpretation::         How the exporter looks at the file
5141 @end menu
5143 @node ASCII export, HTML export, Exporting, Exporting
5144 @section ASCII export
5145 @cindex ASCII export
5147 ASCII export produces a simple and very readable version of an Org-mode
5148 file.
5150 @cindex region, active
5151 @cindex active region
5152 @cindex transient-mark-mode
5153 @table @kbd
5154 @kindex C-c C-e a
5155 @item C-c C-e a
5156 Export as ASCII file.  If there is an active region, only the region
5157 will be exported.  For an org file @file{myfile.org}, the ASCII file
5158 will be @file{myfile.txt}.  The file will be overwritten without
5159 warning.
5160 @kindex C-c C-e v a
5161 @item C-c C-e v a
5162 Export only the visible part of the document.
5163 @end table
5165 @cindex headline levels, for exporting
5166 In the exported version, the first 3 outline levels will become
5167 headlines, defining a general document structure.  Additional levels
5168 will be exported as itemized lists.  If you want that transition to occur
5169 at a different level, specify it with a prefix argument.  For example,
5171 @example
5172 @kbd{C-1 C-c C-e a}
5173 @end example
5175 @noindent
5176 creates only top level headlines and does the rest as items.  When
5177 headlines are converted to items, the indentation of the text following
5178 the headline is changed to fit nicely under the item.  This is done with
5179 the assumption that the first bodyline indicates the base indentation of
5180 the body text.  Any indentation larger than this is adjusted to preserve
5181 the layout relative to the first line.  Should there be lines with less
5182 indentation than the first, these are left alone.
5184 @node HTML export, XOXO export, ASCII export, Exporting
5185 @section HTML export
5186 @cindex HTML export
5188 Org-mode contains an HTML (XHTML 1.0 strict) exporter with extensive
5189 HTML formatting, in ways similar to John Grubers @emph{markdown}
5190 language, but with additional support for tables.
5192 @menu
5193 * Export commands::             How to invoke HTML export
5194 * Quoting HTML tags::           Using direct HTML in Org-mode
5195 * Links::                       How hyperlinks get transferred to HTML
5196 * Images::                      To inline or not to inline?
5197 * CSS support::                 Style specifications
5198 @end menu
5200 @node Export commands, Quoting HTML tags, HTML export, HTML export
5201 @subsection HTML export commands
5203 @cindex region, active
5204 @cindex active region
5205 @cindex transient-mark-mode
5206 @table @kbd
5207 @kindex C-c C-e h
5208 @item C-c C-e h
5209 Export as HTML file @file{myfile.html}.
5210 @kindex C-c C-e b
5211 @item C-c C-e b
5212 Export as HTML file and open it with a browser.
5213 @kindex C-c C-e H
5214 @item C-c C-e H
5215 Export to a temporary buffer, do not create a file.
5216 @kindex C-c C-e R
5217 @item C-c C-e H
5218 Export the active region to a temporary buffer.  With prefix arg, do not
5219 produce file header and foot, but just the plain HTML section for the
5220 region.  This is good for cut-and-paste operations.
5221 @kindex C-c C-e v h
5222 @kindex C-c C-e v b
5223 @kindex C-c C-e v H
5224 @kindex C-c C-e v R
5225 @item C-c C-e v h
5226 @item C-c C-e v b
5227 @item C-c C-e v H
5228 @item C-c C-e v R
5229 Export only the visible part of the document.
5230 @item M-x org-export-region-as-html
5231 Convert the region to HTML under the assumption that it was org-mode
5232 syntax before.  This is a global command that can be invoked in any
5233 buffer.
5234 @end table
5236 @cindex headline levels, for exporting
5237 In the exported version, the first 3 outline levels will become
5238 headlines, defining a general document structure.  Additional levels
5239 will be exported as itemized lists.  If you want that transition to occur
5240 at a different level, specify it with a prefix argument.  For example,
5242 @example
5243 @kbd{C-2 C-c C-e b}
5244 @end example
5246 @noindent
5247 creates two levels of headings and does the rest as items.
5249 @node Quoting HTML tags, Links, Export commands, HTML export
5250 @subsection Quoting HTML tags
5252 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
5253 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
5254 which should be interpreted as such, mark them with @samp{@@} as in
5255 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
5256 simple tags.  For more extensive HTML that should be copied verbatim to
5257 the exported file use either
5259 @example
5260 #+HTML: Literal HTML code for export
5261 @end example
5263 @noindent or
5265 @example
5266 #+BEGIN_HTML
5267 All lines between these markers are exported literally
5268 #+END_HTML
5269 @end example
5272 @node Links, Images, Quoting HTML tags, HTML export
5273 @subsection Links
5275 @cindex links, in HTML export
5276 @cindex internal links, in HTML export
5277 @cindex external links, in HTML export
5278 Internal links (@pxref{Internal links}) will continue to work in HTML
5279 files only if they match a dedicated @samp{<<target>>}.  Automatic links
5280 created by radio targets (@pxref{Radio targets}) will also work in the
5281 HTML file.  Links to external files will still work if the HTML file is
5282 in the same directory as the Org-mode file.  Links to other @file{.org}
5283 files will be translated into HTML links under the assumption that an
5284 HTML version also exists of the linked file.  For information related to
5285 linking files while publishing them to a publishing directory see
5286 @ref{Publishing links}.
5288 @node Images, CSS support, Links, HTML export
5289 @subsection Images
5291 @cindex images, inline in HTML
5292 @cindex inlining images in HTML
5293 HTML export can inline images given as links in the Org-mode file, and
5294 it can make an image the clickable part of a link.  By
5295 default@footnote{but see the variable
5296 @code{org-export-html-inline-images}}, images are inlined if a link does
5297 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
5298 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
5299 @samp{the image} that points to the image.  If the description part
5300 itself is a @code{file:} link or a @code{http:} URL pointing to an
5301 image, this image will be inlined and activated so that clicking on the
5302 image will activate the link.  For example, to include a thumbnail that
5303 will link to a high resolution version of the image, you could use:
5305 @example
5306 [[file:highres.jpg][file:thumb.jpg]]
5307 @end example
5309 @noindent
5310 and you could use @code{http} addresses just as well.
5312 @node CSS support,  , Images, HTML export
5313 @subsection CSS support
5315 You can also give style information for the exported file.  The HTML
5316 exporter assigns the following CSS classes to appropriate parts of the
5317 document - your style specifications may change these:
5318 @example
5319 .todo           @r{TODO keywords}
5320 .done           @r{the DONE keyword}
5321 .timestamp      @r{time stamp}
5322 .timestamp-kwd  @r{keyword associated with a time stamp, like SCHEDULED}
5323 .tag            @r{tag in a headline}
5324 .target         @r{target for links}
5325 @end example
5327 The default style specification can be configured through the option
5328 @code{org-export-html-style}.  If you want to use a file-local style,
5329 you may use file variables, best wrapped into a COMMENT section at the
5330 end of the outline tree.  For example@footnote{Under Emacs 21, the
5331 continuation lines for a variable value should have no @samp{#} at the
5332 start of the line.}:
5334 @example
5335 * COMMENT html style specifications
5337 # Local Variables:
5338 # org-export-html-style: "   <style type=\"text/css\">
5339 #       p @{font-weight: normal; color: gray; @}
5340 #       h1 @{color: black; @}
5341 #   </style>"
5342 # End:
5343 @end example
5345 Remember to execute @kbd{M-x normal-mode} after changing this to make
5346 the new style visible to Emacs.  This command restarts org-mode for the
5347 current buffer and forces Emacs to re-evaluate the local variables
5348 section in the buffer.
5350 @c FIXME: More about header and footer styles
5351 @c FIXME: Talk about links and targets.
5353 @node XOXO export, iCalendar export, HTML export, Exporting
5354 @section XOXO export
5355 @cindex XOXO export
5357 Org-mode contains an exporter that produces XOXO-style output.
5358 Currently, this exporter only handles the general outline structure and
5359 does not interpret any additional Org-mode features.
5361 @table @kbd
5362 @kindex C-c C-e x
5363 @item C-c C-e x
5364 Export as XOXO file @file{myfile.html}.
5365 @kindex C-c C-e v
5366 @item C-c C-e v x
5367 Export only the visible part of the document.
5368 @end table
5370 @node iCalendar export, Text interpretation, XOXO export, Exporting
5371 @section iCalendar export
5372 @cindex iCalendar export
5374 Some people like to use Org-mode for keeping track of projects, but
5375 still prefer a standard calendar application for anniversaries and
5376 appointments.  In this case it can be useful to have deadlines and
5377 other time-stamped items in Org-mode files show up in the calendar
5378 application.  Org-mode can export calendar information in the standard
5379 iCalendar format.  If you also want to have TODO entries included in the
5380 export, configure the variable @code{org-icalendar-include-todo}.
5382 @table @kbd
5383 @kindex C-c C-e i
5384 @item C-c C-e i
5385 Create iCalendar entries for the current file and store them in the same
5386 directory, using a file extension @file{.ics}.
5387 @kindex C-c C-e I
5388 @item C-c C-e I
5389 Like @kbd{C-c C-e i}, but do this for all files in
5390 @code{org-agenda-files}.  For each of these files, a separate iCalendar
5391 file will be written.
5392 @kindex C-c C-e c
5393 @item C-c C-e c
5394 Create a single large iCalendar file from all files in
5395 @code{org-agenda-files} and write it to the file given by
5396 @code{org-combined-agenda-icalendar-file}.
5397 @end table
5399 How this calendar is best read and updated, depends on the application
5400 you are using.  The FAQ covers this issue.
5403 @node Text interpretation,  , iCalendar export, Exporting
5404 @section Text interpretation by the exporter
5406 The exporter backends interpret additional structure in the Org-mode file
5407 in order to produce better output.
5409 @menu
5410 * Comment lines::               Some lines will not be exported
5411 * Initial text::                Text before the first headline
5412 * Footnotes::                   Numbers like [1]
5413 * Enhancing text::              Subscripts, symbols and more
5414 * Export options::              How to influence the export settings
5415 @end menu
5417 @node Comment lines, Initial text, Text interpretation, Text interpretation
5418 @subsection Comment lines
5419 @cindex comment lines
5420 @cindex exporting, not
5422 Lines starting with @samp{#} in column zero are treated as comments
5423 and will never be exported.  Also entire subtrees starting with the
5424 word @samp{COMMENT} will never be exported.
5426 @table @kbd
5427 @kindex C-c ;
5428 @item C-c ;
5429 Toggle the COMMENT keyword at the beginning of an entry.
5430 @end table
5432 @node Initial text, Footnotes, Comment lines, Text interpretation
5433 @subsection Text before the first headline
5435 Org-mode normally ignores any text before the first headline when
5436 exporting, leaving this region for internal links to speed up navigation
5437 etc.  However, in publishing-oriented files, you might want to have some
5438 text before the first headline, like a small introduction, special HTML
5439 code with a navigation bar, etc.  You can ask to have this part of the
5440 file exported as well by setting the variable
5441 @code{org-export-skip-text-before-1st-heading} to @code{nil}.  On a
5442 per-file basis, you can get the same effect with
5444 @example
5445 #+OPTIONS: skip:nil
5446 @end example
5448 The text before the first headline will be fully processed
5449 (@pxref{Enhancing text}), and the first non-comment line becomes the
5450 title of the exported document.  If you need to include literal HTML,
5451 use the special constructs described in @ref{Quoting HTML tags}.  The
5452 table of contents is normally inserted directly before the first
5453 headline of the file.  If you would like to get it to a different
5454 location, insert the string @code{[TABLE-OF-CONTENTS]} on a line by
5455 itself at the desired location.
5457 Finally, if you want to use the space before the first headline for
5458 internal purposes, but @emph{still} want to place something before the
5459 first headline when exporting the file, you can use the @code{#+TEXT}
5460 construct:
5462 @example
5463 #+OPTIONS: skip:t
5464 #+TEXT: This text will go before the *first* headline.
5465 #+TEXT: We place the table of contents here:
5466 #+TEXT: [TABLE-OF-CONTENTS]
5467 #+TEXT: This goes between the table of contents and the first headline
5468 @end example
5470 @node Footnotes, Enhancing text, Initial text, Text interpretation
5471 @subsection Footnotes
5472 @cindex footnotes
5473 @cindex @file{footnote.el}
5475 Numbers in square brackets are treated as footnotes, so that you can use
5476 the Emacs package @file{footnote.el} to create footnotes.  For example:
5478 @example
5479 The org-mode homepage[1] clearly needs help from
5480 a good web designer.
5482 [1] The link is: http://www.astro.uva.nl/~dominik/Tools/org
5483 @end example
5485 @noindent
5486 @kindex C-c !
5487 Note that the @file{footnote} package uses @kbd{C-c !} to invoke its
5488 commands.  This binding conflicts with the org-mode command for
5489 inserting inactive time stamps.  You could use the variable
5490 @code{footnote-prefix} to switch footnotes commands to another key.  Or,
5491 if you are too used to this binding, you could use
5492 @code{org-replace-disputed-keys} and @code{org-disputed-keys} to change
5493 the settings in Org-mode.
5495 @node Enhancing text, Export options, Footnotes, Text interpretation
5496 @subsection Enhancing text for export
5497 @cindex enhancing text
5498 @cindex richer text
5500 Some of the export backends of Org-mode allow for sophisticated text
5501 formatting, this is true in particular for the HTML backend.  Org-mode
5502 has a number of typing conventions that allow to produce a richly
5503 formatted output.
5505 @itemize @bullet
5507 @cindex hand-formatted lists
5508 @cindex lists, hand-formatted
5509 @item
5510 Plain lists @samp{-}, @samp{*} or @samp{+} as bullet, or with @samp{1.}
5511 or @samp{2)} as enumerator will be recognized and transformed if the
5512 backend supports lists.  See @xref{Plain lists}.
5514 @cindex underlined text
5515 @cindex bold text
5516 @cindex italic text
5517 @item
5518 You can make words @b{*bold*}, @i{/italic/}, _underlined_,
5519 @code{=code=}, and even @samp{+strikethrough+}@footnote{but remember
5520 that strikethrough is typographically evil and should @i{never} be
5521 used.}.
5523 @cindex horizontal rules, in exported files
5524 @item
5525 A line consisting of only dashes, and at least 5 of them, will be
5526 exported as a horizontal line (@samp{<hr/>} in HTML).
5528 @cindex LaTeX fragments, export
5529 @cindex TeX macros, export
5530 @item
5531 Many @TeX{} macros and entire La@TeX{} fragments are converted into HTML
5532 entities or images (@pxref{Embedded LaTeX}).
5534 @cindex tables, export
5535 @item
5536 Tables are transformed into native tables under the exporter, if the
5537 export backend supports this. Data fields before the first horizontal
5538 separator line will be formatted as table header fields.
5540 @cindex fixed width
5541 @item
5542 If a headline starts with the word @samp{QUOTE}, the text below the
5543 headline will be typeset as fixed-width, to allow quoting of computer
5544 codes etc.  Lines starting with @samp{:} are also typeset in
5545 fixed-width font.
5546 @table @kbd
5547 @kindex C-c :
5548 @item C-c :
5549 Toggle fixed-width for entry (QUOTE) or region, see below.
5550 @end table
5552 @cindex linebreak, forced
5553 @item 
5554 A double backslash @emph{at the end of a line} enforces a line break at
5555 this position.
5556 @end itemize
5558 If these conversions conflict with your habits of typing ASCII text,
5559 they can all be turned off with corresponding variables.  See the
5560 customization group @code{org-export-general}, and the following section
5561 which explains how to set export options with special lines in a
5562 buffer.
5565 @node Export options,  , Enhancing text, Text interpretation
5566 @subsection Export options
5567 @cindex options, for export
5569 @cindex completion, of option keywords
5570 The exporter recognizes special lines in the buffer which provide
5571 additional information.  These lines may be put anywhere in the file.
5572 The whole set of lines can be inserted into the buffer with @kbd{C-c
5573 C-e t}.  For individual lines, a good way to make sure the keyword is
5574 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
5575 (@pxref{Completion}).
5577 @table @kbd
5578 @kindex C-c C-e t
5579 @item C-c C-e t
5580 Insert template with export options, see example below.
5581 @end table
5583 @example
5584 #+TITLE:     the title to be shown (default is the buffer name)
5585 #+AUTHOR:    the author (default taken from @code{user-full-name})
5586 #+EMAIL:     his/her email address (default from @code{user-mail-address})
5587 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
5588 #+TEXT:      Some descriptive text to be inserted at the beginning.
5589 #+TEXT:      Several lines may be given.
5590 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t *:nil TeX:t LaTeX:t skip:t
5591 @end example
5593 @noindent
5594 The OPTIONS line is a compact form to specify export settings.  Here
5595 you can:
5596 @cindex headline levels
5597 @cindex section-numbers
5598 @cindex table of contents
5599 @cindex linebreak preservation
5600 @cindex quoted HTML tags
5601 @cindex fixed-width sections
5602 @cindex tables
5603 @cindex @TeX{}-like syntax for sub- and superscripts
5604 @cindex emphasized text
5605 @cindex @TeX{} macros
5606 @cindex La@TeX{} fragments
5607 @example
5608 H:      @r{set the number of headline levels for export}
5609 num:    @r{turn on/off section-numbers}
5610 toc:    @r{turn on/off table of contents, or set level limit (integer)}
5611 \n:     @r{turn on/off linebreak-preservation}
5612 @@:      @r{turn on/off quoted HTML tags}
5613 ::      @r{turn on/off fixed-width sections}
5614 |:      @r{turn on/off tables}
5615 ^:      @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
5616         @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
5617         @r{the simple @code{a_b} will be left as it is.}
5618 *:      @r{turn on/off emphasized text (bold, italic, underlined)}
5619 TeX:    @r{turn on/off simple @TeX{} macros in plain text}
5620 LaTeX:  @r{turn on/off La@TeX{} fragments}
5621 skip:   @r{turn on/off skipping the text before the first heading}
5622 @end example
5624 @node Publishing, Miscellaneous, Exporting, Top
5625 @chapter Publishing
5626 @cindex publishing
5628 Org-mode includes@footnote{@file{org-publish.el} is not yet part of
5629 Emacs, so if you are using @file{org.el} as it comes with Emacs, you
5630 need to download this file separately.  Also make sure org.el is at
5631 least version 4.27.} a publishing management system
5632 that allows you to configure automatic HTML conversion of
5633 @emph{projects} composed of interlinked org files.  This system is
5634 called @emph{org-publish}.  You can also configure org-publish to
5635 automatically upload your exported HTML pages and related attachments,
5636 such as images and source code files, to a web server.  Org-publish turns
5637 org-mode into a web-site authoring tool.
5639 Org-publish has been contributed to Org-mode by David O'Toole.
5641 @menu
5642 * Configuration::               Defining projects
5643 * Sample configuration::        Example projects
5644 * Triggering publication::      Publication commands
5645 @end menu
5647 @node Configuration, Sample configuration, Publishing, Publishing
5648 @section Configuration
5650 Publishing needs significant configuration to specify files, destination
5651 and many other properties of a project.
5653 @menu
5654 * Project alist::               The central configuration variable
5655 * Sources and destinations::    From here to there
5656 * Selecting files::             What files are part of the project?
5657 * Publishing action::           Setting the function doing the publishing
5658 * Publishing options::          Tweaking HTML export
5659 * Publishing links::            Which links keep working after publishing?
5660 * Project page index::          Publishing a list of project files
5661 @end menu
5663 @node Project alist, Sources and destinations, Configuration, Configuration
5664 @subsection The variable @code{org-publish-project-alist}
5665 @cindex org-publish-project-alist
5666 @cindex projects, for publishing
5668 Org-publish is configured almost entirely through setting the value of
5669 one variable, called @code{org-publish-project-alist}.
5670 Each element of the list configures one project, and may be in one of
5671 the two following forms:
5673 @lisp
5674 ("project-name"  :property value :property value ...)
5676 @r{or} 
5678 ("project-name"  :components ("project-name" "project-name" ...))
5680 @end lisp
5682 In both cases, projects are configured by specifying property values.
5683 A project defines the set of files that will be published, as well as
5684 the publishing configuration to use when publishing those files.  When
5685 a project takes the second form listed above, the individual members
5686 of the ``components'' property are taken to be components of the
5687 project, which group together files requiring different publishing
5688 options. When you publish such a ``meta-project'' all the components
5689 will also publish.
5691 @node Sources and destinations, Selecting files, Project alist, Configuration
5692 @subsection Sources and destinations for files
5693 @cindex directories, for publishing
5695 Most properties are optional, but some should always be set. In
5696 particular, org-publish needs to know where to look for source files,
5697 and where to put published files.
5699 @multitable @columnfractions 0.3 0.7
5700 @item @code{:base-directory}
5701 @tab Directory containing publishing source files
5702 @item @code{:publishing-directory}
5703 @tab Directory (possibly remote) where output files will be published.
5704 @item @code{:preparation-function}
5705 @tab Function called before starting publishing process, for example to
5706 run @code{make} for updating files to be published.
5707 @end multitable
5708 @noindent
5710 @node Selecting files, Publishing action, Sources and destinations, Configuration
5711 @subsection Selecting files
5712 @cindex files, selecting for publishing
5714 By default, all files with extension @file{.org} in the base directory
5715 are considered part of the project.  This can be modified by setting the
5716 properties 
5717 @multitable @columnfractions 0.25 0.75
5718 @item @code{:base-extension}
5719 @tab Extension (without the dot!) of source files.  This actually is a
5720 regular expression.
5722 @item @code{:exclude} 
5723 @tab Regular expression to match file names that should not be
5724 published, even though they have been selected on the basis of their
5725 extension.
5727 @item @code{:include}
5728 @tab List of files to be included regardless of @code{:base-extension}
5729 and @code{:exclude}.
5730 @end multitable
5732 @node Publishing action, Publishing options, Selecting files, Configuration
5733 @subsection Publishing Action
5734 @cindex action, for publishing
5736 Publishing means that a file is copied to the destination directory and
5737 possibly transformed in the process.  The default transformation is to
5738 export Org-mode files as HTML files, and this is done by the function
5739 @code{org-publish-org-to-html} which calls the HTML exporter
5740 (@pxref{HTML export}).  Other files like images only need to be copied
5741 to the publishing destination.  For non-Org-mode files, you need to
5742 specify the publishing function.
5744 @multitable @columnfractions 0.3 0.7
5745 @item @code{:publishing-function}
5746 @tab Function executing the publication of a file.  This may also be a
5747 list of functions, which will all be called in turn.
5748 @end multitable
5750 The function must accept two arguments: a property list containing at
5751 least a @code{:publishing-directory} property, and the name of the file
5752 to be published.  It should take the specified file, make the necessary
5753 transformation (if any) and place the result into the destination folder.
5754 You can write your own publishing function, but @code{org-publish}
5755 provides one for attachments (files that only need to be copied):
5756 @code{org-publish-attachment}.
5758 @node Publishing options, Publishing links, Publishing action, Configuration
5759 @subsection Options for the HTML exporter
5760 @cindex options, for publishing
5762 The property list can be used to set many export options for the HTML
5763 exporter.  In most cases, these properties correspond to user variables
5764 in Org-mode.  The table below lists these properties along with the
5765 variable they belong to.  See the documentation string for the
5766 respective variable for details.
5768 @multitable @columnfractions 0.3 0.7
5769 @item @code{:language}              @tab @code{org-export-default-language}
5770 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
5771 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
5772 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
5773 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
5774 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
5775 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
5776 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
5777 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
5778 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
5779 @item @code{:timestamps}           .@tab @code{org-export-with-timestamps}
5780 @item @code{:tags}                 .@tab @code{org-export-with-tags}
5781 @item @code{:tables}                @tab @code{org-export-with-tables}
5782 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
5783 @item @code{:style}                 @tab @code{org-export-html-style}
5784 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
5785 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
5786 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
5787 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
5788 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
5789 @item @code{:preamble}              @tab @code{org-export-html-preamble}
5790 @item @code{:postamble}             @tab @code{org-export-html-postamble}
5791 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
5792 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
5793 @item @code{:author}                @tab @code{user-full-name}
5794 @item @code{:email}                 @tab @code{user-mail-address}
5795 @end multitable
5797 When a property is given a value in org-publish-project-alist, its
5798 setting overrides the value of the corresponding user variable (if any)
5799 during publishing.  options set within a file (@pxref{Export
5800 options}), however, override everything.
5802 @node Publishing links, Project page index, Publishing options, Configuration
5803 @subsection Links between published files
5804 @cindex links, publishing
5806 To create a link from one Org-mode file to another, you would use
5807 something like @samp{[[file:foo.org][The foo]]} or simply
5808 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
5809 becomes a link to @file{foo.html}.  In this way, you can interlink the
5810 pages of your "org web" project and the links will work as expected when
5811 you publish them to HTML.
5813 You may also link to related files, such as images. Provided you are
5814 careful with relative pathnames, and provided you have also configured
5815 org-publish to upload the related files, these links will work
5816 too. @ref{Complex example} for an example of this usage.
5818 Sometime an Org-mode file to be published may contain links that are
5819 only valid in your production environment, but not in the publishing
5820 location.  In this case, use the property 
5822 @multitable @columnfractions 0.4 0.6
5823 @item @code{:link-validation-function}
5824 @tab Function to validate links
5825 @end multitable
5827 @noindent
5828 to define a function for checking link validity.  This function must
5829 accept two arguments, the file name and a directory relative to which
5830 the file name is interpreted in the production environment.  If this
5831 function returns @code{nil}, then the HTML generator will only insert a
5832 description into the HTML file, but no link.  One option for this
5833 function is @code{org-publish-validate-link} which checks if the given
5834 file is part of any project in @code{org-publish-project-alist}.
5836 @node Project page index,  , Publishing links, Configuration
5837 @subsection Project page index
5838 @cindex index, of published pages
5840 The following properties may be used to control publishing of an
5841 index of files or summary page for a given project.
5843 @multitable @columnfractions 0.25 0.75
5844 @item @code{:auto-index}
5845 @tab When non-nil, publish an index during org-publish-current-project or
5846 org-publish-all.
5848 @item @code{:index-filename}
5849 @tab Filename for output of index. Defaults to @file{index.org} (which
5850 becomes @file{index.html}).
5852 @item @code{:index-title}
5853 @tab Title of index page. Defaults to name of file.
5855 @item @code{:index-function}
5856 @tab Plugin function to use for generation of index.
5857 Defaults to @code{org-publish-org-index}, which generates a plain list
5858 of links to all files in the project.
5859 @end multitable
5861 @node Sample configuration, Triggering publication, Configuration, Publishing
5862 @section Sample configuration
5864 Below we provide two example configurations.  The first one is a simple
5865 project publishing only a set of Org-mode files.  The second example is
5866 more complex, with a multi-component project.
5868 @menu
5869 * Simple example::              One-component publishing
5870 * Complex example::             A multi-component publishing example
5871 @end menu
5873 @node Simple example, Complex example, Sample configuration, Sample configuration
5874 @subsection Example: simple publishing configuration
5876 This example publishes a set of Org-mode files to the @file{public_html}
5877 directory on the local machine.
5879 @lisp
5880 (setq org-publish-project-alist
5881       '(("org" 
5882          :base-directory "~/org/"
5883          :publishing-directory "~/public_html"
5884          :section-numbers nil
5885          :table-of-contents nil
5886          :style "<link rel=stylesheet 
5887                 href=\"../other/mystyle.css\"
5888                 type=\"text/css\">")))
5889 @end lisp
5891 @node Complex example,  , Simple example, Sample configuration
5892 @subsection Example: complex publishing configuration
5894 This more complicated example publishes an entire website, including
5895 org files converted to HTML, image files, emacs lisp source code, and
5896 stylesheets. The publishing-directory is remote and private files are
5897 excluded.
5899 To ensure that links are preserved, care should be taken to replicate
5900 your directory structure on the web server, and to use relative file
5901 paths. For example, if your org files are kept in @file{~/org} and your
5902 publishable images in @file{~/images}, you'd link to an image with
5904 @example
5905 file:../images/myimage.png
5906 @end example
5908 On the web server, the relative path to the image should be the
5909 same. You can accomplish this by setting up an "images" folder in the
5910 right place on the webserver, and publishing images to it.
5912 @lisp
5913 (setq org-publish-project-alist
5914       '(("orgfiles"
5915           :base-directory "~/org/"
5916           :base-extension "org"
5917           :publishing-directory "/ssh:user@@host:~/html/notebook/"
5918           :publishing-function org-publish-org-to-html
5919           :exclude "PrivatePage.org"   ;; regexp
5920           :headline-levels 3
5921           :section-numbers nil
5922           :table-of-contents nil
5923           :style "<link rel=stylesheet 
5924                   href=\"../other/mystyle.css\" type=\"text/css\">"
5925           :auto-preamble t
5926           :auto-postamble nil)
5927          
5928          ("images"
5929           :base-directory "~/images/"
5930           :base-extension "jpg\\|gif\\|png"
5931           :publishing-directory "/ssh:user@@host:~/html/images/"
5932           :publishing-function org-publish-attachment)
5934          ("other"
5935           :base-directory "~/other/"
5936           :base-extension "css\\|el"
5937           :publishing-directory "/ssh:user@@host:~/html/other/"
5938           :publishing-function org-publish-attachment)
5939          ("website" :components ("orgfiles" "images" "other"))))
5940 @end lisp
5942 @node Triggering publication,  , Sample configuration, Publishing
5943 @section Triggering publication
5945 Once org-publish is properly configured, you can publish with the
5946 following functions: 
5948 @table @kbd
5949 @item C-c C-e C
5950 Prompt for a specific project and publish all files that belong to it.
5951 @item C-c C-e P
5952 Publish the project containing the current file.
5953 @item C-c C-e F
5954 Publish only the current file.
5955 @item C-c C-e A
5956 Publish all projects.
5957 @end table
5959 Org uses timestamps to track when a file has changed. The above
5960 functions normally only publish changed files. You can override this and
5961 force publishing of all files by giving a prefix argument.
5963 @node Miscellaneous, Extensions and Hacking, Publishing, Top
5964 @chapter Miscellaneous
5966 @menu
5967 * Completion::                  M-TAB knows what you need
5968 * Customization::               Adapting Org-mode to your taste
5969 * In-buffer settings::          Overview of the #+KEYWORDS
5970 * The very busy C-c C-c key::   When in doubt, press C-c C-c
5971 * Clean view::                  Getting rid of leading stars in the outline
5972 * TTY keys::                    Using Org-mode on a tty
5973 * Interaction::                 Other Emacs packages
5974 * Bugs::                        Things which do not work perfectly
5975 @end menu
5977 @node Completion, Customization, Miscellaneous, Miscellaneous
5978 @section Completion
5979 @cindex completion, of @TeX{} symbols
5980 @cindex completion, of TODO keywords
5981 @cindex completion, of dictionary words
5982 @cindex completion, of option keywords
5983 @cindex completion, of tags
5984 @cindex completion, of link abbreviations
5985 @cindex @TeX{} symbol completion
5986 @cindex TODO keywords completion
5987 @cindex dictionary word completion
5988 @cindex option keyword completion
5989 @cindex tag completion
5990 @cindex link abbreviations, completion of
5992 Org-mode supports in-buffer completion.  This type of completion does
5993 not make use of the minibuffer.  You simply type a few letters into
5994 the buffer and use the key to complete text right there.
5996 @table @kbd
5997 @kindex M-@key{TAB}
5998 @item M-@key{TAB}
5999 Complete word at point
6000 @itemize @bullet
6001 @item
6002 At the beginning of a headline, complete TODO keywords.
6003 @item
6004 After @samp{\}, complete @TeX{} symbols supported by the exporter.
6005 @item
6006 After @samp{*}, complete headlines in the current buffer so that they
6007 can be used in search links like @samp{[[*find this headline]]}.
6008 @item
6009 After @samp{:}, complete tags.  The list of tags is taken from the
6010 variable @code{org-tag-alist} (possibly set through the @samp{#+TAGS}
6011 in-buffer option, @pxref{Setting tags}), or it is created dynamically
6012 from all tags used in the current buffer.
6013 @item
6014 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
6015 @item
6016 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
6017 @samp{OPTIONS} which set file-specific options for Org-mode.  When the
6018 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
6019 will insert example settings for this keyword.
6020 @item
6021 In the line after @samp{#+STARTUP: }, complete startup keywords,
6022 i.e. valid keys for this line.
6023 @item
6024 Elsewhere, complete dictionary words using ispell.
6025 @end itemize
6026 @end table
6028 @node Customization, In-buffer settings, Completion, Miscellaneous
6029 @section Customization
6030 @cindex customization
6031 @cindex options, for customization
6032 @cindex variables, for customization
6034 There are more than 180 variables that can be used to customize
6035 Org-mode.  For the sake of compactness of the manual, I am not
6036 describing the variables here.  A structured overview of customization
6037 variables is available with @kbd{M-x org-customize}.  Or select
6038 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
6039 settings can also be activated on a per-file basis, by putting special
6040 lines into the buffer (@pxref{In-buffer settings}).
6042 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
6043 @section Summary of in-buffer settings
6044 @cindex in-buffer settings
6045 @cindex special keywords
6047 Org-mode uses special lines in the buffer to define settings on a
6048 per-file basis.  These lines start with a @samp{#+} followed by a
6049 keyword, a colon, and then individual words defining a setting.  Several
6050 setting words can be in the same line, but you can also have multiple
6051 lines for the keyword.  While these settings are described throughout
6052 the manual, here is a summary.  After changing any of those lines in the
6053 buffer, press @kbd{C-c C-c} with the cursor still in the line to
6054 activate the changes immediately.  Otherwise they become effective only
6055 when the file is visited again in a new Emacs session.
6057 @table @kbd
6058 @item #+STARTUP:
6059 This line sets options to be used at startup of org-mode, when an
6060 Org-mode file is being visited.  The first set of options deals with the
6061 initial visibility of the outline tree.  The corresponding variable for
6062 global default settings is @code{org-startup-folded}, with a default
6063 value @code{t}, which means @code{overview}.
6064 @cindex @code{overview}, STARTUP keyword
6065 @cindex @code{content}, STARTUP keyword
6066 @cindex @code{showall}, STARTUP keyword
6067 @example
6068 overview   @r{top-level headlines only}
6069 content    @r{all headlines}
6070 showall    @r{no folding at all, show everything}
6071 @end example
6072 Then there are options for aligning tables upon visiting a file.  This
6073 is useful in files containing narrowed table columns.  The corresponding
6074 variable is @code{org-startup-align-all-tables}, with a default value
6075 @code{nil}. 
6076 @cindex @code{align}, STARTUP keyword
6077 @cindex @code{noalign}, STARTUP keyword
6078 @example
6079 align      @r{align all tables}
6080 noalign    @r{don't align tables on startup}
6081 @end example
6082 Logging TODO state changes and clock intervals (variable
6083 @code{org-log-done}) can be configured using these options.
6084 @cindex @code{logdone}, STARTUP keyword
6085 @cindex @code{nologging}, STARTUP keyword
6086 @cindex @code{lognotedone}, STARTUP keyword
6087 @cindex @code{lognoteclock-out}, STARTUP keyword
6088 @cindex @code{lognotestate}, STARTUP keyword
6089 @cindex @code{logrepeat}, STARTUP keyword
6090 @cindex @code{nologrepeat}, STARTUP keyword
6091 @example
6092 logging          @r{record a timestamp when an item is marked DONE}
6093 nologging        @r{don't record when items are marked DONE}
6094 lognotedone      @r{record timestamp and a note when DONE}
6095 lognotestate     @r{record timestamp, note when TODO state changes}
6096 logrepeat        @r{record a not when re-instating a repeating item}
6097 nologrepeat      @r{do not record when re-instating repeating item}
6098 lognoteclock-out @r{record timestamp and a note when clocking out}
6099 @end example
6100 Here are the options for hiding leading stars in outline headings.  The
6101 corresponding variables are @code{org-hide-leading-stars} and
6102 @code{org-odd-levels-only}, both with a default setting @code{nil}
6103 (meaning @code{showstars} and @code{oddeven}).
6104 @cindex @code{hidestars}, STARTUP keyword
6105 @cindex @code{showstars}, STARTUP keyword
6106 @cindex @code{odd}, STARTUP keyword
6107 @cindex @code{even}, STARTUP keyword
6108 @example
6109 hidestars  @r{make all but one of the stars starting a headline invisible.}
6110 showstars  @r{show all stars starting a headline}
6111 odd        @r{allow only odd outline levels (1,3,...)}
6112 oddeven    @r{allow all outline levels}
6113 @end example
6114 To turn on custom format overlays over time stamps (variables
6115 @code{org-put-time-stamp-overlays} and
6116 @code{org-time-stamp-overlay-formats}), use
6117 @cindex @code{customtime}, STARTUP keyword
6118 @example
6119 customtime @r{overlay custom time format}
6120 @end example
6121 The following options influence the table spreadsheet (variable
6122 @code{constants-unit-system}).
6123 @cindex @code{constcgs}, STARTUP keyword
6124 @cindex @code{constSI}, STARTUP keyword
6125 @example
6126 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
6127 constSI    @r{@file{constants.el} should use the SI unit system}
6128 @end example
6129 @item #+SEQ_TODO:   #+TYP_TODO:
6130 These lines set the TODO keywords and their interpretation in the
6131 current file.  The corresponding variables are @code{org-todo-keywords}
6132 and @code{org-todo-interpretation}.
6133 @item #+TAGS:  TAG1(c1) TAG2(c2)
6134 These lines (several such lines are allowed) specify the legal tags in
6135 this file, and (potentially) the corresponding @emph{fast tag selection}
6136 keys.  The corresponding variable is @code{org-tag-alist}.
6137 @item #+LINK:  linkword replace
6138 These lines (several are allowed) specify link abbreviations.
6139 @xref{Link abbreviations}.  The corresponding variable is
6140 @code{org-link-abbrev-alist}.
6141 @item #+CATEGORY:
6142 This line sets the category for the agenda file.  The category applies
6143 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
6144 end of the file.  The first such line also applies to any entries before it.
6145 @item #+ARCHIVE: %s_done::
6146 This line sets the archive location for the agenda file.  It applies for
6147 all subsequent lines until the next @samp{#+CATEGORY} line, or the end
6148 of the file.  The first such line also applies to any entries before it.
6149 The corresponding variable is @code{org-archive-location}.
6150 @item #+PRIORITIES: highest lowest default
6151 This line sets the limits and the default for the priorities.  All three
6152 must be either letters A-Z or numbers 0-9.  The highest priority must
6153 have a lower ASCII number that the lowest priority.
6154 @item #+TBLFM:
6155 This line contains the formulas for the table directly above the line.
6156 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS:
6157 These lines provide settings for exporting files.  For more details see
6158 @ref{Export options}.
6159 @end table
6161 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
6162 @section The very busy C-c C-c key
6163 @kindex C-c C-c
6164 @cindex C-c C-c, overview
6166 The key @kbd{C-c C-c} has many purposes in org-mode, which are all
6167 mentioned scattered throughout this manual.  One specific function of
6168 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
6169 other circumstances it means something like @emph{Hey Org-mode, look
6170 here and update according to what you see here}.  Here is a summary of
6171 what this means in different contexts.
6173 @itemize @minus
6174 @item
6175 If there are highlights in the buffer from the creation of a sparse
6176 tree, or from clock display, remove these highlights.
6177 @item
6178 If the cursor is in one of the special @code{#+KEYWORD} lines, this
6179 triggers scanning the buffer for these lines and updating the
6180 information. 
6181 @item
6182 If the cursor is inside a table, realign the table.  This command
6183 works even if the automatic table editor has been turned off.
6184 @item
6185 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
6186 the entire table.
6187 @item
6188 If the cursor is inside a table created by the @file{table.el} package,
6189 activate that table.
6190 @item
6191 If the current buffer is a remember buffer, close the note and file it.
6192 With a prefix argument, file it, without further interaction, to the
6193 default location.
6194 @item
6195 If the cursor is on a @code{<<<target>>>}, update radio targets and
6196 corresponding links in this buffer.
6197 @item
6198 If the cursor is in a plain list item with a checkbox, toggle the status
6199 of the checkbox.
6200 @item
6201 If the cursor is on a numbered item in a plain list, renumber the
6202 ordered list.
6203 @end itemize
6205 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
6206 @section A cleaner outline view
6207 @cindex hiding leading stars
6208 @cindex clean outline view
6210 Some people find it noisy and distracting that the Org-mode headlines
6211 are starting with a potentially large number of stars.  For example
6212 the tree from @ref{Headlines}:
6214 @example
6215 * Top level headline
6216 ** Second level
6217 *** 3rd level
6218     some text
6219 *** 3rd level
6220     more text
6221 * Another top level headline
6222 @end example
6224 @noindent
6225 Unfortunately this is deeply ingrained into the code of Org-mode and
6226 cannot be easily changed.  You can, however, modify the display in such
6227 a way that all leading stars become invisible and the outline more easy
6228 to read.  To do this, customize the variable
6229 @code{org-hide-leading-stars} like this:
6231 @lisp
6232 (setq org-hide-leading-stars t)
6233 @end lisp
6235 @noindent
6236 or change this on a per-file basis with one of the lines (anywhere in
6237 the buffer)
6239 @example
6240 #+STARTUP: showstars
6241 #+STARTUP: hidestars
6242 @end example
6244 @noindent
6245 Press @kbd{C-c C-c} with the cursor in a @samp{STARTUP} line to activate
6246 the modifications.
6248 With stars hidden, the tree becomes:
6250 @example
6251 * Top level headline
6252  * Second level
6253   * 3rd level
6254     some text
6255   * 3rd level
6256     more text
6257 * Another top level headline
6258 @end example
6260 @noindent
6261 Note that the leading stars are not truly replaced by whitespace, they
6262 are only fontified with the face @code{org-hide} that uses the
6263 background color as font color.  If you are not using either white or
6264 black background, you may have to customize this face to get the wanted
6265 effect.  Another possibility is to set this font such that the extra
6266 stars are @i{almost} invisible, for example using the color
6267 @code{grey90} on a white background.
6269 Things become cleaner still if you skip all the even levels and use only
6270 odd levels 1, 3, 5..., effectively adding two stars to go from one
6271 outline level to the next:
6273 @example
6274 * Top level headline
6275   * Second level
6276     * 3rd level
6277       some text
6278     * 3rd level
6279       more text
6280 * Another top level headline
6281 @end example
6283 @noindent
6284 In order to make the structure editing and export commands handle this
6285 convention correctly, use
6287 @lisp
6288 (setq org-odd-levels-only t)
6289 @end lisp
6291 @noindent
6292 or set this on a per-file basis with one of the following lines (don't
6293 forget to press @kbd{C-c C-c} with the cursor in the startup line to
6294 activate changes immediately).
6296 @example
6297 #+STARTUP: odd
6298 #+STARTUP: oddeven
6299 @end example
6301 You can convert an Org-mode file from single-star-per-level to the
6302 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
6303 RET} in that file.  The reverse operation is @kbd{M-x
6304 org-convert-to-oddeven-levels}.
6306 @node TTY keys, Interaction, Clean view, Miscellaneous
6307 @section Using org-mode on a tty
6308 @cindex tty keybindings
6310 Org-mode uses a number of keys that are not accessible on a tty.  This
6311 applies to most special keys like cursor keys, @key{TAB} and
6312 @key{RET}, when these are combined with modifier keys like @key{Meta}
6313 and/or @key{Shift}.  Org-mode uses these bindings because it needs to
6314 provide keys for a large number of commands, and because these keys
6315 appeared particularly easy to remember.  In order to still be able to
6316 access the core functionality of Org-mode on a tty, alternative
6317 bindings are provided.  Here is a complete list of these bindings,
6318 which are obviously more cumbersome to use.  Note that sometimes a
6319 work-around can be better.  For example changing a time stamp is
6320 really only fun with @kbd{S-@key{cursor}} keys.  On a tty you would
6321 rather use @kbd{C-c .}  to re-insert the timestamp.
6323 @multitable @columnfractions 0.15 0.2 0.2
6324 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
6325 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
6326 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
6327 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
6328 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
6329 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
6330 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
6331 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
6332 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
6333 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
6334 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
6335 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
6336 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
6337 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
6338 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
6339 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
6340 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
6341 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
6342 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
6343 @end multitable
6345 @node Interaction, Bugs, TTY keys, Miscellaneous
6346 @section Interaction with other packages
6347 @cindex packages, interaction with other
6348 Org-mode lives in the world of GNU Emacs and interacts in various ways
6349 with other code out there.
6351 @menu
6352 * Cooperation::                 Packages Org-mode cooperates with
6353 * Conflicts::                   Packages that lead to conflicts
6354 @end menu
6356 @node Cooperation, Conflicts, Interaction, Interaction
6357 @subsection Packages that Org-mode cooperates with
6359 @table @asis
6360 @cindex @file{calc.el}
6361 @item @file{calc.el} by Dave Gillespie
6362 Org-mode uses the calc package for implementing spreadsheet
6363 functionality in its tables (@pxref{The spreadsheet}).  Org-mode
6364 checks for the availability of calc by looking for the function
6365 @code{calc-eval} which should be autoloaded in your setup if calc has
6366 been installed properly.  As of Emacs 22, calc is part of the Emacs
6367 distribution.  Another possibility for interaction between the two
6368 packages is using calc for embedded calculations. @xref{Embedded Mode,
6369 , Embedded Mode, calc, GNU Emacs Calc Manual}.
6370 @cindex @file{constants.el}
6371 @item @file{constants.el} by Carsten Dominik
6372 In a table formula (@pxref{The spreadsheet}), it is possible to use
6373 names for natural constants or units.  Instead of defining your own
6374 constants in the variable @code{org-table-formula-constants}, install
6375 the @file{constants} package which defines a large number of constants
6376 and units, and lets you use unit prefixes like @samp{M} for
6377 @samp{Mega} etc.  You will need version 2.0 of this package, available
6378 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org-mode checks for
6379 the function @code{constants-get}, which has to be autoloaded in your
6380 setup.  See the installation instructions in the file
6381 @file{constants.el}.
6382 @item @file{cdlatex.el} by Carsten Dominik
6383 @cindex @file{cdlatex.el}
6384 Org-mode can make use of the cdlatex package to efficiently enter
6385 La@TeX{} fragments into Org-mode files. See @ref{CDLaTeX mode}.
6386 @item @file{remember.el} by John Wiegley
6387 @cindex @file{remember.el}
6388 Org mode cooperates with remember, see @ref{Remember}.
6389 @file{Remember.el} is not part of Emacs, find it on the web.
6390 @cindex @file{table.el}
6391 @item @file{table.el} by Takaaki Ota
6392 @kindex C-c C-c
6393 @cindex table editor, @file{table.el}
6394 @cindex @file{table.el}
6396 Complex ASCII tables with automatic line wrapping, column- and
6397 row-spanning, and alignment can be created using the Emacs table
6398 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
6399 and also part of Emacs 22).
6400 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org-mode
6401 will call @command{table-recognize-table} and move the cursor into the
6402 table.  Inside a table, the keymap of Org-mode is inactive.  In order
6403 to execute Org-mode-related commands, leave the table.
6405 @table @kbd
6406 @kindex C-c C-c
6407 @item C-c C-c
6408 Recognize @file{table.el} table.  Works when the cursor is in a
6409 table.el table.
6411 @kindex C-c ~
6412 @item C-c ~
6413 Insert a table.el table.  If there is already a table at point, this
6414 command converts it between the table.el format and the Org-mode
6415 format.  See the documentation string of the command
6416 @code{org-convert-table} for the restrictions under which this is
6417 possible.
6418 @end table
6419 @file{table.el} is part of Emacs 22.
6420 @cindex @file{footnote.el}
6421 @item @file{footnote.el} by Steven L. Baur
6422 Org-mode recognizes numerical footnotes as provided by this package
6423 (@pxref{Footnotes}).
6424 @end table
6426 @node Conflicts,  , Cooperation, Interaction
6427 @subsection Packages that lead to conflicts with Org-mode
6429 @table @asis
6431 @cindex @file{allout.el}
6432 @item @file{allout.el} by Ken Manheimer
6433 Startup of Org-mode may fail with the error message
6434 @code{(wrong-type-argument keymapp nil)} when there is an outdated
6435 version @file{allout.el} on the load path, for example the version
6436 distributed with Emacs 21.x.  Upgrade to Emacs 22 and this problem will
6437 disappear.  If for some reason you cannot do this, make sure that org.el
6438 is loaded @emph{before} @file{allout.el}, for example by putting
6439 @code{(require 'org)} early enough into your @file{.emacs} file.
6441 @cindex @file{CUA.el}
6442 @item @file{CUA.el} by Kim. F. Storm
6443 Keybindings in Org-mode conflict with the @kbd{S-<cursor>} keys
6444 used by CUA-mode (as well as pc-select-mode and s-region-mode) to
6445 select and extend the region.  If you want to use one of these
6446 packages along with Org-mode, configure the variable
6447 @code{org-CUA-compatible}.  When set, Org-mode will move the following
6448 keybindings in org-mode files, and in the agenda buffer (but not
6449 during date selection).
6451 @example
6452 S-UP    -> M-p             S-DOWN  -> M-n
6453 S-LEFT  -> M--             S-RIGHT -> M-+
6454 @end example
6456 Yes, these are unfortunately more difficult to remember.  If you want
6457 to have other replacement keys, look at the variable
6458 @code{org-disputed-keys}.
6459 @item @file{windmove.el} by Hovav Shacham
6460 @cindex @file{windmove.el}
6461 Also this package uses the @kbd{S-<cursor>} keys, so everything written
6462 in the paragraph above about CUA mode also applies here.
6464 @cindex @file{footnote.el}
6465 @item @file{footnote.el} by Steven L. Baur
6466 Org-mode supports the syntax of the footnote package, but only the
6467 numerical footnote markers.  Also, the default key for footnote
6468 commands, @kbd{C-c !} is already used by org-mode.  You could use the
6469 variable @code{footnote-prefix} to switch footnotes commands to another
6470 key.  Or, you could use @code{org-replace-disputed-keys} and
6471 @code{org-disputed-keys} to change the settings in Org-mode.
6473 @end table
6476 @node Bugs,  , Interaction, Miscellaneous
6477 @section Bugs
6478 @cindex bugs
6480 Here is a list of things that should work differently, but which I
6481 have found too hard to fix.
6483 @itemize @bullet
6484 @item
6485 If a table field starts with a link, and if the corresponding table
6486 column is narrowed (@pxref{Narrow columns}) to a width too small to
6487 display the link, the field would look entirely empty even though it is
6488 not.  To prevent this, Org-mode throws an error.  The work-around is to
6489 make the column wide enough to fit the link, or to add some text (at
6490 least 2 characters) before the link in the same field.
6491 @item
6492 Narrowing table columns does not work on XEmacs, because the
6493 @code{format} function does not transport text properties.
6494 @item
6495 Text in an entry protected with the @samp{QUOTE} keyword should not
6496 autowrap.
6497 @item
6498 When the application called by @kbd{C-c C-o} to open a file link fails
6499 (for example because the application does not exist or refuses to open
6500 the file), it does so silently.  No error message is displayed.
6501 @item
6502 Recalculating a table line applies the formulas from left to right.
6503 If a formula uses @emph{calculated} fields further down the row,
6504 multiple recalculation may be needed to get all fields consistent.  You
6505 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
6506 recalculate until convergence.
6507 @item
6508 A single letter cannot be made bold, for example @samp{*a*}.
6509 @item
6510 The exporters work well, but could be made more efficient.
6511 @end itemize
6514 @node Extensions and Hacking, History and Acknowledgments, Miscellaneous, Top
6515 @appendix Extensions, Hooks and Hacking
6517 This appendix lists extensions for Org-mode written by other authors.
6518 It also covers some aspects where users can extend the functionality of
6519 Org-mode.
6521 @menu
6522 * Extensions::                  Existing 3rd-part extensions
6523 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
6524 * Dynamic blocks::              Automatically filled blocks
6525 * Special agenda views::        Customized views
6526 @end menu
6528 @node Extensions, Tables in arbitrary syntax, Extensions and Hacking, Extensions and Hacking
6529 @section Third-party extensions for Org-mode
6530 @cindex extension, third-party
6532 The following extensions for Org-mode have been written by other people:
6534 @table @asis
6535 @cindex @file{org-publish.el}
6536 @item @file{org-publish.el} by David O'Toole
6537 This package provides facilities for publishing related sets of Org-mode
6538 files together with linked files like images as webpages.  It is
6539 highly configurable and can be used for other publishing purposes as
6540 well.  As of Org-mode version 4.30, @file{org-publish.el} is part of the
6541 Org-mode distribution.  It is not yet part of Emacs, however, a delay
6542 caused by the preparations for the 22.1 release.  In the mean time,
6543 @file{org-publish.el} can be downloaded from David's site:
6544 @url{http://dto.freeshell.org/e/org-publish.el}.
6545 @cindex @file{org-mouse.el}
6546 @item @file{org-mouse.el} by Piotr Zielinski
6547 This package implements extended mouse functionality for Org-mode.  It
6548 allows you to cycle visibility and to edit the document structure with
6549 the mouse.  Best of all, it provides a context-sensitive menu on
6550 @key{mouse-3} that changes depending on the context of a mouse-click.
6551 As of Org-mode version 4.53, @file{org-mouse.el} is part of the
6552 Org-mode distribution.  It is not yet part of Emacs, however, a delay
6553 caused by the preparations for the 22.1 release.  In the mean time,
6554 @file{org-mouse.el} can be downloaded from Piotr's site:
6555 @url{http://www.cl.cam.ac.uk/~pz215/files/org-mouse.el}.
6556 @cindex @file{org-blog.el}
6557 @item @file{org-blog.el} by David O'Toole
6558 A blogging plug-in for @file{org-publish.el}.@*
6559 @url{http://dto.freeshell.org/notebook/OrgMode.html}.
6560 @cindex @file{blorg.el}
6561 @item @file{blorg.el} by Bastien Guerry
6562 Publish Org-mode files as
6563 blogs. @url{http://www.cognition.ens.fr/~guerry/blorg.html}.
6564 @cindex @file{org2rem.el}
6565 @item @file{org2rem.el} by Bastien Guerry
6566 Translates Org-mode files into something readable by
6567 Remind. @url{http://www.cognition.ens.fr/~guerry/u/org2rem.el}.
6568 @end table
6570 @page
6572 @node Tables in arbitrary syntax, Dynamic blocks, Extensions, Extensions and Hacking
6573 @section Tables in arbitrary syntax
6574 @cindex tables, in other modes
6575 @cindex orgtbl-mode
6577 Since Orgtbl-mode can be used as a minor mode in arbitrary buffers, a
6578 frequent feature request has been to make it work with native tables in
6579 specific languages, for example LaTeX.  However, this is extremely hard
6580 to do in a general way, would lead to a customization nightmare, and
6581 would take away much of the simplicity of the Orgtbl-mode table editor.
6583 This appendix describes a different approach.  We keep the Orgtbl-mode
6584 table in its native format (the @i{source table}), and use a custom
6585 function to @i{translate} the table to the correct syntax, and to
6586 @i{install} it in the right location (the @i{target table}).  This puts
6587 the burden of writing conversion functions on the user, but it allows
6588 for a very flexible system.
6590 @menu
6591 * Radio tables::                Sending and receiving
6592 * A LaTeX example::             Step by step, almost a tutorial
6593 * Translator functions::        Copy and modify
6594 @end menu
6596 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
6597 @subsection Radio tables
6598 @cindex radio tables
6600 To define the location of the target table, you first need to create two
6601 lines that are comments in the current mode, but contain magic words for
6602 Orgtbl-mode to find.  Orgtbl-mode will insert the translated table
6603 between these lines, replacing whatever was there before.  For example:
6605 @example
6606 /* BEGIN RECEIVE ORGTBL table_name */
6607 /* END RECEIVE ORGTBL table_name */
6608 @end example
6610 @noindent
6611 Just above the source table, we put a special line that tells
6612 Orgtbl-mode how to translate this table and where to install it.  For
6613 example:
6614 @example
6615 #+ORGTBL: SEND table_name translation_function arguments....
6616 @end example
6618 @noindent
6619 @code{table_name} is the reference name for the table that is also used
6620 in the receiver lines. @code{translation_function} is the Lisp function
6621 that does the translation.  Furthermore, the line can contain a list of
6622 arguments (alternating key and value) at the end.  The arguments will be
6623 passed as a property list to the translation function for
6624 interpretation.  A few standard parameters are already recognized and
6625 acted upon before the translation function is called:
6627 @table @code
6628 @item :skip N
6629 Skip the first N lines of the table. Hlines do count!
6630 @item :skipcols (n1 n2 ...)
6631 List of columns that should be skipped.  If the table has a column with
6632 calculation marks, that column is automatically discarded as well.
6633 Please note that the translator function sees the table @emph{after} the
6634 removal of these columns, the function never knows that there have been
6635 additional columns.
6636 @end table
6638 @noindent
6639 The one problem remaining is how to keep the source table in the buffer
6640 without disturbing the normal workings of the file, for example during
6641 compilation of a C file or processing of a LaTeX file.  There are a
6642 number of different solutions:
6644 @itemize @bullet
6645 @item
6646 The table could be placed in a block comment if that is supported by the
6647 language.  For example, in C-mode you could wrap the table between
6648 @samp{/*} and @samp{*/} lines.
6649 @item 
6650 Sometimes it is possible to put the table after some kind of @i{END}
6651 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
6652 in LaTeX.
6653 @item
6654 You can just comment the table line by line whenever you want to process
6655 the file, and uncomment it whenever you need to edit the table.  This
6656 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
6657 make this comment-toggling very easy, in particular if you bind it to a
6658 key.
6659 @end itemize
6661 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
6662 @subsection A LaTeX example
6663 @cindex LaTeX, and orgtbl-mode
6665 The best way to wrap the source table in LaTeX is to use the
6666 @code{comment} environment provided by @file{comment.sty}.  It has to be
6667 activated by placing @code{\usepackage@{comment@}} into the document
6668 header.  Orgtbl-mode can insert a radio table skeleton@footnote{By
6669 default this works only for LaTeX, HTML, and TeXInfo.  Configure the
6670 variable @code{orgtbl-radio-tables} to install templates for other
6671 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
6672 be prompted for a table name, lets say we use @samp{salesfigures}.  You
6673 will then get the following template:
6675 @example
6676 % BEGIN RECEIVE ORGTBL salesfigures
6677 % END RECEIVE ORGTBL salesfigures
6678 \begin@{comment@}
6679 #+ORGTBL: SEND salesfigures orgtbl-to-latex
6680 | | |
6681 \end@{comment@}
6682 @end example
6684 @noindent
6685 The @code{#+ORGTBL: SEND} line tells orgtbl-mode to use the function
6686 @code{orgtbl-to-latex} to convert the table into LaTeX and to put it
6687 into the receiver location with name @code{salesfigures}.  You may now
6688 fill in the table, feel free to use the spreadsheet features@footnote{If
6689 the @samp{#+TBLFM} line contains an odd number of dollar characters,
6690 this may cause problems with font-lock in latex-mode.  As shown in the
6691 example you can fix this by adding an extra line inside the
6692 @code{comment} environment that is used to balance the dollar
6693 expressions.  If you are using AUCTeX with the font-latex library, a
6694 much better solution is to add the @code{comment} environment to the
6695 variable @code{LaTeX-verbatim-environments}.}:
6697 @example
6698 % BEGIN RECEIVE ORGTBL salesfigures
6699 % END RECEIVE ORGTBL salesfigures
6700 \begin@{comment@}
6701 #+ORGTBL: SEND salesfigures orgtbl-to-latex
6702 | Month | Days | Nr sold | per day |
6703 |-------+------+---------+---------|
6704 | Jan   |   23 |      55 |     2.4 |
6705 | Feb   |   21 |      16 |     0.8 |
6706 | March |   22 |     278 |    12.6 |
6707 #+TBLFM: $4=$3/$2;%.1f
6708 % $ (optional extra dollar to keep font-lock happy, see footnote)
6709 \end@{comment@}
6710 @end example
6712 @noindent
6713 When you are done, press @kbd{C-c C-c} in the table to get the converted
6714 table inserted between the two marker lines.
6716 Now lets assume you want to make the table header by hand, because you
6717 want to control how columns are aligned etc.  In this case we make sure
6718 that the table translator does skip the first 2 lines of the source
6719 table, and tell the command to work as a @i{splice}, i.e. to not produce
6720 header and footer commands of the target table:
6722 @example
6723 \begin@{tabular@}@{lrrr@}
6724 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
6725 % BEGIN RECEIVE ORGTBL salesfigures
6726 % END RECEIVE ORGTBL salesfigures
6727 \end@{tabular@}
6729 \begin@{comment@}
6730 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
6731 | Month | Days | Nr sold | per day |
6732 |-------+------+---------+---------|
6733 | Jan   |   23 |      55 |     2.4 |
6734 | Feb   |   21 |      16 |     0.8 |
6735 | March |   22 |     278 |    12.6 |
6736 #+TBLFM: $4=$3/$2;%.1f
6737 \end@{comment@}
6738 @end example
6740 The LaTeX translator function @code{orgtbl-to-latex} is already part of
6741 Orgtbl-mode.  It uses a @code{tabular} environment to typeset the table
6742 and marks horizontal lines with @code{\hline}.  Furthermore, it
6743 interprets the following parameters:
6745 @table @code
6746 @item :splice nil/t
6747 When set to t, return only table body lines, don't wrap them into a
6748 tabular environment.  Default is nil.
6750 @item :fmt fmt
6751 A format to be used to wrap each field, should contain @code{%s} for the
6752 original field value.  For example, to wrap each field value in dollars,
6753 you could use @code{:fmt "$%s$"}.  This may also be a property list with
6754 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
6756 @item :efmt efmt
6757 Use this format to print numbers with exponentials.  The format should
6758 have @code{%s} twice for inserting mantissa and exponent, for example
6759 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
6760 may also be a property list with column numbers and formats, for example
6761 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
6762 @code{efmt} has been applied to a value, @code{fmt} will also be
6763 applied.
6764 @end table
6766 @node Translator functions,  , A LaTeX example, Tables in arbitrary syntax
6767 @subsection Translator functions
6768 @cindex HTML, and orgtbl-mode
6769 @cindex translator function
6771 Orgtbl-mode has several translator functions built-in:
6772 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and
6773 @code{orgtbl-to-texinfo}.  Except for @code{orgtbl-to-html}@footnote{The
6774 HTML translator uses the same code that produces tables during HTML
6775 export.}, these all use a generic translator, @code{orgtbl-to-generic}.
6776 For example, @code{orgtbl-to-latex} itself is a very short function that
6777 computes the column definitions for the @code{tabular} environment,
6778 defines a few field and line separators and then hands over to the
6779 generic translator.  Here is the entire code:
6781 @lisp
6782 @group
6783 (defun orgtbl-to-latex (table params)
6784   "Convert the orgtbl-mode TABLE to LaTeX."
6785   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
6786                                org-table-last-alignment ""))
6787          (params2
6788           (list
6789            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
6790            :tend "\\end@{tabular@}"
6791            :lstart "" :lend " \\\\" :sep " & "
6792            :efmt "%s\\,(%s)" :hline "\\hline")))
6793     (orgtbl-to-generic table (org-combine-plists params2 params))))
6794 @end group
6795 @end lisp
6797 As you can see, the properties passed into the function (variable
6798 @var{PARAMS}) are combined with the ones newly defined in the function
6799 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
6800 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
6801 would like to use the LaTeX translator, but wanted the line endings to
6802 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
6803 overrule the default with
6805 @example
6806 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
6807 @end example
6809 For a new language, you can either write your own converter function in
6810 analogy with the LaTeX translator, or you can use the generic function
6811 directly.  For example, if you have a language where a table is started
6812 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
6813 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
6814 separator is a TAB, you could call the generic translator like this (on
6815 a single line!):
6817 @example
6818 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
6819                               :lstart "!BL! " :lend " !EL!" :sep "\t"
6820 @end example
6822 @noindent
6823 Please check the documentation string of the function
6824 @code{orgtbl-to-generic} for a full list of parameters understood by
6825 that function and remember that you can pass each of them into
6826 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
6827 using the generic function.
6829 Of course you can also write a completely new function doing complicated
6830 things the generic translator cannot do.  A translator function takes
6831 two arguments.  The first argument is the table, a list of lines, each
6832 line either the symbol @code{hline} or a list of fields.  The second
6833 argument is the property list containing all parameters specified in the
6834 @samp{#+ORGTBL: SEND} line.  The function must return a single string
6835 containing the formatted table.  If you write a generally useful
6836 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
6837 others can benefit from your work.
6839 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Extensions and Hacking
6840 @section Dynamic blocks
6841 @cindex dynamic blocks
6843 Org-mode documents can contain @emph{dynamic blocks}.  These are
6844 specially marked regions that are updated by some user-written function.
6845 A good example for such a block is the clock table inserted by the
6846 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
6848 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
6849 to the block and can also specify parameters for the function producing
6850 the content of the block.
6852 @example
6853 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
6855 #+END:
6856 @end example
6858 Dynamic blocks are updated with the following commands
6860 @table @kbd
6861 @kindex C-c C-x C-u
6862 @item C-c C-x C-u
6863 Update dynamic block at point.
6864 @kindex C-u C-c C-x C-u
6865 @item C-u C-c C-x C-u
6866 Update all dynamic blocks in the current file.
6867 @end table
6869 Updating a dynamic block means to remove all the text between BEGIN and
6870 END, parse the BEGIN line for parameters and then call the specific
6871 writer function for this block to insert the new content.  For a block
6872 with name @code{myblock}, the writer function is
6873 @code{org-dblock-write:myblock} with as only parameter a property list
6874 with the parameters given in the begin line.  Here is a trivial example
6875 of a block that keeps track of when the block update function was last
6876 run:
6878 @example
6879 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
6881 #+END:
6882 @end example
6884 @noindent
6885 The corresponding block writer function could look like this:
6887 @lisp
6888 (defun org-dblock-write:block-update-time (params)
6889    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
6890      (insert "Last block update at: "
6891              (format-time-string fmt (current-time)))))
6892 @end lisp
6894 If you want to make sure that all dynamic blocks are always up-to-date,
6895 you could add the function @code{org-update-all-dblocks} to a hook, for
6896 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
6897 written in a way that is does nothing in buffers that are not in Org-mode.
6899 @node Special agenda views,  , Dynamic blocks, Extensions and Hacking
6900 @section Special Agenda Views
6901 @cindex agenda views, user-defined
6903 Org-mode provides a special hook that can be used to narrow down the
6904 selection made by any of the agenda views.  You may specify a function
6905 that is used at each match to verify if the match should indeed be part
6906 of the agenda view, and if not, how much should be skipped.
6908 Let's say you want to produce a list of projects that contain a WAITING
6909 tag anywhere in the project tree.  Let's further assume that you have
6910 marked all tree headings that define a project with the todo keyword
6911 PROJECT.  In this case you would run a todo search for the keyword
6912 PROJECT, but skip the match unless there is a WAITING tag anywhere in
6913 the subtree belonging to the project line.
6915 To achieve this, you must write a function that searches the subtree for
6916 the tag.  If the tag is found, the function must return @code{nil} to
6917 indicate that this match should not be skipped.  If there is no such
6918 tag, return the location of the end of the subtree, to indicate that
6919 search should continue from there.
6921 @lisp
6922 (defun my-skip-unless-waiting ()
6923   "Skip trees that are not waiting"
6924   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
6925     (if (re-search-forward ":WAITING:" subtree-end t)
6926         nil          ; tag found, do not skip
6927       subtree-end))) ; tag not found, continue after end of subtree
6928 @end lisp
6930 Furthermore you must write a command that uses @code{let} to temporarily
6931 put this function into the variable @code{org-agenda-skip-function},
6932 sets the header string for the agenda buffer, and calls the todo-list
6933 generator while asking for the specific TODO keyword PROJECT.  The
6934 function must also accept one argument MATCH, but it can choose to
6935 ignore it@footnote{MATCH must be present in case you want to define a
6936 custom command for producing this special list.  Custom commands always
6937 supply the MATCH argument, but it can be empty if you do not specify it
6938 while defining the command(@pxref{Custom agenda
6939 views}).} (as we do in the example below).  Here is the example:
6941 @lisp
6942 (defun my-org-waiting-projects (&optional match)
6943   "Produce a list of projects that contain a WAITING tag.
6944 MATCH is being ignored."
6945   (interactive)
6946   (let ((org-agenda-skip-function 'my-skip-unless-waiting)
6947         (org-agenda-overriding-header "Projects waiting for something: "))
6948     ;; make the list
6949     (org-todo-list "PROJECT")))
6950 @end lisp
6953 @node History and Acknowledgments, Index, Extensions and Hacking, Top
6954 @appendix History and Acknowledgments
6955 @cindex acknowledgments
6956 @cindex history
6957 @cindex thanks
6959 Org-mode was borne in 2003, out of frustration over the user interface
6960 of the Emacs outline-mode.  I was trying to organize my notes and
6961 projects, and using Emacs seemed to be the natural way to go.  However,
6962 having to remember eleven different commands with two or three keys per
6963 command, only to hide and unhide parts of the outline tree, that seemed
6964 entirely unacceptable to me.  Also, when using outlines to take notes, I
6965 constantly want to restructure the tree, organizing it parallel to my
6966 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
6967 editing} were originally implemented in the package
6968 @file{outline-magic.el}, but quickly moved to the more general
6969 @file{org.el}.  As this environment became comfortable for project
6970 planning, the next step was adding @emph{TODO entries}, basic @emph{time
6971 stamps}, and @emph{table support}.  These areas highlight the two main
6972 goals that Org-mode still has today: To create a new, outline-based,
6973 plain text mode with innovative and intuitive editing features, and to
6974 incorporate project planning functionality directly into a notes file.
6976 Since the first release, hundreds of emails to me or on
6977 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
6978 reports, feedback, new ideas, and sometimes patches and add-on code.
6979 Many thanks to everyone who has helped to improve this package.  I am
6980 trying to keep here a list of the people who had significant influence
6981 in shaping one or more aspects of Org-mode.  The list may not be
6982 complete, if I have forgotten someone, please accept my apologies and
6983 let me know.
6985 @itemize @bullet
6987 @item
6988 @i{Thomas Baumann} contributed the code for links to the MH-E email
6989 system.
6990 @item
6991 @i{Alex Bochannek} provided a patch for rounding time stamps.
6992 @item
6993 @i{Charles Cave}'s suggestion sparked the implementation of templates
6994 for Remember.
6995 @item
6996 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
6997 specified time.
6998 @item
6999 @i{Gregory Chernov} patched support for lisp forms into table
7000 calculations and improved XEmacs compatibility, in particular by porting
7001 @file{nouline.el} to XEmacs.
7002 @item
7003 @i{Sacha Chua} suggested to copy some linking code from Planner.
7004 @item
7005 @i{Eddward DeVilla} proposed and tested checkbox statistics.
7006 @item
7007 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
7008 inspired some of the early development, including HTML export.  He also
7009 asked for a way to narrow wide table columns.
7010 @item
7011 @i{Christian Egli} converted the documentation into TeXInfo format,
7012 patched CSS formatting into the HTML exporter, and inspired the agenda.
7013 @item
7014 @i{David Emery} provided a patch for custom CSS support in exported
7015 HTML agendas.
7016 @item
7017 @i{Nic Ferrier} contributed mailcap and XOXO support.
7018 @item
7019 @i{John Foerch} figured out how to make incremental search show context
7020 around a match in a hidden outline tree.
7021 @item
7022 @i{Niels Giessen} had the idea to automatically archive DONE trees.
7023 @item
7024 @i{Bastien Guerry} provided extensive feedback and some patches, and
7025 translated David O'Toole's tutorial into French.
7026 @item
7027 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
7028 @item
7029 @i{Shidai Liu} ("Leo") asked for embedded LaTeX and tested it.  He also
7030 provided frequent feedback and some patches.
7031 @item
7032 @i{Jason F. McBrayer} suggested agenda export to CSV format.
7033 @item
7034 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
7035 basis.
7036 @item
7037 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
7038 happy.
7039 @item
7040 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file.
7041 @item
7042 @i{Todd Neal} provided patches for links to Info files and elisp forms.
7043 @item
7044 @i{Tim O'Callaghan} suggested in-file links, search options for general
7045 file links, and TAGS.
7046 @item
7047 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
7048 into Japanese.
7049 @item
7050 @i{Oliver Oppitz} suggested multi-state TODO items.
7051 @item
7052 @i{Scott Otterson} sparked the introduction of descriptive text for
7053 links, among other things.
7054 @item
7055 @i{Pete Phillips} helped during the development of the TAGS feature, and
7056 provided frequent feedback.
7057 @item
7058 @i{T.V. Raman} reported bugs and suggested improvements.
7059 @item
7060 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
7061 control.
7062 @item
7063 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
7064 @item
7065 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
7066 conflict with @file{allout.el}.
7067 @item
7068 @i{Jason Riedy} sent a patch to fix a bug with export of TODO keywords.
7069 @item
7070 @i{Philip Rooke} created the Org-mode reference card and provided lots
7071 of feedback.
7072 @item
7073 @i{Christian Schlauer} proposed angular brackets around links, among
7074 other things.
7075 @item
7076 Linking to VM/BBDB/GNUS was inspired by @i{Tom Shannon}'s
7077 @file{organizer-mode.el}.
7078 @item
7079 @i{Daniel Sinder} came up with the idea of internal archiving by locking
7080 subtrees.
7081 @item
7082 @i{Dale Smith} proposed link abbreviations.
7083 @item
7084 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
7085 chapter about publishing.
7086 @item
7087 @i{J@"urgen Vollmer} contributed code generating the table of contents
7088 in HTML output.
7089 @item
7090 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
7091 keyword.
7092 @item
7093 @i{David Wainberg} suggested archiving, and improvements to the linking
7094 system.
7095 @item
7096 @i{John Wiegley} wrote @file{emacs-wiki.el} and @file{planner.el}.  The
7097 development of Org-mode was fully independent, and both systems are
7098 really different beasts in their basic ideas and implementation details.
7099 I later looked at John's code, however, and learned from his
7100 implementation of (i) links where the link itself is hidden and only a
7101 description is shown, and (ii) popping up a calendar to select a date.
7102 @item
7103 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
7104 linking to GNUS.
7105 @item
7106 @i{Roland Winkler} requested additional keybindings to make Org-mode
7107 work on a tty.
7108 @item
7109 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
7110 and contributed various ideas and code snippets.
7111 @end itemize
7114 @node Index, Key Index, History and Acknowledgments, Top
7115 @unnumbered Index
7117 @printindex cp
7119 @node Key Index,  , Index, Top
7120 @unnumbered Key Index
7122 @printindex ky
7124 @bye
7126 @ignore
7127    arch-tag: 7893d1fe-cc57-4d13-b5e5-f494a1bcc7ac
7128 @end ignore