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