org.texi: Overwrite with the one generated from "org-manual.org"
[org-mode/org-tableheadings.git] / doc / org.texi
blobb78a22ef2e36a69704657e9a5b231ddf618e1be4
1 \input texinfo    @c -*- texinfo -*-
2 @c %**start of header
3 @setfilename org.info
4 @settitle The Org Manual
5 @documentencoding UTF-8
6 @documentlanguage en
7 @set txicodequoteundirected
8 @set txicodequotebacktick
9 @set MAINTAINERSITE @uref{https://orgmode.org,maintainers webpage}
10 @set MAINTAINER Carsten Dominik
11 @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
12 @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
13 @c %**end of header
15 @copying
16 This manual is for Org version 9.1.
18 Copyright @copyright{} 2004--2018  Free Software Foundation, Inc.
20 @quotation
21 Permission is granted to copy, distribute and/or modify this document
22 under the terms of the GNU Free Documentation License, Version 1.3 or
23 any later version published by the Free Software Foundation; with no
24 Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
25 and with the Back-Cover Texts as in (a) below.  A copy of the license
26 is included in the section entitled ``GNU Free Documentation License.''
28 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
29 modify this GNU manual.''
30 @end quotation
31 @end copying
33 @dircategory Emacs editing modes
34 @direntry
35 * Org Mode: (org).      Outline-based notes management and organizer.
36 @end direntry
38 @finalout
39 @titlepage
40 @title The Org Manual
41 @subtitle Release 9.1
42 @author by Carsten Dominik
43 @author with contributions by Bastien Guerry, Nicolas Goaziou, Eric Schulte, Jambunathan K, Dan Davison, Thomas Dye, David O'Toole, and Philip Rooke.
44 @page
45 @vskip 0pt plus 1filll
46 @insertcopying
47 @end titlepage
49 @contents
51 @ifnottex
52 @node Top
53 @top The Org Manual
55 @insertcopying
56 @end ifnottex
58 @menu
59 * Introduction::                 Getting started.
60 * Document Structure::           A tree works like your brain.
61 * Tables::                       Pure magic for quick formatting.
62 * Hyperlinks::                   Notes in context.
63 * TODO Items::                   Every tree branch can be a TODO item.
64 * Tags::                         Tagging headlines and matching sets of tags.
65 * Properties and Columns::       Storing information about an entry.
66 * Dates and Times::              Making items useful for planning.
67 * Capture, Refile, Archive: Capture Refile Archive.  The ins and outs for projects.
68 * Agenda Views::                 Collecting information into views.
69 * Markup::                       Prepare text for rich export.
70 * Exporting::                    Sharing and publishing notes.
71 * Publishing::                   Create a web site of linked Org files.
72 * Working with Source Code::     Export, evaluate, and tangle code blocks.
73 * Miscellaneous::                All the rest which did not fit elsewhere.
74 * Hacking::                      How to hack your way around.
75 * MobileOrg::                    Viewing and capture on a mobile device.
76 * History and Acknowledgments::  How Org came into being.
77 * GNU Free Documentation License:: The license for this documentation.
78 * Main Index::                   An index of Org's concepts and features.
79 * Key Index::                    Key bindings and where they are described.
80 * Command and Function Index::   Command names and some internal functions.
81 * Variable Index::               Variables mentioned in the manual.
83 @detailmenu
84 --- The Detailed Node Listing ---
86 Introduction
88 * Summary::                      Brief summary of what Org does.
89 * Installation::                 Installing Org.
90 * Activation::                   How to activate Org for certain buffers.
91 * Feedback::                     Bug reports, ideas, patches, etc.
92 * Conventions::                  Typesetting conventions used in this manual.
94 Document Structure
96 * Outlines::                     Org is based on Outline mode.
97 * Headlines::                    How to typeset Org tree headlines.
98 * Visibility Cycling::           Show and hide, much simplified.
99 * Motion::                       Jumping to other headlines.
100 * Structure Editing::            Changing sequence and level of headlines.
101 * Sparse Trees::                 Matches embedded in context.
102 * Plain Lists::                  Additional structure within an entry.
103 * Drawers::                      Tucking stuff away.
104 * Blocks::                       Folding blocks.
105 * Creating Footnotes::           How footnotes are defined in Org's syntax.
106 * Org Syntax::                   Formal description of Org's syntax.
108 Visibility Cycling
110 * Global and local cycling::     Cycling through various visibility states.
111 * Initial visibility::           Setting the initial visibility state.
112 * Catching invisible edits::     Preventing mistakes when editing invisible parts.
114 Tables
116 * Built-in Table Editor::        Simple tables.
117 * Column Width and Alignment::   Overrule the automatic settings.
118 * Column Groups::                Grouping to trigger vertical lines.
119 * Orgtbl Mode::                  The table editor as minor mode.
120 * The spreadsheet::              The table editor has spreadsheet capabilities.
121 * Org Plot::                     Plotting from Org tables.
123 The spreadsheet
125 * References::                   How to refer to another field or range.
126 * Formula syntax for Calc::      Using Calc to compute stuff.
127 * Formula syntax for Lisp::      Writing formulas in Emacs Lisp.
128 * Durations and time values::    How to compute durations and time values.
129 * Field and range formulas::     Formula for specific (ranges of) fields.
130 * Column formulas::              Formulas valid for an entire column.
131 * Lookup functions::             Lookup functions for searching tables.
132 * Editing and debugging formulas:: Fixing formulas.
133 * Updating the table::           Recomputing all dependent fields.
134 * Advanced features::            Field and column names, automatic recalculation...
136 Hyperlinks
138 * Link Format::                  How links in Org are formatted.
139 * Internal Links::               Links to other places in the current file.
140 * Radio Targets::                Make targets trigger links in plain text.
141 * External Links::               URL-like links to the world.
142 * Handling Links::               Creating, inserting and following.
143 * Using Links Outside Org::      Linking from my C source code?
144 * Link Abbreviations::           Shortcuts for writing complex links.
145 * Search Options::               Linking to a specific location.
146 * Custom Searches::              When the default search is not enough.
148 TODO Items
150 * TODO Basics::                  Marking and displaying TODO entries.
151 * TODO Extensions::              Workflow and assignments.
152 * Progress Logging::             Dates and notes for progress.
153 * Priorities::                   Some things are more important than others.
154 * Breaking Down Tasks::          Splitting a task into manageable pieces.
155 * Checkboxes::                   Tick-off lists.
157 TODO Extensions
159 * Workflow states::              From TODO to DONE in steps.
160 * TODO types::                   I do this, Fred does the rest.
161 * Multiple sets in one file::    Mixing it all, still finding your way.
162 * Fast access to TODO states::   Single letter selection of state.
163 * Per-file keywords::            Different files, different requirements.
164 * Faces for TODO keywords::      Highlighting states.
165 * TODO dependencies::            When one task needs to wait for others.
167 Progress Logging
169 * Closing items::                When was this entry marked DONE?
170 * Tracking TODO state changes::  When did the status change?
171 * Tracking your habits::         How consistent have you been?
173 Tags
175 * Tag Inheritance::              Tags use the tree structure of an outline.
176 * Setting Tags::                 How to assign tags to a headline.
177 * Tag Hierarchy::                Create a hierarchy of tags.
178 * Tag Searches::                 Searching for combinations of tags.
180 Properties and Columns
182 * Property Syntax::              How properties are spelled out.
183 * Special Properties::           Access to other Org mode features.
184 * Property Searches::            Matching property values.
185 * Property Inheritance::         Passing values down a tree.
186 * Column View::                  Tabular viewing and editing.
188 Column View
190 * Defining columns::             The COLUMNS format property.
191 * Using column view::            How to create and use column view.
192 * Capturing column view::        A dynamic block for column view.
194 Defining columns
196 * Scope of column definitions::  Where defined, where valid?
197 * Column attributes::            Appearance and content of a column.
199 Dates and Times
201 * Timestamps::                   Assigning a time to a tree entry.
202 * Creating Timestamps::          Commands to insert timestamps.
203 * Deadlines and Scheduling::     Planning your work.
204 * Clocking Work Time::           Tracking how long you spend on a task.
205 * Effort Estimates::             Planning work effort in advance.
206 * Timers::                       Notes with a running timer.
208 Creating Timestamps
210 * The date/time prompt::         How Org mode helps you enter dates and times.
211 * Custom time format::           Making dates look different.
213 Deadlines and Scheduling
215 * Inserting deadline/schedule::  Planning items.
216 * Repeated tasks::               Items that show up again and again.
218 Clocking Work Time
220 * Clocking commands::            Starting and stopping a clock.
221 * The clock table::              Detailed reports.
222 * Resolving idle time::          Resolving time when you've been idle.
224 Capture, Refile, Archive
226 * Capture::                      Capturing new stuff.
227 * Attachments::                  Add files to tasks.
228 * RSS Feeds::                    Getting input from RSS feeds.
229 * Protocols::                    External access to Emacs and Org.
230 * Refile and Copy::              Moving/copying a tree from one place to another.
231 * Archiving::                    What to do with finished products.
233 Capture
235 * Setting up capture::           Where notes will be stored.
236 * Using capture::                Commands to invoke and terminate capture.
237 * Capture templates::            Define the outline of different note types.
239 Capture templates
241 * Template elements::            What is needed for a complete template entry.
242 * Template expansion::           Filling in information about time and context.
243 * Templates in contexts::        Only show a template in a specific context.
245 Protocols
247 * @code{store-link} protocol::   Store a link, push URL to kill-ring.
248 * @code{capture} protocol::      Fill a buffer with external information.
249 * @code{open-source} protocol::  Edit published contents.
251 Archiving
253 * Moving subtrees::              Moving a tree to an archive file.
254 * Internal archiving::           Switch off a tree but keep it in the file.
256 Agenda Views
258 * Agenda Files::                 Files being searched for agenda information.
259 * Agenda Dispatcher::            Keyboard access to agenda views.
260 * Built-in Agenda Views::        What is available out of the box?
261 * Presentation and Sorting::     How agenda items are prepared for display.
262 * Agenda Commands::              Remote editing of Org trees.
263 * Custom Agenda Views::          Defining special searches and views.
264 * Exporting Agenda Views::       Writing a view to a file.
265 * Agenda Column View::           Using column view for collected entries.
267 Built-in Agenda Views
269 * Weekly/daily agenda::          The calendar page with current tasks.
270 * Global TODO list::             All unfinished action items.
271 * Matching tags and properties:: Structured information with fine-tuned search.
272 * Search view::                  Find entries by searching for text.
273 * Stuck projects::               Find projects you need to review.
275 Presentation and Sorting
277 * Categories::                   Not all tasks are equal.
278 * Time-of-day specifications::   How the agenda knows the time.
279 * Sorting of agenda items::      The order of things.
280 * Filtering/limiting agenda times:: Dynamically narrow the agenda.
282 Custom Agenda Views
284 * Storing searches::             Type once, use often.
285 * Block agenda::                 All the stuff you need in a single buffer.
286 * Setting options::              Changing the rules.
288 Markup
290 * Paragraphs::                   The basic unit of text.
291 * Emphasis and Monospace::       Bold, italic, etc.
292 * Horizontal Rules::             Make a line.
293 * Images and Tables::            Images, tables and caption mechanism.
294 * Literal Examples::             Source code examples with special formatting.
295 * Special Symbols::              Greek letters and other symbols.
296 * Subscripts and Superscripts::  Simple syntax for raising/lowering text.
297 * Embedded @LaTeX{}::            LaTeX can be freely used inside Org documents.
299 Embedded @LaTeX{}
301 * @LaTeX{} fragments::           Complex formulas made easy.
302 * Previewing @LaTeX{} fragments:: What will this snippet look like?
303 * CD@LaTeX{} mode::              Speed up entering of formulas.
305 Exporting
307 * The Export Dispatcher::        The main interface.
308 * Export Settings::              Common export settings.
309 * Table of Contents::            The if and where of the table of contents.
310 * Include Files::                Include additional files into a document.
311 * Macro Replacement::            Use macros to create templates.
312 * Comment Lines::                What will not be exported.
313 * ASCII/Latin-1/UTF-8 export::   Exporting to flat files with encoding.
314 * Beamer Export::
315 * HTML Export::                  Exporting to HTML.
316 * @LaTeX{} Export::              Exporting to @LaTeX{} and processing to PDF.
317 * Markdown Export::              Exporting to Markdown.
318 * OpenDocument Text Export::     Exporting to OpenDocument Text.
319 * Org Export::                   Exporting to Org.
320 * Texinfo Export::               Exporting to Texinfo.
321 * iCalendar Export::             Exporting to iCalendar.
322 * Other Built-in Back-ends::     Exporting to a man page.
323 * Advanced Configuration::       Fine-tuning the export output.
324 * Export in Foreign Buffers::    Author tables and lists in Org syntax.
326 Beamer Export
328 * Beamer export commands::       For creating Beamer documents.
329 * Beamer specific export settings:: For customizing Beamer export.
330 * Frames and Blocks in Beamer::  For composing Beamer slides.
331 * Beamer specific syntax::       For using in Org documents.
332 * Editing support::              Editing support.
333 * A Beamer example::             A complete presentation.
335 HTML Export
337 * HTML export commands::         Invoking HTML export.
338 * HTML specific export settings:: Settings for HTML export.
339 * HTML doctypes::                Exporting various (X)HTML flavors.
340 * HTML preamble and postamble::  Inserting preamble and postamble.
341 * Quoting HTML tags::            Using direct HTML in Org files.
342 * Links in HTML export::         Inserting and formatting links.
343 * Tables in HTML export::        How to modify the formatting of tables.
344 * Images in HTML export::        How to insert figures into HTML output.
345 * Math formatting in HTML export:: Beautiful math also on the web.
346 * Text areas in HTML export::    An alternate way to show an example.
347 * CSS support::                  Changing the appearance of the output.
348 * JavaScript support::           Info and folding in a web browser.
350 @LaTeX{} Export
352 * @LaTeX{}/PDF export commands:: For producing @LaTeX{} and PDF documents.
353 * @LaTeX{} specific export settings:: Unique to this @LaTeX{} back-end.
354 * @LaTeX{} header and sectioning:: Setting up the export file structure.
355 * Quoting @LaTeX{} code::        Incorporating literal @LaTeX{} code.
356 * Tables in @LaTeX{} export::    Options for exporting tables to @LaTeX{}.
357 * Images in @LaTeX{} export::    How to insert figures into @LaTeX{} output.
358 * Plain lists in @LaTeX{} export:: Attributes specific to lists.
359 * Source blocks in @LaTeX{} export:: Attributes specific to source code blocks.
360 * Example blocks in @LaTeX{} export:: Attributes specific to example blocks.
361 * Special blocks in @LaTeX{} export:: Attributes specific to special blocks.
362 * Horizontal rules in @LaTeX{} export:: Attributes specific to horizontal rules.
364 OpenDocument Text Export
366 * Pre-requisites for ODT export:: Required packages.
367 * ODT export commands::          Invoking export.
368 * ODT specific export settings:: Configuration options.
369 * Extending ODT export::         Producing DOC, PDF files.
370 * Applying custom styles::       Styling the output.
371 * Links in ODT export::          Handling and formatting links.
372 * Tables in ODT export::         Org tables conversions.
373 * Images in ODT export::         Inserting images.
374 * Math formatting in ODT export:: Formatting @LaTeX{} fragments.
375 * Labels and captions in ODT export:: Rendering objects.
376 * Literal examples in ODT export:: For source code and example blocks.
377 * Advanced topics in ODT export:: For power users.
379 Math formatting in ODT export
381 * @LaTeX{} math snippets::       Embedding in @LaTeX{} format.
382 * MathML and OpenDocument formula files:: Embedding in native format.
384 Texinfo Export
386 * Texinfo export commands::      Invoking commands.
387 * Texinfo specific export settings:: Setting the environment.
388 * Texinfo file header::          Generating the header.
389 * Texinfo title and copyright page:: Creating preamble pages.
390 * Info directory file::          Installing a manual in Info file hierarchy.
391 * Headings and sectioning structure:: Building document structure.
392 * Indices::                      Creating indices.
393 * Quoting Texinfo code::         Incorporating literal Texinfo code.
394 * Plain lists in Texinfo export:: List attributes.
395 * Tables in Texinfo export::     Table attributes.
396 * Images in Texinfo export::     Image attributes.
397 * Special blocks in Texinfo export:: Special block attributes.
398 * A Texinfo example::            Processing Org to Texinfo.
400 Publishing
402 * Configuration::                Defining projects.
403 * Uploading Files::              How to get files up on the server.
404 * Sample Configuration::         Example projects.
405 * Triggering Publication::       Publication commands.
407 Configuration
409 * Project alist::                The central configuration variable.
410 * Sources and destinations::     From here to there.
411 * Selecting files::              What files are part of the project?
412 * Publishing action::            Setting the function doing the publishing.
413 * Publishing options::           Tweaking HTML/@LaTeX{} export.
414 * Publishing links::             Which links keep working after publishing?
415 * Site map::                     Generating a list of all pages.
416 * Generating an index::          An index that reaches across pages.
418 Sample Configuration
420 * Simple example::               One-component publishing.
421 * Complex example::              A multi-component publishing example.
423 Working with Source Code
425 * Structure of Code Blocks::     Code block syntax described.
426 * Using Header Arguments::       Different ways to set header arguments.
427 * Environment of a Code Block::  Arguments, sessions, working directory...
428 * Evaluating Code Blocks::       Place results of evaluation in the Org buffer.
429 * Results of Evaluation::        Choosing a results type, post-processing...
430 * Exporting Code Blocks::        Export contents and/or results.
431 * Extracting Source Code::       Create pure source code files.
432 * Languages::                    List of supported code block languages.
433 * Editing Source Code::          Language major-mode editing.
434 * Noweb Reference Syntax::       Literate programming in Org mode.
435 * Library of Babel::             Use and contribute to a library of useful code blocks.
436 * Key bindings and Useful Functions:: Work quickly with code blocks.
437 * Batch Execution::              Call functions from the command line.
439 Miscellaneous
441 * Completion::                   M-@key{TAB} guesses completions.
442 * Structure Templates::          Quick insertion of structural elements.
443 * Speed Keys::                   Electric commands at the beginning of a headline.
444 * Code Evaluation Security::     Org files evaluate in-line code.
445 * Customization::                Adapting Org to your taste.
446 * In-buffer Settings::           Overview of keywords.
447 * The Very Busy @kbd{C-c C-c} Key:: When in doubt, press @kbd{C-c C-c}.
448 * Clean View::                   Getting rid of leading stars in the outline.
449 * TTY Keys::                     Using Org on a tty.
450 * Interaction::                  With other Emacs packages.
451 * Org Crypt::                    Encrypting Org files.
453 Interaction
455 * Cooperation::                  Packages Org cooperates with.
456 * Conflicts::                    Packages that lead to conflicts.
458 Hacking
460 * Hooks: Hooks (2).              How to reach into Org's internals.
461 * Add-on Packages::              Available extensions.
462 * Adding Hyperlink Types::       New custom link types.
463 * Adding Export Back-ends::      How to write new export back-ends.
464 * Tables in Arbitrary Syntax::   Orgtbl for LaTeX and other programs.
465 * Dynamic Blocks::               Automatically filled blocks.
466 * Special Agenda Views::         Customized views.
467 * Speeding Up Your Agendas::     Tips on how to speed up your agendas.
468 * Extracting Agenda Information:: Post-processing agenda information.
469 * Using the Property API::       Writing programs that use entry properties.
470 * Using the Mapping API::        Mapping over all or selected entries.
472 Tables in Arbitrary Syntax
474 * Radio tables::                 Sending and receiving radio tables.
475 * A @LaTeX{} example::           Step by step, almost a tutorial.
476 * Translator functions::         Copy and modify.
478 MobileOrg
480 * Setting Up the Staging Area::  For the mobile device.
481 * Pushing to MobileOrg::         Uploading Org files and agendas.
482 * Pulling from MobileOrg::       Integrating captured and flagged items.
484 @end detailmenu
485 @end menu
487 @node Introduction
488 @chapter Introduction
490 @cindex introduction
492 @menu
493 * Summary::                      Brief summary of what Org does.
494 * Installation::                 Installing Org.
495 * Activation::                   How to activate Org for certain buffers.
496 * Feedback::                     Bug reports, ideas, patches, etc.
497 * Conventions::                  Typesetting conventions used in this manual.
498 @end menu
500 @node Summary
501 @section Summary
503 @cindex summary
505 Org is a mode for keeping notes, maintaining TODO lists, and project
506 planning with a fast and effective plain-text system.  It also is an
507 authoring system with unique support for literate programming and
508 reproducible research.
510 Org is implemented on top of Outline mode, which makes it possible to
511 keep the content of large files well structured.  Visibility cycling
512 and structure editing help to work with the tree.  Tables are easily
513 created with a built-in table editor.  Plain text URL-like links
514 connect to websites, emails, Usenet messages, BBDB entries, and any
515 files related to the projects.
517 Org develops organizational tasks around notes files that contain
518 lists or information about projects as plain text.  Project planning
519 and task management makes use of metadata which is part of an outline
520 node.  Based on this data, specific entries can be extracted in
521 queries and create dynamic @emph{agenda views} that also integrate the
522 Emacs calendar and diary.  Org can be used to implement many different
523 project planning schemes, such as David Allen's GTD system.
525 Org files can serve as a single source authoring system with export to
526 many different formats such as HTML, @LaTeX{}, Open Document, and
527 Markdown.  New export backends can be derived from existing ones, or
528 defined from scratch.
530 Org files can include source code blocks, which makes Org uniquely
531 suited for authoring technical documents with code examples. Org
532 source code blocks are fully functional; they can be evaluated in
533 place and their results can be captured in the file.  This makes it
534 possible to create a single file reproducible research compendium.
536 Org keeps simple things simple.  When first fired up, it should feel
537 like a straightforward, easy to use outliner.  Complexity is not
538 imposed, but a large amount of functionality is available when needed.
539 Org is a toolbox.  Many users actually run only a---very
540 personal---fraction of Org's capabilities, and know that there is more
541 whenever they need it.
543 All of this is achieved with strictly plain text files, the most
544 portable and future-proof file format.  Org runs in Emacs.  Emacs is
545 one of the most widely ported programs, so that Org mode is available
546 on every major platform.
548 @cindex FAQ
549 There is a website for Org which provides links to the newest version
550 of Org, as well as additional information, frequently asked questions
551 (FAQ), links to tutorials, etc.  This page is located at
552 @uref{https://orgmode.org}.
554 @cindex print edition
555 An earlier version (7.3) of this manual is available as a @uref{http://www.network-theory.co.uk/org/manual/, paperback
556 book from Network Theory Ltd.}.
558 @node Installation
559 @section Installation
561 @cindex installation
563 Org is part of recent distributions of GNU Emacs, so you normally do
564 not need to install it.  If, for one reason or another, you want to
565 install Org on top of this pre-packaged version, there are three ways
566 to do it:
568 @itemize
569 @item
570 By using Emacs package system.
571 @item
572 By downloading Org as an archive.
573 @item
574 By using Org's git repository.
575 @end itemize
577 We @strong{strongly recommend} to stick to a single installation method.
579 @anchor{Using Emacs packaging system}
580 @subheading Using Emacs packaging system
582 Recent Emacs distributions include a packaging system which lets you
583 install Elisp libraries.  You can install Org with @kbd{M-x package-install @key{RET} org}.
585 @noindent
586 @strong{Important}: you need to do this in a session where no @samp{.org} file has
587 been visited, i.e., where no Org built-in function have been loaded.
588 Otherwise autoload Org functions will mess up the installation.
590 Then, to make sure your Org configuration is taken into account,
591 initialize the package system with @code{(package-initialize)} in your
592 Emacs init file before setting any Org option.  If you want to use
593 Org's package repository, check out the @uref{https://orgmode.org/elpa.html, Org ELPA page}.
595 @anchor{Downloading Org as an archive}
596 @subheading Downloading Org as an archive
598 You can download Org latest release from @uref{https://orgmode.org/, Org's website}.  In this case,
599 make sure you set the load-path correctly in your Emacs init file:
601 @lisp
602 (add-to-list 'load-path "~/path/to/orgdir/lisp")
603 @end lisp
605 The downloaded archive contains contributed libraries that are not
606 included in Emacs.  If you want to use them, add the @samp{contrib/}
607 directory to your load-path:
609 @lisp
610 (add-to-list 'load-path "~/path/to/orgdir/contrib/lisp" t)
611 @end lisp
613 Optionally, you can compile the files and/or install them in your
614 system.  Run @samp{make help} to list compilation and installation options.
616 @anchor{Using Org's git repository}
617 @subheading Using Org's git repository
619 You can clone Org's repository and install Org like this:
621 @example
622 $ cd ~/src/
623 $ git clone git@@code.orgmode.org:bzg/org-mode.git
624 $ make autoloads
625 @end example
627 Note that in this case, @code{make autoloads} is mandatory: it defines
628 Org's version in @samp{org-version.el} and Org's autoloads in
629 @samp{org-loaddefs.el}.
631 Remember to add the correct load-path as described in the method
632 above.
634 You can also compile with @samp{make}, generate the documentation with
635 @samp{make doc}, create a local configuration with @samp{make config} and
636 install Org with @samp{make install}.  Please run @samp{make help} to get the
637 list of compilation/installation options.
639 For more detailed explanations on Org's build system, please check the
640 Org Build System page on @uref{https://orgmode.org/worg/dev/org-build-system.html, Worg}.
642 @node Activation
643 @section Activation
645 @cindex activation
646 @cindex autoload
647 @cindex ELPA
648 @cindex global key bindings
649 @cindex key bindings, global
651 Org mode buffers need Font Lock to be turned on: this is the default
652 in Emacs@footnote{If you do not use Font Lock globally turn it on in Org buffer
653 with @code{(add-hook 'org-mode-hook 'turn-on-font-lock)}.}.
655 There are compatibility issues between Org mode and some other Elisp
656 packages (see @ref{Conflicts}).  Please take the
657 time to check the list.
659 @findex org-agenda
660 @findex org-capture
661 @findex org-store-link
662 For a better experience, the three Org commands @code{org-store-link},
663 @code{org-capture} and @code{org-agenda} ought to be accessible anywhere in
664 Emacs, not just in Org buffers.  To that effect, you need to bind them
665 to globally available keys, like the ones reserved for users (see
666 @ref{Key Binding Conventions,,,elisp,}).  Here are suggested
667 bindings, please modify the keys to your own liking.
669 @lisp
670 (global-set-key "\C-cl" 'org-store-link)
671 (global-set-key "\C-ca" 'org-agenda)
672 (global-set-key "\C-cc" 'org-capture)
673 @end lisp
675 @cindex Org mode, turning on
676 Files with the @samp{.org} extension use Org mode by default.  To turn on
677 Org mode in a file that does not have the extension @samp{.org}, make the
678 first line of a file look like this:
680 @example
681 MY PROJECTS    -*- mode: org; -*-
682 @end example
684 @vindex org-insert-mode-line-in-empty-file
685 @noindent
686 which selects Org mode for this buffer no matter what the file's name
687 is.  See also the variable @code{org-insert-mode-line-in-empty-file}.
689 Many commands in Org work on the region if the region is @emph{active}.  To
690 make use of this, you need to have @code{transient-mark-mode} turned on,
691 which is the default.  If you do not like @code{transient-mark-mode}, you
692 can create an active region by using the mouse to select a region, or
693 pressing @kbd{C-@key{SPC}} twice before moving the cursor.
695 @node Feedback
696 @section Feedback
698 @cindex feedback
699 @cindex bug reports
700 @cindex reporting a bug
701 @cindex maintainer
702 @cindex author
704 If you find problems with Org, or if you have questions, remarks, or
705 ideas about it, please mail to the Org mailing list
706 @email{emacs-orgmode@@gnu.org}.  You can subscribe to the list @uref{https://lists.gnu.org/mailman/listinfo/emacs-orgmode, on this
707 web page}.  If you are not a member of the mailing list, your mail will
708 be passed to the list after a moderator has approved it@footnote{Please consider subscribing to the mailing list in order to
709 minimize the work the mailing list moderators have to do.}.
711 @findex org-version
712 @findex org-submit-bug-report
713 For bug reports, please first try to reproduce the bug with the latest
714 version of Org available---if you are running an outdated version, it
715 is quite possible that the bug has been fixed already.  If the bug
716 persists, prepare a report and provide as much information as
717 possible, including the version information of Emacs (@kbd{M-x emacs-version}) and Org (@kbd{M-x org-version}), as well as
718 the Org related setup in the Emacs init file.  The easiest way to do
719 this is to use the command
721 @example
722 M-x org-submit-bug-report <RET>
723 @end example
725 @noindent
726 which puts all this information into an Emacs mail buffer so that you
727 only need to add your description.  If you are not sending the Email
728 from within Emacs, please copy and paste the content into your Email
729 program.
731 Sometimes you might face a problem due to an error in your Emacs or
732 Org mode setup.  Before reporting a bug, it is very helpful to start
733 Emacs with minimal customizations and reproduce the problem.  Doing so
734 often helps you determine if the problem is with your customization or
735 with Org mode itself.  You can start a typical minimal session with
736 a command like the example below.
738 @example
739 $ emacs -Q -l /path/to/minimal-org.el
740 @end example
742 However if you are using Org mode as distributed with Emacs, a minimal
743 setup is not necessary.  In that case it is sufficient to start Emacs
744 as @samp{emacs -Q}.  The @samp{minimal-org.el} setup file can have contents as
745 shown below.
747 @lisp
748 ;;; Minimal setup to load latest `org-mode'.
750 ;; Activate debugging.
751 (setq debug-on-error t
752       debug-on-signal nil
753       debug-on-quit nil)
755 ;; Add latest Org mode to load path.
756 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
757 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t))
758 @end lisp
760 If an error occurs, a ``backtrace'' can be very useful---see below on
761 how to create one.  Often a small example file helps, along with clear
762 information about:
764 @enumerate
765 @item
766 What exactly did you do?
767 @item
768 What did you expect to happen?
769 @item
770 What happened instead?
771 @end enumerate
773 @noindent
774 Thank you for helping to improve this program.
776 @anchor{How to create a useful backtrace}
777 @subheading How to create a useful backtrace
779 @cindex backtrace of an error
780 If working with Org produces an error with a message you do not
781 understand, you may have hit a bug.  The best way to report this is by
782 providing, in addition to what was mentioned above, a backtrace.  This
783 is information from the built-in debugger about where and how the
784 error occurred.  Here is how to produce a useful backtrace:
786 @enumerate
787 @item
788 Reload uncompiled versions of all Org mode Lisp files.  The
789 backtrace contains much more information if it is produced with
790 uncompiled code.  To do this, use
792 @example
793 C-u M-x org-reload <RET>
794 @end example
796 @noindent
797 or, from the menu: Org @arrow{} Refresh/Reload @arrow{} Reload Org uncompiled.
799 @item
800 Then, activate the debugger:
802 @example
803 M-x toggle-debug-or-error <RET>
804 @end example
806 @noindent
807 or, from the menu: Options @arrow{} Enter Debugger on Error.
809 @item
810 Do whatever you have to do to hit the error.  Do not forget to
811 document the steps you take.
813 @item
814 When you hit the error, a @samp{*Backtrace*} buffer appears on the
815 screen.  Save this buffer to a file---for example using @kbd{C-x C-w}---and attach it to your bug report.
816 @end enumerate
818 @node Conventions
819 @section Typesetting Conventions Used in this Manual
823 @anchor{TODO keywords tags properties etc}
824 @subheading TODO keywords, tags, properties, etc.
826 Org uses various syntactical elements: TODO keywords, tags, property
827 names, keywords, blocks, etc.  In this manual we use the following
828 conventions:
830 @table @asis
831 @item @samp{TODO}
832 @itemx @samp{WAITING}
833 TODO keywords are written with all capitals, even if they are
834 user-defined.
836 @item @samp{boss}
837 @itemx @samp{ARCHIVE}
838 User-defined tags are written in lowercase; built-in tags with
839 special meaning are written with all capitals.
841 @item @samp{Release}
842 @itemx @samp{PRIORITY}
843 User-defined properties are capitalized; built-in properties with
844 special meaning are written with all capitals.
846 @item @samp{TITLE}
847 @itemx @samp{BEGIN} @dots{} @samp{END}
848 Keywords and blocks are written in uppercase to enhance their
849 readability, but you can use lowercase in your Org files.
850 @end table
852 @anchor{Key bindings and commands}
853 @subheading Key bindings and commands
855 The manual lists both the keys and the corresponding commands for
856 accessing a functionality.  Org mode often uses the same key for
857 different functions, depending on context.  The command that is bound
858 to such keys has a generic name, like @code{org-metaright}.  In the manual
859 we will, wherever possible, give the function that is internally
860 called by the generic command.  For example, in the chapter on
861 document structure, @kbd{M-@key{RIGHT}} will be listed to call
862 @code{org-do-demote}, while in the chapter on tables, it will be listed to
863 call @code{org-table-move-column-right}.
865 @node Document Structure
866 @chapter Document Structure
868 @cindex document structure
869 @cindex structure of document
871 Org is based on Outline mode and provides flexible commands to
872 edit the structure of the document.
874 @menu
875 * Outlines::                     Org is based on Outline mode.
876 * Headlines::                    How to typeset Org tree headlines.
877 * Visibility Cycling::           Show and hide, much simplified.
878 * Motion::                       Jumping to other headlines.
879 * Structure Editing::            Changing sequence and level of headlines.
880 * Sparse Trees::                 Matches embedded in context.
881 * Plain Lists::                  Additional structure within an entry.
882 * Drawers::                      Tucking stuff away.
883 * Blocks::                       Folding blocks.
884 * Creating Footnotes::           How footnotes are defined in Org's syntax.
885 * Org Syntax::                   Formal description of Org's syntax.
886 @end menu
888 @node Outlines
889 @section Outlines
891 @cindex outlines
892 @cindex Outline mode
894 Org is implemented on top of Outline mode.  Outlines allow a document
895 to be organized in a hierarchical structure, which, least for me, is
896 the best representation of notes and thoughts.  An overview of this
897 structure is achieved by folding, i.e., hiding large parts of the
898 document to show only the general document structure and the parts
899 currently being worked on.  Org greatly simplifies the use of outlines
900 by compressing the entire show and hide functionalities into a single
901 command, @code{org-cycle}, which is bound to the @kbd{@key{TAB}} key.
903 @node Headlines
904 @section Headlines
906 @cindex headlines
907 @cindex outline tree
908 @vindex org-special-ctrl-a/e
909 @vindex org-special-ctrl-k
910 @vindex org-ctrl-k-protect-subtree
912 Headlines define the structure of an outline tree.  The headlines in
913 Org start with one or more stars, on the left margin@footnote{See the variables @code{org-special-ctrl-a/e}, @code{org-special-ctrl-k},
914 and @code{org-ctrl-k-protect-subtree} to configure special behavior of
915 @kbd{C-a}, @kbd{C-e}, and @kbd{C-k} in headlines.  Note
916 also that clocking only works with headings indented less than 30
917 stars.}.  For
918 example:
920 @example
921 * Top level headline
922 ** Second level
923 *** Third level
924     some text
925 *** Third level
926     more text
927 * Another top level headline
928 @end example
930 @vindex org-footnote-section
931 @noindent
932 Note that the name defined in @code{org-footnote-section} is reserved.  Do
933 not use it as a title for your own headings.
935 Some people find the many stars too noisy and would prefer an outline
936 that has whitespace followed by a single star as headline starters.
937 See @ref{Clean View}.
939 @vindex org-cycle-separator-lines
940 An empty line after the end of a subtree is considered part of it and
941 is hidden when the subtree is folded.  However, if you leave at least
942 two empty lines, one empty line remains visible after folding the
943 subtree, in order to structure the collapsed view.  See the variable
944 @code{org-cycle-separator-lines} to modify this behavior.
946 @node Visibility Cycling
947 @section Visibility Cycling
949 @cindex cycling, visibility
950 @cindex visibility cycling
951 @cindex trees, visibility
952 @cindex show hidden text
953 @cindex hide text
955 @menu
956 * Global and local cycling::     Cycling through various visibility states.
957 * Initial visibility::           Setting the initial visibility state.
958 * Catching invisible edits::     Preventing mistakes when editing invisible parts.
959 @end menu
961 @node Global and local cycling
962 @subsection Global and local cycling
964 @cindex subtree visibility states
965 @cindex subtree cycling
966 @cindex folded, subtree visibility state
967 @cindex children, subtree visibility state
968 @cindex subtree, subtree visibility state
970 Outlines make it possible to hide parts of the text in the buffer.
971 Org uses just two commands, bound to @kbd{@key{TAB}} and
972 @kbd{S-@key{TAB}} to change the visibility in the buffer.
974 @table @asis
975 @item @kbd{@key{TAB}} (@code{org-cycle})
976 @kindex TAB
977 @findex org-cycle
978 @emph{Subtree cycling}: Rotate current subtree among the states
980 @example
981 ,-> FOLDED -> CHILDREN -> SUBTREE --.
982 '-----------------------------------'
983 @end example
985 @vindex org-cycle-emulate-tab
986 The cursor must be on a headline for this to work@footnote{See, however, the option @code{org-cycle-emulate-tab}.}.
988 @item @kbd{S-@key{TAB}} (@code{org-global-cycle})
989 @itemx @kbd{C-u @key{TAB}}
990 @cindex global visibility states
991 @cindex global cycling
992 @cindex overview, global visibility state
993 @cindex contents, global visibility state
994 @cindex show all, global visibility state
995 @kindex C-u TAB
996 @kindex S-TAB
997 @findex org-global-cycle
998 @emph{Global cycling}: Rotate the entire buffer among the states
1000 @example
1001 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
1002 '--------------------------------------'
1003 @end example
1005 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N,
1006 the CONTENTS view up to headlines of level N are shown.  Note
1007 that inside tables (see @ref{Tables}), @kbd{S-@key{TAB}} jumps to the
1008 previous field instead.
1010 @vindex org-cycle-global-at-bob
1011 You can run global cycling using @kbd{@key{TAB}} only if point is
1012 at the very beginning of the buffer, but not on a headline, and
1013 @code{org-cycle-global-at-bob} is set to a non-@code{nil} value.
1015 @item @kbd{C-u C-u @key{TAB}} (@code{org-set-startup-visibility})
1016 @cindex startup visibility
1017 @kindex C-u C-u TAB
1018 @findex org-set-startup-visibility
1019 Switch back to the startup visibility of the buffer (see @ref{Initial visibility}).
1021 @item @kbd{C-u C-u C-u @key{TAB}} (@code{outline-show-all})
1022 @cindex show all, command
1023 @kindex C-u C-u C-u TAB
1024 @findex outline-show-all
1025 Show all, including drawers.
1027 @item @kbd{C-c C-r} (@code{org-reveal})
1028 @cindex revealing context
1029 @kindex C-c C-r
1030 @findex org-reveal
1031 Reveal context around point, showing the current entry, the
1032 following heading and the hierarchy above.  Useful for working
1033 near a location that has been exposed by a sparse tree command
1034 (see @ref{Sparse Trees}) or an agenda command (see @ref{Agenda Commands}).  With a prefix argument show, on each level, all
1035 sibling headings.  With a double prefix argument, also show the
1036 entire subtree of the parent.
1038 @item @kbd{C-c C-k} (@code{outline-show-branches})
1039 @cindex show branches, command
1040 @kindex C-c C-k
1041 @findex outline-show-branches
1042 Expose all the headings of the subtree, CONTENTS view for just
1043 one subtree.
1045 @item @kbd{C-c @key{TAB}} (@code{outline-show-children})
1046 @cindex show children, command
1047 @kindex C-c TAB
1048 @findex outline-show-children
1049 Expose all direct children of the subtree.  With a numeric prefix
1050 argument N, expose all children down to level N.
1052 @item @kbd{C-c C-x b} (@code{org-tree-to-indirect-buffer})
1053 @kindex C-c C-x b
1054 @findex org-tree-to-indirect-buffer
1055 Show the current subtree in an indirect buffer@footnote{The indirect buffer contains the entire buffer, but is narrowed
1056 to the current tree.  Editing the indirect buffer also changes the
1057 original buffer, but without affecting visibility in that buffer.  For
1058 more information about indirect buffers, see @ref{Indirect Buffers,GNU Emacs Manual,,emacs,}.}.  With
1059 a numeric prefix argument, N, go up to level N and then take that
1060 tree.  If N is negative then go up that many levels.  With
1061 a @kbd{C-u} prefix, do not remove the previously used
1062 indirect buffer.
1064 @item @kbd{C-c C-x v} (@code{org-copy-visible})
1065 @kindex C-c C-x v
1066 @findex org-copy-visible
1067 Copy the @emph{visible} text in the region into the kill ring.
1068 @end table
1070 @node Initial visibility
1071 @subsection Initial visibility
1073 @vindex org-startup-folded
1074 When Emacs first visits an Org file, the global state is set to
1075 OVERVIEW, i.e., only the top level headlines are visible@footnote{When @code{org-agenda-inhibit-startup} is non-@code{nil}, Org does not
1076 honor the default visibility state when first opening a file for the
1077 agenda (see @ref{Speeding Up Your Agendas}).}.  This
1078 can be configured through the variable @code{org-startup-folded}, or on
1079 a per-file basis by adding one of the following lines anywhere in the
1080 buffer:
1082 @cindex STARTUP, keyword
1083 @example
1084 #+STARTUP: overview
1085 #+STARTUP: content
1086 #+STARTUP: showall
1087 #+STARTUP: showeverything
1088 @end example
1090 @cindex @samp{VISIBILITY}, property
1091 @noindent
1092 Furthermore, any entries with a @samp{VISIBILITY} property (see @ref{Properties and Columns}) get their visibility adapted accordingly.  Allowed values
1093 for this property are @samp{folded}, @samp{children}, @samp{content}, and @code{all}.
1095 @table @asis
1096 @item @kbd{C-u C-u @key{TAB}} (@code{org-set-startup-visibility})
1097 @kindex C-u C-u TAB
1098 @findex org-set-startup-visibility
1099 Switch back to the startup visibility of the buffer, i.e.,
1100 whatever is requested by startup options and @samp{VISIBILITY}
1101 properties in individual entries.
1102 @end table
1104 @node Catching invisible edits
1105 @subsection Catching invisible edits
1107 @cindex edits, catching invisible
1109 @vindex org-catch-invisible-edits
1110 Sometimes you may inadvertently edit an invisible part of the buffer
1111 and be confused on what has been edited and how to undo the mistake.
1112 Setting @code{org-catch-invisible-edits} to non-@code{nil} helps preventing
1113 this.  See the docstring of this option on how Org should catch
1114 invisible edits and process them.
1116 @node Motion
1117 @section Motion
1119 @cindex motion, between headlines
1120 @cindex jumping, to headlines
1121 @cindex headline navigation
1123 The following commands jump to other headlines in the buffer.
1125 @table @asis
1126 @item @kbd{C-c C-n} (@code{outline-next-visible-heading})
1127 @kindex C-c C-n
1128 @findex outline-next-visible-heading
1129 Next heading.
1131 @item @kbd{C-c C-p} (@code{outline-previous-visible-heading})
1132 @kindex C-c C-p
1133 @findex outline-previous-visible-heading
1134 Previous heading.
1136 @item @kbd{C-c C-f} (@code{org-forward-same-level})
1137 @kindex C-c C-f
1138 @findex org-forward-same-level
1139 Next heading same level.
1141 @item @kbd{C-c C-b} (@code{org-backward-same-level})
1142 @kindex C-c C-b
1143 @findex org-backward-same-level
1144 Previous heading same level.
1146 @item @kbd{C-c C-u} (@code{outline-up-heading})
1147 @kindex C-c C-u
1148 @findex outline-up-heading
1149 Backward to higher level heading.
1151 @item @kbd{C-c C-j} (@code{org-goto})
1152 @kindex C-c C-j
1153 @findex org-goto
1154 @vindex org-goto-auto-isearch
1155 Jump to a different place without changing the current outline
1156 visibility.  Shows the document structure in a temporary buffer,
1157 where you can use the following keys to find your destination:
1159 @multitable @columnfractions 0.3 0.7
1160 @item @kbd{@key{TAB}}
1161 @tab Cycle visibility.
1162 @item @kbd{@key{DOWN}} / @kbd{@key{UP}}
1163 @tab Next/previous visible headline.
1164 @item @kbd{@key{RET}}
1165 @tab Select this location.
1166 @item @kbd{/}
1167 @tab Do a Sparse-tree search
1168 @end multitable
1170 @noindent
1171 The following keys work if you turn off @code{org-goto-auto-isearch}
1173 @multitable @columnfractions 0.3 0.7
1174 @item @kbd{n} / @kbd{p}
1175 @tab Next/previous visible headline.
1176 @item @kbd{f} / @kbd{b}
1177 @tab Next/previous headline same level.
1178 @item @kbd{u}
1179 @tab One level up.
1180 @item @kbd{0} @dots{} @kbd{9}
1181 @tab Digit argument.
1182 @item @kbd{q}
1183 @tab Quit.
1184 @end multitable
1186 @vindex org-goto-interface
1187 @noindent
1188 See also the variable @code{org-goto-interface}.
1189 @end table
1191 @node Structure Editing
1192 @section Structure Editing
1194 @cindex structure editing
1195 @cindex headline, promotion and demotion
1196 @cindex promotion, of subtrees
1197 @cindex demotion, of subtrees
1198 @cindex subtree, cut and paste
1199 @cindex pasting, of subtrees
1200 @cindex cutting, of subtrees
1201 @cindex copying, of subtrees
1202 @cindex sorting, of subtrees
1203 @cindex subtrees, cut and paste
1205 @table @asis
1206 @item @kbd{M-@key{RET}} (@code{org-meta-return})
1207 @kindex M-RET
1208 @findex org-meta-return
1209 @vindex org-M-RET-may-split-line
1210 Insert a new heading, item or row.
1212 If the command is used at the @emph{beginning} of a line, and if there
1213 is a heading or a plain list item (see @ref{Plain Lists}) at point,
1214 the new heading/item is created @emph{before} the current line.  When
1215 used at the beginning of a regular line of text, turn that line
1216 into a heading.
1218 When this command is used in the middle of a line, the line is
1219 split and the rest of the line becomes the new item or headline.
1220 If you do not want the line to be split, customize
1221 @code{org-M-RET-may-split-line}.
1223 Calling the command with a @kbd{C-u} prefix unconditionally
1224 inserts a new heading at the end of the current subtree, thus
1225 preserving its contents.  With a double @kbd{C-u C-u}
1226 prefix, the new heading is created at the end of the parent
1227 subtree instead.
1229 @item @kbd{C-@key{RET}} (@code{org-insert-heading-respect-content})
1230 @kindex C-RET
1231 @findex org-insert-heading-respect-content
1232 Insert a new heading at the end of the current subtree.
1234 @item @kbd{M-S-@key{RET}} (@code{org-insert-todo-heading})
1235 @kindex M-S-RET
1236 @findex org-insert-todo-heading
1237 @vindex org-treat-insert-todo-heading-as-state-change
1238 Insert new TODO entry with same level as current heading.  See
1239 also the variable
1240 @code{org-treat-insert-todo-heading-as-state-change}.
1242 @item @kbd{C-S-@key{RET}} (@code{org-insert-todo-heading-respect-content})
1243 @kindex C-S-RET
1244 @findex org-insert-todo-heading-respect-content
1245 Insert new TODO entry with same level as current heading.  Like
1246 @kbd{C-@key{RET}}, the new headline is inserted after the current
1247 subtree.
1249 @item @kbd{@key{TAB}} (@code{org-cycle})
1250 @kindex TAB
1251 @findex org-cycle
1252 In a new entry with no text yet, the first @kbd{@key{TAB}} demotes
1253 the entry to become a child of the previous one.  The next
1254 @kbd{@key{TAB}} makes it a parent, and so on, all the way to top
1255 level.  Yet another @kbd{@key{TAB}}, and you are back to the
1256 initial level.
1258 @item @kbd{M-@key{LEFT}} (@code{org-do-promote})
1259 @kindex M-LEFT
1260 @findex org-do-promote
1261 Promote current heading by one level.
1263 @item @kbd{M-@key{RIGHT}} (@code{org-do-demote})
1264 @kindex M-RIGHT
1265 @findex org-do-demote
1266 Demote current heading by one level.
1268 @item @kbd{M-S-@key{LEFT}} (@code{org-promote-subtree})
1269 @kindex M-S-LEFT
1270 @findex org-promote-subtree
1271 Promote the current subtree by one level.
1273 @item @kbd{M-S-@key{RIGHT}} (@code{org-demote-subtree})
1274 @kindex M-S-RIGHT
1275 @findex org-demote-subtree
1276 Demote the current subtree by one level.
1278 @item @kbd{M-@key{UP}} (@code{org-move-subtree-up})
1279 @kindex M-UP
1280 @findex org-move-subtree-up
1281 Move subtree up, i.e., swap with previous subtree of same level.
1283 @item @kbd{M-@key{DOWN}} (@code{org-move-subtree-down})
1284 @kindex M-DOWN
1285 @findex org-move-subtree-down
1286 Move subtree down, i.e., swap with next subtree of same level.
1288 @item @kbd{C-c @@} (@code{org-mark-subtree})
1289 @kindex C-c @@
1290 @findex org-mark-subtree
1291 Mark the subtree at point.  Hitting repeatedly marks subsequent
1292 subtrees of the same level as the marked subtree.
1294 @item @kbd{C-c C-x C-w} (@code{org-cut-subtree})
1295 @kindex C-c C-x C-w
1296 @findex org-cut-subtree
1297 Kill subtree, i.e., remove it from buffer but save in kill ring.
1298 With a numeric prefix argument N, kill N sequential subtrees.
1300 @item @kbd{C-c C-x M-w} (@code{org-copy-subtree})
1301 @kindex C-c C-x M-w
1302 @findex org-copy-subtree
1303 Copy subtree to kill ring.  With a numeric prefix argument N,
1304 copy the N sequential subtrees.
1306 @item @kbd{C-c C-x C-y} (@code{org-paste-subtree})
1307 @kindex C-c C-x C-y
1308 @findex org-paste-subtree
1309 Yank subtree from kill ring.  This does modify the level of the
1310 subtree to make sure the tree fits in nicely at the yank
1311 position.  The yank level can also be specified with a numeric
1312 prefix argument, or by yanking after a headline marker like
1313 @samp{****}.
1315 @item @kbd{C-y} (@code{org-yank})
1316 @kindex C-y
1317 @findex org-yank
1318 @vindex org-yank-adjusted-subtrees
1319 @vindex org-yank-folded-subtrees
1320 Depending on the variables @code{org-yank-adjusted-subtrees} and
1321 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command pastes
1322 subtrees folded and in a clever way, using the same command as
1323 @kbd{C-c C-x C-y}.  With the default settings, no level
1324 adjustment takes place, but the yanked tree is folded unless
1325 doing so would swallow text previously visible.  Any prefix
1326 argument to this command forces a normal @code{yank} to be executed,
1327 with the prefix passed along.  A good way to force a normal yank
1328 is @kbd{C-u C-y}.  If you use @code{yank-pop} after a yank, it
1329 yanks previous kill items plainly, without adjustment and
1330 folding.
1332 @item @kbd{C-c C-x c} (@code{org-clone-subtree-with-time-shift})
1333 @kindex C-c C-x c
1334 @findex org-clone-subtree-with-time-shift
1335 Clone a subtree by making a number of sibling copies of it.  You
1336 are prompted for the number of copies to make, and you can also
1337 specify if any timestamps in the entry should be shifted.  This
1338 can be useful, for example, to create a number of tasks related
1339 to a series of lectures to prepare.  For more details, see the
1340 docstring of the command @code{org-clone-subtree-with-time-shift}.
1342 @item @kbd{C-c C-w} (@code{org-refile})
1343 @kindex C-c C-w
1344 @findex org-refile
1345 Refile entry or region to a different location.  See @ref{Refile and Copy}.
1347 @item @kbd{C-c ^} (@code{org-sort})
1348 @kindex C-c ^
1349 @findex org-sort
1350 Sort same-level entries.  When there is an active region, all
1351 entries in the region are sorted.  Otherwise the children of the
1352 current headline are sorted.  The command prompts for the sorting
1353 method, which can be alphabetically, numerically, by time---first
1354 timestamp with active preferred, creation time, scheduled time,
1355 deadline time---by priority, by TODO keyword---in the sequence
1356 the keywords have been defined in the setup---or by the value of
1357 a property.  Reverse sorting is possible as well.  You can also
1358 supply your own function to extract the sorting key.  With
1359 a @kbd{C-u} prefix, sorting is case-sensitive.
1361 @item @kbd{C-x n s} (@code{org-narrow-to-subtree})
1362 @kindex C-x n s
1363 @findex org-narrow-to-subtree
1364 Narrow buffer to current subtree.
1366 @item @kbd{C-x n b} (@code{org-narrow-to-block})
1367 @kindex C-x n b
1368 @findex org-narrow-to-block
1369 Narrow buffer to current block.
1371 @item @kbd{C-x n w} (@code{widen})
1372 @kindex C-x n w
1373 @findex widen
1374 Widen buffer to remove narrowing.
1376 @item @kbd{C-c *} (@code{org-toggle-heading})
1377 @kindex C-c *
1378 @findex org-toggle-heading
1379 Turn a normal line or plain list item into a headline---so that
1380 it becomes a subheading at its location.  Also turn a headline
1381 into a normal line by removing the stars.  If there is an active
1382 region, turn all lines in the region into headlines.  If the
1383 first line in the region was an item, turn only the item lines
1384 into headlines.  Finally, if the first line is a headline, remove
1385 the stars from all headlines in the region.
1386 @end table
1388 @cindex region, active
1389 @cindex active region
1390 @cindex transient mark mode
1391 When there is an active region---i.e., when Transient Mark mode is
1392 active---promotion and demotion work on all headlines in the region.
1393 To select a region of headlines, it is best to place both point and
1394 mark at the beginning of a line, mark at the beginning of the first
1395 headline, and point at the line just after the last headline to
1396 change.  Note that when the cursor is inside a table (see @ref{Tables}),
1397 the Meta-Cursor keys have different functionality.
1399 @node Sparse Trees
1400 @section Sparse Trees
1402 @cindex sparse trees
1403 @cindex trees, sparse
1404 @cindex folding, sparse trees
1405 @cindex occur, command
1407 @vindex org-show-context-detail
1408 An important feature of Org mode is the ability to construct @emph{sparse
1409 trees} for selected information in an outline tree, so that the entire
1410 document is folded as much as possible, but the selected information
1411 is made visible along with the headline structure above it@footnote{See also the variable @code{org-show-context-detail} to decide how
1412 much context is shown around each match.}.
1413 Just try it out and you will see immediately how it works.
1415 Org mode contains several commands creating such trees, all these
1416 commands can be accessed through a dispatcher:
1418 @table @asis
1419 @item @kbd{C-c /} (@code{org-sparse-tree})
1420 @kindex C-c /
1421 @findex org-sparse-tree
1422 This prompts for an extra key to select a sparse-tree creating
1423 command.
1425 @item @kbd{C-c / r} or @kbd{C-c / /} (@code{org-occur})
1426 @kindex C-c / r
1427 @kindex C-c / /
1428 @findex org-occur
1429 @vindex org-remove-highlights-with-change
1430 Prompts for a regexp and shows a sparse tree with all matches.
1431 If the match is in a headline, the headline is made visible.  If
1432 the match is in the body of an entry, headline and body are made
1433 visible.  In order to provide minimal context, also the full
1434 hierarchy of headlines above the match is shown, as well as the
1435 headline following the match.  Each match is also highlighted;
1436 the highlights disappear when the buffer is changed by an editing
1437 command, or by pressing @kbd{C-c C-c}@footnote{This depends on the option @code{org-remove-highlights-with-change}.}.  When called
1438 with a @kbd{C-u} prefix argument, previous highlights are
1439 kept, so several calls to this command can be stacked.
1441 @item @kbd{M-g n} or @kbd{M-g M-n} (@code{next-error})
1442 @kindex M-g n
1443 @kindex M-g M-n
1444 @findex next-error
1445 Jump to the next sparse tree match in this buffer.
1447 @item @kbd{M-g p} or @kbd{M-g M-p} (@code{previous-error})
1448 @kindex M-g p
1449 @kindex M-g M-p
1450 @findex previous-error
1451 Jump to the previous sparse tree match in this buffer.
1452 @end table
1454 @vindex org-agenda-custom-commands
1455 @noindent
1456 For frequently used sparse trees of specific search strings, you can
1457 use the variable @code{org-agenda-custom-commands} to define fast keyboard
1458 access to specific sparse trees.  These commands will then be
1459 accessible through the agenda dispatcher (see @ref{Agenda Dispatcher}).
1460 For example:
1462 @lisp
1463 (setq org-agenda-custom-commands
1464       '(("f" occur-tree "FIXME")))
1465 @end lisp
1467 @noindent
1468 defines the key @kbd{f} as a shortcut for creating a sparse tree
1469 matching the string @samp{FIXME}.
1471 The other sparse tree commands select headings based on TODO keywords,
1472 tags, or properties and are discussed later in this manual.
1474 @kindex C-c C-e v
1475 @cindex printing sparse trees
1476 @cindex visible text, printing
1477 To print a sparse tree, you can use the Emacs command
1478 @code{ps-print-buffer-with-faces} which does not print invisible parts of
1479 the document.  Or you can use the command @kbd{C-c C-e v} to
1480 export only the visible part of the document and print the resulting
1481 file.
1483 @node Plain Lists
1484 @section Plain Lists
1486 @cindex plain lists
1487 @cindex lists, plain
1488 @cindex lists, ordered
1489 @cindex ordered lists
1491 Within an entry of the outline tree, hand-formatted lists can provide
1492 additional structure.  They also provide a way to create lists of
1493 checkboxes (see @ref{Checkboxes}).  Org supports editing such lists, and
1494 every exporter (see @ref{Exporting}) can parse and format them.
1496 Org knows ordered lists, unordered lists, and description lists.
1498 @itemize
1499 @item
1500 @emph{Unordered} list items start with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented so that they
1501 are not interpreted as headlines.  Also, when you are hiding leading
1502 stars to get a clean outline view, plain list items starting with
1503 a star may be hard to distinguish from true headlines.  In short: even
1504 though @samp{*} is supported, it may be better to not use it for plain list
1505 items.} as bullets.
1507 @item
1508 @vindex org-plain-list-ordered-item-terminator
1509 @vindex org-alphabetical-lists
1510 @emph{Ordered} list items start with a numeral followed by either
1511 a period or a right parenthesis@footnote{You can filter out any of them by configuring
1512 @code{org-plain-list-ordered-item-terminator}.}, such as @samp{1.} or @samp{1)}@footnote{You can also get @samp{a.}, @samp{A.}, @samp{a)} and @samp{A)} by configuring
1513 @code{org-list-allow-alphabetical}.  To minimize confusion with normal
1514 text, those are limited to one character only.  Beyond that limit,
1515 bullets automatically become numbers.}
1516 If you want a list to start with a different value---e.g.,
1517 20---start the text of the item with @samp{[@@20]}@footnote{If there's a checkbox in the item, the cookie must be put
1518 @emph{before} the checkbox.  If you have activated alphabetical lists, you
1519 can also use counters like @samp{[@@b]}.}.  Those
1520 constructs can be used in any item of the list in order to enforce
1521 a particular numbering.
1523 @item
1524 @emph{Description} list items are unordered list items, and contain the
1525 separator @samp{::} to distinguish the description @emph{term} from the
1526 description.
1527 @end itemize
1529 Items belonging to the same list must have the same indentation on the
1530 first line.  In particular, if an ordered list reaches number @samp{10.},
1531 then the 2-digit numbers must be written left-aligned with the other
1532 numbers in the list.  An item ends before the next line that is less
1533 or equally indented than its bullet/number.
1535 A list ends whenever every item has ended, which means before any line
1536 less or equally indented than items at top level.  It also ends before
1537 two blank lines.  In that case, all items are closed.  Here is an
1538 example:
1540 @example
1541 * Lord of the Rings
1542 My favorite scenes are (in this order)
1543 1. The attack of the Rohirrim
1544 2. Eowyn's fight with the witch king
1545    + this was already my favorite scene in the book
1546    + I really like Miranda Otto.
1547 3. Peter Jackson being shot by Legolas
1548    - on DVD only
1549    He makes a really funny face when it happens.
1550 But in the end, no individual scenes matter but the film as a whole.
1551 Important actors in this film are:
1552 - Elijah Wood :: He plays Frodo
1553 - Sean Astin :: He plays Sam, Frodo's friend. I still remember him
1554      very well from his role as Mikey Walsh in /The Goonies/.
1555 @end example
1557 Org supports these lists by tuning filling and wrapping commands to
1558 deal with them correctly, and by exporting them properly (see
1559 @ref{Exporting}).  Since indentation is what governs the structure of these
1560 lists, many structural constructs like @samp{#+BEGIN_} blocks can be
1561 indented to signal that they belong to a particular item.
1563 @vindex org-list-demote-modify-bullet
1564 @vindex org-list-indent-offset
1565 If you find that using a different bullet for a sub-list---than that
1566 used for the current list-level---improves readability, customize the
1567 variable @code{org-list-demote-modify-bullet}.  To get a greater difference
1568 of indentation between items and theirs sub-items, customize
1569 @code{org-list-indent-offset}.
1571 @vindex org-list-automatic-rules
1572 The following commands act on items when the cursor is in the first
1573 line of an item---the line with the bullet or number.  Some of them
1574 imply the application of automatic rules to keep list structure
1575 intact.  If some of these actions get in your way, configure
1576 @code{org-list-automatic-rules} to disable them individually.
1578 @table @asis
1579 @item @kbd{@key{TAB}} (@code{org-cycle})
1580 @cindex cycling, in plain lists
1581 @kindex TAB
1582 @findex org-cycle
1583 @vindex org-cycle-include-plain-lists
1584 Items can be folded just like headline levels.  Normally this
1585 works only if the cursor is on a plain list item.  For more
1586 details, see the variable @code{org-cycle-include-plain-lists}.  If
1587 this variable is set to @code{integrate}, plain list items are treated
1588 like low-level headlines.  The level of an item is then given by
1589 the indentation of the bullet/number.  Items are always
1590 subordinate to real headlines, however; the hierarchies remain
1591 completely separated.  In a new item with no text yet, the first
1592 @kbd{@key{TAB}} demotes the item to become a child of the previous
1593 one.  Subsequent @kbd{@key{TAB}}s move the item to meaningful
1594 levels in the list and eventually get it back to its initial
1595 position.
1597 @item @kbd{M-@key{RET}} (@code{org-insert-heading})
1598 @kindex M-RET
1599 @findex org-insert-heading
1600 @vindex org-M-RET-may-split-line
1601 Insert new item at current level.  With a prefix argument, force
1602 a new heading (see @ref{Structure Editing}).  If this command is used
1603 in the middle of an item, that item is @emph{split} in two, and the
1604 second part becomes the new item@footnote{If you do not want the item to be split, customize the
1605 variable @code{org-M-RET-may-split-line}.}.  If this command is
1606 executed @emph{before item's body}, the new item is created @emph{before}
1607 the current one.
1609 @item @kbd{M-S-@key{RET}}
1610 @kindex M-S-RET
1611 Insert a new item with a checkbox (see @ref{Checkboxes}).
1613 @item @kbd{S-@key{UP}}
1614 @itemx @kbd{S-@key{DOWN}}
1615 @kindex S-UP
1616 @kindex S-DOWN
1617 @cindex shift-selection-mode
1618 @vindex org-support-shift-select
1619 @vindex org-list-use-circular-motion
1620 Jump to the previous/next item in the current list, but only if
1621 @code{org-support-shift-select} is off@footnote{If you want to cycle around items that way, you may customize
1622 @code{org-list-use-circular-motion}.}.  If not, you can
1623 still use paragraph jumping commands like @kbd{C-@key{UP}}
1624 and @kbd{C-@key{DOWN}} to quite similar effect.
1626 @item @kbd{M-@key{UP}}
1627 @itemx @kbd{M-@key{DOWN}}
1628 @kindex M-UP
1629 @kindex M-DOWN
1630 Move the item including subitems up/down@footnote{See @code{org-list-use-circular-motion} for a cyclic behavior.}, i.e., swap with
1631 previous/next item of same indentation.  If the list is ordered,
1632 renumbering is automatic.
1634 @item @kbd{M-@key{LEFT}}
1635 @itemx @kbd{M-@key{RIGHT}}
1636 @kindex M-LEFT
1637 @kindex M-RIGHT
1638 Decrease/increase the indentation of an item, leaving children
1639 alone.
1641 @item @kbd{M-S-@key{LEFT}}
1642 @itemx @kbd{M-S-@key{RIGHT}}
1643 @kindex M-S-LEFT
1644 @kindex M-S-RIGHT
1645 Decrease/increase the indentation of the item, including
1646 subitems.  Initially, the item tree is selected based on current
1647 indentation.  When these commands are executed several times in
1648 direct succession, the initially selected region is used, even if
1649 the new indentation would imply a different hierarchy.  To use
1650 the new hierarchy, break the command chain with a cursor motion
1651 or so.
1653 As a special case, using this command on the very first item of
1654 a list moves the whole list.  This behavior can be disabled by
1655 configuring @code{org-list-automatic-rules}.  The global indentation
1656 of a list has no influence on the text @emph{after} the list.
1658 @item @kbd{C-c C-c}
1659 @kindex C-c C-c
1660 If there is a checkbox (see @ref{Checkboxes}) in the item line, toggle
1661 the state of the checkbox.  In any case, verify bullets and
1662 indentation consistency in the whole list.
1664 @item @kbd{C-c -}
1665 @kindex C-c -
1666 @vindex org-plain-list-ordered-item-terminator
1667 Cycle the entire list level through the different
1668 itemize/enumerate bullets (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}) or a subset
1669 of them, depending on @code{org-plain-list-ordered-item-terminator},
1670 the type of list, and its indentation.  With a numeric prefix
1671 argument N, select the Nth bullet from this list.  If there is an
1672 active region when calling this, selected text is changed into an
1673 item.  With a prefix argument, all lines are converted to list
1674 items.  If the first line already was a list item, any item
1675 marker is removed from the list.  Finally, even without an active
1676 region, a normal line is converted into a list item.
1678 @item @kbd{C-c *}
1679 @kindex C-c *
1680 Turn a plain list item into a headline---so that it becomes
1681 a subheading at its location.  See @ref{Structure Editing}, for
1682 a detailed explanation.
1684 @item @kbd{C-c C-*}
1685 @kindex C-c C-*
1686 Turn the whole plain list into a subtree of the current heading.
1687 Checkboxes (see @ref{Checkboxes}) become TODO, respectively DONE,
1688 keywords when unchecked, respectively checked.
1690 @item @kbd{S-@key{LEFT}}
1691 @itemx @kbd{S-@key{RIGHT}}
1692 @vindex org-support-shift-select
1693 @kindex S-LEFT
1694 @kindex S-RIGHT
1695 This command also cycles bullet styles when the cursor in on the
1696 bullet or anywhere in an item line, details depending on
1697 @code{org-support-shift-select}.
1699 @item @kbd{C-c ^}
1700 @kindex C-c ^
1701 @cindex sorting, of plain list
1702 Sort the plain list.  Prompt for the sorting method: numerically,
1703 alphabetically, by time, or by custom function.
1704 @end table
1706 @node Drawers
1707 @section Drawers
1709 @cindex drawers
1710 @cindex visibility cycling, drawers
1712 Sometimes you want to keep information associated with an entry, but
1713 you normally do not want to see it.  For this, Org mode has @emph{drawers}.
1714 They can contain anything but a headline and another drawer.  Drawers
1715 look like this:
1717 @example
1718 ** This is a headline
1719 Still outside the drawer
1720 :DRAWERNAME:
1721 This is inside the drawer.
1722 :END:
1723 After the drawer.
1724 @end example
1726 @kindex C-c C-x d
1727 @findex org-insert-drawer
1728 You can interactively insert a drawer at point by calling
1729 @code{org-insert-drawer}, which is bound to @kbd{C-c C-x d}.  With an
1730 active region, this command puts the region inside the drawer.  With
1731 a prefix argument, this command calls @code{org-insert-property-drawer},
1732 which creates a @samp{PROPERTIES} drawer right below the current headline.
1733 Org mode uses this special drawer for storing properties (see
1734 @ref{Properties and Columns}).  You cannot use it for anything else.
1736 Completion over drawer keywords is also possible using
1737 @kbd{M-@key{TAB}}@footnote{Many desktops intercept @kbd{M-@key{TAB}} to switch windows.
1738 Use @kbd{C-M-i} or @kbd{@key{ESC} @key{TAB}} instead.}.
1740 Visibility cycling (see @ref{Visibility Cycling}) on the headline hides and
1741 shows the entry, but keep the drawer collapsed to a single line.  In
1742 order to look inside the drawer, you need to move the cursor to the
1743 drawer line and press @kbd{@key{TAB}} there.
1745 You can also arrange for state change notes (see @ref{Tracking TODO state changes}) and clock times (see @ref{Clocking Work Time}) to be stored in
1746 a @samp{LOGBOOK} drawer.  If you want to store a quick note there, in
1747 a similar way to state changes, use
1749 @table @asis
1750 @item @kbd{C-c C-z}
1751 @kindex C-c C-z
1752 Add a time-stamped note to the @samp{LOGBOOK} drawer.
1753 @end table
1755 @node Blocks
1756 @section Blocks
1758 @vindex org-hide-block-startup
1759 @cindex blocks, folding
1761 Org mode uses @samp{#+BEGIN} @dots{} @samp{#+END} blocks for various purposes from
1762 including source code examples (see @ref{Literal Examples}) to capturing
1763 time logging information (see @ref{Clocking Work Time}).  These blocks can
1764 be folded and unfolded by pressing @kbd{@key{TAB}} in the @samp{#+BEGIN}
1765 line.  You can also get all blocks folded at startup by configuring
1766 the variable @code{org-hide-block-startup} or on a per-file basis by using
1768 @cindex STARTUP, keyword
1769 @example
1770 #+STARTUP: hideblocks
1771 #+STARTUP: nohideblocks
1772 @end example
1774 @node Creating Footnotes
1775 @section Creating Footnotes
1777 @cindex footnotes
1779 Org mode supports the creation of footnotes.
1781 A footnote is started by a footnote marker in square brackets in
1782 column 0, no indentation allowed.  It ends at the next footnote
1783 definition, headline, or after two consecutive empty lines.  The
1784 footnote reference is simply the marker in square brackets, inside
1785 text.  Markers always start with @samp{fn:}.  For example:
1787 @example
1788 The Org homepage[fn:1] now looks a lot better than it used to.
1790 [fn:1] The link is: https://orgmode.org
1791 @end example
1793 Org mode extends the number-based syntax to @emph{named} footnotes and
1794 optional inline definition.  Here are the valid references:
1796 @table @asis
1797 @item @samp{[fn:NAME]}
1798 A named footnote reference, where @var{NAME} is a unique
1799 label word, or, for simplicity of automatic creation, a number.
1801 @item @samp{[fn:: This is the inline definition of this footnote]}
1802 A @LaTeX{}-like anonymous footnote where the definition is given
1803 directly at the reference point.
1805 @item @samp{[fn:NAME: a definition]}
1806 An inline definition of a footnote, which also specifies a name
1807 for the note.  Since Org allows multiple references to the same
1808 note, you can then use @samp{[fn:NAME]} to create additional
1809 references.
1810 @end table
1812 @vindex org-footnote-auto-label
1813 Footnote labels can be created automatically, or you can create names
1814 yourself.  This is handled by the variable @code{org-footnote-auto-label}
1815 and its corresponding @samp{STARTUP} keywords.  See the docstring of that
1816 variable for details.
1818 @noindent
1819 The following command handles footnotes:
1821 @table @asis
1822 @item @kbd{C-c C-x f}
1823 The footnote action command.
1825 @kindex C-c C-x f
1826 When the cursor is on a footnote reference, jump to the
1827 definition.  When it is at a definition, jump to
1828 the---first---reference.
1830 @vindex org-footnote-define-inline
1831 @vindex org-footnote-section
1832 Otherwise, create a new footnote.  Depending on the variable
1833 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer setting is: @samp{#+STARTUP: fninline}
1834 or @samp{#+STARTUP: nofninline}.}, the definition is placed
1835 right into the text as part of the reference, or separately into
1836 the location determined by the variable @code{org-footnote-section}.
1838 When this command is called with a prefix argument, a menu of
1839 additional options is offered:
1841 @multitable @columnfractions 0.1 0.9
1842 @item @kbd{s}
1843 @tab Sort the footnote definitions by reference sequence.
1844 @item @kbd{r}
1845 @tab Renumber the simple @samp{fn:N} footnotes.
1846 @item @kbd{S}
1847 @tab Short for first @kbd{r}, then @kbd{s} action.
1848 @item @kbd{n}
1849 @tab Rename all footnotes into a @samp{fn:1} @dots{} @samp{fn:n} sequence.
1850 @item @kbd{d}
1851 @tab Delete the footnote at point, including definition and references.
1852 @end multitable
1854 @vindex org-footnote-auto-adjust
1855 Depending on the variable @code{org-footnote-auto-adjust}@footnote{The corresponding in-buffer options are @samp{#+STARTUP: fnadjust}
1856 and @samp{#+STARTUP: nofnadjust}.},
1857 renumbering and sorting footnotes can be automatic after each
1858 insertion or deletion.
1860 @item @kbd{C-c C-c}
1861 @kindex C-c C-c
1862 If the cursor is on a footnote reference, jump to the definition.
1863 If it is at the definition, jump back to the reference.  When
1864 called at a footnote location with a prefix argument, offer the
1865 same menu as @kbd{C-c C-x f}.
1867 @item @kbd{C-c C-o} or @kbd{mouse-1/2}
1868 @kindex C-c C-o
1869 @kindex mouse-1
1870 @kindex mouse-2
1871 Footnote labels are also links to the corresponding definition or
1872 reference, and you can use the usual commands to follow these
1873 links.
1874 @end table
1876 @node Org Syntax
1877 @section Org Syntax
1879 A reference document providing a formal description of Org's syntax is
1880 available as @uref{https://orgmode.org/worg/dev/org-syntax.html, a draft on Worg}, written and maintained by Nicolas
1881 Goaziou.  It defines Org's core internal concepts such as @samp{headlines},
1882 @samp{sections}, @samp{affiliated keywords}, @samp{(greater) elements} and @samp{objects}.
1883 Each part of an Org file falls into one of the categories above.
1885 To explore the abstract structure of an Org buffer, run this in
1886 a buffer:
1888 @example
1889 M-: (org-element-parse-buffer) <RET>
1890 @end example
1892 @noindent
1893 It outputs a list containing the buffer's content represented as an
1894 abstract structure.  The export engine relies on the information
1895 stored in this list.  Most interactive commands---e.g., for structure
1896 editing---also rely on the syntactic meaning of the surrounding
1897 context.
1899 @cindex syntax checker
1900 @cindex linter
1901 @findex org-lint
1902 You can check syntax in your documents using @code{org-lint} command.
1904 @node Tables
1905 @chapter Tables
1907 @cindex tables
1908 @cindex editing tables
1910 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1911 calculations are supported using the Emacs Calc package (see @ref{Top,GNU Emacs
1912 Calculator Manual,,calc,}).
1914 @menu
1915 * Built-in Table Editor::        Simple tables.
1916 * Column Width and Alignment::   Overrule the automatic settings.
1917 * Column Groups::                Grouping to trigger vertical lines.
1918 * Orgtbl Mode::                  The table editor as minor mode.
1919 * The spreadsheet::              The table editor has spreadsheet capabilities.
1920 * Org Plot::                     Plotting from Org tables.
1921 @end menu
1923 @node Built-in Table Editor
1924 @section Built-in Table Editor
1926 @cindex table editor, built-in
1928 Org makes it easy to format tables in plain ASCII.  Any line with @samp{|}
1929 as the first non-whitespace character is considered part of a table.
1930 @samp{|} is also the column separator@footnote{To insert a vertical bar into a table field, use @samp{\vert} or,
1931 inside a word @samp{abc\vert@{@}def}.}.  A table might look like
1932 this:
1934 @example
1935 | Name  | Phone | Age |
1936 |-------+-------+-----|
1937 | Peter |  1234 |  17 |
1938 | Anna  |  4321 |  25 |
1939 @end example
1941 A table is re-aligned automatically each time you press
1942 @kbd{@key{TAB}}, @kbd{@key{RET}} or @kbd{C-c C-c} inside the table.
1943 @kbd{@key{TAB}} also moves to the next field---@kbd{@key{RET}} to the
1944 next row---and creates new table rows at the end of the table or
1945 before horizontal lines.  The indentation of the table is set by the
1946 first line.  Any line starting with @samp{|-} is considered as a horizontal
1947 separator line and will be expanded on the next re-align to span the
1948 whole table width.  So, to create the above table, you would only type
1950 @example
1951 |Name|Phone|Age|
1953 @end example
1955 @noindent
1956 and then press @kbd{@key{TAB}} to align the table and start filling in
1957 fields.  Even faster would be to type @samp{|Name|Phone|Age} followed by
1958 @kbd{C-c @key{RET}}.
1960 When typing text into a field, Org treats @kbd{DEL},
1961 @kbd{Backspace}, and all character keys in a special way, so that
1962 inserting and deleting avoids shifting other fields.  Also, when
1963 typing @emph{immediately} after the cursor was moved into a new field with
1964 @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}, the field is
1965 automatically made blank.  If this behavior is too unpredictable for
1966 you, configure the option @code{org-table-auto-blank-field}.
1968 @anchor{Creation and conversion}
1969 @subheading Creation and conversion
1971 @table @asis
1972 @item @kbd{C-c |} (@code{org-table-create-or-convert-from-region})
1973 @kindex C-c |
1974 @findex org-table-create-or-convert-from-region
1975 Convert the active region to table.  If every line contains at
1976 least one @kbd{@key{TAB}} character, the function assumes that the
1977 material is tab separated.  If every line contains a comma,
1978 comma-separated values (CSV) are assumed.  If not, lines are
1979 split at whitespace into fields.  You can use a prefix argument
1980 to force a specific separator: @kbd{C-u} forces CSV,
1981 @kbd{C-u C-u} forces @kbd{@key{TAB}}, @kbd{C-u C-u C-u}
1982 prompts for a regular expression to match the separator, and
1983 a numeric argument N indicates that at least N consecutive
1984 spaces, or alternatively a @kbd{@key{TAB}} will be the separator.
1986 If there is no active region, this command creates an empty Org
1987 table.  But it is easier just to start typing, like @kbd{| N a m e | P h o n e | A g e @key{RET} | - @key{TAB}}.
1988 @end table
1990 @anchor{Re-aligning and field motion}
1991 @subheading Re-aligning and field motion
1993 @table @asis
1994 @item @kbd{C-c C-c} (@code{org-table-align})
1995 @kindex C-c C-c
1996 @findex org-table-align
1997 Re-align the table without moving the cursor.
1999 @item @kbd{@key{TAB}} (@code{org-table-next-field})
2000 @kindex TAB
2001 @findex org-table-next-field
2002 Re-align the table, move to the next field.  Creates a new row if
2003 necessary.
2005 @item @kbd{C-c @key{SPC}} (@code{org-table-blank-field})
2006 @kindex C-c SPC
2007 @findex org-table-blank-field
2008 Blank the field at point.
2010 @item @kbd{S-@key{TAB}} (@code{org-table-previous-field})
2011 @kindex S-TAB
2012 @findex org-table-previous-field
2013 Re-align, move to previous field.
2015 @item @kbd{@key{RET}} (@code{org-table-next-row})
2016 @kindex RET
2017 @findex org-table-next-row
2018 Re-align the table and move down to next row.  Creates a new row
2019 if necessary.  At the beginning or end of a line, @kbd{@key{RET}}
2020 still inserts a new line, so it can be used to split a table.
2022 @item @kbd{M-a} (@code{org-table-beginning-of-field})
2023 @kindex M-a
2024 @findex org-table-beginning-of-field
2025 Move to beginning of the current table field, or on to the
2026 previous field.
2028 @item @kbd{M-e} (@code{org-table-end-of-field})
2029 @kindex M-e
2030 @findex org-table-end-of-field
2031 Move to end of the current table field, or on to the next field.
2032 @end table
2034 @anchor{Column and row editing}
2035 @subheading Column and row editing
2037 @table @asis
2038 @item @kbd{M-@key{LEFT}} (@code{org-table-move-column-left})
2039 @kindex M-LEFT
2040 @findex org-table-move-column-left
2041 Move the current column left.
2043 @item @kbd{M-@key{RIGHT}} (@code{org-table-move-column-right})
2044 @kindex M-RIGHT
2045 @findex org-table-move-column-right
2046 Move the current column right.
2048 @item @kbd{M-S-@key{LEFT}} (@code{org-table-delete-column})
2049 @kindex M-S-LEFT
2050 @findex org-table-delete-column
2051 Kill the current column.
2053 @item @kbd{M-S-@key{RIGHT}} (@code{org-table-insert-column})
2054 @kindex M-S-RIGHT
2055 @findex org-table-insert-column
2056 Insert a new column to the left of the cursor position.
2058 @item @kbd{M-@key{UP}} (@code{org-table-move-row-up})
2059 @kindex M-UP
2060 @findex org-table-move-row-up
2061 Move the current row up.
2063 @item @kbd{M-@key{DOWN}} (@code{org-table-move-row-down})
2064 @kindex M-DOWN
2065 @findex org-table-move-row-down
2066 Move the current row down.
2068 @item @kbd{M-S-@key{UP}} (@code{org-table-kill-row})
2069 @kindex M-S-UP
2070 @findex org-table-kill-row
2071 Kill the current row or horizontal line.
2073 @item @kbd{M-S-@key{DOWN}} (@code{org-table-insert-row})
2074 @kindex M-S-DOWN
2075 @findex org-table-insert-row
2076 Insert a new row above the current row.  With a prefix argument,
2077 the line is created below the current one.
2079 @item @kbd{C-c -} (@code{org-table-insert-hline})
2080 @kindex C-c -
2081 @findex org-table-insert-hline
2082 Insert a horizontal line below current row.  With a prefix
2083 argument, the line is created above the current line.
2085 @item @kbd{C-c @key{RET}} (@code{org-table-hline-and-move})
2086 @kindex C-c RET
2087 @findex org-table-hline-and-move
2088 Insert a horizontal line below current row, and move the cursor
2089 into the row below that line.
2091 @item @kbd{C-c ^} (@code{org-table-sort-lines})
2092 @kindex C-c ^
2093 @findex org-table-sort-lines
2094 Sort the table lines in the region.  The position of point
2095 indicates the column to be used for sorting, and the range of
2096 lines is the range between the nearest horizontal separator
2097 lines, or the entire table.  If point is before the first column,
2098 you are prompted for the sorting column.  If there is an active
2099 region, the mark specifies the first line and the sorting column,
2100 while point should be in the last line to be included into the
2101 sorting.  The command prompts for the sorting type,
2102 alphabetically, numerically, or by time.  You can sort in normal
2103 or reverse order.  You can also supply your own key extraction
2104 and comparison functions.  When called with a prefix argument,
2105 alphabetic sorting is case-sensitive.
2106 @end table
2108 @anchor{Regions}
2109 @subheading Regions
2111 @table @asis
2112 @item @kbd{C-c C-x M-w} (@code{org-table-copy-region})
2113 @kindex C-c C-x M-w
2114 @findex org-table-copy-region
2115 Copy a rectangular region from a table to a special clipboard.
2116 Point and mark determine edge fields of the rectangle.  If there
2117 is no active region, copy just the current field.  The process
2118 ignores horizontal separator lines.
2120 @item @kbd{C-c C-x C-w} (@code{org-table-cut-region})
2121 @kindex C-c C-x C-w
2122 @findex org-table-cut-region
2123 Copy a rectangular region from a table to a special clipboard,
2124 and blank all fields in the rectangle.  So this is the ``cut''
2125 operation.
2127 @item @kbd{C-c C-x C-y} (@code{org-table-paste-rectangle})
2128 @kindex C-c C-x C-y
2129 @findex org-table-paste-rectangle
2130 Paste a rectangular region into a table.  The upper left corner
2131 ends up in the current field.  All involved fields are
2132 overwritten.  If the rectangle does not fit into the present
2133 table, the table is enlarged as needed.  The process ignores
2134 horizontal separator lines.
2136 @item @kbd{M-@key{RET}} (@code{org-table-wrap-region})
2137 @kindex M-RET
2138 @findex org-table-wrap-region
2139 Split the current field at the cursor position and move the rest
2140 to the line below.  If there is an active region, and both point
2141 and mark are in the same column, the text in the column is
2142 wrapped to minimum width for the given number of lines.
2143 A numeric prefix argument may be used to change the number of
2144 desired lines.  If there is no region, but you specify a prefix
2145 argument, the current field is made blank, and the content is
2146 appended to the field above.
2147 @end table
2149 @anchor{Calculations}
2150 @subheading Calculations
2152 @cindex formula, in tables
2153 @cindex calculations, in tables
2155 @table @asis
2156 @item @kbd{C-c +} (@code{org-table-sum})
2157 @kindex C-c +
2158 @findex org-table-sum
2159 Sum the numbers in the current column, or in the rectangle
2160 defined by the active region.  The result is shown in the echo
2161 area and can be inserted with @kbd{C-y}.
2163 @item @kbd{S-@key{RET}} (@code{org-table-copy-down})
2164 @kindex S-RET
2165 @findex org-table-copy-down
2166 @vindex org-table-copy-increment
2167 When current field is empty, copy from first non-empty field
2168 above.  When not empty, copy current field down to next row and
2169 move cursor along with it.  Depending on the variable
2170 @code{org-table-copy-increment}, integer field values can be
2171 incremented during copy.  Integers that are too large are not
2172 incremented, however.  Also, a @code{0} prefix argument temporarily
2173 disables the increment.  This key is also used by shift-selection
2174 and related modes (see @ref{Conflicts}).
2175 @end table
2177 @anchor{Miscellaneous (1)}
2178 @subheading Miscellaneous
2180 @table @asis
2181 @item @kbd{C-c `} (@code{org-table-edit-field})
2182 @kindex C-c `
2183 @findex org-table-edit-field
2184 Edit the current field in a separate window.  This is useful for
2185 fields that are not fully visible (see @ref{Column Width and Alignment}).  When called with a @kbd{C-u} prefix, just make
2186 the full field visible, so that it can be edited in place.  When
2187 called with two @kbd{C-u} prefixes, make the editor window
2188 follow the cursor through the table and always show the current
2189 field.  The follow mode exits automatically when the cursor
2190 leaves the table, or when you repeat this command with @kbd{C-u C-u C-c `}.
2192 @item @kbd{M-x org-table-import}
2193 @findex org-table-import
2194 Import a file as a table.  The table should be TAB or whitespace
2195 separated.  Use, for example, to import a spreadsheet table or
2196 data from a database, because these programs generally can write
2197 TAB-separated text files.  This command works by inserting the
2198 file into the buffer and then converting the region to a table.
2199 Any prefix argument is passed on to the converter, which uses it
2200 to determine the separator.
2202 @item @kbd{C-c |} (@code{org-table-create-or-convert-from-region})
2203 @kindex C-c |
2204 @findex org-table-create-or-convert-from-region
2205 Tables can also be imported by pasting tabular text into the Org
2206 buffer, selecting the pasted text with @kbd{C-x C-x} and
2207 then using the @kbd{C-c |} command (see @ref{Creation and conversion}).
2209 @item @kbd{M-x org-table-export}
2210 @findex org-table-export
2211 @vindex org-table-export-default-format
2212 Export the table, by default as a TAB-separated file.  Use for
2213 data exchange with, for example, spreadsheet or database
2214 programs.  The format used to export the file can be configured
2215 in the variable @code{org-table-export-default-format}.  You may also
2216 use properties @samp{TABLE_EXPORT_FILE} and @samp{TABLE_EXPORT_FORMAT} to
2217 specify the file name and the format for table export in
2218 a subtree.  Org supports quite general formats for exported
2219 tables.  The exporter format is the same as the format used by
2220 Orgtbl radio tables, see @ref{Translator functions}, for a detailed
2221 description.
2222 @end table
2224 @node Column Width and Alignment
2225 @section Column Width and Alignment
2227 @cindex narrow columns in tables
2228 @cindex alignment in tables
2230 The width of columns is automatically determined by the table editor.
2231 The alignment of a column is determined automatically from the
2232 fraction of number-like versus non-number fields in the column.
2234 @vindex org-table-automatic-realign
2235 Editing a field may modify alignment of the table.  Moving
2236 a contiguous row or column---i.e., using @kbd{@key{TAB}} or
2237 @kbd{@key{RET}}---automatically re-aligns it.  If you want to disable
2238 this behavior, set @code{org-table-automatic-realign} to @code{nil}.  In any
2239 case, you can always align manually a table:
2241 @table @asis
2242 @item @kbd{C-c C-c} (@code{org-table-align})
2243 @kindex C-c C-c
2244 @findex org-table-align
2245 Align the current table.
2246 @end table
2248 @noindent
2249 @vindex org-startup-align-all-tables
2250 Setting the option @code{org-startup-align-all-tables} re-aligns all tables
2251 in a file upon visiting it.  You can also set this option on
2252 a per-file basis with:
2254 @example
2255 #+STARTUP: align
2256 #+STARTUP: noalign
2257 @end example
2259 Sometimes a single field or a few fields need to carry more text,
2260 leading to inconveniently wide columns.  Maybe you want to hide away
2261 several columns or display them with a fixed width, regardless of
2262 content, as shown in the following example.
2264 @example
2265 |---+---------------------+--------|           |---+-------…|…|
2266 |   | <6>                 |        |           |   | <6>   …|…|
2267 | 1 | one                 | some   |   ----\   | 1 | one   …|…|
2268 | 2 | two                 | boring |   ----/   | 2 | two   …|…|
2269 | 3 | This is a long text | column |           | 3 | This i…|…|
2270 |---+---------------------+--------|           |---+-------…|…|
2271 @end example
2273 To set the width of a column, one field anywhere in the column may
2274 contain just the string @samp{<N>} where @var{N} specifies the width
2275 as a number of characters.  You control displayed width of columns
2276 with the following tools:
2278 @table @asis
2279 @item @kbd{C-c @key{TAB}} (@code{org-table-toggle-column-width})
2280 @kindex C-c TAB
2281 @findex org-table-toggle-column-width
2282 Shrink or expand current column.
2284 If a width cookie specifies a width W for the column, shrinking
2285 it displays the first W visible characters only.  Otherwise, the
2286 column is shrunk to a single character.
2288 When called before the first column or after the last one, ask
2289 for a list of column ranges to operate on.
2291 @item @kbd{C-u C-c @key{TAB}} (@code{org-table-shrink})
2292 @kindex C-u C-c TAB
2293 @findex org-table-shrink
2294 Shrink all columns with a column width.  Expand the others.
2296 @item @kbd{C-u C-u C-c @key{TAB}} (@code{org-table-expand})
2297 @kindex C-u C-u C-c TAB
2298 @findex org-table-expand
2299 Expand all columns.
2300 @end table
2302 To see the full text of a shrunk field, hold the mouse over it---a
2303 tool-tip window then shows the full content.  Alternatively @kbd{C-h .}  (@code{display-local-help}) reveals the full content.  For
2304 convenience, any change to a shrunk column expands it.
2306 @vindex org-startup-shrink-all-tables
2307 Setting the option @code{org-startup-shrink-all-tables} shrinks all columns
2308 containing a width cookie in a file the moment it is visited.  You can
2309 also set this option on a per-file basis with:
2311 @example
2312 #+STARTUP: shrink
2313 @end example
2315 If you would like to overrule the automatic alignment of number-rich
2316 columns to the right and of string-rich columns to the left, you can
2317 use @samp{<r>}, @samp{<c>} or @samp{<l>} in a similar fashion.  You may also combine
2318 alignment and field width like this: @samp{<r10>}.
2320 Lines which only contain these formatting cookies are removed
2321 automatically upon exporting the document.
2323 @node Column Groups
2324 @section Column Groups
2326 @cindex grouping columns in tables
2328 When Org exports tables, it does so by default without vertical lines
2329 because that is visually more satisfying in general.  Occasionally
2330 however, vertical lines can be useful to structure a table into groups
2331 of columns, much like horizontal lines can do for groups of rows.  In
2332 order to specify column groups, you can use a special row where the
2333 first field contains only @samp{/}.  The further fields can either contain
2334 @samp{<} to indicate that this column should start a group, @samp{>} to indicate
2335 the end of a column, or @samp{<>} (no space between @samp{<} and @samp{>}) to make
2336 a column a group of its own.  Upon export, boundaries between column
2337 groups are marked with vertical lines.  Here is an example:
2339 @example
2340 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2341 |---+-----+-----+-----+---------+------------|
2342 | / |  <  |     |  >  |       < |          > |
2343 | 1 |  1  |  1  |  1  |       1 |          1 |
2344 | 2 |  4  |  8  | 16  |  1.4142 |     1.1892 |
2345 | 3 |  9  | 27  | 81  |  1.7321 |     1.3161 |
2346 |---+-----+-----+-----+---------+------------|
2347 #+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
2348 @end example
2350 It is also sufficient to just insert the column group starters after
2351 every vertical line you would like to have:
2353 @example
2354 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2355 |---+-----+-----+-----+---------+------------|
2356 | / | <   |     |     | <       |            |
2357 @end example
2359 @node Orgtbl Mode
2360 @section The Orgtbl Minor Mode
2362 @cindex Orgtbl mode
2363 @cindex minor mode for tables
2365 @findex orgtbl-mode
2366 If you like the intuitive way the Org table editor works, you might
2367 also want to use it in other modes like Text mode or Mail mode.  The
2368 minor mode Orgtbl mode makes this possible.  You can always toggle the
2369 mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
2370 example in Message mode, use
2372 @lisp
2373 (add-hook 'message-mode-hook 'turn-on-orgtbl)
2374 @end lisp
2376 Furthermore, with some special setup, it is possible to maintain
2377 tables in arbitrary syntax with Orgtbl mode.  For example, it is
2378 possible to construct @LaTeX{} tables with the underlying ease and power
2379 of Orgtbl mode, including spreadsheet capabilities.  For details, see
2380 @ref{Tables in Arbitrary Syntax}.
2382 @node The spreadsheet
2383 @section The spreadsheet
2385 @cindex calculations, in tables
2386 @cindex spreadsheet capabilities
2387 @cindex Calc package
2389 The table editor makes use of the Emacs Calc package to implement
2390 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms
2391 to derive fields from other fields.  While fully featured, Org's
2392 implementation is not identical to other spreadsheets.  For example,
2393 Org knows the concept of a @emph{column formula} that will be applied to
2394 all non-header fields in a column without having to copy the formula
2395 to each relevant field.  There is also a formula debugger, and
2396 a formula editor with features for highlighting fields in the table
2397 corresponding to the references at the point in the formula, moving
2398 these references by arrow keys.
2400 @menu
2401 * References::                   How to refer to another field or range.
2402 * Formula syntax for Calc::      Using Calc to compute stuff.
2403 * Formula syntax for Lisp::      Writing formulas in Emacs Lisp.
2404 * Durations and time values::    How to compute durations and time values.
2405 * Field and range formulas::     Formula for specific (ranges of) fields.
2406 * Column formulas::              Formulas valid for an entire column.
2407 * Lookup functions::             Lookup functions for searching tables.
2408 * Editing and debugging formulas:: Fixing formulas.
2409 * Updating the table::           Recomputing all dependent fields.
2410 * Advanced features::            Field and column names, automatic recalculation...
2411 @end menu
2413 @node References
2414 @subsection References
2416 @cindex references
2418 To compute fields in the table from other fields, formulas must
2419 reference other fields or ranges.  In Org, fields can be referenced by
2420 name, by absolute coordinates, and by relative coordinates.  To find
2421 out what the coordinates of a field are, press @kbd{C-c ?} in
2422 that field, or press @kbd{C-c @}} to toggle the display of a grid.
2424 @anchor{Field references}
2425 @subsubheading Field references
2427 @cindex field references
2428 @cindex references, to fields
2429 Formulas can reference the value of another field in two ways.  Like
2430 in any other spreadsheet, you may reference fields with
2431 a letter/number combination like @samp{B3}, meaning the second field in the
2432 third row.  However, Org prefers to use another, more general
2433 representation that looks like this:@footnote{Org understands references typed by the user as @samp{B4}, but it
2434 does not use this syntax when offering a formula for editing.  You can
2435 customize this behavior using the variable
2436 @code{org-table-use-standard-references}.}
2438 @example
2439 @@ROW$COLUMN
2440 @end example
2442 Column specifications can be absolute like @samp{$1}, @samp{$2}, @dots{}, @samp{$N}, or
2443 relative to the current column, i.e., the column of the field which is
2444 being computed, like @samp{$+1} or @samp{$-2}.  @samp{$<} and @samp{$>} are immutable
2445 references to the first and last column, respectively, and you can use
2446 @samp{$>>>} to indicate the third column from the right.
2448 The row specification only counts data lines and ignores horizontal
2449 separator lines, or ``hlines''.  Like with columns, you can use absolute
2450 row numbers @samp{@@1}, @samp{@@2}, @dots{}, @samp{@@N}, and row numbers relative to the
2451 current row like @samp{@@+3} or @samp{@@-1}.  @samp{@@<} and @samp{@@>} are immutable
2452 references the first and last row in the table, respectively.  You may
2453 also specify the row relative to one of the hlines: @samp{@@I} refers to the
2454 first hline, @samp{@@II} to the second, etc.  @samp{@@-I} refers to the first such
2455 line above the current line, @samp{@@+I} to the first such line below the
2456 current line.  You can also write @samp{@@III+2} which is the second data
2457 line after the third hline in the table.
2459 @samp{@@0} and @samp{$0} refer to the current row and column, respectively, i.e.,
2460 to the row/column for the field being computed.  Also, if you omit
2461 either the column or the row part of the reference, the current
2462 row/column is implied.
2464 Org's references with @emph{unsigned} numbers are fixed references in the
2465 sense that if you use the same reference in the formula for two
2466 different fields, the same field is referenced each time.  Org's
2467 references with @emph{signed} numbers are floating references because the
2468 same reference operator can reference different fields depending on
2469 the field being calculated by the formula.
2471 Here are a few examples:
2473 @multitable @columnfractions 0.2 0.8
2474 @item @samp{@@2$3}
2475 @tab 2nd row, 3rd column (same as @samp{C2})
2476 @item @samp{$5}
2477 @tab column 5 in the current row (same as @samp{E&})
2478 @item @samp{@@2}
2479 @tab current column, row 2
2480 @item @samp{@@-1$-3}
2481 @tab field one row up, three columns to the left
2482 @item @samp{@@-I$2}
2483 @tab field just under hline above current row, column 2
2484 @item @samp{@@>$5}
2485 @tab field in the last row, in column 5
2486 @end multitable
2488 @anchor{Range references}
2489 @subsubheading Range references
2491 @cindex range references
2492 @cindex references, to ranges
2493 You may reference a rectangular range of fields by specifying two
2494 field references connected by two dots @samp{..}.  If both fields are in
2495 the current row, you may simply use @samp{$2..$7}, but if at least one
2496 field is in a different row, you need to use the general @samp{@@ROW$COLUMN}
2497 format at least for the first field, i.e., the reference must start
2498 with @samp{@@} in order to be interpreted correctly.  Examples:
2500 @multitable @columnfractions 0.2 0.8
2501 @item @samp{$1..$3}
2502 @tab first three fields in the current row
2503 @item @samp{$P..$Q}
2504 @tab range, using column names (see @ref{Advanced features})
2505 @item @samp{$<<<..$>>}
2506 @tab start in third column, continue to the last but one
2507 @item @samp{@@2$1..@@4$3}
2508 @tab six fields between these two fields (same as @samp{A2..C4})
2509 @item @samp{@@-1$-2..@@-1}
2510 @tab 3 fields in the row above, starting from 2 columns on the left
2511 @item @samp{@@I..II}
2512 @tab between first and second hline, short for @samp{@@I..@@II}
2513 @end multitable
2515 @noindent
2516 Range references return a vector of values that can be fed into Calc
2517 vector functions.  Empty fields in ranges are normally suppressed, so
2518 that the vector contains only the non-empty fields.  For other options
2519 with the mode switches @samp{E}, @samp{N} and examples, see @ref{Formula syntax for Calc}.
2521 @anchor{Field coordinates in formulas}
2522 @subsubheading Field coordinates in formulas
2524 @cindex field coordinates
2525 @cindex coordinates, of field
2526 @cindex row, of field coordinates
2527 @cindex column, of field coordinates
2528 @vindex org-table-current-column
2529 @vindex org-table-current-dline
2530 One of the very first actions during evaluation of Calc formulas and
2531 Lisp formulas is to substitute @samp{@@#} and @samp{$#} in the formula with the
2532 row or column number of the field where the current result will go to.
2533 The traditional Lisp formula equivalents are @code{org-table-current-dline}
2534 and @code{org-table-current-column}.  Examples:
2536 @table @asis
2537 @item @samp{if(@@# % 2, $#, string(""))}
2538 Insert column number on odd rows, set field to empty on even
2539 rows.
2541 @item @samp{$2 = '(identity remote(FOO, @@@@#$1))}
2542 Copy text or values of each row of column 1 of the table named
2543 @var{FOO} into column 2 of the current table.
2545 @item @samp{@@3 = 2 * remote(FOO, @@@@1$$#)}
2546 Insert the doubled value of each column of row 1 of the table
2547 named @var{FOO} into row 3 of the current table.
2548 @end table
2550 @noindent
2551 For the second and third examples, table @var{FOO} must have at
2552 least as many rows or columns as the current table.  Note that this is
2553 inefficient@footnote{The computation time scales as O(N^2) because table
2554 @var{FOO} is parsed for each field to be copied.} for large number of rows.
2556 @anchor{Named references}
2557 @subsubheading Named references
2559 @cindex named references
2560 @cindex references, named
2561 @cindex name, of column or field
2562 @cindex constants, in calculations
2563 @cindex @samp{CONSTANTS}, keyword
2564 @vindex org-table-formula-constants
2566 @samp{$name} is interpreted as the name of a column, parameter or constant.
2567 Constants are defined globally through the variable
2568 @code{org-table-formula-constants}, and locally---for the file---through
2569 a line like this example:
2571 @example
2572 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2573 @end example
2575 @noindent
2576 @vindex constants-unit-system
2577 @pindex constants.el
2578 Also, properties (see @ref{Properties and Columns}) can be used as
2579 constants in table formulas: for a property @samp{Xyz} use the name
2580 @samp{$PROP_Xyz}, and the property will be searched in the current outline
2581 entry and in the hierarchy above it.  If you have the @samp{constants.el}
2582 package, it will also be used to resolve constants, including natural
2583 constants like @samp{$h} for Planck's constant, and units like @samp{$km} for
2584 kilometers@footnote{The file @samp{constants.el} can supply the values of constants in
2585 two different unit systems, @samp{SI} and @samp{cgs}.  Which one is used depends
2586 on the value of the variable @code{constants-unit-system}.  You can use the
2587 @samp{STARTUP} options @samp{constSI} and @samp{constcgs} to set this value for the
2588 current buffer.}.  Column names and parameters can be specified in
2589 special table lines.  These are described below, see @ref{Advanced features}.  All names must start with a letter, and further consist
2590 of letters and numbers.
2592 @anchor{Remote references}
2593 @subsubheading Remote references
2595 @cindex remote references
2596 @cindex references, remote
2597 @cindex references, to a different table
2598 @cindex name, of column or field
2599 @cindex @samp{NAME}, keyword
2600 You may also reference constants, fields and ranges from a different
2601 table, either in the current file or even in a different file.  The
2602 syntax is
2604 @example
2605 remote(NAME,REF)
2606 @end example
2608 @noindent
2609 where @var{NAME} can be the name of a table in the current file
2610 as set by a @samp{#+NAME:} line before the table.  It can also be the ID of
2611 an entry, even in a different file, and the reference then refers to
2612 the first table in that entry.  @var{REF} is an absolute field or
2613 range reference as described above for example @samp{@@3$3} or @samp{$somename},
2614 valid in the referenced table.
2616 @cindex table indirection
2617 When @var{NAME} has the format @samp{@@ROW$COLUMN}, it is substituted
2618 with the name or ID found in this field of the current table.  For
2619 example @samp{remote($1, @@@@>$2)} @result{} @samp{remote(year_2013, @@@@>$1)}.  The format
2620 @samp{B3} is not supported because it can not be distinguished from a plain
2621 table name or ID.
2623 @node Formula syntax for Calc
2624 @subsection Formula syntax for Calc
2626 @cindex formula syntax, Calc
2627 @cindex syntax, of formulas
2629 A formula can be any algebraic expression understood by the Emacs Calc
2630 package.  Note that Calc has the non-standard convention that @samp{/} has
2631 lower precedence than @samp{*}, so that @samp{a/b*c} is interpreted as
2632 @samp{(a/(b*c))}.  Before evaluation by @code{calc-eval} (see @ref{Calling Calc from Your Programs,Calling Calc from
2633 Your Lisp Programs,,calc,}), variable substitution takes place according to
2634 the rules described above.
2636 @cindex vectors, in table calculations
2637 The range vectors can be directly fed into the Calc vector functions
2638 like @code{vmean} and @code{vsum}.
2640 @cindex format specifier, in spreadsheet
2641 @cindex mode, for Calc
2642 @vindex org-calc-default-modes
2643 A formula can contain an optional mode string after a semicolon.  This
2644 string consists of flags to influence Calc and other modes during
2645 execution.  By default, Org uses the standard Calc modes (precision
2646 12, angular units degrees, fraction and symbolic modes off).  The
2647 display format, however, has been changed to @code{(float 8)} to keep
2648 tables compact.  The default settings can be configured using the
2649 variable @code{org-calc-default-modes}.
2651 @table @asis
2652 @item @samp{p20}
2653 Set the internal Calc calculation precision to 20 digits.
2655 @item @samp{n3}, @samp{s3}, @samp{e2}, @samp{f4}
2656 Normal, scientific, engineering or fixed format of the result of
2657 Calc passed back to Org.  Calc formatting is unlimited in
2658 precision as long as the Calc calculation precision is greater.
2660 @item @samp{D}, @samp{R}
2661 Degree and radian angle modes of Calc.
2663 @item @samp{F}, @samp{S}
2664 Fraction and symbolic modes of Calc.
2666 @item @samp{T}, @samp{t}, @samp{U}
2667 Duration computations in Calc or Lisp, @ref{Durations and time values}.
2669 @item @samp{E}
2670 If and how to consider empty fields.  Without @samp{E} empty fields in
2671 range references are suppressed so that the Calc vector or Lisp
2672 list contains only the non-empty fields.  With @samp{E} the empty
2673 fields are kept.  For empty fields in ranges or empty field
2674 references the value @samp{nan} (not a number) is used in Calc
2675 formulas and the empty string is used for Lisp formulas.  Add @samp{N}
2676 to use 0 instead for both formula types.  For the value of
2677 a field the mode @samp{N} has higher precedence than @samp{E}.
2679 @item @samp{N}
2680 Interpret all fields as numbers, use 0 for non-numbers.  See the
2681 next section to see how this is essential for computations with
2682 Lisp formulas.  In Calc formulas it is used only occasionally
2683 because there number strings are already interpreted as numbers
2684 without @samp{N}.
2686 @item @samp{L}
2687 Literal, for Lisp formulas only.  See the next section.
2688 @end table
2690 @noindent
2691 Unless you use large integer numbers or high-precision calculation and
2692 display for floating point numbers you may alternatively provide
2693 a @code{printf} format specifier to reformat the Calc result after it has
2694 been passed back to Org instead of letting Calc already do the
2695 formatting@footnote{The printf reformatting is limited in precision because the
2696 value passed to it is converted into an ``integer'' or ``double''.  The
2697 ``integer'' is limited in size by truncating the signed value to 32
2698 bits.  The ``double'' is limited in precision to 64 bits overall which
2699 leaves approximately 16 significant decimal digits.}.  A few examples:
2701 @multitable {aaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
2702 @item @samp{$1+$2}
2703 @tab Sum of first and second field
2704 @item @samp{$1+$2;%.2f}
2705 @tab Same, format result to two decimals
2706 @item @samp{exp($2)+exp($1)}
2707 @tab Math functions can be used
2708 @item @samp{$0;%.1f}
2709 @tab Reformat current cell to 1 decimal
2710 @item @samp{($3-32)*5/9}
2711 @tab Degrees F @arrow{} C conversion
2712 @item @samp{$c/$1/$cm}
2713 @tab Hz @arrow{} cm conversion, using @samp{constants.el}
2714 @item @samp{tan($1);Dp3s1}
2715 @tab Compute in degrees, precision 3, display SCI 1
2716 @item @samp{sin($1);Dp3%.1e}
2717 @tab Same, but use @code{printf} specifier for display
2718 @item @samp{vmean($2..$7)}
2719 @tab Compute column range mean, using vector function
2720 @item @samp{vmean($2..$7);EN}
2721 @tab Same, but treat empty fields as 0
2722 @item @samp{taylor($3,x=7,2)}
2723 @tab Taylor series of $3, at x=7, second degree
2724 @end multitable
2726 Calc also contains a complete set of logical operations (see @ref{Logical Operations,Logical
2727 Operations,,calc,}).  For example
2729 @table @asis
2730 @item @samp{if($1 < 20, teen, string(""))}
2731 @samp{"teen"} if age @samp{$1} is less than 20, else the Org table result
2732 field is set to empty with the empty string.
2734 @item @samp{if("$1" =} ``nan'' || ``$2'' @samp{= "nan", string(""), $1 + $2); E f-1}
2735 Sum of the first two columns.  When at least one of the input
2736 fields is empty the Org table result field is set to empty.  @samp{E}
2737 is required to not convert empty fields to 0.  @samp{f-1} is an
2738 optional Calc format string similar to @samp{%.1f} but leaves empty
2739 results empty.
2741 @item @samp{if(typeof(vmean($1..$7)) =} 12, string(``''), vmean($1..$7); E=
2742 Mean value of a range unless there is any empty field.  Every
2743 field in the range that is empty is replaced by @samp{nan} which lets
2744 @samp{vmean} result in @samp{nan}.  Then @samp{typeof =} 12= detects the @samp{nan}
2745 from @code{vmean} and the Org table result field is set to empty.  Use
2746 this when the sample set is expected to never have missing
2747 values.
2749 @item @samp{if("$1..$7" =} ``[]'', string(``''), vmean($1..$7))=
2750 Mean value of a range with empty fields skipped.  Every field in
2751 the range that is empty is skipped.  When all fields in the range
2752 are empty the mean value is not defined and the Org table result
2753 field is set to empty.  Use this when the sample set can have
2754 a variable size.
2756 @item @samp{vmean($1..$7); EN}
2757 To complete the example before: Mean value of a range with empty
2758 fields counting as samples with value 0.  Use this only when
2759 incomplete sample sets should be padded with 0 to the full size.
2760 @end table
2762 You can add your own Calc functions defined in Emacs Lisp with
2763 @code{defmath} and use them in formula syntax for Calc.
2765 @node Formula syntax for Lisp
2766 @subsection Emacs Lisp forms as formulas
2768 @cindex Lisp forms, as table formulas
2770 It is also possible to write a formula in Emacs Lisp.  This can be
2771 useful for string manipulation and control structures, if Calc's
2772 functionality is not enough.
2774 If a formula starts with a single-quote followed by an opening
2775 parenthesis, then it is evaluated as a Lisp form.  The evaluation
2776 should return either a string or a number.  Just as with Calc
2777 formulas, you can specify modes and a @code{printf} format after
2778 a semicolon.
2780 With Emacs Lisp forms, you need to be conscious about the way field
2781 references are interpolated into the form.  By default, a reference is
2782 interpolated as a Lisp string (in double-quotes) containing the field.
2783 If you provide the @samp{N} mode switch, all referenced elements are
2784 numbers---non-number fields will be zero---and interpolated as Lisp
2785 numbers, without quotes.  If you provide the @samp{L} flag, all fields are
2786 interpolated literally, without quotes.  I.e., if you want a reference
2787 to be interpreted as a string by the Lisp form, enclose the reference
2788 operator itself in double-quotes, like @samp{"$3"}.  Ranges are inserted as
2789 space-separated fields, so you can embed them in list or vector
2790 syntax.
2792 Here are a few examples---note how the @samp{N} mode is used when we do
2793 computations in Lisp:
2795 @table @asis
2796 @item @samp{'(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))}
2797 Swap the first two characters of the content of column 1.
2799 @item @samp{'(+ $1 $2);N}
2800 Add columns 1 and 2, equivalent to Calc's @samp{$1+$2}.
2802 @item @samp{'(apply '+ '($1..$4));N}
2803 Compute the sum of columns 1 to 4, like Calc's @samp{vsum($1..$4)}.
2804 @end table
2806 @node Durations and time values
2807 @subsection Durations and time values
2809 @cindex Duration, computing
2810 @cindex Time, computing
2811 @vindex org-table-duration-custom-format
2813 If you want to compute time values use the @samp{T}, @samp{t}, or @samp{U} flag,
2814 either in Calc formulas or Elisp formulas:
2816 @example
2817 |  Task 1 |   Task 2 |    Total |
2818 |---------+----------+----------|
2819 |    2:12 |     1:47 | 03:59:00 |
2820 |    2:12 |     1:47 |    03:59 |
2821 | 3:02:20 | -2:07:00 |     0.92 |
2822 #+TBLFM: @@2$3=$1+$2;T::@@3$3=$1+$2;U::@@4$3=$1+$2;t
2823 @end example
2825 Input duration values must be of the form @samp{HH:MM[:SS]}, where seconds
2826 are optional.  With the @samp{T} flag, computed durations are displayed as
2827 @samp{HH:MM:SS} (see the first formula above).  With the @samp{U} flag, seconds
2828 are omitted so that the result is only @samp{HH:MM} (see second formula
2829 above).  Zero-padding of the hours field depends upon the value of the
2830 variable @code{org-table-duration-hour-zero-padding}.
2832 With the @samp{t} flag, computed durations are displayed according to the
2833 value of the option @code{org-table-duration-custom-format}, which defaults
2834 to @code{hours} and displays the result as a fraction of hours (see the
2835 third formula in the example above).
2837 Negative duration values can be manipulated as well, and integers are
2838 considered as seconds in addition and subtraction.
2840 @node Field and range formulas
2841 @subsection Field and range formulas
2843 @cindex field formula
2844 @cindex range formula
2845 @cindex formula, for individual table field
2846 @cindex formula, for range of fields
2848 To assign a formula to a particular field, type it directly into the
2849 field, preceded by @samp{:=}, for example @samp{vsum(@@II..III)}.  When you press
2850 @kbd{@key{TAB}} or @kbd{@key{RET}} or @kbd{C-c C-c} with the cursor
2851 still in the field, the formula is stored as the formula for this
2852 field, evaluated, and the current field is replaced with the result.
2854 @cindex @samp{TBLFM}, keyword
2855 Formulas are stored in a special @samp{TBLFM} keyword located directly
2856 below the table.  If you type the equation in the fourth field of the
2857 third data line in the table, the formula looks like @samp{@@3$4=$1+$2}.
2858 When inserting/deleting/swapping column and rows with the appropriate
2859 commands, @emph{absolute references} (but not relative ones) in stored
2860 formulas are modified in order to still reference the same field.  To
2861 avoid this from happening, in particular in range references, anchor
2862 ranges at the table borders (using @samp{@@<}, @samp{@@>}, @samp{$<}, @samp{$>}), or at
2863 hlines using the @samp{@@I} notation.  Automatic adaptation of field
2864 references does of course not happen if you edit the table structure
2865 with normal editing commands---then you must fix the equations
2866 yourself.
2868 Instead of typing an equation into the field, you may also use the
2869 following command
2871 @table @asis
2872 @item @kbd{C-u C-c =} (@code{org-table-eval-formula})
2873 @kindex C-u C-c =
2874 @findex org-table-eval-formula
2875 Install a new formula for the current field.  The command prompts
2876 for a formula with default taken from the @samp{TBLFM} keyword,
2877 applies it to the current field, and stores it.
2878 @end table
2880 The left-hand side of a formula can also be a special expression in
2881 order to assign the formula to a number of different fields.  There is
2882 no keyboard shortcut to enter such range formulas.  To add them, use
2883 the formula editor (see @ref{Editing and debugging formulas}) or edit the
2884 @samp{TBLFM} keyword directly.
2886 @table @asis
2887 @item @samp{$2=}
2888 Column formula, valid for the entire column.  This is so common
2889 that Org treats these formulas in a special way, see @ref{Column formulas}.
2891 @item @code{@@3=}
2892 Row formula, applies to all fields in the specified row.  @samp{@@>=}
2893 means the last row.
2895 @item @samp{@@1$2..@@4$3=}
2896 Range formula, applies to all fields in the given rectangular
2897 range.  This can also be used to assign a formula to some but not
2898 all fields in a row.
2900 @item @samp{$NAME=}
2901 Named field, see @ref{Advanced features}.
2902 @end table
2904 @node Column formulas
2905 @subsection Column formulas
2907 @cindex column formula
2908 @cindex formula, for table column
2910 When you assign a formula to a simple column reference like @samp{$3=}, the
2911 same formula is used in all fields of that column, with the following
2912 very convenient exceptions: (i) If the table contains horizontal
2913 separator hlines with rows above and below, everything before the
2914 first such hline is considered part of the table @emph{header} and is not
2915 modified by column formulas.  Therefore a header is mandatory when you
2916 use column formulas and want to add hlines to group rows, like for
2917 example to separate a total row at the bottom from the summand rows
2918 above.  (ii) Fields that already get a value from a field/range
2919 formula are left alone by column formulas.  These conditions make
2920 column formulas very easy to use.
2922 To assign a formula to a column, type it directly into any field in
2923 the column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2924 @kbd{@key{TAB}} or @kbd{@key{RET}} or @kbd{C-c C-c} with the cursor
2925 still in the field, the formula is stored as the formula for the
2926 current column, evaluated and the current field replaced with the
2927 result.  If the field contains only @samp{=}, the previously stored formula
2928 for this column is used.  For each column, Org only remembers the most
2929 recently used formula.  In the @samp{TBLFM} keyword, column formulas look
2930 like @samp{$4=$1+$2}.  The left-hand side of a column formula can not be
2931 the name of column, it must be the numeric column reference or @samp{$>}.
2933 Instead of typing an equation into the field, you may also use the
2934 following command:
2936 @table @asis
2937 @item @kbd{C-c =} (@code{org-table-eval-formula})
2938 @kindex C-c =
2939 @findex org-table-eval-formula
2940 Install a new formula for the current column and replace current
2941 field with the result of the formula.  The command prompts for
2942 a formula, with default taken from the @samp{TBLFM} keyword, applies
2943 it to the current field and stores it.  With a numeric prefix
2944 argument, e.g., @kbd{C-5 C-c =}, the command applies it to
2945 that many consecutive fields in the current column.
2946 @end table
2948 @node Lookup functions
2949 @subsection Lookup functions
2951 @cindex lookup functions in tables
2952 @cindex table lookup functions
2954 Org has three predefined Emacs Lisp functions for lookups in tables.
2956 @table @asis
2957 @item @code{(org-lookup-first VAL S-LIST R-LIST &optional PREDICATE)}
2958 @findex org-lookup-first
2959 Searches for the first element @var{S} in list
2960 @var{S-LIST} for which
2961 @lisp
2962 (PREDICATE VAL S)
2963 @end lisp
2964 is non-@code{nil}; returns the value from the corresponding position
2965 in list @var{R-LIST}.  The default @var{PREDICATE} is
2966 @code{equal}.  Note that the parameters @var{VAL} and
2967 @var{S} are passed to @var{PREDICATE} in the same order
2968 as the corresponding parameters are in the call to
2969 @code{org-lookup-first}, where @var{VAL} precedes
2970 @var{S-LIST}.  If @var{R-LIST} is @code{nil}, the matching
2971 element @var{S} of @var{S-LIST} is returned.
2973 @item @code{(org-lookup-last VAL S-LIST R-LIST &optional PREDICATE)}
2974 @findex org-lookup-last
2975 Similar to @code{org-lookup-first} above, but searches for the @emph{last}
2976 element for which @var{PREDICATE} is non-@code{nil}.
2978 @item @code{(org-lookup-all VAL S-LIST R-LIST &optional PREDICATE)}
2979 @findex org-lookup-all
2980 Similar to @code{org-lookup-first}, but searches for @emph{all} elements
2981 for which @var{PREDICATE} is non-@code{nil}, and returns @emph{all}
2982 corresponding values.  This function can not be used by itself in
2983 a formula, because it returns a list of values.  However,
2984 powerful lookups can be built when this function is combined with
2985 other Emacs Lisp functions.
2986 @end table
2988 If the ranges used in these functions contain empty fields, the @samp{E}
2989 mode for the formula should usually be specified: otherwise empty
2990 fields are not included in @var{S-LIST} and/or @var{R-LIST}
2991 which can, for example, result in an incorrect mapping from an element
2992 of @var{S-LIST} to the corresponding element of
2993 @var{R-LIST}.
2995 These three functions can be used to implement associative arrays,
2996 count matching cells, rank results, group data, etc.  For practical
2997 examples see @uref{https://orgmode.org/worg/org-tutorials/org-lookups.html, this tutorial on Worg}.
2999 @node Editing and debugging formulas
3000 @subsection Editing and debugging formulas
3002 @cindex formula editing
3003 @cindex editing, of table formulas
3005 @vindex org-table-use-standard-references
3006 You can edit individual formulas in the minibuffer or directly in the
3007 field.  Org can also prepare a special buffer with all active formulas
3008 of a table.  When offering a formula for editing, Org converts
3009 references to the standard format (like @samp{B3} or @samp{D&}) if possible.  If
3010 you prefer to only work with the internal format (like @samp{@@3$2} or
3011 @samp{$4}), configure the variable @code{org-table-use-standard-references}.
3013 @table @asis
3014 @item @kbd{C-c =} or @kbd{C-u C-c =} (@code{org-table-eval-formula})
3015 @kindex C-c =
3016 @kindex C-u C-c =
3017 @findex org-table-eval-formula
3018 Edit the formula associated with the current column/field in the
3019 minibuffer.  See @ref{Column formulas}, and @ref{Field and range formulas}.
3021 @item @kbd{C-u C-u C-c =} (@code{org-table-eval-formula})
3022 @kindex C-u C-u C-c =
3023 @findex org-table-eval-formula
3024 Re-insert the active formula (either a field formula, or a column
3025 formula) into the current field, so that you can edit it directly
3026 in the field.  The advantage over editing in the minibuffer is
3027 that you can use the command @kbd{C-c ?}.
3029 @item @kbd{C-c ?} (@code{org-table-field-info})
3030 @kindex C-c ?
3031 @findex org-table-field-info
3032 While editing a formula in a table field, highlight the field(s)
3033 referenced by the reference at the cursor position in the
3034 formula.
3036 @item @kbd{C-c @}} (@code{org-table-toggle-coordinate-overlays})
3037 @kindex C-c @}
3038 @findex org-table-toggle-coordinate-overlays
3039 Toggle the display of row and column numbers for a table, using
3040 overlays.  These are updated each time the table is aligned; you
3041 can force it with @kbd{C-c C-c}.
3043 @item @kbd{C-c @{} (@code{org-table-toggle-formula-debugger})
3044 @kindex C-c @{
3045 @findex org-table-toggle-formula-debugger
3046 Toggle the formula debugger on and off.  See below.
3048 @item @kbd{C-c '} (@code{org-table-edit-formulas})
3049 @kindex C-c '
3050 @findex org-table-edit-formulas
3051 Edit all formulas for the current table in a special buffer,
3052 where the formulas are displayed one per line.  If the current
3053 field has an active formula, the cursor in the formula editor
3054 marks it.  While inside the special buffer, Org automatically
3055 highlights any field or range reference at the cursor position.
3056 You may edit, remove and add formulas, and use the following
3057 commands:
3059 @table @asis
3060 @item @kbd{C-c C-c} or @kbd{C-x C-s} (@code{org-table-fedit-finish})
3061 @kindex C-x C-s
3062 @kindex C-c C-c
3063 @findex org-table-fedit-finish
3064 Exit the formula editor and store the modified formulas.  With
3065 @kbd{C-u} prefix, also apply the new formulas to the
3066 entire table.
3068 @item @kbd{C-c C-q} (@code{org-table-fedit-abort})
3069 @kindex C-c C-q
3070 @findex org-table-fedit-abort
3071 Exit the formula editor without installing changes.
3073 @item @kbd{C-c C-r} (@code{org-table-fedit-toggle-ref-type})
3074 @kindex C-c C-r
3075 @findex org-table-fedit-toggle-ref-type
3076 Toggle all references in the formula editor between standard
3077 (like @samp{B3}) and internal (like @samp{@@3$2}).
3079 @item @kbd{@key{TAB}} (@code{org-table-fedit-lisp-indent})
3080 @kindex TAB
3081 @findex org-table-fedit-lisp-indent
3082 Pretty-print or indent Lisp formula at point.  When in a line
3083 containing a Lisp formula, format the formula according to
3084 Emacs Lisp rules.  Another @kbd{@key{TAB}} collapses the formula
3085 back again.  In the open formula, @kbd{@key{TAB}} re-indents
3086 just like in Emacs Lisp mode.
3088 @item @kbd{M-@key{TAB}} (@code{lisp-complete-symbol})
3089 @kindex M-TAB
3090 @findex lisp-complete-symbol
3091 Complete Lisp symbols, just like in Emacs Lisp mode.
3093 @item @kbd{S-@key{UP}}, @kbd{S-@key{DOWN}}, @kbd{S-@key{LEFT}}, @kbd{S-@key{RIGHT}}
3094 @kindex S-UP
3095 @kindex S-DOWN
3096 @kindex S-LEFT
3097 @kindex S-RIGHT
3098 @findex org-table-fedit-ref-up
3099 @findex org-table-fedit-ref-down
3100 @findex org-table-fedit-ref-left
3101 @findex org-table-fedit-ref-right
3102 Shift the reference at point.  For example, if the reference
3103 is @samp{B3} and you press @kbd{S-@key{RIGHT}}, it becomes @samp{C3}.
3104 This also works for relative references and for hline
3105 references.
3107 @item @kbd{M-S-@key{UP}} (@code{org-table-fedit-line-up})
3108 @kindex M-S-UP
3109 @findex org-table-fedit-line-up
3110 Move the test line for column formulas up in the Org buffer.
3112 @item @kbd{M-S-@key{DOWN}} (@code{org-table-fedit-line-down})
3113 @kindex M-S-DOWN
3114 @findex org-table-fedit-line-down
3115 Move the test line for column formulas down in the Org buffer.
3117 @item @kbd{M-@key{UP}} (@code{org-table-fedit-scroll-up})
3118 @kindex M-UP
3119 @findex org-table-fedit-scroll-up
3120 Scroll up the window displaying the table.
3122 @item @kbd{M-@key{DOWN}} (@code{org-table-fedit-scroll-down})
3123 @kindex M-DOWN
3124 @findex org-table-fedit-scroll-down
3125 Scroll down the window displaying the table.
3127 @item @kbd{C-c @}}
3128 @kindex C-c @}
3129 @findex org-table-toggle-coordinate-overlays
3130 Turn the coordinate grid in the table on and off.
3131 @end table
3132 @end table
3134 Making a table field blank does not remove the formula associated with
3135 the field, because that is stored in a different line---the @samp{TBLFM}
3136 keyword line.  During the next recalculation, the field will be filled
3137 again.  To remove a formula from a field, you have to give an empty
3138 reply when prompted for the formula, or to edit the @samp{TBLFM} keyword.
3140 @kindex C-c C-c
3141 You may edit the @samp{TBLFM} keyword directly and re-apply the changed
3142 equations with @kbd{C-c C-c} in that line or with the normal
3143 recalculation commands in the table.
3145 @anchor{Using multiple @samp{TBLFM} lines}
3146 @subsubheading Using multiple @samp{TBLFM} lines
3148 @cindex multiple formula lines
3149 @cindex @samp{TBLFM} keywords, multiple
3150 @cindex @samp{TBLFM}, switching
3152 @kindex C-c C-c
3153 You may apply the formula temporarily.  This is useful when you switch
3154 the formula.  Place multiple @samp{TBLFM} keywords right after the table,
3155 and then press @kbd{C-c C-c} on the formula to apply.  Here is an
3156 example:
3158 @example
3159 | x | y |
3160 |---+---|
3161 | 1 |   |
3162 | 2 |   |
3163 #+TBLFM: $2=$1*1
3164 #+TBLFM: $2=$1*2
3165 @end example
3167 @noindent
3168 Pressing @kbd{C-c C-c} in the line of @samp{#+TBLFM: $2=$1*2} yields:
3170 @example
3171 | x | y |
3172 |---+---|
3173 | 1 | 2 |
3174 | 2 | 4 |
3175 #+TBLFM: $2=$1*1
3176 #+TBLFM: $2=$1*2
3177 @end example
3179 @noindent
3180 Note: If you recalculate this table, with @kbd{C-u C-c *}, for
3181 example, you get the following result of applying only the first
3182 @samp{TBLFM} keyword.
3184 @example
3185 | x | y |
3186 |---+---|
3187 | 1 | 1 |
3188 | 2 | 2 |
3189 #+TBLFM: $2=$1*1
3190 #+TBLFM: $2=$1*2
3191 @end example
3193 @anchor{Debugging formulas}
3194 @subsubheading Debugging formulas
3196 @cindex formula debugging
3197 @cindex debugging, of table formulas
3199 When the evaluation of a formula leads to an error, the field content
3200 becomes the string @samp{#ERROR}.  If you would like to see what is going
3201 on during variable substitution and calculation in order to find
3202 a bug, turn on formula debugging in the Tbl menu and repeat the
3203 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in
3204 a field.  Detailed information are displayed.
3206 @node Updating the table
3207 @subsection Updating the table
3209 @cindex recomputing table fields
3210 @cindex updating, table
3212 Recalculation of a table is normally not automatic, but needs to be
3213 triggered by a command.  To make recalculation at least
3214 semi-automatic, see @ref{Advanced features}.
3216 In order to recalculate a line of a table or the entire table, use the
3217 following commands:
3219 @table @asis
3220 @item @kbd{C-c *} (@code{org-table-recalculate})
3221 @kindex C-c *
3222 @findex org-table-recalculate
3223 Recalculate the current row by first applying the stored column
3224 formulas from left to right, and all field/range formulas in the
3225 current row.
3227 @item @kbd{C-u C-c *} or @kbd{C-u C-c C-c}
3228 @kindex C-u C-c *
3229 @kindex C-u C-c C-c
3230 Recompute the entire table, line by line.  Any lines before the
3231 first hline are left alone, assuming that these are part of the
3232 table header.
3234 @item @kbd{C-u C-u C-c *} or @kbd{C-u C-u C-c C-c} (@code{org-table-iterate})
3235 @kindex C-u C-u C-c *
3236 @kindex C-u C-u C-c C-c
3237 @findex org-table-iterate
3238 Iterate the table by recomputing it until no further changes
3239 occur.  This may be necessary if some computed fields use the
3240 value of other fields that are computed @emph{later} in the
3241 calculation sequence.
3243 @item @kbd{M-x org-table-recalculate-buffer-tables}
3244 @findex org-table-recalculate-buffer-tables
3245 Recompute all tables in the current buffer.
3247 @item @kbd{M-x org-table-iterate-buffer-tables}
3248 @findex org-table-iterate-buffer-tables
3249 Iterate all tables in the current buffer, in order to converge
3250 table-to-table dependencies.
3251 @end table
3253 @node Advanced features
3254 @subsection Advanced features
3256 If you want the recalculation of fields to happen automatically, or if
3257 you want to be able to assign @emph{names}@footnote{Such names must start with an alphabetic character and use
3258 only alphanumeric/underscore characters.} to fields and columns,
3259 you need to reserve the first column of the table for special marking
3260 characters.
3262 @table @asis
3263 @item @kbd{C-#} (@code{org-table-rotate-recalc-marks})
3264 @kindex C-#
3265 @findex org-table-rotate-recalc-marks
3266 Rotate the calculation mark in first column through the states
3267 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region, change all
3268 marks in the region.
3269 @end table
3271 Here is an example of a table that collects exam results of students
3272 and makes use of these features:
3274 @example
3275 |---+---------+--------+--------+--------+-------+------|
3276 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
3277 |---+---------+--------+--------+--------+-------+------|
3278 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
3279 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
3280 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
3281 |---+---------+--------+--------+--------+-------+------|
3282 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
3283 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
3284 |---+---------+--------+--------+--------+-------+------|
3285 |   | Average |        |        |        |  25.0 |      |
3286 | ^ |         |        |        |        |    at |      |
3287 | $ | max=50  |        |        |        |       |      |
3288 |---+---------+--------+--------+--------+-------+------|
3289 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
3290 @end example
3292 @noindent
3293 @strong{Important}: please note that for these special tables, recalculating
3294 the table with @kbd{C-u C-c *} only affects rows that are marked
3295 @samp{#} or @samp{*}, and fields that have a formula assigned to the field
3296 itself.  The column formulas are not applied in rows with empty first
3297 field.
3299 @cindex marking characters, tables
3300 The marking characters have the following meaning:
3302 @table @asis
3303 @item @samp{!}
3304 The fields in this line define names for the columns, so that you
3305 may refer to a column as @samp{$Tot} instead of @samp{$6}.
3307 @item @samp{^}
3308 This row defines names for the fields @emph{above} the row.  With such
3309 a definition, any formula in the table may use @samp{$m1} to refer to
3310 the value @samp{10}.  Also, if you assign a formula to a names field,
3311 it is stored as @samp{$name = ...}.
3313 @item @samp{_}
3314 Similar to @samp{^}, but defines names for the fields in the row
3315 @emph{below}.
3317 @item @samp{$}
3318 Fields in this row can define @emph{parameters} for formulas.  For
3319 example, if a field in a @samp{$} row contains @samp{max=50}, then formulas
3320 in this table can refer to the value 50 using @samp{$max}.  Parameters
3321 work exactly like constants, only that they can be defined on
3322 a per-table basis.
3324 @item @samp{#}
3325 Fields in this row are automatically recalculated when pressing
3326 @kbd{@key{TAB}} or @kbd{@key{RET}} or @kbd{S-@key{TAB}} in this row.
3327 Also, this row is selected for a global recalculation with
3328 @kbd{C-u C-c *}.  Unmarked lines are left alone by this
3329 command.
3331 @item @samp{*}
3332 Selects this line for global recalculation with @kbd{C-u C-c *}, but not for automatic recalculation.  Use this when
3333 automatic recalculation slows down editing too much.
3335 @item @samp{/}
3336 Do not export this line.  Useful for lines that contain the
3337 narrowing @samp{<N>} markers or column group markers.
3338 @end table
3340 Finally, just to whet your appetite for what can be done with the
3341 fantastic Calc package, here is a table that computes the Taylor
3342 series of degree n at location x for a couple of functions.
3344 @example
3345 |---+-------------+---+-----+--------------------------------------|
3346 |   | Func        | n | x   | Result                               |
3347 |---+-------------+---+-----+--------------------------------------|
3348 | # | exp(x)      | 1 | x   | 1 + x                                |
3349 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
3350 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
3351 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
3352 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
3353 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
3354 |---+-------------+---+-----+--------------------------------------|
3355 #+TBLFM: $5=taylor($2,$4,$3);n3
3356 @end example
3358 @node Org Plot
3359 @section Org Plot
3361 @cindex graph, in tables
3362 @cindex plot tables using Gnuplot
3364 Org Plot can produce graphs of information stored in Org tables,
3365 either graphically or in ASCII art.
3367 @anchor{Graphical plots using Gnuplot}
3368 @subheading Graphical plots using Gnuplot
3370 @cindex @samp{PLOT}, keyword
3371 Org Plot can produce 2D and 3D graphs of information stored in Org
3372 tables using @uref{http://www.gnuplot.info/, Gnuplot} and @uref{http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html, Gnuplot mode}.  To see this in action, ensure
3373 that you have both Gnuplot and Gnuplot mode installed on your system,
3374 then call @kbd{C-c " g} or @kbd{M-x org-plot/gnuplot} on the
3375 following table.
3377 @example
3378 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
3379 | Sede      | Max cites | H-index |
3380 |-----------+-----------+---------|
3381 | Chile     |    257.72 |   21.39 |
3382 | Leeds     |    165.77 |   19.68 |
3383 | Sao Paolo |     71.00 |   11.50 |
3384 | Stockholm |    134.19 |   14.33 |
3385 | Morelia   |    257.56 |   17.67 |
3386 @end example
3388 Notice that Org Plot is smart enough to apply the table's headers as
3389 labels.  Further control over the labels, type, content, and
3390 appearance of plots can be exercised through the @samp{PLOT} keyword
3391 preceding a table.  See below for a complete list of Org Plot options.
3392 For more information and examples see the @uref{https://orgmode.org/worg/org-tutorials/org-plot.html, Org Plot tutorial}.
3394 @anchor{Plot options}
3395 @subsubheading Plot options
3397 @table @asis
3398 @item @samp{set}
3399 Specify any Gnuplot option to be set when graphing.
3401 @item @samp{title}
3402 Specify the title of the plot.
3404 @item @samp{ind}
3405 Specify which column of the table to use as the @samp{x} axis.
3407 @item @samp{deps}
3408 Specify the columns to graph as a Lisp style list, surrounded by
3409 parentheses and separated by spaces for example @samp{dep:(3 4)} to
3410 graph the third and fourth columns.  Defaults to graphing all
3411 other columns aside from the @samp{ind} column.
3413 @item @samp{type}
3414 Specify whether the plot is @samp{2d}, @samp{3d}, or @samp{grid}.
3416 @item @samp{with}
3417 Specify a @samp{with} option to be inserted for every column being
3418 plotted, e.g., @samp{lines}, @samp{points}, @samp{boxes}, @samp{impulses}.  Defaults
3419 to @samp{lines}.
3421 @item @samp{file}
3422 If you want to plot to a file, specify
3423 @samp{"path/to/desired/output-file"}.
3425 @item @samp{labels}
3426 List of labels to be used for the @samp{deps}.  Defaults to the column
3427 headers if they exist.
3429 @item @samp{line}
3430 Specify an entire line to be inserted in the Gnuplot script.
3432 @item @samp{map}
3433 When plotting @samp{3d} or @samp{grid} types, set this to @samp{t} to graph
3434 a flat mapping rather than a @samp{3d} slope.
3436 @item @samp{timefmt}
3437 Specify format of Org mode timestamps as they will be parsed by
3438 Gnuplot.  Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
3440 @item @samp{script}
3441 If you want total control, you can specify a script file---place
3442 the file name between double-quotes---which will be used to plot.
3443 Before plotting, every instance of @samp{$datafile} in the specified
3444 script will be replaced with the path to the generated data file.
3445 Note: even if you set this option, you may still want to specify
3446 the plot type, as that can impact the content of the data file.
3447 @end table
3449 @anchor{ASCII bar plots}
3450 @subheading ASCII bar plots
3452 While the cursor is on a column, typing @kbd{C-c `` a} or
3453 @kbd{M-x orgtbl-ascii-plot} create a new column containing an
3454 ASCII-art bars plot.  The plot is implemented through a regular column
3455 formula.  When the source column changes, the bar plot may be updated
3456 by refreshing the table, for example typing @kbd{C-u C-c *}.
3458 @example
3459 | Sede          | Max cites |              |
3460 |---------------+-----------+--------------|
3461 | Chile         |    257.72 | WWWWWWWWWWWW |
3462 | Leeds         |    165.77 | WWWWWWWh     |
3463 | Sao Paolo     |     71.00 | WWW;         |
3464 | Stockholm     |    134.19 | WWWWWW:      |
3465 | Morelia       |    257.56 | WWWWWWWWWWWH |
3466 | Rochefourchat |      0.00 |              |
3467 #+TBLFM: $3='(orgtbl-ascii-draw $2 0.0 257.72 12)
3468 @end example
3470 The formula is an Elisp call.
3472 @defun orgtbl-ascii-draw value min max &optional width
3473 Draw an ASCII bar in a table.
3475 @var{VALUE} is the value to plot.
3477 @var{MIN} is the value displayed as an empty bar.  @var{MAX}
3478 is the value filling all the @var{WIDTH}.  Sources values outside
3479 this range are displayed as @samp{too small} or @samp{too large}.
3481 @var{WIDTH} is the number of characters of the bar plot.  It
3482 defaults to @samp{12}.
3483 @end defun
3485 @node Hyperlinks
3486 @chapter Hyperlinks
3488 @cindex hyperlinks
3490 Like HTML, Org provides links inside a file, external links to
3491 other files, Usenet articles, emails, and much more.
3493 @menu
3494 * Link Format::                  How links in Org are formatted.
3495 * Internal Links::               Links to other places in the current file.
3496 * Radio Targets::                Make targets trigger links in plain text.
3497 * External Links::               URL-like links to the world.
3498 * Handling Links::               Creating, inserting and following.
3499 * Using Links Outside Org::      Linking from my C source code?
3500 * Link Abbreviations::           Shortcuts for writing complex links.
3501 * Search Options::               Linking to a specific location.
3502 * Custom Searches::              When the default search is not enough.
3503 @end menu
3505 @node Link Format
3506 @section Link Format
3508 @cindex link format
3509 @cindex format, of links
3511 Org recognizes plain URL-like links and activate them as clickable
3512 links.  The general link format, however, looks like this:
3514 @example
3515 [[LINK][DESCRIPTION]]
3516 @end example
3518 @noindent
3519 or alternatively
3521 @example
3522 [[LINK]]
3523 @end example
3525 @noindent
3526 Once a link in the buffer is complete (all brackets present), Org
3527 changes the display so that @samp{DESCRIPTION} is displayed instead of
3528 @samp{[[LINK][DESCRIPTION]]} and @samp{LINK} is displayed instead of @samp{[[LINK]]}.  Links are be
3529 highlighted in the face @code{org-link}, which by default is an underlined
3530 face.  You can directly edit the visible part of a link.  Note that
3531 this can be either the LINK part, if there is no description, or the
3532 @var{DESCRIPTION} part.  To edit also the invisible
3533 @var{LINK} part, use @kbd{C-c C-l} with the cursor on the
3534 link.
3536 If you place the cursor at the beginning or just behind the end of the
3537 displayed text and press @kbd{@key{BS}}, you remove
3538 the---invisible---bracket at that location.  This makes the link
3539 incomplete and the internals are again displayed as plain text.
3540 Inserting the missing bracket hides the link internals again.  To show
3541 the internal structure of all links, use the menu: Org @arrow{} Hyperlinks @arrow{}
3542 Literal links.
3544 @node Internal Links
3545 @section Internal Links
3547 @cindex internal links
3548 @cindex links, internal
3549 @cindex targets, for links
3551 @cindex @samp{CUSTOM_ID}, property
3552 If the link does not look like a URL, it is considered to be internal
3553 in the current file.  The most important case is a link like
3554 @samp{[[#my-custom-id]]} which links to the entry with the @samp{CUSTOM_ID} property
3555 @samp{my-custom-id}.  You are responsible yourself to make sure these
3556 custom IDs are unique in a file.
3558 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]} lead to a text search in
3559 the current file.
3561 The link can be followed with @kbd{C-c C-o} when the cursor is on
3562 the link, or with a mouse click (see @ref{Handling Links}).  Links to
3563 custom IDs point to the corresponding headline.  The preferred match
3564 for a text link is a @emph{dedicated target}: the same string in double
3565 angular brackets, like @samp{<<My Target>>}.
3567 @cindex @samp{NAME}, keyword
3568 If no dedicated target exists, the link tries to match the exact name
3569 of an element within the buffer.  Naming is done with the @samp{NAME}
3570 keyword, which has to be put in the line before the element it refers
3571 to, as in the following example
3573 @example
3574 #+NAME: My Target
3575 | a  | table      |
3576 |----+------------|
3577 | of | four cells |
3578 @end example
3580 If none of the above succeeds, Org searches for a headline that is
3581 exactly the link text but may also include a TODO keyword and
3582 tags@footnote{To insert a link targeting a headline, in-buffer completion
3583 can be used.  Just type a star followed by a few optional letters into
3584 the buffer and press @kbd{M-@key{TAB}}.  All headlines in the current
3585 buffer are offered as completions.}.
3587 During export, internal links are used to mark objects and assign them
3588 a number.  Marked objects are then referenced by links pointing to
3589 them.  In particular, links without a description appear as the number
3590 assigned to the marked object@footnote{When targeting a @samp{NAME} keyword, @samp{CAPTION} keyword is
3591 mandatory in order to get proper numbering (see @ref{Images and Tables}).}.  In the following excerpt from
3592 an Org buffer
3594 @example
3595 1. one item
3596 2. <<target>>another item
3597 Here we refer to item [[target]].
3598 @end example
3600 @noindent
3601 The last sentence will appear as @samp{Here we refer to item 2} when
3602 exported.
3604 In non-Org files, the search looks for the words in the link text.  In
3605 the above example the search would be for @samp{target}.
3607 Following a link pushes a mark onto Org's own mark ring.  You can
3608 return to the previous position with @kbd{C-c &}.  Using this
3609 command several times in direct succession goes back to positions
3610 recorded earlier.
3612 @node Radio Targets
3613 @section Radio Targets
3615 @cindex radio targets
3616 @cindex targets, radio
3617 @cindex links, radio targets
3619 Org can automatically turn any occurrences of certain target names in
3620 normal text into a link.  So without explicitly creating a link, the
3621 text connects to the target radioing its position.  Radio targets are
3622 enclosed by triple angular brackets.  For example, a target @samp{<<<My
3623 Target>>>} causes each occurrence of @samp{my target} in normal text to
3624 become activated as a link.  The Org file is scanned automatically for
3625 radio targets only when the file is first loaded into Emacs.  To
3626 update the target list during editing, press @kbd{C-c C-c} with
3627 the cursor on or at a target.
3629 @node External Links
3630 @section External Links
3632 @cindex links, external
3633 @cindex external links
3634 @cindex Gnus links
3635 @cindex BBDB links
3636 @cindex irc links
3637 @cindex URL links
3638 @cindex file links
3639 @cindex Rmail links
3640 @cindex MH-E links
3641 @cindex Usenet links
3642 @cindex shell links
3643 @cindex Info links
3644 @cindex Elisp links
3646 Org supports links to files, websites, Usenet and email messages, BBDB
3647 database entries and links to both IRC conversations and their logs.
3648 External links are URL-like locators.  They start with a short
3649 identifying string followed by a colon.  There can be no space after
3650 the colon.  The following list shows examples for each link type.
3652 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
3653 @item @samp{http://www.astro.uva.nl/=dominik}
3654 @tab on the web
3655 @item @samp{doi:10.1000/182}
3656 @tab DOI for an electronic resource
3657 @item @samp{file:/home/dominik/images/jupiter.jpg}
3658 @tab file, absolute path
3659 @item @samp{/home/dominik/images/jupiter.jpg}
3660 @tab same as above
3661 @item @samp{file:papers/last.pdf}
3662 @tab file, relative path
3663 @item @samp{./papers/last.pdf}
3664 @tab same as above
3665 @item @samp{file:/ssh:me@@some.where:papers/last.pdf}
3666 @tab file, path on remote machine
3667 @item @samp{/ssh:me@@some.where:papers/last.pdf}
3668 @tab same as above
3669 @item @samp{file:sometextfile::NNN}
3670 @tab file, jump to line number
3671 @item @samp{file:projects.org}
3672 @tab another Org file
3673 @item @samp{file:projects.org::some words}
3674 @tab text search in Org file@footnote{The actual behavior of the search depends on the value of the
3675 variable @code{org-link-search-must-match-exact-headline}.  If its value is
3676 @code{nil}, then a fuzzy text search is done.  If it is @code{t}, then only the
3677 exact headline is matched, ignoring spaces and statistic cookies.  If
3678 the value is @code{query-to-create}, then an exact headline is searched; if
3679 it is not found, then the user is queried to create it.}
3680 @item @samp{file:projects.org::*task title}
3681 @tab heading search in Org file
3682 @item @samp{file+sys:/path/to/file}
3683 @tab open via OS, like double-click
3684 @item @samp{file+emacs:/path/to/file}
3685 @tab force opening by Emacs
3686 @item @samp{docview:papers/last.pdf::NNN}
3687 @tab open in doc-view mode at page
3688 @item @samp{id:B7423F4D-2E8A-471B-8810-C40F074717E9}
3689 @tab Link to heading by ID
3690 @item @samp{news:comp.emacs}
3691 @tab Usenet link
3692 @item @samp{mailto:adent@@galaxy.net}
3693 @tab Mail link
3694 @item @samp{mhe:folder}
3695 @tab MH-E folder link
3696 @item @samp{mhe:folder#id}
3697 @tab MH-E message link
3698 @item @samp{rmail:folder}
3699 @tab Rmail folder link
3700 @item @samp{rmail:folder#id}
3701 @tab Rmail message link
3702 @item @samp{gnus:group}
3703 @tab Gnus group link
3704 @item @samp{gnus:group#id}
3705 @tab Gnus article link
3706 @item @samp{bbdb:R.*Stallman}
3707 @tab BBDB link (with regexp)
3708 @item @samp{irc:/irc.com/#emacs/bob}
3709 @tab IRC link
3710 @item @samp{info:org#External links}
3711 @tab Info node link
3712 @item @samp{shell:ls *.org}
3713 @tab A shell command
3714 @item @samp{elisp:org-agenda}
3715 @tab Interactive Elisp command
3716 @item @samp{elisp:(find-file-other-frame "Elisp.org")}
3717 @tab Elisp form to evaluate
3718 @end multitable
3720 @cindex VM links
3721 @cindex Wanderlust links
3722 On top of these built-in link types, some are available through the
3723 @samp{contrib/} directory (see @ref{Installation}).  For example, these links to
3724 VM or Wanderlust messages are available when you load the
3725 corresponding libraries from the @samp{contrib/} directory:
3727 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaa}
3728 @item @samp{vm:folder}
3729 @tab VM folder link
3730 @item @samp{vm:folder#id}
3731 @tab VM message link
3732 @item @samp{vm://myself@@some.where.org/folder#id}
3733 @tab VM on remote machine
3734 @item @samp{vm-imap:account:folder}
3735 @tab VM IMAP folder link
3736 @item @samp{vm-imap:account:folder#id}
3737 @tab VM IMAP message link
3738 @item @samp{wl:folder}
3739 @tab Wanderlust folder link
3740 @item @samp{wl:folder#id}
3741 @tab Wanderlust message link
3742 @end multitable
3744 For customizing Org to add new link types, see @ref{Adding Hyperlink Types}.
3746 A link should be enclosed in double brackets and may contain
3747 a descriptive text to be displayed instead of the URL (see @ref{Link Format}), for example:
3749 @example
3750 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
3751 @end example
3753 @noindent
3754 If the description is a file name or URL that points to an image, HTML
3755 export (see @ref{HTML Export}) inlines the image as a clickable button.  If
3756 there is no description at all and the link points to an image, that
3757 image is inlined into the exported HTML file.
3759 @cindex square brackets, around links
3760 @cindex angular brackets, around links
3761 @cindex plain text external links
3762 Org also finds external links in the normal text and activates them as
3763 links.  If spaces must be part of the link (for example in
3764 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities about
3765 the end of the link, enclose them in square or angular brackets.
3767 @node Handling Links
3768 @section Handling Links
3770 @cindex links, handling
3772 Org provides methods to create a link in the correct syntax, to insert
3773 it into an Org file, and to follow the link.
3775 @findex org-store-link
3776 @cindex storing links
3777 The main function is @code{org-store-link}, called with @kbd{M-x org-store-link}.  Because of its importance, we suggest to bind it
3778 to a widely available key (see @ref{Activation}).  It stores a link to the
3779 current location.  The link is stored for later insertion into an Org
3780 buffer---see below.  What kind of link is created depends on the
3781 current buffer:
3783 @table @asis
3784 @item @emph{Org mode buffers}
3785 For Org files, if there is a @samp{<<target>>} at the cursor, the link
3786 points to the target.  Otherwise it points to the current
3787 headline, which is also the description@footnote{If the headline contains a timestamp, it is removed from the
3788 link, which results in a wrong link---you should avoid putting
3789 a timestamp in the headline.}.
3791 @vindex org-link-to-org-use-id
3792 @cindex @samp{CUSTOM_ID}, property
3793 @cindex @samp{ID}, property
3794 If the headline has a @samp{CUSTOM_ID} property, store a link to this
3795 custom ID.  In addition or alternatively, depending on the value
3796 of @code{org-link-to-org-use-id}, create and/or use a globally unique
3797 ID property for the link@footnote{The Org Id library must first be loaded, either through
3798 @code{org-customize}, by enabling @code{id} in @code{org-modules}, or by adding
3799 @code{(require 'org-id)} in your Emacs init file.}.  So using this command in Org
3800 buffers potentially creates two links: a human-readable link from
3801 the custom ID, and one that is globally unique and works even if
3802 the entry is moved from file to file.  Later, when inserting the
3803 link, you need to decide which one to use.
3805 @item @emph{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}
3806 Pretty much all Emacs mail clients are supported.  The link
3807 points to the current article, or, in some Gnus buffers, to the
3808 group.  The description is constructed from the author and the
3809 subject.
3811 @item @emph{Web browsers: W3, W3M and EWW}
3812 Here the link is the current URL, with the page title as
3813 description.
3815 @item @emph{Contacts: BBDB}
3816 Links created in a BBDB buffer point to the current entry.
3818 @item @emph{Chat: IRC}
3819 @vindex org-irc-links-to-logs
3820 For IRC links, if the variable @code{org-irc-link-to-logs} is
3821 non-@code{nil}, create a @samp{file} style link to the relevant point in
3822 the logs for the current conversation.  Otherwise store an @samp{irc}
3823 style link to the user/channel/server under the point.
3825 @item @emph{Other files}
3826 For any other file, the link points to the file, with a search
3827 string (see @ref{Search Options}) pointing to the
3828 contents of the current line.  If there is an active region, the
3829 selected words form the basis of the search string.  If the
3830 automatically created link is not working correctly or accurately
3831 enough, you can write custom functions to select the search
3832 string and to do the search for particular file types (see
3833 @ref{Custom Searches}).
3835 You can also define dedicated links to other files.  See @ref{Adding Hyperlink Types}.
3837 @item @emph{Agenda view}
3838 When the cursor is in an agenda view, the created link points to
3839 the entry referenced by the current line.
3840 @end table
3842 From an Org buffer, the following commands create, navigate or, more
3843 generally, act on links.
3845 @table @asis
3846 @item @kbd{C-c C-l} (@code{org-insert-link})
3847 @kindex C-c C-l
3848 @findex org-insert-link
3849 @cindex link completion
3850 @cindex completion, of links
3851 @cindex inserting links
3852 @vindex org-keep-stored-link-after-insertion
3853 Insert a link@footnote{Note that you do not have to use this command to insert
3854 a link.  Links in Org are plain text, and you can type or paste them
3855 straight into the buffer.  By using this command, the links are
3856 automatically enclosed in double brackets, and you will be asked for
3857 the optional descriptive text.}.  This prompts for a link to be inserted
3858 into the buffer.  You can just type a link, using text for an
3859 internal link, or one of the link type prefixes mentioned in the
3860 examples above.  The link is inserted into the buffer, along with
3861 a descriptive text@footnote{After insertion of a stored link, the link will be removed
3862 from the list of stored links.  To keep it in the list later use, use
3863 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or
3864 configure the option @code{org-keep-stored-link-after-insertion}.}.  If some text was selected at this
3865 time, it becomes the default description.
3867 @table @asis
3868 @item @emph{Inserting stored links}
3869 All links stored during the current session are part of the
3870 history for this prompt, so you can access them with
3871 @kbd{@key{UP}} and @kbd{@key{DOWN}} (or @kbd{M-p},
3872 @kbd{M-n}).
3874 @item @emph{Completion support}
3875 Completion with @kbd{@key{TAB}} helps you to insert valid link
3876 prefixes like @samp{http} or @samp{ftp}, including the prefixes defined
3877 through link abbreviations (see @ref{Link Abbreviations}).  If you
3878 press @kbd{@key{RET}} after inserting only the prefix, Org
3879 offers specific completion support for some link types@footnote{This works if a function has been defined in the @code{:complete}
3880 property of a link in @code{org-link-parameters}.}.
3881 For example, if you type @kbd{f i l e @key{RET}}---alternative
3882 access: @kbd{C-u C-c C-l}, see below---Org offers file
3883 name completion, and after @kbd{b b d b @key{RET}} you can
3884 complete contact names.
3885 @end table
3887 @item @kbd{C-u C-c C-l}
3888 @cindex file name completion
3889 @cindex completion, of file names
3890 @kindex C-u C-c C-l
3891 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix
3892 argument, insert a link to a file.  You may use file name
3893 completion to select the name of the file.  The path to the file
3894 is inserted relative to the directory of the current Org file, if
3895 the linked file is in the current directory or in a sub-directory
3896 of it, or if the path is written relative to the current
3897 directory using @samp{../}.  Otherwise an absolute path is used, if
3898 possible with @samp{~/} for your home directory.  You can force an
3899 absolute path with two @kbd{C-u} prefixes.
3901 @item @kbd{C-c C-l} (with cursor on existing link)
3902 @cindex following links
3903 When the cursor is on an existing link, @kbd{C-c C-l} allows
3904 you to edit the link and description parts of the link.
3906 @item @kbd{C-c C-o} (@code{org-open-at-point})
3907 @kindex C-c C-o
3908 @findex org-open-at-point
3909 @vindex org-file-apps
3910 Open link at point.  This launches a web browser for URL (using
3911 @code{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB
3912 for the corresponding links, and execute the command in a shell
3913 link.  When the cursor is on an internal link, this command runs
3914 the corresponding search.  When the cursor is on a TAG list in
3915 a headline, it creates the corresponding TAGS view.  If the
3916 cursor is on a timestamp, it compiles the agenda for that date.
3917 Furthermore, it visits text and remote files in @samp{file} links with
3918 Emacs and select a suitable application for local non-text files.
3919 Classification of files is based on file extension only.  See
3920 option @code{org-file-apps}.  If you want to override the default
3921 application and visit the file with Emacs, use a @kbd{C-u}
3922 prefix.  If you want to avoid opening in Emacs, use a @kbd{C-u C-u} prefix.
3924 @vindex org-link-frame-setup
3925 If the cursor is on a headline, but not on a link, offer all
3926 links in the headline and entry text.  If you want to setup the
3927 frame configuration for following links, customize
3928 @code{org-link-frame-setup}.
3930 @item @kbd{@key{RET}}
3931 @vindex org-return-follows-link
3932 @kindex RET
3933 When @code{org-return-follows-link} is set, @kbd{@key{RET}} also
3934 follows the link at point.
3936 @item @kbd{mouse-2} or @kbd{mouse-1}
3937 @kindex mouse-2
3938 @kindex mouse-1
3939 On links, @kbd{mouse-1} and @kbd{mouse-2} opens the
3940 link just as @kbd{C-c C-o} does.
3942 @item @kbd{mouse-3}
3943 @vindex org-display-internal-link-with-indirect-buffer
3944 @kindex mouse-3
3945 Like @kbd{mouse-2}, but force file links to be opened with
3946 Emacs, and internal links to be displayed in another
3947 window@footnote{See the variable @code{org-display-internal-link-with-indirect-buffer}.}.
3949 @item @kbd{C-c C-x C-v} (@code{org-toggle-inline-images})
3950 @cindex inlining images
3951 @cindex images, inlining
3952 @vindex org-startup-with-inline-images
3953 @kindex C-c C-x C-v
3954 @findex org-toggle-inline-images
3955 Toggle the inline display of linked images.  Normally this only
3956 inlines images that have no description part in the link, i.e.,
3957 images that are inlined during export.  When called with a prefix
3958 argument, also display images that do have a link description.
3959 You can ask for inline images to be displayed at startup by
3960 configuring the variable @code{org-startup-with-inline-images}@footnote{The variable @code{org-startup-with-inline-images} can be set
3961 within a buffer with the @samp{STARTUP} options @samp{inlineimages} and
3962 @samp{noinlineimages}.}.
3964 @item @kbd{C-c %} (@code{org-mark-ring-push})
3965 @kindex C-c %
3966 @findex org-mark-ring-push
3967 @cindex mark ring
3968 Push the current position onto the mark ring, to be able to
3969 return easily.  Commands following an internal link do this
3970 automatically.
3972 @item @kbd{C-c &} (@code{org-mark-ring-goto})
3973 @kindex C-c &
3974 @findex org-mark-ring-goto
3975 @cindex links, returning to
3976 Jump back to a recorded position.  A position is recorded by the
3977 commands following internal links, and by @kbd{C-c %}.
3978 Using this command several times in direct succession moves
3979 through a ring of previously recorded positions.
3981 @item @kbd{C-c C-x C-n} (@code{org-next-link})
3982 @itemx @kbd{C-c C-x C-p} (@code{org-previous-link})
3983 @kindex C-c C-x C-p
3984 @findex org-previous-link
3985 @kindex C-c C-x C-n
3986 @findex org-next-link
3987 @cindex links, finding next/previous
3988 Move forward/backward to the next link in the buffer.  At the
3989 limit of the buffer, the search fails once, and then wraps
3990 around.  The key bindings for this are really too long; you might
3991 want to bind this also to @kbd{M-n} and @kbd{M-p}.
3993 @lisp
3994 (add-hook 'org-load-hook
3995           (lambda ()
3996             (define-key org-mode-map "\M-n" 'org-next-link)
3997             (define-key org-mode-map "\M-p" 'org-previous-link)))
3998 @end lisp
3999 @end table
4001 @node Using Links Outside Org
4002 @section Using Links Outside Org
4004 @findex org-insert-link-global
4005 @findex org-open-at-point-global
4006 You can insert and follow links that have Org syntax not only in Org,
4007 but in any Emacs buffer.  For this, Org provides two functions:
4008 @code{org-insert-link-global} and @code{org-open-at-point-global}.
4010 You might want to bind them to globally available keys.  See
4011 @ref{Activation} for some advice.
4013 @node Link Abbreviations
4014 @section Link Abbreviations
4016 @cindex link abbreviations
4017 @cindex abbreviation, links
4019 Long URL can be cumbersome to type, and often many similar links are
4020 needed in a document.  For this you can use link abbreviations.  An
4021 abbreviated link looks like this
4023 @example
4024 [[linkword:tag][description]]
4025 @end example
4027 @noindent
4028 @vindex org-link-abbrev-alist
4029 where the tag is optional.  The @emph{linkword} must be a word, starting
4030 with a letter, followed by letters, numbers, @samp{-}, and @samp{_}.
4031 Abbreviations are resolved according to the information in the
4032 variable @code{org-link-abbrev-alist} that relates the linkwords to
4033 replacement text.  Here is an example:
4035 @lisp
4036 (setq org-link-abbrev-alist
4037       '(("bugzilla"  . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
4038         ("url-to-ja" . "http://translate.google.fr/translate?sl=en&tl=ja&u=%h")
4039         ("google"    . "http://www.google.com/search?q=")
4040         ("gmap"      . "http://maps.google.com/maps?q=%s")
4041         ("omap"      . "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")
4042         ("ads"       . "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?author=%s&db_key=AST")))
4043 @end lisp
4045 If the replacement text contains the string @samp{%s}, it is replaced with
4046 the tag.  Using @samp{%h} instead of @samp{%s} percent-encodes the tag (see the
4047 example above, where we need to encode the URL parameter).  Using
4048 @samp{%(my-function)} passes the tag to a custom function, and replace it
4049 by the resulting string.
4051 If the replacement text do not contain any specifier, it is simply
4052 appended to the string in order to create the link.
4054 Instead of a string, you may also specify a function that will be
4055 called with the tag as the only argument to create the link.
4057 With the above setting, you could link to a specific bug with
4058 @samp{[[bugzilla:129]]}, search the web for @samp{OrgMode} with @samp{[[google:OrgMode]]},
4059 show the map location of the Free Software Foundation @samp{[[gmap:51
4060 Franklin Street, Boston]]} or of Carsten office @samp{[[omap:Science Park 904,
4061 Amsterdam, The Netherlands]]} and find out what the Org author is doing
4062 besides Emacs hacking with @samp{[[ads:Dominik,C]]}.
4064 If you need special abbreviations just for a single Org buffer, you
4065 can define them in the file with
4067 @cindex @samp{LINK}, keyword
4068 @example
4069 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
4070 #+LINK: google    http://www.google.com/search?q=%s
4071 @end example
4073 @noindent
4074 In-buffer completion (see @ref{Completion}) can be used after @samp{[} to
4075 complete link abbreviations.  You may also define a function that
4076 implements special (e.g., completion) support for inserting such
4077 a link with @kbd{C-c C-l}.  Such a function should not accept any
4078 arguments, and return the full link with prefix.  You can set the link
4079 completion function like this:
4081 @lisp
4082 (org-link-set-parameter "type" :complete #'some-completion-function)
4083 @end lisp
4085 @node Search Options
4086 @section Search Options in File Links
4088 @cindex search option in file links
4089 @cindex file links, searching
4091 File links can contain additional information to make Emacs jump to
4092 a particular location in the file when following a link.  This can be
4093 a line number or a search option after a double colon@footnote{For backward compatibility, line numbers can also follow a
4094 single colon.}.  For
4095 example, when the command @code{org-store-link} creates a link (see
4096 @ref{Handling Links}) to a file, it encodes the words in the current line
4097 as a search string that can be used to find this line back later when
4098 following the link with @kbd{C-c C-o}.
4100 Here is the syntax of the different ways to attach a search to a file
4101 link, together with an explanation:
4103 @example
4104 [[file:~/code/main.c::255]]
4105 [[file:~/xx.org::My Target]]
4106 [[file:~/xx.org::*My Target]]
4107 [[file:~/xx.org::#my-custom-id]]
4108 [[file:~/xx.org::/regexp/]]
4109 @end example
4111 @table @asis
4112 @item @samp{255}
4113 Jump to line 255.
4115 @item @samp{My Target}
4116 Search for a link target @samp{<<My Target>>}, or do a text search for
4117 @samp{my target}, similar to the search in internal links, see
4118 @ref{Internal Links}.  In HTML export (see @ref{HTML Export}), such a file
4119 link becomes a HTML reference to the corresponding named anchor
4120 in the linked file.
4122 @item @samp{*My Target}
4123 In an Org file, restrict search to headlines.
4125 @item @samp{#my-custom-id}
4126 Link to a heading with a @samp{CUSTOM_ID} property
4128 @item @samp{/REGEXP/}
4129 Do a regular expression search for @var{REGEXP}.  This uses
4130 the Emacs command @code{occur} to list all matches in a separate
4131 window.  If the target file is in Org mode, @code{org-occur} is used
4132 to create a sparse tree with the matches.
4133 @end table
4135 As a degenerate case, a file link with an empty file name can be used
4136 to search the current file.  For example, @samp{[[file:::find me]]} does
4137 a search for @samp{find me} in the current file, just as @samp{[[find me]]} would.
4139 @node Custom Searches
4140 @section Custom Searches
4142 @cindex custom search strings
4143 @cindex search strings, custom
4145 The default mechanism for creating search strings and for doing the
4146 actual search related to a file link may not work correctly in all
4147 cases.  For example, Bib@TeX{} database files have many entries like
4148 @code{year="1993"} which would not result in good search strings, because
4149 the only unique identification for a Bib@TeX{} entry is the citation key.
4151 @vindex org-create-file-search-functions
4152 @vindex org-execute-file-search-functions
4153 If you come across such a problem, you can write custom functions to
4154 set the right search string for a particular file type, and to do the
4155 search for the string in the file.  Using @code{add-hook}, these functions
4156 need to be added to the hook variables
4157 @code{org-create-file-search-functions} and
4158 @code{org-execute-file-search-functions}.  See the docstring for these
4159 variables for more information.  Org actually uses this mechanism for
4160 Bib@TeX{} database files, and you can use the corresponding code as an
4161 implementation example.  See the file @samp{org-bibtex.el}.
4163 @node TODO Items
4164 @chapter TODO Items
4166 @cindex TODO items
4168 Org mode does not maintain TODO lists as separate documents@footnote{Of course, you can make a document that contains only long
4169 lists of TODO items, but this is not required.}.
4170 Instead, TODO items are an integral part of the notes file, because
4171 TODO items usually come up while taking notes!  With Org mode, simply
4172 mark any entry in a tree as being a TODO item.  In this way,
4173 information is not duplicated, and the entire context from which the
4174 TODO item emerged is always present.
4176 Of course, this technique for managing TODO items scatters them
4177 throughout your notes file.  Org mode compensates for this by
4178 providing methods to give you an overview of all the things that you
4179 have to do.
4181 @menu
4182 * TODO Basics::                  Marking and displaying TODO entries.
4183 * TODO Extensions::              Workflow and assignments.
4184 * Progress Logging::             Dates and notes for progress.
4185 * Priorities::                   Some things are more important than others.
4186 * Breaking Down Tasks::          Splitting a task into manageable pieces.
4187 * Checkboxes::                   Tick-off lists.
4188 @end menu
4190 @node TODO Basics
4191 @section Basic TODO Functionality
4193 Any headline becomes a TODO item when it starts with the word @samp{TODO},
4194 for example:
4196 @example
4197 *** TODO Write letter to Sam Fortune
4198 @end example
4200 @noindent
4201 The most important commands to work with TODO entries are:
4203 @table @asis
4204 @item @kbd{C-c C-t} (@code{org-todo})
4205 @kindex C-c C-t
4206 @cindex cycling, of TODO states
4207 Rotate the TODO state of the current item among
4209 @example
4210 ,-> (unmarked) -> TODO -> DONE --.
4211 '--------------------------------'
4212 @end example
4214 If TODO keywords have fast access keys (see @ref{Fast access to TODO states}), prompt for a TODO keyword through the fast
4215 selection interface; this is the default behavior when
4216 @code{org-use-fast-todo-selection} is non-@code{nil}.
4218 The same rotation can also be done ``remotely'' from the timeline
4219 and agenda buffers with the @kbd{t} command key (see
4220 @ref{Agenda Commands}).
4222 @item @kbd{C-u C-c C-t}
4223 @kindex C-u C-c C-t
4224 When TODO keywords have no selection keys, select a specific
4225 keyword using completion; otherwise force cycling through TODO
4226 states with no prompt.  When @code{org-use-fast-todo-selection} is set
4227 to @code{prefix}, use the fast selection interface.
4229 @item @kbd{S-@key{RIGHT}} @kbd{S-@key{LEFT}}
4230 @kindex S-RIGHT
4231 @kindex S-LEFT
4232 @vindex org-treat-S-cursor-todo-selection-as-state-change
4233 Select the following/preceding TODO state, similar to cycling.
4234 Useful mostly if more than two TODO states are possible (see
4235 @ref{TODO Extensions}).  See also @ref{Conflicts}, for a discussion of the interaction with
4236 @code{shift-selection-mode}.  See also the variable
4237 @code{org-treat-S-cursor-todo-selection-as-state-change}.
4239 @item @kbd{C-c / t} (@code{org-show-todo-tree})
4240 @kindex C-c / t
4241 @cindex sparse tree, for TODO
4242 @vindex org-todo-keywords
4243 @findex org-show-todo-tree
4244 View TODO items in a @emph{sparse tree} (see @ref{Sparse Trees}).  Folds
4245 the entire buffer, but shows all TODO items---with not-DONE
4246 state---and the headings hierarchy above them.  With a prefix
4247 argument, or by using @kbd{C-c / T}, search for a specific
4248 TODO.  You are prompted for the keyword, and you can also give
4249 a list of keywords like @samp{KWD1|KWD2|...} to list entries that
4250 match any one of these keywords.  With a numeric prefix argument
4251 N, show the tree for the Nth keyword in the variable
4252 @code{org-todo-keywords}.  With two prefix arguments, find all TODO
4253 states, both un-done and done.
4255 @item @kbd{C-c a t} (@code{org-todo-list})
4256 @kindex C-c a t
4257 Show the global TODO list.  Collects the TODO items (with
4258 not-DONE states) from all agenda files (see @ref{Agenda Views}) into
4259 a single buffer.  The new buffer is in Org Agenda mode, which
4260 provides commands to examine and manipulate the TODO entries from
4261 the new buffer (see @ref{Agenda Commands}).  See @ref{Global TODO list}, for more information.
4263 @item @kbd{S-M-@key{RET}} (@code{org-insert-todo-heading})
4264 @kindex S-M-RET
4265 @findex org-insert-todo-heading
4266 Insert a new TODO entry below the current one.
4267 @end table
4269 @vindex org-todo-state-tags-triggers
4270 @noindent
4271 Changing a TODO state can also trigger tag changes.  See the docstring
4272 of the option @code{org-todo-state-tags-triggers} for details.
4274 @node TODO Extensions
4275 @section Extended Use of TODO Keywords
4277 @cindex extended TODO keywords
4279 @vindex org-todo-keywords
4280 By default, marked TODO entries have one of only two states: TODO and
4281 DONE.  Org mode allows you to classify TODO items in more complex ways
4282 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With special
4283 setup, the TODO keyword system can work differently in different
4284 files.
4286 Note that @emph{tags} are another way to classify headlines in general and
4287 TODO items in particular (see @ref{Tags}).
4289 @menu
4290 * Workflow states::              From TODO to DONE in steps.
4291 * TODO types::                   I do this, Fred does the rest.
4292 * Multiple sets in one file::    Mixing it all, still finding your way.
4293 * Fast access to TODO states::   Single letter selection of state.
4294 * Per-file keywords::            Different files, different requirements.
4295 * Faces for TODO keywords::      Highlighting states.
4296 * TODO dependencies::            When one task needs to wait for others.
4297 @end menu
4299 @node Workflow states
4300 @subsection TODO keywords as workflow states
4302 @cindex TODO workflow
4303 @cindex workflow states as TODO keywords
4305 You can use TODO keywords to indicate different @emph{sequential} states in
4306 the process of working on an item, for example@footnote{Changing the variable @code{org-todo-keywords} only becomes
4307 effective after restarting Org mode in a buffer.}:
4309 @lisp
4310 (setq org-todo-keywords
4311       '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
4312 @end lisp
4314 The vertical bar separates the TODO keywords (states that @emph{need
4315 action}) from the DONE states (which need @emph{no further action}).  If
4316 you do not provide the separator bar, the last state is used as the
4317 DONE state.
4319 @cindex completion, of TODO keywords
4320 With this setup, the command @kbd{C-c C-t} cycles an entry from
4321 @samp{TODO} to @samp{FEEDBACK}, then to @samp{VERIFY}, and finally to @samp{DONE} and
4322 @samp{DELEGATED}.  You may also use a numeric prefix argument to quickly
4323 select a specific state.  For example @kbd{C-3 C-c C-t} changes
4324 the state immediately to @samp{VERIFY}.  Or you can use @kbd{S-@key{LEFT}}
4325 to go backward through the sequence.  If you define many keywords, you
4326 can use in-buffer completion (see @ref{Completion}) or even a special
4327 one-key selection scheme (see @ref{Fast access to TODO states}) to insert
4328 these words into the buffer.  Changing a TODO state can be logged with
4329 a timestamp, see @ref{Tracking TODO state changes}, for more information.
4331 @node TODO types
4332 @subsection TODO keywords as types
4334 @cindex TODO types
4335 @cindex names as TODO keywords
4336 @cindex types as TODO keywords
4338 The second possibility is to use TODO keywords to indicate different
4339 @emph{types} of action items.  For example, you might want to indicate that
4340 items are for ``work'' or ``home''.  Or, when you work with several people
4341 on a single project, you might want to assign action items directly to
4342 persons, by using their names as TODO keywords.  This would be set up
4343 like this:
4345 @lisp
4346 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
4347 @end lisp
4349 In this case, different keywords do not indicate a sequence, but
4350 rather different types.  So the normal work flow would be to assign
4351 a task to a person, and later to mark it DONE.  Org mode supports this
4352 style by adapting the workings of the command @kbd{C-c C-t}@footnote{This is also true for the @kbd{t} command in the timeline
4353 and agenda buffers.}.  When used several times in succession, it still
4354 cycles through all names, in order to first select the right type for
4355 a task.  But when you return to the item after some time and execute
4356 @kbd{C-c C-t} again, it will switch from any name directly to
4357 @samp{DONE}.  Use prefix arguments or completion to quickly select
4358 a specific name.  You can also review the items of a specific TODO
4359 type in a sparse tree by using a numeric prefix to @kbd{C-c / t}.
4360 For example, to see all things Lucy has to do, you would use
4361 @kbd{C-3 C-c / t}.  To collect Lucy's items from all agenda files
4362 into a single buffer, you would use the numeric prefix argument as
4363 well when creating the global TODO list: @kbd{C-3 C-c a t}.
4365 @node Multiple sets in one file
4366 @subsection Multiple keyword sets in one file
4368 @cindex TODO keyword sets
4370 Sometimes you may want to use different sets of TODO keywords in
4371 parallel.  For example, you may want to have the basic TODO/DONE, but
4372 also a workflow for bug fixing, and a separate state indicating that
4373 an item has been canceled---so it is not DONE, but also does not
4374 require action.  Your setup would then look like this:
4376 @lisp
4377 (setq org-todo-keywords
4378       '((sequence "TODO" "|" "DONE")
4379         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
4380         (sequence "|" "CANCELED")))
4381 @end lisp
4383 The keywords should all be different, this helps Org mode to keep
4384 track of which subsequence should be used for a given entry.  In this
4385 setup, @kbd{C-c C-t} only operates within a subsequence, so it
4386 switches from @samp{DONE} to (nothing) to @samp{TODO}, and from @samp{FIXED} to
4387 (nothing) to @samp{REPORT}.  Therefore you need a mechanism to initially
4388 select the correct sequence.  Besides the obvious ways like typing
4389 a keyword or using completion, you may also apply the following
4390 commands:
4392 @table @asis
4393 @item @kbd{C-u C-u C-c C-t}
4394 @itemx @kbd{C-S-@key{RIGHT}}
4395 @itemx @kbd{C-S-@key{LEFT}}
4396 @kindex C-S-RIGHT
4397 @kindex C-S-LEFT
4398 @kindex C-u C-u C-c C-t
4399 These keys jump from one TODO subset to the next.  In the above
4400 example, @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{RIGHT}} would
4401 jump from @samp{TODO} or @samp{DONE} to @samp{REPORT}, and any of the words in
4402 the second row to @samp{CANCELED}.  Note that the @kbd{C-S-} key
4403 binding conflict with @code{shift-selection-mode} (see @ref{Conflicts}).
4405 @item @kbd{S-@key{RIGHT}}
4406 @itemx @kbd{S-@key{LEFT}}
4407 @kindex S-RIGHT
4408 @kindex S-LEFT
4409 @kbd{S-@key{LEFT}} and @kbd{S-@key{RIGHT}} walk through @emph{all}
4410 keywords from all sets, so for example @kbd{S-@key{RIGHT}} would
4411 switch from @samp{DONE} to @samp{REPORT} in the example above.  For
4412 a discussion of the interaction with @code{shift-selection-mode}, see
4413 @ref{Conflicts}.
4414 @end table
4416 @node Fast access to TODO states
4417 @subsection Fast access to TODO states
4419 If you would like to quickly change an entry to an arbitrary TODO
4420 state instead of cycling through the states, you can set up keys for
4421 single-letter access to the states.  This is done by adding the
4422 selection character after each keyword, in parentheses@footnote{All characters are allowed except @samp{@@}, @samp{^} and @samp{!}, which have
4423 a special meaning here.}.  For
4424 example:
4426 @lisp
4427 (setq org-todo-keywords
4428       '((sequence "TODO(t)" "|" "DONE(d)")
4429         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
4430         (sequence "|" "CANCELED(c)")))
4431 @end lisp
4433 @vindex org-fast-tag-selection-include-todo
4434 If you then press @kbd{C-c C-t} followed by the selection key,
4435 the entry is switched to this state.  @kbd{@key{SPC}} can be used to
4436 remove any TODO keyword from an entry@footnote{Check also the variable @code{org-fast-tag-selection-include-todo},
4437 it allows you to change the TODO state through the tags interface
4438 (@ref{Setting Tags}), in case you like to mingle the two concepts.  Note
4439 that this means you need to come up with unique keys across both sets
4440 of keywords.}.
4442 @node Per-file keywords
4443 @subsection Setting up keywords for individual files
4445 @cindex keyword options
4446 @cindex per-file keywords
4447 @cindex @samp{TODO}, keyword
4448 @cindex @samp{TYP_TODO}, keyword
4449 @cindex @samp{SEQ_TODO}, keyword
4451 It can be very useful to use different aspects of the TODO mechanism
4452 in different files.  For file-local settings, you need to add special
4453 lines to the file which set the keywords and interpretation for that
4454 file only.  For example, to set one of the two examples discussed
4455 above, you need one of the following lines, starting in column zero
4456 anywhere in the file:
4458 @example
4459 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
4460 @end example
4462 @noindent
4463 you may also write @samp{#+SEQ_TODO} to be explicit about the
4464 interpretation, but it means the same as @samp{#+TODO}, or
4466 @example
4467 #+TYP_TODO: Fred Sara Lucy Mike | DONE
4468 @end example
4470 A setup for using several sets in parallel would be:
4472 @example
4473 #+TODO: TODO | DONE
4474 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
4475 #+TODO: | CANCELED
4476 @end example
4478 @cindex completion, of option keywords
4479 @kindex M-TAB
4480 @noindent
4481 To make sure you are using the correct keyword, type @samp{#+} into the
4482 buffer and then use @kbd{M-@key{TAB}} completion.
4484 @cindex DONE, final TODO keyword
4485 Remember that the keywords after the vertical bar---or the last
4486 keyword if no bar is there---must always mean that the item is DONE,
4487 although you may use a different word.  After changing one of these
4488 lines, use @kbd{C-c C-c} with the cursor still in the line to
4489 make the changes known to Org mode@footnote{Org mode parses these lines only when Org mode is activated
4490 after visiting a file.  @kbd{C-c C-c} with the cursor in a line
4491 starting with @samp{#+} is simply restarting Org mode for the current
4492 buffer.}.
4494 @node Faces for TODO keywords
4495 @subsection Faces for TODO keywords
4497 @cindex faces, for TODO keywords
4499 @vindex org-todo, face
4500 @vindex org-done, face
4501 @vindex org-todo-keyword-faces
4502 Org mode highlights TODO keywords with special faces: @code{org-todo} for
4503 keywords indicating that an item still has to be acted upon, and
4504 @code{org-done} for keywords indicating that an item is finished.  If you
4505 are using more than two different states, you might want to use
4506 special faces for some of them.  This can be done using the variable
4507 @code{org-todo-keyword-faces}.  For example:
4509 @lisp
4510 (setq org-todo-keyword-faces
4511       '(("TODO" . org-warning) ("STARTED" . "yellow")
4512         ("CANCELED" . (:foreground "blue" :weight bold))))
4513 @end lisp
4515 @vindex org-faces-easy-properties
4516 While using a list with face properties as shown for @samp{CANCELED}
4517 @emph{should} work, this does not always seem to be the case.  If
4518 necessary, define a special face and use that.  A string is
4519 interpreted as a color.  The variable @code{org-faces-easy-properties}
4520 determines if that color is interpreted as a foreground or
4521 a background color.
4523 @node TODO dependencies
4524 @subsection TODO dependencies
4526 @cindex TODO dependencies
4527 @cindex dependencies, of TODO states
4529 @vindex org-enforce-todo-dependencies
4530 @cindex @samp{ORDERED}, property
4531 The structure of Org files---hierarchy and lists---makes it easy to
4532 define TODO dependencies.  Usually, a parent TODO task should not be
4533 marked DONE until all subtasks, defined as children tasks, are marked
4534 as DONE.  And sometimes there is a logical sequence to a number of
4535 (sub)tasks, so that one task cannot be acted upon before all siblings
4536 above it are done.  If you customize the variable
4537 @code{org-enforce-todo-dependencies}, Org blocks entries from changing
4538 state to DONE while they have children that are not DONE.
4539 Furthermore, if an entry has a property @samp{ORDERED}, each of its
4540 children is blocked until all earlier siblings are marked DONE.  Here
4541 is an example:
4543 @example
4544 * TODO Blocked until (two) is done
4545 ** DONE one
4546 ** TODO two
4548 * Parent
4549 :PROPERTIES:
4550 :ORDERED:  t
4551 :END:
4552 ** TODO a
4553 ** TODO b, needs to wait for (a)
4554 ** TODO c, needs to wait for (a) and (b)
4555 @end example
4557 @cindex TODO dependencies, NOBLOCKING
4558 @cindex NOBLOCKING, property
4559 You can ensure an entry is never blocked by using the @samp{NOBLOCKING}
4560 property:
4562 @example
4563 * This entry is never blocked
4564 :PROPERTIES:
4565 :NOBLOCKING: t
4566 :END:
4567 @end example
4569 @table @asis
4570 @item @kbd{C-c C-x o} (@code{org-toggle-ordered-property})
4571 @kindex C-c C-x o
4572 @findex org-toggle-ordered-property
4573 @vindex org-track-ordered-property-with-tag
4574 Toggle the @samp{ORDERED} property of the current entry.  A property
4575 is used for this behavior because this should be local to the
4576 current entry, not inherited like a tag.  However, if you would
4577 like to @emph{track} the value of this property with a tag for better
4578 visibility, customize the variable
4579 @code{org-track-ordered-property-with-tag}.
4581 @item @kbd{C-u C-u C-u C-c C-t}
4582 @kindex C-u C-u C-u C-c C-t
4583 Change TODO state, circumventing any state blocking.
4584 @end table
4586 @vindex org-agenda-dim-blocked-tasks
4587 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
4588 that cannot be closed because of such dependencies are shown in
4589 a dimmed font or even made invisible in agenda views (see @ref{Agenda Views}).
4591 @cindex checkboxes and TODO dependencies
4592 @vindex org-enforce-todo-dependencies
4593 You can also block changes of TODO states by looking at checkboxes
4594 (see @ref{Checkboxes}).  If you set the variable
4595 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
4596 checkboxes is blocked from switching to DONE.
4598 If you need more complex dependency structures, for example
4599 dependencies between entries in different trees or files, check out
4600 the contributed module @samp{org-depend.el}.
4602 @node Progress Logging
4603 @section Progress Logging
4605 @cindex progress logging
4606 @cindex logging, of progress
4608 Org mode can automatically record a timestamp and possibly a note when
4609 you mark a TODO item as DONE, or even each time you change the state
4610 of a TODO item.  This system is highly configurable, settings can be
4611 on a per-keyword basis and can be localized to a file or even
4612 a subtree.  For information on how to clock working time for a task,
4613 see @ref{Clocking Work Time}.
4615 @menu
4616 * Closing items::                When was this entry marked DONE?
4617 * Tracking TODO state changes::  When did the status change?
4618 * Tracking your habits::         How consistent have you been?
4619 @end menu
4621 @node Closing items
4622 @subsection Closing items
4624 The most basic logging is to keep track of @emph{when} a certain TODO item
4625 was finished.  This is achieved with@footnote{The corresponding in-buffer setting is: @samp{#+STARTUP: logdone}.}
4627 @lisp
4628 (setq org-log-done 'time)
4629 @end lisp
4631 @vindex org-closed-keep-when-no-todo
4632 @noindent
4633 Then each time you turn an entry from a TODO (not-done) state into any
4634 of the DONE states, a line @samp{CLOSED: [timestamp]} is inserted just
4635 after the headline.  If you turn the entry back into a TODO item
4636 through further state cycling, that line is removed again.  If you
4637 turn the entry back to a non-TODO state (by pressing @kbd{C-c C-t @key{SPC}} for example), that line is also removed, unless you set
4638 @code{org-closed-keep-when-no-todo} to non-@code{nil}.  If you want to record
4639 a note along with the timestamp, use@footnote{The corresponding in-buffer setting is: @samp{#+STARTUP:
4640 lognotedone}.}
4642 @lisp
4643 (setq org-log-done 'note)
4644 @end lisp
4646 @noindent
4647 You are then be prompted for a note, and that note is stored below the
4648 entry with a @samp{Closing Note} heading.
4650 @node Tracking TODO state changes
4651 @subsection Tracking TODO state changes
4653 @cindex drawer, for state change recording
4655 @vindex org-log-states-order-reversed
4656 @vindex org-log-into-drawer
4657 @cindex @samp{LOG_INTO_DRAWER}, property
4658 When TODO keywords are used as workflow states (see @ref{Workflow states, , *Workflow states}),
4659 you might want to keep track of when a state change occurred and maybe
4660 take a note about this change.  You can either record just
4661 a timestamp, or a time-stamped note for a change.  These records are
4662 inserted after the headline as an itemized list, newest first@footnote{See the variable @code{org-log-states-order-reversed}.}.
4663 When taking a lot of notes, you might want to get the notes out of the
4664 way into a drawer (see @ref{Drawers}).  Customize the variable
4665 @code{org-log-into-drawer} to get this behavior---the recommended drawer
4666 for this is called @samp{LOGBOOK}@footnote{Note that the @samp{LOGBOOK} drawer is unfolded when pressing
4667 @kbd{@key{SPC}} in the agenda to show an entry---use @kbd{C-u @key{SPC}} to keep it folded here.}.  You can also overrule the
4668 setting of this variable for a subtree by setting a @samp{LOG_INTO_DRAWER}
4669 property.
4671 Since it is normally too much to record a note for every state, Org
4672 mode expects configuration on a per-keyword basis for this.  This is
4673 achieved by adding special markers @samp{!} (for a timestamp) or @samp{@@} (for
4674 a note with timestamp) in parentheses after each keyword.  For
4675 example, with the setting
4677 @lisp
4678 (setq org-todo-keywords
4679       '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
4680 @end lisp
4682 To record a timestamp without a note for TODO keywords configured with
4683 @samp{@@}, just type @kbd{C-c C-c} to enter a blank note when prompted.
4685 @vindex org-log-done
4686 noindent
4687 you not only define global TODO keywords and fast access keys, but
4688 also request that a time is recorded when the entry is set to @samp{DONE},
4689 and that a note is recorded when switching to @samp{WAIT} or
4690 @samp{CANCELED}@footnote{It is possible that Org mode records two timestamps when you
4691 are using both @code{org-log-done} and state change logging.  However, it
4692 never prompts for two notes: if you have configured both, the state
4693 change recording note takes precedence and cancel the closing note.}.  The setting for @samp{WAIT} is even more special: the
4694 @samp{!} after the slash means that in addition to the note taken when
4695 entering the state, a timestamp should be recorded when @emph{leaving} the
4696 @samp{WAIT} state, if and only if the @emph{target} state does not configure
4697 logging for entering it.  So it has no effect when switching from
4698 @samp{WAIT} to @samp{DONE}, because @samp{DONE} is configured to record a timestamp
4699 only.  But when switching from @samp{WAIT} back to @samp{TODO}, the @samp{/!} in the
4700 @samp{WAIT} setting now triggers a timestamp even though @samp{TODO} has no
4701 logging configured.
4703 You can use the exact same syntax for setting logging preferences local
4704 to a buffer:
4706 @example
4707 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
4708 @end example
4710 @cindex @samp{LOGGING}, property
4711 In order to define logging settings that are local to a subtree or
4712 a single item, define a @samp{LOGGING} property in this entry.  Any
4713 non-empty @samp{LOGGING} property resets all logging settings to @code{nil}.
4714 You may then turn on logging for this specific tree using @samp{STARTUP}
4715 keywords like @samp{lognotedone} or @samp{logrepeat}, as well as adding state
4716 specific settings like @samp{TODO(!)}.  For example:
4718 @example
4719 * TODO Log each state with only a time
4720   :PROPERTIES:
4721   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
4722   :END:
4723 * TODO Only log when switching to WAIT, and when repeating
4724   :PROPERTIES:
4725   :LOGGING: WAIT(@@) logrepeat
4726   :END:
4727 * TODO No logging at all
4728   :PROPERTIES:
4729   :LOGGING: nil
4730   :END:
4731 @end example
4733 @node Tracking your habits
4734 @subsection Tracking your habits
4736 @cindex habits
4737 @cindex STYLE, property
4739 Org has the ability to track the consistency of a special category of
4740 TODO, called ``habits.''  A habit has the following properties:
4742 @enumerate
4743 @item
4744 You have enabled the @code{habits} module by customizing the variable
4745 @code{org-modules}.
4747 @item
4748 The habit is a TODO item, with a TODO keyword representing an open
4749 state.
4751 @item
4752 The property @samp{STYLE} is set to the value @samp{habit}.
4754 @item
4755 The TODO has a scheduled date, usually with a @samp{.+} style repeat
4756 interval.  A @samp{++} style may be appropriate for habits with time
4757 constraints, e.g., must be done on weekends, or a @samp{+} style for an
4758 unusual habit that can have a backlog, e.g., weekly reports.
4760 @item
4761 The TODO may also have minimum and maximum ranges specified by
4762 using the syntax @samp{.+2d/3d}, which says that you want to do the task
4763 at least every three days, but at most every two days.
4765 @item
4766 You must also have state logging for the DONE state enabled (see
4767 @ref{Tracking TODO state changes}), in order for historical data to be
4768 represented in the consistency graph.  If it is not enabled it is
4769 not an error, but the consistency graphs are largely meaningless.
4770 @end enumerate
4772 To give you an idea of what the above rules look like in action, here's an
4773 actual habit with some history:
4775 @example
4776 ** TODO Shave
4777    SCHEDULED: <2009-10-17 Sat .+2d/4d>
4778    :PROPERTIES:
4779    :STYLE:    habit
4780    :LAST_REPEAT: [2009-10-19 Mon 00:36]
4781    :END:
4782    - State "DONE"       from "TODO"       [2009-10-15 Thu]
4783    - State "DONE"       from "TODO"       [2009-10-12 Mon]
4784    - State "DONE"       from "TODO"       [2009-10-10 Sat]
4785    - State "DONE"       from "TODO"       [2009-10-04 Sun]
4786    - State "DONE"       from "TODO"       [2009-10-02 Fri]
4787    - State "DONE"       from "TODO"       [2009-09-29 Tue]
4788    - State "DONE"       from "TODO"       [2009-09-25 Fri]
4789    - State "DONE"       from "TODO"       [2009-09-19 Sat]
4790    - State "DONE"       from "TODO"       [2009-09-16 Wed]
4791    - State "DONE"       from "TODO"       [2009-09-12 Sat]
4792 @end example
4794 What this habit says is: I want to shave at most every 2 days---given
4795 by the @samp{SCHEDULED} date and repeat interval---and at least every
4796 4 days.  If today is the 15th, then the habit first appears in the
4797 agenda on Oct 17, after the minimum of 2 days has elapsed, and will
4798 appear overdue on Oct 19, after four days have elapsed.
4800 What's really useful about habits is that they are displayed along
4801 with a consistency graph, to show how consistent you've been at
4802 getting that task done in the past.  This graph shows every day that
4803 the task was done over the past three weeks, with colors for each day.
4804 The colors used are:
4806 @table @asis
4807 @item Blue
4808 If the task was not to be done yet on that day.
4809 @item Green
4810 If the task could have been done on that day.
4811 @item Yellow
4812 If the task was going to be overdue the next day.
4813 @item Red
4814 If the task was overdue on that day.
4815 @end table
4817 In addition to coloring each day, the day is also marked with an
4818 asterisk if the task was actually done that day, and an exclamation
4819 mark to show where the current day falls in the graph.
4821 There are several configuration variables that can be used to change
4822 the way habits are displayed in the agenda.
4824 @table @asis
4825 @item @code{org-habit-graph-column}
4826 @vindex org-habit-graph-column
4827 The buffer column at which the consistency graph should be drawn.
4828 This overwrites any text in that column, so it is a good idea to
4829 keep your habits' titles brief and to the point.
4831 @item @code{org-habit-preceding-days}
4832 @vindex org-habit-preceding-days
4833 The amount of history, in days before today, to appear in
4834 consistency graphs.
4836 @item @code{org-habit-following-days}
4837 @vindex org-habit-following-days
4838 The number of days after today that appear in consistency graphs.
4840 @item @code{org-habit-show-habits-only-for-today}
4841 @vindex org-habit-show-habits-only-for-today
4842 If non-@code{nil}, only show habits in today's agenda view.  This is
4843 set to true by default.
4844 @end table
4846 Lastly, pressing @kbd{K} in the agenda buffer causes habits to
4847 temporarily be disabled and do not appear at all.  Press @kbd{K}
4848 again to bring them back.  They are also subject to tag filtering, if
4849 you have habits which should only be done in certain contexts, for
4850 example.
4852 @node Priorities
4853 @section Priorities
4855 @cindex priorities
4856 @cindex priority cookie
4858 If you use Org mode extensively, you may end up with enough TODO items
4859 that it starts to make sense to prioritize them.  Prioritizing can be
4860 done by placing a @emph{priority cookie} into the headline of a TODO item,
4861 like this
4863 @example
4864 *** TODO [#A] Write letter to Sam Fortune
4865 @end example
4867 @vindex org-priority-faces
4868 @noindent
4869 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and @samp{C}.
4870 @samp{A} is the highest priority.  An entry without a cookie is treated
4871 just like priority @samp{B}.  Priorities make a difference only for sorting
4872 in the agenda (see @ref{Weekly/daily agenda}); outside the agenda, they
4873 have no inherent meaning to Org mode.  The cookies can be highlighted
4874 with special faces by customizing the variable @code{org-priority-faces}.
4876 Priorities can be attached to any outline node; they do not need to be
4877 TODO items.
4879 @table @asis
4880 @item @kbd{C-c ,} (@code{org-priority})
4881 @kindex C-c ,
4882 @findex org-priority
4883 Set the priority of the current headline.  The command prompts
4884 for a priority character @samp{A}, @samp{B} or @samp{C}.  When you press
4885 @kbd{@key{SPC}} instead, the priority cookie is removed from the
4886 headline.  The priorities can also be changed ``remotely'' from the
4887 timeline and agenda buffer with the @kbd{,} command (see
4888 @ref{Agenda Commands}).
4890 @item @kbd{S-@key{UP}} (@code{org-priority-up})
4891 @itemx @kbd{S-@key{DOWN}} (@code{org-priority-down})
4892 @kindex S-UP
4893 @kindex S-DOWN
4894 @findex org-priority-up
4895 @findex org-priority-down
4896 @vindex org-priority-start-cycle-with-default
4897 Increase/decrease priority of current headline@footnote{See also the option @code{org-priority-start-cycle-with-default}.}.  Note that
4898 these keys are also used to modify timestamps (see @ref{Creating Timestamps}).  See also @ref{Conflicts}, for
4899 a discussion of the interaction with @code{shift-selection-mode}.
4900 @end table
4902 @vindex org-highest-priority
4903 @vindex org-lowest-priority
4904 @vindex org-default-priority
4905 You can change the range of allowed priorities by setting the
4906 variables @code{org-highest-priority}, @code{org-lowest-priority}, and
4907 @code{org-default-priority}.  For an individual buffer, you may set these
4908 values (highest, lowest, default) like this (please make sure that the
4909 highest priority is earlier in the alphabet than the lowest priority):
4911 @cindex @samp{PRIORITIES}, keyword
4912 @example
4913 #+PRIORITIES: A C B
4914 @end example
4916 @node Breaking Down Tasks
4917 @section Breaking Down Tasks into Subtasks
4919 @cindex tasks, breaking down
4920 @cindex statistics, for TODO items
4922 @vindex org-agenda-todo-list-sublevels
4923 It is often advisable to break down large tasks into smaller,
4924 manageable subtasks.  You can do this by creating an outline tree
4925 below a TODO item, with detailed subtasks on the tree@footnote{To keep subtasks out of the global TODO list, see the
4926 @code{org-agenda-todo-list-sublevels}.}.  To keep
4927 the overview over the fraction of subtasks that are already completed,
4928 insert either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies
4929 are updated each time the TODO status of a child changes, or when
4930 pressing @kbd{C-c C-c} on the cookie.  For example:
4932 @example
4933 * Organize Party [33%]
4934 ** TODO Call people [1/2]
4935 *** TODO Peter
4936 *** DONE Sarah
4937 ** TODO Buy food
4938 ** DONE Talk to neighbor
4939 @end example
4941 @cindex @samp{COOKIE_DATA}, property
4942 If a heading has both checkboxes and TODO children below it, the
4943 meaning of the statistics cookie become ambiguous.  Set the property
4944 @samp{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve this issue.
4946 @vindex org-hierarchical-todo-statistics
4947 If you would like to have the statistics cookie count any TODO entries
4948 in the subtree (not just direct children), configure the variable
4949 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
4950 include the word @samp{recursive} into the value of the @samp{COOKIE_DATA}
4951 property.
4953 @example
4954 * Parent capturing statistics [2/20]
4955   :PROPERTIES:
4956   :COOKIE_DATA: todo recursive
4957   :END:
4958 @end example
4960 If you would like a TODO entry to automatically change to DONE when
4961 all children are done, you can use the following setup:
4963 @lisp
4964 (defun org-summary-todo (n-done n-not-done)
4965   "Switch entry to DONE when all subentries are done, to TODO otherwise."
4966   (let (org-log-done org-log-states)   ; turn off logging
4967     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
4969 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
4970 @end lisp
4972 Another possibility is the use of checkboxes to identify (a hierarchy
4973 of) a large number of subtasks (see @ref{Checkboxes}).
4975 @node Checkboxes
4976 @section Checkboxes
4978 @cindex checkboxes
4980 @vindex org-list-automatic-rules
4981 Every item in a plain list@footnote{With the exception of description lists.  But you can allow it
4982 by modifying @code{org-list-automatic-rules} accordingly.} (see @ref{Plain Lists}) can be made into
4983 a checkbox by starting it with the string @samp{[ ]}.  This feature is
4984 similar to TODO items (see @ref{TODO Items}), but is more lightweight.
4985 Checkboxes are not included into the global TODO list, so they are
4986 often great to split a task into a number of simple steps.  Or you can
4987 use them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or use the mouse (thanks to Piotr Zielinski's
4988 @samp{org-mouse.el}).
4990 Here is an example of a checkbox list.
4992 @example
4993 * TODO Organize party [2/4]
4994   - [-] call people [1/3]
4995     - [ ] Peter
4996     - [X] Sarah
4997     - [ ] Sam
4998   - [X] order food
4999   - [ ] think about what music to play
5000   - [X] talk to the neighbors
5001 @end example
5003 Checkboxes work hierarchically, so if a checkbox item has children
5004 that are checkboxes, toggling one of the children checkboxes makes the
5005 parent checkbox reflect if none, some, or all of the children are
5006 checked.
5008 @cindex statistics, for checkboxes
5009 @cindex checkbox statistics
5010 @cindex @samp{COOKIE_DATA}, property
5011 @vindex org-hierarchical-checkbox-statistics
5012 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
5013 indicating how many checkboxes present in this entry have been checked
5014 off, and the total number of checkboxes present.  This can give you an
5015 idea on how many checkboxes remain, even without opening a folded
5016 entry.  The cookies can be placed into a headline or into (the first
5017 line of) a plain list item.  Each cookie covers checkboxes of direct
5018 children structurally below the headline/item on which the cookie
5019 appears@footnote{Set the variable @code{org-hierarchical-checkbox-statistics} if you
5020 want such cookies to count all checkboxes below the cookie, not just
5021 those belonging to direct children.}.  You have to insert the cookie yourself by typing
5022 either @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as
5023 in the examples above.  With @samp{[%]} you get information about the
5024 percentage of checkboxes checked (in the above example, this would be
5025 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can count
5026 either checkboxes below the heading or TODO states of children, and it
5027 displays whatever was changed last.  Set the property @samp{COOKIE_DATA} to
5028 either @samp{checkbox} or @samp{todo} to resolve this issue.
5030 @cindex blocking, of checkboxes
5031 @cindex checkbox blocking
5032 @cindex @samp{ORDERED}, property
5033 If the current outline node has an @samp{ORDERED} property, checkboxes must
5034 be checked off in sequence, and an error is thrown if you try to check
5035 off a box while there are unchecked boxes above it.
5037 @noindent
5038 The following commands work with checkboxes:
5040 @table @asis
5041 @item @kbd{C-c C-c} (@code{org-toggle-checkbox})
5042 @kindex C-c C-c
5043 @findex org-toggle-checkbox
5044 Toggle checkbox status or---with prefix argument---checkbox
5045 presence at point.  With a single prefix argument, add an empty
5046 checkbox or remove the current one@footnote{@kbd{C-u C-c C-c} on the @emph{first} item of a list with no
5047 checkbox adds checkboxes to the rest of the list.}.  With a double prefix
5048 argument, set it to @samp{[-]}, which is considered to be an
5049 intermediate state.
5051 @item @kbd{C-c C-x C-b} (@code{org-toggle-checkbox})
5052 @kindex C-c C-x C-b
5053 Toggle checkbox status or---with prefix argument---checkbox
5054 presence at point.  With double prefix argument, set it to @samp{[-]},
5055 which is considered to be an intermediate state.
5057 @itemize
5058 @item
5059 If there is an active region, toggle the first checkbox in the
5060 region and set all remaining boxes to the same status as the
5061 first.  With a prefix argument, add or remove the checkbox for
5062 all items in the region.
5064 @item
5065 If the cursor is in a headline, toggle checkboxes in the region
5066 between this headline and the next---so @emph{not} the entire
5067 subtree.
5069 @item
5070 If there is no active region, just toggle the checkbox at
5071 point.
5072 @end itemize
5074 @item @kbd{M-S-@key{RET}} (@code{org-insert-todo-heading})
5075 @kindex M-S-RET
5076 @findex org-insert-todo-heading
5077 Insert a new item with a checkbox.  This works only if the cursor
5078 is already in a plain list item (see @ref{Plain Lists}).
5080 @item @kbd{C-c C-x o} (@code{org-toggle-ordered-property})
5081 @kindex C-c C-x o
5082 @findex org-toggle-ordered-property
5083 @vindex org-track-ordered-property-with-tag
5084 Toggle the @samp{ORDERED} property of the entry, to toggle if
5085 checkboxes must be checked off in sequence.  A property is used
5086 for this behavior because this should be local to the current
5087 entry, not inherited like a tag.  However, if you would like to
5088 @emph{track} the value of this property with a tag for better
5089 visibility, customize @code{org-track-ordered-property-with-tag}.
5091 @item @kbd{C-c #} (@code{org-update-statistics-cookies})
5092 @kindex C-c #
5093 @findex org-update-statistics-cookies
5094 Update the statistics cookie in the current outline entry.  When
5095 called with a @kbd{C-u} prefix, update the entire file.
5096 Checkbox statistic cookies are updated automatically if you
5097 toggle checkboxes with @kbd{C-c C-c} and make new ones with
5098 @kbd{M-S-@key{RET}}.  TODO statistics cookies update when changing
5099 TODO states.  If you delete boxes/entries or add/change them by
5100 hand, use this command to get things back into sync.
5101 @end table
5103 @node Tags
5104 @chapter Tags
5106 @cindex tags
5107 @cindex headline tagging
5108 @cindex matching, tags
5109 @cindex sparse tree, tag based
5111 An excellent way to implement labels and contexts for
5112 cross-correlating information is to assign @emph{tags} to headlines.  Org
5113 mode has extensive support for tags.
5115 @vindex org-tag-faces
5116 Every headline can contain a list of tags; they occur at the end of
5117 the headline.  Tags are normal words containing letters, numbers, @samp{_},
5118 and @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
5119 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.  Tags
5120 by default are in bold face with the same color as the headline.  You
5121 may specify special faces for specific tags using the variable
5122 @code{org-tag-faces}, in much the same way as you can for TODO keywords
5123 (see @ref{Faces for TODO keywords}).
5125 @menu
5126 * Tag Inheritance::              Tags use the tree structure of an outline.
5127 * Setting Tags::                 How to assign tags to a headline.
5128 * Tag Hierarchy::                Create a hierarchy of tags.
5129 * Tag Searches::                 Searching for combinations of tags.
5130 @end menu
5132 @node Tag Inheritance
5133 @section Tag Inheritance
5135 @cindex tag inheritance
5136 @cindex inheritance, of tags
5137 @cindex sublevels, inclusion into tags match
5139 @emph{Tags} make use of the hierarchical structure of outline trees.  If
5140 a heading has a certain tag, all subheadings inherit the tag as well.
5141 For example, in the list
5143 @example
5144 * Meeting with the French group      :work:
5145 ** Summary by Frank                  :boss:notes:
5146 *** TODO Prepare slides for him      :action:
5147 @end example
5149 @noindent
5150 the final heading has the tags @samp{work}, @samp{boss}, @samp{notes}, and @samp{action}
5151 even though the final heading is not explicitly marked with those
5152 tags.  You can also set tags that all entries in a file should inherit
5153 just as if these tags were defined in a hypothetical level zero that
5154 surrounds the entire file.  Use a line like this@footnote{As with all these in-buffer settings, pressing @kbd{C-c C-c} activates any changes in the line.}
5156 @cindex @samp{FILETAGS}, keyword
5157 @example
5158 #+FILETAGS: :Peter:Boss:Secret:
5159 @end example
5161 @vindex org-use-tag-inheritance
5162 @vindex org-tags-exclude-from-inheritance
5163 @noindent
5164 To limit tag inheritance to specific tags, or to turn it off entirely,
5165 use the variables @code{org-use-tag-inheritance} and
5166 @code{org-tags-exclude-from-inheritance}.
5168 @vindex org-tags-match-list-sublevels
5169 When a headline matches during a tags search while tag inheritance is
5170 turned on, all the sublevels in the same tree---for a simple match
5171 form---match as well@footnote{This is only true if the search does not involve more complex
5172 tests including properties (see @ref{Property Searches}).}.  The list of matches may then become
5173 very long.  If you only want to see the first tags match in a subtree,
5174 configure the variable @code{org-tags-match-list-sublevels} (not
5175 recommended).
5177 @vindex org-agenda-use-tag-inheritance
5178 Tag inheritance is relevant when the agenda search tries to match
5179 a tag, either in the @code{tags} or @code{tags-todo} agenda types.  In other
5180 agenda types, @code{org-use-tag-inheritance} has no effect.  Still, you may
5181 want to have your tags correctly set in the agenda, so that tag
5182 filtering works fine, with inherited tags.  Set
5183 @code{org-agenda-use-tag-inheritance} to control this: the default value
5184 includes all agenda types, but setting this to @code{nil} can really speed
5185 up agenda generation.
5187 @node Setting Tags
5188 @section Setting Tags
5190 @cindex setting tags
5191 @cindex tags, setting
5193 @kindex M-TAB
5194 Tags can simply be typed into the buffer at the end of a headline.
5195 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
5196 also a special command for inserting tags:
5198 @table @asis
5199 @item @kbd{C-c C-q} (@code{org-set-tags-command})
5200 @kindex C-c C-q
5201 @findex org-set-tags-command
5202 @cindex completion, of tags
5203 @vindex org-tags-column
5204 Enter new tags for the current headline.  Org mode either offers
5205 completion or a special single-key interface for setting tags,
5206 see below.  After pressing @kbd{@key{RET}}, the tags are inserted
5207 and aligned to @code{org-tags-column}.  When called with
5208 a @kbd{C-u} prefix, all tags in the current buffer are
5209 aligned to that column, just to make things look nice.  Tags are
5210 automatically realigned after promotion, demotion, and TODO state
5211 changes (see @ref{TODO Basics}).
5213 @item @kbd{C-c C-c} (@code{org-set-tags-command})
5214 @kindex C-c C-c
5215 When the cursor is in a headline, this does the same as
5216 @kbd{C-c C-q}.
5217 @end table
5219 @vindex org-tag-alist
5220 Org supports tag insertion based on a @emph{list of tags}.  By default this
5221 list is constructed dynamically, containing all tags currently used in
5222 the buffer.  You may also globally specify a hard list of tags with
5223 the variable @code{org-tag-alist}.  Finally you can set the default tags
5224 for a given file with lines like
5226 @cindex @samp{TAGS}, keyword
5227 @example
5228 #+TAGS: @@work @@home @@tennisclub
5229 #+TAGS: laptop car pc sailboat
5230 @end example
5232 If you have globally defined your preferred set of tags using the
5233 variable @code{org-tag-alist}, but would like to use a dynamic tag list in
5234 a specific file, add an empty @samp{TAGS} keyword to that file:
5236 @example
5237 #+TAGS:
5238 @end example
5240 @vindex org-tag-persistent-alist
5241 If you have a preferred set of tags that you would like to use in
5242 every file, in addition to those defined on a per-file basis by @samp{TAGS}
5243 keyword, then you may specify a list of tags with the variable
5244 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
5245 by adding a @samp{STARTUP} keyword to that file:
5247 @example
5248 #+STARTUP: noptag
5249 @end example
5251 By default Org mode uses the standard minibuffer completion facilities
5252 for entering tags.  However, it also implements another, quicker, tag
5253 selection method called @emph{fast tag selection}.  This allows you to
5254 select and deselect tags with just a single key press.  For this to
5255 work well you should assign unique letters to most of your commonly
5256 used tags.  You can do this globally by configuring the variable
5257 @code{org-tag-alist} in your Emacs init file.  For example, you may find
5258 the need to tag many items in different files with @samp{@@home}.  In this
5259 case you can set something like:
5261 @lisp
5262 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
5263 @end lisp
5265 @noindent
5266 If the tag is only relevant to the file you are working on, then you
5267 can instead set the @samp{TAGS} keyword as:
5269 @example
5270 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
5271 @end example
5273 @noindent
5274 The tags interface shows the available tags in a splash window.  If
5275 you want to start a new line after a specific tag, insert @samp{\n} into
5276 the tag list
5278 @example
5279 #+TAGS: @@work(w) @@home(h) @@tennisclub(t) \n laptop(l) pc(p)
5280 @end example
5282 @noindent
5283 or write them in two lines:
5285 @example
5286 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
5287 #+TAGS: laptop(l)  pc(p)
5288 @end example
5290 @noindent
5291 You can also group together tags that are mutually exclusive by using
5292 braces, as in:
5294 @example
5295 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
5296 @end example
5298 @noindent
5299 you indicate that at most one of @samp{@@work}, @samp{@@home}, and @samp{@@tennisclub}
5300 should be selected.  Multiple such groups are allowed.
5302 @noindent
5303 Do not forget to press @kbd{C-c C-c} with the cursor in one of
5304 these lines to activate any changes.
5306 @noindent
5307 To set these mutually exclusive groups in the variable
5308 @code{org-tags-alist}, you must use the dummy tags @code{:startgroup} and
5309 @code{:endgroup} instead of the braces.  Similarly, you can use @code{:newline}
5310 to indicate a line break.  The previous example would be set globally
5311 by the following configuration:
5313 @lisp
5314 (setq org-tag-alist '((:startgroup . nil)
5315                       ("@@work" . ?w) ("@@home" . ?h)
5316                       ("@@tennisclub" . ?t)
5317                       (:endgroup . nil)
5318                       ("laptop" . ?l) ("pc" . ?p)))
5319 @end lisp
5321 If at least one tag has a selection key then pressing @kbd{C-c C-c} automatically presents you with a special interface, listing
5322 inherited tags, the tags of the current headline, and a list of all
5323 valid tags with corresponding keys@footnote{Keys are automatically assigned to tags that have no
5324 configured keys.}.
5326 Pressing keys assigned to tags adds or removes them from the list of
5327 tags in the current line.  Selecting a tag in a group of mutually
5328 exclusive tags turns off any other tag from that group.
5330 In this interface, you can also use the following special keys:
5332 @table @asis
5333 @item @kbd{@key{TAB}}
5334 @kindex TAB
5335 Enter a tag in the minibuffer, even if the tag is not in the
5336 predefined list.  You can complete on all tags present in the
5337 buffer.  You can also add several tags: just separate them with
5338 a comma.
5340 @item @kbd{@key{SPC}}
5341 @kindex SPC
5342 Clear all tags for this line.
5344 @item @kbd{@key{RET}}
5345 @kindex RET
5346 Accept the modified set.
5348 @item @kbd{C-g}
5349 @kindex C-g
5350 Abort without installing changes.
5352 @item @kbd{q}
5353 @kindex q
5354 If @kbd{q} is not assigned to a tag, it aborts like
5355 @kbd{C-g}.
5357 @item @kbd{!}
5358 @kindex !
5359 Turn off groups of mutually exclusive tags.  Use this to (as an
5360 exception) assign several tags from such a group.
5362 @item @kbd{C-c}
5363 @kindex C-c C-c
5364 Toggle auto-exit after the next change (see below).  If you are
5365 using expert mode, the first @kbd{C-c} displays the
5366 selection window.
5367 @end table
5369 @noindent
5370 This method lets you assign tags to a headline with very few keys.
5371 With the above setup, you could clear the current tags and set
5372 @samp{@@home}, @samp{laptop} and @samp{pc} tags with just the following keys:
5373 @kbd{C-c C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to @samp{@@work}
5374 would be done with @kbd{C-c C-c w @key{RET}} or alternatively with
5375 @kbd{C-c C-c C-c w}.  Adding the non-predefined tag @samp{Sarah} could
5376 be done with @kbd{C-c C-c @key{TAB} S a r a h @key{RET}}.
5378 @vindex org-fast-tag-selection-single-key
5379 If you find that most of the time you need only a single key press to
5380 modify your list of tags, set the variable
5381 @code{org-fast-tag-selection-single-key}.  Then you no longer have to press
5382 @kbd{@key{RET}} to exit fast tag selection---it exits after the first
5383 change.  If you then occasionally need more keys, press @kbd{C-c}
5384 to turn off auto-exit for the current tag selection process (in
5385 effect: start selection with @kbd{C-c C-c C-c} instead of
5386 @kbd{C-c C-c}).  If you set the variable to the value @code{expert},
5387 the special window is not even shown for single-key tag selection, it
5388 comes up only when you press an extra @kbd{C-c}.
5390 @node Tag Hierarchy
5391 @section Tag Hierarchy
5393 @cindex group tags
5394 @cindex tags, groups
5395 @cindex tags hierarchy
5397 Tags can be defined in hierarchies.  A tag can be defined as a @emph{group
5398 tag} for a set of other tags.  The group tag can be seen as the
5399 ``broader term'' for its set of tags.  Defining multiple group tags and
5400 nesting them creates a tag hierarchy.
5402 One use-case is to create a taxonomy of terms (tags) that can be used
5403 to classify nodes in a document or set of documents.
5405 When you search for a group tag, it return matches for all members in
5406 the group and its subgroups.  In an agenda view, filtering by a group
5407 tag displays or hide headlines tagged with at least one of the members
5408 of the group or any of its subgroups.  This makes tag searches and
5409 filters even more flexible.
5411 You can set group tags by using brackets and inserting a colon between
5412 the group tag and its related tags---beware that all whitespaces are
5413 mandatory so that Org can parse this line correctly:
5415 @example
5416 #+TAGS: [ GTD : Control Persp ]
5417 @end example
5419 In this example, @samp{GTD} is the group tag and it is related to two other
5420 tags: @samp{Control}, @samp{Persp}.  Defining @samp{Control} and @samp{Persp} as group
5421 tags creates an hierarchy of tags:
5423 @example
5424 #+TAGS: [ Control : Context Task ]
5425 #+TAGS: [ Persp : Vision Goal AOF Project ]
5426 @end example
5428 That can conceptually be seen as a hierarchy of tags:
5430 @itemize
5431 @item
5432 @samp{GTD}
5433 @itemize
5434 @item
5435 @samp{Persp}
5436 @itemize
5437 @item
5438 @samp{Vision}
5439 @item
5440 @samp{Goal}
5441 @item
5442 @samp{AOF}
5443 @item
5444 @samp{Project}
5445 @end itemize
5446 @item
5447 @samp{Control}
5448 @itemize
5449 @item
5450 @samp{Context}
5451 @item
5452 @samp{Task}
5453 @end itemize
5454 @end itemize
5455 @end itemize
5457 You can use the @code{:startgrouptag}, @code{:grouptags} and @code{:endgrouptag}
5458 keyword directly when setting @code{org-tag-alist} directly:
5460 @lisp
5461 (setq org-tag-alist '((:startgrouptag)
5462                       ("GTD")
5463                       (:grouptags)
5464                       ("Control")
5465                       ("Persp")
5466                       (:endgrouptag)
5467                       (:startgrouptag)
5468                       ("Control")
5469                       (:grouptags)
5470                       ("Context")
5471                       ("Task")
5472                       (:endgrouptag)))
5473 @end lisp
5475 The tags in a group can be mutually exclusive if using the same group
5476 syntax as is used for grouping mutually exclusive tags together; using
5477 curly brackets.
5479 @example
5480 #+TAGS: @{ Context : @@Home @@Work @@Call @}
5481 @end example
5483 When setting @code{org-tag-alist} you can use @code{:startgroup} and @code{:endgroup}
5484 instead of @code{:startgrouptag} and @code{:endgrouptag} to make the tags
5485 mutually exclusive.
5487 Furthermore, the members of a group tag can also be regular
5488 expressions, creating the possibility of a more dynamic and rule-based
5489 tag structure.  The regular expressions in the group must be specified
5490 within curly brackets.  Here is an expanded example:
5492 @example
5493 #+TAGS: [ Vision : @{V@@.+@} ]
5494 #+TAGS: [ Goal : @{G@@.+@} ]
5495 #+TAGS: [ AOF : @{AOF@@.+@} ]
5496 #+TAGS: [ Project : @{P@@.+@} ]
5497 @end example
5499 Searching for the tag @samp{Project} now lists all tags also including
5500 regular expression matches for @samp{P@@.+}, and similarly for tag searches
5501 on @samp{Vision}, @samp{Goal} and @samp{AOF}.  For example, this would work well for
5502 a project tagged with a common project-identifier,
5503 e.g. @samp{P@@2014_OrgTags}.
5505 @kindex C-c C-x q
5506 @findex org-toggle-tags-groups
5507 @vindex org-group-tags
5508 If you want to ignore group tags temporarily, toggle group tags
5509 support with @code{org-toggle-tags-groups}, bound to @kbd{C-c C-x q}.
5510 If you want to disable tag groups completely, set @code{org-group-tags} to
5511 @code{nil}.
5513 @node Tag Searches
5514 @section Tag Searches
5516 @cindex tag searches
5517 @cindex searching for tags
5519 Once a system of tags has been set up, it can be used to collect
5520 related information into special lists.
5522 @table @asis
5523 @item @kbd{C-c / m} or @kbd{C-c \} (@code{org-match-sparse-tree})
5524 @kindex C-c / m
5525 @kindex C-c \
5526 @findex org-match-sparse-tree
5527 Create a sparse tree with all headlines matching a tags search.
5528 With a @kbd{C-u} prefix argument, ignore headlines that are
5529 not a TODO line.
5531 @item @kbd{C-c a m} (@code{org-tags-view})
5532 @kindex C-c a m
5533 @findex org-tags-view
5534 Create a global list of tag matches from all agenda files.  See
5535 @ref{Matching tags and properties}.
5537 @item @kbd{C-c a M} (@code{org-tags-view})
5538 @kindex C-c a M
5539 @vindex org-tags-match-list-sublevels
5540 Create a global list of tag matches from all agenda files, but
5541 check only TODO items and force checking subitems (see the option
5542 @code{org-tags-match-list-sublevels}).
5543 @end table
5545 These commands all prompt for a match string which allows basic
5546 Boolean logic like @samp{+boss+urgent-project1}, to find entries with tags
5547 @samp{boss} and @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find
5548 entries which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of
5549 the search string is rich and allows also matching against TODO
5550 keywords, entry levels and properties.  For a complete description
5551 with many examples, see @ref{Matching tags and properties}.
5553 @node Properties and Columns
5554 @chapter Properties and Columns
5556 @cindex properties
5558 A property is a key-value pair associated with an entry.  Properties
5559 can be set so they are associated with a single entry, with every
5560 entry in a tree, or with every entry in an Org file.
5562 There are two main applications for properties in Org mode.  First,
5563 properties are like tags, but with a value.  Imagine maintaining
5564 a file where you document bugs and plan releases for a piece of
5565 software.  Instead of using tags like @samp{release_1}, @samp{release_2}, you
5566 can use a property, say @samp{Release}, that in different subtrees has
5567 different values, such as @samp{1.0} or @samp{2.0}.  Second, you can use
5568 properties to implement (very basic) database capabilities in an Org
5569 buffer.  Imagine keeping track of your music CDs, where properties
5570 could be things such as the album, artist, date of release, number of
5571 tracks, and so on.
5573 Properties can be conveniently edited and viewed in column view (see
5574 @ref{Column View}).
5576 @menu
5577 * Property Syntax::              How properties are spelled out.
5578 * Special Properties::           Access to other Org mode features.
5579 * Property Searches::            Matching property values.
5580 * Property Inheritance::         Passing values down a tree.
5581 * Column View::                  Tabular viewing and editing.
5582 @end menu
5584 @node Property Syntax
5585 @section Property Syntax
5587 @cindex property syntax
5588 @cindex drawer, for properties
5590 Properties are key--value pairs.  When they are associated with
5591 a single entry or with a tree they need to be inserted into a special
5592 drawer (see @ref{Drawers}) with the name @samp{PROPERTIES}, which has to be
5593 located right below a headline, and its planning line (see @ref{Deadlines and Scheduling}) when applicable.  Each property is specified on
5594 a single line, with the key---surrounded by colons---first, and the
5595 value after it.  Keys are case-insensitive.  Here is an example:
5597 @example
5598 * CD collection
5599 ** Classic
5600 *** Goldberg Variations
5601     :PROPERTIES:
5602     :Title:     Goldberg Variations
5603     :Composer:  J.S. Bach
5604     :Artist:    Glen Gould
5605     :Publisher: Deutsche Grammophon
5606     :NDisks:    1
5607     :END:
5608 @end example
5610 Depending on the value of @code{org-use-property-inheritance}, a property
5611 set this way is associated either with a single entry, or with the
5612 sub-tree defined by the entry, see @ref{Property Inheritance}.
5614 You may define the allowed values for a particular property @samp{Xyz} by
5615 setting a property @samp{Xyz_ALL}.  This special property is @emph{inherited},
5616 so if you set it in a level 1 entry, it applies to the entire tree.
5617 When allowed values are defined, setting the corresponding property
5618 becomes easier and is less prone to typing errors.  For the example
5619 with the CD collection, we can pre-define publishers and the number of
5620 disks in a box like this:
5622 @example
5623 * CD collection
5624   :PROPERTIES:
5625   :NDisks_ALL:  1 2 3 4
5626   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
5627   :END:
5628 @end example
5630 If you want to set properties that can be inherited by any entry in
5631 a file, use a line like:
5633 @cindex @samp{_ALL} suffix, in properties
5634 @cindex @samp{PROPERTY}, keyword
5635 @example
5636 #+PROPERTY: NDisks_ALL 1 2 3 4
5637 @end example
5639 @cindex @samp{+} suffix, in properties
5640 If you want to add to the value of an existing property, append a @samp{+}
5641 to the property name.  The following results in the property @samp{var}
5642 having the value @samp{foo=1 bar=2}.
5644 @example
5645 #+PROPERTY: var  foo=1
5646 #+PROPERTY: var+ bar=2
5647 @end example
5649 It is also possible to add to the values of inherited properties.  The
5650 following results in the @samp{Genres} property having the value @samp{Classic
5651 Baroque} under the @samp{Goldberg Variations} subtree.
5653 @example
5654 * CD collection
5655 ** Classic
5656     :PROPERTIES:
5657     :Genres: Classic
5658     :END:
5659 *** Goldberg Variations
5660     :PROPERTIES:
5661     :Title:     Goldberg Variations
5662     :Composer:  J.S. Bach
5663     :Artist:    Glen Gould
5664     :Publisher: Deutsche Grammophon
5665     :NDisks:    1
5666     :Genres+:   Baroque
5667     :END:
5668 @end example
5670 Note that a property can only have one entry per drawer.
5672 @vindex org-global-properties
5673 Property values set with the global variable @code{org-global-properties}
5674 can be inherited by all entries in all Org files.
5676 @noindent
5677 The following commands help to work with properties:
5679 @table @asis
5680 @item @kbd{M-@key{TAB}} (@code{pcomplete})
5681 @kindex M-TAB
5682 @findex pcomplete
5683 After an initial colon in a line, complete property keys.  All
5684 keys used in the current file are offered as possible
5685 completions.
5687 @item @kbd{C-c C-x p} (@code{org-set-property})
5688 @kindex C-c C-x p
5689 @findex org-set-property
5690 Set a property.  This prompts for a property name and a value.
5691 If necessary, the property drawer is created as well.
5693 @item @kbd{C-u M-x org-insert-drawer}
5694 @findex org-insert-drawer
5695 Insert a property drawer into the current entry.  The drawer is
5696 inserted early in the entry, but after the lines with planning
5697 information like deadlines.
5699 @item @kbd{C-c C-c} (@code{org-property-action})
5700 @kindex C-c C-c
5701 @findex org-property-action
5702 With the cursor in a property drawer, this executes property
5703 commands.
5705 @item @kbd{C-c C-c s} (@code{org-set-property})
5706 @kindex C-c C-c s
5707 @findex org-set-property
5708 Set a property in the current entry.  Both the property and the value
5709 can be inserted using completion.
5711 @item @kbd{S-@key{RIGHT}} (@code{org-property-next-allowed-values})
5712 @itemx @kbd{S-@key{LEFT}} (@code{org-property-previous-allowed-value})
5713 @kindex S-RIGHT
5714 @kindex S-LEFT
5715 Switch property at point to the next/previous allowed value.
5717 @item @kbd{C-c C-c d} (@code{org-delete-property})
5718 @kindex C-c C-c d
5719 @findex org-delete-property
5720 Remove a property from the current entry.
5722 @item @kbd{C-c C-c D} (@code{org-delete-property-globally})
5723 @kindex C-c C-c D
5724 @findex org-delete-property-globally
5725 Globally remove a property, from all entries in the current file.
5727 @item @kbd{C-c C-c c} (@code{org-compute-property-at-point})
5728 @kindex C-c C-c c
5729 @findex org-compute-property-at-point
5730 Compute the property at point, using the operator and scope from
5731 the nearest column format definition.
5732 @end table
5734 @node Special Properties
5735 @section Special Properties
5737 @cindex properties, special
5739 Special properties provide an alternative access method to Org mode
5740 features, like the TODO state or the priority of an entry, discussed
5741 in the previous chapters.  This interface exists so that you can
5742 include these states in a column view (see @ref{Column View}), or to use
5743 them in queries.  The following property names are special and should
5744 not be used as keys in the properties drawer:
5746 @cindex @samp{ALLTAGS}, special property
5747 @cindex @samp{BLOCKED}, special property
5748 @cindex @samp{CLOCKSUM}, special property
5749 @cindex @samp{CLOCKSUM_T}, special property
5750 @cindex @samp{CLOSED}, special property
5751 @cindex @samp{DEADLINE}, special property
5752 @cindex @samp{FILE}, special property
5753 @cindex @samp{ITEM}, special property
5754 @cindex @samp{PRIORITY}, special property
5755 @cindex @samp{SCHEDULED}, special property
5756 @cindex @samp{TAGS}, special property
5757 @cindex @samp{TIMESTAMP}, special property
5758 @cindex @samp{TIMESTAMP_IA}, special property
5759 @cindex @samp{TODO}, special property
5760 @multitable {aaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
5761 @item @samp{ALLTAGS}
5762 @tab All tags, including inherited ones.
5763 @item @samp{BLOCKED}
5764 @tab @code{t} if task is currently blocked by children or siblings.
5765 @item @samp{CATEGORY}
5766 @tab The category of an entry.
5767 @item @samp{CLOCKSUM}
5768 @tab The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}
5769 @item 
5770 @tab must be run first to compute the values in the current buffer.
5771 @item @samp{CLOCKSUM_T}
5772 @tab The sum of CLOCK intervals in the subtree for today.
5773 @item 
5774 @tab @code{org-clock-sum-today} must be run first to compute the
5775 @item 
5776 @tab values in the current buffer.
5777 @item @samp{CLOSED}
5778 @tab When was this entry closed?
5779 @item @samp{DEADLINE}
5780 @tab The deadline time string, without the angular brackets.
5781 @item @samp{FILE}
5782 @tab The filename the entry is located in.
5783 @item @samp{ITEM}
5784 @tab The headline of the entry.
5785 @item @samp{PRIORITY}
5786 @tab The priority of the entry, a string with a single letter.
5787 @item @samp{SCHEDULED}
5788 @tab The scheduling timestamp, without the angular brackets.
5789 @item @samp{TAGS}
5790 @tab The tags defined directly in the headline.
5791 @item @samp{TIMESTAMP}
5792 @tab The first keyword-less timestamp in the entry.
5793 @item @samp{TIMESTAMP_IA}
5794 @tab The first inactive timestamp in the entry.
5795 @item @samp{TODO}
5796 @tab The TODO keyword of the entry.
5797 @end multitable
5799 @node Property Searches
5800 @section Property Searches
5802 @cindex properties, searching
5803 @cindex searching, of properties
5805 To create sparse trees and special lists with selection based on
5806 properties, the same commands are used as for tag searches (see @ref{Tag Searches}).
5808 @table @asis
5809 @item @kbd{C-c / m} or @kbd{C-c \} (@code{org-match-sparse-tree})
5810 @kindex C-c / m
5811 @kindex C-c \
5812 @findex org-match-sparse-tree
5813 Create a sparse tree with all matching entries.  With
5814 a @kbd{C-u} prefix argument, ignore headlines that are not
5815 a TODO line.
5817 @item @kbd{C-c a m}, @code{org-tags-view}
5818 @kindex C-c a m
5819 Create a global list of tag/property matches from all agenda
5820 files.
5822 @item @kbd{C-c a M} (@code{org-tags-view})
5823 @kindex C-c a M
5824 @findex org-tags-view
5825 @vindex org-tags-match-list-sublevels
5826 Create a global list of tag matches from all agenda files, but
5827 check only TODO items and force checking of subitems (see the
5828 option @code{org-tags-match-list-sublevels}).
5829 @end table
5831 The syntax for the search string is described in @ref{Matching tags and properties}.
5833 There is also a special command for creating sparse trees based on a
5834 single property:
5836 @table @asis
5837 @item @kbd{C-c / p}
5838 @kindex C-c / p
5839 Create a sparse tree based on the value of a property.  This
5840 first prompts for the name of a property, and then for a value.
5841 A sparse tree is created with all entries that define this
5842 property with the given value.  If you enclose the value in curly
5843 braces, it is interpreted as a regular expression and matched
5844 against the property values.
5845 @end table
5847 @node Property Inheritance
5848 @section Property Inheritance
5850 @cindex properties, inheritance
5851 @cindex inheritance, of properties
5853 @vindex org-use-property-inheritance
5854 The outline structure of Org documents lends itself to an inheritance
5855 model of properties: if the parent in a tree has a certain property,
5856 the children can inherit this property.  Org mode does not turn this
5857 on by default, because it can slow down property searches
5858 significantly and is often not needed.  However, if you find
5859 inheritance useful, you can turn it on by setting the variable
5860 @code{org-use-property-inheritance}.  It may be set to @code{t} to make all
5861 properties inherited from the parent, to a list of properties that
5862 should be inherited, or to a regular expression that matches inherited
5863 properties.  If a property has the value @code{nil}, this is interpreted as
5864 an explicit un-define of the property, so that inheritance search
5865 stops at this value and returns @code{nil}.
5867 Org mode has a few properties for which inheritance is hard-coded, at
5868 least for the special applications for which they are used:
5870 @table @asis
5871 @item @code{COLUMNS}
5872 @cindex @samp{COLUMNS}, property
5873 The @samp{COLUMNS} property defines the format of column view (see
5874 @ref{Column View}).  It is inherited in the sense that the level where
5875 a @samp{COLUMNS} property is defined is used as the starting point for
5876 a column view table, independently of the location in the subtree
5877 from where columns view is turned on.
5879 @item @code{CATEGORY}
5880 @cindex @samp{CATEGORY}, property
5881 For agenda view, a category set through a @samp{CATEGORY} property
5882 applies to the entire subtree.
5884 @item @code{ARCHIVE}
5885 @cindex @samp{ARCHIVE}, property
5886 For archiving, the @samp{ARCHIVE} property may define the archive
5887 location for the entire subtree (see @ref{Moving subtrees}).
5889 @item @code{LOGGING}
5890 @cindex @samp{LOGGING}, property
5891 The @samp{LOGGING} property may define logging settings for an entry
5892 or a subtree (see @ref{Tracking TODO state changes}).
5893 @end table
5895 @node Column View
5896 @section Column View
5898 A great way to view and edit properties in an outline tree is @emph{column
5899 view}.  In column view, each outline node is turned into a table row.
5900 Columns in this table provide access to properties of the entries.
5901 Org mode implements columns by overlaying a tabular structure over the
5902 headline of each item.  While the headlines have been turned into
5903 a table row, you can still change the visibility of the outline tree.
5904 For example, you get a compact table by switching to ``contents''
5905 view---@kbd{S-@key{TAB}} @kbd{S-@key{TAB}}, or simply @kbd{c}
5906 while column view is active---but you can still open, read, and edit
5907 the entry below each headline.  Or, you can switch to column view
5908 after executing a sparse tree command and in this way get a table only
5909 for the selected items.  Column view also works in agenda buffers (see
5910 @ref{Agenda Views}) where queries have collected selected items, possibly
5911 from a number of files.
5913 @menu
5914 * Defining columns::             The COLUMNS format property.
5915 * Using column view::            How to create and use column view.
5916 * Capturing column view::        A dynamic block for column view.
5917 @end menu
5919 @node Defining columns
5920 @subsection Defining columns
5922 @cindex column view, for properties
5923 @cindex properties, column view
5925 Setting up a column view first requires defining the columns.  This is
5926 done by defining a column format line.
5928 @menu
5929 * Scope of column definitions::  Where defined, where valid?
5930 * Column attributes::            Appearance and content of a column.
5931 @end menu
5933 @node Scope of column definitions
5934 @subsubsection Scope of column definitions
5936 To define a column format for an entire file, use a line like:
5938 @cindex @samp{COLUMNS}, keyword
5939 @example
5940 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5941 @end example
5943 To specify a format that only applies to a specific tree, add
5944 a @samp{COLUMNS} property to the top node of that tree, for example:
5946 @example
5947 ** Top node for columns view
5948    :PROPERTIES:
5949    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5950    :END:
5951 @end example
5953 If a @samp{COLUMNS} property is present in an entry, it defines columns for
5954 the entry itself, and for the entire subtree below it.  Since the
5955 column definition is part of the hierarchical structure of the
5956 document, you can define columns on level 1 that are general enough
5957 for all sublevels, and more specific columns further down, when you
5958 edit a deeper part of the tree.
5960 @node Column attributes
5961 @subsubsection Column attributes
5963 A column definition sets the attributes of a column.  The general
5964 definition looks like this:
5966 @example
5967 %[WIDTH]PROPERTY[(TITLE)][@{SUMMARY-TYPE@}]
5968 @end example
5970 @noindent
5971 Except for the percent sign and the property name, all items are
5972 optional.  The individual parts have the following meaning:
5974 @table @asis
5975 @item @var{WIDTH}
5976 An integer specifying the width of the column in characters.  If
5977 omitted, the width is determined automatically.
5979 @item @var{PROPERTY}
5980 The property that should be edited in this column.  Special
5981 properties representing meta data are allowed here as well (see
5982 @ref{Special Properties}).
5984 @item @var{TITLE}
5985 The header text for the column.  If omitted, the property name is
5986 used.
5988 @item @var{SUMMARY-TYPE}
5989 The summary type.  If specified, the column values for parent
5990 nodes are computed from the children@footnote{If more than one summary type applies to the same property,
5991 the parent values are computed according to the first of them.}.
5993 Supported summary types are:
5995 @multitable {aaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
5996 @item @samp{+}
5997 @tab Sum numbers in this column.
5998 @item @samp{+;%.1f}
5999 @tab Like @samp{+}, but format result with @samp{%.1f}.
6000 @item @samp{$}
6001 @tab Currency, short for @samp{+;%.2f}.
6002 @item @samp{min}
6003 @tab Smallest number in column.
6004 @item @samp{max}
6005 @tab Largest number.
6006 @item @samp{mean}
6007 @tab Arithmetic mean of numbers.
6008 @item @samp{X}
6009 @tab Checkbox status, @samp{[X]} if all children are @samp{[X]}.
6010 @item @samp{X/}
6011 @tab Checkbox status, @samp{[n/m]}.
6012 @item @samp{X%}
6013 @tab Checkbox status, @samp{[n%]}.
6014 @item @samp{:}
6015 @tab Sum times, HH:MM, plain numbers are hours.
6016 @item @samp{:min}
6017 @tab Smallest time value in column.
6018 @item @samp{:max}
6019 @tab Largest time value.
6020 @item @samp{:mean}
6021 @tab Arithmetic mean of time values.
6022 @item @samp{@@min}
6023 @tab Minimum age@footnote{An age is defined as a duration, using effort modifiers
6024 defined in @code{org-effort-durations}, e.g., @samp{3d 1h}.  If any value in the
6025 column is as such, the summary is also an effort duration.} (in days/hours/mins/seconds).
6026 @item @samp{@@max}
6027 @tab Maximum age (in days/hours/mins/seconds).
6028 @item @samp{@@mean}
6029 @tab Arithmetic mean of ages (in days/hours/mins/seconds).
6030 @item @samp{est+}
6031 @tab Add low-high estimates.
6032 @end multitable
6034 @noindent
6035 @vindex org-columns-summary-types
6036 You can also define custom summary types by setting
6037 @code{org-columns-summary-types}.
6038 @end table
6040 The @samp{est+} summary type requires further explanation.  It is used for
6041 combining estimates, expressed as low-high ranges.  For example,
6042 instead of estimating a particular task will take 5 days, you might
6043 estimate it as 5--6 days if you're fairly confident you know how much
6044 work is required, or 1--10 days if you do not really know what needs
6045 to be done.  Both ranges average at 5.5 days, but the first represents
6046 a more predictable delivery.
6048 When combining a set of such estimates, simply adding the lows and
6049 highs produces an unrealistically wide result.  Instead, @samp{est+} adds
6050 the statistical mean and variance of the sub-tasks, generating a final
6051 estimate from the sum.  For example, suppose you had ten tasks, each
6052 of which was estimated at 0.5 to 2 days of work.  Straight addition
6053 produces an estimate of 5 to 20 days, representing what to expect if
6054 everything goes either extremely well or extremely poorly.  In
6055 contrast, @samp{est+} estimates the full job more realistically, at 10--15
6056 days.
6058 Here is an example for a complete columns definition, along with
6059 allowed values@footnote{Please note that the @samp{COLUMNS} definition must be on a single
6060 line; it is wrapped here only because of formatting constraints.}.
6062 @example
6063 :COLUMNS:  %25ITEM %9Approved(Approved?)@{X@} %Owner %11Status \
6064                    %10Time_Estimate@{:@} %CLOCKSUM %CLOCKSUM_T
6065 :Owner_ALL:    Tammy Mark Karl Lisa Don
6066 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
6067 :Approved_ALL: "[ ]" "[X]"
6068 @end example
6070 @noindent
6071 The first column, @samp{%25ITEM}, means the first 25 characters of the item
6072 itself, i.e., of the headline.  You probably always should start the
6073 column definition with the @samp{ITEM} specifier.  The other specifiers
6074 create columns @samp{Owner} with a list of names as allowed values, for
6075 @samp{Status} with four different possible values, and for a checkbox field
6076 @samp{Approved}.  When no width is given after the @samp{%} character, the
6077 column is exactly as wide as it needs to be in order to fully display
6078 all values.  The @samp{Approved} column does have a modified title
6079 (@samp{Approved?}, with a question mark).  Summaries are created for the
6080 @samp{Time_Estimate} column by adding time duration expressions like HH:MM,
6081 and for the @samp{Approved} column, by providing an @samp{[X]} status if all
6082 children have been checked.  The @samp{CLOCKSUM} and @samp{CLOCKSUM_T} columns
6083 are special, they lists the sums of CLOCK intervals in the subtree,
6084 either for all clocks or just for today.
6086 @node Using column view
6087 @subsection Using column view
6091 @anchor{Turning column view on or off}
6092 @subsubheading Turning column view on or off
6094 @table @asis
6095 @item @kbd{C-c C-x C-c} (@code{org-columns})
6096 @kindex C-c C-x C-c
6097 @vindex org-columns
6098 @vindex org-columns-default-format
6099 Turn on column view.  If the cursor is before the first headline
6100 in the file, column view is turned on for the entire file, using
6101 the @samp{#+COLUMNS} definition.  If the cursor is somewhere inside
6102 the outline, this command searches the hierarchy, up from point,
6103 for a @samp{COLUMNS} property that defines a format.  When one is
6104 found, the column view table is established for the tree starting
6105 at the entry that contains the @samp{COLUMNS} property.  If no such
6106 property is found, the format is taken from the @samp{#+COLUMNS} line
6107 or from the variable @code{org-columns-default-format}, and column
6108 view is established for the current entry and its subtree.
6110 @item @kbd{r} or @kbd{g} (@code{org-columns-redo})
6111 @kindex r
6112 @kindex g
6113 @findex org-columns-redo
6114 Recreate the column view, to include recent changes made in the
6115 buffer.
6117 @item @kbd{q} (@code{org-columns-quit})
6118 @kindex q
6119 @findex org-columns-quit
6120 Exit column view.
6121 @end table
6123 @anchor{Editing values}
6124 @subsubheading Editing values
6126 @table @asis
6127 @item @kbd{@key{LEFT}}, @kbd{@key{RIGHT}}, @kbd{@key{UP}}, @kbd{@key{DOWN}}
6128 Move through the column view from field to field.
6130 @item @kbd{1..9,0}
6131 @kindex 1..9,0
6132 Directly select the Nth allowed value, @kbd{0} selects the
6133 10th value.
6135 @item @kbd{n} or @kbd{S-@key{RIGHT}} (@code{org-columns-next-allowed-value})
6136 @itemx @kbd{p} or @kbd{S-@key{LEFT}} (@code{org-columns-previous-allowed-value})
6137 @kindex n
6138 @kindex S-RIGHT
6139 @kindex p
6140 @kindex S-LEFT
6141 @findex org-columns-next-allowed-value
6142 @findex org-columns-previous-allowed-value
6143 Switch to the next/previous allowed value of the field.  For
6144 this, you have to have specified allowed values for a property.
6146 @item @kbd{e} (@code{org-columns-edit-value})
6147 @kindex e
6148 @findex org-columns-edit-value
6149 Edit the property at point.  For the special properties, this
6150 invokes the same interface that you normally use to change that
6151 property.  For example, the tag completion or fast selection
6152 interface pops up when editing a @samp{TAGS} property.
6154 @item @kbd{C-c C-c} (@code{org-columns-set-tags-or-toggle})
6155 @kindex C-c C-c
6156 @findex org-columns-set-tags-or-toggle
6157 When there is a checkbox at point, toggle it.
6159 @item @kbd{v} (@code{org-columns-show-value})
6160 @kindex v
6161 @findex org-columns-show-value
6162 View the full value of this property.  This is useful if the
6163 width of the column is smaller than that of the value.
6165 @item @kbd{a} (@code{org-columns-edit-allowed})
6166 @kindex a
6167 @findex org-columns-edit-allowed
6168 Edit the list of allowed values for this property.  If the list
6169 is found in the hierarchy, the modified values is stored there.
6170 If no list is found, the new value is stored in the first entry
6171 that is part of the current column view.
6172 @end table
6174 @anchor{Modifying column view on-the-fly}
6175 @subsubheading Modifying column view on-the-fly:
6177 @table @asis
6178 @item @kbd{<} (@code{org-columns-narrow})
6179 @itemx @kbd{>} (@code{org-columns-widen})
6180 @kindex <
6181 @kindex >
6182 @findex org-columns-narrow
6183 @findex org-columns-widen
6184 Make the column narrower/wider by one character.
6186 @item @kbd{S-M-@key{RIGHT}} (@code{org-columns-new})
6187 @kindex S-M-RIGHT
6188 @findex org-columns-new
6189 Insert a new column, to the left of the current column.
6191 @item @kbd{S-M-@key{LEFT}} (@code{org-columns-delete})
6192 @kindex S-M-LEFT
6193 @findex org-columns-delete
6194 Delete the current column.
6195 @end table
6197 @node Capturing column view
6198 @subsection Capturing column view
6200 Since column view is just an overlay over a buffer, it cannot be
6201 exported or printed directly.  If you want to capture a column view,
6202 use a @samp{columnview} dynamic block (see @ref{Dynamic Blocks}).  The frame of
6203 this block looks like this:
6205 @cindex @samp{BEGIN columnview}
6206 @example
6207 * The column view
6208 #+BEGIN: columnview :hlines 1 :id "label"
6210 #+END:
6211 @end example
6213 @noindent
6214 This dynamic block has the following parameters:
6216 @table @asis
6217 @item @samp{:id}
6218 This is the most important parameter.  Column view is a feature
6219 that is often localized to a certain (sub)tree, and the capture
6220 block might be at a different location in the file.  To identify
6221 the tree whose view to capture, you can use four values:
6223 @table @asis
6224 @item @samp{local}
6225 Use the tree in which the capture block is located.
6227 @item @samp{global}
6228 Make a global view, including all headings in the file.
6230 @item @samp{file:FILENAME}
6231 Run column view at the top of the @var{FILENAME} file
6233 @item @samp{LABEL}
6234 @cindex @samp{ID}, property
6235 Call column view in the tree that has an @samp{ID} property with
6236 the value @var{LABEL}.  You can use @kbd{M-x org-id-copy} to create a globally unique ID for the
6237 current entry and copy it to the kill-ring.
6238 @end table
6240 @item @samp{:hlines}
6241 When @code{t}, insert an hline after every line.  When a number N,
6242 insert an hline before each headline with level @code{<= N}.
6244 @item @samp{:vlines}
6245 When non-@code{nil}, force column groups to get vertical lines.
6247 @item @samp{:maxlevel}
6248 When set to a number, do not capture entries below this level.
6250 @item @samp{:skip-empty-rows}
6251 When non-@code{nil}, skip rows where the only non-empty specifier of
6252 the column view is @samp{ITEM}.
6254 @item @samp{:indent}
6255 When non-@code{nil}, indent each @samp{ITEM} field according to its level.
6256 @end table
6258 @noindent
6259 The following commands insert or update the dynamic block:
6261 @table @asis
6262 @item @kbd{C-c C-x i} (@code{org-insert-columns-dblock})
6263 @kindex C-c C-x i
6264 @findex org-insert-columns-dblock
6265 Insert a dynamic block capturing a column view.  Prompt for the
6266 scope or ID of the view.
6268 @item @kbd{C-c C-c} @kbd{C-c C-x C-u} (@code{org-dblock-update})
6269 @kindex C-c C-c
6270 @kindex C-c C-x C-u
6271 @findex org-dblock-update
6272 Update dynamic block at point.  The cursor needs to be in the
6273 @samp{#+BEGIN} line of the dynamic block.
6275 @item @kbd{C-u C-c C-x C-u} (@code{org-update-all-dblocks})
6276 @kindex C-u C-c C-x C-u
6277 Update all dynamic blocks (see @ref{Dynamic Blocks}).  This is useful
6278 if you have several clock table blocks, column-capturing blocks
6279 or other dynamic blocks in a buffer.
6280 @end table
6282 You can add formulas to the column view table and you may add plotting
6283 instructions in front of the table---these survive an update of the
6284 block.  If there is a @samp{TBLFM} keyword after the table, the table is
6285 recalculated automatically after an update.
6287 An alternative way to capture and process property values into a table
6288 is provided by Eric Schulte's @samp{org-collector.el} which is
6289 a contributed package@footnote{Contributed packages are not part of Emacs, but are
6290 distributed with the main distribution of Org---visit
6291 @uref{https://orgmode.org}.}.  It provides a general API to collect
6292 properties from entries in a certain scope, and arbitrary Lisp
6293 expressions to process these values before inserting them into a table
6294 or a dynamic block.
6296 @node Dates and Times
6297 @chapter Dates and Times
6299 @cindex dates
6300 @cindex times
6301 @cindex timestamp
6302 @cindex date stamp
6304 To assist project planning, TODO items can be labeled with a date
6305 and/or a time.  The specially formatted string carrying the date and
6306 time information is called a @emph{timestamp} in Org mode.  This may be
6307 a little confusing because timestamp is often used as indicating when
6308 something was created or last changed.  However, in Org mode this term
6309 is used in a much wider sense.
6311 @menu
6312 * Timestamps::                   Assigning a time to a tree entry.
6313 * Creating Timestamps::          Commands to insert timestamps.
6314 * Deadlines and Scheduling::     Planning your work.
6315 * Clocking Work Time::           Tracking how long you spend on a task.
6316 * Effort Estimates::             Planning work effort in advance.
6317 * Timers::                       Notes with a running timer.
6318 @end menu
6320 @node Timestamps
6321 @section Timestamps, Deadlines and Scheduling
6323 @cindex timestamps
6324 @cindex ranges, time
6325 @cindex date stamps
6326 @cindex deadlines
6327 @cindex scheduling
6329 A timestamp is a specification of a date (possibly with a time or
6330 a range of times) in a special format, either @samp{<2003-09-16 Tue>} or
6331 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue 12:00-12:30>}@footnote{The Org date format is inspired by the standard ISO 8601
6332 date/time format.  To use an alternative format, see @ref{Custom time format}.  The day name is optional when you type the date yourself.
6333 However, any date inserted or modified by Org adds that day name, for
6334 reading convenience.}.
6335 A timestamp can appear anywhere in the headline or body of an Org tree
6336 entry.  Its presence causes entries to be shown on specific dates in
6337 the agenda (see @ref{Weekly/daily agenda}).  We distinguish:
6339 @table @asis
6340 @item Plain timestamp; Event; Appointment
6341 @cindex timestamp
6342 @cindex appointment
6343 A simple timestamp just assigns a date/time to an item.  This is
6344 just like writing down an appointment or event in a paper agenda.
6345 In the timeline and agenda displays, the headline of an entry
6346 associated with a plain timestamp is shown exactly on that date.
6348 @example
6349 * Meet Peter at the movies
6350   <2006-11-01 Wed 19:15>
6351 * Discussion on climate change
6352   <2006-11-02 Thu 20:00-22:00>
6353 @end example
6355 @item Timestamp with repeater interval
6356 @cindex timestamp, with repeater interval
6357 A timestamp may contain a @emph{repeater interval}, indicating that it
6358 applies not only on the given date, but again and again after
6359 a certain interval of N days (d), weeks (w), months (m), or years
6360 (y).  The following shows up in the agenda every Wednesday:
6362 @example
6363 * Pick up Sam at school
6364   <2007-05-16 Wed 12:30 +1w>
6365 @end example
6367 @item Diary-style sexp entries
6368 @cindex diary style timestamps
6369 @cindex sexp timestamps
6370 For more complex date specifications, Org mode supports using the
6371 special sexp diary entries implemented in the Emacs
6372 calendar/diary package@footnote{When working with the standard diary sexp functions, you need
6373 to be very careful with the order of the arguments.  That order
6374 depends evilly on the variable @code{calendar-date-style}.  For example, to
6375 specify a date December 12, 2005, the call might look like
6376 @samp{(diary-date 12 1 2005)} or @samp{(diary-date 1 12 2005)} or @samp{(diary-date
6377 2005 12 1)}, depending on the settings.  This has been the source of
6378 much confusion.  Org mode users can resort to special versions of
6379 these functions like @code{org-date} or @code{org-anniversary}.  These work just
6380 like the corresponding @code{diary-} functions, but with stable ISO order
6381 of arguments (year, month, day) wherever applicable, independent of
6382 the value of @code{calendar-date-style}.}.  For example, with optional time:
6384 @example
6385 * 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
6386   <%%(org-float t 4 2)>
6387 @end example
6389 @item Time/Date range
6390 @cindex timerange
6391 @cindex date range
6392 Two timestamps connected by @samp{--} denote a range.  The headline is
6393 shown on the first and last day of the range, and on any dates
6394 that are displayed and fall in the range.  Here is an example:
6396 @example
6397 ** Meeting in Amsterdam
6398    <2004-08-23 Mon>--<2004-08-26 Thu>
6399 @end example
6401 @item Inactive timestamp
6402 @cindex timestamp, inactive
6403 @cindex inactive timestamp
6404 Just like a plain timestamp, but with square brackets instead of
6405 angular ones.  These timestamps are inactive in the sense that
6406 they do @emph{not} trigger an entry to show up in the agenda.
6408 @example
6409 * Gillian comes late for the fifth time
6410   [2006-11-01 Wed]
6411 @end example
6412 @end table
6414 @node Creating Timestamps
6415 @section Creating Timestamps
6417 For Org mode to recognize timestamps, they need to be in the specific
6418 format.  All commands listed below produce timestamps in the correct
6419 format.
6421 @table @asis
6422 @item @kbd{C-c .} (@code{org-time-stamp})
6423 @kindex C-c .
6424 @findex org-time-stamp
6425 Prompt for a date and insert a corresponding timestamp.  When the
6426 cursor is at an existing timestamp in the buffer, the command is
6427 used to modify this timestamp instead of inserting a new one.
6428 When this command is used twice in succession, a time range is
6429 inserted.
6431 @kindex C-u C-c .
6432 @vindex org-time-stamp-rounding-minutes
6433 When called with a prefix argument, use the alternative format
6434 which contains date and time.  The default time can be rounded to
6435 multiples of 5 minutes.  See the option
6436 @code{org-time-stamp-rounding-minutes}.
6438 @kindex C-u C-u C-c .
6439 With two prefix arguments, insert an active timestamp with the
6440 current time without prompting.
6442 @item @kbd{C-c !} (@code{org-time-stamp-inactive})
6443 @kindex C-c !
6444 @kindex C-u C-c !
6445 @kindex C-u C-u C-c !
6446 @findex org-time-stamp-inactive
6447 Like @kbd{C-c .}, but insert an inactive timestamp that does
6448 not cause an agenda entry.
6450 @item @kbd{C-c C-c}
6451 @kindex C-c C-c
6452 Normalize timestamp, insert or fix day name if missing or wrong.
6454 @item @kbd{C-c <} (@code{org-date-from-calendar})
6455 @kindex C-c <
6456 @findex org-date-from-calendar
6457 Insert a timestamp corresponding to the cursor date in the
6458 calendar.
6460 @item @kbd{C-c >} (@code{org-goto-calendar})
6461 @kindex C-c >
6462 @findex org-goto-calendar
6463 Access the Emacs calendar for the current date.  If there is
6464 a timestamp in the current line, go to the corresponding date
6465 instead.
6467 @item @kbd{C-c C-o} (@code{org-open-at-point})
6468 @kindex C-c C-o
6469 @findex org-open-at-point
6470 Access the agenda for the date given by the timestamp or -range
6471 at point (see @ref{Weekly/daily agenda}).
6473 @item @kbd{S-@key{LEFT}} (@code{org-timestamp-down-day})
6474 @itemx @kbd{S-@key{RIGHT}} (@code{org-timestamp-up-day})
6475 @kindex S-LEFT
6476 @kindex S-RIGHT
6477 @findex org-timestamp-down-day
6478 @findex org-timestamp-up-day
6479 Change date at cursor by one day.  These key bindings conflict
6480 with shift-selection and related modes (see @ref{Conflicts}).
6482 @item @kbd{S-@key{UP}} (@code{org-timestamp-up})
6483 @itemx @kbd{S-@key{DOWN}} (@code{org-timestamp-down})
6484 @kindex S-UP
6485 @kindex S-DOWN
6486 Change the item under the cursor in a timestamp.  The cursor can
6487 be on a year, month, day, hour or minute.  When the timestamp
6488 contains a time range like @samp{15:30-16:30}, modifying the first
6489 time also shifts the second, shifting the time block with
6490 constant length.  To change the length, modify the second time.
6491 Note that if the cursor is in a headline and not at a timestamp,
6492 these same keys modify the priority of an item.  (see
6493 @ref{Priorities}).  The key bindings also conflict with
6494 shift-selection and related modes (see @ref{Conflicts}).
6496 @item @kbd{C-c C-y} (@code{org-evaluate-time-range})
6497 @kindex C-c C-y
6498 @findex org-evaluate-time-range
6499 @cindex evaluate time range
6500 Evaluate a time range by computing the difference between start
6501 and end.  With a prefix argument, insert result after the time
6502 range (in a table: into the following column).
6503 @end table
6505 @menu
6506 * The date/time prompt::         How Org mode helps you enter dates and times.
6507 * Custom time format::           Making dates look different.
6508 @end menu
6510 @node The date/time prompt
6511 @subsection The date/time prompt
6513 @cindex date, reading in minibuffer
6514 @cindex time, reading in minibuffer
6516 @vindex org-read-date-prefer-future
6517 When Org mode prompts for a date/time, the default is shown in default
6518 date/time format, and the prompt therefore seems to ask for a specific
6519 format.  But it in fact accepts date/time information in a variety of
6520 formats.  Generally, the information should start at the beginning of
6521 the string.  Org mode finds whatever information is in there and
6522 derives anything you have not specified from the @emph{default date and
6523 time}.  The default is usually the current date and time, but when
6524 modifying an existing timestamp, or when entering the second stamp of
6525 a range, it is taken from the stamp in the buffer.  When filling in
6526 information, Org mode assumes that most of the time you want to enter
6527 a date in the future: if you omit the month/year and the given
6528 day/month is @emph{before} today, it assumes that you mean a future
6529 date@footnote{See the variable @code{org-read-date-prefer-future}.  You may set
6530 that variable to the symbol @code{time} to even make a time before now
6531 shift the date to tomorrow.}.  If the date has been automatically shifted into the
6532 future, the time prompt shows this with @samp{(=>F)}.
6534 For example, let's assume that today is @strong{June 13, 2006}.  Here is how
6535 various inputs are interpreted, the items filled in by Org mode are in
6536 @strong{bold}.
6538 @multitable {aaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
6539 @item @samp{3-2-5}
6540 @tab @result{} 2003-02-05
6541 @item @samp{2/5/3}
6542 @tab @result{} 2003-02-05
6543 @item @samp{14}
6544 @tab @result{} @strong{2006}-@strong{06}-14
6545 @item @samp{12}
6546 @tab @result{} @strong{2006}-@strong{07}-12
6547 @item @samp{2/5}
6548 @tab @result{} @strong{2007}-02-05
6549 @item @samp{Fri}
6550 @tab @result{} nearest Friday (default date or later)
6551 @item @samp{sep 15}
6552 @tab @result{} @strong{2006}-09-15
6553 @item @samp{feb 15}
6554 @tab @result{} @strong{2007}-02-15
6555 @item @samp{sep 12 9}
6556 @tab @result{} 2009-09-12
6557 @item @samp{12:45}
6558 @tab @result{} @strong{2006}-@strong{06}-@strong{13} 12:45
6559 @item @samp{22 sept 0:34}
6560 @tab @result{} @strong{2006}-09-22 0:34
6561 @item @samp{w4}
6562 @tab @result{} ISO week for of the current year @strong{2006}
6563 @item @samp{2012 w4 fri}
6564 @tab @result{} Friday of ISO week 4 in 2012
6565 @item @samp{2012-w04-5}
6566 @tab @result{} Same as above
6567 @end multitable
6569 Furthermore you can specify a relative date by giving, as the @emph{first}
6570 thing in the input: a plus/minus sign, a number and a letter---@samp{d},
6571 @samp{w}, @samp{m} or @samp{y}---to indicate change in days, weeks, months, or
6572 years.  With a single plus or minus, the date is always relative to
6573 today.  With a double plus or minus, it is relative to the default
6574 date.  If instead of a single letter, you use the abbreviation of day
6575 name, the date is the Nth such day, e.g.:
6577 @multitable {aaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
6578 @item @samp{+0}
6579 @tab @result{} today
6580 @item @samp{.}
6581 @tab @result{} today
6582 @item @samp{+4d}
6583 @tab @result{} four days from today
6584 @item @samp{+4}
6585 @tab @result{} same as +4d
6586 @item @samp{+2w}
6587 @tab @result{} two weeks from today
6588 @item @samp{++5}
6589 @tab @result{} five days from default date
6590 @item @samp{+2tue}
6591 @tab @result{} second Tuesday from now
6592 @end multitable
6594 @vindex parse-time-months
6595 @vindex parse-time-weekdays
6596 The function understands English month and weekday abbreviations.  If
6597 you want to use un-abbreviated names and/or other languages, configure
6598 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
6600 @vindex org-read-date-force-compatible-dates
6601 Not all dates can be represented in a given Emacs implementation.  By
6602 default Org mode forces dates into the compatibility range 1970--2037
6603 which works on all Emacs implementations.  If you want to use dates
6604 outside of this range, read the docstring of the variable
6605 @code{org-read-date-force-compatible-dates}.
6607 You can specify a time range by giving start and end times or by
6608 giving a start time and a duration (in HH:MM format).  Use one or two
6609 dash(es) as the separator in the former case and use @samp{+} as the
6610 separator in the latter case, e.g.:
6612 @multitable {aaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaa}
6613 @item @samp{11am-1:15pm}
6614 @tab @result{} 11:00-13:15
6615 @item @samp{11am--1:15pm}
6616 @tab @result{} same as above
6617 @item @samp{11am+2:15}
6618 @tab @result{} same as above
6619 @end multitable
6621 @cindex calendar, for selecting date
6622 @vindex org-popup-calendar-for-date-prompt
6623 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If you do not need/want the calendar, configure the variable
6624 @code{org-popup-calendar-for-date-prompt}.}.
6625 When you exit the date prompt, either by clicking on a date in the
6626 calendar, or by pressing @kbd{@key{RET}}, the date selected in the
6627 calendar is combined with the information entered at the prompt.  You
6628 can control the calendar fully from the minibuffer:
6630 @kindex <
6631 @kindex >
6632 @kindex M-v
6633 @kindex C-v
6634 @kindex mouse-1
6635 @kindex S-RIGHT
6636 @kindex S-LEFT
6637 @kindex S-DOWN
6638 @kindex S-UP
6639 @kindex M-S-RIGHT
6640 @kindex M-S-LEFT
6641 @kindex RET
6642 @multitable @columnfractions 0.25 0.55
6643 @item @kbd{@key{RET}}
6644 @tab Choose date at cursor in calendar.
6645 @item @kbd{mouse-1}
6646 @tab Select date by clicking on it.
6647 @item @kbd{S-@key{RIGHT}}
6648 @tab One day forward.
6649 @item @kbd{S-@key{LEFT}}
6650 @tab One day backward.
6651 @item @kbd{S-@key{DOWN}}
6652 @tab One week forward.
6653 @item @kbd{S-@key{UP}}
6654 @tab One week backward.
6655 @item @kbd{M-S-@key{RIGHT}}
6656 @tab One month forward.
6657 @item @kbd{M-S-@key{LEFT}}
6658 @tab One month backward.
6659 @item @kbd{>}
6660 @tab Scroll calendar forward by one month.
6661 @item @kbd{<}
6662 @tab Scroll calendar backward by one month.
6663 @item @kbd{M-v}
6664 @tab Scroll calendar forward by 3 months.
6665 @item @kbd{C-v}
6666 @tab Scroll calendar backward by 3 months.
6667 @end multitable
6669 @vindex org-read-date-display-live
6670 The actions of the date/time prompt may seem complex, but I assure you
6671 they will grow on you, and you will start getting annoyed by pretty
6672 much any other way of entering a date/time out there.  To help you
6673 understand what is going on, the current interpretation of your input
6674 is displayed live in the minibuffer@footnote{If you find this distracting, turn off the display with
6675 @code{org-read-date-display-live}.}.
6677 @node Custom time format
6678 @subsection Custom time format
6680 @cindex custom date/time format
6681 @cindex time format, custom
6682 @cindex date format, custom
6684 @vindex org-display-custom-times
6685 @vindex org-time-stamp-custom-formats
6686 Org mode uses the standard ISO notation for dates and times as it is
6687 defined in ISO 8601.  If you cannot get used to this and require
6688 another representation of date and time to keep you happy, you can get
6689 it by customizing the variables @code{org-display-custom-times} and
6690 @code{org-time-stamp-custom-formats}.
6692 @table @asis
6693 @item @kbd{C-c C-x C-t} (@code{org-toggle-time-stamp-overlays})
6694 @kindex C-c C-x C-t
6695 @findex org-toggle-time-stamp-overlays
6696 Toggle the display of custom formats for dates and times.
6697 @end table
6699 @noindent
6700 Org mode needs the default format for scanning, so the custom
6701 date/time format does not @emph{replace} the default format.  Instead, it
6702 is put @emph{over} the default format using text properties.  This has the
6703 following consequences:
6705 @itemize
6706 @item
6707 You cannot place the cursor onto a timestamp anymore, only before or
6708 after.
6710 @item
6711 The @kbd{S-@key{UP}} and @kbd{S-@key{DOWN}} keys can no longer be used
6712 to adjust each component of a timestamp.  If the cursor is at the
6713 beginning of the stamp, @kbd{S-@key{UP}} and @kbd{S-@key{DOWN}} change
6714 the stamp by one day, just like @kbd{S-@key{LEFT}}
6715 @kbd{S-@key{RIGHT}}.  At the end of the stamp, change the time by one
6716 minute.
6718 @item
6719 If the timestamp contains a range of clock times or a repeater,
6720 these are not overlaid, but remain in the buffer as they were.
6722 @item
6723 When you delete a timestamp character-by-character, it only
6724 disappears from the buffer after @emph{all} (invisible) characters
6725 belonging to the ISO timestamp have been removed.
6727 @item
6728 If the custom timestamp format is longer than the default and you
6729 are using dates in tables, table alignment will be messed up.  If
6730 the custom format is shorter, things do work as expected.
6731 @end itemize
6733 @node Deadlines and Scheduling
6734 @section Deadlines and Scheduling
6736 A timestamp may be preceded by special keywords to facilitate
6737 planning.  Both the timestamp and the keyword have to be positioned
6738 immediately after the task they refer to.
6740 @table @asis
6741 @item @samp{DEADLINE}
6742 @cindex @samp{DEADLINE}
6743 Meaning: the task (most likely a TODO item, though not
6744 necessarily) is supposed to be finished on that date.
6746 @vindex org-deadline-warning-days
6747 On the deadline date, the task is listed in the agenda.  In
6748 addition, the agenda for @emph{today} carries a warning about the
6749 approaching or missed deadline, starting
6750 @code{org-deadline-warning-days} before the due date, and continuing
6751 until the entry is marked DONE.  An example:
6753 @example
6754 *** TODO write article about the Earth for the Guide
6755     DEADLINE: <2004-02-29 Sun>
6756     The editor in charge is [[bbdb:Ford Prefect]]
6757 @end example
6759 @vindex org-agenda-skip-deadline-prewarning-if-scheduled
6760 You can specify a different lead time for warnings for a specific
6761 deadlines using the following syntax.  Here is an example with
6762 a warning period of 5 days @samp{DEADLINE: <2004-02-29 Sun -5d>}.
6763 This warning is deactivated if the task gets scheduled and you
6764 set @code{org-agenda-skip-deadline-prewarning-if-scheduled} to @code{t}.
6766 @item @samp{SCHEDULED}
6767 @cindex @samp{SCHEDULED}
6768 Meaning: you are planning to start working on that task on the
6769 given date.
6771 @vindex org-agenda-skip-scheduled-if-done
6772 The headline is listed under the given date@footnote{It will still be listed on that date after it has been marked
6773 DONE.  If you do not like this, set the variable
6774 @code{org-agenda-skip-scheduled-if-done}.}.  In addition,
6775 a reminder that the scheduled date has passed is present in the
6776 compilation for @emph{today}, until the entry is marked DONE, i.e.,
6777 the task is automatically forwarded until completed.
6779 @example
6780 *** TODO Call Trillian for a date on New Years Eve.
6781     SCHEDULED: <2004-12-25 Sat>
6782 @end example
6784 @vindex org-scheduled-delay-days
6785 @vindex org-agenda-skip-scheduled-delay-if-deadline
6786 If you want to @emph{delay} the display of this task in the agenda,
6787 use @samp{SCHEDULED: <2004-12-25 Sat -2d>}: the task is still
6788 scheduled on the 25th but will appear two days later.  In case
6789 the task contains a repeater, the delay is considered to affect
6790 all occurrences; if you want the delay to only affect the first
6791 scheduled occurrence of the task, use @samp{--2d} instead.  See
6792 @code{org-scheduled-delay-days} and
6793 @code{org-agenda-skip-scheduled-delay-if-deadline} for details on how
6794 to control this globally or per agenda.
6796 @noindent
6797 @strong{Important:} Scheduling an item in Org mode should @emph{not} be
6798 understood in the same way that we understand @emph{scheduling
6799 a meeting}.  Setting a date for a meeting is just a simple
6800 appointment, you should mark this entry with a simple plain
6801 timestamp, to get this item shown on the date where it applies.
6802 This is a frequent misunderstanding by Org users.  In Org mode,
6803 @emph{scheduling} means setting a date when you want to start working
6804 on an action item.
6805 @end table
6807 You may use timestamps with repeaters in scheduling and deadline
6808 entries.  Org mode issues early and late warnings based on the
6809 assumption that the timestamp represents the @emph{nearest instance} of the
6810 repeater.  However, the use of diary S-exp entries like
6812 @example
6813 <%%(org-float t 42)>
6814 @end example
6816 @noindent
6817 in scheduling and deadline timestamps is limited.  Org mode does not
6818 know enough about the internals of each S-exp function to issue early
6819 and late warnings.  However, it shows the item on each day where the
6820 S-exp entry matches.
6822 @menu
6823 * Inserting deadline/schedule::  Planning items.
6824 * Repeated tasks::               Items that show up again and again.
6825 @end menu
6827 @node Inserting deadline/schedule
6828 @subsection Inserting deadlines or schedules
6830 The following commands allow you to quickly insert a deadline or to
6831 schedule an item:@footnote{The @samp{SCHEDULED} and @samp{DEADLINE} dates are inserted on the line
6832 right below the headline.  Do not put any text between this line and
6833 the headline.}
6835 @table @asis
6836 @item @kbd{C-c C-d} (@code{org-deadline})
6837 @kindex C-c C-d
6838 @findex org-deadline
6839 @vindex org-log-redeadline
6840 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion
6841 happens in the line directly following the headline.  Remove any
6842 @samp{CLOSED} timestamp .  When called with a prefix argument, also
6843 remove any existing deadline from the entry.  Depending on the
6844 variable @code{org-log-redeadline}, take a note when changing an
6845 existing deadline@footnote{Note the corresponding @samp{STARTUP} options @samp{logredeadline},
6846 @samp{lognoteredeadline}, and @samp{nologredeadline}.}.
6848 @item @kbd{C-c C-s} (@code{org-schedule})
6849 @kindex C-c C-s
6850 @findex org-schedule
6851 @vindex org-log-reschedule
6852 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion
6853 happens in the line directly following the headline.  Remove any
6854 @samp{CLOSED} timestamp.  When called with a prefix argument, also
6855 remove the scheduling date from the entry.  Depending on the
6856 variable @code{org-log-reschedule}, take a note when changing an
6857 existing scheduling time@footnote{Note the corresponding @samp{STARTUP} options @samp{logreschedule},
6858 @samp{lognotereschedule}, and @samp{nologreschedule}.}.
6860 @item @kbd{C-c C-x C-k} (@code{org-mark-entry-for-agenda-action})
6861 @kindex C-c C-x C-k
6862 @kindex k a
6863 @kindex k s
6864 @findex org-mark-entry-for-agenda-action
6865 Mark the current entry for agenda action.  After you have marked
6866 the entry like this, you can open the agenda or the calendar to
6867 find an appropriate date.  With the cursor on the selected date,
6868 press @kbd{k s} or @kbd{k d} to schedule the marked
6869 item.
6871 @item @kbd{C-c / d} (@code{org-check-deadlines})
6872 @kindex C-c / d
6873 @findex org-check-deadlines
6874 @cindex sparse tree, for deadlines
6875 @vindex org-deadline-warning-days
6876 Create a sparse tree with all deadlines that are either past-due,
6877 or which will become due within @code{org-deadline-warning-days}.
6878 With @kbd{C-u} prefix, show all deadlines in the file.  With
6879 a numeric prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows all deadlines due tomorrow.
6881 @item @kbd{C-c / b}, @code{org-check-before-date}
6882 @kindex C-c / b
6883 @findex org-check-before-date
6884 Sparse tree for deadlines and scheduled items before a given
6885 date.
6887 @item @kbd{C-c / a}, @code{org-check-after-date}
6888 @kindex C-c / a
6889 @findex org-check-after-date
6890 Sparse tree for deadlines and scheduled items after a given date.
6891 @end table
6893 Note that @code{org-schedule} and @code{org-deadline} supports setting the date
6894 by indicating a relative time e.g., @samp{+1d} sets the date to the next
6895 day after today, and @samp{--1w} sets the date to the previous week before
6896 any current timestamp.
6898 @node Repeated tasks
6899 @subsection Repeated tasks
6901 @cindex tasks, repeated
6902 @cindex repeated tasks
6904 Some tasks need to be repeated again and again.  Org mode helps to
6905 organize such tasks using a so-called repeater in a @samp{DEADLINE},
6906 @samp{SCHEDULED}, or plain timestamp.  In the following example:
6908 @example
6909 ** TODO Pay the rent
6910    DEADLINE: <2005-10-01 Sat +1m>
6911 @end example
6913 noindent
6914 the @samp{+1m} is a repeater; the intended interpretation is that the task
6915 has a deadline on @samp{<2005-10-01>} and repeats itself every (one) month
6916 starting from that time.  You can use yearly, monthly, weekly, daily
6917 and hourly repeat cookies by using the @code{y/w/m/d/h} letters.  If you
6918 need both a repeater and a special warning period in a deadline entry,
6919 the repeater should come first and the warning period last: @samp{DEADLINE:
6920 <2005-10-01 Sat +1m -3d>}.
6922 @vindex org-todo-repeat-to-state
6923 Deadlines and scheduled items produce entries in the agenda when they
6924 are over-due, so it is important to be able to mark such an entry as
6925 completed once you have done so.  When you mark a @samp{DEADLINE} or
6926 a @samp{SCHEDULED} with the TODO keyword @samp{DONE}, it no longer produces
6927 entries in the agenda.  The problem with this is, however, is that
6928 then also the @emph{next} instance of the repeated entry will not be
6929 active.  Org mode deals with this in the following way: when you try
6930 to mark such an entry DONE, using @kbd{C-c C-t}, it shifts the
6931 base date of the repeating timestamp by the repeater interval, and
6932 immediately sets the entry state back to TODO@footnote{In fact, the target state is taken from, in this sequence, the
6933 @samp{REPEAT_TO_STATE} property, the variable @code{org-todo-repeat-to-state} if
6934 it is a string, the previous TODO state if @code{org-todo-repeat-to-state}
6935 is @code{t}, or the first state of the TODO state sequence.}.  In the example
6936 above, setting the state to DONE would actually switch the date like
6937 this:
6939 @example
6940 ** TODO Pay the rent
6941    DEADLINE: <2005-11-01 Tue +1m>
6942 @end example
6944 To mark a task with a repeater as DONE, use @kbd{C-- 1 C-c C-t},
6945 i.e., @code{org-todo} with a numeric prefix argument of @samp{-1}.
6947 @vindex org-log-repeat
6948 A timestamp@footnote{You can change this using the option @code{org-log-repeat}, or the
6949 @samp{STARTUP} options @samp{logrepeat}, @samp{lognoterepeat}, and @samp{nologrepeat}.
6950 With @samp{lognoterepeat}, you will also be prompted for a note.} is added under the deadline, to keep a record that
6951 you actually acted on the previous instance of this deadline.
6953 As a consequence of shifting the base date, this entry is no longer
6954 visible in the agenda when checking past dates, but all future
6955 instances will be visible.
6957 With the @samp{+1m} cookie, the date shift is always exactly one month.  So
6958 if you have not paid the rent for three months, marking this entry
6959 DONE still keeps it as an overdue deadline.  Depending on the task,
6960 this may not be the best way to handle it.  For example, if you forgot
6961 to call your father for 3 weeks, it does not make sense to call him
6962 3 times in a single day to make up for it.  Finally, there are tasks
6963 like changing batteries which should always repeat a certain time
6964 @emph{after} the last time you did it.  For these tasks, Org mode has
6965 special repeaters @samp{++} and @samp{.+}.  For example:
6967 @example
6968 ** TODO Call Father
6969    DEADLINE: <2008-02-10 Sun ++1w>
6970    Marking this DONE shifts the date by at least one week, but also
6971    by as many weeks as it takes to get this date into the future.
6972    However, it stays on a Sunday, even if you called and marked it
6973    done on Saturday.
6975 ** TODO Empty kitchen trash
6976    DEADLINE: <2008-02-08 Fri 20:00 ++1d>
6977    Marking this DONE shifts the date by at least one day, and also
6978    by as many days as it takes to get the timestamp into the future.
6979    Since there is a time in the timestamp, the next deadline in the
6980    future will be on today's date if you complete the task before
6981    20:00.
6983 ** TODO Check the batteries in the smoke detectors
6984    DEADLINE: <2005-11-01 Tue .+1m>
6985    Marking this DONE will shift the date to one month after today.
6986 @end example
6988 @vindex org-agenda-skip-scheduled-if-deadline-is-shown
6989 You may have both scheduling and deadline information for a specific
6990 task.  If the repeater is set for the scheduling information only, you
6991 probably want the repeater to be ignored after the deadline.  If so,
6992 set the variable @code{org-agenda-skip-scheduled-if-deadline-is-shown} to
6993 @code{repeated-after-deadline}.  However, any scheduling information
6994 without a repeater is no longer relevant once the task is done, and
6995 thus, removed upon repeating the task.  If you want both scheduling
6996 and deadline information to repeat after the same interval, set the
6997 same repeater for both timestamps.
6999 An alternative to using a repeater is to create a number of copies of
7000 a task subtree, with dates shifted in each copy.  The command
7001 @kbd{C-c C-x c} was created for this purpose; it is described in
7002 @ref{Structure Editing}.
7004 @node Clocking Work Time
7005 @section Clocking Work Time
7007 @cindex clocking time
7008 @cindex time clocking
7010 Org mode allows you to clock the time you spend on specific tasks in
7011 a project.  When you start working on an item, you can start the
7012 clock.  When you stop working on that task, or when you mark the task
7013 done, the clock is stopped and the corresponding time interval is
7014 recorded.  It also computes the total time spent on each
7015 subtree@footnote{Clocking only works if all headings are indented with less
7016 than 30 stars.  This is a hard-coded limitation of @code{lmax} in
7017 @code{org-clock-sum}.} of a project.  And it remembers a history or tasks
7018 recently clocked, to that you can jump quickly between a number of
7019 tasks absorbing your time.
7021 To save the clock history across Emacs sessions, use:
7023 @lisp
7024 (setq org-clock-persist 'history)
7025 (org-clock-persistence-insinuate)
7026 @end lisp
7028 @vindex org-clock-persist
7029 When you clock into a new task after resuming Emacs, the incomplete
7030 clock@footnote{To resume the clock under the assumption that you have worked
7031 on this task while outside Emacs, use @code{(setq org-clock-persist t)}.} is retrieved (see @ref{Resolving idle time (1)}) and you are
7032 prompted about what to do with it.
7034 @menu
7035 * Clocking commands::            Starting and stopping a clock.
7036 * The clock table::              Detailed reports.
7037 * Resolving idle time::          Resolving time when you've been idle.
7038 @end menu
7040 @node Clocking commands
7041 @subsection Clocking commands
7043 @table @asis
7044 @item @kbd{C-c C-x C-i} (@code{org-clock-in})
7045 @kindex C-c C-x C-i
7046 @findex org-clock-in
7047 @vindex org-clock-into-drawer
7048 @vindex org-clock-continuously
7049 @cindex @samp{LOG_INTO_DRAWER}, property
7050 Start the clock on the current item (clock-in).  This inserts the
7051 CLOCK keyword together with a timestamp.  If this is not the
7052 first clocking of this item, the multiple CLOCK lines are wrapped
7053 into a @samp{LOGBOOK} drawer (see also the variable
7054 @code{org-clock-into-drawer}).  You can also overrule the setting of
7055 this variable for a subtree by setting a @samp{CLOCK_INTO_DRAWER} or
7056 @samp{LOG_INTO_DRAWER} property.  When called with a @kbd{C-u}
7057 prefix argument, select the task from a list of recently clocked
7058 tasks.  With two @kbd{C-u C-u} prefixes, clock into the task
7059 at point and mark it as the default task; the default task is
7060 always be available with letter @kbd{d} when selecting
7061 a clocking task.  With three @kbd{C-u C-u C-u} prefixes,
7062 force continuous clocking by starting the clock when the last
7063 clock stopped.
7065 @cindex @samp{CLOCK_MODELINE_TOTAL}, property
7066 @cindex @samp{LAST_REPEAT}, property
7067 @vindex org-clock-modeline-total
7068 @vindex org-clock-in-prepare-hook
7069 While the clock is running, Org shows the current clocking time
7070 in the mode line, along with the title of the task.  The clock
7071 time shown is all time ever clocked for this task and its
7072 children.  If the task has an effort estimate (see @ref{Effort Estimates}), the mode line displays the current clocking time
7073 against it@footnote{To add an effort estimate ``on the fly'', hook a function doing
7074 this to @code{org-clock-in-prepare-hook}.}.  If the task is a repeating one (see @ref{Repeated tasks}), show only the time since the last reset of the
7075 task@footnote{The last reset of the task is recorded by the @samp{LAST_REPEAT}
7076 property.}.  You can exercise more control over show time with
7077 the @samp{CLOCK_MODELINE_TOTAL} property.  It may have the values
7078 @samp{current} to show only the current clocking instance, @samp{today} to
7079 show all time clocked on this tasks today---see also the
7080 variable @code{org-extend-today-until}, @code{all} to include all time, or
7081 @code{auto} which is the default@footnote{See also the variable @code{org-clock-modeline-total}.}.  Clicking with
7082 @kbd{mouse-1} onto the mode line entry pops up a menu with
7083 clocking options.
7085 @item @kbd{C-c C-x C-o} (@code{org-clock-out})
7086 @kindex C-c C-x C-o
7087 @findex org-clock-out
7088 @vindex org-log-note-clock-out
7089 Stop the clock (clock-out).  This inserts another timestamp at
7090 the same location where the clock was last started.  It also
7091 directly computes the resulting time in inserts it after the time
7092 range as @samp{=>HH:MM}.  See the variable @code{org-log-note-clock-out}
7093 for the possibility to record an additional note together with
7094 the clock-out timestamp@footnote{The corresponding in-buffer setting is: @samp{#+STARTUP:
7095 lognoteclock-out}.}.
7097 @item @kbd{C-c C-x C-x} (@code{org-clock-in-last})
7098 @kindex C-c C-x C-x
7099 @findex org-clock-in-last
7100 @vindex org-clock-continuously
7101 Re-clock the last clocked task.  With one @kbd{C-u} prefix
7102 argument, select the task from the clock history.  With two
7103 @kbd{C-u} prefixes, force continuous clocking by starting
7104 the clock when the last clock stopped.
7106 @item @kbd{C-c C-x C-e} (@code{org-clock-modify-effort-estimate})
7107 @kindex C-c C-x C-e
7108 @findex org-clock-modify-effort-estimate
7109 Update the effort estimate for the current clock task.
7111 @item @kbd{C-c C-c} or @kbd{C-c C-y} (@code{org-evaluate-time-range})
7112 @kindex C-c C-c
7113 @kindex C-c C-y
7114 @findex org-evaluate-time-range
7115 Recompute the time interval after changing one of the timestamps.
7116 This is only necessary if you edit the timestamps directly.  If
7117 you change them with @kbd{S-<cursor>} keys, the update is
7118 automatic.
7120 @item @kbd{C-S-@key{UP}} (@code{org-clock-timestamps-up})
7121 @itemx @kbd{C-S-@key{DOWN}} (@code{org-clock-timestamps-down})
7122 @kindex C-S-UP
7123 @findex org-clock-timestamps-up
7124 @kindex C-S-DOWN
7125 @findex org-clock-timestamps-down
7126 On CLOCK log lines, increase/decrease both timestamps so that the
7127 clock duration keeps the same value.
7129 @item @kbd{S-M-@key{UP}} (@code{org-timestamp-up})
7130 @itemx @kbd{S-M-@key{DOWN}} (@code{org-timestamp-down})
7131 @kindex S-M-UP
7132 @findex org-clock-timestamp-up
7133 @kindex S-M-DOWN
7134 @findex org-clock-timestamp-down
7135 On @samp{CLOCK} log lines, increase/decrease the timestamp at point
7136 and the one of the previous, or the next, clock timestamp by the
7137 same duration.  For example, if you hit @kbd{S-M-@key{UP}} to
7138 increase a clocked-out timestamp by five minutes, then the
7139 clocked-in timestamp of the next clock is increased by five
7140 minutes.
7142 @item @kbd{C-c C-t} (@code{org-todo})
7143 @kindex C-c C-t
7144 @findex org-todo
7145 Changing the TODO state of an item to DONE automatically stops
7146 the clock if it is running in this same item.
7148 @item @kbd{C-c C-x C-q} (@code{org-clock-cancel})
7149 @kindex C-c C-x C-q
7150 @findex org-clock-cancel
7151 Cancel the current clock.  This is useful if a clock was started
7152 by mistake, or if you ended up working on something else.
7154 @item @kbd{C-c C-x C-j} (@code{org-clock-goto})
7155 @kindex C-c C-x C-j
7156 @findex or-clock-goto
7157 Jump to the headline of the currently clocked in task.  With
7158 a @kbd{C-u} prefix argument, select the target task from
7159 a list of recently clocked tasks.
7161 @item @kbd{C-c C-x C-d} (@code{org-clock-display})
7162 @kindex C-c C-x C-d
7163 @findex org-clock-display
7164 @vindex org-remove-highlights-with-change
7165 Display time summaries for each subtree in the current buffer.
7166 This puts overlays at the end of each headline, showing the total
7167 time recorded under that heading, including the time of any
7168 subheadings.  You can use visibility cycling to study the tree,
7169 but the overlays disappear when you change the buffer (see
7170 variable @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
7171 @end table
7173 The @kbd{l} key may be used in the agenda (see @ref{Weekly/daily agenda}) to show which tasks have been worked on or closed during
7174 a day.
7176 @strong{Important:} note that both @code{org-clock-out} and @code{org-clock-in-last}
7177 can have a global keybinding and do not modify the window disposition.
7179 @node The clock table
7180 @subsection The clock table
7182 @cindex clocktable, dynamic block
7183 @cindex report, of clocked time
7185 Org mode can produce quite complex reports based on the time clocking
7186 information.  Such a report is called a @emph{clock table}, because it is
7187 formatted as one or several Org tables.
7189 @table @asis
7190 @item @kbd{C-c C-x C-r} (@code{org-clock-report})
7191 @kindex C-c C-x C-r
7192 @findex org-clock-report
7193 Insert a dynamic block (see @ref{Dynamic Blocks}) containing a clock
7194 report as an Org mode table into the current file.  When the
7195 cursor is at an existing clock table, just update it.  When
7196 called with a prefix argument, jump to the first clock report in
7197 the current document and update it.  The clock table includes
7198 archived trees.
7200 @item @kbd{C-c C-c} or @kbd{C-c C-x C-u} (@code{org-dblock-update})
7201 @kindex C-c C-c
7202 @kindex C-c C-x C-u
7203 @findex org-dblock-update
7204 Update dynamic block at point.  The cursor needs to be in the
7205 @samp{BEGIN} line of the dynamic block.
7207 @item @kbd{C-u C-c C-x C-u}
7208 @kindex C-u C-c C-x C-u
7209 Update all dynamic blocks (see @ref{Dynamic Blocks}).  This is useful
7210 if you have several clock table blocks in a buffer.
7212 @item @kbd{S-@key{LEFT}}
7213 @itemx @kbd{S-@key{RIGHT}} (@code{org-clocktable-try-shift})
7214 @kindex S-LEFT
7215 @kindex S-RIGHT
7216 @findex org-clocktable-try-shift
7217 Shift the current @samp{:block} interval and update the table.  The
7218 cursor needs to be in the @samp{#+BEGIN: clocktable} line for this
7219 command.  If @samp{:block} is @samp{today}, it is shifted to @samp{today-1},
7220 etc.
7221 @end table
7223 Here is an example of the frame for a clock table as it is inserted
7224 into the buffer with the @kbd{C-c C-x C-r} command:
7226 @cindex @samp{BEGIN clocktable}
7227 @example
7228 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
7229 #+END: clocktable
7230 @end example
7232 @noindent
7233 @vindex org-clocktable-defaults
7234 The @samp{#+BEGIN} line and specify a number of options to define the
7235 scope, structure, and formatting of the report.  Defaults for all
7236 these options can be configured in the variable
7237 @code{org-clocktable-defaults}.
7239 @noindent
7240 First there are options that determine which clock entries are to
7241 be selected:
7243 @table @asis
7244 @item :maxlevel
7245 Maximum level depth to which times are listed in the table.
7246 Clocks at deeper levels are summed into the upper level.
7248 @item :scope
7249 The scope to consider.  This can be any of the following:
7251 @multitable {aaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
7252 @item @code{nil}
7253 @tab the current buffer or narrowed region
7254 @item @code{file}
7255 @tab the full current buffer
7256 @item @code{subtree}
7257 @tab the subtree where the clocktable is located
7258 @item @code{treeN}
7259 @tab the surrounding level N tree, for example @samp{tree3}
7260 @item @code{tree}
7261 @tab the surrounding level 1 tree
7262 @item @code{agenda}
7263 @tab all agenda files
7264 @item @samp{("file" ...)}
7265 @tab scan these files
7266 @item @samp{FUNCTION}
7267 @tab scan files returned by calling FUNCTION with no argument
7268 @item @code{file-with-archives}
7269 @tab current file and its archives
7270 @item @code{agenda-with-archives}
7271 @tab all agenda files, including archives
7272 @end multitable
7274 @item :block
7275 The time block to consider.  This block is specified either
7276 absolutely, or relative to the current time and may be any of
7277 these formats:
7279 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaa}
7280 @item @samp{2007-12-31}
7281 @tab New year eve 2007
7282 @item @samp{2007-12}
7283 @tab December 2007
7284 @item @samp{2007-W50}
7285 @tab ISO-week 50 in 2007
7286 @item @samp{2007-Q2}
7287 @tab 2nd quarter in 2007
7288 @item @samp{2007}
7289 @tab the year 2007
7290 @item @code{today}, @code{yesterday}, @code{today-N}
7291 @tab a relative day
7292 @item @code{thisweek}, @code{lastweek}, @code{thisweek-N}
7293 @tab a relative week
7294 @item @code{thismonth}, @code{lastmonth}, @code{thismonth-N}
7295 @tab a relative month
7296 @item @code{thisyear}, @code{lastyear}, @code{thisyear-N}
7297 @tab a relative year
7298 @item @code{untilnow}
7299 @tab all clocked time ever
7300 @end multitable
7302 @vindex org-clock-display-default-range
7303 When this option is not set, Org falls back to the value in
7304 @code{org-clock-display-default-range}, which defaults to the current
7305 year.
7307 Use @kbd{S-@key{LEFT}} or @kbd{S-@key{RIGHT}} to shift the time
7308 interval.
7310 @item :tstart
7311 A time string specifying when to start considering times.
7312 Relative times like @samp{"<-2w>"} can also be used.  See @ref{Matching tags and properties} for relative time syntax.
7314 @item :tend 
7315 A time string specifying when to stop considering times.
7316 Relative times like @samp{"<now>"} can also be used.  See @ref{Matching tags and properties} for relative time syntax.
7318 @item wstart
7319 The starting day of the week.  The default is 1 for Monday.
7321 @item mstart
7322 The starting day of the month.  The default is 1 for the first.
7324 @item :step
7325 Set to @code{week} or @code{day} to split the table into chunks.  To use
7326 this, @code{:block} or @code{:tstart}, @code{:tend} are needed.
7328 @item :stepskip0
7329 Do not show steps that have zero time.
7331 @item :fileskip0
7332 Do not show table sections from files which did not contribute.
7334 @item :tags
7335 A tags match to select entries that should contribute.  See
7336 @ref{Matching tags and properties} for the match syntax.
7337 @end table
7339 @findex org-clocktable-write-default
7340 Then there are options that determine the formatting of the table.
7341 There options are interpreted by the function
7342 @code{org-clocktable-write-default}, but you can specify your own function
7343 using the @samp{:formatter} parameter.
7345 @table @asis
7346 @item :emphasize
7347 When @code{t}, emphasize level one and level two items.
7349 @item :lang
7350 Language@footnote{Language terms can be set through the variable
7351 @code{org-clock-clocktable-language-setup}.} to use for descriptive cells like ``Task''.
7353 @item :link
7354 Link the item headlines in the table to their origins.
7356 @item :narrow
7357 An integer to limit the width of the headline column in the Org
7358 table.  If you write it like @samp{50!}, then the headline is also
7359 shortened in export.
7361 @item :indent
7362 Indent each headline field according to its level.
7364 @item :tcolumns
7365 Number of columns to be used for times.  If this is smaller than
7366 @samp{:maxlevel}, lower levels are lumped into one column.
7368 @item :level
7369 Should a level number column be included?
7371 @item :sort
7372 A cons cell containing the column to sort and a sorting type.
7373 E.g., @samp{:sort (1 . ?a)} sorts the first column alphabetically.
7375 @item :compact
7376 Abbreviation for @samp{:level nil :indent t :narrow 40! :tcolumns 1}.
7377 All are overwritten except if there is an explicit @samp{:narrow}.
7379 @item :timestamp
7380 A timestamp for the entry, when available.  Look for SCHEDULED,
7381 DEADLINE, TIMESTAMP and TIMESTAMP_IA special properties (see
7382 @ref{Special Properties}), in this order.
7384 @item :properties
7385 List of properties shown in the table.  Each property gets its
7386 own column.
7388 @item :inherit-props
7389 When this flag is non-@code{nil}, the values for @samp{:properties} are
7390 inherited.
7392 @item :formula
7393 Content of a @samp{TBLFM} keyword to be added and evaluated.  As
7394 a special case, @samp{:formula %} adds a column with % time.  If you
7395 do not specify a formula here, any existing formula below the
7396 clock table survives updates and is evaluated.
7398 @item :formatter
7399 A function to format clock data and insert it into the buffer.
7400 @end table
7402 To get a clock summary of the current level 1 tree, for the current
7403 day, you could write:
7405 @example
7406 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
7407 #+END: clocktable
7408 @end example
7410 @noindent
7411 To use a specific time range you could write@footnote{Note that all parameters must be specified in a single
7412 line---the line is broken here only to fit it into the manual.}
7414 @example
7415 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
7416                     :tend "<2006-08-10 Thu 12:00>"
7417 #+END: clocktable
7418 @end example
7420 A range starting a week ago and ending right now could be written as
7422 @example
7423 #+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
7424 #+END: clocktable
7425 @end example
7427 A summary of the current subtree with % times would be:
7429 @example
7430 #+BEGIN: clocktable :scope subtree :link t :formula %
7431 #+END: clocktable
7432 @end example
7434 A horizontally compact representation of everything clocked during
7435 last week would be:
7437 @example
7438 #+BEGIN: clocktable :scope agenda :block lastweek :compact t
7439 #+END: clocktable
7440 @end example
7442 @node Resolving idle time
7443 @subsection Resolving idle time and continuous clocking
7447 @anchor{Resolving idle time (1)}
7448 @subsubheading Resolving idle time
7450 @cindex resolve idle time
7451 @cindex idle, resolve, dangling
7453 If you clock in on a work item, and then walk away from your
7454 computer---perhaps to take a phone call---you often need to
7455 ``resolve'' the time you were away by either subtracting it from the
7456 current clock, or applying it to another one.
7458 @vindex org-clock-idle-time
7459 @vindex org-clock-x11idle-program-name
7460 By customizing the variable @code{org-clock-idle-time} to some integer,
7461 such as 10 or 15, Emacs can alert you when you get back to your
7462 computer after being idle for that many minutes@footnote{On computers using macOS, idleness is based on actual user
7463 idleness, not just Emacs' idle time.  For X11, you can install
7464 a utility program @samp{x11idle.c}, available in the @samp{contrib/scripts/}
7465 directory of the Org Git distribution, or install the xprintidle
7466 package and set it to the variable @code{org-clock-x11idle-program-name} if
7467 you are running Debian, to get the same general treatment of idleness.
7468 On other systems, idle time refers to Emacs idle time only.}, and ask what
7469 you want to do with the idle time.  There will be a question waiting
7470 for you when you get back, indicating how much idle time has passed
7471 constantly updated with the current amount, as well as a set of
7472 choices to correct the discrepancy:
7474 @table @asis
7475 @item @kbd{k}
7476 @kindex k
7477 To keep some or all of the minutes and stay clocked in, press
7478 @kbd{k}.  Org asks how many of the minutes to keep.  Press
7479 @kbd{@key{RET}} to keep them all, effectively changing nothing, or
7480 enter a number to keep that many minutes.
7482 @item @kbd{K}
7483 @kindex K
7484 If you use the shift key and press @kbd{K}, it keeps however
7485 many minutes you request and then immediately clock out of that
7486 task.  If you keep all of the minutes, this is the same as just
7487 clocking out of the current task.
7489 @item @kbd{s}
7490 @kindex s
7491 To keep none of the minutes, use @kbd{s} to subtract all the
7492 away time from the clock, and then check back in from the moment
7493 you returned.
7495 @item @kbd{S}
7496 @kindex S
7497 To keep none of the minutes and just clock out at the start of
7498 the away time, use the shift key and press @kbd{S}.
7499 Remember that using shift always leave you clocked out, no matter
7500 which option you choose.
7502 @item @kbd{C}
7503 @kindex C
7504 To cancel the clock altogether, use @kbd{C}.  Note that if
7505 instead of canceling you subtract the away time, and the
7506 resulting clock amount is less than a minute, the clock is still
7507 canceled rather than cluttering up the log with an empty entry.
7508 @end table
7510 What if you subtracted those away minutes from the current clock, and
7511 now want to apply them to a new clock?  Simply clock in to any task
7512 immediately after the subtraction.  Org will notice that you have
7513 subtracted time ``on the books'', so to speak, and will ask if you want
7514 to apply those minutes to the next task you clock in on.
7516 There is one other instance when this clock resolution magic occurs.
7517 Say you were clocked in and hacking away, and suddenly your cat chased
7518 a mouse who scared a hamster that crashed into your UPS's power
7519 button!  You suddenly lose all your buffers, but thanks to auto-save
7520 you still have your recent Org mode changes, including your last clock
7523 If you restart Emacs and clock into any task, Org will notice that you
7524 have a dangling clock which was never clocked out from your last
7525 session.  Using that clock's starting time as the beginning of the
7526 unaccounted-for period, Org will ask how you want to resolve that
7527 time.  The logic and behavior is identical to dealing with away time
7528 due to idleness; it is just happening due to a recovery event rather
7529 than a set amount of idle time.
7531 You can also check all the files visited by your Org agenda for
7532 dangling clocks at any time using @kbd{M-x org-resolve-clocks @key{RET}} (or @kbd{C-c C-x C-z}).
7534 @anchor{Continuous clocking}
7535 @subsubheading Continuous clocking
7537 @cindex continuous clocking
7539 @vindex org-clock-continuously
7540 You may want to start clocking from the time when you clocked out the
7541 previous task.  To enable this systematically, set
7542 @code{org-clock-continuously} to non-@code{nil}.  Each time you clock in, Org
7543 retrieves the clock-out time of the last clocked entry for this
7544 session, and start the new clock from there.
7546 If you only want this from time to time, use three universal prefix
7547 arguments with @code{org-clock-in} and two @kbd{C-u C-u} with
7548 @code{org-clock-in-last}.
7550 @node Effort Estimates
7551 @section Effort Estimates
7553 @cindex effort estimates
7554 @cindex @samp{EFFORT}, property
7555 @vindex org-effort-property
7557 If you want to plan your work in a very detailed way, or if you need
7558 to produce offers with quotations of the estimated work effort, you
7559 may want to assign effort estimates to entries.  If you are also
7560 clocking your work, you may later want to compare the planned effort
7561 with the actual working time, a great way to improve planning
7562 estimates.  Effort estimates are stored in a special property
7563 @samp{EFFORT}.  You can set the effort for an entry with the following
7564 commands:
7566 @table @asis
7567 @item @kbd{C-c C-x e}  (@code{org-set-effort})
7568 @kindex C-c C-x e
7569 @findex org-set-effort
7570 Set the effort estimate for the current entry.  With a prefix
7571 argument, set it to the next allowed value---see below.  This
7572 command is also accessible from the agenda with the @kbd{e}
7573 key.
7575 @item @kbd{C-c C-x C-e} (@code{org-clock-modify-effort-estimate})
7576 @kindex C-c C-x C-e
7577 @findex org-clock-modify-effort-estimate
7578 Modify the effort estimate of the item currently being clocked.
7579 @end table
7581 Clearly the best way to work with effort estimates is through column
7582 view (see @ref{Column View}).  You should start by setting up discrete
7583 values for effort estimates, and a @samp{COLUMNS} format that displays
7584 these values together with clock sums---if you want to clock your
7585 time.  For a specific buffer you can use:
7587 @example
7588 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
7589 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
7590 @end example
7592 noindent
7593 @vindex org-global-properties
7594 @vindex org-columns-default-format
7595 or, even better, you can set up these values globally by customizing
7596 the variables @code{org-global-properties} and
7597 @code{org-columns-default-format}.  In particular if you want to use this
7598 setup also in the agenda, a global setup may be advised.
7600 The way to assign estimates to individual items is then to switch to
7601 column mode, and to use @kbd{S-@key{RIGHT}} and @kbd{S-@key{LEFT}} to
7602 change the value.  The values you enter are immediately summed up in
7603 the hierarchy.  In the column next to it, any clocked time is
7604 displayed.
7606 @vindex org-agenda-columns-add-appointments-to-effort-sum
7607 If you switch to column view in the daily/weekly agenda, the effort
7608 column summarizes the estimated work effort for each day@footnote{Please note the pitfalls of summing hierarchical data in
7609 a flat list (@ref{Agenda Column View}).}, and
7610 you can use this to find space in your schedule.  To get an overview
7611 of the entire part of the day that is committed, you can set the
7612 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
7613 appointments on a day that take place over a specified time interval
7614 are then also added to the load estimate of the day.
7616 Effort estimates can be used in secondary agenda filtering that is
7617 triggered with the @kbd{/} key in the agenda (see @ref{Agenda Commands}).  If you have these estimates defined consistently,
7618 two or three key presses narrow down the list to stuff that fits into
7619 an available time slot.
7621 @node Timers
7622 @section Taking Notes with a Relative Timer
7624 @cindex relative timer
7625 @cindex countdown timer
7627 Org provides two types of timers.  There is a relative timer that
7628 counts up, which can be useful when taking notes during, for example,
7629 a meeting or a video viewing.  There is also a countdown timer.
7631 The relative and countdown are started with separate commands.
7633 @table @asis
7634 @item @kbd{C-c C-x 0} (@code{org-timer-start})
7635 @kindex C-c C-x 0
7636 @findex org-timer-start
7637 Start or reset the relative timer.  By default, the timer is set
7638 to 0.  When called with a @kbd{C-u} prefix, prompt the user
7639 for a starting offset.  If there is a timer string at point, this
7640 is taken as the default, providing a convenient way to restart
7641 taking notes after a break in the process.  When called with
7642 a double prefix argument @kbd{C-u C-u}, change all timer
7643 strings in the active region by a certain amount.  This can be
7644 used to fix timer strings if the timer was not started at exactly
7645 the right moment.
7647 @item @kbd{C-c C-x ;} (@code{org-timer-set-timer})
7648 @kindex C-c C-x ;
7649 @findex org-timer-set-timer
7650 @vindex org-timer-default-timer
7651 Start a countdown timer.  The user is prompted for a duration.
7652 @code{org-timer-default-timer} sets the default countdown value.
7653 Giving a numeric prefix argument overrides this default value.
7654 This command is available as @kbd{;} in agenda buffers.
7655 @end table
7657 Once started, relative and countdown timers are controlled with the
7658 same commands.
7660 @table @asis
7661 @item @kbd{C-c C-x .} (@code{org-timer})
7662 @kindex C-c C-x .
7663 @findex org-timer
7664 Insert a relative time into the buffer.  The first time you use
7665 this, the timer starts.  Using a prefix argument restarts it.
7667 @item @kbd{C-c C-x -} (@code{org-timer-item})
7668 @kindex C-c C-x -
7669 @findex org-timer-item
7670 Insert a description list item with the current relative time.
7671 With a prefix argument, first reset the timer to 0.
7673 @item @kbd{M-@key{RET}} (@code{org-insert-heading})
7674 @kindex M-RET
7675 @findex org-insert-heading
7676 Once the timer list is started, you can also use
7677 @kbd{M-@key{RET}} to insert new timer items.
7679 @item @kbd{C-c C-x ,} (@code{org-timer-pause-or-continue})
7680 @kindex C-c C-x ,
7681 @findex org-timer-pause-or-continue
7682 Pause the timer, or continue it if it is already paused.
7684 @item @kbd{C-c C-x _} (@code{org-timer-stop})
7685 @kindex C-c C-x _
7686 @findex org-timer-stop
7687 Stop the timer.  After this, you can only start a new timer, not
7688 continue the old one.  This command also removes the timer from
7689 the mode line.
7690 @end table
7692 @node Capture Refile Archive
7693 @chapter Capture, Refile, Archive
7695 @cindex capture
7697 An important part of any organization system is the ability to quickly
7698 capture new ideas and tasks, and to associate reference material with
7699 them.  Org does this using a process called @emph{capture}.  It also can
7700 store files related to a task (@emph{attachments}) in a special directory.
7701 Once in the system, tasks and projects need to be moved around.
7702 Moving completed project trees to an archive file keeps the system
7703 compact and fast.
7705 @menu
7706 * Capture::                      Capturing new stuff.
7707 * Attachments::                  Add files to tasks.
7708 * RSS Feeds::                    Getting input from RSS feeds.
7709 * Protocols::                    External access to Emacs and Org.
7710 * Refile and Copy::              Moving/copying a tree from one place to another.
7711 * Archiving::                    What to do with finished products.
7712 @end menu
7714 @node Capture
7715 @section Capture
7717 @cindex capture
7719 Capture lets you quickly store notes with little interruption of your
7720 work flow.  Org's method for capturing new items is heavily inspired
7721 by John Wiegley's excellent Remember package.
7723 @menu
7724 * Setting up capture::           Where notes will be stored.
7725 * Using capture::                Commands to invoke and terminate capture.
7726 * Capture templates::            Define the outline of different note types.
7727 @end menu
7729 @node Setting up capture
7730 @subsection Setting up capture
7732 The following customization sets a default target file for notes.
7734 @vindex org-default-notes-file
7735 @lisp
7736 (setq org-default-notes-file (concat org-directory "/notes.org"))
7737 @end lisp
7739 You may also define a global key for capturing new material (see
7740 @ref{Activation}).
7742 @node Using capture
7743 @subsection Using capture
7745 @table @asis
7746 @item @kbd{M-x org-capture} (@code{org-capture})
7747 @findex org-capture
7748 @cindex date tree
7749 Display the capture templates menu.  If you have templates
7750 defined (see @ref{Capture templates}), it offers these templates for
7751 selection or use a new Org outline node as the default template.
7752 It inserts the template into the target file and switch to an
7753 indirect buffer narrowed to this new node.  You may then insert
7754 the information you want.
7756 @item @kbd{C-c C-c} (@code{org-capture-finalize})
7757 @kindex C-c C-c @r{(Capture buffer)}
7758 @findex org-capture-finalize
7759 Once you have finished entering information into the capture
7760 buffer, @kbd{C-c C-c} returns you to the window
7761 configuration before the capture process, so that you can resume
7762 your work without further distraction.  When called with a prefix
7763 argument, finalize and then jump to the captured item.
7765 @item @kbd{C-c C-w} (@code{org-capture-refile})
7766 @kindex C-c C-w @r{(Capture buffer)}
7767 @findex org-capture-refile
7768 Finalize the capture process by refiling the note to a different
7769 place (see @ref{Refile and Copy}).  Please realize that this is
7770 a normal refiling command that will be executed---so the cursor
7771 position at the moment you run this command is important.  If you
7772 have inserted a tree with a parent and children, first move the
7773 cursor back to the parent.  Any prefix argument given to this
7774 command is passed on to the @code{org-refile} command.
7776 @item @kbd{C-c C-k} (@code{org-capture-kill})
7777 @kindex C-c C-k @r{(Capture buffer)}
7778 @findex org-capture-kill
7779 Abort the capture process and return to the previous state.
7780 @end table
7782 @kindex k c @r{(Agenda)}
7783 You can also call @code{org-capture} in a special way from the agenda,
7784 using the @kbd{k c} key combination.  With this access, any
7785 timestamps inserted by the selected capture template defaults to the
7786 cursor date in the agenda, rather than to the current date.
7788 To find the locations of the last stored capture, use @code{org-capture}
7789 with prefix commands:
7791 @table @asis
7792 @item @kbd{C-u M-x org-capture}
7793 Visit the target location of a capture template.  You get to
7794 select the template in the usual way.
7796 @item @kbd{C-u C-u M-x org-capture}
7797 Visit the last stored capture item in its buffer.
7798 @end table
7800 @vindex org-capture-bookmark
7801 @vindex org-capture-last-stored
7802 You can also jump to the bookmark @code{org-capture-last-stored}, which is
7803 automatically created unless you set @code{org-capture-bookmark} to @code{nil}.
7805 To insert the capture at point in an Org buffer, call @code{org-capture}
7806 with a @code{C-0} prefix argument.
7808 @node Capture templates
7809 @subsection Capture templates
7811 @cindex templates, for Capture
7813 You can use templates for different types of capture items, and for
7814 different target locations.  The easiest way to create such templates
7815 is through the customize interface.
7817 @table @asis
7818 @item @kbd{C}
7819 @kindex C @r{(Capture menu}
7820 @vindex org-capture-templates
7821 Customize the variable @code{org-capture-templates}.
7822 @end table
7824 Before we give the formal description of template definitions, let's
7825 look at an example.  Say you would like to use one template to create
7826 general TODO entries, and you want to put these entries under the
7827 heading @samp{Tasks} in your file @samp{~/org/gtd.org}.  Also, a date tree in
7828 the file @samp{journal.org} should capture journal entries.  A possible
7829 configuration would look like:
7831 @lisp
7832 (setq org-capture-templates
7833       '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
7834          "* TODO %?\n  %i\n  %a")
7835         ("j" "Journal" entry (file+datetree "~/org/journal.org")
7836          "* %?\nEntered on %U\n  %i\n  %a")))
7837 @end lisp
7839 @noindent
7840 If you then press @kbd{t} from the capture menu, Org will prepare
7841 the template for you like this:
7843 @example
7844 * TODO
7845   [[file:LINK TO WHERE YOU INITIATED CAPTURE]]
7846 @end example
7848 @noindent
7849 During expansion of the template, @code{%a} has been replaced by a link to
7850 the location from where you called the capture command.  This can be
7851 extremely useful for deriving tasks from emails, for example.  You
7852 fill in the task definition, press @kbd{C-c C-c} and Org returns
7853 you to the same place where you started the capture process.
7855 To define special keys to capture to a particular template without
7856 going through the interactive template selection, you can create your
7857 key binding like this:
7859 @lisp
7860 (define-key global-map "\C-cx"
7861   (lambda () (interactive) (org-capture nil "x")))
7862 @end lisp
7864 @menu
7865 * Template elements::            What is needed for a complete template entry.
7866 * Template expansion::           Filling in information about time and context.
7867 * Templates in contexts::        Only show a template in a specific context.
7868 @end menu
7870 @node Template elements
7871 @subsubsection Template elements
7873 Now lets look at the elements of a template definition.  Each entry in
7874 @code{org-capture-templates} is a list with the following items:
7876 @table @asis
7877 @item keys
7878 The keys that selects the template, as a string, characters only,
7879 for example @samp{"a"}, for a template to be selected with a single
7880 key, or @samp{"bt"} for selection with two keys.  When using several
7881 keys, keys using the same prefix key must be sequential in the
7882 list and preceded by a 2-element entry explaining the prefix key,
7883 for example:
7885 @lisp
7886 ("b" "Templates for marking stuff to buy")
7887 @end lisp
7889 @noindent
7890 If you do not define a template for the @kbd{C} key, this
7891 key opens the Customize buffer for this complex variable.
7893 @item description
7894 A short string describing the template, shown during selection.
7896 @item type
7897 The type of entry, a symbol.  Valid values are:
7899 @table @asis
7900 @item @code{entry}
7901 An Org mode node, with a headline.  Will be filed as the child
7902 of the target entry or as a top-level entry.  The target file
7903 should be an Org file.
7905 @item @code{item}
7906 A plain list item, placed in the first plain list at the
7907 target location.  Again the target file should be an Org
7908 file.
7910 @item @code{checkitem}
7911 A checkbox item.  This only differs from the plain list item
7912 by the default template.
7914 @item @code{table-line}
7915 A new line in the first table at the target location.  Where
7916 exactly the line will be inserted depends on the properties
7917 @code{:prepend} and @code{:table-line-pos} (see below).
7919 @item @code{plain}
7920 Text to be inserted as it is.
7921 @end table
7923 @item target
7924 @vindex org-default-notes-file
7925 @vindex org-directory
7926 Specification of where the captured item should be placed.  In
7927 Org files, targets usually define a node.  Entries will become
7928 children of this node.  Other types will be added to the table or
7929 list in the body of this node.  Most target specifications
7930 contain a file name.  If that file name is the empty string, it
7931 defaults to @code{org-default-notes-file}.  A file can also be given
7932 as a variable or as a function called with no argument.  When an
7933 absolute path is not specified for a target, it is taken as
7934 relative to @code{org-directory}.
7936 Valid values are:
7938 @table @asis
7939 @item @samp{(file "path/to/file")}
7940 Text will be placed at the beginning or end of that file.
7942 @item @samp{(id "id of existing org entry")}
7943 Filing as child of this entry, or in the body of the entry.
7945 @item @samp{(file+headline "filename" "node headline")}
7946 Fast configuration if the target heading is unique in the file.
7948 @item @samp{(file+olp "filename" "Level 1 heading" "Level 2" ...)}
7949 For non-unique headings, the full path is safer.
7951 @item @samp{(file+regexp "filename" "regexp to find location")}
7952 Use a regular expression to position the cursor.
7954 @item @samp{(file+olp+datetree "filename" [ "Level 1 heading" ...])}
7955 This target@footnote{Org used to offer four different targets for date/week tree
7956 capture.  Now, Org automatically translates these to use
7957 @code{file+olp+datetree}, applying the @code{:time-prompt} and @code{:tree-type}
7958 properties.  Please rewrite your date/week-tree targets using
7959 @code{file+olp+datetree} since the older targets are now deprecated.} creates a heading in a date tree@footnote{A date tree is an outline structure with years on the highest
7960 level, months or ISO weeks as sublevels and then dates on the lowest
7961 level.  Tags are allowed in the tree structure.} for
7962 today's date.  If the optional outline path is given, the tree
7963 will be built under the node it is pointing to, instead of at
7964 top level.  Check out the @code{:time-prompt} and @code{:tree-type}
7965 properties below for additional options.
7967 @item @code{(file+function "filename" function-finding-location)}
7968 A function to find the right location in the file.
7970 @item @code{(clock)}
7971 File to the entry that is currently being clocked.
7973 @item @code{(function function-finding-location)}
7974 Most general way: write your own function which both visits the
7975 file and moves point to the right location.
7976 @end table
7978 @item template
7979 The template for creating the capture item.  If you leave this
7980 empty, an appropriate default template will be used.  Otherwise
7981 this is a string with escape codes, which will be replaced
7982 depending on time and context of the capture call.  The string
7983 with escapes may be loaded from a template file, using the
7984 special syntax @samp{(file "template filename")}.  See below for more
7985 details.
7987 @item properties
7988 The rest of the entry is a property list of additional options.
7989 Recognized properties are:
7991 @table @asis
7992 @item @code{:prepend}
7993 Normally new captured information will be appended at the
7994 target location (last child, last table line, last list item,
7995 @dots{}).  Setting this property changes that.
7997 @item @code{:immediate-finish}
7998 When set, do not offer to edit the information, just file it
7999 away immediately.  This makes sense if the template only needs
8000 information that can be added automatically.
8002 @item @code{:empty-lines}
8003 Set this to the number of lines to insert before and after the
8004 new item.  Default 0, and the only other common value is 1.
8006 @item @code{:clock-in}
8007 Start the clock in this item.
8009 @item @code{:clock-keep}
8010 Keep the clock running when filing the captured entry.
8012 @item @code{:clock-resume}
8013 If starting the capture interrupted a clock, restart that clock
8014 when finished with the capture.  Note that @code{:clock-keep} has
8015 precedence over @code{:clock-resume}.  When setting both to
8016 non-@code{nil}, the current clock will run and the previous one will
8017 not be resumed.
8019 @item @code{:time-prompt}
8020 Prompt for a date/time to be used for date/week trees and when
8021 filling the template.  Without this property, capture uses the
8022 current date and time.  Even if this property has not been set,
8023 you can force the same behavior by calling @code{org-capture} with
8024 a @kbd{C-1} prefix argument.
8026 @item @code{:tree-type}
8027 When @code{week}, make a week tree instead of the month tree, i.e.,
8028 place the headings for each day under a heading with the
8029 current ISO week.
8031 @item @code{:unnarrowed}
8032 Do not narrow the target buffer, simply show the full buffer.  Default
8033 is to narrow it so that you only see the new material.
8035 @item @code{:table-line-pos}
8036 Specification of the location in the table where the new line
8037 should be inserted.  It should be a string like @samp{II-3} meaning
8038 that the new line should become the third line before the
8039 second horizontal separator line.
8041 @item @code{:kill-buffer}
8042 If the target file was not yet visited when capture was invoked, kill
8043 the buffer again after capture is completed.
8044 @end table
8045 @end table
8047 @node Template expansion
8048 @subsubsection Template expansion
8050 In the template itself, special ``%-escapes''@footnote{If you need one of these sequences literally, escape the @samp{%}
8051 with a backslash.} allow dynamic
8052 insertion of content.  The templates are expanded in the order given
8053 here:
8055 @table @asis
8056 @item @code{%[FILE]}
8057 Insert the contents of the file given by @var{FILE}.
8059 @item @code{%(SEXP)}
8060 Evaluate Elisp SEXP and replace with the result.  The
8061 @var{SEXP} must return a string.
8063 @item @code{%<FORMAT>}
8064 The result of format-time-string on the @var{FORMAT}
8065 specification.
8067 @item @code{%t}
8068 Timestamp, date only.
8070 @item @code{%T}
8071 Timestamp, with date and time.
8073 @item @code{%u}, @code{%U}
8074 Like @code{%t}, @code{%T} above, but inactive timestamps.
8076 @item @code{%i}
8077 Initial content, the region when capture is called while the
8078 region is active.  The entire text will be indented like @code{%i}
8079 itself.
8081 @item @code{%a}
8082 Annotation, normally the link created with @code{org-store-link}.
8084 @item @code{%A}
8085 Like @code{%a}, but prompt for the description part.
8087 @item @code{%l}
8088 Like @code{%a}, but only insert the literal link.
8090 @item @code{%c}
8091 Current kill ring head.
8093 @item @code{%x}
8094 Content of the X clipboard.
8096 @item @code{%k}
8097 Title of the currently clocked task.
8099 @item @code{%K}
8100 Link to the currently clocked task.
8102 @item @code{%n}
8103 User name (taken from @code{user-full-name}).
8105 @item @code{%f}
8106 File visited by current buffer when org-capture was called.
8108 @item @code{%F}
8109 Full path of the file or directory visited by current buffer.
8111 @item @code{%:keyword}
8112 Specific information for certain link types, see below.
8114 @item @code{%^g}
8115 Prompt for tags, with completion on tags in target file.
8117 @item @code{%^G}
8118 Prompt for tags, with completion all tags in all agenda files.
8120 @item @code{%^t}
8121 Like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}.  You may
8122 define a prompt like @code{%^@{Birthday@}t}.
8124 @item @code{%^C}
8125 Interactive selection of which kill or clip to use.
8127 @item @code{%^L}
8128 Like @code{%^C}, but insert as link.
8130 @item @code{%^@{PROP@}p}
8131 Prompt the user for a value for property PROP.
8133 @item @code{%^@{PROMPT@}}
8134 Prompt the user for a string and replace this sequence with it.
8135 You may specify a default value and a completion table with
8136 @code{%^@{prompt|default|completion2|completion3...@}}.  The arrow keys
8137 access a prompt-specific history.
8139 @item @code{%\n}
8140 Insert the text entered at the Nth @code{%^@{PROMPT@}}, where N is
8141 a number, starting from 1.
8143 @item @code{%?}
8144 After completing the template, position cursor here.
8145 @end table
8147 @noindent
8148 @vindex org-store-link-props
8149 For specific link types, the following keywords are defined@footnote{If you define your own link types (see @ref{Adding Hyperlink Types}), any property you store with @code{org-store-link-props} can be
8150 accessed in capture templates in a similar way.}:
8152 @vindex org-from-is-user-regexp
8153 @multitable {aaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
8154 @headitem Link type
8155 @tab Available keywords
8156 @item bbdb
8157 @tab @code{%:name}, @code{%:company}
8158 @item irc
8159 @tab @code{%:server}, @code{%:port}, @code{%:nick}
8160 @item mh, rmail
8161 @tab @code{%:type}, @code{%:subject}, @code{%:message-id}
8162 @item 
8163 @tab @code{%:from}, @code{%:fromname}, @code{%:fromaddress}
8164 @item 
8165 @tab @code{%:to}, @code{%:toname}, @code{%:toaddress}
8166 @item 
8167 @tab @code{%:date} (message date header field)
8168 @item 
8169 @tab @code{%:date-timestamp} (date as active timestamp)
8170 @item 
8171 @tab @code{%:date-timestamp-inactive} (date as inactive timestamp)
8172 @item 
8173 @tab @code{%:fromto} (either ``to NAME'' or ``from NAME'')@footnote{This is always the other, not the user.  See the variable
8174 @code{org-from-is-user-regexp}.}
8175 @item gnus
8176 @tab @code{%:group}, for messages also all email fields
8177 @item w3, w3m
8178 @tab @code{%:url}
8179 @item info
8180 @tab @code{%:file}, @code{%:node}
8181 @item calendar
8182 @tab @code{%:date}
8183 @item org-protocol
8184 @tab @code{%:link}, @code{%:description}, @code{%:annotation}
8185 @end multitable
8187 @node Templates in contexts
8188 @subsubsection Templates in contexts
8190 @vindex org-capture-templates-contexts
8191 To control whether a capture template should be accessible from
8192 a specific context, you can customize
8193 @code{org-capture-templates-contexts}.  Let's say, for example, that you
8194 have a capture template ``p'' for storing Gnus emails containing
8195 patches.  Then you would configure this option like this:
8197 @lisp
8198 (setq org-capture-templates-contexts
8199       '(("p" (in-mode . "message-mode"))))
8200 @end lisp
8202 You can also tell that the command key @kbd{p} should refer to
8203 another template.  In that case, add this command key like this:
8205 @lisp
8206 (setq org-capture-templates-contexts
8207       '(("p" "q" (in-mode . "message-mode"))))
8208 @end lisp
8210 See the docstring of the variable for more information.
8212 @node Attachments
8213 @section Attachments
8215 @cindex attachments
8216 @vindex org-attach-directory
8218 It is often useful to associate reference material with an outline
8219 node/task.  Small chunks of plain text can simply be stored in the
8220 subtree of a project.  Hyperlinks (see @ref{Hyperlinks}) can establish
8221 associations with files that live elsewhere on your computer or in the
8222 cloud, like emails or source code files belonging to a project.
8223 Another method is @emph{attachments}, which are files located in
8224 a directory belonging to an outline node.  Org uses directories named
8225 by the unique ID of each entry.  These directories are located in the
8226 @code{data} directory which lives in the same directory where your Org file
8227 lives@footnote{If you move entries or Org files from one directory to
8228 another, you may want to configure @code{org-attach-directory} to contain
8229 an absolute path.}.  If you initialize this directory with @samp{git init}, Org
8230 automatically commits changes when it sees them.  The attachment
8231 system has been contributed to Org by John Wiegley.
8233 In cases where it seems better to do so, you can attach a directory of
8234 your choice to an entry.  You can also make children inherit the
8235 attachment directory from a parent, so that an entire subtree uses the
8236 same attached directory.
8238 @noindent
8239 The following commands deal with attachments:
8241 @table @asis
8242 @item @kbd{C-c C-a} (@code{org-attach})
8243 @kindex C-c C-a
8244 @findex org-attach
8245 The dispatcher for commands related to the attachment system.
8246 After these keys, a list of commands is displayed and you must
8247 press an additional key to select a command:
8249 @table @asis
8250 @item @kbd{a} (@code{org-attach-attach})
8251 @kindex C-c C-a a
8252 @findex org-attach-attach
8253 @vindex org-attach-method
8254 Select a file and move it into the task's attachment
8255 directory.  The file is copied, moved, or linked, depending
8256 on @code{org-attach-method}.  Note that hard links are not
8257 supported on all systems.
8259 @item @kbd{c}/@kbd{m}/@kbd{l}
8260 @kindex C-c C-a c
8261 @kindex C-c C-a m
8262 @kindex C-c C-a l
8263 Attach a file using the copy/move/link method.  Note that
8264 hard links are not supported on all systems.
8266 @item @kbd{n} (@code{org-attach-new})
8267 @kindex C-c C-a n
8268 @findex org-attach-new
8269 Create a new attachment as an Emacs buffer.
8271 @item @kbd{z} (@code{org-attach-sync})
8272 @kindex C-c C-a z
8273 @findex org-attach-sync
8274 Synchronize the current task with its attachment directory, in case
8275 you added attachments yourself.
8277 @item @kbd{o} (@code{org-attach-open})
8278 @kindex C-c C-a o
8279 @findex org-attach-open
8280 @vindex org-file-apps
8281 Open current task's attachment.  If there is more than one,
8282 prompt for a file name first.  Opening follows the rules set
8283 by @code{org-file-apps}.  For more details, see the information
8284 on following hyperlinks (see @ref{Handling Links}).
8286 @item @kbd{O} (@code{org-attach-open-in-emacs})
8287 @kindex C-c C-a O
8288 @findex org-attach-open-in-emacs
8289 Also open the attachment, but force opening the file in
8290 Emacs.
8292 @item @kbd{f} (@code{org-attach-reveal})
8293 @kindex C-c C-a f
8294 @findex org-attach-reveal
8295 Open the current task's attachment directory.
8297 @item @kbd{F} (@code{org-attach-reveal-in-emacs})
8298 @kindex C-c C-a F
8299 @findex org-attach-reveal-in-emacs
8300 Also open the directory, but force using Dired in Emacs.
8302 @item @kbd{d} (@code{org-attach-delete-one})
8303 @kindex C-c C-a d
8304 Select and delete a single attachment.
8306 @item @kbd{D} (@code{org-attach-delete-all})
8307 @kindex C-c C-a D
8308 Delete all of a task's attachments.  A safer way is to open
8309 the directory in Dired and delete from there.
8311 @item @kbd{s} (@code{org-attach-set-directory})
8312 @kindex C-c C-a s
8313 @cindex @samp{ATTACH_DIR}, property
8314 Set a specific directory as the entry's attachment
8315 directory.  This works by putting the directory path into
8316 the @samp{ATTACH_DIR} property.
8318 @item @kbd{i} (@code{org-attach-set-inherit})
8319 @kindex C-c C-a i
8320 @cindex @samp{ATTACH_DIR_INHERIT}, property
8321 Set the @samp{ATTACH_DIR_INHERIT} property, so that children use
8322 the same directory for attachments as the parent does.
8323 @end table
8324 @end table
8326 @cindex attach from Dired
8327 @findex org-attach-dired-to-subtree
8328 It is possible to attach files to a subtree from a Dired buffer.  To
8329 use this feature, have one window in Dired mode containing the file(s)
8330 to be attached and another window with point in the subtree that shall
8331 get the attachments.  In the Dired window, with point on a file,
8332 @kbd{M-x org-attach-dired-to-subtree} attaches the file to the
8333 subtree using the attachment method set by variable
8334 @code{org-attach-method}.  When files are marked in the Dired window then
8335 all marked files get attached.
8337 Add the following lines to the Emacs init file to have @kbd{C-c C-x a} attach files in Dired buffers.
8339 @lisp
8340 (add-hook 'dired-mode-hook
8341           (lambda ()
8342             (define-key dired-mode-map
8343               (kbd "C-c C-x a")
8344               #'org-attach-dired-to-subtree))))
8345 @end lisp
8347 The following code shows how to bind the previous command with
8348 a specific attachment method.
8350 @lisp
8351 (add-hook 'dired-mode-hook
8352           (lambda ()
8353             (define-key dired-mode-map (kbd "C-c C-x c")
8354               (lambda ()
8355                 (interactive)
8356                 (let ((org-attach-method 'cp))
8357                   (call-interactively #'org-attach-dired-to-subtree))))))
8358 @end lisp
8360 @node RSS Feeds
8361 @section RSS Feeds
8363 @cindex RSS feeds
8364 @cindex Atom feeds
8366 Org can add and change entries based on information found in RSS feeds
8367 and Atom feeds.  You could use this to make a task out of each new
8368 podcast in a podcast feed.  Or you could use a phone-based
8369 note-creating service on the web to import tasks into Org.  To access
8370 feeds, configure the variable @code{org-feed-alist}.  The docstring of this
8371 variable has detailed information.  With the following
8373 @lisp
8374 (setq org-feed-alist
8375       '(("Slashdot"
8376          "http://rss.slashdot.org/Slashdot/slashdot"
8377          "~/txt/org/feeds.org" "Slashdot Entries")))
8378 @end lisp
8380 @noindent
8381 new items from the feed provided by @samp{rss.slashdot.org} result in new
8382 entries in the file @samp{~/org/feeds.org} under the heading @samp{Slashdot
8383 Entries}, whenever the following command is used:
8385 @table @asis
8386 @item @kbd{C-c C-x g} (@code{org-feed-update-all})
8387 @kindex C-c C-x g
8388 Collect items from the feeds configured in @code{org-feed-alist} and
8389 act upon them.
8391 @item @kbd{C-c C-x G} (@code{org-feed-goto-inbox})
8392 @kindex C-c C-x G
8393 Prompt for a feed name and go to the inbox configured for this feed.
8394 @end table
8396 Under the same headline, Org creates a drawer @samp{FEEDSTATUS} in which it
8397 stores information about the status of items in the feed, to avoid
8398 adding the same item several times.
8400 For more information, including how to read atom feeds, see
8401 @samp{org-feed.el} and the docstring of @code{org-feed-alist}.
8403 @node Protocols
8404 @section Protocols for External Access
8406 @cindex protocols, for external access
8408 Org protocol is a means to trigger custom actions in Emacs from
8409 external applications.  Any application that supports calling external
8410 programs with an URL as argument may be used with this functionality.
8411 For example, you can configure bookmarks in your web browser to send
8412 a link to the current page to Org and create a note from it using
8413 capture (see @ref{Capture}).  You can also create a bookmark that tells
8414 Emacs to open the local source file of a remote website you are
8415 browsing.
8417 @cindex Org protocol, set-up
8418 @cindex Installing Org protocol
8419 In order to use Org protocol from an application, you need to register
8420 @samp{org-protocol://} as a valid scheme-handler.  External calls are
8421 passed to Emacs through the @samp{emacsclient} command, so you also need to
8422 ensure an Emacs server is running.  More precisely, when the
8423 application calls
8425 @example
8426 emacsclient org-protocol://PROTOCOL?key1=val1&key2=val2
8427 @end example
8429 @noindent
8430 Emacs calls the handler associated to @var{PROTOCOL} with
8431 argument @samp{(:key1 val1 :key2 val2)}.
8433 @cindex protocol, new protocol
8434 @cindex defining new protocols
8435 Org protocol comes with three predefined protocols, detailed in the
8436 following sections.  Configure @code{org-protocol-protocol-alist} to define
8437 your own.
8439 @menu
8440 * @code{store-link} protocol::   Store a link, push URL to kill-ring.
8441 * @code{capture} protocol::      Fill a buffer with external information.
8442 * @code{open-source} protocol::  Edit published contents.
8443 @end menu
8445 @node @code{store-link} protocol
8446 @subsection @code{store-link} protocol
8448 @cindex store-link protocol
8449 @cindex protocol, store-link
8451 Using @code{store-link} handler, you can copy links, insertable through
8452 @kbd{M-x org-insert-link} or yanking thereafter.  More precisely,
8453 the command
8455 @example
8456 emacsclient org-protocol://store-link?url=URL&title=TITLE
8457 @end example
8459 @noindent
8460 stores the following link:
8462 @example
8463 [[URL][TITLE]]
8464 @end example
8466 In addition, @var{URL} is pushed on the kill-ring for yanking.
8467 You need to encode @var{URL} and @var{TITLE} if they contain
8468 slashes, and probably quote those for the shell.
8470 To use this feature from a browser, add a bookmark with an arbitrary
8471 name, e.g., @samp{Org: store-link} and enter this as @emph{Location}:
8473 @example
8474 javascript:location.href='org-protocol://store-link?url='+
8475       encodeURIComponent(location.href);
8476 @end example
8478 @node @code{capture} protocol
8479 @subsection @code{capture} protocol
8481 @cindex capture protocol
8482 @cindex protocol, capture
8484 Activating ``capture'' handler pops up a @samp{Capture} buffer and fills the
8485 capture template associated to the @samp{X} key with them.
8487 @example
8488 emacsclient org-protocol://capture?template=X?url=URL?title=TITLE?body=BODY
8489 @end example
8491 To use this feature, add a bookmark with an arbitrary name, e.g.
8492 @samp{Org: capture} and enter this as @samp{Location}:
8494 @example
8495 javascript:location.href='org-protocol://capture?template=x'+
8496       '&url='+encodeURIComponent(window.location.href)+
8497       '&title='+encodeURIComponent(document.title)+
8498       '&body='+encodeURIComponent(window.getSelection());
8499 @end example
8501 @vindex org-protocol-default-template-key
8502 The result depends on the capture template used, which is set in the
8503 bookmark itself, as in the example above, or in
8504 @code{org-protocol-default-template-key}.
8506 The following template placeholders are available:
8508 @example
8509 %:link          The URL
8510 %:description   The webpage title
8511 %:annotation    Equivalent to [[%:link][%:description]]
8512 %i              The selected text
8513 @end example
8515 @node @code{open-source} protocol
8516 @subsection @code{open-source} protocol
8518 @cindex open-source protocol
8519 @cindex protocol, open-source
8521 The @code{open-source} handler is designed to help with editing local
8522 sources when reading a document.  To that effect, you can use
8523 a bookmark with the following location:
8525 @example
8526 javascript:location.href='org-protocol://open-source?&url='+
8527       encodeURIComponent(location.href)
8528 @end example
8530 @vindex org-protocol-project-alist
8531 The variable @code{org-protocol-project-alist} maps URLs to local file
8532 names, by stripping URL parameters from the end and replacing the
8533 @code{:base-url} with @code{:working-directory} and @code{:online-suffix} with
8534 @code{:working-suffix}.  For example, assuming you own a local copy of
8535 @samp{https://orgmode.org/worg/} contents at @samp{/home/user/worg}, you can set
8536 @code{org-protocol-project-alist} to the following
8538 @lisp
8539 (setq org-protocol-project-alist
8540       '(("Worg"
8541          :base-url "https://orgmode.org/worg/"
8542          :working-directory "/home/user/worg/"
8543          :online-suffix ".html"
8544          :working-suffix ".org")))
8545 @end lisp
8547 @noindent
8548 If you are now browsing
8549 @samp{https://orgmode.org/worg/org-contrib/org-protocol.html} and find
8550 a typo or have an idea about how to enhance the documentation, simply
8551 click the bookmark and start editing.
8553 @cindex rewritten URL in open-source protocol
8554 @cindex protocol, open-source rewritten URL
8555 However, such mapping may not yield the desired results.  Suppose you
8556 maintain an online store located at @samp{http://example.com/}.  The local
8557 sources reside in @samp{/home/user/example/}.  It is common practice to
8558 serve all products in such a store through one file and rewrite URLs
8559 that do not match an existing file on the server.  That way, a request
8560 to @samp{http://example.com/print/posters.html} might be rewritten on the
8561 server to something like
8562 @samp{http://example.com/shop/products.php/posters.html.php}.  The
8563 @code{open-source} handler probably cannot find a file named
8564 @samp{/home/user/example/print/posters.html.php} and fails.
8566 Such an entry in @code{org-protocol-project-alist} may hold an additional
8567 property @code{:rewrites}.  This property is a list of cons cells, each of
8568 which maps a regular expression to a path relative to the
8569 @code{:working-directory}.
8571 Now map the URL to the path @samp{/home/user/example/products.php} by
8572 adding @code{:rewrites} rules like this:
8574 @lisp
8575 (setq org-protocol-project-alist
8576       '(("example.com"
8577          :base-url "http://example.com/"
8578          :working-directory "/home/user/example/"
8579          :online-suffix ".php"
8580          :working-suffix ".php"
8581          :rewrites (("example.com/print/" . "products.php")
8582                     ("example.com/$" . "index.php")))))
8583 @end lisp
8585 @noindent
8586 Since @samp{example.com/$} is used as a regular expression, it maps
8587 @samp{http://example.com/}, @samp{https://example.com},
8588 @samp{http://www.example.com/} and similar to
8589 @samp{/home/user/example/index.php}.
8591 The @code{:rewrites} rules are searched as a last resort if and only if no
8592 existing file name is matched.
8594 @cindex protocol, open-source, set-up mapping
8595 @cindex mappings in open-source protocol
8596 @findex org-protocol-create
8597 @findex org-protocol-create-for-org
8598 Two functions can help you filling @code{org-protocol-project-alist} with
8599 valid contents: @code{org-protocol-create} and
8600 @code{org-protocol-create-for-org}.  The latter is of use if you're editing
8601 an Org file that is part of a publishing project.
8603 @node Refile and Copy
8604 @section Refile and Copy
8606 @cindex refiling notes
8607 @cindex copying notes
8609 When reviewing the captured data, you may want to refile or to copy
8610 some of the entries into a different list, for example into a project.
8611 Cutting, finding the right location, and then pasting the note is
8612 cumbersome.  To simplify this process, you can use the following
8613 special command:
8615 @table @asis
8616 @item @kbd{C-c M-w} (@code{org-copy})
8617 @kindex C-c M-w
8618 @findex org-copy
8619 Copying works like refiling, except that the original note is not
8620 deleted.
8622 @item @kbd{C-c C-w} (@code{org-refile})
8623 @kindex C-c C-w
8624 @findex org-refile
8625 @vindex org-reverse-note-order
8626 @vindex org-refile-targets
8627 @vindex org-refile-use-outline-path
8628 @vindex org-outline-path-complete-in-steps
8629 @vindex org-refile-allow-creating-parent-nodes
8630 @vindex org-log-refile
8631 Refile the entry or region at point.  This command offers
8632 possible locations for refiling the entry and lets you select one
8633 with completion.  The item (or all items in the region) is filed
8634 below the target heading as a subitem.  Depending on
8635 @code{org-reverse-note-order}, it is either the first or last subitem.
8637 By default, all level 1 headlines in the current buffer are
8638 considered to be targets, but you can have more complex
8639 definitions across a number of files.  See the variable
8640 @code{org-refile-targets} for details.  If you would like to select
8641 a location via a file-path-like completion along the outline
8642 path, see the variables @code{org-refile-use-outline-path} and
8643 @code{org-outline-path-complete-in-steps}.  If you would like to be
8644 able to create new nodes as new parents for refiling on the fly,
8645 check the variable @code{org-refile-allow-creating-parent-nodes}.
8646 When the variable @code{org-log-refile}@footnote{Note the corresponding @samp{STARTUP} options @samp{logrefile},
8647 @samp{lognoterefile}, and @samp{nologrefile}.} is set, a timestamp or
8648 a note is recorded whenever an entry is refiled.
8650 @item @kbd{C-u C-c C-w}
8651 @kindex C-u C-c C-w
8652 Use the refile interface to jump to a heading.
8654 @item @kbd{C-u C-u C-c C-w} (@code{org-refile-goto-last-stored})
8655 @kindex C-u C-u C-c C-w
8656 @findex org-refile-goto-last-stored
8657 Jump to the location where @code{org-refile} last moved a tree to.
8659 @item @kbd{C-2 C-c C-w}
8660 @kindex C-2 C-c C-w
8661 Refile as the child of the item currently being clocked.
8663 @item @kbd{C-3 C-c C-w}
8664 @kindex C-3 C-c C-w
8665 @vindex org-refile-keep
8666 Refile and keep the entry in place.  Also see @code{org-refile-keep}
8667 to make this the default behavior, and beware that this may
8668 result in duplicated @code{ID} properties.
8670 @item @kbd{C-0 C-c C-w} or @kbd{C-u C-u C-u C-c C-w} (@code{org-refile-cache-clear})
8671 @kindex C-u C-u C-u C-c C-w
8672 @kindex C-0 C-c C-w
8673 @findex org-refile-cache-clear
8674 @vindex org-refile-use-cache
8675 Clear the target cache.  Caching of refile targets can be turned
8676 on by setting @code{org-refile-use-cache}.  To make the command see
8677 new possible targets, you have to clear the cache with this
8678 command.
8679 @end table
8681 @node Archiving
8682 @section Archiving
8684 @cindex archiving
8686 When a project represented by a (sub)tree is finished, you may want to
8687 move the tree out of the way and to stop it from contributing to the
8688 agenda.  Archiving is important to keep your working files compact and
8689 global searches like the construction of agenda views fast.
8691 @table @asis
8692 @item @kbd{C-c C-x C-a} (@code{org-archive-subtree-default})
8693 @kindex C-c C-x C-a
8694 @findex org-archive-subtree-default
8695 @vindex org-archive-default-command
8696 Archive the current entry using the command specified in the
8697 variable @code{org-archive-default-command}.
8698 @end table
8700 @menu
8701 * Moving subtrees::              Moving a tree to an archive file.
8702 * Internal archiving::           Switch off a tree but keep it in the file.
8703 @end menu
8705 @node Moving subtrees
8706 @subsection Moving a tree to an archive file
8708 @cindex external archiving
8710 The most common archiving action is to move a project tree to another
8711 file, the archive file.
8713 @table @asis
8714 @item @kbd{C-c C-x C-s} or short @kbd{C-c $} (@code{org-archive-subtree})
8715 @kindex C-c C-x C-s
8716 @kindex C-c $
8717 @findex org-archive-subtree
8718 @vindex org-archive-location
8719 Archive the subtree starting at the cursor position to the
8720 location given by @code{org-archive-location}.
8722 @item @kbd{C-u C-c C-x C-s}
8723 @kindex C-u C-c C-x C-s
8724 Check if any direct children of the current headline could be
8725 moved to the archive.  To do this, check each subtree for open
8726 TODO entries.  If none is found, the command offers to move it to
8727 the archive location.  If the cursor is @emph{not} on a headline when
8728 this command is invoked, check level 1 trees.
8730 @item @kbd{C-u C-u C-c C-x C-s}
8731 @kindex C-u C-u C-c C-x C-s
8732 As above, but check subtree for timestamps instead of TODO
8733 entries.  The command offers to archive the subtree if it @emph{does}
8734 contain a timestamp, and that timestamp is in the past.
8735 @end table
8737 @cindex archive locations
8738 The default archive location is a file in the same directory as the
8739 current file, with the name derived by appending @samp{_archive} to the
8740 current file name.  You can also choose what heading to file archived
8741 items under, with the possibility to add them to a datetree in a file.
8742 For information and examples on how to specify the file and the
8743 heading, see the documentation string of the variable
8744 @code{org-archive-location}.
8746 There is also an in-buffer option for setting this variable, for
8747 example:
8749 @cindex @samp{ARCHIVE}, keyword
8750 @example
8751 #+ARCHIVE: %s_done::
8752 @end example
8754 @noindent
8755 @cindex ARCHIVE, property
8756 If you would like to have a special archive location for a single
8757 entry or a (sub)tree, give the entry an @samp{ARCHIVE} property with the
8758 location as the value (see @ref{Properties and Columns}).
8760 @vindex org-archive-save-context-info
8761 When a subtree is moved, it receives a number of special properties
8762 that record context information like the file from where the entry
8763 came, its outline path the archiving time etc.  Configure the variable
8764 @code{org-archive-save-context-info} to adjust the amount of information
8765 added.
8767 @node Internal archiving
8768 @subsection Internal archiving
8770 @cindex @samp{ARCHIVE}, tag
8771 If you want to just switch off---for agenda views---certain subtrees
8772 without moving them to a different file, you can use the @samp{ARCHIVE}
8773 tag.
8775 A headline that is marked with the @samp{ARCHIVE} tag (see @ref{Tags}) stays at
8776 its location in the outline tree, but behaves in the following way:
8778 @itemize
8779 @item
8780 @vindex org-cycle-open-archived-trees
8781 It does not open when you attempt to do so with a visibility cycling
8782 command (see @ref{Visibility Cycling}).  You can force cycling archived
8783 subtrees with @kbd{C-@key{TAB}}, or by setting the option
8784 @code{org-cycle-open-archived-trees}.  Also normal outline commands, like
8785 @code{outline-show-all}, open archived subtrees.
8787 @item
8788 @vindex org-sparse-tree-open-archived-trees
8789 During sparse tree construction (see @ref{Sparse Trees}), matches in
8790 archived subtrees are not exposed, unless you configure the option
8791 @code{org-sparse-tree-open-archived-trees}.
8793 @item
8794 @vindex org-agenda-skip-archived-trees
8795 During agenda view construction (see @ref{Agenda Views}), the content of
8796 archived trees is ignored unless you configure the option
8797 @code{org-agenda-skip-archived-trees}, in which case these trees are
8798 always included.  In the agenda you can press @kbd{v a} to get
8799 archives temporarily included.
8801 @item
8802 @vindex org-export-with-archived-trees
8803 Archived trees are not exported (see @ref{Exporting}), only the headline
8804 is.  Configure the details using the variable
8805 @code{org-export-with-archived-trees}.
8807 @item
8808 @vindex org-columns-skip-archived-trees
8809 Archived trees are excluded from column view unless the variable
8810 @code{org-columns-skip-archived-trees} is configured to @code{nil}.
8811 @end itemize
8813 The following commands help manage the @samp{ARCHIVE} tag:
8815 @table @asis
8816 @item @kbd{C-c C-x a} (@code{org-toggle-archive-tag})
8817 @kindex C-c C-x a
8818 @findex org-toggle-archive-tag
8819 Toggle the archive tag for the current headline.  When the tag is
8820 set, the headline changes to a shadowed face, and the subtree
8821 below it is hidden.
8823 @item @kbd{C-u C-c C-x a}
8824 @kindex C-u C-c C-x a
8825 Check if any direct children of the current headline should be
8826 archived.  To do this, check each subtree for open TODO entries.
8827 If none is found, the command offers to set the @samp{ARCHIVE} tag for
8828 the child.  If the cursor is @emph{not} on a headline when this
8829 command is invoked, check the level 1 trees.
8831 @item @kbd{C-@key{TAB}}, @code{org-force-cycle-archived}
8832 @kindex C-TAB
8833 Cycle a tree even if it is tagged with @samp{ARCHIVE}.
8835 @item @kbd{C-c C-x A} (@code{org-archive-to-archive-sibling})
8836 @kindex C-c C-x A
8837 @findex org-archive-to-archive-sibling
8838 Move the current entry to the @emph{Archive Sibling}.  This is
8839 a sibling of the entry with the heading @samp{Archive} and the archive
8840 tag.  The entry becomes a child of that sibling and in this way
8841 retains a lot of its original context, including inherited tags
8842 and approximate position in the outline.
8843 @end table
8845 @node Agenda Views
8846 @chapter Agenda Views
8848 @cindex agenda views
8850 Due to the way Org works, TODO items, time-stamped items, and tagged
8851 headlines can be scattered throughout a file or even a number of
8852 files.  To get an overview of open action items, or of events that are
8853 important for a particular date, this information must be collected,
8854 sorted and displayed in an organized way.
8856 Org can select items based on various criteria and display them in
8857 a separate buffer.  Seven different view types are provided:
8859 @itemize
8860 @item
8861 an @emph{agenda} that is like a calendar and shows information for
8862 specific dates,
8864 @item
8865 a @emph{TODO list} that covers all unfinished action items,
8867 @item
8868 a @emph{match view}, showings headlines based on the tags, properties,
8869 and TODO state associated with them,
8871 @item
8872 a @emph{timeline view} that shows all events in a single Org file, in
8873 time-sorted view,
8875 @item
8876 a @emph{text search view} that shows all entries from multiple files that
8877 contain specified keywords,
8879 @item
8880 a @emph{stuck projects view} showing projects that currently do not move
8881 along, and
8883 @item
8884 @emph{custom views} that are special searches and combinations of
8885 different views.
8886 @end itemize
8888 @noindent
8889 The extracted information is displayed in a special @emph{agenda buffer}.
8890 This buffer is read-only, but provides commands to visit the
8891 corresponding locations in the original Org files, and even to edit
8892 these files remotely.
8894 @vindex org-agenda-skip-comment-trees
8895 @vindex org-agenda-skip-archived-trees
8896 @cindex commented entries, in agenda views
8897 @cindex archived entries, in agenda views
8898 By default, the report ignores commented (see @ref{Comment Lines}) and
8899 archived (see @ref{Internal archiving}) entries.  You can override this by
8900 setting @code{org-agenda-skip-comment-trees} and
8901 @code{org-agenda-skip-archived-trees} to @code{nil}.
8903 @vindex org-agenda-window-setup
8904 @vindex org-agenda-restore-windows-after-quit
8905 Two variables control how the agenda buffer is displayed and whether
8906 the window configuration is restored when the agenda exits:
8907 @code{org-agenda-window-setup} and @code{org-agenda-restore-windows-after-quit}.
8909 @menu
8910 * Agenda Files::                 Files being searched for agenda information.
8911 * Agenda Dispatcher::            Keyboard access to agenda views.
8912 * Built-in Agenda Views::        What is available out of the box?
8913 * Presentation and Sorting::     How agenda items are prepared for display.
8914 * Agenda Commands::              Remote editing of Org trees.
8915 * Custom Agenda Views::          Defining special searches and views.
8916 * Exporting Agenda Views::       Writing a view to a file.
8917 * Agenda Column View::           Using column view for collected entries.
8918 @end menu
8920 @node Agenda Files
8921 @section Agenda Files
8923 @cindex agenda files
8924 @cindex files for agenda
8926 @vindex org-agenda-files
8927 The information to be shown is normally collected from all @emph{agenda
8928 files}, the files listed in the variable @code{org-agenda-files}@footnote{If the value of that variable is not a list, but a single file
8929 name, then the list of agenda files in maintained in that external
8930 file.}.
8931 If a directory is part of this list, all files with the extension
8932 @samp{.org} in this directory are part of the list.
8934 Thus, even if you only work with a single Org file, that file should
8935 be put into the list@footnote{When using the dispatcher, pressing @kbd{<} before
8936 selecting a command actually limits the command to the current file,
8937 and ignores @code{org-agenda-files} until the next dispatcher command.}.  You can customize @code{org-agenda-files},
8938 but the easiest way to maintain it is through the following commands
8940 @table @asis
8941 @item @kbd{C-c [} (@code{org-agenda-file-to-front})
8942 @kindex C-c [
8943 @findex org-agenda-file-to-front
8944 @cindex files, adding to agenda list
8945 Add current file to the list of agenda files.  The file is added
8946 to the front of the list.  If it was already in the list, it is
8947 moved to the front.  With a prefix argument, file is added/moved
8948 to the end.
8950 @item @kbd{C-c ]} (@code{org-remove-file})
8951 @kindex C-c ]
8952 @findex org-remove-file
8953 Remove current file from the list of agenda files.
8955 @item @kbd{C-'}
8956 @itemx @kbd{C-,} (@code{org-cycle-agenda-files})
8957 @kindex C-'
8958 @kindex C-,
8959 @findex org-cycle-agenda-files
8960 @cindex cycling, of agenda files
8961 Cycle through agenda file list, visiting one file after the other.
8963 @item @kbd{M-x org-switchb}
8964 @findex org-switchb
8965 Command to use an iswitchb-like interface to switch to and
8966 between Org buffers.
8967 @end table
8969 @noindent
8970 The Org menu contains the current list of files and can be used to
8971 visit any of them.
8973 If you would like to focus the agenda temporarily on a file not in
8974 this list, or on just one file in the list, or even on only a subtree
8975 in a file, then this can be done in different ways.  For a single
8976 agenda command, you may press @kbd{<} once or several times in
8977 the dispatcher (see @ref{Agenda Dispatcher}).  To restrict the agenda
8978 scope for an extended period, use the following commands:
8980 @table @asis
8981 @item @kbd{C-c C-x <} (@code{org-agenda-set-restriction-lock})
8982 @kindex C-c C-x <
8983 @findex org-agenda-set-restriction-lock
8984 Permanently restrict the agenda to the current subtree.  When
8985 called with a prefix argument, or with the cursor before the
8986 first headline in a file, set the agenda scope to the entire
8987 file.  This restriction remains in effect until removed with
8988 @kbd{C-c C-x >}, or by typing either @kbd{<} or
8989 @kbd{>} in the agenda dispatcher.  If there is a window
8990 displaying an agenda view, the new restriction takes effect
8991 immediately.
8993 @item @kbd{C-c C-x >} (@code{org-agenda-remove-restriction-lock})
8994 @kindex C-c C-x >
8995 @findex org-agenda-remove-restriction-lock
8996 Remove the permanent restriction created by @kbd{C-c C-x <}.
8997 @end table
8999 @noindent
9000 When working with @samp{speedbar.el}, you can use the following commands in
9001 the Speedbar frame:
9003 @table @asis
9004 @item @kbd{<} (@code{org-speedbar-set-agenda-restriction})
9005 @findex org-speedbar-set-agenda-restriction
9006 Permanently restrict the agenda to the item---either an Org file
9007 or a subtree in such a file---at the cursor in the Speedbar
9008 frame.  If there is a window displaying an agenda view, the new
9009 restriction takes effect immediately.
9011 @item @kbd{>} (@code{org-agenda-remove-restriction-lock})
9012 @findex org-agenda-remove-restriction-lock
9013 Lift the restriction.
9014 @end table
9016 @node Agenda Dispatcher
9017 @section The Agenda Dispatcher
9019 @cindex agenda dispatcher
9020 @cindex dispatching agenda commands
9022 The views are created through a dispatcher, accessible with @kbd{M-x org-agenda}, or, better, bound to a global key (see @ref{Activation}).
9023 It displays a menu from which an additional letter is required to
9024 execute a command.  The dispatcher offers the following default
9025 commands:
9027 @table @asis
9028 @item @kbd{a}
9029 Create the calendar-like agenda (see @ref{Weekly/daily agenda}).
9031 @item @kbd{t} or @kbd{T}
9032 Create a list of all TODO items (see @ref{Global TODO list}).
9034 @item @kbd{m} or @kbd{M}
9035 Create a list of headlines matching a given expression (see
9036 @ref{Matching tags and properties}).
9038 @item @kbd{s}
9039 @kindex s @r{(Agenda dispatcher)}
9040 Create a list of entries selected by a boolean expression of
9041 keywords and/or regular expressions that must or must not occur
9042 in the entry.
9044 @item @kbd{/}
9045 @kindex / @r{(Agenda dispatcher)}
9046 @vindex org-agenda-text-search-extra-files
9047 Search for a regular expression in all agenda files and
9048 additionally in the files listed in
9049 @code{org-agenda-text-search-extra-files}.  This uses the Emacs
9050 command @code{multi-occur}.  A prefix argument can be used to specify
9051 the number of context lines for each match, default is
9052 @enumerate
9053 @item
9054 @end enumerate
9056 @item @kbd{#} or @kbd{!}
9057 Create a list of stuck projects (see @ref{Stuck projects}).
9059 @item @kbd{<}
9060 @kindex < @r{(Agenda dispatcher)}
9061 Restrict an agenda command to the current buffer@footnote{For backward compatibility, you can also press @kbd{1} to
9062 restrict to the current buffer.}.  After
9063 pressing @kbd{<}, you still need to press the character
9064 selecting the command.
9066 @item @kbd{< <}
9067 @kindex < < @r{(Agenda dispatcher)}
9068 If there is an active region, restrict the following agenda
9069 command to the region.  Otherwise, restrict it to the current
9070 subtree@footnote{For backward compatibility, you can also press @kbd{0} to
9071 restrict to the current region/subtree.}.  After pressing @kbd{< <}, you still need to
9072 press the character selecting the command.
9074 @item @kbd{*}
9075 @kindex * @r{(Agenda dispatcher)}
9076 @vindex org-agenda-sticky
9077 @findex org-toggle-sticky-agenda
9078 Toggle sticky agenda views.  By default, Org maintains only
9079 a single agenda buffer and rebuilds it each time you change the
9080 view, to make sure everything is always up to date.  If you
9081 switch between views often and the build time bothers you, you
9082 can turn on sticky agenda buffers (make this the default by
9083 customizing the variable @code{org-agenda-sticky}).  With sticky
9084 agendas, the dispatcher only switches to the selected view, you
9085 need to update it by hand with @kbd{r} or @kbd{g}.  You
9086 can toggle sticky agenda view any time with
9087 @code{org-toggle-sticky-agenda}.
9088 @end table
9090 You can also define custom commands that are accessible through the
9091 dispatcher, just like the default commands.  This includes the
9092 possibility to create extended agenda buffers that contain several
9093 blocks together, for example the weekly agenda, the global TODO list
9094 and a number of special tags matches.  See @ref{Custom Agenda Views}.
9096 @node Built-in Agenda Views
9097 @section The Built-in Agenda Views
9099 In this section we describe the built-in views.
9101 @menu
9102 * Weekly/daily agenda::          The calendar page with current tasks.
9103 * Global TODO list::             All unfinished action items.
9104 * Matching tags and properties:: Structured information with fine-tuned search.
9105 * Search view::                  Find entries by searching for text.
9106 * Stuck projects::               Find projects you need to review.
9107 @end menu
9109 @node Weekly/daily agenda
9110 @subsection Weekly/daily agenda
9112 @cindex agenda
9113 @cindex weekly agenda
9114 @cindex daily agenda
9116 The purpose of the weekly/daily @emph{agenda} is to act like a page of
9117 a paper agenda, showing all the tasks for the current week or day.
9119 @table @asis
9120 @item @kbd{M-x org-agenda a} (@code{org-agenda-list})
9121 @kindex a @r{(Agenda dispatcher)}
9122 @findex org-agenda-list
9123 @cindex org-agenda, command
9124 Compile an agenda for the current week from a list of Org files.
9125 The agenda shows the entries for each day.  With a numeric prefix
9126 argument@footnote{For backward compatibility, the universal prefix argument
9127 @kbd{C-u} causes all TODO entries to be listed before the agenda.
9128 This feature is deprecated, use the dedicated TODO list, or a block
9129 agenda instead (see @ref{Block agenda}).}---like @kbd{C-u 2 1 M-x org-agenda a}---you
9130 may set the number of days to be displayed.
9131 @end table
9133 @vindex org-agenda-span
9134 @vindex org-agenda-start-day
9135 @vindex org-agenda-start-on-weekday
9136 The default number of days displayed in the agenda is set by the
9137 variable @code{org-agenda-span}.  This variable can be set to any number of
9138 days you want to see by default in the agenda, or to a span name, such
9139 a @code{day}, @code{week}, @code{month} or @code{year}.  For weekly agendas, the default
9140 is to start on the previous Monday (see
9141 @code{org-agenda-start-on-weekday}).  You can also set the start date using
9142 a date shift: @code{(setq org-agenda-start-day "+10d")} starts the agenda
9143 ten days from today in the future.
9145 Remote editing from the agenda buffer means, for example, that you can
9146 change the dates of deadlines and appointments from the agenda buffer.
9147 The commands available in the Agenda buffer are listed in @ref{Agenda Commands}.
9149 @anchor{Calendar/Diary integration}
9150 @subsubheading Calendar/Diary integration
9152 @cindex calendar integration
9153 @cindex diary integration
9155 Emacs contains the calendar and diary by Edward M. Reingold.  The
9156 calendar displays a three-month calendar with holidays from different
9157 countries and cultures.  The diary allows you to keep track of
9158 anniversaries, lunar phases, sunrise/set, recurrent appointments
9159 (weekly, monthly) and more.  In this way, it is quite complementary to
9160 Org.  It can be very useful to combine output from Org with the diary.
9162 In order to include entries from the Emacs diary into Org mode's
9163 agenda, you only need to customize the variable
9165 @lisp
9166 (setq org-agenda-include-diary t)
9167 @end lisp
9169 @noindent
9170 After that, everything happens automatically.  All diary entries
9171 including holidays, anniversaries, etc., are included in the agenda
9172 buffer created by Org mode.  @kbd{@key{SPC}}, @kbd{@key{TAB}}, and
9173 @kbd{@key{RET}} can be used from the agenda buffer to jump to the diary
9174 file in order to edit existing diary entries.  The @kbd{i}
9175 command to insert new entries for the current date works in the agenda
9176 buffer, as well as the commands @kbd{S}, @kbd{M}, and
9177 @kbd{C} to display Sunrise/Sunset times, show lunar phases and to
9178 convert to other calendars, respectively.  @kbd{c} can be used to
9179 switch back and forth between calendar and agenda.
9181 If you are using the diary only for S-exp entries and holidays, it is
9182 faster to not use the above setting, but instead to copy or even move
9183 the entries into an Org file.  Org mode evaluates diary-style sexp
9184 entries, and does it faster because there is no overhead for first
9185 creating the diary display.  Note that the sexp entries must start at
9186 the left margin, no whitespace is allowed before them, as seen in the
9187 following segment of an Org file:@footnote{The variable @code{org-anniversary} used in the example is just
9188 like @code{diary-anniversary}, but the argument order is always according
9189 to ISO and therefore independent of the value of
9190 @code{calendar-date-style}.}
9192 @example
9193 * Holidays
9194   :PROPERTIES:
9195   :CATEGORY: Holiday
9196   :END:
9197 %%(org-calendar-holiday)   ; special function for holiday names
9199 * Birthdays
9200   :PROPERTIES:
9201   :CATEGORY: Ann
9202   :END:
9203 %%(org-anniversary 1956  5 14) Arthur Dent is %d years old
9204 %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
9205 @end example
9207 @anchor{Anniversaries from BBDB}
9208 @subsubheading Anniversaries from BBDB
9210 @cindex BBDB, anniversaries
9211 @cindex anniversaries, from BBDB
9213 @findex org-bbdb-anniversaries
9214 If you are using the Insidious Big Brother Database to store your
9215 contacts, you very likely prefer to store anniversaries in BBDB rather
9216 than in a separate Org or diary file.  Org supports this and can show
9217 BBDB anniversaries as part of the agenda.  All you need to do is to
9218 add the following to one of your agenda files:
9220 @example
9221 * Anniversaries
9222   :PROPERTIES:
9223   :CATEGORY: Anniv
9224   :END:
9225 %%(org-bbdb-anniversaries)
9226 @end example
9228 You can then go ahead and define anniversaries for a BBDB record.
9229 Basically, you need to press @kbd{C-o anniversary @key{RET}} with the
9230 cursor in a BBDB record and then add the date in the format
9231 @samp{YYYY-MM-DD} or @samp{MM-DD}, followed by a space and the class of the
9232 anniversary (@samp{birthday}, @samp{wedding}, or a format string).  If you omit
9233 the class, it defaults to @samp{birthday}.  Here are a few examples, the
9234 header for the file @samp{org-bbdb.el} contains more detailed information.
9236 @example
9237 1973-06-22
9238 06-22
9239 1955-08-02 wedding
9240 2008-04-14 %s released version 6.01 of Org mode, %d years ago
9241 @end example
9243 After a change to BBDB, or for the first agenda display during an
9244 Emacs session, the agenda display suffers a short delay as Org updates
9245 its hash with anniversaries.  However, from then on things will be
9246 very fast, much faster in fact than a long list of
9247 @samp{%%(diary-anniversary)} entries in an Org or Diary file.
9249 @findex org-bbdb-anniversaries-future
9250 If you would like to see upcoming anniversaries with a bit of
9251 forewarning, you can use the following instead:
9253 @example
9254 * Anniversaries
9255   :PROPERTIES:
9256   :CATEGORY: Anniv
9257   :END:
9258 %%(org-bbdb-anniversaries-future 3)
9259 @end example
9261 That will give you three days' warning: on the anniversary date itself
9262 and the two days prior.  The argument is optional: if omitted, it
9263 defaults to 7.
9265 @anchor{Appointment reminders}
9266 @subsubheading Appointment reminders
9268 @cindex @file{appt.el}
9269 @cindex appointment reminders
9270 @cindex appointment
9271 @cindex reminders
9273 @cindex APPT_WARNTIME, keyword
9274 Org can interact with Emacs appointments notification facility.  To
9275 add the appointments of your agenda files, use the command
9276 @code{org-agenda-to-appt}.  This command lets you filter through the list
9277 of your appointments and add only those belonging to a specific
9278 category or matching a regular expression.  It also reads
9279 a @samp{APPT_WARNTIME} property which overrides the value of
9280 @code{appt-message-warning-time} for this appointment.  See the docstring
9281 for details.
9283 @node Global TODO list
9284 @subsection The global TODO list
9286 @cindex global TODO list
9287 @cindex TODO list, global
9289 The global TODO list contains all unfinished TODO items formatted and
9290 collected into a single place.
9292 @table @asis
9293 @item @kbd{M-x org-agenda t} (@code{org-todo-list})
9294 @kindex t @r{(Agenda dispatcher)}
9295 @findex org-todo-list
9296 Show the global TODO list.  This collects the TODO items from all
9297 agenda files (see @ref{Agenda Views}) into a single buffer.  By
9298 default, this lists items with a state the is not a DONE state.
9299 The buffer is in @code{agenda-mode}, so there are commands to examine
9300 and manipulate the TODO entries directly from that buffer (see
9301 @ref{Agenda Commands}).
9303 @item @kbd{M-x org-agenda T} (@code{org-todo-list})
9304 @kindex T @r{(Agenda dispatcher)}
9305 @findex org-todo-list
9306 @cindex TODO keyword matching
9307 @vindex org-todo-keywords
9308 Like the above, but allows selection of a specific TODO keyword.
9309 You can also do this by specifying a prefix argument to
9310 @kbd{t}.  You are prompted for a keyword, and you may also
9311 specify several keywords by separating them with @samp{|} as the
9312 boolean OR operator.  With a numeric prefix, the Nth keyword in
9313 @code{org-todo-keywords} is selected.
9315 @kindex r
9316 The @kbd{r} key in the agenda buffer regenerates it, and you
9317 can give a prefix argument to this command to change the selected
9318 TODO keyword, for example @kbd{3 r}.  If you often need
9319 a search for a specific keyword, define a custom command for it
9320 (see @ref{Agenda Dispatcher}).
9322 Matching specific TODO keywords can also be done as part of
9323 a tags search (see @ref{Tag Searches}).
9324 @end table
9326 Remote editing of TODO items means that you can change the state of
9327 a TODO entry with a single key press.  The commands available in the
9328 TODO list are described in @ref{Agenda Commands}.
9330 @cindex sublevels, inclusion into TODO list
9331 Normally the global TODO list simply shows all headlines with TODO
9332 keywords.  This list can become very long.  There are two ways to keep
9333 it more compact:
9335 @itemize
9336 @item
9337 @vindex org-agenda-todo-ignore-scheduled
9338 @vindex org-agenda-todo-ignore-deadlines
9339 @vindex org-agenda-todo-ignore-timestamp
9340 @vindex org-agenda-todo-ignore-with-date
9341 Some people view a TODO item that has been @emph{scheduled} for execution
9342 or have a @emph{deadline} (see @ref{Timestamps}) as
9343 no longer @emph{open}.  Configure the variables
9344 @code{org-agenda-todo-ignore-scheduled},
9345 @code{org-agenda-todo-ignore-deadlines},
9346 @code{org-agenda-todo-ignore-timestamp} and/or
9347 @code{org-agenda-todo-ignore-with-date} to exclude such items from the
9348 global TODO list.
9350 @item
9351 @vindex org-agenda-todo-list-sublevels
9352 TODO items may have sublevels to break up the task into subtasks.
9353 In such cases it may be enough to list only the highest level TODO
9354 headline and omit the sublevels from the global list.  Configure the
9355 variable @code{org-agenda-todo-list-sublevels} to get this behavior.
9356 @end itemize
9358 @node Matching tags and properties
9359 @subsection Matching tags and properties
9361 @cindex matching, of tags
9362 @cindex matching, of properties
9363 @cindex tags view
9364 @cindex match view
9366 If headlines in the agenda files are marked with @emph{tags} (see @ref{Tags}),
9367 or have properties (see @ref{Properties and Columns}), you can select
9368 headlines based on this metadata and collect them into an agenda
9369 buffer.  The match syntax described here also applies when creating
9370 sparse trees with @kbd{C-c / m}.
9372 @table @asis
9373 @item @kbd{M-x org-agenda m} (@code{org-tags-view})
9374 @kindex m @r{(Agenda dispatcher)}
9375 @findex org-tags-view
9376 Produce a list of all headlines that match a given set of tags.
9377 The command prompts for a selection criterion, which is a boolean
9378 logic expression with tags, like @samp{+work+urgent-withboss} or
9379 @samp{work|home} (see @ref{Tags}).  If you often need a specific search,
9380 define a custom command for it (see @ref{Agenda Dispatcher}).
9382 @item @kbd{M-x org-agenda M} (@code{org-tags-view})
9383 @kindex M @r{(Agenda dispatcher)}
9384 @findex org-tags-view
9385 @vindex org-tags-match-list-sublevels
9386 @vindex org-agenda-tags-todo-honor-ignore-options
9387 Like @kbd{m}, but only select headlines that are also TODO
9388 items and force checking subitems (see the variable
9389 @code{org-tags-match-list-sublevels}).  To exclude scheduled/deadline
9390 items, see the variable
9391 @code{org-agenda-tags-todo-honor-ignore-options}.  Matching specific
9392 TODO keywords together with a tags match is also possible, see
9393 @ref{Tag Searches}.
9394 @end table
9396 The commands available in the tags list are described in @ref{Agenda Commands}.
9398 @cindex boolean logic, for agenda searches
9399 A search string can use Boolean operators @samp{&} for AND and @samp{|} for OR.
9400 @samp{&} binds more strongly than @samp{|}.  Parentheses are currently not
9401 implemented.  Each element in the search is either a tag, a regular
9402 expression matching tags, or an expression like @samp{PROPERTY OPERATOR
9403 VALUE} with a comparison operator, accessing a property value.  Each
9404 element may be preceded by @samp{-} to select against it, and @samp{+} is
9405 syntactic sugar for positive selection.  The AND operator @samp{&} is
9406 optional when @samp{+} or @samp{-} is present.  Here are some examples, using
9407 only tags.
9409 @table @asis
9410 @item @code{+work-boss}
9411 Select headlines tagged @samp{work}, but discard those also tagged
9412 @samp{boss}.
9414 @item @code{work|laptop}
9415 Selects lines tagged @samp{work} or @samp{laptop}.
9417 @item @code{work|laptop+night}
9418 Like before, but require the @samp{laptop} lines to be tagged
9419 also @samp{night}.
9420 @end table
9422 @cindex regular expressions, with tags search
9423 Instead of a tag, you may also specify a regular expression enclosed
9424 in curly braces.  For example, @samp{work+@{^boss.*@}} matches headlines that
9425 contain the tag @samp{:work:} and any tag @emph{starting} with @samp{boss}.
9427 @cindex group tags, as regular expressions
9428 Group tags (see @ref{Tag Hierarchy}) are expanded as regular expressions.
9429 E.g., if @samp{work} is a group tag for the group @samp{:work:lab:conf:}, then
9430 searching for @samp{work} also searches for @samp{@{\(?:work\|lab\|conf\)@}} and
9431 searching for @samp{-work} searches for all headlines but those with one of
9432 the tags in the group (i.e., @samp{-@{\(?:work\|lab\|conf\)@}}).
9434 @cindex TODO keyword matching, with tags search
9435 @cindex level, for tags/property match
9436 @cindex category, for tags/property match
9437 @vindex org-odd-levels-only
9438 You may also test for properties (see @ref{Properties and Columns}) at the
9439 same time as matching tags.  The properties may be real properties, or
9440 special properties that represent other metadata (see @ref{Special Properties}).  For example, the property @samp{TODO} represents the TODO
9441 keyword of the entry.  Or, the property @samp{LEVEL} represents the level
9442 of an entry.  So searching @samp{+LEVEL=3+boss-TODO​="DONE"} lists all level
9443 three headlines that have the tag @samp{boss} and are @emph{not} marked with the
9444 TODO keyword @samp{DONE}.  In buffers with @code{org-odd-levels-only} set,
9445 @samp{LEVEL} does not count the number of stars, but @samp{LEVEL=2} corresponds
9446 to 3 stars etc.
9448 Here are more examples:
9450 @table @asis
9451 @item @samp{work+TODO​="WAITING"}
9452 Select @samp{work}-tagged TODO lines with the specific TODO keyword
9453 @samp{WAITING}.
9455 @item @samp{work+TODO​="WAITING"|home+TODO​="WAITING"}
9456 Waiting tasks both at work and at home.
9457 @end table
9459 When matching properties, a number of different operators can be used
9460 to test the value of a property.  Here is a complex example:
9462 @example
9463 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2
9464          +With=@{Sarah|Denny@}+SCHEDULED>="<2008-10-11>"
9465 @end example
9467 @noindent
9468 The type of comparison depends on how the comparison value is written:
9470 @itemize
9471 @item
9472 If the comparison value is a plain number, a numerical comparison is
9473 done, and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=}, @samp{>=}, and
9474 @samp{<>}.
9476 @item
9477 If the comparison value is enclosed in double-quotes, a string
9478 comparison is done, and the same operators are allowed.
9480 @item
9481 If the comparison value is enclosed in double-quotes @emph{and} angular
9482 brackets (like @samp{DEADLINE<​="<2008-12-24 18:30>"}), both values are
9483 assumed to be date/time specifications in the standard Org way, and
9484 the comparison is done accordingly.  Valid values also include
9485 @samp{"<now>"} for now (including time), @samp{"<today>"}, and @samp{"<tomorrow>"}
9486 for these days at 0:00 hours, i.e., without a time specification.
9487 You can also use strings like @samp{"<+5d>"} or @samp{"<-2m>"} with units @samp{d},
9488 @samp{w}, @samp{m}, and @samp{y} for day, week, month, and year, respectively.
9490 @item
9491 If the comparison value is enclosed in curly braces, a regexp match
9492 is performed, with @samp{=} meaning that the regexp matches the property
9493 value, and @samp{<>} meaning that it does not match.
9494 @end itemize
9496 So the search string in the example finds entries tagged @samp{work} but
9497 not @samp{boss}, which also have a priority value @samp{A}, a @samp{Coffee} property
9498 with the value @samp{unlimited}, an @samp{EFFORT} property that is numerically
9499 smaller than 2, a @samp{With} property that is matched by the regular
9500 expression @samp{Sarah|Denny}, and that are scheduled on or after October
9501 11, 2008.
9503 You can configure Org mode to use property inheritance during
9504 a search, but beware that this can slow down searches considerably.
9505 See @ref{Property Inheritance}, for details.
9507 For backward compatibility, and also for typing speed, there is also
9508 a different way to test TODO states in a search.  For this, terminate
9509 the tags/property part of the search string (which may include several
9510 terms connected with @samp{|}) with a @samp{/} and then specify a Boolean
9511 expression just for TODO keywords.  The syntax is then similar to that
9512 for tags, but should be applied with care: for example, a positive
9513 selection on several TODO keywords cannot meaningfully be combined
9514 with boolean AND.  However, @emph{negative selection} combined with AND can
9515 be meaningful.  To make sure that only lines are checked that actually
9516 have any TODO keyword (resulting in a speed-up), use @kbd{M-x org-agenda M}, or equivalently start the TODO part after the slash
9517 with @samp{!}.  Using @kbd{M-x org-agenda M} or @samp{/!} does not match
9518 TODO keywords in a DONE state.  Examples:
9520 @table @asis
9521 @item @samp{work/WAITING}
9522 Same as @samp{work+TODO​="WAITING"}.
9524 @item @samp{work/!-WAITING-NEXT}
9525 Select @samp{work}-tagged TODO lines that are neither @samp{WAITING} nor
9526 @samp{NEXT}.
9528 @item @samp{work/!+WAITING|+NEXT}
9529 Select @samp{work}-tagged TODO lines that are either @samp{WAITING} or
9530 @samp{NEXT}.
9531 @end table
9533 @node Search view
9534 @subsection Search view
9536 @cindex search view
9537 @cindex text search
9538 @cindex searching, for text
9540 This agenda view is a general text search facility for Org mode
9541 entries.  It is particularly useful to find notes.
9543 @table @asis
9544 @item @kbd{M-x org-agenda s} (@code{org-search-view})
9545 @kindex s @r{(Agenda dispatcher)}
9546 @findex org-search-view
9547 This is a special search that lets you select entries by matching
9548 a substring or specific words using a boolean logic.
9549 @end table
9551 For example, the search string @samp{computer equipment} matches entries
9552 that contain @samp{computer equipment} as a substring, even if the two
9553 words are separated by more space or a line break.
9555 Search view can also search for specific keywords in the entry, using
9556 Boolean logic.  The search string @samp{+computer
9557 +wifi -ethernet -@{8\.11[bg]@}} matches note entries that contain the
9558 keywords @samp{computer} and @samp{wifi}, but not the keyword @samp{ethernet}, and
9559 which are also not matched by the regular expression @samp{8\.11[bg]},
9560 meaning to exclude both @samp{8.11b} and @samp{8.11g}.  The first @samp{+} is
9561 necessary to turn on boolean search, other @samp{+} characters are
9562 optional.  For more details, see the docstring of the command
9563 @code{org-search-view}.
9565 You can incrementally adjust a boolean search with the following keys
9567 @multitable @columnfractions 0.1 0.6
9568 @item @kbd{[}
9569 @tab Add a positive search word
9570 @item @kbd{]}
9571 @tab Add a negative search word
9572 @item @kbd{@{}
9573 @tab Add a positive regular expression
9574 @item @kbd{@}}
9575 @tab Add a negative regular expression
9576 @end multitable
9578 @vindex org-agenda-text-search-extra-files
9579 Note that in addition to the agenda files, this command also searches
9580 the files listed in @code{org-agenda-text-search-extra-files}.
9582 @node Stuck projects
9583 @subsection Stuck projects
9585 @pindex GTD, Getting Things Done
9587 If you are following a system like David Allen's GTD to organize your
9588 work, one of the ``duties'' you have is a regular review to make sure
9589 that all projects move along.  A @emph{stuck} project is a project that has
9590 no defined next actions, so it never shows up in the TODO lists Org
9591 mode produces.  During the review, you need to identify such projects
9592 and define next actions for them.
9594 @table @asis
9595 @item @kbd{M-x org-agenda #} (@code{org-agenda-list-stuck-projects})
9596 @kindex # @r{(Agenda dispatcher)}
9597 @findex org-agenda-list-stuck-projects
9598 List projects that are stuck.
9600 @item @kbd{M-x org-agenda !}
9601 @kindex ! @r{(Agenda dispatcher)}
9602 @vindex org-stuck-projects
9603 Customize the variable @code{org-stuck-projects} to define what
9604 a stuck project is and how to find it.
9605 @end table
9607 You almost certainly need to configure this view before it works for
9608 you.  The built-in default assumes that all your projects are level-2
9609 headlines, and that a project is not stuck if it has at least one
9610 entry marked with a TODO keyword @samp{TODO} or @samp{NEXT} or @samp{NEXTACTION}.
9612 Let's assume that you, in your own way of using Org mode, identify
9613 projects with a tag @samp{:PROJECT:}, and that you use a TODO keyword
9614 @samp{MAYBE} to indicate a project that should not be considered yet.
9615 Let's further assume that the TODO keyword @samp{DONE} marks finished
9616 projects, and that @samp{NEXT} and @samp{TODO} indicate next actions.  The tag
9617 @samp{:@@shop:} indicates shopping and is a next action even without the
9618 NEXT tag.  Finally, if the project contains the special word @samp{IGNORE}
9619 anywhere, it should not be listed either.  In this case you would
9620 start by identifying eligible projects with a tags/TODO match (see
9621 @ref{Tag Searches}) @samp{+PROJECT/-MAYBE-DONE}, and then check for @samp{TODO},
9622 @samp{NEXT}, @samp{@@shop}, and @samp{IGNORE} in the subtree to identify projects that
9623 are not stuck.  The correct customization for this is:
9625 @lisp
9626 (setq org-stuck-projects
9627       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@shop")
9628         "\\<IGNORE\\>"))
9629 @end lisp
9631 Note that if a project is identified as non-stuck, the subtree of this
9632 entry is searched for stuck projects.
9634 @node Presentation and Sorting
9635 @section Presentation and Sorting
9637 @cindex presentation, of agenda items
9639 @vindex org-agenda-prefix-format
9640 @vindex org-agenda-tags-column
9641 Before displaying items in an agenda view, Org mode visually prepares
9642 the items and sorts them.  Each item occupies a single line.  The line
9643 starts with a @emph{prefix} that contains the @emph{category} (see @ref{Categories})
9644 of the item and other important information.  You can customize in
9645 which column tags are displayed through @code{org-agenda-tags-column}.  You
9646 can also customize the prefix using the option
9647 @code{org-agenda-prefix-format}.  This prefix is followed by a cleaned-up
9648 version of the outline headline associated with the item.
9650 @menu
9651 * Categories::                   Not all tasks are equal.
9652 * Time-of-day specifications::   How the agenda knows the time.
9653 * Sorting of agenda items::      The order of things.
9654 * Filtering/limiting agenda times:: Dynamically narrow the agenda.
9655 @end menu
9657 @node Categories
9658 @subsection Categories
9660 @cindex category
9661 @cindex @samp{CATEGORY}, keyword
9663 The category is a broad label assigned to each agenda item.  By
9664 default, the category is simply derived from the file name, but you
9665 can also specify it with a special line in the buffer, like
9666 this:
9668 @example
9669 #+CATEGORY: Thesis
9670 @end example
9672 @noindent
9673 @cindex @samp{CATEGORY}, property
9674 If you would like to have a special category for a single entry or
9675 a (sub)tree, give the entry a @samp{CATEGORY} property with the special
9676 category you want to apply as the value.
9678 @noindent
9679 The display in the agenda buffer looks best if the category is not
9680 longer than 10 characters.
9682 @noindent
9683 @vindex org-agenda-category-icon-alist
9684 You can set up icons for category by customizing the
9685 @code{org-agenda-category-icon-alist} variable.
9687 @node Time-of-day specifications
9688 @subsection Time-of-day specifications
9690 @cindex time-of-day specification
9692 Org mode checks each agenda item for a time-of-day specification.  The
9693 time can be part of the timestamp that triggered inclusion into the
9694 agenda, for example
9696 @example
9697 <2005-05-10 Tue 19:00>
9698 @end example
9700 @noindent
9701 Time ranges can be specified with two timestamps:
9703 @example
9704 <2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>
9705 @end example
9707 In the headline of the entry itself, a time(range) may also appear as
9708 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda integrates
9709 the Emacs diary (see @ref{Weekly/daily agenda}), time specifications in
9710 diary entries are recognized as well.
9712 For agenda display, Org mode extracts the time and displays it in
9713 a standard 24 hour format as part of the prefix.  The example times in
9714 the previous paragraphs would end up in the agenda like this:
9716 @example
9717  8:30-13:00 Arthur Dent lies in front of the bulldozer
9718 12:45...... Ford Prefect arrives and takes Arthur to the pub
9719 19:00...... The Vogon reads his poem
9720 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9721 @end example
9723 @cindex time grid
9724 If the agenda is in single-day mode, or for the display of today, the
9725 timed entries are embedded in a time grid, like
9727 @example
9728  8:00...... ------------------
9729  8:30-13:00 Arthur Dent lies in front of the bulldozer
9730 10:00...... ------------------
9731 12:00...... ------------------
9732 12:45...... Ford Prefect arrives and takes Arthur to the pub
9733 14:00...... ------------------
9734 16:00...... ------------------
9735 18:00...... ------------------
9736 19:00...... The Vogon reads his poem
9737 20:00...... ------------------
9738 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9739 @end example
9741 @vindex org-agenda-use-time-grid
9742 @vindex org-agenda-time-grid
9743 The time grid can be turned on and off with the variable
9744 @code{org-agenda-use-time-grid}, and can be configured with
9745 @code{org-agenda-time-grid}.
9747 @node Sorting of agenda items
9748 @subsection Sorting of agenda items
9750 @cindex sorting, of agenda items
9751 @cindex priorities, of agenda items
9753 Before being inserted into a view, the items are sorted.  How this is
9754 done depends on the type of view.
9756 @itemize
9757 @item
9758 @vindex org-agenda-files
9759 For the daily/weekly agenda, the items for each day are sorted.  The
9760 default order is to first collect all items containing an explicit
9761 time-of-day specification.  These entries are shown at the beginning
9762 of the list, as a @emph{schedule} for the day.  After that, items remain
9763 grouped in categories, in the sequence given by @code{org-agenda-files}.
9764 Within each category, items are sorted by priority (see
9765 @ref{Priorities}), which is composed of the base priority (2000 for
9766 priority @samp{A}, 1000 for @samp{B}, and 0 for @samp{C}), plus additional
9767 increments for overdue scheduled or deadline items.
9769 @item
9770 For the TODO list, items remain in the order of categories, but
9771 within each category, sorting takes place according to priority (see
9772 @ref{Priorities}).  The priority used for sorting derives from the
9773 priority cookie, with additions depending on how close an item is to
9774 its due or scheduled date.
9776 @item
9777 For tags matches, items are not sorted at all, but just appear in
9778 the sequence in which they are found in the agenda files.
9779 @end itemize
9781 @vindex org-agenda-sorting-strategy
9782 Sorting can be customized using the variable
9783 @code{org-agenda-sorting-strategy}, and may also include criteria based on
9784 the estimated effort of an entry (see @ref{Effort Estimates}).
9786 @node Filtering/limiting agenda times
9787 @subsection Filtering/limiting agenda times
9789 Agenda built-in or customized commands are statically defined.  Agenda
9790 filters and limits provide two ways of dynamically narrowing down the
9791 list of agenda entries: @emph{filters} and @emph{limits}.  Filters only act on
9792 the display of the items, while limits take effect before the list of
9793 agenda entries is built.  Filters are more often used interactively,
9794 while limits are mostly useful when defined as local variables within
9795 custom agenda commands.
9797 @anchor{Filtering in the agenda}
9798 @subsubheading Filtering in the agenda
9800 @cindex agenda filtering
9801 @cindex filtering entries, in agenda
9802 @cindex tag filtering, in agenda
9803 @cindex category filtering, in agenda
9804 @cindex top headline filtering, in agenda
9805 @cindex effort filtering, in agenda
9806 @cindex query editing, in agenda
9808 @table @asis
9809 @item @kbd{/} (@code{org-agenda-filter-by-tag})
9810 @findex org-agenda-filter-by-tag
9811 @vindex org-agenda-tag-filter-preset
9812 Filter the agenda view with respect to a tag and/or effort
9813 estimates.  The difference between this and a custom agenda
9814 command is that filtering is very fast, so that you can switch
9815 quickly between different filters without having to recreate the
9816 agenda.@footnote{Custom commands can preset a filter by binding the variable
9817 @code{org-agenda-tag-filter-preset} as an option.  This filter is then
9818 applied to the view and persists as a basic filter through refreshes
9819 and more secondary filtering.  The filter is a global property of the
9820 entire agenda view---in a block agenda, you should only set this in
9821 the global options section, not in the section of an individual block.}
9823 You are prompted for a tag selection letter; @kbd{@key{SPC}} means
9824 any tag at all.  Pressing @kbd{@key{TAB}} at that prompt offers
9825 completion to select a tag, including any tags that do not have
9826 a selection character.  The command then hides all entries that
9827 do not contain or inherit this tag.  When called with prefix
9828 argument, remove the entries that @emph{do} have the tag.  A second
9829 @kbd{/} at the prompt turns off the filter and shows any
9830 hidden entries.  Pressing @kbd{+} or @kbd{-} switches
9831 between filtering and excluding the next tag.
9833 @vindex org-agenda-auto-exclude-function
9834 Org also supports automatic, context-aware tag filtering.  If the
9835 variable @code{org-agenda-auto-exclude-function} is set to
9836 a user-defined function, that function can decide which tags
9837 should be excluded from the agenda automatically.  Once this is
9838 set, the @kbd{/} command then accepts @kbd{@key{RET}} as
9839 a sub-option key and runs the auto exclusion logic.  For example,
9840 let's say you use a @samp{Net} tag to identify tasks which need
9841 network access, an @samp{Errand} tag for errands in town, and a @samp{Call}
9842 tag for making phone calls.  You could auto-exclude these tags
9843 based on the availability of the Internet, and outside of
9844 business hours, with something like this:
9846 @lisp
9847 (defun org-my-auto-exclude-function (tag)
9848   (and (cond
9849         ((string= tag "Net")
9850          (/= 0 (call-process "/sbin/ping" nil nil nil
9851                              "-c1" "-q" "-t1" "mail.gnu.org")))
9852         ((or (string= tag "Errand") (string= tag "Call"))
9853          (let ((hour (nth 2 (decode-time))))
9854            (or (< hour 8) (> hour 21)))))
9855        (concat "-" tag)))
9857 (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
9858 @end lisp
9860 @item @kbd{<} (@code{org-agenda-filter-by-category})
9861 @findex org-agenda-filter-by-category
9862 Filter the current agenda view with respect to the category of
9863 the item at point.  Pressing @kbd{<} another time removes
9864 this filter.  When called with a prefix argument exclude the
9865 category of the item at point from the agenda.
9867 @vindex org-agenda-category-filter-preset
9868 You can add a filter preset in custom agenda commands through the
9869 option @code{org-agenda-category-filter-preset}.  See @ref{Setting options}.
9871 @item @kbd{^} (@code{org-agenda-filter-by-top-headline})
9872 @findex org-agenda-filter-by-top-headline
9873 Filter the current agenda view and only display the siblings and
9874 the parent headline of the one at point.
9876 @item @kbd{=} (@code{org-agenda-filter-by-regexp})
9877 @findex org-agenda-filter-by-regexp
9878 Filter the agenda view by a regular expression: only show agenda
9879 entries matching the regular expression the user entered.  When
9880 called with a prefix argument, it filters @emph{out} entries matching
9881 the regexp.  With two universal prefix arguments, it removes all
9882 the regexp filters, which can be accumulated.
9884 @vindex org-agenda-regexp-filter-preset
9885 You can add a filter preset in custom agenda commands through the
9886 option @code{org-agenda-regexp-filter-preset}.  See @ref{Setting options}.
9888 @item @kbd{_} (@code{org-agenda-filter-by-effort})
9889 @findex org-agenda-filter-by-effort
9890 Filter the agenda view with respect to effort estimates.  You
9891 first need to set up allowed efforts globally, for example
9893 @lisp
9894 (setq org-global-properties
9895       '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
9896 @end lisp
9898 @vindex org-sort-agenda-noeffort-is-high
9899 You can then filter for an effort by first typing an operator,
9900 one of @kbd{<}, @kbd{>} and @kbd{=}, and then the
9901 one-digit index of an effort estimate in your array of allowed
9902 values, where @kbd{0} means the 10th value.  The filter then
9903 restricts to entries with effort smaller-or-equal, equal, or
9904 larger-or-equal than the selected value.  For application of the
9905 operator, entries without a defined effort are treated according
9906 to the value of @code{org-sort-agenda-noeffort-is-high}.
9908 When called with a prefix argument, it removes entries matching
9909 the condition.  With two universal prefix arguments, it clears
9910 effort filters, which can be accumulated.
9912 @vindex org-agenda-effort-filter-preset
9913 You can add a filter preset in custom agenda commands through the
9914 option @code{org-agenda-effort-filter-preset}.  See @ref{Setting options}.
9916 @item @kbd{|} (@code{org-agenda-filter-remove-all})
9917 Remove all filters in the current agenda view.
9918 @end table
9920 @anchor{Setting limits for the agenda}
9921 @subsubheading Setting limits for the agenda
9923 @cindex limits, in agenda
9925 Here is a list of options that you can set, either globally, or
9926 locally in your custom agenda views (see @ref{Custom Agenda Views}).
9928 @table @asis
9929 @item @code{org-agenda-max-entries}
9930 @vindex org-agenda-max-entries
9931 Limit the number of entries.
9933 @item @code{org-agenda-max-effort}
9934 @vindex org-agenda-max-effort
9935 Limit the duration of accumulated efforts (as minutes).
9937 @item @code{org-agenda-max-todos}
9938 @vindex org-agenda-max-todos
9939 Limit the number of entries with TODO keywords.
9941 @item @code{org-agenda-max-tags}
9942 @vindex org-agenda-max-tags
9943 Limit the number of tagged entries.
9944 @end table
9946 When set to a positive integer, each option excludes entries from
9947 other categories: for example, @code{(setq org-agenda-max-effort 100)}
9948 limits the agenda to 100 minutes of effort and exclude any entry that
9949 has no effort property.  If you want to include entries with no effort
9950 property, use a negative value for @code{org-agenda-max-effort}.  One
9951 useful setup is to use @code{org-agenda-max-entries} locally in a custom
9952 command.  For example, this custom command displays the next five
9953 entries with a @samp{NEXT} TODO keyword.
9955 @lisp
9956 (setq org-agenda-custom-commands
9957       '(("n" todo "NEXT"
9958          ((org-agenda-max-entries 5)))))
9959 @end lisp
9961 Once you mark one of these five entry as DONE, rebuilding the agenda
9962 will again the next five entries again, including the first entry that
9963 was excluded so far.
9965 You can also dynamically set temporary limits, which are lost when
9966 rebuilding the agenda:
9968 @table @asis
9969 @item @kbd{~} (@code{org-agenda-limit-interactively})
9970 @findex org-agenda-limit-interactively
9971 This prompts for the type of limit to apply and its value.
9972 @end table
9974 @node Agenda Commands
9975 @section Commands in the Agenda Buffer
9977 @cindex commands, in agenda buffer
9979 Entries in the agenda buffer are linked back to the Org file or diary
9980 file where they originate.  You are not allowed to edit the agenda
9981 buffer itself, but commands are provided to show and jump to the
9982 original entry location, and to edit the Org files ``remotely'' from the
9983 agenda buffer.  In this way, all information is stored only once,
9984 removing the risk that your agenda and note files may diverge.
9986 Some commands can be executed with mouse clicks on agenda lines.  For
9987 the other commands, the cursor needs to be in the desired line.
9989 @anchor{Motion (1)}
9990 @subheading Motion
9992 @cindex motion commands in agenda
9994 @table @asis
9995 @item @kbd{n} (@code{org-agenda-next-line})
9996 @kindex n
9997 @findex org-agenda-next-line
9998 Next line (same as @kbd{@key{DOWN}} and @kbd{C-n}).
10000 @item @kbd{p} (@code{org-agenda-previous-line})
10001 @kindex p
10002 @findex org-agenda-previous-line
10003 Previous line (same as @kbd{@key{UP}} and @kbd{C-p}).
10004 @end table
10006 @anchor{View/Go to Org file}
10007 @subheading View/Go to Org file
10009 @cindex view file commands in agenda
10011 @table @asis
10012 @item @kbd{@key{SPC}} or @kbd{mouse-3} (@code{org-agenda-show-and-scroll-up})
10013 @kindex SPC
10014 @kindex mouse-3
10015 @findex org-agenda-show-and-scroll-up
10016 Display the original location of the item in another window.
10017 With a prefix argument, make sure that drawers stay folded.
10019 @item @kbd{L} (@code{org-agenda-recenter})
10020 @findex org-agenda-recenter
10021 Display original location and recenter that window.
10023 @item @kbd{@key{TAB}} or @kbd{mouse-2} (@code{org-agenda-goto})
10024 @kindex TAB
10025 @kindex mouse-2
10026 @findex org-agenda-goto
10027 Go to the original location of the item in another window.
10029 @item @kbd{@key{RET}} (@code{org-agenda-switch-to})
10030 @kindex RET
10031 @findex org-agenda-switch-to
10032 Go to the original location of the item and delete other windows.
10034 @item @kbd{F} (@code{org-agenda-follow-mode})
10035 @kindex F
10036 @findex org-agenda-follow-mode
10037 @vindex org-agenda-start-with-follow-mode
10038 Toggle Follow mode.  In Follow mode, as you move the cursor
10039 through the agenda buffer, the other window always shows the
10040 corresponding location in the Org file.  The initial setting for
10041 this mode in new agenda buffers can be set with the variable
10042 @code{org-agenda-start-with-follow-mode}.
10044 @item @kbd{C-c C-x b} (@code{org-agenda-tree-to-indirect-buffer})
10045 @kindex C-c C-x b
10046 @findex org-agenda-tree-to-indirect-buffer
10047 Display the entire subtree of the current item in an indirect
10048 buffer.  With a numeric prefix argument N, go up to level N and
10049 then take that tree.  If N is negative, go up that many levels.
10050 With a @kbd{C-u} prefix, do not remove the previously used
10051 indirect buffer.
10053 @item @kbd{C-c C-o} (@code{org-agenda-open-link})
10054 @kindex C-c C-o
10055 @findex org-agenda-open-link
10056 Follow a link in the entry.  This offers a selection of any links
10057 in the text belonging to the referenced Org node.  If there is
10058 only one link, follow it without a selection prompt.
10059 @end table
10061 @anchor{Change display}
10062 @subheading Change display
10064 @cindex change agenda display
10065 @cindex display changing, in agenda
10067 @table @asis
10068 @item @kbd{A}
10069 @kindex A
10070 Interactively select another agenda view and append it to the
10071 current view.
10073 @item @kbd{o}
10074 @kindex o
10075 Delete other windows.
10077 @item @kbd{v d} or short @kbd{d} (@code{org-agenda-day-view})
10078 @kindex v d
10079 @kindex d
10080 @findex org-agenda-day-view
10081 Switch to day view.  When switching to day view, this setting
10082 becomes the default for subsequent agenda refreshes.  A numeric
10083 prefix argument may be used to jump directly to a specific day of
10084 the year.  For example, @kbd{32 d} jumps to February 1st.
10085 When setting day view, a year may be encoded in the prefix
10086 argument as well.  For example, @kbd{200712 d} jumps to
10087 January 12, 2007.  If such a year specification has only one or
10088 two digits, it is expanded into one of the 30 next years or the
10089 last 69 years.
10091 @item @kbd{v w} or short @kbd{w} (@code{org-agenda-week-view})
10092 @kindex v w
10093 @kindex w
10094 @findex org-agenda-week-view
10095 Switch to week view.  When switching week view, this setting
10096 becomes the default for subsequent agenda refreshes.  A numeric
10097 prefix argument may be used to jump directly to a specific day of
10098 the ISO week.  For example @kbd{9 w} to ISO week number 9.
10099 When setting week view, a year may be encoded in the prefix
10100 argument as well.  For example, @kbd{200712 w} jumps to week
10101 12 in 2007.  If such a year specification has only one or two
10102 digits, it is expanded into one of the 30 next years or the last
10103 69 years.
10105 @item @kbd{v m} (@code{org-agenda-month-view})
10106 @kindex v m
10107 @findex org-agenda-month-view
10108 Switch to month view.  Because month views are slow to create,
10109 they do not become the default for subsequent agenda refreshes.
10110 A numeric prefix argument may be used to jump directly to
10111 a specific day of the month.  When setting month view, a year may
10112 be encoded in the prefix argument as well.  For example,
10113 @kbd{200712 m} jumps to December, 2007.  If such a year
10114 specification has only one or two digits, it is expanded into one
10115 of the 30 next years or the last 69 years.
10117 @item @kbd{v y} (@code{org-agenda-year-view})
10118 @kindex v y
10119 @findex org-agenda-year-view
10120 Switch to year view.  Because year views are slow to create, they
10121 do not become the default for subsequent agenda refreshes.
10122 A numeric prefix argument may be used to jump directly to
10123 a specific day of the year.
10125 @item @kbd{v @key{SPC}} (@code{org-agenda-reset-view})
10126 @kindex v SPC
10127 @findex org-agenda-reset-view
10128 @vindex org-agenda-span
10129 Reset the current view to @code{org-agenda-span}.
10131 @item @kbd{f} (@code{org-agenda-later})
10132 @kindex f
10133 @findex org-agenda-later
10134 Go forward in time to display the span following the current one.
10135 For example, if the display covers a week, switch to the
10136 following week.  With a prefix argument, repeat that many times.
10138 @item @kbd{b} (@code{org-agenda-earlier})
10139 @kindex b
10140 @findex org-agenda-earlier
10141 Go backward in time to display earlier dates.
10143 @item @kbd{.} (@code{org-agenda-goto-today})
10144 @kindex .
10145 @findex org-agenda-goto-today
10146 Go to today.
10148 @item @kbd{j} (@code{org-agenda-goto-date})
10149 @kindex j
10150 @findex org-agenda-goto-date
10151 Prompt for a date and go there.
10153 @item @kbd{J} (@code{org-agenda-clock-goto})
10154 @kindex J
10155 @findex org-agenda-clock-goto
10156 Go to the currently clocked-in task @emph{in the agenda buffer}.
10158 @item @kbd{D} (@code{org-agenda-toggle-diary})
10159 @kindex D
10160 @findex org-agenda-toggle-diary
10161 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
10163 @item @kbd{v l} or @kbd{v L} or short @kbd{l} (@code{org-agenda-log-mode})
10164 @kindex v l
10165 @kindex l
10166 @kindex v L
10167 @findex org-agenda-log-mode
10168 @vindex org-log-done
10169 @vindex org-agenda-log-mode-items
10170 Toggle Logbook mode.  In Logbook mode, entries that were marked
10171 DONE while logging was on (see the variable @code{org-log-done}) are
10172 shown in the agenda, as are entries that have been clocked on
10173 that day.  You can configure the entry types that should be
10174 included in log mode using the variable
10175 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u}
10176 prefix, show all possible logbook entries, including state
10177 changes.  When called with two prefix arguments @kbd{C-u C-u}, show only logging information, nothing else.  @kbd{v L} is equivalent to @kbd{C-u v l}.
10179 @item @kbd{v [} or short @kbd{[} (@code{org-agenda-manipulate-query-add})
10180 @kindex v [
10181 @kindex [
10182 @findex org-agenda-manipulate-query-add
10183 Include inactive timestamps into the current view.  Only for
10184 weekly/daily agenda and timeline views.
10186 @item @kbd{v a} (@code{org-agenda-archives-mode})
10187 @kindex v a
10188 @findex org-agenda-archives-mode
10189 Toggle Archives mode.  In Archives mode, trees that are archived
10190 (see @ref{Internal archiving}) are also scanned when producing the
10191 agenda.  To exit archives mode, press @kbd{v a} again.
10193 @item @kbd{v A}
10194 @kindex v A
10195 Toggle Archives mode.  Include all archive files as well.
10197 @item @kbd{v R} or short @kbd{R} (@code{org-agenda-clockreport-mode})
10198 @kindex v R
10199 @kindex R
10200 @findex org-agenda-clockreport-mode
10201 @vindex org-agenda-start-with-clockreport-mode
10202 @vindex org-clock-report-include-clocking-task
10203 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly
10204 agenda always shows a table with the clocked times for the time
10205 span and file scope covered by the current agenda view.  The
10206 initial setting for this mode in new agenda buffers can be set
10207 with the variable @code{org-agenda-start-with-clockreport-mode}.  By
10208 using a prefix argument when toggling this mode (i.e., @kbd{C-u R}), the clock table does not show contributions from entries
10209 that are hidden by agenda filtering@footnote{Only tags filtering is respected here, effort filtering is
10210 ignored.}.  See also the
10211 variable @code{org-clock-report-include-clocking-task}.
10213 @item @kbd{v c}
10214 @kindex v c
10215 @vindex org-agenda-clock-consistency-checks
10216 Show overlapping clock entries, clocking gaps, and other clocking
10217 problems in the current agenda range.  You can then visit
10218 clocking lines and fix them manually.  See the variable
10219 @code{org-agenda-clock-consistency-checks} for information on how to
10220 customize the definition of what constituted a clocking problem.
10221 To return to normal agenda display, press @kbd{l} to exit
10222 Logbook mode.
10224 @item @kbd{v E} or short @kbd{E} (@code{org-agenda-entry-text-mode})
10225 @kindex v E
10226 @kindex E
10227 @findex org-agenda-entry-text-mode
10228 @vindex org-agenda-start-with-entry-text-mode
10229 @vindex org-agenda-entry-text-maxlines
10230 Toggle entry text mode.  In entry text mode, a number of lines
10231 from the Org outline node referenced by an agenda line are
10232 displayed below the line.  The maximum number of lines is given
10233 by the variable @code{org-agenda-entry-text-maxlines}.  Calling this
10234 command with a numeric prefix argument temporarily modifies that
10235 number to the prefix value.
10237 @item @kbd{G} (@code{org-agenda-toggle-time-grid})
10238 @kindex G
10239 @vindex org-agenda-use-time-grid
10240 @vindex org-agenda-time-grid
10241 Toggle the time grid on and off.  See also the variables
10242 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
10244 @item @kbd{r} (@code{org-agenda-redo})
10245 @itemx @kbd{g}
10246 @kindex r
10247 @kindex g
10248 @findex org-agenda-redo
10249 Recreate the agenda buffer, for example to reflect the changes
10250 after modification of the timestamps of items with
10251 @kbd{S-@key{LEFT}} and @kbd{S-@key{RIGHT}}.  When the
10252 buffer is the global TODO list, a prefix argument is interpreted
10253 to create a selective list for a specific TODO keyword.
10255 @item @kbd{C-x C-s} or short @kbd{s} (@code{org-save-all-org-buffers})
10256 @kindex C-x C-s
10257 @findex org-save-all-org-buffers
10258 @kindex s
10259 Save all Org buffers in the current Emacs session, and also the
10260 locations of IDs.
10262 @item @kbd{C-c C-x C-c} (@code{org-agenda-columns})
10263 @kindex C-c C-x C-c
10264 @findex org-agenda-columns
10265 @vindex org-columns-default-format
10266 Invoke column view (see @ref{Column View}) in the agenda buffer.  The
10267 column view format is taken from the entry at point, or, if there
10268 is no entry at point, from the first entry in the agenda view.
10269 So whatever the format for that entry would be in the original
10270 buffer (taken from a property, from a @samp{COLUMNS} keyword, or from
10271 the default variable @code{org-columns-default-format}) is used in the
10272 agenda.
10274 @item @kbd{C-c C-x >} (@code{org-agenda-remove-restriction-lock})
10275 @kindex C-c C-x >
10276 @findex org-agenda-remove-restriction-lock
10277 Remove the restriction lock on the agenda, if it is currently
10278 restricted to a file or subtree (see @ref{Agenda Files}).
10280 @item @kbd{M-@key{UP}} (@code{org-agenda-drag-line-backward})
10281 @kindex M-UP
10282 @findex org-agenda-drag-line-backward
10283 Drag the line at point backward one line.  With a numeric prefix
10284 argument, drag backward by that many lines.
10286 Moving agenda lines does not persist after an agenda refresh and
10287 does not modify the contributing Org files.
10289 @item @kbd{M-@key{DOWN}} (@code{org-agenda-drag-line-forward})
10290 @kindex M-DOWN
10291 @findex org-agenda-drag-line-forward
10292 Drag the line at point forward one line.  With a numeric prefix
10293 argument, drag forward by that many lines.
10294 @end table
10296 @anchor{Remote editing}
10297 @subheading Remote editing
10299 @cindex remote editing, from agenda
10301 @table @asis
10302 @item @kbd{0--9}
10303 Digit argument.
10305 @item @kbd{C-_} (@code{org-agenda-undo})
10306 @kindex C-_
10307 @findex org-agenda-undo
10308 @cindex undoing remote-editing events
10309 @cindex remote editing, undo
10310 Undo a change due to a remote editing command.  The change is
10311 undone both in the agenda buffer and in the remote buffer.
10313 @item @kbd{t} (@code{org-agenda-todo})
10314 @kindex t
10315 @findex org-agenda-todo
10316 Change the TODO state of the item, both in the agenda and in the
10317 original Org file.
10319 @item @kbd{C-S-@key{RIGHT}} (@code{org-agenda-todo-nextset})
10320 @kindex C-S-RIGHT
10321 @findex org-agenda-todo-nextset
10322 Switch to the next set of TODO keywords.
10324 @item @kbd{C-S-@key{LEFT}}, @code{org-agenda-todo-previousset}
10325 @kindex C-S-LEFT
10326 Switch to the previous set of TODO keywords.
10328 @item @kbd{C-k} (@code{org-agenda-kill})
10329 @kindex C-k
10330 @findex org-agenda-kill
10331 @vindex org-agenda-confirm-kill
10332 Delete the current agenda item along with the entire subtree
10333 belonging to it in the original Org file.  If the text to be
10334 deleted remotely is longer than one line, the kill needs to be
10335 confirmed by the user.  See variable @code{org-agenda-confirm-kill}.
10337 @item @kbd{C-c C-w} (@code{org-agenda-refile})
10338 @kindex C-c C-w
10339 @findex org-agenda-refile
10340 Refile the entry at point.
10342 @item @kbd{C-c C-x C-a} or short @kbd{a} (@code{org-agenda-archive-default-with-confirmation})
10343 @kindex C-c C-x C-a
10344 @kindex a
10345 @findex org-agenda-archive-default-with-confirmation
10346 @vindex org-archive-default-command
10347 Archive the subtree corresponding to the entry at point using the
10348 default archiving command set in @code{org-archive-default-command}.
10349 When using the @kbd{a} key, confirmation is required.
10351 @item @kbd{C-c C-x a} (@code{org-agenda-toggle-archive-tag})
10352 @kindex C-c C-x a
10353 @findex org-agenda-toggle-archive-tag
10354 Toggle the archive tag (see @ref{Internal archiving}) for the current
10355 headline.
10357 @item @kbd{C-c C-x A} (@code{org-agenda-archive-to-archive-sibling})
10358 @kindex C-c C-x A
10359 @findex org-agenda-archive-to-archive-sibling
10360 Move the subtree corresponding to the current entry to its
10361 @emph{archive sibling}.
10363 @item @kbd{C-c C-x C-s} or short @kbd{$} (@code{org-agenda-archive})
10364 @kindex C-c C-x C-s
10365 @kindex $
10366 @findex org-agenda-archive
10367 Archive the subtree corresponding to the current headline.  This
10368 means the entry is moved to the configured archive location, most
10369 likely a different file.
10371 @item @kbd{T} (@code{org-agenda-show-tags})
10372 @kindex T
10373 @findex org-agenda-show-tags
10374 @vindex org-agenda-show-inherited-tags
10375 Show all tags associated with the current item.  This is useful
10376 if you have turned off @code{org-agenda-show-inherited-tags}, but
10377 still want to see all tags of a headline occasionally.
10379 @item @kbd{:} (@code{org-agenda-set-tags})
10380 @kindex :
10381 @findex org-agenda-set-tags
10382 Set tags for the current headline.  If there is an active region
10383 in the agenda, change a tag for all headings in the region.
10385 @item @kbd{,} (@code{org-agenda-priority})
10386 @kindex ,
10387 @findex org-agenda-priority
10388 Set the priority for the current item.  Org mode prompts for the
10389 priority character.  If you reply with @kbd{@key{SPC}}, the
10390 priority cookie is removed from the entry.
10392 @item @kbd{P} (@code{org-agenda-show-priority})
10393 @kindex P
10394 @findex org-agenda-show-priority
10395 Display weighted priority of current item.
10397 @item @kbd{+} or @kbd{S-@key{UP}} (@code{org-agenda-priority-up})
10398 @kindex +
10399 @kindex S-UP
10400 @findex org-agenda-priority-up
10401 Increase the priority of the current item.  The priority is
10402 changed in the original buffer, but the agenda is not resorted.
10403 Use the @kbd{r} key for this.
10405 @item @kbd{-} or @kbd{S-@key{DOWN}} (@code{org-agenda-priority-down})
10406 @kindex -
10407 @kindex S-DOWN
10408 @findex org-agenda-priority-down
10409 Decrease the priority of the current item.
10411 @item @kbd{C-c C-z} or short @kbd{z} (@code{org-agenda-add-note})
10412 @kindex z
10413 @kindex C-c C-z
10414 @findex org-agenda-add-note
10415 @vindex org-log-into-drawer
10416 Add a note to the entry.  This note is recorded, and then filed
10417 to the same location where state change notes are put.  Depending
10418 on @code{org-log-into-drawer}, this may be inside a drawer.
10420 @item @kbd{C-c C-a} (@code{org-attach})
10421 @kindex C-c C-a
10422 @findex org-attach
10423 Dispatcher for all command related to attachments.
10425 @item @kbd{C-c C-s} (@code{org-agenda-schedule})
10426 @kindex C-c C-s
10427 @findex org-agenda-schedule
10428 Schedule this item.  With a prefix argument, remove the
10429 scheduling timestamp
10431 @item @kbd{C-c C-d} (@code{org-agenda-deadline})
10432 @kindex C-c C-d
10433 @findex org-agenda-deadline
10434 Set a deadline for this item.  With a prefix argument, remove the
10435 deadline.
10437 @item @kbd{S-@key{RIGHT}} (@code{org-agenda-do-date-later})
10438 @kindex S-RIGHT
10439 @findex org-agenda-do-date-later
10440 Change the timestamp associated with the current line by one day
10441 into the future.  If the date is in the past, the first call to
10442 this command moves it to today.  With a numeric prefix argument,
10443 change it by that many days.  For example, @kbd{3 6 5 S-@key{RIGHT}} changes it by a year.  With a @kbd{C-u}
10444 prefix, change the time by one hour.  If you immediately repeat
10445 the command, it will continue to change hours even without the
10446 prefix argument.  With a double @kbd{C-u C-u} prefix, do the
10447 same for changing minutes.  The stamp is changed in the original
10448 Org file, but the change is not directly reflected in the agenda
10449 buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
10451 @item @kbd{S-@key{LEFT}} (@code{org-agenda-do-date-earlier})
10452 @kindex S-LEFT
10453 @findex org-agenda-do-date-earlier
10454 Change the timestamp associated with the current line by one day
10455 into the past.
10457 @item @kbd{>} (@code{org-agenda-date-prompt})
10458 @kindex >
10459 @findex org-agenda-date-prompt
10460 Change the timestamp associated with the current line.  The key
10461 @kbd{>} has been chosen, because it is the same as
10462 @kbd{S-.}  on my keyboard.
10464 @item @kbd{I} (@code{org-agenda-clock-in})
10465 @kindex I
10466 @findex org-agenda-clock-in
10467 Start the clock on the current item.  If a clock is running
10468 already, it is stopped first.
10470 @item @kbd{O} (@code{org-agenda-clock-out})
10471 @kindex O
10472 @findex org-agenda-clock-out
10473 Stop the previously started clock.
10475 @item @kbd{X} (@code{org-agenda-clock-cancel})
10476 @kindex X
10477 @findex org-agenda-clock-cancel
10478 Cancel the currently running clock.
10480 @item @kbd{J} (@code{org-agenda-clock-goto})
10481 @kindex J
10482 @findex org-agenda-clock-goto
10483 Jump to the running clock in another window.
10485 @item @kbd{k} (@code{org-agenda-capture})
10486 @kindex k
10487 @findex org-agenda-capture
10488 @cindex capturing, from agenda
10489 @vindex org-capture-use-agenda-date
10490 Like @code{org-capture}, but use the date at point as the default date
10491 for the capture template.  See @code{org-capture-use-agenda-date} to
10492 make this the default behavior of @code{org-capture}.
10493 @end table
10495 @anchor{Bulk remote editing selected entries}
10496 @subheading Bulk remote editing selected entries
10498 @cindex remote editing, bulk, from agenda
10499 @vindex org-agenda-bulk-custom-functions
10501 @table @asis
10502 @item @kbd{m} (@code{org-agenda-bulk-mark})
10503 @kindex m
10504 @findex org-agenda-bulk-mark
10506 Mark the entry at point for bulk action.  If there is an active
10507 region in the agenda, mark the entries in the region.  With
10508 numeric prefix argument, mark that many successive entries.
10510 @item @kbd{*} (@code{org-agenda-bulk-mark-all})
10511 @kindex *
10512 @findex org-agenda-bulk-mark-all
10514 Mark all visible agenda entries for bulk action.
10516 @item @kbd{u} (@code{org-agenda-bulk-unmark})
10517 @kindex u
10518 @findex org-agenda-bulk-unmark
10520 Unmark entry for bulk action.
10522 @item @kbd{U} (@code{org-agenda-bulk-remove-all-marks})
10523 @kindex U
10524 @findex org-agenda-bulk-remove-all-marks
10526 Unmark all marked entries for bulk action.
10528 @item @kbd{M-m} (@code{org-agenda-bulk-toggle})
10529 @kindex M-m
10530 @findex org-agenda-bulk-toggle
10532 Toggle mark of the entry at point for bulk action.
10534 @item @kbd{M-*} (@code{org-agenda-bulk-toggle-all})
10535 @kindex M-*
10536 @findex org-agenda-bulk-toggle-all
10538 Mark entries matching a regular expression for bulk action.
10540 @item @kbd{%} (@code{org-agenda-bulk-mark-regexp})
10541 @kindex %
10542 @findex org-agenda-bulk-mark-regexp
10544 Mark entries matching a regular expression for bulk action.
10546 @item @kbd{B} (@code{org-agenda-bulk-action})
10547 @kindex B
10548 @findex org-agenda-bulk-action
10549 @vindex org-agenda-bulk-persistent-marks
10551 Bulk action: act on all marked entries in the agenda.  This
10552 prompts for another key to select the action to be applied.  The
10553 prefix argument to @kbd{B} is passed through to the
10554 @kbd{s} and @kbd{d} commands, to bulk-remove these
10555 special timestamps.  By default, marks are removed after the
10556 bulk.  If you want them to persist, set
10557 @code{org-agenda-bulk-persistent-marks} to @code{t} or hit @kbd{p} at
10558 the prompt.
10560 @table @asis
10561 @item @kbd{*}
10562 Toggle persistent marks.
10564 @item @kbd{$}
10565 Archive all selected entries.
10567 @item @kbd{A}
10568 Archive entries by moving them to their respective archive
10569 siblings.
10571 @item @kbd{t}
10572 Change TODO state.  This prompts for a single TODO keyword and
10573 changes the state of all selected entries, bypassing blocking
10574 and suppressing logging notes---but not timestamps.
10576 @item @kbd{+}
10577 Add a tag to all selected entries.
10579 @item @kbd{-}
10580 Remove a tag from all selected entries.
10582 @item @kbd{s}
10583 Schedule all items to a new date.  To shift existing schedule
10584 dates by a fixed number of days, use something starting with
10585 double plus at the prompt, for example @samp{++8d} or @samp{++2w}.
10587 @item @kbd{d}
10588 Set deadline to a specific date.
10590 @item @kbd{r}
10591 Prompt for a single refile target and move all entries.  The
10592 entries are no longer in the agenda; refresh (@kbd{g}) to
10593 bring them back.
10595 @item @kbd{S}
10596 Reschedule randomly into the coming N days.  N is prompted for.
10597 With a prefix argument (@kbd{C-u B S}), scatter only
10598 across weekdays.
10600 @item @kbd{f}
10601 @vindex org-agenda-bulk-custom-functions
10602 Apply a function@footnote{You can also create persistent custom functions through
10603 @code{org-agenda-bulk-custom-functions}.} to marked entries.  For example, the
10604 function below sets the @samp{CATEGORY} property of the entries to
10605 @samp{web}.
10607 @lisp
10608 (defun set-category ()
10609   (interactive "P")
10610   (let ((marker (or (org-get-at-bol 'org-hd-marker)
10611                     (org-agenda-error))))
10612     (org-with-point-at marker
10613       (org-back-to-heading t)
10614       (org-set-property "CATEGORY" "web"))))
10615 @end lisp
10616 @end table
10617 @end table
10619 @anchor{Calendar commands}
10620 @subheading Calendar commands
10622 @cindex calendar commands, from agenda
10624 @table @asis
10625 @item @kbd{c} (@code{org-agenda-goto-calendar})
10626 @kindex c
10627 @findex org-agenda-goto-calendar
10628 Open the Emacs calendar and move to the date at the agenda
10629 cursor.
10631 @item @kbd{c} (@code{org-calendar-goto-agenda})
10632 @kindex c
10633 @findex org-calendar-goto-agenda
10634 When in the calendar, compute and show the Org agenda for the
10635 date at the cursor.
10637 @item @kbd{i} (@code{org-agenda-diary-entry})
10638 @kindex i
10639 @findex org-agenda-diary-entry
10641 @cindex diary entries, creating from agenda
10642 Insert a new entry into the diary, using the date at the cursor
10643 and (for block entries) the date at the mark.  This adds to the
10644 Emacs diary file@footnote{This file is parsed for the agenda when
10645 @code{org-agenda-include-diary} is set.}, in a way similar to the @kbd{i}
10646 command in the calendar.  The diary file pops up in another
10647 window, where you can add the entry.
10649 @vindex org-agenda-diary-file
10650 If you configure @code{org-agenda-diary-file} to point to an Org file,
10651 Org creates entries in that file instead.  Most entries are
10652 stored in a date-based outline tree that will later make it easy
10653 to archive appointments from previous months/years.  The tree is
10654 built under an entry with a @samp{DATE_TREE} property, or else with
10655 years as top-level entries.  Emacs prompts you for the entry
10656 text---if you specify it, the entry is created in
10657 @code{org-agenda-diary-file} without further interaction.  If you
10658 directly press @kbd{@key{RET}} at the prompt without typing text,
10659 the target file is shown in another window for you to finish the
10660 entry there.  See also the @kbd{k r} command.
10662 @item @kbd{M} (@code{org-agenda-phases-of-moon})
10663 @kindex M
10664 @findex org-agenda-phases-of-moon
10665 Show the phases of the moon for the three months around current
10666 date.
10668 @item @kbd{S} (@code{org-agenda-sunrise-sunset})
10669 @kindex S
10670 @findex org-agenda-sunrise-sunset
10671 Show sunrise and sunset times.  The geographical location must be
10672 set with calendar variables, see the documentation for the Emacs
10673 calendar.
10675 @item @kbd{C} (@code{org-agenda-convert-date})
10676 @kindex C
10677 @findex org-agenda-convert-date
10678 Convert the date at cursor into many other cultural and historic
10679 calendars.
10681 @item @kbd{H} (@code{org-agenda-holidays})
10682 @kindex H
10683 @findex org-agenda-holidays
10684 Show holidays for three months around the cursor date.
10685 @end table
10687 @anchor{Quit and exit}
10688 @subheading Quit and exit
10690 @table @asis
10691 @item @kbd{q} (@code{org-agenda-quit})
10692 @kindex q
10693 @findex org-agenda-quit
10695 Quit agenda, remove the agenda buffer.
10697 @item @kbd{x} (@code{org-agenda-exit})
10698 @kindex x
10699 @findex org-agenda-exit
10701 @cindex agenda files, removing buffers
10702 Exit agenda, remove the agenda buffer and all buffers loaded by
10703 Emacs for the compilation of the agenda.  Buffers created by the
10704 user to visit Org files are not removed.
10705 @end table
10707 @node Custom Agenda Views
10708 @section Custom Agenda Views
10710 @cindex custom agenda views
10711 @cindex agenda views, custom
10713 Custom agenda commands serve two purposes: to store and quickly access
10714 frequently used TODO and tags searches, and to create special
10715 composite agenda buffers.  Custom agenda commands are accessible
10716 through the dispatcher (see @ref{Agenda Dispatcher}), just like the
10717 default commands.
10719 @menu
10720 * Storing searches::             Type once, use often.
10721 * Block agenda::                 All the stuff you need in a single buffer.
10722 * Setting options::              Changing the rules.
10723 @end menu
10725 @node Storing searches
10726 @subsection Storing searches
10728 The first application of custom searches is the definition of keyboard
10729 shortcuts for frequently used searches, either creating an agenda
10730 buffer, or a sparse tree (the latter covering of course only the
10731 current buffer).
10733 @kindex C @r{(Agenda dispatcher)}
10734 @vindex org-agenda-custom-commands
10735 @cindex agenda views, main example
10736 @cindex agenda, as an agenda views
10737 @cindex agenda*, as an agenda views
10738 @cindex tags, as an agenda view
10739 @cindex todo, as an agenda view
10740 @cindex tags-todo
10741 @cindex todo-tree
10742 @cindex occur-tree
10743 @cindex tags-tree
10744 Custom commands are configured in the variable
10745 @code{org-agenda-custom-commands}.  You can customize this variable, for
10746 example by pressing @kbd{C} from the agenda dispatcher (see @ref{Agenda Dispatcher}).  You can also directly set it with Emacs Lisp in
10747 the Emacs init file.  The following example contains all valid agenda
10748 views:
10750 @lisp
10751 (setq org-agenda-custom-commands
10752       '(("x" agenda)
10753         ("y" agenda*)
10754         ("w" todo "WAITING")
10755         ("W" todo-tree "WAITING")
10756         ("u" tags "+boss-urgent")
10757         ("v" tags-todo "+boss-urgent")
10758         ("U" tags-tree "+boss-urgent")
10759         ("f" occur-tree "\\<FIXME\\>")
10760         ("h" . "HOME+Name tags searches") ;description for "h" prefix
10761         ("hl" tags "+home+Lisa")
10762         ("hp" tags "+home+Peter")
10763         ("hk" tags "+home+Kim")))
10764 @end lisp
10766 @noindent
10767 The initial string in each entry defines the keys you have to press
10768 after the dispatcher command in order to access the command.  Usually
10769 this will be just a single character, but if you have many similar
10770 commands, you can also define two-letter combinations where the first
10771 character is the same in several combinations and serves as a prefix
10772 key@footnote{You can provide a description for a prefix key by inserting
10773 a cons cell with the prefix and the description.}.  The second parameter is the search type, followed by the
10774 string or regular expression to be used for the matching.  The example
10775 above will therefore define:
10777 @table @asis
10778 @item @kbd{x}
10779 as a global search for agenda entries planned@footnote{@emph{Planned} means here that these entries have some planning
10780 information attached to them, like a time-stamp, a scheduled or
10781 a deadline string.  See @code{org-agenda-entry-types} on how to set what
10782 planning information is taken into account.} this
10783 week/day.
10785 @item @kbd{y}
10786 as the same search, but only for entries with an hour
10787 specification like @samp{[h]h:mm}---think of them as appointments.
10789 @item @kbd{w}
10790 as a global search for TODO entries with @samp{WAITING} as the TODO
10791 keyword.
10793 @item @kbd{W}
10794 as the same search, but only in the current buffer and displaying
10795 the results as a sparse tree.
10797 @item @kbd{u}
10798 as a global tags search for headlines tagged @samp{boss} but not
10799 @samp{urgent}.
10801 @item @kbd{v}
10802 The same search, but limiting it to headlines that are also TODO
10803 items.
10805 @item @kbd{U}
10806 as the same search, but only in the current buffer and displaying
10807 the result as a sparse tree.
10809 @item @kbd{f}
10810 to create a sparse tree (again, current buffer only) with all
10811 entries containing the word @samp{FIXME}.
10813 @item @kbd{h}
10814 as a prefix command for a @samp{HOME} tags search where you have to
10815 press an additional key (@kbd{l}, @kbd{p} or
10816 @kbd{k}) to select a name (Lisa, Peter, or Kim) as
10817 additional tag to match.
10818 @end table
10820 Note that @code{*-tree} agenda views need to be called from an Org buffer
10821 as they operate on the current buffer only.
10823 @node Block agenda
10824 @subsection Block agenda
10826 @cindex block agenda
10827 @cindex agenda, with block views
10829 Another possibility is the construction of agenda views that comprise
10830 the results of @emph{several} commands, each of which creates a block in
10831 the agenda buffer.  The available commands include @code{agenda} for the
10832 daily or weekly agenda (as created with @kbd{a}) , @code{alltodo} for
10833 the global TODO list (as constructed with @kbd{t}), and the
10834 matching commands discussed above: @code{todo}, @code{tags}, and @code{tags-todo}.
10835 Here are two examples:
10837 @lisp
10838 (setq org-agenda-custom-commands
10839       '(("h" "Agenda and Home-related tasks"
10840          ((agenda "")
10841           (tags-todo "home")
10842           (tags "garden")))
10843         ("o" "Agenda and Office-related tasks"
10844          ((agenda "")
10845           (tags-todo "work")
10846           (tags "office")))))
10847 @end lisp
10849 @noindent
10850 This defines @kbd{h} to create a multi-block view for stuff you
10851 need to attend to at home.  The resulting agenda buffer contains your
10852 agenda for the current week, all TODO items that carry the tag @samp{home},
10853 and also all lines tagged with @samp{garden}.  Finally the command
10854 @kbd{o} provides a similar view for office tasks.
10856 @node Setting options
10857 @subsection Setting options for custom commands
10859 @cindex options, for custom agenda views
10861 @vindex org-agenda-custom-commands
10862 Org mode contains a number of variables regulating agenda construction
10863 and display.  The global variables define the behavior for all agenda
10864 commands, including the custom commands.  However, if you want to
10865 change some settings just for a single custom view, you can do so.
10866 Setting options requires inserting a list of variable names and values
10867 at the right spot in @code{org-agenda-custom-commands}.  For example:
10869 @lisp
10870 (setq org-agenda-custom-commands
10871       '(("w" todo "WAITING"
10872          ((org-agenda-sorting-strategy '(priority-down))
10873           (org-agenda-prefix-format "  Mixed: ")))
10874         ("U" tags-tree "+boss-urgent"
10875          ((org-show-context-detail 'minimal)))
10876         ("N" search ""
10877          ((org-agenda-files '("~org/notes.org"))
10878           (org-agenda-text-search-extra-files nil)))))
10879 @end lisp
10881 @noindent
10882 Now the @kbd{w} command sorts the collected entries only by
10883 priority, and the prefix format is modified to just say @samp{Mixed:}
10884 instead of giving the category of the entry.  The sparse tags tree of
10885 @kbd{U} now turns out ultra-compact, because neither the headline
10886 hierarchy above the match, nor the headline following the match are
10887 shown.  The command @kbd{N} does a text search limited to only
10888 a single file.
10890 For command sets creating a block agenda, @code{org-agenda-custom-commands}
10891 has two separate spots for setting options.  You can add options that
10892 should be valid for just a single command in the set, and options that
10893 should be valid for all commands in the set.  The former are just
10894 added to the command entry; the latter must come after the list of
10895 command entries.  Going back to the block agenda example (see @ref{Block agenda}), let's change the sorting strategy for the @kbd{h}
10896 commands to @code{priority-down}, but let's sort the results for GARDEN
10897 tags query in the opposite order, @code{priority-up}.  This would look like
10898 this:
10900 @lisp
10901 (setq org-agenda-custom-commands
10902       '(("h" "Agenda and Home-related tasks"
10903          ((agenda)
10904           (tags-todo "home")
10905           (tags "garden"
10906                 ((org-agenda-sorting-strategy '(priority-up)))))
10907          ((org-agenda-sorting-strategy '(priority-down))))
10908         ("o" "Agenda and Office-related tasks"
10909          ((agenda)
10910           (tags-todo "work")
10911           (tags "office")))))
10912 @end lisp
10914 As you see, the values and parentheses setting is a little complex.
10915 When in doubt, use the customize interface to set this variable---it
10916 fully supports its structure.  Just one caveat: when setting options
10917 in this interface, the @emph{values} are just Lisp expressions.  So if the
10918 value is a string, you need to add the double-quotes around the value
10919 yourself.
10921 @vindex org-agenda-custom-commands-contexts
10922 To control whether an agenda command should be accessible from
10923 a specific context, you can customize
10924 @code{org-agenda-custom-commands-contexts}.  Let's say for example that you
10925 have an agenda command @kbd{o} displaying a view that you only
10926 need when reading emails.  Then you would configure this option like
10927 this:
10929 @lisp
10930 (setq org-agenda-custom-commands-contexts
10931       '(("o" (in-mode . "message-mode"))))
10932 @end lisp
10934 You can also tell that the command key @kbd{o} should refer to
10935 another command key @kbd{r}.  In that case, add this command key
10936 like this:
10938 @lisp
10939 (setq org-agenda-custom-commands-contexts
10940       '(("o" "r" (in-mode . "message-mode"))))
10941 @end lisp
10943 See the docstring of the variable for more information.
10945 @node Exporting Agenda Views
10946 @section Exporting Agenda Views
10948 @cindex agenda views, exporting
10950 If you are away from your computer, it can be very useful to have
10951 a printed version of some agenda views to carry around.  Org mode can
10952 export custom agenda views as plain text, HTML@footnote{For HTML you need to install Hrvoje Niksic's @samp{htmlize.el}
10953 from @uref{https://github.com/hniksic/emacs-htmlize, Hrvoje Niksic's repository}.}, Postscript,
10954 PDF@footnote{To create PDF output, the Ghostscript ps2pdf utility must be
10955 installed on the system.  Selecting a PDF file also creates the
10956 postscript file.}, and iCalendar files.  If you want to do this only
10957 occasionally, use the following command:
10959 @table @asis
10960 @item @kbd{C-x C-w} (@code{org-agenda-write})
10961 @kindex C-x C-w
10962 @findex org-agenda-write
10963 @cindex exporting agenda views
10964 @cindex agenda views, exporting
10966 @vindex org-agenda-exporter-settings
10967 Write the agenda view to a file.
10968 @end table
10970 If you need to export certain agenda views frequently, you can
10971 associate any custom agenda command with a list of output file
10972 names@footnote{If you want to store standard views like the weekly agenda or
10973 the global TODO list as well, you need to define custom commands for
10974 them in order to be able to specify file names.}.  Here is an example that first defines custom commands
10975 for the agenda and the global TODO list, together with a number of
10976 files to which to export them.  Then we define two block agenda
10977 commands and specify file names for them as well.  File names can be
10978 relative to the current working directory, or absolute.
10980 @lisp
10981 (setq org-agenda-custom-commands
10982       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
10983         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
10984         ("h" "Agenda and Home-related tasks"
10985          ((agenda "")
10986           (tags-todo "home")
10987           (tags "garden"))
10988          nil
10989          ("~/views/home.html"))
10990         ("o" "Agenda and Office-related tasks"
10991          ((agenda)
10992           (tags-todo "work")
10993           (tags "office"))
10994          nil
10995          ("~/views/office.ps" "~/calendars/office.ics"))))
10996 @end lisp
10998 The extension of the file name determines the type of export.  If it
10999 is @samp{.html}, Org mode uses the htmlize package to convert the buffer to
11000 HTML and save it to this file name.  If the extension is @samp{.ps},
11001 @code{ps-print-buffer-with-faces} is used to produce Postscript output.  If
11002 the extension is @samp{.ics}, iCalendar export is run export over all files
11003 that were used to construct the agenda, and limit the export to
11004 entries listed in the agenda.  Any other extension produces a plain
11005 ASCII file.
11007 The export files are @emph{not} created when you use one of those
11008 commands interactively because this might use too much overhead.
11009 Instead, there is a special command to produce @emph{all} specified
11010 files in one step:
11012 @table @asis
11013 @item @kbd{e} (@code{org-store-agenda-views})
11014 @kindex e @r{(Agenda dispatcher)}
11015 @findex org-store-agenda-views
11016 Export all agenda views that have export file names associated
11017 with them.
11018 @end table
11020 You can use the options section of the custom agenda commands to also
11021 set options for the export commands.  For example:
11023 @lisp
11024 (setq org-agenda-custom-commands
11025       '(("X" agenda ""
11026          ((ps-number-of-columns 2)
11027           (ps-landscape-mode t)
11028           (org-agenda-prefix-format " [ ] ")
11029           (org-agenda-with-colors nil)
11030           (org-agenda-remove-tags t))
11031          ("theagenda.ps"))))
11032 @end lisp
11034 @noindent
11035 @vindex org-agenda-exporter-settings
11036 This command sets two options for the Postscript exporter, to make it
11037 print in two columns in landscape format---the resulting page can be
11038 cut in two and then used in a paper agenda.  The remaining settings
11039 modify the agenda prefix to omit category and scheduling information,
11040 and instead include a checkbox to check off items.  We also remove the
11041 tags to make the lines compact, and we do not want to use colors for
11042 the black-and-white printer.  Settings specified in
11043 @code{org-agenda-exporter-settings} also apply, e.g.,
11045 @lisp
11046 (setq org-agenda-exporter-settings
11047       '((ps-number-of-columns 2)
11048         (ps-landscape-mode t)
11049         (org-agenda-add-entry-text-maxlines 5)
11050         (htmlize-output-type 'css)))
11051 @end lisp
11053 @noindent
11054 but the settings in @code{org-agenda-custom-commands} take precedence.
11056 @noindent
11057 From the command line you may also use:
11059 @example
11060 emacs -eval (org-batch-store-agenda-views) -kill
11061 @end example
11063 @noindent
11064 or, if you need to modify some parameters@footnote{Quoting depends on the system you use, please check the FAQ
11065 for examples.}
11067 @example
11068 emacs -eval '(org-batch-store-agenda-views                      \
11069               org-agenda-span (quote month)                     \
11070               org-agenda-start-day "2007-11-01"                 \
11071               org-agenda-include-diary nil                      \
11072               org-agenda-files (quote ("~/org/project.org")))'  \
11073       -kill
11074 @end example
11076 @noindent
11077 which creates the agenda views restricted to the file
11078 @samp{~/org/project.org}, without diary entries and with a 30-day extent.
11080 You can also extract agenda information in a way that allows further
11081 processing by other programs.  See @ref{Extracting Agenda Information}, for
11082 more information.
11084 @node Agenda Column View
11085 @section Using Column View in the Agenda
11087 @cindex column view, in agenda
11088 @cindex agenda, column view
11090 Column view (see @ref{Column View}) is normally used to view and edit
11091 properties embedded in the hierarchical structure of an Org file.  It
11092 can be quite useful to use column view also from the agenda, where
11093 entries are collected by certain criteria.
11095 @table @asis
11096 @item @kbd{C-c C-x C-c} (@code{org-agenda-columns})
11097 @kindex C-c C-x C-c
11098 @findex org-agenda-columns
11100 Turn on column view in the agenda.
11101 @end table
11103 To understand how to use this properly, it is important to realize
11104 that the entries in the agenda are no longer in their proper outline
11105 environment.  This causes the following issues:
11107 @enumerate
11108 @item
11109 @vindex org-columns-default-format
11110 @vindex org-overriding-columns-format
11111 Org needs to make a decision which columns format to use.  Since
11112 the entries in the agenda are collected from different files, and
11113 different files may have different columns formats, this is
11114 a non-trivial problem.  Org first checks if the variable
11115 @code{org-agenda-overriding-columns-format} is currently set, and if so,
11116 takes the format from there.  Otherwise it takes the format
11117 associated with the first item in the agenda, or, if that item does
11118 not have a specific format (defined in a property, or in its file),
11119 it uses @code{org-columns-default-format}.
11121 @item
11122 @cindex @samp{CLOCKSUM}, special property
11123 If any of the columns has a summary type defined (see @ref{Column attributes}), turning on column view in the agenda visits all
11124 relevant agenda files and make sure that the computations of this
11125 property are up to date.  This is also true for the special
11126 @samp{CLOCKSUM} property.  Org then sums the values displayed in the
11127 agenda.  In the daily/weekly agenda, the sums cover a single day;
11128 in all other views they cover the entire block.
11130 It is important to realize that the agenda may show the same entry
11131 @emph{twice}---for example as scheduled and as a deadline---and it may
11132 show two entries from the same hierarchy (for example a @emph{parent}
11133 and its @emph{child}).  In these cases, the summation in the agenda
11134 leads to incorrect results because some values count double.
11136 @item
11137 When the column view in the agenda shows the @samp{CLOCKSUM} property,
11138 that is always the entire clocked time for this item.  So even in
11139 the daily/weekly agenda, the clocksum listed in column view may
11140 originate from times outside the current view.  This has the
11141 advantage that you can compare these values with a column listing
11142 the planned total effort for a task---one of the major
11143 applications for column view in the agenda.  If you want
11144 information about clocked time in the displayed period use clock
11145 table mode (press @kbd{R} in the agenda).
11147 @item
11148 @cindex @samp{CLOCKSUM_T}, special property
11149 When the column view in the agenda shows the @samp{CLOCKSUM_T} property,
11150 that is always today's clocked time for this item.  So even in the
11151 weekly agenda, the clocksum listed in column view only originates
11152 from today.  This lets you compare the time you spent on a task for
11153 today, with the time already spent---via @samp{CLOCKSUM}---and with
11154 the planned total effort for it.
11155 @end enumerate
11157 @node Markup
11158 @chapter Markup for Rich Export
11160 When exporting Org documents, the exporter tries to reflect the
11161 structure of the document as accurately as possible in the back-end.
11162 Since export targets like HTML and @LaTeX{} allow much richer formatting,
11163 Org mode has rules on how to prepare text for rich export.  This
11164 section summarizes the markup rules used in an Org mode buffer.
11166 @menu
11167 * Paragraphs::                   The basic unit of text.
11168 * Emphasis and Monospace::       Bold, italic, etc.
11169 * Horizontal Rules::             Make a line.
11170 * Images and Tables::            Images, tables and caption mechanism.
11171 * Literal Examples::             Source code examples with special formatting.
11172 * Special Symbols::              Greek letters and other symbols.
11173 * Subscripts and Superscripts::  Simple syntax for raising/lowering text.
11174 * Embedded @LaTeX{}::            LaTeX can be freely used inside Org documents.
11175 @end menu
11177 @node Paragraphs
11178 @section Paragraphs
11180 @cindex paragraphs, markup rules
11182 Paragraphs are separated by at least one empty line.  If you need to
11183 enforce a line break within a paragraph, use @code{\\} at the end of
11184 a line.
11186 To preserve the line breaks, indentation and blank lines in a region,
11187 but otherwise use normal formatting, you can use this construct, which
11188 can also be used to format poetry.
11190 @cindex @samp{BEGIN_VERSE}
11191 @cindex verse blocks
11192 @example
11193 #+BEGIN_VERSE
11194  Great clouds overhead
11195  Tiny black birds rise and fall
11196  Snow covers Emacs
11198     ---AlexSchroeder
11199 #+END_VERSE
11200 @end example
11202 When quoting a passage from another document, it is customary to
11203 format this as a paragraph that is indented on both the left and the
11204 right margin.  You can include quotations in Org documents like this:
11206 @cindex @samp{BEGIN_QUOTE}
11207 @cindex quote blocks
11208 @example
11209 #+BEGIN_QUOTE
11210 Everything should be made as simple as possible,
11211 but not any simpler ---Albert Einstein
11212 #+END_QUOTE
11213 @end example
11215 If you would like to center some text, do it like this:
11217 @cindex @samp{BEGIN_CENTER}
11218 @cindex center blocks
11219 @example
11220 #+BEGIN_CENTER
11221 Everything should be made as simple as possible, \\
11222 but not any simpler
11223 #+END_CENTER
11224 @end example
11226 @node Emphasis and Monospace
11227 @section Emphasis and Monospace
11229 @cindex underlined text, markup rules
11230 @cindex bold text, markup rules
11231 @cindex italic text, markup rules
11232 @cindex verbatim text, markup rules
11233 @cindex code text, markup rules
11234 @cindex strike-through text, markup rules
11236 You can make words @samp{*bold*}, @samp{/italic/}, @samp{_underlined_}, @samp{=verbatim=}
11237 and @samp{~code~}, and, if you must, @samp{+strike-through+}.  Text in the code
11238 and verbatim string is not processed for Org mode specific syntax; it
11239 is exported verbatim.
11241 @vindex org-fontify-emphasized-text
11242 To turn off fontification for marked up text, you can set
11243 @code{org-fontify-emphasized-text} to @code{nil}.  To narrow down the list of
11244 available markup syntax, you can customize @code{org-emphasis-alist}.
11246 @node Horizontal Rules
11247 @section Horizontal Rules
11249 @cindex horizontal rules, markup rules
11251 A line consisting of only dashes, and at least 5 of them, is exported
11252 as a horizontal line.
11254 @node Images and Tables
11255 @section Images and Tables
11257 @cindex tables, markup rules
11258 @cindex @samp{CAPTION}, keyword
11259 @cindex @samp{NAME}, keyword
11261 Both the native Org mode tables (see @ref{Tables}) and tables formatted
11262 with the @samp{table.el} package are exported properly.  For Org mode
11263 tables, the lines before the first horizontal separator line become
11264 table header lines.  You can use the following lines somewhere before
11265 the table to assign a caption and a label for cross references, and in
11266 the text you can refer to the object with @samp{[[tab:basic-data]]} (see
11267 @ref{Internal Links}):
11269 @example
11270 #+CAPTION: This is the caption for the next table (or link)
11271 #+NAME:   tab:basic-data
11272 | ... | ... |
11273 |-----+-----|
11274 @end example
11276 Optionally, the caption can take the form:
11278 @example
11279 #+CAPTION[Caption for list of tables]: Caption for table.
11280 @end example
11282 @cindex inlined images, markup rules
11283 Some back-ends allow you to directly include images into the exported
11284 document.  Org does this, if a link to an image file does not have
11285 a description part, for example @samp{[[./img/a.jpg]]}.  If you wish to define
11286 a caption for the image and maybe a label for internal cross
11287 references, make sure that the link is on a line by itself and precede
11288 it with @samp{CAPTION} and @samp{NAME} keywords as follows:
11290 @example
11291 #+CAPTION: This is the caption for the next figure link (or table)
11292 #+NAME:   fig:SED-HR4049
11293 [[./img/a.jpg]]
11294 @end example
11296 @noindent
11297 Such images can be displayed within the buffer.  See @ref{Handling Links, , the discussion of
11298 image links}.
11300 Even though images and tables are prominent examples of captioned
11301 structures, the same caption mechanism can apply to many
11302 others---e.g., @LaTeX{} equations, source code blocks.  Depending on the
11303 export back-end, those may or may not be handled.
11305 @node Literal Examples
11306 @section Literal Examples
11308 @cindex literal examples, markup
11309 @cindex code line references, markup
11311 You can include literal examples that should not be subjected to
11312 markup.  Such examples are typeset in monospace, so this is well
11313 suited for source code and similar examples.
11315 @cindex @samp{BEGIN_EXAMPLE}
11316 @cindex example block
11317 @example
11318 #+BEGIN_EXAMPLE
11319   Some example from a text file.
11320 #+END_EXAMPLE
11321 @end example
11323 Note that such blocks may be @emph{indented} in order to align nicely with
11324 indented text and in particular with plain list structure (see
11325 @ref{Plain Lists}).  For simplicity when using small examples, you can
11326 also start the example lines with a colon followed by a space.  There
11327 may also be additional whitespace before the colon:
11329 @example
11330 Here is an example
11331    : Some example from a text file.
11332 @end example
11334 @cindex formatting source code, markup rules
11335 @vindex org-latex-listings
11336 If the example is source code from a programming language, or any
11337 other text that can be marked up by Font Lock in Emacs, you can ask
11338 for the example to look like the fontified Emacs buffer@footnote{This works automatically for the HTML backend (it requires
11339 version 1.34 of the @samp{htmlize.el} package, which you need to install).
11340 Fontified code chunks in @LaTeX{} can be achieved using either the
11341 listings package or the @uref{https://github.com/gpoore/minted, minted} package.  Refer to
11342 @code{org-export-latex-listings} for details.}.  This
11343 is done with the code block, where you also need to specify the name
11344 of the major mode that should be used to fontify the example@footnote{Source code in code blocks may also be evaluated either
11345 interactively or on export.  See @ref{Working with Source Code} for more
11346 information on evaluating code blocks.},
11347 see @ref{Structure Templates} for shortcuts to easily insert code blocks.
11349 @cindex @samp{BEGIN_SRC}
11350 @cindex src block
11351 @example
11352 #+BEGIN_SRC emacs-lisp
11353   (defun org-xor (a b)
11354     "Exclusive or."
11355     (if a (not b) b))
11356  #+END_SRC
11357 @end example
11359 Both in @samp{example} and in @samp{src} snippets, you can add a @samp{-n} switch to
11360 the end of the @samp{#+BEGIN} line, to get the lines of the example
11361 numbered.  The @samp{-n} takes an optional numeric argument specifying the
11362 starting line number of the block.  If you use a @samp{+n} switch, the
11363 numbering from the previous numbered snippet is continued in the
11364 current one.  The @samp{+n} switch can also take a numeric argument.  This
11365 adds the value of the argument to the last line of the previous block
11366 to determine the starting line number.
11368 @example
11369 #+BEGIN_SRC emacs-lisp -n 20
11370   ;; This exports with line number 20.
11371   (message "This is line 21")
11372 #+END_SRC
11374 #+BEGIN_SRC emacs-lisp +n 10
11375   ;; This is listed as line 31.
11376   (message "This is line 32")
11377 #+END_SRC
11378 @end example
11380 In literal examples, Org interprets strings like @samp{(ref:name)} as
11381 labels, and use them as targets for special hyperlinks like
11382 @samp{[[(name)]]}---i.e., the reference name enclosed in single parenthesis.
11383 In HTML, hovering the mouse over such a link remote-highlights the
11384 corresponding code line, which is kind of cool.
11386 You can also add a @samp{-r} switch which @emph{removes} the labels from the
11387 source code@footnote{Adding @samp{-k} to @samp{-n -r} @emph{keeps} the labels in the source code
11388 while using line numbers for the links, which might be useful to
11389 explain those in an Org mode example code.}.  With the @samp{-n} switch, links to these references
11390 are labeled by the line numbers from the code listing.  Otherwise
11391 links use the labels with no parentheses.  Here is an example:
11393 @example
11394 #+BEGIN_SRC emacs-lisp -n -r
11395   (save-excursion                 (ref:sc)
11396      (goto-char (point-min))      (ref:jump)
11397 #+END_SRC
11398 In line [[(sc)]] we remember the current position. [[(jump)][Line (jump)]]
11399 jumps to point-min.
11400 @end example
11402 @cindex indentation, in source blocks
11403 Finally, you can use @samp{-i} to preserve the indentation of a specific
11404 code block (see @ref{Editing Source Code}).
11406 @vindex org-coderef-label-format
11407 If the syntax for the label format conflicts with the language syntax,
11408 use a @samp{-l} switch to change the format, for example
11410 @example
11411 #+BEGIN_SRC pascal -n -r -l "((%s))"
11412 @end example
11414 @noindent
11415 See also the variable @code{org-coderef-label-format}.
11417 HTML export also allows examples to be published as text areas (see
11418 @ref{Text areas in HTML export}).
11420 Because the @samp{#+BEGIN} @dots{} @samp{#+END} patterns need to be added so often,
11421 a shortcut is provided (see @ref{Structure Templates}).
11423 @table @asis
11424 @item @kbd{C-c '} (@code{org-edit-special})
11425 @kindex C-c '
11426 @findex org-edit-special
11427 Edit the source code example at point in its native mode.  This
11428 works by switching to a temporary buffer with the source code.
11429 You need to exit by pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*}, @samp{,*}, @samp{#+} and @samp{,#+} get
11430 a comma prepended, to keep them from being interpreted by Org as
11431 outline nodes or special syntax.  These commas are stripped when
11432 editing with @kbd{C-c '}, and also before export.}.  The
11433 edited version then replaces the old version in the Org buffer.
11434 Fixed-width regions---where each line starts with a colon
11435 followed by a space---are edited using @code{artist-mode}@footnote{You may select a different-mode with the variable
11436 @code{org-edit-fixed-width-region-mode}.} to
11437 allow creating ASCII drawings easily.  Using this command in an
11438 empty line creates a new fixed-width region.
11439 @end table
11441 @cindex storing link, in a source code buffer
11442 Calling @code{org-store-link} (see @ref{Handling Links}) while editing a source
11443 code example in a temporary buffer created with @kbd{C-c '}
11444 prompts for a label.  Make sure that it is unique in the current
11445 buffer, and insert it with the proper formatting like @samp{(ref:label)} at
11446 the end of the current line.  Then the label is stored as a link
11447 @samp{(label)}, for retrieval with @kbd{C-c C-l}.
11449 @node Special Symbols
11450 @section Special Symbols
11452 @cindex math symbols
11453 @cindex special symbols
11454 @cindex @TeX{} macros
11455 @cindex @LaTeX{} fragments, markup rules
11456 @cindex HTML entities
11457 @cindex @LaTeX{} entities
11459 You can use @LaTeX{}-like syntax to insert special symbols---named
11460 entities---like @samp{\alpha} to indicate the Greek letter, or @samp{\to} to indicate
11461 an arrow.  Completion for these symbols is available, just type @samp{\}
11462 and maybe a few letters, and press @kbd{M-@key{TAB}} to see possible
11463 completions.  If you need such a symbol inside a word, terminate it
11464 with a pair of curly brackets.  For example
11466 @example
11467 Pro tip: Given a circle \Gamma of diameter d, the length of its
11468 circumference is \pi@{@}d.
11469 @end example
11471 @findex org-entities-help
11472 @vindex org-entities-user
11473 A large number of entities is provided, with names taken from both
11474 HTML and @LaTeX{}; you can comfortably browse the complete list from
11475 a dedicated buffer using the command @code{org-entities-help}.  It is also
11476 possible to provide your own special symbols in the variable
11477 @code{org-entities-user}.
11479 During export, these symbols are transformed into the native format of
11480 the exporter back-end.  Strings like @samp{\alpha} are exported as @samp{&alpha;} in
11481 the HTML output, and as @samp{\(\alpha\)} in the @LaTeX{} output.  Similarly, @samp{\nbsp}
11482 becomes @samp{&nbsp;} in HTML and @samp{~} in @LaTeX{}.
11484 @cindex escaping characters
11485 Entities may also be used as a way to escape markup in an Org
11486 document, e.g., @samp{\under@{@}not underlined\under} exports as @samp{_not underlined_}.
11488 @cindex special symbols, in-buffer display
11489 If you would like to see entities displayed as UTF-8 characters, use
11490 the following command@footnote{You can turn this on by default by setting the variable
11491 @code{org-pretty-entities}, or on a per-file base with the @samp{STARTUP} option
11492 @samp{entitiespretty}.}:
11494 @table @asis
11495 @item @kbd{C-c C-x \} (@code{org-toggle-pretty-entities})
11496 @kindex C-c C-x \
11497 @findex org-toggle-pretty-entities
11499 Toggle display of entities as UTF-8 characters.  This does not
11500 change the buffer content which remains plain ASCII, but it
11501 overlays the UTF-8 character for display purposes only.
11502 @end table
11504 @cindex shy hyphen, special symbol
11505 @cindex dash, special symbol
11506 @cindex ellipsis, special symbol
11507 In addition to regular entities defined above, Org exports in
11508 a special way@footnote{This behavior can be disabled with @samp{-} export setting (see
11509 @ref{Export Settings}).} the following commonly used character
11510 combinations: @samp{\-} is treated as a shy hyphen, @samp{--} and @samp{---} are
11511 converted into dashes, and @samp{...} becomes a compact set of dots.
11513 @node Subscripts and Superscripts
11514 @section Subscripts and Superscripts
11516 @cindex subscript
11517 @cindex superscript
11519 @samp{^} and @samp{_} are used to indicate super- and subscripts.  To increase
11520 the readability of ASCII text, it is not necessary, but OK, to
11521 surround multi-character sub- and superscripts with curly braces.  For
11522 example
11524 @example
11525 The radius of the sun is R_sun = 6.96 x 10^8 m.  On the other hand,
11526 the radius of Alpha Centauri is R_@{Alpha Centauri@} = 1.28 x R_@{sun@}.
11527 @end example
11529 @vindex org-use-sub-superscripts
11530 If you write a text where the underscore is often used in a different
11531 context, Org's convention to always interpret these as subscripts can
11532 get in your way.  Configure the variable @code{org-use-sub-superscripts} to
11533 change this convention.  For example, when setting this variable to
11534 @code{@{@}}, @samp{a_b} is not interpreted as a subscript, but @samp{a_@{b@}} is.
11536 @table @asis
11537 @item @kbd{C-c C-x \} (@code{org-toggle-pretty-entities~})
11538 @kindex C-c C-x \
11539 @findex org-toggle-pretty-entities
11541 In addition to showing entities as UTF-8 characters, this command
11542 also formats sub- and superscripts in a WYSIWYM way.
11543 @end table
11545 @node Embedded @LaTeX{}
11546 @section Embedded @LaTeX{}
11548 @cindex @TeX{} interpretation
11549 @cindex @LaTeX{} interpretation
11551 Plain ASCII is normally sufficient for almost all note taking.
11552 Exceptions include scientific notes, which often require mathematical
11553 symbols and the occasional formula.  @LaTeX{}@footnote{@LaTeX{} is a macro system based on Donald@tie{}E.@tie{}Knuth's @TeX{}
11554 system.  Many of the features described here as ``@LaTeX{}'' are really
11555 from @TeX{}, but for simplicity I am blurring this distinction.} is widely used to
11556 typeset scientific documents.  Org mode supports embedding @LaTeX{} code
11557 into its files, because many academics are used to writing and reading
11558 @LaTeX{} source code, and because it can be readily processed to produce
11559 pretty output for a number of export back-ends.
11561 @menu
11562 * @LaTeX{} fragments::           Complex formulas made easy.
11563 * Previewing @LaTeX{} fragments:: What will this snippet look like?
11564 * CD@LaTeX{} mode::              Speed up entering of formulas.
11565 @end menu
11567 @node @LaTeX{} fragments
11568 @subsection @LaTeX{} fragments
11570 @cindex @LaTeX{} fragments
11572 @vindex org-format-latex-header
11573 Org mode can contain @LaTeX{} math fragments, and it supports ways to
11574 process these for several export back-ends.  When exporting to @LaTeX{},
11575 the code is left as it is.  When exporting to HTML, Org can use either
11576 @uref{http://www.mathjax.org, MathJax} (see @ref{Math formatting in HTML export}) or transcode the math
11577 into images (see @ref{Previewing @LaTeX{} fragments}).
11579 @LaTeX{} fragments do not need any special marking at all.  The following
11580 snippets are identified as @LaTeX{} source code:
11582 @itemize
11583 @item
11584 Environments of any kind@footnote{When MathJax is used, only the environments recognized by
11585 MathJax are processed.  When dvipng, dvisvgm, or ImageMagick suite is
11586 used to create images, any @LaTeX{} environment is handled.}.  The only requirement is that the
11587 @samp{\begin} statement appears on a new line, preceded by only
11588 whitespace.
11590 @item
11591 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts
11592 with currency specifications, single @samp{$} characters are only
11593 recognized as math delimiters if the enclosed text contains at most
11594 two line breaks, is directly attached to the @samp{$} characters with no
11595 whitespace in between, and if the closing @samp{$} is followed by
11596 whitespace, punctuation or a dash.  For the other delimiters, there
11597 is no such restriction, so when in doubt, use @samp{\(...\)} as inline
11598 math delimiters.
11599 @end itemize
11601 @noindent
11602 For example:
11604 @example
11605 \begin@{equation@}                        % arbitrary environments,
11606 x=\sqrt@{b@}                              % even tables, figures
11607 \end@{equation@}                          % etc
11609 If $a^2=b$ and \( b=2 \), then the solution must be
11610 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
11611 @end example
11613 @vindex org-export-with-latex
11614 @LaTeX{} processing can be configured with the variable
11615 @code{org-export-with-latex}.  The default setting is @code{t} which means
11616 MathJax for HTML, and no processing for ASCII and @LaTeX{} back-ends.
11617 You can also set this variable on a per-file basis using one of these
11618 lines:
11620 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
11621 @item @samp{#+OPTIONS: tex:t}
11622 @tab Do the right thing automatically (MathJax)
11623 @item @samp{#+OPTIONS: tex:nil}
11624 @tab Do not process @LaTeX{} fragments at all
11625 @item @samp{#+OPTIONS: tex:verbatim}
11626 @tab Verbatim export, for jsMath or so
11627 @end multitable
11629 @node Previewing @LaTeX{} fragments
11630 @subsection Previewing @LaTeX{} fragments
11632 @cindex @LaTeX{} fragments, preview
11634 @vindex org-preview-latex-default-process
11635 If you have a working @LaTeX{} installation and @samp{dvipng}, @samp{dvisvgm} or
11636 @samp{convert} installed@footnote{These are respectively available at
11637 @uref{http://sourceforge.net/projects/dvipng/}, @uref{http://dvisvgm.bplaced.net/}
11638 and from the ImageMagick suite.  Choose the converter by setting the
11639 variable @code{org-preview-latex-default-process} accordingly.}, @LaTeX{} fragments can be processed to
11640 produce images of the typeset expressions to be used for inclusion
11641 while exporting to HTML (see @ref{@LaTeX{} fragments}), or for inline
11642 previewing within Org mode.
11644 @vindex org-format-latex-options
11645 @vindex org-format-latex-header
11646 You can customize the variables @code{org-format-latex-options} and
11647 @code{org-format-latex-header} to influence some aspects of the preview.
11648 In particular, the @code{:scale} (and for HTML export, @code{:html-scale})
11649 property of the former can be used to adjust the size of the preview
11650 images.
11652 @table @asis
11653 @item @kbd{C-c C-x C-l} (@code{org-toggle-latex-fragment})
11654 @kindex C-c C-x C-l
11655 @findex org-toggle-latex-fragment
11657 Produce a preview image of the @LaTeX{} fragment at point and
11658 overlay it over the source code.  If there is no fragment at
11659 point, process all fragments in the current entry (between two
11660 headlines).  When called with a prefix argument, process the
11661 entire subtree.  When called with two prefix arguments, or when
11662 the cursor is before the first headline, process the entire
11663 buffer.
11664 @end table
11666 @vindex org-startup-with-latex-preview
11667 You can turn on the previewing of all @LaTeX{} fragments in a file with
11669 @example
11670 #+STARTUP: latexpreview
11671 @end example
11673 To disable it, simply use
11675 @example
11676 #+STARTUP: nolatexpreview
11677 @end example
11679 @node CD@LaTeX{} mode
11680 @subsection Using CD@LaTeX{} to enter math
11682 @cindex CD@LaTeX{}
11684 CD@LaTeX{} mode is a minor mode that is normally used in combination with
11685 a major @LaTeX{} mode like AUC@TeX{} in order to speed-up insertion of
11686 environments and math templates.  Inside Org mode, you can make use of
11687 some of the features of CD@LaTeX{} mode.  You need to install
11688 @samp{cdlatex.el} and @samp{texmathp.el} (the latter comes also with AUC@TeX{})
11689 from @uref{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.  Do not use
11690 CD@LaTeX{} mode itself under Org mode, but use the light version
11691 @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it on for the
11692 current buffer with @kbd{M-x org-cdlatex-mode}, or for all Org
11693 files with
11695 @lisp
11696 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
11697 @end lisp
11699 When this mode is enabled, the following features are present (for
11700 more details see the documentation of CD@LaTeX{} mode):
11702 @table @asis
11703 @item @kbd{C-c @{}
11704 @kindex C-c @{
11706 Insert an environment template.
11708 @item @kbd{@key{TAB}}
11709 @kindex TAB
11711 The @kbd{@key{TAB}} key expands the template if the cursor is
11712 inside a @LaTeX{} fragment@footnote{Org mode has a method to test if the cursor is inside such
11713 a fragment, see the documentation of the function
11714 @code{org-inside-LaTeX-fragment-p}.}.  For example, @kbd{@key{TAB}}
11715 expands @samp{fr} to @samp{\frac@{@}@{@}} and position the cursor correctly
11716 inside the first brace.  Another @kbd{@key{TAB}} gets you into the
11717 second brace.
11719 Even outside fragments, @kbd{@key{TAB}} expands environment
11720 abbreviations at the beginning of a line.  For example, if you
11721 write @samp{equ} at the beginning of a line and press @kbd{@key{TAB}},
11722 this abbreviation is expanded to an @samp{equation} environment.  To
11723 get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
11725 @item @kbd{^}
11726 @itemx @kbd{_}
11727 @kindex _
11728 @kindex ^
11729 @vindex cdlatex-simplify-sub-super-scripts
11731 Pressing @kbd{_} and @kbd{^} inside a @LaTeX{} fragment
11732 inserts these characters together with a pair of braces.  If you
11733 use @kbd{@key{TAB}} to move out of the braces, and if the braces
11734 surround only a single character or macro, they are removed again
11735 (depending on the variable @code{cdlatex-simplify-sub-super-scripts}).
11737 @item @kbd{`}
11738 @kindex `
11740 Pressing the backquote followed by a character inserts math
11741 macros, also outside @LaTeX{} fragments.  If you wait more than 1.5
11742 seconds after the backquote, a help window pops up.
11744 @item @kbd{'}
11745 @kindex '
11747 Pressing the single-quote followed by another character modifies
11748 the symbol before point with an accent or a font.  If you wait
11749 more than 1.5 seconds after the single-quote, a help window pops
11750 up.  Character modification works only inside @LaTeX{} fragments;
11751 outside the quote is normal.
11752 @end table
11754 @node Exporting
11755 @chapter Exporting
11757 @cindex exporting
11759 Sometimes, you may want to pretty print your notes, publish them on
11760 the web or even share them with people not using Org.  In these cases,
11761 the Org export facilities can be used to convert your documents to
11762 a variety of other formats, while retaining as much structure (see
11763 @ref{Document Structure}) and markup (see @ref{Markup}) as
11764 possible.
11766 @cindex export back-end
11767 Libraries responsible for such translation are called back-ends.  Org
11768 ships with the following ones
11770 @itemize
11771 @item
11772 @emph{ascii} (ASCII format)
11773 @item
11774 @emph{beamer} (@LaTeX{} Beamer format)
11775 @item
11776 @emph{html} (HTML format)
11777 @item
11778 @emph{icalendar} (iCalendar format)
11779 @item
11780 @emph{latex} (@LaTeX{} format)
11781 @item
11782 @emph{md} (Markdown format)
11783 @item
11784 @emph{odt} (OpenDocument Text format)
11785 @item
11786 @emph{org} (Org format)
11787 @item
11788 @emph{texinfo} (Texinfo format)
11789 @item
11790 @emph{man} (Man page format)
11791 @end itemize
11793 @noindent
11794 Org also uses additional libraries located in @samp{contrib/} directory
11795 (see @ref{Installation}).  Users can install additional export libraries
11796 for additional formats from the Emacs packaging system.  For easy
11797 discovery, these packages have a common naming scheme: @code{ox-NAME},
11798 where @var{NAME} is one of the formats.  For example,
11799 @code{ox-koma-letter} @emph{koma-letter} back-end.
11801 @vindex org-export-backends
11802 Org loads back-ends for the following formats by default: ASCII, HTML,
11803 iCalendar, @LaTeX{} and ODT.  Org can load additional back-ends either of
11804 two ways: through the @code{org-export-backends} variable configuration;
11805 or, by requiring the library in the Emacs init file like this:
11807 @lisp
11808 (require 'ox-md)
11809 @end lisp
11811 @menu
11812 * The Export Dispatcher::        The main interface.
11813 * Export Settings::              Common export settings.
11814 * Table of Contents::            The if and where of the table of contents.
11815 * Include Files::                Include additional files into a document.
11816 * Macro Replacement::            Use macros to create templates.
11817 * Comment Lines::                What will not be exported.
11818 * ASCII/Latin-1/UTF-8 export::   Exporting to flat files with encoding.
11819 * Beamer Export::
11820 * HTML Export::                  Exporting to HTML.
11821 * @LaTeX{} Export::              Exporting to @LaTeX{} and processing to PDF.
11822 * Markdown Export::              Exporting to Markdown.
11823 * OpenDocument Text Export::     Exporting to OpenDocument Text.
11824 * Org Export::                   Exporting to Org.
11825 * Texinfo Export::               Exporting to Texinfo.
11826 * iCalendar Export::             Exporting to iCalendar.
11827 * Other Built-in Back-ends::     Exporting to a man page.
11828 * Advanced Configuration::       Fine-tuning the export output.
11829 * Export in Foreign Buffers::    Author tables and lists in Org syntax.
11830 @end menu
11832 @node The Export Dispatcher
11833 @section The Export Dispatcher
11835 @cindex dispatcher, for export commands
11836 @cindex Export, dispatcher
11838 The export dispatcher is the main interface for Org's exports.
11839 A hierarchical menu presents the currently configured export formats.
11840 Options are shown as easy toggle switches on the same screen.
11842 @vindex org-export-dispatch-use-expert-ui
11843 Org also has a minimal prompt interface for the export dispatcher.
11844 When the variable @code{org-export-dispatch-use-expert-ui} is set to
11845 a non-@code{nil} value, Org prompts in the minibuffer.  To switch back to
11846 the hierarchical menu, press @kbd{?}.
11848 @table @asis
11849 @item @kbd{C-c C-e} (@code{org-export})
11850 @kindex C-c C-e
11851 @findex org-export
11853 Invokes the export dispatcher interface.  The options show
11854 default settings.  The @kbd{C-u} prefix argument preserves
11855 options from the previous export, including any sub-tree
11856 selections.
11857 @end table
11859 Org exports the entire buffer by default.  If the Org buffer has an
11860 active region, then Org exports just that region.
11862 Within the dispatcher interface, the following key combinations can
11863 further alter what is exported, and how.
11865 @table @asis
11866 @item @kbd{C-a}
11867 @kindex C-c C-e C-a
11869 Toggle asynchronous export.  Asynchronous export uses an external
11870 Emacs process with a specially configured initialization file to
11871 complete the exporting process in the background thereby
11872 releasing the current interface.  This is particularly useful
11873 when exporting long documents.
11875 Output from an asynchronous export is saved on the ``the export
11876 stack''.  To view this stack, call the export dispatcher with
11877 a double @kbd{C-u} prefix argument.  If already in the
11878 export dispatcher menu, @kbd{&} displays the stack.
11880 @vindex org-export-async-init-file
11881 To make the background export process the default, customize the
11882 variable, @code{org-export-in-background}.  Additionally, you can set
11883 the initialization file used by the background process with
11884 @code{org-export-async-init-file}.
11886 @vindex org-export-in-background
11887 You can make asynchronous export the default by setting
11888 @code{org-export-in-background}.
11890 @item @kbd{C-b}
11891 @kindex C-c C-e C-b
11893 Toggle body-only export.  Useful for excluding headers and
11894 footers in the export.  Affects only those back-end formats that
11895 have such sections---like @samp{<head>...</head>} in HTML.
11897 @item @{@{@{kbd(C-s@}@}@}
11898 @kindex C-c C-e C-s
11900 Toggle sub-tree export.  When turned on, Org exports only the
11901 sub-tree starting from the cursor position at the time the export
11902 dispatcher was invoked.  Org uses the top heading of this
11903 sub-tree as the document's title.  If the cursor is not on
11904 a heading, Org uses the nearest enclosing header.  If the cursor
11905 is in the document preamble, Org signals an error and aborts
11906 export.
11908 @vindex org-export-initial-scope
11909 To make the sub-tree export the default, customize the variable
11910 @code{org-export-initial-scope}.
11912 @item @kbd{C-v}
11913 @kindex C-c C-e C-v
11915 Toggle visible-only export.  Useful for exporting only visible
11916 parts of an Org document by adjusting outline visibility
11917 settings.
11918 @end table
11920 @node Export Settings
11921 @section Export Settings
11923 @cindex options, for export
11924 @cindex Export, settings
11926 @cindex @samp{OPTIONS}, keyword
11927 Export options can be set: globally with variables; for an individual
11928 file by making variables buffer-local with in-buffer settings (see
11929 @ref{In-buffer Settings}), by setting individual keywords, or by
11930 specifying them in a compact form with the @samp{OPTIONS} keyword; or for
11931 a tree by setting properties (see @ref{Properties and Columns}).  Options
11932 set at a specific level override options set at a more general level.
11934 @cindex SETUPFILE, keyword
11935 In-buffer settings may appear anywhere in the file, either directly or
11936 indirectly through a file included using @samp{#+SETUPFILE: filename or
11937 URL} syntax.  Option keyword sets tailored to a particular back-end
11938 can be inserted from the export dispatcher (see @ref{The Export Dispatcher}) using the @samp{Insert template} command by pressing
11939 @kbd{#}.  To insert keywords individually, a good way to make
11940 sure the keyword is correct is to type @samp{#+} and then to use
11941 @kbd{M-@key{TAB}}@footnote{Many desktops intercept @kbd{M-@key{TAB}} to switch windows.
11942 Use @kbd{C-M-i} or @kbd{@key{ESC} @key{TAB}} instead.} for completion.
11944 The export keywords available for every back-end, and their equivalent
11945 global variables, include:
11947 @table @asis
11948 @item @samp{AUTHOR}
11949 @cindex @samp{AUTHOR}, keyword
11950 @vindex user-full-name
11951 The document author (@code{user-full-name}).
11953 @item @samp{CREATOR}
11954 @cindex @samp{CREATOR}, keyword
11955 @vindex org-expot-creator-string
11956 Entity responsible for output generation
11957 (@code{org-export-creator-string}).
11959 @item @samp{DATE}
11960 @cindex @samp{DATE}, keyword
11961 @vindex org-export-date-timestamp-format
11962 A date or a time-stamp@footnote{The variable @code{org-export-date-timestamp-format} defines how
11963 this timestamp are exported.}.
11965 @item @samp{EMAIL}
11966 @cindex @samp{EMAIL}, keyword
11967 @vindex user-mail-address
11968 The email address (@code{user-mail-address}).
11970 @item @samp{LANGUAGE}
11971 @cindex @samp{LANGUAGE}, keyword
11972 @vindex org-export-default-language
11973 Language to use for translating certain strings
11974 (@code{org-export-default-language}).  With @samp{#+LANGUAGE: fr}, for
11975 example, Org translates @samp{Table of contents} to the French @samp{Table
11976      des matières}.
11978 @item @samp{SELECT_TAGS}
11979 @cindex @samp{SELECT_TAGS}, keyword
11980 @vindex org-export-select-tags
11981 The default value is @code{("export")}.  When a tree is tagged with
11982 @samp{export} (@code{org-export-select-tags}), Org selects that tree and
11983 its sub-trees for export.  Org excludes trees with @samp{noexport}
11984 tags, see below.  When selectively exporting files with @samp{export}
11985 tags set, Org does not export any text that appears before the
11986 first headline.
11988 @item @samp{EXCLUDE_TAGS}
11989 @cindex @samp{EXCLUDE_TAGS}, keyword
11990 @vindex org-export-exclude-tags
11991 The default value is @code{("noexport")}.  When a tree is tagged with
11992 @samp{noexport} (@code{org-export-exclude-tags}), Org excludes that tree
11993 and its sub-trees from export.  Entries tagged with @samp{noexport}
11994 are unconditionally excluded from the export, even if they have
11995 an @samp{export} tag.  Even if a sub-tree is not exported, Org
11996 executes any code blocks contained there.
11998 @item @samp{TITLE}
11999 @cindex @samp{TITLE}, keyword
12000 @cindex document title
12001 Org displays this title.  For long titles, use multiple @samp{#+TITLE}
12002 lines.
12004 @item @samp{EXPORT_FILE_NAME}
12005 @cindex @samp{EXPORT_FILE_NAME}, keyword
12006 The name of the output file to be generated.  Otherwise, Org
12007 generates the file name based on the buffer name and the
12008 extension based on the back-end format.
12009 @end table
12011 The @samp{OPTIONS} keyword is a compact form.  To configure multiple
12012 options, use several @samp{OPTIONS} lines.  @samp{OPTIONS} recognizes the
12013 following arguments.
12015 @table @asis
12016 @item @code{'}
12017 @vindex org-export-with-smart-quotes
12018 Toggle smart quotes (@code{org-export-with-smart-quotes}).  Depending
12019 on the language used, when activated, Org treats pairs of double
12020 quotes as primary quotes, pairs of single quotes as secondary
12021 quotes, and single quote marks as apostrophes.
12023 @item @code{*}
12024 @vindex org-export-with-emphasize
12025 Toggle emphasized text (@code{org-export-with-emphasize}).
12027 @item @code{-}
12028 @vindex org-export-with-special-strings
12029 Toggle conversion of special strings
12030 (@code{org-export-with-special-strings}).
12032 @item @code{:}
12033 @vindex org-export-with-fixed-width
12034 Toggle fixed-width sections (@code{org-export-with-fixed-width}).
12036 @item @code{<}
12037 @vindex org-export-with-timestamps
12038 Toggle inclusion of time/date active/inactive stamps
12039 (@code{org-export-with-timestamps}).
12041 @item @code{\n}
12042 @vindex org-export-preserve-breaks
12043 Toggles whether to preserve line breaks
12044 (@code{org-export-preserve-breaks}).
12046 @item @code{^}
12047 @vindex org-export-with-sub-superscripts
12048 Toggle @TeX{}-like syntax for sub- and superscripts.  If you write
12049 @samp{^:@{@}}, @samp{a_@{b@}} is interpreted, but the simple @samp{a_b} is left as
12050 it is (@code{org-export-with-sub-superscripts}).
12052 @item @code{arch}
12053 @vindex org-export-with-archived-trees
12054 Configure how archived trees are exported.  When set to
12055 @code{headline}, the export process skips the contents and processes
12056 only the headlines (@code{org-export-with-archived-trees}).
12058 @item @code{author}
12059 @vindex org-export-with-author
12060 Toggle inclusion of author name into exported file
12061 (@code{org-export-with-author}).
12063 @item @code{broken-links}
12064 @vindex org-export-with-broken-links
12065 Toggles if Org should continue exporting upon finding a broken
12066 internal link.  When set to @code{mark}, Org clearly marks the problem
12067 link in the output (@code{org-export-with-broken-links}).
12069 @item @code{c}
12070 @vindex org-export-with-clocks
12071 Toggle inclusion of CLOCK keywords (@code{org-export-with-clocks}).
12073 @item @code{creator}
12074 @vindex org-export-with-creator
12075 Toggle inclusion of creator information in the exported file
12076 (@code{org-export-with-creator}).
12078 @item @code{d}
12079 @vindex org-export-with-drawers
12080 Toggles inclusion of drawers, or list of drawers to include, or
12081 list of drawers to exclude (@code{org-export-with-drawers}).
12083 @item @code{date}
12084 @vindex org-export-with-date
12085 Toggle inclusion of a date into exported file
12086 (@code{org-export-with-date}).
12088 @item @code{e}
12089 @vindex org-export-with-entities
12090 Toggle inclusion of entities (@code{org-export-with-entities}).
12092 @item @code{email}
12093 @vindex org-export-with-email
12094 Toggle inclusion of the author's e-mail into exported file
12095 (@code{org-export-with-email}).
12097 @item @code{f}
12098 @vindex org-export-with-footnotes
12099 Toggle the inclusion of footnotes (@code{org-export-with-footnotes}).
12101 @item @code{H}
12102 @vindex org-export-headline-levels
12103 Set the number of headline levels for export
12104 (@code{org-export-headline-levels}).  Below that level, headlines are
12105 treated differently.  In most back-ends, they become list items.
12107 @item @code{inline}
12108 @vindex org-export-with-inlinetasks
12109 Toggle inclusion of inlinetasks (@code{org-export-with-inlinetasks}).
12111 @item @code{num}
12112 @vindex org-export-with-section-numbers
12113 @cindex @samp{UNNUMBERED}, property
12114 Toggle section-numbers (@code{org-export-with-section-numbers}).  When
12115 set to number N, Org numbers only those headlines at level N or
12116 above.  Set @samp{UNNUMBERED} property to non-@code{nil} to disable
12117 numbering of heading and subheadings entirely.  Moreover, when
12118 the value is @samp{notoc} the headline, and all its children, do not
12119 appear in the table of contents either (see @ref{Table of Contents}).
12121 @item @code{p}
12122 @vindex org-export-with-planning
12123 Toggle export of planning information
12124 (@code{org-export-with-planning}).  ``Planning information'' comes from
12125 lines located right after the headline and contain any
12126 combination of these cookies: @samp{SCHEDULED}, @samp{DEADLINE}, or
12127 @samp{CLOSED}.
12129 @item @code{pri}
12130 @vindex org-export-with-priority
12131 Toggle inclusion of priority cookies
12132 (@code{org-export-with-priority}).
12134 @item @code{prop}
12135 @vindex org-export-with-properties
12136 Toggle inclusion of property drawers, or list the properties to
12137 include (@code{org-export-with-properties}).
12139 @item @code{stat}
12140 @vindex org-export-with-statistics-cookies
12141 Toggle inclusion of statistics cookies
12142 (@code{org-export-with-statistics-cookies}).
12144 @item @code{tags}
12145 @vindex org-export-with-tags
12146 Toggle inclusion of tags, may also be @code{not-in-toc}
12147 (@code{org-export-with-tags}).
12149 @item @code{tasks}
12150 @vindex org-export-with-tasks
12151 Toggle inclusion of tasks (TODO items); or @code{nil} to remove all
12152 tasks; or @code{todo} to remove DONE tasks; or list the keywords to
12153 keep (@code{org-export-with-tasks}).
12155 @item @code{tex}
12156 @vindex org-export-with-latex
12157 @code{nil} does not export; @code{t} exports; @code{verbatim} keeps everything
12158 in verbatim (@code{org-export-with-latex}).
12160 @item @code{timestamp}
12161 @vindex org-export-time-stamp-file
12162 Toggle inclusion of the creation time in the exported file
12163 (@code{org-export-time-stamp-file}).
12165 @item @code{title}
12166 @vindex org-export-with-title
12167 Toggle inclusion of title (@code{org-export-with-title}).
12169 @item @code{toc}
12170 @vindex org-export-with-toc
12171 Toggle inclusion of the table of contents, or set the level limit
12172 (@code{org-export-with-toc}).
12174 @item @code{todo}
12175 @vindex org-export-with-todo-keywords
12176 Toggle inclusion of TODO keywords into exported text
12177 (@code{org-export-with-todo-keywords}).
12179 @item @code{|}
12180 @vindex org-export-with-tables
12181 Toggle inclusion of tables (@code{org-export-with-tables}).
12182 @end table
12184 When exporting sub-trees, special node properties in them can override
12185 the above keywords.  They are special because they have an @samp{EXPORT_}
12186 prefix.  For example, @samp{DATE} and @samp{EXPORT_FILE_NAME} keywords become,
12187 respectively, @samp{EXPORT_DATE} and @samp{EXPORT_FILE_NAME}.  Except for
12188 @samp{SETUPFILE}, all other keywords listed above have an @samp{EXPORT_}
12189 equivalent.
12191 @cindex @samp{BIND}, keyword
12192 @vindex org-export-allow-bind-keywords
12193 If @code{org-export-allow-bind-keywords} is non-@code{nil}, Emacs variables can
12194 become buffer-local during export by using the @samp{BIND} keyword.  Its
12195 syntax is @samp{#+BIND: variable value}.  This is particularly useful for
12196 in-buffer settings that cannot be changed using keywords.
12198 @node Table of Contents
12199 @section Table of Contents
12201 @cindex table of contents
12202 @cindex list of tables
12203 @cindex list of listings
12205 @cindex @samp{toc}, in @samp{OPTIONS} keyword
12206 @vindex org-export-with-toc
12207 The table of contents includes all headlines in the document.  Its
12208 depth is therefore the same as the headline levels in the file.  If
12209 you need to use a different depth, or turn it off entirely, set the
12210 @code{org-export-with-toc} variable accordingly.  You can achieve the same
12211 on a per file basis, using the following @samp{toc} item in @samp{OPTIONS}
12212 keyword:
12214 @example
12215 #+OPTIONS: toc:2          (only include two levels in TOC)
12216 #+OPTIONS: toc:nil        (no default TOC at all)
12217 @end example
12219 @cindex excluding entries from table of contents
12220 @cindex table of contents, exclude entries
12221 Org includes both numbered and unnumbered headlines in the table of
12222 contents@footnote{At the moment, some export back-ends do not obey this
12223 specification.  For example, @LaTeX{} export excludes every unnumbered
12224 headline from the table of contents.}.  If you need to exclude an unnumbered headline,
12225 along with all its children, set the @samp{UNNUMBERED} property to @samp{notoc}
12226 value.
12228 @example
12229 * Subtree not numbered, not in table of contents either
12230   :PROPERTIES:
12231   :UNNUMBERED: notoc
12232   :END:
12233 @end example
12235 @cindex @samp{TOC}, keyword
12236 Org normally inserts the table of contents directly before the first
12237 headline of the file.  To move the table of contents to a different
12238 location, first turn off the default with @code{org-export-with-toc}
12239 variable or with @samp{#+OPTIONS: toc:nil}.  Then insert @samp{#+TOC: headlines
12240 N} at the desired location(s).
12242 @example
12243 #+OPTIONS: toc:nil
12245 #+TOC: headlines 2
12246 @end example
12248 To adjust the table of contents depth for a specific section of the
12249 Org document, append an additional @samp{local} parameter.  This parameter
12250 becomes a relative depth for the current level.  The following example
12251 inserts a local table of contents, with direct children only.
12253 @example
12254 * Section
12255 #+TOC: headlines 1 local
12256 @end example
12258 Note that for this feature to work properly in @LaTeX{} export, the Org
12259 file requires the inclusion of the titletoc package.  Because of
12260 compatibility issues, titletoc has to be loaded @emph{before} hyperref.
12261 Customize the @code{org-latex-default-packages-alist} variable.
12263 Use the @samp{TOC} keyword to generate list of tables---respectively, all
12264 listings---with captions.
12266 @example
12267 #+TOC: listings
12268 #+TOC: tables
12269 @end example
12271 @cindex @samp{ALT_TITLE}, property
12272 Normally Org uses the headline for its entry in the table of contents.
12273 But with @samp{ALT_TITLE} property, a different entry can be specified for
12274 the table of contents.
12276 @node Include Files
12277 @section Include Files
12279 @cindex include files, during export
12280 @cindex Export, include files
12281 @cindex @samp{INCLUDE}, keyword
12283 During export, you can include the content of another file.  For
12284 example, to include your @samp{.emacs} file, you could use:
12286 @example
12287 #+INCLUDE: "~/.emacs" src emacs-lisp
12288 @end example
12290 @noindent
12291 The optional second and third parameter are the markup (e.g., @samp{quote},
12292 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the language for
12293 formatting the contents.  The markup is optional; if it is not given,
12294 assume text is in Org syntax and process it normally.  The @samp{INCLUDE}
12295 keyword also allows additional parameters @samp{:prefix1} and @samp{:prefix} to
12296 specify prefixes for the first line and for each following line,
12297 @samp{:minlevel} in order to get Org mode content demoted to a specified
12298 level, as well as any options accepted by the selected markup.  For
12299 example, to include a file as an item, use:
12301 @example
12302 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
12303 @end example
12305 You can also include a portion of a file by specifying a lines range
12306 using the @samp{:lines} parameter.  The line at the upper end of the range
12307 is not included.  The start and/or the end of the range may be omitted
12308 to use the obvious defaults.
12310 @table @asis
12311 @item @samp{#+INCLUDE: "~/.emacs" :lines "5-10"}
12312 Include lines 5 to 10, 10 excluded.
12314 @item @samp{#+INCLUDE: "~/.emacs" :lines "-10"} 
12315 Include lines 1 to 10, 10 excluded.
12317 @item @samp{#+INCLUDE: "~/.emacs" :lines "10-"} 
12318 Include lines from 10 to EOF.
12319 @end table
12321 You can visit the file being included with the following command.
12323 @table @asis
12324 @item @kbd{C-c '} (@code{org-edit~special})
12325 @kindex C-c '
12326 @findex org-edit-special
12328 Visit the include file at point.
12329 @end table
12331 @node Macro Replacement
12332 @section Macro Replacement
12334 @cindex macro replacement, during export
12335 @cindex @samp{MACRO}, keyword
12337 @vindex org-export-global-macros
12338 Macros replace text snippets during export.  Macros are defined
12339 globally in @code{org-export-global-macros}, or document-wise with the
12340 following syntax:
12342 @example
12343 #+MACRO: name   replacement text; $1, $2 are arguments
12344 @end example
12346 @noindent
12347 which can be referenced using @samp{@{@{@{name(arg1, arg2)@}@}@}}@footnote{Since commas separate the arguments, commas within arguments
12348 have to be escaped with the backslash character.  So only those
12349 backslash characters before a comma need escaping with another
12350 backslash character.}.  For
12351 example
12353 @example
12354 #+MACRO: poem The rose is $1, The violet's $2. Life's ordered: Org assists you.
12355 @{@{@{poem(red,blue)@}@}@}
12356 @end example
12358 @noindent
12359 becomes
12361 @example
12362 The rose is red, The violet's blue. Life's ordered: Org assists you.
12363 @end example
12365 As a special case, Org parses any replacement text starting with
12366 @samp{(eval} as an Emacs Lisp expression and evaluates it accordingly.
12367 Within such templates, arguments become strings.  Thus, the following
12368 macro
12370 @example
12371 #+MACRO: gnucheck (eval (concat "GNU/" (capitalize $1)))
12372 @end example
12374 @noindent
12375 turns @samp{@{@{@{gnucheck(linux)@}@}@}} into @samp{GNU/Linux} during export.
12377 Org recognizes macro references in following Org markup areas:
12378 paragraphs, headlines, verse blocks, tables cells and lists.  Org also
12379 recognizes macro references in keywords, such as @samp{CAPTION}, @samp{TITLE},
12380 @samp{AUTHOR}, @samp{DATE}, and for some back-end specific export options.
12382 Org comes with following pre-defined macros:
12384 @table @asis
12385 @item @samp{@{@{@{keyword(NAME)@}@}@}}
12386 @itemx @samp{@{@{@{title@}@}@}}
12387 @itemx @samp{@{@{@{author@}@}@}}
12388 @itemx @samp{@{@{@{email@}@}@}}
12389 @cindex @samp{keyword}, macro
12390 @cindex @samp{title}, macro
12391 @cindex @samp{author}, macro
12392 @cindex @samp{email}, macro
12393 The @samp{keyword} macro collects all values from @var{NAME}
12394 keywords throughout the buffer, separated with white space.
12395 @samp{title}, @samp{author} and @samp{email} macros are shortcuts for,
12396 respectively, @samp{@{@{@{keyword(TITLE)@}@}@}}, @samp{@{@{@{keyword(AUTHOR)@}@}@}} and
12397 @samp{@{@{@{keyword(EMAIL)@}@}@}}.
12399 @item @samp{@{@{@{date@}@}@}}
12400 @itemx @samp{@{@{@{date(FORMAT)@}@}@}}
12401 @cindex @samp{date}, macro
12402 This macro refers to the @samp{DATE} keyword.  @var{FORMAT} is an
12403 optional argument to the @samp{date} macro that is used only if @samp{DATE}
12404 is a single timestamp.  @var{FORMAT} should be a format
12405 string understood by @code{format-time-string}.
12407 @item @samp{@{@{@{time(FORMAT)@}@}@}}
12408 @itemx @samp{@{@{@{modification-time(FORMAT, VC)@}@}@}}
12409 @cindex @samp{time}, macro
12410 @cindex @samp{modification-time}, macro
12411 These macros refer to the document's date and time of export and
12412 date and time of modification.  @var{FORMAT} is a string
12413 understood by @code{format-time-string}.  If the second argument to
12414 the @code{modification-time} macro is non-@code{nil}, Org uses @samp{vc.el} to
12415 retrieve the document's modification time from the version
12416 control system.  Otherwise Org reads the file attributes.
12418 @item @samp{@{@{@{input-file@}@}@}}
12419 @cindex @samp{input-file}, macro
12420 This macro refers to the filename of the exported file.
12422 @item @samp{@{@{@{property(PROPERTY-NAME)@}@}@}}
12423 @itemx @samp{@{@{@{property(PROPERTY-NAME, SEARCH OPTION)@}@}@}}
12424 @cindex @samp{property}, macro
12425 This macro returns the value of property @var{PROPERTY-NAME}
12426 in the current entry.  If @var{SEARCH-OPTION} (see @ref{Search Options}) refers to a remote entry, use it instead.
12428 @item @samp{@{@{@{n@}@}@}}
12429 @itemx @samp{@{@{@{n(NAME)@}@}@}}
12430 @itemx @samp{@{@{@{n(NAME, ACTION)@}@}@}}
12431 @cindex @samp{n}, macro
12432 @cindex counter, macro
12433 This macro implements custom counters by returning the number of
12434 times the macro has been expanded so far while exporting the
12435 buffer.  You can create more than one counter using different
12436 @var{NAME} values.  If @var{ACTION} is @samp{-}, previous
12437 value of the counter is held, i.e., the specified counter is not
12438 incremented.  If the value is a number, the specified counter is
12439 set to that value.  If it is any other non-empty string, the
12440 specified counter is reset to 1.  You may leave @var{NAME}
12441 empty to reset the default counter.
12442 @end table
12444 @vindex org-hide-macro-markers
12445 The surrounding brackets can be made invisible by setting
12446 @code{org-hide-macro-markers} non-@code{nil}.
12448 Org expands macros at the very beginning of the export process.
12450 @node Comment Lines
12451 @section Comment Lines
12453 @cindex exporting, not
12455 @cindex comment lines
12456 Lines starting with zero or more whitespace characters followed by one
12457 @samp{#} and a whitespace are treated as comments and, as such, are not
12458 exported.
12460 @cindex @samp{BEGIN_COMMENT}
12461 @cindex comment block
12462 Likewise, regions surrounded by @samp{#+BEGIN_COMMENT} @dots{} @samp{#+END_COMMENT}
12463 are not exported.
12465 @cindex comment trees
12466 Finally, a @samp{COMMENT} keyword at the beginning of an entry, but after
12467 any other keyword or priority cookie, comments out the entire subtree.
12468 In this case, the subtree is not exported and no code block within it
12469 is executed either@footnote{For a less drastic behavior, consider using a select tag (see
12470 @ref{Export Settings}) instead.}.  The command below helps changing the
12471 comment status of a headline.
12473 @table @asis
12474 @item @kbd{C-c ;} (@code{org-toggle-comment})
12475 @kindex C-c ;
12476 @findex org-toggle-comment
12478 Toggle the @samp{COMMENT} keyword at the beginning of an entry.
12479 @end table
12481 @node ASCII/Latin-1/UTF-8 export
12482 @section ASCII/Latin-1/UTF-8 export
12484 @cindex ASCII export
12485 @cindex Latin-1 export
12486 @cindex UTF-8 export
12488 ASCII export produces an output file containing only plain ASCII
12489 characters.  This is the simplest and most direct text output.  It
12490 does not contain any Org markup.  Latin-1 and UTF-8 export use
12491 additional characters and symbols available in these encoding
12492 standards.  All three of these export formats offer the most basic of
12493 text output for maximum portability.
12495 @vindex org-ascii-text-width
12496 On export, Org fills and justifies text according to the text width
12497 set in @code{org-ascii-text-width}.
12499 @vindex org-ascii-links-to-notes
12500 Org exports links using a footnote-like style where the descriptive
12501 part is in the text and the link is in a note before the next heading.
12502 See the variable @code{org-ascii-links-to-notes} for details.
12504 @anchor{ASCII export commands}
12505 @subheading ASCII export commands
12507 @table @asis
12508 @item @kbd{C-c C-e t a} (@code{org-ascii-export-to-ascii})
12509 @itemx @kbd{C-c C-e t l}
12510 @itemx @kbd{C-c C-e t u}
12511 @kindex C-c C-e t a
12512 @kindex C-c C-e t l
12513 @kindex C-c C-e t u
12514 @findex org-ascii-export-to-ascii
12516 Export as an ASCII file with a @samp{.txt} extension.  For
12517 @samp{myfile.org}, Org exports to @samp{myfile.txt}, overwriting without
12518 warning.  For @samp{myfile.txt}, Org exports to @samp{myfile.txt.txt} in
12519 order to prevent data loss.
12520 @end table
12522 @table @asis
12523 @item @kbd{C-c C-e t A} (@code{org-ascii-export-to-ascii})
12524 @itemx @kbd{C-c C-e t L}
12525 @itemx @kbd{C-c C-e t U}
12526 @kindex C-c C-e t A
12527 @kindex C-c C-e t L
12528 @kindex C-c C-e t U
12529 @findex org-ascii-export-to-ascii
12531 Export to a temporary buffer.  Does not create a file.
12532 @end table
12534 @anchor{ASCII specific export settings}
12535 @subheading ASCII specific export settings
12537 The ASCII export back-end has one extra keyword for customizing ASCII
12538 output.  Setting this keyword works similar to the general options
12539 (see @ref{Export Settings}).
12541 @table @asis
12542 @item @samp{SUBTITLE}
12543 @cindex @samp{SUBTITLE}, keyword
12544 The document subtitle.  For long subtitles, use multiple
12545 @samp{#+SUBTITLE} lines in the Org file.  Org prints them on one
12546 continuous line, wrapping into multiple lines if necessary.
12547 @end table
12549 @anchor{Header and sectioning structure}
12550 @subheading Header and sectioning structure
12552 Org converts the first three outline levels into headlines for ASCII
12553 export.  The remaining levels are turned into lists.  To change this
12554 cut-off point where levels become lists, see @ref{Export Settings}.
12556 @anchor{Quoting ASCII text}
12557 @subheading Quoting ASCII text
12559 To insert text within the Org file by the ASCII back-end, use one the
12560 following constructs, inline, keyword, or export block:
12562 @cindex @samp{ASCII}, keyword
12563 @cindex @samp{BEGIN_EXPORT ascii}
12564 @example
12565 Inline text @@@@ascii:and additional text@@@@ within a paragraph.
12567 #+ASCII: Some text
12569 #+BEGIN_EXPORT ascii
12570 Org exports text in this block only when using ASCII back-end.
12571 #+END_EXPORT
12572 @end example
12574 @anchor{ASCII specific attributes}
12575 @subheading ASCII specific attributes
12577 @cindex @samp{ATTR_ASCII}, keyword
12578 @cindex horizontal rules, in ASCII export
12580 ASCII back-end recognizes only one attribute, @code{:width}, which
12581 specifies the width of an horizontal rule in number of characters.
12582 The keyword and syntax for specifying widths is:
12584 @example
12585 #+ATTR_ASCII: :width 10
12586 -----
12587 @end example
12589 @anchor{ASCII special blocks}
12590 @subheading ASCII special blocks
12592 @cindex special blocks, in ASCII export
12593 @cindex @samp{BEGIN_JUSTIFYLEFT}
12594 @cindex @samp{BEGIN_JUSTIFYRIGHT}
12596 Besides @samp{#+BEGIN_CENTER} blocks (see @ref{Paragraphs}), ASCII back-end has
12597 these two left and right justification blocks:
12599 @example
12600 #+BEGIN_JUSTIFYLEFT
12601 It's just a jump to the left...
12602 #+END_JUSTIFYLEFT
12604 #+BEGIN_JUSTIFYRIGHT
12605 ...and then a step to the right.
12606 #+END_JUSTIFYRIGHT
12607 @end example
12609 @node Beamer Export
12610 @section Beamer Export
12612 @cindex Beamer export
12614 Org uses Beamer export to convert an Org file tree structure into
12615 high-quality interactive slides for presentations.  Beamer is a @LaTeX{}
12616 document class for creating presentations in PDF, HTML, and other
12617 popular display formats.
12619 @menu
12620 * Beamer export commands::       For creating Beamer documents.
12621 * Beamer specific export settings:: For customizing Beamer export.
12622 * Frames and Blocks in Beamer::  For composing Beamer slides.
12623 * Beamer specific syntax::       For using in Org documents.
12624 * Editing support::              Editing support.
12625 * A Beamer example::             A complete presentation.
12626 @end menu
12628 @node Beamer export commands
12629 @subsection Beamer export commands
12631 @table @asis
12632 @item @kbd{C-c C-e l b} (@code{org-beamer-export-to-latex})
12633 @kindex C-c C-e l b
12634 @findex org-beamer-export-to-latex
12636 Export as @LaTeX{} file with a @samp{.tex} extension.  For @samp{myfile.org},
12637 Org exports to @samp{myfile.tex}, overwriting without warning.
12639 @item @kbd{C-c C-e l B} (@code{org-beamer-export-as-latex})
12640 @kindex C-c C-e l B
12641 @findex org-beamer-export-as-latex
12643 Export to a temporary buffer.  Does not create a file.
12645 @item @kbd{C-c C-e l P} (@code{org-beamer-export-to-pdf})
12646 @kindex C-c C-e l P
12647 @findex org-beamer-export-to-pdf
12649 Export as @LaTeX{} file and then convert it to PDF format.
12651 @item @kbd{C-c C-e l O}
12652 @kindex C-c C-e l O
12654 Export as @LaTeX{} file, convert it to PDF format, and then open the
12655 PDF file.
12656 @end table
12658 @node Beamer specific export settings
12659 @subsection Beamer specific export settings
12661 Beamer export back-end has several additional keywords for customizing
12662 Beamer output.  These keywords work similar to the general options
12663 settings (see @ref{Export Settings}).
12665 @table @asis
12666 @item @samp{BEAMER_THEME}
12667 @cindex @samp{BEAMER_THEME}, keyword
12668 @vindex org-beamer-theme
12669 The Beamer layout theme (@code{org-beamer-theme}).  Use square
12670 brackets for options.  For example:
12672 @example
12673 #+BEAMER_THEME: Rochester [height=20pt]
12674 @end example
12676 @item @samp{BEAMER_FONT_THEME}
12677 @cindex @samp{BEAMER_FONT_THEME}, keyword
12678 The Beamer font theme.
12680 @item @samp{BEAMER_INNER_THEME}
12681 @cindex @samp{BEAMER_INNER_THEME}, keyword
12682 The Beamer inner theme.
12684 @item @samp{BEAMER_OUTER_THEME}
12685 @cindex @samp{BEAMER_OUTER_THEME}, keyword
12686 The Beamer outer theme.
12688 @item @samp{BEAMER_HEADER}
12689 @cindex @samp{BEAMER_HEADER}, keyword
12690 Arbitrary lines inserted in the preamble, just before the
12691 @samp{hyperref} settings.
12693 @item @samp{DESCRIPTION}
12694 @cindex @samp{DESCRIPTION}, keyword
12695 The document description.  For long descriptions, use multiple
12696 @samp{DESCRIPTION} keywords.  By default, @samp{hyperref} inserts
12697 @samp{DESCRIPTION} as metadata.  Use @code{org-latex-hyperref-template} to
12698 configure document metadata.  Use @code{org-latex-title-command} to
12699 configure typesetting of description as part of front matter.
12701 @item @samp{KEYWORDS}
12702 @cindex @samp{KEYWORDS}, keyword
12703 The keywords for defining the contents of the document.  Use
12704 multiple @samp{KEYWORDS} lines if necessary.  By default, @samp{hyperref}
12705 inserts @samp{KEYWORDS} as metadata.  Use
12706 @code{org-latex-hyperref-template} to configure document metadata.
12707 Use @code{org-latex-title-command} to configure typesetting of
12708 keywords as part of front matter.
12710 @item @samp{SUBTITLE}
12711 @cindex @samp{SUBTITLE}, keyword
12712 Document's subtitle.  For typesetting, use
12713 @code{org-beamer-subtitle-format} string.  Use
12714 @code{org-latex-hyperref-template} to configure document metadata.
12715 Use @code{org-latex-title-command} to configure typesetting of
12716 subtitle as part of front matter.
12717 @end table
12719 @node Frames and Blocks in Beamer
12720 @subsection Frames and Blocks in Beamer
12722 Org transforms heading levels into Beamer's sectioning elements,
12723 frames and blocks.  Any Org tree with a not-too-deep-level nesting
12724 should in principle be exportable as a Beamer presentation.
12726 @itemize
12727 @item
12728 @vindex org-beamer-frame-level
12729 Org headlines become Beamer frames when the heading level in Org is
12730 equal to @code{org-beamer-frame-level} or @samp{H} value in a @samp{OPTIONS} line
12731 (see @ref{Export Settings}).
12733 @cindex @samp{BEAMER_ENV}, property
12734 Org overrides headlines to frames conversion for the current tree of
12735 an Org file if it encounters the @samp{BEAMER_ENV} property set to
12736 @samp{frame} or @samp{fullframe}.  Org ignores whatever
12737 @code{org-beamer-frame-level} happens to be for that headline level in
12738 the Org tree.  In Beamer terminology, a full frame is a frame
12739 without its title.
12741 @item
12742 Org exports a Beamer frame's objects as block environments.  Org can
12743 enforce wrapping in special block types when @samp{BEAMER_ENV} property
12744 is set@footnote{If @samp{BEAMER_ENV} is set, Org export adds @samp{B_environment} tag
12745 to make it visible.  The tag serves as a visual aid and has no
12746 semantic relevance.}.  For valid values see
12747 @code{org-beamer-environments-default}.  To add more values, see
12748 @code{org-beamer-environments-extra}.
12749 @vindex org-beamer-environments-default
12750 @vindex org-beamer-environments-extra
12752 @item
12753 @cindex @samp{BEAMER_REF}, property
12754 If @samp{BEAMER_ENV} is set to @samp{appendix}, Org exports the entry as an
12755 appendix.  When set to @samp{note}, Org exports the entry as a note
12756 within the frame or between frames, depending on the entry's heading
12757 level.  When set to @samp{noteNH}, Org exports the entry as a note
12758 without its title.  When set to @samp{againframe}, Org exports the entry
12759 with @samp{\againframe} command, which makes setting the @samp{BEAMER_REF}
12760 property mandatory because @samp{\againframe} needs frame to resume.
12762 When @samp{ignoreheading} is set, Org export ignores the entry's headline
12763 but not its content.  This is useful for inserting content between
12764 frames.  It is also useful for properly closing a @samp{column}
12765 environment.  @@end itemize
12767 @cindex @samp{BEAMER_ACT}, property
12768 @cindex @samp{BEAMER_OPT}, property
12769 When @samp{BEAMER_ACT} is set for a headline, Org export translates that
12770 headline as an overlay or action specification.  When enclosed in
12771 square brackets, Org export makes the overlay specification
12772 a default.  Use @samp{BEAMER_OPT} to set any options applicable to the
12773 current Beamer frame or block.  The Beamer export back-end wraps
12774 with appropriate angular or square brackets.  It also adds the
12775 @samp{fragile} option for any code that may require a verbatim block.
12777 @cindex @samp{BEAMER_COL}, property
12778 To create a column on the Beamer slide, use the @samp{BEAMER_COL}
12779 property for its headline in the Org file.  Set the value of
12780 @samp{BEAMER_COL} to a decimal number representing the fraction of the
12781 total text width.  Beamer export uses this value to set the column's
12782 width and fills the column with the contents of the Org entry.  If
12783 the Org entry has no specific environment defined, Beamer export
12784 ignores the heading.  If the Org entry has a defined environment,
12785 Beamer export uses the heading as title.  Behind the scenes, Beamer
12786 export automatically handles @LaTeX{} column separations for contiguous
12787 headlines.  To manually adjust them for any unique configurations
12788 needs, use the @samp{BEAMER_ENV} property.
12789 @end itemize
12791 @node Beamer specific syntax
12792 @subsection Beamer specific syntax
12794 Since Org's Beamer export back-end is an extension of the @LaTeX{}
12795 back-end, it recognizes other @LaTeX{} specific syntax---for example,
12796 @samp{#+LATEX:} or @samp{#+ATTR_LATEX:}.  See @ref{@LaTeX{} Export}, for details.
12798 Beamer export wraps the table of contents generated with @samp{toc:t}
12799 @samp{OPTION} keyword in a @samp{frame} environment.  Beamer export does not
12800 wrap the table of contents generated with @samp{TOC} keyword (see @ref{Table of Contents}).  Use square brackets for specifying options.
12802 @example
12803 #+TOC: headlines [currentsection]
12804 @end example
12806 Insert Beamer-specific code using the following constructs:
12808 @cindex @samp{BEAMER}, keyword
12809 @cindex @samp{BEGIN_EXPORT beamer}
12810 @example
12811 #+BEAMER: \pause
12813 #+BEGIN_EXPORT beamer
12814   Only Beamer export back-end exports this.
12815 #+END_BEAMER
12817 Text @@@@beamer:some code@@@@ within a paragraph.
12818 @end example
12820 Inline constructs, such as the last one above, are useful for adding
12821 overlay specifications to objects with @code{bold}, @code{item}, @code{link},
12822 @code{radio-target} and @code{target} types.  Enclose the value in angular
12823 brackets and place the specification at the beginning of the object as
12824 shown in this example:
12826 @example
12827 A *@@@@beamer:<2->@@@@useful* feature
12828 @end example
12830 @cindex @samp{ATTR_BEAMER}, keyword
12831 Beamer export recognizes the @samp{ATTR_BEAMER} keyword with the following
12832 attributes from Beamer configurations: @samp{:environment} for changing
12833 local Beamer environment, @samp{:overlay} for specifying Beamer overlays in
12834 angular or square brackets, and @samp{:options} for inserting optional
12835 arguments.
12837 @example
12838 #+ATTR_BEAMER: :environment nonindentlist
12839 - item 1, not indented
12840 - item 2, not indented
12841 - item 3, not indented
12842 @end example
12844 @example
12845 #+ATTR_BEAMER: :overlay <+->
12846 - item 1
12847 - item 2
12848 @end example
12850 @example
12851 #+ATTR_BEAMER: :options [Lagrange]
12852 Let $G$ be a finite group, and let $H$ be
12853 a subgroup of $G$.  Then the order of $H$ divides the order of $G$.
12854 @end example
12856 @node Editing support
12857 @subsection Editing support
12859 The @code{org-beamer-mode} is a special minor mode for faster editing of
12860 Beamer documents.
12862 @example
12863 #+STARTUP: beamer
12864 @end example
12866 @table @asis
12867 @item @kbd{C-c C-b} (@code{org-beamer-select-environment})
12868 @kindex C-c C-b
12869 @findex org-beamer-select-environment
12871 The @code{org-beamer-mode} provides this key for quicker selections in
12872 Beamer normal environments, and for selecting the @samp{BEAMER_COL}
12873 property.
12874 @end table
12876 @node A Beamer example
12877 @subsection A Beamer example
12879 Here is an example of an Org document ready for Beamer export.
12881 @example
12882 ;#+TITLE: Example Presentation
12883 ;#+AUTHOR: Carsten Dominik
12884 ;#+OPTIONS: H:2 toc:t num:t
12885 ;#+LATEX_CLASS: beamer
12886 ;#+LATEX_CLASS_OPTIONS: [presentation]
12887 ;#+BEAMER_THEME: Madrid
12888 ;#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) %8BEAMER_OPT(Opt)
12890 * This is the first structural section
12892 ** Frame 1
12893 *** Thanks to Eric Fraga                                           :B_block:
12894     :PROPERTIES:
12895     :BEAMER_COL: 0.48
12896     :BEAMER_ENV: block
12897     :END:
12898     for the first viable Beamer setup in Org
12899 *** Thanks to everyone else                                        :B_block:
12900     :PROPERTIES:
12901     :BEAMER_COL: 0.48
12902     :BEAMER_ACT: <2->
12903     :BEAMER_ENV: block
12904     :END:
12905     for contributing to the discussion
12906 **** This will be formatted as a beamer note                       :B_note:
12907      :PROPERTIES:
12908      :BEAMER_env: note
12909      :END:
12910 ** Frame 2 (where we will not use columns)
12911 *** Request
12912     Please test this stuff!
12913 @end example
12915 @node HTML Export
12916 @section HTML Export
12918 @cindex HTML export
12920 Org mode contains an HTML exporter with extensive HTML formatting
12921 compatible with XHTML 1.0 strict standard.
12923 @menu
12924 * HTML export commands::         Invoking HTML export.
12925 * HTML specific export settings:: Settings for HTML export.
12926 * HTML doctypes::                Exporting various (X)HTML flavors.
12927 * HTML preamble and postamble::  Inserting preamble and postamble.
12928 * Quoting HTML tags::            Using direct HTML in Org files.
12929 * Links in HTML export::         Inserting and formatting links.
12930 * Tables in HTML export::        How to modify the formatting of tables.
12931 * Images in HTML export::        How to insert figures into HTML output.
12932 * Math formatting in HTML export:: Beautiful math also on the web.
12933 * Text areas in HTML export::    An alternate way to show an example.
12934 * CSS support::                  Changing the appearance of the output.
12935 * JavaScript support::           Info and folding in a web browser.
12936 @end menu
12938 @node HTML export commands
12939 @subsection HTML export commands
12941 @table @asis
12942 @item @kbd{C-c C-e h h} (@code{org-html-export-to-html})
12943 @kindex C-c C-e h h
12944 @kindex C-c C-e h o
12945 @findex org-html-export-to-html
12947 Export as HTML file with a @samp{.html} extension.  For @samp{myfile.org},
12948 Org exports to @samp{myfile.html}, overwriting without warning.
12949 @{@{@{kbd@{C-c C-e h o)@}@}@} exports to HTML and opens it in a web
12950 browser.
12952 @item @kbd{C-c C-e h H} (@code{org-html-export-as-html})
12953 @kindex C-c C-e h H
12954 @findex org-html-export-as-html
12956 Exports to a temporary buffer.  Does not create a file.
12957 @end table
12959 @node HTML specific export settings
12960 @subsection HTML specific export settings
12962 HTML export has a number of keywords, similar to the general options
12963 settings described in @ref{Export Settings}.
12965 @table @asis
12966 @item @samp{DESCRIPTION}
12967 @cindex @samp{DESCRIPTION}, keyword
12968 This is the document's description, which the HTML exporter
12969 inserts it as a HTML meta tag in the HTML file.  For long
12970 descriptions, use multiple @samp{DESCRIPTION} lines.  The exporter
12971 takes care of wrapping the lines properly.
12973 @item @samp{HTML_DOCTYPE}
12974 @cindex @samp{HTML_DOCTYPE}, keyword
12975 @vindex org-html-doctype
12976 Specify the document type, for example: HTML5
12977 (@code{org-html-doctype}).
12979 @item @samp{HTML_CONTAINER}
12980 @cindex @samp{HTML_CONTAINER}, keyword
12981 @vindex org-html-container-element
12982 Specify the HTML container, such as @samp{div}, for wrapping sections
12983 and elements (@code{org-html-container-element}).
12985 @item @samp{HTML_LINK_HOME}
12986 @cindex @samp{HTML_LINK_HOME}, keyword
12987 @vindex org-html-link-home
12988 The URL for home link (@code{org-html-link-home}).
12990 @item @samp{HTML_LINK_UP}
12991 @cindex @samp{HTML_LINK_UP}, keyword
12992 @vindex org-html-link-up
12993 The URL for the up link of exported HTML pages
12994 (@code{org-html-link-up}).
12996 @item @samp{HTML_MATHJAX}
12997 @cindex @samp{HTML_MATHJAX}, keyword
12998 @vindex org-html-mathjax-options
12999 Options for MathJax (@code{org-html-mathjax-options}).  MathJax is
13000 used to typeset @LaTeX{} math in HTML documents.  See @ref{Math formatting in HTML export}, for an example.
13002 @item @samp{HTML_HEAD}
13003 @cindex @samp{HTML_HEAD}, keyword
13004 @vindex org-html-head
13005 Arbitrary lines for appending to the HTML document's head
13006 (@code{org-html-head}).
13008 @item @samp{HTML_HEAD_EXTRA}
13009 @cindex @samp{HTML_HEAD_EXTRA}, keyword
13010 @vindex org-html-head-extra
13011 More arbitrary lines for appending to the HTML document's head
13012 (@code{org-html-head-extra}).
13014 @item @samp{KEYWORDS}
13015 @cindex @samp{KEYWORDS}, keyword
13016 Keywords to describe the document's content.  HTML exporter
13017 inserts these keywords as HTML meta tags.  For long keywords, use
13018 multiple @samp{KEYWORDS} lines.
13020 @item @samp{LATEX_HEADER}
13021 @cindex @samp{LATEX_HEADER}, keyword
13022 Arbitrary lines for appending to the preamble; HTML exporter
13023 appends when transcoding @LaTeX{} fragments to images (see @ref{Math formatting in HTML export}).
13025 @item @samp{SUBTITLE}
13026 @cindex @samp{SUBTITLE}, keyword
13027 The document's subtitle.  HTML exporter formats subtitle if
13028 document type is @samp{HTML5} and the CSS has a @samp{subtitle} class.
13029 @end table
13031 Some of these keywords are explained in more detail in the following
13032 sections of the manual.
13034 @node HTML doctypes
13035 @subsection HTML doctypes
13037 Org can export to various (X)HTML flavors.
13039 @vindex org-html-doctype
13040 @vindex org-html-doctype-alist
13041 Set the @code{org-html-doctype} variable for different (X)HTML variants.
13042 Depending on the variant, the HTML exporter adjusts the syntax of HTML
13043 conversion accordingly.  Org includes the following ready-made
13044 variants:
13046 @itemize
13047 @item
13048 @code{"html4-strict"}
13049 @item
13050 @code{"html4-transitional"}
13051 @item
13052 @code{"html4-frameset"}
13053 @item
13054 @code{"xhtml-strict"}
13055 @item
13056 @code{"xhtml-transitional"}
13057 @item
13058 @code{"xhtml-frameset"}
13059 @item
13060 @code{"xhtml-11"}
13061 @item
13062 @code{"html5"}
13063 @item
13064 @code{"xhtml5"}
13065 @end itemize
13067 @noindent
13068 See the variable @code{org-html-doctype-alist} for details.  The default is
13069 @code{"xhtml-strict"}.
13071 @vindex org-html-html5-fancy
13072 @cindex @samp{HTML5}, export new elements
13073 Org's HTML exporter does not by default enable new block elements
13074 introduced with the HTML5 standard.  To enable them, set
13075 @code{org-html-html5-fancy} to non-@code{nil}.  Or use an @samp{OPTIONS} line in the
13076 file to set @samp{html5-fancy}.
13078 HTML5 documents can now have arbitrary @samp{#+BEGIN} @dots{} @samp{#+END} blocks.
13079 For example:
13081 @example
13082 #+BEGIN_aside
13083   Lorem ipsum
13084 #+END_aside
13085 @end example
13087 @noindent
13088 exports to:
13090 @example
13091 <aside>
13092   <p>Lorem ipsum</p>
13093 </aside>
13094 @end example
13096 @noindent
13097 while this:
13099 @example
13100 #+ATTR_HTML: :controls controls :width 350
13101 #+BEGIN_video
13102 #+HTML: <source src="movie.mp4" type="video/mp4">
13103 #+HTML: <source src="movie.ogg" type="video/ogg">
13104 Your browser does not support the video tag.
13105 #+END_video
13106 @end example
13108 @noindent
13109 exports to:
13111 @example
13112 <video controls="controls" width="350">
13113   <source src="movie.mp4" type="video/mp4">
13114     <source src="movie.ogg" type="video/ogg">
13115       <p>Your browser does not support the video tag.</p>
13116 </video>
13117 @end example
13119 @vindex org-html-html5-elements
13120 When special blocks do not have a corresponding HTML5 element, the
13121 HTML exporter reverts to standard translation (see
13122 @code{org-html-html5-elements}).  For example, @samp{#+BEGIN_lederhosen} exports
13123 to @code{<div class="lederhosen">}.
13125 Special blocks cannot have headlines.  For the HTML exporter to wrap
13126 the headline and its contents in @code{<section>} or @code{<article>} tags, set
13127 the @samp{HTML_CONTAINER} property for the headline.
13129 @node HTML preamble and postamble
13130 @subsection HTML preamble and postamble
13132 @vindex org-html-preamble
13133 @vindex org-html-postamble
13134 @vindex org-html-preamble-format
13135 @vindex org-html-postamble-format
13136 @vindex org-html-validation-link
13137 @vindex org-export-creator-string
13138 @vindex org-export-time-stamp-file
13140 The HTML exporter has delineations for preamble and postamble.  The
13141 default value for @code{org-html-preamble} is @code{t}, which makes the HTML
13142 exporter insert the preamble.  See the variable
13143 @code{org-html-preamble-format} for the format string.
13145 Set @code{org-html-preamble} to a string to override the default format
13146 string.  If the string is a function, the HTML exporter expects the
13147 function to return a string upon execution.  The HTML exporter inserts
13148 this string in the preamble.  The HTML exporter does not insert
13149 a preamble if @code{org-html-preamble} is set @code{nil}.
13151 The default value for @code{org-html-postamble} is @code{auto}, which makes the
13152 HTML exporter build a postamble from looking up author's name, email
13153 address, creator's name, and date.  Set @code{org-html-postamble} to @code{t} to
13154 insert the postamble in the format specified in the
13155 @code{org-html-postamble-format} variable.  The HTML exporter does not
13156 insert a postamble if @code{org-html-postamble} is set to @code{nil}.
13158 @node Quoting HTML tags
13159 @subsection Quoting HTML tags
13161 The HTML export back-end transforms @samp{<} and @samp{>} to @samp{&lt;} and @samp{&gt;}.
13163 To include raw HTML code in the Org file so the HTML export back-end
13164 can insert that HTML code in the output, use this inline syntax:
13165 @samp{@@@@html:...@@@@}.  For example:
13167 @example
13168 @@@@html:<b>@@@@bold text@@@@html:</b>@@@@
13169 @end example
13171 @cindex @samp{HTML}, keyword
13172 @cindex @samp{BEGIN_EXPORT html}
13173 For larger raw HTML code blocks, use these HTML export code blocks:
13175 @example
13176 #+HTML: Literal HTML code for export
13178 #+BEGIN_EXPORT html
13179   All lines between these markers are exported literally
13180 #+END_EXPORT
13181 @end example
13183 @node Links in HTML export
13184 @subsection Links in HTML export
13186 @cindex links, in HTML export
13187 @cindex internal links, in HTML export
13188 @cindex external links, in HTML export
13190 The HTML export back-end transforms Org's internal links (see
13191 @ref{Internal Links}) to equivalent HTML links in the output.  The back-end
13192 similarly handles Org's automatic links created by radio targets (see
13193 @ref{Radio Targets}) similarly.  For Org links to external files, the
13194 back-end transforms the links to @emph{relative} paths.
13196 @vindex org-html-link-org-files-as-html
13197 For Org links to other @samp{.org} files, the back-end automatically
13198 changes the file extension to @samp{.html} and makes file paths relative.
13199 If the @samp{.org} files have an equivalent @samp{.html} version at the same
13200 location, then the converted links should work without any further
13201 manual intervention.  However, to disable this automatic path
13202 translation, set @code{org-html-link-org-files-as-html} to @code{nil}.  When
13203 disabled, the HTML export back-end substitutes the ID-based links in
13204 the HTML output.  For more about linking files when publishing to
13205 a directory, see @ref{Publishing links}.
13207 Org files can also have special directives to the HTML export
13208 back-end.  For example, by using @samp{#+ATTR_HTML} lines to specify new
13209 format attributes to @code{<a>} or @code{<img>} tags.  This example shows
13210 changing the link's title and style:
13212 @cindex @samp{ATTR_HTML}, keyword
13213 @example
13214 #+ATTR_HTML: :title The Org mode homepage :style color:red;
13215 [[https://orgmode.org]]
13216 @end example
13218 @node Tables in HTML export
13219 @subsection Tables in HTML export
13221 @cindex tables, in HTML
13222 @vindex org-export-html-table-tag
13224 The HTML export back-end uses @code{org-html-table-default-attributes} when
13225 exporting Org tables to HTML.  By default, the exporter does not draw
13226 frames and cell borders.  To change for this for a table, use the
13227 following lines before the table in the Org file:
13229 @cindex @samp{CAPTION}, keyword
13230 @cindex @samp{ATTR_HTML}, keyword
13231 @example
13232 #+CAPTION: This is a table with lines around and between cells
13233 #+ATTR_HTML: border="2" rules="all" frame="border"
13234 @end example
13236 The HTML export back-end preserves column groupings in Org tables (see
13237 @ref{Column Groups}) when exporting to HTML.
13239 Additional options for customizing tables for HTML export.
13241 @table @asis
13242 @item @code{org-html-table-align-individual-fields}
13243 @vindex org-html-table-align-individual-fields
13244 Non-@code{nil} attaches style attributes for alignment to each table
13245 field.
13247 @item @code{org-html-table-caption-above}
13248 @vindex org-html-table-caption-above
13249 Non-@code{nil} places caption string at the beginning of the table.
13251 @item @code{org-html-table-data-tags}
13252 @vindex org-html-table-data-tags
13253 Opening and ending tags for table data fields.
13255 @item @code{org-html-table-default-attributes}
13256 @vindex org-html-table-default-attributes
13257 Default attributes and values for table tags.
13259 @item @code{org-html-table-header-tags}
13260 @vindex org-html-table-header-tags
13261 Opening and ending tags for table's header fields.
13263 @item @code{org-html-table-row-tags}
13264 @vindex org-html-table-row-tags
13265 Opening and ending tags for table rows.
13267 @item @code{org-html-table-use-header-tags-for-first-column}
13268 @vindex org-html-table-use-header-tags-for-first-column
13269 Non-@code{nil} formats column one in tables with header tags.
13270 @end table
13272 @node Images in HTML export
13273 @subsection Images in HTML export
13275 @cindex images, inline in HTML
13276 @cindex inlining images in HTML
13278 The HTML export back-end has features to convert Org image links to
13279 HTML inline images and HTML clickable image links.
13281 @vindex org-html-inline-images
13282 When the link in the Org file has no description, the HTML export
13283 back-end by default in-lines that image.  For example:
13284 @samp{[[file:myimg.jpg]]} is in-lined, while @samp{[[file:myimg.jpg][the image]]} links to the text,
13285 @samp{the image}.  For more details, see the variable
13286 @code{org-html-inline-images}.
13288 On the other hand, if the description part of the Org link is itself
13289 another link, such as @samp{file:} or @samp{http:} URL pointing to an image, the
13290 HTML export back-end in-lines this image and links to the main image.
13291 This Org syntax enables the back-end to link low-resolution thumbnail
13292 to the high-resolution version of the image, as shown in this example:
13294 @example
13295 [[file:highres.jpg][file:thumb.jpg]]
13296 @end example
13298 To change attributes of in-lined images, use @samp{#+ATTR_HTML} lines in
13299 the Org file.  This example shows realignment to right, and adds @code{alt}
13300 and @code{title} attributes in support of text viewers and modern web
13301 accessibility standards.
13303 @cindex @samp{CAPTION}, keyword
13304 @cindex @samp{ATTR_HTML}, keyword
13305 @example
13306 #+CAPTION: A black cat stalking a spider
13307 #+ATTR_HTML: :alt cat/spider image :title Action! :align right
13308 [[./img/a.jpg]]
13309 @end example
13311 @noindent
13312 The HTML export back-end copies the @samp{http} links from the Org file as
13315 @node Math formatting in HTML export
13316 @subsection Math formatting in HTML export
13318 @cindex MathJax
13319 @cindex dvipng
13320 @cindex dvisvgm
13321 @cindex ImageMagick
13323 @vindex org-html-mathjax-options~
13324 @LaTeX{} math snippets (see @ref{@LaTeX{} fragments}) can be displayed in two
13325 different ways on HTML pages.  The default is to use the @uref{http://www.mathjax.org, MathJax},
13326 which should work out of the box with Org@footnote{By default Org loads MathJax from @uref{https://cdnjs.com, cdnjs.com} as recommended by
13327 @uref{http://www.mathjax.org, MathJax}.}.  Some MathJax
13328 display options can be configured via @code{org-html-mathjax-options}, or
13329 in the buffer.  For example, with the following settings,
13331 @example
13332 #+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
13333 #+HTML_MATHJAX: cancel.js noErrors.js
13334 @end example
13336 @noindent
13337 equation labels are displayed on the left margin and equations are
13338 five em from the left margin.  In addition, it loads the two MathJax
13339 extensions @samp{cancel.js} and @samp{noErrors.js}@footnote{See @uref{http://docs.mathjax.org/en/latest/tex.html#tex-extensions, @TeX{} and @LaTeX{} extensions} in the @uref{http://docs.mathjax.org, MathJax manual} to learn
13340 about extensions.}.
13342 @vindex org-html-mathjax-template
13343 See the docstring of @code{org-html-mathjax-options} for all supported
13344 variables.  The MathJax template can be configure via
13345 @code{org-html-mathjax-template}.
13347 If you prefer, you can also request that @LaTeX{} fragments are processed
13348 into small images that will be inserted into the browser page.  Before
13349 the availability of MathJax, this was the default method for Org
13350 files.  This method requires that the dvipng program, dvisvgm or
13351 ImageMagick suite is available on your system.  You can still get this
13352 processing with
13354 @example
13355 #+OPTIONS: tex:dvipng
13356 @end example
13358 @example
13359 #+OPTIONS: tex:dvisvgm
13360 @end example
13362 @noindent
13365 @example
13366 #+OPTIONS: tex:imagemagick
13367 @end example
13369 @node Text areas in HTML export
13370 @subsection Text areas in HTML export
13372 @cindex text areas, in HTML
13373 Before Org mode's Babel, one popular approach to publishing code in
13374 HTML was by using @samp{:textarea}.  The advantage of this approach was
13375 that copying and pasting was built into browsers with simple
13376 JavaScript commands.  Even editing before pasting was made simple.
13378 The HTML export back-end can create such text areas.  It requires an
13379 @samp{#+ATTR_HTML} line as shown in the example below with the @samp{:textarea}
13380 option.  This must be followed by either an example or a source code
13381 block.  Other Org block types do not honor the @samp{:textarea} option.
13383 By default, the HTML export back-end creates a text area 80 characters
13384 wide and height just enough to fit the content.  Override these
13385 defaults with @samp{:width} and @samp{:height} options on the @samp{#+ATTR_HTML}
13386 line.
13388 @example
13389 #+ATTR_HTML: :textarea t :width 40
13390 #+BEGIN_EXAMPLE
13391   (defun org-xor (a b)
13392      "Exclusive or."
13393      (if a (not b) b))
13394 #+END_EXAMPLE
13395 @end example
13397 @node CSS support
13398 @subsection CSS support
13400 @cindex CSS, for HTML export
13401 @cindex HTML export, CSS
13403 @vindex org-export-html-todo-kwd-class-prefix
13404 @vindex org-export-html-tag-class-prefix
13405 You can modify the CSS style definitions for the exported file.  The
13406 HTML exporter assigns the following special CSS classes@footnote{If the classes on TODO keywords and tags lead to conflicts,
13407 use the variables @code{org-html-todo-kwd-class-prefix} and
13408 @code{org-html-tag-class-prefix} to make them unique.} to
13409 appropriate parts of the document---your style specifications may
13410 change these, in addition to any of the standard classes like for
13411 headlines, tables, etc.
13413 @multitable {aaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
13414 @item @code{p.author}
13415 @tab author information, including email
13416 @item @code{p.date}
13417 @tab publishing date
13418 @item @code{p.creator}
13419 @tab creator info, about org mode version
13420 @item @code{.title}
13421 @tab document title
13422 @item @code{.subtitle}
13423 @tab document subtitle
13424 @item @code{.todo}
13425 @tab TODO keywords, all not-done states
13426 @item @code{.done}
13427 @tab the DONE keywords, all states that count as done
13428 @item @code{.WAITING}
13429 @tab each TODO keyword also uses a class named after itself
13430 @item @code{.timestamp}
13431 @tab timestamp
13432 @item @code{.timestamp-kwd}
13433 @tab keyword associated with a timestamp, like @samp{SCHEDULED}
13434 @item @code{.timestamp-wrapper}
13435 @tab span around keyword plus timestamp
13436 @item @code{.tag}
13437 @tab tag in a headline
13438 @item @code{._HOME}
13439 @tab each tag uses itself as a class, ``@@'' replaced by ``_''
13440 @item @code{.target}
13441 @tab target for links
13442 @item @code{.linenr}
13443 @tab the line number in a code example
13444 @item @code{.code-highlighted}
13445 @tab for highlighting referenced code lines
13446 @item @code{div.outline-N}
13447 @tab div for outline level N (headline plus text)
13448 @item @code{div.outline-text-N}
13449 @tab extra div for text at outline level N
13450 @item @code{.section-number-N}
13451 @tab section number in headlines, different for each level
13452 @item @code{.figure-number}
13453 @tab label like ``Figure 1:''
13454 @item @code{.table-number}
13455 @tab label like ``Table 1:''
13456 @item @code{.listing-number}
13457 @tab label like ``Listing 1:''
13458 @item @code{div.figure}
13459 @tab how to format an in-lined image
13460 @item @code{pre.src}
13461 @tab formatted source code
13462 @item @code{pre.example}
13463 @tab normal example
13464 @item @code{p.verse}
13465 @tab verse paragraph
13466 @item @code{div.footnotes}
13467 @tab footnote section headline
13468 @item @code{p.footnote}
13469 @tab footnote definition paragraph, containing a footnote
13470 @item @code{.footref}
13471 @tab a footnote reference number (always a <sup>)
13472 @item @code{.footnum}
13473 @tab footnote number in footnote definition (always <sup>)
13474 @item @code{.org-svg}
13475 @tab default class for a linked @samp{.svg} image
13476 @end multitable
13478 @vindex org-html-style-default
13479 @vindex org-html-head
13480 @vindex org-html-head-extra
13481 @cindex @samp{HTML_INCLUDE_STYLE}, keyword
13482 The HTML export back-end includes a compact default style in each
13483 exported HTML file.  To override the default style with another style,
13484 use these keywords in the Org file.  They will replace the global
13485 defaults the HTML exporter uses.
13487 @cindex @samp{HTML_HEAD}, keyword
13488 @cindex @samp{HTML_HEAD_EXTRA}, keyword
13489 @example
13490 #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
13491 #+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
13492 @end example
13494 @vindex org-html-head-include-default-style
13495 To just turn off the default style, customize
13496 @code{org-html-head-include-default-style} variable, or use this option
13497 line in the Org file.
13499 @cindex @samp{html-style}, @samp{OPTIONS} item
13500 @example
13501 #+OPTIONS: html-style:nil
13502 @end example
13504 For longer style definitions, either use several @samp{HTML_HEAD} and
13505 @samp{HTML_HEAD_EXTRA} keywords, or use @code{<style> ... </style>} blocks
13506 around them.  Both of these approaches can avoid referring to an
13507 external file.
13509 @cindex @samp{HTML_CONTAINER_CLASS}, property
13510 In order to add styles to a sub-tree, use the @samp{HTML_CONTAINER_CLASS}
13511 property to assign a class to the tree.  In order to specify CSS
13512 styles for a particular headline, you can use the id specified in
13513 a @samp{CUSTOM_ID} property.
13515 Never change the @code{org-html-style-default} constant.  Instead use other
13516 simpler ways of customizing as described above.
13518 @node JavaScript support
13519 @subsection JavaScript supported display of web pages
13521 Sebastian Rose has written a JavaScript program especially designed to
13522 enhance the web viewing experience of HTML files created with Org.
13523 This program enhances large files in two different ways of viewing.
13524 One is an @emph{Info}-like mode where each section is displayed separately
13525 and navigation can be done with the @kbd{n} and @kbd{p}
13526 keys, and some other keys as well, press @kbd{?} for an overview
13527 of the available keys.  The second one has a @emph{folding} view, much like
13528 Org provides inside Emacs.  The script is available at
13529 @uref{https://orgmode.org/org-info.js} and the documentation at
13530 @uref{https://orgmode.org/worg/code/org-info-js/}.  The script is hosted on
13531 @uref{https://orgmode.org}, but for reliability, prefer installing it on your
13532 own web server.
13534 To use this program, just add this line to the Org file:
13536 @cindex @samp{INFOJS_OPT}, keyword
13537 @example
13538 #+INFOJS_OPT: view:info toc:nil
13539 @end example
13541 @noindent
13542 The HTML header now has the code needed to automatically invoke the
13543 script.  For setting options, use the syntax from the above line for
13544 options described below:
13546 @table @asis
13547 @item @samp{path:}
13548 The path to the script.  The default is to grab the script from
13549 @uref{https://orgmode.org/org-info.js}, but you might want to have
13550 a local copy and use a path like @samp{../scripts/org-info.js}.
13552 @item @samp{view:}
13553 Initial view when the website is first shown.  Possible values are:
13555 @multitable {aaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
13556 @item @samp{info}
13557 @tab Info-like interface with one section per page
13558 @item @samp{overview}
13559 @tab Folding interface, initially showing only top-level
13560 @item @samp{content}
13561 @tab Folding interface, starting with all headlines visible
13562 @item @samp{showall}
13563 @tab Folding interface, all headlines and text visible
13564 @end multitable
13566 @item @samp{sdepth:}
13567 Maximum headline level still considered as an independent section
13568 for info and folding modes.  The default is taken from
13569 @code{org-export-headline-levels}, i.e., the @samp{H} switch in @samp{OPTIONS}.
13570 If this is smaller than in @code{org-export-headline-levels}, each
13571 info/folding section can still contain child headlines.
13573 @item @samp{toc:}
13574 Should the table of contents @emph{initially} be visible?  Even when
13575 @samp{nil}, you can always get to the ``toc'' with @kbd{i}.
13577 @item @samp{tdepth:}
13578 The depth of the table of contents.  The defaults are taken from
13579 the variables @code{org-export-headline-levels} and
13580 @code{org-export-with-toc}.
13582 @item @samp{ftoc:}
13583 Does the CSS of the page specify a fixed position for the ``toc''?
13584 If yes, the toc is displayed as a section.
13586 @item @samp{ltoc:}
13587 Should there be short contents (children) in each section?  Make
13588 this @samp{above} if the section should be above initial text.
13590 @item @samp{mouse:}
13591 Headings are highlighted when the mouse is over them.  Should be
13592 @samp{underline} (default) or a background color like @samp{#cccccc}.
13594 @item @samp{buttons:}
13595 Should view-toggle buttons be everywhere?  When @samp{nil} (the
13596 default), only one such button is present.
13597 @end table
13599 @noindent
13600 @vindex org-infojs-options
13601 @vindex org-export-html-use-infojs
13602 You can choose default values for these options by customizing the
13603 variable @code{org-infojs-options}.  If you always want to apply the script
13604 to your pages, configure the variable @code{org-export-html-use-infojs}.
13606 @node @LaTeX{} Export
13607 @section @LaTeX{} Export
13609 @cindex @LaTeX{} export
13610 @cindex PDF export
13612 The @LaTeX{} export back-end can handle complex documents, incorporate
13613 standard or custom @LaTeX{} document classes, generate documents using
13614 alternate @LaTeX{} engines, and produce fully linked PDF files with
13615 indexes, bibliographies, and tables of contents, destined for
13616 interactive online viewing or high-quality print publication.
13618 While the details are covered in-depth in this section, here are some
13619 quick references to variables for the impatient: for engines, see
13620 @code{org-latex-compiler}; for build sequences, see
13621 @code{org-latex-pdf-process}; for packages, see
13622 @code{org-latex-default-packages-alist} and @code{org-latex-packages-alist}.
13624 An important note about the @LaTeX{} export back-end: it is sensitive to
13625 blank lines in the Org document.  That's because @LaTeX{} itself depends
13626 on blank lines to tell apart syntactical elements, such as paragraphs.
13628 @menu
13629 * @LaTeX{}/PDF export commands:: For producing @LaTeX{} and PDF documents.
13630 * @LaTeX{} specific export settings:: Unique to this @LaTeX{} back-end.
13631 * @LaTeX{} header and sectioning:: Setting up the export file structure.
13632 * Quoting @LaTeX{} code::        Incorporating literal @LaTeX{} code.
13633 * Tables in @LaTeX{} export::    Options for exporting tables to @LaTeX{}.
13634 * Images in @LaTeX{} export::    How to insert figures into @LaTeX{} output.
13635 * Plain lists in @LaTeX{} export:: Attributes specific to lists.
13636 * Source blocks in @LaTeX{} export:: Attributes specific to source code blocks.
13637 * Example blocks in @LaTeX{} export:: Attributes specific to example blocks.
13638 * Special blocks in @LaTeX{} export:: Attributes specific to special blocks.
13639 * Horizontal rules in @LaTeX{} export:: Attributes specific to horizontal rules.
13640 @end menu
13642 @node @LaTeX{}/PDF export commands
13643 @subsection @LaTeX{}/PDF export commands
13645 @table @asis
13646 @item @kbd{C-c C-e l l} (@code{org-latex-export-to-latex})
13647 @kindex C-c C-e l l
13648 @findex org-latex-export-to-latex~
13649 Export to a @LaTeX{} file with a @samp{.tex} extension.  For
13650 @samp{myfile.org}, Org exports to @samp{myfile.tex}, overwriting without
13651 warning.
13653 @item @kbd{C-c C-e l L} (@code{org-latex-export-as-latex})
13654 @kindex C-c C-e l L
13655 @findex org-latex-export-as-latex
13656 Export to a temporary buffer.  Do not create a file.
13658 @item @kbd{C-c C-e l p} (@code{org-latex-export-to-pdf})
13659 @kindex C-c C-e l p
13660 @findex org-latex-export-to-pdf
13661 Export as @LaTeX{} file and convert it to PDF file.
13663 @item @kbd{C-c C-e l o}
13664 @kindex C-c C-e l o
13665 Export as @LaTeX{} file and convert it to PDF, then open the PDF
13666 using the default viewer.
13668 @item @kbd{M-x org-export-region-as-latex}
13669 Convert the region to @LaTeX{} under the assumption that it was in Org
13670 mode syntax before.  This is a global command that can be invoked in
13671 any buffer.
13672 @end table
13674 @vindex org-latex-compiler
13675 @vindex org-latex-bibtex-compiler
13676 @vindex org-latex-default-packages-alist
13677 @cindex pdflatex
13678 @cindex xelatex
13679 @cindex lualatex
13680 @cindex @samp{LATEX_COMPILER}, keyword
13681 The @LaTeX{} export back-end can use any of these @LaTeX{} engines:
13682 @samp{pdflatex}, @samp{xelatex}, and @samp{lualatex}.  These engines compile @LaTeX{}
13683 files with different compilers, packages, and output options.  The
13684 @LaTeX{} export back-end finds the compiler version to use from
13685 @code{org-latex-compiler} variable or the @samp{#+LATEX_COMPILER} keyword in the
13686 Org file.  See the docstring for the
13687 @code{org-latex-default-packages-alist} for loading packages with certain
13688 compilers.  Also see @code{org-latex-bibtex-compiler} to set the
13689 bibliography compiler@footnote{This does not allow setting different bibliography compilers
13690 for different files.  However, ``smart'' @LaTeX{} compilation systems, such
13691 as latexmk, can select the correct bibliography compiler.}.
13693 @node @LaTeX{} specific export settings
13694 @subsection @LaTeX{} specific export settings
13696 The @LaTeX{} export back-end has several additional keywords for
13697 customizing @LaTeX{} output.  Setting these keywords works similar to the
13698 general options (see @ref{Export Settings}).
13700 @table @asis
13701 @item @samp{DESCRIPTION}
13702 @cindex @samp{DESCRIPTION}, keyword
13703 @vindex org-latex-hyperref-template
13704 @vindex org-latex-title-command
13705 The document's description.  The description along with author
13706 name, keywords, and related file metadata are inserted in the
13707 output file by the hyperref package.  See
13708 @code{org-latex-hyperref-template} for customizing metadata items.
13709 See @code{org-latex-title-command} for typesetting description into
13710 the document's front matter.  Use multiple @samp{DESCRIPTION} keywords
13711 for long descriptions.
13713 @item @samp{LATEX_CLASS}
13714 @cindex @samp{LATEX_CLASS}, keyword
13715 @vindex org-latex-default-class
13716 @vindex org-latex-classes
13717 This is @LaTeX{} document class, such as @emph{article}, @emph{report},
13718 @emph{book}, and so on, which contain predefined preamble and headline
13719 level mapping that the @LaTeX{} export back-end needs.  The back-end
13720 reads the default class name from the @code{org-latex-default-class}
13721 variable.  Org has @emph{article} as the default class.  A valid
13722 default class must be an element of @code{org-latex-classes}.
13724 @item @samp{LATEX_CLASS_OPTIONS}
13725 @cindex @samp{LATEX_CLASS_OPTIONS}, keyword
13726 Options the @LaTeX{} export back-end uses when calling the @LaTeX{}
13727 document class.
13729 @item @samp{LATEX_COMPILER}
13730 @cindex @samp{LATEX_COMPILER}, keyword
13731 @vindex org-latex-compiler
13732 The compiler, such as @samp{pdflatex}, @samp{xelatex}, @samp{lualatex}, for
13733 producing the PDF.  See @code{org-latex-compiler}.
13735 @item @samp{LATEX_HEADER}
13736 @itemx @samp{LATEX_HEADER_EXTRA}
13737 @cindex @samp{LATEX_HEADER}, keyword
13738 @cindex @samp{LATEX_HEADER_EXTRA}, keyword
13739 @vindex org-latex-classes
13740 Arbitrary lines to add to the document's preamble, before the
13741 hyperref settings.  See @code{org-latex-classes} for adjusting the
13742 structure and order of the @LaTeX{} headers.
13744 @item @samp{KEYWORDS}
13745 @cindex @samp{KEYWORDS}, keyword
13746 @vindex org-latex-hyperref-template
13747 @vindex org-latex-title-command
13748 The keywords for the document.  The description along with author
13749 name, keywords, and related file metadata are inserted in the
13750 output file by the hyperref package.  See
13751 @code{org-latex-hyperref-template} for customizing metadata items.
13752 See @code{org-latex-title-command} for typesetting description into
13753 the document's front matter.  Use multiple @samp{KEYWORDS} lines if
13754 necessary.
13756 @item @samp{SUBTITLE}
13757 @cindex @samp{SUBTITLE}, keyword
13758 @vindex org-latex-subtitle-separate
13759 @vindex org-latex-subtitle-format
13760 The document's subtitle.  It is typeset as per
13761 @code{org-latex-subtitle-format}.  If @code{org-latex-subtitle-separate} is
13762 non-@code{nil}, it is typed as part of the @code{\title} macro.  See
13763 @code{org-latex-hyperref-template} for customizing metadata items.
13764 See @code{org-latex-title-command} for typesetting description
13765 into the document's front matter.
13766 @end table
13768 The following sections have further details.
13770 @node @LaTeX{} header and sectioning
13771 @subsection @LaTeX{} header and sectioning structure
13773 @cindex @LaTeX{} class
13774 @cindex @LaTeX{} sectioning structure
13775 @cindex @LaTeX{} header
13776 @cindex header, for @LaTeX{} files
13777 @cindex sectioning structure, for @LaTeX{} export
13779 The @LaTeX{} export back-end converts the first three of Org's outline
13780 levels into @LaTeX{} headlines.  The remaining Org levels are exported as
13781 lists.  To change this globally for the cut-off point between levels
13782 and lists, (see @ref{Export Settings}).
13784 By default, the @LaTeX{} export back-end uses the @emph{article} class.
13786 @vindex org-latex-default-class
13787 @vindex org-latex-classes
13788 @vindex org-latex-default-packages-alist
13789 @vindex org-latex-packages-alist
13790 To change the default class globally, edit @code{org-latex-default-class}.
13791 To change the default class locally in an Org file, add option lines
13792 @samp{#+LATEX_CLASS: myclass}.  To change the default class for just a part
13793 of the Org file, set a sub-tree property, @samp{EXPORT_LATEX_CLASS}.  The
13794 class name entered here must be valid member of @code{org-latex-classes}.
13795 This variable defines a header template for each class into which the
13796 exporter splices the values of @code{org-latex-default-packages-alist} and
13797 @code{org-latex-packages-alist}.  Use the same three variables to define
13798 custom sectioning or custom classes.
13800 @cindex @samp{LATEX_CLASS}, keyword
13801 @cindex @samp{LATEX_CLASS_OPTIONS}, keyword
13802 @cindex @samp{EXPORT_LATEX_CLASS}, property
13803 @cindex @samp{EXPORT_LATEX_CLASS_OPTIONS}, property
13804 The @LaTeX{} export back-end sends the @samp{LATEX_CLASS_OPTIONS} keyword and
13805 @samp{EXPORT_LATEX_CLASS_OPTIONS} property as options to the @LaTeX{}
13806 @code{\documentclass} macro.  The options and the syntax for specifying
13807 them, including enclosing them in square brackets, follow @LaTeX{}
13808 conventions.
13810 @example
13811 #+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside,twocolumn]
13812 @end example
13814 @cindex @samp{LATEX_HEADER}, keyword
13815 @cindex @samp{LATEX_HEADER_EXTRA}, keyword
13816 The @LaTeX{} export back-end appends values from @samp{LATEX_HEADER} and
13817 @samp{LATEX_HEADER_EXTRA} keywords to the @LaTeX{} header.  The docstring for
13818 @code{org-latex-classes} explains in more detail.  Also note that @LaTeX{}
13819 export back-end does not append @samp{LATEX_HEADER_EXTRA} to the header
13820 when previewing @LaTeX{} snippets (see @ref{Previewing @LaTeX{} fragments}).
13822 A sample Org file with the above headers:
13824 @example
13825 #+LATEX_CLASS: article
13826 #+LATEX_CLASS_OPTIONS: [a4paper]
13827 #+LATEX_HEADER: \usepackage@{xyz@}
13829 * Headline 1
13830   some text
13831 * Headline 2
13832   some more text
13833 @end example
13835 @node Quoting @LaTeX{} code
13836 @subsection Quoting @LaTeX{} code
13838 The @LaTeX{} export back-end can insert any arbitrary @LaTeX{} code, see
13839 @ref{Embedded @LaTeX{}}.  There are three ways to embed such code in the Org
13840 file and they all use different quoting syntax.
13842 @cindex inline, in @LaTeX{} export
13843 Inserting in-line quoted with @@ symbols:
13845 @example
13846 Code embedded in-line @@@@latex:any arbitrary LaTeX code@@@@ in a paragraph.
13847 @end example
13849 @cindex @samp{LATEX}, keyword
13850 Inserting as one or more keyword lines in the Org file:
13852 @example
13853 #+LATEX: any arbitrary LaTeX code
13854 @end example
13856 @cindex @samp{BEGIN_EXPORT latex}
13857 Inserting as an export block in the Org file, where the back-end
13858 exports any code between begin and end markers:
13860 @example
13861 #+BEGIN_EXPORT latex
13862   any arbitrary LaTeX code
13863 #+END_EXPORT
13864 @end example
13866 @node Tables in @LaTeX{} export
13867 @subsection Tables in @LaTeX{} export
13869 @cindex tables, in @LaTeX{} export
13871 The @LaTeX{} export back-end can pass several @LaTeX{} attributes for table
13872 contents and layout.  Besides specifying label and caption (see
13873 @ref{Images and Tables}), the other valid @LaTeX{} attributes include:
13875 @table @asis
13876 @item @samp{:mode}
13877 @vindex org-latex-default-table-mode
13878 The @LaTeX{} export back-end wraps the table differently depending
13879 on the mode for accurate rendering of math symbols.  Mode is
13880 either @samp{table}, @samp{math}, @samp{inline-math} or @samp{verbatim}.
13882 For @samp{math} or @samp{inline-math} mode, @LaTeX{} export back-end wraps the
13883 table in a math environment, but every cell in it is exported
13884 as-is.  The @LaTeX{} export back-end determines the default mode
13885 from @code{org-latex-default-table-mode}.  The @LaTeX{} export back-end
13886 merges contiguous tables in the same mode into a single
13887 environment.
13889 @item @samp{:environment}
13890 @vindex org-latex-default-table-environment
13891 Set the default @LaTeX{} table environment for the @LaTeX{} export
13892 back-end to use when exporting Org tables.  Common @LaTeX{} table
13893 environments are provided by these packages: tabularx, longtable,
13894 array, tabu, and bmatrix.  For packages, such as tabularx and
13895 tabu, or any newer replacements, include them in the
13896 @code{org-latex-packages-alist} variable so the @LaTeX{} export back-end
13897 can insert the appropriate load package headers in the converted
13898 @LaTeX{} file.  Look in the docstring for the
13899 @code{org-latex-packages-alist} variable for configuring these
13900 packages for @LaTeX{} snippet previews, if any.
13902 @item @samp{:caption}
13903 Use @samp{CAPTION} keyword to set a simple caption for a table (see
13904 @ref{Images and Tables}).  For custom captions, use @samp{:caption}
13905 attribute, which accepts raw @LaTeX{} code.  @samp{:caption} value
13906 overrides @samp{CAPTION} value.
13908 @item @samp{:float}
13909 @itemx @samp{:placement}
13910 The table environments by default are not floats in @LaTeX{}.  To
13911 make them floating objects use @samp{:float} with one of the following
13912 options: @samp{sideways}, @samp{multicolumn}, @samp{t}, and @samp{nil}.
13914 @LaTeX{} floats can also have additional layout @samp{:placement}
13915 attributes.  These are the usual @samp{[h t b p ! H]} permissions
13916 specified in square brackets.  Note that for @samp{:float sideways}
13917 tables, the @LaTeX{} export back-end ignores @samp{:placement}
13918 attributes.
13920 @item @samp{:align}
13921 @itemx @samp{:font}
13922 @itemx @samp{:width}
13923 The @LaTeX{} export back-end uses these attributes for regular
13924 tables to set their alignments, fonts, and widths.
13926 @item @samp{:spread}
13927 When @samp{:spread} is non-@code{nil}, the @LaTeX{} export back-end spreads or
13928 shrinks the table by the @samp{:width} for tabu and longtabu
13929 environments.  @samp{:spread} has no effect if @samp{:width} is not set.
13931 @item @samp{:booktabs}
13932 @itemx @samp{:center}
13933 @itemx @samp{:rmlines}
13934 @vindex org-latex-tables-booktabs
13935 @vindex org-latex-tables-centered
13936 All three commands are toggles.  @samp{:booktabs} brings in modern
13937 typesetting enhancements to regular tables.  The booktabs package
13938 has to be loaded through @code{org-latex-packages-alist}.  @samp{:center}
13939 is for centering the table.  @samp{:rmlines} removes all but the very
13940 first horizontal line made of ASCII characters from ``table.el''
13941 tables only.
13943 @item @samp{:math-prefix}
13944 @itemx @samp{:math-suffix}
13945 @itemx @samp{:math-arguments}
13946 The @LaTeX{} export back-end inserts @samp{:math-prefix} string value in
13947 a math environment before the table.  The @LaTeX{} export back-end
13948 inserts @samp{:math-suffix} string value in a math environment after
13949 the table.  The @LaTeX{} export back-end inserts @samp{:math-arguments}
13950 string value between the macro name and the table's contents.
13951 @samp{:math-arguments} comes in use for matrix macros that require
13952 more than one argument, such as @samp{qbordermatrix}.
13953 @end table
13955 @LaTeX{} table attributes help formatting tables for a wide range of
13956 situations, such as matrix product or spanning multiple pages:
13958 @example
13959 #+ATTR_LATEX: :environment longtable :align l|lp@{3cm@}r|l
13960 | ... | ... |
13961 | ... | ... |
13963 #+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
13964 | a | b |
13965 | c | d |
13966 #+ATTR_LATEX: :mode math :environment bmatrix
13967 | 1 | 2 |
13968 | 3 | 4 |
13969 @end example
13971 Set the caption with the @LaTeX{} command
13972 @samp{\bicaption@{HeadingA@}@{HeadingB@}}:
13974 @example
13975 #+ATTR_LATEX: :caption \bicaption@{HeadingA@}@{HeadingB@}
13976 | ... | ... |
13977 | ... | ... |
13978 @end example
13980 @node Images in @LaTeX{} export
13981 @subsection Images in @LaTeX{} export
13983 @cindex images, inline in LaTeX
13984 @cindex inlining images in LaTeX
13985 @cindex @samp{ATTR_LATEX}, keyword
13987 The @LaTeX{} export back-end processes image links in Org files that do
13988 not have descriptions, such as these links @samp{[[file:img.jpg]]} or
13989 @samp{[[./img.jpg]]}, as direct image insertions in the final PDF output.  In
13990 the PDF, they are no longer links but actual images embedded on the
13991 page.  The @LaTeX{} export back-end uses @samp{\includegraphics} macro to
13992 insert the image.  But for TikZ (@uref{http://sourceforge.net/projects/pgf/})
13993 images, the back-end uses an @code{\input} macro wrapped within
13994 a @code{tikzpicture} environment.
13996 For specifying image @samp{:width}, @samp{:height}, and other @samp{:options}, use
13997 this syntax:
13999 @example
14000 #+ATTR_LATEX: :width 5cm :options angle=90
14001 [[./img/sed-hr4049.pdf]]
14002 @end example
14004 For custom commands for captions, use the @samp{:caption} attribute.  It
14005 overrides the default @samp{#+CAPTION} value:
14007 @example
14008 #+ATTR_LATEX: :caption \bicaption@{HeadingA@}@{HeadingB@}
14009 [[./img/sed-hr4049.pdf]]
14010 @end example
14012 When captions follow the method as described in @ref{Images and Tables},
14013 the @LaTeX{} export back-end wraps the picture in a floating @samp{figure}
14014 environment.  To float an image without specifying a caption, set the
14015 @samp{:float} attribute to one of the following:
14017 @table @asis
14018 @item @samp{t}
14019 For a standard @samp{figure} environment; used by default whenever an
14020 image has a caption.
14022 @item @samp{multicolumn}
14023 To span the image across multiple columns of a page; the back-end
14024 wraps the image in a @samp{figure*} environment.
14026 @item @samp{wrap}
14027 For text to flow around the image on the right; the figure
14028 occupies the left half of the page.
14030 @item @samp{sideways}
14031 For a new page with the image sideways, rotated ninety degrees,
14032 in a @samp{sidewaysfigure} environment; overrides @samp{:placement}
14033 setting.
14035 @item @samp{nil}
14036 To avoid a @samp{:float} even if using a caption.
14037 @end table
14039 @noindent
14040 Use the @samp{placement} attribute to modify a floating environment's
14041 placement.
14043 @example
14044 #+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement @{r@}@{0.4\textwidth@}
14045 [[./img/hst.png]]
14046 @end example
14048 @vindex org-latex-images-centered
14049 @cindex center image in LaTeX export
14050 @cindex image, centering in LaTeX export
14051 The @LaTeX{} export back-end centers all images by default.  Setting
14052 @samp{:center} to @samp{nil} disables centering.  To disable centering globally,
14053 set @code{org-latex-images-centered} to @samp{t}.
14055 Set the @samp{:comment-include} attribute to non-@code{nil} value for the @LaTeX{}
14056 export back-end to comment out the @samp{\includegraphics} macro.
14058 @node Plain lists in @LaTeX{} export
14059 @subsection Plain lists in @LaTeX{} export
14061 @cindex plain lists, in @LaTeX{} export
14062 @cindex @samp{ATTR_LATEX}, keyword
14063 The @LaTeX{} export back-end accepts the @samp{environment} and @samp{options}
14064 attributes for plain lists.  Both attributes work together for
14065 customizing lists, as shown in the examples:
14067 @example
14068 #+LATEX_HEADER: \usepackage[inline]@{enumitem@}
14069 Some ways to say "Hello":
14070 #+ATTR_LATEX: :environment itemize*
14071 #+ATTR_LATEX: :options [label=@{@}, itemjoin=@{,@}, itemjoin*=@{, and@}]
14072 - Hola
14073 - Bonjour
14074 - Guten Tag.
14075 @end example
14077 Since @LaTeX{} supports only four levels of nesting for lists, use an
14078 external package, such as @samp{enumitem} in @LaTeX{}, for levels deeper than
14079 four:
14081 @example
14082 #+LATEX_HEADER: \usepackage@{enumitem@}
14083 #+LATEX_HEADER: \renewlist@{itemize@}@{itemize@}@{9@}
14084 #+LATEX_HEADER: \setlist[itemize]@{label=$\circ$@}
14085 - One
14086   - Two
14087     - Three
14088       - Four
14089         - Five
14090 @end example
14092 @node Source blocks in @LaTeX{} export
14093 @subsection Source blocks in @LaTeX{} export
14095 @cindex source blocks, in @LaTeX{} export
14096 @cindex @samp{ATTR_LATEX}, keyword
14098 The @LaTeX{} export back-end can make source code blocks into floating
14099 objects through the attributes @samp{:float} and @samp{:options}.  For @samp{:float}:
14101 @table @asis
14102 @item @samp{t}
14103 Makes a source block float; by default floats any source block
14104 with a caption.
14106 @item @samp{multicolumn}
14107 Spans the source block across multiple columns of a page.
14109 @item @samp{nil}
14110 Avoids a @samp{:float} even if using a caption; useful for source code
14111 blocks that may not fit on a page.
14112 @end table
14114 @example
14115 #+ATTR_LATEX: :float nil
14116 #+BEGIN_SRC emacs-lisp
14117   Lisp code that may not fit in a single page.
14118 #+END_SRC
14119 @end example
14121 @vindex org-latex-listings-options
14122 @vindex org-latex-minted-options
14123 The @LaTeX{} export back-end passes string values in @samp{:options} to @LaTeX{}
14124 packages for customization of that specific source block.  In the
14125 example below, the @samp{:options} are set for Minted.  Minted is a source
14126 code highlighting @LaTeX{} package with many configurable options.
14128 @example
14129 #+ATTR_LATEX: :options commentstyle=\bfseries
14130 #+BEGIN_SRC emacs-lisp
14131   (defun Fib (n)
14132     (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
14133 #+END_SRC
14134 @end example
14136 To apply similar configuration options for all source blocks in
14137 a file, use the @code{org-latex-listings-options} and
14138 @code{org-latex-minted-options} variables.
14140 @node Example blocks in @LaTeX{} export
14141 @subsection Example blocks in @LaTeX{} export
14143 @cindex example blocks, in @LaTeX{} export
14144 @cindex verbatim blocks, in @LaTeX{} export
14145 @cindex @samp{ATTR_LATEX}, keyword
14147 The @LaTeX{} export back-end wraps the contents of example blocks in
14148 a @samp{verbatim} environment.  To change this behavior to use another
14149 environment globally, specify an appropriate export filter (see
14150 @ref{Advanced Configuration}).  To change this behavior to use another
14151 environment for each block, use the @samp{:environment} parameter to
14152 specify a custom environment.
14154 @example
14155 #+ATTR_LATEX: :environment myverbatim
14156 #+BEGIN_EXAMPLE
14157   This sentence is false.
14158 #+END_EXAMPLE
14159 @end example
14161 @node Special blocks in @LaTeX{} export
14162 @subsection Special blocks in @LaTeX{} export
14164 @cindex special blocks, in @LaTeX{} export
14165 @cindex abstract, in @LaTeX{} export
14166 @cindex proof, in @LaTeX{} export
14167 @cindex @samp{ATTR_LATEX}, keyword
14169 For other special blocks in the Org file, the @LaTeX{} export back-end
14170 makes a special environment of the same name.  The back-end also takes
14171 @samp{:options}, if any, and appends as-is to that environment's opening
14172 string.  For example:
14174 @example
14175 #+BEGIN_abstract
14176   We demonstrate how to solve the Syracuse problem.
14177 #+END_abstract
14179 #+ATTR_LATEX: :options [Proof of important theorem]
14180 #+BEGIN_proof
14181   ...
14182   Therefore, any even number greater than 2 is the sum of two primes.
14183 #+END_proof
14184 @end example
14186 @noindent
14187 exports to
14189 @example
14190 \begin@{abstract@}
14191   We demonstrate how to solve the Syracuse problem.
14192 \end@{abstract@}
14194 \begin@{proof@}[Proof of important theorem]
14195   ...
14196   Therefore, any even number greater than 2 is the sum of two primes.
14197 \end@{proof@}
14198 @end example
14200 If you need to insert a specific caption command, use @samp{:caption}
14201 attribute.  It overrides standard @samp{CAPTION} value, if any.  For
14202 example:
14204 @example
14205 #+ATTR_LATEX: :caption \MyCaption@{HeadingA@}
14206 #+BEGIN_proof
14207   ...
14208 #+END_proof
14209 @end example
14211 @node Horizontal rules in @LaTeX{} export
14212 @subsection Horizontal rules in @LaTeX{} export
14214 @cindex horizontal rules, in @LaTeX{} export
14215 @cindex @samp{ATTR_LATEX}, keyword
14217 The @LaTeX{} export back-end converts horizontal rules by the specified
14218 @samp{:width} and @samp{:thickness} attributes.  For example:
14220 @example
14221 #+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt
14222 -----
14223 @end example
14225 @node Markdown Export
14226 @section Markdown Export
14228 @cindex Markdown export
14230 The Markdown export back-end, ``md'', converts an Org file to a Markdown
14231 format, as defined at @uref{http://daringfireball.net/projects/markdown/}.
14233 Since ``md'' is built on top of the HTML back-end, any Org constructs
14234 not supported by Markdown, such as tables, the underlying ``html''
14235 back-end (see @ref{HTML Export}) converts them.
14237 @anchor{Markdown export commands}
14238 @subheading Markdown export commands
14240 @table @asis
14241 @item @kbd{C-c C-e m m} (@code{org-md-export-to-markdown})
14242 @kindex C-c C-c m m
14243 @findex org-md-export-to-markdown
14244 Export to a text file with Markdown syntax.  For @samp{myfile.org},
14245 Org exports to @samp{myfile.md}, overwritten without warning.
14247 @item @kbd{C-c C-e m M} (@code{org-md-export-as-markdown})
14248 @kindex C-c C-c m M
14249 @findex org-md-export-as-markdown
14250 Export to a temporary buffer.  Does not create a file.
14252 @item @kbd{C-c C-e m o}
14253 @kindex C-c C-e m o
14254 Export as a text file with Markdown syntax, then open it.
14255 @end table
14257 @anchor{Header and sectioning structure (1)}
14258 @subheading Header and sectioning structure
14260 @vindex org-md-headline-style
14261 Based on @code{org-md-headline-style}, Markdown export can generate
14262 headlines of both @emph{atx} and @emph{setext} types.  @emph{atx} limits headline
14263 levels to two whereas @emph{setext} limits headline levels to six.  Beyond
14264 these limits, the export back-end converts headlines to lists.  To set
14265 a limit to a level before the absolute limit (see @ref{Export Settings}).
14267 @node OpenDocument Text Export
14268 @section OpenDocument Text Export
14270 @cindex ODT
14271 @cindex OpenDocument
14272 @cindex export, OpenDocument
14273 @cindex LibreOffice
14275 The ODT export back-end handles creating of OpenDocument Text (ODT)
14276 format.  Documents created by this exporter use the
14277 @cite{OpenDocument-v1.2 specification}@footnote{See @uref{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html, Open Document Format for Office Applications
14278 (OpenDocument) Version 1.2}.} and are compatible
14279 with LibreOffice 3.4.
14281 @menu
14282 * Pre-requisites for ODT export:: Required packages.
14283 * ODT export commands::          Invoking export.
14284 * ODT specific export settings:: Configuration options.
14285 * Extending ODT export::         Producing DOC, PDF files.
14286 * Applying custom styles::       Styling the output.
14287 * Links in ODT export::          Handling and formatting links.
14288 * Tables in ODT export::         Org tables conversions.
14289 * Images in ODT export::         Inserting images.
14290 * Math formatting in ODT export:: Formatting @LaTeX{} fragments.
14291 * Labels and captions in ODT export:: Rendering objects.
14292 * Literal examples in ODT export:: For source code and example blocks.
14293 * Advanced topics in ODT export:: For power users.
14294 @end menu
14296 @node Pre-requisites for ODT export
14297 @subsection Pre-requisites for ODT export
14299 @cindex zip
14301 The ODT export back-end relies on the zip program to create the final
14302 compressed ODT output.  Check if @samp{zip} is locally available and
14303 executable.  Without it, export cannot finish.
14305 @node ODT export commands
14306 @subsection ODT export commands
14308 @table @asis
14309 @item @kbd{C-c C-e o o} (@code{org-export-to-odt})
14310 @kindex C-c C-e o o
14311 @findex org-export-to-odt
14312 Export as OpenDocument Text file.
14314 @cindex @samp{EXPORT_FILE_NAME}, property
14315 @vindex org-odt-preferred-output-format
14317 If @code{org-odt-preferred-output-format} is specified, the ODT export
14318 back-end automatically converts the exported file to that format.
14320 For @samp{myfile.org}, Org exports to @samp{myfile.odt}, overwriting
14321 without warning.  The ODT export back-end exports a region only
14322 if a region was active.
14324 If the selected region is a single tree, the ODT export back-end
14325 makes the tree head the document title.  Incidentally, @kbd{C-c @@} selects the current sub-tree.  If the tree head entry has,
14326 or inherits, an @samp{EXPORT_FILE_NAME} property, the ODT export
14327 back-end uses that for file name.
14329 @item @kbd{C-c C-e o O}
14330 @kindex C-c C-e o O
14331 Export as an OpenDocument Text file and open the resulting file.
14333 @vindex org-export-odt-preferred-output-format
14334 If @code{org-export-odt-preferred-output-format} is specified, open
14335 the converted file instead.  See @ref{Automatically exporting to other formats}.
14336 @end table
14338 @node ODT specific export settings
14339 @subsection ODT specific export settings
14341 The ODT export back-end has several additional keywords for
14342 customizing ODT output.  Setting these keywords works similar to the
14343 general options (see @ref{Export Settings}).
14345 @table @asis
14346 @item @samp{DESCRIPTION}
14347 @cindex @samp{DESCRIPTION}, keyword
14348 This is the document's description, which the ODT export back-end
14349 inserts as document metadata.  For long descriptions, use
14350 multiple lines, prefixed with @samp{DESCRIPTION}.
14352 @item @samp{KEYWORDS}
14353 @cindex @samp{KEYWORDS}, keyword
14354 The keywords for the document.  The ODT export back-end inserts
14355 the description along with author name, keywords, and related
14356 file metadata as metadata in the output file.  Use multiple
14357 @samp{KEYWORDS} if necessary.
14359 @item @samp{ODT_STYLES_FILE}
14360 @cindex @samp{ODT_STYLES_FILE}, keyword
14361 @vindex org-odt-styles-file
14362 The ODT export back-end uses the @code{org-odt-styles-file} by
14363 default.  See @ref{Applying custom styles} for details.
14365 @item @samp{SUBTITLE}
14366 @cindex @samp{SUBTITLE}, keyword
14367 The document subtitle.
14368 @end table
14370 @node Extending ODT export
14371 @subsection Extending ODT export
14373 The ODT export back-end can produce documents in other formats besides
14374 ODT using a specialized ODT converter process.  Its common interface
14375 works with popular converters to produce formats such as @samp{doc}, or
14376 convert a document from one format, say @samp{csv}, to another format, say
14377 @samp{xls}.
14379 @cindex @file{unoconv}
14380 @vindex org-odt-convert-process
14381 Customize @code{org-odt-convert-process} variable to point to @samp{unoconv},
14382 which is the ODT's preferred converter.  Working installations of
14383 LibreOffice would already have @samp{unoconv} installed.  Alternatively,
14384 other converters may be substituted here.  See @ref{Configuring a document converter}.
14386 @anchor{Automatically exporting to other formats}
14387 @subsubheading Automatically exporting to other formats
14389 @vindex org-odt-preferred-output-format
14390 If ODT format is just an intermediate step to get to other formats,
14391 such as @samp{doc}, @samp{docx}, @samp{rtf}, or @samp{pdf}, etc., then extend the ODT
14392 export back-end to directly produce that format.  Specify the final
14393 format in the @code{org-odt-preferred-output-format} variable.  This is one
14394 way to extend (see @ref{ODT export commands}).
14396 @anchor{Converting between document formats}
14397 @subsubheading Converting between document formats
14399 The Org export back-end is made to be inter-operable with a wide range
14400 of text document format converters.  Newer generation converters, such
14401 as LibreOffice and Pandoc, can handle hundreds of formats at once.
14402 Org provides a consistent interaction with whatever converter is
14403 installed.  Here are some generic commands:
14405 @table @asis
14406 @item @kbd{M-x org-odt-convert}
14407 @findex org-odt-convert
14408 Convert an existing document from one format to another.  With
14409 a prefix argument, opens the newly produced file.
14410 @end table
14412 @node Applying custom styles
14413 @subsection Applying custom styles
14415 @cindex styles, custom
14416 @cindex template, custom
14418 The ODT export back-end comes with many OpenDocument styles (see
14419 @ref{Working with OpenDocument style files}).  To expand or further
14420 customize these built-in style sheets, either edit the style sheets
14421 directly or generate them using an application such as LibreOffice.
14422 The example here shows creating a style using LibreOffice.
14424 @anchor{Applying custom styles the easy way}
14425 @subsubheading Applying custom styles: the easy way
14427 @enumerate
14428 @item
14429 Create a sample @samp{example.org} file with settings as shown below,
14430 and export it to ODT format.
14432 @example
14433 #+OPTIONS: H:10 num:t
14434 @end example
14436 @item
14437 Open the above @samp{example.odt} using LibreOffice.  Use the @emph{Stylist}
14438 to locate the target styles, which typically have the ``Org'' prefix.
14439 Open one, modify, and save as either OpenDocument Text (ODT) or
14440 OpenDocument Template (OTT) file.
14442 @item
14443 @vindex org-odt-styles-file
14444 Customize the variable @code{org-odt-styles-file} and point it to the
14445 newly created file.  For additional configuration options, see
14446 @ref{x-overriding-factory-styles, , Overriding factory styles}.
14448 @cindex @samp{ODT_STYLES_FILE}, keyword
14449 To apply an ODT style to a particular file, use the
14450 @samp{ODT_STYLES_FILE} keyword as shown in the example below:
14452 @example
14453 #+ODT_STYLES_FILE: "/path/to/example.ott"
14454 @end example
14456 @noindent
14459 @example
14460 #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
14461 @end example
14462 @end enumerate
14464 @anchor{Using third-party styles and templates}
14465 @subsubheading Using third-party styles and templates
14467 The ODT export back-end relies on many templates and style names.
14468 Using third-party styles and templates can lead to mismatches.
14469 Templates derived from built in ODT templates and styles seem to have
14470 fewer problems.
14472 @node Links in ODT export
14473 @subsection Links in ODT export
14475 @cindex links, in ODT export
14477 ODT exporter creates native cross-references for internal links.  It
14478 creates Internet-style links for all other links.
14480 A link with no description and pointing to a regular, un-itemized,
14481 outline heading is replaced with a cross-reference and section number
14482 of the heading.
14484 A @samp{\ref@{label@}}-style reference to an image, table etc., is replaced
14485 with a cross-reference and sequence number of the labeled entity.  See
14486 @ref{Labels and captions in ODT export}.
14488 @node Tables in ODT export
14489 @subsection Tables in ODT export
14491 @cindex tables, in ODT export
14493 The ODT export back-end handles native Org mode tables (see @ref{Tables})
14494 and simple @samp{table.el} tables.  Complex @samp{table.el} tables having column
14495 or row spans are not supported.  Such tables are stripped from the
14496 exported document.
14498 By default, the ODT export back-end exports a table with top and
14499 bottom frames and with ruled lines separating row and column groups
14500 (see @ref{Column Groups}).  All tables are typeset to occupy the same
14501 width.  The ODT export back-end honors any table alignments and
14502 relative widths for columns (see @ref{Column Width and Alignment}).
14504 Note that the ODT export back-end interprets column widths as weighted
14505 ratios, the default weight being 1.
14507 @cindex @samp{ATTR_ODT}, keyword
14508 Specifying @samp{:rel-width} property on an @samp{ATTR_ODT} line controls the
14509 width of the table.  For example:
14511 @example
14512 #+ATTR_ODT: :rel-width 50
14513 | Area/Month    |   Jan |   Feb |   Mar |   Sum |
14514 |---------------+-------+-------+-------+-------|
14515 | /             |     < |       |       |     < |
14516 | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
14517 | North America |     1 |    21 |   926 |   948 |
14518 | Middle East   |     6 |    75 |   844 |   925 |
14519 | Asia Pacific  |     9 |    27 |   790 |   826 |
14520 |---------------+-------+-------+-------+-------|
14521 | Sum           |    16 |   123 |  2560 |  2699 |
14522 @end example
14524 On export, the above table takes 50% of text width area.  The exporter
14525 sizes the columns in the ratio: 13:5:5:5:6.  The first column is
14526 left-aligned and rest of the columns, right-aligned.  Vertical rules
14527 separate the header and the last column.  Horizontal rules separate
14528 the header and the last row.
14530 For even more customization, create custom table styles and associate
14531 them with a table using the @samp{ATTR_ODT} keyword.  See @ref{Customizing tables in ODT export}.
14533 @node Images in ODT export
14534 @subsection Images in ODT export
14536 @cindex images, embedding in ODT
14537 @cindex embedding images in ODT
14539 @anchor{Embedding images}
14540 @subsubheading Embedding images
14542 The ODT export back-end processes image links in Org files that do not
14543 have descriptions, such as these links @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]},
14544 as direct image insertions in the final output.  Either of these
14545 examples works:
14547 @example
14548 [[file:img.png]]
14549 @end example
14551 @example
14552 [[./img.png]]
14553 @end example
14555 @anchor{Embedding clickable images}
14556 @subsubheading Embedding clickable images
14558 For clickable images, provide a link whose description is another link
14559 to an image file.  For example, to embed an image
14560 @samp{org-mode-unicorn.png} which when clicked jumps to @uref{https://orgmode.org}
14561 website, do the following
14563 @example
14564 [[https://orgmode.org][./org-mode-unicorn.png]]
14565 @end example
14567 @anchor{Sizing and scaling of embedded images}
14568 @subsubheading Sizing and scaling of embedded images
14570 @cindex @samp{ATTR_ODT}, keyword
14572 Control the size and scale of the embedded images with the @samp{ATTR_ODT}
14573 attribute.
14575 @cindex identify, ImageMagick
14576 @vindex org-odt-pixels-per-inch
14577 The ODT export back-end starts with establishing the size of the image
14578 in the final document.  The dimensions of this size are measured in
14579 centimeters.  The back-end then queries the image file for its
14580 dimensions measured in pixels.  For this measurement, the back-end
14581 relies on ImageMagick's identify program or Emacs @code{create-image} and
14582 @code{image-size} API.  ImageMagick is the preferred choice for large file
14583 sizes or frequent batch operations.  The back-end then converts the
14584 pixel dimensions using @code{org-odt-pixels-per-inch} into the familiar 72
14585 dpi or 96 dpi.  The default value for this is in
14586 @code{display-pixels-per-inch}, which can be tweaked for better results
14587 based on the capabilities of the output device.  Here are some common
14588 image scaling operations:
14590 @table @asis
14591 @item Explicitly size the image
14592 To embed @samp{img.png} as a 10 cm x 10 cm image, do the following:
14594 @example
14595 #+ATTR_ODT: :width 10 :height 10
14596 [[./img.png]]
14597 @end example
14599 @item Scale the image
14600 To embed @samp{img.png} at half its size, do the following:
14602 @example
14603 #+ATTR_ODT: :scale 0.5
14604 [[./img.png]]
14605 @end example
14607 @item Scale the image to a specific width
14608 To embed @samp{img.png} with a width of 10 cm while retaining the
14609 original height:width ratio, do the following:
14611 @example
14612 #+ATTR_ODT: :width 10
14613 [[./img.png]]
14614 @end example
14616 @item Scale the image to a specific height
14617 To embed @samp{img.png} with a height of 10 cm while retaining the
14618 original height:width ratio, do the following:
14620 @example
14621 #+ATTR_ODT: :height 10
14622 [[./img.png]]
14623 @end example
14624 @end table
14626 @anchor{Anchoring of images}
14627 @subsubheading Anchoring of images
14629 @cindex @samp{ATTR_ODT}, keyword
14630 The ODT export back-end can anchor images to @samp{"as-char"},
14631 @samp{"paragraph"}, or @samp{"page"}.  Set the preferred anchor using the
14632 @samp{:anchor} property of the @samp{ATTR_ODT} line.
14634 To create an image that is anchored to a page:
14636 @example
14637 #+ATTR_ODT: :anchor "page"
14638 [[./img.png]]
14639 @end example
14641 @node Math formatting in ODT export
14642 @subsection Math formatting in ODT export
14644 The ODT exporter has special support for handling math.
14646 @menu
14647 * @LaTeX{} math snippets::       Embedding in @LaTeX{} format.
14648 * MathML and OpenDocument formula files:: Embedding in native format.
14649 @end menu
14651 @node @LaTeX{} math snippets
14652 @subsubsection @LaTeX{} math snippets
14654 @LaTeX{} math snippets (see @ref{@LaTeX{} fragments}) can be embedded in the ODT
14655 document in one of the following ways:
14657 @table @asis
14658 @item MathML
14659 @cindex MathML
14660 Add this line to the Org file.  This option is activated on
14661 a per-file basis.
14663 @example
14664 #+OPTIONS: tex:t
14665 @end example
14667 With this option, @LaTeX{} fragments are first converted into MathML
14668 fragments using an external @LaTeX{}-to-MathML converter program.
14669 The resulting MathML fragments are then embedded as an
14670 OpenDocument Formula in the exported document.
14672 @vindex org-latex-to-mathml-convert-command
14673 @vindex org-latex-to-mathml-jar-file
14674 You can specify the @LaTeX{}-to-MathML converter by customizing the
14675 variables @code{org-latex-to-mathml-convert-command} and
14676 @code{org-latex-to-mathml-jar-file}.
14678 If you prefer to use MathToWeb@footnote{See @uref{http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl, MathToWeb}.} as your converter, you can
14679 configure the above variables as shown below.
14681 @lisp
14682 (setq org-latex-to-mathml-convert-command
14683       "java -jar %j -unicode -force -df %o %I"
14684       org-latex-to-mathml-jar-file
14685       "/path/to/mathtoweb.jar")
14686 @end lisp
14688 To use @LaTeX{}​ML@footnote{See @uref{http://dlmf.nist.gov/LaTeXML/}.} use
14690 @lisp
14691 (setq org-latex-to-mathml-convert-command
14692       "latexmlmath \"%i\" --presentationmathml=%o")
14693 @end lisp
14695 To quickly verify the reliability of the @LaTeX{}-to-MathML
14696 converter, use the following commands:
14698 @table @asis
14699 @item @kbd{M-x org-export-as-odf}
14700 Convert a @LaTeX{} math snippet to an OpenDocument formula
14701 (@samp{.odf}) file.
14703 @item @kbd{M-x org-export-as-odf-and-open}
14704 Convert a @LaTeX{} math snippet to an OpenDocument formula
14705 (@samp{.odf}) file and open the formula file with the
14706 system-registered application.
14707 @end table
14709 @item PNG images
14710 @cindex dvipng
14711 @cindex dvisvgm
14712 @cindex ImageMagick
14713 Add this line to the Org file.  This option is activated on
14714 a per-file basis.
14716 @example
14717 #+OPTIONS: tex:dvipng
14718 @end example
14720 @example
14721 #+OPTIONS: tex:dvisvgm
14722 @end example
14724 @noindent
14727 @example
14728 #+OPTIONS: tex:imagemagick
14729 @end example
14731 Under this option, @LaTeX{} fragments are processed into PNG or SVG
14732 images and the resulting images are embedded in the exported
14733 document.  This method requires dvipng program, dvisvgm or
14734 ImageMagick programs.
14735 @end table
14737 @node MathML and OpenDocument formula files
14738 @subsubsection MathML and OpenDocument formula files
14740 When embedding @LaTeX{} math snippets in ODT documents is not reliable,
14741 there is one more option to try.  Embed an equation by linking to its
14742 MathML (@samp{.mml}) source or its OpenDocument formula (@samp{.odf}) file as
14743 shown below:
14745 @example
14746 [[./equation.mml]]
14747 @end example
14749 @noindent
14752 @example
14753 [[./equation.odf]]
14754 @end example
14756 @node Labels and captions in ODT export
14757 @subsection Labels and captions in ODT export
14759 ODT format handles labeling and captioning of objects based on their
14760 types.  Inline images, tables, @LaTeX{} fragments, and Math formulas are
14761 numbered and captioned separately.  Each object also gets a unique
14762 sequence number based on its order of first appearance in the Org
14763 file.  Each category has its own sequence.  A caption is just a label
14764 applied to these objects.
14766 @example
14767 #+CAPTION: Bell curve
14768 #+NAME:   fig:SED-HR4049
14769 [[./img/a.png]]
14770 @end example
14772 When rendered, it may show as follows in the exported document:
14774 @example
14775 Figure 2: Bell curve
14776 @end example
14778 @vindex org-odt-category-map-alist
14779 To modify the category component of the caption, customize the option
14780 @code{org-odt-category-map-alist}.  For example, to tag embedded images
14781 with the string ``Illustration'' instead of the default string ``Figure'',
14782 use the following setting:
14784 @lisp
14785 (setq org-odt-category-map-alist
14786       '(("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))
14787 @end lisp
14789 With the above modification, the previous example changes to:
14791 @example
14792 Illustration 2: Bell curve
14793 @end example
14795 @node Literal examples in ODT export
14796 @subsection Literal examples in ODT export
14798 The ODT export back-end supports literal examples (see @ref{Literal Examples}) with full fontification.  Internally, the ODT export
14799 back-end relies on @samp{htmlfontify.el} to generate the style definitions
14800 needed for fancy listings.  The auto-generated styles get @samp{OrgSrc}
14801 prefix and inherit colors from the faces used by Emacs Font Lock
14802 library for that source language.
14804 @vindex org-odt-fontify-srcblocks
14805 For custom fontification styles, customize the
14806 @code{org-odt-create-custom-styles-for-srcblocks} option.
14808 @vindex org-odt-create-custom-styles-for-srcblocks
14809 To turn off fontification of literal examples, customize the
14810 @code{org-odt-fontify-srcblocks} option.
14812 @node Advanced topics in ODT export
14813 @subsection Advanced topics in ODT export
14815 The ODT export back-end has extensive features useful for power users
14816 and frequent uses of ODT formats.
14818 @anchor{Configuring a document converter}
14819 @subsubheading Configuring a document converter
14821 @cindex convert
14822 @cindex doc, docx, rtf
14823 @cindex converter
14825 The ODT export back-end works with popular converters with little or
14826 no extra configuration.  See @ref{Extending ODT export}.  The following is
14827 for unsupported converters or tweaking existing defaults.
14829 @table @asis
14830 @item Register the converter
14831 @vindex org-export-odt-convert-processes
14832 Add the name of the converter to the @code{org-odt-convert-processes}
14833 variable.  Note that it also requires how the converter is
14834 invoked on the command line.  See the variable's docstring for
14835 details.
14837 @item Configure its capabilities
14838 @vindex org-export-odt-convert-capabilities
14839 Specify which formats the converter can handle by customizing the
14840 variable @code{org-odt-convert-capabilities}.  Use the entry for the
14841 default values in this variable for configuring the new
14842 converter.  Also see its docstring for details.
14844 @item Choose the converter
14845 @vindex org-export-odt-convert-process
14846 Select the newly added converter as the preferred one by
14847 customizing the option @code{org-odt-convert-process}.
14848 @end table
14850 @anchor{Working with OpenDocument style files}
14851 @subsubheading Working with OpenDocument style files
14853 @cindex styles, custom
14854 @cindex template, custom
14856 This section explores the internals of the ODT exporter; the means by which
14857 it produces styled documents; the use of automatic and custom OpenDocument
14858 styles.
14860 The ODT exporter relies on two files for generating its output.  These
14861 files are bundled with the distribution under the directory pointed to
14862 by the variable @code{org-odt-styles-dir}.  The two files are:
14864 @table @asis
14865 @item @samp{OrgOdtStyles.xml} @anchor{x-orgodtstyles-xml}
14866 This file contributes to the @samp{styles.xml} file of the final ODT
14867 document.  This file gets modified for the following purposes:
14869 @enumerate
14870 @item
14871 To control outline numbering based on user settings;
14873 @item
14874 To add styles generated by @samp{htmlfontify.el} for fontification of
14875 code blocks.
14876 @end enumerate
14878 @item @samp{OrgOdtContentTemplate.xml} @anchor{x-orgodtcontenttemplate-xml}
14879 This file contributes to the @samp{content.xml} file of the final ODT
14880 document.  The contents of the Org outline are inserted between the
14881 @samp{<office:text>} @dots{} @samp{</office:text>} elements of this file.
14883 Apart from serving as a template file for the final @samp{content.xml},
14884 the file serves the following purposes:
14886 @enumerate
14887 @item
14888 It contains automatic styles for formatting of tables which are
14889 referenced by the exporter;
14891 @item
14892 It contains @samp{<text:sequence-decl>} @dots{} @samp{</text:sequence-decl>}
14893 elements that control numbering of tables, images, equations, and
14894 similar entities.
14895 @end enumerate
14896 @end table
14898 @anchor{x-overriding-factory-styles} The following two variables control
14899 the location from where the ODT exporter picks up the custom styles
14900 and content template files.  Customize these variables to override the
14901 factory styles used by the exporter.
14903 @table @asis
14904 @item @code{org-odt-styles-file}
14905 The ODT export back-end uses the file pointed to by this
14906 variable, such as @samp{styles.xml}, for the final output.  It can
14907 take one of the following values:
14909 @table @asis
14910 @item @samp{FILE.xml}
14911 Use this file instead of the default @samp{styles.xml}
14913 @item @samp{FILE.odt} or @samp{FILE.ott}
14914 Use the @samp{styles.xml} contained in the specified OpenDocument
14915 Text or Template file
14917 @item @samp{FILE.odt} or @samp{FILE.ott} and a subset of included files
14918 Use the @samp{styles.xml} contained in the specified OpenDocument
14919 Text or Template file.  Additionally extract the specified
14920 member files and embed those within the final ODT document.
14922 Use this option if the @samp{styles.xml} file references additional
14923 files like header and footer images.
14925 @item @code{nil}
14926 Use the default @samp{styles.xml}.
14927 @end table
14929 @item @code{org-odt-content-template-file}
14930 Use this variable to specify the blank @samp{content.xml} used in the
14931 final output.
14932 @end table
14934 @anchor{Creating one-off styles}
14935 @subsubheading Creating one-off styles
14937 The ODT export back-end can read embedded raw OpenDocument XML from
14938 the Org file.  Such direct formatting is useful for one-off instances.
14940 @table @asis
14941 @item Embedding ODT tags as part of regular text
14942 Enclose OpenDocument syntax in @samp{@@@@odt:...@@@@} for inline markup.
14943 For example, to highlight a region of text do the following:
14945 @example
14946 @@@@odt:<text:span text:style-name="Highlight">This is highlighted
14947 text</text:span>@@@@.  But this is regular text.
14948 @end example
14950 @strong{Hint:} To see the above example in action, edit the @samp{styles.xml}
14951 (see @ref{x-orgodtstyles-xml, , Factory styles}) and add a custom @emph{Highlight} style as shown
14952 below:
14954 @example
14955 <style:style style:name="Highlight" style:family="text">
14956   <style:text-properties fo:background-color="#ff0000"/>
14957 </style:style>
14958 @end example
14960 @item Embedding a one-line OpenDocument XML
14961 @cindex @samp{ODT}, keyword
14962 The ODT export back-end can read one-liner options with @samp{#+ODT:}
14963 in the Org file.  For example, to force a page break:
14965 @example
14966 #+ODT: <text:p text:style-name="PageBreak"/>
14967 @end example
14969 @strong{Hint:} To see the above example in action, edit your
14970 @samp{styles.xml} (see @ref{x-orgodtstyles-xml, , Factory styles}) and add a custom @samp{PageBreak}
14971 style as shown below.
14973 @example
14974 <style:style style:name="PageBreak" style:family="paragraph"
14975              style:parent-style-name="Text_20_body">
14976   <style:paragraph-properties fo:break-before="page"/>
14977 </style:style>
14978 @end example
14980 @item Embedding a block of OpenDocument XML
14981 The ODT export back-end can also read ODT export blocks for
14982 OpenDocument XML.  Such blocks use the @samp{#+BEGIN_EXPORT odt}
14983 @dots{} @samp{#+END_EXPORT} constructs.
14985 For example, to create a one-off paragraph that uses bold text,
14986 do the following:
14988 @example
14989 #+BEGIN_EXPORT odt
14990   <text:p text:style-name="Text_20_body_20_bold">
14991   This paragraph is specially formatted and uses bold text.
14992   </text:p>
14993 #+END_EXPORT
14994 @end example
14995 @end table
14997 @anchor{Customizing tables in ODT export}
14998 @subsubheading Customizing tables in ODT export
15000 @cindex tables, in ODT export
15001 @cindex @samp{ATTR_ODT}, keyword
15003 Override the default table format by specifying a custom table style
15004 with the @samp{#+ATTR_ODT} line.  For a discussion on default formatting of
15005 tables, see @ref{Tables in ODT export}.
15007 This feature closely mimics the way table templates are defined in the
15008 OpenDocument-v1.2 specification.@footnote{@uref{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html, OpenDocument-v1.2 Specification}}
15010 @vindex org-odt-table-styles
15011 For quick preview of this feature, install the settings below and export the
15012 table that follows:
15014 @lisp
15015 (setq org-export-odt-table-styles
15016       (append org-export-odt-table-styles
15017               '(("TableWithHeaderRowAndColumn" "Custom"
15018                  ((use-first-row-styles . t)
15019                   (use-first-column-styles . t)))
15020                 ("TableWithFirstRowandLastRow" "Custom"
15021                  ((use-first-row-styles . t)
15022                   (use-last-row-styles . t))))))
15023 @end lisp
15025 @example
15026 #+ATTR_ODT: :style TableWithHeaderRowAndColumn
15027 | Name  | Phone | Age |
15028 | Peter |  1234 |  17 |
15029 | Anna  |  4321 |  25 |
15030 @end example
15032 The example above used @samp{Custom} template and installed two table
15033 styles @samp{TableWithHeaderRowAndColumn} and
15034 @samp{TableWithFirstRowandLastRow}.  @strong{Important:} The OpenDocument styles
15035 needed for producing the above template were pre-defined.  They are
15036 available in the section marked @samp{Custom Table Template} in
15037 @samp{OrgOdtContentTemplate.xml} (see @ref{x-orgodtcontenttemplate-xml, , Factory styles}).  For adding new
15038 templates, define new styles there.
15040 To use this feature proceed as follows:
15042 @enumerate
15043 @item
15044 Create a table template@footnote{See the @samp{<table:table-template>} element of the
15045 OpenDocument-v1.2 specification.}.
15047 A table template is set of @samp{table-cell} and @samp{paragraph} styles for
15048 each of the following table cell categories:
15050 @itemize
15051 @item
15052 Body
15053 @item
15054 First column
15055 @item
15056 Last column
15057 @item
15058 First row
15059 @item
15060 Last row
15061 @item
15062 Even row
15063 @item
15064 Odd row
15065 @item
15066 Even column
15067 @item
15068 Odd Column
15069 @end itemize
15071 The names for the above styles must be chosen based on the name of
15072 the table template using a well-defined convention.
15074 The naming convention is better illustrated with an example.  For
15075 a table template with the name @samp{Custom}, the needed style names are
15076 listed in the following table.
15078 @multitable {aaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
15079 @headitem Cell type
15080 @tab Cell style
15081 @tab Paragraph style
15082 @item Body
15083 @tab @samp{CustomTableCell}
15084 @tab @samp{CustomTableParagraph}
15085 @item First column
15086 @tab @samp{CustomFirstColumnTableCell}
15087 @tab @samp{CustomFirstColumnTableParagraph}
15088 @item Last column
15089 @tab @samp{CustomLastColumnTableCell}
15090 @tab @samp{CustomLastColumnTableParagraph}
15091 @item First row
15092 @tab @samp{CustomFirstRowTableCell}
15093 @tab @samp{CustomFirstRowTableParagraph}
15094 @item Last row
15095 @tab @samp{CustomLastRowTableCell}
15096 @tab @samp{CustomLastRowTableParagraph}
15097 @item Even row
15098 @tab @samp{CustomEvenRowTableCell}
15099 @tab @samp{CustomEvenRowTableParagraph}
15100 @item Odd row
15101 @tab @samp{CustomOddRowTableCell}
15102 @tab @samp{CustomOddRowTableParagraph}
15103 @item Even column
15104 @tab @samp{CustomEvenColumnTableCell}
15105 @tab @samp{CustomEvenColumnTableParagraph}
15106 @item Odd column
15107 @tab @samp{CustomOddColumnTableCell}
15108 @tab @samp{CustomOddColumnTableParagraph}
15109 @end multitable
15111 To create a table template with the name @samp{Custom}, define the above
15112 styles in the @samp{<office:automatic-styles>} @dots{}
15113 @samp{</office:automatic-styles>} element of the content template file
15114 (see @ref{x-orgodtcontenttemplate-xml, , Factory styles}).
15116 @item
15117 Define a table style@footnote{See the attributes @samp{table:template-name},
15118 @samp{table:use-first-row-styles}, @samp{table:use-last-row-styles},
15119 @samp{table:use-first-column-styles}, @samp{table:use-last-column-styles},
15120 @samp{table:use-banding-rows-styles}, and @samp{table:use-banding-column-styles}
15121 of the @samp{<table:table>} element in the OpenDocument-v1.2 specification.}.
15123 @vindex org-odt-table-styles
15124 To define a table style, create an entry for the style in the
15125 variable @code{org-odt-table-styles} and specify the following:
15127 @itemize
15128 @item
15129 the name of the table template created in step (1),
15130 @item
15131 the set of cell styles in that template that are to be activated.
15132 @end itemize
15134 For example, the entry below defines two different table styles
15135 @samp{TableWithHeaderRowAndColumn} and @samp{TableWithFirstRowandLastRow}
15136 based on the same template @samp{Custom}.  The styles achieve their
15137 intended effect by selectively activating the individual cell
15138 styles in that template.
15140 @lisp
15141 (setq org-export-odt-table-styles
15142       (append org-export-odt-table-styles
15143               '(("TableWithHeaderRowAndColumn" "Custom"
15144                  ((use-first-row-styles . t)
15145                   (use-first-column-styles . t)))
15146                 ("TableWithFirstRowandLastRow" "Custom"
15147                  ((use-first-row-styles . t)
15148                   (use-last-row-styles . t))))))
15149 @end lisp
15151 @item
15152 Associate a table with the table style.
15154 To do this, specify the table style created in step (2) as part of
15155 the @samp{ATTR_ODT} line as shown below.
15157 @example
15158 #+ATTR_ODT: :style TableWithHeaderRowAndColumn
15159 | Name  | Phone | Age |
15160 | Peter |  1234 |  17 |
15161 | Anna  |  4321 |  25 |
15162 @end example
15163 @end enumerate
15165 @anchor{Validating OpenDocument XML}
15166 @subsubheading Validating OpenDocument XML
15168 Sometimes ODT format files may not open due to @samp{.odt} file corruption.
15169 To verify if such a file is corrupt, validate it against the
15170 OpenDocument Relax NG Compact (RNC) syntax schema.  But first the
15171 @samp{.odt} files have to be decompressed using @samp{zip}.  Note that @samp{.odt}
15172 files are ZIP archives: @ref{File Archives,,,emacs,}.  The contents of
15173 ODT files are in XML.  For general help with validation---and
15174 schema-sensitive editing---of XML files:
15175 @ref{Introduction,,,nxml-mode,}.
15177 @vindex org-export-odt-schema-dir
15178 Customize @code{org-odt-schema-dir} to point to a directory with
15179 OpenDocument RNC files and the needed schema-locating rules.  The ODT
15180 export back-end takes care of updating the
15181 @code{rng-schema-locating-files}.
15183 @node Org Export
15184 @section Org Export
15186 @cindex Org export
15187 @emph{org} export back-end creates a normalized version of the Org document
15188 in current buffer.  The exporter evaluates Babel code (see @ref{Evaluating Code Blocks}) and removes content specific to other back-ends.
15190 @anchor{Org export commands}
15191 @subheading Org export commands
15193 @table @asis
15194 @item @kbd{C-c C-e O o} (@code{org-org-export-to-org})
15195 @kindex C-c C-e O o
15196 @findex org-org-export-to-org
15197 Export as an Org file with a @samp{.org} extension.  For @samp{myfile.org},
15198 Org exports to @samp{myfile.org.org}, overwriting without warning.
15200 @item @kbd{C-c C-e O v} (~~)
15201 @kindex C-c C-e O v
15202 Export to an Org file, then open it.
15203 @end table
15205 @node Texinfo Export
15206 @section Texinfo Export
15208 @menu
15209 * Texinfo export commands::      Invoking commands.
15210 * Texinfo specific export settings:: Setting the environment.
15211 * Texinfo file header::          Generating the header.
15212 * Texinfo title and copyright page:: Creating preamble pages.
15213 * Info directory file::          Installing a manual in Info file hierarchy.
15214 * Headings and sectioning structure:: Building document structure.
15215 * Indices::                      Creating indices.
15216 * Quoting Texinfo code::         Incorporating literal Texinfo code.
15217 * Plain lists in Texinfo export:: List attributes.
15218 * Tables in Texinfo export::     Table attributes.
15219 * Images in Texinfo export::     Image attributes.
15220 * Special blocks in Texinfo export:: Special block attributes.
15221 * A Texinfo example::            Processing Org to Texinfo.
15222 @end menu
15224 @node Texinfo export commands
15225 @subsection Texinfo export commands
15227 @table @asis
15228 @item @kbd{C-c C-e i t} (@code{org-texinfo-export-to-texinfo})
15229 @kindex C-c C-e i t
15230 @findex org-texinfo-export-to-texinfo
15231 Export as a Texinfo file with @samp{.texi} extension.  For
15232 @samp{myfile.org}, Org exports to @samp{myfile.texi}, overwriting without
15233 warning.
15235 @item @kbd{C-c C-e i i} (@code{org-texinfo-export-to-info})
15236 @kindex C-c C-e i i
15237 @findex org-texinfo-export-to-info
15238 @vindex org-texinfo-info-process
15239 Export to Texinfo format first and then process it to make an
15240 Info file.  To generate other formats, such as DocBook, customize
15241 the @code{org-texinfo-info-process} variable.
15242 @end table
15244 @node Texinfo specific export settings
15245 @subsection Texinfo specific export settings
15247 The Texinfo export back-end has several additional keywords for
15248 customizing Texinfo output.  Setting these keywords works similar to
15249 the general options (see @ref{Export Settings}).
15251 @table @asis
15252 @item @samp{SUBTITLE}
15253 @cindex @samp{SUBTITLE}, keyword
15254 The document subtitle.
15256 @item @samp{SUBAUTHOR}
15257 @cindex @samp{SUBAUTHOR}, keyword
15258 Additional authors for the document.
15260 @item @samp{TEXINFO_FILENAME}
15261 @cindex @samp{TEXINFO_FILENAME}, keyword
15262 The Texinfo filename.
15264 @item @samp{TEXINFO_CLASS}
15265 @cindex @samp{TEXINFO_CLASS}, keyword
15266 @vindex org-texinfo-default-class
15267 The default document class (@code{org-texinfo-default-class}), which
15268 must be a member of @code{org-texinfo-classes}.
15270 @item @samp{TEXINFO_HEADER}
15271 @cindex @samp{TEXINFO_HEADER}, keyword
15272 Arbitrary lines inserted at the end of the header.
15274 @item @samp{TEXINFO_POST_HEADER}
15275 @cindex @samp{TEXINFO_POST_HEADER}, keyword
15276 Arbitrary lines inserted after the end of the header.
15278 @item @samp{TEXINFO_DIR_CATEGORY}
15279 @cindex @samp{TEXINFO_DIR_CATEGORY}, keyword
15280 The directory category of the document.
15282 @item @samp{TEXINFO_DIR_TITLE}
15283 @cindex @samp{TEXINFO_DIR_TITLE}, keyword
15284 The directory title of the document.
15286 @item @samp{TEXINFO_DIR_DESC}
15287 @cindex @samp{TEXINFO_DIR_DESC}, keyword
15288 The directory description of the document.
15290 @item @samp{TEXINFO_PRINTED_TITLE}
15291 @cindex @samp{TEXINFO_PRINTED_TITLE}, keyword
15292 The printed title of the document.
15293 @end table
15295 @node Texinfo file header
15296 @subsection Texinfo file header
15298 @cindex @samp{TEXINFO_FILENAME}, keyword
15299 After creating the header for a Texinfo file, the Texinfo back-end
15300 automatically generates a name and destination path for the Info file.
15301 To override this default with a more sensible path and name, specify
15302 the @samp{TEXINFO_FILENAME} keyword.
15304 @vindex org-texinfo-coding-system
15305 @cindex @samp{TEXINFO_HEADER}, keyword
15306 Along with the output's file name, the Texinfo header also contains
15307 language details (see @ref{Export Settings}) and encoding system as set in
15308 the @code{org-texinfo-coding-system} variable.  Insert @samp{TEXINFO_HEADER}
15309 keywords for each additional command in the header, for example:
15311 @example
15312 #+TEXINFO_HEADER: @@synindex
15313 @end example
15315 @cindex @samp{TEXINFO_CLASS}, keyword
15316 @vindex org-texinfo-classes
15317 Instead of repeatedly installing the same set of commands, define
15318 a class in @code{org-texinfo-classes} once, and then activate it in the
15319 document by setting the @samp{TEXINFO_CLASS} keyword to that class.
15321 @node Texinfo title and copyright page
15322 @subsection Texinfo title and copyright page
15324 @cindex @samp{TEXINFO_PRINTED_TITLE}, keyword
15325 The default template for hard copy output has a title page with
15326 @samp{TITLE} and @samp{AUTHOR} keywords (see @ref{Export Settings}).  To replace the
15327 regular title with something different for the printed version, use
15328 the @samp{TEXINFO_PRINTED_TITLE} and @samp{SUBTITLE} keywords.  Both expect raw
15329 Texinfo code for setting their values.
15331 @cindex @samp{SUBAUTHOR}, keyword
15332 If one @samp{AUTHOR} line is not sufficient, add multiple @samp{SUBAUTHOR}
15333 keywords.  They have to be set in raw Texinfo code.
15335 @example
15336 #+AUTHOR: Jane Smith
15337 #+SUBAUTHOR: John Doe
15338 #+TEXINFO_PRINTED_TITLE: This Long Title@@@@inlinefmt@{tex,@@*@} Is Broken in @@TeX@{@}
15339 @end example
15341 @cindex @samp{COPYING}, property
15342 Copying material is defined in a dedicated headline with a non-@code{nil}
15343 @samp{COPYING} property.  The back-end inserts the contents within
15344 a @samp{@@copying} command at the beginning of the document.  The heading
15345 itself does not appear in the structure of the document.
15347 Copyright information is printed on the back of the title page.
15349 @example
15350 * Legalese
15351   :PROPERTIES:
15352   :COPYING: t
15353   :END:
15355   This is a short example of a complete Texinfo file, version 1.0.
15357   Copyright \copy 2016 Free Software Foundation, Inc.
15358 @end example
15360 @node Info directory file
15361 @subsection Info directory file
15363 @cindex @samp{dir} file, in Texinfo export
15364 @cindex Info directory file, in Texinfo export
15365 @cindex @code{install-info}, in Texinfo export
15367 @cindex @samp{TEXINFO_DIR_CATEGORY}, keyword
15368 @cindex @samp{TEXINFO_DIR_TITLE}, keyword
15369 @cindex @samp{TEXINFO_DIR_DESC}, keyword
15370 The end result of the Texinfo export process is the creation of an
15371 Info file.  This Info file's metadata has variables for category,
15372 title, and description: @samp{TEXINFO_DIR_CATEGORY}, @samp{TEXINFO_DIR_TITLE},
15373 and @samp{TEXINFO_DIR_DESC} keywords that establish where in the Info
15374 hierarchy the file fits.
15376 Here is an example that writes to the Info directory file:
15378 @example
15379 #+TEXINFO_DIR_CATEGORY: Emacs
15380 #+TEXINFO_DIR_TITLE: Org Mode: (org)
15381 #+TEXINFO_DIR_DESC: Outline-based notes management and organizer
15382 @end example
15384 @node Headings and sectioning structure
15385 @subsection Headings and sectioning structure
15387 @vindex org-texinfo-classes
15388 @vindex org-texinfo-default-class
15389 @cindex @samp{TEXINFO_CLASS}, keyword
15390 The Texinfo export back-end uses a pre-defined scheme to convert Org
15391 headlines to equivalent Texinfo structuring commands.  A scheme like
15392 this maps top-level headlines to numbered chapters tagged as
15393 @code{@@chapter} and lower-level headlines to unnumbered chapters tagged as
15394 @code{@@unnumbered}.  To override such mappings to introduce @code{@@part} or
15395 other Texinfo structuring commands, define a new class in
15396 @code{org-texinfo-classes}.  Activate the new class with the
15397 @samp{TEXINFO_CLASS} keyword.  When no new class is defined and activated,
15398 the Texinfo export back-end defaults to the
15399 @code{org-texinfo-default-class}.
15401 If an Org headline's level has no associated Texinfo structuring
15402 command, or is below a certain threshold (see @ref{Export Settings}), then
15403 the Texinfo export back-end makes it into a list item.
15405 @cindex @samp{APPENDIX}, property
15406 The Texinfo export back-end makes any headline with a non-@code{nil}
15407 @samp{APPENDIX} property into an appendix.  This happens independent of the
15408 Org headline level or the @samp{TEXINFO_CLASS} keyword.
15410 @cindex @samp{ALT_TITLE}, property
15411 @cindex @samp{DESCRIPTION}, property
15412 The Texinfo export back-end creates a menu entry after the Org
15413 headline for each regular sectioning structure.  To override this with
15414 a shorter menu entry, use the @samp{ALT_TITLE} property (see @ref{Table of Contents}).  Texinfo menu entries also have an option for a longer
15415 @samp{DESCRIPTION} property.  Here's an example that uses both to override
15416 the default menu entry:
15418 @example
15419 * Controlling Screen Display
15420   :PROPERTIES:
15421   :ALT_TITLE: Display
15422   :DESCRIPTION: Controlling Screen Display
15423   :END:
15424 @end example
15426 @cindex Top node, in Texinfo export
15427 The text before the first headline belongs to the @emph{Top} node, i.e.,
15428 the node in which a reader enters an Info manual.  As such, it is
15429 expected not to appear in printed output generated from the @samp{.texi}
15430 file.  See @ref{The Top Node,,,texinfo,}, for more information.
15432 @node Indices
15433 @subsection Indices
15435 @cindex @samp{CINDEX}, keyword
15436 @cindex concept index, in Texinfo export
15437 @cindex @samp{FINDEX}, keyword
15438 @cindex function index, in Texinfo export
15439 @cindex @samp{KINDEX}, keyword
15440 @cindex keystroke index, in Texinfo export
15441 @cindex @samp{PINDEX}, keyword
15442 @cindex program index, in Texinfo export
15443 @cindex @samp{TINDEX}, keyword
15444 @cindex data type index, in Texinfo export
15445 @cindex @samp{VINDEX}, keyword
15446 @cindex variable index, in Texinfo export
15447 The Texinfo export back-end recognizes these indexing keywords if used
15448 in the Org file: @samp{CINDEX}, @samp{FINDEX}, @samp{KINDEX}, @samp{PINDEX}, @samp{TINDEX} and
15449 @samp{VINDEX}.  Write their value as verbatim Texinfo code; in particular,
15450 @samp{@{}, @samp{@}} and @samp{@@} characters need to be escaped with @samp{@@} if they do not
15451 belong to a Texinfo command.
15453 @example
15454 #+CINDEX: Defining indexing entries
15455 @end example
15457 @cindex @samp{INDEX}, property
15458 For the back-end to generate an index entry for a headline, set the
15459 @samp{INDEX} property to @samp{cp} or @samp{vr}.  These abbreviations come from
15460 Texinfo that stand for concept index and variable index.  The Texinfo
15461 manual has abbreviations for all other kinds of indexes.  The back-end
15462 exports the headline as an unnumbered chapter or section command, and
15463 then inserts the index after its contents.
15465 @example
15466 * Concept Index
15467   :PROPERTIES:
15468   :INDEX: cp
15469   :END:
15470 @end example
15472 @node Quoting Texinfo code
15473 @subsection Quoting Texinfo code
15475 Use any of the following three methods to insert or escape raw Texinfo
15476 code:
15478 @cindex @samp{TEXINFO}, keyword
15479 @cindex @samp{BEGIN_EXPORT texinfo}
15480 @example
15481 Richard @@@@texinfo:@@sc@{@@@@Stallman@@@@texinfo:@}@@@@ commence' GNU.
15483 #+TEXINFO: @@need800
15484 This paragraph is preceded by...
15486 #+BEGIN_EXPORT texinfo
15487   @@auindex Johnson, Mark
15488   @@auindex Lakoff, George
15489 #+END_EXPORT
15490 @end example
15492 @node Plain lists in Texinfo export
15493 @subsection Plain lists in Texinfo export
15495 @cindex @samp{ATTR_TEXINFO}, keyword
15496 @cindex two-column tables, in Texinfo export
15498 @cindex table types, in Texinfo export
15499 The Texinfo export back-end by default converts description lists in
15500 the Org file using the default command @samp{@@table}, which results in
15501 a table with two columns.  To change this behavior, specify
15502 @samp{:table-type} with @samp{ftable} or @samp{vtable} attributes.  For more
15503 information, see @ref{Two-column Tables,,,texinfo,}.
15505 @vindex org-texinfo-table-default-markup
15506 The Texinfo export back-end by default also applies a text highlight
15507 based on the defaults stored in @code{org-texinfo-table-default-markup}.
15508 To override the default highlight command, specify another one with
15509 the @samp{:indic} attribute.
15511 @cindex multiple items in Texinfo lists
15512 Org syntax is limited to one entry per list item.  Nevertheless, the
15513 Texinfo export back-end can split that entry according to any text
15514 provided through the @samp{:sep} attribute.  Each part then becomes a new
15515 entry in the first column of the table.
15517 The following example illustrates all the attributes above:
15519 @example
15520 #+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
15521 - foo, bar :: This is the common text for variables foo and bar.
15522 @end example
15524 @noindent
15525 becomes
15527 @example
15528 @@vtable @@asis
15529 @@item foo
15530 @@itemx bar
15531 This is the common text for variables foo and bar.
15532 @@end table
15533 @end example
15535 @node Tables in Texinfo export
15536 @subsection Tables in Texinfo export
15538 @cindex @samp{ATTR_TEXINFO}, keyword
15539 When exporting tables, the Texinfo export back-end uses the widest
15540 cell width in each column.  To override this and instead specify as
15541 fractions of line length, use the @samp{:columns} attribute.  See example
15542 below.
15544 @example
15545 #+ATTR_TEXINFO: :columns .5 .5
15546 | a cell | another cell |
15547 @end example
15549 @node Images in Texinfo export
15550 @subsection Images in Texinfo export
15552 @cindex @samp{ATTR_TEXINFO}, keyword
15553 Insert a file link to the image in the Org file, and the Texinfo
15554 export back-end inserts the image.  These links must have the usual
15555 supported image extensions and no descriptions.  To scale the image,
15556 use @samp{:width} and @samp{:height} attributes.  For alternate text, use @samp{:alt}
15557 and specify the text using Texinfo code, as shown in the example:
15559 @example
15560 #+ATTR_TEXINFO: :width 1in :alt Alternate @@i@{text@}
15561 [[ridt.pdf]]
15562 @end example
15564 @node Special blocks in Texinfo export
15565 @subsection Special blocks in Texinfo export
15567 @cindex @samp{ATTR_TEXINFO}, keyword
15569 The Texinfo export back-end converts special blocks to commands with
15570 the same name.  It also adds any @samp{:options} attributes to the end of
15571 the command, as shown in this example:
15573 @example
15574 #+ATTR_TEXINFO: :options org-org-export-to-org ...
15575 #+BEGIN_defun
15576   A somewhat obsessive function name.
15577 #+END_defun
15578 @end example
15580 @noindent
15581 becomes
15583 @example
15584 @@defun org-org-export-to-org ...
15585   A somewhat obsessive function name.
15586 @@end defun
15587 @end example
15589 @node A Texinfo example
15590 @subsection A Texinfo example
15592 Here is a more detailed example Org file.  See
15593 @ref{GNU Sample Texts,,,texinfo,} for an equivalent example using
15594 Texinfo code.
15596 @example
15597 #+TITLE: GNU Sample @{@{@{version@}@}@}
15598 #+SUBTITLE: for version @{@{@{version@}@}@}, @{@{@{updated@}@}@}
15599 #+AUTHOR: A.U. Thor
15600 #+EMAIL: bug-sample@@gnu.org
15602 #+OPTIONS: ':t toc:t author:t email:t
15603 #+LANGUAGE: en
15605 #+MACRO: version 2.0
15606 #+MACRO: updated last updated 4 March 2014
15608 #+TEXINFO_FILENAME: sample.info
15609 #+TEXINFO_HEADER: @@syncodeindex pg cp
15611 #+TEXINFO_DIR_CATEGORY: Texinfo documentation system
15612 #+TEXINFO_DIR_TITLE: sample: (sample)
15613 #+TEXINFO_DIR_DESC: Invoking sample
15615 #+TEXINFO_PRINTED_TITLE: GNU Sample
15617 This manual is for GNU Sample (version @{@{@{version@}@}@},
15618 @{@{@{updated@}@}@}).
15620 * Copying
15621   :PROPERTIES:
15622   :COPYING:  t
15623   :END:
15625   This manual is for GNU Sample (version @{@{@{version@}@}@},
15626   @{@{@{updated@}@}@}), which is an example in the Texinfo documentation.
15628   Copyright \copy 2016 Free Software Foundation, Inc.
15630   #+BEGIN_QUOTE
15631   Permission is granted to copy, distribute and/or modify this
15632   document under the terms of the GNU Free Documentation License,
15633   Version 1.3 or any later version published by the Free Software
15634   Foundation; with no Invariant Sections, with no Front-Cover Texts,
15635   and with no Back-Cover Texts.  A copy of the license is included in
15636   the section entitled "GNU Free Documentation License".
15637   #+END_QUOTE
15639 * Invoking sample
15641   #+PINDEX: sample
15642   #+CINDEX: invoking @@command@{sample@}
15644   This is a sample manual.  There is no sample program to invoke, but
15645   if there were, you could see its basic usage and command line
15646   options here.
15648 * GNU Free Documentation License
15649   :PROPERTIES:
15650   :APPENDIX: t
15651   :END:
15653   #+TEXINFO: @@include fdl.texi
15655 * Index
15656   :PROPERTIES:
15657   :INDEX:    cp
15658   :END:
15659 @end example
15661 @node iCalendar Export
15662 @section iCalendar Export
15664 @cindex iCalendar export
15666 A large part of Org mode's interoperability success is its ability to
15667 easily export to or import from external applications.  The iCalendar
15668 export back-end takes calendar data from Org files and exports to the
15669 standard iCalendar format.
15671 @vindex org-icalendar-include-todo
15672 @vindex org-icalendar-use-deadline
15673 @vindex org-icalendar-use-scheduled
15674 The iCalendar export back-end can also incorporate TODO entries based
15675 on the configuration of the @code{org-icalendar-include-todo} variable.
15676 The back-end exports plain timestamps as @samp{VEVENT}, TODO items as
15677 @samp{VTODO}, and also create events from deadlines that are in non-TODO
15678 items.  The back-end uses the deadlines and scheduling dates in Org
15679 TODO items for setting the start and due dates for the iCalendar TODO
15680 entry.  Consult the @code{org-icalendar-use-deadline} and
15681 @code{org-icalendar-use-scheduled} variables for more details.
15683 @vindex org-icalendar-categories
15684 @vindex org-icalendar-alarm-time
15685 For tags on the headline, the iCalendar export back-end makes them
15686 into iCalendar categories.  To tweak the inheritance of tags and TODO
15687 states, configure the variable @code{org-icalendar-categories}.  To assign
15688 clock alarms based on time, configure the @code{org-icalendar-alarm-time}
15689 variable.
15691 @vindex org-icalendar-store-UID
15692 @cindex @samp{ID}, property
15693 The iCalendar format standard requires globally unique identifier---or
15694 UID---for each entry.  The iCalendar export back-end creates UIDs
15695 during export.  To save a copy of the UID in the Org file set the
15696 variable @code{org-icalendar-store-UID}.  The back-end looks for the @samp{ID}
15697 property of the entry for re-using the same UID for subsequent
15698 exports.
15700 Since a single Org entry can result in multiple iCalendar
15701 entries---timestamp, deadline, scheduled item, or TODO item---Org adds
15702 prefixes to the UID, depending on which part of the Org entry
15703 triggered the creation of the iCalendar entry.  Prefixing ensures UIDs
15704 remains unique, yet enable synchronization programs trace the
15705 connections.
15707 @table @asis
15708 @item @kbd{C-c C-e c f} (@code{org-icalendar-export-to-ics})
15709 @kindex C-c C-e c f
15710 @findex org-icalendar-export-to-ics
15711 Create iCalendar entries from the current Org buffer and store
15712 them in the same directory, using a file extension @samp{.ics}.
15714 @item @kbd{C-c C-e c a} (@code{org-icalendar-export-agenda-files})
15715 @kindex C-c C-e c a
15716 @findex org-icalendar-export-agenda-files
15717 Create iCalendar entries from Org files in @code{org-agenda-files} and
15718 store in a separate iCalendar file for each Org file.
15720 @item @kbd{C-c C-e c c} (@code{org-icalendar-combine-agenda-files})
15721 @kindex C-c C-e c c
15722 @findex org-icalendar-combine-agenda-files
15723 @vindex org-icalendar-combined-agenda-file
15724 Create a combined iCalendar file from Org files in
15725 @code{org-agenda-files} and write it to
15726 @code{org-icalendar-combined-agenda-file} file name.
15727 @end table
15729 @cindex @samp{SUMMARY}, property
15730 @cindex @samp{DESCRIPTION}, property
15731 @cindex @samp{LOCATION}, property
15732 @cindex @samp{TIMEZONE}, property
15733 The iCalendar export back-end includes @samp{SUMMARY}, @samp{DESCRIPTION},
15734 @samp{LOCATION} and @samp{TIMEZONE} properties from the Org entries when
15735 exporting.  To force the back-end to inherit the @samp{LOCATION} and
15736 @samp{TIMEZONE} properties, configure the @code{org-use-property-inheritance}
15737 variable.
15739 @vindex org-icalendar-include-body
15740 When Org entries do not have @samp{SUMMARY}, @samp{DESCRIPTION} and @samp{LOCATION}
15741 properties, the iCalendar export back-end derives the summary from the
15742 headline, and derives the description from the body of the Org item.
15743 The @code{org-icalendar-include-body} variable limits the maximum number of
15744 characters of the content are turned into its description.
15746 The @samp{TIMEZONE} property can be used to specify a per-entry time zone,
15747 and is applied to any entry with timestamp information.  Time zones
15748 should be specified as per the IANA time zone database format, e.g.,
15749 @samp{Asia/Almaty}.  Alternately, the property value can be @samp{UTC}, to force
15750 UTC time for this entry only.
15752 Exporting to iCalendar format depends in large part on the
15753 capabilities of the destination application.  Some are more lenient
15754 than others.  Consult the Org mode FAQ for advice on specific
15755 applications.
15757 @node Other Built-in Back-ends
15758 @section Other Built-in Back-ends
15760 Other export back-ends included with Org are:
15762 @itemize
15763 @item
15764 @samp{ox-man.el}: Export to a man page.
15765 @end itemize
15767 To activate such back-ends, either customize @code{org-export-backends} or
15768 load directly with @code{(require 'ox-man)}.  On successful load, the
15769 back-end adds new keys in the export dispatcher (see @ref{The Export Dispatcher}).
15771 Follow the comment section of such files, for example, @samp{ox-man.el},
15772 for usage and configuration details.
15774 @node Advanced Configuration
15775 @section Advanced Configuration
15779 @anchor{Hooks}
15780 @subheading Hooks
15782 @vindex org-export-before-processing-hook
15783 @vindex org-export-before-parsing-hook
15784 The export process executes two hooks before the actual exporting
15785 begins.  The first hook, @code{org-export-before-processing-hook}, runs
15786 before any expansions of macros, Babel code, and include keywords in
15787 the buffer.  The second hook, @code{org-export-before-parsing-hook}, runs
15788 before the buffer is parsed.
15790 Functions added to these hooks are called with a single argument: the
15791 export back-end actually used, as a symbol.  You may use them for
15792 heavy duty structural modifications of the document.  For example, you
15793 can remove every headline in the buffer during export like this:
15795 @lisp
15796 (defun my-headline-removal (backend)
15797   "Remove all headlines in the current buffer.
15798 BACKEND is the export back-end being used, as a symbol."
15799   (org-map-entries
15800    (lambda () (delete-region (point) (line-beginning-position 2)))))
15802 (add-hook 'org-export-before-parsing-hook 'my-headline-removal)
15803 @end lisp
15805 @anchor{Filters}
15806 @subheading Filters
15808 @cindex Filters, exporting
15809 Filters are lists of functions to be applied to certain parts for
15810 a given back-end.  The output from the first function in the filter is
15811 passed on to the next function in the filter.  The final output is the
15812 output from the final function in the filter.
15814 The Org export process has many filter sets applicable to different
15815 types of objects, plain text, parse trees, export options, and final
15816 output formats.  The filters are named after the element type or
15817 object type: @code{org-export-filter-TYPE-functions}, where @var{TYPE}
15818 is the type targeted by the filter.  Valid types are:
15820 @multitable @columnfractions 0.33 0.33 0.33
15821 @item body
15822 @tab bold
15823 @tab babel-call
15824 @item center-block
15825 @tab clock
15826 @tab code
15827 @item diary-sexp
15828 @tab drawer
15829 @tab dynamic-block
15830 @item entity
15831 @tab example-block
15832 @tab export-block
15833 @item export-snippet
15834 @tab final-output
15835 @tab fixed-width
15836 @item footnote-definition
15837 @tab footnote-reference
15838 @tab headline
15839 @item horizontal-rule
15840 @tab inline-babel-call
15841 @tab inline-src-block
15842 @item inlinetask
15843 @tab italic
15844 @tab item
15845 @item keyword
15846 @tab latex-environment
15847 @tab latex-fragment
15848 @item line-break
15849 @tab link
15850 @tab node-property
15851 @item options
15852 @tab paragraph
15853 @tab parse-tree
15854 @item plain-list
15855 @tab plain-text
15856 @tab planning
15857 @item property-drawer
15858 @tab quote-block
15859 @tab radio-target
15860 @item section
15861 @tab special-block
15862 @tab src-block
15863 @item statistics-cookie
15864 @tab strike-through
15865 @tab subscript
15866 @item superscript
15867 @tab table
15868 @tab table-cell
15869 @item table-row
15870 @tab target
15871 @tab timestamp
15872 @item underline
15873 @tab verbatim
15874 @tab verse-block
15875 @end multitable
15877 Here is an example filter that replaces non-breaking spaces @code{ } in the
15878 Org buffer with @samp{~} for the @LaTeX{} back-end.
15880 @lisp
15881 (defun my-latex-filter-nobreaks (text backend info)
15882   "Ensure \" \" are properly handled in LaTeX export."
15883   (when (org-export-derived-backend-p backend 'latex)
15884     (replace-regexp-in-string " " "~" text)))
15886 (add-to-list 'org-export-filter-plain-text-functions
15887              'my-latex-filter-nobreaks)
15888 @end lisp
15890 A filter requires three arguments: the code to be transformed, the
15891 name of the back-end, and some optional information about the export
15892 process.  The third argument can be safely ignored.  Note the use of
15893 @code{org-export-derived-backend-p} predicate that tests for @emph{latex}
15894 back-end or any other back-end, such as @emph{beamer}, derived from
15895 @emph{latex}.
15897 @anchor{Defining filters for individual files}
15898 @subheading Defining filters for individual files
15900 The Org export can filter not just for back-ends, but also for
15901 specific files through the @samp{BIND} keyword.  Here is an example with
15902 two filters; one removes brackets from time stamps, and the other
15903 removes strike-through text.  The filter functions are defined in
15904 a code block in the same Org file, which is a handy location for
15905 debugging.
15907 @example
15908 #+BIND: org-export-filter-timestamp-functions (tmp-f-timestamp)
15909 #+BIND: org-export-filter-strike-through-functions (tmp-f-strike-through)
15910 #+BEGIN_SRC emacs-lisp :exports results :results none
15911   (defun tmp-f-timestamp (s backend info)
15912     (replace-regexp-in-string "&[lg]t;\\|[][]" "" s))
15913   (defun tmp-f-strike-through (s backend info) "")
15914 #+END_SRC
15915 @end example
15917 @anchor{Extending an existing back-end}
15918 @subheading Extending an existing back-end
15920 Some parts of the conversion process can be extended for certain
15921 elements so as to introduce a new or revised translation.  That is how
15922 the HTML export back-end was extended to handle Markdown format.  The
15923 extensions work seamlessly so any aspect of filtering not done by the
15924 extended back-end is handled by the original back-end.  Of all the
15925 export customization in Org, extending is very powerful as it operates
15926 at the parser level.
15928 For this example, make the @emph{ascii} back-end display the language used
15929 in a source code block.  Also make it display only when some attribute
15930 is non-@code{nil}, like the following:
15932 @example
15933 #+ATTR_ASCII: :language t
15934 @end example
15936 Then extend ASCII back-end with a custom ``my-ascii'' back-end.
15938 @lisp
15939 (defun my-ascii-src-block (src-block contents info)
15940   "Transcode a SRC-BLOCK element from Org to ASCII.
15941 CONTENTS is nil.  INFO is a plist used as a communication
15942 channel."
15943   (if (not (org-export-read-attribute :attr_ascii src-block :language))
15944       (org-export-with-backend 'ascii src-block contents info)
15945     (concat
15946      (format ",--[ %s ]--\n%s`----"
15947              (org-element-property :language src-block)
15948              (replace-regexp-in-string
15949               "^" "| "
15950               (org-element-normalize-string
15951                (org-export-format-code-default src-block info)))))))
15953 (org-export-define-derived-backend 'my-ascii 'ascii
15954   :translate-alist '((src-block . my-ascii-src-block)))
15955 @end lisp
15957 The @code{my-ascii-src-block} function looks at the attribute above the
15958 current element.  If not true, hands over to @emph{ascii} back-end.  If
15959 true, which it is in this example, it creates a box around the code
15960 and leaves room for the inserting a string for language.  The last
15961 form creates the new back-end that springs to action only when
15962 translating @code{src-block} type elements.
15964 To use the newly defined back-end, evaluate the following from an Org
15965 buffer:
15967 @lisp
15968 (org-export-to-buffer 'my-ascii "*Org MY-ASCII Export*")
15969 @end lisp
15971 Further steps to consider would be an interactive function,
15972 self-installing an item in the export dispatcher menu, and other
15973 user-friendly improvements.
15975 @node Export in Foreign Buffers
15976 @section Export in Foreign Buffers
15978 The export back-ends in Org often include commands to convert selected
15979 regions.  A convenient feature of this in-place conversion is that the
15980 exported output replaces the original source.  Here are such
15981 functions:
15983 @table @asis
15984 @item @code{org-html-convert-region-to-html}
15985 @findex org-html-convert-region-to-html
15986 Convert the selected region into HTML.
15988 @item @code{org-latex-convert-region-to-latex}
15989 @findex org-latex-convert-region-to-latex
15990 Convert the selected region into @LaTeX{}.
15992 @item @code{org-texinfo-convert-region-to-texinfo}
15993 @findex org-texinfo-convert-region-to-texinfo
15994 Convert the selected region into Texinfo.
15996 @item @code{org-md-convert-region-to-md}
15997 @findex org-md-convert-region-to-md
15998 Convert the selected region into Markdown.
15999 @end table
16001 In-place conversions are particularly handy for quick conversion of
16002 tables and lists in foreign buffers.  For example, turn on the minor
16003 mode @kbd{M-x orgstruct-mode} in an HTML buffer, then use the
16004 convenient Org keyboard commands to create a list, select it, and
16005 covert it to HTML with @kbd{M-x org-html-convert-region-to-html}.
16007 @node Publishing
16008 @chapter Publishing
16010 @cindex publishing
16012 Org includes a publishing management system that allows you to
16013 configure automatic HTML conversion of @emph{projects} composed of
16014 interlinked Org files.  You can also configure Org to automatically
16015 upload your exported HTML pages and related attachments, such as
16016 images and source code files, to a web server.
16018 You can also use Org to convert files into PDF, or even combine HTML
16019 and PDF conversion so that files are available in both formats on the
16020 server.
16022 Publishing has been contributed to Org by David O'Toole.
16024 @menu
16025 * Configuration::                Defining projects.
16026 * Uploading Files::              How to get files up on the server.
16027 * Sample Configuration::         Example projects.
16028 * Triggering Publication::       Publication commands.
16029 @end menu
16031 @node Configuration
16032 @section Configuration
16034 Publishing needs significant configuration to specify files,
16035 destination and many other properties of a project.
16037 @menu
16038 * Project alist::                The central configuration variable.
16039 * Sources and destinations::     From here to there.
16040 * Selecting files::              What files are part of the project?
16041 * Publishing action::            Setting the function doing the publishing.
16042 * Publishing options::           Tweaking HTML/@LaTeX{} export.
16043 * Publishing links::             Which links keep working after publishing?
16044 * Site map::                     Generating a list of all pages.
16045 * Generating an index::          An index that reaches across pages.
16046 @end menu
16048 @node Project alist
16049 @subsection The variable @code{org-publish-project-alist}
16051 @cindex projects, for publishing
16053 @vindex org-publish-project-alist
16054 Publishing is configured almost entirely through setting the value of
16055 one variable, called @code{org-publish-project-alist}.  Each element of the
16056 list configures one project, and may be in one of the two following
16057 forms:
16059 @lisp
16060 ("project-name" :property value :property value ...)
16061 @end lisp
16063 @noindent
16064 i.e., a well-formed property list with alternating keys and values,
16067 @lisp
16068 ("project-name" :components ("project-name" "project-name" ...))
16069 @end lisp
16071 In both cases, projects are configured by specifying property values.
16072 A project defines the set of files that are to be published, as well
16073 as the publishing configuration to use when publishing those files.
16074 When a project takes the second form listed above, the individual
16075 members of the @code{:components} property are taken to be sub-projects,
16076 which group together files requiring different publishing options.
16077 When you publish such a ``meta-project'', all the components are also
16078 published, in the sequence given.
16080 @node Sources and destinations
16081 @subsection Sources and destinations for files
16083 @cindex directories, for publishing
16085 Most properties are optional, but some should always be set.  In
16086 particular, Org needs to know where to look for source files, and
16087 where to put published files.
16089 @table @asis
16090 @item @code{:base-directory}
16091 Directory containing publishing source files.
16093 @item @code{:publishing-directory}
16094 Directory where output files are published.  You can directly
16095 publish to a webserver using a file name syntax appropriate for
16096 the Emacs tramp package.  Or you can publish to a local directory
16097 and use external tools to upload your website (see @ref{Uploading Files}).
16099 @item @code{:preparation-function}
16100 Function or list of functions to be called before starting the
16101 publishing process, for example, to run @samp{make} for updating files
16102 to be published.  Each preparation function is called with
16103 a single argument, the project property list.
16105 @item @code{:completion-function}
16106 Function or list of functions called after finishing the
16107 publishing process, for example, to change permissions of the
16108 resulting files.  Each completion function is called with
16109 a single argument, the project property list.
16110 @end table
16112 @node Selecting files
16113 @subsection Selecting files
16115 @cindex files, selecting for publishing
16117 By default, all files with extension @samp{.org} in the base directory are
16118 considered part of the project.  This can be modified by setting the
16119 following properties
16121 @table @asis
16122 @item @code{:base-extension}
16123 Extension---without the dot---of source files.  This actually
16124 is a regular expression.  Set this to the symbol @code{any} if you
16125 want to get all files in @code{:base-directory}, even without
16126 extension.
16128 @item @code{:exclude}
16129 Regular expression to match file names that should not be published,
16130 even though they have been selected on the basis of their extension.
16132 @item @code{:include}
16133 List of files to be included regardless of @code{:base-extension} and
16134 @code{:exclude}.
16136 @item @code{:recursive}
16137 Non-@code{nil} means, check base-directory recursively for files to
16138 publish.
16139 @end table
16141 @node Publishing action
16142 @subsection Publishing action
16144 @cindex action, for publishing
16146 Publishing means that a file is copied to the destination directory
16147 and possibly transformed in the process.  The default transformation
16148 is to export Org files as HTML files, and this is done by the function
16149 @code{org-publish-org-to-html} which calls the HTML exporter (see @ref{HTML Export}).  But you can also publish your content as PDF files using
16150 @code{org-publish-org-to-pdf}, or as ASCII, Texinfo, etc., using the
16151 corresponding functions.
16153 If you want to publish the Org file as an @samp{.org} file but with
16154 @emph{archived}, @emph{commented}, and @emph{tag-excluded} trees removed, use
16155 @code{org-publish-org-to-org}.  This produces @samp{file.org} and put it in the
16156 publishing directory.  If you want a htmlized version of this file,
16157 set the parameter @code{:htmlized-source} to @code{t}.  It produces
16158 @samp{file.org.html} in the publishing directory@footnote{If the publishing directory is the same as the source
16159 directory, @samp{file.org} is exported as @samp{file.org.org}, so you probably
16160 do not want to do this.}.
16162 Other files like images only need to be copied to the publishing
16163 destination; for this you can use @code{org-publish-attachment}.  For
16164 non-Org files, you always need to specify the publishing function:
16166 @table @asis
16167 @item @code{:publishing-function}
16168 Function executing the publication of a file.  This may also be
16169 a list of functions, which are all called in turn.
16171 @item @code{:plain-source}
16172 Non-@code{nil} means, publish plain source.
16174 @item @code{:htmlized-source}
16175 Non-@code{nil} means, publish htmlized source.
16176 @end table
16178 The function must accept three arguments: a property list containing
16179 at least a @code{:publishing-directory} property, the name of the file to
16180 be published, and the path to the publishing directory of the output
16181 file.  It should take the specified file, make the necessary
16182 transformation, if any, and place the result into the destination
16183 folder.
16185 @node Publishing options
16186 @subsection Options for the exporters
16188 @cindex options, for publishing
16189 @cindex publishing options
16191 The property list can be used to set many export options for the HTML
16192 and @LaTeX{} exporters.  In most cases, these properties correspond to
16193 user variables in Org.  The table below lists these properties along
16194 with the variable they belong to.  See the documentation string for
16195 the respective variable for details.
16197 @vindex org-publish-project-alist
16198 When a property is given a value in @code{org-publish-project-alist}, its
16199 setting overrides the value of the corresponding user variable, if
16200 any, during publishing.  Options set within a file (see @ref{Export Settings}), however, override everything.
16202 @anchor{Generic properties}
16203 @subsubheading Generic properties
16205 @multitable {aaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16206 @item @code{:archived-trees}
16207 @tab @code{org-export-with-archived-trees}
16208 @item @code{:exclude-tags}
16209 @tab @code{org-export-exclude-tags}
16210 @item @code{:headline-levels}
16211 @tab @code{org-export-headline-levels}
16212 @item @code{:language}
16213 @tab @code{org-export-default-language}
16214 @item @code{:preserve-breaks}
16215 @tab @code{org-export-preserve-breaks}
16216 @item @code{:section-numbers}
16217 @tab @code{org-export-with-section-numbers}
16218 @item @code{:select-tags}
16219 @tab @code{org-export-select-tags}
16220 @item @code{:with-author}
16221 @tab @code{org-export-with-author}
16222 @item @code{:with-broken-links}
16223 @tab @code{org-export-with-broken-links}
16224 @item @code{:with-clocks}
16225 @tab @code{org-export-with-clocks}
16226 @item @code{:with-creator}
16227 @tab @code{org-export-with-creator}
16228 @item @code{:with-date}
16229 @tab @code{org-export-with-date}
16230 @item @code{:with-drawers}
16231 @tab @code{org-export-with-drawers}
16232 @item @code{:with-email}
16233 @tab @code{org-export-with-email}
16234 @item @code{:with-emphasize}
16235 @tab @code{org-export-with-emphasize}
16236 @item @code{:with-fixed-width}
16237 @tab @code{org-export-with-fixed-width}
16238 @item @code{:with-footnotes}
16239 @tab @code{org-export-with-footnotes}
16240 @item @code{:with-latex}
16241 @tab @code{org-export-with-latex}
16242 @item @code{:with-planning}
16243 @tab @code{org-export-with-planning}
16244 @item @code{:with-priority}
16245 @tab @code{org-export-with-priority}
16246 @item @code{:with-properties}
16247 @tab @code{org-export-with-properties}
16248 @item @code{:with-special-strings}
16249 @tab @code{org-export-with-special-strings}
16250 @item @code{:with-sub-superscript}
16251 @tab @code{org-export-with-sub-superscripts}
16252 @item @code{:with-tables}
16253 @tab @code{org-export-with-tables}
16254 @item @code{:with-tags}
16255 @tab @code{org-export-with-tags}
16256 @item @code{:with-tasks}
16257 @tab @code{org-export-with-tasks}
16258 @item @code{:with-timestamps}
16259 @tab @code{org-export-with-timestamps}
16260 @item @code{:with-title}
16261 @tab @code{org-export-with-title}
16262 @item @code{:with-toc}
16263 @tab @code{org-export-with-toc}
16264 @item @code{:with-todo-keywords}
16265 @tab @code{org-export-with-todo-keywords}
16266 @end multitable
16268 @anchor{ASCII specific properties}
16269 @subsubheading ASCII specific properties
16271 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16272 @item @code{:ascii-bullets}
16273 @tab @code{org-ascii-bullets}
16274 @item @code{:ascii-caption-above}
16275 @tab @code{org-ascii-caption-above}
16276 @item @code{:ascii-charset}
16277 @tab @code{org-ascii-charset}
16278 @item @code{:ascii-global-margin}
16279 @tab @code{org-ascii-global-margin}
16280 @item @code{:ascii-format-drawer-function}
16281 @tab @code{org-ascii-format-drawer-function}
16282 @item @code{:ascii-format-inlinetask-function}
16283 @tab @code{org-ascii-format-inlinetask-function}
16284 @item @code{:ascii-headline-spacing}
16285 @tab @code{org-ascii-headline-spacing}
16286 @item @code{:ascii-indented-line-width}
16287 @tab @code{org-ascii-indented-line-width}
16288 @item @code{:ascii-inlinetask-width}
16289 @tab @code{org-ascii-inlinetask-width}
16290 @item @code{:ascii-inner-margin}
16291 @tab @code{org-ascii-inner-margin}
16292 @item @code{:ascii-links-to-notes}
16293 @tab @code{org-ascii-links-to-notes}
16294 @item @code{:ascii-list-margin}
16295 @tab @code{org-ascii-list-margin}
16296 @item @code{:ascii-paragraph-spacing}
16297 @tab @code{org-ascii-paragraph-spacing}
16298 @item @code{:ascii-quote-margin}
16299 @tab @code{org-ascii-quote-margin}
16300 @item @code{:ascii-table-keep-all-vertical-lines}
16301 @tab @code{org-ascii-table-keep-all-vertical-lines}
16302 @item @code{:ascii-table-use-ascii-art}
16303 @tab @code{org-ascii-table-use-ascii-art}
16304 @item @code{:ascii-table-widen-columns}
16305 @tab @code{org-ascii-table-widen-columns}
16306 @item @code{:ascii-text-width}
16307 @tab @code{org-ascii-text-width}
16308 @item @code{:ascii-underline}
16309 @tab @code{org-ascii-underline}
16310 @item @code{:ascii-verbatim-format}
16311 @tab @code{org-ascii-verbatim-format}
16312 @end multitable
16314 @anchor{Beamer specific properties}
16315 @subsubheading Beamer specific properties
16317 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16318 @item @code{:beamer-theme}
16319 @tab @code{org-beamer-theme}
16320 @item @code{:beamer-column-view-format}
16321 @tab @code{org-beamer-column-view-format}
16322 @item @code{:beamer-environments-extra}
16323 @tab @code{org-beamer-environments-extra}
16324 @item @code{:beamer-frame-default-options}
16325 @tab @code{org-beamer-frame-default-options}
16326 @item @code{:beamer-outline-frame-options}
16327 @tab @code{org-beamer-outline-frame-options}
16328 @item @code{:beamer-outline-frame-title}
16329 @tab @code{org-beamer-outline-frame-title}
16330 @item @code{:beamer-subtitle-format}
16331 @tab @code{org-beamer-subtitle-format}
16332 @end multitable
16334 @anchor{HTML specific properties}
16335 @subsubheading HTML specific properties
16337 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16338 @item @code{:html-allow-name-attribute-in-anchors}
16339 @tab @code{org-html-allow-name-attribute-in-anchors}
16340 @item @code{:html-checkbox-type}
16341 @tab @code{org-html-checkbox-type}
16342 @item @code{:html-container}
16343 @tab @code{org-html-container-element}
16344 @item @code{:html-divs}
16345 @tab @code{org-html-divs}
16346 @item @code{:html-doctype}
16347 @tab @code{org-html-doctype}
16348 @item @code{:html-extension}
16349 @tab @code{org-html-extension}
16350 @item @code{:html-footnote-format}
16351 @tab @code{org-html-footnote-format}
16352 @item @code{:html-footnote-separator}
16353 @tab @code{org-html-footnote-separator}
16354 @item @code{:html-footnotes-section}
16355 @tab @code{org-html-footnotes-section}
16356 @item @code{:html-format-drawer-function}
16357 @tab @code{org-html-format-drawer-function}
16358 @item @code{:html-format-headline-function}
16359 @tab @code{org-html-format-headline-function}
16360 @item @code{:html-format-inlinetask-function}
16361 @tab @code{org-html-format-inlinetask-function}
16362 @item @code{:html-head-extra}
16363 @tab @code{org-html-head-extra}
16364 @item @code{:html-head-include-default-style}
16365 @tab @code{org-html-head-include-default-style}
16366 @item @code{:html-head-include-scripts}
16367 @tab @code{org-html-head-include-scripts}
16368 @item @code{:html-head}
16369 @tab @code{org-html-head}
16370 @item @code{:html-home/up-format}
16371 @tab @code{org-html-home/up-format}
16372 @item @code{:html-html5-fancy}
16373 @tab @code{org-html-html5-fancy}
16374 @item @code{:html-indent}
16375 @tab @code{org-html-indent}
16376 @item @code{:html-infojs-options}
16377 @tab @code{org-html-infojs-options}
16378 @item @code{:html-infojs-template}
16379 @tab @code{org-html-infojs-template}
16380 @item @code{:html-inline-image-rules}
16381 @tab @code{org-html-inline-image-rules}
16382 @item @code{:html-inline-images}
16383 @tab @code{org-html-inline-images}
16384 @item @code{:html-link-home}
16385 @tab @code{org-html-link-home}
16386 @item @code{:html-link-org-files-as-html}
16387 @tab @code{org-html-link-org-files-as-html}
16388 @item @code{:html-link-up}
16389 @tab @code{org-html-link-up}
16390 @item @code{:html-link-use-abs-url}
16391 @tab @code{org-html-link-use-abs-url}
16392 @item @code{:html-mathjax-options}
16393 @tab @code{org-html-mathjax-options}
16394 @item @code{:html-mathjax-template}
16395 @tab @code{org-html-mathjax-template}
16396 @item @code{:html-metadata-timestamp-format}
16397 @tab @code{org-html-metadata-timestamp-format}
16398 @item @code{:html-postamble-format}
16399 @tab @code{org-html-postamble-format}
16400 @item @code{:html-postamble}
16401 @tab @code{org-html-postamble}
16402 @item @code{:html-preamble-format}
16403 @tab @code{org-html-preamble-format}
16404 @item @code{:html-preamble}
16405 @tab @code{org-html-preamble}
16406 @item @code{:html-table-align-individual-field}
16407 @tab @code{de@{org-html-table-align-individual-fields}
16408 @item @code{:html-table-attributes}
16409 @tab @code{org-html-table-default-attributes}
16410 @item @code{:html-table-caption-above}
16411 @tab @code{org-html-table-caption-above}
16412 @item @code{:html-table-data-tags}
16413 @tab @code{org-html-table-data-tags}
16414 @item @code{:html-table-header-tags}
16415 @tab @code{org-html-table-header-tags}
16416 @item @code{:html-table-row-tags}
16417 @tab @code{org-html-table-row-tags}
16418 @item @code{:html-table-use-header-tags-for-first-column}
16419 @tab @code{org-html-table-use-header-tags-for-first-column}
16420 @item @code{:html-tag-class-prefix}
16421 @tab @code{org-html-tag-class-prefix}
16422 @item @code{:html-text-markup-alist}
16423 @tab @code{org-html-text-markup-alist}
16424 @item @code{:html-todo-kwd-class-prefix}
16425 @tab @code{org-html-todo-kwd-class-prefix}
16426 @item @code{:html-toplevel-hlevel}
16427 @tab @code{org-html-toplevel-hlevel}
16428 @item @code{:html-use-infojs}
16429 @tab @code{org-html-use-infojs}
16430 @item @code{:html-validation-link}
16431 @tab @code{org-html-validation-link}
16432 @item @code{:html-viewport}
16433 @tab @code{org-html-viewport}
16434 @item @code{:html-xml-declaration}
16435 @tab @code{org-html-xml-declaration}
16436 @end multitable
16438 @anchor{@LaTeX{} specific properties}
16439 @subsubheading @LaTeX{} specific properties
16441 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16442 @item @code{:latex-active-timestamp-format}
16443 @tab @code{org-latex-active-timestamp-format}
16444 @item @code{:latex-caption-above}
16445 @tab @code{org-latex-caption-above}
16446 @item @code{:latex-classes}
16447 @tab @code{org-latex-classes}
16448 @item @code{:latex-class}
16449 @tab @code{org-latex-default-class}
16450 @item @code{:latex-compiler}
16451 @tab @code{org-latex-compiler}
16452 @item @code{:latex-default-figure-position}
16453 @tab @code{org-latex-default-figure-position}
16454 @item @code{:latex-default-table-environment}
16455 @tab @code{org-latex-default-table-environment}
16456 @item @code{:latex-default-table-mode}
16457 @tab @code{org-latex-default-table-mode}
16458 @item @code{:latex-diary-timestamp-format}
16459 @tab @code{org-latex-diary-timestamp-format}
16460 @item @code{:latex-footnote-defined-format}
16461 @tab @code{org-latex-footnote-defined-format}
16462 @item @code{:latex-footnote-separator}
16463 @tab @code{org-latex-footnote-separator}
16464 @item @code{:latex-format-drawer-function}
16465 @tab @code{org-latex-format-drawer-function}
16466 @item @code{:latex-format-headline-function}
16467 @tab @code{org-latex-format-headline-function}
16468 @item @code{:latex-format-inlinetask-function}
16469 @tab @code{org-latex-format-inlinetask-function}
16470 @item @code{:latex-hyperref-template}
16471 @tab @code{org-latex-hyperref-template}
16472 @item @code{:latex-image-default-height}
16473 @tab @code{org-latex-image-default-height}
16474 @item @code{:latex-image-default-option}
16475 @tab @code{org-latex-image-default-option}
16476 @item @code{:latex-image-default-width}
16477 @tab @code{org-latex-image-default-width}
16478 @item @code{:latex-images-centered}
16479 @tab @code{org-latex-images-centered}
16480 @item @code{:latex-inactive-timestamp-format}
16481 @tab @code{org-latex-inactive-timestamp-format}
16482 @item @code{:latex-inline-image-rules}
16483 @tab @code{org-latex-inline-image-rules}
16484 @item @code{:latex-link-with-unknown-path-format}
16485 @tab @code{org-latex-link-with-unknown-path-format}
16486 @item @code{:latex-listings-langs}
16487 @tab @code{org-latex-listings-langs}
16488 @item @code{:latex-listings-options}
16489 @tab @code{org-latex-listings-options}
16490 @item @code{:latex-listings}
16491 @tab @code{org-latex-listings}
16492 @item @code{:latex-minted-langs}
16493 @tab @code{org-latex-minted-langs}
16494 @item @code{:latex-minted-options}
16495 @tab @code{org-latex-minted-options}
16496 @item @code{:latex-prefer-user-labels}
16497 @tab @code{org-latex-prefer-user-labels}
16498 @item @code{:latex-subtitle-format}
16499 @tab @code{org-latex-subtitle-format}
16500 @item @code{:latex-subtitle-separate}
16501 @tab @code{org-latex-subtitle-separate}
16502 @item @code{:latex-table-scientific-notation}
16503 @tab @code{org-latex-table-scientific-notation}
16504 @item @code{:latex-tables-booktabs}
16505 @tab @code{org-latex-tables-booktabs}
16506 @item @code{:latex-tables-centered}
16507 @tab @code{org-latex-tables-centered}
16508 @item @code{:latex-text-markup-alist}
16509 @tab @code{org-latex-text-markup-alist}
16510 @item @code{:latex-title-command}
16511 @tab @code{org-latex-title-command}
16512 @item @code{:latex-toc-command}
16513 @tab @code{org-latex-toc-command}
16514 @end multitable
16516 @anchor{Markdown specific properties}
16517 @subsubheading Markdown specific properties
16519 @multitable {aaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaa}
16520 @item @code{:md-footnote-format}
16521 @tab @code{org-md-footnote-format}
16522 @item @code{:md-footnotes-section}
16523 @tab @code{org-md-footnotes-section}
16524 @item @code{:md-headline-style}
16525 @tab @code{org-md-headline-style}
16526 @end multitable
16528 @anchor{ODT specific properties}
16529 @subsubheading ODT specific properties
16531 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16532 @item @code{:odt-content-template-file}
16533 @tab @code{org-odt-content-template-file}
16534 @item @code{:odt-display-outline-level}
16535 @tab @code{org-odt-display-outline-level}
16536 @item @code{:odt-fontify-srcblocks}
16537 @tab @code{org-odt-fontify-srcblocks}
16538 @item @code{:odt-format-drawer-function}
16539 @tab @code{org-odt-format-drawer-function}
16540 @item @code{:odt-format-headline-function}
16541 @tab @code{org-odt-format-headline-function}
16542 @item @code{:odt-format-inlinetask-function}
16543 @tab @code{org-odt-format-inlinetask-function}
16544 @item @code{:odt-inline-formula-rules}
16545 @tab @code{org-odt-inline-formula-rules}
16546 @item @code{:odt-inline-image-rules}
16547 @tab @code{org-odt-inline-image-rules}
16548 @item @code{:odt-pixels-per-inch}
16549 @tab @code{org-odt-pixels-per-inch}
16550 @item @code{:odt-styles-file}
16551 @tab @code{org-odt-styles-file}
16552 @item @code{:odt-table-styles}
16553 @tab @code{org-odt-table-styles}
16554 @item @code{:odt-use-date-fields}
16555 @tab @code{org-odt-use-date-fields}
16556 @end multitable
16558 @anchor{Texinfo specific properties}
16559 @subsubheading Texinfo specific properties
16561 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16562 @item @code{:texinfo-active-timestamp-format}
16563 @tab @code{org-texinfo-active-timestamp-format}
16564 @item @code{:texinfo-classes}
16565 @tab @code{org-texinfo-classes}
16566 @item @code{:texinfo-class}
16567 @tab @code{org-texinfo-default-class}
16568 @item @code{:texinfo-table-default-markup}
16569 @tab @code{org-texinfo-table-default-markup}
16570 @item @code{:texinfo-diary-timestamp-format}
16571 @tab @code{org-texinfo-diary-timestamp-format}
16572 @item @code{:texinfo-filename}
16573 @tab @code{org-texinfo-filename}
16574 @item @code{:texinfo-format-drawer-function}
16575 @tab @code{org-texinfo-format-drawer-function}
16576 @item @code{:texinfo-format-headline-function}
16577 @tab @code{org-texinfo-format-headline-function}
16578 @item @code{:texinfo-format-inlinetask-function}
16579 @tab @code{org-texinfo-format-inlinetask-function}
16580 @item @code{:texinfo-inactive-timestamp-format}
16581 @tab @code{org-texinfo-inactive-timestamp-format}
16582 @item @code{:texinfo-link-with-unknown-path-format}
16583 @tab @code{org-texinfo-link-with-unknown-path-format}
16584 @item @code{:texinfo-node-description-column}
16585 @tab @code{org-texinfo-node-description-column}
16586 @item @code{:texinfo-table-scientific-notation}
16587 @tab @code{org-texinfo-table-scientific-notation}
16588 @item @code{:texinfo-tables-verbatim}
16589 @tab @code{org-texinfo-tables-verbatim}
16590 @item @code{:texinfo-text-markup-alist}
16591 @tab @code{org-texinfo-text-markup-alist}
16592 @end multitable
16594 @node Publishing links
16595 @subsection Publishing links
16597 @cindex links, publishing
16599 To create a link from one Org file to another, you would use something
16600 like @samp{[[file:foo.org][The foo]]} or simply @samp{[[file:foo.org]]} (see @ref{External Links}).  When
16601 published, this link becomes a link to @samp{foo.html}.  You can thus
16602 interlink the pages of your ``Org web'' project and the links will work
16603 as expected when you publish them to HTML.  If you also publish the
16604 Org source file and want to link to it, use an @samp{http} link instead of
16605 a @samp{file:} link, because @samp{file} links are converted to link to the
16606 corresponding @samp{.html} file.
16608 You may also link to related files, such as images.  Provided you are
16609 careful with relative file names, and provided you have also
16610 configured Org to upload the related files, these links will work too.
16611 See @ref{Complex example}, for an example of this
16612 usage.
16614 Eventually, links between published documents can contain some search
16615 options (see @ref{Search Options}), which will be resolved to
16616 the appropriate location in the linked file.  For example, once
16617 published to HTML, the following links all point to a dedicated anchor
16618 in @samp{foo.html}.
16620 @example
16621 [[file:foo.org::*heading]]
16622 [[file:foo.org::#custom-id]]
16623 [[file:foo.org::target]]
16624 @end example
16626 @node Site map
16627 @subsection Generating a sitemap
16629 @cindex sitemap, of published pages
16631 The following properties may be used to control publishing of
16632 a map of files for a given project.
16634 @table @asis
16635 @item @code{:auto-sitemap}
16636 When non-@code{nil}, publish a sitemap during
16637 @code{org-publish-current-project} or @code{org-publish-all}.
16639 @item @code{:sitemap-filename}
16640 Filename for output of sitemap.  Defaults to @samp{sitemap.org}, which
16641 becomes @samp{sitemap.html}.
16643 @item @code{:sitemap-title}
16644 Title of sitemap page.  Defaults to name of file.
16646 @item @code{:sitemap-format-entry}
16647 @findex org-publish-find-date
16648 @findex org-publish-find-property
16649 @findex org-publish-find-title
16650 With this option one can tell how a site-map entry is formatted
16651 in the site-map.  It is a function called with three arguments:
16652 the file or directory name relative to base directory of the
16653 project, the site-map style and the current project.  It is
16654 expected to return a string.  Default value turns file names into
16655 links and use document titles as descriptions.  For specific
16656 formatting needs, one can use @code{org-publish-find-date},
16657 @code{org-publish-find-title} and @code{org-publish-find-property}, to
16658 retrieve additional information about published documents.
16660 @item @code{:sitemap-function}
16661 Plug-in function to use for generation of the sitemap.  It is
16662 called with two arguments: the title of the site-map and
16663 a representation of the files and directories involved in the
16664 project as a nested list, which can further be transformed using
16665 @code{org-list-to-generic}, @code{org-list-to-subtree} and alike.  Default
16666 value generates a plain list of links to all files in the
16667 project.
16669 @item @code{:sitemap-sort-folders}
16670 Where folders should appear in the sitemap.  Set this to @code{first}
16671 (default) or @code{last} to display folders first or last,
16672 respectively.  When set to @code{ignore}, folders are ignored
16673 altogether.  Any other value mixes files and folders.  This
16674 variable has no effect when site-map style is @code{tree}.
16676 @item @code{:sitemap-sort-files}
16677 How the files are sorted in the site map.  Set this to
16678 @code{alphabetically} (default), @code{chronologically} or
16679 @code{anti-chronologically}.  @code{chronologically} sorts the files with
16680 older date first while @code{anti-chronologically} sorts the files
16681 with newer date first.  @code{alphabetically} sorts the files
16682 alphabetically.  The date of a file is retrieved with
16683 @code{org-publish-find-date}.
16685 @item @code{:sitemap-ignore-case}
16686 Should sorting be case-sensitive?  Default @code{nil}.
16688 @item @code{:sitemap-file-entry-format}
16689 With this option one can tell how a sitemap's entry is formatted
16690 in the sitemap.  This is a format string with some escape
16691 sequences: @code{%t} stands for the title of the file, @code{%a} stands for
16692 the author of the file and @code{%d} stands for the date of the file.
16693 The date is retrieved with the @code{org-publish-find-date} function
16694 and formatted with @code{org-publish-sitemap-date-format}.  Default
16695 @code{%t}.
16697 @item @code{:sitemap-date-format}
16698 Format string for the @code{format-time-string} function that tells
16699 how a sitemap entry's date is to be formatted.  This property
16700 bypasses @code{org-publish-sitemap-date-format} which defaults to
16701 @code{%Y-%m-%d}.
16702 @end table
16704 @node Generating an index
16705 @subsection Generating an index
16707 @cindex index, in a publishing project
16709 Org mode can generate an index across the files of a publishing project.
16711 @table @asis
16712 @item @code{:makeindex}
16713 When non-@code{nil}, generate in index in the file @samp{theindex.org} and
16714 publish it as @samp{theindex.html}.
16715 @end table
16717 The file is created when first publishing a project with the
16718 @code{:makeindex} set.  The file only contains a statement @samp{#+INCLUDE:
16719 "theindex.inc"}.  You can then build around this include statement by
16720 adding a title, style information, etc.
16722 @cindex @samp{INDEX}, keyword
16723 Index entries are specified with @samp{INDEX} keyword.  An entry that
16724 contains an exclamation mark creates a sub item.
16726 @example
16727 *** Curriculum Vitae
16728 #+INDEX: CV
16729 #+INDEX: Application!CV
16730 @end example
16732 @node Uploading Files
16733 @section Uploading Files
16735 @cindex rsync
16736 @cindex unison
16738 For those people already utilizing third party sync tools such as
16739 Rsync or Unison, it might be preferable not to use the built-in remote
16740 publishing facilities of Org mode which rely heavily on Tramp.  Tramp,
16741 while very useful and powerful, tends not to be so efficient for
16742 multiple file transfer and has been known to cause problems under
16743 heavy usage.
16745 Specialized synchronization utilities offer several advantages.  In
16746 addition to timestamp comparison, they also do content and
16747 permissions/attribute checks.  For this reason you might prefer to
16748 publish your web to a local directory---possibly even @emph{in place} with
16749 your Org files---and then use Unison or Rsync to do the
16750 synchronization with the remote host.
16752 Since Unison, for example, can be configured as to which files to
16753 transfer to a certain remote destination, it can greatly simplify the
16754 project publishing definition.  Simply keep all files in the correct
16755 location, process your Org files with @code{org-publish} and let the
16756 synchronization tool do the rest.  You do not need, in this scenario,
16757 to include attachments such as JPG, CSS or PNG files in the project
16758 definition since the third-party tool syncs them.
16760 Publishing to a local directory is also much faster than to a remote
16761 one, so that you can afford more easily to republish entire projects.
16762 If you set @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the
16763 main benefit of re-including any changed external files such as source
16764 example files you might include with @samp{INCLUDE} keyword.  The timestamp
16765 mechanism in Org is not smart enough to detect if included files have
16766 been modified.
16768 @node Sample Configuration
16769 @section Sample Configuration
16771 Below we provide two example configurations.  The first one is
16772 a simple project publishing only a set of Org files.  The second
16773 example is more complex, with a multi-component project.
16775 @menu
16776 * Simple example::               One-component publishing.
16777 * Complex example::              A multi-component publishing example.
16778 @end menu
16780 @node Simple example
16781 @subsection Example: simple publishing configuration
16783 This example publishes a set of Org files to the @samp{public_html}
16784 directory on the local machine.
16786 @lisp
16787 (setq org-publish-project-alist
16788       '(("org"
16789          :base-directory "~/org/"
16790          :publishing-directory "~/public_html"
16791          :section-numbers nil
16792          :table-of-contents nil
16793          :style "<link rel=\"stylesheet\"
16794                 href=\"../other/mystyle.css\"
16795                 type=\"text/css\"/>")))
16796 @end lisp
16798 @node Complex example
16799 @subsection Example: complex publishing configuration
16801 This more complicated example publishes an entire website, including
16802 Org files converted to HTML, image files, Emacs Lisp source code, and
16803 style sheets.  The publishing directory is remote and private files
16804 are excluded.
16806 To ensure that links are preserved, care should be taken to replicate
16807 your directory structure on the web server, and to use relative file
16808 paths.  For example, if your Org files are kept in @samp{~/org/} and your
16809 publishable images in @samp{~/images/}, you would link to an image with
16811 @example
16812 file:../images/myimage.png
16813 @end example
16815 On the web server, the relative path to the image should be the same.
16816 You can accomplish this by setting up an @samp{images/} folder in the right
16817 place on the web server, and publishing images to it.
16819 @lisp
16820 (setq org-publish-project-alist
16821       '(("orgfiles"
16822          :base-directory "~/org/"
16823          :base-extension "org"
16824          :publishing-directory "/ssh:user@@host:~/html/notebook/"
16825          :publishing-function org-html-publish-to-html
16826          :exclude "PrivatePage.org" ;; regexp
16827          :headline-levels 3
16828          :section-numbers nil
16829          :with-toc nil
16830          :html-head "<link rel=\"stylesheet\"
16831                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
16832          :html-preamble t)
16834         ("images"
16835          :base-directory "~/images/"
16836          :base-extension "jpg\\|gif\\|png"
16837          :publishing-directory "/ssh:user@@host:~/html/images/"
16838          :publishing-function org-publish-attachment)
16840         ("other"
16841          :base-directory "~/other/"
16842          :base-extension "css\\|el"
16843          :publishing-directory "/ssh:user@@host:~/html/other/"
16844          :publishing-function org-publish-attachment)
16845         ("website" :components ("orgfiles" "images" "other"))))
16846 @end lisp
16848 @node Triggering Publication
16849 @section Triggering Publication
16851 Once properly configured, Org can publish with the following commands:
16853 @table @asis
16854 @item @kbd{C-c C-e X} (@code{org-publish})
16855 @kindex C-c C-e X
16856 @findex org-publish
16857 Prompt for a specific project and publish all files that belong
16858 to it.
16860 @item @kbd{C-c C-e P} (@code{org-publish-current-project})
16861 @kindex C-c C-e P
16862 @findex org-publish-current-project
16863 Publish the project containing the current file.
16865 @item @kbd{C-c C-e F} (@code{org-publish-current-file})
16866 @kindex C-c C-e F
16867 @findex org-publish-current-file
16868 Publish only the current file.
16870 @item @kbd{C-c C-e E} (@code{org-publish-all})
16871 @kindex C-c C-e E
16872 @findex org-publish-all
16873 Publish every project.
16874 @end table
16876 @vindex org-publish-use-timestamps-flag
16877 Org uses timestamps to track when a file has changed.  The above
16878 functions normally only publish changed files.  You can override this
16879 and force publishing of all files by giving a prefix argument to any
16880 of the commands above, or by customizing the variable
16881 @code{org-publish-use-timestamps-flag}.  This may be necessary in
16882 particular if files include other files via @samp{SETUPFILE} or @samp{INCLUDE}
16883 keywords.
16885 @node Working with Source Code
16886 @chapter Working with Source Code
16888 @cindex source code, working with
16890 Source code here refers to any plain text collection of computer
16891 instructions, possibly with comments, written using a human-readable
16892 programming language.  Org can manage source code in an Org document
16893 when the source code is identified with begin and end markers.
16894 Working with source code begins with identifying source code blocks.
16895 A source code block can be placed almost anywhere in an Org document;
16896 it is not restricted to the preamble or the end of the document.
16897 However, Org cannot manage a source code block if it is placed inside
16898 an Org comment or within a fixed width section.
16900 Here is an example source code block in the Emacs Lisp language:
16902 @example
16903 #+BEGIN_SRC emacs-lisp
16904   (defun org-xor (a b)
16905      "Exclusive or."
16906      (if a (not b) b))
16907 #+END_SRC
16908 @end example
16910 Org can manage the source code in the block delimited by @samp{#+BEGIN_SRC}
16911 @dots{} @samp{#+END_SRC} in several ways that can simplify housekeeping tasks
16912 essential to modern source code maintenance.  Org can edit, format,
16913 extract, export, and publish source code blocks.  Org can also compile
16914 and execute a source code block, then capture the results.  The Org
16915 mode literature sometimes refers to source code blocks as @emph{live code}
16916 blocks because they can alter the content of the Org document or the
16917 material that it exports.  Users can control how live they want each
16918 source code block by tweaking the header arguments (see @ref{Using Header Arguments}) for compiling, execution, extraction, and
16919 exporting.
16921 Source code blocks are one of many Org block types, which also include
16922 @samp{quote}, @samp{export}, @samp{verse}, @samp{latex}, @samp{example}, and @samp{verbatim}.  This
16923 section pertains to blocks between @samp{#+BEGIN_SRC} and @samp{#+END_SRC}.
16925 For editing and formatting a source code block, Org uses an
16926 appropriate Emacs major mode that includes features specifically
16927 designed for source code in that language.
16929 Org can extract one or more source code blocks and write them to one
16930 or more source files---a process known as @emph{tangling} in literate
16931 programming terminology.
16933 For exporting and publishing, Org's back-ends can format a source code
16934 block appropriately, often with native syntax highlighting.
16936 For executing and compiling a source code block, the user can
16937 configure Org to select the appropriate compiler.  Org provides
16938 facilities to collect the result of the execution or compiler output,
16939 insert it into the Org document, and/or export it.  In addition to
16940 text results, Org can insert links to other data types, including
16941 audio, video, and graphics.  Org can also link a compiler error
16942 message to the appropriate line in the source code block.
16944 An important feature of Org's management of source code blocks is the
16945 ability to pass variables, functions, and results to one another using
16946 a common syntax for source code blocks in any language.  Although most
16947 literate programming facilities are restricted to one language or
16948 another, Org's language-agnostic approach lets the literate programmer
16949 match each programming task with the appropriate computer language and
16950 to mix them all together in a single Org document.  This
16951 interoperability among languages explains why Org's source code
16952 management facility was named @emph{Org Babel} by its originators, Eric
16953 Schulte and Dan Davison.
16955 Org mode fulfills the promise of easy verification and maintenance of
16956 publishing reproducible research by keeping text, data, code,
16957 configuration settings of the execution environment, the results of
16958 the execution, and associated narratives, claims, references, and
16959 internal and external links in a single Org document.
16961 Details of Org's facilities for working with source code are described
16962 in the following sections.
16964 @menu
16965 * Structure of Code Blocks::     Code block syntax described.
16966 * Using Header Arguments::       Different ways to set header arguments.
16967 * Environment of a Code Block::  Arguments, sessions, working directory...
16968 * Evaluating Code Blocks::       Place results of evaluation in the Org buffer.
16969 * Results of Evaluation::        Choosing a results type, post-processing...
16970 * Exporting Code Blocks::        Export contents and/or results.
16971 * Extracting Source Code::       Create pure source code files.
16972 * Languages::                    List of supported code block languages.
16973 * Editing Source Code::          Language major-mode editing.
16974 * Noweb Reference Syntax::       Literate programming in Org mode.
16975 * Library of Babel::             Use and contribute to a library of useful code blocks.
16976 * Key bindings and Useful Functions:: Work quickly with code blocks.
16977 * Batch Execution::              Call functions from the command line.
16978 @end menu
16980 @node Structure of Code Blocks
16981 @section Structure of Code Blocks
16983 @cindex code block, structure
16984 @cindex source code, block structure
16985 @cindex @samp{NAME} keyword, in source blocks
16986 @cindex @samp{BEGIN_SRC}
16988 Org offers two ways to structure source code in Org documents: in
16989 a source code block, and directly inline.  Both specifications are
16990 shown below.
16992 A source code block conforms to this structure:
16994 @example
16995 #+NAME: <name>
16996 #+BEGIN_SRC <language> <switches> <header arguments>
16997   <body>
16998 #+END_SRC
16999 @end example
17001 Do not be put-off by having to remember the source block syntax.  Org
17002 mode offers a command for wrapping existing text in a block (see
17003 @ref{Structure Templates}).  Org also works with other completion systems
17004 in Emacs, some of which predate Org and have custom domain-specific
17005 languages for defining templates.  Regular use of templates reduces
17006 errors, increases accuracy, and maintains consistency.
17008 @cindex source code, inline
17009 An inline code block conforms to this structure:
17011 @example
17012 src_<language>@{<body>@}
17013 @end example
17015 @noindent
17018 @example
17019 src_<language>[<header arguments>]@{<body>@}
17020 @end example
17022 @table @asis
17023 @item @samp{#+NAME: <name>}
17024 Optional.  Names the source block so it can be called, like
17025 a function, from other source blocks or inline code to evaluate
17026 or to capture the results.  Code from other blocks, other files,
17027 and from table formulas (see @ref{The spreadsheet}) can use the name
17028 to reference a source block.  This naming serves the same purpose
17029 as naming Org tables.  Org mode requires unique names.  For
17030 duplicate names, Org mode's behavior is undefined.
17032 @item @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}
17033 Mandatory.  They mark the start and end of a block that Org
17034 requires.  The @samp{#+BEGIN_SRC} line takes additional arguments, as
17035 described next.
17037 @item @samp{<language>}
17038 @cindex language, in code blocks
17039 Mandatory.  It is the identifier of the source code language in
17040 the block.  See @ref{Languages}, for identifiers of supported
17041 languages.
17043 @item @samp{<switches>}
17044 @cindex switches, in code blocks
17045 Optional.  Switches provide finer control of the code execution,
17046 export, and format (see the discussion of switches in @ref{Literal Examples}).
17048 @item @samp{<header arguments>}
17049 @cindex header arguments, in code blocks
17050 Optional.  Heading arguments control many aspects of evaluation,
17051 export and tangling of code blocks (see @ref{Using Header Arguments}).
17052 Using Org's properties feature, header arguments can be
17053 selectively applied to the entire buffer or specific sub-trees of
17054 the Org document.
17056 @item @samp{<body>}
17057 Source code in the dialect of the specified language identifier.
17058 @end table
17060 @node Using Header Arguments
17061 @section Using Header Arguments
17063 Org comes with many header arguments common to all languages.  New
17064 header arguments are added for specific languages as they become
17065 available for use in source code blocks.  A header argument is
17066 specified with an initial colon followed by the argument's name in
17067 lowercase.
17069 Since header arguments can be set in several ways, Org prioritizes
17070 them in case of overlaps or conflicts by giving local settings
17071 a higher priority.  Header values in function calls, for example,
17072 override header values from global defaults.
17074 @anchor{System-wide header arguments}
17075 @subheading System-wide header arguments
17077 @vindex org-babel-default-header-args
17079 @vindex org-babel-default-header-args
17080 System-wide values of header arguments can be specified by customizing
17081 the @code{org-babel-default-header-args} variable, which defaults to the
17082 following values:
17084 @example
17085 :session    => "none"
17086 :results    => "replace"
17087 :exports    => "code"
17088 :cache      => "no"
17089 :noweb      => "no"
17090 @end example
17092 The example below sets @samp{:noweb} header arguments to @samp{yes}, which makes
17093 Org expand @samp{:noweb} references by default.
17095 @lisp
17096 (setq org-babel-default-header-args
17097       (cons '(:noweb . "yes")
17098             (assq-delete-all :noweb org-babel-default-header-args)))
17099 @end lisp
17101 @cindex language specific default header arguments
17102 @cindex default header arguments per language
17103 Each language can have separate default header arguments by
17104 customizing the variable @code{org-babel-default-header-args:<LANG>}, where
17105 @var{<LANG>} is the name of the language.  For details, see the
17106 language-specific online documentation at
17107 @uref{https://orgmode.org/worg/org-contrib/babel/}.
17109 @anchor{Header arguments in Org mode properties}
17110 @subheading Header arguments in Org mode properties
17112 For header arguments applicable to the buffer, use @samp{PROPERTY} keyword
17113 anywhere in the Org file (see @ref{Property Syntax}).
17115 The following example makes all the R code blocks execute in the same
17116 session.  Setting @samp{:results} to @samp{silent} ignores the results of
17117 executions for all blocks, not just R code blocks; no results inserted
17118 for any block.
17120 @example
17121 #+PROPERTY: header-args:R  :session *R*
17122 #+PROPERTY: header-args    :results silent
17123 @end example
17125 @vindex org-use-property-inheritance
17126 Header arguments set through Org's property drawers (see @ref{Property Syntax}) apply at the sub-tree level on down.  Since these property
17127 drawers can appear anywhere in the file hierarchy, Org uses outermost
17128 call or source block to resolve the values.  Org ignores
17129 @code{org-use-property-inheritance} setting.
17131 In this example, @samp{:cache} defaults to @samp{yes} for all code blocks in the
17132 sub-tree.
17134 @example
17135 * sample header
17136   :PROPERTIES:
17137   :header-args:    :cache yes
17138   :END:
17139 @end example
17141 @kindex C-c C-x p
17142 @findex org-set-property
17143 Properties defined through @code{org-set-property} function, bound to
17144 @kbd{C-c C-x p}, apply to all active languages.  They override
17145 properties set in @code{org-babel-default-header-args}.
17147 @cindex language specific header arguments properties
17148 @cindex header arguments per language
17149 Language-specific header arguments are also read from properties
17150 @samp{header-args:<LANG>} where @var{<LANG>} is the language
17151 identifier.  For example,
17153 @example
17154 * Heading
17155   :PROPERTIES:
17156   :header-args:clojure:    :session *clojure-1*
17157   :header-args:R:          :session *R*
17158   :END:
17159 ** Subheading
17160   :PROPERTIES:
17161   :header-args:clojure:    :session *clojure-2*
17162   :END:
17163 @end example
17165 @noindent
17166 would force separate sessions for Clojure blocks in @samp{Heading} and
17167 @samp{Subheading}, but use the same session for all R blocks.  Blocks in
17168 @samp{Subheading} inherit settings from @samp{Heading}.
17170 @anchor{Code block specific header arguments}
17171 @subheading Code block specific header arguments
17173 Header arguments are most commonly set at the source code block level,
17174 on the @samp{#+BEGIN_SRC} line.  Arguments set at this level take
17175 precedence over those set in the @code{org-babel-default-header-args}
17176 variable, and also those set as header properties.
17178 In the following example, setting @samp{:results} to @samp{silent} makes it
17179 ignore results of the code execution.  Setting @samp{:exports} to @samp{code}
17180 exports only the body of the code block to HTML or @LaTeX{}.
17182 @example
17183 #+NAME: factorial
17184 #+BEGIN_SRC haskell :results silent :exports code :var n=0
17185   fac 0 = 1
17186   fac n = n * fac (n-1)
17187 #+END_SRC
17188 @end example
17190 The same header arguments in an inline code block:
17192 @example
17193 src_haskell[:exports both]@{fac 5@}
17194 @end example
17196 @cindex @samp{HEADER}, keyword
17197 Code block header arguments can span multiple lines using @samp{#+HEADER:}
17198 on each line.  Note that Org currently accepts the plural spelling of
17199 @samp{#+HEADER:} only as a convenience for backward-compatibility.  It may
17200 be removed at some point.
17202 Multi-line header arguments on an unnamed code block:
17204 @example
17205 #+HEADER: :var data1=1
17206 #+BEGIN_SRC emacs-lisp :var data2=2
17207    (message "data1:%S, data2:%S" data1 data2)
17208 #+END_SRC
17210 #+RESULTS:
17211 : data1:1, data2:2
17212 @end example
17214 Multi-line header arguments on a named code block:
17216 @example
17217 #+NAME: named-block
17218 #+HEADER: :var data=2
17219 #+BEGIN_SRC emacs-lisp
17220   (message "data:%S" data)
17221 #+END_SRC
17223 #+RESULTS: named-block
17224   : data:2
17225 @end example
17227 @anchor{Header arguments in function calls}
17228 @subheading Header arguments in function calls
17230 Header arguments in function calls are the most specific and override
17231 all other settings in case of an overlap.  They get the highest
17232 priority.  Two @samp{#+CALL:} examples are shown below.  For the complete
17233 syntax of @samp{CALL} keyword, see @ref{Evaluating Code Blocks}.
17235 In this example, @samp{:exports results} header argument is applied to the
17236 evaluation of the @samp{#+CALL:} line.
17238 @example
17239 #+CALL: factorial(n=5) :exports results
17240 @end example
17242 In this example, @samp{:session special} header argument is applied to the
17243 evaluation of @samp{factorial} code block.
17245 @example
17246 #+CALL: factorial[:session special](n=5)
17247 @end example
17249 @node Environment of a Code Block
17250 @section Environment of a Code Block
17254 @anchor{Passing arguments}
17255 @subheading Passing arguments
17257 @cindex passing arguments to code blocks
17258 @cindex arguments, in code blocks
17259 @cindex @samp{var}, header argument
17260 Use @samp{var} for passing arguments to source code blocks.  The specifics
17261 of variables in code blocks vary by the source language and are
17262 covered in the language-specific documentation.  The syntax for @samp{var},
17263 however, is the same for all languages.  This includes declaring
17264 a variable, and assigning a default value.
17266 The following syntax is used to pass arguments to code blocks using
17267 the @samp{var} header argument.
17269 @example
17270 :var NAME=ASSIGN
17271 @end example
17273 @noindent
17274 @var{NAME} is the name of the variable bound in the code block
17275 body.  @var{ASSIGN} is a literal value, such as a string,
17276 a number, a reference to a table, a list, a literal example, another
17277 code block---with or without arguments---or the results of evaluating
17278 a code block.
17280 Here are examples of passing values by reference:
17282 @table @asis
17283 @item table
17284 A table named with a @samp{NAME} keyword.
17286 @example
17287 #+NAME: example-table
17288 | 1 |
17289 | 2 |
17290 | 3 |
17291 | 4 |
17293 #+NAME: table-length
17294 #+BEGIN_SRC emacs-lisp :var table=example-table
17295   (length table)
17296 #+END_SRC
17298 #+RESULTS: table-length
17299 : 4
17300 @end example
17302 When passing a table, you can treat specially the row, or the
17303 column, containing labels for the columns, or the rows, in the
17304 table.
17306 @cindex @samp{colnames}, header argument
17307 The @samp{colnames} header argument accepts @samp{yes}, @samp{no}, or @samp{nil}
17308 values.  The default value is @samp{nil}: if an input table has column
17309 names---because the second row is a horizontal rule---then Org
17310 removes the column names, processes the table, puts back the
17311 column names, and then writes the table to the results block.
17312 Using @samp{yes}, Org does the same to the first row, even if the
17313 initial table does not contain any horizontal rule.  When set to
17314 @samp{no}, Org does not pre-process column names at all.
17316 @example
17317 #+NAME: less-cols
17318 | a |
17319 |---|
17320 | b |
17321 | c |
17323 #+BEGIN_SRC python :var tab=less-cols :colnames nil
17324   return [[val + '*' for val in row] for row in tab]
17325 #+END_SRC
17327 #+RESULTS:
17328 | a  |
17329 |----|
17330 | b* |
17331 | c* |
17332 @end example
17334 @cindex @samp{rownames}, header argument
17335 Similarly, the @samp{rownames} header argument can take two values:
17336 @samp{yes} or @samp{no}.  When set to @samp{yes}, Org removes the first column,
17337 processes the table, puts back the first column, and then writes
17338 the table to the results block.  The default is @samp{no}, which means
17339 Org does not pre-process the first column.  Note that Emacs Lisp
17340 code blocks ignore @samp{rownames} header argument because of the ease
17341 of table-handling in Emacs.
17343 @example
17344 #+NAME: with-rownames
17345 | one | 1 | 2 | 3 | 4 |  5 |
17346 | two | 6 | 7 | 8 | 9 | 10 |
17348 #+BEGIN_SRC python :var tab=with-rownames :rownames yes
17349   return [[val + 10 for val in row] for row in tab]
17350 #+END_SRC
17352 #+RESULTS:
17353 | one | 11 | 12 | 13 | 14 | 15 |
17354 | two | 16 | 17 | 18 | 19 | 20 |
17355 @end example
17357 @item list
17358 A simple named list.
17360 @example
17361 #+NAME: example-list
17362 - simple
17363   - not
17364   - nested
17365 - list
17367 #+BEGIN_SRC emacs-lisp :var x=example-list
17368   (print x)
17369 #+END_SRC
17371 #+RESULTS:
17372 | simple | list |
17373 @end example
17375 Note that only the top level list items are passed along.  Nested
17376 list items are ignored.
17378 @item code block without arguments
17379 A code block name, as assigned by @samp{NAME} keyword from the example
17380 above, optionally followed by parentheses.
17382 @example
17383 #+BEGIN_SRC emacs-lisp :var length=table-length()
17384   (* 2 length)
17385 #+END_SRC
17387 #+RESULTS:
17388 : 8
17389 @end example
17391 @item code block with arguments
17392 A code block name, as assigned by @samp{NAME} keyword, followed by
17393 parentheses and optional arguments passed within the parentheses.
17395 @example
17396 #+NAME: double
17397 #+BEGIN_SRC emacs-lisp :var input=8
17398   (* 2 input)
17399 #+END_SRC
17401 #+RESULTS: double
17402 : 16
17404 #+NAME: squared
17405 #+BEGIN_SRC emacs-lisp :var input=double(input=1)
17406   (* input input)
17407 #+END_SRC
17409 #+RESULTS: squared
17410 : 4
17411 @end example
17413 @item literal example
17414 A literal example block named with a @samp{NAME} keyword.
17416 @example
17417 #+NAME: literal-example
17418 #+BEGIN_EXAMPLE
17419   A literal example
17420   on two lines
17421 #+END_EXAMPLE
17423 #+NAME: read-literal-example
17424 #+BEGIN_SRC emacs-lisp :var x=literal-example
17425   (concatenate #'string x " for you.")
17426 #+END_SRC
17428 #+RESULTS: read-literal-example
17429 : A literal example
17430 : on two lines for you.
17431 @end example
17432 @end table
17434 Indexing variable values enables referencing portions of a variable.
17435 Indexes are 0 based with negative values counting backwards from the
17436 end.  If an index is separated by commas then each subsequent section
17437 indexes as the next dimension.  Note that this indexing occurs
17438 @emph{before} other table-related header arguments are applied, such as
17439 @samp{hlines}, @samp{colnames} and @samp{rownames}.  The following example assigns
17440 the last cell of the first row the table @samp{example-table} to the
17441 variable @samp{data}:
17443 @example
17444 #+NAME: example-table
17445 | 1 | a |
17446 | 2 | b |
17447 | 3 | c |
17448 | 4 | d |
17450 #+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
17451   data
17452 #+END_SRC
17454 #+RESULTS:
17455 : a
17456 @end example
17458 Two integers separated by a colon reference a range of variable
17459 values.  In that case the entire inclusive range is referenced.  For
17460 example the following assigns the middle three rows of @samp{example-table}
17461 to @samp{data}.
17463 @example
17464 #+NAME: example-table
17465 | 1 | a |
17466 | 2 | b |
17467 | 3 | c |
17468 | 4 | d |
17469 | 5 | 3 |
17471 #+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
17472   data
17473 #+END_SRC
17475 #+RESULTS:
17476 | 2 | b |
17477 | 3 | c |
17478 | 4 | d |
17479 @end example
17481 To pick the entire range, use an empty index, or the single character
17482 @samp{*}.  @samp{0:-1} does the same thing.  Example below shows how to
17483 reference the first column only.
17485 @example
17486 #+NAME: example-table
17487 | 1 | a |
17488 | 2 | b |
17489 | 3 | c |
17490 | 4 | d |
17492 #+BEGIN_SRC emacs-lisp :var data=example-table[,0]
17493   data
17494 #+END_SRC
17496 #+RESULTS:
17497 | 1 | 2 | 3 | 4 |
17498 @end example
17500 Index referencing can be used for tables and code blocks.  Index
17501 referencing can handle any number of dimensions.  Commas delimit
17502 multiple dimensions, as shown below.
17504 @example
17505 #+NAME: 3D
17506 #+BEGIN_SRC emacs-lisp
17507   '(((1  2  3)  (4  5  6)  (7  8  9))
17508     ((10 11 12) (13 14 15) (16 17 18))
17509     ((19 20 21) (22 23 24) (25 26 27)))
17510 #+END_SRC
17512 #+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
17513   data
17514 #+END_SRC
17516 #+RESULTS:
17517 | 11 | 14 | 17 |
17518 @end example
17520 Note that row names and column names are not removed prior to variable
17521 indexing.  You need to take them into account, even when @samp{colnames} or
17522 @samp{rownames} header arguments remove them.
17524 Emacs lisp code can also set the values for variables.  To
17525 differentiate a value from Lisp code, Org interprets any value
17526 starting with @samp{(}, @samp{[}, @samp{'} or @samp{`} as Emacs Lisp code.  The result of
17527 evaluating that code is then assigned to the value of that variable.
17528 The following example shows how to reliably query and pass the file
17529 name of the Org mode buffer to a code block using headers.  We need
17530 reliability here because the file's name could change once the code in
17531 the block starts executing.
17533 @example
17534 #+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
17535   wc -w $filename
17536 #+END_SRC
17537 @end example
17539 Note that values read from tables and lists are not mistakenly
17540 evaluated as Emacs Lisp code, as illustrated in the following example.
17542 @example
17543 #+NAME: table
17544 | (a b c) |
17546 #+HEADER: :var data=table[0,0]
17547 #+BEGIN_SRC perl
17548   $data
17549 #+END_SRC
17551 #+RESULTS:
17552 : (a b c)
17553 @end example
17555 @anchor{Using sessions}
17556 @subheading Using sessions
17558 @cindex using sessions in code blocks
17559 @cindex @samp{session}, header argument
17560 Two code blocks can share the same environment.  The @samp{session} header
17561 argument is for running multiple source code blocks under one session.
17562 Org runs code blocks with the same session name in the same
17563 interpreter process.
17565 @table @asis
17566 @item @samp{none}
17567 Default.  Each code block gets a new interpreter process to
17568 execute.  The process terminates once the block is evaluated.
17570 @item @var{STRING}
17571 Any string besides @samp{none} turns that string into the name of that
17572 session.  For example, @samp{:session STRING} names it @samp{STRING}.  If
17573 @samp{session} has no value, then the session name is derived from the
17574 source language identifier.  Subsequent blocks with the same
17575 source code language use the same session.  Depending on the
17576 language, state variables, code from other blocks, and the
17577 overall interpreted environment may be shared.  Some interpreted
17578 languages support concurrent sessions when subsequent source code
17579 language blocks change session names.
17580 @end table
17582 Only languages that provide interactive evaluation can have session
17583 support.  Not all languages provide this support, such as C and ditaa.
17584 Even languages, such as Python and Haskell, that do support
17585 interactive evaluation impose limitations on allowable language
17586 constructs that can run interactively.  Org inherits those limitations
17587 for those code blocks running in a session.
17589 @anchor{Choosing a working directory}
17590 @subheading Choosing a working directory
17592 @cindex working directory, in a code block
17593 @cindex @samp{dir}, header argument
17594 The @samp{dir} header argument specifies the default directory during code
17595 block execution.  If it is absent, then the directory associated with
17596 the current buffer is used.  In other words, supplying @samp{:dir PATH}
17597 temporarily has the same effect as changing the current directory with
17598 @kbd{M-x cd PATH}, and then not setting @samp{dir}.  Under the
17599 surface, @samp{dir} simply sets the value of the Emacs variable
17600 @code{default-directory}.
17602 For example, to save the plot file in the @samp{Work/} folder of the home
17603 directory---notice tilde is expanded:
17605 @example
17606 #+BEGIN_SRC R :file myplot.png :dir ~/Work
17607   matplot(matrix(rnorm(100), 10), type="l")
17608 #+END_SRC
17609 @end example
17611 To evaluate the code block on a remote machine, supply a remote
17612 directory name using Tramp syntax.  For example:
17614 @example
17615 #+BEGIN_SRC R :file plot.png :dir /scp:dand@@yakuba.princeton.edu:
17616   plot(1:10, main=system("hostname", intern=TRUE))
17617 #+END_SRC
17618 @end example
17620 Org first captures the text results as usual for insertion in the Org
17621 file.  Then Org also inserts a link to the remote file, thanks to
17622 Emacs Tramp.  Org constructs the remote path to the file name from
17623 @samp{dir} and @code{default-directory}, as illustrated here:
17625 @example
17626 [[file:/scp:dand@@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
17627 @end example
17629 When @samp{dir} is used with @samp{session}, Org sets the starting directory for
17630 a new session.  But Org does not alter the directory of an already
17631 existing session.
17633 Do not use @samp{dir} with @samp{:exports results} or with @samp{:exports both} to
17634 avoid Org inserting incorrect links to remote files.  That is because
17635 Org does not expand @code{default directory} to avoid some underlying
17636 portability issues.
17638 @anchor{Inserting headers and footers}
17639 @subheading Inserting headers and footers
17641 @cindex headers, in code blocks
17642 @cindex footers, in code blocks
17643 @cindex @samp{prologue}, header argument
17644 The @samp{prologue} header argument is for appending to the top of the code
17645 block for execution, like a reset instruction.  For example, you may
17646 use @samp{:prologue "reset"} in a Gnuplot code block or, for every such
17647 block:
17649 @lisp
17650 (add-to-list 'org-babel-default-header-args:gnuplot
17651              '((:prologue . "reset")))
17653 @end lisp
17655 @cindex @samp{epilogue}, header argument
17656 Likewise, the value of the @samp{epilogue} header argument is for appending
17657 to the end of the code block for execution.
17659 @node Evaluating Code Blocks
17660 @section Evaluating Code Blocks
17662 @cindex code block, evaluating
17663 @cindex source code, evaluating
17664 @cindex @samp{RESULTS}, keyword
17666 A note about security: With code evaluation comes the risk of harm.
17667 Org safeguards by prompting for user's permission before executing any
17668 code in the source block.  To customize this safeguard, or disable it,
17669 see @ref{Code Evaluation Security}.
17671 @anchor{How to evaluate source code}
17672 @subheading How to evaluate source code
17674 Org captures the results of the code block evaluation and inserts them
17675 in the Org file, right after the code block.  The insertion point is
17676 after a newline and the @samp{RESULTS} keyword.  Org creates the @samp{RESULTS}
17677 keyword if one is not already there.
17679 By default, Org enables only Emacs Lisp code blocks for execution.
17680 See @ref{Languages} to enable other languages.
17682 @kindex C-c C-c
17683 @kindex C-c C-v e
17684 @findex org-babel-execute-src-block
17685 Org provides many ways to execute code blocks.  @kbd{C-c C-c} or
17686 @kbd{C-c C-v e} with the point on a code block@footnote{The option @code{org-babel-no-eval-on-ctrl-c-ctrl-c} can be used
17687 to remove code evaluation from the @kbd{C-c C-c} key binding.} calls the
17688 @code{org-babel-execute-src-block} function, which executes the code in the
17689 block, collects the results, and inserts them in the buffer.
17691 @cindex @samp{CALL}, keyword
17692 @vindex org-babel-inline-result-wrap
17693 By calling a named code block@footnote{Actually, the constructs @samp{call_<name>()} and @samp{src_<lang>@{@}}
17694 are not evaluated when they appear in a keyword line---i.e. lines
17695 starting with @samp{#+KEYWORD:}, see @ref{In-buffer Settings}.} from an Org mode buffer or
17696 a table.  Org can call the named code blocks from the current Org mode
17697 buffer or from the ``Library of Babel'' (see @ref{Library of Babel}).
17699 The syntax for @samp{CALL} keyword is:
17701 @example
17702 #+CALL: <name>(<arguments>)
17703 #+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
17704 @end example
17706 The syntax for inline named code blocks is:
17708 @example
17709 ... call_<name>(<arguments>) ...
17710 ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
17711 @end example
17713 When inline syntax is used, the result is wrapped based on the
17714 variable @code{org-babel-inline-result-wrap}, which by default is set to
17715 @code{"=%s="} to produce verbatim text suitable for markup.
17717 @table @asis
17718 @item @samp{<name>}
17719 This is the name of the code block (see @ref{Structure of Code Blocks}) to be evaluated in the current document.  If the block is
17720 located in another file, start @samp{<name>} with the file name
17721 followed by a colon. For example, in order to execute a block
17722 named @samp{clear-data} in @samp{file.org}, you can write the following:
17724 @example
17725 #+CALL: file.org:clear-data()
17726 @end example
17728 @item @samp{<arguments>}
17729 Org passes arguments to the code block using standard function
17730 call syntax.  For example, a @samp{#+CALL:} line that passes @samp{4} to
17731 a code block named @samp{double}, which declares the header argument
17732 @samp{:var n=2}, would be written as:
17734 @example
17735 #+CALL: double(n=4)
17736 @end example
17738 @noindent
17739 Note how this function call syntax is different from the header
17740 argument syntax.
17742 @item @samp{<inside header arguments>}
17743 Org passes inside header arguments to the named code block using
17744 the header argument syntax.  Inside header arguments apply to
17745 code block evaluation.  For example, @samp{[:results output]} collects
17746 results printed to stdout during code execution of that block.
17747 Note how this header argument syntax is different from the
17748 function call syntax.
17750 @item @samp{<end header arguments>}
17751 End header arguments affect the results returned by the code
17752 block.  For example, @samp{:results html} wraps the results in
17753 a @samp{#+BEGIN_EXPORT html} block before inserting the results in the
17754 Org buffer.
17755 @end table
17757 @anchor{Limit code block evaluation}
17758 @subheading Limit code block evaluation
17760 @cindex @samp{eval}, header argument
17761 @cindex control code block evaluation
17762 The @samp{eval} header argument can limit evaluation of specific code
17763 blocks and @samp{CALL} keyword.  It is useful for protection against
17764 evaluating untrusted code blocks by prompting for a confirmation.
17766 @table @asis
17767 @item @samp{never} or @samp{no}
17768 Org never evaluates the source code.
17770 @item @samp{query}
17771 Org prompts the user for permission to evaluate the source code.
17773 @item @samp{never-export} or @samp{no-export}
17774 Org does not evaluate the source code when exporting, yet the
17775 user can evaluate it interactively.
17777 @item @samp{query-export}
17778 Org prompts the user for permission to evaluate the source code
17779 during export.
17780 @end table
17782 If @samp{eval} header argument is not set, then Org determines whether to
17783 evaluate the source code from the @code{org-confirm-babel-evaluate}
17784 variable (see @ref{Code Evaluation Security}).
17786 @anchor{Cache results of evaluation}
17787 @subheading Cache results of evaluation
17789 @cindex @samp{cache}, header argument
17790 @cindex cache results of code evaluation
17791 The @samp{cache} header argument is for caching results of evaluating code
17792 blocks.  Caching results can avoid re-evaluating a code block that
17793 have not changed since the previous run.  To benefit from the cache
17794 and avoid redundant evaluations, the source block must have a result
17795 already present in the buffer, and neither the header
17796 arguments---including the value of @samp{var} references---nor the text of
17797 the block itself has changed since the result was last computed.  This
17798 feature greatly helps avoid long-running calculations.  For some edge
17799 cases, however, the cached results may not be reliable.
17801 The caching feature is best for when code blocks are pure functions,
17802 that is functions that return the same value for the same input
17803 arguments (see @ref{Environment of a Code Block}), and that do not have
17804 side effects, and do not rely on external variables other than the
17805 input arguments.  Functions that depend on a timer, file system
17806 objects, and random number generators are clearly unsuitable for
17807 caching.
17809 A note of warning: when @samp{cache} is used in a session, caching may
17810 cause unexpected results.
17812 When the caching mechanism tests for any source code changes, it does
17813 not expand Noweb style references (see @ref{Noweb Reference Syntax}).  For
17814 reasons why, see @uref{http://thread.gmane.org/gmane.emacs.orgmode/79046}.
17816 The @samp{cache} header argument can have one of two values: @samp{yes} or @samp{no}.
17818 @table @asis
17819 @item @samp{no}
17820 Default.  No caching of results; code block evaluated every
17821 time.
17823 @item @samp{yes}
17824 Whether to run the code or return the cached results is
17825 determined by comparing the SHA1 hash value of the combined code
17826 block and arguments passed to it.  This hash value is packed on
17827 the @samp{#+RESULTS:} line from previous evaluation.  When hash values
17828 match, Org does not evaluate the code block.  When hash values
17829 mismatch, Org evaluates the code block, inserts the results,
17830 recalculates the hash value, and updates @samp{#+RESULTS:} line.
17831 @end table
17833 In this example, both functions are cached.  But @samp{caller} runs only if
17834 the result from @samp{random} has changed since the last run.
17836 @example
17837 #+NAME: random
17838 #+BEGIN_SRC R :cache yes
17839   runif(1)
17840 #+END_SRC
17842 #+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
17843 0.4659510825295
17845 #+NAME: caller
17846 #+BEGIN_SRC emacs-lisp :var x=random :cache yes
17847   x
17848 #+END_SRC
17850 #+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
17851 0.254227238707244
17852 @end example
17854 @node Results of Evaluation
17855 @section Results of Evaluation
17857 @cindex code block, results of evaluation
17858 @cindex source code, results of evaluation
17860 @cindex @samp{results}, header argument
17861 How Org handles results of a code block execution depends on many
17862 header arguments working together.  The primary determinant, however,
17863 is the @samp{results} header argument.  It accepts four classes of options.
17864 Each code block can take only one option per class:
17866 @table @asis
17867 @item collection
17868 For how the results should be collected from the code block;
17870 @item type
17871 For which type of result the code block will return; affects how
17872 Org processes and inserts results in the Org buffer;
17874 @item format
17875 For the result; affects how Org processes and inserts results in
17876 the Org buffer;
17878 @item handling
17879 For processing results after evaluation of the code block;
17880 @end table
17882 @anchor{Collection}
17883 @subheading Collection
17885 Collection options specify the results.  Choose one of the options;
17886 they are mutually exclusive.
17888 @table @asis
17889 @item @samp{value}
17890 Default.  Functional mode.  Org gets the value by wrapping the
17891 code in a function definition in the language of the source
17892 block.  That is why when using @samp{:results value}, code should
17893 execute like a function and return a value.  For languages like
17894 Python, an explicit @code{return} statement is mandatory when using
17895 @samp{:results value}.  Result is the value returned by the last
17896 statement in the code block.
17898 When evaluating the code block in a session (see @ref{Environment of a Code Block}), Org passes the code to an interpreter running as
17899 an interactive Emacs inferior process. Org gets the value from
17900 the source code interpreter's last statement output.  Org has to
17901 use language-specific methods to obtain the value.  For example,
17902 from the variable @code{_} in Python and Ruby, and the value of
17903 @code{.Last.value} in R.
17905 @item @samp{output}
17906 Scripting mode.  Org passes the code to an external process
17907 running the interpreter.  Org returns the contents of the
17908 standard output stream as text results.
17910 When using a session, Org passes the code to the interpreter
17911 running as an interactive Emacs inferior process.  Org
17912 concatenates any text output from the interpreter and returns the
17913 collection as a result.
17915 Note that this collection is not the same as that would be
17916 collected from stdout of a non-interactive interpreter running as
17917 an external process.  Compare for example these two blocks:
17919 @example
17920 #+BEGIN_SRC python :results output
17921   print "hello"
17922   2
17923   print "bye"
17924 #+END_SRC
17926 #+RESULTS:
17927 : hello
17928 : bye
17929 @end example
17931 In the above non-session mode, the ``2'' is not printed; so it does
17932 not appear in results.
17934 @example
17935 #+BEGIN_SRC python :results output :session
17936   print "hello"
17937   2
17938   print "bye"
17939 #+END_SRC
17941 #+RESULTS:
17942 : hello
17943 : 2
17944 : bye
17945 @end example
17947 In the above session, the interactive interpreter receives and
17948 prints ``2''.  Results show that.
17949 @end table
17951 @anchor{Type}
17952 @subheading Type
17954 Type tells what result types to expect from the execution of the code
17955 block.  Choose one of the options; they are mutually exclusive.  The
17956 default behavior is to automatically determine the result type.
17958 @table @asis
17959 @item @samp{table}
17960 @itemx @samp{vector}
17961 Interpret the results as an Org table.  If the result is a single
17962 value, create a table with one row and one column.  Usage
17963 example: @samp{:results value table}.
17965 @cindex @samp{hlines}, header argument
17966 In-between each table row or below the table headings, sometimes
17967 results have horizontal lines, which are also known as ``hlines''.
17968 The @samp{hlines} argument with the default @samp{no} value strips such
17969 lines from the input table.  For most code, this is desirable, or
17970 else those @samp{hline} symbols raise unbound variable errors.
17971 A @samp{yes} accepts such lines, as demonstrated in the following
17972 example.
17974 @example
17975 #+NAME: many-cols
17976 | a | b | c |
17977 |---+---+---|
17978 | d | e | f |
17979 |---+---+---|
17980 | g | h | i |
17982 #+NAME: no-hline
17983 #+BEGIN_SRC python :var tab=many-cols :hlines no
17984   return tab
17985 #+END_SRC
17987 #+RESULTS: no-hline
17988 | a | b | c |
17989 | d | e | f |
17990 | g | h | i |
17992 #+NAME: hlines
17993 #+BEGIN_SRC python :var tab=many-cols :hlines yes
17994   return tab
17995 #+END_SRC
17997 #+RESULTS: hlines
17998 | a | b | c |
17999 |---+---+---|
18000 | d | e | f |
18001 |---+---+---|
18002 | g | h | i |
18003 @end example
18005 @item @samp{list}
18006 Interpret the results as an Org list.  If the result is a single
18007 value, create a list of one element.
18009 @item @samp{scalar}
18010 @itemx @samp{verbatim}
18011 Interpret literally and insert as quoted text.  Do not create
18012 a table.  Usage example: @samp{:results value verbatim}.
18014 @item @samp{file}
18015 Interpret as a filename.  Save the results of execution of the
18016 code block to that file, then insert a link to it.  You can
18017 control both the filename and the description associated to the
18018 link.
18020 @cindex @samp{file}, header argument
18021 @cindex @samp{output-dir}, header argument
18022 Org first tries to generate the filename from the value of the
18023 @samp{file} header argument and the directory specified using the
18024 @samp{output-dir} header arguments.  If @samp{output-dir} is not specified,
18025 Org assumes it is the current directory.
18027 @example
18028 #+BEGIN_SRC asymptote :results value file :file circle.pdf :output-dir img/
18029   size(2cm);
18030   draw(unitcircle);
18031 #+END_SRC
18032 @end example
18034 @cindex @samp{file-ext}, header argument
18035 If @samp{file} is missing, Org generates the base name of the output
18036 file from the name of the code block, and its extension from the
18037 @samp{file-ext} header argument.  In that case, both the name and the
18038 extension are mandatory.
18040 @example
18041 #+name: circle
18042 #+BEGIN_SRC asymptote :results value file :file-ext pdf
18043   size(2cm);
18044   draw(unitcircle);
18045 #+END_SRC
18046 @end example
18048 @cindex @samp{file-desc}, header argument
18049 The @samp{file-desc} header argument defines the description (see
18050 @ref{Link Format}) for the link.  If @samp{file-desc} has no value, Org
18051 uses the generated file name for both the ``link'' and
18052 ``description'' parts of the link.
18053 @end table
18055 @anchor{Format}
18056 @subheading Format
18058 Format pertains to the type of the result returned by the code block.
18059 Choose one of the options; they are mutually exclusive.  The default
18060 follows from the type specified above.
18062 @table @asis
18063 @item @samp{raw}
18064 Interpreted as raw Org mode.  Inserted directly into the buffer.
18065 Aligned if it is a table.  Usage example: @samp{:results value raw}.
18067 @item @samp{org}
18068 Results enclosed in a @samp{BEGIN_SRC org} block.  For comma-escape,
18069 either @kbd{@key{TAB}} in the block, or export the file.  Usage
18070 example: @samp{:results value org}.
18072 @item @samp{html}
18073 Results enclosed in a @samp{BEGIN_EXPORT html} block.  Usage example:
18074 @samp{:results value html}.
18076 @item @samp{latex}
18077 Results enclosed in a @samp{BEGIN_EXPORT latex} block.  Usage example:
18078 @samp{:results value latex}.
18080 @item @samp{code}
18081 Result enclosed in a code block.  Useful for parsing.  Usage
18082 example: @samp{:results value code}.
18084 @item @samp{pp}
18085 Result converted to pretty-print source code.  Enclosed in a code
18086 block.  Languages supported: Emacs Lisp, Python, and Ruby.  Usage
18087 example: @samp{:results value pp}.
18089 @item @samp{drawer}
18090 Result wrapped in a @samp{RESULTS} drawer.  Useful for containing
18091 @samp{raw} or @samp{org} results for later scripting and automated
18092 processing.  Usage example: @samp{:results value drawer}.
18093 @end table
18095 @anchor{Handling}
18096 @subheading Handling
18098 Handling options after collecting the results.
18100 @table @asis
18101 @item @samp{silent}
18102 Do not insert results in the Org mode buffer, but echo them in
18103 the minibuffer.  Usage example: @samp{:results output silent}.
18105 @item @samp{replace}
18106 Default.  Insert results in the Org buffer.  Remove previous
18107 results.  Usage example: @samp{:results output replace}.
18109 @item @samp{append}
18110 Append results to the Org buffer.  Latest results are at the
18111 bottom.  Does not remove previous results.  Usage example:
18112 @samp{:results output append}.
18114 @item @samp{prepend}
18115 Prepend results to the Org buffer.  Latest results are at the
18116 top.  Does not remove previous results.  Usage example: @samp{:results
18117      output prepend}.
18118 @end table
18120 @anchor{Post-processing}
18121 @subheading Post-processing
18123 @cindex @samp{post}, header argument
18124 @cindex @samp{*this*}, in @samp{post} header argument
18125 The @samp{post} header argument is for post-processing results from block
18126 evaluation.  When @samp{post} has any value, Org binds the results to
18127 @code{*this*} variable for easy passing to @samp{var} header argument
18128 specifications (see @ref{Environment of a Code Block}).  That makes results
18129 available to other code blocks, or even for direct Emacs Lisp code
18130 execution.
18132 The following two examples illustrate @samp{post} header argument in
18133 action.  The first one shows how to attach an @samp{ATTR_LATEX} keyword
18134 using @samp{post}.
18136 @example
18137 #+NAME: attr_wrap
18138 #+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output
18139   echo "#+ATTR_LATEX: :width $width"
18140   echo "$data"
18141 #+END_SRC
18143 #+HEADER: :file /tmp/it.png
18144 #+BEGIN_SRC dot :post attr_wrap(width="5cm", data=*this*) :results drawer
18145   digraph@{
18146           a -> b;
18147           b -> c;
18148           c -> a;
18149   @}
18150 #+end_src
18152 #+RESULTS:
18153 :RESULTS:
18154 #+ATTR_LATEX :width 5cm
18155 [[file:/tmp/it.png]]
18156 :END:
18157 @end example
18159 The second example shows use of @samp{colnames} header argument in @samp{post}
18160 to pass data between code blocks.
18162 @example
18163 #+NAME: round-tbl
18164 #+BEGIN_SRC emacs-lisp :var tbl="" fmt="%.3f"
18165   (mapcar (lambda (row)
18166             (mapcar (lambda (cell)
18167                       (if (numberp cell)
18168                           (format fmt cell)
18169                         cell))
18170                     row))
18171           tbl)
18172 #+end_src
18174 #+BEGIN_SRC R :colnames yes :post round-tbl[:colnames yes](*this*)
18175   set.seed(42)
18176   data.frame(foo=rnorm(1))
18177 #+END_SRC
18179 #+RESULTS:
18180 |   foo |
18181 |-------|
18182 | 1.371 |
18183 @end example
18185 @node Exporting Code Blocks
18186 @section Exporting Code Blocks
18188 @cindex code block, exporting
18189 @cindex source code, exporting
18191 It is possible to export the @emph{code} of code blocks, the @emph{results} of
18192 code block evaluation, @emph{both} the code and the results of code block
18193 evaluation, or @emph{none}.  Org defaults to exporting @emph{code} for most
18194 languages.  For some languages, such as ditaa, Org defaults to
18195 @emph{results}.  To export just the body of code blocks, see @ref{Literal Examples}.  To selectively export sub-trees of an Org document, see
18196 @ref{Exporting}.
18198 @cindex @samp{export}, header argument
18199 The @samp{exports} header argument is to specify if that part of the Org
18200 file is exported to, say, HTML or @LaTeX{} formats.
18202 @table @asis
18203 @item @samp{code}
18204 The default.  The body of code is included into the exported
18205 file.  Example: @samp{:exports code}.
18207 @item @samp{results}
18208 The results of evaluation of the code is included in the exported
18209 file.  Example: @samp{:exports results}.
18211 @item @samp{both}
18212 Both the code and results of evaluation are included in the
18213 exported file.  Example: @samp{:exports both}.
18215 @item @samp{none}
18216 Neither the code nor the results of evaluation is included in the
18217 exported file.  Whether the code is evaluated at all depends on
18218 other options.  Example: @samp{:exports none}.
18219 @end table
18221 @vindex org-export-use-babel
18222 To stop Org from evaluating code blocks to speed exports, use the
18223 header argument @samp{:eval never-export} (see @ref{Evaluating Code Blocks}).
18224 To stop Org from evaluating code blocks for greater security, set the
18225 @code{org-export-use-babel} variable to @code{nil}, but understand that header
18226 arguments will have no effect.
18228 Turning off evaluation comes in handy when batch processing.  For
18229 example, markup languages for wikis, which have a high risk of
18230 untrusted code.  Stopping code block evaluation also stops evaluation
18231 of all header arguments of the code block.  This may not be desirable
18232 in some circumstances.  So during export, to allow evaluation of just
18233 the header arguments but not any code evaluation in the source block,
18234 set @samp{:eval never-export} (see @ref{Evaluating Code Blocks}).
18236 Org never evaluates code blocks in commented sub-trees when exporting
18237 (see @ref{Comment Lines}).  On the other hand, Org does evaluate code
18238 blocks in sub-trees excluded from export (see @ref{Export Settings}).
18240 @node Extracting Source Code
18241 @section Extracting Source Code
18243 @cindex tangling
18244 @cindex source code, extracting
18245 @cindex code block, extracting source code
18247 Extracting source code from code blocks is a basic task in literate
18248 programming.  Org has features to make this easy.  In literate
18249 programming parlance, documents on creation are @emph{woven} with code and
18250 documentation, and on export, the code is tangled for execution by
18251 a computer.  Org facilitates weaving and tangling for producing,
18252 maintaining, sharing, and exporting literate programming documents.
18253 Org provides extensive customization options for extracting source
18254 code.
18256 When Org tangles code blocks, it expands, merges, and transforms them.
18257 Then Org recomposes them into one or more separate files, as
18258 configured through the options.  During this tangling process, Org
18259 expands variables in the source code, and resolves any Noweb style
18260 references (see @ref{Noweb Reference Syntax}).
18262 @anchor{Header arguments}
18263 @subheading Header arguments
18265 @cindex @samp{tangle}, header argument
18266 The @samp{tangle} header argument specifies if the code block is exported
18267 to source file(s).
18269 @table @asis
18270 @item @samp{yes}
18271 Export the code block to source file.  The file name for the
18272 source file is derived from the name of the Org file, and the
18273 file extension is derived from the source code language
18274 identifier.  Example: @samp{:tangle yes}.
18276 @item @samp{no}
18277 The default.  Do not extract the code in a source code file.
18278 Example: @samp{:tangle no}.
18280 @item @var{FILENAME}
18281 Export the code block to source file whose file name is derived
18282 from any string passed to the @samp{tangle} header argument.  Org
18283 derives the file name as being relative to the directory of the
18284 Org file's location.  Example: @samp{:tangle FILENAME}.
18285 @end table
18287 @cindex @samp{mkdirp}, header argument
18288 The @samp{mkdirp} header argument creates parent directories for tangled
18289 files if the directory does not exist.  @samp{yes} enables directory
18290 creation and @samp{no} inhibits directory creation.
18292 @cindex @samp{comments}, header argument
18293 The @samp{comments} header argument controls inserting comments into
18294 tangled files.  These are above and beyond whatever comments may
18295 already exist in the code block.
18297 @table @asis
18298 @item @samp{no}
18299 The default.  Do not insert any extra comments during tangling.
18301 @item @samp{link}
18302 Wrap the code block in comments.  Include links pointing back to
18303 the place in the Org file from where the code was tangled.
18305 @item @samp{yes}
18306 Kept for backward compatibility; same as @samp{link}.
18308 @item @samp{org}
18309 Nearest headline text from Org file is inserted as comment.  The
18310 exact text that is inserted is picked from the leading context of
18311 the source block.
18313 @item @samp{both}
18314 Includes both @samp{link} and @samp{org} options.
18316 @item @samp{noweb}
18317 Includes @samp{link} option, expands Noweb references (see @ref{Noweb Reference Syntax}), and wraps them in link comments inside the
18318 body of the code block.
18319 @end table
18321 @cindex @samp{padline}, header argument
18322 The @samp{padline} header argument controls insertion of newlines to pad
18323 source code in the tangled file.
18325 @table @asis
18326 @item @samp{yes}
18327 Default.  Insert a newline before and after each code block in
18328 the tangled file.
18330 @item @samp{no}
18331 Do not insert newlines to pad the tangled code blocks.
18332 @end table
18334 @cindex @samp{shebang}, header argument
18335 The @samp{shebang} header argument can turn results into executable script
18336 files.  By setting it to a string value---for example, @samp{:shebang
18337 "#!/bin/bash"}---Org inserts that string as the first line of the
18338 tangled file that the code block is extracted to.  Org then turns on
18339 the tangled file's executable permission.
18341 @cindex @samp{no-expand}, header argument
18342 By default Org expands code blocks during tangling.  The @samp{no-expand}
18343 header argument turns off such expansions.  Note that one side-effect
18344 of expansion by @code{org-babel-expand-src-block} also assigns values (see
18345 @ref{Environment of a Code Block}) to variables.  Expansions also replace
18346 Noweb references with their targets (see @ref{Noweb Reference Syntax}).
18347 Some of these expansions may cause premature assignment, hence this
18348 option.  This option makes a difference only for tangling.  It has no
18349 effect when exporting since code blocks for execution have to be
18350 expanded anyway.
18352 @anchor{Functions}
18353 @subheading Functions
18355 @table @asis
18356 @item @code{org-babel-tangle}
18357 @findex org-babel-tangle
18358 @kindex C-c C-v t
18359 Tangle the current file.  Bound to @kbd{C-c C-v t}.
18361 With prefix argument only tangle the current code block.
18363 @item @code{org-babel-tangle-file}
18364 @findex org-babel-tangle-file
18365 @kindex C-c C-v f
18366 Choose a file to tangle.  Bound to @kbd{C-c C-v f}.
18367 @end table
18369 @anchor{Hooks (1)}
18370 @subheading Hooks
18372 @table @asis
18373 @item @code{org-babel-post-tangle-hook}
18374 @vindex org-babel-post-tangle-hook
18375 This hook is run from within code files tangled by
18376 @code{org-babel-tangle}, making it suitable for post-processing,
18377 compilation, and evaluation of code in the tangled files.
18378 @end table
18380 @anchor{Jumping between code and Org}
18381 @subheading Jumping between code and Org
18383 @findex org-babel-tangle-jump-to-org
18384 Debuggers normally link errors and messages back to the source code.
18385 But for tangled files, we want to link back to the Org file, not to
18386 the tangled source file.  To make this extra jump, Org uses
18387 @code{org-babel-tangle-jump-to-org} function with two additional source
18388 code block header arguments:
18390 @enumerate
18391 @item
18392 Set @samp{padline} to true---this is the default setting.
18393 @item
18394 Set @samp{comments} to @samp{link}, which makes Org insert links to the Org
18395 file.
18396 @end enumerate
18398 @node Languages
18399 @section Languages
18401 @cindex babel, languages
18402 @cindex source code, languages
18403 @cindex code block, languages
18405 Code blocks in the following languages are supported.
18407 @multitable {aaaaaaaaaa} {aaaaaaaaaa} {aaaaaaaaaaaaaa} {aaaaaaaaaa}
18408 @headitem Language
18409 @tab Identifier
18410 @tab Language
18411 @tab Identifier
18412 @item Asymptote
18413 @tab asymptote
18414 @tab Awk
18415 @tab awk
18416 @item C
18417 @tab C
18418 @tab C++
18419 @tab C++
18420 @item Clojure
18421 @tab clojure
18422 @tab CSS
18423 @tab css
18424 @item D
18425 @tab d
18426 @tab ditaa
18427 @tab ditaa
18428 @item Graphviz
18429 @tab dot
18430 @tab Emacs Calc
18431 @tab calc
18432 @item Emacs Lisp
18433 @tab emacs-lisp
18434 @tab Fortran
18435 @tab fortran
18436 @item Gnuplot
18437 @tab gnuplot
18438 @tab Haskell
18439 @tab haskell
18440 @item Java
18441 @tab java
18442 @tab Javascript
18443 @tab js
18444 @item @LaTeX{}
18445 @tab latex
18446 @tab Ledger
18447 @tab ledger
18448 @item Lisp
18449 @tab lisp
18450 @tab Lilypond
18451 @tab lilypond
18452 @item Lua
18453 @tab lua
18454 @tab MATLAB
18455 @tab matlab
18456 @item Mscgen
18457 @tab mscgen
18458 @tab Objective Caml
18459 @tab ocaml
18460 @item Octave
18461 @tab octave
18462 @tab Org mode
18463 @tab org
18464 @item Oz
18465 @tab oz
18466 @tab Perl
18467 @tab perl
18468 @item Plantuml
18469 @tab plantuml
18470 @tab Processing.js
18471 @tab processing
18472 @item Python
18473 @tab python
18474 @tab R
18475 @tab R
18476 @item Ruby
18477 @tab ruby
18478 @tab Sass
18479 @tab sass
18480 @item Scheme
18481 @tab scheme
18482 @tab GNU Screen
18483 @tab screen
18484 @item Sed
18485 @tab sed
18486 @tab shell
18487 @tab sh
18488 @item SQL
18489 @tab sql
18490 @tab SQLite
18491 @tab sqlite
18492 @item Vala
18493 @tab vala
18494 @tab 
18495 @tab 
18496 @end multitable
18498 Additional documentation for some languages is at
18499 @uref{https://orgmode.org/worg/org-contrib/babel/languages.html}.
18501 @vindex org-babel-load-languages
18502 By default, only Emacs Lisp is enabled for evaluation.  To enable or
18503 disable other languages, customize the @code{org-babel-load-languages}
18504 variable either through the Emacs customization interface, or by
18505 adding code to the init file as shown next.
18507 In this example, evaluation is disabled for Emacs Lisp, and enabled
18508 for R.
18510 @lisp
18511 (org-babel-do-load-languages
18512  'org-babel-load-languages
18513  '((emacs-lisp . nil)
18514    (R . t)))
18515 @end lisp
18517 Note that this is not the only way to enable a language.  Org also
18518 enables languages when loaded with @code{require} statement.  For example,
18519 the following enables execution of Clojure code blocks:
18521 @lisp
18522 (require 'ob-clojure)
18523 @end lisp
18525 @node Editing Source Code
18526 @section Editing Source Code
18528 @cindex code block, editing
18529 @cindex source code, editing
18531 @kindex C-c '
18532 Use @kbd{C-c '} to edit the current code block.  It opens a new
18533 major-mode edit buffer containing the body of the source code block,
18534 ready for any edits.  Use @kbd{C-c '} again to close the buffer
18535 and return to the Org buffer.
18537 @kindex C-x C-s
18538 @vindex org-edit-src-auto-save-idle-delay
18539 @cindex auto-save, in code block editing
18540 @kbd{C-x C-s} saves the buffer and updates the contents of the
18541 Org buffer.  Set @code{org-edit-src-auto-save-idle-delay} to save the base
18542 buffer after a certain idle delay time.  Set
18543 @code{org-edit-src-turn-on-auto-save} to auto-save this buffer into
18544 a separate file using Auto-save mode.
18546 While editing the source code in the major mode, the Org Src minor
18547 mode remains active.  It provides these customization variables as
18548 described below.  For even more variables, look in the customization
18549 group @code{org-edit-structure}.
18551 @table @asis
18552 @item @code{org-src-lang-modes}
18553 @vindex org-src-lang-modes
18554 If an Emacs major-mode named @code{<LANG>-mode} exists, where
18555 @var{<LANG>} is the language identifier from code block's
18556 header line, then the edit buffer uses that major mode.  Use this
18557 variable to arbitrarily map language identifiers to major modes.
18559 @item @code{org-src-window-setup}
18560 @vindex org-src-window-setup
18561 For specifying Emacs window arrangement when the new edit buffer
18562 is created.
18564 @item @code{org-src-preserve-indentation}
18565 @cindex indentation, in code blocks
18566 @vindex org-src-preserve-indentation
18567 Default is @code{nil}.  Source code is indented.  This indentation
18568 applies during export or tangling, and depending on the context,
18569 may alter leading spaces and tabs.  When non-@code{nil}, source code
18570 is aligned with the leftmost column.  No lines are modified
18571 during export or tangling, which is very useful for white-space
18572 sensitive languages, such as Python.
18574 @item @code{org-src-ask-before-returning-to-edit-buffer}
18575 @vindex org-src-ask-before-returning-to-edit-buffer
18576 When @code{nil}, Org returns to the edit buffer without further
18577 prompts.  The default prompts for a confirmation.
18578 @end table
18580 @vindex org-src-fontify-natively
18581 @vindex org-src-block-faces
18582 Set @code{org-src-fontify-natively} to non-@code{nil} to turn on native code
18583 fontification in the @emph{Org} buffer.  Fontification of code blocks can
18584 give visual separation of text and code on the display page.  To
18585 further customize the appearance of @code{org-block} for specific
18586 languages, customize @code{org-src-block-faces}.  The following example
18587 shades the background of regular blocks, and colors source blocks only
18588 for Python and Emacs Lisp languages.
18590 @lisp
18591 (require 'color)
18592 (set-face-attribute 'org-block nil :background
18593                     (color-darken-name
18594                      (face-attribute 'default :background) 3))
18596 (setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF"))
18597                             ("python" (:background "#E5FFB8"))))
18598 @end lisp
18600 @node Noweb Reference Syntax
18601 @section Noweb Reference Syntax
18603 @cindex code block, Noweb reference
18604 @cindex syntax, Noweb
18605 @cindex source code, Noweb reference
18607 Org supports named blocks in Noweb@footnote{For Noweb literate programming details, see
18608 @uref{http://www.cs.tufts.edu/~nr/noweb/}.} style syntax:
18610 @example
18611 <<CODE-BLOCK-ID>>
18612 @end example
18614 Org can replace the construct with the source code, or the results of
18615 evaluation, of the code block identified as @var{CODE-BLOCK-ID}.
18617 @cindex @samp{noweb}, header argument
18618 The @samp{noweb} header argument controls expansion of Noweb syntax
18619 references.  Expansions occur when source code blocks are evaluated,
18620 tangled, or exported.
18622 @table @asis
18623 @item @samp{no}
18624 Default.  No expansion of Noweb syntax references in the body of
18625 the code when evaluating, tangling, or exporting.
18627 @item @samp{yes}
18628 Expansion of Noweb syntax references in the body of the code
18629 block when evaluating, tangling, or exporting.
18631 @item @samp{tangle}
18632 Expansion of Noweb syntax references in the body of the code
18633 block when tangling.  No expansion when evaluating or exporting.
18635 @item @samp{no-export}
18636 Expansion of Noweb syntax references in the body of the code
18637 block when evaluating or tangling.  No expansion when exporting.
18639 @item @samp{strip-export}
18640 Expansion of Noweb syntax references in the body of the code
18641 block when expanding prior to evaluating or tangling.  Removes
18642 Noweb syntax references when exporting.
18644 @item @samp{eval}
18645 Expansion of Noweb syntax references in the body of the code
18646 block only before evaluating.
18647 @end table
18649 In the following example,
18651 @example
18652 #+NAME: initialization
18653 #+BEGIN_SRC emacs-lisp
18654   (setq sentence "Never a foot too far, even.")
18655 #+END_SRC
18657 #+BEGIN_SRC emacs-lisp :noweb yes
18658   <<initialization>>
18659   (reverse sentence)
18660 #+END_SRC
18661 @end example
18663 @noindent
18664 the second code block is expanded as
18666 @example
18667 #+BEGIN_SRC emacs-lisp :noweb yes
18668   (setq sentence "Never a foot too far, even.")
18669   (reverse sentence)
18670 #+END_SRC
18671 @end example
18673 Noweb insertions honor prefix characters that appear before the Noweb
18674 syntax reference.  This behavior is illustrated in the following
18675 example.  Because the @samp{<<example>>} Noweb reference appears behind the
18676 SQL comment syntax, each line of the expanded Noweb reference is
18677 commented.  With:
18679 @example
18680 #+NAME: example
18681 #+BEGIN_SRC text
18682   this is the
18683   multi-line body of example
18684 #+END_SRC
18685 @end example
18687 @noindent
18688 this code block:
18690 @example
18691 #+BEGIN_SRC sql :noweb yes
18692  ---<<example>>
18693 #+END_SRC
18694 @end example
18696 @noindent
18697 expands to:
18699 @example
18700 #+BEGIN_SRC sql :noweb yes
18701  ---this is the
18702  ---multi-line body of example
18703 #+END_SRC
18704 @end example
18706 Since this change does not affect Noweb replacement text without
18707 newlines in them, inline Noweb references are acceptable.
18709 This feature can also be used for management of indentation in
18710 exported code snippets.  With:
18712 @example
18713 #+NAME: if-true
18714 #+BEGIN_SRC python :exports none
18715   print('do things when true')
18716 #+end_src
18718 #+name: if-false
18719 #+begin_src python :exports none
18720   print('do things when false')
18721 #+end_src
18722 @end example
18724 @noindent
18725 this code block:
18727 @example
18728 #+begin_src python :noweb yes :results output
18729   if true:
18730       <<if-true>>
18731   else:
18732       <<if-false>>
18733 #+end_src
18734 @end example
18736 @noindent
18737 expands to:
18739 @example
18740 if true:
18741     print('do things when true')
18742 else:
18743     print('do things when false')
18744 @end example
18746 @cindex @samp{noweb-ref}, header argument
18747 When expanding Noweb style references, Org concatenates code blocks by
18748 matching the reference name to either the code block name or, if none
18749 is found, to the @samp{noweb-ref} header argument.
18751 For simple concatenation, set this @samp{noweb-ref} header argument at the
18752 sub-tree or file level.  In the example Org file shown next, the body
18753 of the source code in each block is extracted for concatenation to
18754 a pure code file when tangled.
18756 @example
18757 #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
18758   <<fullest-disk>>
18759 #+END_SRC
18760 * the mount point of the fullest disk
18761   :PROPERTIES:
18762   :header-args: :noweb-ref fullest-disk
18763   :END:
18765 ** query all mounted disks
18766 #+BEGIN_SRC sh
18767   df \
18768 #+END_SRC
18770 ** strip the header row
18771 #+BEGIN_SRC sh
18772   |sed '1d' \
18773 #+END_SRC
18775 ** output mount point of fullest disk
18776 #+BEGIN_SRC sh
18777   |awk '@{if (u < +$5) @{u = +$5; m = $6@}@} END @{print m@}'
18778 #+END_SRC
18779 @end example
18781 @cindex @samp{noweb-sep}, header argument
18782 By default a newline separates each noweb reference concatenation.  To
18783 change this newline separator, edit the @samp{noweb-sep} header argument.
18785 Eventually, Org can include the results of a code block rather than
18786 its body.  To that effect, append parentheses, possibly including
18787 arguments, to the code block name, as shown below.
18789 @example
18790 <<code-block-name(optional arguments)>>
18791 @end example
18793 Note that when using the above approach to a code block's results, the
18794 code block name set by @samp{NAME} keyword is required; the reference set
18795 by @samp{noweb-ref} does not work in that case.
18797 Here is an example that demonstrates how the exported content changes
18798 when Noweb style references are used with parentheses versus without.
18799 With:
18801 @example
18802 #+NAME: some-code
18803 #+BEGIN_SRC python :var num=0 :results output :exports none
18804   print(num*10)
18805 #+END_SRC
18806 @end example
18808 @noindent
18809 this code block:
18811 @example
18812 #+BEGIN_SRC text :noweb yes
18813   <<some-code>>
18814 #+END_SRC
18815 @end example
18817 @noindent
18818 expands to:
18820 @example
18821 print(num*10)
18822 @end example
18824 Below, a similar Noweb style reference is used, but with parentheses,
18825 while setting a variable @samp{num} to 10:
18827 @example
18828 #+BEGIN_SRC text :noweb yes
18829   <<some-code(num=10)>>
18830 #+END_SRC
18831 @end example
18833 @noindent
18834 Note that now the expansion contains the results of the code block
18835 @samp{some-code}, not the code block itself:
18837 @example
18839 @end example
18841 @node Library of Babel
18842 @section Library of Babel
18844 @cindex babel, library of
18845 @cindex source code, library
18846 @cindex code block, library
18848 The ``Library of Babel'' is a collection of code blocks.  Like
18849 a function library, these code blocks can be called from other Org
18850 files.  A collection of useful code blocks is available on @uref{https://orgmode.org/worg/library-of-babel.html, Worg}.  For
18851 remote code block evaluation syntax, see @ref{Evaluating Code Blocks}.
18853 @kindex C-c C-v i
18854 @findex org-babel-lob-ingest
18855 For any user to add code to the library, first save the code in
18856 regular code blocks of an Org file, and then load the Org file with
18857 @code{org-babel-lob-ingest}, which is bound to @kbd{C-c C-v i}.
18859 @node Key bindings and Useful Functions
18860 @section Key bindings and Useful Functions
18862 @cindex code block, key bindings
18864 Many common Org mode key sequences are re-bound depending on
18865 the context.
18867 Active key bindings in code blocks:
18869 @kindex C-c C-c
18870 @findex org-babel-execute-src-block
18871 @kindex C-c C-o
18872 @findex org-babel-open-src-block-result
18873 @kindex M-UP
18874 @findex org-babel-load-in-session
18875 @kindex M-DOWN
18876 @findex org-babel-pop-to-session
18877 @multitable @columnfractions 0.2 0.55
18878 @headitem Key binding
18879 @tab Function
18880 @item @kbd{C-c C-c}
18881 @tab @code{org-babel-execute-src-block}
18882 @item @kbd{C-c C-o}
18883 @tab @code{org-babel-open-src-block-result}
18884 @item @kbd{M-@key{UP}}
18885 @tab @code{org-babel-load-in-session}
18886 @item @kbd{M-@key{DOWN}}
18887 @tab @code{org-babel-pop-to-session}
18888 @end multitable
18890 Active key bindings in Org mode buffer:
18892 @kindex C-c C-v p
18893 @kindex C-c C-v C-p
18894 @kindex C-c C-v n
18895 @kindex C-c C-v C-n
18896 @kindex C-c C-v e
18897 @kindex C-c C-v C-e
18898 @kindex C-c C-v o
18899 @kindex C-c C-v C-o
18900 @kindex C-c C-v v
18901 @kindex C-c C-v C-v
18902 @kindex C-c C-v u
18903 @kindex C-c C-v C-u
18904 @kindex C-c C-v g
18905 @kindex C-c C-v C-g
18906 @kindex C-c C-v r
18907 @kindex C-c C-v C-r
18908 @kindex C-c C-v b
18909 @kindex C-c C-v C-b
18910 @kindex C-c C-v s
18911 @kindex C-c C-v C-s
18912 @kindex C-c C-v d
18913 @kindex C-c C-v C-d
18914 @kindex C-c C-v t
18915 @kindex C-c C-v C-t
18916 @kindex C-c C-v f
18917 @kindex C-c C-v C-f
18918 @kindex C-c C-v c
18919 @kindex C-c C-v C-c
18920 @kindex C-c C-v j
18921 @kindex C-c C-v C-j
18922 @kindex C-c C-v l
18923 @kindex C-c C-v C-l
18924 @kindex C-c C-v i
18925 @kindex C-c C-v C-i
18926 @kindex C-c C-v I
18927 @kindex C-c C-v C-I
18928 @kindex C-c C-v z
18929 @kindex C-c C-v C-z
18930 @kindex C-c C-v a
18931 @kindex C-c C-v C-a
18932 @kindex C-c C-v h
18933 @kindex C-c C-v C-h
18934 @kindex C-c C-v x
18935 @kindex C-c C-v C-x
18936 @findex org-babel-previous-src-block
18937 @findex org-babel-next-src-block
18938 @findex org-babel-execute-maybe
18939 @findex org-babel-open-src-block-result
18940 @findex org-babel-expand-src-block
18941 @findex org-babel-goto-src-block-head
18942 @findex org-babel-goto-named-src-block
18943 @findex org-babel-goto-named-result
18944 @findex org-babel-execute-buffer
18945 @findex org-babel-execute-subtree
18946 @findex org-babel-demarcate-block
18947 @findex org-babel-tangle
18948 @findex org-babel-tangle-file
18949 @findex org-babel-check-src-block
18950 @findex org-babel-insert-header-arg
18951 @findex org-babel-load-in-session
18952 @findex org-babel-lob-ingest
18953 @findex org-babel-view-src-block-info
18954 @findex org-babel-switch-to-session-with-code
18955 @findex org-babel-sha1-hash
18956 @findex org-babel-describe-bindings
18957 @findex org-babel-do-key-sequence-in-edit-buffer
18958 @multitable @columnfractions 0.45 0.55
18959 @headitem Key binding
18960 @tab Function
18961 @item @kbd{C-c C-v p} or @kbd{C-c C-v C-p}
18962 @tab @code{org-babel-previous-src-block}
18963 @item @kbd{C-c C-v n} or @kbd{C-c C-v C-n}
18964 @tab @code{org-babel-next-src-block}
18965 @item @kbd{C-c C-v e} or @kbd{C-c C-v C-e}
18966 @tab @code{org-babel-execute-maybe}
18967 @item @kbd{C-c C-v o} or @kbd{C-c C-v C-o}
18968 @tab @code{org-babel-open-src-block-result}
18969 @item @kbd{C-c C-v v} or @kbd{C-c C-v C-v}
18970 @tab @code{org-babel-expand-src-block}
18971 @item @kbd{C-c C-v u} or @kbd{C-c C-v C-u}
18972 @tab @code{org-babel-goto-src-block-head}
18973 @item @kbd{C-c C-v g} or @kbd{C-c C-v C-g}
18974 @tab @code{org-babel-goto-named-src-block}
18975 @item @kbd{C-c C-v r} or @kbd{C-c C-v C-r}
18976 @tab @code{org-babel-goto-named-result}
18977 @item @kbd{C-c C-v b} or @kbd{C-c C-v C-b}
18978 @tab @code{org-babel-execute-buffer}
18979 @item @kbd{C-c C-v s} or @kbd{C-c C-v C-s}
18980 @tab @code{org-babel-execute-subtree}
18981 @item @kbd{C-c C-v d} or @kbd{C-c C-v C-d}
18982 @tab @code{org-babel-demarcate-block}
18983 @item @kbd{C-c C-v t} or @kbd{C-c C-v C-t}
18984 @tab @code{org-babel-tangle}
18985 @item @kbd{C-c C-v f} or @kbd{C-c C-v C-f}
18986 @tab @code{org-babel-tangle-file}
18987 @item @kbd{C-c C-v c} or @kbd{C-c C-v C-c}
18988 @tab @code{org-babel-check-src-block}
18989 @item @kbd{C-c C-v j} or @kbd{C-c C-v C-j}
18990 @tab @code{org-babel-insert-header-arg}
18991 @item @kbd{C-c C-v l} or @kbd{C-c C-v C-l}
18992 @tab @code{org-babel-load-in-session}
18993 @item @kbd{C-c C-v i} or @kbd{C-c C-v C-i}
18994 @tab @code{org-babel-lob-ingest}
18995 @item @kbd{C-c C-v I} or @kbd{C-c C-v C-I}
18996 @tab @code{org-babel-view-src-block-info}
18997 @item @kbd{C-c C-v z} or @kbd{C-c C-v C-z}
18998 @tab @code{org-babel-switch-to-session-with-code}
18999 @item @kbd{C-c C-v a} or @kbd{C-c C-v C-a}
19000 @tab @code{org-babel-sha1-hash}
19001 @item @kbd{C-c C-v h} or @kbd{C-c C-v C-h}
19002 @tab @code{org-babel-describe-bindings}
19003 @item @kbd{C-c C-v x} or @kbd{C-c C-v C-x}
19004 @tab @code{org-babel-do-key-sequence-in-edit-buffer}
19005 @end multitable
19007 @node Batch Execution
19008 @section Batch Execution
19010 @cindex code block, batch execution
19011 @cindex source code, batch execution
19013 Org mode features, including working with source code facilities can
19014 be invoked from the command line.  This enables building shell scripts
19015 for batch processing, running automated system tasks, and expanding
19016 Org mode's usefulness.
19018 The sample script shows batch processing of multiple files using
19019 @code{org-babel-tangle}.
19021 @example
19022 #!/bin/sh
19023 # Tangle files with Org mode
19025 emacs -Q --batch --eval "
19026     (progn
19027       (require 'ob-tangle)
19028       (dolist (file command-line-args-left)
19029         (with-current-buffer (find-file-noselect file)
19030           (org-babel-tangle))))
19031   " "$@@"
19032 @end example
19034 @node Miscellaneous
19035 @chapter Miscellaneous
19037 @menu
19038 * Completion::                   M-@key{TAB} guesses completions.
19039 * Structure Templates::          Quick insertion of structural elements.
19040 * Speed Keys::                   Electric commands at the beginning of a headline.
19041 * Code Evaluation Security::     Org files evaluate in-line code.
19042 * Customization::                Adapting Org to your taste.
19043 * In-buffer Settings::           Overview of keywords.
19044 * The Very Busy @kbd{C-c C-c} Key:: When in doubt, press @kbd{C-c C-c}.
19045 * Clean View::                   Getting rid of leading stars in the outline.
19046 * TTY Keys::                     Using Org on a tty.
19047 * Interaction::                  With other Emacs packages.
19048 * Org Crypt::                    Encrypting Org files.
19049 @end menu
19051 @node Completion
19052 @section Completion
19054 @cindex completion, of @TeX{} symbols
19055 @cindex completion, of TODO keywords
19056 @cindex completion, of dictionary words
19057 @cindex completion, of option keywords
19058 @cindex completion, of tags
19059 @cindex completion, of property keys
19060 @cindex completion, of link abbreviations
19061 @cindex @TeX{} symbol completion
19062 @cindex TODO keywords completion
19063 @cindex dictionary word completion
19064 @cindex option keyword completion
19065 @cindex tag completion
19066 @cindex link abbreviations, completion of
19068 Org has in-buffer completions.  Unlike minibuffer completions, which
19069 are useful for quick command interactions, Org's in-buffer completions
19070 are more suitable for content creation in Org documents.  Type one or
19071 more letters and invoke the hot key to complete the text in-place.
19072 Depending on the context and the keys, Org offers different types of
19073 completions.  No minibuffer is involved.  Such mode-specific hot keys
19074 have become an integral part of Emacs and Org provides several
19075 shortcuts.
19077 @table @asis
19078 @item @kbd{M-@key{TAB}}
19079 @kindex M-TAB
19081 Complete word at point.
19083 @itemize
19084 @item
19085 At the beginning of a headline, complete TODO keywords.
19087 @item
19088 After @samp{\}, complete @TeX{} symbols supported by the exporter.
19090 @item
19091 After @samp{*}, complete headlines in the current buffer so that
19092 they can be used in search links like:
19094 @example
19095 [[*find this headline]]
19096 @end example
19098 @item
19099 After @samp{:} in a headline, complete tags.  Org deduces the list
19100 of tags from the @samp{TAGS} in-buffer option (see @ref{Setting Tags}),
19101 the variable @code{org-tag-alist}, or from all tags used in the
19102 current buffer.
19104 @item
19105 After @samp{:} and not in a headline, complete property keys.  The
19106 list of keys is constructed dynamically from all keys used in
19107 the current buffer.
19109 @item
19110 After @samp{[}, complete link abbreviations (see @ref{Link Abbreviations}).
19112 @item
19113 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
19114 file-specific @samp{OPTIONS}.  After option keyword is complete,
19115 pressing @kbd{M-@key{TAB}} again inserts example settings for
19116 this keyword.
19118 @item
19119 After @samp{STARTUP} keyword, complete startup items.
19121 @item
19122 When point is anywhere else, complete dictionary words using
19123 Ispell.
19124 @end itemize
19125 @end table
19127 @node Structure Templates
19128 @section Structure Templates
19130 @cindex template insertion
19131 @cindex insertion, of templates
19133 With just a few keystrokes, it is possible to insert empty structural
19134 blocks, such as @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}, or to wrap existing
19135 text in such a block.
19137 @table @asis
19138 @item @kbd{C-c C-x w} (@code{org-insert-structure-template})
19139 Prompt for a type of block structure, and insert the block at
19140 point.  If the region is active, it is wrapped in the block.
19141 First prompts the user for a key, which is used to look up
19142 a structure type from the values below.  If the key is
19143 @kbd{@key{TAB}}, the user is prompted to enter a type.
19144 @end table
19146 @vindex org-structure-template-alist
19147 Available structure types are defined in
19148 @code{org-structure-template-alist}, see the docstring for adding or
19149 changing values.
19151 @cindex Tempo
19152 @cindex template expansion
19153 @cindex insertion, of templates
19154 @vindex org-tempo-keywords-alist
19155 @vindex org-structure-template-alist
19156 Org Tempo expands snippets to structures defined in
19157 @code{org-structure-template-alist} and @code{org-tempo-keywords-alist}.  For
19158 example, @kbd{< s @key{TAB}} creates a code block.  Enable it by
19159 customizing @code{org-modules} or add @code{(require 'org-tempo)} to your Emacs
19160 init file@footnote{For more information, please refer to the commentary section
19161 in @samp{org-tempo.el}.}.
19164 @multitable @columnfractions 0.1 0.9
19165 @item @kbd{a}
19166 @tab @samp{#+BEGIN_EXPORT ascii} @dots{} @samp{#+END_EXPORT}
19167 @item @kbd{c}
19168 @tab @samp{#+BEGIN_CENTER} @dots{} @samp{#+END_CENTER}
19169 @item @kbd{C}
19170 @tab @samp{#+BEGIN_COMMENT} @dots{} @samp{#+END_COMMENT}
19171 @item @kbd{e}
19172 @tab @samp{#+BEGIN_EXAMPLE} @dots{} @samp{#+END_EXAMPLE}
19173 @item @kbd{h}
19174 @tab @samp{#+BEGIN_EXPORT html} @dots{} @samp{#+END_EXPORT}
19175 @item @kbd{l}
19176 @tab @samp{#+BEGIN_EXPORT latex} @dots{} @samp{#+END_EXPORT}
19177 @item @kbd{q}
19178 @tab @samp{#+BEGIN_QUOTE} @dots{} @samp{#+END_QUOTE}
19179 @item @kbd{s}
19180 @tab @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}
19181 @item @kbd{v}
19182 @tab @samp{#+BEGIN_VERSE} @dots{} @samp{#+END_VERSE}
19183 @end multitable
19185 @node Speed Keys
19186 @section Speed Keys
19188 @cindex speed keys
19190 Single keystrokes can execute custom commands in an Org file when the
19191 cursor is on a headline.  Without the extra burden of a meta or
19192 modifier key, Speed Keys can speed navigation or execute custom
19193 commands.  Besides faster navigation, Speed Keys may come in handy on
19194 small mobile devices that do not have full keyboards.  Speed Keys may
19195 also work on TTY devices known for their problems when entering Emacs
19196 key chords.
19198 @vindex org-use-speed-commands
19199 By default, Org has Speed Keys disabled.  To activate Speed Keys, set
19200 the variable @code{org-use-speed-commands} to a non-@code{nil} value.  To
19201 trigger a Speed Key, the cursor must be at the beginning of an Org
19202 headline, before any of the stars.
19204 @vindex org-speed-commands-user
19205 @findex org-speed-command-help
19206 Org comes with a pre-defined list of Speed Keys.  To add or modify
19207 Speed Keys, customize the variable, @code{org-speed-commands-user}.  For
19208 more details, see the variable's docstring.  With Speed Keys
19209 activated, @kbd{M-x org-speed-command-help}, or @kbd{?} when
19210 cursor is at the beginning of an Org headline, shows currently active
19211 Speed Keys, including the user-defined ones.
19213 @node Code Evaluation Security
19214 @section Code Evaluation and Security Issues
19216 Unlike plain text, running code comes with risk.  Each @samp{src} code
19217 block, in terms of risk, is equivalent to an executable file.  Org
19218 therefore puts a few confirmation prompts by default.  This is to
19219 alert the casual user from accidentally running untrusted code.
19221 For users who do not run code blocks or write code regularly, Org's
19222 default settings should suffice.  However, some users may want to
19223 tweak the prompts for fewer interruptions.  To weigh the risks of
19224 automatic execution of code blocks, here are some details about code
19225 evaluation.
19227 Org evaluates code in the following circumstances:
19229 @table @asis
19230 @item @emph{Source code blocks}
19231 Org evaluates @samp{src} code blocks in an Org file during export.
19232 Org also evaluates a @samp{src} code block with the @kbd{C-c C-c}
19233 key chord.  Users exporting or running code blocks must load
19234 files only from trusted sources.  Be wary of customizing
19235 variables that remove or alter default security measures.
19237 @defopt org-confirm-babel-evaluate
19238 When @code{t}, Org prompts the user for confirmation before executing
19239 each code block.  When @code{nil}, Org executes code blocks without
19240 prompting the user for confirmation.  When this option is set to
19241 a custom function, Org invokes the function with these two
19242 arguments: the source code language and the body of the code
19243 block.  The custom function must return either a @code{t} or @code{nil},
19244 which determines if the user is prompted.  Each source code
19245 language can be handled separately through this function
19246 argument.
19247 @end defopt
19249 For example, here is how to execute ditaa code blocks without
19250 prompting:
19252 @lisp
19253 (defun my-org-confirm-babel-evaluate (lang body)
19254   (not (string= lang "ditaa")))  ;don't ask for ditaa
19255 (setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
19256 @end lisp
19258 @item @emph{Following @samp{shell} and @samp{elisp} links}
19259 Org has two link types that can directly evaluate code (see
19260 @ref{External Links}).  Because such code is not visible, these links
19261 have a potential risk.  Org therefore prompts the user when it
19262 encounters such links.  The customization variables are:
19264 @defopt org-confirm-shell-link-function
19265 Function that prompts the user before executing a shell link.
19266 @end defopt
19268 @defopt org-confirm-elisp-link-function
19269 Function that prompts the user before executing an Emacs Lisp link.
19270 @end defopt
19272 @item @emph{Formulas in tables}
19273 Formulas in tables (see @ref{The spreadsheet}) are code that is
19274 evaluated either by the Calc interpreter, or by the Emacs Lisp
19275 interpreter.
19276 @end table
19278 @node Customization
19279 @section Customization
19281 @cindex customization
19282 @cindex options, for customization
19283 @cindex variables, for customization
19285 Org has more than 500 variables for customization.  They can be
19286 accessed through the usual @kbd{M-x org-customize} command.  Or
19287 through the Org menu: Org @arrow{} Customization @arrow{} Browse Org Group.
19289 Org also has per-file settings for some variables (see @ref{In-buffer Settings}).
19291 @node In-buffer Settings
19292 @section Summary of In-Buffer Settings
19294 @cindex in-buffer settings
19295 @cindex special keywords
19297 In-buffer settings start with @samp{#+}, followed by a keyword, a colon,
19298 and then a word for each setting.  Org accepts multiple settings on
19299 the same line.  Org also accepts multiple lines for a keyword.  This
19300 manual describes these settings throughout.  A summary follows here.
19302 @cindex refresh set-up
19303 @kbd{C-c C-c} activates any changes to the in-buffer settings.
19304 Closing and reopening the Org file in Emacs also activates the
19305 changes.
19307 @table @asis
19308 @item @samp{#+ARCHIVE: %s_done}
19309 @cindex @samp{ARCHIVE}, keyword
19310 @vindex org-archive-location
19311 Sets the archive location of the agenda file.  The corresponding
19312 variable is @code{org-archive-location}.
19314 @item @samp{#+CATEGORY}
19315 @cindex @samp{CATEGORY}, keyword
19316 Sets the category of the agenda file, which applies to the entire
19317 document.
19319 @item @samp{#+COLUMNS: %25ITEM ...}
19320 @cindex @samp{COLUMNS}, property
19321 Set the default format for columns view.  This format applies
19322 when columns view is invoked in locations where no @samp{COLUMNS}
19323 property applies.
19325 @item @samp{#+CONSTANTS: name1=value1 ...}
19326 @cindex @samp{CONSTANTS}, keyword
19327 @vindex org-table-formula-constants
19328 @vindex org-table-formula
19329 Set file-local values for constants that table formulas can use.
19330 This line sets the local variable
19331 @code{org-table-formula-constants-local}.  The global version of this
19332 variable is @code{org-table-formula-constants}.
19334 @item @samp{#+FILETAGS: :tag1:tag2:tag3:}
19335 @cindex @samp{FILETAGS}, keyword
19336 Set tags that all entries in the file inherit from, including the
19337 top-level entries.
19339 @item @samp{#+LINK: linkword replace}
19340 @cindex @samp{LINK}, keyword
19341 @vindex org-link-abbrev-alist
19342 Each line specifies one abbreviation for one link.  Use multiple
19343 @samp{LINK} keywords for more, see @ref{Link Abbreviations}.  The
19344 corresponding variable is @code{org-link-abbrev-alist}.
19346 @item @samp{#+PRIORITIES: highest lowest default}
19347 @cindex @samp{PRIORITIES}, keyword
19348 @vindex org-highest-priority
19349 @vindex org-lowest-priority
19350 @vindex org-default-priority
19351 This line sets the limits and the default for the priorities.
19352 All three must be either letters A--Z or numbers 0--9.  The
19353 highest priority must have a lower ASCII number than the lowest
19354 priority.
19356 @item @samp{#+PROPERTY: Property_Name Value}
19357 @cindex @samp{PROPERTY}, keyword
19358 This line sets a default inheritance value for entries in the
19359 current buffer, most useful for specifying the allowed values of
19360 a property.
19362 @item @samp{#+SETUPFILE: file}
19363 @cindex @samp{SETUPFILE}, keyword
19364 The setup file or a URL pointing to such file is for additional
19365 in-buffer settings.  Org loads this file and parses it for any
19366 settings in it only when Org opens the main file.  If URL is
19367 specified, the contents are downloaded and stored in a temporary
19368 file cache.  @kbd{C-c C-c} on the settings line parses and
19369 loads the file, and also resets the temporary file cache.  Org
19370 also parses and loads the document during normal exporting
19371 process.  Org parses the contents of this document as if it was
19372 included in the buffer.  It can be another Org file.  To visit
19373 the file---not a URL---use @kbd{C-c '} while the cursor is
19374 on the line with the file name.
19376 @item @samp{#+STARTUP:}
19377 @cindex @samp{STARTUP}, keyword
19378 Startup options Org uses when first visiting a file.
19380 @vindex org-startup-folded
19381 The first set of options deals with the initial visibility of the
19382 outline tree.  The corresponding variable for global default
19383 settings is @code{org-startup-folded} with a default value of @code{t},
19384 which is the same as @code{overview}.
19386 @table @asis
19387 @item @samp{overview}
19388 Top-level headlines only.
19390 @item @samp{content}
19391 All headlines.
19393 @item @samp{showall}
19394 No folding on any entry.
19396 @item @samp{showeverything}
19397 Show even drawer contents.
19398 @end table
19400 @vindex org-startup-indented
19401 Dynamic virtual indentation is controlled by the variable
19402 @code{org-startup-indented}.@footnote{Note that @code{org-indent-mode} also sets the @code{wrap-prefix}
19403 property, such that @code{visual-line-mode} (or purely setting @code{word-wrap})
19404 wraps long lines (including headlines) correctly indented.}
19406 @table @asis
19407 @item @samp{indent}
19408 Start with @code{org-indent-mode} turned on.
19410 @item @samp{noindent}
19411 Start with @code{org-indent-mode} turned off.
19412 @end table
19414 @vindex org-startup-align-all-tables
19415 Aligns tables consistently upon visiting a file.  The corresponding
19416 variable is @code{org-startup-align-all-tables} with @code{nil} as default
19417 value.
19419 @table @asis
19420 @item @samp{align}
19421 Align all tables.
19423 @item @samp{noalign}
19424 Do not align tables on startup.
19425 @end table
19427 @vindex org-startup-shrink-all-tables
19428 Shrink table columns with a width cookie.  The corresponding
19429 variable is @code{org-startup-shrink-all-tables} with @code{nil} as default
19430 value.
19432 @vindex org-startup-with-inline-images
19433 When visiting a file, inline images can be automatically displayed.
19434 The corresponding variable is @code{org-startup-with-inline-images},
19435 with a default value @code{nil} to avoid delays when visiting a file.
19437 @table @asis
19438 @item @samp{inlineimages}
19439 Show inline images.
19441 @item @samp{noinlineimages}
19442 Do not show inline images on startup.
19443 @end table
19445 @vindex org-log-done
19446 @vindex org-log-note-clock-out
19447 @vindex org-log-repeat
19448 Logging the closing and reopening of TODO items and clock
19449 intervals can be configured using these options (see variables
19450 @code{org-log-done}, @code{org-log-note-clock-out}, and @code{org-log-repeat}).
19452 @table @asis
19453 @item @samp{logdone}
19454 Record a timestamp when an item is marked DONE.
19456 @item @samp{lognotedone}
19457 Record timestamp and a note when DONE.
19459 @item @samp{nologdone}
19460 Do not record when items are marked DONE.
19462 @item @samp{logrepeat}
19463 Record a time when reinstating a repeating item.
19465 @item @samp{lognoterepeat}
19466 Record a note when reinstating a repeating item.
19468 @item @samp{nologrepeat}
19469 Do not record when reinstating repeating item.
19471 @item @samp{lognoteclock-out}
19472 Record a note when clocking out.
19474 @item @samp{nolognoteclock-out}
19475 Do not record a note when clocking out.
19477 @item @samp{logreschedule}
19478 Record a timestamp when scheduling time changes.
19480 @item @samp{lognotereschedule}
19481 Record a note when scheduling time changes.
19483 @item @samp{nologreschedule}
19484 Do not record when a scheduling date changes.
19486 @item @samp{logredeadline}
19487 Record a timestamp when deadline changes.
19489 @item @samp{lognoteredeadline}
19490 Record a note when deadline changes.
19492 @item @samp{nologredeadline}
19493 Do not record when a deadline date changes.
19495 @item @samp{logrefile}
19496 Record a timestamp when refiling.
19498 @item @samp{lognoterefile}
19499 Record a note when refiling.
19501 @item @samp{nologrefile}
19502 Do not record when refiling.
19503 @end table
19505 @vindex org-hide-leading-stars
19506 @vindex org-odd-levels-only
19507 Here are the options for hiding leading stars in outline headings,
19508 and for indenting outlines.  The corresponding variables are
19509 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with
19510 a default setting @code{nil} (meaning @samp{showstars} and @samp{oddeven}).
19512 @table @asis
19513 @item @samp{hidestars}
19514 Make all but one of the stars starting a headline invisible.
19516 @item @samp{showstars}
19517 Show all stars starting a headline.
19519 @item @samp{indent}
19520 Virtual indentation according to outline level.
19522 @item @samp{noindent}
19523 No virtual indentation according to outline level.
19525 @item @samp{odd}
19526 Allow only odd outline levels (1, 3, @dots{}).
19528 @item @samp{oddeven}
19529 Allow all outline levels.
19530 @end table
19532 @vindex org-put-time-stamp-overlays
19533 @vindex org-time-stamp-overlay-formats
19534 To turn on custom format overlays over timestamps (variables
19535 @code{org-put-time-stamp-overlays} and @code{org-time-stamp-overlay-formats}),
19536 use:
19538 @table @asis
19539 @item @samp{customtime}
19540 Overlay custom time format.
19541 @end table
19543 @vindex constants-unit-system
19544 The following options influence the table spreadsheet (variable
19545 @code{constants-unit-system}).
19547 @table @asis
19548 @item @samp{constcgs}
19549 @samp{constants.el} should use the c-g-s unit system.
19551 @item @samp{constSI}
19552 @samp{constants.el} should use the SI unit system.
19553 @end table
19555 @vindex org-footnote-define-inline
19556 @vindex org-footnote-auto-label
19557 @vindex org-footnote-auto-adjust
19558 To influence footnote settings, use the following keywords.  The
19559 corresponding variables are @code{org-footnote-define-inline},
19560 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
19562 @table @asis
19563 @item @samp{fninline}
19564 Define footnotes inline.
19566 @item @samp{fnnoinline}
19567 Define footnotes in separate section.
19569 @item @samp{fnlocal}
19570 Define footnotes near first reference, but not inline.
19572 @item @samp{fnprompt}
19573 Prompt for footnote labels.
19575 @item @samp{fnauto}
19576 Create @samp{[fn:1]}-like labels automatically (default).
19578 @item @samp{fnconfirm}
19579 Offer automatic label for editing or confirmation.
19581 @item @samp{fnadjust}
19582 Automatically renumber and sort footnotes.
19584 @item @samp{nofnadjust}
19585 Do not renumber and sort automatically.
19586 @end table
19588 @vindex org-hide-block-startup
19589 To hide blocks on startup, use these keywords.  The corresponding
19590 variable is @code{org-hide-block-startup}.
19592 @table @asis
19593 @item @samp{hideblocks}
19594 Hide all begin/end blocks on startup.
19596 @item @samp{nohideblocks}
19597 Do not hide blocks on startup.
19598 @end table
19600 @vindex org-pretty-entities
19601 The display of entities as UTF-8 characters is governed by the
19602 variable @code{org-pretty-entities} and the keywords
19604 @table @asis
19605 @item @samp{entitiespretty}
19606 Show entities as UTF-8 characters where possible.
19608 @item @samp{entitiesplain}
19609 Leave entities plain.
19610 @end table
19612 @item @samp{#+TAGS: TAG1(c1) TAG2(c2)}
19613 @cindex @samp{TAGS}, keyword
19614 @vindex org-tag-alist
19615 These lines (several such lines are allowed) specify the valid
19616 tags in this file, and (potentially) the corresponding @emph{fast tag
19617 selection} keys.  The corresponding variable is @code{org-tag-alist}.
19619 @item @samp{#+TODO:}
19620 @itemx @samp{#+SEQ_TODO:}
19621 @itemx @samp{#+TYP_TODO:}
19622 @cindex @samp{SEQ_TODO}, keyword
19623 @cindex @samp{TODO}, keyword
19624 @cindex @samp{TYP_TODO}, keyword
19625 @vindex org-todo-keywords
19626 These lines set the TODO keywords and their interpretation in the
19627 current file.  The corresponding variable is @code{org-todo-keywords}.
19628 @end table
19630 @node The Very Busy @kbd{C-c C-c} Key
19631 @section The Very Busy @kbd{C-c C-c} Key
19633 @kindex C-c C-c
19634 @cindex @kbd{C-c C-c}, overview
19636 The @kbd{C-c C-c} key in Org serves many purposes depending on
19637 the context.  It is probably the most over-worked, multi-purpose key
19638 combination in Org.  Its uses are well documented throughout this
19639 manual, but here is a consolidated list for easy reference.
19641 @itemize
19642 @item
19643 If any highlights shown in the buffer from the creation of a sparse
19644 tree, or from clock display, remove such highlights.
19646 @item
19647 If the cursor is in one of the special @samp{KEYWORD} lines, scan the
19648 buffer for these lines and update the information.  Also reset the
19649 Org file cache used to temporary store the contents of URLs used as
19650 values for keywords like @samp{SETUPFILE}.
19652 @item
19653 If the cursor is inside a table, realign the table.  The table
19654 realigns even if automatic table editor is turned off.
19656 @item
19657 If the cursor is on a @samp{TBLFM} keyword, re-apply the formulas to the
19658 entire table.
19660 @item
19661 If the current buffer is a capture buffer, close the note and file
19662 it.  With a prefix argument, also jump to the target location after
19663 saving the note.
19665 @item
19666 If the cursor is on a @samp{<<<target>>>}, update radio targets and
19667 corresponding links in this buffer.
19669 @item
19670 If the cursor is on a property line or at the start or end of
19671 a property drawer, offer property commands.
19673 @item
19674 If the cursor is at a footnote reference, go to the corresponding
19675 definition, and @emph{vice versa}.
19677 @item
19678 If the cursor is on a statistics cookie, update it.
19680 @item
19681 If the cursor is in a plain list item with a checkbox, toggle the
19682 status of the checkbox.
19684 @item
19685 If the cursor is on a numbered item in a plain list, renumber the
19686 ordered list.
19688 @item
19689 If the cursor is on the @samp{#+BEGIN} line of a dynamic block, the block
19690 is updated.
19692 @item
19693 If the cursor is at a timestamp, fix the day name in the timestamp.
19694 @end itemize
19696 @node Clean View
19697 @section A Cleaner Outline View
19699 @cindex hiding leading stars
19700 @cindex dynamic indentation
19701 @cindex odd-levels-only outlines
19702 @cindex clean outline view
19704 Org's default outline with stars and no indents can become too
19705 cluttered for short documents.  For @emph{book-like} long documents, the
19706 effect is not as noticeable.  Org provides an alternate stars and
19707 indentation scheme, as shown on the right in the following table.  It
19708 uses only one star and indents text to line with the heading:
19710 @example
19711 * Top level headline             |    * Top level headline
19712 ** Second level                  |      * Second level
19713 *** Third level                  |        * Third level
19714     some text                    |          some text
19715 *** Third level                  |        * Third level
19716     more text                    |          more text
19717 * Another top level headline     |    * Another top level headline
19718 @end example
19720 @noindent
19721 @cindex Indent mode
19722 @findex org-indent-mode
19723 To turn this mode on, use the minor mode, @code{org-indent-mode}.  Text
19724 lines that are not headlines are prefixed with spaces to vertically
19725 align with the headline text@footnote{The @code{org-indent-mode} also sets the @code{wrap-prefix} correctly
19726 for indenting and wrapping long lines of headlines or text.  This
19727 minor mode handles @code{visual-line-mode} and directly applied settings
19728 through @code{word-wrap}.}.
19730 @vindex org-indent-indentation-per-level
19731 To make more horizontal space, the headlines are shifted by two stars.
19732 This can be configured by the @code{org-indent-indentation-per-level}
19733 variable.  Only one star on each headline is visible, the rest are
19734 masked with the same font color as the background.
19736 Note that turning on @code{org-indent-mode} sets @code{org-hide-leading-stars}
19737 to @code{t} and @code{org-adapt-indentation} to @code{nil}.
19739 @vindex org-startup-indented
19740 To globally turn on @code{org-indent-mode} for all files, customize the
19741 variable @code{org-startup-indented}.
19743 To turn on indenting for individual files, use @samp{STARTUP} keyword as
19744 follows:
19746 @example
19747 #+STARTUP: indent
19748 @end example
19750 Indent on startup makes Org use hard spaces to align text with
19751 headings as shown in examples below.
19753 @table @asis
19754 @item @emph{Indentation of text below headlines}
19755 Indent text to align with the headline.
19757 @example
19758 *** Third level
19759     more text, now indented
19760 @end example
19762 @vindex org-adapt-indentation
19763 Org supports this with paragraph filling, line wrapping, and
19764 structure editing, preserving or adapting the indentation as
19765 appropriate@footnote{Also see the variable @code{org-adapt-indentation}.}.
19767 @item @emph{Hiding leading stars}
19768 @vindex org-hide-leading-stars
19769 Org can make leading stars invisible.  For global preference,
19770 configure the variable @code{org-hide-leading-stars}.  For per-file
19771 preference, use these file @samp{STARTUP} options:
19773 @example
19774 #+STARTUP: hidestars
19775 #+STARTUP: showstars
19776 @end example
19778 With stars hidden, the tree is shown as:
19780 @example
19781 * Top level headline
19782  * Second level
19783   * Third level
19784   ...
19785 @end example
19787 @noindent
19788 @vindex org-hide, face
19789 Because Org makes the font color the same as the background color
19790 to hide to stars, sometimes @code{org-hide} face may need tweaking to
19791 get the effect right.  For some black and white combinations,
19792 @code{grey90} on a white background might mask the stars better.
19794 @item @emph{Odd levels}
19795 @vindex org-odd-levels-only
19796 Using stars for only odd levels, 1, 3, 5, @dots{}, can also clean up
19797 the clutter.  This removes two stars from each level@footnote{Because @samp{LEVEL=2} has 3 stars, @samp{LEVEL=3} has 4 stars, and so
19798 on.}.
19799 For Org to properly handle this cleaner structure during edits
19800 and exports, configure the variable @code{org-odd-levels-only}.  To
19801 set this per-file, use either one of the following lines:
19803 @example
19804 #+STARTUP: odd
19805 #+STARTUP: oddeven
19806 @end example
19808 To switch between single and double stars layouts, use @kbd{M-x org-convert-to-odd-levels} and @kbd{M-x org-convert-to-oddeven-levels}.
19809 @end table
19811 @node TTY Keys
19812 @section Using Org on a TTY
19814 @cindex tty key bindings
19816 Org provides alternative key bindings for TTY and modern mobile
19817 devices that cannot handle cursor keys and complex modifier key
19818 chords.  Some of these workarounds may be more cumbersome than
19819 necessary.  Users should look into customizing these further based on
19820 their usage needs.  For example, the normal @kbd{S-<cursor>} for
19821 editing timestamp might be better with @kbd{C-c .} chord.
19823 @multitable @columnfractions 0.2 0.28 0.15 0.21
19824 @headitem Default
19825 @tab Alternative 1
19826 @tab Speed key
19827 @tab Alternative 2
19828 @item @kbd{S-@key{TAB}}
19829 @tab @kbd{C-u @key{TAB}}
19830 @tab @kbd{C}
19831 @tab 
19832 @item @kbd{M-@key{LEFT}}
19833 @tab @kbd{C-c C-x l}
19834 @tab @kbd{l}
19835 @tab @kbd{Esc @key{LEFT}}
19836 @item @kbd{M-S-@key{LEFT}}
19837 @tab @kbd{C-c C-x L}
19838 @tab @kbd{L}
19839 @tab 
19840 @item @kbd{M-@key{RIGHT}}
19841 @tab @kbd{C-c C-x r}
19842 @tab @kbd{r}
19843 @tab @kbd{Esc @key{RIGHT}}
19844 @item @kbd{M-S-@key{RIGHT}}
19845 @tab @kbd{C-c C-x R}
19846 @tab @kbd{R}
19847 @tab 
19848 @item @kbd{M-@key{UP}}
19849 @tab @kbd{C-c C-x u}
19850 @tab 
19851 @tab @kbd{Esc @key{UP}}
19852 @item @kbd{M-S-@key{UP}}
19853 @tab @kbd{C-c C-x U}
19854 @tab @kbd{U}
19855 @tab 
19856 @item @kbd{M-@key{DOWN}}
19857 @tab @kbd{C-c C-x d}
19858 @tab 
19859 @tab @kbd{Esc @key{DOWN}}
19860 @item @kbd{M-S-@key{DOWN}}
19861 @tab @kbd{C-c C-x D}
19862 @tab @kbd{D}
19863 @tab 
19864 @item @kbd{S-@key{RET}}
19865 @tab @kbd{C-c C-x c}
19866 @tab 
19867 @tab 
19868 @item @kbd{M-@key{RET}}
19869 @tab @kbd{C-c C-x m}
19870 @tab 
19871 @tab @kbd{Esc @key{RET}}
19872 @item @kbd{M-S-@key{RET}}
19873 @tab @kbd{C-c C-x M}
19874 @tab 
19875 @tab 
19876 @item @kbd{S-@key{LEFT}}
19877 @tab @kbd{C-c @key{LEFT}}
19878 @tab 
19879 @tab 
19880 @item @kbd{S-@key{RIGHT}}
19881 @tab @kbd{C-c @key{RIGHT}}
19882 @tab 
19883 @tab 
19884 @item @kbd{S-@key{UP}}
19885 @tab @kbd{C-c @key{UP}}
19886 @tab 
19887 @tab 
19888 @item @kbd{S-@key{DOWN}}
19889 @tab @kbd{C-c @key{DOWN}}
19890 @tab 
19891 @tab 
19892 @item @kbd{C-S-@key{LEFT}}
19893 @tab @kbd{C-c C-x @key{LEFT}}
19894 @tab 
19895 @tab 
19896 @item @kbd{C-S-@key{RIGHT}}
19897 @tab @kbd{C-c C-x @key{RIGHT}}
19898 @tab 
19899 @tab 
19900 @end multitable
19902 @node Interaction
19903 @section Interaction with Other Packages
19905 @cindex packages, interaction with other
19907 Org's compatibility and the level of interaction with other Emacs
19908 packages are documented here.
19910 @menu
19911 * Cooperation::                  Packages Org cooperates with.
19912 * Conflicts::                    Packages that lead to conflicts.
19913 @end menu
19915 @node Cooperation
19916 @subsection Packages that Org cooperates with
19918 @table @asis
19919 @item @samp{calc.el} by Dave Gillespie
19920 @cindex @file{calc.el}
19922 Org uses the Calc package for implementing spreadsheet
19923 functionality in its tables (see @ref{The spreadsheet}).  Org also
19924 uses Calc for embedded calculations.  See @ref{Embedded Mode,GNU Emacs Calc Manual,,calc,}.
19926 @item @samp{constants.el} by Carsten Dominik
19927 @cindex @file{constants.el}
19928 @vindex org-table-formula-constants
19930 Org can use names for constants in formulas in tables.  Org can
19931 also use calculation suffixes for units, such as @samp{M} for @samp{Mega}.
19932 For a standard collection of such constants, install the
19933 @samp{constants} package.  Install version 2.0 of this package,
19934 available at @uref{http://www.astro.uva.nl/~dominik/Tools}.  Org checks
19935 if the function @code{constants-get} has been autoloaded.
19936 Installation instructions are in the file @samp{constants.el}.
19938 @item @samp{cdlatex.el} by Carsten Dominik
19939 @cindex @file{cdlatex.el}
19941 Org mode can make use of the CD@LaTeX{} package to efficiently enter
19942 @LaTeX{} fragments into Org files.  See @ref{CD@LaTeX{} mode}.
19944 @item @samp{imenu.el} by Ake Stenhoff and Lars Lindberg
19945 @cindex @file{imenu.el}
19947 Imenu creates dynamic menus based on an index of items in a file.
19948 Org mode supports Imenu menus.  Enable it with a mode hook as
19949 follows:
19951 @lisp
19952 (add-hook 'org-mode-hook
19953           (lambda () (imenu-add-to-menubar "Imenu")))
19954 @end lisp
19956 @vindex org-imenu-depth
19957 By default the index is two levels deep---you can modify the
19958 depth using the option @code{org-imenu-depth}.
19960 @item @samp{speedbar.el} by Eric M. Ludlam
19961 @cindex @file{speedbar.el}
19963 Speedbar package creates a special Emacs frame for displaying
19964 files and index items in files.  Org mode supports Speedbar;
19965 users can drill into Org files directly from the Speedbar.  The
19966 @kbd{<} in the Speedbar frame tweaks the agenda commands to
19967 that file or to a subtree.
19969 @item @samp{table.el} by Takaaki Ota
19970 @cindex table editor, @file{table.el}
19971 @cindex @file{table.el}
19973 Complex ASCII tables with automatic line wrapping, column- and
19974 row-spanning, and alignment can be created using the Emacs table
19975 package by Takaaki Ota.  Org mode recognizes such tables and
19976 exports them properly.  @kbd{C-c '} to edit these tables in
19977 a special buffer, much like Org's code blocks.  Because of
19978 interference with other Org mode functionality, Takaaki Ota
19979 tables cannot be edited directly in the Org buffer.
19981 @table @asis
19982 @item @kbd{C-c '} (@code{org-edit-special})
19983 @kindex C-c '
19984 @findex org-edit-special
19985 Edit a @samp{table.el} table.  Works when the cursor is in
19986 a @samp{table.el} table.
19988 @item @kbd{C-c ~​} (@code{org-table-create-with-table.el})
19989 @kindex C-c ~
19990 @findex org-table-create-with-table.el
19991 Insert a @samp{table.el} table.  If there is already a table at
19992 point, this command converts it between the @samp{table.el}
19993 format and the Org mode format.  See the documentation
19994 string of the command @code{org-convert-table} for the
19995 restrictions under which this is possible.
19996 @end table
19997 @end table
19999 @node Conflicts
20000 @subsection Packages that conflict with Org mode
20002 @cindex shift-selection-mode
20003 @vindex org-support-shift-select
20004 In Emacs, @code{shift-selection-mode} combines cursor motions with shift
20005 key to enlarge regions.  Emacs sets this mode by default.  This
20006 conflicts with Org's use of @kbd{S-<cursor>} commands to change
20007 timestamps, TODO keywords, priorities, and item bullet types, etc.
20008 Since @kbd{S-<cursor>} commands outside of specific contexts do
20009 not do anything, Org offers the variable @code{org-support-shift-select}
20010 for customization.  Org mode accommodates shift selection by (i)
20011 making it available outside of the special contexts where special
20012 commands apply, and (ii) extending an existing active region even if
20013 the cursor moves across a special context.
20015 @table @asis
20016 @item @samp{cua.el} by Kim. F. Storm
20017 @cindex @file{cua.el}
20018 @vindex org-replace-disputed-keys
20019 Org key bindings conflict with @kbd{S-<cursor>} keys used by
20020 CUA mode.  For Org to relinquish these bindings to CUA mode,
20021 configure the variable @code{org-replace-disputed-keys}.  When set,
20022 Org moves the following key bindings in Org files, and in the
20023 agenda buffer---but not during date selection.
20025 @multitable @columnfractions 0.4 0.4
20026 @item @kbd{S-@key{UP}}      @result{}  @kbd{M-p}
20027 @tab @kbd{S-@key{DOWN}}     @result{}  @kbd{M-n}
20028 @item @kbd{S-@key{LEFT}}    @result{}  @kbd{M--}
20029 @tab @kbd{S-@key{RIGHT}}    @result{}  @kbd{M-+}
20030 @item @kbd{C-S-@key{LEFT}}  @result{}  @kbd{M-S--}
20031 @tab @kbd{C-S-@key{RIGHT}}  @result{}  @kbd{M-S-+}
20032 @end multitable
20034 @vindex org-disputed-keys
20035 Yes, these are unfortunately more difficult to remember.  If you
20036 want to have other replacement keys, look at the variable
20037 @code{org-disputed-keys}.
20039 @item @samp{ecomplete.el} by Lars Magne Ingebrigtsen
20040 @cindex @file{ecomplete.el}
20041 Ecomplete provides ``electric'' address completion in address
20042 header lines in message buffers.  Sadly Orgtbl mode cuts
20043 Ecomplete's power supply: no completion happens when Orgtbl mode
20044 is enabled in message buffers while entering text in address
20045 header lines.  If one wants to use ecomplete one should @emph{not}
20046 follow the advice to automagically turn on Orgtbl mode in message
20047 buffers (see @ref{Orgtbl Mode}), but instead---after
20048 filling in the message headers---turn on Orgtbl mode manually
20049 when needed in the messages body.
20051 @item @samp{filladapt.el} by Kyle Jones
20052 @cindex @file{filladapt.el}
20053 Org mode tries to do the right thing when filling paragraphs,
20054 list items and other elements.  Many users reported problems
20055 using both @samp{filladapt.el} and Org mode, so a safe thing to do is
20056 to disable filladapt like this:
20058 @lisp
20059 (add-hook 'org-mode-hook 'turn-off-filladapt-mode)
20060 @end lisp
20062 @item @samp{viper.el} by Michael Kifer
20063 @cindex @file{viper.el}
20064 @kindex C-c /
20066 Viper uses @kbd{C-c /} and therefore makes this key not
20067 access the corresponding Org mode command @code{org-sparse-tree}.  You
20068 need to find another key for this command, or override the key in
20069 @code{viper-vi-global-user-map} with
20071 @lisp
20072 (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
20073 @end lisp
20075 @item @samp{windmove.el} by Hovav Shacham
20076 @cindex @file{windmove.el}
20078 This package also uses the @kbd{S-<cursor>} keys, so
20079 everything written in the paragraph above about CUA mode also
20080 applies here.  If you want to make the windmove function active
20081 in locations where Org mode does not have special functionality
20082 on @kbd{S-<cursor>}, add this to your configuration:
20084 @lisp
20085 ;; Make windmove work in Org mode:
20086 (add-hook 'org-shiftup-final-hook 'windmove-up)
20087 (add-hook 'org-shiftleft-final-hook 'windmove-left)
20088 (add-hook 'org-shiftdown-final-hook 'windmove-down)
20089 (add-hook 'org-shiftright-final-hook 'windmove-right)
20090 @end lisp
20092 @item @samp{yasnippet.el}
20093 @cindex @file{yasnippet.el}
20094 The way Org mode binds the @kbd{@key{TAB}} key (binding to @code{[tab]}
20095 instead of @code{"\t"}) overrules YASnippet's access to this key.  The
20096 following code fixed this problem:
20098 @lisp
20099 (add-hook 'org-mode-hook
20100           (lambda ()
20101             (setq-local yas/trigger-key [tab])
20102             (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
20103 @end lisp
20105 The latest version of YASnippet does not play well with Org mode.
20106 If the above code does not fix the conflict, start by defining
20107 the following function:
20109 @lisp
20110 (defun yas/org-very-safe-expand ()
20111   (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
20112 @end lisp
20114 Then, tell Org mode to use that function:
20116 @lisp
20117 (add-hook 'org-mode-hook
20118           (lambda ()
20119             (make-variable-buffer-local 'yas/trigger-key)
20120             (setq yas/trigger-key [tab])
20121             (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
20122             (define-key yas/keymap [tab] 'yas/next-field)))
20123 @end lisp
20124 @end table
20126 @node Org Crypt
20127 @section Org Crypt
20129 Org Crypt encrypts the text of an entry, but not the headline, or
20130 properties.  Behind the scene, it uses the Emacs EasyPG library to
20131 encrypt and decrypt files.
20133 @vindex org-crypt-tag-matcher
20134 Any text below a headline that has a @samp{crypt} tag is automatically
20135 encrypted when the file is saved.  To use a different tag, customize
20136 the @code{org-crypt-tag-matcher} setting.
20138 Here is a suggestion for Org Crypt settings in Emacs init file:
20140 @lisp
20141 (require 'org-crypt)
20142 (org-crypt-use-before-save-magic)
20143 (setq org-tags-exclude-from-inheritance '("crypt"))
20145 (setq org-crypt-key nil)
20146 ;; GPG key to use for encryption
20147 ;; Either the Key ID or set to nil to use symmetric encryption.
20149 (setq auto-save-default nil)
20150 ;; Auto-saving does not cooperate with org-crypt.el: so you need to
20151 ;; turn it off if you plan to use org-crypt.el quite often.  Otherwise,
20152 ;; you'll get an (annoying) message each time you start Org.
20154 ;; To turn it off only locally, you can insert this:
20156 ;; # -*- buffer-auto-save-file-name: nil; -*-
20157 @end lisp
20159 Excluding the @samp{crypt} tag from inheritance prevents already encrypted
20160 text from being encrypted again.
20162 @node Hacking
20163 @appendix Hacking
20165 @cindex hacking
20167 This appendix describes some ways a user can extend the functionality
20168 of Org.
20170 @menu
20171 * Hooks: Hooks (2).              How to reach into Org's internals.
20172 * Add-on Packages::              Available extensions.
20173 * Adding Hyperlink Types::       New custom link types.
20174 * Adding Export Back-ends::      How to write new export back-ends.
20175 * Tables in Arbitrary Syntax::   Orgtbl for LaTeX and other programs.
20176 * Dynamic Blocks::               Automatically filled blocks.
20177 * Special Agenda Views::         Customized views.
20178 * Speeding Up Your Agendas::     Tips on how to speed up your agendas.
20179 * Extracting Agenda Information:: Post-processing agenda information.
20180 * Using the Property API::       Writing programs that use entry properties.
20181 * Using the Mapping API::        Mapping over all or selected entries.
20182 @end menu
20184 @node Hooks (2)
20185 @appendixsec Hooks
20187 @cindex hooks
20189 Org has a large number of hook variables for adding functionality.
20190 This appendix illustrates using a few.  A complete list of hooks with
20191 documentation is maintained by the Worg project at
20192 @uref{https://orgmode.org/worg/doc.html#hooks}.
20194 @node Add-on Packages
20195 @appendixsec Add-on Packages
20197 @cindex add-on packages
20199 Various authors wrote a large number of add-on packages for Org.
20201 These packages are not part of Emacs, but they are distributed as
20202 contributed packages with the separate release available at
20203 @uref{https://orgmode.org}.  See the @samp{contrib/README} file in the source code
20204 directory for a list of contributed files.  Worg page with more
20205 information is at: @uref{https://orgmode.org/worg/org-contrib/}.
20207 @node Adding Hyperlink Types
20208 @appendixsec Adding Hyperlink Types
20210 @cindex hyperlinks, adding new types
20212 Org has many built-in hyperlink types (see @ref{Hyperlinks}), and an
20213 interface for adding new link types.  The following example shows the
20214 process of adding Org links to Unix man pages, which look like this
20216 @example
20217 [[man:printf][The printf manual]]
20218 @end example
20220 @noindent
20221 The following @samp{org-man.el} file implements it
20223 @lisp
20224 ;;; org-man.el - Support for links to man pages in Org mode
20225 (require 'org)
20227 (org-link-set-parameters "man"
20228                          :follow org-man-command
20229                          :export #'org-man-export
20230                          :store #'org-man-store-link)
20232 (defcustom org-man-command 'man
20233   "The Emacs command to be used to display a man page."
20234   :group 'org-link
20235   :type '(choice (const man) (const woman)))
20237 (defun org-man-store-link ()
20238   "Store a link to a man page."
20239   (when (memq major-mode '(Man-mode woman-mode))
20240     ;; This is a man page, we do make this link.
20241     (let* ((page (org-man-get-page-name))
20242            (link (concat "man:" page))
20243            (description (format "Man page for %s" page)))
20244       (org-store-link-props
20245        :type "man"
20246        :link link
20247        :description description))))
20249 (defun org-man-get-page-name ()
20250   "Extract the page name from the buffer name."
20251   ;; This works for both `Man-mode' and `woman-mode'.
20252   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
20253       (match-string 1 (buffer-name))
20254     (error "Cannot create link to this man page")))
20256 (defun org-man-export (link description format)
20257   "Export a man page link from Org files."
20258   (let ((path (format "http://man.he.net/?topic=%s&section=all" link))
20259         (desc (or description link)))
20260     (pcase format
20261       (`html (format "<a target=\"_blank\" href=\"%s\">%s</a>" path desc))
20262       (`latex (format "\\href@{%s@}@{%s@}" path desc))
20263       (`texinfo (format "@@uref@{%s,%s@}" path desc))
20264       (`ascii (format "%s (%s)" desc path))
20265       (t path))))
20267 (provide 'org-man)
20268 ;;; org-man.el ends here
20269 @end lisp
20271 @noindent
20272 To activate links to man pages in Org, enter this in the Emacs init
20273 file:
20275 @lisp
20276 (require 'org-man)
20277 @end lisp
20279 @noindent
20280 A review of @samp{org-man.el}:
20282 @enumerate
20283 @item
20284 First, @code{(require 'org)} ensures @samp{org.el} is loaded.
20286 @item
20287 @findex org-link-set-parameters
20288 @vindex org-link-parameters
20289 Then @code{org-link-set-parameters} defines a new link type with @samp{man}
20290 prefix and associates functions for following, exporting and
20291 storing such links.  See the variable @code{org-link-parameters} for
20292 a complete list of possible associations.
20294 @item
20295 The rest of the file implements necessary variables and functions.
20297 For example, @code{org-man-store-link} is responsible for storing a link
20298 when @code{org-store-link} (see @ref{Handling Links}) is called from a buffer
20299 displaying a man page.  It first checks if the @code{major-mode} is
20300 appropriate.  If check fails, the function returns @code{nil}, which
20301 means it isn't responsible for creating a link to the current
20302 buffer.  Otherwise the function makes a link string by combining
20303 the @samp{man:} prefix with the man topic.  It also provides a default
20304 description.  The function @code{org-insert-link} can insert it back
20305 into an Org buffer later on.
20306 @end enumerate
20308 @node Adding Export Back-ends
20309 @appendixsec Adding Export Back-ends
20311 @cindex Export, writing back-ends
20313 Org's export engine makes it easy for writing new back-ends.  The
20314 framework on which the engine was built makes it easy to derive new
20315 back-ends from existing ones.
20317 @findex org-export-define-backend
20318 @findex org-export-define-derived-backend
20319 The two main entry points to the export engine are:
20320 @code{org-export-define-backend} and @code{org-export-define-derived-backend}.
20321 To grok these functions, see @samp{ox-latex.el} for an example of defining
20322 a new back-end from scratch, and @samp{ox-beamer.el} for an example of
20323 deriving from an existing engine.
20325 For creating a new back-end from scratch, first set its name as
20326 a symbol in an alist consisting of elements and export functions.  To
20327 make the back-end visible to the export dispatcher, set @code{:menu-entry}
20328 keyword.  For export options specific to this back-end, set the
20329 @code{:options-alist}.
20331 For creating a new back-end from an existing one, set
20332 @code{:translate-alist} to an alist of export functions.  This alist
20333 replaces the parent back-end functions.
20335 For complete documentation, see @uref{https://orgmode.org/worg/dev/org-export-reference.html, the Org Export Reference on Worg}.
20337 @node Tables in Arbitrary Syntax
20338 @appendixsec Tables in Arbitrary Syntax
20340 @cindex tables, in other modes
20341 @cindex lists, in other modes
20342 @cindex Orgtbl mode
20344 Due to Org's success in handling tables with Orgtbl, a frequently
20345 requested feature is the use of Org's table functions in other modes,
20346 e.g., @LaTeX{}.  This would be hard to do in a general way without
20347 complicated customization nightmares.  Moreover, that would take Org
20348 away from its simplicity roots that Orgtbl has proven.  There is,
20349 however, an alternate approach to accomplishing the same.
20351 This approach involves implementing a custom @emph{translate} function that
20352 operates on a native Org @emph{source table} to produce a table in another
20353 format.  This strategy would keep the excellently working Orgtbl
20354 simple and isolate complications, if any, confined to the translate
20355 function.  To add more alien table formats, we just add more translate
20356 functions.  Also the burden of developing custom translate functions
20357 for new table formats is in the hands of those who know those formats
20358 best.
20360 @menu
20361 * Radio tables::                 Sending and receiving radio tables.
20362 * A @LaTeX{} example::           Step by step, almost a tutorial.
20363 * Translator functions::         Copy and modify.
20364 @end menu
20366 @node Radio tables
20367 @appendixsubsec Radio tables
20369 @cindex radio tables
20371 Radio tables are target locations for translated tables that are not near
20372 their source.  Org finds the target location and inserts the translated
20373 table.
20375 The key to finding the target location is the magic words @samp{BEGIN/END
20376 RECEIVE ORGTBL}.  They have to appear as comments in the current mode.
20377 If the mode is C, then:
20379 @example
20380 /* BEGIN RECEIVE ORGTBL table_name */
20381 /* END RECEIVE ORGTBL table_name */
20382 @end example
20384 @noindent
20385 At the location of source, Org needs a special line to direct Orgtbl
20386 to translate and to find the target for inserting the translated
20387 table.  For example:
20389 @cindex @samp{ORGTBL}, keyword
20390 @example
20391 #+ORGTBL: SEND table_name translation_function arguments ...
20392 @end example
20394 @noindent
20395 @samp{table_name} is the table's reference name, which is also used in the
20396 receiver lines, and the @samp{translation_function} is the Lisp function
20397 that translates.  This line, in addition, may also contain alternating
20398 key and value arguments at the end.  The translation function gets
20399 these values as a property list.  A few standard parameters are
20400 already recognized and acted upon before the translation function is
20401 called:
20403 @table @asis
20404 @item @samp{:skip N}
20405 Skip the first N lines of the table.  Hlines do count; include
20406 them if they are to be skipped.
20408 @item @samp{:skipcols (n1 n2 ...)}
20409 List of columns to be skipped.  First Org automatically discards
20410 columns with calculation marks and then sends the table to the
20411 translator function, which then skips columns as specified in
20412 @samp{skipcols}.
20413 @end table
20415 @noindent
20416 To keep the source table intact in the buffer without being disturbed
20417 when the source file is compiled or otherwise being worked on, use one
20418 of these strategies:
20420 @itemize
20421 @item
20422 Place the table in a block comment.  For example, in C mode you
20423 could wrap the table between @samp{/*} and @samp{*/} lines.
20425 @item
20426 Put the table after an ``end'' statement.  For example @code{\bye} in @TeX{}
20427 and @code{\end@{document@}} in @LaTeX{}.
20429 @item
20430 Comment and un-comment each line of the table during edits.  The
20431 @kbd{M-x orgtbl-toggle-comment} command makes toggling easy.
20432 @end itemize
20434 @node A @LaTeX{} example
20435 @appendixsubsec A @LaTeX{} example of radio tables
20437 @cindex @LaTeX{}, and Orgtbl mode
20439 To wrap a source table in @LaTeX{}, use the @samp{comment} environment
20440 provided by @samp{comment.sty}@footnote{@uref{https://ctan.org/tex-archive/macros/latex/contrib/comment?lang=en}}.  To activate it, put
20441 @code{\usepackage@{comment@}} in the document header.  Orgtbl mode inserts
20442 a radio table skeleton@footnote{Because @samp{LEVEL=2} has 3 stars, @samp{LEVEL=3} has 4 stars, and so
20443 on.} with the command @kbd{M-x orgtbl-insert-radio-table}, which prompts for a table name.  For
20444 example, if @samp{salesfigures} is the name, the template inserts:
20446 @example
20447 % BEGIN RECEIVE ORGTBL salesfigures
20448 % END RECEIVE ORGTBL salesfigures
20449 \begin@{comment@}
20450 #+ORGTBL: SEND salesfigures orgtbl-to-latex
20451 | | |
20452 \end@{comment@}
20453 @end example
20455 @vindex LaTeX-verbatim-environments
20456 @noindent
20457 The line @samp{#+ORGTBL: SEND} tells Orgtbl mode to use the function
20458 @code{orgtbl-to-latex} to convert the table to @LaTeX{} format, then insert
20459 the table at the target (receive) location named @samp{salesfigures}.  Now
20460 the table is ready for data entry.  It can even use spreadsheet
20461 features@footnote{If the @samp{TBLFM} keyword contains an odd number of dollar
20462 characters, this may cause problems with Font Lock in @LaTeX{} mode.  As
20463 shown in the example you can fix this by adding an extra line inside
20464 the @samp{comment} environment that is used to balance the dollar
20465 expressions.  If you are using AUC@TeX{} with the font-latex library,
20466 a much better solution is to add the @samp{comment} environment to the
20467 variable @code{LaTeX-verbatim-environments}.}:
20469 @example
20470 % BEGIN RECEIVE ORGTBL salesfigures
20471 % END RECEIVE ORGTBL salesfigures
20472 \begin@{comment@}
20473 #+ORGTBL: SEND salesfigures orgtbl-to-latex
20474 | Month | Days | Nr sold | per day |
20475 |-------+------+---------+---------|
20476 | Jan   |   23 |      55 |     2.4 |
20477 | Feb   |   21 |      16 |     0.8 |
20478 | March |   22 |     278 |    12.6 |
20479 #+TBLFM: $4=$3/$2;%.1f
20480 % $ (optional extra dollar to keep Font Lock happy, see footnote)
20481 \end@{comment@}
20482 @end example
20484 @noindent
20485 After editing, @kbd{C-c C-c} inserts the translated table at the
20486 target location, between the two marker lines.
20488 For hand-made custom tables, note that the translator needs to skip
20489 the first two lines of the source table.  Also the command has to
20490 @emph{splice} out the target table without the header and footer.
20492 @example
20493 \begin@{tabular@}@{lrrr@}
20494 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
20495 % BEGIN RECEIVE ORGTBL salesfigures
20496 % END RECEIVE ORGTBL salesfigures
20497 \end@{tabular@}
20499 \begin@{comment@}
20500 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
20501 | Month | Days | Nr sold | per day |
20502 |-------+------+---------+---------|
20503 | Jan   |   23 |      55 |     2.4 |
20504 | Feb   |   21 |      16 |     0.8 |
20505 | March |   22 |     278 |    12.6 |
20506 #+TBLFM: $4=$3/$2;%.1f
20507 \end@{comment@}
20508 @end example
20510 The @LaTeX{} translator function @code{orgtbl-to-latex} is already part of
20511 Orgtbl mode and uses a @samp{tabular} environment to typeset the table and
20512 marks horizontal lines with @code{\hline}.  For additional parameters to
20513 control output, see @ref{Translator functions}:
20515 @table @asis
20516 @item @code{:splice nil/t}
20517 When non-@code{nil}, return only table body lines; not wrapped in
20518 tabular environment.  Default is @code{nil}.
20520 @item @code{:fmt FMT}
20521 Format to warp each field.  It should contain @samp{%s} for the
20522 original field value.  For example, to wrap each field value in
20523 dollar symbol, you could use @samp{:fmt "$%s$"}.  Format can also wrap
20524 a property list with column numbers and formats, for example
20525 @samp{:fmt (2 "$%s$" 4 "%s\\%%")}.  In place of a string, a function
20526 of one argument can be used; the function must return a formatted
20527 string.
20529 @item @code{:efmt EFMT}
20530 Format numbers as exponentials.  The spec should have @samp{%s} twice
20531 for inserting mantissa and exponent, for example
20532 @samp{"%s\\times10^@{%s@}"}.  This may also be a property list with
20533 column numbers and formats, for example @samp{:efmt (2
20534      "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
20535 @var{EFMT} has been applied to a value, @var{FMT}---see
20536 above---is also be applied.  Functions with two arguments can be
20537 supplied instead of strings.  By default, no special formatting
20538 is applied.
20539 @end table
20541 @node Translator functions
20542 @appendixsubsec Translator functions
20544 @cindex HTML, and Orgtbl mode
20545 @cindex translator function
20547 @findex orgtbl-to-csv
20548 @findex orgtbl-to-tsv
20549 @findex orgtbl-to-latex
20550 @findex orgtbl-to-html
20551 @findex orgtbl-to-texinfo
20552 @findex orgtbl-to-unicode
20553 @findex orgtbl-to-orgtbl
20554 @findex orgtbl-to-generic
20555 Orgtbl mode has built-in translator functions: @code{orgtbl-to-csv}
20556 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values),
20557 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, @code{orgtbl-to-texinfo},
20558 @code{orgtbl-to-unicode} and @code{orgtbl-to-orgtbl}.  They use the generic
20559 translator, @code{orgtbl-to-generic}, which delegates translations to
20560 various export back-ends.
20562 Properties passed to the function through the @samp{ORGTBL SEND} line take
20563 precedence over properties defined inside the function.  For example,
20564 this overrides the default @LaTeX{} line endings, @code{\\}, with @code{\\[2mm]}:
20566 @example
20567 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
20568 @end example
20570 For a new language translator, define a converter function.  It can be
20571 a generic function, such as shown in this example.  It marks
20572 a beginning and ending of a table with @samp{!BTBL!} and @samp{!ETBL!};
20573 a beginning and ending of lines with @samp{!BL!} and @samp{!EL!}; and uses a TAB
20574 for a field separator:
20576 @lisp
20577 (defun orgtbl-to-language (table params)
20578   "Convert the orgtbl-mode TABLE to language."
20579   (orgtbl-to-generic
20580    table
20581    (org-combine-plists
20582     '(:tstart "!BTBL!" :tend "!ETBL!" :lstart "!BL!" :lend "!EL!" :sep "\t")
20583     params)))
20584 @end lisp
20586 @noindent
20587 The documentation for the @code{orgtbl-to-generic} function shows
20588 a complete list of parameters, each of which can be passed through to
20589 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function using
20590 that generic function.
20592 For complicated translations the generic translator function could be
20593 replaced by a custom translator function.  Such a custom function must
20594 take two arguments and return a single string containing the formatted
20595 table.  The first argument is the table whose lines are a list of
20596 fields or the symbol @code{hline}.  The second argument is the property
20597 list consisting of parameters specified in the @samp{#+ORGTBL: SEND} line.
20598 Please share your translator functions by posting them to the Org
20599 users mailing list, at @email{emacs-orgmode@@gnu.org}.
20601 @node Dynamic Blocks
20602 @appendixsec Dynamic Blocks
20604 @cindex dynamic blocks
20606 Org supports @emph{dynamic blocks} in Org documents.  They are inserted
20607 with begin and end markers like any other code block, but the contents
20608 are updated automatically by a user function.  For example, @kbd{C-c C-x C-r} inserts a dynamic table that updates the work time (see
20609 @ref{Clocking Work Time}).
20611 Dynamic blocks can have names and function parameters.  The syntax is
20612 similar to source code block specifications:
20614 @example
20615 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
20616   ...
20617 #+END:
20618 @end example
20620 These commands update dynamic blocks:
20622 @table @asis
20623 @item @kbd{C-c C-x C-u} (@code{org-dblock-update})
20624 @kindex C-c C-x C-u
20625 @findex org-dblock-update
20626 Update dynamic block at point.
20628 @item @kbd{C-u C-c C-x C-u}
20629 @kindex C-u C-c C-x C-u
20630 Update all dynamic blocks in the current file.
20631 @end table
20633 Before updating a dynamic block, Org removes content between the
20634 @samp{BEGIN} and @samp{END} markers.  Org then reads the parameters on the
20635 @samp{BEGIN} line for passing to the writer function.  If the function
20636 expects to access the removed content, then Org expects an extra
20637 parameter, @samp{:content}, on the @samp{BEGIN} line.
20639 The syntax for naming a writer function with a dynamic block labelled
20640 @samp{myblock} is: @code{org-dblock-write:myblock}.  Parameters come from the
20641 @samp{BEGIN} line.
20643 The following is an example of a dynamic block and a block writer function
20644 that updates the time when the function was last run:
20646 @example
20647 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
20648   ...
20649 #+END:
20650 @end example
20652 @noindent
20653 The dynamic block's writer function:
20655 @lisp
20656 (defun org-dblock-write:block-update-time (params)
20657   (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
20658     (insert "Last block update at: "
20659             (format-time-string fmt))))
20660 @end lisp
20662 To keep dynamic blocks up-to-date in an Org file, use the function,
20663 @code{org-update-all-dblocks} in hook, such as @code{before-save-hook}.  The
20664 @code{org-update-all-dblocks} function does not run if the file is not in
20665 Org mode.
20667 @findex org-narrow-to-block
20668 Dynamic blocks, like any other block, can be narrowed with
20669 @code{org-narrow-to-block}.
20671 @node Special Agenda Views
20672 @appendixsec Special Agenda Views
20674 @cindex agenda views, user-defined
20676 @vindex org-agenda-skip-function
20677 @vindex org-agenda-skip-function-global
20678 Org provides a special hook to further limit items in agenda views:
20679 @code{agenda}, @code{agenda*}@footnote{The @code{agenda*} view is the same as @code{agenda} except that it
20680 only considers @emph{appointments}, i.e., scheduled and deadline items that
20681 have a time specification @samp{[h]h:mm} in their time-stamps.}, @code{todo}, @code{alltodo}, @code{tags}, @code{tags-todo},
20682 @code{tags-tree}.  Specify a custom function that tests inclusion of every
20683 matched item in the view.  This function can also skip as much as is
20684 needed.
20686 For a global condition applicable to agenda views, use the
20687 @code{org-agenda-skip-function-global} variable.  Org uses a global
20688 condition with @code{org-agenda-skip-function} for custom searching.
20690 This example defines a function for a custom view showing TODO items
20691 with @samp{waiting} status.  Manually this is a multi-step search process,
20692 but with a custom view, this can be automated as follows:
20694 The custom function searches the subtree for the @samp{waiting} tag and
20695 returns @code{nil} on match.  Otherwise it gives the location from where
20696 the search continues.
20698 @lisp
20699 (defun my-skip-unless-waiting ()
20700   "Skip trees that are not waiting"
20701   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
20702     (if (re-search-forward ":waiting:" subtree-end t)
20703         nil          ; tag found, do not skip
20704       subtree-end))) ; tag not found, continue after end of subtree
20705 @end lisp
20707 To use this custom function in a custom agenda command:
20709 @lisp
20710 (org-add-agenda-custom-command
20711  '("b" todo "PROJECT"
20712    ((org-agenda-skip-function 'my-skip-unless-waiting)
20713     (org-agenda-overriding-header "Projects waiting for something: "))))
20714 @end lisp
20716 @vindex org-agenda-overriding-header
20717 Note that this also binds @code{org-agenda-overriding-header} to a more
20718 meaningful string suitable for the agenda view.
20720 @vindex org-odd-levels-only
20721 @vindex org-agenda-skip-function
20722 Search for entries with a limit set on levels for the custom search.
20723 This is a general approach to creating custom searches in Org.  To
20724 include all levels, use @samp{LEVEL>0}@footnote{Note that, for @code{org-odd-levels-only}, a level number
20725 corresponds to order in the hierarchy, not to the number of stars.}.  Then to selectively pick
20726 the matched entries, use @code{org-agenda-skip-function}, which also
20727 accepts Lisp forms, such as @code{org-agenda-skip-entry-if} and
20728 @code{org-agenda-skip-subtree-if}.  For example:
20730 @table @asis
20731 @item @code{(org-agenda-skip-entry-if 'scheduled)}
20732 Skip current entry if it has been scheduled.
20734 @item @code{(org-agenda-skip-entry-if 'notscheduled)}
20735 Skip current entry if it has not been scheduled.
20737 @item @code{(org-agenda-skip-entry-if 'deadline)}
20738 Skip current entry if it has a deadline.
20740 @item @code{(org-agenda-skip-entry-if 'scheduled 'deadline)}
20741 Skip current entry if it has a deadline, or if it is scheduled.
20743 @item @code{(org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))}
20744 Skip current entry if the TODO keyword is TODO or WAITING.
20746 @item @code{(org-agenda-skip-entry-if 'todo 'done)}
20747 Skip current entry if the TODO keyword marks a DONE state.
20749 @item @code{(org-agenda-skip-entry-if 'timestamp)}
20750 Skip current entry if it has any timestamp, may also be deadline
20751 or scheduled.
20753 @item @code{(org-agenda-skip-entry-if 'regexp "regular expression")}
20754 Skip current entry if the regular expression matches in the
20755 entry.
20757 @item @code{(org-agenda-skip-entry-if 'notregexp "regular expression")}
20758 Skip current entry unless the regular expression matches.
20760 @item @code{(org-agenda-skip-subtree-if 'regexp "regular expression")}
20761 Same as above, but check and skip the entire subtree.
20762 @end table
20764 The following is an example of a search for @samp{waiting} without the
20765 special function:
20767 @lisp
20768 (org-add-agenda-custom-command
20769  '("b" todo "PROJECT"
20770    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
20771                                 'regexp ":waiting:"))
20772     (org-agenda-overriding-header "Projects waiting for something: "))))
20773 @end lisp
20775 @node Speeding Up Your Agendas
20776 @appendixsec Speeding Up Your Agendas
20778 @cindex agenda views, optimization
20780 Some agenda commands slow down when the Org files grow in size or
20781 number.  Here are tips to speed up:
20783 @itemize
20784 @item
20785 Reduce the number of Org agenda files to avoid slowdowns due to hard drive
20786 accesses.
20788 @item
20789 Reduce the number of DONE and archived headlines so agenda
20790 operations that skip over these can finish faster.
20792 @item
20793 Do not dim blocked tasks:
20794 @vindex org-agenda-dim-blocked-tasks
20796 @lisp
20797 (setq org-agenda-dim-blocked-tasks nil)
20798 @end lisp
20800 @item
20801 Stop preparing agenda buffers on startup:
20802 @vindex org-startup-folded
20803 @vindex org-agenda-inhibit-startup
20805 @lisp
20806 (setq org-agenda-inhibit-startup nil)
20807 @end lisp
20809 @item
20810 Disable tag inheritance for agendas:
20811 @vindex org-agenda-show-inherited-tags
20812 @vindex org-agenda-use-tag-inheritance
20814 @lisp
20815 (setq org-agenda-use-tag-inheritance nil)
20816 @end lisp
20817 @end itemize
20819 These options can be applied to selected agenda views.  For more
20820 details about generation of agenda views, see the docstrings for the
20821 relevant variables, and this @uref{https://orgmode.org/worg/agenda-optimization.html, dedicated Worg page} for agenda
20822 optimization.
20824 @node Extracting Agenda Information
20825 @appendixsec Extracting Agenda Information
20827 @cindex agenda, pipe
20828 @cindex scripts, for agenda processing
20830 Org provides commands to access agendas through Emacs batch mode.
20831 Through this command-line interface, agendas are automated for further
20832 processing or printing.
20834 @vindex org-agenda-custom-commands
20835 @findex org-batch-agenda
20836 @code{org-batch-agenda} creates an agenda view in ASCII and outputs to
20837 standard output.  This command takes one string parameter.  When
20838 string consists of a single character, Org uses it as a key to
20839 @code{org-agenda-custom-commands}.  These are the same ones available
20840 through the agenda dispatcher (see @ref{Agenda Dispatcher}).
20842 This example command line directly prints the TODO list to the printer:
20844 @example
20845 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
20846 @end example
20848 When the string parameter length is two or more characters, Org
20849 matches it with tags/TODO strings.  For example, this example command
20850 line prints items tagged with @samp{shop}, but excludes items tagged with
20851 @samp{NewYork}:
20853 @example
20854 emacs -batch -l ~/.emacs                                      \
20855       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
20856 @end example
20858 @noindent
20859 An example showing on-the-fly parameter modifications:
20861 @example
20862 emacs -batch -l ~/.emacs                                      \
20863    -eval '(org-batch-agenda "a"                               \
20864            org-agenda-span (quote month)                      \
20865            org-agenda-include-diary nil                       \
20866            org-agenda-files (quote ("~/org/project.org")))'   \
20867    | lpr
20868 @end example
20870 @noindent
20871 which produces an agenda for the next 30 days from just the
20872 @samp{~/org/projects.org} file.
20874 @findex org-batch-agenda-csv
20875 For structured processing of agenda output, use @code{org-batch-agenda-csv}
20876 with the following fields:
20878 @table @asis
20879 @item category
20880 The category of the item
20881 @item head
20882 The headline, without TODO keyword, TAGS and PRIORITY
20883 @item type
20884 The type of the agenda entry, can be
20886 @multitable {aaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
20887 @item @code{todo}
20888 @tab selected in TODO match
20889 @item @code{tagsmatch}
20890 @tab selected in tags match
20891 @item @code{diary}
20892 @tab imported from diary
20893 @item @code{deadline}
20894 @tab a deadline
20895 @item @code{scheduled}
20896 @tab scheduled
20897 @item @code{timestamp}
20898 @tab appointment, selected by timestamp
20899 @item @code{closed}
20900 @tab entry was closed on date
20901 @item @code{upcoming-deadline}
20902 @tab warning about nearing deadline
20903 @item @code{past-scheduled}
20904 @tab forwarded scheduled item
20905 @item @code{block}
20906 @tab entry has date block including date
20907 @end multitable
20909 @item todo
20910 The TODO keyword, if any
20911 @item tags
20912 All tags including inherited ones, separated by colons
20913 @item date
20914 The relevant date, like @samp{2007-2-14}
20915 @item time
20916 The time, like @samp{15:00-16:50}
20917 @item extra
20918 String with extra planning info
20919 @item priority-l
20920 The priority letter if any was given
20921 @item priority-n
20922 The computed numerical priority
20923 @end table
20925 @noindent
20926 If the selection of the agenda item was based on a timestamp,
20927 including those items with @samp{DEADLINE} and @samp{SCHEDULED} keywords, then
20928 Org includes date and time in the output.
20930 If the selection of the agenda item was based on a timestamp  (or
20931 deadline/scheduled), then Org includes date and time in the output.
20933 Here is an example of a post-processing script in Perl.  It takes the
20934 CSV output from Emacs and prints with a checkbox:
20936 @example
20937 #!/usr/bin/perl
20939 # define the Emacs command to run
20940 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
20942 # run it and capture the output
20943 $agenda = qx@{$cmd 2>/dev/null@};
20945 # loop over all lines
20946 foreach $line (split(/\n/,$agenda)) @{
20947     # get the individual values
20948     ($category,$head,$type,$todo,$tags,$date,$time,$extra,
20949      $priority_l,$priority_n) = split(/,/,$line);
20950     # process and print
20951     print "[ ] $head\n";
20953 @end example
20955 @node Using the Property API
20956 @appendixsec Using the Property API
20958 @cindex API, for properties
20959 @cindex properties, API
20961 Here is a description of the functions that can be used to work with
20962 properties.
20964 @defun org-entry-properties &optional pom which
20965 Get all properties of the entry at point-or-marker @var{POM}.
20966 This includes the TODO keyword, the tags, time strings for deadline,
20967 scheduled, and clocking, and any additional properties defined in the
20968 entry.  The return value is an alist.  Keys may occur multiple times
20969 if the property key was used several times.  @var{POM} may also
20970 be @code{nil}, in which case the current entry is used.  If
20971 @var{WHICH} is @code{nil} or @code{all}, get all properties.  If
20972 @var{WHICH} is @code{special} or @code{standard}, only get that subclass.
20973 @end defun
20975 @vindex org-use-property-inheritance
20976 @findex org-insert-property-drawer
20977 @defun org-entry-get pom property &optional inherit
20978 Get value of @var{PROPERTY} for entry at point-or-marker
20979 @var{POM}.  By default, this only looks at properties defined
20980 locally in the entry.  If @var{INHERIT} is non-@code{nil} and the
20981 entry does not have the property, then also check higher levels of the
20982 hierarchy.  If @var{INHERIT} is the symbol @code{selective}, use
20983 inheritance if and only if the setting of
20984 @code{org-use-property-inheritance} selects @var{PROPERTY} for
20985 inheritance.
20986 @end defun
20988 @defun org-entry-delete pom property
20989 Delete the property @var{PROPERTY} from entry at point-or-marker
20990 @var{POM}.
20991 @end defun
20993 @defun org-entry-put pom property value
20994 Set @var{PROPERTY} to @var{VALUES} for entry at
20995 point-or-marker POM.
20996 @end defun
20998 @defun org-buffer-property-keys &optional include-specials
20999 Get all property keys in the current buffer.
21000 @end defun
21002 @defun org-insert-property-drawer
21003 Insert a property drawer for the current entry.  Also
21004 @end defun
21006 @defun org-entry-put-multivalued-property pom property &rest values
21007 Set @var{PROPERTY} at point-or-marker @var{POM} to
21008 @var{VALUES}.  @var{VALUES} should be a list of strings.
21009 They are concatenated, with spaces as separators.
21010 @end defun
21012 @defun org-entry-get-multivalued-property pom property
21013 Treat the value of the property @var{PROPERTY} as
21014 a whitespace-separated list of values and return the values as a list
21015 of strings.
21016 @end defun
21018 @defun org-entry-add-to-multivalued-property pom property value
21019 Treat the value of the property @var{PROPERTY} as
21020 a whitespace-separated list of values and make sure that
21021 @var{VALUE} is in this list.
21022 @end defun
21024 @defun org-entry-remove-from-multivalued-property pom property value
21025 Treat the value of the property @var{PROPERTY} as
21026 a whitespace-separated list of values and make sure that
21027 @var{VALUE} is @emph{not} in this list.
21028 @end defun
21030 @defun org-entry-member-in-multivalued-property pom property value
21031 Treat the value of the property @var{PROPERTY} as
21032 a whitespace-separated list of values and check if @var{VALUE} is
21033 in this list.
21034 @end defun
21036 @defopt org-property-allowed-value-functions
21037 Hook for functions supplying allowed values for a specific property.
21038 The functions must take a single argument, the name of the property,
21039 and return a flat list of allowed values.  If @samp{:ETC} is one of the
21040 values, use the values as completion help, but allow also other values
21041 to be entered.  The functions must return @code{nil} if they are not
21042 responsible for this property.
21043 @end defopt
21045 @node Using the Mapping API
21046 @appendixsec Using the Mapping API
21048 @cindex API, for mapping
21049 @cindex mapping entries, API
21051 Org has sophisticated mapping capabilities to find all entries
21052 satisfying certain criteria.  Internally, this functionality is used
21053 to produce agenda views, but there is also an API that can be used to
21054 execute arbitrary functions for each or selected entries.  The main
21055 entry point for this API is:
21057 @defun org-map-entries func &optional match scope &rest skip
21058 Call @{@{@{(var(FUNC))@}@}@} at each headline selected by @var{MATCH}
21059 in @var{SCOPE}.
21061 @var{FUNC} is a function or a Lisp form.  With the cursor
21062 positioned at the beginning of the headline, call the function without
21063 arguments.  Org returns an alist of return values of calls to the
21064 function.
21066 To avoid preserving point, Org wraps the call to @var{FUNC} in
21067 save-excursion form.  After evaluation, Org moves the cursor to the
21068 end of the line that was just processed.  Search continues from that
21069 point forward.  This may not always work as expected under some
21070 conditions, such as if the current sub-tree was removed by a previous
21071 archiving operation.  In such rare circumstances, Org skips the next
21072 entry entirely when it should not.  To stop Org from such skips, make
21073 @var{FUNC} set the variable @code{org-map-continue-from} to a specific
21074 buffer position.
21076 @var{MATCH} is a tags/property/TODO match.  Org iterates only
21077 matched headlines.  Org iterates over all headlines when
21078 @var{MATCH} is @code{nil} or @code{t}.
21080 @var{SCOPE} determines the scope of this command.  It can be any
21083 @table @asis
21084 @item @code{nil}
21085 The current buffer, respecting the restriction, if any.
21087 @item @code{tree}
21088 The subtree started with the entry at point.
21090 @item @code{region}
21091 The entries within the active region, if any.
21093 @item @code{file}
21094 The current buffer, without restriction.
21096 @item @code{file-with-archives}
21097 The current buffer, and any archives associated with it.
21099 @item @code{agenda}
21100 All agenda files.
21102 @item @code{agenda-with-archives}
21103 All agenda files with any archive files associated with them.
21105 @item @code{(file1 file2 ...)}
21106 If this is a list, all files in the list are scanned.
21107 @end table
21109 @noindent
21110 The remaining arguments are treated as settings for the scanner's
21111 skipping facilities.  Valid arguments are:
21113 @table @asis
21114 @item @code{archive}
21115 Skip trees with the archive tag.
21117 @item @code{comment}
21118 Skip trees with the COMMENT keyword.
21120 @item function or Lisp form
21121 @vindex org-agenda-skip-function
21122 Used as value for @code{org-agenda-skip-function}, so whenever the
21123 function returns @code{t}, @var{FUNC} is called for that entry
21124 and search continues from the point where the function leaves it.
21125 @end table
21126 @end defun
21128 The mapping routine can call any arbitrary function, even functions
21129 that change meta data or query the property API (see @ref{Using the Property API}).  Here are some handy functions:
21131 @defun org-todo &optional arg
21132 Change the TODO state of the entry.  See the docstring of the
21133 functions for the many possible values for the argument
21134 @var{ARG}.
21135 @end defun
21137 @defun org-priority &optional action
21138 Change the priority of the entry.  See the docstring of this function
21139 for the possible values for @var{ACTION}.
21140 @end defun
21142 @defun org-toggle-tag tag &optional onoff
21143 Toggle the tag @var{TAG} in the current entry.  Setting
21144 @var{ONOFF} to either @code{on} or @code{off} does not toggle tag, but
21145 ensure that it is either on or off.
21146 @end defun
21148 @defun org-promote
21149 Promote the current entry.
21150 @end defun
21152 @defun org-demote
21153 Demote the current entry.
21154 @end defun
21156 This example turns all entries tagged with @samp{TOMORROW} into TODO
21157 entries with keyword @samp{UPCOMING}.  Org ignores entries in comment trees
21158 and archive trees.
21160 @lisp
21161 (org-map-entries '(org-todo "UPCOMING")
21162                  "+TOMORROW" 'file 'archive 'comment)
21163 @end lisp
21165 The following example counts the number of entries with TODO keyword
21166 @samp{WAITING}, in all agenda files.
21168 @lisp
21169 (length (org-map-entries t "/+WAITING" 'agenda))
21170 @end lisp
21172 @node MobileOrg
21173 @appendix MobileOrg
21175 @cindex iPhone
21176 @cindex smartphone
21177 @cindex android
21178 @cindex MobileOrg
21180 MobileOrg is a companion mobile app that runs on iOS and Android
21181 devices.  MobileOrg enables offline-views and capture support for an
21182 Org mode system that is rooted on a ``real'' computer.  MobileOrg can
21183 record changes to existing entries.
21185 The @uref{https://github.com/MobileOrg/, iOS implementation} for the @emph{iPhone/iPod Touch/iPad} series of
21186 devices, was started by Richard Moreland and is now in the hands of
21187 Sean Escriva.  Android users should check out @uref{http://wiki.github.com/matburt/mobileorg-android/, MobileOrg Android} by
21188 Matt Jones.  Though the two implementations are not identical, they
21189 offer similar features.
21191 This appendix describes Org's support for agenda view formats
21192 compatible with MobileOrg.  It also describes synchronizing changes,
21193 such as to notes, between MobileOrg and the computer.
21195 To change tags and TODO states in MobileOrg, first customize the
21196 variables @code{org-todo-keywords} and @code{org-tag-alist}.  These should cover
21197 all the important tags and TODO keywords, even if Org files use only
21198 some of them.  Though MobileOrg has in-buffer settings, it understands
21199 TODO states @emph{sets} (see @ref{Per-file keywords}) and
21200 @emph{mutually exclusive} tags (see @ref{Setting Tags}) only for those set in
21201 these variables.
21203 @menu
21204 * Setting Up the Staging Area::  For the mobile device.
21205 * Pushing to MobileOrg::         Uploading Org files and agendas.
21206 * Pulling from MobileOrg::       Integrating captured and flagged items.
21207 @end menu
21209 @node Setting Up the Staging Area
21210 @appendixsec Setting Up the Staging Area
21212 MobileOrg needs access to a file directory on a server to interact
21213 with Emacs.  With a public server, consider encrypting the files.
21214 MobileOrg version 1.5 supports encryption for the iPhone.  Org also
21215 requires @samp{openssl} installed on the local computer.  To turn on
21216 encryption, set the same password in MobileOrg and in Emacs.  Set the
21217 password in the variable @code{org-mobile-use-encryption}@footnote{If Emacs is configured for safe storing of passwords, then
21218 configure the variable, @code{org-mobile-encryption-password}; please read
21219 the docstring of that variable.}.  Note
21220 that even after MobileOrg encrypts the file contents, the file name
21221 remains visible on the file systems of the local computer, the server,
21222 and the mobile device.
21224 For a server to host files, consider options like @uref{http://dropbox.com, Dropbox.com}
21225 account@footnote{An alternative is to use a WebDAV server.  MobileOrg
21226 documentation has details of WebDAV server configuration.  Additional
21227 help is at this @uref{https://orgmode.org/worg/org-faq.html#mobileorg_webdav, FAQ entry}.}.  On first connection, MobileOrg creates a directory
21228 @samp{MobileOrg} on Dropbox.  Pass its location to Emacs through an
21229 initialisation file variable as follows:
21231 @lisp
21232 (setq org-mobile-directory "~/Dropbox/MobileOrg")
21233 @end lisp
21235 Org copies files to the above directory for MobileOrg.  Org also uses
21236 the same directory for sharing notes between Org and MobileOrg.
21238 @node Pushing to MobileOrg
21239 @appendixsec Pushing to MobileOrg
21241 @vindex org-mobile-files
21242 @vindex org-directory
21243 Org pushes files listed in @code{org-mobile-files} to
21244 @code{org-mobile-directory}.  Files include agenda files (as listed in
21245 @code{org-agenda-files}).  Customize @code{org-mobile-files} to add other files.
21246 File names are staged with paths relative to @code{org-directory}, so all
21247 files should be inside this directory@footnote{Symbolic links in @code{org-directory} need to have the same name
21248 as their targets.}.
21250 Push creates a special Org file @samp{agendas.org} with custom agenda views
21251 defined by the user@footnote{While creating the agendas, Org mode forces ID properties on
21252 all referenced entries, so that these entries can be uniquely
21253 identified if MobileOrg flags them for further action.  To avoid
21254 setting properties configure the variable
21255 @code{org-mobile-force-id-on-agenda-items} to @code{nil}.  Org mode then relies
21256 on outline paths, assuming they are unique.}.
21258 Finally, Org writes the file @samp{index.org}, containing links to other
21259 files.  MobileOrg reads this file first from the server to determine
21260 what other files to download for agendas.  For faster downloads,
21261 MobileOrg only reads files whose checksums@footnote{Checksums are stored automatically in the file
21262 @samp{checksums.dat}.} have changed.
21264 @node Pulling from MobileOrg
21265 @appendixsec Pulling from MobileOrg
21267 When MobileOrg synchronizes with the server, it pulls the Org files
21268 for viewing.  It then appends to the file @samp{mobileorg.org} on the
21269 server the captured entries, pointers to flagged and changed entries.
21270 Org integrates its data in an inbox file format.
21272 @enumerate
21273 @item
21274 @vindex org-mobile-inbox-for-pull
21275 Org moves all entries found in @samp{mobileorg.org}@footnote{The file will be empty after this operation.} and appends
21276 them to the file pointed to by the variable
21277 @code{org-mobile-inbox-for-pull}.  Each captured entry and each editing
21278 event is a top-level entry in the inbox file.
21280 @item
21281 After moving the entries, Org attempts changes to MobileOrg.  Some
21282 changes are applied directly and without user interaction.
21283 Examples include changes to tags, TODO state, headline and body
21284 text.  Entries for further action are tagged as @samp{FLAGGED}.  Org
21285 marks entries with problems with an error message in the inbox.
21286 They have to be resolved manually.
21288 @item
21289 Org generates an agenda view for flagged entries for user
21290 intervention to clean up.  For notes stored in flagged entries,
21291 MobileOrg displays them in the echo area when the cursor is on the
21292 corresponding agenda item.
21294 @table @asis
21295 @item @kbd{?}
21296 @kindex ?
21298 Pressing @kbd{?} displays the entire flagged note in
21299 another window.  Org also pushes it to the kill ring.  To
21300 store flagged note as a normal note, use @kbd{? z C-y C-c C-c}.  Pressing@kbd{?} twice does these things: first
21301 it removes the @samp{FLAGGED} tag; second, it removes the flagged
21302 note from the property drawer; third, it signals that manual
21303 editing of the flagged entry is now finished.
21304 @end table
21305 @end enumerate
21307 @kindex ? @r{(Agenda dispatcher)}
21308 From the agenda dispatcher, @kbd{?} returns to the view to finish
21309 processing flagged entries.  Note that these entries may not be the
21310 most recent since MobileOrg searches files that were last pulled.  To
21311 get an updated agenda view with changes since the last pull, pull
21312 again.
21314 @node History and Acknowledgments
21315 @appendix History and Acknowledgments
21319 @anchor{From Carsten}
21320 @appendixsec From Carsten
21322 Org was born in 2003, out of frustration over the user interface of
21323 the Emacs Outline mode.  I was trying to organize my notes and
21324 projects, and using Emacs seemed to be the natural way to go.
21325 However, having to remember eleven different commands with two or
21326 three keys per command, only to hide and show parts of the outline
21327 tree, that seemed entirely unacceptable to me.  Also, when using
21328 outlines to take notes, I constantly wanted to restructure the tree,
21329 organizing it parallel to my thoughts and plans.  @emph{Visibility cycling}
21330 and @emph{structure editing} were originally implemented in the package
21331 @samp{outline-magic.el}, but quickly moved to the more general @samp{org.el}.
21332 As this environment became comfortable for project planning, the next
21333 step was adding @emph{TODO entries}, basic @emph{timestamps}, and @emph{table
21334 support}.  These areas highlighted the two main goals that Org still
21335 has today: to be a new, outline-based, plain text mode with innovative
21336 and intuitive editing features, and to incorporate project planning
21337 functionality directly into a notes file.
21339 Since the first release, literally thousands of emails to me or to the
21340 @email{emacs-orgmode@@gnu.org, mailing list} have provided a constant stream of bug reports, feedback,
21341 new ideas, and sometimes patches and add-on code.  Many thanks to
21342 everyone who has helped to improve this package.  I am trying to keep
21343 here a list of the people who had significant influence in shaping one
21344 or more aspects of Org.  The list may not be complete, if I have
21345 forgotten someone, please accept my apologies and let me know.
21347 Before I get to this list, a few special mentions are in order:
21349 @table @asis
21350 @item Bastien Guerry
21351 Bastien has written a large number of extensions to Org (most of
21352 them integrated into the core by now), including the @LaTeX{}
21353 exporter and the plain list parser.  His support during the early
21354 days was central to the success of this project.  Bastien also
21355 invented Worg, helped establishing the Web presence of Org, and
21356 sponsored hosting costs for the orgmode.org website.  Bastien
21357 stepped in as maintainer of Org between 2011 and 2013, at a time
21358 when I desperately needed a break.
21360 @item Eric Schulte and Dan Davison
21361 Eric and Dan are jointly responsible for the Org Babel system,
21362 which turns Org into a multi-language environment for evaluating
21363 code and doing literate programming and reproducible research.
21364 This has become one of Org's killer features that define what Org
21365 is today.
21367 @item John Wiegley
21368 John has contributed a number of great ideas and patches directly
21369 to Org, including the attachment system (@samp{org-attach.el}),
21370 integration with Apple Mail (@samp{org-mac-message.el}), hierarchical
21371 dependencies of TODO items, habit tracking (@samp{org-habits.el}), and
21372 encryption (@samp{org-crypt.el}).  Also, the capture system is really
21373 an extended copy of his great @samp{remember.el}.
21375 @item Sebastian Rose
21376 Without Sebastian, the HTML/XHTML publishing of Org would be the
21377 pitiful work of an ignorant amateur.  Sebastian has pushed this
21378 part of Org onto a much higher level.  He also wrote
21379 @samp{org-info.js}, a Java script for displaying webpages derived from
21380 Org using an Info-like or a folding interface with single-key
21381 navigation.
21382 @end table
21384 @noindent
21385 See below for the full list of contributions! Again, please let me
21386 know what I am missing here!
21388 @anchor{From Bastien}
21389 @appendixsec From Bastien
21391 I (Bastien) have been maintaining Org between 2011 and 2013.  This
21392 appendix would not be complete without adding a few more
21393 acknowledgments and thanks.
21395 I am first grateful to Carsten for his trust while handing me over the
21396 maintainership of Org.  His unremitting support is what really helped
21397 me getting more confident over time, with both the community and the
21398 code.
21400 When I took over maintainership, I knew I would have to make Org more
21401 collaborative than ever, as I would have to rely on people that are
21402 more knowledgeable than I am on many parts of the code.  Here is
21403 a list of the persons I could rely on, they should really be
21404 considered co-maintainers, either of the code or the community:
21406 @table @asis
21407 @item Eric Schulte
21408 Eric is maintaining the Babel parts of Org.  His reactivity here
21409 kept me away from worrying about possible bugs here and let me
21410 focus on other parts.
21412 @item Nicolas Goaziou
21413 Nicolas is maintaining the consistency of the deepest parts of
21414 Org.  His work on @samp{org-element.el} and @samp{ox.el} has been
21415 outstanding, and it opened the doors for many new ideas and
21416 features.  He rewrote many of the old exporters to use the new
21417 export engine, and helped with documenting this major change.
21418 More importantly (if that's possible), he has been more than
21419 reliable during all the work done for Org 8.0, and always very
21420 reactive on the mailing list.
21422 @item Achim Gratz
21423 Achim rewrote the building process of Org, turning some @emph{ad hoc}
21424 tools into a flexible and conceptually clean process.  He
21425 patiently coped with the many hiccups that such a change can
21426 create for users.
21428 @item Nick Dokos
21429 The Org mode mailing list would not be such a nice place without
21430 Nick, who patiently helped users so many times.  It is impossible
21431 to overestimate such a great help, and the list would not be so
21432 active without him.
21433 @end table
21435 I received support from so many users that it is clearly impossible to
21436 be fair when shortlisting a few of them, but Org's history would not
21437 be complete if the ones above were not mentioned in this manual.
21439 @anchor{List of Contributions}
21440 @appendixsec List of Contributions
21442 @itemize
21443 @item
21444 Russel Adams came up with the idea for drawers.
21446 @item
21447 Thomas Baumann wrote @samp{org-bbdb.el} and @samp{org-mhe.el}.
21449 @item
21450 Christophe Bataillon created the great unicorn logo that we use on
21451 the Org mode website.
21453 @item
21454 Alex Bochannek provided a patch for rounding timestamps.
21456 @item
21457 Jan Böcker wrote @samp{org-docview.el}.
21459 @item
21460 Brad Bozarth showed how to pull RSS feed data into Org files.
21462 @item
21463 Tom Breton wrote @samp{org-choose.el}.
21465 @item
21466 Charles Cave's suggestion sparked the implementation of templates
21467 for Remember, which are now templates for capture.
21469 @item
21470 Pavel Chalmoviansky influenced the agenda treatment of items with
21471 specified time.
21473 @item
21474 Gregory Chernov patched support for Lisp forms into table
21475 calculations and improved XEmacs compatibility, in particular by
21476 porting @samp{nouline.el} to XEmacs.
21478 @item
21479 Sacha Chua suggested copying some linking code from Planner.
21481 @item
21482 Baoqiu Cui contributed the DocBook exporter.
21484 @item
21485 Eddward DeVilla proposed and tested checkbox statistics.  He also
21486 came up with the idea of properties, and that there should be an API
21487 for them.
21489 @item
21490 Nick Dokos tracked down several nasty bugs.
21492 @item
21493 Kees Dullemond used to edit projects lists directly in HTML and so
21494 inspired some of the early development, including HTML export.  He
21495 also asked for a way to narrow wide table columns.
21497 @item
21498 Thomas S. Dye contributed documentation on Worg and helped
21499 integrating the Org Babel documentation into the manual.
21501 @item
21502 Christian Egli converted the documentation into Texinfo format,
21503 inspired the agenda, patched CSS formatting into the HTML exporter,
21504 and wrote @samp{org-taskjuggler.el}.
21506 @item
21507 David Emery provided a patch for custom CSS support in exported HTML
21508 agendas.
21510 @item
21511 Nic Ferrier contributed mailcap and XOXO support.
21513 @item
21514 Miguel A.  Figueroa-Villanueva implemented hierarchical checkboxes.
21516 @item
21517 John Foerch figured out how to make incremental search show context
21518 around a match in a hidden outline tree.
21520 @item
21521 Raimar Finken wrote @samp{org-git-line.el}.
21523 @item
21524 Mikael Fornius works as a mailing list moderator.
21526 @item
21527 Austin Frank works as a mailing list moderator.
21529 @item
21530 Eric Fraga drove the development of Beamer export with ideas and
21531 testing.
21533 @item
21534 Barry Gidden did proofreading the manual in preparation for the book
21535 publication through Network Theory Ltd.
21537 @item
21538 Niels Giesen had the idea to automatically archive DONE trees.
21540 @item
21541 Nicolas Goaziou rewrote much of the plain list code.
21543 @item
21544 Kai Grossjohann pointed out key-binding conflicts with other
21545 packages.
21547 @item
21548 Brian Gough of Network Theory Ltd publishes the Org mode manual as
21549 a book.
21551 @item
21552 Bernt Hansen has driven much of the support for auto-repeating
21553 tasks, task state change logging, and the clocktable.  His clear
21554 explanations have been critical when we started to adopt the Git
21555 version control system.
21557 @item
21558 Manuel Hermenegildo has contributed various ideas, small fixes and
21559 patches.
21561 @item
21562 Phil Jackson wrote @samp{org-irc.el}.
21564 @item
21565 Scott Jaderholm proposed footnotes, control over whitespace between
21566 folded entries, and column view for properties.
21568 @item
21569 Matt Jones wrote MobileOrg Android.
21571 @item
21572 Tokuya Kameshima wrote @samp{org-wl.el} and @samp{org-mew.el}.
21574 @item
21575 Shidai Liu (``Leo'') asked for embedded @LaTeX{} and tested it.  He also
21576 provided frequent feedback and some patches.
21578 @item
21579 Matt Lundin has proposed last-row references for table formulas and
21580 named invisible anchors.  He has also worked a lot on the FAQ.
21582 @item
21583 David Maus wrote @samp{org-atom.el}, maintains the issues file for Org,
21584 and is a prolific contributor on the mailing list with competent
21585 replies, small fixes and patches.
21587 @item
21588 Jason F. McBrayer suggested agenda export to CSV format.
21590 @item
21591 Max Mikhanosha came up with the idea of refiling.
21593 @item
21594 Dmitri Minaev sent a patch to set priority limits on a per-file
21595 basis.
21597 @item
21598 Stefan Monnier provided a patch to keep the Emacs Lisp compiler
21599 happy.
21601 @item
21602 Richard Moreland wrote MobileOrg for the iPhone.
21604 @item
21605 Rick Moynihan proposed allowing multiple TODO sequences in a file
21606 and being able to quickly restrict the agenda to a subtree.
21608 @item
21609 Todd Neal provided patches for links to Info files and Elisp forms.
21611 @item
21612 Greg Newman refreshed the unicorn logo into its current form.
21614 @item
21615 Tim O'Callaghan suggested in-file links, search options for general
21616 file links, and tags.
21618 @item
21619 Osamu Okano wrote @samp{orgcard2ref.pl}, a Perl program to create a text
21620 version of the reference card.
21622 @item
21623 Takeshi Okano translated the manual and David O'Toole's tutorial
21624 into Japanese.
21626 @item
21627 Oliver Oppitz suggested multi-state TODO items.
21629 @item
21630 Scott Otterson sparked the introduction of descriptive text for
21631 links, among other things.
21633 @item
21634 Pete Phillips helped during the development of the TAGS feature,
21635 and provided frequent feedback.
21637 @item
21638 Martin Pohlack provided the code snippet to bundle character
21639 insertion into bundles of 20 for undo.
21641 @item
21642 T.V. Raman reported bugs and suggested improvements.
21644 @item
21645 Matthias Rempe (Oelde) provided ideas, Windows support, and quality
21646 control.
21648 @item
21649 Paul Rivier provided the basic implementation of named footnotes.
21650 He also acted as mailing list moderator for some time.
21652 @item
21653 Kevin Rogers contributed code to access VM files on remote hosts.
21655 @item
21656 Frank Ruell solved the mystery of the @samp{keymapp nil} bug, a conflict
21657 with @samp{allout.el}.
21659 @item
21660 Jason Riedy generalized the send-receive mechanism for Orgtbl
21661 tables with extensive patches.
21663 @item
21664 Philip Rooke created the Org reference card, provided lots of
21665 feedback, developed and applied standards to the Org documentation.
21667 @item
21668 Christian Schlauer proposed angular brackets around links, among
21669 other things.
21671 @item
21672 Paul Sexton wrote @samp{org-ctags.el}.
21674 @item
21675 Tom Shannon's @samp{organizer-mode.el} inspired linking to VM/BBDB/Gnus.
21677 @item
21678 Ilya Shlyakhter proposed the Archive Sibling, line numbering in
21679 literal examples, and remote highlighting for referenced code lines.
21681 @item
21682 Stathis Sideris wrote the @samp{ditaa.jar} ASCII to PNG converter that is
21683 now packaged into Org's @samp{contrib/} directory.
21685 @item
21686 Daniel Sinder came up with the idea of internal archiving by locking
21687 subtrees.
21689 @item
21690 Dale Smith proposed link abbreviations.
21692 @item
21693 James TD Smith has contributed a large number of patches for
21694 useful tweaks and features.
21696 @item
21697 Adam Spiers asked for global linking commands, inspired the link
21698 extension system, added support for Mairix, and proposed the mapping
21699 API.
21701 @item
21702 Ulf Stegemann created the table to translate special symbols to
21703 HTML, @LaTeX{}, UTF-8, Latin-1 and ASCII.
21705 @item
21706 Andy Stewart contributed code to @samp{org-w3m.el}, to copy
21707 HTML content with links transformation to Org syntax.
21709 @item
21710 David O'Toole wrote @samp{org-publish.el} and drafted the
21711 manual chapter about publishing.
21713 @item
21714 Jambunathan K. contributed the ODT exporter.
21716 @item
21717 Sebastien Vauban reported many issues with @LaTeX{} and Beamer export
21718 and enabled source code highlighting in Gnus.
21720 @item
21721 Stefan Vollmar organized a video-recorded talk at the
21722 Max-Planck-Institute for Neurology.  He also inspired the creation
21723 of a concept index for HTML export.
21725 @item
21726 Jürgen Vollmer contributed code generating the table of contents in
21727 HTML output.
21729 @item
21730 Samuel Wales has provided important feedback and bug reports.
21732 @item
21733 Chris Wallace provided a patch implementing the @samp{QUOTE} block.
21735 @item
21736 David Wainberg suggested archiving, and improvements to the
21737 linking system.
21739 @item
21740 Carsten Wimmer suggested some changes and helped fix a bug in
21741 linking to Gnus.
21743 @item
21744 Roland Winkler requested additional key bindings to make Org work on
21745 a TTY.
21747 @item
21748 Piotr Zielinski wrote @samp{org-mouse.el}, proposed agenda
21749 blocks and contributed various ideas and code snippets.
21751 @item
21752 Marco Wahl wrote @samp{org-eww.el}.
21753 @end itemize
21755 @node GNU Free Documentation License
21756 @appendix GNU Free Documentation License
21758 @include doclicense.texi
21760 @node Main Index
21761 @chapter Main Index
21763 @printindex cp
21765 @node Key Index
21766 @chapter Key Index
21768 @printindex ky
21770 @node Command and Function Index
21771 @chapter Command and Function Index
21773 @printindex fn
21775 @node Variable Index
21776 @chapter Variable Index
21778 This is not a complete index of variables and faces, only the ones
21779 that are mentioned in the manual.  For a more complete list, use
21780 @kbd{M-x org-customize} and then click yourself through the tree.
21782 @printindex vr
21784 @bye