Move some functions into "org-macs.el"
[org-mode/org-tableheadings.git] / doc / org.texi
blobe81e24732e0122d30bb94670d63b90b0b557c28d
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 $ cd org-mode/
625 $ make autoloads
626 @end example
628 Note that in this case, @code{make autoloads} is mandatory: it defines
629 Org's version in @samp{org-version.el} and Org's autoloads in
630 @samp{org-loaddefs.el}.
632 Remember to add the correct load-path as described in the method
633 above.
635 You can also compile with @samp{make}, generate the documentation with
636 @samp{make doc}, create a local configuration with @samp{make config} and
637 install Org with @samp{make install}.  Please run @samp{make help} to get the
638 list of compilation/installation options.
640 For more detailed explanations on Org's build system, please check the
641 Org Build System page on @uref{https://orgmode.org/worg/dev/org-build-system.html, Worg}.
643 @node Activation
644 @section Activation
646 @cindex activation
647 @cindex autoload
648 @cindex ELPA
649 @cindex global key bindings
650 @cindex key bindings, global
652 Org mode buffers need Font Lock to be turned on: this is the default
653 in Emacs@footnote{If you do not use Font Lock globally turn it on in Org buffer
654 with @code{(add-hook 'org-mode-hook 'turn-on-font-lock)}.}.
656 There are compatibility issues between Org mode and some other Elisp
657 packages (see @ref{Conflicts}).  Please take the
658 time to check the list.
660 @findex org-agenda
661 @findex org-capture
662 @findex org-store-link
663 For a better experience, the three Org commands @code{org-store-link},
664 @code{org-capture} and @code{org-agenda} ought to be accessible anywhere in
665 Emacs, not just in Org buffers.  To that effect, you need to bind them
666 to globally available keys, like the ones reserved for users (see
667 @ref{Key Binding Conventions,,,elisp,}).  Here are suggested
668 bindings, please modify the keys to your own liking.
670 @lisp
671 (global-set-key "\C-cl" 'org-store-link)
672 (global-set-key "\C-ca" 'org-agenda)
673 (global-set-key "\C-cc" 'org-capture)
674 @end lisp
676 @cindex Org mode, turning on
677 Files with the @samp{.org} extension use Org mode by default.  To turn on
678 Org mode in a file that does not have the extension @samp{.org}, make the
679 first line of a file look like this:
681 @example
682 MY PROJECTS    -*- mode: org; -*-
683 @end example
685 @vindex org-insert-mode-line-in-empty-file
686 @noindent
687 which selects Org mode for this buffer no matter what the file's name
688 is.  See also the variable @code{org-insert-mode-line-in-empty-file}.
690 Many commands in Org work on the region if the region is @emph{active}.  To
691 make use of this, you need to have @code{transient-mark-mode} turned on,
692 which is the default.  If you do not like @code{transient-mark-mode}, you
693 can create an active region by using the mouse to select a region, or
694 pressing @kbd{C-@key{SPC}} twice before moving the cursor.
696 @node Feedback
697 @section Feedback
699 @cindex feedback
700 @cindex bug reports
701 @cindex reporting a bug
702 @cindex maintainer
703 @cindex author
705 If you find problems with Org, or if you have questions, remarks, or
706 ideas about it, please mail to the Org mailing list
707 @email{emacs-orgmode@@gnu.org}.  You can subscribe to the list @uref{https://lists.gnu.org/mailman/listinfo/emacs-orgmode, on this
708 web page}.  If you are not a member of the mailing list, your mail will
709 be passed to the list after a moderator has approved it@footnote{Please consider subscribing to the mailing list in order to
710 minimize the work the mailing list moderators have to do.}.
712 @findex org-version
713 @findex org-submit-bug-report
714 For bug reports, please first try to reproduce the bug with the latest
715 version of Org available---if you are running an outdated version, it
716 is quite possible that the bug has been fixed already.  If the bug
717 persists, prepare a report and provide as much information as
718 possible, including the version information of Emacs (@kbd{M-x emacs-version}) and Org (@kbd{M-x org-version}), as well as
719 the Org related setup in the Emacs init file.  The easiest way to do
720 this is to use the command
722 @example
723 M-x org-submit-bug-report <RET>
724 @end example
726 @noindent
727 which puts all this information into an Emacs mail buffer so that you
728 only need to add your description.  If you are not sending the Email
729 from within Emacs, please copy and paste the content into your Email
730 program.
732 Sometimes you might face a problem due to an error in your Emacs or
733 Org mode setup.  Before reporting a bug, it is very helpful to start
734 Emacs with minimal customizations and reproduce the problem.  Doing so
735 often helps you determine if the problem is with your customization or
736 with Org mode itself.  You can start a typical minimal session with
737 a command like the example below.
739 @example
740 $ emacs -Q -l /path/to/minimal-org.el
741 @end example
743 However if you are using Org mode as distributed with Emacs, a minimal
744 setup is not necessary.  In that case it is sufficient to start Emacs
745 as @samp{emacs -Q}.  The @samp{minimal-org.el} setup file can have contents as
746 shown below.
748 @lisp
749 ;;; Minimal setup to load latest `org-mode'.
751 ;; Activate debugging.
752 (setq debug-on-error t
753       debug-on-signal nil
754       debug-on-quit nil)
756 ;; Add latest Org mode to load path.
757 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
758 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t))
759 @end lisp
761 If an error occurs, a ``backtrace'' can be very useful---see below on
762 how to create one.  Often a small example file helps, along with clear
763 information about:
765 @enumerate
766 @item
767 What exactly did you do?
768 @item
769 What did you expect to happen?
770 @item
771 What happened instead?
772 @end enumerate
774 @noindent
775 Thank you for helping to improve this program.
777 @anchor{How to create a useful backtrace}
778 @subheading How to create a useful backtrace
780 @cindex backtrace of an error
781 If working with Org produces an error with a message you do not
782 understand, you may have hit a bug.  The best way to report this is by
783 providing, in addition to what was mentioned above, a backtrace.  This
784 is information from the built-in debugger about where and how the
785 error occurred.  Here is how to produce a useful backtrace:
787 @enumerate
788 @item
789 Reload uncompiled versions of all Org mode Lisp files.  The
790 backtrace contains much more information if it is produced with
791 uncompiled code.  To do this, use
793 @example
794 C-u M-x org-reload <RET>
795 @end example
797 @noindent
798 or, from the menu: Org @arrow{} Refresh/Reload @arrow{} Reload Org uncompiled.
800 @item
801 Then, activate the debugger:
803 @example
804 M-x toggle-debug-or-error <RET>
805 @end example
807 @noindent
808 or, from the menu: Options @arrow{} Enter Debugger on Error.
810 @item
811 Do whatever you have to do to hit the error.  Do not forget to
812 document the steps you take.
814 @item
815 When you hit the error, a @samp{*Backtrace*} buffer appears on the
816 screen.  Save this buffer to a file---for example using @kbd{C-x C-w}---and attach it to your bug report.
817 @end enumerate
819 @node Conventions
820 @section Typesetting Conventions Used in this Manual
824 @anchor{TODO keywords tags properties etc}
825 @subheading TODO keywords, tags, properties, etc.
827 Org uses various syntactical elements: TODO keywords, tags, property
828 names, keywords, blocks, etc.  In this manual we use the following
829 conventions:
831 @table @asis
832 @item @samp{TODO}
833 @itemx @samp{WAITING}
834 TODO keywords are written with all capitals, even if they are
835 user-defined.
837 @item @samp{boss}
838 @itemx @samp{ARCHIVE}
839 User-defined tags are written in lowercase; built-in tags with
840 special meaning are written with all capitals.
842 @item @samp{Release}
843 @itemx @samp{PRIORITY}
844 User-defined properties are capitalized; built-in properties with
845 special meaning are written with all capitals.
847 @item @samp{TITLE}
848 @itemx @samp{BEGIN} @dots{} @samp{END}
849 Keywords and blocks are written in uppercase to enhance their
850 readability, but you can use lowercase in your Org files.
851 @end table
853 @anchor{Key bindings and commands}
854 @subheading Key bindings and commands
856 The manual lists both the keys and the corresponding commands for
857 accessing a functionality.  Org mode often uses the same key for
858 different functions, depending on context.  The command that is bound
859 to such keys has a generic name, like @code{org-metaright}.  In the manual
860 we will, wherever possible, give the function that is internally
861 called by the generic command.  For example, in the chapter on
862 document structure, @kbd{M-@key{RIGHT}} will be listed to call
863 @code{org-do-demote}, while in the chapter on tables, it will be listed to
864 call @code{org-table-move-column-right}.
866 @node Document Structure
867 @chapter Document Structure
869 @cindex document structure
870 @cindex structure of document
872 Org is based on Outline mode and provides flexible commands to
873 edit the structure of the document.
875 @menu
876 * Outlines::                     Org is based on Outline mode.
877 * Headlines::                    How to typeset Org tree headlines.
878 * Visibility Cycling::           Show and hide, much simplified.
879 * Motion::                       Jumping to other headlines.
880 * Structure Editing::            Changing sequence and level of headlines.
881 * Sparse Trees::                 Matches embedded in context.
882 * Plain Lists::                  Additional structure within an entry.
883 * Drawers::                      Tucking stuff away.
884 * Blocks::                       Folding blocks.
885 * Creating Footnotes::           How footnotes are defined in Org's syntax.
886 * Org Syntax::                   Formal description of Org's syntax.
887 @end menu
889 @node Outlines
890 @section Outlines
892 @cindex outlines
893 @cindex Outline mode
895 Org is implemented on top of Outline mode.  Outlines allow a document
896 to be organized in a hierarchical structure, which, least for me, is
897 the best representation of notes and thoughts.  An overview of this
898 structure is achieved by folding, i.e., hiding large parts of the
899 document to show only the general document structure and the parts
900 currently being worked on.  Org greatly simplifies the use of outlines
901 by compressing the entire show and hide functionalities into a single
902 command, @code{org-cycle}, which is bound to the @kbd{@key{TAB}} key.
904 @node Headlines
905 @section Headlines
907 @cindex headlines
908 @cindex outline tree
909 @vindex org-special-ctrl-a/e
910 @vindex org-special-ctrl-k
911 @vindex org-ctrl-k-protect-subtree
913 Headlines define the structure of an outline tree.  The headlines in
914 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},
915 and @code{org-ctrl-k-protect-subtree} to configure special behavior of
916 @kbd{C-a}, @kbd{C-e}, and @kbd{C-k} in headlines.  Note
917 also that clocking only works with headings indented less than 30
918 stars.}.  For
919 example:
921 @example
922 * Top level headline
923 ** Second level
924 *** Third level
925     some text
926 *** Third level
927     more text
928 * Another top level headline
929 @end example
931 @vindex org-footnote-section
932 @noindent
933 Note that the name defined in @code{org-footnote-section} is reserved.  Do
934 not use it as a title for your own headings.
936 Some people find the many stars too noisy and would prefer an outline
937 that has whitespace followed by a single star as headline starters.
938 See @ref{Clean View}.
940 @vindex org-cycle-separator-lines
941 An empty line after the end of a subtree is considered part of it and
942 is hidden when the subtree is folded.  However, if you leave at least
943 two empty lines, one empty line remains visible after folding the
944 subtree, in order to structure the collapsed view.  See the variable
945 @code{org-cycle-separator-lines} to modify this behavior.
947 @node Visibility Cycling
948 @section Visibility Cycling
950 @cindex cycling, visibility
951 @cindex visibility cycling
952 @cindex trees, visibility
953 @cindex show hidden text
954 @cindex hide text
956 @menu
957 * Global and local cycling::     Cycling through various visibility states.
958 * Initial visibility::           Setting the initial visibility state.
959 * Catching invisible edits::     Preventing mistakes when editing invisible parts.
960 @end menu
962 @node Global and local cycling
963 @subsection Global and local cycling
965 @cindex subtree visibility states
966 @cindex subtree cycling
967 @cindex folded, subtree visibility state
968 @cindex children, subtree visibility state
969 @cindex subtree, subtree visibility state
971 Outlines make it possible to hide parts of the text in the buffer.
972 Org uses just two commands, bound to @kbd{@key{TAB}} and
973 @kbd{S-@key{TAB}} to change the visibility in the buffer.
975 @table @asis
976 @item @kbd{@key{TAB}} (@code{org-cycle})
977 @kindex TAB
978 @findex org-cycle
979 @emph{Subtree cycling}: Rotate current subtree among the states
981 @example
982 ,-> FOLDED -> CHILDREN -> SUBTREE --.
983 '-----------------------------------'
984 @end example
986 @vindex org-cycle-emulate-tab
987 The cursor must be on a headline for this to work@footnote{See, however, the option @code{org-cycle-emulate-tab}.}.
989 @item @kbd{S-@key{TAB}} (@code{org-global-cycle})
990 @itemx @kbd{C-u @key{TAB}}
991 @cindex global visibility states
992 @cindex global cycling
993 @cindex overview, global visibility state
994 @cindex contents, global visibility state
995 @cindex show all, global visibility state
996 @kindex C-u TAB
997 @kindex S-TAB
998 @findex org-global-cycle
999 @emph{Global cycling}: Rotate the entire buffer among the states
1001 @example
1002 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
1003 '--------------------------------------'
1004 @end example
1006 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N,
1007 the CONTENTS view up to headlines of level N are shown.  Note
1008 that inside tables (see @ref{Tables}), @kbd{S-@key{TAB}} jumps to the
1009 previous field instead.
1011 @vindex org-cycle-global-at-bob
1012 You can run global cycling using @kbd{@key{TAB}} only if point is
1013 at the very beginning of the buffer, but not on a headline, and
1014 @code{org-cycle-global-at-bob} is set to a non-@code{nil} value.
1016 @item @kbd{C-u C-u @key{TAB}} (@code{org-set-startup-visibility})
1017 @cindex startup visibility
1018 @kindex C-u C-u TAB
1019 @findex org-set-startup-visibility
1020 Switch back to the startup visibility of the buffer (see @ref{Initial visibility}).
1022 @item @kbd{C-u C-u C-u @key{TAB}} (@code{outline-show-all})
1023 @cindex show all, command
1024 @kindex C-u C-u C-u TAB
1025 @findex outline-show-all
1026 Show all, including drawers.
1028 @item @kbd{C-c C-r} (@code{org-reveal})
1029 @cindex revealing context
1030 @kindex C-c C-r
1031 @findex org-reveal
1032 Reveal context around point, showing the current entry, the
1033 following heading and the hierarchy above.  Useful for working
1034 near a location that has been exposed by a sparse tree command
1035 (see @ref{Sparse Trees}) or an agenda command (see @ref{Agenda Commands}).  With a prefix argument show, on each level, all
1036 sibling headings.  With a double prefix argument, also show the
1037 entire subtree of the parent.
1039 @item @kbd{C-c C-k} (@code{outline-show-branches})
1040 @cindex show branches, command
1041 @kindex C-c C-k
1042 @findex outline-show-branches
1043 Expose all the headings of the subtree, CONTENTS view for just
1044 one subtree.
1046 @item @kbd{C-c @key{TAB}} (@code{outline-show-children})
1047 @cindex show children, command
1048 @kindex C-c TAB
1049 @findex outline-show-children
1050 Expose all direct children of the subtree.  With a numeric prefix
1051 argument N, expose all children down to level N.
1053 @item @kbd{C-c C-x b} (@code{org-tree-to-indirect-buffer})
1054 @kindex C-c C-x b
1055 @findex org-tree-to-indirect-buffer
1056 Show the current subtree in an indirect buffer@footnote{The indirect buffer contains the entire buffer, but is narrowed
1057 to the current tree.  Editing the indirect buffer also changes the
1058 original buffer, but without affecting visibility in that buffer.  For
1059 more information about indirect buffers, see @ref{Indirect Buffers,GNU Emacs Manual,,emacs,}.}.  With
1060 a numeric prefix argument, N, go up to level N and then take that
1061 tree.  If N is negative then go up that many levels.  With
1062 a @kbd{C-u} prefix, do not remove the previously used
1063 indirect buffer.
1065 @item @kbd{C-c C-x v} (@code{org-copy-visible})
1066 @kindex C-c C-x v
1067 @findex org-copy-visible
1068 Copy the @emph{visible} text in the region into the kill ring.
1069 @end table
1071 @node Initial visibility
1072 @subsection Initial visibility
1074 @vindex org-startup-folded
1075 When Emacs first visits an Org file, the global state is set to
1076 OVERVIEW, i.e., only the top level headlines are visible@footnote{When @code{org-agenda-inhibit-startup} is non-@code{nil}, Org does not
1077 honor the default visibility state when first opening a file for the
1078 agenda (see @ref{Speeding Up Your Agendas}).}.  This
1079 can be configured through the variable @code{org-startup-folded}, or on
1080 a per-file basis by adding one of the following lines anywhere in the
1081 buffer:
1083 @cindex STARTUP, keyword
1084 @example
1085 #+STARTUP: overview
1086 #+STARTUP: content
1087 #+STARTUP: showall
1088 #+STARTUP: showeverything
1089 @end example
1091 @cindex @samp{VISIBILITY}, property
1092 @noindent
1093 Furthermore, any entries with a @samp{VISIBILITY} property (see @ref{Properties and Columns}) get their visibility adapted accordingly.  Allowed values
1094 for this property are @samp{folded}, @samp{children}, @samp{content}, and @code{all}.
1096 @table @asis
1097 @item @kbd{C-u C-u @key{TAB}} (@code{org-set-startup-visibility})
1098 @kindex C-u C-u TAB
1099 @findex org-set-startup-visibility
1100 Switch back to the startup visibility of the buffer, i.e.,
1101 whatever is requested by startup options and @samp{VISIBILITY}
1102 properties in individual entries.
1103 @end table
1105 @node Catching invisible edits
1106 @subsection Catching invisible edits
1108 @cindex edits, catching invisible
1110 @vindex org-catch-invisible-edits
1111 Sometimes you may inadvertently edit an invisible part of the buffer
1112 and be confused on what has been edited and how to undo the mistake.
1113 Setting @code{org-catch-invisible-edits} to non-@code{nil} helps preventing
1114 this.  See the docstring of this option on how Org should catch
1115 invisible edits and process them.
1117 @node Motion
1118 @section Motion
1120 @cindex motion, between headlines
1121 @cindex jumping, to headlines
1122 @cindex headline navigation
1124 The following commands jump to other headlines in the buffer.
1126 @table @asis
1127 @item @kbd{C-c C-n} (@code{outline-next-visible-heading})
1128 @kindex C-c C-n
1129 @findex outline-next-visible-heading
1130 Next heading.
1132 @item @kbd{C-c C-p} (@code{outline-previous-visible-heading})
1133 @kindex C-c C-p
1134 @findex outline-previous-visible-heading
1135 Previous heading.
1137 @item @kbd{C-c C-f} (@code{org-forward-same-level})
1138 @kindex C-c C-f
1139 @findex org-forward-same-level
1140 Next heading same level.
1142 @item @kbd{C-c C-b} (@code{org-backward-same-level})
1143 @kindex C-c C-b
1144 @findex org-backward-same-level
1145 Previous heading same level.
1147 @item @kbd{C-c C-u} (@code{outline-up-heading})
1148 @kindex C-c C-u
1149 @findex outline-up-heading
1150 Backward to higher level heading.
1152 @item @kbd{C-c C-j} (@code{org-goto})
1153 @kindex C-c C-j
1154 @findex org-goto
1155 @vindex org-goto-auto-isearch
1156 Jump to a different place without changing the current outline
1157 visibility.  Shows the document structure in a temporary buffer,
1158 where you can use the following keys to find your destination:
1160 @multitable @columnfractions 0.3 0.7
1161 @item @kbd{@key{TAB}}
1162 @tab Cycle visibility.
1163 @item @kbd{@key{DOWN}} / @kbd{@key{UP}}
1164 @tab Next/previous visible headline.
1165 @item @kbd{@key{RET}}
1166 @tab Select this location.
1167 @item @kbd{/}
1168 @tab Do a Sparse-tree search
1169 @end multitable
1171 @noindent
1172 The following keys work if you turn off @code{org-goto-auto-isearch}
1174 @multitable @columnfractions 0.3 0.7
1175 @item @kbd{n} / @kbd{p}
1176 @tab Next/previous visible headline.
1177 @item @kbd{f} / @kbd{b}
1178 @tab Next/previous headline same level.
1179 @item @kbd{u}
1180 @tab One level up.
1181 @item @kbd{0} @dots{} @kbd{9}
1182 @tab Digit argument.
1183 @item @kbd{q}
1184 @tab Quit.
1185 @end multitable
1187 @vindex org-goto-interface
1188 @noindent
1189 See also the variable @code{org-goto-interface}.
1190 @end table
1192 @node Structure Editing
1193 @section Structure Editing
1195 @cindex structure editing
1196 @cindex headline, promotion and demotion
1197 @cindex promotion, of subtrees
1198 @cindex demotion, of subtrees
1199 @cindex subtree, cut and paste
1200 @cindex pasting, of subtrees
1201 @cindex cutting, of subtrees
1202 @cindex copying, of subtrees
1203 @cindex sorting, of subtrees
1204 @cindex subtrees, cut and paste
1206 @table @asis
1207 @item @kbd{M-@key{RET}} (@code{org-meta-return})
1208 @kindex M-RET
1209 @findex org-meta-return
1210 @vindex org-M-RET-may-split-line
1211 Insert a new heading, item or row.
1213 If the command is used at the @emph{beginning} of a line, and if there
1214 is a heading or a plain list item (see @ref{Plain Lists}) at point,
1215 the new heading/item is created @emph{before} the current line.  When
1216 used at the beginning of a regular line of text, turn that line
1217 into a heading.
1219 When this command is used in the middle of a line, the line is
1220 split and the rest of the line becomes the new item or headline.
1221 If you do not want the line to be split, customize
1222 @code{org-M-RET-may-split-line}.
1224 Calling the command with a @kbd{C-u} prefix unconditionally
1225 inserts a new heading at the end of the current subtree, thus
1226 preserving its contents.  With a double @kbd{C-u C-u}
1227 prefix, the new heading is created at the end of the parent
1228 subtree instead.
1230 @item @kbd{C-@key{RET}} (@code{org-insert-heading-respect-content})
1231 @kindex C-RET
1232 @findex org-insert-heading-respect-content
1233 Insert a new heading at the end of the current subtree.
1235 @item @kbd{M-S-@key{RET}} (@code{org-insert-todo-heading})
1236 @kindex M-S-RET
1237 @findex org-insert-todo-heading
1238 @vindex org-treat-insert-todo-heading-as-state-change
1239 Insert new TODO entry with same level as current heading.  See
1240 also the variable
1241 @code{org-treat-insert-todo-heading-as-state-change}.
1243 @item @kbd{C-S-@key{RET}} (@code{org-insert-todo-heading-respect-content})
1244 @kindex C-S-RET
1245 @findex org-insert-todo-heading-respect-content
1246 Insert new TODO entry with same level as current heading.  Like
1247 @kbd{C-@key{RET}}, the new headline is inserted after the current
1248 subtree.
1250 @item @kbd{@key{TAB}} (@code{org-cycle})
1251 @kindex TAB
1252 @findex org-cycle
1253 In a new entry with no text yet, the first @kbd{@key{TAB}} demotes
1254 the entry to become a child of the previous one.  The next
1255 @kbd{@key{TAB}} makes it a parent, and so on, all the way to top
1256 level.  Yet another @kbd{@key{TAB}}, and you are back to the
1257 initial level.
1259 @item @kbd{M-@key{LEFT}} (@code{org-do-promote})
1260 @kindex M-LEFT
1261 @findex org-do-promote
1262 Promote current heading by one level.
1264 @item @kbd{M-@key{RIGHT}} (@code{org-do-demote})
1265 @kindex M-RIGHT
1266 @findex org-do-demote
1267 Demote current heading by one level.
1269 @item @kbd{M-S-@key{LEFT}} (@code{org-promote-subtree})
1270 @kindex M-S-LEFT
1271 @findex org-promote-subtree
1272 Promote the current subtree by one level.
1274 @item @kbd{M-S-@key{RIGHT}} (@code{org-demote-subtree})
1275 @kindex M-S-RIGHT
1276 @findex org-demote-subtree
1277 Demote the current subtree by one level.
1279 @item @kbd{M-@key{UP}} (@code{org-move-subtree-up})
1280 @kindex M-UP
1281 @findex org-move-subtree-up
1282 Move subtree up, i.e., swap with previous subtree of same level.
1284 @item @kbd{M-@key{DOWN}} (@code{org-move-subtree-down})
1285 @kindex M-DOWN
1286 @findex org-move-subtree-down
1287 Move subtree down, i.e., swap with next subtree of same level.
1289 @item @kbd{C-c @@} (@code{org-mark-subtree})
1290 @kindex C-c @@
1291 @findex org-mark-subtree
1292 Mark the subtree at point.  Hitting repeatedly marks subsequent
1293 subtrees of the same level as the marked subtree.
1295 @item @kbd{C-c C-x C-w} (@code{org-cut-subtree})
1296 @kindex C-c C-x C-w
1297 @findex org-cut-subtree
1298 Kill subtree, i.e., remove it from buffer but save in kill ring.
1299 With a numeric prefix argument N, kill N sequential subtrees.
1301 @item @kbd{C-c C-x M-w} (@code{org-copy-subtree})
1302 @kindex C-c C-x M-w
1303 @findex org-copy-subtree
1304 Copy subtree to kill ring.  With a numeric prefix argument N,
1305 copy the N sequential subtrees.
1307 @item @kbd{C-c C-x C-y} (@code{org-paste-subtree})
1308 @kindex C-c C-x C-y
1309 @findex org-paste-subtree
1310 Yank subtree from kill ring.  This does modify the level of the
1311 subtree to make sure the tree fits in nicely at the yank
1312 position.  The yank level can also be specified with a numeric
1313 prefix argument, or by yanking after a headline marker like
1314 @samp{****}.
1316 @item @kbd{C-y} (@code{org-yank})
1317 @kindex C-y
1318 @findex org-yank
1319 @vindex org-yank-adjusted-subtrees
1320 @vindex org-yank-folded-subtrees
1321 Depending on the variables @code{org-yank-adjusted-subtrees} and
1322 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command pastes
1323 subtrees folded and in a clever way, using the same command as
1324 @kbd{C-c C-x C-y}.  With the default settings, no level
1325 adjustment takes place, but the yanked tree is folded unless
1326 doing so would swallow text previously visible.  Any prefix
1327 argument to this command forces a normal @code{yank} to be executed,
1328 with the prefix passed along.  A good way to force a normal yank
1329 is @kbd{C-u C-y}.  If you use @code{yank-pop} after a yank, it
1330 yanks previous kill items plainly, without adjustment and
1331 folding.
1333 @item @kbd{C-c C-x c} (@code{org-clone-subtree-with-time-shift})
1334 @kindex C-c C-x c
1335 @findex org-clone-subtree-with-time-shift
1336 Clone a subtree by making a number of sibling copies of it.  You
1337 are prompted for the number of copies to make, and you can also
1338 specify if any timestamps in the entry should be shifted.  This
1339 can be useful, for example, to create a number of tasks related
1340 to a series of lectures to prepare.  For more details, see the
1341 docstring of the command @code{org-clone-subtree-with-time-shift}.
1343 @item @kbd{C-c C-w} (@code{org-refile})
1344 @kindex C-c C-w
1345 @findex org-refile
1346 Refile entry or region to a different location.  See @ref{Refile and Copy}.
1348 @item @kbd{C-c ^} (@code{org-sort})
1349 @kindex C-c ^
1350 @findex org-sort
1351 Sort same-level entries.  When there is an active region, all
1352 entries in the region are sorted.  Otherwise the children of the
1353 current headline are sorted.  The command prompts for the sorting
1354 method, which can be alphabetically, numerically, by time---first
1355 timestamp with active preferred, creation time, scheduled time,
1356 deadline time---by priority, by TODO keyword---in the sequence
1357 the keywords have been defined in the setup---or by the value of
1358 a property.  Reverse sorting is possible as well.  You can also
1359 supply your own function to extract the sorting key.  With
1360 a @kbd{C-u} prefix, sorting is case-sensitive.
1362 @item @kbd{C-x n s} (@code{org-narrow-to-subtree})
1363 @kindex C-x n s
1364 @findex org-narrow-to-subtree
1365 Narrow buffer to current subtree.
1367 @item @kbd{C-x n b} (@code{org-narrow-to-block})
1368 @kindex C-x n b
1369 @findex org-narrow-to-block
1370 Narrow buffer to current block.
1372 @item @kbd{C-x n w} (@code{widen})
1373 @kindex C-x n w
1374 @findex widen
1375 Widen buffer to remove narrowing.
1377 @item @kbd{C-c *} (@code{org-toggle-heading})
1378 @kindex C-c *
1379 @findex org-toggle-heading
1380 Turn a normal line or plain list item into a headline---so that
1381 it becomes a subheading at its location.  Also turn a headline
1382 into a normal line by removing the stars.  If there is an active
1383 region, turn all lines in the region into headlines.  If the
1384 first line in the region was an item, turn only the item lines
1385 into headlines.  Finally, if the first line is a headline, remove
1386 the stars from all headlines in the region.
1387 @end table
1389 @cindex region, active
1390 @cindex active region
1391 @cindex transient mark mode
1392 When there is an active region---i.e., when Transient Mark mode is
1393 active---promotion and demotion work on all headlines in the region.
1394 To select a region of headlines, it is best to place both point and
1395 mark at the beginning of a line, mark at the beginning of the first
1396 headline, and point at the line just after the last headline to
1397 change.  Note that when the cursor is inside a table (see @ref{Tables}),
1398 the Meta-Cursor keys have different functionality.
1400 @node Sparse Trees
1401 @section Sparse Trees
1403 @cindex sparse trees
1404 @cindex trees, sparse
1405 @cindex folding, sparse trees
1406 @cindex occur, command
1408 @vindex org-show-context-detail
1409 An important feature of Org mode is the ability to construct @emph{sparse
1410 trees} for selected information in an outline tree, so that the entire
1411 document is folded as much as possible, but the selected information
1412 is made visible along with the headline structure above it@footnote{See also the variable @code{org-show-context-detail} to decide how
1413 much context is shown around each match.}.
1414 Just try it out and you will see immediately how it works.
1416 Org mode contains several commands creating such trees, all these
1417 commands can be accessed through a dispatcher:
1419 @table @asis
1420 @item @kbd{C-c /} (@code{org-sparse-tree})
1421 @kindex C-c /
1422 @findex org-sparse-tree
1423 This prompts for an extra key to select a sparse-tree creating
1424 command.
1426 @item @kbd{C-c / r} or @kbd{C-c / /} (@code{org-occur})
1427 @kindex C-c / r
1428 @kindex C-c / /
1429 @findex org-occur
1430 @vindex org-remove-highlights-with-change
1431 Prompts for a regexp and shows a sparse tree with all matches.
1432 If the match is in a headline, the headline is made visible.  If
1433 the match is in the body of an entry, headline and body are made
1434 visible.  In order to provide minimal context, also the full
1435 hierarchy of headlines above the match is shown, as well as the
1436 headline following the match.  Each match is also highlighted;
1437 the highlights disappear when the buffer is changed by an editing
1438 command, or by pressing @kbd{C-c C-c}@footnote{This depends on the option @code{org-remove-highlights-with-change}.}.  When called
1439 with a @kbd{C-u} prefix argument, previous highlights are
1440 kept, so several calls to this command can be stacked.
1442 @item @kbd{M-g n} or @kbd{M-g M-n} (@code{next-error})
1443 @kindex M-g n
1444 @kindex M-g M-n
1445 @findex next-error
1446 Jump to the next sparse tree match in this buffer.
1448 @item @kbd{M-g p} or @kbd{M-g M-p} (@code{previous-error})
1449 @kindex M-g p
1450 @kindex M-g M-p
1451 @findex previous-error
1452 Jump to the previous sparse tree match in this buffer.
1453 @end table
1455 @vindex org-agenda-custom-commands
1456 @noindent
1457 For frequently used sparse trees of specific search strings, you can
1458 use the variable @code{org-agenda-custom-commands} to define fast keyboard
1459 access to specific sparse trees.  These commands will then be
1460 accessible through the agenda dispatcher (see @ref{Agenda Dispatcher}).
1461 For example:
1463 @lisp
1464 (setq org-agenda-custom-commands
1465       '(("f" occur-tree "FIXME")))
1466 @end lisp
1468 @noindent
1469 defines the key @kbd{f} as a shortcut for creating a sparse tree
1470 matching the string @samp{FIXME}.
1472 The other sparse tree commands select headings based on TODO keywords,
1473 tags, or properties and are discussed later in this manual.
1475 @kindex C-c C-e v
1476 @cindex printing sparse trees
1477 @cindex visible text, printing
1478 To print a sparse tree, you can use the Emacs command
1479 @code{ps-print-buffer-with-faces} which does not print invisible parts of
1480 the document.  Or you can use the command @kbd{C-c C-e v} to
1481 export only the visible part of the document and print the resulting
1482 file.
1484 @node Plain Lists
1485 @section Plain Lists
1487 @cindex plain lists
1488 @cindex lists, plain
1489 @cindex lists, ordered
1490 @cindex ordered lists
1492 Within an entry of the outline tree, hand-formatted lists can provide
1493 additional structure.  They also provide a way to create lists of
1494 checkboxes (see @ref{Checkboxes}).  Org supports editing such lists, and
1495 every exporter (see @ref{Exporting}) can parse and format them.
1497 Org knows ordered lists, unordered lists, and description lists.
1499 @itemize
1500 @item
1501 @emph{Unordered} list items start with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented so that they
1502 are not interpreted as headlines.  Also, when you are hiding leading
1503 stars to get a clean outline view, plain list items starting with
1504 a star may be hard to distinguish from true headlines.  In short: even
1505 though @samp{*} is supported, it may be better to not use it for plain list
1506 items.} as bullets.
1508 @item
1509 @vindex org-plain-list-ordered-item-terminator
1510 @vindex org-alphabetical-lists
1511 @emph{Ordered} list items start with a numeral followed by either
1512 a period or a right parenthesis@footnote{You can filter out any of them by configuring
1513 @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
1514 @code{org-list-allow-alphabetical}.  To minimize confusion with normal
1515 text, those are limited to one character only.  Beyond that limit,
1516 bullets automatically become numbers.}
1517 If you want a list to start with a different value---e.g.,
1518 20---start the text of the item with @samp{[@@20]}@footnote{If there's a checkbox in the item, the cookie must be put
1519 @emph{before} the checkbox.  If you have activated alphabetical lists, you
1520 can also use counters like @samp{[@@b]}.}.  Those
1521 constructs can be used in any item of the list in order to enforce
1522 a particular numbering.
1524 @item
1525 @emph{Description} list items are unordered list items, and contain the
1526 separator @samp{::} to distinguish the description @emph{term} from the
1527 description.
1528 @end itemize
1530 Items belonging to the same list must have the same indentation on the
1531 first line.  In particular, if an ordered list reaches number @samp{10.},
1532 then the 2-digit numbers must be written left-aligned with the other
1533 numbers in the list.  An item ends before the next line that is less
1534 or equally indented than its bullet/number.
1536 A list ends whenever every item has ended, which means before any line
1537 less or equally indented than items at top level.  It also ends before
1538 two blank lines.  In that case, all items are closed.  Here is an
1539 example:
1541 @example
1542 * Lord of the Rings
1543 My favorite scenes are (in this order)
1544 1. The attack of the Rohirrim
1545 2. Eowyn's fight with the witch king
1546    + this was already my favorite scene in the book
1547    + I really like Miranda Otto.
1548 3. Peter Jackson being shot by Legolas
1549    - on DVD only
1550    He makes a really funny face when it happens.
1551 But in the end, no individual scenes matter but the film as a whole.
1552 Important actors in this film are:
1553 - Elijah Wood :: He plays Frodo
1554 - Sean Astin :: He plays Sam, Frodo's friend. I still remember him
1555      very well from his role as Mikey Walsh in /The Goonies/.
1556 @end example
1558 Org supports these lists by tuning filling and wrapping commands to
1559 deal with them correctly, and by exporting them properly (see
1560 @ref{Exporting}).  Since indentation is what governs the structure of these
1561 lists, many structural constructs like @samp{#+BEGIN_} blocks can be
1562 indented to signal that they belong to a particular item.
1564 @vindex org-list-demote-modify-bullet
1565 @vindex org-list-indent-offset
1566 If you find that using a different bullet for a sub-list---than that
1567 used for the current list-level---improves readability, customize the
1568 variable @code{org-list-demote-modify-bullet}.  To get a greater difference
1569 of indentation between items and theirs sub-items, customize
1570 @code{org-list-indent-offset}.
1572 @vindex org-list-automatic-rules
1573 The following commands act on items when the cursor is in the first
1574 line of an item---the line with the bullet or number.  Some of them
1575 imply the application of automatic rules to keep list structure
1576 intact.  If some of these actions get in your way, configure
1577 @code{org-list-automatic-rules} to disable them individually.
1579 @table @asis
1580 @item @kbd{@key{TAB}} (@code{org-cycle})
1581 @cindex cycling, in plain lists
1582 @kindex TAB
1583 @findex org-cycle
1584 @vindex org-cycle-include-plain-lists
1585 Items can be folded just like headline levels.  Normally this
1586 works only if the cursor is on a plain list item.  For more
1587 details, see the variable @code{org-cycle-include-plain-lists}.  If
1588 this variable is set to @code{integrate}, plain list items are treated
1589 like low-level headlines.  The level of an item is then given by
1590 the indentation of the bullet/number.  Items are always
1591 subordinate to real headlines, however; the hierarchies remain
1592 completely separated.  In a new item with no text yet, the first
1593 @kbd{@key{TAB}} demotes the item to become a child of the previous
1594 one.  Subsequent @kbd{@key{TAB}}s move the item to meaningful
1595 levels in the list and eventually get it back to its initial
1596 position.
1598 @item @kbd{M-@key{RET}} (@code{org-insert-heading})
1599 @kindex M-RET
1600 @findex org-insert-heading
1601 @vindex org-M-RET-may-split-line
1602 Insert new item at current level.  With a prefix argument, force
1603 a new heading (see @ref{Structure Editing}).  If this command is used
1604 in the middle of an item, that item is @emph{split} in two, and the
1605 second part becomes the new item@footnote{If you do not want the item to be split, customize the
1606 variable @code{org-M-RET-may-split-line}.}.  If this command is
1607 executed @emph{before item's body}, the new item is created @emph{before}
1608 the current one.
1610 @item @kbd{M-S-@key{RET}}
1611 @kindex M-S-RET
1612 Insert a new item with a checkbox (see @ref{Checkboxes}).
1614 @item @kbd{S-@key{UP}}
1615 @itemx @kbd{S-@key{DOWN}}
1616 @kindex S-UP
1617 @kindex S-DOWN
1618 @cindex shift-selection-mode
1619 @vindex org-support-shift-select
1620 @vindex org-list-use-circular-motion
1621 Jump to the previous/next item in the current list, but only if
1622 @code{org-support-shift-select} is off@footnote{If you want to cycle around items that way, you may customize
1623 @code{org-list-use-circular-motion}.}.  If not, you can
1624 still use paragraph jumping commands like @kbd{C-@key{UP}}
1625 and @kbd{C-@key{DOWN}} to quite similar effect.
1627 @item @kbd{M-@key{UP}}
1628 @itemx @kbd{M-@key{DOWN}}
1629 @kindex M-UP
1630 @kindex M-DOWN
1631 Move the item including subitems up/down@footnote{See @code{org-list-use-circular-motion} for a cyclic behavior.}, i.e., swap with
1632 previous/next item of same indentation.  If the list is ordered,
1633 renumbering is automatic.
1635 @item @kbd{M-@key{LEFT}}
1636 @itemx @kbd{M-@key{RIGHT}}
1637 @kindex M-LEFT
1638 @kindex M-RIGHT
1639 Decrease/increase the indentation of an item, leaving children
1640 alone.
1642 @item @kbd{M-S-@key{LEFT}}
1643 @itemx @kbd{M-S-@key{RIGHT}}
1644 @kindex M-S-LEFT
1645 @kindex M-S-RIGHT
1646 Decrease/increase the indentation of the item, including
1647 subitems.  Initially, the item tree is selected based on current
1648 indentation.  When these commands are executed several times in
1649 direct succession, the initially selected region is used, even if
1650 the new indentation would imply a different hierarchy.  To use
1651 the new hierarchy, break the command chain with a cursor motion
1652 or so.
1654 As a special case, using this command on the very first item of
1655 a list moves the whole list.  This behavior can be disabled by
1656 configuring @code{org-list-automatic-rules}.  The global indentation
1657 of a list has no influence on the text @emph{after} the list.
1659 @item @kbd{C-c C-c}
1660 @kindex C-c C-c
1661 If there is a checkbox (see @ref{Checkboxes}) in the item line, toggle
1662 the state of the checkbox.  In any case, verify bullets and
1663 indentation consistency in the whole list.
1665 @item @kbd{C-c -}
1666 @kindex C-c -
1667 @vindex org-plain-list-ordered-item-terminator
1668 Cycle the entire list level through the different
1669 itemize/enumerate bullets (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}) or a subset
1670 of them, depending on @code{org-plain-list-ordered-item-terminator},
1671 the type of list, and its indentation.  With a numeric prefix
1672 argument N, select the Nth bullet from this list.  If there is an
1673 active region when calling this, selected text is changed into an
1674 item.  With a prefix argument, all lines are converted to list
1675 items.  If the first line already was a list item, any item
1676 marker is removed from the list.  Finally, even without an active
1677 region, a normal line is converted into a list item.
1679 @item @kbd{C-c *}
1680 @kindex C-c *
1681 Turn a plain list item into a headline---so that it becomes
1682 a subheading at its location.  See @ref{Structure Editing}, for
1683 a detailed explanation.
1685 @item @kbd{C-c C-*}
1686 @kindex C-c C-*
1687 Turn the whole plain list into a subtree of the current heading.
1688 Checkboxes (see @ref{Checkboxes}) become TODO, respectively DONE,
1689 keywords when unchecked, respectively checked.
1691 @item @kbd{S-@key{LEFT}}
1692 @itemx @kbd{S-@key{RIGHT}}
1693 @vindex org-support-shift-select
1694 @kindex S-LEFT
1695 @kindex S-RIGHT
1696 This command also cycles bullet styles when the cursor in on the
1697 bullet or anywhere in an item line, details depending on
1698 @code{org-support-shift-select}.
1700 @item @kbd{C-c ^}
1701 @kindex C-c ^
1702 @cindex sorting, of plain list
1703 Sort the plain list.  Prompt for the sorting method: numerically,
1704 alphabetically, by time, or by custom function.
1705 @end table
1707 @node Drawers
1708 @section Drawers
1710 @cindex drawers
1711 @cindex visibility cycling, drawers
1713 Sometimes you want to keep information associated with an entry, but
1714 you normally do not want to see it.  For this, Org mode has @emph{drawers}.
1715 They can contain anything but a headline and another drawer.  Drawers
1716 look like this:
1718 @example
1719 ** This is a headline
1720 Still outside the drawer
1721 :DRAWERNAME:
1722 This is inside the drawer.
1723 :END:
1724 After the drawer.
1725 @end example
1727 @kindex C-c C-x d
1728 @findex org-insert-drawer
1729 You can interactively insert a drawer at point by calling
1730 @code{org-insert-drawer}, which is bound to @kbd{C-c C-x d}.  With an
1731 active region, this command puts the region inside the drawer.  With
1732 a prefix argument, this command calls @code{org-insert-property-drawer},
1733 which creates a @samp{PROPERTIES} drawer right below the current headline.
1734 Org mode uses this special drawer for storing properties (see
1735 @ref{Properties and Columns}).  You cannot use it for anything else.
1737 Completion over drawer keywords is also possible using
1738 @kbd{M-@key{TAB}}@footnote{Many desktops intercept @kbd{M-@key{TAB}} to switch windows.
1739 Use @kbd{C-M-i} or @kbd{@key{ESC} @key{TAB}} instead.}.
1741 Visibility cycling (see @ref{Visibility Cycling}) on the headline hides and
1742 shows the entry, but keep the drawer collapsed to a single line.  In
1743 order to look inside the drawer, you need to move the cursor to the
1744 drawer line and press @kbd{@key{TAB}} there.
1746 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
1747 a @samp{LOGBOOK} drawer.  If you want to store a quick note there, in
1748 a similar way to state changes, use
1750 @table @asis
1751 @item @kbd{C-c C-z}
1752 @kindex C-c C-z
1753 Add a time-stamped note to the @samp{LOGBOOK} drawer.
1754 @end table
1756 @node Blocks
1757 @section Blocks
1759 @vindex org-hide-block-startup
1760 @cindex blocks, folding
1762 Org mode uses @samp{#+BEGIN} @dots{} @samp{#+END} blocks for various purposes from
1763 including source code examples (see @ref{Literal Examples}) to capturing
1764 time logging information (see @ref{Clocking Work Time}).  These blocks can
1765 be folded and unfolded by pressing @kbd{@key{TAB}} in the @samp{#+BEGIN}
1766 line.  You can also get all blocks folded at startup by configuring
1767 the variable @code{org-hide-block-startup} or on a per-file basis by using
1769 @cindex STARTUP, keyword
1770 @example
1771 #+STARTUP: hideblocks
1772 #+STARTUP: nohideblocks
1773 @end example
1775 @node Creating Footnotes
1776 @section Creating Footnotes
1778 @cindex footnotes
1780 Org mode supports the creation of footnotes.
1782 A footnote is started by a footnote marker in square brackets in
1783 column 0, no indentation allowed.  It ends at the next footnote
1784 definition, headline, or after two consecutive empty lines.  The
1785 footnote reference is simply the marker in square brackets, inside
1786 text.  Markers always start with @samp{fn:}.  For example:
1788 @example
1789 The Org homepage[fn:1] now looks a lot better than it used to.
1791 [fn:1] The link is: https://orgmode.org
1792 @end example
1794 Org mode extends the number-based syntax to @emph{named} footnotes and
1795 optional inline definition.  Here are the valid references:
1797 @table @asis
1798 @item @samp{[fn:NAME]}
1799 A named footnote reference, where @var{NAME} is a unique
1800 label word, or, for simplicity of automatic creation, a number.
1802 @item @samp{[fn:: This is the inline definition of this footnote]}
1803 A @LaTeX{}-like anonymous footnote where the definition is given
1804 directly at the reference point.
1806 @item @samp{[fn:NAME: a definition]}
1807 An inline definition of a footnote, which also specifies a name
1808 for the note.  Since Org allows multiple references to the same
1809 note, you can then use @samp{[fn:NAME]} to create additional
1810 references.
1811 @end table
1813 @vindex org-footnote-auto-label
1814 Footnote labels can be created automatically, or you can create names
1815 yourself.  This is handled by the variable @code{org-footnote-auto-label}
1816 and its corresponding @samp{STARTUP} keywords.  See the docstring of that
1817 variable for details.
1819 @noindent
1820 The following command handles footnotes:
1822 @table @asis
1823 @item @kbd{C-c C-x f}
1824 The footnote action command.
1826 @kindex C-c C-x f
1827 When the cursor is on a footnote reference, jump to the
1828 definition.  When it is at a definition, jump to
1829 the---first---reference.
1831 @vindex org-footnote-define-inline
1832 @vindex org-footnote-section
1833 Otherwise, create a new footnote.  Depending on the variable
1834 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer setting is: @samp{#+STARTUP: fninline}
1835 or @samp{#+STARTUP: nofninline}.}, the definition is placed
1836 right into the text as part of the reference, or separately into
1837 the location determined by the variable @code{org-footnote-section}.
1839 When this command is called with a prefix argument, a menu of
1840 additional options is offered:
1842 @multitable @columnfractions 0.1 0.9
1843 @item @kbd{s}
1844 @tab Sort the footnote definitions by reference sequence.
1845 @item @kbd{r}
1846 @tab Renumber the simple @samp{fn:N} footnotes.
1847 @item @kbd{S}
1848 @tab Short for first @kbd{r}, then @kbd{s} action.
1849 @item @kbd{n}
1850 @tab Rename all footnotes into a @samp{fn:1} @dots{} @samp{fn:n} sequence.
1851 @item @kbd{d}
1852 @tab Delete the footnote at point, including definition and references.
1853 @end multitable
1855 @vindex org-footnote-auto-adjust
1856 Depending on the variable @code{org-footnote-auto-adjust}@footnote{The corresponding in-buffer options are @samp{#+STARTUP: fnadjust}
1857 and @samp{#+STARTUP: nofnadjust}.},
1858 renumbering and sorting footnotes can be automatic after each
1859 insertion or deletion.
1861 @item @kbd{C-c C-c}
1862 @kindex C-c C-c
1863 If the cursor is on a footnote reference, jump to the definition.
1864 If it is at the definition, jump back to the reference.  When
1865 called at a footnote location with a prefix argument, offer the
1866 same menu as @kbd{C-c C-x f}.
1868 @item @kbd{C-c C-o} or @kbd{mouse-1/2}
1869 @kindex C-c C-o
1870 @kindex mouse-1
1871 @kindex mouse-2
1872 Footnote labels are also links to the corresponding definition or
1873 reference, and you can use the usual commands to follow these
1874 links.
1875 @end table
1877 @node Org Syntax
1878 @section Org Syntax
1880 A reference document providing a formal description of Org's syntax is
1881 available as @uref{https://orgmode.org/worg/dev/org-syntax.html, a draft on Worg}, written and maintained by Nicolas
1882 Goaziou.  It defines Org's core internal concepts such as @samp{headlines},
1883 @samp{sections}, @samp{affiliated keywords}, @samp{(greater) elements} and @samp{objects}.
1884 Each part of an Org file falls into one of the categories above.
1886 To explore the abstract structure of an Org buffer, run this in
1887 a buffer:
1889 @example
1890 M-: (org-element-parse-buffer) <RET>
1891 @end example
1893 @noindent
1894 It outputs a list containing the buffer's content represented as an
1895 abstract structure.  The export engine relies on the information
1896 stored in this list.  Most interactive commands---e.g., for structure
1897 editing---also rely on the syntactic meaning of the surrounding
1898 context.
1900 @cindex syntax checker
1901 @cindex linter
1902 @findex org-lint
1903 You can check syntax in your documents using @code{org-lint} command.
1905 @node Tables
1906 @chapter Tables
1908 @cindex tables
1909 @cindex editing tables
1911 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1912 calculations are supported using the Emacs Calc package (see @ref{Top,GNU Emacs
1913 Calculator Manual,,calc,}).
1915 @menu
1916 * Built-in Table Editor::        Simple tables.
1917 * Column Width and Alignment::   Overrule the automatic settings.
1918 * Column Groups::                Grouping to trigger vertical lines.
1919 * Orgtbl Mode::                  The table editor as minor mode.
1920 * The spreadsheet::              The table editor has spreadsheet capabilities.
1921 * Org Plot::                     Plotting from Org tables.
1922 @end menu
1924 @node Built-in Table Editor
1925 @section Built-in Table Editor
1927 @cindex table editor, built-in
1929 Org makes it easy to format tables in plain ASCII.  Any line with @samp{|}
1930 as the first non-whitespace character is considered part of a table.
1931 @samp{|} is also the column separator@footnote{To insert a vertical bar into a table field, use @samp{\vert} or,
1932 inside a word @samp{abc\vert@{@}def}.}.  A table might look like
1933 this:
1935 @example
1936 | Name  | Phone | Age |
1937 |-------+-------+-----|
1938 | Peter |  1234 |  17 |
1939 | Anna  |  4321 |  25 |
1940 @end example
1942 A table is re-aligned automatically each time you press
1943 @kbd{@key{TAB}}, @kbd{@key{RET}} or @kbd{C-c C-c} inside the table.
1944 @kbd{@key{TAB}} also moves to the next field---@kbd{@key{RET}} to the
1945 next row---and creates new table rows at the end of the table or
1946 before horizontal lines.  The indentation of the table is set by the
1947 first line.  Any line starting with @samp{|-} is considered as a horizontal
1948 separator line and will be expanded on the next re-align to span the
1949 whole table width.  So, to create the above table, you would only type
1951 @example
1952 |Name|Phone|Age|
1954 @end example
1956 @noindent
1957 and then press @kbd{@key{TAB}} to align the table and start filling in
1958 fields.  Even faster would be to type @samp{|Name|Phone|Age} followed by
1959 @kbd{C-c @key{RET}}.
1961 When typing text into a field, Org treats @kbd{DEL},
1962 @kbd{Backspace}, and all character keys in a special way, so that
1963 inserting and deleting avoids shifting other fields.  Also, when
1964 typing @emph{immediately} after the cursor was moved into a new field with
1965 @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}, the field is
1966 automatically made blank.  If this behavior is too unpredictable for
1967 you, configure the option @code{org-table-auto-blank-field}.
1969 @anchor{Creation and conversion}
1970 @subheading Creation and conversion
1972 @table @asis
1973 @item @kbd{C-c |} (@code{org-table-create-or-convert-from-region})
1974 @kindex C-c |
1975 @findex org-table-create-or-convert-from-region
1976 Convert the active region to table.  If every line contains at
1977 least one @kbd{@key{TAB}} character, the function assumes that the
1978 material is tab separated.  If every line contains a comma,
1979 comma-separated values (CSV) are assumed.  If not, lines are
1980 split at whitespace into fields.  You can use a prefix argument
1981 to force a specific separator: @kbd{C-u} forces CSV,
1982 @kbd{C-u C-u} forces @kbd{@key{TAB}}, @kbd{C-u C-u C-u}
1983 prompts for a regular expression to match the separator, and
1984 a numeric argument N indicates that at least N consecutive
1985 spaces, or alternatively a @kbd{@key{TAB}} will be the separator.
1987 If there is no active region, this command creates an empty Org
1988 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}}.
1989 @end table
1991 @anchor{Re-aligning and field motion}
1992 @subheading Re-aligning and field motion
1994 @table @asis
1995 @item @kbd{C-c C-c} (@code{org-table-align})
1996 @kindex C-c C-c
1997 @findex org-table-align
1998 Re-align the table without moving the cursor.
2000 @item @kbd{@key{TAB}} (@code{org-table-next-field})
2001 @kindex TAB
2002 @findex org-table-next-field
2003 Re-align the table, move to the next field.  Creates a new row if
2004 necessary.
2006 @item @kbd{C-c @key{SPC}} (@code{org-table-blank-field})
2007 @kindex C-c SPC
2008 @findex org-table-blank-field
2009 Blank the field at point.
2011 @item @kbd{S-@key{TAB}} (@code{org-table-previous-field})
2012 @kindex S-TAB
2013 @findex org-table-previous-field
2014 Re-align, move to previous field.
2016 @item @kbd{@key{RET}} (@code{org-table-next-row})
2017 @kindex RET
2018 @findex org-table-next-row
2019 Re-align the table and move down to next row.  Creates a new row
2020 if necessary.  At the beginning or end of a line, @kbd{@key{RET}}
2021 still inserts a new line, so it can be used to split a table.
2023 @item @kbd{M-a} (@code{org-table-beginning-of-field})
2024 @kindex M-a
2025 @findex org-table-beginning-of-field
2026 Move to beginning of the current table field, or on to the
2027 previous field.
2029 @item @kbd{M-e} (@code{org-table-end-of-field})
2030 @kindex M-e
2031 @findex org-table-end-of-field
2032 Move to end of the current table field, or on to the next field.
2033 @end table
2035 @anchor{Column and row editing}
2036 @subheading Column and row editing
2038 @table @asis
2039 @item @kbd{M-@key{LEFT}} (@code{org-table-move-column-left})
2040 @kindex M-LEFT
2041 @findex org-table-move-column-left
2042 Move the current column left.
2044 @item @kbd{M-@key{RIGHT}} (@code{org-table-move-column-right})
2045 @kindex M-RIGHT
2046 @findex org-table-move-column-right
2047 Move the current column right.
2049 @item @kbd{M-S-@key{LEFT}} (@code{org-table-delete-column})
2050 @kindex M-S-LEFT
2051 @findex org-table-delete-column
2052 Kill the current column.
2054 @item @kbd{M-S-@key{RIGHT}} (@code{org-table-insert-column})
2055 @kindex M-S-RIGHT
2056 @findex org-table-insert-column
2057 Insert a new column to the left of the cursor position.
2059 @item @kbd{M-@key{UP}} (@code{org-table-move-row-up})
2060 @kindex M-UP
2061 @findex org-table-move-row-up
2062 Move the current row up.
2064 @item @kbd{M-@key{DOWN}} (@code{org-table-move-row-down})
2065 @kindex M-DOWN
2066 @findex org-table-move-row-down
2067 Move the current row down.
2069 @item @kbd{M-S-@key{UP}} (@code{org-table-kill-row})
2070 @kindex M-S-UP
2071 @findex org-table-kill-row
2072 Kill the current row or horizontal line.
2074 @item @kbd{M-S-@key{DOWN}} (@code{org-table-insert-row})
2075 @kindex M-S-DOWN
2076 @findex org-table-insert-row
2077 Insert a new row above the current row.  With a prefix argument,
2078 the line is created below the current one.
2080 @item @kbd{C-c -} (@code{org-table-insert-hline})
2081 @kindex C-c -
2082 @findex org-table-insert-hline
2083 Insert a horizontal line below current row.  With a prefix
2084 argument, the line is created above the current line.
2086 @item @kbd{C-c @key{RET}} (@code{org-table-hline-and-move})
2087 @kindex C-c RET
2088 @findex org-table-hline-and-move
2089 Insert a horizontal line below current row, and move the cursor
2090 into the row below that line.
2092 @item @kbd{C-c ^} (@code{org-table-sort-lines})
2093 @kindex C-c ^
2094 @findex org-table-sort-lines
2095 Sort the table lines in the region.  The position of point
2096 indicates the column to be used for sorting, and the range of
2097 lines is the range between the nearest horizontal separator
2098 lines, or the entire table.  If point is before the first column,
2099 you are prompted for the sorting column.  If there is an active
2100 region, the mark specifies the first line and the sorting column,
2101 while point should be in the last line to be included into the
2102 sorting.  The command prompts for the sorting type,
2103 alphabetically, numerically, or by time.  You can sort in normal
2104 or reverse order.  You can also supply your own key extraction
2105 and comparison functions.  When called with a prefix argument,
2106 alphabetic sorting is case-sensitive.
2107 @end table
2109 @anchor{Regions}
2110 @subheading Regions
2112 @table @asis
2113 @item @kbd{C-c C-x M-w} (@code{org-table-copy-region})
2114 @kindex C-c C-x M-w
2115 @findex org-table-copy-region
2116 Copy a rectangular region from a table to a special clipboard.
2117 Point and mark determine edge fields of the rectangle.  If there
2118 is no active region, copy just the current field.  The process
2119 ignores horizontal separator lines.
2121 @item @kbd{C-c C-x C-w} (@code{org-table-cut-region})
2122 @kindex C-c C-x C-w
2123 @findex org-table-cut-region
2124 Copy a rectangular region from a table to a special clipboard,
2125 and blank all fields in the rectangle.  So this is the ``cut''
2126 operation.
2128 @item @kbd{C-c C-x C-y} (@code{org-table-paste-rectangle})
2129 @kindex C-c C-x C-y
2130 @findex org-table-paste-rectangle
2131 Paste a rectangular region into a table.  The upper left corner
2132 ends up in the current field.  All involved fields are
2133 overwritten.  If the rectangle does not fit into the present
2134 table, the table is enlarged as needed.  The process ignores
2135 horizontal separator lines.
2137 @item @kbd{M-@key{RET}} (@code{org-table-wrap-region})
2138 @kindex M-RET
2139 @findex org-table-wrap-region
2140 Split the current field at the cursor position and move the rest
2141 to the line below.  If there is an active region, and both point
2142 and mark are in the same column, the text in the column is
2143 wrapped to minimum width for the given number of lines.
2144 A numeric prefix argument may be used to change the number of
2145 desired lines.  If there is no region, but you specify a prefix
2146 argument, the current field is made blank, and the content is
2147 appended to the field above.
2148 @end table
2150 @anchor{Calculations}
2151 @subheading Calculations
2153 @cindex formula, in tables
2154 @cindex calculations, in tables
2156 @table @asis
2157 @item @kbd{C-c +} (@code{org-table-sum})
2158 @kindex C-c +
2159 @findex org-table-sum
2160 Sum the numbers in the current column, or in the rectangle
2161 defined by the active region.  The result is shown in the echo
2162 area and can be inserted with @kbd{C-y}.
2164 @item @kbd{S-@key{RET}} (@code{org-table-copy-down})
2165 @kindex S-RET
2166 @findex org-table-copy-down
2167 @vindex org-table-copy-increment
2168 When current field is empty, copy from first non-empty field
2169 above.  When not empty, copy current field down to next row and
2170 move cursor along with it.  Depending on the variable
2171 @code{org-table-copy-increment}, integer field values can be
2172 incremented during copy.  Integers that are too large are not
2173 incremented, however.  Also, a @code{0} prefix argument temporarily
2174 disables the increment.  This key is also used by shift-selection
2175 and related modes (see @ref{Conflicts}).
2176 @end table
2178 @anchor{Miscellaneous (1)}
2179 @subheading Miscellaneous
2181 @table @asis
2182 @item @kbd{C-c `} (@code{org-table-edit-field})
2183 @kindex C-c `
2184 @findex org-table-edit-field
2185 Edit the current field in a separate window.  This is useful for
2186 fields that are not fully visible (see @ref{Column Width and Alignment}).  When called with a @kbd{C-u} prefix, just make
2187 the full field visible, so that it can be edited in place.  When
2188 called with two @kbd{C-u} prefixes, make the editor window
2189 follow the cursor through the table and always show the current
2190 field.  The follow mode exits automatically when the cursor
2191 leaves the table, or when you repeat this command with @kbd{C-u C-u C-c `}.
2193 @item @kbd{M-x org-table-import}
2194 @findex org-table-import
2195 Import a file as a table.  The table should be TAB or whitespace
2196 separated.  Use, for example, to import a spreadsheet table or
2197 data from a database, because these programs generally can write
2198 TAB-separated text files.  This command works by inserting the
2199 file into the buffer and then converting the region to a table.
2200 Any prefix argument is passed on to the converter, which uses it
2201 to determine the separator.
2203 @item @kbd{C-c |} (@code{org-table-create-or-convert-from-region})
2204 @kindex C-c |
2205 @findex org-table-create-or-convert-from-region
2206 Tables can also be imported by pasting tabular text into the Org
2207 buffer, selecting the pasted text with @kbd{C-x C-x} and
2208 then using the @kbd{C-c |} command (see @ref{Creation and conversion}).
2210 @item @kbd{M-x org-table-export}
2211 @findex org-table-export
2212 @vindex org-table-export-default-format
2213 Export the table, by default as a TAB-separated file.  Use for
2214 data exchange with, for example, spreadsheet or database
2215 programs.  The format used to export the file can be configured
2216 in the variable @code{org-table-export-default-format}.  You may also
2217 use properties @samp{TABLE_EXPORT_FILE} and @samp{TABLE_EXPORT_FORMAT} to
2218 specify the file name and the format for table export in
2219 a subtree.  Org supports quite general formats for exported
2220 tables.  The exporter format is the same as the format used by
2221 Orgtbl radio tables, see @ref{Translator functions}, for a detailed
2222 description.
2223 @end table
2225 @node Column Width and Alignment
2226 @section Column Width and Alignment
2228 @cindex narrow columns in tables
2229 @cindex alignment in tables
2231 The width of columns is automatically determined by the table editor.
2232 The alignment of a column is determined automatically from the
2233 fraction of number-like versus non-number fields in the column.
2235 @vindex org-table-automatic-realign
2236 Editing a field may modify alignment of the table.  Moving
2237 a contiguous row or column---i.e., using @kbd{@key{TAB}} or
2238 @kbd{@key{RET}}---automatically re-aligns it.  If you want to disable
2239 this behavior, set @code{org-table-automatic-realign} to @code{nil}.  In any
2240 case, you can always align manually a table:
2242 @table @asis
2243 @item @kbd{C-c C-c} (@code{org-table-align})
2244 @kindex C-c C-c
2245 @findex org-table-align
2246 Align the current table.
2247 @end table
2249 @noindent
2250 @vindex org-startup-align-all-tables
2251 Setting the option @code{org-startup-align-all-tables} re-aligns all tables
2252 in a file upon visiting it.  You can also set this option on
2253 a per-file basis with:
2255 @example
2256 #+STARTUP: align
2257 #+STARTUP: noalign
2258 @end example
2260 Sometimes a single field or a few fields need to carry more text,
2261 leading to inconveniently wide columns.  Maybe you want to hide away
2262 several columns or display them with a fixed width, regardless of
2263 content, as shown in the following example.
2265 @example
2266 |---+---------------------+--------|           |---+-------…|…|
2267 |   | <6>                 |        |           |   | <6>   …|…|
2268 | 1 | one                 | some   |   ----\   | 1 | one   …|…|
2269 | 2 | two                 | boring |   ----/   | 2 | two   …|…|
2270 | 3 | This is a long text | column |           | 3 | This i…|…|
2271 |---+---------------------+--------|           |---+-------…|…|
2272 @end example
2274 To set the width of a column, one field anywhere in the column may
2275 contain just the string @samp{<N>} where @var{N} specifies the width
2276 as a number of characters.  You control displayed width of columns
2277 with the following tools:
2279 @table @asis
2280 @item @kbd{C-c @key{TAB}} (@code{org-table-toggle-column-width})
2281 @kindex C-c TAB
2282 @findex org-table-toggle-column-width
2283 Shrink or expand current column.
2285 If a width cookie specifies a width W for the column, shrinking
2286 it displays the first W visible characters only.  Otherwise, the
2287 column is shrunk to a single character.
2289 When called before the first column or after the last one, ask
2290 for a list of column ranges to operate on.
2292 @item @kbd{C-u C-c @key{TAB}} (@code{org-table-shrink})
2293 @kindex C-u C-c TAB
2294 @findex org-table-shrink
2295 Shrink all columns with a column width.  Expand the others.
2297 @item @kbd{C-u C-u C-c @key{TAB}} (@code{org-table-expand})
2298 @kindex C-u C-u C-c TAB
2299 @findex org-table-expand
2300 Expand all columns.
2301 @end table
2303 To see the full text of a shrunk field, hold the mouse over it---a
2304 tool-tip window then shows the full content.  Alternatively @kbd{C-h .}  (@code{display-local-help}) reveals the full content.  For
2305 convenience, any change to a shrunk column expands it.
2307 @vindex org-startup-shrink-all-tables
2308 Setting the option @code{org-startup-shrink-all-tables} shrinks all columns
2309 containing a width cookie in a file the moment it is visited.  You can
2310 also set this option on a per-file basis with:
2312 @example
2313 #+STARTUP: shrink
2314 @end example
2316 If you would like to overrule the automatic alignment of number-rich
2317 columns to the right and of string-rich columns to the left, you can
2318 use @samp{<r>}, @samp{<c>} or @samp{<l>} in a similar fashion.  You may also combine
2319 alignment and field width like this: @samp{<r10>}.
2321 Lines which only contain these formatting cookies are removed
2322 automatically upon exporting the document.
2324 @node Column Groups
2325 @section Column Groups
2327 @cindex grouping columns in tables
2329 When Org exports tables, it does so by default without vertical lines
2330 because that is visually more satisfying in general.  Occasionally
2331 however, vertical lines can be useful to structure a table into groups
2332 of columns, much like horizontal lines can do for groups of rows.  In
2333 order to specify column groups, you can use a special row where the
2334 first field contains only @samp{/}.  The further fields can either contain
2335 @samp{<} to indicate that this column should start a group, @samp{>} to indicate
2336 the end of a column, or @samp{<>} (no space between @samp{<} and @samp{>}) to make
2337 a column a group of its own.  Upon export, boundaries between column
2338 groups are marked with vertical lines.  Here is an example:
2340 @example
2341 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2342 |---+-----+-----+-----+---------+------------|
2343 | / |  <  |     |  >  |       < |          > |
2344 | 1 |  1  |  1  |  1  |       1 |          1 |
2345 | 2 |  4  |  8  | 16  |  1.4142 |     1.1892 |
2346 | 3 |  9  | 27  | 81  |  1.7321 |     1.3161 |
2347 |---+-----+-----+-----+---------+------------|
2348 #+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
2349 @end example
2351 It is also sufficient to just insert the column group starters after
2352 every vertical line you would like to have:
2354 @example
2355 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2356 |---+-----+-----+-----+---------+------------|
2357 | / | <   |     |     | <       |            |
2358 @end example
2360 @node Orgtbl Mode
2361 @section The Orgtbl Minor Mode
2363 @cindex Orgtbl mode
2364 @cindex minor mode for tables
2366 @findex orgtbl-mode
2367 If you like the intuitive way the Org table editor works, you might
2368 also want to use it in other modes like Text mode or Mail mode.  The
2369 minor mode Orgtbl mode makes this possible.  You can always toggle the
2370 mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
2371 example in Message mode, use
2373 @lisp
2374 (add-hook 'message-mode-hook 'turn-on-orgtbl)
2375 @end lisp
2377 Furthermore, with some special setup, it is possible to maintain
2378 tables in arbitrary syntax with Orgtbl mode.  For example, it is
2379 possible to construct @LaTeX{} tables with the underlying ease and power
2380 of Orgtbl mode, including spreadsheet capabilities.  For details, see
2381 @ref{Tables in Arbitrary Syntax}.
2383 @node The spreadsheet
2384 @section The spreadsheet
2386 @cindex calculations, in tables
2387 @cindex spreadsheet capabilities
2388 @cindex Calc package
2390 The table editor makes use of the Emacs Calc package to implement
2391 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms
2392 to derive fields from other fields.  While fully featured, Org's
2393 implementation is not identical to other spreadsheets.  For example,
2394 Org knows the concept of a @emph{column formula} that will be applied to
2395 all non-header fields in a column without having to copy the formula
2396 to each relevant field.  There is also a formula debugger, and
2397 a formula editor with features for highlighting fields in the table
2398 corresponding to the references at the point in the formula, moving
2399 these references by arrow keys.
2401 @menu
2402 * References::                   How to refer to another field or range.
2403 * Formula syntax for Calc::      Using Calc to compute stuff.
2404 * Formula syntax for Lisp::      Writing formulas in Emacs Lisp.
2405 * Durations and time values::    How to compute durations and time values.
2406 * Field and range formulas::     Formula for specific (ranges of) fields.
2407 * Column formulas::              Formulas valid for an entire column.
2408 * Lookup functions::             Lookup functions for searching tables.
2409 * Editing and debugging formulas:: Fixing formulas.
2410 * Updating the table::           Recomputing all dependent fields.
2411 * Advanced features::            Field and column names, automatic recalculation...
2412 @end menu
2414 @node References
2415 @subsection References
2417 @cindex references
2419 To compute fields in the table from other fields, formulas must
2420 reference other fields or ranges.  In Org, fields can be referenced by
2421 name, by absolute coordinates, and by relative coordinates.  To find
2422 out what the coordinates of a field are, press @kbd{C-c ?} in
2423 that field, or press @kbd{C-c @}} to toggle the display of a grid.
2425 @anchor{Field references}
2426 @subsubheading Field references
2428 @cindex field references
2429 @cindex references, to fields
2430 Formulas can reference the value of another field in two ways.  Like
2431 in any other spreadsheet, you may reference fields with
2432 a letter/number combination like @samp{B3}, meaning the second field in the
2433 third row.  However, Org prefers to use another, more general
2434 representation that looks like this:@footnote{Org understands references typed by the user as @samp{B4}, but it
2435 does not use this syntax when offering a formula for editing.  You can
2436 customize this behavior using the variable
2437 @code{org-table-use-standard-references}.}
2439 @example
2440 @@ROW$COLUMN
2441 @end example
2443 Column specifications can be absolute like @samp{$1}, @samp{$2}, @dots{}, @samp{$N}, or
2444 relative to the current column, i.e., the column of the field which is
2445 being computed, like @samp{$+1} or @samp{$-2}.  @samp{$<} and @samp{$>} are immutable
2446 references to the first and last column, respectively, and you can use
2447 @samp{$>>>} to indicate the third column from the right.
2449 The row specification only counts data lines and ignores horizontal
2450 separator lines, or ``hlines''.  Like with columns, you can use absolute
2451 row numbers @samp{@@1}, @samp{@@2}, @dots{}, @samp{@@N}, and row numbers relative to the
2452 current row like @samp{@@+3} or @samp{@@-1}.  @samp{@@<} and @samp{@@>} are immutable
2453 references the first and last row in the table, respectively.  You may
2454 also specify the row relative to one of the hlines: @samp{@@I} refers to the
2455 first hline, @samp{@@II} to the second, etc.  @samp{@@-I} refers to the first such
2456 line above the current line, @samp{@@+I} to the first such line below the
2457 current line.  You can also write @samp{@@III+2} which is the second data
2458 line after the third hline in the table.
2460 @samp{@@0} and @samp{$0} refer to the current row and column, respectively, i.e.,
2461 to the row/column for the field being computed.  Also, if you omit
2462 either the column or the row part of the reference, the current
2463 row/column is implied.
2465 Org's references with @emph{unsigned} numbers are fixed references in the
2466 sense that if you use the same reference in the formula for two
2467 different fields, the same field is referenced each time.  Org's
2468 references with @emph{signed} numbers are floating references because the
2469 same reference operator can reference different fields depending on
2470 the field being calculated by the formula.
2472 Here are a few examples:
2474 @multitable @columnfractions 0.2 0.8
2475 @item @samp{@@2$3}
2476 @tab 2nd row, 3rd column (same as @samp{C2})
2477 @item @samp{$5}
2478 @tab column 5 in the current row (same as @samp{E&})
2479 @item @samp{@@2}
2480 @tab current column, row 2
2481 @item @samp{@@-1$-3}
2482 @tab field one row up, three columns to the left
2483 @item @samp{@@-I$2}
2484 @tab field just under hline above current row, column 2
2485 @item @samp{@@>$5}
2486 @tab field in the last row, in column 5
2487 @end multitable
2489 @anchor{Range references}
2490 @subsubheading Range references
2492 @cindex range references
2493 @cindex references, to ranges
2494 You may reference a rectangular range of fields by specifying two
2495 field references connected by two dots @samp{..}.  If both fields are in
2496 the current row, you may simply use @samp{$2..$7}, but if at least one
2497 field is in a different row, you need to use the general @samp{@@ROW$COLUMN}
2498 format at least for the first field, i.e., the reference must start
2499 with @samp{@@} in order to be interpreted correctly.  Examples:
2501 @multitable @columnfractions 0.2 0.8
2502 @item @samp{$1..$3}
2503 @tab first three fields in the current row
2504 @item @samp{$P..$Q}
2505 @tab range, using column names (see @ref{Advanced features})
2506 @item @samp{$<<<..$>>}
2507 @tab start in third column, continue to the last but one
2508 @item @samp{@@2$1..@@4$3}
2509 @tab six fields between these two fields (same as @samp{A2..C4})
2510 @item @samp{@@-1$-2..@@-1}
2511 @tab 3 fields in the row above, starting from 2 columns on the left
2512 @item @samp{@@I..II}
2513 @tab between first and second hline, short for @samp{@@I..@@II}
2514 @end multitable
2516 @noindent
2517 Range references return a vector of values that can be fed into Calc
2518 vector functions.  Empty fields in ranges are normally suppressed, so
2519 that the vector contains only the non-empty fields.  For other options
2520 with the mode switches @samp{E}, @samp{N} and examples, see @ref{Formula syntax for Calc}.
2522 @anchor{Field coordinates in formulas}
2523 @subsubheading Field coordinates in formulas
2525 @cindex field coordinates
2526 @cindex coordinates, of field
2527 @cindex row, of field coordinates
2528 @cindex column, of field coordinates
2529 @vindex org-table-current-column
2530 @vindex org-table-current-dline
2531 One of the very first actions during evaluation of Calc formulas and
2532 Lisp formulas is to substitute @samp{@@#} and @samp{$#} in the formula with the
2533 row or column number of the field where the current result will go to.
2534 The traditional Lisp formula equivalents are @code{org-table-current-dline}
2535 and @code{org-table-current-column}.  Examples:
2537 @table @asis
2538 @item @samp{if(@@# % 2, $#, string(""))}
2539 Insert column number on odd rows, set field to empty on even
2540 rows.
2542 @item @samp{$2 = '(identity remote(FOO, @@@@#$1))}
2543 Copy text or values of each row of column 1 of the table named
2544 @var{FOO} into column 2 of the current table.
2546 @item @samp{@@3 = 2 * remote(FOO, @@@@1$$#)}
2547 Insert the doubled value of each column of row 1 of the table
2548 named @var{FOO} into row 3 of the current table.
2549 @end table
2551 @noindent
2552 For the second and third examples, table @var{FOO} must have at
2553 least as many rows or columns as the current table.  Note that this is
2554 inefficient@footnote{The computation time scales as O(N^2) because table
2555 @var{FOO} is parsed for each field to be copied.} for large number of rows.
2557 @anchor{Named references}
2558 @subsubheading Named references
2560 @cindex named references
2561 @cindex references, named
2562 @cindex name, of column or field
2563 @cindex constants, in calculations
2564 @cindex @samp{CONSTANTS}, keyword
2565 @vindex org-table-formula-constants
2567 @samp{$name} is interpreted as the name of a column, parameter or constant.
2568 Constants are defined globally through the variable
2569 @code{org-table-formula-constants}, and locally---for the file---through
2570 a line like this example:
2572 @example
2573 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2574 @end example
2576 @noindent
2577 @vindex constants-unit-system
2578 @pindex constants.el
2579 Also, properties (see @ref{Properties and Columns}) can be used as
2580 constants in table formulas: for a property @samp{Xyz} use the name
2581 @samp{$PROP_Xyz}, and the property will be searched in the current outline
2582 entry and in the hierarchy above it.  If you have the @samp{constants.el}
2583 package, it will also be used to resolve constants, including natural
2584 constants like @samp{$h} for Planck's constant, and units like @samp{$km} for
2585 kilometers@footnote{The file @samp{constants.el} can supply the values of constants in
2586 two different unit systems, @samp{SI} and @samp{cgs}.  Which one is used depends
2587 on the value of the variable @code{constants-unit-system}.  You can use the
2588 @samp{STARTUP} options @samp{constSI} and @samp{constcgs} to set this value for the
2589 current buffer.}.  Column names and parameters can be specified in
2590 special table lines.  These are described below, see @ref{Advanced features}.  All names must start with a letter, and further consist
2591 of letters and numbers.
2593 @anchor{Remote references}
2594 @subsubheading Remote references
2596 @cindex remote references
2597 @cindex references, remote
2598 @cindex references, to a different table
2599 @cindex name, of column or field
2600 @cindex @samp{NAME}, keyword
2601 You may also reference constants, fields and ranges from a different
2602 table, either in the current file or even in a different file.  The
2603 syntax is
2605 @example
2606 remote(NAME,REF)
2607 @end example
2609 @noindent
2610 where @var{NAME} can be the name of a table in the current file
2611 as set by a @samp{#+NAME:} line before the table.  It can also be the ID of
2612 an entry, even in a different file, and the reference then refers to
2613 the first table in that entry.  @var{REF} is an absolute field or
2614 range reference as described above for example @samp{@@3$3} or @samp{$somename},
2615 valid in the referenced table.
2617 @cindex table indirection
2618 When @var{NAME} has the format @samp{@@ROW$COLUMN}, it is substituted
2619 with the name or ID found in this field of the current table.  For
2620 example @samp{remote($1, @@@@>$2)} @result{} @samp{remote(year_2013, @@@@>$1)}.  The format
2621 @samp{B3} is not supported because it can not be distinguished from a plain
2622 table name or ID.
2624 @node Formula syntax for Calc
2625 @subsection Formula syntax for Calc
2627 @cindex formula syntax, Calc
2628 @cindex syntax, of formulas
2630 A formula can be any algebraic expression understood by the Emacs Calc
2631 package.  Note that Calc has the non-standard convention that @samp{/} has
2632 lower precedence than @samp{*}, so that @samp{a/b*c} is interpreted as
2633 @samp{(a/(b*c))}.  Before evaluation by @code{calc-eval} (see @ref{Calling Calc from Your Programs,Calling Calc from
2634 Your Lisp Programs,,calc,}), variable substitution takes place according to
2635 the rules described above.
2637 @cindex vectors, in table calculations
2638 The range vectors can be directly fed into the Calc vector functions
2639 like @code{vmean} and @code{vsum}.
2641 @cindex format specifier, in spreadsheet
2642 @cindex mode, for Calc
2643 @vindex org-calc-default-modes
2644 A formula can contain an optional mode string after a semicolon.  This
2645 string consists of flags to influence Calc and other modes during
2646 execution.  By default, Org uses the standard Calc modes (precision
2647 12, angular units degrees, fraction and symbolic modes off).  The
2648 display format, however, has been changed to @code{(float 8)} to keep
2649 tables compact.  The default settings can be configured using the
2650 variable @code{org-calc-default-modes}.
2652 @table @asis
2653 @item @samp{p20}
2654 Set the internal Calc calculation precision to 20 digits.
2656 @item @samp{n3}, @samp{s3}, @samp{e2}, @samp{f4}
2657 Normal, scientific, engineering or fixed format of the result of
2658 Calc passed back to Org.  Calc formatting is unlimited in
2659 precision as long as the Calc calculation precision is greater.
2661 @item @samp{D}, @samp{R}
2662 Degree and radian angle modes of Calc.
2664 @item @samp{F}, @samp{S}
2665 Fraction and symbolic modes of Calc.
2667 @item @samp{T}, @samp{t}, @samp{U}
2668 Duration computations in Calc or Lisp, @ref{Durations and time values}.
2670 @item @samp{E}
2671 If and how to consider empty fields.  Without @samp{E} empty fields in
2672 range references are suppressed so that the Calc vector or Lisp
2673 list contains only the non-empty fields.  With @samp{E} the empty
2674 fields are kept.  For empty fields in ranges or empty field
2675 references the value @samp{nan} (not a number) is used in Calc
2676 formulas and the empty string is used for Lisp formulas.  Add @samp{N}
2677 to use 0 instead for both formula types.  For the value of
2678 a field the mode @samp{N} has higher precedence than @samp{E}.
2680 @item @samp{N}
2681 Interpret all fields as numbers, use 0 for non-numbers.  See the
2682 next section to see how this is essential for computations with
2683 Lisp formulas.  In Calc formulas it is used only occasionally
2684 because there number strings are already interpreted as numbers
2685 without @samp{N}.
2687 @item @samp{L}
2688 Literal, for Lisp formulas only.  See the next section.
2689 @end table
2691 @noindent
2692 Unless you use large integer numbers or high-precision calculation and
2693 display for floating point numbers you may alternatively provide
2694 a @code{printf} format specifier to reformat the Calc result after it has
2695 been passed back to Org instead of letting Calc already do the
2696 formatting@footnote{The printf reformatting is limited in precision because the
2697 value passed to it is converted into an ``integer'' or ``double''.  The
2698 ``integer'' is limited in size by truncating the signed value to 32
2699 bits.  The ``double'' is limited in precision to 64 bits overall which
2700 leaves approximately 16 significant decimal digits.}.  A few examples:
2702 @multitable {aaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
2703 @item @samp{$1+$2}
2704 @tab Sum of first and second field
2705 @item @samp{$1+$2;%.2f}
2706 @tab Same, format result to two decimals
2707 @item @samp{exp($2)+exp($1)}
2708 @tab Math functions can be used
2709 @item @samp{$0;%.1f}
2710 @tab Reformat current cell to 1 decimal
2711 @item @samp{($3-32)*5/9}
2712 @tab Degrees F @arrow{} C conversion
2713 @item @samp{$c/$1/$cm}
2714 @tab Hz @arrow{} cm conversion, using @samp{constants.el}
2715 @item @samp{tan($1);Dp3s1}
2716 @tab Compute in degrees, precision 3, display SCI 1
2717 @item @samp{sin($1);Dp3%.1e}
2718 @tab Same, but use @code{printf} specifier for display
2719 @item @samp{vmean($2..$7)}
2720 @tab Compute column range mean, using vector function
2721 @item @samp{vmean($2..$7);EN}
2722 @tab Same, but treat empty fields as 0
2723 @item @samp{taylor($3,x=7,2)}
2724 @tab Taylor series of $3, at x=7, second degree
2725 @end multitable
2727 Calc also contains a complete set of logical operations (see @ref{Logical Operations,Logical
2728 Operations,,calc,}).  For example
2730 @table @asis
2731 @item @samp{if($1 < 20, teen, string(""))}
2732 @samp{"teen"} if age @samp{$1} is less than 20, else the Org table result
2733 field is set to empty with the empty string.
2735 @item @samp{if("$1" =} ``nan'' || ``$2'' @samp{= "nan", string(""), $1 + $2); E f-1}
2736 Sum of the first two columns.  When at least one of the input
2737 fields is empty the Org table result field is set to empty.  @samp{E}
2738 is required to not convert empty fields to 0.  @samp{f-1} is an
2739 optional Calc format string similar to @samp{%.1f} but leaves empty
2740 results empty.
2742 @item @samp{if(typeof(vmean($1..$7)) =} 12, string(``''), vmean($1..$7); E=
2743 Mean value of a range unless there is any empty field.  Every
2744 field in the range that is empty is replaced by @samp{nan} which lets
2745 @samp{vmean} result in @samp{nan}.  Then @samp{typeof =} 12= detects the @samp{nan}
2746 from @code{vmean} and the Org table result field is set to empty.  Use
2747 this when the sample set is expected to never have missing
2748 values.
2750 @item @samp{if("$1..$7" =} ``[]'', string(``''), vmean($1..$7))=
2751 Mean value of a range with empty fields skipped.  Every field in
2752 the range that is empty is skipped.  When all fields in the range
2753 are empty the mean value is not defined and the Org table result
2754 field is set to empty.  Use this when the sample set can have
2755 a variable size.
2757 @item @samp{vmean($1..$7); EN}
2758 To complete the example before: Mean value of a range with empty
2759 fields counting as samples with value 0.  Use this only when
2760 incomplete sample sets should be padded with 0 to the full size.
2761 @end table
2763 You can add your own Calc functions defined in Emacs Lisp with
2764 @code{defmath} and use them in formula syntax for Calc.
2766 @node Formula syntax for Lisp
2767 @subsection Emacs Lisp forms as formulas
2769 @cindex Lisp forms, as table formulas
2771 It is also possible to write a formula in Emacs Lisp.  This can be
2772 useful for string manipulation and control structures, if Calc's
2773 functionality is not enough.
2775 If a formula starts with a single-quote followed by an opening
2776 parenthesis, then it is evaluated as a Lisp form.  The evaluation
2777 should return either a string or a number.  Just as with Calc
2778 formulas, you can specify modes and a @code{printf} format after
2779 a semicolon.
2781 With Emacs Lisp forms, you need to be conscious about the way field
2782 references are interpolated into the form.  By default, a reference is
2783 interpolated as a Lisp string (in double-quotes) containing the field.
2784 If you provide the @samp{N} mode switch, all referenced elements are
2785 numbers---non-number fields will be zero---and interpolated as Lisp
2786 numbers, without quotes.  If you provide the @samp{L} flag, all fields are
2787 interpolated literally, without quotes.  I.e., if you want a reference
2788 to be interpreted as a string by the Lisp form, enclose the reference
2789 operator itself in double-quotes, like @samp{"$3"}.  Ranges are inserted as
2790 space-separated fields, so you can embed them in list or vector
2791 syntax.
2793 Here are a few examples---note how the @samp{N} mode is used when we do
2794 computations in Lisp:
2796 @table @asis
2797 @item @samp{'(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))}
2798 Swap the first two characters of the content of column 1.
2800 @item @samp{'(+ $1 $2);N}
2801 Add columns 1 and 2, equivalent to Calc's @samp{$1+$2}.
2803 @item @samp{'(apply '+ '($1..$4));N}
2804 Compute the sum of columns 1 to 4, like Calc's @samp{vsum($1..$4)}.
2805 @end table
2807 @node Durations and time values
2808 @subsection Durations and time values
2810 @cindex Duration, computing
2811 @cindex Time, computing
2812 @vindex org-table-duration-custom-format
2814 If you want to compute time values use the @samp{T}, @samp{t}, or @samp{U} flag,
2815 either in Calc formulas or Elisp formulas:
2817 @example
2818 |  Task 1 |   Task 2 |    Total |
2819 |---------+----------+----------|
2820 |    2:12 |     1:47 | 03:59:00 |
2821 |    2:12 |     1:47 |    03:59 |
2822 | 3:02:20 | -2:07:00 |     0.92 |
2823 #+TBLFM: @@2$3=$1+$2;T::@@3$3=$1+$2;U::@@4$3=$1+$2;t
2824 @end example
2826 Input duration values must be of the form @samp{HH:MM[:SS]}, where seconds
2827 are optional.  With the @samp{T} flag, computed durations are displayed as
2828 @samp{HH:MM:SS} (see the first formula above).  With the @samp{U} flag, seconds
2829 are omitted so that the result is only @samp{HH:MM} (see second formula
2830 above).  Zero-padding of the hours field depends upon the value of the
2831 variable @code{org-table-duration-hour-zero-padding}.
2833 With the @samp{t} flag, computed durations are displayed according to the
2834 value of the option @code{org-table-duration-custom-format}, which defaults
2835 to @code{hours} and displays the result as a fraction of hours (see the
2836 third formula in the example above).
2838 Negative duration values can be manipulated as well, and integers are
2839 considered as seconds in addition and subtraction.
2841 @node Field and range formulas
2842 @subsection Field and range formulas
2844 @cindex field formula
2845 @cindex range formula
2846 @cindex formula, for individual table field
2847 @cindex formula, for range of fields
2849 To assign a formula to a particular field, type it directly into the
2850 field, preceded by @samp{:=}, for example @samp{vsum(@@II..III)}.  When you press
2851 @kbd{@key{TAB}} or @kbd{@key{RET}} or @kbd{C-c C-c} with the cursor
2852 still in the field, the formula is stored as the formula for this
2853 field, evaluated, and the current field is replaced with the result.
2855 @cindex @samp{TBLFM}, keyword
2856 Formulas are stored in a special @samp{TBLFM} keyword located directly
2857 below the table.  If you type the equation in the fourth field of the
2858 third data line in the table, the formula looks like @samp{@@3$4=$1+$2}.
2859 When inserting/deleting/swapping column and rows with the appropriate
2860 commands, @emph{absolute references} (but not relative ones) in stored
2861 formulas are modified in order to still reference the same field.  To
2862 avoid this from happening, in particular in range references, anchor
2863 ranges at the table borders (using @samp{@@<}, @samp{@@>}, @samp{$<}, @samp{$>}), or at
2864 hlines using the @samp{@@I} notation.  Automatic adaptation of field
2865 references does of course not happen if you edit the table structure
2866 with normal editing commands---then you must fix the equations
2867 yourself.
2869 Instead of typing an equation into the field, you may also use the
2870 following command
2872 @table @asis
2873 @item @kbd{C-u C-c =} (@code{org-table-eval-formula})
2874 @kindex C-u C-c =
2875 @findex org-table-eval-formula
2876 Install a new formula for the current field.  The command prompts
2877 for a formula with default taken from the @samp{TBLFM} keyword,
2878 applies it to the current field, and stores it.
2879 @end table
2881 The left-hand side of a formula can also be a special expression in
2882 order to assign the formula to a number of different fields.  There is
2883 no keyboard shortcut to enter such range formulas.  To add them, use
2884 the formula editor (see @ref{Editing and debugging formulas}) or edit the
2885 @samp{TBLFM} keyword directly.
2887 @table @asis
2888 @item @samp{$2=}
2889 Column formula, valid for the entire column.  This is so common
2890 that Org treats these formulas in a special way, see @ref{Column formulas}.
2892 @item @code{@@3=}
2893 Row formula, applies to all fields in the specified row.  @samp{@@>=}
2894 means the last row.
2896 @item @samp{@@1$2..@@4$3=}
2897 Range formula, applies to all fields in the given rectangular
2898 range.  This can also be used to assign a formula to some but not
2899 all fields in a row.
2901 @item @samp{$NAME=}
2902 Named field, see @ref{Advanced features}.
2903 @end table
2905 @node Column formulas
2906 @subsection Column formulas
2908 @cindex column formula
2909 @cindex formula, for table column
2911 When you assign a formula to a simple column reference like @samp{$3=}, the
2912 same formula is used in all fields of that column, with the following
2913 very convenient exceptions: (i) If the table contains horizontal
2914 separator hlines with rows above and below, everything before the
2915 first such hline is considered part of the table @emph{header} and is not
2916 modified by column formulas.  Therefore a header is mandatory when you
2917 use column formulas and want to add hlines to group rows, like for
2918 example to separate a total row at the bottom from the summand rows
2919 above.  (ii) Fields that already get a value from a field/range
2920 formula are left alone by column formulas.  These conditions make
2921 column formulas very easy to use.
2923 To assign a formula to a column, type it directly into any field in
2924 the column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2925 @kbd{@key{TAB}} or @kbd{@key{RET}} or @kbd{C-c C-c} with the cursor
2926 still in the field, the formula is stored as the formula for the
2927 current column, evaluated and the current field replaced with the
2928 result.  If the field contains only @samp{=}, the previously stored formula
2929 for this column is used.  For each column, Org only remembers the most
2930 recently used formula.  In the @samp{TBLFM} keyword, column formulas look
2931 like @samp{$4=$1+$2}.  The left-hand side of a column formula can not be
2932 the name of column, it must be the numeric column reference or @samp{$>}.
2934 Instead of typing an equation into the field, you may also use the
2935 following command:
2937 @table @asis
2938 @item @kbd{C-c =} (@code{org-table-eval-formula})
2939 @kindex C-c =
2940 @findex org-table-eval-formula
2941 Install a new formula for the current column and replace current
2942 field with the result of the formula.  The command prompts for
2943 a formula, with default taken from the @samp{TBLFM} keyword, applies
2944 it to the current field and stores it.  With a numeric prefix
2945 argument, e.g., @kbd{C-5 C-c =}, the command applies it to
2946 that many consecutive fields in the current column.
2947 @end table
2949 @node Lookup functions
2950 @subsection Lookup functions
2952 @cindex lookup functions in tables
2953 @cindex table lookup functions
2955 Org has three predefined Emacs Lisp functions for lookups in tables.
2957 @table @asis
2958 @item @code{(org-lookup-first VAL S-LIST R-LIST &optional PREDICATE)}
2959 @findex org-lookup-first
2960 Searches for the first element @var{S} in list
2961 @var{S-LIST} for which
2962 @lisp
2963 (PREDICATE VAL S)
2964 @end lisp
2965 is non-@code{nil}; returns the value from the corresponding position
2966 in list @var{R-LIST}.  The default @var{PREDICATE} is
2967 @code{equal}.  Note that the parameters @var{VAL} and
2968 @var{S} are passed to @var{PREDICATE} in the same order
2969 as the corresponding parameters are in the call to
2970 @code{org-lookup-first}, where @var{VAL} precedes
2971 @var{S-LIST}.  If @var{R-LIST} is @code{nil}, the matching
2972 element @var{S} of @var{S-LIST} is returned.
2974 @item @code{(org-lookup-last VAL S-LIST R-LIST &optional PREDICATE)}
2975 @findex org-lookup-last
2976 Similar to @code{org-lookup-first} above, but searches for the @emph{last}
2977 element for which @var{PREDICATE} is non-@code{nil}.
2979 @item @code{(org-lookup-all VAL S-LIST R-LIST &optional PREDICATE)}
2980 @findex org-lookup-all
2981 Similar to @code{org-lookup-first}, but searches for @emph{all} elements
2982 for which @var{PREDICATE} is non-@code{nil}, and returns @emph{all}
2983 corresponding values.  This function can not be used by itself in
2984 a formula, because it returns a list of values.  However,
2985 powerful lookups can be built when this function is combined with
2986 other Emacs Lisp functions.
2987 @end table
2989 If the ranges used in these functions contain empty fields, the @samp{E}
2990 mode for the formula should usually be specified: otherwise empty
2991 fields are not included in @var{S-LIST} and/or @var{R-LIST}
2992 which can, for example, result in an incorrect mapping from an element
2993 of @var{S-LIST} to the corresponding element of
2994 @var{R-LIST}.
2996 These three functions can be used to implement associative arrays,
2997 count matching cells, rank results, group data, etc.  For practical
2998 examples see @uref{https://orgmode.org/worg/org-tutorials/org-lookups.html, this tutorial on Worg}.
3000 @node Editing and debugging formulas
3001 @subsection Editing and debugging formulas
3003 @cindex formula editing
3004 @cindex editing, of table formulas
3006 @vindex org-table-use-standard-references
3007 You can edit individual formulas in the minibuffer or directly in the
3008 field.  Org can also prepare a special buffer with all active formulas
3009 of a table.  When offering a formula for editing, Org converts
3010 references to the standard format (like @samp{B3} or @samp{D&}) if possible.  If
3011 you prefer to only work with the internal format (like @samp{@@3$2} or
3012 @samp{$4}), configure the variable @code{org-table-use-standard-references}.
3014 @table @asis
3015 @item @kbd{C-c =} or @kbd{C-u C-c =} (@code{org-table-eval-formula})
3016 @kindex C-c =
3017 @kindex C-u C-c =
3018 @findex org-table-eval-formula
3019 Edit the formula associated with the current column/field in the
3020 minibuffer.  See @ref{Column formulas}, and @ref{Field and range formulas}.
3022 @item @kbd{C-u C-u C-c =} (@code{org-table-eval-formula})
3023 @kindex C-u C-u C-c =
3024 @findex org-table-eval-formula
3025 Re-insert the active formula (either a field formula, or a column
3026 formula) into the current field, so that you can edit it directly
3027 in the field.  The advantage over editing in the minibuffer is
3028 that you can use the command @kbd{C-c ?}.
3030 @item @kbd{C-c ?} (@code{org-table-field-info})
3031 @kindex C-c ?
3032 @findex org-table-field-info
3033 While editing a formula in a table field, highlight the field(s)
3034 referenced by the reference at the cursor position in the
3035 formula.
3037 @item @kbd{C-c @}} (@code{org-table-toggle-coordinate-overlays})
3038 @kindex C-c @}
3039 @findex org-table-toggle-coordinate-overlays
3040 Toggle the display of row and column numbers for a table, using
3041 overlays.  These are updated each time the table is aligned; you
3042 can force it with @kbd{C-c C-c}.
3044 @item @kbd{C-c @{} (@code{org-table-toggle-formula-debugger})
3045 @kindex C-c @{
3046 @findex org-table-toggle-formula-debugger
3047 Toggle the formula debugger on and off.  See below.
3049 @item @kbd{C-c '} (@code{org-table-edit-formulas})
3050 @kindex C-c '
3051 @findex org-table-edit-formulas
3052 Edit all formulas for the current table in a special buffer,
3053 where the formulas are displayed one per line.  If the current
3054 field has an active formula, the cursor in the formula editor
3055 marks it.  While inside the special buffer, Org automatically
3056 highlights any field or range reference at the cursor position.
3057 You may edit, remove and add formulas, and use the following
3058 commands:
3060 @table @asis
3061 @item @kbd{C-c C-c} or @kbd{C-x C-s} (@code{org-table-fedit-finish})
3062 @kindex C-x C-s
3063 @kindex C-c C-c
3064 @findex org-table-fedit-finish
3065 Exit the formula editor and store the modified formulas.  With
3066 @kbd{C-u} prefix, also apply the new formulas to the
3067 entire table.
3069 @item @kbd{C-c C-q} (@code{org-table-fedit-abort})
3070 @kindex C-c C-q
3071 @findex org-table-fedit-abort
3072 Exit the formula editor without installing changes.
3074 @item @kbd{C-c C-r} (@code{org-table-fedit-toggle-ref-type})
3075 @kindex C-c C-r
3076 @findex org-table-fedit-toggle-ref-type
3077 Toggle all references in the formula editor between standard
3078 (like @samp{B3}) and internal (like @samp{@@3$2}).
3080 @item @kbd{@key{TAB}} (@code{org-table-fedit-lisp-indent})
3081 @kindex TAB
3082 @findex org-table-fedit-lisp-indent
3083 Pretty-print or indent Lisp formula at point.  When in a line
3084 containing a Lisp formula, format the formula according to
3085 Emacs Lisp rules.  Another @kbd{@key{TAB}} collapses the formula
3086 back again.  In the open formula, @kbd{@key{TAB}} re-indents
3087 just like in Emacs Lisp mode.
3089 @item @kbd{M-@key{TAB}} (@code{lisp-complete-symbol})
3090 @kindex M-TAB
3091 @findex lisp-complete-symbol
3092 Complete Lisp symbols, just like in Emacs Lisp mode.
3094 @item @kbd{S-@key{UP}}, @kbd{S-@key{DOWN}}, @kbd{S-@key{LEFT}}, @kbd{S-@key{RIGHT}}
3095 @kindex S-UP
3096 @kindex S-DOWN
3097 @kindex S-LEFT
3098 @kindex S-RIGHT
3099 @findex org-table-fedit-ref-up
3100 @findex org-table-fedit-ref-down
3101 @findex org-table-fedit-ref-left
3102 @findex org-table-fedit-ref-right
3103 Shift the reference at point.  For example, if the reference
3104 is @samp{B3} and you press @kbd{S-@key{RIGHT}}, it becomes @samp{C3}.
3105 This also works for relative references and for hline
3106 references.
3108 @item @kbd{M-S-@key{UP}} (@code{org-table-fedit-line-up})
3109 @kindex M-S-UP
3110 @findex org-table-fedit-line-up
3111 Move the test line for column formulas up in the Org buffer.
3113 @item @kbd{M-S-@key{DOWN}} (@code{org-table-fedit-line-down})
3114 @kindex M-S-DOWN
3115 @findex org-table-fedit-line-down
3116 Move the test line for column formulas down in the Org buffer.
3118 @item @kbd{M-@key{UP}} (@code{org-table-fedit-scroll-up})
3119 @kindex M-UP
3120 @findex org-table-fedit-scroll-up
3121 Scroll up the window displaying the table.
3123 @item @kbd{M-@key{DOWN}} (@code{org-table-fedit-scroll-down})
3124 @kindex M-DOWN
3125 @findex org-table-fedit-scroll-down
3126 Scroll down the window displaying the table.
3128 @item @kbd{C-c @}}
3129 @kindex C-c @}
3130 @findex org-table-toggle-coordinate-overlays
3131 Turn the coordinate grid in the table on and off.
3132 @end table
3133 @end table
3135 Making a table field blank does not remove the formula associated with
3136 the field, because that is stored in a different line---the @samp{TBLFM}
3137 keyword line.  During the next recalculation, the field will be filled
3138 again.  To remove a formula from a field, you have to give an empty
3139 reply when prompted for the formula, or to edit the @samp{TBLFM} keyword.
3141 @kindex C-c C-c
3142 You may edit the @samp{TBLFM} keyword directly and re-apply the changed
3143 equations with @kbd{C-c C-c} in that line or with the normal
3144 recalculation commands in the table.
3146 @anchor{Using multiple @samp{TBLFM} lines}
3147 @subsubheading Using multiple @samp{TBLFM} lines
3149 @cindex multiple formula lines
3150 @cindex @samp{TBLFM} keywords, multiple
3151 @cindex @samp{TBLFM}, switching
3153 @kindex C-c C-c
3154 You may apply the formula temporarily.  This is useful when you switch
3155 the formula.  Place multiple @samp{TBLFM} keywords right after the table,
3156 and then press @kbd{C-c C-c} on the formula to apply.  Here is an
3157 example:
3159 @example
3160 | x | y |
3161 |---+---|
3162 | 1 |   |
3163 | 2 |   |
3164 #+TBLFM: $2=$1*1
3165 #+TBLFM: $2=$1*2
3166 @end example
3168 @noindent
3169 Pressing @kbd{C-c C-c} in the line of @samp{#+TBLFM: $2=$1*2} yields:
3171 @example
3172 | x | y |
3173 |---+---|
3174 | 1 | 2 |
3175 | 2 | 4 |
3176 #+TBLFM: $2=$1*1
3177 #+TBLFM: $2=$1*2
3178 @end example
3180 @noindent
3181 Note: If you recalculate this table, with @kbd{C-u C-c *}, for
3182 example, you get the following result of applying only the first
3183 @samp{TBLFM} keyword.
3185 @example
3186 | x | y |
3187 |---+---|
3188 | 1 | 1 |
3189 | 2 | 2 |
3190 #+TBLFM: $2=$1*1
3191 #+TBLFM: $2=$1*2
3192 @end example
3194 @anchor{Debugging formulas}
3195 @subsubheading Debugging formulas
3197 @cindex formula debugging
3198 @cindex debugging, of table formulas
3200 When the evaluation of a formula leads to an error, the field content
3201 becomes the string @samp{#ERROR}.  If you would like to see what is going
3202 on during variable substitution and calculation in order to find
3203 a bug, turn on formula debugging in the Tbl menu and repeat the
3204 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in
3205 a field.  Detailed information are displayed.
3207 @node Updating the table
3208 @subsection Updating the table
3210 @cindex recomputing table fields
3211 @cindex updating, table
3213 Recalculation of a table is normally not automatic, but needs to be
3214 triggered by a command.  To make recalculation at least
3215 semi-automatic, see @ref{Advanced features}.
3217 In order to recalculate a line of a table or the entire table, use the
3218 following commands:
3220 @table @asis
3221 @item @kbd{C-c *} (@code{org-table-recalculate})
3222 @kindex C-c *
3223 @findex org-table-recalculate
3224 Recalculate the current row by first applying the stored column
3225 formulas from left to right, and all field/range formulas in the
3226 current row.
3228 @item @kbd{C-u C-c *} or @kbd{C-u C-c C-c}
3229 @kindex C-u C-c *
3230 @kindex C-u C-c C-c
3231 Recompute the entire table, line by line.  Any lines before the
3232 first hline are left alone, assuming that these are part of the
3233 table header.
3235 @item @kbd{C-u C-u C-c *} or @kbd{C-u C-u C-c C-c} (@code{org-table-iterate})
3236 @kindex C-u C-u C-c *
3237 @kindex C-u C-u C-c C-c
3238 @findex org-table-iterate
3239 Iterate the table by recomputing it until no further changes
3240 occur.  This may be necessary if some computed fields use the
3241 value of other fields that are computed @emph{later} in the
3242 calculation sequence.
3244 @item @kbd{M-x org-table-recalculate-buffer-tables}
3245 @findex org-table-recalculate-buffer-tables
3246 Recompute all tables in the current buffer.
3248 @item @kbd{M-x org-table-iterate-buffer-tables}
3249 @findex org-table-iterate-buffer-tables
3250 Iterate all tables in the current buffer, in order to converge
3251 table-to-table dependencies.
3252 @end table
3254 @node Advanced features
3255 @subsection Advanced features
3257 If you want the recalculation of fields to happen automatically, or if
3258 you want to be able to assign @emph{names}@footnote{Such names must start with an alphabetic character and use
3259 only alphanumeric/underscore characters.} to fields and columns,
3260 you need to reserve the first column of the table for special marking
3261 characters.
3263 @table @asis
3264 @item @kbd{C-#} (@code{org-table-rotate-recalc-marks})
3265 @kindex C-#
3266 @findex org-table-rotate-recalc-marks
3267 Rotate the calculation mark in first column through the states
3268 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region, change all
3269 marks in the region.
3270 @end table
3272 Here is an example of a table that collects exam results of students
3273 and makes use of these features:
3275 @example
3276 |---+---------+--------+--------+--------+-------+------|
3277 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
3278 |---+---------+--------+--------+--------+-------+------|
3279 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
3280 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
3281 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
3282 |---+---------+--------+--------+--------+-------+------|
3283 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
3284 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
3285 |---+---------+--------+--------+--------+-------+------|
3286 |   | Average |        |        |        |  25.0 |      |
3287 | ^ |         |        |        |        |    at |      |
3288 | $ | max=50  |        |        |        |       |      |
3289 |---+---------+--------+--------+--------+-------+------|
3290 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
3291 @end example
3293 @noindent
3294 @strong{Important}: please note that for these special tables, recalculating
3295 the table with @kbd{C-u C-c *} only affects rows that are marked
3296 @samp{#} or @samp{*}, and fields that have a formula assigned to the field
3297 itself.  The column formulas are not applied in rows with empty first
3298 field.
3300 @cindex marking characters, tables
3301 The marking characters have the following meaning:
3303 @table @asis
3304 @item @samp{!}
3305 The fields in this line define names for the columns, so that you
3306 may refer to a column as @samp{$Tot} instead of @samp{$6}.
3308 @item @samp{^}
3309 This row defines names for the fields @emph{above} the row.  With such
3310 a definition, any formula in the table may use @samp{$m1} to refer to
3311 the value @samp{10}.  Also, if you assign a formula to a names field,
3312 it is stored as @samp{$name = ...}.
3314 @item @samp{_}
3315 Similar to @samp{^}, but defines names for the fields in the row
3316 @emph{below}.
3318 @item @samp{$}
3319 Fields in this row can define @emph{parameters} for formulas.  For
3320 example, if a field in a @samp{$} row contains @samp{max=50}, then formulas
3321 in this table can refer to the value 50 using @samp{$max}.  Parameters
3322 work exactly like constants, only that they can be defined on
3323 a per-table basis.
3325 @item @samp{#}
3326 Fields in this row are automatically recalculated when pressing
3327 @kbd{@key{TAB}} or @kbd{@key{RET}} or @kbd{S-@key{TAB}} in this row.
3328 Also, this row is selected for a global recalculation with
3329 @kbd{C-u C-c *}.  Unmarked lines are left alone by this
3330 command.
3332 @item @samp{*}
3333 Selects this line for global recalculation with @kbd{C-u C-c *}, but not for automatic recalculation.  Use this when
3334 automatic recalculation slows down editing too much.
3336 @item @samp{/}
3337 Do not export this line.  Useful for lines that contain the
3338 narrowing @samp{<N>} markers or column group markers.
3339 @end table
3341 Finally, just to whet your appetite for what can be done with the
3342 fantastic Calc package, here is a table that computes the Taylor
3343 series of degree n at location x for a couple of functions.
3345 @example
3346 |---+-------------+---+-----+--------------------------------------|
3347 |   | Func        | n | x   | Result                               |
3348 |---+-------------+---+-----+--------------------------------------|
3349 | # | exp(x)      | 1 | x   | 1 + x                                |
3350 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
3351 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
3352 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
3353 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
3354 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
3355 |---+-------------+---+-----+--------------------------------------|
3356 #+TBLFM: $5=taylor($2,$4,$3);n3
3357 @end example
3359 @node Org Plot
3360 @section Org Plot
3362 @cindex graph, in tables
3363 @cindex plot tables using Gnuplot
3365 Org Plot can produce graphs of information stored in Org tables,
3366 either graphically or in ASCII art.
3368 @anchor{Graphical plots using Gnuplot}
3369 @subheading Graphical plots using Gnuplot
3371 @cindex @samp{PLOT}, keyword
3372 Org Plot can produce 2D and 3D graphs of information stored in Org
3373 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
3374 that you have both Gnuplot and Gnuplot mode installed on your system,
3375 then call @kbd{C-c " g} or @kbd{M-x org-plot/gnuplot} on the
3376 following table.
3378 @example
3379 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
3380 | Sede      | Max cites | H-index |
3381 |-----------+-----------+---------|
3382 | Chile     |    257.72 |   21.39 |
3383 | Leeds     |    165.77 |   19.68 |
3384 | Sao Paolo |     71.00 |   11.50 |
3385 | Stockholm |    134.19 |   14.33 |
3386 | Morelia   |    257.56 |   17.67 |
3387 @end example
3389 Notice that Org Plot is smart enough to apply the table's headers as
3390 labels.  Further control over the labels, type, content, and
3391 appearance of plots can be exercised through the @samp{PLOT} keyword
3392 preceding a table.  See below for a complete list of Org Plot options.
3393 For more information and examples see the @uref{https://orgmode.org/worg/org-tutorials/org-plot.html, Org Plot tutorial}.
3395 @anchor{Plot options}
3396 @subsubheading Plot options
3398 @table @asis
3399 @item @samp{set}
3400 Specify any Gnuplot option to be set when graphing.
3402 @item @samp{title}
3403 Specify the title of the plot.
3405 @item @samp{ind}
3406 Specify which column of the table to use as the @samp{x} axis.
3408 @item @samp{deps}
3409 Specify the columns to graph as a Lisp style list, surrounded by
3410 parentheses and separated by spaces for example @samp{dep:(3 4)} to
3411 graph the third and fourth columns.  Defaults to graphing all
3412 other columns aside from the @samp{ind} column.
3414 @item @samp{type}
3415 Specify whether the plot is @samp{2d}, @samp{3d}, or @samp{grid}.
3417 @item @samp{with}
3418 Specify a @samp{with} option to be inserted for every column being
3419 plotted, e.g., @samp{lines}, @samp{points}, @samp{boxes}, @samp{impulses}.  Defaults
3420 to @samp{lines}.
3422 @item @samp{file}
3423 If you want to plot to a file, specify
3424 @samp{"path/to/desired/output-file"}.
3426 @item @samp{labels}
3427 List of labels to be used for the @samp{deps}.  Defaults to the column
3428 headers if they exist.
3430 @item @samp{line}
3431 Specify an entire line to be inserted in the Gnuplot script.
3433 @item @samp{map}
3434 When plotting @samp{3d} or @samp{grid} types, set this to @samp{t} to graph
3435 a flat mapping rather than a @samp{3d} slope.
3437 @item @samp{timefmt}
3438 Specify format of Org mode timestamps as they will be parsed by
3439 Gnuplot.  Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
3441 @item @samp{script}
3442 If you want total control, you can specify a script file---place
3443 the file name between double-quotes---which will be used to plot.
3444 Before plotting, every instance of @samp{$datafile} in the specified
3445 script will be replaced with the path to the generated data file.
3446 Note: even if you set this option, you may still want to specify
3447 the plot type, as that can impact the content of the data file.
3448 @end table
3450 @anchor{ASCII bar plots}
3451 @subheading ASCII bar plots
3453 While the cursor is on a column, typing @kbd{C-c `` a} or
3454 @kbd{M-x orgtbl-ascii-plot} create a new column containing an
3455 ASCII-art bars plot.  The plot is implemented through a regular column
3456 formula.  When the source column changes, the bar plot may be updated
3457 by refreshing the table, for example typing @kbd{C-u C-c *}.
3459 @example
3460 | Sede          | Max cites |              |
3461 |---------------+-----------+--------------|
3462 | Chile         |    257.72 | WWWWWWWWWWWW |
3463 | Leeds         |    165.77 | WWWWWWWh     |
3464 | Sao Paolo     |     71.00 | WWW;         |
3465 | Stockholm     |    134.19 | WWWWWW:      |
3466 | Morelia       |    257.56 | WWWWWWWWWWWH |
3467 | Rochefourchat |      0.00 |              |
3468 #+TBLFM: $3='(orgtbl-ascii-draw $2 0.0 257.72 12)
3469 @end example
3471 The formula is an Elisp call.
3473 @defun orgtbl-ascii-draw value min max &optional width
3474 Draw an ASCII bar in a table.
3476 @var{VALUE} is the value to plot.
3478 @var{MIN} is the value displayed as an empty bar.  @var{MAX}
3479 is the value filling all the @var{WIDTH}.  Sources values outside
3480 this range are displayed as @samp{too small} or @samp{too large}.
3482 @var{WIDTH} is the number of characters of the bar plot.  It
3483 defaults to @samp{12}.
3484 @end defun
3486 @node Hyperlinks
3487 @chapter Hyperlinks
3489 @cindex hyperlinks
3491 Like HTML, Org provides links inside a file, external links to
3492 other files, Usenet articles, emails, and much more.
3494 @menu
3495 * Link Format::                  How links in Org are formatted.
3496 * Internal Links::               Links to other places in the current file.
3497 * Radio Targets::                Make targets trigger links in plain text.
3498 * External Links::               URL-like links to the world.
3499 * Handling Links::               Creating, inserting and following.
3500 * Using Links Outside Org::      Linking from my C source code?
3501 * Link Abbreviations::           Shortcuts for writing complex links.
3502 * Search Options::               Linking to a specific location.
3503 * Custom Searches::              When the default search is not enough.
3504 @end menu
3506 @node Link Format
3507 @section Link Format
3509 @cindex link format
3510 @cindex format, of links
3512 Org recognizes plain URL-like links and activate them as clickable
3513 links.  The general link format, however, looks like this:
3515 @example
3516 [[LINK][DESCRIPTION]]
3517 @end example
3519 @noindent
3520 or alternatively
3522 @example
3523 [[LINK]]
3524 @end example
3526 @noindent
3527 Once a link in the buffer is complete (all brackets present), Org
3528 changes the display so that @samp{DESCRIPTION} is displayed instead of
3529 @samp{[[LINK][DESCRIPTION]]} and @samp{LINK} is displayed instead of @samp{[[LINK]]}.  Links are be
3530 highlighted in the face @code{org-link}, which by default is an underlined
3531 face.  You can directly edit the visible part of a link.  Note that
3532 this can be either the LINK part, if there is no description, or the
3533 @var{DESCRIPTION} part.  To edit also the invisible
3534 @var{LINK} part, use @kbd{C-c C-l} with the cursor on the
3535 link.
3537 If you place the cursor at the beginning or just behind the end of the
3538 displayed text and press @kbd{@key{BS}}, you remove
3539 the---invisible---bracket at that location.  This makes the link
3540 incomplete and the internals are again displayed as plain text.
3541 Inserting the missing bracket hides the link internals again.  To show
3542 the internal structure of all links, use the menu: Org @arrow{} Hyperlinks @arrow{}
3543 Literal links.
3545 @node Internal Links
3546 @section Internal Links
3548 @cindex internal links
3549 @cindex links, internal
3550 @cindex targets, for links
3552 @cindex @samp{CUSTOM_ID}, property
3553 If the link does not look like a URL, it is considered to be internal
3554 in the current file.  The most important case is a link like
3555 @samp{[[#my-custom-id]]} which links to the entry with the @samp{CUSTOM_ID} property
3556 @samp{my-custom-id}.  You are responsible yourself to make sure these
3557 custom IDs are unique in a file.
3559 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]} lead to a text search in
3560 the current file.
3562 The link can be followed with @kbd{C-c C-o} when the cursor is on
3563 the link, or with a mouse click (see @ref{Handling Links}).  Links to
3564 custom IDs point to the corresponding headline.  The preferred match
3565 for a text link is a @emph{dedicated target}: the same string in double
3566 angular brackets, like @samp{<<My Target>>}.
3568 @cindex @samp{NAME}, keyword
3569 If no dedicated target exists, the link tries to match the exact name
3570 of an element within the buffer.  Naming is done with the @samp{NAME}
3571 keyword, which has to be put in the line before the element it refers
3572 to, as in the following example
3574 @example
3575 #+NAME: My Target
3576 | a  | table      |
3577 |----+------------|
3578 | of | four cells |
3579 @end example
3581 If none of the above succeeds, Org searches for a headline that is
3582 exactly the link text but may also include a TODO keyword and
3583 tags@footnote{To insert a link targeting a headline, in-buffer completion
3584 can be used.  Just type a star followed by a few optional letters into
3585 the buffer and press @kbd{M-@key{TAB}}.  All headlines in the current
3586 buffer are offered as completions.}.
3588 During export, internal links are used to mark objects and assign them
3589 a number.  Marked objects are then referenced by links pointing to
3590 them.  In particular, links without a description appear as the number
3591 assigned to the marked object@footnote{When targeting a @samp{NAME} keyword, @samp{CAPTION} keyword is
3592 mandatory in order to get proper numbering (see @ref{Images and Tables}).}.  In the following excerpt from
3593 an Org buffer
3595 @example
3596 1. one item
3597 2. <<target>>another item
3598 Here we refer to item [[target]].
3599 @end example
3601 @noindent
3602 The last sentence will appear as @samp{Here we refer to item 2} when
3603 exported.
3605 In non-Org files, the search looks for the words in the link text.  In
3606 the above example the search would be for @samp{target}.
3608 Following a link pushes a mark onto Org's own mark ring.  You can
3609 return to the previous position with @kbd{C-c &}.  Using this
3610 command several times in direct succession goes back to positions
3611 recorded earlier.
3613 @node Radio Targets
3614 @section Radio Targets
3616 @cindex radio targets
3617 @cindex targets, radio
3618 @cindex links, radio targets
3620 Org can automatically turn any occurrences of certain target names in
3621 normal text into a link.  So without explicitly creating a link, the
3622 text connects to the target radioing its position.  Radio targets are
3623 enclosed by triple angular brackets.  For example, a target @samp{<<<My
3624 Target>>>} causes each occurrence of @samp{my target} in normal text to
3625 become activated as a link.  The Org file is scanned automatically for
3626 radio targets only when the file is first loaded into Emacs.  To
3627 update the target list during editing, press @kbd{C-c C-c} with
3628 the cursor on or at a target.
3630 @node External Links
3631 @section External Links
3633 @cindex links, external
3634 @cindex external links
3635 @cindex Gnus links
3636 @cindex BBDB links
3637 @cindex irc links
3638 @cindex URL links
3639 @cindex file links
3640 @cindex Rmail links
3641 @cindex MH-E links
3642 @cindex Usenet links
3643 @cindex shell links
3644 @cindex Info links
3645 @cindex Elisp links
3647 Org supports links to files, websites, Usenet and email messages, BBDB
3648 database entries and links to both IRC conversations and their logs.
3649 External links are URL-like locators.  They start with a short
3650 identifying string followed by a colon.  There can be no space after
3651 the colon.  The following list shows examples for each link type.
3653 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
3654 @item @samp{http://www.astro.uva.nl/=dominik}
3655 @tab on the web
3656 @item @samp{doi:10.1000/182}
3657 @tab DOI for an electronic resource
3658 @item @samp{file:/home/dominik/images/jupiter.jpg}
3659 @tab file, absolute path
3660 @item @samp{/home/dominik/images/jupiter.jpg}
3661 @tab same as above
3662 @item @samp{file:papers/last.pdf}
3663 @tab file, relative path
3664 @item @samp{./papers/last.pdf}
3665 @tab same as above
3666 @item @samp{file:/ssh:me@@some.where:papers/last.pdf}
3667 @tab file, path on remote machine
3668 @item @samp{/ssh:me@@some.where:papers/last.pdf}
3669 @tab same as above
3670 @item @samp{file:sometextfile::NNN}
3671 @tab file, jump to line number
3672 @item @samp{file:projects.org}
3673 @tab another Org file
3674 @item @samp{file:projects.org::some words}
3675 @tab text search in Org file@footnote{The actual behavior of the search depends on the value of the
3676 variable @code{org-link-search-must-match-exact-headline}.  If its value is
3677 @code{nil}, then a fuzzy text search is done.  If it is @code{t}, then only the
3678 exact headline is matched, ignoring spaces and statistic cookies.  If
3679 the value is @code{query-to-create}, then an exact headline is searched; if
3680 it is not found, then the user is queried to create it.}
3681 @item @samp{file:projects.org::*task title}
3682 @tab heading search in Org file
3683 @item @samp{file+sys:/path/to/file}
3684 @tab open via OS, like double-click
3685 @item @samp{file+emacs:/path/to/file}
3686 @tab force opening by Emacs
3687 @item @samp{docview:papers/last.pdf::NNN}
3688 @tab open in doc-view mode at page
3689 @item @samp{id:B7423F4D-2E8A-471B-8810-C40F074717E9}
3690 @tab Link to heading by ID
3691 @item @samp{news:comp.emacs}
3692 @tab Usenet link
3693 @item @samp{mailto:adent@@galaxy.net}
3694 @tab Mail link
3695 @item @samp{mhe:folder}
3696 @tab MH-E folder link
3697 @item @samp{mhe:folder#id}
3698 @tab MH-E message link
3699 @item @samp{rmail:folder}
3700 @tab Rmail folder link
3701 @item @samp{rmail:folder#id}
3702 @tab Rmail message link
3703 @item @samp{gnus:group}
3704 @tab Gnus group link
3705 @item @samp{gnus:group#id}
3706 @tab Gnus article link
3707 @item @samp{bbdb:R.*Stallman}
3708 @tab BBDB link (with regexp)
3709 @item @samp{irc:/irc.com/#emacs/bob}
3710 @tab IRC link
3711 @item @samp{info:org#External links}
3712 @tab Info node link
3713 @item @samp{shell:ls *.org}
3714 @tab A shell command
3715 @item @samp{elisp:org-agenda}
3716 @tab Interactive Elisp command
3717 @item @samp{elisp:(find-file-other-frame "Elisp.org")}
3718 @tab Elisp form to evaluate
3719 @end multitable
3721 @cindex VM links
3722 @cindex Wanderlust links
3723 On top of these built-in link types, some are available through the
3724 @samp{contrib/} directory (see @ref{Installation}).  For example, these links to
3725 VM or Wanderlust messages are available when you load the
3726 corresponding libraries from the @samp{contrib/} directory:
3728 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaa}
3729 @item @samp{vm:folder}
3730 @tab VM folder link
3731 @item @samp{vm:folder#id}
3732 @tab VM message link
3733 @item @samp{vm://myself@@some.where.org/folder#id}
3734 @tab VM on remote machine
3735 @item @samp{vm-imap:account:folder}
3736 @tab VM IMAP folder link
3737 @item @samp{vm-imap:account:folder#id}
3738 @tab VM IMAP message link
3739 @item @samp{wl:folder}
3740 @tab Wanderlust folder link
3741 @item @samp{wl:folder#id}
3742 @tab Wanderlust message link
3743 @end multitable
3745 For customizing Org to add new link types, see @ref{Adding Hyperlink Types}.
3747 A link should be enclosed in double brackets and may contain
3748 a descriptive text to be displayed instead of the URL (see @ref{Link Format}), for example:
3750 @example
3751 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
3752 @end example
3754 @noindent
3755 If the description is a file name or URL that points to an image, HTML
3756 export (see @ref{HTML Export}) inlines the image as a clickable button.  If
3757 there is no description at all and the link points to an image, that
3758 image is inlined into the exported HTML file.
3760 @cindex square brackets, around links
3761 @cindex angular brackets, around links
3762 @cindex plain text external links
3763 Org also finds external links in the normal text and activates them as
3764 links.  If spaces must be part of the link (for example in
3765 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities about
3766 the end of the link, enclose them in square or angular brackets.
3768 @node Handling Links
3769 @section Handling Links
3771 @cindex links, handling
3773 Org provides methods to create a link in the correct syntax, to insert
3774 it into an Org file, and to follow the link.
3776 @findex org-store-link
3777 @cindex storing links
3778 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
3779 to a widely available key (see @ref{Activation}).  It stores a link to the
3780 current location.  The link is stored for later insertion into an Org
3781 buffer---see below.  What kind of link is created depends on the
3782 current buffer:
3784 @table @asis
3785 @item @emph{Org mode buffers}
3786 For Org files, if there is a @samp{<<target>>} at the cursor, the link
3787 points to the target.  Otherwise it points to the current
3788 headline, which is also the description@footnote{If the headline contains a timestamp, it is removed from the
3789 link, which results in a wrong link---you should avoid putting
3790 a timestamp in the headline.}.
3792 @vindex org-link-to-org-use-id
3793 @cindex @samp{CUSTOM_ID}, property
3794 @cindex @samp{ID}, property
3795 If the headline has a @samp{CUSTOM_ID} property, store a link to this
3796 custom ID.  In addition or alternatively, depending on the value
3797 of @code{org-link-to-org-use-id}, create and/or use a globally unique
3798 ID property for the link@footnote{The Org Id library must first be loaded, either through
3799 @code{org-customize}, by enabling @code{id} in @code{org-modules}, or by adding
3800 @code{(require 'org-id)} in your Emacs init file.}.  So using this command in Org
3801 buffers potentially creates two links: a human-readable link from
3802 the custom ID, and one that is globally unique and works even if
3803 the entry is moved from file to file.  Later, when inserting the
3804 link, you need to decide which one to use.
3806 @item @emph{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}
3807 Pretty much all Emacs mail clients are supported.  The link
3808 points to the current article, or, in some Gnus buffers, to the
3809 group.  The description is constructed from the author and the
3810 subject.
3812 @item @emph{Web browsers: W3, W3M and EWW}
3813 Here the link is the current URL, with the page title as
3814 description.
3816 @item @emph{Contacts: BBDB}
3817 Links created in a BBDB buffer point to the current entry.
3819 @item @emph{Chat: IRC}
3820 @vindex org-irc-links-to-logs
3821 For IRC links, if the variable @code{org-irc-link-to-logs} is
3822 non-@code{nil}, create a @samp{file} style link to the relevant point in
3823 the logs for the current conversation.  Otherwise store an @samp{irc}
3824 style link to the user/channel/server under the point.
3826 @item @emph{Other files}
3827 For any other file, the link points to the file, with a search
3828 string (see @ref{Search Options}) pointing to the
3829 contents of the current line.  If there is an active region, the
3830 selected words form the basis of the search string.  If the
3831 automatically created link is not working correctly or accurately
3832 enough, you can write custom functions to select the search
3833 string and to do the search for particular file types (see
3834 @ref{Custom Searches}).
3836 You can also define dedicated links to other files.  See @ref{Adding Hyperlink Types}.
3838 @item @emph{Agenda view}
3839 When the cursor is in an agenda view, the created link points to
3840 the entry referenced by the current line.
3841 @end table
3843 From an Org buffer, the following commands create, navigate or, more
3844 generally, act on links.
3846 @table @asis
3847 @item @kbd{C-c C-l} (@code{org-insert-link})
3848 @kindex C-c C-l
3849 @findex org-insert-link
3850 @cindex link completion
3851 @cindex completion, of links
3852 @cindex inserting links
3853 @vindex org-keep-stored-link-after-insertion
3854 Insert a link@footnote{Note that you do not have to use this command to insert
3855 a link.  Links in Org are plain text, and you can type or paste them
3856 straight into the buffer.  By using this command, the links are
3857 automatically enclosed in double brackets, and you will be asked for
3858 the optional descriptive text.}.  This prompts for a link to be inserted
3859 into the buffer.  You can just type a link, using text for an
3860 internal link, or one of the link type prefixes mentioned in the
3861 examples above.  The link is inserted into the buffer, along with
3862 a descriptive text@footnote{After insertion of a stored link, the link will be removed
3863 from the list of stored links.  To keep it in the list later use, use
3864 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or
3865 configure the option @code{org-keep-stored-link-after-insertion}.}.  If some text was selected at this
3866 time, it becomes the default description.
3868 @table @asis
3869 @item @emph{Inserting stored links}
3870 All links stored during the current session are part of the
3871 history for this prompt, so you can access them with
3872 @kbd{@key{UP}} and @kbd{@key{DOWN}} (or @kbd{M-p},
3873 @kbd{M-n}).
3875 @item @emph{Completion support}
3876 Completion with @kbd{@key{TAB}} helps you to insert valid link
3877 prefixes like @samp{http} or @samp{ftp}, including the prefixes defined
3878 through link abbreviations (see @ref{Link Abbreviations}).  If you
3879 press @kbd{@key{RET}} after inserting only the prefix, Org
3880 offers specific completion support for some link types@footnote{This works if a function has been defined in the @code{:complete}
3881 property of a link in @code{org-link-parameters}.}.
3882 For example, if you type @kbd{f i l e @key{RET}}---alternative
3883 access: @kbd{C-u C-c C-l}, see below---Org offers file
3884 name completion, and after @kbd{b b d b @key{RET}} you can
3885 complete contact names.
3886 @end table
3888 @item @kbd{C-u C-c C-l}
3889 @cindex file name completion
3890 @cindex completion, of file names
3891 @kindex C-u C-c C-l
3892 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix
3893 argument, insert a link to a file.  You may use file name
3894 completion to select the name of the file.  The path to the file
3895 is inserted relative to the directory of the current Org file, if
3896 the linked file is in the current directory or in a sub-directory
3897 of it, or if the path is written relative to the current
3898 directory using @samp{../}.  Otherwise an absolute path is used, if
3899 possible with @samp{~/} for your home directory.  You can force an
3900 absolute path with two @kbd{C-u} prefixes.
3902 @item @kbd{C-c C-l} (with cursor on existing link)
3903 @cindex following links
3904 When the cursor is on an existing link, @kbd{C-c C-l} allows
3905 you to edit the link and description parts of the link.
3907 @item @kbd{C-c C-o} (@code{org-open-at-point})
3908 @kindex C-c C-o
3909 @findex org-open-at-point
3910 @vindex org-file-apps
3911 Open link at point.  This launches a web browser for URL (using
3912 @code{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB
3913 for the corresponding links, and execute the command in a shell
3914 link.  When the cursor is on an internal link, this command runs
3915 the corresponding search.  When the cursor is on a TAG list in
3916 a headline, it creates the corresponding TAGS view.  If the
3917 cursor is on a timestamp, it compiles the agenda for that date.
3918 Furthermore, it visits text and remote files in @samp{file} links with
3919 Emacs and select a suitable application for local non-text files.
3920 Classification of files is based on file extension only.  See
3921 option @code{org-file-apps}.  If you want to override the default
3922 application and visit the file with Emacs, use a @kbd{C-u}
3923 prefix.  If you want to avoid opening in Emacs, use a @kbd{C-u C-u} prefix.
3925 @vindex org-link-frame-setup
3926 If the cursor is on a headline, but not on a link, offer all
3927 links in the headline and entry text.  If you want to setup the
3928 frame configuration for following links, customize
3929 @code{org-link-frame-setup}.
3931 @item @kbd{@key{RET}}
3932 @vindex org-return-follows-link
3933 @kindex RET
3934 When @code{org-return-follows-link} is set, @kbd{@key{RET}} also
3935 follows the link at point.
3937 @item @kbd{mouse-2} or @kbd{mouse-1}
3938 @kindex mouse-2
3939 @kindex mouse-1
3940 On links, @kbd{mouse-1} and @kbd{mouse-2} opens the
3941 link just as @kbd{C-c C-o} does.
3943 @item @kbd{mouse-3}
3944 @vindex org-display-internal-link-with-indirect-buffer
3945 @kindex mouse-3
3946 Like @kbd{mouse-2}, but force file links to be opened with
3947 Emacs, and internal links to be displayed in another
3948 window@footnote{See the variable @code{org-display-internal-link-with-indirect-buffer}.}.
3950 @item @kbd{C-c C-x C-v} (@code{org-toggle-inline-images})
3951 @cindex inlining images
3952 @cindex images, inlining
3953 @vindex org-startup-with-inline-images
3954 @kindex C-c C-x C-v
3955 @findex org-toggle-inline-images
3956 Toggle the inline display of linked images.  Normally this only
3957 inlines images that have no description part in the link, i.e.,
3958 images that are inlined during export.  When called with a prefix
3959 argument, also display images that do have a link description.
3960 You can ask for inline images to be displayed at startup by
3961 configuring the variable @code{org-startup-with-inline-images}@footnote{The variable @code{org-startup-with-inline-images} can be set
3962 within a buffer with the @samp{STARTUP} options @samp{inlineimages} and
3963 @samp{noinlineimages}.}.
3965 @item @kbd{C-c %} (@code{org-mark-ring-push})
3966 @kindex C-c %
3967 @findex org-mark-ring-push
3968 @cindex mark ring
3969 Push the current position onto the mark ring, to be able to
3970 return easily.  Commands following an internal link do this
3971 automatically.
3973 @item @kbd{C-c &} (@code{org-mark-ring-goto})
3974 @kindex C-c &
3975 @findex org-mark-ring-goto
3976 @cindex links, returning to
3977 Jump back to a recorded position.  A position is recorded by the
3978 commands following internal links, and by @kbd{C-c %}.
3979 Using this command several times in direct succession moves
3980 through a ring of previously recorded positions.
3982 @item @kbd{C-c C-x C-n} (@code{org-next-link})
3983 @itemx @kbd{C-c C-x C-p} (@code{org-previous-link})
3984 @kindex C-c C-x C-p
3985 @findex org-previous-link
3986 @kindex C-c C-x C-n
3987 @findex org-next-link
3988 @cindex links, finding next/previous
3989 Move forward/backward to the next link in the buffer.  At the
3990 limit of the buffer, the search fails once, and then wraps
3991 around.  The key bindings for this are really too long; you might
3992 want to bind this also to @kbd{M-n} and @kbd{M-p}.
3994 @lisp
3995 (add-hook 'org-load-hook
3996           (lambda ()
3997             (define-key org-mode-map "\M-n" 'org-next-link)
3998             (define-key org-mode-map "\M-p" 'org-previous-link)))
3999 @end lisp
4000 @end table
4002 @node Using Links Outside Org
4003 @section Using Links Outside Org
4005 @findex org-insert-link-global
4006 @findex org-open-at-point-global
4007 You can insert and follow links that have Org syntax not only in Org,
4008 but in any Emacs buffer.  For this, Org provides two functions:
4009 @code{org-insert-link-global} and @code{org-open-at-point-global}.
4011 You might want to bind them to globally available keys.  See
4012 @ref{Activation} for some advice.
4014 @node Link Abbreviations
4015 @section Link Abbreviations
4017 @cindex link abbreviations
4018 @cindex abbreviation, links
4020 Long URL can be cumbersome to type, and often many similar links are
4021 needed in a document.  For this you can use link abbreviations.  An
4022 abbreviated link looks like this
4024 @example
4025 [[linkword:tag][description]]
4026 @end example
4028 @noindent
4029 @vindex org-link-abbrev-alist
4030 where the tag is optional.  The @emph{linkword} must be a word, starting
4031 with a letter, followed by letters, numbers, @samp{-}, and @samp{_}.
4032 Abbreviations are resolved according to the information in the
4033 variable @code{org-link-abbrev-alist} that relates the linkwords to
4034 replacement text.  Here is an example:
4036 @lisp
4037 (setq org-link-abbrev-alist
4038       '(("bugzilla"  . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
4039         ("url-to-ja" . "http://translate.google.fr/translate?sl=en&tl=ja&u=%h")
4040         ("google"    . "http://www.google.com/search?q=")
4041         ("gmap"      . "http://maps.google.com/maps?q=%s")
4042         ("omap"      . "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")
4043         ("ads"       . "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?author=%s&db_key=AST")))
4044 @end lisp
4046 If the replacement text contains the string @samp{%s}, it is replaced with
4047 the tag.  Using @samp{%h} instead of @samp{%s} percent-encodes the tag (see the
4048 example above, where we need to encode the URL parameter).  Using
4049 @samp{%(my-function)} passes the tag to a custom function, and replace it
4050 by the resulting string.
4052 If the replacement text do not contain any specifier, it is simply
4053 appended to the string in order to create the link.
4055 Instead of a string, you may also specify a function that will be
4056 called with the tag as the only argument to create the link.
4058 With the above setting, you could link to a specific bug with
4059 @samp{[[bugzilla:129]]}, search the web for @samp{OrgMode} with @samp{[[google:OrgMode]]},
4060 show the map location of the Free Software Foundation @samp{[[gmap:51
4061 Franklin Street, Boston]]} or of Carsten office @samp{[[omap:Science Park 904,
4062 Amsterdam, The Netherlands]]} and find out what the Org author is doing
4063 besides Emacs hacking with @samp{[[ads:Dominik,C]]}.
4065 If you need special abbreviations just for a single Org buffer, you
4066 can define them in the file with
4068 @cindex @samp{LINK}, keyword
4069 @example
4070 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
4071 #+LINK: google    http://www.google.com/search?q=%s
4072 @end example
4074 @noindent
4075 In-buffer completion (see @ref{Completion}) can be used after @samp{[} to
4076 complete link abbreviations.  You may also define a function that
4077 implements special (e.g., completion) support for inserting such
4078 a link with @kbd{C-c C-l}.  Such a function should not accept any
4079 arguments, and return the full link with prefix.  You can set the link
4080 completion function like this:
4082 @lisp
4083 (org-link-set-parameter "type" :complete #'some-completion-function)
4084 @end lisp
4086 @node Search Options
4087 @section Search Options in File Links
4089 @cindex search option in file links
4090 @cindex file links, searching
4092 File links can contain additional information to make Emacs jump to
4093 a particular location in the file when following a link.  This can be
4094 a line number or a search option after a double colon@footnote{For backward compatibility, line numbers can also follow a
4095 single colon.}.  For
4096 example, when the command @code{org-store-link} creates a link (see
4097 @ref{Handling Links}) to a file, it encodes the words in the current line
4098 as a search string that can be used to find this line back later when
4099 following the link with @kbd{C-c C-o}.
4101 Here is the syntax of the different ways to attach a search to a file
4102 link, together with an explanation:
4104 @example
4105 [[file:~/code/main.c::255]]
4106 [[file:~/xx.org::My Target]]
4107 [[file:~/xx.org::*My Target]]
4108 [[file:~/xx.org::#my-custom-id]]
4109 [[file:~/xx.org::/regexp/]]
4110 @end example
4112 @table @asis
4113 @item @samp{255}
4114 Jump to line 255.
4116 @item @samp{My Target}
4117 Search for a link target @samp{<<My Target>>}, or do a text search for
4118 @samp{my target}, similar to the search in internal links, see
4119 @ref{Internal Links}.  In HTML export (see @ref{HTML Export}), such a file
4120 link becomes a HTML reference to the corresponding named anchor
4121 in the linked file.
4123 @item @samp{*My Target}
4124 In an Org file, restrict search to headlines.
4126 @item @samp{#my-custom-id}
4127 Link to a heading with a @samp{CUSTOM_ID} property
4129 @item @samp{/REGEXP/}
4130 Do a regular expression search for @var{REGEXP}.  This uses
4131 the Emacs command @code{occur} to list all matches in a separate
4132 window.  If the target file is in Org mode, @code{org-occur} is used
4133 to create a sparse tree with the matches.
4134 @end table
4136 As a degenerate case, a file link with an empty file name can be used
4137 to search the current file.  For example, @samp{[[file:::find me]]} does
4138 a search for @samp{find me} in the current file, just as @samp{[[find me]]} would.
4140 @node Custom Searches
4141 @section Custom Searches
4143 @cindex custom search strings
4144 @cindex search strings, custom
4146 The default mechanism for creating search strings and for doing the
4147 actual search related to a file link may not work correctly in all
4148 cases.  For example, Bib@TeX{} database files have many entries like
4149 @code{year="1993"} which would not result in good search strings, because
4150 the only unique identification for a Bib@TeX{} entry is the citation key.
4152 @vindex org-create-file-search-functions
4153 @vindex org-execute-file-search-functions
4154 If you come across such a problem, you can write custom functions to
4155 set the right search string for a particular file type, and to do the
4156 search for the string in the file.  Using @code{add-hook}, these functions
4157 need to be added to the hook variables
4158 @code{org-create-file-search-functions} and
4159 @code{org-execute-file-search-functions}.  See the docstring for these
4160 variables for more information.  Org actually uses this mechanism for
4161 Bib@TeX{} database files, and you can use the corresponding code as an
4162 implementation example.  See the file @samp{org-bibtex.el}.
4164 @node TODO Items
4165 @chapter TODO Items
4167 @cindex TODO items
4169 Org mode does not maintain TODO lists as separate documents@footnote{Of course, you can make a document that contains only long
4170 lists of TODO items, but this is not required.}.
4171 Instead, TODO items are an integral part of the notes file, because
4172 TODO items usually come up while taking notes!  With Org mode, simply
4173 mark any entry in a tree as being a TODO item.  In this way,
4174 information is not duplicated, and the entire context from which the
4175 TODO item emerged is always present.
4177 Of course, this technique for managing TODO items scatters them
4178 throughout your notes file.  Org mode compensates for this by
4179 providing methods to give you an overview of all the things that you
4180 have to do.
4182 @menu
4183 * TODO Basics::                  Marking and displaying TODO entries.
4184 * TODO Extensions::              Workflow and assignments.
4185 * Progress Logging::             Dates and notes for progress.
4186 * Priorities::                   Some things are more important than others.
4187 * Breaking Down Tasks::          Splitting a task into manageable pieces.
4188 * Checkboxes::                   Tick-off lists.
4189 @end menu
4191 @node TODO Basics
4192 @section Basic TODO Functionality
4194 Any headline becomes a TODO item when it starts with the word @samp{TODO},
4195 for example:
4197 @example
4198 *** TODO Write letter to Sam Fortune
4199 @end example
4201 @noindent
4202 The most important commands to work with TODO entries are:
4204 @table @asis
4205 @item @kbd{C-c C-t} (@code{org-todo})
4206 @kindex C-c C-t
4207 @cindex cycling, of TODO states
4208 Rotate the TODO state of the current item among
4210 @example
4211 ,-> (unmarked) -> TODO -> DONE --.
4212 '--------------------------------'
4213 @end example
4215 If TODO keywords have fast access keys (see @ref{Fast access to TODO states}), prompt for a TODO keyword through the fast
4216 selection interface; this is the default behavior when
4217 @code{org-use-fast-todo-selection} is non-@code{nil}.
4219 The same rotation can also be done ``remotely'' from the timeline
4220 and agenda buffers with the @kbd{t} command key (see
4221 @ref{Agenda Commands}).
4223 @item @kbd{C-u C-c C-t}
4224 @kindex C-u C-c C-t
4225 When TODO keywords have no selection keys, select a specific
4226 keyword using completion; otherwise force cycling through TODO
4227 states with no prompt.  When @code{org-use-fast-todo-selection} is set
4228 to @code{prefix}, use the fast selection interface.
4230 @item @kbd{S-@key{RIGHT}} @kbd{S-@key{LEFT}}
4231 @kindex S-RIGHT
4232 @kindex S-LEFT
4233 @vindex org-treat-S-cursor-todo-selection-as-state-change
4234 Select the following/preceding TODO state, similar to cycling.
4235 Useful mostly if more than two TODO states are possible (see
4236 @ref{TODO Extensions}).  See also @ref{Conflicts}, for a discussion of the interaction with
4237 @code{shift-selection-mode}.  See also the variable
4238 @code{org-treat-S-cursor-todo-selection-as-state-change}.
4240 @item @kbd{C-c / t} (@code{org-show-todo-tree})
4241 @kindex C-c / t
4242 @cindex sparse tree, for TODO
4243 @vindex org-todo-keywords
4244 @findex org-show-todo-tree
4245 View TODO items in a @emph{sparse tree} (see @ref{Sparse Trees}).  Folds
4246 the entire buffer, but shows all TODO items---with not-DONE
4247 state---and the headings hierarchy above them.  With a prefix
4248 argument, or by using @kbd{C-c / T}, search for a specific
4249 TODO.  You are prompted for the keyword, and you can also give
4250 a list of keywords like @samp{KWD1|KWD2|...} to list entries that
4251 match any one of these keywords.  With a numeric prefix argument
4252 N, show the tree for the Nth keyword in the variable
4253 @code{org-todo-keywords}.  With two prefix arguments, find all TODO
4254 states, both un-done and done.
4256 @item @kbd{C-c a t} (@code{org-todo-list})
4257 @kindex C-c a t
4258 Show the global TODO list.  Collects the TODO items (with
4259 not-DONE states) from all agenda files (see @ref{Agenda Views}) into
4260 a single buffer.  The new buffer is in Org Agenda mode, which
4261 provides commands to examine and manipulate the TODO entries from
4262 the new buffer (see @ref{Agenda Commands}).  See @ref{Global TODO list}, for more information.
4264 @item @kbd{S-M-@key{RET}} (@code{org-insert-todo-heading})
4265 @kindex S-M-RET
4266 @findex org-insert-todo-heading
4267 Insert a new TODO entry below the current one.
4268 @end table
4270 @vindex org-todo-state-tags-triggers
4271 @noindent
4272 Changing a TODO state can also trigger tag changes.  See the docstring
4273 of the option @code{org-todo-state-tags-triggers} for details.
4275 @node TODO Extensions
4276 @section Extended Use of TODO Keywords
4278 @cindex extended TODO keywords
4280 @vindex org-todo-keywords
4281 By default, marked TODO entries have one of only two states: TODO and
4282 DONE.  Org mode allows you to classify TODO items in more complex ways
4283 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With special
4284 setup, the TODO keyword system can work differently in different
4285 files.
4287 Note that @emph{tags} are another way to classify headlines in general and
4288 TODO items in particular (see @ref{Tags}).
4290 @menu
4291 * Workflow states::              From TODO to DONE in steps.
4292 * TODO types::                   I do this, Fred does the rest.
4293 * Multiple sets in one file::    Mixing it all, still finding your way.
4294 * Fast access to TODO states::   Single letter selection of state.
4295 * Per-file keywords::            Different files, different requirements.
4296 * Faces for TODO keywords::      Highlighting states.
4297 * TODO dependencies::            When one task needs to wait for others.
4298 @end menu
4300 @node Workflow states
4301 @subsection TODO keywords as workflow states
4303 @cindex TODO workflow
4304 @cindex workflow states as TODO keywords
4306 You can use TODO keywords to indicate different @emph{sequential} states in
4307 the process of working on an item, for example@footnote{Changing the variable @code{org-todo-keywords} only becomes
4308 effective after restarting Org mode in a buffer.}:
4310 @lisp
4311 (setq org-todo-keywords
4312       '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
4313 @end lisp
4315 The vertical bar separates the TODO keywords (states that @emph{need
4316 action}) from the DONE states (which need @emph{no further action}).  If
4317 you do not provide the separator bar, the last state is used as the
4318 DONE state.
4320 @cindex completion, of TODO keywords
4321 With this setup, the command @kbd{C-c C-t} cycles an entry from
4322 @samp{TODO} to @samp{FEEDBACK}, then to @samp{VERIFY}, and finally to @samp{DONE} and
4323 @samp{DELEGATED}.  You may also use a numeric prefix argument to quickly
4324 select a specific state.  For example @kbd{C-3 C-c C-t} changes
4325 the state immediately to @samp{VERIFY}.  Or you can use @kbd{S-@key{LEFT}}
4326 to go backward through the sequence.  If you define many keywords, you
4327 can use in-buffer completion (see @ref{Completion}) or even a special
4328 one-key selection scheme (see @ref{Fast access to TODO states}) to insert
4329 these words into the buffer.  Changing a TODO state can be logged with
4330 a timestamp, see @ref{Tracking TODO state changes}, for more information.
4332 @node TODO types
4333 @subsection TODO keywords as types
4335 @cindex TODO types
4336 @cindex names as TODO keywords
4337 @cindex types as TODO keywords
4339 The second possibility is to use TODO keywords to indicate different
4340 @emph{types} of action items.  For example, you might want to indicate that
4341 items are for ``work'' or ``home''.  Or, when you work with several people
4342 on a single project, you might want to assign action items directly to
4343 persons, by using their names as TODO keywords.  This would be set up
4344 like this:
4346 @lisp
4347 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
4348 @end lisp
4350 In this case, different keywords do not indicate a sequence, but
4351 rather different types.  So the normal work flow would be to assign
4352 a task to a person, and later to mark it DONE.  Org mode supports this
4353 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
4354 and agenda buffers.}.  When used several times in succession, it still
4355 cycles through all names, in order to first select the right type for
4356 a task.  But when you return to the item after some time and execute
4357 @kbd{C-c C-t} again, it will switch from any name directly to
4358 @samp{DONE}.  Use prefix arguments or completion to quickly select
4359 a specific name.  You can also review the items of a specific TODO
4360 type in a sparse tree by using a numeric prefix to @kbd{C-c / t}.
4361 For example, to see all things Lucy has to do, you would use
4362 @kbd{C-3 C-c / t}.  To collect Lucy's items from all agenda files
4363 into a single buffer, you would use the numeric prefix argument as
4364 well when creating the global TODO list: @kbd{C-3 C-c a t}.
4366 @node Multiple sets in one file
4367 @subsection Multiple keyword sets in one file
4369 @cindex TODO keyword sets
4371 Sometimes you may want to use different sets of TODO keywords in
4372 parallel.  For example, you may want to have the basic TODO/DONE, but
4373 also a workflow for bug fixing, and a separate state indicating that
4374 an item has been canceled---so it is not DONE, but also does not
4375 require action.  Your setup would then look like this:
4377 @lisp
4378 (setq org-todo-keywords
4379       '((sequence "TODO" "|" "DONE")
4380         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
4381         (sequence "|" "CANCELED")))
4382 @end lisp
4384 The keywords should all be different, this helps Org mode to keep
4385 track of which subsequence should be used for a given entry.  In this
4386 setup, @kbd{C-c C-t} only operates within a subsequence, so it
4387 switches from @samp{DONE} to (nothing) to @samp{TODO}, and from @samp{FIXED} to
4388 (nothing) to @samp{REPORT}.  Therefore you need a mechanism to initially
4389 select the correct sequence.  Besides the obvious ways like typing
4390 a keyword or using completion, you may also apply the following
4391 commands:
4393 @table @asis
4394 @item @kbd{C-u C-u C-c C-t}
4395 @itemx @kbd{C-S-@key{RIGHT}}
4396 @itemx @kbd{C-S-@key{LEFT}}
4397 @kindex C-S-RIGHT
4398 @kindex C-S-LEFT
4399 @kindex C-u C-u C-c C-t
4400 These keys jump from one TODO subset to the next.  In the above
4401 example, @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{RIGHT}} would
4402 jump from @samp{TODO} or @samp{DONE} to @samp{REPORT}, and any of the words in
4403 the second row to @samp{CANCELED}.  Note that the @kbd{C-S-} key
4404 binding conflict with @code{shift-selection-mode} (see @ref{Conflicts}).
4406 @item @kbd{S-@key{RIGHT}}
4407 @itemx @kbd{S-@key{LEFT}}
4408 @kindex S-RIGHT
4409 @kindex S-LEFT
4410 @kbd{S-@key{LEFT}} and @kbd{S-@key{RIGHT}} walk through @emph{all}
4411 keywords from all sets, so for example @kbd{S-@key{RIGHT}} would
4412 switch from @samp{DONE} to @samp{REPORT} in the example above.  For
4413 a discussion of the interaction with @code{shift-selection-mode}, see
4414 @ref{Conflicts}.
4415 @end table
4417 @node Fast access to TODO states
4418 @subsection Fast access to TODO states
4420 If you would like to quickly change an entry to an arbitrary TODO
4421 state instead of cycling through the states, you can set up keys for
4422 single-letter access to the states.  This is done by adding the
4423 selection character after each keyword, in parentheses@footnote{All characters are allowed except @samp{@@}, @samp{^} and @samp{!}, which have
4424 a special meaning here.}.  For
4425 example:
4427 @lisp
4428 (setq org-todo-keywords
4429       '((sequence "TODO(t)" "|" "DONE(d)")
4430         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
4431         (sequence "|" "CANCELED(c)")))
4432 @end lisp
4434 @vindex org-fast-tag-selection-include-todo
4435 If you then press @kbd{C-c C-t} followed by the selection key,
4436 the entry is switched to this state.  @kbd{@key{SPC}} can be used to
4437 remove any TODO keyword from an entry@footnote{Check also the variable @code{org-fast-tag-selection-include-todo},
4438 it allows you to change the TODO state through the tags interface
4439 (@ref{Setting Tags}), in case you like to mingle the two concepts.  Note
4440 that this means you need to come up with unique keys across both sets
4441 of keywords.}.
4443 @node Per-file keywords
4444 @subsection Setting up keywords for individual files
4446 @cindex keyword options
4447 @cindex per-file keywords
4448 @cindex @samp{TODO}, keyword
4449 @cindex @samp{TYP_TODO}, keyword
4450 @cindex @samp{SEQ_TODO}, keyword
4452 It can be very useful to use different aspects of the TODO mechanism
4453 in different files.  For file-local settings, you need to add special
4454 lines to the file which set the keywords and interpretation for that
4455 file only.  For example, to set one of the two examples discussed
4456 above, you need one of the following lines, starting in column zero
4457 anywhere in the file:
4459 @example
4460 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
4461 @end example
4463 @noindent
4464 you may also write @samp{#+SEQ_TODO} to be explicit about the
4465 interpretation, but it means the same as @samp{#+TODO}, or
4467 @example
4468 #+TYP_TODO: Fred Sara Lucy Mike | DONE
4469 @end example
4471 A setup for using several sets in parallel would be:
4473 @example
4474 #+TODO: TODO | DONE
4475 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
4476 #+TODO: | CANCELED
4477 @end example
4479 @cindex completion, of option keywords
4480 @kindex M-TAB
4481 @noindent
4482 To make sure you are using the correct keyword, type @samp{#+} into the
4483 buffer and then use @kbd{M-@key{TAB}} completion.
4485 @cindex DONE, final TODO keyword
4486 Remember that the keywords after the vertical bar---or the last
4487 keyword if no bar is there---must always mean that the item is DONE,
4488 although you may use a different word.  After changing one of these
4489 lines, use @kbd{C-c C-c} with the cursor still in the line to
4490 make the changes known to Org mode@footnote{Org mode parses these lines only when Org mode is activated
4491 after visiting a file.  @kbd{C-c C-c} with the cursor in a line
4492 starting with @samp{#+} is simply restarting Org mode for the current
4493 buffer.}.
4495 @node Faces for TODO keywords
4496 @subsection Faces for TODO keywords
4498 @cindex faces, for TODO keywords
4500 @vindex org-todo, face
4501 @vindex org-done, face
4502 @vindex org-todo-keyword-faces
4503 Org mode highlights TODO keywords with special faces: @code{org-todo} for
4504 keywords indicating that an item still has to be acted upon, and
4505 @code{org-done} for keywords indicating that an item is finished.  If you
4506 are using more than two different states, you might want to use
4507 special faces for some of them.  This can be done using the variable
4508 @code{org-todo-keyword-faces}.  For example:
4510 @lisp
4511 (setq org-todo-keyword-faces
4512       '(("TODO" . org-warning) ("STARTED" . "yellow")
4513         ("CANCELED" . (:foreground "blue" :weight bold))))
4514 @end lisp
4516 @vindex org-faces-easy-properties
4517 While using a list with face properties as shown for @samp{CANCELED}
4518 @emph{should} work, this does not always seem to be the case.  If
4519 necessary, define a special face and use that.  A string is
4520 interpreted as a color.  The variable @code{org-faces-easy-properties}
4521 determines if that color is interpreted as a foreground or
4522 a background color.
4524 @node TODO dependencies
4525 @subsection TODO dependencies
4527 @cindex TODO dependencies
4528 @cindex dependencies, of TODO states
4530 @vindex org-enforce-todo-dependencies
4531 @cindex @samp{ORDERED}, property
4532 The structure of Org files---hierarchy and lists---makes it easy to
4533 define TODO dependencies.  Usually, a parent TODO task should not be
4534 marked DONE until all subtasks, defined as children tasks, are marked
4535 as DONE.  And sometimes there is a logical sequence to a number of
4536 (sub)tasks, so that one task cannot be acted upon before all siblings
4537 above it are done.  If you customize the variable
4538 @code{org-enforce-todo-dependencies}, Org blocks entries from changing
4539 state to DONE while they have children that are not DONE.
4540 Furthermore, if an entry has a property @samp{ORDERED}, each of its
4541 children is blocked until all earlier siblings are marked DONE.  Here
4542 is an example:
4544 @example
4545 * TODO Blocked until (two) is done
4546 ** DONE one
4547 ** TODO two
4549 * Parent
4550 :PROPERTIES:
4551 :ORDERED:  t
4552 :END:
4553 ** TODO a
4554 ** TODO b, needs to wait for (a)
4555 ** TODO c, needs to wait for (a) and (b)
4556 @end example
4558 @cindex TODO dependencies, NOBLOCKING
4559 @cindex NOBLOCKING, property
4560 You can ensure an entry is never blocked by using the @samp{NOBLOCKING}
4561 property:
4563 @example
4564 * This entry is never blocked
4565 :PROPERTIES:
4566 :NOBLOCKING: t
4567 :END:
4568 @end example
4570 @table @asis
4571 @item @kbd{C-c C-x o} (@code{org-toggle-ordered-property})
4572 @kindex C-c C-x o
4573 @findex org-toggle-ordered-property
4574 @vindex org-track-ordered-property-with-tag
4575 Toggle the @samp{ORDERED} property of the current entry.  A property
4576 is used for this behavior because this should be local to the
4577 current entry, not inherited like a tag.  However, if you would
4578 like to @emph{track} the value of this property with a tag for better
4579 visibility, customize the variable
4580 @code{org-track-ordered-property-with-tag}.
4582 @item @kbd{C-u C-u C-u C-c C-t}
4583 @kindex C-u C-u C-u C-c C-t
4584 Change TODO state, circumventing any state blocking.
4585 @end table
4587 @vindex org-agenda-dim-blocked-tasks
4588 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
4589 that cannot be closed because of such dependencies are shown in
4590 a dimmed font or even made invisible in agenda views (see @ref{Agenda Views}).
4592 @cindex checkboxes and TODO dependencies
4593 @vindex org-enforce-todo-dependencies
4594 You can also block changes of TODO states by looking at checkboxes
4595 (see @ref{Checkboxes}).  If you set the variable
4596 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
4597 checkboxes is blocked from switching to DONE.
4599 If you need more complex dependency structures, for example
4600 dependencies between entries in different trees or files, check out
4601 the contributed module @samp{org-depend.el}.
4603 @node Progress Logging
4604 @section Progress Logging
4606 @cindex progress logging
4607 @cindex logging, of progress
4609 Org mode can automatically record a timestamp and possibly a note when
4610 you mark a TODO item as DONE, or even each time you change the state
4611 of a TODO item.  This system is highly configurable, settings can be
4612 on a per-keyword basis and can be localized to a file or even
4613 a subtree.  For information on how to clock working time for a task,
4614 see @ref{Clocking Work Time}.
4616 @menu
4617 * Closing items::                When was this entry marked DONE?
4618 * Tracking TODO state changes::  When did the status change?
4619 * Tracking your habits::         How consistent have you been?
4620 @end menu
4622 @node Closing items
4623 @subsection Closing items
4625 The most basic logging is to keep track of @emph{when} a certain TODO item
4626 was finished.  This is achieved with@footnote{The corresponding in-buffer setting is: @samp{#+STARTUP: logdone}.}
4628 @lisp
4629 (setq org-log-done 'time)
4630 @end lisp
4632 @vindex org-closed-keep-when-no-todo
4633 @noindent
4634 Then each time you turn an entry from a TODO (not-done) state into any
4635 of the DONE states, a line @samp{CLOSED: [timestamp]} is inserted just
4636 after the headline.  If you turn the entry back into a TODO item
4637 through further state cycling, that line is removed again.  If you
4638 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
4639 @code{org-closed-keep-when-no-todo} to non-@code{nil}.  If you want to record
4640 a note along with the timestamp, use@footnote{The corresponding in-buffer setting is: @samp{#+STARTUP:
4641 lognotedone}.}
4643 @lisp
4644 (setq org-log-done 'note)
4645 @end lisp
4647 @noindent
4648 You are then be prompted for a note, and that note is stored below the
4649 entry with a @samp{Closing Note} heading.
4651 @node Tracking TODO state changes
4652 @subsection Tracking TODO state changes
4654 @cindex drawer, for state change recording
4656 @vindex org-log-states-order-reversed
4657 @vindex org-log-into-drawer
4658 @cindex @samp{LOG_INTO_DRAWER}, property
4659 When TODO keywords are used as workflow states (see @ref{Workflow states, , *Workflow states}),
4660 you might want to keep track of when a state change occurred and maybe
4661 take a note about this change.  You can either record just
4662 a timestamp, or a time-stamped note for a change.  These records are
4663 inserted after the headline as an itemized list, newest first@footnote{See the variable @code{org-log-states-order-reversed}.}.
4664 When taking a lot of notes, you might want to get the notes out of the
4665 way into a drawer (see @ref{Drawers}).  Customize the variable
4666 @code{org-log-into-drawer} to get this behavior---the recommended drawer
4667 for this is called @samp{LOGBOOK}@footnote{Note that the @samp{LOGBOOK} drawer is unfolded when pressing
4668 @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
4669 setting of this variable for a subtree by setting a @samp{LOG_INTO_DRAWER}
4670 property.
4672 Since it is normally too much to record a note for every state, Org
4673 mode expects configuration on a per-keyword basis for this.  This is
4674 achieved by adding special markers @samp{!} (for a timestamp) or @samp{@@} (for
4675 a note with timestamp) in parentheses after each keyword.  For
4676 example, with the setting
4678 @lisp
4679 (setq org-todo-keywords
4680       '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
4681 @end lisp
4683 @noindent
4684 to record a timestamp without a note for TODO keywords configured with
4685 @samp{@@}, just type @kbd{C-c C-c} to enter a blank note when prompted.
4687 @vindex org-log-done
4688 @noindent
4689 You not only define global TODO keywords and fast access keys, but
4690 also request that a time is recorded when the entry is set to @samp{DONE},
4691 and that a note is recorded when switching to @samp{WAIT} or
4692 @samp{CANCELED}@footnote{It is possible that Org mode records two timestamps when you
4693 are using both @code{org-log-done} and state change logging.  However, it
4694 never prompts for two notes: if you have configured both, the state
4695 change recording note takes precedence and cancel the closing note.}.  The setting for @samp{WAIT} is even more special: the
4696 @samp{!} after the slash means that in addition to the note taken when
4697 entering the state, a timestamp should be recorded when @emph{leaving} the
4698 @samp{WAIT} state, if and only if the @emph{target} state does not configure
4699 logging for entering it.  So it has no effect when switching from
4700 @samp{WAIT} to @samp{DONE}, because @samp{DONE} is configured to record a timestamp
4701 only.  But when switching from @samp{WAIT} back to @samp{TODO}, the @samp{/!} in the
4702 @samp{WAIT} setting now triggers a timestamp even though @samp{TODO} has no
4703 logging configured.
4705 You can use the exact same syntax for setting logging preferences local
4706 to a buffer:
4708 @example
4709 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
4710 @end example
4712 @cindex @samp{LOGGING}, property
4713 In order to define logging settings that are local to a subtree or
4714 a single item, define a @samp{LOGGING} property in this entry.  Any
4715 non-empty @samp{LOGGING} property resets all logging settings to @code{nil}.
4716 You may then turn on logging for this specific tree using @samp{STARTUP}
4717 keywords like @samp{lognotedone} or @samp{logrepeat}, as well as adding state
4718 specific settings like @samp{TODO(!)}.  For example:
4720 @example
4721 * TODO Log each state with only a time
4722   :PROPERTIES:
4723   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
4724   :END:
4725 * TODO Only log when switching to WAIT, and when repeating
4726   :PROPERTIES:
4727   :LOGGING: WAIT(@@) logrepeat
4728   :END:
4729 * TODO No logging at all
4730   :PROPERTIES:
4731   :LOGGING: nil
4732   :END:
4733 @end example
4735 @node Tracking your habits
4736 @subsection Tracking your habits
4738 @cindex habits
4739 @cindex STYLE, property
4741 Org has the ability to track the consistency of a special category of
4742 TODO, called ``habits.''  A habit has the following properties:
4744 @enumerate
4745 @item
4746 You have enabled the @code{habits} module by customizing the variable
4747 @code{org-modules}.
4749 @item
4750 The habit is a TODO item, with a TODO keyword representing an open
4751 state.
4753 @item
4754 The property @samp{STYLE} is set to the value @samp{habit}.
4756 @item
4757 The TODO has a scheduled date, usually with a @samp{.+} style repeat
4758 interval.  A @samp{++} style may be appropriate for habits with time
4759 constraints, e.g., must be done on weekends, or a @samp{+} style for an
4760 unusual habit that can have a backlog, e.g., weekly reports.
4762 @item
4763 The TODO may also have minimum and maximum ranges specified by
4764 using the syntax @samp{.+2d/3d}, which says that you want to do the task
4765 at least every three days, but at most every two days.
4767 @item
4768 You must also have state logging for the DONE state enabled (see
4769 @ref{Tracking TODO state changes}), in order for historical data to be
4770 represented in the consistency graph.  If it is not enabled it is
4771 not an error, but the consistency graphs are largely meaningless.
4772 @end enumerate
4774 To give you an idea of what the above rules look like in action, here's an
4775 actual habit with some history:
4777 @example
4778 ** TODO Shave
4779    SCHEDULED: <2009-10-17 Sat .+2d/4d>
4780    :PROPERTIES:
4781    :STYLE:    habit
4782    :LAST_REPEAT: [2009-10-19 Mon 00:36]
4783    :END:
4784    - State "DONE"       from "TODO"       [2009-10-15 Thu]
4785    - State "DONE"       from "TODO"       [2009-10-12 Mon]
4786    - State "DONE"       from "TODO"       [2009-10-10 Sat]
4787    - State "DONE"       from "TODO"       [2009-10-04 Sun]
4788    - State "DONE"       from "TODO"       [2009-10-02 Fri]
4789    - State "DONE"       from "TODO"       [2009-09-29 Tue]
4790    - State "DONE"       from "TODO"       [2009-09-25 Fri]
4791    - State "DONE"       from "TODO"       [2009-09-19 Sat]
4792    - State "DONE"       from "TODO"       [2009-09-16 Wed]
4793    - State "DONE"       from "TODO"       [2009-09-12 Sat]
4794 @end example
4796 What this habit says is: I want to shave at most every 2 days---given
4797 by the @samp{SCHEDULED} date and repeat interval---and at least every
4798 4 days.  If today is the 15th, then the habit first appears in the
4799 agenda on Oct 17, after the minimum of 2 days has elapsed, and will
4800 appear overdue on Oct 19, after four days have elapsed.
4802 What's really useful about habits is that they are displayed along
4803 with a consistency graph, to show how consistent you've been at
4804 getting that task done in the past.  This graph shows every day that
4805 the task was done over the past three weeks, with colors for each day.
4806 The colors used are:
4808 @table @asis
4809 @item Blue
4810 If the task was not to be done yet on that day.
4811 @item Green
4812 If the task could have been done on that day.
4813 @item Yellow
4814 If the task was going to be overdue the next day.
4815 @item Red
4816 If the task was overdue on that day.
4817 @end table
4819 In addition to coloring each day, the day is also marked with an
4820 asterisk if the task was actually done that day, and an exclamation
4821 mark to show where the current day falls in the graph.
4823 There are several configuration variables that can be used to change
4824 the way habits are displayed in the agenda.
4826 @table @asis
4827 @item @code{org-habit-graph-column}
4828 @vindex org-habit-graph-column
4829 The buffer column at which the consistency graph should be drawn.
4830 This overwrites any text in that column, so it is a good idea to
4831 keep your habits' titles brief and to the point.
4833 @item @code{org-habit-preceding-days}
4834 @vindex org-habit-preceding-days
4835 The amount of history, in days before today, to appear in
4836 consistency graphs.
4838 @item @code{org-habit-following-days}
4839 @vindex org-habit-following-days
4840 The number of days after today that appear in consistency graphs.
4842 @item @code{org-habit-show-habits-only-for-today}
4843 @vindex org-habit-show-habits-only-for-today
4844 If non-@code{nil}, only show habits in today's agenda view.  This is
4845 set to true by default.
4846 @end table
4848 Lastly, pressing @kbd{K} in the agenda buffer causes habits to
4849 temporarily be disabled and do not appear at all.  Press @kbd{K}
4850 again to bring them back.  They are also subject to tag filtering, if
4851 you have habits which should only be done in certain contexts, for
4852 example.
4854 @node Priorities
4855 @section Priorities
4857 @cindex priorities
4858 @cindex priority cookie
4860 If you use Org mode extensively, you may end up with enough TODO items
4861 that it starts to make sense to prioritize them.  Prioritizing can be
4862 done by placing a @emph{priority cookie} into the headline of a TODO item,
4863 like this
4865 @example
4866 *** TODO [#A] Write letter to Sam Fortune
4867 @end example
4869 @vindex org-priority-faces
4870 @noindent
4871 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and @samp{C}.
4872 @samp{A} is the highest priority.  An entry without a cookie is treated
4873 just like priority @samp{B}.  Priorities make a difference only for sorting
4874 in the agenda (see @ref{Weekly/daily agenda}); outside the agenda, they
4875 have no inherent meaning to Org mode.  The cookies can be highlighted
4876 with special faces by customizing the variable @code{org-priority-faces}.
4878 Priorities can be attached to any outline node; they do not need to be
4879 TODO items.
4881 @table @asis
4882 @item @kbd{C-c ,} (@code{org-priority})
4883 @kindex C-c ,
4884 @findex org-priority
4885 Set the priority of the current headline.  The command prompts
4886 for a priority character @samp{A}, @samp{B} or @samp{C}.  When you press
4887 @kbd{@key{SPC}} instead, the priority cookie is removed from the
4888 headline.  The priorities can also be changed ``remotely'' from the
4889 timeline and agenda buffer with the @kbd{,} command (see
4890 @ref{Agenda Commands}).
4892 @item @kbd{S-@key{UP}} (@code{org-priority-up})
4893 @itemx @kbd{S-@key{DOWN}} (@code{org-priority-down})
4894 @kindex S-UP
4895 @kindex S-DOWN
4896 @findex org-priority-up
4897 @findex org-priority-down
4898 @vindex org-priority-start-cycle-with-default
4899 Increase/decrease priority of current headline@footnote{See also the option @code{org-priority-start-cycle-with-default}.}.  Note that
4900 these keys are also used to modify timestamps (see @ref{Creating Timestamps}).  See also @ref{Conflicts}, for
4901 a discussion of the interaction with @code{shift-selection-mode}.
4902 @end table
4904 @vindex org-highest-priority
4905 @vindex org-lowest-priority
4906 @vindex org-default-priority
4907 You can change the range of allowed priorities by setting the
4908 variables @code{org-highest-priority}, @code{org-lowest-priority}, and
4909 @code{org-default-priority}.  For an individual buffer, you may set these
4910 values (highest, lowest, default) like this (please make sure that the
4911 highest priority is earlier in the alphabet than the lowest priority):
4913 @cindex @samp{PRIORITIES}, keyword
4914 @example
4915 #+PRIORITIES: A C B
4916 @end example
4918 @node Breaking Down Tasks
4919 @section Breaking Down Tasks into Subtasks
4921 @cindex tasks, breaking down
4922 @cindex statistics, for TODO items
4924 @vindex org-agenda-todo-list-sublevels
4925 It is often advisable to break down large tasks into smaller,
4926 manageable subtasks.  You can do this by creating an outline tree
4927 below a TODO item, with detailed subtasks on the tree@footnote{To keep subtasks out of the global TODO list, see the
4928 @code{org-agenda-todo-list-sublevels}.}.  To keep
4929 the overview over the fraction of subtasks that are already completed,
4930 insert either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies
4931 are updated each time the TODO status of a child changes, or when
4932 pressing @kbd{C-c C-c} on the cookie.  For example:
4934 @example
4935 * Organize Party [33%]
4936 ** TODO Call people [1/2]
4937 *** TODO Peter
4938 *** DONE Sarah
4939 ** TODO Buy food
4940 ** DONE Talk to neighbor
4941 @end example
4943 @cindex @samp{COOKIE_DATA}, property
4944 If a heading has both checkboxes and TODO children below it, the
4945 meaning of the statistics cookie become ambiguous.  Set the property
4946 @samp{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve this issue.
4948 @vindex org-hierarchical-todo-statistics
4949 If you would like to have the statistics cookie count any TODO entries
4950 in the subtree (not just direct children), configure the variable
4951 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
4952 include the word @samp{recursive} into the value of the @samp{COOKIE_DATA}
4953 property.
4955 @example
4956 * Parent capturing statistics [2/20]
4957   :PROPERTIES:
4958   :COOKIE_DATA: todo recursive
4959   :END:
4960 @end example
4962 If you would like a TODO entry to automatically change to DONE when
4963 all children are done, you can use the following setup:
4965 @lisp
4966 (defun org-summary-todo (n-done n-not-done)
4967   "Switch entry to DONE when all subentries are done, to TODO otherwise."
4968   (let (org-log-done org-log-states)   ; turn off logging
4969     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
4971 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
4972 @end lisp
4974 Another possibility is the use of checkboxes to identify (a hierarchy
4975 of) a large number of subtasks (see @ref{Checkboxes}).
4977 @node Checkboxes
4978 @section Checkboxes
4980 @cindex checkboxes
4982 @vindex org-list-automatic-rules
4983 Every item in a plain list@footnote{With the exception of description lists.  But you can allow it
4984 by modifying @code{org-list-automatic-rules} accordingly.} (see @ref{Plain Lists}) can be made into
4985 a checkbox by starting it with the string @samp{[ ]}.  This feature is
4986 similar to TODO items (see @ref{TODO Items}), but is more lightweight.
4987 Checkboxes are not included into the global TODO list, so they are
4988 often great to split a task into a number of simple steps.  Or you can
4989 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
4990 @samp{org-mouse.el}).
4992 Here is an example of a checkbox list.
4994 @example
4995 * TODO Organize party [2/4]
4996   - [-] call people [1/3]
4997     - [ ] Peter
4998     - [X] Sarah
4999     - [ ] Sam
5000   - [X] order food
5001   - [ ] think about what music to play
5002   - [X] talk to the neighbors
5003 @end example
5005 Checkboxes work hierarchically, so if a checkbox item has children
5006 that are checkboxes, toggling one of the children checkboxes makes the
5007 parent checkbox reflect if none, some, or all of the children are
5008 checked.
5010 @cindex statistics, for checkboxes
5011 @cindex checkbox statistics
5012 @cindex @samp{COOKIE_DATA}, property
5013 @vindex org-hierarchical-checkbox-statistics
5014 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
5015 indicating how many checkboxes present in this entry have been checked
5016 off, and the total number of checkboxes present.  This can give you an
5017 idea on how many checkboxes remain, even without opening a folded
5018 entry.  The cookies can be placed into a headline or into (the first
5019 line of) a plain list item.  Each cookie covers checkboxes of direct
5020 children structurally below the headline/item on which the cookie
5021 appears@footnote{Set the variable @code{org-hierarchical-checkbox-statistics} if you
5022 want such cookies to count all checkboxes below the cookie, not just
5023 those belonging to direct children.}.  You have to insert the cookie yourself by typing
5024 either @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as
5025 in the examples above.  With @samp{[%]} you get information about the
5026 percentage of checkboxes checked (in the above example, this would be
5027 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can count
5028 either checkboxes below the heading or TODO states of children, and it
5029 displays whatever was changed last.  Set the property @samp{COOKIE_DATA} to
5030 either @samp{checkbox} or @samp{todo} to resolve this issue.
5032 @cindex blocking, of checkboxes
5033 @cindex checkbox blocking
5034 @cindex @samp{ORDERED}, property
5035 If the current outline node has an @samp{ORDERED} property, checkboxes must
5036 be checked off in sequence, and an error is thrown if you try to check
5037 off a box while there are unchecked boxes above it.
5039 @noindent
5040 The following commands work with checkboxes:
5042 @table @asis
5043 @item @kbd{C-c C-c} (@code{org-toggle-checkbox})
5044 @kindex C-c C-c
5045 @findex org-toggle-checkbox
5046 Toggle checkbox status or---with prefix argument---checkbox
5047 presence at point.  With a single prefix argument, add an empty
5048 checkbox or remove the current one@footnote{@kbd{C-u C-c C-c} on the @emph{first} item of a list with no
5049 checkbox adds checkboxes to the rest of the list.}.  With a double prefix
5050 argument, set it to @samp{[-]}, which is considered to be an
5051 intermediate state.
5053 @item @kbd{C-c C-x C-b} (@code{org-toggle-checkbox})
5054 @kindex C-c C-x C-b
5055 Toggle checkbox status or---with prefix argument---checkbox
5056 presence at point.  With double prefix argument, set it to @samp{[-]},
5057 which is considered to be an intermediate state.
5059 @itemize
5060 @item
5061 If there is an active region, toggle the first checkbox in the
5062 region and set all remaining boxes to the same status as the
5063 first.  With a prefix argument, add or remove the checkbox for
5064 all items in the region.
5066 @item
5067 If the cursor is in a headline, toggle checkboxes in the region
5068 between this headline and the next---so @emph{not} the entire
5069 subtree.
5071 @item
5072 If there is no active region, just toggle the checkbox at
5073 point.
5074 @end itemize
5076 @item @kbd{M-S-@key{RET}} (@code{org-insert-todo-heading})
5077 @kindex M-S-RET
5078 @findex org-insert-todo-heading
5079 Insert a new item with a checkbox.  This works only if the cursor
5080 is already in a plain list item (see @ref{Plain Lists}).
5082 @item @kbd{C-c C-x o} (@code{org-toggle-ordered-property})
5083 @kindex C-c C-x o
5084 @findex org-toggle-ordered-property
5085 @vindex org-track-ordered-property-with-tag
5086 Toggle the @samp{ORDERED} property of the entry, to toggle if
5087 checkboxes must be checked off in sequence.  A property is used
5088 for this behavior because this should be local to the current
5089 entry, not inherited like a tag.  However, if you would like to
5090 @emph{track} the value of this property with a tag for better
5091 visibility, customize @code{org-track-ordered-property-with-tag}.
5093 @item @kbd{C-c #} (@code{org-update-statistics-cookies})
5094 @kindex C-c #
5095 @findex org-update-statistics-cookies
5096 Update the statistics cookie in the current outline entry.  When
5097 called with a @kbd{C-u} prefix, update the entire file.
5098 Checkbox statistic cookies are updated automatically if you
5099 toggle checkboxes with @kbd{C-c C-c} and make new ones with
5100 @kbd{M-S-@key{RET}}.  TODO statistics cookies update when changing
5101 TODO states.  If you delete boxes/entries or add/change them by
5102 hand, use this command to get things back into sync.
5103 @end table
5105 @node Tags
5106 @chapter Tags
5108 @cindex tags
5109 @cindex headline tagging
5110 @cindex matching, tags
5111 @cindex sparse tree, tag based
5113 An excellent way to implement labels and contexts for
5114 cross-correlating information is to assign @emph{tags} to headlines.  Org
5115 mode has extensive support for tags.
5117 @vindex org-tag-faces
5118 Every headline can contain a list of tags; they occur at the end of
5119 the headline.  Tags are normal words containing letters, numbers, @samp{_},
5120 and @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
5121 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.  Tags
5122 by default are in bold face with the same color as the headline.  You
5123 may specify special faces for specific tags using the variable
5124 @code{org-tag-faces}, in much the same way as you can for TODO keywords
5125 (see @ref{Faces for TODO keywords}).
5127 @menu
5128 * Tag Inheritance::              Tags use the tree structure of an outline.
5129 * Setting Tags::                 How to assign tags to a headline.
5130 * Tag Hierarchy::                Create a hierarchy of tags.
5131 * Tag Searches::                 Searching for combinations of tags.
5132 @end menu
5134 @node Tag Inheritance
5135 @section Tag Inheritance
5137 @cindex tag inheritance
5138 @cindex inheritance, of tags
5139 @cindex sublevels, inclusion into tags match
5141 @emph{Tags} make use of the hierarchical structure of outline trees.  If
5142 a heading has a certain tag, all subheadings inherit the tag as well.
5143 For example, in the list
5145 @example
5146 * Meeting with the French group      :work:
5147 ** Summary by Frank                  :boss:notes:
5148 *** TODO Prepare slides for him      :action:
5149 @end example
5151 @noindent
5152 the final heading has the tags @samp{work}, @samp{boss}, @samp{notes}, and @samp{action}
5153 even though the final heading is not explicitly marked with those
5154 tags.  You can also set tags that all entries in a file should inherit
5155 just as if these tags were defined in a hypothetical level zero that
5156 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.}
5158 @cindex @samp{FILETAGS}, keyword
5159 @example
5160 #+FILETAGS: :Peter:Boss:Secret:
5161 @end example
5163 @vindex org-use-tag-inheritance
5164 @vindex org-tags-exclude-from-inheritance
5165 @noindent
5166 To limit tag inheritance to specific tags, or to turn it off entirely,
5167 use the variables @code{org-use-tag-inheritance} and
5168 @code{org-tags-exclude-from-inheritance}.
5170 @vindex org-tags-match-list-sublevels
5171 When a headline matches during a tags search while tag inheritance is
5172 turned on, all the sublevels in the same tree---for a simple match
5173 form---match as well@footnote{This is only true if the search does not involve more complex
5174 tests including properties (see @ref{Property Searches}).}.  The list of matches may then become
5175 very long.  If you only want to see the first tags match in a subtree,
5176 configure the variable @code{org-tags-match-list-sublevels} (not
5177 recommended).
5179 @vindex org-agenda-use-tag-inheritance
5180 Tag inheritance is relevant when the agenda search tries to match
5181 a tag, either in the @code{tags} or @code{tags-todo} agenda types.  In other
5182 agenda types, @code{org-use-tag-inheritance} has no effect.  Still, you may
5183 want to have your tags correctly set in the agenda, so that tag
5184 filtering works fine, with inherited tags.  Set
5185 @code{org-agenda-use-tag-inheritance} to control this: the default value
5186 includes all agenda types, but setting this to @code{nil} can really speed
5187 up agenda generation.
5189 @node Setting Tags
5190 @section Setting Tags
5192 @cindex setting tags
5193 @cindex tags, setting
5195 @kindex M-TAB
5196 Tags can simply be typed into the buffer at the end of a headline.
5197 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
5198 also a special command for inserting tags:
5200 @table @asis
5201 @item @kbd{C-c C-q} (@code{org-set-tags-command})
5202 @kindex C-c C-q
5203 @findex org-set-tags-command
5204 @cindex completion, of tags
5205 @vindex org-tags-column
5206 Enter new tags for the current headline.  Org mode either offers
5207 completion or a special single-key interface for setting tags,
5208 see below.  After pressing @kbd{@key{RET}}, the tags are inserted
5209 and aligned to @code{org-tags-column}.  When called with
5210 a @kbd{C-u} prefix, all tags in the current buffer are
5211 aligned to that column, just to make things look nice.  Tags are
5212 automatically realigned after promotion, demotion, and TODO state
5213 changes (see @ref{TODO Basics}).
5215 @item @kbd{C-c C-c} (@code{org-set-tags-command})
5216 @kindex C-c C-c
5217 When the cursor is in a headline, this does the same as
5218 @kbd{C-c C-q}.
5219 @end table
5221 @vindex org-tag-alist
5222 Org supports tag insertion based on a @emph{list of tags}.  By default this
5223 list is constructed dynamically, containing all tags currently used in
5224 the buffer.  You may also globally specify a hard list of tags with
5225 the variable @code{org-tag-alist}.  Finally you can set the default tags
5226 for a given file with lines like
5228 @cindex @samp{TAGS}, keyword
5229 @example
5230 #+TAGS: @@work @@home @@tennisclub
5231 #+TAGS: laptop car pc sailboat
5232 @end example
5234 If you have globally defined your preferred set of tags using the
5235 variable @code{org-tag-alist}, but would like to use a dynamic tag list in
5236 a specific file, add an empty @samp{TAGS} keyword to that file:
5238 @example
5239 #+TAGS:
5240 @end example
5242 @vindex org-tag-persistent-alist
5243 If you have a preferred set of tags that you would like to use in
5244 every file, in addition to those defined on a per-file basis by @samp{TAGS}
5245 keyword, then you may specify a list of tags with the variable
5246 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
5247 by adding a @samp{STARTUP} keyword to that file:
5249 @example
5250 #+STARTUP: noptag
5251 @end example
5253 By default Org mode uses the standard minibuffer completion facilities
5254 for entering tags.  However, it also implements another, quicker, tag
5255 selection method called @emph{fast tag selection}.  This allows you to
5256 select and deselect tags with just a single key press.  For this to
5257 work well you should assign unique letters to most of your commonly
5258 used tags.  You can do this globally by configuring the variable
5259 @code{org-tag-alist} in your Emacs init file.  For example, you may find
5260 the need to tag many items in different files with @samp{@@home}.  In this
5261 case you can set something like:
5263 @lisp
5264 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
5265 @end lisp
5267 @noindent
5268 If the tag is only relevant to the file you are working on, then you
5269 can instead set the @samp{TAGS} keyword as:
5271 @example
5272 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
5273 @end example
5275 @noindent
5276 The tags interface shows the available tags in a splash window.  If
5277 you want to start a new line after a specific tag, insert @samp{\n} into
5278 the tag list
5280 @example
5281 #+TAGS: @@work(w) @@home(h) @@tennisclub(t) \n laptop(l) pc(p)
5282 @end example
5284 @noindent
5285 or write them in two lines:
5287 @example
5288 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
5289 #+TAGS: laptop(l)  pc(p)
5290 @end example
5292 @noindent
5293 You can also group together tags that are mutually exclusive by using
5294 braces, as in:
5296 @example
5297 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
5298 @end example
5300 @noindent
5301 you indicate that at most one of @samp{@@work}, @samp{@@home}, and @samp{@@tennisclub}
5302 should be selected.  Multiple such groups are allowed.
5304 @noindent
5305 Do not forget to press @kbd{C-c C-c} with the cursor in one of
5306 these lines to activate any changes.
5308 @noindent
5309 To set these mutually exclusive groups in the variable
5310 @code{org-tags-alist}, you must use the dummy tags @code{:startgroup} and
5311 @code{:endgroup} instead of the braces.  Similarly, you can use @code{:newline}
5312 to indicate a line break.  The previous example would be set globally
5313 by the following configuration:
5315 @lisp
5316 (setq org-tag-alist '((:startgroup . nil)
5317                       ("@@work" . ?w) ("@@home" . ?h)
5318                       ("@@tennisclub" . ?t)
5319                       (:endgroup . nil)
5320                       ("laptop" . ?l) ("pc" . ?p)))
5321 @end lisp
5323 If at least one tag has a selection key then pressing @kbd{C-c C-c} automatically presents you with a special interface, listing
5324 inherited tags, the tags of the current headline, and a list of all
5325 valid tags with corresponding keys@footnote{Keys are automatically assigned to tags that have no
5326 configured keys.}.
5328 Pressing keys assigned to tags adds or removes them from the list of
5329 tags in the current line.  Selecting a tag in a group of mutually
5330 exclusive tags turns off any other tag from that group.
5332 In this interface, you can also use the following special keys:
5334 @table @asis
5335 @item @kbd{@key{TAB}}
5336 @kindex TAB
5337 Enter a tag in the minibuffer, even if the tag is not in the
5338 predefined list.  You can complete on all tags present in the
5339 buffer.  You can also add several tags: just separate them with
5340 a comma.
5342 @item @kbd{@key{SPC}}
5343 @kindex SPC
5344 Clear all tags for this line.
5346 @item @kbd{@key{RET}}
5347 @kindex RET
5348 Accept the modified set.
5350 @item @kbd{C-g}
5351 @kindex C-g
5352 Abort without installing changes.
5354 @item @kbd{q}
5355 @kindex q
5356 If @kbd{q} is not assigned to a tag, it aborts like
5357 @kbd{C-g}.
5359 @item @kbd{!}
5360 @kindex !
5361 Turn off groups of mutually exclusive tags.  Use this to (as an
5362 exception) assign several tags from such a group.
5364 @item @kbd{C-c}
5365 @kindex C-c C-c
5366 Toggle auto-exit after the next change (see below).  If you are
5367 using expert mode, the first @kbd{C-c} displays the
5368 selection window.
5369 @end table
5371 @noindent
5372 This method lets you assign tags to a headline with very few keys.
5373 With the above setup, you could clear the current tags and set
5374 @samp{@@home}, @samp{laptop} and @samp{pc} tags with just the following keys:
5375 @kbd{C-c C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to @samp{@@work}
5376 would be done with @kbd{C-c C-c w @key{RET}} or alternatively with
5377 @kbd{C-c C-c C-c w}.  Adding the non-predefined tag @samp{Sarah} could
5378 be done with @kbd{C-c C-c @key{TAB} S a r a h @key{RET}}.
5380 @vindex org-fast-tag-selection-single-key
5381 If you find that most of the time you need only a single key press to
5382 modify your list of tags, set the variable
5383 @code{org-fast-tag-selection-single-key}.  Then you no longer have to press
5384 @kbd{@key{RET}} to exit fast tag selection---it exits after the first
5385 change.  If you then occasionally need more keys, press @kbd{C-c}
5386 to turn off auto-exit for the current tag selection process (in
5387 effect: start selection with @kbd{C-c C-c C-c} instead of
5388 @kbd{C-c C-c}).  If you set the variable to the value @code{expert},
5389 the special window is not even shown for single-key tag selection, it
5390 comes up only when you press an extra @kbd{C-c}.
5392 @node Tag Hierarchy
5393 @section Tag Hierarchy
5395 @cindex group tags
5396 @cindex tags, groups
5397 @cindex tags hierarchy
5399 Tags can be defined in hierarchies.  A tag can be defined as a @emph{group
5400 tag} for a set of other tags.  The group tag can be seen as the
5401 ``broader term'' for its set of tags.  Defining multiple group tags and
5402 nesting them creates a tag hierarchy.
5404 One use-case is to create a taxonomy of terms (tags) that can be used
5405 to classify nodes in a document or set of documents.
5407 When you search for a group tag, it return matches for all members in
5408 the group and its subgroups.  In an agenda view, filtering by a group
5409 tag displays or hide headlines tagged with at least one of the members
5410 of the group or any of its subgroups.  This makes tag searches and
5411 filters even more flexible.
5413 You can set group tags by using brackets and inserting a colon between
5414 the group tag and its related tags---beware that all whitespaces are
5415 mandatory so that Org can parse this line correctly:
5417 @example
5418 #+TAGS: [ GTD : Control Persp ]
5419 @end example
5421 In this example, @samp{GTD} is the group tag and it is related to two other
5422 tags: @samp{Control}, @samp{Persp}.  Defining @samp{Control} and @samp{Persp} as group
5423 tags creates an hierarchy of tags:
5425 @example
5426 #+TAGS: [ Control : Context Task ]
5427 #+TAGS: [ Persp : Vision Goal AOF Project ]
5428 @end example
5430 That can conceptually be seen as a hierarchy of tags:
5432 @itemize
5433 @item
5434 @samp{GTD}
5435 @itemize
5436 @item
5437 @samp{Persp}
5438 @itemize
5439 @item
5440 @samp{Vision}
5441 @item
5442 @samp{Goal}
5443 @item
5444 @samp{AOF}
5445 @item
5446 @samp{Project}
5447 @end itemize
5448 @item
5449 @samp{Control}
5450 @itemize
5451 @item
5452 @samp{Context}
5453 @item
5454 @samp{Task}
5455 @end itemize
5456 @end itemize
5457 @end itemize
5459 You can use the @code{:startgrouptag}, @code{:grouptags} and @code{:endgrouptag}
5460 keyword directly when setting @code{org-tag-alist} directly:
5462 @lisp
5463 (setq org-tag-alist '((:startgrouptag)
5464                       ("GTD")
5465                       (:grouptags)
5466                       ("Control")
5467                       ("Persp")
5468                       (:endgrouptag)
5469                       (:startgrouptag)
5470                       ("Control")
5471                       (:grouptags)
5472                       ("Context")
5473                       ("Task")
5474                       (:endgrouptag)))
5475 @end lisp
5477 The tags in a group can be mutually exclusive if using the same group
5478 syntax as is used for grouping mutually exclusive tags together; using
5479 curly brackets.
5481 @example
5482 #+TAGS: @{ Context : @@Home @@Work @@Call @}
5483 @end example
5485 When setting @code{org-tag-alist} you can use @code{:startgroup} and @code{:endgroup}
5486 instead of @code{:startgrouptag} and @code{:endgrouptag} to make the tags
5487 mutually exclusive.
5489 Furthermore, the members of a group tag can also be regular
5490 expressions, creating the possibility of a more dynamic and rule-based
5491 tag structure.  The regular expressions in the group must be specified
5492 within curly brackets.  Here is an expanded example:
5494 @example
5495 #+TAGS: [ Vision : @{V@@.+@} ]
5496 #+TAGS: [ Goal : @{G@@.+@} ]
5497 #+TAGS: [ AOF : @{AOF@@.+@} ]
5498 #+TAGS: [ Project : @{P@@.+@} ]
5499 @end example
5501 Searching for the tag @samp{Project} now lists all tags also including
5502 regular expression matches for @samp{P@@.+}, and similarly for tag searches
5503 on @samp{Vision}, @samp{Goal} and @samp{AOF}.  For example, this would work well for
5504 a project tagged with a common project-identifier,
5505 e.g. @samp{P@@2014_OrgTags}.
5507 @kindex C-c C-x q
5508 @findex org-toggle-tags-groups
5509 @vindex org-group-tags
5510 If you want to ignore group tags temporarily, toggle group tags
5511 support with @code{org-toggle-tags-groups}, bound to @kbd{C-c C-x q}.
5512 If you want to disable tag groups completely, set @code{org-group-tags} to
5513 @code{nil}.
5515 @node Tag Searches
5516 @section Tag Searches
5518 @cindex tag searches
5519 @cindex searching for tags
5521 Once a system of tags has been set up, it can be used to collect
5522 related information into special lists.
5524 @table @asis
5525 @item @kbd{C-c / m} or @kbd{C-c \} (@code{org-match-sparse-tree})
5526 @kindex C-c / m
5527 @kindex C-c \
5528 @findex org-match-sparse-tree
5529 Create a sparse tree with all headlines matching a tags search.
5530 With a @kbd{C-u} prefix argument, ignore headlines that are
5531 not a TODO line.
5533 @item @kbd{C-c a m} (@code{org-tags-view})
5534 @kindex C-c a m
5535 @findex org-tags-view
5536 Create a global list of tag matches from all agenda files.  See
5537 @ref{Matching tags and properties}.
5539 @item @kbd{C-c a M} (@code{org-tags-view})
5540 @kindex C-c a M
5541 @vindex org-tags-match-list-sublevels
5542 Create a global list of tag matches from all agenda files, but
5543 check only TODO items and force checking subitems (see the option
5544 @code{org-tags-match-list-sublevels}).
5545 @end table
5547 These commands all prompt for a match string which allows basic
5548 Boolean logic like @samp{+boss+urgent-project1}, to find entries with tags
5549 @samp{boss} and @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find
5550 entries which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of
5551 the search string is rich and allows also matching against TODO
5552 keywords, entry levels and properties.  For a complete description
5553 with many examples, see @ref{Matching tags and properties}.
5555 @node Properties and Columns
5556 @chapter Properties and Columns
5558 @cindex properties
5560 A property is a key-value pair associated with an entry.  Properties
5561 can be set so they are associated with a single entry, with every
5562 entry in a tree, or with every entry in an Org file.
5564 There are two main applications for properties in Org mode.  First,
5565 properties are like tags, but with a value.  Imagine maintaining
5566 a file where you document bugs and plan releases for a piece of
5567 software.  Instead of using tags like @samp{release_1}, @samp{release_2}, you
5568 can use a property, say @samp{Release}, that in different subtrees has
5569 different values, such as @samp{1.0} or @samp{2.0}.  Second, you can use
5570 properties to implement (very basic) database capabilities in an Org
5571 buffer.  Imagine keeping track of your music CDs, where properties
5572 could be things such as the album, artist, date of release, number of
5573 tracks, and so on.
5575 Properties can be conveniently edited and viewed in column view (see
5576 @ref{Column View}).
5578 @menu
5579 * Property Syntax::              How properties are spelled out.
5580 * Special Properties::           Access to other Org mode features.
5581 * Property Searches::            Matching property values.
5582 * Property Inheritance::         Passing values down a tree.
5583 * Column View::                  Tabular viewing and editing.
5584 @end menu
5586 @node Property Syntax
5587 @section Property Syntax
5589 @cindex property syntax
5590 @cindex drawer, for properties
5592 Properties are key--value pairs.  When they are associated with
5593 a single entry or with a tree they need to be inserted into a special
5594 drawer (see @ref{Drawers}) with the name @samp{PROPERTIES}, which has to be
5595 located right below a headline, and its planning line (see @ref{Deadlines and Scheduling}) when applicable.  Each property is specified on
5596 a single line, with the key---surrounded by colons---first, and the
5597 value after it.  Keys are case-insensitive.  Here is an example:
5599 @example
5600 * CD collection
5601 ** Classic
5602 *** Goldberg Variations
5603     :PROPERTIES:
5604     :Title:     Goldberg Variations
5605     :Composer:  J.S. Bach
5606     :Artist:    Glen Gould
5607     :Publisher: Deutsche Grammophon
5608     :NDisks:    1
5609     :END:
5610 @end example
5612 Depending on the value of @code{org-use-property-inheritance}, a property
5613 set this way is associated either with a single entry, or with the
5614 sub-tree defined by the entry, see @ref{Property Inheritance}.
5616 You may define the allowed values for a particular property @samp{Xyz} by
5617 setting a property @samp{Xyz_ALL}.  This special property is @emph{inherited},
5618 so if you set it in a level 1 entry, it applies to the entire tree.
5619 When allowed values are defined, setting the corresponding property
5620 becomes easier and is less prone to typing errors.  For the example
5621 with the CD collection, we can pre-define publishers and the number of
5622 disks in a box like this:
5624 @example
5625 * CD collection
5626   :PROPERTIES:
5627   :NDisks_ALL:  1 2 3 4
5628   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
5629   :END:
5630 @end example
5632 If you want to set properties that can be inherited by any entry in
5633 a file, use a line like:
5635 @cindex @samp{_ALL} suffix, in properties
5636 @cindex @samp{PROPERTY}, keyword
5637 @example
5638 #+PROPERTY: NDisks_ALL 1 2 3 4
5639 @end example
5641 @cindex @samp{+} suffix, in properties
5642 If you want to add to the value of an existing property, append a @samp{+}
5643 to the property name.  The following results in the property @samp{var}
5644 having the value @samp{foo=1 bar=2}.
5646 @example
5647 #+PROPERTY: var  foo=1
5648 #+PROPERTY: var+ bar=2
5649 @end example
5651 It is also possible to add to the values of inherited properties.  The
5652 following results in the @samp{Genres} property having the value @samp{Classic
5653 Baroque} under the @samp{Goldberg Variations} subtree.
5655 @example
5656 * CD collection
5657 ** Classic
5658     :PROPERTIES:
5659     :Genres: Classic
5660     :END:
5661 *** Goldberg Variations
5662     :PROPERTIES:
5663     :Title:     Goldberg Variations
5664     :Composer:  J.S. Bach
5665     :Artist:    Glen Gould
5666     :Publisher: Deutsche Grammophon
5667     :NDisks:    1
5668     :Genres+:   Baroque
5669     :END:
5670 @end example
5672 Note that a property can only have one entry per drawer.
5674 @vindex org-global-properties
5675 Property values set with the global variable @code{org-global-properties}
5676 can be inherited by all entries in all Org files.
5678 @noindent
5679 The following commands help to work with properties:
5681 @table @asis
5682 @item @kbd{M-@key{TAB}} (@code{pcomplete})
5683 @kindex M-TAB
5684 @findex pcomplete
5685 After an initial colon in a line, complete property keys.  All
5686 keys used in the current file are offered as possible
5687 completions.
5689 @item @kbd{C-c C-x p} (@code{org-set-property})
5690 @kindex C-c C-x p
5691 @findex org-set-property
5692 Set a property.  This prompts for a property name and a value.
5693 If necessary, the property drawer is created as well.
5695 @item @kbd{C-u M-x org-insert-drawer}
5696 @findex org-insert-drawer
5697 Insert a property drawer into the current entry.  The drawer is
5698 inserted early in the entry, but after the lines with planning
5699 information like deadlines.
5701 @item @kbd{C-c C-c} (@code{org-property-action})
5702 @kindex C-c C-c
5703 @findex org-property-action
5704 With the cursor in a property drawer, this executes property
5705 commands.
5707 @item @kbd{C-c C-c s} (@code{org-set-property})
5708 @kindex C-c C-c s
5709 @findex org-set-property
5710 Set a property in the current entry.  Both the property and the value
5711 can be inserted using completion.
5713 @item @kbd{S-@key{RIGHT}} (@code{org-property-next-allowed-values})
5714 @itemx @kbd{S-@key{LEFT}} (@code{org-property-previous-allowed-value})
5715 @kindex S-RIGHT
5716 @kindex S-LEFT
5717 Switch property at point to the next/previous allowed value.
5719 @item @kbd{C-c C-c d} (@code{org-delete-property})
5720 @kindex C-c C-c d
5721 @findex org-delete-property
5722 Remove a property from the current entry.
5724 @item @kbd{C-c C-c D} (@code{org-delete-property-globally})
5725 @kindex C-c C-c D
5726 @findex org-delete-property-globally
5727 Globally remove a property, from all entries in the current file.
5729 @item @kbd{C-c C-c c} (@code{org-compute-property-at-point})
5730 @kindex C-c C-c c
5731 @findex org-compute-property-at-point
5732 Compute the property at point, using the operator and scope from
5733 the nearest column format definition.
5734 @end table
5736 @node Special Properties
5737 @section Special Properties
5739 @cindex properties, special
5741 Special properties provide an alternative access method to Org mode
5742 features, like the TODO state or the priority of an entry, discussed
5743 in the previous chapters.  This interface exists so that you can
5744 include these states in a column view (see @ref{Column View}), or to use
5745 them in queries.  The following property names are special and should
5746 not be used as keys in the properties drawer:
5748 @cindex @samp{ALLTAGS}, special property
5749 @cindex @samp{BLOCKED}, special property
5750 @cindex @samp{CLOCKSUM}, special property
5751 @cindex @samp{CLOCKSUM_T}, special property
5752 @cindex @samp{CLOSED}, special property
5753 @cindex @samp{DEADLINE}, special property
5754 @cindex @samp{FILE}, special property
5755 @cindex @samp{ITEM}, special property
5756 @cindex @samp{PRIORITY}, special property
5757 @cindex @samp{SCHEDULED}, special property
5758 @cindex @samp{TAGS}, special property
5759 @cindex @samp{TIMESTAMP}, special property
5760 @cindex @samp{TIMESTAMP_IA}, special property
5761 @cindex @samp{TODO}, special property
5762 @multitable {aaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
5763 @item @samp{ALLTAGS}
5764 @tab All tags, including inherited ones.
5765 @item @samp{BLOCKED}
5766 @tab @code{t} if task is currently blocked by children or siblings.
5767 @item @samp{CATEGORY}
5768 @tab The category of an entry.
5769 @item @samp{CLOCKSUM}
5770 @tab The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}
5771 @item 
5772 @tab must be run first to compute the values in the current buffer.
5773 @item @samp{CLOCKSUM_T}
5774 @tab The sum of CLOCK intervals in the subtree for today.
5775 @item 
5776 @tab @code{org-clock-sum-today} must be run first to compute the
5777 @item 
5778 @tab values in the current buffer.
5779 @item @samp{CLOSED}
5780 @tab When was this entry closed?
5781 @item @samp{DEADLINE}
5782 @tab The deadline time string, without the angular brackets.
5783 @item @samp{FILE}
5784 @tab The filename the entry is located in.
5785 @item @samp{ITEM}
5786 @tab The headline of the entry.
5787 @item @samp{PRIORITY}
5788 @tab The priority of the entry, a string with a single letter.
5789 @item @samp{SCHEDULED}
5790 @tab The scheduling timestamp, without the angular brackets.
5791 @item @samp{TAGS}
5792 @tab The tags defined directly in the headline.
5793 @item @samp{TIMESTAMP}
5794 @tab The first keyword-less timestamp in the entry.
5795 @item @samp{TIMESTAMP_IA}
5796 @tab The first inactive timestamp in the entry.
5797 @item @samp{TODO}
5798 @tab The TODO keyword of the entry.
5799 @end multitable
5801 @node Property Searches
5802 @section Property Searches
5804 @cindex properties, searching
5805 @cindex searching, of properties
5807 To create sparse trees and special lists with selection based on
5808 properties, the same commands are used as for tag searches (see @ref{Tag Searches}).
5810 @table @asis
5811 @item @kbd{C-c / m} or @kbd{C-c \} (@code{org-match-sparse-tree})
5812 @kindex C-c / m
5813 @kindex C-c \
5814 @findex org-match-sparse-tree
5815 Create a sparse tree with all matching entries.  With
5816 a @kbd{C-u} prefix argument, ignore headlines that are not
5817 a TODO line.
5819 @item @kbd{C-c a m}, @code{org-tags-view}
5820 @kindex C-c a m
5821 Create a global list of tag/property matches from all agenda
5822 files.
5824 @item @kbd{C-c a M} (@code{org-tags-view})
5825 @kindex C-c a M
5826 @findex org-tags-view
5827 @vindex org-tags-match-list-sublevels
5828 Create a global list of tag matches from all agenda files, but
5829 check only TODO items and force checking of subitems (see the
5830 option @code{org-tags-match-list-sublevels}).
5831 @end table
5833 The syntax for the search string is described in @ref{Matching tags and properties}.
5835 There is also a special command for creating sparse trees based on a
5836 single property:
5838 @table @asis
5839 @item @kbd{C-c / p}
5840 @kindex C-c / p
5841 Create a sparse tree based on the value of a property.  This
5842 first prompts for the name of a property, and then for a value.
5843 A sparse tree is created with all entries that define this
5844 property with the given value.  If you enclose the value in curly
5845 braces, it is interpreted as a regular expression and matched
5846 against the property values.
5847 @end table
5849 @node Property Inheritance
5850 @section Property Inheritance
5852 @cindex properties, inheritance
5853 @cindex inheritance, of properties
5855 @vindex org-use-property-inheritance
5856 The outline structure of Org documents lends itself to an inheritance
5857 model of properties: if the parent in a tree has a certain property,
5858 the children can inherit this property.  Org mode does not turn this
5859 on by default, because it can slow down property searches
5860 significantly and is often not needed.  However, if you find
5861 inheritance useful, you can turn it on by setting the variable
5862 @code{org-use-property-inheritance}.  It may be set to @code{t} to make all
5863 properties inherited from the parent, to a list of properties that
5864 should be inherited, or to a regular expression that matches inherited
5865 properties.  If a property has the value @code{nil}, this is interpreted as
5866 an explicit un-define of the property, so that inheritance search
5867 stops at this value and returns @code{nil}.
5869 Org mode has a few properties for which inheritance is hard-coded, at
5870 least for the special applications for which they are used:
5872 @table @asis
5873 @item @code{COLUMNS}
5874 @cindex @samp{COLUMNS}, property
5875 The @samp{COLUMNS} property defines the format of column view (see
5876 @ref{Column View}).  It is inherited in the sense that the level where
5877 a @samp{COLUMNS} property is defined is used as the starting point for
5878 a column view table, independently of the location in the subtree
5879 from where columns view is turned on.
5881 @item @code{CATEGORY}
5882 @cindex @samp{CATEGORY}, property
5883 For agenda view, a category set through a @samp{CATEGORY} property
5884 applies to the entire subtree.
5886 @item @code{ARCHIVE}
5887 @cindex @samp{ARCHIVE}, property
5888 For archiving, the @samp{ARCHIVE} property may define the archive
5889 location for the entire subtree (see @ref{Moving subtrees}).
5891 @item @code{LOGGING}
5892 @cindex @samp{LOGGING}, property
5893 The @samp{LOGGING} property may define logging settings for an entry
5894 or a subtree (see @ref{Tracking TODO state changes}).
5895 @end table
5897 @node Column View
5898 @section Column View
5900 A great way to view and edit properties in an outline tree is @emph{column
5901 view}.  In column view, each outline node is turned into a table row.
5902 Columns in this table provide access to properties of the entries.
5903 Org mode implements columns by overlaying a tabular structure over the
5904 headline of each item.  While the headlines have been turned into
5905 a table row, you can still change the visibility of the outline tree.
5906 For example, you get a compact table by switching to ``contents''
5907 view---@kbd{S-@key{TAB}} @kbd{S-@key{TAB}}, or simply @kbd{c}
5908 while column view is active---but you can still open, read, and edit
5909 the entry below each headline.  Or, you can switch to column view
5910 after executing a sparse tree command and in this way get a table only
5911 for the selected items.  Column view also works in agenda buffers (see
5912 @ref{Agenda Views}) where queries have collected selected items, possibly
5913 from a number of files.
5915 @menu
5916 * Defining columns::             The COLUMNS format property.
5917 * Using column view::            How to create and use column view.
5918 * Capturing column view::        A dynamic block for column view.
5919 @end menu
5921 @node Defining columns
5922 @subsection Defining columns
5924 @cindex column view, for properties
5925 @cindex properties, column view
5927 Setting up a column view first requires defining the columns.  This is
5928 done by defining a column format line.
5930 @menu
5931 * Scope of column definitions::  Where defined, where valid?
5932 * Column attributes::            Appearance and content of a column.
5933 @end menu
5935 @node Scope of column definitions
5936 @subsubsection Scope of column definitions
5938 To define a column format for an entire file, use a line like:
5940 @cindex @samp{COLUMNS}, keyword
5941 @example
5942 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5943 @end example
5945 To specify a format that only applies to a specific tree, add
5946 a @samp{COLUMNS} property to the top node of that tree, for example:
5948 @example
5949 ** Top node for columns view
5950    :PROPERTIES:
5951    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5952    :END:
5953 @end example
5955 If a @samp{COLUMNS} property is present in an entry, it defines columns for
5956 the entry itself, and for the entire subtree below it.  Since the
5957 column definition is part of the hierarchical structure of the
5958 document, you can define columns on level 1 that are general enough
5959 for all sublevels, and more specific columns further down, when you
5960 edit a deeper part of the tree.
5962 @node Column attributes
5963 @subsubsection Column attributes
5965 A column definition sets the attributes of a column.  The general
5966 definition looks like this:
5968 @example
5969 %[WIDTH]PROPERTY[(TITLE)][@{SUMMARY-TYPE@}]
5970 @end example
5972 @noindent
5973 Except for the percent sign and the property name, all items are
5974 optional.  The individual parts have the following meaning:
5976 @table @asis
5977 @item @var{WIDTH}
5978 An integer specifying the width of the column in characters.  If
5979 omitted, the width is determined automatically.
5981 @item @var{PROPERTY}
5982 The property that should be edited in this column.  Special
5983 properties representing meta data are allowed here as well (see
5984 @ref{Special Properties}).
5986 @item @var{TITLE}
5987 The header text for the column.  If omitted, the property name is
5988 used.
5990 @item @var{SUMMARY-TYPE}
5991 The summary type.  If specified, the column values for parent
5992 nodes are computed from the children@footnote{If more than one summary type applies to the same property,
5993 the parent values are computed according to the first of them.}.
5995 Supported summary types are:
5997 @multitable {aaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
5998 @item @samp{+}
5999 @tab Sum numbers in this column.
6000 @item @samp{+;%.1f}
6001 @tab Like @samp{+}, but format result with @samp{%.1f}.
6002 @item @samp{$}
6003 @tab Currency, short for @samp{+;%.2f}.
6004 @item @samp{min}
6005 @tab Smallest number in column.
6006 @item @samp{max}
6007 @tab Largest number.
6008 @item @samp{mean}
6009 @tab Arithmetic mean of numbers.
6010 @item @samp{X}
6011 @tab Checkbox status, @samp{[X]} if all children are @samp{[X]}.
6012 @item @samp{X/}
6013 @tab Checkbox status, @samp{[n/m]}.
6014 @item @samp{X%}
6015 @tab Checkbox status, @samp{[n%]}.
6016 @item @samp{:}
6017 @tab Sum times, HH:MM, plain numbers are hours.
6018 @item @samp{:min}
6019 @tab Smallest time value in column.
6020 @item @samp{:max}
6021 @tab Largest time value.
6022 @item @samp{:mean}
6023 @tab Arithmetic mean of time values.
6024 @item @samp{@@min}
6025 @tab Minimum age@footnote{An age is defined as a duration, using effort modifiers
6026 defined in @code{org-effort-durations}, e.g., @samp{3d 1h}.  If any value in the
6027 column is as such, the summary is also an effort duration.} (in days/hours/mins/seconds).
6028 @item @samp{@@max}
6029 @tab Maximum age (in days/hours/mins/seconds).
6030 @item @samp{@@mean}
6031 @tab Arithmetic mean of ages (in days/hours/mins/seconds).
6032 @item @samp{est+}
6033 @tab Add low-high estimates.
6034 @end multitable
6036 @noindent
6037 @vindex org-columns-summary-types
6038 You can also define custom summary types by setting
6039 @code{org-columns-summary-types}.
6040 @end table
6042 The @samp{est+} summary type requires further explanation.  It is used for
6043 combining estimates, expressed as low-high ranges.  For example,
6044 instead of estimating a particular task will take 5 days, you might
6045 estimate it as 5--6 days if you're fairly confident you know how much
6046 work is required, or 1--10 days if you do not really know what needs
6047 to be done.  Both ranges average at 5.5 days, but the first represents
6048 a more predictable delivery.
6050 When combining a set of such estimates, simply adding the lows and
6051 highs produces an unrealistically wide result.  Instead, @samp{est+} adds
6052 the statistical mean and variance of the sub-tasks, generating a final
6053 estimate from the sum.  For example, suppose you had ten tasks, each
6054 of which was estimated at 0.5 to 2 days of work.  Straight addition
6055 produces an estimate of 5 to 20 days, representing what to expect if
6056 everything goes either extremely well or extremely poorly.  In
6057 contrast, @samp{est+} estimates the full job more realistically, at 10--15
6058 days.
6060 Here is an example for a complete columns definition, along with
6061 allowed values@footnote{Please note that the @samp{COLUMNS} definition must be on a single
6062 line; it is wrapped here only because of formatting constraints.}.
6064 @example
6065 :COLUMNS:  %25ITEM %9Approved(Approved?)@{X@} %Owner %11Status \
6066                    %10Time_Estimate@{:@} %CLOCKSUM %CLOCKSUM_T
6067 :Owner_ALL:    Tammy Mark Karl Lisa Don
6068 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
6069 :Approved_ALL: "[ ]" "[X]"
6070 @end example
6072 @noindent
6073 The first column, @samp{%25ITEM}, means the first 25 characters of the item
6074 itself, i.e., of the headline.  You probably always should start the
6075 column definition with the @samp{ITEM} specifier.  The other specifiers
6076 create columns @samp{Owner} with a list of names as allowed values, for
6077 @samp{Status} with four different possible values, and for a checkbox field
6078 @samp{Approved}.  When no width is given after the @samp{%} character, the
6079 column is exactly as wide as it needs to be in order to fully display
6080 all values.  The @samp{Approved} column does have a modified title
6081 (@samp{Approved?}, with a question mark).  Summaries are created for the
6082 @samp{Time_Estimate} column by adding time duration expressions like HH:MM,
6083 and for the @samp{Approved} column, by providing an @samp{[X]} status if all
6084 children have been checked.  The @samp{CLOCKSUM} and @samp{CLOCKSUM_T} columns
6085 are special, they lists the sums of CLOCK intervals in the subtree,
6086 either for all clocks or just for today.
6088 @node Using column view
6089 @subsection Using column view
6093 @anchor{Turning column view on or off}
6094 @subsubheading Turning column view on or off
6096 @table @asis
6097 @item @kbd{C-c C-x C-c} (@code{org-columns})
6098 @kindex C-c C-x C-c
6099 @vindex org-columns
6100 @vindex org-columns-default-format
6101 Turn on column view.  If the cursor is before the first headline
6102 in the file, column view is turned on for the entire file, using
6103 the @samp{#+COLUMNS} definition.  If the cursor is somewhere inside
6104 the outline, this command searches the hierarchy, up from point,
6105 for a @samp{COLUMNS} property that defines a format.  When one is
6106 found, the column view table is established for the tree starting
6107 at the entry that contains the @samp{COLUMNS} property.  If no such
6108 property is found, the format is taken from the @samp{#+COLUMNS} line
6109 or from the variable @code{org-columns-default-format}, and column
6110 view is established for the current entry and its subtree.
6112 @item @kbd{r} or @kbd{g} (@code{org-columns-redo})
6113 @kindex r
6114 @kindex g
6115 @findex org-columns-redo
6116 Recreate the column view, to include recent changes made in the
6117 buffer.
6119 @item @kbd{q} (@code{org-columns-quit})
6120 @kindex q
6121 @findex org-columns-quit
6122 Exit column view.
6123 @end table
6125 @anchor{Editing values}
6126 @subsubheading Editing values
6128 @table @asis
6129 @item @kbd{@key{LEFT}}, @kbd{@key{RIGHT}}, @kbd{@key{UP}}, @kbd{@key{DOWN}}
6130 Move through the column view from field to field.
6132 @item @kbd{1..9,0}
6133 @kindex 1..9,0
6134 Directly select the Nth allowed value, @kbd{0} selects the
6135 10th value.
6137 @item @kbd{n} or @kbd{S-@key{RIGHT}} (@code{org-columns-next-allowed-value})
6138 @itemx @kbd{p} or @kbd{S-@key{LEFT}} (@code{org-columns-previous-allowed-value})
6139 @kindex n
6140 @kindex S-RIGHT
6141 @kindex p
6142 @kindex S-LEFT
6143 @findex org-columns-next-allowed-value
6144 @findex org-columns-previous-allowed-value
6145 Switch to the next/previous allowed value of the field.  For
6146 this, you have to have specified allowed values for a property.
6148 @item @kbd{e} (@code{org-columns-edit-value})
6149 @kindex e
6150 @findex org-columns-edit-value
6151 Edit the property at point.  For the special properties, this
6152 invokes the same interface that you normally use to change that
6153 property.  For example, the tag completion or fast selection
6154 interface pops up when editing a @samp{TAGS} property.
6156 @item @kbd{C-c C-c} (@code{org-columns-set-tags-or-toggle})
6157 @kindex C-c C-c
6158 @findex org-columns-set-tags-or-toggle
6159 When there is a checkbox at point, toggle it.
6161 @item @kbd{v} (@code{org-columns-show-value})
6162 @kindex v
6163 @findex org-columns-show-value
6164 View the full value of this property.  This is useful if the
6165 width of the column is smaller than that of the value.
6167 @item @kbd{a} (@code{org-columns-edit-allowed})
6168 @kindex a
6169 @findex org-columns-edit-allowed
6170 Edit the list of allowed values for this property.  If the list
6171 is found in the hierarchy, the modified values is stored there.
6172 If no list is found, the new value is stored in the first entry
6173 that is part of the current column view.
6174 @end table
6176 @anchor{Modifying column view on-the-fly}
6177 @subsubheading Modifying column view on-the-fly:
6179 @table @asis
6180 @item @kbd{<} (@code{org-columns-narrow})
6181 @itemx @kbd{>} (@code{org-columns-widen})
6182 @kindex <
6183 @kindex >
6184 @findex org-columns-narrow
6185 @findex org-columns-widen
6186 Make the column narrower/wider by one character.
6188 @item @kbd{S-M-@key{RIGHT}} (@code{org-columns-new})
6189 @kindex S-M-RIGHT
6190 @findex org-columns-new
6191 Insert a new column, to the left of the current column.
6193 @item @kbd{S-M-@key{LEFT}} (@code{org-columns-delete})
6194 @kindex S-M-LEFT
6195 @findex org-columns-delete
6196 Delete the current column.
6197 @end table
6199 @node Capturing column view
6200 @subsection Capturing column view
6202 Since column view is just an overlay over a buffer, it cannot be
6203 exported or printed directly.  If you want to capture a column view,
6204 use a @samp{columnview} dynamic block (see @ref{Dynamic Blocks}).  The frame of
6205 this block looks like this:
6207 @cindex @samp{BEGIN columnview}
6208 @example
6209 * The column view
6210 #+BEGIN: columnview :hlines 1 :id "label"
6212 #+END:
6213 @end example
6215 @noindent
6216 This dynamic block has the following parameters:
6218 @table @asis
6219 @item @samp{:id}
6220 This is the most important parameter.  Column view is a feature
6221 that is often localized to a certain (sub)tree, and the capture
6222 block might be at a different location in the file.  To identify
6223 the tree whose view to capture, you can use four values:
6225 @table @asis
6226 @item @samp{local}
6227 Use the tree in which the capture block is located.
6229 @item @samp{global}
6230 Make a global view, including all headings in the file.
6232 @item @samp{file:FILENAME}
6233 Run column view at the top of the @var{FILENAME} file
6235 @item @samp{LABEL}
6236 @cindex @samp{ID}, property
6237 Call column view in the tree that has an @samp{ID} property with
6238 the value @var{LABEL}.  You can use @kbd{M-x org-id-copy} to create a globally unique ID for the
6239 current entry and copy it to the kill-ring.
6240 @end table
6242 @item @samp{:hlines}
6243 When @code{t}, insert an hline after every line.  When a number N,
6244 insert an hline before each headline with level @code{<= N}.
6246 @item @samp{:vlines}
6247 When non-@code{nil}, force column groups to get vertical lines.
6249 @item @samp{:maxlevel}
6250 When set to a number, do not capture entries below this level.
6252 @item @samp{:skip-empty-rows}
6253 When non-@code{nil}, skip rows where the only non-empty specifier of
6254 the column view is @samp{ITEM}.
6256 @item @samp{:indent}
6257 When non-@code{nil}, indent each @samp{ITEM} field according to its level.
6258 @end table
6260 @noindent
6261 The following commands insert or update the dynamic block:
6263 @table @asis
6264 @item @kbd{C-c C-x i} (@code{org-insert-columns-dblock})
6265 @kindex C-c C-x i
6266 @findex org-insert-columns-dblock
6267 Insert a dynamic block capturing a column view.  Prompt for the
6268 scope or ID of the view.
6270 @item @kbd{C-c C-c} @kbd{C-c C-x C-u} (@code{org-dblock-update})
6271 @kindex C-c C-c
6272 @kindex C-c C-x C-u
6273 @findex org-dblock-update
6274 Update dynamic block at point.  The cursor needs to be in the
6275 @samp{#+BEGIN} line of the dynamic block.
6277 @item @kbd{C-u C-c C-x C-u} (@code{org-update-all-dblocks})
6278 @kindex C-u C-c C-x C-u
6279 Update all dynamic blocks (see @ref{Dynamic Blocks}).  This is useful
6280 if you have several clock table blocks, column-capturing blocks
6281 or other dynamic blocks in a buffer.
6282 @end table
6284 You can add formulas to the column view table and you may add plotting
6285 instructions in front of the table---these survive an update of the
6286 block.  If there is a @samp{TBLFM} keyword after the table, the table is
6287 recalculated automatically after an update.
6289 An alternative way to capture and process property values into a table
6290 is provided by Eric Schulte's @samp{org-collector.el} which is
6291 a contributed package@footnote{Contributed packages are not part of Emacs, but are
6292 distributed with the main distribution of Org---visit
6293 @uref{https://orgmode.org}.}.  It provides a general API to collect
6294 properties from entries in a certain scope, and arbitrary Lisp
6295 expressions to process these values before inserting them into a table
6296 or a dynamic block.
6298 @node Dates and Times
6299 @chapter Dates and Times
6301 @cindex dates
6302 @cindex times
6303 @cindex timestamp
6304 @cindex date stamp
6306 To assist project planning, TODO items can be labeled with a date
6307 and/or a time.  The specially formatted string carrying the date and
6308 time information is called a @emph{timestamp} in Org mode.  This may be
6309 a little confusing because timestamp is often used as indicating when
6310 something was created or last changed.  However, in Org mode this term
6311 is used in a much wider sense.
6313 @menu
6314 * Timestamps::                   Assigning a time to a tree entry.
6315 * Creating Timestamps::          Commands to insert timestamps.
6316 * Deadlines and Scheduling::     Planning your work.
6317 * Clocking Work Time::           Tracking how long you spend on a task.
6318 * Effort Estimates::             Planning work effort in advance.
6319 * Timers::                       Notes with a running timer.
6320 @end menu
6322 @node Timestamps
6323 @section Timestamps, Deadlines and Scheduling
6325 @cindex timestamps
6326 @cindex ranges, time
6327 @cindex date stamps
6328 @cindex deadlines
6329 @cindex scheduling
6331 A timestamp is a specification of a date (possibly with a time or
6332 a range of times) in a special format, either @samp{<2003-09-16 Tue>} or
6333 @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
6334 date/time format.  To use an alternative format, see @ref{Custom time format}.  The day name is optional when you type the date yourself.
6335 However, any date inserted or modified by Org adds that day name, for
6336 reading convenience.}.
6337 A timestamp can appear anywhere in the headline or body of an Org tree
6338 entry.  Its presence causes entries to be shown on specific dates in
6339 the agenda (see @ref{Weekly/daily agenda}).  We distinguish:
6341 @table @asis
6342 @item Plain timestamp; Event; Appointment
6343 @cindex timestamp
6344 @cindex appointment
6345 A simple timestamp just assigns a date/time to an item.  This is
6346 just like writing down an appointment or event in a paper agenda.
6347 In the timeline and agenda displays, the headline of an entry
6348 associated with a plain timestamp is shown exactly on that date.
6350 @example
6351 * Meet Peter at the movies
6352   <2006-11-01 Wed 19:15>
6353 * Discussion on climate change
6354   <2006-11-02 Thu 20:00-22:00>
6355 @end example
6357 @item Timestamp with repeater interval
6358 @cindex timestamp, with repeater interval
6359 A timestamp may contain a @emph{repeater interval}, indicating that it
6360 applies not only on the given date, but again and again after
6361 a certain interval of N days (d), weeks (w), months (m), or years
6362 (y).  The following shows up in the agenda every Wednesday:
6364 @example
6365 * Pick up Sam at school
6366   <2007-05-16 Wed 12:30 +1w>
6367 @end example
6369 @item Diary-style sexp entries
6370 @cindex diary style timestamps
6371 @cindex sexp timestamps
6372 For more complex date specifications, Org mode supports using the
6373 special sexp diary entries implemented in the Emacs
6374 calendar/diary package@footnote{When working with the standard diary sexp functions, you need
6375 to be very careful with the order of the arguments.  That order
6376 depends evilly on the variable @code{calendar-date-style}.  For example, to
6377 specify a date December 12, 2005, the call might look like
6378 @samp{(diary-date 12 1 2005)} or @samp{(diary-date 1 12 2005)} or @samp{(diary-date
6379 2005 12 1)}, depending on the settings.  This has been the source of
6380 much confusion.  Org mode users can resort to special versions of
6381 these functions like @code{org-date} or @code{org-anniversary}.  These work just
6382 like the corresponding @code{diary-} functions, but with stable ISO order
6383 of arguments (year, month, day) wherever applicable, independent of
6384 the value of @code{calendar-date-style}.}.  For example, with optional time:
6386 @example
6387 * 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
6388   <%%(org-float t 4 2)>
6389 @end example
6391 @item Time/Date range
6392 @cindex timerange
6393 @cindex date range
6394 Two timestamps connected by @samp{--} denote a range.  The headline is
6395 shown on the first and last day of the range, and on any dates
6396 that are displayed and fall in the range.  Here is an example:
6398 @example
6399 ** Meeting in Amsterdam
6400    <2004-08-23 Mon>--<2004-08-26 Thu>
6401 @end example
6403 @item Inactive timestamp
6404 @cindex timestamp, inactive
6405 @cindex inactive timestamp
6406 Just like a plain timestamp, but with square brackets instead of
6407 angular ones.  These timestamps are inactive in the sense that
6408 they do @emph{not} trigger an entry to show up in the agenda.
6410 @example
6411 * Gillian comes late for the fifth time
6412   [2006-11-01 Wed]
6413 @end example
6414 @end table
6416 @node Creating Timestamps
6417 @section Creating Timestamps
6419 For Org mode to recognize timestamps, they need to be in the specific
6420 format.  All commands listed below produce timestamps in the correct
6421 format.
6423 @table @asis
6424 @item @kbd{C-c .} (@code{org-time-stamp})
6425 @kindex C-c .
6426 @findex org-time-stamp
6427 Prompt for a date and insert a corresponding timestamp.  When the
6428 cursor is at an existing timestamp in the buffer, the command is
6429 used to modify this timestamp instead of inserting a new one.
6430 When this command is used twice in succession, a time range is
6431 inserted.
6433 @kindex C-u C-c .
6434 @vindex org-time-stamp-rounding-minutes
6435 When called with a prefix argument, use the alternative format
6436 which contains date and time.  The default time can be rounded to
6437 multiples of 5 minutes.  See the option
6438 @code{org-time-stamp-rounding-minutes}.
6440 @kindex C-u C-u C-c .
6441 With two prefix arguments, insert an active timestamp with the
6442 current time without prompting.
6444 @item @kbd{C-c !} (@code{org-time-stamp-inactive})
6445 @kindex C-c !
6446 @kindex C-u C-c !
6447 @kindex C-u C-u C-c !
6448 @findex org-time-stamp-inactive
6449 Like @kbd{C-c .}, but insert an inactive timestamp that does
6450 not cause an agenda entry.
6452 @item @kbd{C-c C-c}
6453 @kindex C-c C-c
6454 Normalize timestamp, insert or fix day name if missing or wrong.
6456 @item @kbd{C-c <} (@code{org-date-from-calendar})
6457 @kindex C-c <
6458 @findex org-date-from-calendar
6459 Insert a timestamp corresponding to the cursor date in the
6460 calendar.
6462 @item @kbd{C-c >} (@code{org-goto-calendar})
6463 @kindex C-c >
6464 @findex org-goto-calendar
6465 Access the Emacs calendar for the current date.  If there is
6466 a timestamp in the current line, go to the corresponding date
6467 instead.
6469 @item @kbd{C-c C-o} (@code{org-open-at-point})
6470 @kindex C-c C-o
6471 @findex org-open-at-point
6472 Access the agenda for the date given by the timestamp or -range
6473 at point (see @ref{Weekly/daily agenda}).
6475 @item @kbd{S-@key{LEFT}} (@code{org-timestamp-down-day})
6476 @itemx @kbd{S-@key{RIGHT}} (@code{org-timestamp-up-day})
6477 @kindex S-LEFT
6478 @kindex S-RIGHT
6479 @findex org-timestamp-down-day
6480 @findex org-timestamp-up-day
6481 Change date at cursor by one day.  These key bindings conflict
6482 with shift-selection and related modes (see @ref{Conflicts}).
6484 @item @kbd{S-@key{UP}} (@code{org-timestamp-up})
6485 @itemx @kbd{S-@key{DOWN}} (@code{org-timestamp-down})
6486 @kindex S-UP
6487 @kindex S-DOWN
6488 Change the item under the cursor in a timestamp.  The cursor can
6489 be on a year, month, day, hour or minute.  When the timestamp
6490 contains a time range like @samp{15:30-16:30}, modifying the first
6491 time also shifts the second, shifting the time block with
6492 constant length.  To change the length, modify the second time.
6493 Note that if the cursor is in a headline and not at a timestamp,
6494 these same keys modify the priority of an item.  (see
6495 @ref{Priorities}).  The key bindings also conflict with
6496 shift-selection and related modes (see @ref{Conflicts}).
6498 @item @kbd{C-c C-y} (@code{org-evaluate-time-range})
6499 @kindex C-c C-y
6500 @findex org-evaluate-time-range
6501 @cindex evaluate time range
6502 Evaluate a time range by computing the difference between start
6503 and end.  With a prefix argument, insert result after the time
6504 range (in a table: into the following column).
6505 @end table
6507 @menu
6508 * The date/time prompt::         How Org mode helps you enter dates and times.
6509 * Custom time format::           Making dates look different.
6510 @end menu
6512 @node The date/time prompt
6513 @subsection The date/time prompt
6515 @cindex date, reading in minibuffer
6516 @cindex time, reading in minibuffer
6518 @vindex org-read-date-prefer-future
6519 When Org mode prompts for a date/time, the default is shown in default
6520 date/time format, and the prompt therefore seems to ask for a specific
6521 format.  But it in fact accepts date/time information in a variety of
6522 formats.  Generally, the information should start at the beginning of
6523 the string.  Org mode finds whatever information is in there and
6524 derives anything you have not specified from the @emph{default date and
6525 time}.  The default is usually the current date and time, but when
6526 modifying an existing timestamp, or when entering the second stamp of
6527 a range, it is taken from the stamp in the buffer.  When filling in
6528 information, Org mode assumes that most of the time you want to enter
6529 a date in the future: if you omit the month/year and the given
6530 day/month is @emph{before} today, it assumes that you mean a future
6531 date@footnote{See the variable @code{org-read-date-prefer-future}.  You may set
6532 that variable to the symbol @code{time} to even make a time before now
6533 shift the date to tomorrow.}.  If the date has been automatically shifted into the
6534 future, the time prompt shows this with @samp{(=>F)}.
6536 For example, let's assume that today is @strong{June 13, 2006}.  Here is how
6537 various inputs are interpreted, the items filled in by Org mode are in
6538 @strong{bold}.
6540 @multitable {aaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
6541 @item @samp{3-2-5}
6542 @tab @result{} 2003-02-05
6543 @item @samp{2/5/3}
6544 @tab @result{} 2003-02-05
6545 @item @samp{14}
6546 @tab @result{} @strong{2006}-@strong{06}-14
6547 @item @samp{12}
6548 @tab @result{} @strong{2006}-@strong{07}-12
6549 @item @samp{2/5}
6550 @tab @result{} @strong{2007}-02-05
6551 @item @samp{Fri}
6552 @tab @result{} nearest Friday (default date or later)
6553 @item @samp{sep 15}
6554 @tab @result{} @strong{2006}-09-15
6555 @item @samp{feb 15}
6556 @tab @result{} @strong{2007}-02-15
6557 @item @samp{sep 12 9}
6558 @tab @result{} 2009-09-12
6559 @item @samp{12:45}
6560 @tab @result{} @strong{2006}-@strong{06}-@strong{13} 12:45
6561 @item @samp{22 sept 0:34}
6562 @tab @result{} @strong{2006}-09-22 0:34
6563 @item @samp{w4}
6564 @tab @result{} ISO week for of the current year @strong{2006}
6565 @item @samp{2012 w4 fri}
6566 @tab @result{} Friday of ISO week 4 in 2012
6567 @item @samp{2012-w04-5}
6568 @tab @result{} Same as above
6569 @end multitable
6571 Furthermore you can specify a relative date by giving, as the @emph{first}
6572 thing in the input: a plus/minus sign, a number and a letter---@samp{d},
6573 @samp{w}, @samp{m} or @samp{y}---to indicate change in days, weeks, months, or
6574 years.  With a single plus or minus, the date is always relative to
6575 today.  With a double plus or minus, it is relative to the default
6576 date.  If instead of a single letter, you use the abbreviation of day
6577 name, the date is the Nth such day, e.g.:
6579 @multitable {aaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
6580 @item @samp{+0}
6581 @tab @result{} today
6582 @item @samp{.}
6583 @tab @result{} today
6584 @item @samp{+4d}
6585 @tab @result{} four days from today
6586 @item @samp{+4}
6587 @tab @result{} same as +4d
6588 @item @samp{+2w}
6589 @tab @result{} two weeks from today
6590 @item @samp{++5}
6591 @tab @result{} five days from default date
6592 @item @samp{+2tue}
6593 @tab @result{} second Tuesday from now
6594 @end multitable
6596 @vindex parse-time-months
6597 @vindex parse-time-weekdays
6598 The function understands English month and weekday abbreviations.  If
6599 you want to use un-abbreviated names and/or other languages, configure
6600 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
6602 @vindex org-read-date-force-compatible-dates
6603 Not all dates can be represented in a given Emacs implementation.  By
6604 default Org mode forces dates into the compatibility range 1970--2037
6605 which works on all Emacs implementations.  If you want to use dates
6606 outside of this range, read the docstring of the variable
6607 @code{org-read-date-force-compatible-dates}.
6609 You can specify a time range by giving start and end times or by
6610 giving a start time and a duration (in HH:MM format).  Use one or two
6611 dash(es) as the separator in the former case and use @samp{+} as the
6612 separator in the latter case, e.g.:
6614 @multitable {aaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaa}
6615 @item @samp{11am-1:15pm}
6616 @tab @result{} 11:00-13:15
6617 @item @samp{11am--1:15pm}
6618 @tab @result{} same as above
6619 @item @samp{11am+2:15}
6620 @tab @result{} same as above
6621 @end multitable
6623 @cindex calendar, for selecting date
6624 @vindex org-popup-calendar-for-date-prompt
6625 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If you do not need/want the calendar, configure the variable
6626 @code{org-popup-calendar-for-date-prompt}.}.
6627 When you exit the date prompt, either by clicking on a date in the
6628 calendar, or by pressing @kbd{@key{RET}}, the date selected in the
6629 calendar is combined with the information entered at the prompt.  You
6630 can control the calendar fully from the minibuffer:
6632 @kindex <
6633 @kindex >
6634 @kindex M-v
6635 @kindex C-v
6636 @kindex mouse-1
6637 @kindex S-RIGHT
6638 @kindex S-LEFT
6639 @kindex S-DOWN
6640 @kindex S-UP
6641 @kindex M-S-RIGHT
6642 @kindex M-S-LEFT
6643 @kindex RET
6644 @multitable @columnfractions 0.25 0.55
6645 @item @kbd{@key{RET}}
6646 @tab Choose date at cursor in calendar.
6647 @item @kbd{mouse-1}
6648 @tab Select date by clicking on it.
6649 @item @kbd{S-@key{RIGHT}}
6650 @tab One day forward.
6651 @item @kbd{S-@key{LEFT}}
6652 @tab One day backward.
6653 @item @kbd{S-@key{DOWN}}
6654 @tab One week forward.
6655 @item @kbd{S-@key{UP}}
6656 @tab One week backward.
6657 @item @kbd{M-S-@key{RIGHT}}
6658 @tab One month forward.
6659 @item @kbd{M-S-@key{LEFT}}
6660 @tab One month backward.
6661 @item @kbd{>}
6662 @tab Scroll calendar forward by one month.
6663 @item @kbd{<}
6664 @tab Scroll calendar backward by one month.
6665 @item @kbd{M-v}
6666 @tab Scroll calendar forward by 3 months.
6667 @item @kbd{C-v}
6668 @tab Scroll calendar backward by 3 months.
6669 @end multitable
6671 @vindex org-read-date-display-live
6672 The actions of the date/time prompt may seem complex, but I assure you
6673 they will grow on you, and you will start getting annoyed by pretty
6674 much any other way of entering a date/time out there.  To help you
6675 understand what is going on, the current interpretation of your input
6676 is displayed live in the minibuffer@footnote{If you find this distracting, turn off the display with
6677 @code{org-read-date-display-live}.}.
6679 @node Custom time format
6680 @subsection Custom time format
6682 @cindex custom date/time format
6683 @cindex time format, custom
6684 @cindex date format, custom
6686 @vindex org-display-custom-times
6687 @vindex org-time-stamp-custom-formats
6688 Org mode uses the standard ISO notation for dates and times as it is
6689 defined in ISO 8601.  If you cannot get used to this and require
6690 another representation of date and time to keep you happy, you can get
6691 it by customizing the variables @code{org-display-custom-times} and
6692 @code{org-time-stamp-custom-formats}.
6694 @table @asis
6695 @item @kbd{C-c C-x C-t} (@code{org-toggle-time-stamp-overlays})
6696 @kindex C-c C-x C-t
6697 @findex org-toggle-time-stamp-overlays
6698 Toggle the display of custom formats for dates and times.
6699 @end table
6701 @noindent
6702 Org mode needs the default format for scanning, so the custom
6703 date/time format does not @emph{replace} the default format.  Instead, it
6704 is put @emph{over} the default format using text properties.  This has the
6705 following consequences:
6707 @itemize
6708 @item
6709 You cannot place the cursor onto a timestamp anymore, only before or
6710 after.
6712 @item
6713 The @kbd{S-@key{UP}} and @kbd{S-@key{DOWN}} keys can no longer be used
6714 to adjust each component of a timestamp.  If the cursor is at the
6715 beginning of the stamp, @kbd{S-@key{UP}} and @kbd{S-@key{DOWN}} change
6716 the stamp by one day, just like @kbd{S-@key{LEFT}}
6717 @kbd{S-@key{RIGHT}}.  At the end of the stamp, change the time by one
6718 minute.
6720 @item
6721 If the timestamp contains a range of clock times or a repeater,
6722 these are not overlaid, but remain in the buffer as they were.
6724 @item
6725 When you delete a timestamp character-by-character, it only
6726 disappears from the buffer after @emph{all} (invisible) characters
6727 belonging to the ISO timestamp have been removed.
6729 @item
6730 If the custom timestamp format is longer than the default and you
6731 are using dates in tables, table alignment will be messed up.  If
6732 the custom format is shorter, things do work as expected.
6733 @end itemize
6735 @node Deadlines and Scheduling
6736 @section Deadlines and Scheduling
6738 A timestamp may be preceded by special keywords to facilitate
6739 planning.  Both the timestamp and the keyword have to be positioned
6740 immediately after the task they refer to.
6742 @table @asis
6743 @item @samp{DEADLINE}
6744 @cindex @samp{DEADLINE}
6745 Meaning: the task (most likely a TODO item, though not
6746 necessarily) is supposed to be finished on that date.
6748 @vindex org-deadline-warning-days
6749 On the deadline date, the task is listed in the agenda.  In
6750 addition, the agenda for @emph{today} carries a warning about the
6751 approaching or missed deadline, starting
6752 @code{org-deadline-warning-days} before the due date, and continuing
6753 until the entry is marked DONE.  An example:
6755 @example
6756 *** TODO write article about the Earth for the Guide
6757     DEADLINE: <2004-02-29 Sun>
6758     The editor in charge is [[bbdb:Ford Prefect]]
6759 @end example
6761 @vindex org-agenda-skip-deadline-prewarning-if-scheduled
6762 You can specify a different lead time for warnings for a specific
6763 deadlines using the following syntax.  Here is an example with
6764 a warning period of 5 days @samp{DEADLINE: <2004-02-29 Sun -5d>}.
6765 This warning is deactivated if the task gets scheduled and you
6766 set @code{org-agenda-skip-deadline-prewarning-if-scheduled} to @code{t}.
6768 @item @samp{SCHEDULED}
6769 @cindex @samp{SCHEDULED}
6770 Meaning: you are planning to start working on that task on the
6771 given date.
6773 @vindex org-agenda-skip-scheduled-if-done
6774 The headline is listed under the given date@footnote{It will still be listed on that date after it has been marked
6775 DONE.  If you do not like this, set the variable
6776 @code{org-agenda-skip-scheduled-if-done}.}.  In addition,
6777 a reminder that the scheduled date has passed is present in the
6778 compilation for @emph{today}, until the entry is marked DONE, i.e.,
6779 the task is automatically forwarded until completed.
6781 @example
6782 *** TODO Call Trillian for a date on New Years Eve.
6783     SCHEDULED: <2004-12-25 Sat>
6784 @end example
6786 @vindex org-scheduled-delay-days
6787 @vindex org-agenda-skip-scheduled-delay-if-deadline
6788 If you want to @emph{delay} the display of this task in the agenda,
6789 use @samp{SCHEDULED: <2004-12-25 Sat -2d>}: the task is still
6790 scheduled on the 25th but will appear two days later.  In case
6791 the task contains a repeater, the delay is considered to affect
6792 all occurrences; if you want the delay to only affect the first
6793 scheduled occurrence of the task, use @samp{--2d} instead.  See
6794 @code{org-scheduled-delay-days} and
6795 @code{org-agenda-skip-scheduled-delay-if-deadline} for details on how
6796 to control this globally or per agenda.
6798 @noindent
6799 @strong{Important:} Scheduling an item in Org mode should @emph{not} be
6800 understood in the same way that we understand @emph{scheduling
6801 a meeting}.  Setting a date for a meeting is just a simple
6802 appointment, you should mark this entry with a simple plain
6803 timestamp, to get this item shown on the date where it applies.
6804 This is a frequent misunderstanding by Org users.  In Org mode,
6805 @emph{scheduling} means setting a date when you want to start working
6806 on an action item.
6807 @end table
6809 You may use timestamps with repeaters in scheduling and deadline
6810 entries.  Org mode issues early and late warnings based on the
6811 assumption that the timestamp represents the @emph{nearest instance} of the
6812 repeater.  However, the use of diary S-exp entries like
6814 @example
6815 <%%(org-float t 42)>
6816 @end example
6818 @noindent
6819 in scheduling and deadline timestamps is limited.  Org mode does not
6820 know enough about the internals of each S-exp function to issue early
6821 and late warnings.  However, it shows the item on each day where the
6822 S-exp entry matches.
6824 @menu
6825 * Inserting deadline/schedule::  Planning items.
6826 * Repeated tasks::               Items that show up again and again.
6827 @end menu
6829 @node Inserting deadline/schedule
6830 @subsection Inserting deadlines or schedules
6832 The following commands allow you to quickly insert a deadline or to
6833 schedule an item:@footnote{The @samp{SCHEDULED} and @samp{DEADLINE} dates are inserted on the line
6834 right below the headline.  Do not put any text between this line and
6835 the headline.}
6837 @table @asis
6838 @item @kbd{C-c C-d} (@code{org-deadline})
6839 @kindex C-c C-d
6840 @findex org-deadline
6841 @vindex org-log-redeadline
6842 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion
6843 happens in the line directly following the headline.  Remove any
6844 @samp{CLOSED} timestamp .  When called with a prefix argument, also
6845 remove any existing deadline from the entry.  Depending on the
6846 variable @code{org-log-redeadline}, take a note when changing an
6847 existing deadline@footnote{Note the corresponding @samp{STARTUP} options @samp{logredeadline},
6848 @samp{lognoteredeadline}, and @samp{nologredeadline}.}.
6850 @item @kbd{C-c C-s} (@code{org-schedule})
6851 @kindex C-c C-s
6852 @findex org-schedule
6853 @vindex org-log-reschedule
6854 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion
6855 happens in the line directly following the headline.  Remove any
6856 @samp{CLOSED} timestamp.  When called with a prefix argument, also
6857 remove the scheduling date from the entry.  Depending on the
6858 variable @code{org-log-reschedule}, take a note when changing an
6859 existing scheduling time@footnote{Note the corresponding @samp{STARTUP} options @samp{logreschedule},
6860 @samp{lognotereschedule}, and @samp{nologreschedule}.}.
6862 @item @kbd{C-c C-x C-k} (@code{org-mark-entry-for-agenda-action})
6863 @kindex C-c C-x C-k
6864 @kindex k a
6865 @kindex k s
6866 @findex org-mark-entry-for-agenda-action
6867 Mark the current entry for agenda action.  After you have marked
6868 the entry like this, you can open the agenda or the calendar to
6869 find an appropriate date.  With the cursor on the selected date,
6870 press @kbd{k s} or @kbd{k d} to schedule the marked
6871 item.
6873 @item @kbd{C-c / d} (@code{org-check-deadlines})
6874 @kindex C-c / d
6875 @findex org-check-deadlines
6876 @cindex sparse tree, for deadlines
6877 @vindex org-deadline-warning-days
6878 Create a sparse tree with all deadlines that are either past-due,
6879 or which will become due within @code{org-deadline-warning-days}.
6880 With @kbd{C-u} prefix, show all deadlines in the file.  With
6881 a numeric prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows all deadlines due tomorrow.
6883 @item @kbd{C-c / b}, @code{org-check-before-date}
6884 @kindex C-c / b
6885 @findex org-check-before-date
6886 Sparse tree for deadlines and scheduled items before a given
6887 date.
6889 @item @kbd{C-c / a}, @code{org-check-after-date}
6890 @kindex C-c / a
6891 @findex org-check-after-date
6892 Sparse tree for deadlines and scheduled items after a given date.
6893 @end table
6895 Note that @code{org-schedule} and @code{org-deadline} supports setting the date
6896 by indicating a relative time e.g., @samp{+1d} sets the date to the next
6897 day after today, and @samp{--1w} sets the date to the previous week before
6898 any current timestamp.
6900 @node Repeated tasks
6901 @subsection Repeated tasks
6903 @cindex tasks, repeated
6904 @cindex repeated tasks
6906 Some tasks need to be repeated again and again.  Org mode helps to
6907 organize such tasks using a so-called repeater in a @samp{DEADLINE},
6908 @samp{SCHEDULED}, or plain timestamp.  In the following example:
6910 @example
6911 ** TODO Pay the rent
6912    DEADLINE: <2005-10-01 Sat +1m>
6913 @end example
6915 noindent
6916 the @samp{+1m} is a repeater; the intended interpretation is that the task
6917 has a deadline on @samp{<2005-10-01>} and repeats itself every (one) month
6918 starting from that time.  You can use yearly, monthly, weekly, daily
6919 and hourly repeat cookies by using the @code{y/w/m/d/h} letters.  If you
6920 need both a repeater and a special warning period in a deadline entry,
6921 the repeater should come first and the warning period last: @samp{DEADLINE:
6922 <2005-10-01 Sat +1m -3d>}.
6924 @vindex org-todo-repeat-to-state
6925 Deadlines and scheduled items produce entries in the agenda when they
6926 are over-due, so it is important to be able to mark such an entry as
6927 completed once you have done so.  When you mark a @samp{DEADLINE} or
6928 a @samp{SCHEDULED} with the TODO keyword @samp{DONE}, it no longer produces
6929 entries in the agenda.  The problem with this is, however, is that
6930 then also the @emph{next} instance of the repeated entry will not be
6931 active.  Org mode deals with this in the following way: when you try
6932 to mark such an entry DONE, using @kbd{C-c C-t}, it shifts the
6933 base date of the repeating timestamp by the repeater interval, and
6934 immediately sets the entry state back to TODO@footnote{In fact, the target state is taken from, in this sequence, the
6935 @samp{REPEAT_TO_STATE} property, the variable @code{org-todo-repeat-to-state} if
6936 it is a string, the previous TODO state if @code{org-todo-repeat-to-state}
6937 is @code{t}, or the first state of the TODO state sequence.}.  In the example
6938 above, setting the state to DONE would actually switch the date like
6939 this:
6941 @example
6942 ** TODO Pay the rent
6943    DEADLINE: <2005-11-01 Tue +1m>
6944 @end example
6946 To mark a task with a repeater as DONE, use @kbd{C-- 1 C-c C-t},
6947 i.e., @code{org-todo} with a numeric prefix argument of @samp{-1}.
6949 @vindex org-log-repeat
6950 A timestamp@footnote{You can change this using the option @code{org-log-repeat}, or the
6951 @samp{STARTUP} options @samp{logrepeat}, @samp{lognoterepeat}, and @samp{nologrepeat}.
6952 With @samp{lognoterepeat}, you will also be prompted for a note.} is added under the deadline, to keep a record that
6953 you actually acted on the previous instance of this deadline.
6955 As a consequence of shifting the base date, this entry is no longer
6956 visible in the agenda when checking past dates, but all future
6957 instances will be visible.
6959 With the @samp{+1m} cookie, the date shift is always exactly one month.  So
6960 if you have not paid the rent for three months, marking this entry
6961 DONE still keeps it as an overdue deadline.  Depending on the task,
6962 this may not be the best way to handle it.  For example, if you forgot
6963 to call your father for 3 weeks, it does not make sense to call him
6964 3 times in a single day to make up for it.  Finally, there are tasks
6965 like changing batteries which should always repeat a certain time
6966 @emph{after} the last time you did it.  For these tasks, Org mode has
6967 special repeaters @samp{++} and @samp{.+}.  For example:
6969 @example
6970 ** TODO Call Father
6971    DEADLINE: <2008-02-10 Sun ++1w>
6972    Marking this DONE shifts the date by at least one week, but also
6973    by as many weeks as it takes to get this date into the future.
6974    However, it stays on a Sunday, even if you called and marked it
6975    done on Saturday.
6977 ** TODO Empty kitchen trash
6978    DEADLINE: <2008-02-08 Fri 20:00 ++1d>
6979    Marking this DONE shifts the date by at least one day, and also
6980    by as many days as it takes to get the timestamp into the future.
6981    Since there is a time in the timestamp, the next deadline in the
6982    future will be on today's date if you complete the task before
6983    20:00.
6985 ** TODO Check the batteries in the smoke detectors
6986    DEADLINE: <2005-11-01 Tue .+1m>
6987    Marking this DONE will shift the date to one month after today.
6988 @end example
6990 @vindex org-agenda-skip-scheduled-if-deadline-is-shown
6991 You may have both scheduling and deadline information for a specific
6992 task.  If the repeater is set for the scheduling information only, you
6993 probably want the repeater to be ignored after the deadline.  If so,
6994 set the variable @code{org-agenda-skip-scheduled-if-deadline-is-shown} to
6995 @code{repeated-after-deadline}.  However, any scheduling information
6996 without a repeater is no longer relevant once the task is done, and
6997 thus, removed upon repeating the task.  If you want both scheduling
6998 and deadline information to repeat after the same interval, set the
6999 same repeater for both timestamps.
7001 An alternative to using a repeater is to create a number of copies of
7002 a task subtree, with dates shifted in each copy.  The command
7003 @kbd{C-c C-x c} was created for this purpose; it is described in
7004 @ref{Structure Editing}.
7006 @node Clocking Work Time
7007 @section Clocking Work Time
7009 @cindex clocking time
7010 @cindex time clocking
7012 Org mode allows you to clock the time you spend on specific tasks in
7013 a project.  When you start working on an item, you can start the
7014 clock.  When you stop working on that task, or when you mark the task
7015 done, the clock is stopped and the corresponding time interval is
7016 recorded.  It also computes the total time spent on each
7017 subtree@footnote{Clocking only works if all headings are indented with less
7018 than 30 stars.  This is a hard-coded limitation of @code{lmax} in
7019 @code{org-clock-sum}.} of a project.  And it remembers a history or tasks
7020 recently clocked, to that you can jump quickly between a number of
7021 tasks absorbing your time.
7023 To save the clock history across Emacs sessions, use:
7025 @lisp
7026 (setq org-clock-persist 'history)
7027 (org-clock-persistence-insinuate)
7028 @end lisp
7030 @vindex org-clock-persist
7031 When you clock into a new task after resuming Emacs, the incomplete
7032 clock@footnote{To resume the clock under the assumption that you have worked
7033 on this task while outside Emacs, use @code{(setq org-clock-persist t)}.} is retrieved (see @ref{Resolving idle time (1)}) and you are
7034 prompted about what to do with it.
7036 @menu
7037 * Clocking commands::            Starting and stopping a clock.
7038 * The clock table::              Detailed reports.
7039 * Resolving idle time::          Resolving time when you've been idle.
7040 @end menu
7042 @node Clocking commands
7043 @subsection Clocking commands
7045 @table @asis
7046 @item @kbd{C-c C-x C-i} (@code{org-clock-in})
7047 @kindex C-c C-x C-i
7048 @findex org-clock-in
7049 @vindex org-clock-into-drawer
7050 @vindex org-clock-continuously
7051 @cindex @samp{LOG_INTO_DRAWER}, property
7052 Start the clock on the current item (clock-in).  This inserts the
7053 CLOCK keyword together with a timestamp.  If this is not the
7054 first clocking of this item, the multiple CLOCK lines are wrapped
7055 into a @samp{LOGBOOK} drawer (see also the variable
7056 @code{org-clock-into-drawer}).  You can also overrule the setting of
7057 this variable for a subtree by setting a @samp{CLOCK_INTO_DRAWER} or
7058 @samp{LOG_INTO_DRAWER} property.  When called with a @kbd{C-u}
7059 prefix argument, select the task from a list of recently clocked
7060 tasks.  With two @kbd{C-u C-u} prefixes, clock into the task
7061 at point and mark it as the default task; the default task is
7062 always be available with letter @kbd{d} when selecting
7063 a clocking task.  With three @kbd{C-u C-u C-u} prefixes,
7064 force continuous clocking by starting the clock when the last
7065 clock stopped.
7067 @cindex @samp{CLOCK_MODELINE_TOTAL}, property
7068 @cindex @samp{LAST_REPEAT}, property
7069 @vindex org-clock-mode-line-total
7070 @vindex org-clock-in-prepare-hook
7071 While the clock is running, Org shows the current clocking time
7072 in the mode line, along with the title of the task.  The clock
7073 time shown is all time ever clocked for this task and its
7074 children.  If the task has an effort estimate (see @ref{Effort Estimates}), the mode line displays the current clocking time
7075 against it@footnote{To add an effort estimate ``on the fly'', hook a function doing
7076 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
7077 task@footnote{The last reset of the task is recorded by the @samp{LAST_REPEAT}
7078 property.}.  You can exercise more control over show time with
7079 the @samp{CLOCK_MODELINE_TOTAL} property.  It may have the values
7080 @samp{current} to show only the current clocking instance, @samp{today} to
7081 show all time clocked on this tasks today---see also the
7082 variable @code{org-extend-today-until}, @code{all} to include all time, or
7083 @code{auto} which is the default@footnote{See also the variable @code{org-clock-mode-line-total}.}.  Clicking with
7084 @kbd{mouse-1} onto the mode line entry pops up a menu with
7085 clocking options.
7087 @item @kbd{C-c C-x C-o} (@code{org-clock-out})
7088 @kindex C-c C-x C-o
7089 @findex org-clock-out
7090 @vindex org-log-note-clock-out
7091 Stop the clock (clock-out).  This inserts another timestamp at
7092 the same location where the clock was last started.  It also
7093 directly computes the resulting time in inserts it after the time
7094 range as @samp{=>HH:MM}.  See the variable @code{org-log-note-clock-out}
7095 for the possibility to record an additional note together with
7096 the clock-out timestamp@footnote{The corresponding in-buffer setting is: @samp{#+STARTUP:
7097 lognoteclock-out}.}.
7099 @item @kbd{C-c C-x C-x} (@code{org-clock-in-last})
7100 @kindex C-c C-x C-x
7101 @findex org-clock-in-last
7102 @vindex org-clock-continuously
7103 Re-clock the last clocked task.  With one @kbd{C-u} prefix
7104 argument, select the task from the clock history.  With two
7105 @kbd{C-u} prefixes, force continuous clocking by starting
7106 the clock when the last clock stopped.
7108 @item @kbd{C-c C-x C-e} (@code{org-clock-modify-effort-estimate})
7109 @kindex C-c C-x C-e
7110 @findex org-clock-modify-effort-estimate
7111 Update the effort estimate for the current clock task.
7113 @item @kbd{C-c C-c} or @kbd{C-c C-y} (@code{org-evaluate-time-range})
7114 @kindex C-c C-c
7115 @kindex C-c C-y
7116 @findex org-evaluate-time-range
7117 Recompute the time interval after changing one of the timestamps.
7118 This is only necessary if you edit the timestamps directly.  If
7119 you change them with @kbd{S-<cursor>} keys, the update is
7120 automatic.
7122 @item @kbd{C-S-@key{UP}} (@code{org-clock-timestamps-up})
7123 @itemx @kbd{C-S-@key{DOWN}} (@code{org-clock-timestamps-down})
7124 @kindex C-S-UP
7125 @findex org-clock-timestamps-up
7126 @kindex C-S-DOWN
7127 @findex org-clock-timestamps-down
7128 On CLOCK log lines, increase/decrease both timestamps so that the
7129 clock duration keeps the same value.
7131 @item @kbd{S-M-@key{UP}} (@code{org-timestamp-up})
7132 @itemx @kbd{S-M-@key{DOWN}} (@code{org-timestamp-down})
7133 @kindex S-M-UP
7134 @findex org-clock-timestamp-up
7135 @kindex S-M-DOWN
7136 @findex org-clock-timestamp-down
7137 On @samp{CLOCK} log lines, increase/decrease the timestamp at point
7138 and the one of the previous, or the next, clock timestamp by the
7139 same duration.  For example, if you hit @kbd{S-M-@key{UP}} to
7140 increase a clocked-out timestamp by five minutes, then the
7141 clocked-in timestamp of the next clock is increased by five
7142 minutes.
7144 @item @kbd{C-c C-t} (@code{org-todo})
7145 @kindex C-c C-t
7146 @findex org-todo
7147 Changing the TODO state of an item to DONE automatically stops
7148 the clock if it is running in this same item.
7150 @item @kbd{C-c C-x C-q} (@code{org-clock-cancel})
7151 @kindex C-c C-x C-q
7152 @findex org-clock-cancel
7153 Cancel the current clock.  This is useful if a clock was started
7154 by mistake, or if you ended up working on something else.
7156 @item @kbd{C-c C-x C-j} (@code{org-clock-goto})
7157 @kindex C-c C-x C-j
7158 @findex or-clock-goto
7159 Jump to the headline of the currently clocked in task.  With
7160 a @kbd{C-u} prefix argument, select the target task from
7161 a list of recently clocked tasks.
7163 @item @kbd{C-c C-x C-d} (@code{org-clock-display})
7164 @kindex C-c C-x C-d
7165 @findex org-clock-display
7166 @vindex org-remove-highlights-with-change
7167 Display time summaries for each subtree in the current buffer.
7168 This puts overlays at the end of each headline, showing the total
7169 time recorded under that heading, including the time of any
7170 subheadings.  You can use visibility cycling to study the tree,
7171 but the overlays disappear when you change the buffer (see
7172 variable @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
7173 @end table
7175 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
7176 a day.
7178 @strong{Important:} note that both @code{org-clock-out} and @code{org-clock-in-last}
7179 can have a global keybinding and do not modify the window disposition.
7181 @node The clock table
7182 @subsection The clock table
7184 @cindex clocktable, dynamic block
7185 @cindex report, of clocked time
7187 Org mode can produce quite complex reports based on the time clocking
7188 information.  Such a report is called a @emph{clock table}, because it is
7189 formatted as one or several Org tables.
7191 @table @asis
7192 @item @kbd{C-c C-x C-r} (@code{org-clock-report})
7193 @kindex C-c C-x C-r
7194 @findex org-clock-report
7195 Insert a dynamic block (see @ref{Dynamic Blocks}) containing a clock
7196 report as an Org mode table into the current file.  When the
7197 cursor is at an existing clock table, just update it.  When
7198 called with a prefix argument, jump to the first clock report in
7199 the current document and update it.  The clock table includes
7200 archived trees.
7202 @item @kbd{C-c C-c} or @kbd{C-c C-x C-u} (@code{org-dblock-update})
7203 @kindex C-c C-c
7204 @kindex C-c C-x C-u
7205 @findex org-dblock-update
7206 Update dynamic block at point.  The cursor needs to be in the
7207 @samp{BEGIN} line of the dynamic block.
7209 @item @kbd{C-u C-c C-x C-u}
7210 @kindex C-u C-c C-x C-u
7211 Update all dynamic blocks (see @ref{Dynamic Blocks}).  This is useful
7212 if you have several clock table blocks in a buffer.
7214 @item @kbd{S-@key{LEFT}}
7215 @itemx @kbd{S-@key{RIGHT}} (@code{org-clocktable-try-shift})
7216 @kindex S-LEFT
7217 @kindex S-RIGHT
7218 @findex org-clocktable-try-shift
7219 Shift the current @samp{:block} interval and update the table.  The
7220 cursor needs to be in the @samp{#+BEGIN: clocktable} line for this
7221 command.  If @samp{:block} is @samp{today}, it is shifted to @samp{today-1},
7222 etc.
7223 @end table
7225 Here is an example of the frame for a clock table as it is inserted
7226 into the buffer with the @kbd{C-c C-x C-r} command:
7228 @cindex @samp{BEGIN clocktable}
7229 @example
7230 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
7231 #+END: clocktable
7232 @end example
7234 @noindent
7235 @vindex org-clocktable-defaults
7236 The @samp{#+BEGIN} line and specify a number of options to define the
7237 scope, structure, and formatting of the report.  Defaults for all
7238 these options can be configured in the variable
7239 @code{org-clocktable-defaults}.
7241 @noindent
7242 First there are options that determine which clock entries are to
7243 be selected:
7245 @table @asis
7246 @item :maxlevel
7247 Maximum level depth to which times are listed in the table.
7248 Clocks at deeper levels are summed into the upper level.
7250 @item :scope
7251 The scope to consider.  This can be any of the following:
7253 @multitable {aaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
7254 @item @code{nil}
7255 @tab the current buffer or narrowed region
7256 @item @code{file}
7257 @tab the full current buffer
7258 @item @code{subtree}
7259 @tab the subtree where the clocktable is located
7260 @item @code{treeN}
7261 @tab the surrounding level N tree, for example @samp{tree3}
7262 @item @code{tree}
7263 @tab the surrounding level 1 tree
7264 @item @code{agenda}
7265 @tab all agenda files
7266 @item @samp{("file" ...)}
7267 @tab scan these files
7268 @item @samp{FUNCTION}
7269 @tab scan files returned by calling FUNCTION with no argument
7270 @item @code{file-with-archives}
7271 @tab current file and its archives
7272 @item @code{agenda-with-archives}
7273 @tab all agenda files, including archives
7274 @end multitable
7276 @item :block
7277 The time block to consider.  This block is specified either
7278 absolutely, or relative to the current time and may be any of
7279 these formats:
7281 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaa}
7282 @item @samp{2007-12-31}
7283 @tab New year eve 2007
7284 @item @samp{2007-12}
7285 @tab December 2007
7286 @item @samp{2007-W50}
7287 @tab ISO-week 50 in 2007
7288 @item @samp{2007-Q2}
7289 @tab 2nd quarter in 2007
7290 @item @samp{2007}
7291 @tab the year 2007
7292 @item @code{today}, @code{yesterday}, @code{today-N}
7293 @tab a relative day
7294 @item @code{thisweek}, @code{lastweek}, @code{thisweek-N}
7295 @tab a relative week
7296 @item @code{thismonth}, @code{lastmonth}, @code{thismonth-N}
7297 @tab a relative month
7298 @item @code{thisyear}, @code{lastyear}, @code{thisyear-N}
7299 @tab a relative year
7300 @item @code{untilnow}
7301 @tab all clocked time ever
7302 @end multitable
7304 @vindex org-clock-display-default-range
7305 When this option is not set, Org falls back to the value in
7306 @code{org-clock-display-default-range}, which defaults to the current
7307 year.
7309 Use @kbd{S-@key{LEFT}} or @kbd{S-@key{RIGHT}} to shift the time
7310 interval.
7312 @item :tstart
7313 A time string specifying when to start considering times.
7314 Relative times like @samp{"<-2w>"} can also be used.  See @ref{Matching tags and properties} for relative time syntax.
7316 @item :tend 
7317 A time string specifying when to stop considering times.
7318 Relative times like @samp{"<now>"} can also be used.  See @ref{Matching tags and properties} for relative time syntax.
7320 @item wstart
7321 The starting day of the week.  The default is 1 for Monday.
7323 @item mstart
7324 The starting day of the month.  The default is 1 for the first.
7326 @item :step
7327 Set to @code{week} or @code{day} to split the table into chunks.  To use
7328 this, @code{:block} or @code{:tstart}, @code{:tend} are needed.
7330 @item :stepskip0
7331 Do not show steps that have zero time.
7333 @item :fileskip0
7334 Do not show table sections from files which did not contribute.
7336 @item :tags
7337 A tags match to select entries that should contribute.  See
7338 @ref{Matching tags and properties} for the match syntax.
7339 @end table
7341 @findex org-clocktable-write-default
7342 Then there are options that determine the formatting of the table.
7343 There options are interpreted by the function
7344 @code{org-clocktable-write-default}, but you can specify your own function
7345 using the @samp{:formatter} parameter.
7347 @table @asis
7348 @item :emphasize
7349 When @code{t}, emphasize level one and level two items.
7351 @item :lang
7352 Language@footnote{Language terms can be set through the variable
7353 @code{org-clock-clocktable-language-setup}.} to use for descriptive cells like ``Task''.
7355 @item :link
7356 Link the item headlines in the table to their origins.
7358 @item :narrow
7359 An integer to limit the width of the headline column in the Org
7360 table.  If you write it like @samp{50!}, then the headline is also
7361 shortened in export.
7363 @item :indent
7364 Indent each headline field according to its level.
7366 @item :tcolumns
7367 Number of columns to be used for times.  If this is smaller than
7368 @samp{:maxlevel}, lower levels are lumped into one column.
7370 @item :level
7371 Should a level number column be included?
7373 @item :sort
7374 A cons cell containing the column to sort and a sorting type.
7375 E.g., @samp{:sort (1 . ?a)} sorts the first column alphabetically.
7377 @item :compact
7378 Abbreviation for @samp{:level nil :indent t :narrow 40! :tcolumns 1}.
7379 All are overwritten except if there is an explicit @samp{:narrow}.
7381 @item :timestamp
7382 A timestamp for the entry, when available.  Look for SCHEDULED,
7383 DEADLINE, TIMESTAMP and TIMESTAMP_IA special properties (see
7384 @ref{Special Properties}), in this order.
7386 @item :properties
7387 List of properties shown in the table.  Each property gets its
7388 own column.
7390 @item :inherit-props
7391 When this flag is non-@code{nil}, the values for @samp{:properties} are
7392 inherited.
7394 @item :formula
7395 Content of a @samp{TBLFM} keyword to be added and evaluated.  As
7396 a special case, @samp{:formula %} adds a column with % time.  If you
7397 do not specify a formula here, any existing formula below the
7398 clock table survives updates and is evaluated.
7400 @item :formatter
7401 A function to format clock data and insert it into the buffer.
7402 @end table
7404 To get a clock summary of the current level 1 tree, for the current
7405 day, you could write:
7407 @example
7408 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
7409 #+END: clocktable
7410 @end example
7412 @noindent
7413 To use a specific time range you could write@footnote{Note that all parameters must be specified in a single
7414 line---the line is broken here only to fit it into the manual.}
7416 @example
7417 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
7418                     :tend "<2006-08-10 Thu 12:00>"
7419 #+END: clocktable
7420 @end example
7422 A range starting a week ago and ending right now could be written as
7424 @example
7425 #+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
7426 #+END: clocktable
7427 @end example
7429 A summary of the current subtree with % times would be:
7431 @example
7432 #+BEGIN: clocktable :scope subtree :link t :formula %
7433 #+END: clocktable
7434 @end example
7436 A horizontally compact representation of everything clocked during
7437 last week would be:
7439 @example
7440 #+BEGIN: clocktable :scope agenda :block lastweek :compact t
7441 #+END: clocktable
7442 @end example
7444 @node Resolving idle time
7445 @subsection Resolving idle time and continuous clocking
7449 @anchor{Resolving idle time (1)}
7450 @subsubheading Resolving idle time
7452 @cindex resolve idle time
7453 @cindex idle, resolve, dangling
7455 If you clock in on a work item, and then walk away from your
7456 computer---perhaps to take a phone call---you often need to
7457 ``resolve'' the time you were away by either subtracting it from the
7458 current clock, or applying it to another one.
7460 @vindex org-clock-idle-time
7461 @vindex org-clock-x11idle-program-name
7462 By customizing the variable @code{org-clock-idle-time} to some integer,
7463 such as 10 or 15, Emacs can alert you when you get back to your
7464 computer after being idle for that many minutes@footnote{On computers using macOS, idleness is based on actual user
7465 idleness, not just Emacs' idle time.  For X11, you can install
7466 a utility program @samp{x11idle.c}, available in the @samp{contrib/scripts/}
7467 directory of the Org Git distribution, or install the xprintidle
7468 package and set it to the variable @code{org-clock-x11idle-program-name} if
7469 you are running Debian, to get the same general treatment of idleness.
7470 On other systems, idle time refers to Emacs idle time only.}, and ask what
7471 you want to do with the idle time.  There will be a question waiting
7472 for you when you get back, indicating how much idle time has passed
7473 constantly updated with the current amount, as well as a set of
7474 choices to correct the discrepancy:
7476 @table @asis
7477 @item @kbd{k}
7478 @kindex k
7479 To keep some or all of the minutes and stay clocked in, press
7480 @kbd{k}.  Org asks how many of the minutes to keep.  Press
7481 @kbd{@key{RET}} to keep them all, effectively changing nothing, or
7482 enter a number to keep that many minutes.
7484 @item @kbd{K}
7485 @kindex K
7486 If you use the shift key and press @kbd{K}, it keeps however
7487 many minutes you request and then immediately clock out of that
7488 task.  If you keep all of the minutes, this is the same as just
7489 clocking out of the current task.
7491 @item @kbd{s}
7492 @kindex s
7493 To keep none of the minutes, use @kbd{s} to subtract all the
7494 away time from the clock, and then check back in from the moment
7495 you returned.
7497 @item @kbd{S}
7498 @kindex S
7499 To keep none of the minutes and just clock out at the start of
7500 the away time, use the shift key and press @kbd{S}.
7501 Remember that using shift always leave you clocked out, no matter
7502 which option you choose.
7504 @item @kbd{C}
7505 @kindex C
7506 To cancel the clock altogether, use @kbd{C}.  Note that if
7507 instead of canceling you subtract the away time, and the
7508 resulting clock amount is less than a minute, the clock is still
7509 canceled rather than cluttering up the log with an empty entry.
7510 @end table
7512 What if you subtracted those away minutes from the current clock, and
7513 now want to apply them to a new clock?  Simply clock in to any task
7514 immediately after the subtraction.  Org will notice that you have
7515 subtracted time ``on the books'', so to speak, and will ask if you want
7516 to apply those minutes to the next task you clock in on.
7518 There is one other instance when this clock resolution magic occurs.
7519 Say you were clocked in and hacking away, and suddenly your cat chased
7520 a mouse who scared a hamster that crashed into your UPS's power
7521 button!  You suddenly lose all your buffers, but thanks to auto-save
7522 you still have your recent Org mode changes, including your last clock
7525 If you restart Emacs and clock into any task, Org will notice that you
7526 have a dangling clock which was never clocked out from your last
7527 session.  Using that clock's starting time as the beginning of the
7528 unaccounted-for period, Org will ask how you want to resolve that
7529 time.  The logic and behavior is identical to dealing with away time
7530 due to idleness; it is just happening due to a recovery event rather
7531 than a set amount of idle time.
7533 You can also check all the files visited by your Org agenda for
7534 dangling clocks at any time using @kbd{M-x org-resolve-clocks @key{RET}} (or @kbd{C-c C-x C-z}).
7536 @anchor{Continuous clocking}
7537 @subsubheading Continuous clocking
7539 @cindex continuous clocking
7541 @vindex org-clock-continuously
7542 You may want to start clocking from the time when you clocked out the
7543 previous task.  To enable this systematically, set
7544 @code{org-clock-continuously} to non-@code{nil}.  Each time you clock in, Org
7545 retrieves the clock-out time of the last clocked entry for this
7546 session, and start the new clock from there.
7548 If you only want this from time to time, use three universal prefix
7549 arguments with @code{org-clock-in} and two @kbd{C-u C-u} with
7550 @code{org-clock-in-last}.
7552 @node Effort Estimates
7553 @section Effort Estimates
7555 @cindex effort estimates
7556 @cindex @samp{EFFORT}, property
7557 @vindex org-effort-property
7559 If you want to plan your work in a very detailed way, or if you need
7560 to produce offers with quotations of the estimated work effort, you
7561 may want to assign effort estimates to entries.  If you are also
7562 clocking your work, you may later want to compare the planned effort
7563 with the actual working time, a great way to improve planning
7564 estimates.  Effort estimates are stored in a special property
7565 @samp{EFFORT}.  You can set the effort for an entry with the following
7566 commands:
7568 @table @asis
7569 @item @kbd{C-c C-x e}  (@code{org-set-effort})
7570 @kindex C-c C-x e
7571 @findex org-set-effort
7572 Set the effort estimate for the current entry.  With a prefix
7573 argument, set it to the next allowed value---see below.  This
7574 command is also accessible from the agenda with the @kbd{e}
7575 key.
7577 @item @kbd{C-c C-x C-e} (@code{org-clock-modify-effort-estimate})
7578 @kindex C-c C-x C-e
7579 @findex org-clock-modify-effort-estimate
7580 Modify the effort estimate of the item currently being clocked.
7581 @end table
7583 Clearly the best way to work with effort estimates is through column
7584 view (see @ref{Column View}).  You should start by setting up discrete
7585 values for effort estimates, and a @samp{COLUMNS} format that displays
7586 these values together with clock sums---if you want to clock your
7587 time.  For a specific buffer you can use:
7589 @example
7590 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
7591 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
7592 @end example
7594 noindent
7595 @vindex org-global-properties
7596 @vindex org-columns-default-format
7597 or, even better, you can set up these values globally by customizing
7598 the variables @code{org-global-properties} and
7599 @code{org-columns-default-format}.  In particular if you want to use this
7600 setup also in the agenda, a global setup may be advised.
7602 The way to assign estimates to individual items is then to switch to
7603 column mode, and to use @kbd{S-@key{RIGHT}} and @kbd{S-@key{LEFT}} to
7604 change the value.  The values you enter are immediately summed up in
7605 the hierarchy.  In the column next to it, any clocked time is
7606 displayed.
7608 @vindex org-agenda-columns-add-appointments-to-effort-sum
7609 If you switch to column view in the daily/weekly agenda, the effort
7610 column summarizes the estimated work effort for each day@footnote{Please note the pitfalls of summing hierarchical data in
7611 a flat list (@ref{Agenda Column View}).}, and
7612 you can use this to find space in your schedule.  To get an overview
7613 of the entire part of the day that is committed, you can set the
7614 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
7615 appointments on a day that take place over a specified time interval
7616 are then also added to the load estimate of the day.
7618 Effort estimates can be used in secondary agenda filtering that is
7619 triggered with the @kbd{/} key in the agenda (see @ref{Agenda Commands}).  If you have these estimates defined consistently,
7620 two or three key presses narrow down the list to stuff that fits into
7621 an available time slot.
7623 @node Timers
7624 @section Taking Notes with a Relative Timer
7626 @cindex relative timer
7627 @cindex countdown timer
7629 Org provides two types of timers.  There is a relative timer that
7630 counts up, which can be useful when taking notes during, for example,
7631 a meeting or a video viewing.  There is also a countdown timer.
7633 The relative and countdown are started with separate commands.
7635 @table @asis
7636 @item @kbd{C-c C-x 0} (@code{org-timer-start})
7637 @kindex C-c C-x 0
7638 @findex org-timer-start
7639 Start or reset the relative timer.  By default, the timer is set
7640 to 0.  When called with a @kbd{C-u} prefix, prompt the user
7641 for a starting offset.  If there is a timer string at point, this
7642 is taken as the default, providing a convenient way to restart
7643 taking notes after a break in the process.  When called with
7644 a double prefix argument @kbd{C-u C-u}, change all timer
7645 strings in the active region by a certain amount.  This can be
7646 used to fix timer strings if the timer was not started at exactly
7647 the right moment.
7649 @item @kbd{C-c C-x ;} (@code{org-timer-set-timer})
7650 @kindex C-c C-x ;
7651 @findex org-timer-set-timer
7652 @vindex org-timer-default-timer
7653 Start a countdown timer.  The user is prompted for a duration.
7654 @code{org-timer-default-timer} sets the default countdown value.
7655 Giving a numeric prefix argument overrides this default value.
7656 This command is available as @kbd{;} in agenda buffers.
7657 @end table
7659 Once started, relative and countdown timers are controlled with the
7660 same commands.
7662 @table @asis
7663 @item @kbd{C-c C-x .} (@code{org-timer})
7664 @kindex C-c C-x .
7665 @findex org-timer
7666 Insert a relative time into the buffer.  The first time you use
7667 this, the timer starts.  Using a prefix argument restarts it.
7669 @item @kbd{C-c C-x -} (@code{org-timer-item})
7670 @kindex C-c C-x -
7671 @findex org-timer-item
7672 Insert a description list item with the current relative time.
7673 With a prefix argument, first reset the timer to 0.
7675 @item @kbd{M-@key{RET}} (@code{org-insert-heading})
7676 @kindex M-RET
7677 @findex org-insert-heading
7678 Once the timer list is started, you can also use
7679 @kbd{M-@key{RET}} to insert new timer items.
7681 @item @kbd{C-c C-x ,} (@code{org-timer-pause-or-continue})
7682 @kindex C-c C-x ,
7683 @findex org-timer-pause-or-continue
7684 Pause the timer, or continue it if it is already paused.
7686 @item @kbd{C-c C-x _} (@code{org-timer-stop})
7687 @kindex C-c C-x _
7688 @findex org-timer-stop
7689 Stop the timer.  After this, you can only start a new timer, not
7690 continue the old one.  This command also removes the timer from
7691 the mode line.
7692 @end table
7694 @node Capture Refile Archive
7695 @chapter Capture, Refile, Archive
7697 @cindex capture
7699 An important part of any organization system is the ability to quickly
7700 capture new ideas and tasks, and to associate reference material with
7701 them.  Org does this using a process called @emph{capture}.  It also can
7702 store files related to a task (@emph{attachments}) in a special directory.
7703 Once in the system, tasks and projects need to be moved around.
7704 Moving completed project trees to an archive file keeps the system
7705 compact and fast.
7707 @menu
7708 * Capture::                      Capturing new stuff.
7709 * Attachments::                  Add files to tasks.
7710 * RSS Feeds::                    Getting input from RSS feeds.
7711 * Protocols::                    External access to Emacs and Org.
7712 * Refile and Copy::              Moving/copying a tree from one place to another.
7713 * Archiving::                    What to do with finished products.
7714 @end menu
7716 @node Capture
7717 @section Capture
7719 @cindex capture
7721 Capture lets you quickly store notes with little interruption of your
7722 work flow.  Org's method for capturing new items is heavily inspired
7723 by John Wiegley's excellent Remember package.
7725 @menu
7726 * Setting up capture::           Where notes will be stored.
7727 * Using capture::                Commands to invoke and terminate capture.
7728 * Capture templates::            Define the outline of different note types.
7729 @end menu
7731 @node Setting up capture
7732 @subsection Setting up capture
7734 The following customization sets a default target file for notes.
7736 @vindex org-default-notes-file
7737 @lisp
7738 (setq org-default-notes-file (concat org-directory "/notes.org"))
7739 @end lisp
7741 You may also define a global key for capturing new material (see
7742 @ref{Activation}).
7744 @node Using capture
7745 @subsection Using capture
7747 @table @asis
7748 @item @kbd{M-x org-capture} (@code{org-capture})
7749 @findex org-capture
7750 @cindex date tree
7751 Display the capture templates menu.  If you have templates
7752 defined (see @ref{Capture templates}), it offers these templates for
7753 selection or use a new Org outline node as the default template.
7754 It inserts the template into the target file and switch to an
7755 indirect buffer narrowed to this new node.  You may then insert
7756 the information you want.
7758 @item @kbd{C-c C-c} (@code{org-capture-finalize})
7759 @kindex C-c C-c @r{(Capture buffer)}
7760 @findex org-capture-finalize
7761 Once you have finished entering information into the capture
7762 buffer, @kbd{C-c C-c} returns you to the window
7763 configuration before the capture process, so that you can resume
7764 your work without further distraction.  When called with a prefix
7765 argument, finalize and then jump to the captured item.
7767 @item @kbd{C-c C-w} (@code{org-capture-refile})
7768 @kindex C-c C-w @r{(Capture buffer)}
7769 @findex org-capture-refile
7770 Finalize the capture process by refiling the note to a different
7771 place (see @ref{Refile and Copy}).  Please realize that this is
7772 a normal refiling command that will be executed---so the cursor
7773 position at the moment you run this command is important.  If you
7774 have inserted a tree with a parent and children, first move the
7775 cursor back to the parent.  Any prefix argument given to this
7776 command is passed on to the @code{org-refile} command.
7778 @item @kbd{C-c C-k} (@code{org-capture-kill})
7779 @kindex C-c C-k @r{(Capture buffer)}
7780 @findex org-capture-kill
7781 Abort the capture process and return to the previous state.
7782 @end table
7784 @kindex k c @r{(Agenda)}
7785 You can also call @code{org-capture} in a special way from the agenda,
7786 using the @kbd{k c} key combination.  With this access, any
7787 timestamps inserted by the selected capture template defaults to the
7788 cursor date in the agenda, rather than to the current date.
7790 To find the locations of the last stored capture, use @code{org-capture}
7791 with prefix commands:
7793 @table @asis
7794 @item @kbd{C-u M-x org-capture}
7795 Visit the target location of a capture template.  You get to
7796 select the template in the usual way.
7798 @item @kbd{C-u C-u M-x org-capture}
7799 Visit the last stored capture item in its buffer.
7800 @end table
7802 @vindex org-capture-bookmark
7803 @vindex org-capture-last-stored
7804 You can also jump to the bookmark @code{org-capture-last-stored}, which is
7805 automatically created unless you set @code{org-capture-bookmark} to @code{nil}.
7807 To insert the capture at point in an Org buffer, call @code{org-capture}
7808 with a @code{C-0} prefix argument.
7810 @node Capture templates
7811 @subsection Capture templates
7813 @cindex templates, for Capture
7815 You can use templates for different types of capture items, and for
7816 different target locations.  The easiest way to create such templates
7817 is through the customize interface.
7819 @table @asis
7820 @item @kbd{C}
7821 @kindex C @r{(Capture menu}
7822 @vindex org-capture-templates
7823 Customize the variable @code{org-capture-templates}.
7824 @end table
7826 Before we give the formal description of template definitions, let's
7827 look at an example.  Say you would like to use one template to create
7828 general TODO entries, and you want to put these entries under the
7829 heading @samp{Tasks} in your file @samp{~/org/gtd.org}.  Also, a date tree in
7830 the file @samp{journal.org} should capture journal entries.  A possible
7831 configuration would look like:
7833 @lisp
7834 (setq org-capture-templates
7835       '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
7836          "* TODO %?\n  %i\n  %a")
7837         ("j" "Journal" entry (file+datetree "~/org/journal.org")
7838          "* %?\nEntered on %U\n  %i\n  %a")))
7839 @end lisp
7841 @noindent
7842 If you then press @kbd{t} from the capture menu, Org will prepare
7843 the template for you like this:
7845 @example
7846 * TODO
7847   [[file:LINK TO WHERE YOU INITIATED CAPTURE]]
7848 @end example
7850 @noindent
7851 During expansion of the template, @code{%a} has been replaced by a link to
7852 the location from where you called the capture command.  This can be
7853 extremely useful for deriving tasks from emails, for example.  You
7854 fill in the task definition, press @kbd{C-c C-c} and Org returns
7855 you to the same place where you started the capture process.
7857 To define special keys to capture to a particular template without
7858 going through the interactive template selection, you can create your
7859 key binding like this:
7861 @lisp
7862 (define-key global-map "\C-cx"
7863   (lambda () (interactive) (org-capture nil "x")))
7864 @end lisp
7866 @menu
7867 * Template elements::            What is needed for a complete template entry.
7868 * Template expansion::           Filling in information about time and context.
7869 * Templates in contexts::        Only show a template in a specific context.
7870 @end menu
7872 @node Template elements
7873 @subsubsection Template elements
7875 Now lets look at the elements of a template definition.  Each entry in
7876 @code{org-capture-templates} is a list with the following items:
7878 @table @asis
7879 @item keys
7880 The keys that selects the template, as a string, characters only,
7881 for example @samp{"a"}, for a template to be selected with a single
7882 key, or @samp{"bt"} for selection with two keys.  When using several
7883 keys, keys using the same prefix key must be sequential in the
7884 list and preceded by a 2-element entry explaining the prefix key,
7885 for example:
7887 @lisp
7888 ("b" "Templates for marking stuff to buy")
7889 @end lisp
7891 @noindent
7892 If you do not define a template for the @kbd{C} key, this
7893 key opens the Customize buffer for this complex variable.
7895 @item description
7896 A short string describing the template, shown during selection.
7898 @item type
7899 The type of entry, a symbol.  Valid values are:
7901 @table @asis
7902 @item @code{entry}
7903 An Org mode node, with a headline.  Will be filed as the child
7904 of the target entry or as a top-level entry.  The target file
7905 should be an Org file.
7907 @item @code{item}
7908 A plain list item, placed in the first plain list at the
7909 target location.  Again the target file should be an Org
7910 file.
7912 @item @code{checkitem}
7913 A checkbox item.  This only differs from the plain list item
7914 by the default template.
7916 @item @code{table-line}
7917 A new line in the first table at the target location.  Where
7918 exactly the line will be inserted depends on the properties
7919 @code{:prepend} and @code{:table-line-pos} (see below).
7921 @item @code{plain}
7922 Text to be inserted as it is.
7923 @end table
7925 @item target
7926 @vindex org-default-notes-file
7927 @vindex org-directory
7928 Specification of where the captured item should be placed.  In
7929 Org files, targets usually define a node.  Entries will become
7930 children of this node.  Other types will be added to the table or
7931 list in the body of this node.  Most target specifications
7932 contain a file name.  If that file name is the empty string, it
7933 defaults to @code{org-default-notes-file}.  A file can also be given
7934 as a variable or as a function called with no argument.  When an
7935 absolute path is not specified for a target, it is taken as
7936 relative to @code{org-directory}.
7938 Valid values are:
7940 @table @asis
7941 @item @samp{(file "path/to/file")}
7942 Text will be placed at the beginning or end of that file.
7944 @item @samp{(id "id of existing org entry")}
7945 Filing as child of this entry, or in the body of the entry.
7947 @item @samp{(file+headline "filename" "node headline")}
7948 Fast configuration if the target heading is unique in the file.
7950 @item @samp{(file+olp "filename" "Level 1 heading" "Level 2" ...)}
7951 For non-unique headings, the full path is safer.
7953 @item @samp{(file+regexp "filename" "regexp to find location")}
7954 Use a regular expression to position the cursor.
7956 @item @samp{(file+olp+datetree "filename" [ "Level 1 heading" ...])}
7957 This target@footnote{Org used to offer four different targets for date/week tree
7958 capture.  Now, Org automatically translates these to use
7959 @code{file+olp+datetree}, applying the @code{:time-prompt} and @code{:tree-type}
7960 properties.  Please rewrite your date/week-tree targets using
7961 @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
7962 level, months or ISO weeks as sublevels and then dates on the lowest
7963 level.  Tags are allowed in the tree structure.} for
7964 today's date.  If the optional outline path is given, the tree
7965 will be built under the node it is pointing to, instead of at
7966 top level.  Check out the @code{:time-prompt} and @code{:tree-type}
7967 properties below for additional options.
7969 @item @code{(file+function "filename" function-finding-location)}
7970 A function to find the right location in the file.
7972 @item @code{(clock)}
7973 File to the entry that is currently being clocked.
7975 @item @code{(function function-finding-location)}
7976 Most general way: write your own function which both visits the
7977 file and moves point to the right location.
7978 @end table
7980 @item template
7981 The template for creating the capture item.  If you leave this
7982 empty, an appropriate default template will be used.  Otherwise
7983 this is a string with escape codes, which will be replaced
7984 depending on time and context of the capture call.  The string
7985 with escapes may be loaded from a template file, using the
7986 special syntax @samp{(file "template filename")}.  See below for more
7987 details.
7989 @item properties
7990 The rest of the entry is a property list of additional options.
7991 Recognized properties are:
7993 @table @asis
7994 @item @code{:prepend}
7995 Normally new captured information will be appended at the
7996 target location (last child, last table line, last list item,
7997 @dots{}).  Setting this property changes that.
7999 @item @code{:immediate-finish}
8000 When set, do not offer to edit the information, just file it
8001 away immediately.  This makes sense if the template only needs
8002 information that can be added automatically.
8004 @item @code{:empty-lines}
8005 Set this to the number of lines to insert before and after the
8006 new item.  Default 0, and the only other common value is 1.
8008 @item @code{:clock-in}
8009 Start the clock in this item.
8011 @item @code{:clock-keep}
8012 Keep the clock running when filing the captured entry.
8014 @item @code{:clock-resume}
8015 If starting the capture interrupted a clock, restart that clock
8016 when finished with the capture.  Note that @code{:clock-keep} has
8017 precedence over @code{:clock-resume}.  When setting both to
8018 non-@code{nil}, the current clock will run and the previous one will
8019 not be resumed.
8021 @item @code{:time-prompt}
8022 Prompt for a date/time to be used for date/week trees and when
8023 filling the template.  Without this property, capture uses the
8024 current date and time.  Even if this property has not been set,
8025 you can force the same behavior by calling @code{org-capture} with
8026 a @kbd{C-1} prefix argument.
8028 @item @code{:tree-type}
8029 When @code{week}, make a week tree instead of the month tree, i.e.,
8030 place the headings for each day under a heading with the
8031 current ISO week.
8033 @item @code{:unnarrowed}
8034 Do not narrow the target buffer, simply show the full buffer.  Default
8035 is to narrow it so that you only see the new material.
8037 @item @code{:table-line-pos}
8038 Specification of the location in the table where the new line
8039 should be inserted.  It should be a string like @samp{II-3} meaning
8040 that the new line should become the third line before the
8041 second horizontal separator line.
8043 @item @code{:kill-buffer}
8044 If the target file was not yet visited when capture was invoked, kill
8045 the buffer again after capture is completed.
8046 @end table
8047 @end table
8049 @node Template expansion
8050 @subsubsection Template expansion
8052 In the template itself, special ``%-escapes''@footnote{If you need one of these sequences literally, escape the @samp{%}
8053 with a backslash.} allow dynamic
8054 insertion of content.  The templates are expanded in the order given
8055 here:
8057 @table @asis
8058 @item @code{%[FILE]}
8059 Insert the contents of the file given by @var{FILE}.
8061 @item @code{%(SEXP)}
8062 Evaluate Elisp SEXP and replace with the result.  The
8063 @var{SEXP} must return a string.
8065 @item @code{%<FORMAT>}
8066 The result of format-time-string on the @var{FORMAT}
8067 specification.
8069 @item @code{%t}
8070 Timestamp, date only.
8072 @item @code{%T}
8073 Timestamp, with date and time.
8075 @item @code{%u}, @code{%U}
8076 Like @code{%t}, @code{%T} above, but inactive timestamps.
8078 @item @code{%i}
8079 Initial content, the region when capture is called while the
8080 region is active.  The entire text will be indented like @code{%i}
8081 itself.
8083 @item @code{%a}
8084 Annotation, normally the link created with @code{org-store-link}.
8086 @item @code{%A}
8087 Like @code{%a}, but prompt for the description part.
8089 @item @code{%l}
8090 Like @code{%a}, but only insert the literal link.
8092 @item @code{%c}
8093 Current kill ring head.
8095 @item @code{%x}
8096 Content of the X clipboard.
8098 @item @code{%k}
8099 Title of the currently clocked task.
8101 @item @code{%K}
8102 Link to the currently clocked task.
8104 @item @code{%n}
8105 User name (taken from @code{user-full-name}).
8107 @item @code{%f}
8108 File visited by current buffer when org-capture was called.
8110 @item @code{%F}
8111 Full path of the file or directory visited by current buffer.
8113 @item @code{%:keyword}
8114 Specific information for certain link types, see below.
8116 @item @code{%^g}
8117 Prompt for tags, with completion on tags in target file.
8119 @item @code{%^G}
8120 Prompt for tags, with completion all tags in all agenda files.
8122 @item @code{%^t}
8123 Like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}.  You may
8124 define a prompt like @code{%^@{Birthday@}t}.
8126 @item @code{%^C}
8127 Interactive selection of which kill or clip to use.
8129 @item @code{%^L}
8130 Like @code{%^C}, but insert as link.
8132 @item @code{%^@{PROP@}p}
8133 Prompt the user for a value for property PROP.
8135 @item @code{%^@{PROMPT@}}
8136 Prompt the user for a string and replace this sequence with it.
8137 You may specify a default value and a completion table with
8138 @code{%^@{prompt|default|completion2|completion3...@}}.  The arrow keys
8139 access a prompt-specific history.
8141 @item @code{%\n}
8142 Insert the text entered at the Nth @code{%^@{PROMPT@}}, where N is
8143 a number, starting from 1.
8145 @item @code{%?}
8146 After completing the template, position cursor here.
8147 @end table
8149 @noindent
8150 @vindex org-store-link-props
8151 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
8152 accessed in capture templates in a similar way.}:
8154 @vindex org-from-is-user-regexp
8155 @multitable {aaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
8156 @headitem Link type
8157 @tab Available keywords
8158 @item bbdb
8159 @tab @code{%:name}, @code{%:company}
8160 @item irc
8161 @tab @code{%:server}, @code{%:port}, @code{%:nick}
8162 @item mh, rmail
8163 @tab @code{%:type}, @code{%:subject}, @code{%:message-id}
8164 @item 
8165 @tab @code{%:from}, @code{%:fromname}, @code{%:fromaddress}
8166 @item 
8167 @tab @code{%:to}, @code{%:toname}, @code{%:toaddress}
8168 @item 
8169 @tab @code{%:date} (message date header field)
8170 @item 
8171 @tab @code{%:date-timestamp} (date as active timestamp)
8172 @item 
8173 @tab @code{%:date-timestamp-inactive} (date as inactive timestamp)
8174 @item 
8175 @tab @code{%:fromto} (either ``to NAME'' or ``from NAME'')@footnote{This is always the other, not the user.  See the variable
8176 @code{org-from-is-user-regexp}.}
8177 @item gnus
8178 @tab @code{%:group}, for messages also all email fields
8179 @item w3, w3m
8180 @tab @code{%:url}
8181 @item info
8182 @tab @code{%:file}, @code{%:node}
8183 @item calendar
8184 @tab @code{%:date}
8185 @item org-protocol
8186 @tab @code{%:link}, @code{%:description}, @code{%:annotation}
8187 @end multitable
8189 @node Templates in contexts
8190 @subsubsection Templates in contexts
8192 @vindex org-capture-templates-contexts
8193 To control whether a capture template should be accessible from
8194 a specific context, you can customize
8195 @code{org-capture-templates-contexts}.  Let's say, for example, that you
8196 have a capture template ``p'' for storing Gnus emails containing
8197 patches.  Then you would configure this option like this:
8199 @lisp
8200 (setq org-capture-templates-contexts
8201       '(("p" (in-mode . "message-mode"))))
8202 @end lisp
8204 You can also tell that the command key @kbd{p} should refer to
8205 another template.  In that case, add this command key like this:
8207 @lisp
8208 (setq org-capture-templates-contexts
8209       '(("p" "q" (in-mode . "message-mode"))))
8210 @end lisp
8212 See the docstring of the variable for more information.
8214 @node Attachments
8215 @section Attachments
8217 @cindex attachments
8218 @vindex org-attach-directory
8220 It is often useful to associate reference material with an outline
8221 node/task.  Small chunks of plain text can simply be stored in the
8222 subtree of a project.  Hyperlinks (see @ref{Hyperlinks}) can establish
8223 associations with files that live elsewhere on your computer or in the
8224 cloud, like emails or source code files belonging to a project.
8225 Another method is @emph{attachments}, which are files located in
8226 a directory belonging to an outline node.  Org uses directories named
8227 by the unique ID of each entry.  These directories are located in the
8228 @code{data} directory which lives in the same directory where your Org file
8229 lives@footnote{If you move entries or Org files from one directory to
8230 another, you may want to configure @code{org-attach-directory} to contain
8231 an absolute path.}.  If you initialize this directory with @samp{git init}, Org
8232 automatically commits changes when it sees them.  The attachment
8233 system has been contributed to Org by John Wiegley.
8235 In cases where it seems better to do so, you can attach a directory of
8236 your choice to an entry.  You can also make children inherit the
8237 attachment directory from a parent, so that an entire subtree uses the
8238 same attached directory.
8240 @noindent
8241 The following commands deal with attachments:
8243 @table @asis
8244 @item @kbd{C-c C-a} (@code{org-attach})
8245 @kindex C-c C-a
8246 @findex org-attach
8247 The dispatcher for commands related to the attachment system.
8248 After these keys, a list of commands is displayed and you must
8249 press an additional key to select a command:
8251 @table @asis
8252 @item @kbd{a} (@code{org-attach-attach})
8253 @kindex C-c C-a a
8254 @findex org-attach-attach
8255 @vindex org-attach-method
8256 Select a file and move it into the task's attachment
8257 directory.  The file is copied, moved, or linked, depending
8258 on @code{org-attach-method}.  Note that hard links are not
8259 supported on all systems.
8261 @item @kbd{c}/@kbd{m}/@kbd{l}
8262 @kindex C-c C-a c
8263 @kindex C-c C-a m
8264 @kindex C-c C-a l
8265 Attach a file using the copy/move/link method.  Note that
8266 hard links are not supported on all systems.
8268 @item @kbd{n} (@code{org-attach-new})
8269 @kindex C-c C-a n
8270 @findex org-attach-new
8271 Create a new attachment as an Emacs buffer.
8273 @item @kbd{z} (@code{org-attach-sync})
8274 @kindex C-c C-a z
8275 @findex org-attach-sync
8276 Synchronize the current task with its attachment directory, in case
8277 you added attachments yourself.
8279 @item @kbd{o} (@code{org-attach-open})
8280 @kindex C-c C-a o
8281 @findex org-attach-open
8282 @vindex org-file-apps
8283 Open current task's attachment.  If there is more than one,
8284 prompt for a file name first.  Opening follows the rules set
8285 by @code{org-file-apps}.  For more details, see the information
8286 on following hyperlinks (see @ref{Handling Links}).
8288 @item @kbd{O} (@code{org-attach-open-in-emacs})
8289 @kindex C-c C-a O
8290 @findex org-attach-open-in-emacs
8291 Also open the attachment, but force opening the file in
8292 Emacs.
8294 @item @kbd{f} (@code{org-attach-reveal})
8295 @kindex C-c C-a f
8296 @findex org-attach-reveal
8297 Open the current task's attachment directory.
8299 @item @kbd{F} (@code{org-attach-reveal-in-emacs})
8300 @kindex C-c C-a F
8301 @findex org-attach-reveal-in-emacs
8302 Also open the directory, but force using Dired in Emacs.
8304 @item @kbd{d} (@code{org-attach-delete-one})
8305 @kindex C-c C-a d
8306 Select and delete a single attachment.
8308 @item @kbd{D} (@code{org-attach-delete-all})
8309 @kindex C-c C-a D
8310 Delete all of a task's attachments.  A safer way is to open
8311 the directory in Dired and delete from there.
8313 @item @kbd{s} (@code{org-attach-set-directory})
8314 @kindex C-c C-a s
8315 @cindex @samp{ATTACH_DIR}, property
8316 Set a specific directory as the entry's attachment
8317 directory.  This works by putting the directory path into
8318 the @samp{ATTACH_DIR} property.
8320 @item @kbd{i} (@code{org-attach-set-inherit})
8321 @kindex C-c C-a i
8322 @cindex @samp{ATTACH_DIR_INHERIT}, property
8323 Set the @samp{ATTACH_DIR_INHERIT} property, so that children use
8324 the same directory for attachments as the parent does.
8325 @end table
8326 @end table
8328 @cindex attach from Dired
8329 @findex org-attach-dired-to-subtree
8330 It is possible to attach files to a subtree from a Dired buffer.  To
8331 use this feature, have one window in Dired mode containing the file(s)
8332 to be attached and another window with point in the subtree that shall
8333 get the attachments.  In the Dired window, with point on a file,
8334 @kbd{M-x org-attach-dired-to-subtree} attaches the file to the
8335 subtree using the attachment method set by variable
8336 @code{org-attach-method}.  When files are marked in the Dired window then
8337 all marked files get attached.
8339 Add the following lines to the Emacs init file to have @kbd{C-c C-x a} attach files in Dired buffers.
8341 @lisp
8342 (add-hook 'dired-mode-hook
8343           (lambda ()
8344             (define-key dired-mode-map
8345               (kbd "C-c C-x a")
8346               #'org-attach-dired-to-subtree))))
8347 @end lisp
8349 The following code shows how to bind the previous command with
8350 a specific attachment method.
8352 @lisp
8353 (add-hook 'dired-mode-hook
8354           (lambda ()
8355             (define-key dired-mode-map (kbd "C-c C-x c")
8356               (lambda ()
8357                 (interactive)
8358                 (let ((org-attach-method 'cp))
8359                   (call-interactively #'org-attach-dired-to-subtree))))))
8360 @end lisp
8362 @node RSS Feeds
8363 @section RSS Feeds
8365 @cindex RSS feeds
8366 @cindex Atom feeds
8368 Org can add and change entries based on information found in RSS feeds
8369 and Atom feeds.  You could use this to make a task out of each new
8370 podcast in a podcast feed.  Or you could use a phone-based
8371 note-creating service on the web to import tasks into Org.  To access
8372 feeds, configure the variable @code{org-feed-alist}.  The docstring of this
8373 variable has detailed information.  With the following
8375 @lisp
8376 (setq org-feed-alist
8377       '(("Slashdot"
8378          "http://rss.slashdot.org/Slashdot/slashdot"
8379          "~/txt/org/feeds.org" "Slashdot Entries")))
8380 @end lisp
8382 @noindent
8383 new items from the feed provided by @samp{rss.slashdot.org} result in new
8384 entries in the file @samp{~/org/feeds.org} under the heading @samp{Slashdot
8385 Entries}, whenever the following command is used:
8387 @table @asis
8388 @item @kbd{C-c C-x g} (@code{org-feed-update-all})
8389 @kindex C-c C-x g
8390 Collect items from the feeds configured in @code{org-feed-alist} and
8391 act upon them.
8393 @item @kbd{C-c C-x G} (@code{org-feed-goto-inbox})
8394 @kindex C-c C-x G
8395 Prompt for a feed name and go to the inbox configured for this feed.
8396 @end table
8398 Under the same headline, Org creates a drawer @samp{FEEDSTATUS} in which it
8399 stores information about the status of items in the feed, to avoid
8400 adding the same item several times.
8402 For more information, including how to read atom feeds, see
8403 @samp{org-feed.el} and the docstring of @code{org-feed-alist}.
8405 @node Protocols
8406 @section Protocols for External Access
8408 @cindex protocols, for external access
8410 Org protocol is a means to trigger custom actions in Emacs from
8411 external applications.  Any application that supports calling external
8412 programs with an URL as argument may be used with this functionality.
8413 For example, you can configure bookmarks in your web browser to send
8414 a link to the current page to Org and create a note from it using
8415 capture (see @ref{Capture}).  You can also create a bookmark that tells
8416 Emacs to open the local source file of a remote website you are
8417 browsing.
8419 @cindex Org protocol, set-up
8420 @cindex Installing Org protocol
8421 In order to use Org protocol from an application, you need to register
8422 @samp{org-protocol://} as a valid scheme-handler.  External calls are
8423 passed to Emacs through the @samp{emacsclient} command, so you also need to
8424 ensure an Emacs server is running.  More precisely, when the
8425 application calls
8427 @example
8428 emacsclient org-protocol://PROTOCOL?key1=val1&key2=val2
8429 @end example
8431 @noindent
8432 Emacs calls the handler associated to @var{PROTOCOL} with
8433 argument @samp{(:key1 val1 :key2 val2)}.
8435 @cindex protocol, new protocol
8436 @cindex defining new protocols
8437 Org protocol comes with three predefined protocols, detailed in the
8438 following sections.  Configure @code{org-protocol-protocol-alist} to define
8439 your own.
8441 @menu
8442 * @code{store-link} protocol::   Store a link, push URL to kill-ring.
8443 * @code{capture} protocol::      Fill a buffer with external information.
8444 * @code{open-source} protocol::  Edit published contents.
8445 @end menu
8447 @node @code{store-link} protocol
8448 @subsection @code{store-link} protocol
8450 @cindex store-link protocol
8451 @cindex protocol, store-link
8453 Using @code{store-link} handler, you can copy links, insertable through
8454 @kbd{M-x org-insert-link} or yanking thereafter.  More precisely,
8455 the command
8457 @example
8458 emacsclient org-protocol://store-link?url=URL&title=TITLE
8459 @end example
8461 @noindent
8462 stores the following link:
8464 @example
8465 [[URL][TITLE]]
8466 @end example
8468 In addition, @var{URL} is pushed on the kill-ring for yanking.
8469 You need to encode @var{URL} and @var{TITLE} if they contain
8470 slashes, and probably quote those for the shell.
8472 To use this feature from a browser, add a bookmark with an arbitrary
8473 name, e.g., @samp{Org: store-link} and enter this as @emph{Location}:
8475 @example
8476 javascript:location.href='org-protocol://store-link?url='+
8477       encodeURIComponent(location.href);
8478 @end example
8480 @node @code{capture} protocol
8481 @subsection @code{capture} protocol
8483 @cindex capture protocol
8484 @cindex protocol, capture
8486 Activating ``capture'' handler pops up a @samp{Capture} buffer and fills the
8487 capture template associated to the @samp{X} key with them.
8489 @example
8490 emacsclient org-protocol://capture?template=X?url=URL?title=TITLE?body=BODY
8491 @end example
8493 To use this feature, add a bookmark with an arbitrary name, e.g.
8494 @samp{Org: capture} and enter this as @samp{Location}:
8496 @example
8497 javascript:location.href='org-protocol://capture?template=x'+
8498       '&url='+encodeURIComponent(window.location.href)+
8499       '&title='+encodeURIComponent(document.title)+
8500       '&body='+encodeURIComponent(window.getSelection());
8501 @end example
8503 @vindex org-protocol-default-template-key
8504 The result depends on the capture template used, which is set in the
8505 bookmark itself, as in the example above, or in
8506 @code{org-protocol-default-template-key}.
8508 The following template placeholders are available:
8510 @example
8511 %:link          The URL
8512 %:description   The webpage title
8513 %:annotation    Equivalent to [[%:link][%:description]]
8514 %i              The selected text
8515 @end example
8517 @node @code{open-source} protocol
8518 @subsection @code{open-source} protocol
8520 @cindex open-source protocol
8521 @cindex protocol, open-source
8523 The @code{open-source} handler is designed to help with editing local
8524 sources when reading a document.  To that effect, you can use
8525 a bookmark with the following location:
8527 @example
8528 javascript:location.href='org-protocol://open-source?&url='+
8529       encodeURIComponent(location.href)
8530 @end example
8532 @vindex org-protocol-project-alist
8533 The variable @code{org-protocol-project-alist} maps URLs to local file
8534 names, by stripping URL parameters from the end and replacing the
8535 @code{:base-url} with @code{:working-directory} and @code{:online-suffix} with
8536 @code{:working-suffix}.  For example, assuming you own a local copy of
8537 @samp{https://orgmode.org/worg/} contents at @samp{/home/user/worg}, you can set
8538 @code{org-protocol-project-alist} to the following
8540 @lisp
8541 (setq org-protocol-project-alist
8542       '(("Worg"
8543          :base-url "https://orgmode.org/worg/"
8544          :working-directory "/home/user/worg/"
8545          :online-suffix ".html"
8546          :working-suffix ".org")))
8547 @end lisp
8549 @noindent
8550 If you are now browsing
8551 @samp{https://orgmode.org/worg/org-contrib/org-protocol.html} and find
8552 a typo or have an idea about how to enhance the documentation, simply
8553 click the bookmark and start editing.
8555 @cindex rewritten URL in open-source protocol
8556 @cindex protocol, open-source rewritten URL
8557 However, such mapping may not yield the desired results.  Suppose you
8558 maintain an online store located at @samp{http://example.com/}.  The local
8559 sources reside in @samp{/home/user/example/}.  It is common practice to
8560 serve all products in such a store through one file and rewrite URLs
8561 that do not match an existing file on the server.  That way, a request
8562 to @samp{http://example.com/print/posters.html} might be rewritten on the
8563 server to something like
8564 @samp{http://example.com/shop/products.php/posters.html.php}.  The
8565 @code{open-source} handler probably cannot find a file named
8566 @samp{/home/user/example/print/posters.html.php} and fails.
8568 Such an entry in @code{org-protocol-project-alist} may hold an additional
8569 property @code{:rewrites}.  This property is a list of cons cells, each of
8570 which maps a regular expression to a path relative to the
8571 @code{:working-directory}.
8573 Now map the URL to the path @samp{/home/user/example/products.php} by
8574 adding @code{:rewrites} rules like this:
8576 @lisp
8577 (setq org-protocol-project-alist
8578       '(("example.com"
8579          :base-url "http://example.com/"
8580          :working-directory "/home/user/example/"
8581          :online-suffix ".php"
8582          :working-suffix ".php"
8583          :rewrites (("example.com/print/" . "products.php")
8584                     ("example.com/$" . "index.php")))))
8585 @end lisp
8587 @noindent
8588 Since @samp{example.com/$} is used as a regular expression, it maps
8589 @samp{http://example.com/}, @samp{https://example.com},
8590 @samp{http://www.example.com/} and similar to
8591 @samp{/home/user/example/index.php}.
8593 The @code{:rewrites} rules are searched as a last resort if and only if no
8594 existing file name is matched.
8596 @cindex protocol, open-source, set-up mapping
8597 @cindex mappings in open-source protocol
8598 @findex org-protocol-create
8599 @findex org-protocol-create-for-org
8600 Two functions can help you filling @code{org-protocol-project-alist} with
8601 valid contents: @code{org-protocol-create} and
8602 @code{org-protocol-create-for-org}.  The latter is of use if you're editing
8603 an Org file that is part of a publishing project.
8605 @node Refile and Copy
8606 @section Refile and Copy
8608 @cindex refiling notes
8609 @cindex copying notes
8611 When reviewing the captured data, you may want to refile or to copy
8612 some of the entries into a different list, for example into a project.
8613 Cutting, finding the right location, and then pasting the note is
8614 cumbersome.  To simplify this process, you can use the following
8615 special command:
8617 @table @asis
8618 @item @kbd{C-c M-w} (@code{org-copy})
8619 @kindex C-c M-w
8620 @findex org-copy
8621 Copying works like refiling, except that the original note is not
8622 deleted.
8624 @item @kbd{C-c C-w} (@code{org-refile})
8625 @kindex C-c C-w
8626 @findex org-refile
8627 @vindex org-reverse-note-order
8628 @vindex org-refile-targets
8629 @vindex org-refile-use-outline-path
8630 @vindex org-outline-path-complete-in-steps
8631 @vindex org-refile-allow-creating-parent-nodes
8632 @vindex org-log-refile
8633 Refile the entry or region at point.  This command offers
8634 possible locations for refiling the entry and lets you select one
8635 with completion.  The item (or all items in the region) is filed
8636 below the target heading as a subitem.  Depending on
8637 @code{org-reverse-note-order}, it is either the first or last subitem.
8639 By default, all level 1 headlines in the current buffer are
8640 considered to be targets, but you can have more complex
8641 definitions across a number of files.  See the variable
8642 @code{org-refile-targets} for details.  If you would like to select
8643 a location via a file-path-like completion along the outline
8644 path, see the variables @code{org-refile-use-outline-path} and
8645 @code{org-outline-path-complete-in-steps}.  If you would like to be
8646 able to create new nodes as new parents for refiling on the fly,
8647 check the variable @code{org-refile-allow-creating-parent-nodes}.
8648 When the variable @code{org-log-refile}@footnote{Note the corresponding @samp{STARTUP} options @samp{logrefile},
8649 @samp{lognoterefile}, and @samp{nologrefile}.} is set, a timestamp or
8650 a note is recorded whenever an entry is refiled.
8652 @item @kbd{C-u C-c C-w}
8653 @kindex C-u C-c C-w
8654 Use the refile interface to jump to a heading.
8656 @item @kbd{C-u C-u C-c C-w} (@code{org-refile-goto-last-stored})
8657 @kindex C-u C-u C-c C-w
8658 @findex org-refile-goto-last-stored
8659 Jump to the location where @code{org-refile} last moved a tree to.
8661 @item @kbd{C-2 C-c C-w}
8662 @kindex C-2 C-c C-w
8663 Refile as the child of the item currently being clocked.
8665 @item @kbd{C-3 C-c C-w}
8666 @kindex C-3 C-c C-w
8667 @vindex org-refile-keep
8668 Refile and keep the entry in place.  Also see @code{org-refile-keep}
8669 to make this the default behavior, and beware that this may
8670 result in duplicated @code{ID} properties.
8672 @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})
8673 @kindex C-u C-u C-u C-c C-w
8674 @kindex C-0 C-c C-w
8675 @findex org-refile-cache-clear
8676 @vindex org-refile-use-cache
8677 Clear the target cache.  Caching of refile targets can be turned
8678 on by setting @code{org-refile-use-cache}.  To make the command see
8679 new possible targets, you have to clear the cache with this
8680 command.
8681 @end table
8683 @node Archiving
8684 @section Archiving
8686 @cindex archiving
8688 When a project represented by a (sub)tree is finished, you may want to
8689 move the tree out of the way and to stop it from contributing to the
8690 agenda.  Archiving is important to keep your working files compact and
8691 global searches like the construction of agenda views fast.
8693 @table @asis
8694 @item @kbd{C-c C-x C-a} (@code{org-archive-subtree-default})
8695 @kindex C-c C-x C-a
8696 @findex org-archive-subtree-default
8697 @vindex org-archive-default-command
8698 Archive the current entry using the command specified in the
8699 variable @code{org-archive-default-command}.
8700 @end table
8702 @menu
8703 * Moving subtrees::              Moving a tree to an archive file.
8704 * Internal archiving::           Switch off a tree but keep it in the file.
8705 @end menu
8707 @node Moving subtrees
8708 @subsection Moving a tree to an archive file
8710 @cindex external archiving
8712 The most common archiving action is to move a project tree to another
8713 file, the archive file.
8715 @table @asis
8716 @item @kbd{C-c C-x C-s} or short @kbd{C-c $} (@code{org-archive-subtree})
8717 @kindex C-c C-x C-s
8718 @kindex C-c $
8719 @findex org-archive-subtree
8720 @vindex org-archive-location
8721 Archive the subtree starting at the cursor position to the
8722 location given by @code{org-archive-location}.
8724 @item @kbd{C-u C-c C-x C-s}
8725 @kindex C-u C-c C-x C-s
8726 Check if any direct children of the current headline could be
8727 moved to the archive.  To do this, check each subtree for open
8728 TODO entries.  If none is found, the command offers to move it to
8729 the archive location.  If the cursor is @emph{not} on a headline when
8730 this command is invoked, check level 1 trees.
8732 @item @kbd{C-u C-u C-c C-x C-s}
8733 @kindex C-u C-u C-c C-x C-s
8734 As above, but check subtree for timestamps instead of TODO
8735 entries.  The command offers to archive the subtree if it @emph{does}
8736 contain a timestamp, and that timestamp is in the past.
8737 @end table
8739 @cindex archive locations
8740 The default archive location is a file in the same directory as the
8741 current file, with the name derived by appending @samp{_archive} to the
8742 current file name.  You can also choose what heading to file archived
8743 items under, with the possibility to add them to a datetree in a file.
8744 For information and examples on how to specify the file and the
8745 heading, see the documentation string of the variable
8746 @code{org-archive-location}.
8748 There is also an in-buffer option for setting this variable, for
8749 example:
8751 @cindex @samp{ARCHIVE}, keyword
8752 @example
8753 #+ARCHIVE: %s_done::
8754 @end example
8756 @noindent
8757 @cindex ARCHIVE, property
8758 If you would like to have a special archive location for a single
8759 entry or a (sub)tree, give the entry an @samp{ARCHIVE} property with the
8760 location as the value (see @ref{Properties and Columns}).
8762 @vindex org-archive-save-context-info
8763 When a subtree is moved, it receives a number of special properties
8764 that record context information like the file from where the entry
8765 came, its outline path the archiving time etc.  Configure the variable
8766 @code{org-archive-save-context-info} to adjust the amount of information
8767 added.
8769 @node Internal archiving
8770 @subsection Internal archiving
8772 @cindex @samp{ARCHIVE}, tag
8773 If you want to just switch off---for agenda views---certain subtrees
8774 without moving them to a different file, you can use the @samp{ARCHIVE}
8775 tag.
8777 A headline that is marked with the @samp{ARCHIVE} tag (see @ref{Tags}) stays at
8778 its location in the outline tree, but behaves in the following way:
8780 @itemize
8781 @item
8782 @vindex org-cycle-open-archived-trees
8783 It does not open when you attempt to do so with a visibility cycling
8784 command (see @ref{Visibility Cycling}).  You can force cycling archived
8785 subtrees with @kbd{C-@key{TAB}}, or by setting the option
8786 @code{org-cycle-open-archived-trees}.  Also normal outline commands, like
8787 @code{outline-show-all}, open archived subtrees.
8789 @item
8790 @vindex org-sparse-tree-open-archived-trees
8791 During sparse tree construction (see @ref{Sparse Trees}), matches in
8792 archived subtrees are not exposed, unless you configure the option
8793 @code{org-sparse-tree-open-archived-trees}.
8795 @item
8796 @vindex org-agenda-skip-archived-trees
8797 During agenda view construction (see @ref{Agenda Views}), the content of
8798 archived trees is ignored unless you configure the option
8799 @code{org-agenda-skip-archived-trees}, in which case these trees are
8800 always included.  In the agenda you can press @kbd{v a} to get
8801 archives temporarily included.
8803 @item
8804 @vindex org-export-with-archived-trees
8805 Archived trees are not exported (see @ref{Exporting}), only the headline
8806 is.  Configure the details using the variable
8807 @code{org-export-with-archived-trees}.
8809 @item
8810 @vindex org-columns-skip-archived-trees
8811 Archived trees are excluded from column view unless the variable
8812 @code{org-columns-skip-archived-trees} is configured to @code{nil}.
8813 @end itemize
8815 The following commands help manage the @samp{ARCHIVE} tag:
8817 @table @asis
8818 @item @kbd{C-c C-x a} (@code{org-toggle-archive-tag})
8819 @kindex C-c C-x a
8820 @findex org-toggle-archive-tag
8821 Toggle the archive tag for the current headline.  When the tag is
8822 set, the headline changes to a shadowed face, and the subtree
8823 below it is hidden.
8825 @item @kbd{C-u C-c C-x a}
8826 @kindex C-u C-c C-x a
8827 Check if any direct children of the current headline should be
8828 archived.  To do this, check each subtree for open TODO entries.
8829 If none is found, the command offers to set the @samp{ARCHIVE} tag for
8830 the child.  If the cursor is @emph{not} on a headline when this
8831 command is invoked, check the level 1 trees.
8833 @item @kbd{C-@key{TAB}}, @code{org-force-cycle-archived}
8834 @kindex C-TAB
8835 Cycle a tree even if it is tagged with @samp{ARCHIVE}.
8837 @item @kbd{C-c C-x A} (@code{org-archive-to-archive-sibling})
8838 @kindex C-c C-x A
8839 @findex org-archive-to-archive-sibling
8840 Move the current entry to the @emph{Archive Sibling}.  This is
8841 a sibling of the entry with the heading @samp{Archive} and the archive
8842 tag.  The entry becomes a child of that sibling and in this way
8843 retains a lot of its original context, including inherited tags
8844 and approximate position in the outline.
8845 @end table
8847 @node Agenda Views
8848 @chapter Agenda Views
8850 @cindex agenda views
8852 Due to the way Org works, TODO items, time-stamped items, and tagged
8853 headlines can be scattered throughout a file or even a number of
8854 files.  To get an overview of open action items, or of events that are
8855 important for a particular date, this information must be collected,
8856 sorted and displayed in an organized way.
8858 Org can select items based on various criteria and display them in
8859 a separate buffer.  Seven different view types are provided:
8861 @itemize
8862 @item
8863 an @emph{agenda} that is like a calendar and shows information for
8864 specific dates,
8866 @item
8867 a @emph{TODO list} that covers all unfinished action items,
8869 @item
8870 a @emph{match view}, showings headlines based on the tags, properties,
8871 and TODO state associated with them,
8873 @item
8874 a @emph{timeline view} that shows all events in a single Org file, in
8875 time-sorted view,
8877 @item
8878 a @emph{text search view} that shows all entries from multiple files that
8879 contain specified keywords,
8881 @item
8882 a @emph{stuck projects view} showing projects that currently do not move
8883 along, and
8885 @item
8886 @emph{custom views} that are special searches and combinations of
8887 different views.
8888 @end itemize
8890 @noindent
8891 The extracted information is displayed in a special @emph{agenda buffer}.
8892 This buffer is read-only, but provides commands to visit the
8893 corresponding locations in the original Org files, and even to edit
8894 these files remotely.
8896 @vindex org-agenda-skip-comment-trees
8897 @vindex org-agenda-skip-archived-trees
8898 @cindex commented entries, in agenda views
8899 @cindex archived entries, in agenda views
8900 By default, the report ignores commented (see @ref{Comment Lines}) and
8901 archived (see @ref{Internal archiving}) entries.  You can override this by
8902 setting @code{org-agenda-skip-comment-trees} and
8903 @code{org-agenda-skip-archived-trees} to @code{nil}.
8905 @vindex org-agenda-window-setup
8906 @vindex org-agenda-restore-windows-after-quit
8907 Two variables control how the agenda buffer is displayed and whether
8908 the window configuration is restored when the agenda exits:
8909 @code{org-agenda-window-setup} and @code{org-agenda-restore-windows-after-quit}.
8911 @menu
8912 * Agenda Files::                 Files being searched for agenda information.
8913 * Agenda Dispatcher::            Keyboard access to agenda views.
8914 * Built-in Agenda Views::        What is available out of the box?
8915 * Presentation and Sorting::     How agenda items are prepared for display.
8916 * Agenda Commands::              Remote editing of Org trees.
8917 * Custom Agenda Views::          Defining special searches and views.
8918 * Exporting Agenda Views::       Writing a view to a file.
8919 * Agenda Column View::           Using column view for collected entries.
8920 @end menu
8922 @node Agenda Files
8923 @section Agenda Files
8925 @cindex agenda files
8926 @cindex files for agenda
8928 @vindex org-agenda-files
8929 The information to be shown is normally collected from all @emph{agenda
8930 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
8931 name, then the list of agenda files in maintained in that external
8932 file.}.
8933 If a directory is part of this list, all files with the extension
8934 @samp{.org} in this directory are part of the list.
8936 Thus, even if you only work with a single Org file, that file should
8937 be put into the list@footnote{When using the dispatcher, pressing @kbd{<} before
8938 selecting a command actually limits the command to the current file,
8939 and ignores @code{org-agenda-files} until the next dispatcher command.}.  You can customize @code{org-agenda-files},
8940 but the easiest way to maintain it is through the following commands
8942 @table @asis
8943 @item @kbd{C-c [} (@code{org-agenda-file-to-front})
8944 @kindex C-c [
8945 @findex org-agenda-file-to-front
8946 @cindex files, adding to agenda list
8947 Add current file to the list of agenda files.  The file is added
8948 to the front of the list.  If it was already in the list, it is
8949 moved to the front.  With a prefix argument, file is added/moved
8950 to the end.
8952 @item @kbd{C-c ]} (@code{org-remove-file})
8953 @kindex C-c ]
8954 @findex org-remove-file
8955 Remove current file from the list of agenda files.
8957 @item @kbd{C-'}
8958 @itemx @kbd{C-,} (@code{org-cycle-agenda-files})
8959 @kindex C-'
8960 @kindex C-,
8961 @findex org-cycle-agenda-files
8962 @cindex cycling, of agenda files
8963 Cycle through agenda file list, visiting one file after the other.
8965 @item @kbd{M-x org-switchb}
8966 @findex org-switchb
8967 Command to use an iswitchb-like interface to switch to and
8968 between Org buffers.
8969 @end table
8971 @noindent
8972 The Org menu contains the current list of files and can be used to
8973 visit any of them.
8975 If you would like to focus the agenda temporarily on a file not in
8976 this list, or on just one file in the list, or even on only a subtree
8977 in a file, then this can be done in different ways.  For a single
8978 agenda command, you may press @kbd{<} once or several times in
8979 the dispatcher (see @ref{Agenda Dispatcher}).  To restrict the agenda
8980 scope for an extended period, use the following commands:
8982 @table @asis
8983 @item @kbd{C-c C-x <} (@code{org-agenda-set-restriction-lock})
8984 @kindex C-c C-x <
8985 @findex org-agenda-set-restriction-lock
8986 Permanently restrict the agenda to the current subtree.  When
8987 called with a prefix argument, or with the cursor before the
8988 first headline in a file, set the agenda scope to the entire
8989 file.  This restriction remains in effect until removed with
8990 @kbd{C-c C-x >}, or by typing either @kbd{<} or
8991 @kbd{>} in the agenda dispatcher.  If there is a window
8992 displaying an agenda view, the new restriction takes effect
8993 immediately.
8995 @item @kbd{C-c C-x >} (@code{org-agenda-remove-restriction-lock})
8996 @kindex C-c C-x >
8997 @findex org-agenda-remove-restriction-lock
8998 Remove the permanent restriction created by @kbd{C-c C-x <}.
8999 @end table
9001 @noindent
9002 When working with @samp{speedbar.el}, you can use the following commands in
9003 the Speedbar frame:
9005 @table @asis
9006 @item @kbd{<} (@code{org-speedbar-set-agenda-restriction})
9007 @findex org-speedbar-set-agenda-restriction
9008 Permanently restrict the agenda to the item---either an Org file
9009 or a subtree in such a file---at the cursor in the Speedbar
9010 frame.  If there is a window displaying an agenda view, the new
9011 restriction takes effect immediately.
9013 @item @kbd{>} (@code{org-agenda-remove-restriction-lock})
9014 @findex org-agenda-remove-restriction-lock
9015 Lift the restriction.
9016 @end table
9018 @node Agenda Dispatcher
9019 @section The Agenda Dispatcher
9021 @cindex agenda dispatcher
9022 @cindex dispatching agenda commands
9024 The views are created through a dispatcher, accessible with @kbd{M-x org-agenda}, or, better, bound to a global key (see @ref{Activation}).
9025 It displays a menu from which an additional letter is required to
9026 execute a command.  The dispatcher offers the following default
9027 commands:
9029 @table @asis
9030 @item @kbd{a}
9031 Create the calendar-like agenda (see @ref{Weekly/daily agenda}).
9033 @item @kbd{t} or @kbd{T}
9034 Create a list of all TODO items (see @ref{Global TODO list}).
9036 @item @kbd{m} or @kbd{M}
9037 Create a list of headlines matching a given expression (see
9038 @ref{Matching tags and properties}).
9040 @item @kbd{s}
9041 @kindex s @r{(Agenda dispatcher)}
9042 Create a list of entries selected by a boolean expression of
9043 keywords and/or regular expressions that must or must not occur
9044 in the entry.
9046 @item @kbd{/}
9047 @kindex / @r{(Agenda dispatcher)}
9048 @vindex org-agenda-text-search-extra-files
9049 Search for a regular expression in all agenda files and
9050 additionally in the files listed in
9051 @code{org-agenda-text-search-extra-files}.  This uses the Emacs
9052 command @code{multi-occur}.  A prefix argument can be used to specify
9053 the number of context lines for each match, default is
9054 @enumerate
9055 @item
9056 @end enumerate
9058 @item @kbd{#} or @kbd{!}
9059 Create a list of stuck projects (see @ref{Stuck projects}).
9061 @item @kbd{<}
9062 @kindex < @r{(Agenda dispatcher)}
9063 Restrict an agenda command to the current buffer@footnote{For backward compatibility, you can also press @kbd{1} to
9064 restrict to the current buffer.}.  After
9065 pressing @kbd{<}, you still need to press the character
9066 selecting the command.
9068 @item @kbd{< <}
9069 @kindex < < @r{(Agenda dispatcher)}
9070 If there is an active region, restrict the following agenda
9071 command to the region.  Otherwise, restrict it to the current
9072 subtree@footnote{For backward compatibility, you can also press @kbd{0} to
9073 restrict to the current region/subtree.}.  After pressing @kbd{< <}, you still need to
9074 press the character selecting the command.
9076 @item @kbd{*}
9077 @kindex * @r{(Agenda dispatcher)}
9078 @vindex org-agenda-sticky
9079 @findex org-toggle-sticky-agenda
9080 Toggle sticky agenda views.  By default, Org maintains only
9081 a single agenda buffer and rebuilds it each time you change the
9082 view, to make sure everything is always up to date.  If you
9083 switch between views often and the build time bothers you, you
9084 can turn on sticky agenda buffers (make this the default by
9085 customizing the variable @code{org-agenda-sticky}).  With sticky
9086 agendas, the dispatcher only switches to the selected view, you
9087 need to update it by hand with @kbd{r} or @kbd{g}.  You
9088 can toggle sticky agenda view any time with
9089 @code{org-toggle-sticky-agenda}.
9090 @end table
9092 You can also define custom commands that are accessible through the
9093 dispatcher, just like the default commands.  This includes the
9094 possibility to create extended agenda buffers that contain several
9095 blocks together, for example the weekly agenda, the global TODO list
9096 and a number of special tags matches.  See @ref{Custom Agenda Views}.
9098 @node Built-in Agenda Views
9099 @section The Built-in Agenda Views
9101 In this section we describe the built-in views.
9103 @menu
9104 * Weekly/daily agenda::          The calendar page with current tasks.
9105 * Global TODO list::             All unfinished action items.
9106 * Matching tags and properties:: Structured information with fine-tuned search.
9107 * Search view::                  Find entries by searching for text.
9108 * Stuck projects::               Find projects you need to review.
9109 @end menu
9111 @node Weekly/daily agenda
9112 @subsection Weekly/daily agenda
9114 @cindex agenda
9115 @cindex weekly agenda
9116 @cindex daily agenda
9118 The purpose of the weekly/daily @emph{agenda} is to act like a page of
9119 a paper agenda, showing all the tasks for the current week or day.
9121 @table @asis
9122 @item @kbd{M-x org-agenda a} (@code{org-agenda-list})
9123 @kindex a @r{(Agenda dispatcher)}
9124 @findex org-agenda-list
9125 @cindex org-agenda, command
9126 Compile an agenda for the current week from a list of Org files.
9127 The agenda shows the entries for each day.  With a numeric prefix
9128 argument@footnote{For backward compatibility, the universal prefix argument
9129 @kbd{C-u} causes all TODO entries to be listed before the agenda.
9130 This feature is deprecated, use the dedicated TODO list, or a block
9131 agenda instead (see @ref{Block agenda}).}---like @kbd{C-u 2 1 M-x org-agenda a}---you
9132 may set the number of days to be displayed.
9133 @end table
9135 @vindex org-agenda-span
9136 @vindex org-agenda-start-day
9137 @vindex org-agenda-start-on-weekday
9138 The default number of days displayed in the agenda is set by the
9139 variable @code{org-agenda-span}.  This variable can be set to any number of
9140 days you want to see by default in the agenda, or to a span name, such
9141 a @code{day}, @code{week}, @code{month} or @code{year}.  For weekly agendas, the default
9142 is to start on the previous Monday (see
9143 @code{org-agenda-start-on-weekday}).  You can also set the start date using
9144 a date shift: @code{(setq org-agenda-start-day "+10d")} starts the agenda
9145 ten days from today in the future.
9147 Remote editing from the agenda buffer means, for example, that you can
9148 change the dates of deadlines and appointments from the agenda buffer.
9149 The commands available in the Agenda buffer are listed in @ref{Agenda Commands}.
9151 @anchor{Calendar/Diary integration}
9152 @subsubheading Calendar/Diary integration
9154 @cindex calendar integration
9155 @cindex diary integration
9157 Emacs contains the calendar and diary by Edward M. Reingold.  The
9158 calendar displays a three-month calendar with holidays from different
9159 countries and cultures.  The diary allows you to keep track of
9160 anniversaries, lunar phases, sunrise/set, recurrent appointments
9161 (weekly, monthly) and more.  In this way, it is quite complementary to
9162 Org.  It can be very useful to combine output from Org with the diary.
9164 In order to include entries from the Emacs diary into Org mode's
9165 agenda, you only need to customize the variable
9167 @lisp
9168 (setq org-agenda-include-diary t)
9169 @end lisp
9171 @noindent
9172 After that, everything happens automatically.  All diary entries
9173 including holidays, anniversaries, etc., are included in the agenda
9174 buffer created by Org mode.  @kbd{@key{SPC}}, @kbd{@key{TAB}}, and
9175 @kbd{@key{RET}} can be used from the agenda buffer to jump to the diary
9176 file in order to edit existing diary entries.  The @kbd{i}
9177 command to insert new entries for the current date works in the agenda
9178 buffer, as well as the commands @kbd{S}, @kbd{M}, and
9179 @kbd{C} to display Sunrise/Sunset times, show lunar phases and to
9180 convert to other calendars, respectively.  @kbd{c} can be used to
9181 switch back and forth between calendar and agenda.
9183 If you are using the diary only for S-exp entries and holidays, it is
9184 faster to not use the above setting, but instead to copy or even move
9185 the entries into an Org file.  Org mode evaluates diary-style sexp
9186 entries, and does it faster because there is no overhead for first
9187 creating the diary display.  Note that the sexp entries must start at
9188 the left margin, no whitespace is allowed before them, as seen in the
9189 following segment of an Org file:@footnote{The variable @code{org-anniversary} used in the example is just
9190 like @code{diary-anniversary}, but the argument order is always according
9191 to ISO and therefore independent of the value of
9192 @code{calendar-date-style}.}
9194 @example
9195 * Holidays
9196   :PROPERTIES:
9197   :CATEGORY: Holiday
9198   :END:
9199 %%(org-calendar-holiday)   ; special function for holiday names
9201 * Birthdays
9202   :PROPERTIES:
9203   :CATEGORY: Ann
9204   :END:
9205 %%(org-anniversary 1956  5 14) Arthur Dent is %d years old
9206 %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
9207 @end example
9209 @anchor{Anniversaries from BBDB}
9210 @subsubheading Anniversaries from BBDB
9212 @cindex BBDB, anniversaries
9213 @cindex anniversaries, from BBDB
9215 @findex org-bbdb-anniversaries
9216 If you are using the Insidious Big Brother Database to store your
9217 contacts, you very likely prefer to store anniversaries in BBDB rather
9218 than in a separate Org or diary file.  Org supports this and can show
9219 BBDB anniversaries as part of the agenda.  All you need to do is to
9220 add the following to one of your agenda files:
9222 @example
9223 * Anniversaries
9224   :PROPERTIES:
9225   :CATEGORY: Anniv
9226   :END:
9227 %%(org-bbdb-anniversaries)
9228 @end example
9230 You can then go ahead and define anniversaries for a BBDB record.
9231 Basically, you need to press @kbd{C-o anniversary @key{RET}} with the
9232 cursor in a BBDB record and then add the date in the format
9233 @samp{YYYY-MM-DD} or @samp{MM-DD}, followed by a space and the class of the
9234 anniversary (@samp{birthday}, @samp{wedding}, or a format string).  If you omit
9235 the class, it defaults to @samp{birthday}.  Here are a few examples, the
9236 header for the file @samp{org-bbdb.el} contains more detailed information.
9238 @example
9239 1973-06-22
9240 06-22
9241 1955-08-02 wedding
9242 2008-04-14 %s released version 6.01 of Org mode, %d years ago
9243 @end example
9245 After a change to BBDB, or for the first agenda display during an
9246 Emacs session, the agenda display suffers a short delay as Org updates
9247 its hash with anniversaries.  However, from then on things will be
9248 very fast, much faster in fact than a long list of
9249 @samp{%%(diary-anniversary)} entries in an Org or Diary file.
9251 @findex org-bbdb-anniversaries-future
9252 If you would like to see upcoming anniversaries with a bit of
9253 forewarning, you can use the following instead:
9255 @example
9256 * Anniversaries
9257   :PROPERTIES:
9258   :CATEGORY: Anniv
9259   :END:
9260 %%(org-bbdb-anniversaries-future 3)
9261 @end example
9263 That will give you three days' warning: on the anniversary date itself
9264 and the two days prior.  The argument is optional: if omitted, it
9265 defaults to 7.
9267 @anchor{Appointment reminders}
9268 @subsubheading Appointment reminders
9270 @cindex @file{appt.el}
9271 @cindex appointment reminders
9272 @cindex appointment
9273 @cindex reminders
9275 @cindex APPT_WARNTIME, keyword
9276 Org can interact with Emacs appointments notification facility.  To
9277 add the appointments of your agenda files, use the command
9278 @code{org-agenda-to-appt}.  This command lets you filter through the list
9279 of your appointments and add only those belonging to a specific
9280 category or matching a regular expression.  It also reads
9281 a @samp{APPT_WARNTIME} property which overrides the value of
9282 @code{appt-message-warning-time} for this appointment.  See the docstring
9283 for details.
9285 @node Global TODO list
9286 @subsection The global TODO list
9288 @cindex global TODO list
9289 @cindex TODO list, global
9291 The global TODO list contains all unfinished TODO items formatted and
9292 collected into a single place.
9294 @table @asis
9295 @item @kbd{M-x org-agenda t} (@code{org-todo-list})
9296 @kindex t @r{(Agenda dispatcher)}
9297 @findex org-todo-list
9298 Show the global TODO list.  This collects the TODO items from all
9299 agenda files (see @ref{Agenda Views}) into a single buffer.  By
9300 default, this lists items with a state the is not a DONE state.
9301 The buffer is in @code{agenda-mode}, so there are commands to examine
9302 and manipulate the TODO entries directly from that buffer (see
9303 @ref{Agenda Commands}).
9305 @item @kbd{M-x org-agenda T} (@code{org-todo-list})
9306 @kindex T @r{(Agenda dispatcher)}
9307 @findex org-todo-list
9308 @cindex TODO keyword matching
9309 @vindex org-todo-keywords
9310 Like the above, but allows selection of a specific TODO keyword.
9311 You can also do this by specifying a prefix argument to
9312 @kbd{t}.  You are prompted for a keyword, and you may also
9313 specify several keywords by separating them with @samp{|} as the
9314 boolean OR operator.  With a numeric prefix, the Nth keyword in
9315 @code{org-todo-keywords} is selected.
9317 @kindex r
9318 The @kbd{r} key in the agenda buffer regenerates it, and you
9319 can give a prefix argument to this command to change the selected
9320 TODO keyword, for example @kbd{3 r}.  If you often need
9321 a search for a specific keyword, define a custom command for it
9322 (see @ref{Agenda Dispatcher}).
9324 Matching specific TODO keywords can also be done as part of
9325 a tags search (see @ref{Tag Searches}).
9326 @end table
9328 Remote editing of TODO items means that you can change the state of
9329 a TODO entry with a single key press.  The commands available in the
9330 TODO list are described in @ref{Agenda Commands}.
9332 @cindex sublevels, inclusion into TODO list
9333 Normally the global TODO list simply shows all headlines with TODO
9334 keywords.  This list can become very long.  There are two ways to keep
9335 it more compact:
9337 @itemize
9338 @item
9339 @vindex org-agenda-todo-ignore-scheduled
9340 @vindex org-agenda-todo-ignore-deadlines
9341 @vindex org-agenda-todo-ignore-timestamp
9342 @vindex org-agenda-todo-ignore-with-date
9343 Some people view a TODO item that has been @emph{scheduled} for execution
9344 or have a @emph{deadline} (see @ref{Timestamps}) as
9345 no longer @emph{open}.  Configure the variables
9346 @code{org-agenda-todo-ignore-scheduled},
9347 @code{org-agenda-todo-ignore-deadlines},
9348 @code{org-agenda-todo-ignore-timestamp} and/or
9349 @code{org-agenda-todo-ignore-with-date} to exclude such items from the
9350 global TODO list.
9352 @item
9353 @vindex org-agenda-todo-list-sublevels
9354 TODO items may have sublevels to break up the task into subtasks.
9355 In such cases it may be enough to list only the highest level TODO
9356 headline and omit the sublevels from the global list.  Configure the
9357 variable @code{org-agenda-todo-list-sublevels} to get this behavior.
9358 @end itemize
9360 @node Matching tags and properties
9361 @subsection Matching tags and properties
9363 @cindex matching, of tags
9364 @cindex matching, of properties
9365 @cindex tags view
9366 @cindex match view
9368 If headlines in the agenda files are marked with @emph{tags} (see @ref{Tags}),
9369 or have properties (see @ref{Properties and Columns}), you can select
9370 headlines based on this metadata and collect them into an agenda
9371 buffer.  The match syntax described here also applies when creating
9372 sparse trees with @kbd{C-c / m}.
9374 @table @asis
9375 @item @kbd{M-x org-agenda m} (@code{org-tags-view})
9376 @kindex m @r{(Agenda dispatcher)}
9377 @findex org-tags-view
9378 Produce a list of all headlines that match a given set of tags.
9379 The command prompts for a selection criterion, which is a boolean
9380 logic expression with tags, like @samp{+work+urgent-withboss} or
9381 @samp{work|home} (see @ref{Tags}).  If you often need a specific search,
9382 define a custom command for it (see @ref{Agenda Dispatcher}).
9384 @item @kbd{M-x org-agenda M} (@code{org-tags-view})
9385 @kindex M @r{(Agenda dispatcher)}
9386 @findex org-tags-view
9387 @vindex org-tags-match-list-sublevels
9388 @vindex org-agenda-tags-todo-honor-ignore-options
9389 Like @kbd{m}, but only select headlines that are also TODO
9390 items and force checking subitems (see the variable
9391 @code{org-tags-match-list-sublevels}).  To exclude scheduled/deadline
9392 items, see the variable
9393 @code{org-agenda-tags-todo-honor-ignore-options}.  Matching specific
9394 TODO keywords together with a tags match is also possible, see
9395 @ref{Tag Searches}.
9396 @end table
9398 The commands available in the tags list are described in @ref{Agenda Commands}.
9400 @cindex boolean logic, for agenda searches
9401 A search string can use Boolean operators @samp{&} for AND and @samp{|} for OR.
9402 @samp{&} binds more strongly than @samp{|}.  Parentheses are currently not
9403 implemented.  Each element in the search is either a tag, a regular
9404 expression matching tags, or an expression like @samp{PROPERTY OPERATOR
9405 VALUE} with a comparison operator, accessing a property value.  Each
9406 element may be preceded by @samp{-} to select against it, and @samp{+} is
9407 syntactic sugar for positive selection.  The AND operator @samp{&} is
9408 optional when @samp{+} or @samp{-} is present.  Here are some examples, using
9409 only tags.
9411 @table @asis
9412 @item @code{+work-boss}
9413 Select headlines tagged @samp{work}, but discard those also tagged
9414 @samp{boss}.
9416 @item @code{work|laptop}
9417 Selects lines tagged @samp{work} or @samp{laptop}.
9419 @item @code{work|laptop+night}
9420 Like before, but require the @samp{laptop} lines to be tagged
9421 also @samp{night}.
9422 @end table
9424 @cindex regular expressions, with tags search
9425 Instead of a tag, you may also specify a regular expression enclosed
9426 in curly braces.  For example, @samp{work+@{^boss.*@}} matches headlines that
9427 contain the tag @samp{:work:} and any tag @emph{starting} with @samp{boss}.
9429 @cindex group tags, as regular expressions
9430 Group tags (see @ref{Tag Hierarchy}) are expanded as regular expressions.
9431 E.g., if @samp{work} is a group tag for the group @samp{:work:lab:conf:}, then
9432 searching for @samp{work} also searches for @samp{@{\(?:work\|lab\|conf\)@}} and
9433 searching for @samp{-work} searches for all headlines but those with one of
9434 the tags in the group (i.e., @samp{-@{\(?:work\|lab\|conf\)@}}).
9436 @cindex TODO keyword matching, with tags search
9437 @cindex level, for tags/property match
9438 @cindex category, for tags/property match
9439 @vindex org-odd-levels-only
9440 You may also test for properties (see @ref{Properties and Columns}) at the
9441 same time as matching tags.  The properties may be real properties, or
9442 special properties that represent other metadata (see @ref{Special Properties}).  For example, the property @samp{TODO} represents the TODO
9443 keyword of the entry.  Or, the property @samp{LEVEL} represents the level
9444 of an entry.  So searching @samp{+LEVEL=3+boss-TODO​="DONE"} lists all level
9445 three headlines that have the tag @samp{boss} and are @emph{not} marked with the
9446 TODO keyword @samp{DONE}.  In buffers with @code{org-odd-levels-only} set,
9447 @samp{LEVEL} does not count the number of stars, but @samp{LEVEL=2} corresponds
9448 to 3 stars etc.
9450 Here are more examples:
9452 @table @asis
9453 @item @samp{work+TODO​="WAITING"}
9454 Select @samp{work}-tagged TODO lines with the specific TODO keyword
9455 @samp{WAITING}.
9457 @item @samp{work+TODO​="WAITING"|home+TODO​="WAITING"}
9458 Waiting tasks both at work and at home.
9459 @end table
9461 When matching properties, a number of different operators can be used
9462 to test the value of a property.  Here is a complex example:
9464 @example
9465 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2
9466          +With=@{Sarah|Denny@}+SCHEDULED>="<2008-10-11>"
9467 @end example
9469 @noindent
9470 The type of comparison depends on how the comparison value is written:
9472 @itemize
9473 @item
9474 If the comparison value is a plain number, a numerical comparison is
9475 done, and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=}, @samp{>=}, and
9476 @samp{<>}.
9478 @item
9479 If the comparison value is enclosed in double-quotes, a string
9480 comparison is done, and the same operators are allowed.
9482 @item
9483 If the comparison value is enclosed in double-quotes @emph{and} angular
9484 brackets (like @samp{DEADLINE<​="<2008-12-24 18:30>"}), both values are
9485 assumed to be date/time specifications in the standard Org way, and
9486 the comparison is done accordingly.  Valid values also include
9487 @samp{"<now>"} for now (including time), @samp{"<today>"}, and @samp{"<tomorrow>"}
9488 for these days at 0:00 hours, i.e., without a time specification.
9489 You can also use strings like @samp{"<+5d>"} or @samp{"<-2m>"} with units @samp{d},
9490 @samp{w}, @samp{m}, and @samp{y} for day, week, month, and year, respectively.
9492 @item
9493 If the comparison value is enclosed in curly braces, a regexp match
9494 is performed, with @samp{=} meaning that the regexp matches the property
9495 value, and @samp{<>} meaning that it does not match.
9496 @end itemize
9498 So the search string in the example finds entries tagged @samp{work} but
9499 not @samp{boss}, which also have a priority value @samp{A}, a @samp{Coffee} property
9500 with the value @samp{unlimited}, an @samp{EFFORT} property that is numerically
9501 smaller than 2, a @samp{With} property that is matched by the regular
9502 expression @samp{Sarah|Denny}, and that are scheduled on or after October
9503 11, 2008.
9505 You can configure Org mode to use property inheritance during
9506 a search, but beware that this can slow down searches considerably.
9507 See @ref{Property Inheritance}, for details.
9509 For backward compatibility, and also for typing speed, there is also
9510 a different way to test TODO states in a search.  For this, terminate
9511 the tags/property part of the search string (which may include several
9512 terms connected with @samp{|}) with a @samp{/} and then specify a Boolean
9513 expression just for TODO keywords.  The syntax is then similar to that
9514 for tags, but should be applied with care: for example, a positive
9515 selection on several TODO keywords cannot meaningfully be combined
9516 with boolean AND.  However, @emph{negative selection} combined with AND can
9517 be meaningful.  To make sure that only lines are checked that actually
9518 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
9519 with @samp{!}.  Using @kbd{M-x org-agenda M} or @samp{/!} does not match
9520 TODO keywords in a DONE state.  Examples:
9522 @table @asis
9523 @item @samp{work/WAITING}
9524 Same as @samp{work+TODO​="WAITING"}.
9526 @item @samp{work/!-WAITING-NEXT}
9527 Select @samp{work}-tagged TODO lines that are neither @samp{WAITING} nor
9528 @samp{NEXT}.
9530 @item @samp{work/!+WAITING|+NEXT}
9531 Select @samp{work}-tagged TODO lines that are either @samp{WAITING} or
9532 @samp{NEXT}.
9533 @end table
9535 @node Search view
9536 @subsection Search view
9538 @cindex search view
9539 @cindex text search
9540 @cindex searching, for text
9542 This agenda view is a general text search facility for Org mode
9543 entries.  It is particularly useful to find notes.
9545 @table @asis
9546 @item @kbd{M-x org-agenda s} (@code{org-search-view})
9547 @kindex s @r{(Agenda dispatcher)}
9548 @findex org-search-view
9549 This is a special search that lets you select entries by matching
9550 a substring or specific words using a boolean logic.
9551 @end table
9553 For example, the search string @samp{computer equipment} matches entries
9554 that contain @samp{computer equipment} as a substring, even if the two
9555 words are separated by more space or a line break.
9557 Search view can also search for specific keywords in the entry, using
9558 Boolean logic.  The search string @samp{+computer
9559 +wifi -ethernet -@{8\.11[bg]@}} matches note entries that contain the
9560 keywords @samp{computer} and @samp{wifi}, but not the keyword @samp{ethernet}, and
9561 which are also not matched by the regular expression @samp{8\.11[bg]},
9562 meaning to exclude both @samp{8.11b} and @samp{8.11g}.  The first @samp{+} is
9563 necessary to turn on boolean search, other @samp{+} characters are
9564 optional.  For more details, see the docstring of the command
9565 @code{org-search-view}.
9567 You can incrementally adjust a boolean search with the following keys
9569 @multitable @columnfractions 0.1 0.6
9570 @item @kbd{[}
9571 @tab Add a positive search word
9572 @item @kbd{]}
9573 @tab Add a negative search word
9574 @item @kbd{@{}
9575 @tab Add a positive regular expression
9576 @item @kbd{@}}
9577 @tab Add a negative regular expression
9578 @end multitable
9580 @vindex org-agenda-text-search-extra-files
9581 Note that in addition to the agenda files, this command also searches
9582 the files listed in @code{org-agenda-text-search-extra-files}.
9584 @node Stuck projects
9585 @subsection Stuck projects
9587 @pindex GTD, Getting Things Done
9589 If you are following a system like David Allen's GTD to organize your
9590 work, one of the ``duties'' you have is a regular review to make sure
9591 that all projects move along.  A @emph{stuck} project is a project that has
9592 no defined next actions, so it never shows up in the TODO lists Org
9593 mode produces.  During the review, you need to identify such projects
9594 and define next actions for them.
9596 @table @asis
9597 @item @kbd{M-x org-agenda #} (@code{org-agenda-list-stuck-projects})
9598 @kindex # @r{(Agenda dispatcher)}
9599 @findex org-agenda-list-stuck-projects
9600 List projects that are stuck.
9602 @item @kbd{M-x org-agenda !}
9603 @kindex ! @r{(Agenda dispatcher)}
9604 @vindex org-stuck-projects
9605 Customize the variable @code{org-stuck-projects} to define what
9606 a stuck project is and how to find it.
9607 @end table
9609 You almost certainly need to configure this view before it works for
9610 you.  The built-in default assumes that all your projects are level-2
9611 headlines, and that a project is not stuck if it has at least one
9612 entry marked with a TODO keyword @samp{TODO} or @samp{NEXT} or @samp{NEXTACTION}.
9614 Let's assume that you, in your own way of using Org mode, identify
9615 projects with a tag @samp{:PROJECT:}, and that you use a TODO keyword
9616 @samp{MAYBE} to indicate a project that should not be considered yet.
9617 Let's further assume that the TODO keyword @samp{DONE} marks finished
9618 projects, and that @samp{NEXT} and @samp{TODO} indicate next actions.  The tag
9619 @samp{:@@shop:} indicates shopping and is a next action even without the
9620 NEXT tag.  Finally, if the project contains the special word @samp{IGNORE}
9621 anywhere, it should not be listed either.  In this case you would
9622 start by identifying eligible projects with a tags/TODO match (see
9623 @ref{Tag Searches}) @samp{+PROJECT/-MAYBE-DONE}, and then check for @samp{TODO},
9624 @samp{NEXT}, @samp{@@shop}, and @samp{IGNORE} in the subtree to identify projects that
9625 are not stuck.  The correct customization for this is:
9627 @lisp
9628 (setq org-stuck-projects
9629       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@shop")
9630         "\\<IGNORE\\>"))
9631 @end lisp
9633 Note that if a project is identified as non-stuck, the subtree of this
9634 entry is searched for stuck projects.
9636 @node Presentation and Sorting
9637 @section Presentation and Sorting
9639 @cindex presentation, of agenda items
9641 @vindex org-agenda-prefix-format
9642 @vindex org-agenda-tags-column
9643 Before displaying items in an agenda view, Org mode visually prepares
9644 the items and sorts them.  Each item occupies a single line.  The line
9645 starts with a @emph{prefix} that contains the @emph{category} (see @ref{Categories})
9646 of the item and other important information.  You can customize in
9647 which column tags are displayed through @code{org-agenda-tags-column}.  You
9648 can also customize the prefix using the option
9649 @code{org-agenda-prefix-format}.  This prefix is followed by a cleaned-up
9650 version of the outline headline associated with the item.
9652 @menu
9653 * Categories::                   Not all tasks are equal.
9654 * Time-of-day specifications::   How the agenda knows the time.
9655 * Sorting of agenda items::      The order of things.
9656 * Filtering/limiting agenda times:: Dynamically narrow the agenda.
9657 @end menu
9659 @node Categories
9660 @subsection Categories
9662 @cindex category
9663 @cindex @samp{CATEGORY}, keyword
9665 The category is a broad label assigned to each agenda item.  By
9666 default, the category is simply derived from the file name, but you
9667 can also specify it with a special line in the buffer, like
9668 this:
9670 @example
9671 #+CATEGORY: Thesis
9672 @end example
9674 @noindent
9675 @cindex @samp{CATEGORY}, property
9676 If you would like to have a special category for a single entry or
9677 a (sub)tree, give the entry a @samp{CATEGORY} property with the special
9678 category you want to apply as the value.
9680 @noindent
9681 The display in the agenda buffer looks best if the category is not
9682 longer than 10 characters.
9684 @noindent
9685 @vindex org-agenda-category-icon-alist
9686 You can set up icons for category by customizing the
9687 @code{org-agenda-category-icon-alist} variable.
9689 @node Time-of-day specifications
9690 @subsection Time-of-day specifications
9692 @cindex time-of-day specification
9694 Org mode checks each agenda item for a time-of-day specification.  The
9695 time can be part of the timestamp that triggered inclusion into the
9696 agenda, for example
9698 @example
9699 <2005-05-10 Tue 19:00>
9700 @end example
9702 @noindent
9703 Time ranges can be specified with two timestamps:
9705 @example
9706 <2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>
9707 @end example
9709 In the headline of the entry itself, a time(range) may also appear as
9710 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda integrates
9711 the Emacs diary (see @ref{Weekly/daily agenda}), time specifications in
9712 diary entries are recognized as well.
9714 For agenda display, Org mode extracts the time and displays it in
9715 a standard 24 hour format as part of the prefix.  The example times in
9716 the previous paragraphs would end up in the agenda like this:
9718 @example
9719  8:30-13:00 Arthur Dent lies in front of the bulldozer
9720 12:45...... Ford Prefect arrives and takes Arthur to the pub
9721 19:00...... The Vogon reads his poem
9722 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9723 @end example
9725 @cindex time grid
9726 If the agenda is in single-day mode, or for the display of today, the
9727 timed entries are embedded in a time grid, like
9729 @example
9730  8:00...... ------------------
9731  8:30-13:00 Arthur Dent lies in front of the bulldozer
9732 10:00...... ------------------
9733 12:00...... ------------------
9734 12:45...... Ford Prefect arrives and takes Arthur to the pub
9735 14:00...... ------------------
9736 16:00...... ------------------
9737 18:00...... ------------------
9738 19:00...... The Vogon reads his poem
9739 20:00...... ------------------
9740 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9741 @end example
9743 @vindex org-agenda-use-time-grid
9744 @vindex org-agenda-time-grid
9745 The time grid can be turned on and off with the variable
9746 @code{org-agenda-use-time-grid}, and can be configured with
9747 @code{org-agenda-time-grid}.
9749 @node Sorting of agenda items
9750 @subsection Sorting of agenda items
9752 @cindex sorting, of agenda items
9753 @cindex priorities, of agenda items
9755 Before being inserted into a view, the items are sorted.  How this is
9756 done depends on the type of view.
9758 @itemize
9759 @item
9760 @vindex org-agenda-files
9761 For the daily/weekly agenda, the items for each day are sorted.  The
9762 default order is to first collect all items containing an explicit
9763 time-of-day specification.  These entries are shown at the beginning
9764 of the list, as a @emph{schedule} for the day.  After that, items remain
9765 grouped in categories, in the sequence given by @code{org-agenda-files}.
9766 Within each category, items are sorted by priority (see
9767 @ref{Priorities}), which is composed of the base priority (2000 for
9768 priority @samp{A}, 1000 for @samp{B}, and 0 for @samp{C}), plus additional
9769 increments for overdue scheduled or deadline items.
9771 @item
9772 For the TODO list, items remain in the order of categories, but
9773 within each category, sorting takes place according to priority (see
9774 @ref{Priorities}).  The priority used for sorting derives from the
9775 priority cookie, with additions depending on how close an item is to
9776 its due or scheduled date.
9778 @item
9779 For tags matches, items are not sorted at all, but just appear in
9780 the sequence in which they are found in the agenda files.
9781 @end itemize
9783 @vindex org-agenda-sorting-strategy
9784 Sorting can be customized using the variable
9785 @code{org-agenda-sorting-strategy}, and may also include criteria based on
9786 the estimated effort of an entry (see @ref{Effort Estimates}).
9788 @node Filtering/limiting agenda times
9789 @subsection Filtering/limiting agenda times
9791 Agenda built-in or customized commands are statically defined.  Agenda
9792 filters and limits provide two ways of dynamically narrowing down the
9793 list of agenda entries: @emph{filters} and @emph{limits}.  Filters only act on
9794 the display of the items, while limits take effect before the list of
9795 agenda entries is built.  Filters are more often used interactively,
9796 while limits are mostly useful when defined as local variables within
9797 custom agenda commands.
9799 @anchor{Filtering in the agenda}
9800 @subsubheading Filtering in the agenda
9802 @cindex agenda filtering
9803 @cindex filtering entries, in agenda
9804 @cindex tag filtering, in agenda
9805 @cindex category filtering, in agenda
9806 @cindex top headline filtering, in agenda
9807 @cindex effort filtering, in agenda
9808 @cindex query editing, in agenda
9810 @table @asis
9811 @item @kbd{/} (@code{org-agenda-filter-by-tag})
9812 @findex org-agenda-filter-by-tag
9813 @vindex org-agenda-tag-filter-preset
9814 Filter the agenda view with respect to a tag and/or effort
9815 estimates.  The difference between this and a custom agenda
9816 command is that filtering is very fast, so that you can switch
9817 quickly between different filters without having to recreate the
9818 agenda.@footnote{Custom commands can preset a filter by binding the variable
9819 @code{org-agenda-tag-filter-preset} as an option.  This filter is then
9820 applied to the view and persists as a basic filter through refreshes
9821 and more secondary filtering.  The filter is a global property of the
9822 entire agenda view---in a block agenda, you should only set this in
9823 the global options section, not in the section of an individual block.}
9825 You are prompted for a tag selection letter; @kbd{@key{SPC}} means
9826 any tag at all.  Pressing @kbd{@key{TAB}} at that prompt offers
9827 completion to select a tag, including any tags that do not have
9828 a selection character.  The command then hides all entries that
9829 do not contain or inherit this tag.  When called with prefix
9830 argument, remove the entries that @emph{do} have the tag.  A second
9831 @kbd{/} at the prompt turns off the filter and shows any
9832 hidden entries.  Pressing @kbd{+} or @kbd{-} switches
9833 between filtering and excluding the next tag.
9835 @vindex org-agenda-auto-exclude-function
9836 Org also supports automatic, context-aware tag filtering.  If the
9837 variable @code{org-agenda-auto-exclude-function} is set to
9838 a user-defined function, that function can decide which tags
9839 should be excluded from the agenda automatically.  Once this is
9840 set, the @kbd{/} command then accepts @kbd{@key{RET}} as
9841 a sub-option key and runs the auto exclusion logic.  For example,
9842 let's say you use a @samp{Net} tag to identify tasks which need
9843 network access, an @samp{Errand} tag for errands in town, and a @samp{Call}
9844 tag for making phone calls.  You could auto-exclude these tags
9845 based on the availability of the Internet, and outside of
9846 business hours, with something like this:
9848 @lisp
9849 (defun org-my-auto-exclude-function (tag)
9850   (and (cond
9851         ((string= tag "Net")
9852          (/= 0 (call-process "/sbin/ping" nil nil nil
9853                              "-c1" "-q" "-t1" "mail.gnu.org")))
9854         ((or (string= tag "Errand") (string= tag "Call"))
9855          (let ((hour (nth 2 (decode-time))))
9856            (or (< hour 8) (> hour 21)))))
9857        (concat "-" tag)))
9859 (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
9860 @end lisp
9862 @item @kbd{<} (@code{org-agenda-filter-by-category})
9863 @findex org-agenda-filter-by-category
9864 Filter the current agenda view with respect to the category of
9865 the item at point.  Pressing @kbd{<} another time removes
9866 this filter.  When called with a prefix argument exclude the
9867 category of the item at point from the agenda.
9869 @vindex org-agenda-category-filter-preset
9870 You can add a filter preset in custom agenda commands through the
9871 option @code{org-agenda-category-filter-preset}.  See @ref{Setting options}.
9873 @item @kbd{^} (@code{org-agenda-filter-by-top-headline})
9874 @findex org-agenda-filter-by-top-headline
9875 Filter the current agenda view and only display the siblings and
9876 the parent headline of the one at point.
9878 @item @kbd{=} (@code{org-agenda-filter-by-regexp})
9879 @findex org-agenda-filter-by-regexp
9880 Filter the agenda view by a regular expression: only show agenda
9881 entries matching the regular expression the user entered.  When
9882 called with a prefix argument, it filters @emph{out} entries matching
9883 the regexp.  With two universal prefix arguments, it removes all
9884 the regexp filters, which can be accumulated.
9886 @vindex org-agenda-regexp-filter-preset
9887 You can add a filter preset in custom agenda commands through the
9888 option @code{org-agenda-regexp-filter-preset}.  See @ref{Setting options}.
9890 @item @kbd{_} (@code{org-agenda-filter-by-effort})
9891 @findex org-agenda-filter-by-effort
9892 Filter the agenda view with respect to effort estimates.  You
9893 first need to set up allowed efforts globally, for example
9895 @lisp
9896 (setq org-global-properties
9897       '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
9898 @end lisp
9900 @vindex org-sort-agenda-noeffort-is-high
9901 You can then filter for an effort by first typing an operator,
9902 one of @kbd{<}, @kbd{>} and @kbd{=}, and then the
9903 one-digit index of an effort estimate in your array of allowed
9904 values, where @kbd{0} means the 10th value.  The filter then
9905 restricts to entries with effort smaller-or-equal, equal, or
9906 larger-or-equal than the selected value.  For application of the
9907 operator, entries without a defined effort are treated according
9908 to the value of @code{org-sort-agenda-noeffort-is-high}.
9910 When called with a prefix argument, it removes entries matching
9911 the condition.  With two universal prefix arguments, it clears
9912 effort filters, which can be accumulated.
9914 @vindex org-agenda-effort-filter-preset
9915 You can add a filter preset in custom agenda commands through the
9916 option @code{org-agenda-effort-filter-preset}.  See @ref{Setting options}.
9918 @item @kbd{|} (@code{org-agenda-filter-remove-all})
9919 Remove all filters in the current agenda view.
9920 @end table
9922 @anchor{Setting limits for the agenda}
9923 @subsubheading Setting limits for the agenda
9925 @cindex limits, in agenda
9927 Here is a list of options that you can set, either globally, or
9928 locally in your custom agenda views (see @ref{Custom Agenda Views}).
9930 @table @asis
9931 @item @code{org-agenda-max-entries}
9932 @vindex org-agenda-max-entries
9933 Limit the number of entries.
9935 @item @code{org-agenda-max-effort}
9936 @vindex org-agenda-max-effort
9937 Limit the duration of accumulated efforts (as minutes).
9939 @item @code{org-agenda-max-todos}
9940 @vindex org-agenda-max-todos
9941 Limit the number of entries with TODO keywords.
9943 @item @code{org-agenda-max-tags}
9944 @vindex org-agenda-max-tags
9945 Limit the number of tagged entries.
9946 @end table
9948 When set to a positive integer, each option excludes entries from
9949 other categories: for example, @code{(setq org-agenda-max-effort 100)}
9950 limits the agenda to 100 minutes of effort and exclude any entry that
9951 has no effort property.  If you want to include entries with no effort
9952 property, use a negative value for @code{org-agenda-max-effort}.  One
9953 useful setup is to use @code{org-agenda-max-entries} locally in a custom
9954 command.  For example, this custom command displays the next five
9955 entries with a @samp{NEXT} TODO keyword.
9957 @lisp
9958 (setq org-agenda-custom-commands
9959       '(("n" todo "NEXT"
9960          ((org-agenda-max-entries 5)))))
9961 @end lisp
9963 Once you mark one of these five entry as DONE, rebuilding the agenda
9964 will again the next five entries again, including the first entry that
9965 was excluded so far.
9967 You can also dynamically set temporary limits, which are lost when
9968 rebuilding the agenda:
9970 @table @asis
9971 @item @kbd{~} (@code{org-agenda-limit-interactively})
9972 @findex org-agenda-limit-interactively
9973 This prompts for the type of limit to apply and its value.
9974 @end table
9976 @node Agenda Commands
9977 @section Commands in the Agenda Buffer
9979 @cindex commands, in agenda buffer
9981 Entries in the agenda buffer are linked back to the Org file or diary
9982 file where they originate.  You are not allowed to edit the agenda
9983 buffer itself, but commands are provided to show and jump to the
9984 original entry location, and to edit the Org files ``remotely'' from the
9985 agenda buffer.  In this way, all information is stored only once,
9986 removing the risk that your agenda and note files may diverge.
9988 Some commands can be executed with mouse clicks on agenda lines.  For
9989 the other commands, the cursor needs to be in the desired line.
9991 @anchor{Motion (1)}
9992 @subheading Motion
9994 @cindex motion commands in agenda
9996 @table @asis
9997 @item @kbd{n} (@code{org-agenda-next-line})
9998 @kindex n
9999 @findex org-agenda-next-line
10000 Next line (same as @kbd{@key{DOWN}} and @kbd{C-n}).
10002 @item @kbd{p} (@code{org-agenda-previous-line})
10003 @kindex p
10004 @findex org-agenda-previous-line
10005 Previous line (same as @kbd{@key{UP}} and @kbd{C-p}).
10006 @end table
10008 @anchor{View/Go to Org file}
10009 @subheading View/Go to Org file
10011 @cindex view file commands in agenda
10013 @table @asis
10014 @item @kbd{@key{SPC}} or @kbd{mouse-3} (@code{org-agenda-show-and-scroll-up})
10015 @kindex SPC
10016 @kindex mouse-3
10017 @findex org-agenda-show-and-scroll-up
10018 Display the original location of the item in another window.
10019 With a prefix argument, make sure that drawers stay folded.
10021 @item @kbd{L} (@code{org-agenda-recenter})
10022 @findex org-agenda-recenter
10023 Display original location and recenter that window.
10025 @item @kbd{@key{TAB}} or @kbd{mouse-2} (@code{org-agenda-goto})
10026 @kindex TAB
10027 @kindex mouse-2
10028 @findex org-agenda-goto
10029 Go to the original location of the item in another window.
10031 @item @kbd{@key{RET}} (@code{org-agenda-switch-to})
10032 @kindex RET
10033 @findex org-agenda-switch-to
10034 Go to the original location of the item and delete other windows.
10036 @item @kbd{F} (@code{org-agenda-follow-mode})
10037 @kindex F
10038 @findex org-agenda-follow-mode
10039 @vindex org-agenda-start-with-follow-mode
10040 Toggle Follow mode.  In Follow mode, as you move the cursor
10041 through the agenda buffer, the other window always shows the
10042 corresponding location in the Org file.  The initial setting for
10043 this mode in new agenda buffers can be set with the variable
10044 @code{org-agenda-start-with-follow-mode}.
10046 @item @kbd{C-c C-x b} (@code{org-agenda-tree-to-indirect-buffer})
10047 @kindex C-c C-x b
10048 @findex org-agenda-tree-to-indirect-buffer
10049 Display the entire subtree of the current item in an indirect
10050 buffer.  With a numeric prefix argument N, go up to level N and
10051 then take that tree.  If N is negative, go up that many levels.
10052 With a @kbd{C-u} prefix, do not remove the previously used
10053 indirect buffer.
10055 @item @kbd{C-c C-o} (@code{org-agenda-open-link})
10056 @kindex C-c C-o
10057 @findex org-agenda-open-link
10058 Follow a link in the entry.  This offers a selection of any links
10059 in the text belonging to the referenced Org node.  If there is
10060 only one link, follow it without a selection prompt.
10061 @end table
10063 @anchor{Change display}
10064 @subheading Change display
10066 @cindex change agenda display
10067 @cindex display changing, in agenda
10069 @table @asis
10070 @item @kbd{A}
10071 @kindex A
10072 Interactively select another agenda view and append it to the
10073 current view.
10075 @item @kbd{o}
10076 @kindex o
10077 Delete other windows.
10079 @item @kbd{v d} or short @kbd{d} (@code{org-agenda-day-view})
10080 @kindex v d
10081 @kindex d
10082 @findex org-agenda-day-view
10083 Switch to day view.  When switching to day view, this setting
10084 becomes the default for subsequent agenda refreshes.  A numeric
10085 prefix argument may be used to jump directly to a specific day of
10086 the year.  For example, @kbd{32 d} jumps to February 1st.
10087 When setting day view, a year may be encoded in the prefix
10088 argument as well.  For example, @kbd{200712 d} jumps to
10089 January 12, 2007.  If such a year specification has only one or
10090 two digits, it is expanded into one of the 30 next years or the
10091 last 69 years.
10093 @item @kbd{v w} or short @kbd{w} (@code{org-agenda-week-view})
10094 @kindex v w
10095 @kindex w
10096 @findex org-agenda-week-view
10097 Switch to week view.  When switching week view, this setting
10098 becomes the default for subsequent agenda refreshes.  A numeric
10099 prefix argument may be used to jump directly to a specific day of
10100 the ISO week.  For example @kbd{9 w} to ISO week number 9.
10101 When setting week view, a year may be encoded in the prefix
10102 argument as well.  For example, @kbd{200712 w} jumps to week
10103 12 in 2007.  If such a year specification has only one or two
10104 digits, it is expanded into one of the 30 next years or the last
10105 69 years.
10107 @item @kbd{v m} (@code{org-agenda-month-view})
10108 @kindex v m
10109 @findex org-agenda-month-view
10110 Switch to month view.  Because month views are slow to create,
10111 they do not become the default for subsequent agenda refreshes.
10112 A numeric prefix argument may be used to jump directly to
10113 a specific day of the month.  When setting month view, a year may
10114 be encoded in the prefix argument as well.  For example,
10115 @kbd{200712 m} jumps to December, 2007.  If such a year
10116 specification has only one or two digits, it is expanded into one
10117 of the 30 next years or the last 69 years.
10119 @item @kbd{v y} (@code{org-agenda-year-view})
10120 @kindex v y
10121 @findex org-agenda-year-view
10122 Switch to year view.  Because year views are slow to create, they
10123 do not become the default for subsequent agenda refreshes.
10124 A numeric prefix argument may be used to jump directly to
10125 a specific day of the year.
10127 @item @kbd{v @key{SPC}} (@code{org-agenda-reset-view})
10128 @kindex v SPC
10129 @findex org-agenda-reset-view
10130 @vindex org-agenda-span
10131 Reset the current view to @code{org-agenda-span}.
10133 @item @kbd{f} (@code{org-agenda-later})
10134 @kindex f
10135 @findex org-agenda-later
10136 Go forward in time to display the span following the current one.
10137 For example, if the display covers a week, switch to the
10138 following week.  With a prefix argument, repeat that many times.
10140 @item @kbd{b} (@code{org-agenda-earlier})
10141 @kindex b
10142 @findex org-agenda-earlier
10143 Go backward in time to display earlier dates.
10145 @item @kbd{.} (@code{org-agenda-goto-today})
10146 @kindex .
10147 @findex org-agenda-goto-today
10148 Go to today.
10150 @item @kbd{j} (@code{org-agenda-goto-date})
10151 @kindex j
10152 @findex org-agenda-goto-date
10153 Prompt for a date and go there.
10155 @item @kbd{J} (@code{org-agenda-clock-goto})
10156 @kindex J
10157 @findex org-agenda-clock-goto
10158 Go to the currently clocked-in task @emph{in the agenda buffer}.
10160 @item @kbd{D} (@code{org-agenda-toggle-diary})
10161 @kindex D
10162 @findex org-agenda-toggle-diary
10163 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
10165 @item @kbd{v l} or @kbd{v L} or short @kbd{l} (@code{org-agenda-log-mode})
10166 @kindex v l
10167 @kindex l
10168 @kindex v L
10169 @findex org-agenda-log-mode
10170 @vindex org-log-done
10171 @vindex org-agenda-log-mode-items
10172 Toggle Logbook mode.  In Logbook mode, entries that were marked
10173 DONE while logging was on (see the variable @code{org-log-done}) are
10174 shown in the agenda, as are entries that have been clocked on
10175 that day.  You can configure the entry types that should be
10176 included in log mode using the variable
10177 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u}
10178 prefix, show all possible logbook entries, including state
10179 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}.
10181 @item @kbd{v [} or short @kbd{[} (@code{org-agenda-manipulate-query-add})
10182 @kindex v [
10183 @kindex [
10184 @findex org-agenda-manipulate-query-add
10185 Include inactive timestamps into the current view.  Only for
10186 weekly/daily agenda and timeline views.
10188 @item @kbd{v a} (@code{org-agenda-archives-mode})
10189 @kindex v a
10190 @findex org-agenda-archives-mode
10191 Toggle Archives mode.  In Archives mode, trees that are archived
10192 (see @ref{Internal archiving}) are also scanned when producing the
10193 agenda.  To exit archives mode, press @kbd{v a} again.
10195 @item @kbd{v A}
10196 @kindex v A
10197 Toggle Archives mode.  Include all archive files as well.
10199 @item @kbd{v R} or short @kbd{R} (@code{org-agenda-clockreport-mode})
10200 @kindex v R
10201 @kindex R
10202 @findex org-agenda-clockreport-mode
10203 @vindex org-agenda-start-with-clockreport-mode
10204 @vindex org-clock-report-include-clocking-task
10205 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly
10206 agenda always shows a table with the clocked times for the time
10207 span and file scope covered by the current agenda view.  The
10208 initial setting for this mode in new agenda buffers can be set
10209 with the variable @code{org-agenda-start-with-clockreport-mode}.  By
10210 using a prefix argument when toggling this mode (i.e., @kbd{C-u R}), the clock table does not show contributions from entries
10211 that are hidden by agenda filtering@footnote{Only tags filtering is respected here, effort filtering is
10212 ignored.}.  See also the
10213 variable @code{org-clock-report-include-clocking-task}.
10215 @item @kbd{v c}
10216 @kindex v c
10217 @vindex org-agenda-clock-consistency-checks
10218 Show overlapping clock entries, clocking gaps, and other clocking
10219 problems in the current agenda range.  You can then visit
10220 clocking lines and fix them manually.  See the variable
10221 @code{org-agenda-clock-consistency-checks} for information on how to
10222 customize the definition of what constituted a clocking problem.
10223 To return to normal agenda display, press @kbd{l} to exit
10224 Logbook mode.
10226 @item @kbd{v E} or short @kbd{E} (@code{org-agenda-entry-text-mode})
10227 @kindex v E
10228 @kindex E
10229 @findex org-agenda-entry-text-mode
10230 @vindex org-agenda-start-with-entry-text-mode
10231 @vindex org-agenda-entry-text-maxlines
10232 Toggle entry text mode.  In entry text mode, a number of lines
10233 from the Org outline node referenced by an agenda line are
10234 displayed below the line.  The maximum number of lines is given
10235 by the variable @code{org-agenda-entry-text-maxlines}.  Calling this
10236 command with a numeric prefix argument temporarily modifies that
10237 number to the prefix value.
10239 @item @kbd{G} (@code{org-agenda-toggle-time-grid})
10240 @kindex G
10241 @vindex org-agenda-use-time-grid
10242 @vindex org-agenda-time-grid
10243 Toggle the time grid on and off.  See also the variables
10244 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
10246 @item @kbd{r} (@code{org-agenda-redo})
10247 @itemx @kbd{g}
10248 @kindex r
10249 @kindex g
10250 @findex org-agenda-redo
10251 Recreate the agenda buffer, for example to reflect the changes
10252 after modification of the timestamps of items with
10253 @kbd{S-@key{LEFT}} and @kbd{S-@key{RIGHT}}.  When the
10254 buffer is the global TODO list, a prefix argument is interpreted
10255 to create a selective list for a specific TODO keyword.
10257 @item @kbd{C-x C-s} or short @kbd{s} (@code{org-save-all-org-buffers})
10258 @kindex C-x C-s
10259 @findex org-save-all-org-buffers
10260 @kindex s
10261 Save all Org buffers in the current Emacs session, and also the
10262 locations of IDs.
10264 @item @kbd{C-c C-x C-c} (@code{org-agenda-columns})
10265 @kindex C-c C-x C-c
10266 @findex org-agenda-columns
10267 @vindex org-columns-default-format
10268 Invoke column view (see @ref{Column View}) in the agenda buffer.  The
10269 column view format is taken from the entry at point, or, if there
10270 is no entry at point, from the first entry in the agenda view.
10271 So whatever the format for that entry would be in the original
10272 buffer (taken from a property, from a @samp{COLUMNS} keyword, or from
10273 the default variable @code{org-columns-default-format}) is used in the
10274 agenda.
10276 @item @kbd{C-c C-x >} (@code{org-agenda-remove-restriction-lock})
10277 @kindex C-c C-x >
10278 @findex org-agenda-remove-restriction-lock
10279 Remove the restriction lock on the agenda, if it is currently
10280 restricted to a file or subtree (see @ref{Agenda Files}).
10282 @item @kbd{M-@key{UP}} (@code{org-agenda-drag-line-backward})
10283 @kindex M-UP
10284 @findex org-agenda-drag-line-backward
10285 Drag the line at point backward one line.  With a numeric prefix
10286 argument, drag backward by that many lines.
10288 Moving agenda lines does not persist after an agenda refresh and
10289 does not modify the contributing Org files.
10291 @item @kbd{M-@key{DOWN}} (@code{org-agenda-drag-line-forward})
10292 @kindex M-DOWN
10293 @findex org-agenda-drag-line-forward
10294 Drag the line at point forward one line.  With a numeric prefix
10295 argument, drag forward by that many lines.
10296 @end table
10298 @anchor{Remote editing}
10299 @subheading Remote editing
10301 @cindex remote editing, from agenda
10303 @table @asis
10304 @item @kbd{0--9}
10305 Digit argument.
10307 @item @kbd{C-_} (@code{org-agenda-undo})
10308 @kindex C-_
10309 @findex org-agenda-undo
10310 @cindex undoing remote-editing events
10311 @cindex remote editing, undo
10312 Undo a change due to a remote editing command.  The change is
10313 undone both in the agenda buffer and in the remote buffer.
10315 @item @kbd{t} (@code{org-agenda-todo})
10316 @kindex t
10317 @findex org-agenda-todo
10318 Change the TODO state of the item, both in the agenda and in the
10319 original Org file.
10321 @item @kbd{C-S-@key{RIGHT}} (@code{org-agenda-todo-nextset})
10322 @kindex C-S-RIGHT
10323 @findex org-agenda-todo-nextset
10324 Switch to the next set of TODO keywords.
10326 @item @kbd{C-S-@key{LEFT}}, @code{org-agenda-todo-previousset}
10327 @kindex C-S-LEFT
10328 Switch to the previous set of TODO keywords.
10330 @item @kbd{C-k} (@code{org-agenda-kill})
10331 @kindex C-k
10332 @findex org-agenda-kill
10333 @vindex org-agenda-confirm-kill
10334 Delete the current agenda item along with the entire subtree
10335 belonging to it in the original Org file.  If the text to be
10336 deleted remotely is longer than one line, the kill needs to be
10337 confirmed by the user.  See variable @code{org-agenda-confirm-kill}.
10339 @item @kbd{C-c C-w} (@code{org-agenda-refile})
10340 @kindex C-c C-w
10341 @findex org-agenda-refile
10342 Refile the entry at point.
10344 @item @kbd{C-c C-x C-a} or short @kbd{a} (@code{org-agenda-archive-default-with-confirmation})
10345 @kindex C-c C-x C-a
10346 @kindex a
10347 @findex org-agenda-archive-default-with-confirmation
10348 @vindex org-archive-default-command
10349 Archive the subtree corresponding to the entry at point using the
10350 default archiving command set in @code{org-archive-default-command}.
10351 When using the @kbd{a} key, confirmation is required.
10353 @item @kbd{C-c C-x a} (@code{org-agenda-toggle-archive-tag})
10354 @kindex C-c C-x a
10355 @findex org-agenda-toggle-archive-tag
10356 Toggle the archive tag (see @ref{Internal archiving}) for the current
10357 headline.
10359 @item @kbd{C-c C-x A} (@code{org-agenda-archive-to-archive-sibling})
10360 @kindex C-c C-x A
10361 @findex org-agenda-archive-to-archive-sibling
10362 Move the subtree corresponding to the current entry to its
10363 @emph{archive sibling}.
10365 @item @kbd{C-c C-x C-s} or short @kbd{$} (@code{org-agenda-archive})
10366 @kindex C-c C-x C-s
10367 @kindex $
10368 @findex org-agenda-archive
10369 Archive the subtree corresponding to the current headline.  This
10370 means the entry is moved to the configured archive location, most
10371 likely a different file.
10373 @item @kbd{T} (@code{org-agenda-show-tags})
10374 @kindex T
10375 @findex org-agenda-show-tags
10376 @vindex org-agenda-show-inherited-tags
10377 Show all tags associated with the current item.  This is useful
10378 if you have turned off @code{org-agenda-show-inherited-tags}, but
10379 still want to see all tags of a headline occasionally.
10381 @item @kbd{:} (@code{org-agenda-set-tags})
10382 @kindex :
10383 @findex org-agenda-set-tags
10384 Set tags for the current headline.  If there is an active region
10385 in the agenda, change a tag for all headings in the region.
10387 @item @kbd{,} (@code{org-agenda-priority})
10388 @kindex ,
10389 @findex org-agenda-priority
10390 Set the priority for the current item.  Org mode prompts for the
10391 priority character.  If you reply with @kbd{@key{SPC}}, the
10392 priority cookie is removed from the entry.
10394 @item @kbd{P} (@code{org-agenda-show-priority})
10395 @kindex P
10396 @findex org-agenda-show-priority
10397 Display weighted priority of current item.
10399 @item @kbd{+} or @kbd{S-@key{UP}} (@code{org-agenda-priority-up})
10400 @kindex +
10401 @kindex S-UP
10402 @findex org-agenda-priority-up
10403 Increase the priority of the current item.  The priority is
10404 changed in the original buffer, but the agenda is not resorted.
10405 Use the @kbd{r} key for this.
10407 @item @kbd{-} or @kbd{S-@key{DOWN}} (@code{org-agenda-priority-down})
10408 @kindex -
10409 @kindex S-DOWN
10410 @findex org-agenda-priority-down
10411 Decrease the priority of the current item.
10413 @item @kbd{C-c C-z} or short @kbd{z} (@code{org-agenda-add-note})
10414 @kindex z
10415 @kindex C-c C-z
10416 @findex org-agenda-add-note
10417 @vindex org-log-into-drawer
10418 Add a note to the entry.  This note is recorded, and then filed
10419 to the same location where state change notes are put.  Depending
10420 on @code{org-log-into-drawer}, this may be inside a drawer.
10422 @item @kbd{C-c C-a} (@code{org-attach})
10423 @kindex C-c C-a
10424 @findex org-attach
10425 Dispatcher for all command related to attachments.
10427 @item @kbd{C-c C-s} (@code{org-agenda-schedule})
10428 @kindex C-c C-s
10429 @findex org-agenda-schedule
10430 Schedule this item.  With a prefix argument, remove the
10431 scheduling timestamp
10433 @item @kbd{C-c C-d} (@code{org-agenda-deadline})
10434 @kindex C-c C-d
10435 @findex org-agenda-deadline
10436 Set a deadline for this item.  With a prefix argument, remove the
10437 deadline.
10439 @item @kbd{S-@key{RIGHT}} (@code{org-agenda-do-date-later})
10440 @kindex S-RIGHT
10441 @findex org-agenda-do-date-later
10442 Change the timestamp associated with the current line by one day
10443 into the future.  If the date is in the past, the first call to
10444 this command moves it to today.  With a numeric prefix argument,
10445 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}
10446 prefix, change the time by one hour.  If you immediately repeat
10447 the command, it will continue to change hours even without the
10448 prefix argument.  With a double @kbd{C-u C-u} prefix, do the
10449 same for changing minutes.  The stamp is changed in the original
10450 Org file, but the change is not directly reflected in the agenda
10451 buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
10453 @item @kbd{S-@key{LEFT}} (@code{org-agenda-do-date-earlier})
10454 @kindex S-LEFT
10455 @findex org-agenda-do-date-earlier
10456 Change the timestamp associated with the current line by one day
10457 into the past.
10459 @item @kbd{>} (@code{org-agenda-date-prompt})
10460 @kindex >
10461 @findex org-agenda-date-prompt
10462 Change the timestamp associated with the current line.  The key
10463 @kbd{>} has been chosen, because it is the same as
10464 @kbd{S-.}  on my keyboard.
10466 @item @kbd{I} (@code{org-agenda-clock-in})
10467 @kindex I
10468 @findex org-agenda-clock-in
10469 Start the clock on the current item.  If a clock is running
10470 already, it is stopped first.
10472 @item @kbd{O} (@code{org-agenda-clock-out})
10473 @kindex O
10474 @findex org-agenda-clock-out
10475 Stop the previously started clock.
10477 @item @kbd{X} (@code{org-agenda-clock-cancel})
10478 @kindex X
10479 @findex org-agenda-clock-cancel
10480 Cancel the currently running clock.
10482 @item @kbd{J} (@code{org-agenda-clock-goto})
10483 @kindex J
10484 @findex org-agenda-clock-goto
10485 Jump to the running clock in another window.
10487 @item @kbd{k} (@code{org-agenda-capture})
10488 @kindex k
10489 @findex org-agenda-capture
10490 @cindex capturing, from agenda
10491 @vindex org-capture-use-agenda-date
10492 Like @code{org-capture}, but use the date at point as the default date
10493 for the capture template.  See @code{org-capture-use-agenda-date} to
10494 make this the default behavior of @code{org-capture}.
10495 @end table
10497 @anchor{Bulk remote editing selected entries}
10498 @subheading Bulk remote editing selected entries
10500 @cindex remote editing, bulk, from agenda
10501 @vindex org-agenda-bulk-custom-functions
10503 @table @asis
10504 @item @kbd{m} (@code{org-agenda-bulk-mark})
10505 @kindex m
10506 @findex org-agenda-bulk-mark
10508 Mark the entry at point for bulk action.  If there is an active
10509 region in the agenda, mark the entries in the region.  With
10510 numeric prefix argument, mark that many successive entries.
10512 @item @kbd{*} (@code{org-agenda-bulk-mark-all})
10513 @kindex *
10514 @findex org-agenda-bulk-mark-all
10516 Mark all visible agenda entries for bulk action.
10518 @item @kbd{u} (@code{org-agenda-bulk-unmark})
10519 @kindex u
10520 @findex org-agenda-bulk-unmark
10522 Unmark entry for bulk action.
10524 @item @kbd{U} (@code{org-agenda-bulk-remove-all-marks})
10525 @kindex U
10526 @findex org-agenda-bulk-remove-all-marks
10528 Unmark all marked entries for bulk action.
10530 @item @kbd{M-m} (@code{org-agenda-bulk-toggle})
10531 @kindex M-m
10532 @findex org-agenda-bulk-toggle
10534 Toggle mark of the entry at point for bulk action.
10536 @item @kbd{M-*} (@code{org-agenda-bulk-toggle-all})
10537 @kindex M-*
10538 @findex org-agenda-bulk-toggle-all
10540 Mark entries matching a regular expression for bulk action.
10542 @item @kbd{%} (@code{org-agenda-bulk-mark-regexp})
10543 @kindex %
10544 @findex org-agenda-bulk-mark-regexp
10546 Mark entries matching a regular expression for bulk action.
10548 @item @kbd{B} (@code{org-agenda-bulk-action})
10549 @kindex B
10550 @findex org-agenda-bulk-action
10551 @vindex org-agenda-bulk-persistent-marks
10553 Bulk action: act on all marked entries in the agenda.  This
10554 prompts for another key to select the action to be applied.  The
10555 prefix argument to @kbd{B} is passed through to the
10556 @kbd{s} and @kbd{d} commands, to bulk-remove these
10557 special timestamps.  By default, marks are removed after the
10558 bulk.  If you want them to persist, set
10559 @code{org-agenda-bulk-persistent-marks} to @code{t} or hit @kbd{p} at
10560 the prompt.
10562 @table @asis
10563 @item @kbd{*}
10564 Toggle persistent marks.
10566 @item @kbd{$}
10567 Archive all selected entries.
10569 @item @kbd{A}
10570 Archive entries by moving them to their respective archive
10571 siblings.
10573 @item @kbd{t}
10574 Change TODO state.  This prompts for a single TODO keyword and
10575 changes the state of all selected entries, bypassing blocking
10576 and suppressing logging notes---but not timestamps.
10578 @item @kbd{+}
10579 Add a tag to all selected entries.
10581 @item @kbd{-}
10582 Remove a tag from all selected entries.
10584 @item @kbd{s}
10585 Schedule all items to a new date.  To shift existing schedule
10586 dates by a fixed number of days, use something starting with
10587 double plus at the prompt, for example @samp{++8d} or @samp{++2w}.
10589 @item @kbd{d}
10590 Set deadline to a specific date.
10592 @item @kbd{r}
10593 Prompt for a single refile target and move all entries.  The
10594 entries are no longer in the agenda; refresh (@kbd{g}) to
10595 bring them back.
10597 @item @kbd{S}
10598 Reschedule randomly into the coming N days.  N is prompted for.
10599 With a prefix argument (@kbd{C-u B S}), scatter only
10600 across weekdays.
10602 @item @kbd{f}
10603 @vindex org-agenda-bulk-custom-functions
10604 Apply a function@footnote{You can also create persistent custom functions through
10605 @code{org-agenda-bulk-custom-functions}.} to marked entries.  For example, the
10606 function below sets the @samp{CATEGORY} property of the entries to
10607 @samp{web}.
10609 @lisp
10610 (defun set-category ()
10611   (interactive "P")
10612   (let ((marker (or (org-get-at-bol 'org-hd-marker)
10613                     (org-agenda-error))))
10614     (org-with-point-at marker
10615       (org-back-to-heading t)
10616       (org-set-property "CATEGORY" "web"))))
10617 @end lisp
10618 @end table
10619 @end table
10621 @anchor{Calendar commands}
10622 @subheading Calendar commands
10624 @cindex calendar commands, from agenda
10626 @table @asis
10627 @item @kbd{c} (@code{org-agenda-goto-calendar})
10628 @kindex c
10629 @findex org-agenda-goto-calendar
10630 Open the Emacs calendar and move to the date at the agenda
10631 cursor.
10633 @item @kbd{c} (@code{org-calendar-goto-agenda})
10634 @kindex c
10635 @findex org-calendar-goto-agenda
10636 When in the calendar, compute and show the Org agenda for the
10637 date at the cursor.
10639 @item @kbd{i} (@code{org-agenda-diary-entry})
10640 @kindex i
10641 @findex org-agenda-diary-entry
10643 @cindex diary entries, creating from agenda
10644 Insert a new entry into the diary, using the date at the cursor
10645 and (for block entries) the date at the mark.  This adds to the
10646 Emacs diary file@footnote{This file is parsed for the agenda when
10647 @code{org-agenda-include-diary} is set.}, in a way similar to the @kbd{i}
10648 command in the calendar.  The diary file pops up in another
10649 window, where you can add the entry.
10651 @vindex org-agenda-diary-file
10652 If you configure @code{org-agenda-diary-file} to point to an Org file,
10653 Org creates entries in that file instead.  Most entries are
10654 stored in a date-based outline tree that will later make it easy
10655 to archive appointments from previous months/years.  The tree is
10656 built under an entry with a @samp{DATE_TREE} property, or else with
10657 years as top-level entries.  Emacs prompts you for the entry
10658 text---if you specify it, the entry is created in
10659 @code{org-agenda-diary-file} without further interaction.  If you
10660 directly press @kbd{@key{RET}} at the prompt without typing text,
10661 the target file is shown in another window for you to finish the
10662 entry there.  See also the @kbd{k r} command.
10664 @item @kbd{M} (@code{org-agenda-phases-of-moon})
10665 @kindex M
10666 @findex org-agenda-phases-of-moon
10667 Show the phases of the moon for the three months around current
10668 date.
10670 @item @kbd{S} (@code{org-agenda-sunrise-sunset})
10671 @kindex S
10672 @findex org-agenda-sunrise-sunset
10673 Show sunrise and sunset times.  The geographical location must be
10674 set with calendar variables, see the documentation for the Emacs
10675 calendar.
10677 @item @kbd{C} (@code{org-agenda-convert-date})
10678 @kindex C
10679 @findex org-agenda-convert-date
10680 Convert the date at cursor into many other cultural and historic
10681 calendars.
10683 @item @kbd{H} (@code{org-agenda-holidays})
10684 @kindex H
10685 @findex org-agenda-holidays
10686 Show holidays for three months around the cursor date.
10687 @end table
10689 @anchor{Quit and exit}
10690 @subheading Quit and exit
10692 @table @asis
10693 @item @kbd{q} (@code{org-agenda-quit})
10694 @kindex q
10695 @findex org-agenda-quit
10697 Quit agenda, remove the agenda buffer.
10699 @item @kbd{x} (@code{org-agenda-exit})
10700 @kindex x
10701 @findex org-agenda-exit
10703 @cindex agenda files, removing buffers
10704 Exit agenda, remove the agenda buffer and all buffers loaded by
10705 Emacs for the compilation of the agenda.  Buffers created by the
10706 user to visit Org files are not removed.
10707 @end table
10709 @node Custom Agenda Views
10710 @section Custom Agenda Views
10712 @cindex custom agenda views
10713 @cindex agenda views, custom
10715 Custom agenda commands serve two purposes: to store and quickly access
10716 frequently used TODO and tags searches, and to create special
10717 composite agenda buffers.  Custom agenda commands are accessible
10718 through the dispatcher (see @ref{Agenda Dispatcher}), just like the
10719 default commands.
10721 @menu
10722 * Storing searches::             Type once, use often.
10723 * Block agenda::                 All the stuff you need in a single buffer.
10724 * Setting options::              Changing the rules.
10725 @end menu
10727 @node Storing searches
10728 @subsection Storing searches
10730 The first application of custom searches is the definition of keyboard
10731 shortcuts for frequently used searches, either creating an agenda
10732 buffer, or a sparse tree (the latter covering of course only the
10733 current buffer).
10735 @kindex C @r{(Agenda dispatcher)}
10736 @vindex org-agenda-custom-commands
10737 @cindex agenda views, main example
10738 @cindex agenda, as an agenda views
10739 @cindex agenda*, as an agenda views
10740 @cindex tags, as an agenda view
10741 @cindex todo, as an agenda view
10742 @cindex tags-todo
10743 @cindex todo-tree
10744 @cindex occur-tree
10745 @cindex tags-tree
10746 Custom commands are configured in the variable
10747 @code{org-agenda-custom-commands}.  You can customize this variable, for
10748 example by pressing @kbd{C} from the agenda dispatcher (see @ref{Agenda Dispatcher}).  You can also directly set it with Emacs Lisp in
10749 the Emacs init file.  The following example contains all valid agenda
10750 views:
10752 @lisp
10753 (setq org-agenda-custom-commands
10754       '(("x" agenda)
10755         ("y" agenda*)
10756         ("w" todo "WAITING")
10757         ("W" todo-tree "WAITING")
10758         ("u" tags "+boss-urgent")
10759         ("v" tags-todo "+boss-urgent")
10760         ("U" tags-tree "+boss-urgent")
10761         ("f" occur-tree "\\<FIXME\\>")
10762         ("h" . "HOME+Name tags searches") ;description for "h" prefix
10763         ("hl" tags "+home+Lisa")
10764         ("hp" tags "+home+Peter")
10765         ("hk" tags "+home+Kim")))
10766 @end lisp
10768 @noindent
10769 The initial string in each entry defines the keys you have to press
10770 after the dispatcher command in order to access the command.  Usually
10771 this will be just a single character, but if you have many similar
10772 commands, you can also define two-letter combinations where the first
10773 character is the same in several combinations and serves as a prefix
10774 key@footnote{You can provide a description for a prefix key by inserting
10775 a cons cell with the prefix and the description.}.  The second parameter is the search type, followed by the
10776 string or regular expression to be used for the matching.  The example
10777 above will therefore define:
10779 @table @asis
10780 @item @kbd{x}
10781 as a global search for agenda entries planned@footnote{@emph{Planned} means here that these entries have some planning
10782 information attached to them, like a time-stamp, a scheduled or
10783 a deadline string.  See @code{org-agenda-entry-types} on how to set what
10784 planning information is taken into account.} this
10785 week/day.
10787 @item @kbd{y}
10788 as the same search, but only for entries with an hour
10789 specification like @samp{[h]h:mm}---think of them as appointments.
10791 @item @kbd{w}
10792 as a global search for TODO entries with @samp{WAITING} as the TODO
10793 keyword.
10795 @item @kbd{W}
10796 as the same search, but only in the current buffer and displaying
10797 the results as a sparse tree.
10799 @item @kbd{u}
10800 as a global tags search for headlines tagged @samp{boss} but not
10801 @samp{urgent}.
10803 @item @kbd{v}
10804 The same search, but limiting it to headlines that are also TODO
10805 items.
10807 @item @kbd{U}
10808 as the same search, but only in the current buffer and displaying
10809 the result as a sparse tree.
10811 @item @kbd{f}
10812 to create a sparse tree (again, current buffer only) with all
10813 entries containing the word @samp{FIXME}.
10815 @item @kbd{h}
10816 as a prefix command for a @samp{HOME} tags search where you have to
10817 press an additional key (@kbd{l}, @kbd{p} or
10818 @kbd{k}) to select a name (Lisa, Peter, or Kim) as
10819 additional tag to match.
10820 @end table
10822 Note that @code{*-tree} agenda views need to be called from an Org buffer
10823 as they operate on the current buffer only.
10825 @node Block agenda
10826 @subsection Block agenda
10828 @cindex block agenda
10829 @cindex agenda, with block views
10831 Another possibility is the construction of agenda views that comprise
10832 the results of @emph{several} commands, each of which creates a block in
10833 the agenda buffer.  The available commands include @code{agenda} for the
10834 daily or weekly agenda (as created with @kbd{a}) , @code{alltodo} for
10835 the global TODO list (as constructed with @kbd{t}), and the
10836 matching commands discussed above: @code{todo}, @code{tags}, and @code{tags-todo}.
10837 Here are two examples:
10839 @lisp
10840 (setq org-agenda-custom-commands
10841       '(("h" "Agenda and Home-related tasks"
10842          ((agenda "")
10843           (tags-todo "home")
10844           (tags "garden")))
10845         ("o" "Agenda and Office-related tasks"
10846          ((agenda "")
10847           (tags-todo "work")
10848           (tags "office")))))
10849 @end lisp
10851 @noindent
10852 This defines @kbd{h} to create a multi-block view for stuff you
10853 need to attend to at home.  The resulting agenda buffer contains your
10854 agenda for the current week, all TODO items that carry the tag @samp{home},
10855 and also all lines tagged with @samp{garden}.  Finally the command
10856 @kbd{o} provides a similar view for office tasks.
10858 @node Setting options
10859 @subsection Setting options for custom commands
10861 @cindex options, for custom agenda views
10863 @vindex org-agenda-custom-commands
10864 Org mode contains a number of variables regulating agenda construction
10865 and display.  The global variables define the behavior for all agenda
10866 commands, including the custom commands.  However, if you want to
10867 change some settings just for a single custom view, you can do so.
10868 Setting options requires inserting a list of variable names and values
10869 at the right spot in @code{org-agenda-custom-commands}.  For example:
10871 @lisp
10872 (setq org-agenda-custom-commands
10873       '(("w" todo "WAITING"
10874          ((org-agenda-sorting-strategy '(priority-down))
10875           (org-agenda-prefix-format "  Mixed: ")))
10876         ("U" tags-tree "+boss-urgent"
10877          ((org-show-context-detail 'minimal)))
10878         ("N" search ""
10879          ((org-agenda-files '("~org/notes.org"))
10880           (org-agenda-text-search-extra-files nil)))))
10881 @end lisp
10883 @noindent
10884 Now the @kbd{w} command sorts the collected entries only by
10885 priority, and the prefix format is modified to just say @samp{Mixed:}
10886 instead of giving the category of the entry.  The sparse tags tree of
10887 @kbd{U} now turns out ultra-compact, because neither the headline
10888 hierarchy above the match, nor the headline following the match are
10889 shown.  The command @kbd{N} does a text search limited to only
10890 a single file.
10892 For command sets creating a block agenda, @code{org-agenda-custom-commands}
10893 has two separate spots for setting options.  You can add options that
10894 should be valid for just a single command in the set, and options that
10895 should be valid for all commands in the set.  The former are just
10896 added to the command entry; the latter must come after the list of
10897 command entries.  Going back to the block agenda example (see @ref{Block agenda}), let's change the sorting strategy for the @kbd{h}
10898 commands to @code{priority-down}, but let's sort the results for GARDEN
10899 tags query in the opposite order, @code{priority-up}.  This would look like
10900 this:
10902 @lisp
10903 (setq org-agenda-custom-commands
10904       '(("h" "Agenda and Home-related tasks"
10905          ((agenda)
10906           (tags-todo "home")
10907           (tags "garden"
10908                 ((org-agenda-sorting-strategy '(priority-up)))))
10909          ((org-agenda-sorting-strategy '(priority-down))))
10910         ("o" "Agenda and Office-related tasks"
10911          ((agenda)
10912           (tags-todo "work")
10913           (tags "office")))))
10914 @end lisp
10916 As you see, the values and parentheses setting is a little complex.
10917 When in doubt, use the customize interface to set this variable---it
10918 fully supports its structure.  Just one caveat: when setting options
10919 in this interface, the @emph{values} are just Lisp expressions.  So if the
10920 value is a string, you need to add the double-quotes around the value
10921 yourself.
10923 @vindex org-agenda-custom-commands-contexts
10924 To control whether an agenda command should be accessible from
10925 a specific context, you can customize
10926 @code{org-agenda-custom-commands-contexts}.  Let's say for example that you
10927 have an agenda command @kbd{o} displaying a view that you only
10928 need when reading emails.  Then you would configure this option like
10929 this:
10931 @lisp
10932 (setq org-agenda-custom-commands-contexts
10933       '(("o" (in-mode . "message-mode"))))
10934 @end lisp
10936 You can also tell that the command key @kbd{o} should refer to
10937 another command key @kbd{r}.  In that case, add this command key
10938 like this:
10940 @lisp
10941 (setq org-agenda-custom-commands-contexts
10942       '(("o" "r" (in-mode . "message-mode"))))
10943 @end lisp
10945 See the docstring of the variable for more information.
10947 @node Exporting Agenda Views
10948 @section Exporting Agenda Views
10950 @cindex agenda views, exporting
10952 If you are away from your computer, it can be very useful to have
10953 a printed version of some agenda views to carry around.  Org mode can
10954 export custom agenda views as plain text, HTML@footnote{For HTML you need to install Hrvoje Niksic's @samp{htmlize.el}
10955 from @uref{https://github.com/hniksic/emacs-htmlize, Hrvoje Niksic's repository}.}, Postscript,
10956 PDF@footnote{To create PDF output, the Ghostscript ps2pdf utility must be
10957 installed on the system.  Selecting a PDF file also creates the
10958 postscript file.}, and iCalendar files.  If you want to do this only
10959 occasionally, use the following command:
10961 @table @asis
10962 @item @kbd{C-x C-w} (@code{org-agenda-write})
10963 @kindex C-x C-w
10964 @findex org-agenda-write
10965 @cindex exporting agenda views
10966 @cindex agenda views, exporting
10968 @vindex org-agenda-exporter-settings
10969 Write the agenda view to a file.
10970 @end table
10972 If you need to export certain agenda views frequently, you can
10973 associate any custom agenda command with a list of output file
10974 names@footnote{If you want to store standard views like the weekly agenda or
10975 the global TODO list as well, you need to define custom commands for
10976 them in order to be able to specify file names.}.  Here is an example that first defines custom commands
10977 for the agenda and the global TODO list, together with a number of
10978 files to which to export them.  Then we define two block agenda
10979 commands and specify file names for them as well.  File names can be
10980 relative to the current working directory, or absolute.
10982 @lisp
10983 (setq org-agenda-custom-commands
10984       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
10985         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
10986         ("h" "Agenda and Home-related tasks"
10987          ((agenda "")
10988           (tags-todo "home")
10989           (tags "garden"))
10990          nil
10991          ("~/views/home.html"))
10992         ("o" "Agenda and Office-related tasks"
10993          ((agenda)
10994           (tags-todo "work")
10995           (tags "office"))
10996          nil
10997          ("~/views/office.ps" "~/calendars/office.ics"))))
10998 @end lisp
11000 The extension of the file name determines the type of export.  If it
11001 is @samp{.html}, Org mode uses the htmlize package to convert the buffer to
11002 HTML and save it to this file name.  If the extension is @samp{.ps},
11003 @code{ps-print-buffer-with-faces} is used to produce Postscript output.  If
11004 the extension is @samp{.ics}, iCalendar export is run export over all files
11005 that were used to construct the agenda, and limit the export to
11006 entries listed in the agenda.  Any other extension produces a plain
11007 ASCII file.
11009 The export files are @emph{not} created when you use one of those
11010 commands interactively because this might use too much overhead.
11011 Instead, there is a special command to produce @emph{all} specified
11012 files in one step:
11014 @table @asis
11015 @item @kbd{e} (@code{org-store-agenda-views})
11016 @kindex e @r{(Agenda dispatcher)}
11017 @findex org-store-agenda-views
11018 Export all agenda views that have export file names associated
11019 with them.
11020 @end table
11022 You can use the options section of the custom agenda commands to also
11023 set options for the export commands.  For example:
11025 @lisp
11026 (setq org-agenda-custom-commands
11027       '(("X" agenda ""
11028          ((ps-number-of-columns 2)
11029           (ps-landscape-mode t)
11030           (org-agenda-prefix-format " [ ] ")
11031           (org-agenda-with-colors nil)
11032           (org-agenda-remove-tags t))
11033          ("theagenda.ps"))))
11034 @end lisp
11036 @noindent
11037 @vindex org-agenda-exporter-settings
11038 This command sets two options for the Postscript exporter, to make it
11039 print in two columns in landscape format---the resulting page can be
11040 cut in two and then used in a paper agenda.  The remaining settings
11041 modify the agenda prefix to omit category and scheduling information,
11042 and instead include a checkbox to check off items.  We also remove the
11043 tags to make the lines compact, and we do not want to use colors for
11044 the black-and-white printer.  Settings specified in
11045 @code{org-agenda-exporter-settings} also apply, e.g.,
11047 @lisp
11048 (setq org-agenda-exporter-settings
11049       '((ps-number-of-columns 2)
11050         (ps-landscape-mode t)
11051         (org-agenda-add-entry-text-maxlines 5)
11052         (htmlize-output-type 'css)))
11053 @end lisp
11055 @noindent
11056 but the settings in @code{org-agenda-custom-commands} take precedence.
11058 @noindent
11059 From the command line you may also use:
11061 @example
11062 emacs -eval (org-batch-store-agenda-views) -kill
11063 @end example
11065 @noindent
11066 or, if you need to modify some parameters@footnote{Quoting depends on the system you use, please check the FAQ
11067 for examples.}
11069 @example
11070 emacs -eval '(org-batch-store-agenda-views                      \
11071               org-agenda-span (quote month)                     \
11072               org-agenda-start-day "2007-11-01"                 \
11073               org-agenda-include-diary nil                      \
11074               org-agenda-files (quote ("~/org/project.org")))'  \
11075       -kill
11076 @end example
11078 @noindent
11079 which creates the agenda views restricted to the file
11080 @samp{~/org/project.org}, without diary entries and with a 30-day extent.
11082 You can also extract agenda information in a way that allows further
11083 processing by other programs.  See @ref{Extracting Agenda Information}, for
11084 more information.
11086 @node Agenda Column View
11087 @section Using Column View in the Agenda
11089 @cindex column view, in agenda
11090 @cindex agenda, column view
11092 Column view (see @ref{Column View}) is normally used to view and edit
11093 properties embedded in the hierarchical structure of an Org file.  It
11094 can be quite useful to use column view also from the agenda, where
11095 entries are collected by certain criteria.
11097 @table @asis
11098 @item @kbd{C-c C-x C-c} (@code{org-agenda-columns})
11099 @kindex C-c C-x C-c
11100 @findex org-agenda-columns
11102 Turn on column view in the agenda.
11103 @end table
11105 To understand how to use this properly, it is important to realize
11106 that the entries in the agenda are no longer in their proper outline
11107 environment.  This causes the following issues:
11109 @enumerate
11110 @item
11111 @vindex org-columns-default-format
11112 @vindex org-overriding-columns-format
11113 Org needs to make a decision which columns format to use.  Since
11114 the entries in the agenda are collected from different files, and
11115 different files may have different columns formats, this is
11116 a non-trivial problem.  Org first checks if the variable
11117 @code{org-agenda-overriding-columns-format} is currently set, and if so,
11118 takes the format from there.  Otherwise it takes the format
11119 associated with the first item in the agenda, or, if that item does
11120 not have a specific format (defined in a property, or in its file),
11121 it uses @code{org-columns-default-format}.
11123 @item
11124 @cindex @samp{CLOCKSUM}, special property
11125 If any of the columns has a summary type defined (see @ref{Column attributes}), turning on column view in the agenda visits all
11126 relevant agenda files and make sure that the computations of this
11127 property are up to date.  This is also true for the special
11128 @samp{CLOCKSUM} property.  Org then sums the values displayed in the
11129 agenda.  In the daily/weekly agenda, the sums cover a single day;
11130 in all other views they cover the entire block.
11132 It is important to realize that the agenda may show the same entry
11133 @emph{twice}---for example as scheduled and as a deadline---and it may
11134 show two entries from the same hierarchy (for example a @emph{parent}
11135 and its @emph{child}).  In these cases, the summation in the agenda
11136 leads to incorrect results because some values count double.
11138 @item
11139 When the column view in the agenda shows the @samp{CLOCKSUM} property,
11140 that is always the entire clocked time for this item.  So even in
11141 the daily/weekly agenda, the clocksum listed in column view may
11142 originate from times outside the current view.  This has the
11143 advantage that you can compare these values with a column listing
11144 the planned total effort for a task---one of the major
11145 applications for column view in the agenda.  If you want
11146 information about clocked time in the displayed period use clock
11147 table mode (press @kbd{R} in the agenda).
11149 @item
11150 @cindex @samp{CLOCKSUM_T}, special property
11151 When the column view in the agenda shows the @samp{CLOCKSUM_T} property,
11152 that is always today's clocked time for this item.  So even in the
11153 weekly agenda, the clocksum listed in column view only originates
11154 from today.  This lets you compare the time you spent on a task for
11155 today, with the time already spent---via @samp{CLOCKSUM}---and with
11156 the planned total effort for it.
11157 @end enumerate
11159 @node Markup
11160 @chapter Markup for Rich Export
11162 When exporting Org documents, the exporter tries to reflect the
11163 structure of the document as accurately as possible in the back-end.
11164 Since export targets like HTML and @LaTeX{} allow much richer formatting,
11165 Org mode has rules on how to prepare text for rich export.  This
11166 section summarizes the markup rules used in an Org mode buffer.
11168 @menu
11169 * Paragraphs::                   The basic unit of text.
11170 * Emphasis and Monospace::       Bold, italic, etc.
11171 * Horizontal Rules::             Make a line.
11172 * Images and Tables::            Images, tables and caption mechanism.
11173 * Literal Examples::             Source code examples with special formatting.
11174 * Special Symbols::              Greek letters and other symbols.
11175 * Subscripts and Superscripts::  Simple syntax for raising/lowering text.
11176 * Embedded @LaTeX{}::            LaTeX can be freely used inside Org documents.
11177 @end menu
11179 @node Paragraphs
11180 @section Paragraphs
11182 @cindex paragraphs, markup rules
11184 Paragraphs are separated by at least one empty line.  If you need to
11185 enforce a line break within a paragraph, use @code{\\} at the end of
11186 a line.
11188 To preserve the line breaks, indentation and blank lines in a region,
11189 but otherwise use normal formatting, you can use this construct, which
11190 can also be used to format poetry.
11192 @cindex @samp{BEGIN_VERSE}
11193 @cindex verse blocks
11194 @example
11195 #+BEGIN_VERSE
11196  Great clouds overhead
11197  Tiny black birds rise and fall
11198  Snow covers Emacs
11200     ---AlexSchroeder
11201 #+END_VERSE
11202 @end example
11204 When quoting a passage from another document, it is customary to
11205 format this as a paragraph that is indented on both the left and the
11206 right margin.  You can include quotations in Org documents like this:
11208 @cindex @samp{BEGIN_QUOTE}
11209 @cindex quote blocks
11210 @example
11211 #+BEGIN_QUOTE
11212 Everything should be made as simple as possible,
11213 but not any simpler ---Albert Einstein
11214 #+END_QUOTE
11215 @end example
11217 If you would like to center some text, do it like this:
11219 @cindex @samp{BEGIN_CENTER}
11220 @cindex center blocks
11221 @example
11222 #+BEGIN_CENTER
11223 Everything should be made as simple as possible, \\
11224 but not any simpler
11225 #+END_CENTER
11226 @end example
11228 @node Emphasis and Monospace
11229 @section Emphasis and Monospace
11231 @cindex underlined text, markup rules
11232 @cindex bold text, markup rules
11233 @cindex italic text, markup rules
11234 @cindex verbatim text, markup rules
11235 @cindex code text, markup rules
11236 @cindex strike-through text, markup rules
11238 You can make words @samp{*bold*}, @samp{/italic/}, @samp{_underlined_}, @samp{=verbatim=}
11239 and @samp{~code~}, and, if you must, @samp{+strike-through+}.  Text in the code
11240 and verbatim string is not processed for Org mode specific syntax; it
11241 is exported verbatim.
11243 @vindex org-fontify-emphasized-text
11244 To turn off fontification for marked up text, you can set
11245 @code{org-fontify-emphasized-text} to @code{nil}.  To narrow down the list of
11246 available markup syntax, you can customize @code{org-emphasis-alist}.
11248 @node Horizontal Rules
11249 @section Horizontal Rules
11251 @cindex horizontal rules, markup rules
11253 A line consisting of only dashes, and at least 5 of them, is exported
11254 as a horizontal line.
11256 @node Images and Tables
11257 @section Images and Tables
11259 @cindex tables, markup rules
11260 @cindex @samp{CAPTION}, keyword
11261 @cindex @samp{NAME}, keyword
11263 Both the native Org mode tables (see @ref{Tables}) and tables formatted
11264 with the @samp{table.el} package are exported properly.  For Org mode
11265 tables, the lines before the first horizontal separator line become
11266 table header lines.  You can use the following lines somewhere before
11267 the table to assign a caption and a label for cross references, and in
11268 the text you can refer to the object with @samp{[[tab:basic-data]]} (see
11269 @ref{Internal Links}):
11271 @example
11272 #+CAPTION: This is the caption for the next table (or link)
11273 #+NAME:   tab:basic-data
11274 | ... | ... |
11275 |-----+-----|
11276 @end example
11278 Optionally, the caption can take the form:
11280 @example
11281 #+CAPTION[Caption for list of tables]: Caption for table.
11282 @end example
11284 @cindex inlined images, markup rules
11285 Some back-ends allow you to directly include images into the exported
11286 document.  Org does this, if a link to an image file does not have
11287 a description part, for example @samp{[[./img/a.jpg]]}.  If you wish to define
11288 a caption for the image and maybe a label for internal cross
11289 references, make sure that the link is on a line by itself and precede
11290 it with @samp{CAPTION} and @samp{NAME} keywords as follows:
11292 @example
11293 #+CAPTION: This is the caption for the next figure link (or table)
11294 #+NAME:   fig:SED-HR4049
11295 [[./img/a.jpg]]
11296 @end example
11298 @noindent
11299 Such images can be displayed within the buffer.  See @ref{Handling Links, , the discussion of
11300 image links}.
11302 Even though images and tables are prominent examples of captioned
11303 structures, the same caption mechanism can apply to many
11304 others---e.g., @LaTeX{} equations, source code blocks.  Depending on the
11305 export back-end, those may or may not be handled.
11307 @node Literal Examples
11308 @section Literal Examples
11310 @cindex literal examples, markup
11311 @cindex code line references, markup
11313 You can include literal examples that should not be subjected to
11314 markup.  Such examples are typeset in monospace, so this is well
11315 suited for source code and similar examples.
11317 @cindex @samp{BEGIN_EXAMPLE}
11318 @cindex example block
11319 @example
11320 #+BEGIN_EXAMPLE
11321   Some example from a text file.
11322 #+END_EXAMPLE
11323 @end example
11325 Note that such blocks may be @emph{indented} in order to align nicely with
11326 indented text and in particular with plain list structure (see
11327 @ref{Plain Lists}).  For simplicity when using small examples, you can
11328 also start the example lines with a colon followed by a space.  There
11329 may also be additional whitespace before the colon:
11331 @example
11332 Here is an example
11333    : Some example from a text file.
11334 @end example
11336 @cindex formatting source code, markup rules
11337 @vindex org-latex-listings
11338 If the example is source code from a programming language, or any
11339 other text that can be marked up by Font Lock in Emacs, you can ask
11340 for the example to look like the fontified Emacs buffer@footnote{This works automatically for the HTML backend (it requires
11341 version 1.34 of the @samp{htmlize.el} package, which you need to install).
11342 Fontified code chunks in @LaTeX{} can be achieved using either the
11343 listings package or the @uref{https://github.com/gpoore/minted, minted} package.  Refer to
11344 @code{org-export-latex-listings} for details.}.  This
11345 is done with the code block, where you also need to specify the name
11346 of the major mode that should be used to fontify the example@footnote{Source code in code blocks may also be evaluated either
11347 interactively or on export.  See @ref{Working with Source Code} for more
11348 information on evaluating code blocks.},
11349 see @ref{Structure Templates} for shortcuts to easily insert code blocks.
11351 @cindex @samp{BEGIN_SRC}
11352 @cindex src block
11353 @example
11354 #+BEGIN_SRC emacs-lisp
11355   (defun org-xor (a b)
11356     "Exclusive or."
11357     (if a (not b) b))
11358  #+END_SRC
11359 @end example
11361 Both in @samp{example} and in @samp{src} snippets, you can add a @samp{-n} switch to
11362 the end of the @samp{#+BEGIN} line, to get the lines of the example
11363 numbered.  The @samp{-n} takes an optional numeric argument specifying the
11364 starting line number of the block.  If you use a @samp{+n} switch, the
11365 numbering from the previous numbered snippet is continued in the
11366 current one.  The @samp{+n} switch can also take a numeric argument.  This
11367 adds the value of the argument to the last line of the previous block
11368 to determine the starting line number.
11370 @example
11371 #+BEGIN_SRC emacs-lisp -n 20
11372   ;; This exports with line number 20.
11373   (message "This is line 21")
11374 #+END_SRC
11376 #+BEGIN_SRC emacs-lisp +n 10
11377   ;; This is listed as line 31.
11378   (message "This is line 32")
11379 #+END_SRC
11380 @end example
11382 In literal examples, Org interprets strings like @samp{(ref:name)} as
11383 labels, and use them as targets for special hyperlinks like
11384 @samp{[[(name)]]}---i.e., the reference name enclosed in single parenthesis.
11385 In HTML, hovering the mouse over such a link remote-highlights the
11386 corresponding code line, which is kind of cool.
11388 You can also add a @samp{-r} switch which @emph{removes} the labels from the
11389 source code@footnote{Adding @samp{-k} to @samp{-n -r} @emph{keeps} the labels in the source code
11390 while using line numbers for the links, which might be useful to
11391 explain those in an Org mode example code.}.  With the @samp{-n} switch, links to these references
11392 are labeled by the line numbers from the code listing.  Otherwise
11393 links use the labels with no parentheses.  Here is an example:
11395 @example
11396 #+BEGIN_SRC emacs-lisp -n -r
11397   (save-excursion                 (ref:sc)
11398      (goto-char (point-min))      (ref:jump)
11399 #+END_SRC
11400 In line [[(sc)]] we remember the current position. [[(jump)][Line (jump)]]
11401 jumps to point-min.
11402 @end example
11404 @cindex indentation, in source blocks
11405 Finally, you can use @samp{-i} to preserve the indentation of a specific
11406 code block (see @ref{Editing Source Code}).
11408 @vindex org-coderef-label-format
11409 If the syntax for the label format conflicts with the language syntax,
11410 use a @samp{-l} switch to change the format, for example
11412 @example
11413 #+BEGIN_SRC pascal -n -r -l "((%s))"
11414 @end example
11416 @noindent
11417 See also the variable @code{org-coderef-label-format}.
11419 HTML export also allows examples to be published as text areas (see
11420 @ref{Text areas in HTML export}).
11422 Because the @samp{#+BEGIN} @dots{} @samp{#+END} patterns need to be added so often,
11423 a shortcut is provided (see @ref{Structure Templates}).
11425 @table @asis
11426 @item @kbd{C-c '} (@code{org-edit-special})
11427 @kindex C-c '
11428 @findex org-edit-special
11429 Edit the source code example at point in its native mode.  This
11430 works by switching to a temporary buffer with the source code.
11431 You need to exit by pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*}, @samp{,*}, @samp{#+} and @samp{,#+} get
11432 a comma prepended, to keep them from being interpreted by Org as
11433 outline nodes or special syntax.  These commas are stripped when
11434 editing with @kbd{C-c '}, and also before export.}.  The
11435 edited version then replaces the old version in the Org buffer.
11436 Fixed-width regions---where each line starts with a colon
11437 followed by a space---are edited using @code{artist-mode}@footnote{You may select a different-mode with the variable
11438 @code{org-edit-fixed-width-region-mode}.} to
11439 allow creating ASCII drawings easily.  Using this command in an
11440 empty line creates a new fixed-width region.
11441 @end table
11443 @cindex storing link, in a source code buffer
11444 Calling @code{org-store-link} (see @ref{Handling Links}) while editing a source
11445 code example in a temporary buffer created with @kbd{C-c '}
11446 prompts for a label.  Make sure that it is unique in the current
11447 buffer, and insert it with the proper formatting like @samp{(ref:label)} at
11448 the end of the current line.  Then the label is stored as a link
11449 @samp{(label)}, for retrieval with @kbd{C-c C-l}.
11451 @node Special Symbols
11452 @section Special Symbols
11454 @cindex math symbols
11455 @cindex special symbols
11456 @cindex @TeX{} macros
11457 @cindex @LaTeX{} fragments, markup rules
11458 @cindex HTML entities
11459 @cindex @LaTeX{} entities
11461 You can use @LaTeX{}-like syntax to insert special symbols---named
11462 entities---like @samp{\alpha} to indicate the Greek letter, or @samp{\to} to indicate
11463 an arrow.  Completion for these symbols is available, just type @samp{\}
11464 and maybe a few letters, and press @kbd{M-@key{TAB}} to see possible
11465 completions.  If you need such a symbol inside a word, terminate it
11466 with a pair of curly brackets.  For example
11468 @example
11469 Pro tip: Given a circle \Gamma of diameter d, the length of its
11470 circumference is \pi@{@}d.
11471 @end example
11473 @findex org-entities-help
11474 @vindex org-entities-user
11475 A large number of entities is provided, with names taken from both
11476 HTML and @LaTeX{}; you can comfortably browse the complete list from
11477 a dedicated buffer using the command @code{org-entities-help}.  It is also
11478 possible to provide your own special symbols in the variable
11479 @code{org-entities-user}.
11481 During export, these symbols are transformed into the native format of
11482 the exporter back-end.  Strings like @samp{\alpha} are exported as @samp{&alpha;} in
11483 the HTML output, and as @samp{\(\alpha\)} in the @LaTeX{} output.  Similarly, @samp{\nbsp}
11484 becomes @samp{&nbsp;} in HTML and @samp{~} in @LaTeX{}.
11486 @cindex escaping characters
11487 Entities may also be used as a way to escape markup in an Org
11488 document, e.g., @samp{\under@{@}not underlined\under} exports as @samp{_not underlined_}.
11490 @cindex special symbols, in-buffer display
11491 If you would like to see entities displayed as UTF-8 characters, use
11492 the following command@footnote{You can turn this on by default by setting the variable
11493 @code{org-pretty-entities}, or on a per-file base with the @samp{STARTUP} option
11494 @samp{entitiespretty}.}:
11496 @table @asis
11497 @item @kbd{C-c C-x \} (@code{org-toggle-pretty-entities})
11498 @kindex C-c C-x \
11499 @findex org-toggle-pretty-entities
11501 Toggle display of entities as UTF-8 characters.  This does not
11502 change the buffer content which remains plain ASCII, but it
11503 overlays the UTF-8 character for display purposes only.
11504 @end table
11506 @cindex shy hyphen, special symbol
11507 @cindex dash, special symbol
11508 @cindex ellipsis, special symbol
11509 In addition to regular entities defined above, Org exports in
11510 a special way@footnote{This behavior can be disabled with @samp{-} export setting (see
11511 @ref{Export Settings}).} the following commonly used character
11512 combinations: @samp{\-} is treated as a shy hyphen, @samp{--} and @samp{---} are
11513 converted into dashes, and @samp{...} becomes a compact set of dots.
11515 @node Subscripts and Superscripts
11516 @section Subscripts and Superscripts
11518 @cindex subscript
11519 @cindex superscript
11521 @samp{^} and @samp{_} are used to indicate super- and subscripts.  To increase
11522 the readability of ASCII text, it is not necessary, but OK, to
11523 surround multi-character sub- and superscripts with curly braces.  For
11524 example
11526 @example
11527 The radius of the sun is R_sun = 6.96 x 10^8 m.  On the other hand,
11528 the radius of Alpha Centauri is R_@{Alpha Centauri@} = 1.28 x R_@{sun@}.
11529 @end example
11531 @vindex org-use-sub-superscripts
11532 If you write a text where the underscore is often used in a different
11533 context, Org's convention to always interpret these as subscripts can
11534 get in your way.  Configure the variable @code{org-use-sub-superscripts} to
11535 change this convention.  For example, when setting this variable to
11536 @code{@{@}}, @samp{a_b} is not interpreted as a subscript, but @samp{a_@{b@}} is.
11538 @table @asis
11539 @item @kbd{C-c C-x \} (@code{org-toggle-pretty-entities~})
11540 @kindex C-c C-x \
11541 @findex org-toggle-pretty-entities
11543 In addition to showing entities as UTF-8 characters, this command
11544 also formats sub- and superscripts in a WYSIWYM way.
11545 @end table
11547 @node Embedded @LaTeX{}
11548 @section Embedded @LaTeX{}
11550 @cindex @TeX{} interpretation
11551 @cindex @LaTeX{} interpretation
11553 Plain ASCII is normally sufficient for almost all note taking.
11554 Exceptions include scientific notes, which often require mathematical
11555 symbols and the occasional formula.  @LaTeX{}@footnote{@LaTeX{} is a macro system based on Donald@tie{}E.@tie{}Knuth's @TeX{}
11556 system.  Many of the features described here as ``@LaTeX{}'' are really
11557 from @TeX{}, but for simplicity I am blurring this distinction.} is widely used to
11558 typeset scientific documents.  Org mode supports embedding @LaTeX{} code
11559 into its files, because many academics are used to writing and reading
11560 @LaTeX{} source code, and because it can be readily processed to produce
11561 pretty output for a number of export back-ends.
11563 @menu
11564 * @LaTeX{} fragments::           Complex formulas made easy.
11565 * Previewing @LaTeX{} fragments:: What will this snippet look like?
11566 * CD@LaTeX{} mode::              Speed up entering of formulas.
11567 @end menu
11569 @node @LaTeX{} fragments
11570 @subsection @LaTeX{} fragments
11572 @cindex @LaTeX{} fragments
11574 @vindex org-format-latex-header
11575 Org mode can contain @LaTeX{} math fragments, and it supports ways to
11576 process these for several export back-ends.  When exporting to @LaTeX{},
11577 the code is left as it is.  When exporting to HTML, Org can use either
11578 @uref{http://www.mathjax.org, MathJax} (see @ref{Math formatting in HTML export}) or transcode the math
11579 into images (see @ref{Previewing @LaTeX{} fragments}).
11581 @LaTeX{} fragments do not need any special marking at all.  The following
11582 snippets are identified as @LaTeX{} source code:
11584 @itemize
11585 @item
11586 Environments of any kind@footnote{When MathJax is used, only the environments recognized by
11587 MathJax are processed.  When dvipng, dvisvgm, or ImageMagick suite is
11588 used to create images, any @LaTeX{} environment is handled.}.  The only requirement is that the
11589 @samp{\begin} statement appears on a new line, preceded by only
11590 whitespace.
11592 @item
11593 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts
11594 with currency specifications, single @samp{$} characters are only
11595 recognized as math delimiters if the enclosed text contains at most
11596 two line breaks, is directly attached to the @samp{$} characters with no
11597 whitespace in between, and if the closing @samp{$} is followed by
11598 whitespace, punctuation or a dash.  For the other delimiters, there
11599 is no such restriction, so when in doubt, use @samp{\(...\)} as inline
11600 math delimiters.
11601 @end itemize
11603 @noindent
11604 For example:
11606 @example
11607 \begin@{equation@}                        % arbitrary environments,
11608 x=\sqrt@{b@}                              % even tables, figures
11609 \end@{equation@}                          % etc
11611 If $a^2=b$ and \( b=2 \), then the solution must be
11612 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
11613 @end example
11615 @vindex org-export-with-latex
11616 @LaTeX{} processing can be configured with the variable
11617 @code{org-export-with-latex}.  The default setting is @code{t} which means
11618 MathJax for HTML, and no processing for ASCII and @LaTeX{} back-ends.
11619 You can also set this variable on a per-file basis using one of these
11620 lines:
11622 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
11623 @item @samp{#+OPTIONS: tex:t}
11624 @tab Do the right thing automatically (MathJax)
11625 @item @samp{#+OPTIONS: tex:nil}
11626 @tab Do not process @LaTeX{} fragments at all
11627 @item @samp{#+OPTIONS: tex:verbatim}
11628 @tab Verbatim export, for jsMath or so
11629 @end multitable
11631 @node Previewing @LaTeX{} fragments
11632 @subsection Previewing @LaTeX{} fragments
11634 @cindex @LaTeX{} fragments, preview
11636 @vindex org-preview-latex-default-process
11637 If you have a working @LaTeX{} installation and @samp{dvipng}, @samp{dvisvgm} or
11638 @samp{convert} installed@footnote{These are respectively available at
11639 @uref{http://sourceforge.net/projects/dvipng/}, @uref{http://dvisvgm.bplaced.net/}
11640 and from the ImageMagick suite.  Choose the converter by setting the
11641 variable @code{org-preview-latex-default-process} accordingly.}, @LaTeX{} fragments can be processed to
11642 produce images of the typeset expressions to be used for inclusion
11643 while exporting to HTML (see @ref{@LaTeX{} fragments}), or for inline
11644 previewing within Org mode.
11646 @vindex org-format-latex-options
11647 @vindex org-format-latex-header
11648 You can customize the variables @code{org-format-latex-options} and
11649 @code{org-format-latex-header} to influence some aspects of the preview.
11650 In particular, the @code{:scale} (and for HTML export, @code{:html-scale})
11651 property of the former can be used to adjust the size of the preview
11652 images.
11654 @table @asis
11655 @item @kbd{C-c C-x C-l} (@code{org-toggle-latex-fragment})
11656 @kindex C-c C-x C-l
11657 @findex org-toggle-latex-fragment
11659 Produce a preview image of the @LaTeX{} fragment at point and
11660 overlay it over the source code.  If there is no fragment at
11661 point, process all fragments in the current entry (between two
11662 headlines).  When called with a prefix argument, process the
11663 entire subtree.  When called with two prefix arguments, or when
11664 the cursor is before the first headline, process the entire
11665 buffer.
11666 @end table
11668 @vindex org-startup-with-latex-preview
11669 You can turn on the previewing of all @LaTeX{} fragments in a file with
11671 @example
11672 #+STARTUP: latexpreview
11673 @end example
11675 To disable it, simply use
11677 @example
11678 #+STARTUP: nolatexpreview
11679 @end example
11681 @node CD@LaTeX{} mode
11682 @subsection Using CD@LaTeX{} to enter math
11684 @cindex CD@LaTeX{}
11686 CD@LaTeX{} mode is a minor mode that is normally used in combination with
11687 a major @LaTeX{} mode like AUC@TeX{} in order to speed-up insertion of
11688 environments and math templates.  Inside Org mode, you can make use of
11689 some of the features of CD@LaTeX{} mode.  You need to install
11690 @samp{cdlatex.el} and @samp{texmathp.el} (the latter comes also with AUC@TeX{})
11691 from @uref{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.  Do not use
11692 CD@LaTeX{} mode itself under Org mode, but use the light version
11693 @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it on for the
11694 current buffer with @kbd{M-x org-cdlatex-mode}, or for all Org
11695 files with
11697 @lisp
11698 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
11699 @end lisp
11701 When this mode is enabled, the following features are present (for
11702 more details see the documentation of CD@LaTeX{} mode):
11704 @table @asis
11705 @item @kbd{C-c @{}
11706 @kindex C-c @{
11708 Insert an environment template.
11710 @item @kbd{@key{TAB}}
11711 @kindex TAB
11713 The @kbd{@key{TAB}} key expands the template if the cursor is
11714 inside a @LaTeX{} fragment@footnote{Org mode has a method to test if the cursor is inside such
11715 a fragment, see the documentation of the function
11716 @code{org-inside-LaTeX-fragment-p}.}.  For example, @kbd{@key{TAB}}
11717 expands @samp{fr} to @samp{\frac@{@}@{@}} and position the cursor correctly
11718 inside the first brace.  Another @kbd{@key{TAB}} gets you into the
11719 second brace.
11721 Even outside fragments, @kbd{@key{TAB}} expands environment
11722 abbreviations at the beginning of a line.  For example, if you
11723 write @samp{equ} at the beginning of a line and press @kbd{@key{TAB}},
11724 this abbreviation is expanded to an @samp{equation} environment.  To
11725 get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
11727 @item @kbd{^}
11728 @itemx @kbd{_}
11729 @kindex _
11730 @kindex ^
11731 @vindex cdlatex-simplify-sub-super-scripts
11733 Pressing @kbd{_} and @kbd{^} inside a @LaTeX{} fragment
11734 inserts these characters together with a pair of braces.  If you
11735 use @kbd{@key{TAB}} to move out of the braces, and if the braces
11736 surround only a single character or macro, they are removed again
11737 (depending on the variable @code{cdlatex-simplify-sub-super-scripts}).
11739 @item @kbd{`}
11740 @kindex `
11742 Pressing the backquote followed by a character inserts math
11743 macros, also outside @LaTeX{} fragments.  If you wait more than 1.5
11744 seconds after the backquote, a help window pops up.
11746 @item @kbd{'}
11747 @kindex '
11749 Pressing the single-quote followed by another character modifies
11750 the symbol before point with an accent or a font.  If you wait
11751 more than 1.5 seconds after the single-quote, a help window pops
11752 up.  Character modification works only inside @LaTeX{} fragments;
11753 outside the quote is normal.
11754 @end table
11756 @node Exporting
11757 @chapter Exporting
11759 @cindex exporting
11761 Sometimes, you may want to pretty print your notes, publish them on
11762 the web or even share them with people not using Org.  In these cases,
11763 the Org export facilities can be used to convert your documents to
11764 a variety of other formats, while retaining as much structure (see
11765 @ref{Document Structure}) and markup (see @ref{Markup}) as
11766 possible.
11768 @cindex export back-end
11769 Libraries responsible for such translation are called back-ends.  Org
11770 ships with the following ones
11772 @itemize
11773 @item
11774 @emph{ascii} (ASCII format)
11775 @item
11776 @emph{beamer} (@LaTeX{} Beamer format)
11777 @item
11778 @emph{html} (HTML format)
11779 @item
11780 @emph{icalendar} (iCalendar format)
11781 @item
11782 @emph{latex} (@LaTeX{} format)
11783 @item
11784 @emph{md} (Markdown format)
11785 @item
11786 @emph{odt} (OpenDocument Text format)
11787 @item
11788 @emph{org} (Org format)
11789 @item
11790 @emph{texinfo} (Texinfo format)
11791 @item
11792 @emph{man} (Man page format)
11793 @end itemize
11795 @noindent
11796 Org also uses additional libraries located in @samp{contrib/} directory
11797 (see @ref{Installation}).  Users can install additional export libraries
11798 for additional formats from the Emacs packaging system.  For easy
11799 discovery, these packages have a common naming scheme: @code{ox-NAME},
11800 where @var{NAME} is one of the formats.  For example,
11801 @code{ox-koma-letter} @emph{koma-letter} back-end.
11803 @vindex org-export-backends
11804 Org loads back-ends for the following formats by default: ASCII, HTML,
11805 iCalendar, @LaTeX{} and ODT.  Org can load additional back-ends either of
11806 two ways: through the @code{org-export-backends} variable configuration;
11807 or, by requiring the library in the Emacs init file like this:
11809 @lisp
11810 (require 'ox-md)
11811 @end lisp
11813 @menu
11814 * The Export Dispatcher::        The main interface.
11815 * Export Settings::              Common export settings.
11816 * Table of Contents::            The if and where of the table of contents.
11817 * Include Files::                Include additional files into a document.
11818 * Macro Replacement::            Use macros to create templates.
11819 * Comment Lines::                What will not be exported.
11820 * ASCII/Latin-1/UTF-8 export::   Exporting to flat files with encoding.
11821 * Beamer Export::
11822 * HTML Export::                  Exporting to HTML.
11823 * @LaTeX{} Export::              Exporting to @LaTeX{} and processing to PDF.
11824 * Markdown Export::              Exporting to Markdown.
11825 * OpenDocument Text Export::     Exporting to OpenDocument Text.
11826 * Org Export::                   Exporting to Org.
11827 * Texinfo Export::               Exporting to Texinfo.
11828 * iCalendar Export::             Exporting to iCalendar.
11829 * Other Built-in Back-ends::     Exporting to a man page.
11830 * Advanced Configuration::       Fine-tuning the export output.
11831 * Export in Foreign Buffers::    Author tables and lists in Org syntax.
11832 @end menu
11834 @node The Export Dispatcher
11835 @section The Export Dispatcher
11837 @cindex dispatcher, for export commands
11838 @cindex Export, dispatcher
11840 The export dispatcher is the main interface for Org's exports.
11841 A hierarchical menu presents the currently configured export formats.
11842 Options are shown as easy toggle switches on the same screen.
11844 @vindex org-export-dispatch-use-expert-ui
11845 Org also has a minimal prompt interface for the export dispatcher.
11846 When the variable @code{org-export-dispatch-use-expert-ui} is set to
11847 a non-@code{nil} value, Org prompts in the minibuffer.  To switch back to
11848 the hierarchical menu, press @kbd{?}.
11850 @table @asis
11851 @item @kbd{C-c C-e} (@code{org-export})
11852 @kindex C-c C-e
11853 @findex org-export
11855 Invokes the export dispatcher interface.  The options show
11856 default settings.  The @kbd{C-u} prefix argument preserves
11857 options from the previous export, including any sub-tree
11858 selections.
11859 @end table
11861 Org exports the entire buffer by default.  If the Org buffer has an
11862 active region, then Org exports just that region.
11864 Within the dispatcher interface, the following key combinations can
11865 further alter what is exported, and how.
11867 @table @asis
11868 @item @kbd{C-a}
11869 @kindex C-c C-e C-a
11871 Toggle asynchronous export.  Asynchronous export uses an external
11872 Emacs process with a specially configured initialization file to
11873 complete the exporting process in the background thereby
11874 releasing the current interface.  This is particularly useful
11875 when exporting long documents.
11877 Output from an asynchronous export is saved on the ``the export
11878 stack''.  To view this stack, call the export dispatcher with
11879 a double @kbd{C-u} prefix argument.  If already in the
11880 export dispatcher menu, @kbd{&} displays the stack.
11882 @vindex org-export-async-init-file
11883 To make the background export process the default, customize the
11884 variable, @code{org-export-in-background}.  Additionally, you can set
11885 the initialization file used by the background process with
11886 @code{org-export-async-init-file}.
11888 @vindex org-export-in-background
11889 You can make asynchronous export the default by setting
11890 @code{org-export-in-background}.
11892 @item @kbd{C-b}
11893 @kindex C-c C-e C-b
11895 Toggle body-only export.  Useful for excluding headers and
11896 footers in the export.  Affects only those back-end formats that
11897 have such sections---like @samp{<head>...</head>} in HTML.
11899 @item @{@{@{kbd(C-s@}@}@}
11900 @kindex C-c C-e C-s
11902 Toggle sub-tree export.  When turned on, Org exports only the
11903 sub-tree starting from the cursor position at the time the export
11904 dispatcher was invoked.  Org uses the top heading of this
11905 sub-tree as the document's title.  If the cursor is not on
11906 a heading, Org uses the nearest enclosing header.  If the cursor
11907 is in the document preamble, Org signals an error and aborts
11908 export.
11910 @vindex org-export-initial-scope
11911 To make the sub-tree export the default, customize the variable
11912 @code{org-export-initial-scope}.
11914 @item @kbd{C-v}
11915 @kindex C-c C-e C-v
11917 Toggle visible-only export.  Useful for exporting only visible
11918 parts of an Org document by adjusting outline visibility
11919 settings.
11920 @end table
11922 @node Export Settings
11923 @section Export Settings
11925 @cindex options, for export
11926 @cindex Export, settings
11928 @cindex @samp{OPTIONS}, keyword
11929 Export options can be set: globally with variables; for an individual
11930 file by making variables buffer-local with in-buffer settings (see
11931 @ref{In-buffer Settings}), by setting individual keywords, or by
11932 specifying them in a compact form with the @samp{OPTIONS} keyword; or for
11933 a tree by setting properties (see @ref{Properties and Columns}).  Options
11934 set at a specific level override options set at a more general level.
11936 @cindex SETUPFILE, keyword
11937 In-buffer settings may appear anywhere in the file, either directly or
11938 indirectly through a file included using @samp{#+SETUPFILE: filename or
11939 URL} syntax.  Option keyword sets tailored to a particular back-end
11940 can be inserted from the export dispatcher (see @ref{The Export Dispatcher}) using the @samp{Insert template} command by pressing
11941 @kbd{#}.  To insert keywords individually, a good way to make
11942 sure the keyword is correct is to type @samp{#+} and then to use
11943 @kbd{M-@key{TAB}}@footnote{Many desktops intercept @kbd{M-@key{TAB}} to switch windows.
11944 Use @kbd{C-M-i} or @kbd{@key{ESC} @key{TAB}} instead.} for completion.
11946 The export keywords available for every back-end, and their equivalent
11947 global variables, include:
11949 @table @asis
11950 @item @samp{AUTHOR}
11951 @cindex @samp{AUTHOR}, keyword
11952 @vindex user-full-name
11953 The document author (@code{user-full-name}).
11955 @item @samp{CREATOR}
11956 @cindex @samp{CREATOR}, keyword
11957 @vindex org-expot-creator-string
11958 Entity responsible for output generation
11959 (@code{org-export-creator-string}).
11961 @item @samp{DATE}
11962 @cindex @samp{DATE}, keyword
11963 @vindex org-export-date-timestamp-format
11964 A date or a time-stamp@footnote{The variable @code{org-export-date-timestamp-format} defines how
11965 this timestamp are exported.}.
11967 @item @samp{EMAIL}
11968 @cindex @samp{EMAIL}, keyword
11969 @vindex user-mail-address
11970 The email address (@code{user-mail-address}).
11972 @item @samp{LANGUAGE}
11973 @cindex @samp{LANGUAGE}, keyword
11974 @vindex org-export-default-language
11975 Language to use for translating certain strings
11976 (@code{org-export-default-language}).  With @samp{#+LANGUAGE: fr}, for
11977 example, Org translates @samp{Table of contents} to the French @samp{Table
11978      des matières}.
11980 @item @samp{SELECT_TAGS}
11981 @cindex @samp{SELECT_TAGS}, keyword
11982 @vindex org-export-select-tags
11983 The default value is @code{("export")}.  When a tree is tagged with
11984 @samp{export} (@code{org-export-select-tags}), Org selects that tree and
11985 its sub-trees for export.  Org excludes trees with @samp{noexport}
11986 tags, see below.  When selectively exporting files with @samp{export}
11987 tags set, Org does not export any text that appears before the
11988 first headline.
11990 @item @samp{EXCLUDE_TAGS}
11991 @cindex @samp{EXCLUDE_TAGS}, keyword
11992 @vindex org-export-exclude-tags
11993 The default value is @code{("noexport")}.  When a tree is tagged with
11994 @samp{noexport} (@code{org-export-exclude-tags}), Org excludes that tree
11995 and its sub-trees from export.  Entries tagged with @samp{noexport}
11996 are unconditionally excluded from the export, even if they have
11997 an @samp{export} tag.  Even if a sub-tree is not exported, Org
11998 executes any code blocks contained there.
12000 @item @samp{TITLE}
12001 @cindex @samp{TITLE}, keyword
12002 @cindex document title
12003 Org displays this title.  For long titles, use multiple @samp{#+TITLE}
12004 lines.
12006 @item @samp{EXPORT_FILE_NAME}
12007 @cindex @samp{EXPORT_FILE_NAME}, keyword
12008 The name of the output file to be generated.  Otherwise, Org
12009 generates the file name based on the buffer name and the
12010 extension based on the back-end format.
12011 @end table
12013 The @samp{OPTIONS} keyword is a compact form.  To configure multiple
12014 options, use several @samp{OPTIONS} lines.  @samp{OPTIONS} recognizes the
12015 following arguments.
12017 @table @asis
12018 @item @code{'}
12019 @vindex org-export-with-smart-quotes
12020 Toggle smart quotes (@code{org-export-with-smart-quotes}).  Depending
12021 on the language used, when activated, Org treats pairs of double
12022 quotes as primary quotes, pairs of single quotes as secondary
12023 quotes, and single quote marks as apostrophes.
12025 @item @code{*}
12026 @vindex org-export-with-emphasize
12027 Toggle emphasized text (@code{org-export-with-emphasize}).
12029 @item @code{-}
12030 @vindex org-export-with-special-strings
12031 Toggle conversion of special strings
12032 (@code{org-export-with-special-strings}).
12034 @item @code{:}
12035 @vindex org-export-with-fixed-width
12036 Toggle fixed-width sections (@code{org-export-with-fixed-width}).
12038 @item @code{<}
12039 @vindex org-export-with-timestamps
12040 Toggle inclusion of time/date active/inactive stamps
12041 (@code{org-export-with-timestamps}).
12043 @item @code{\n}
12044 @vindex org-export-preserve-breaks
12045 Toggles whether to preserve line breaks
12046 (@code{org-export-preserve-breaks}).
12048 @item @code{^}
12049 @vindex org-export-with-sub-superscripts
12050 Toggle @TeX{}-like syntax for sub- and superscripts.  If you write
12051 @samp{^:@{@}}, @samp{a_@{b@}} is interpreted, but the simple @samp{a_b} is left as
12052 it is (@code{org-export-with-sub-superscripts}).
12054 @item @code{arch}
12055 @vindex org-export-with-archived-trees
12056 Configure how archived trees are exported.  When set to
12057 @code{headline}, the export process skips the contents and processes
12058 only the headlines (@code{org-export-with-archived-trees}).
12060 @item @code{author}
12061 @vindex org-export-with-author
12062 Toggle inclusion of author name into exported file
12063 (@code{org-export-with-author}).
12065 @item @code{broken-links}
12066 @vindex org-export-with-broken-links
12067 Toggles if Org should continue exporting upon finding a broken
12068 internal link.  When set to @code{mark}, Org clearly marks the problem
12069 link in the output (@code{org-export-with-broken-links}).
12071 @item @code{c}
12072 @vindex org-export-with-clocks
12073 Toggle inclusion of CLOCK keywords (@code{org-export-with-clocks}).
12075 @item @code{creator}
12076 @vindex org-export-with-creator
12077 Toggle inclusion of creator information in the exported file
12078 (@code{org-export-with-creator}).
12080 @item @code{d}
12081 @vindex org-export-with-drawers
12082 Toggles inclusion of drawers, or list of drawers to include, or
12083 list of drawers to exclude (@code{org-export-with-drawers}).
12085 @item @code{date}
12086 @vindex org-export-with-date
12087 Toggle inclusion of a date into exported file
12088 (@code{org-export-with-date}).
12090 @item @code{e}
12091 @vindex org-export-with-entities
12092 Toggle inclusion of entities (@code{org-export-with-entities}).
12094 @item @code{email}
12095 @vindex org-export-with-email
12096 Toggle inclusion of the author's e-mail into exported file
12097 (@code{org-export-with-email}).
12099 @item @code{f}
12100 @vindex org-export-with-footnotes
12101 Toggle the inclusion of footnotes (@code{org-export-with-footnotes}).
12103 @item @code{H}
12104 @vindex org-export-headline-levels
12105 Set the number of headline levels for export
12106 (@code{org-export-headline-levels}).  Below that level, headlines are
12107 treated differently.  In most back-ends, they become list items.
12109 @item @code{inline}
12110 @vindex org-export-with-inlinetasks
12111 Toggle inclusion of inlinetasks (@code{org-export-with-inlinetasks}).
12113 @item @code{num}
12114 @vindex org-export-with-section-numbers
12115 @cindex @samp{UNNUMBERED}, property
12116 Toggle section-numbers (@code{org-export-with-section-numbers}).  When
12117 set to number N, Org numbers only those headlines at level N or
12118 above.  Set @samp{UNNUMBERED} property to non-@code{nil} to disable
12119 numbering of heading and subheadings entirely.  Moreover, when
12120 the value is @samp{notoc} the headline, and all its children, do not
12121 appear in the table of contents either (see @ref{Table of Contents}).
12123 @item @code{p}
12124 @vindex org-export-with-planning
12125 Toggle export of planning information
12126 (@code{org-export-with-planning}).  ``Planning information'' comes from
12127 lines located right after the headline and contain any
12128 combination of these cookies: @samp{SCHEDULED}, @samp{DEADLINE}, or
12129 @samp{CLOSED}.
12131 @item @code{pri}
12132 @vindex org-export-with-priority
12133 Toggle inclusion of priority cookies
12134 (@code{org-export-with-priority}).
12136 @item @code{prop}
12137 @vindex org-export-with-properties
12138 Toggle inclusion of property drawers, or list the properties to
12139 include (@code{org-export-with-properties}).
12141 @item @code{stat}
12142 @vindex org-export-with-statistics-cookies
12143 Toggle inclusion of statistics cookies
12144 (@code{org-export-with-statistics-cookies}).
12146 @item @code{tags}
12147 @vindex org-export-with-tags
12148 Toggle inclusion of tags, may also be @code{not-in-toc}
12149 (@code{org-export-with-tags}).
12151 @item @code{tasks}
12152 @vindex org-export-with-tasks
12153 Toggle inclusion of tasks (TODO items); or @code{nil} to remove all
12154 tasks; or @code{todo} to remove DONE tasks; or list the keywords to
12155 keep (@code{org-export-with-tasks}).
12157 @item @code{tex}
12158 @vindex org-export-with-latex
12159 @code{nil} does not export; @code{t} exports; @code{verbatim} keeps everything
12160 in verbatim (@code{org-export-with-latex}).
12162 @item @code{timestamp}
12163 @vindex org-export-time-stamp-file
12164 Toggle inclusion of the creation time in the exported file
12165 (@code{org-export-time-stamp-file}).
12167 @item @code{title}
12168 @vindex org-export-with-title
12169 Toggle inclusion of title (@code{org-export-with-title}).
12171 @item @code{toc}
12172 @vindex org-export-with-toc
12173 Toggle inclusion of the table of contents, or set the level limit
12174 (@code{org-export-with-toc}).
12176 @item @code{todo}
12177 @vindex org-export-with-todo-keywords
12178 Toggle inclusion of TODO keywords into exported text
12179 (@code{org-export-with-todo-keywords}).
12181 @item @code{|}
12182 @vindex org-export-with-tables
12183 Toggle inclusion of tables (@code{org-export-with-tables}).
12184 @end table
12186 When exporting sub-trees, special node properties in them can override
12187 the above keywords.  They are special because they have an @samp{EXPORT_}
12188 prefix.  For example, @samp{DATE} and @samp{EXPORT_FILE_NAME} keywords become,
12189 respectively, @samp{EXPORT_DATE} and @samp{EXPORT_FILE_NAME}.  Except for
12190 @samp{SETUPFILE}, all other keywords listed above have an @samp{EXPORT_}
12191 equivalent.
12193 @cindex @samp{BIND}, keyword
12194 @vindex org-export-allow-bind-keywords
12195 If @code{org-export-allow-bind-keywords} is non-@code{nil}, Emacs variables can
12196 become buffer-local during export by using the @samp{BIND} keyword.  Its
12197 syntax is @samp{#+BIND: variable value}.  This is particularly useful for
12198 in-buffer settings that cannot be changed using keywords.
12200 @node Table of Contents
12201 @section Table of Contents
12203 @cindex table of contents
12204 @cindex list of tables
12205 @cindex list of listings
12207 @cindex @samp{toc}, in @samp{OPTIONS} keyword
12208 @vindex org-export-with-toc
12209 The table of contents includes all headlines in the document.  Its
12210 depth is therefore the same as the headline levels in the file.  If
12211 you need to use a different depth, or turn it off entirely, set the
12212 @code{org-export-with-toc} variable accordingly.  You can achieve the same
12213 on a per file basis, using the following @samp{toc} item in @samp{OPTIONS}
12214 keyword:
12216 @example
12217 #+OPTIONS: toc:2          (only include two levels in TOC)
12218 #+OPTIONS: toc:nil        (no default TOC at all)
12219 @end example
12221 @cindex excluding entries from table of contents
12222 @cindex table of contents, exclude entries
12223 Org includes both numbered and unnumbered headlines in the table of
12224 contents@footnote{At the moment, some export back-ends do not obey this
12225 specification.  For example, @LaTeX{} export excludes every unnumbered
12226 headline from the table of contents.}.  If you need to exclude an unnumbered headline,
12227 along with all its children, set the @samp{UNNUMBERED} property to @samp{notoc}
12228 value.
12230 @example
12231 * Subtree not numbered, not in table of contents either
12232   :PROPERTIES:
12233   :UNNUMBERED: notoc
12234   :END:
12235 @end example
12237 @cindex @samp{TOC}, keyword
12238 Org normally inserts the table of contents directly before the first
12239 headline of the file.  To move the table of contents to a different
12240 location, first turn off the default with @code{org-export-with-toc}
12241 variable or with @samp{#+OPTIONS: toc:nil}.  Then insert @samp{#+TOC: headlines
12242 N} at the desired location(s).
12244 @example
12245 #+OPTIONS: toc:nil
12247 #+TOC: headlines 2
12248 @end example
12250 To adjust the table of contents depth for a specific section of the
12251 Org document, append an additional @samp{local} parameter.  This parameter
12252 becomes a relative depth for the current level.  The following example
12253 inserts a local table of contents, with direct children only.
12255 @example
12256 * Section
12257 #+TOC: headlines 1 local
12258 @end example
12260 Note that for this feature to work properly in @LaTeX{} export, the Org
12261 file requires the inclusion of the titletoc package.  Because of
12262 compatibility issues, titletoc has to be loaded @emph{before} hyperref.
12263 Customize the @code{org-latex-default-packages-alist} variable.
12265 Use the @samp{TOC} keyword to generate list of tables---respectively, all
12266 listings---with captions.
12268 @example
12269 #+TOC: listings
12270 #+TOC: tables
12271 @end example
12273 @cindex @samp{ALT_TITLE}, property
12274 Normally Org uses the headline for its entry in the table of contents.
12275 But with @samp{ALT_TITLE} property, a different entry can be specified for
12276 the table of contents.
12278 @node Include Files
12279 @section Include Files
12281 @cindex include files, during export
12282 @cindex Export, include files
12283 @cindex @samp{INCLUDE}, keyword
12285 During export, you can include the content of another file.  For
12286 example, to include your @samp{.emacs} file, you could use:
12288 @example
12289 #+INCLUDE: "~/.emacs" src emacs-lisp
12290 @end example
12292 @noindent
12293 The optional second and third parameter are the markup (e.g., @samp{quote},
12294 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the language for
12295 formatting the contents.  The markup is optional; if it is not given,
12296 assume text is in Org syntax and process it normally.  The @samp{INCLUDE}
12297 keyword also allows additional parameters @samp{:prefix1} and @samp{:prefix} to
12298 specify prefixes for the first line and for each following line,
12299 @samp{:minlevel} in order to get Org mode content demoted to a specified
12300 level, as well as any options accepted by the selected markup.  For
12301 example, to include a file as an item, use:
12303 @example
12304 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
12305 @end example
12307 You can also include a portion of a file by specifying a lines range
12308 using the @samp{:lines} parameter.  The line at the upper end of the range
12309 is not included.  The start and/or the end of the range may be omitted
12310 to use the obvious defaults.
12312 @table @asis
12313 @item @samp{#+INCLUDE: "~/.emacs" :lines "5-10"}
12314 Include lines 5 to 10, 10 excluded.
12316 @item @samp{#+INCLUDE: "~/.emacs" :lines "-10"} 
12317 Include lines 1 to 10, 10 excluded.
12319 @item @samp{#+INCLUDE: "~/.emacs" :lines "10-"} 
12320 Include lines from 10 to EOF.
12321 @end table
12323 You can visit the file being included with the following command.
12325 @table @asis
12326 @item @kbd{C-c '} (@code{org-edit~special})
12327 @kindex C-c '
12328 @findex org-edit-special
12330 Visit the include file at point.
12331 @end table
12333 @node Macro Replacement
12334 @section Macro Replacement
12336 @cindex macro replacement, during export
12337 @cindex @samp{MACRO}, keyword
12339 @vindex org-export-global-macros
12340 Macros replace text snippets during export.  Macros are defined
12341 globally in @code{org-export-global-macros}, or document-wise with the
12342 following syntax:
12344 @example
12345 #+MACRO: name   replacement text; $1, $2 are arguments
12346 @end example
12348 @noindent
12349 which can be referenced using @samp{@{@{@{name(arg1, arg2)@}@}@}}@footnote{Since commas separate the arguments, commas within arguments
12350 have to be escaped with the backslash character.  So only those
12351 backslash characters before a comma need escaping with another
12352 backslash character.}.  For
12353 example
12355 @example
12356 #+MACRO: poem The rose is $1, The violet's $2. Life's ordered: Org assists you.
12357 @{@{@{poem(red,blue)@}@}@}
12358 @end example
12360 @noindent
12361 becomes
12363 @example
12364 The rose is red, The violet's blue. Life's ordered: Org assists you.
12365 @end example
12367 As a special case, Org parses any replacement text starting with
12368 @samp{(eval} as an Emacs Lisp expression and evaluates it accordingly.
12369 Within such templates, arguments become strings.  Thus, the following
12370 macro
12372 @example
12373 #+MACRO: gnucheck (eval (concat "GNU/" (capitalize $1)))
12374 @end example
12376 @noindent
12377 turns @samp{@{@{@{gnucheck(linux)@}@}@}} into @samp{GNU/Linux} during export.
12379 Org recognizes macro references in following Org markup areas:
12380 paragraphs, headlines, verse blocks, tables cells and lists.  Org also
12381 recognizes macro references in keywords, such as @samp{CAPTION}, @samp{TITLE},
12382 @samp{AUTHOR}, @samp{DATE}, and for some back-end specific export options.
12384 Org comes with following pre-defined macros:
12386 @table @asis
12387 @item @samp{@{@{@{keyword(NAME)@}@}@}}
12388 @itemx @samp{@{@{@{title@}@}@}}
12389 @itemx @samp{@{@{@{author@}@}@}}
12390 @itemx @samp{@{@{@{email@}@}@}}
12391 @cindex @samp{keyword}, macro
12392 @cindex @samp{title}, macro
12393 @cindex @samp{author}, macro
12394 @cindex @samp{email}, macro
12395 The @samp{keyword} macro collects all values from @var{NAME}
12396 keywords throughout the buffer, separated with white space.
12397 @samp{title}, @samp{author} and @samp{email} macros are shortcuts for,
12398 respectively, @samp{@{@{@{keyword(TITLE)@}@}@}}, @samp{@{@{@{keyword(AUTHOR)@}@}@}} and
12399 @samp{@{@{@{keyword(EMAIL)@}@}@}}.
12401 @item @samp{@{@{@{date@}@}@}}
12402 @itemx @samp{@{@{@{date(FORMAT)@}@}@}}
12403 @cindex @samp{date}, macro
12404 This macro refers to the @samp{DATE} keyword.  @var{FORMAT} is an
12405 optional argument to the @samp{date} macro that is used only if @samp{DATE}
12406 is a single timestamp.  @var{FORMAT} should be a format
12407 string understood by @code{format-time-string}.
12409 @item @samp{@{@{@{time(FORMAT)@}@}@}}
12410 @itemx @samp{@{@{@{modification-time(FORMAT, VC)@}@}@}}
12411 @cindex @samp{time}, macro
12412 @cindex @samp{modification-time}, macro
12413 These macros refer to the document's date and time of export and
12414 date and time of modification.  @var{FORMAT} is a string
12415 understood by @code{format-time-string}.  If the second argument to
12416 the @code{modification-time} macro is non-@code{nil}, Org uses @samp{vc.el} to
12417 retrieve the document's modification time from the version
12418 control system.  Otherwise Org reads the file attributes.
12420 @item @samp{@{@{@{input-file@}@}@}}
12421 @cindex @samp{input-file}, macro
12422 This macro refers to the filename of the exported file.
12424 @item @samp{@{@{@{property(PROPERTY-NAME)@}@}@}}
12425 @itemx @samp{@{@{@{property(PROPERTY-NAME, SEARCH OPTION)@}@}@}}
12426 @cindex @samp{property}, macro
12427 This macro returns the value of property @var{PROPERTY-NAME}
12428 in the current entry.  If @var{SEARCH-OPTION} (see @ref{Search Options}) refers to a remote entry, use it instead.
12430 @item @samp{@{@{@{n@}@}@}}
12431 @itemx @samp{@{@{@{n(NAME)@}@}@}}
12432 @itemx @samp{@{@{@{n(NAME, ACTION)@}@}@}}
12433 @cindex @samp{n}, macro
12434 @cindex counter, macro
12435 This macro implements custom counters by returning the number of
12436 times the macro has been expanded so far while exporting the
12437 buffer.  You can create more than one counter using different
12438 @var{NAME} values.  If @var{ACTION} is @samp{-}, previous
12439 value of the counter is held, i.e., the specified counter is not
12440 incremented.  If the value is a number, the specified counter is
12441 set to that value.  If it is any other non-empty string, the
12442 specified counter is reset to 1.  You may leave @var{NAME}
12443 empty to reset the default counter.
12444 @end table
12446 @vindex org-hide-macro-markers
12447 The surrounding brackets can be made invisible by setting
12448 @code{org-hide-macro-markers} non-@code{nil}.
12450 Org expands macros at the very beginning of the export process.
12452 @node Comment Lines
12453 @section Comment Lines
12455 @cindex exporting, not
12457 @cindex comment lines
12458 Lines starting with zero or more whitespace characters followed by one
12459 @samp{#} and a whitespace are treated as comments and, as such, are not
12460 exported.
12462 @cindex @samp{BEGIN_COMMENT}
12463 @cindex comment block
12464 Likewise, regions surrounded by @samp{#+BEGIN_COMMENT} @dots{} @samp{#+END_COMMENT}
12465 are not exported.
12467 @cindex comment trees
12468 Finally, a @samp{COMMENT} keyword at the beginning of an entry, but after
12469 any other keyword or priority cookie, comments out the entire subtree.
12470 In this case, the subtree is not exported and no code block within it
12471 is executed either@footnote{For a less drastic behavior, consider using a select tag (see
12472 @ref{Export Settings}) instead.}.  The command below helps changing the
12473 comment status of a headline.
12475 @table @asis
12476 @item @kbd{C-c ;} (@code{org-toggle-comment})
12477 @kindex C-c ;
12478 @findex org-toggle-comment
12480 Toggle the @samp{COMMENT} keyword at the beginning of an entry.
12481 @end table
12483 @node ASCII/Latin-1/UTF-8 export
12484 @section ASCII/Latin-1/UTF-8 export
12486 @cindex ASCII export
12487 @cindex Latin-1 export
12488 @cindex UTF-8 export
12490 ASCII export produces an output file containing only plain ASCII
12491 characters.  This is the simplest and most direct text output.  It
12492 does not contain any Org markup.  Latin-1 and UTF-8 export use
12493 additional characters and symbols available in these encoding
12494 standards.  All three of these export formats offer the most basic of
12495 text output for maximum portability.
12497 @vindex org-ascii-text-width
12498 On export, Org fills and justifies text according to the text width
12499 set in @code{org-ascii-text-width}.
12501 @vindex org-ascii-links-to-notes
12502 Org exports links using a footnote-like style where the descriptive
12503 part is in the text and the link is in a note before the next heading.
12504 See the variable @code{org-ascii-links-to-notes} for details.
12506 @anchor{ASCII export commands}
12507 @subheading ASCII export commands
12509 @table @asis
12510 @item @kbd{C-c C-e t a} (@code{org-ascii-export-to-ascii})
12511 @itemx @kbd{C-c C-e t l}
12512 @itemx @kbd{C-c C-e t u}
12513 @kindex C-c C-e t a
12514 @kindex C-c C-e t l
12515 @kindex C-c C-e t u
12516 @findex org-ascii-export-to-ascii
12518 Export as an ASCII file with a @samp{.txt} extension.  For
12519 @samp{myfile.org}, Org exports to @samp{myfile.txt}, overwriting without
12520 warning.  For @samp{myfile.txt}, Org exports to @samp{myfile.txt.txt} in
12521 order to prevent data loss.
12522 @end table
12524 @table @asis
12525 @item @kbd{C-c C-e t A} (@code{org-ascii-export-to-ascii})
12526 @itemx @kbd{C-c C-e t L}
12527 @itemx @kbd{C-c C-e t U}
12528 @kindex C-c C-e t A
12529 @kindex C-c C-e t L
12530 @kindex C-c C-e t U
12531 @findex org-ascii-export-to-ascii
12533 Export to a temporary buffer.  Does not create a file.
12534 @end table
12536 @anchor{ASCII specific export settings}
12537 @subheading ASCII specific export settings
12539 The ASCII export back-end has one extra keyword for customizing ASCII
12540 output.  Setting this keyword works similar to the general options
12541 (see @ref{Export Settings}).
12543 @table @asis
12544 @item @samp{SUBTITLE}
12545 @cindex @samp{SUBTITLE}, keyword
12546 The document subtitle.  For long subtitles, use multiple
12547 @samp{#+SUBTITLE} lines in the Org file.  Org prints them on one
12548 continuous line, wrapping into multiple lines if necessary.
12549 @end table
12551 @anchor{Header and sectioning structure}
12552 @subheading Header and sectioning structure
12554 Org converts the first three outline levels into headlines for ASCII
12555 export.  The remaining levels are turned into lists.  To change this
12556 cut-off point where levels become lists, see @ref{Export Settings}.
12558 @anchor{Quoting ASCII text}
12559 @subheading Quoting ASCII text
12561 To insert text within the Org file by the ASCII back-end, use one the
12562 following constructs, inline, keyword, or export block:
12564 @cindex @samp{ASCII}, keyword
12565 @cindex @samp{BEGIN_EXPORT ascii}
12566 @example
12567 Inline text @@@@ascii:and additional text@@@@ within a paragraph.
12569 #+ASCII: Some text
12571 #+BEGIN_EXPORT ascii
12572 Org exports text in this block only when using ASCII back-end.
12573 #+END_EXPORT
12574 @end example
12576 @anchor{ASCII specific attributes}
12577 @subheading ASCII specific attributes
12579 @cindex @samp{ATTR_ASCII}, keyword
12580 @cindex horizontal rules, in ASCII export
12582 ASCII back-end recognizes only one attribute, @code{:width}, which
12583 specifies the width of an horizontal rule in number of characters.
12584 The keyword and syntax for specifying widths is:
12586 @example
12587 #+ATTR_ASCII: :width 10
12588 -----
12589 @end example
12591 @anchor{ASCII special blocks}
12592 @subheading ASCII special blocks
12594 @cindex special blocks, in ASCII export
12595 @cindex @samp{BEGIN_JUSTIFYLEFT}
12596 @cindex @samp{BEGIN_JUSTIFYRIGHT}
12598 Besides @samp{#+BEGIN_CENTER} blocks (see @ref{Paragraphs}), ASCII back-end has
12599 these two left and right justification blocks:
12601 @example
12602 #+BEGIN_JUSTIFYLEFT
12603 It's just a jump to the left...
12604 #+END_JUSTIFYLEFT
12606 #+BEGIN_JUSTIFYRIGHT
12607 ...and then a step to the right.
12608 #+END_JUSTIFYRIGHT
12609 @end example
12611 @node Beamer Export
12612 @section Beamer Export
12614 @cindex Beamer export
12616 Org uses Beamer export to convert an Org file tree structure into
12617 high-quality interactive slides for presentations.  Beamer is a @LaTeX{}
12618 document class for creating presentations in PDF, HTML, and other
12619 popular display formats.
12621 @menu
12622 * Beamer export commands::       For creating Beamer documents.
12623 * Beamer specific export settings:: For customizing Beamer export.
12624 * Frames and Blocks in Beamer::  For composing Beamer slides.
12625 * Beamer specific syntax::       For using in Org documents.
12626 * Editing support::              Editing support.
12627 * A Beamer example::             A complete presentation.
12628 @end menu
12630 @node Beamer export commands
12631 @subsection Beamer export commands
12633 @table @asis
12634 @item @kbd{C-c C-e l b} (@code{org-beamer-export-to-latex})
12635 @kindex C-c C-e l b
12636 @findex org-beamer-export-to-latex
12638 Export as @LaTeX{} file with a @samp{.tex} extension.  For @samp{myfile.org},
12639 Org exports to @samp{myfile.tex}, overwriting without warning.
12641 @item @kbd{C-c C-e l B} (@code{org-beamer-export-as-latex})
12642 @kindex C-c C-e l B
12643 @findex org-beamer-export-as-latex
12645 Export to a temporary buffer.  Does not create a file.
12647 @item @kbd{C-c C-e l P} (@code{org-beamer-export-to-pdf})
12648 @kindex C-c C-e l P
12649 @findex org-beamer-export-to-pdf
12651 Export as @LaTeX{} file and then convert it to PDF format.
12653 @item @kbd{C-c C-e l O}
12654 @kindex C-c C-e l O
12656 Export as @LaTeX{} file, convert it to PDF format, and then open the
12657 PDF file.
12658 @end table
12660 @node Beamer specific export settings
12661 @subsection Beamer specific export settings
12663 Beamer export back-end has several additional keywords for customizing
12664 Beamer output.  These keywords work similar to the general options
12665 settings (see @ref{Export Settings}).
12667 @table @asis
12668 @item @samp{BEAMER_THEME}
12669 @cindex @samp{BEAMER_THEME}, keyword
12670 @vindex org-beamer-theme
12671 The Beamer layout theme (@code{org-beamer-theme}).  Use square
12672 brackets for options.  For example:
12674 @example
12675 #+BEAMER_THEME: Rochester [height=20pt]
12676 @end example
12678 @item @samp{BEAMER_FONT_THEME}
12679 @cindex @samp{BEAMER_FONT_THEME}, keyword
12680 The Beamer font theme.
12682 @item @samp{BEAMER_INNER_THEME}
12683 @cindex @samp{BEAMER_INNER_THEME}, keyword
12684 The Beamer inner theme.
12686 @item @samp{BEAMER_OUTER_THEME}
12687 @cindex @samp{BEAMER_OUTER_THEME}, keyword
12688 The Beamer outer theme.
12690 @item @samp{BEAMER_HEADER}
12691 @cindex @samp{BEAMER_HEADER}, keyword
12692 Arbitrary lines inserted in the preamble, just before the
12693 @samp{hyperref} settings.
12695 @item @samp{DESCRIPTION}
12696 @cindex @samp{DESCRIPTION}, keyword
12697 The document description.  For long descriptions, use multiple
12698 @samp{DESCRIPTION} keywords.  By default, @samp{hyperref} inserts
12699 @samp{DESCRIPTION} as metadata.  Use @code{org-latex-hyperref-template} to
12700 configure document metadata.  Use @code{org-latex-title-command} to
12701 configure typesetting of description as part of front matter.
12703 @item @samp{KEYWORDS}
12704 @cindex @samp{KEYWORDS}, keyword
12705 The keywords for defining the contents of the document.  Use
12706 multiple @samp{KEYWORDS} lines if necessary.  By default, @samp{hyperref}
12707 inserts @samp{KEYWORDS} as metadata.  Use
12708 @code{org-latex-hyperref-template} to configure document metadata.
12709 Use @code{org-latex-title-command} to configure typesetting of
12710 keywords as part of front matter.
12712 @item @samp{SUBTITLE}
12713 @cindex @samp{SUBTITLE}, keyword
12714 Document's subtitle.  For typesetting, use
12715 @code{org-beamer-subtitle-format} string.  Use
12716 @code{org-latex-hyperref-template} to configure document metadata.
12717 Use @code{org-latex-title-command} to configure typesetting of
12718 subtitle as part of front matter.
12719 @end table
12721 @node Frames and Blocks in Beamer
12722 @subsection Frames and Blocks in Beamer
12724 Org transforms heading levels into Beamer's sectioning elements,
12725 frames and blocks.  Any Org tree with a not-too-deep-level nesting
12726 should in principle be exportable as a Beamer presentation.
12728 @itemize
12729 @item
12730 @vindex org-beamer-frame-level
12731 Org headlines become Beamer frames when the heading level in Org is
12732 equal to @code{org-beamer-frame-level} or @samp{H} value in a @samp{OPTIONS} line
12733 (see @ref{Export Settings}).
12735 @cindex @samp{BEAMER_ENV}, property
12736 Org overrides headlines to frames conversion for the current tree of
12737 an Org file if it encounters the @samp{BEAMER_ENV} property set to
12738 @samp{frame} or @samp{fullframe}.  Org ignores whatever
12739 @code{org-beamer-frame-level} happens to be for that headline level in
12740 the Org tree.  In Beamer terminology, a full frame is a frame
12741 without its title.
12743 @item
12744 Org exports a Beamer frame's objects as block environments.  Org can
12745 enforce wrapping in special block types when @samp{BEAMER_ENV} property
12746 is set@footnote{If @samp{BEAMER_ENV} is set, Org export adds @samp{B_environment} tag
12747 to make it visible.  The tag serves as a visual aid and has no
12748 semantic relevance.}.  For valid values see
12749 @code{org-beamer-environments-default}.  To add more values, see
12750 @code{org-beamer-environments-extra}.
12751 @vindex org-beamer-environments-default
12752 @vindex org-beamer-environments-extra
12754 @item
12755 @cindex @samp{BEAMER_REF}, property
12756 If @samp{BEAMER_ENV} is set to @samp{appendix}, Org exports the entry as an
12757 appendix.  When set to @samp{note}, Org exports the entry as a note
12758 within the frame or between frames, depending on the entry's heading
12759 level.  When set to @samp{noteNH}, Org exports the entry as a note
12760 without its title.  When set to @samp{againframe}, Org exports the entry
12761 with @samp{\againframe} command, which makes setting the @samp{BEAMER_REF}
12762 property mandatory because @samp{\againframe} needs frame to resume.
12764 When @samp{ignoreheading} is set, Org export ignores the entry's headline
12765 but not its content.  This is useful for inserting content between
12766 frames.  It is also useful for properly closing a @samp{column}
12767 environment.  @@end itemize
12769 @cindex @samp{BEAMER_ACT}, property
12770 @cindex @samp{BEAMER_OPT}, property
12771 When @samp{BEAMER_ACT} is set for a headline, Org export translates that
12772 headline as an overlay or action specification.  When enclosed in
12773 square brackets, Org export makes the overlay specification
12774 a default.  Use @samp{BEAMER_OPT} to set any options applicable to the
12775 current Beamer frame or block.  The Beamer export back-end wraps
12776 with appropriate angular or square brackets.  It also adds the
12777 @samp{fragile} option for any code that may require a verbatim block.
12779 @cindex @samp{BEAMER_COL}, property
12780 To create a column on the Beamer slide, use the @samp{BEAMER_COL}
12781 property for its headline in the Org file.  Set the value of
12782 @samp{BEAMER_COL} to a decimal number representing the fraction of the
12783 total text width.  Beamer export uses this value to set the column's
12784 width and fills the column with the contents of the Org entry.  If
12785 the Org entry has no specific environment defined, Beamer export
12786 ignores the heading.  If the Org entry has a defined environment,
12787 Beamer export uses the heading as title.  Behind the scenes, Beamer
12788 export automatically handles @LaTeX{} column separations for contiguous
12789 headlines.  To manually adjust them for any unique configurations
12790 needs, use the @samp{BEAMER_ENV} property.
12791 @end itemize
12793 @node Beamer specific syntax
12794 @subsection Beamer specific syntax
12796 Since Org's Beamer export back-end is an extension of the @LaTeX{}
12797 back-end, it recognizes other @LaTeX{} specific syntax---for example,
12798 @samp{#+LATEX:} or @samp{#+ATTR_LATEX:}.  See @ref{@LaTeX{} Export}, for details.
12800 Beamer export wraps the table of contents generated with @samp{toc:t}
12801 @samp{OPTION} keyword in a @samp{frame} environment.  Beamer export does not
12802 wrap the table of contents generated with @samp{TOC} keyword (see @ref{Table of Contents}).  Use square brackets for specifying options.
12804 @example
12805 #+TOC: headlines [currentsection]
12806 @end example
12808 Insert Beamer-specific code using the following constructs:
12810 @cindex @samp{BEAMER}, keyword
12811 @cindex @samp{BEGIN_EXPORT beamer}
12812 @example
12813 #+BEAMER: \pause
12815 #+BEGIN_EXPORT beamer
12816   Only Beamer export back-end exports this.
12817 #+END_BEAMER
12819 Text @@@@beamer:some code@@@@ within a paragraph.
12820 @end example
12822 Inline constructs, such as the last one above, are useful for adding
12823 overlay specifications to objects with @code{bold}, @code{item}, @code{link},
12824 @code{radio-target} and @code{target} types.  Enclose the value in angular
12825 brackets and place the specification at the beginning of the object as
12826 shown in this example:
12828 @example
12829 A *@@@@beamer:<2->@@@@useful* feature
12830 @end example
12832 @cindex @samp{ATTR_BEAMER}, keyword
12833 Beamer export recognizes the @samp{ATTR_BEAMER} keyword with the following
12834 attributes from Beamer configurations: @samp{:environment} for changing
12835 local Beamer environment, @samp{:overlay} for specifying Beamer overlays in
12836 angular or square brackets, and @samp{:options} for inserting optional
12837 arguments.
12839 @example
12840 #+ATTR_BEAMER: :environment nonindentlist
12841 - item 1, not indented
12842 - item 2, not indented
12843 - item 3, not indented
12844 @end example
12846 @example
12847 #+ATTR_BEAMER: :overlay <+->
12848 - item 1
12849 - item 2
12850 @end example
12852 @example
12853 #+ATTR_BEAMER: :options [Lagrange]
12854 Let $G$ be a finite group, and let $H$ be
12855 a subgroup of $G$.  Then the order of $H$ divides the order of $G$.
12856 @end example
12858 @node Editing support
12859 @subsection Editing support
12861 The @code{org-beamer-mode} is a special minor mode for faster editing of
12862 Beamer documents.
12864 @example
12865 #+STARTUP: beamer
12866 @end example
12868 @table @asis
12869 @item @kbd{C-c C-b} (@code{org-beamer-select-environment})
12870 @kindex C-c C-b
12871 @findex org-beamer-select-environment
12873 The @code{org-beamer-mode} provides this key for quicker selections in
12874 Beamer normal environments, and for selecting the @samp{BEAMER_COL}
12875 property.
12876 @end table
12878 @node A Beamer example
12879 @subsection A Beamer example
12881 Here is an example of an Org document ready for Beamer export.
12883 @example
12884 ;#+TITLE: Example Presentation
12885 ;#+AUTHOR: Carsten Dominik
12886 ;#+OPTIONS: H:2 toc:t num:t
12887 ;#+LATEX_CLASS: beamer
12888 ;#+LATEX_CLASS_OPTIONS: [presentation]
12889 ;#+BEAMER_THEME: Madrid
12890 ;#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) %8BEAMER_OPT(Opt)
12892 * This is the first structural section
12894 ** Frame 1
12895 *** Thanks to Eric Fraga                                           :B_block:
12896     :PROPERTIES:
12897     :BEAMER_COL: 0.48
12898     :BEAMER_ENV: block
12899     :END:
12900     for the first viable Beamer setup in Org
12901 *** Thanks to everyone else                                        :B_block:
12902     :PROPERTIES:
12903     :BEAMER_COL: 0.48
12904     :BEAMER_ACT: <2->
12905     :BEAMER_ENV: block
12906     :END:
12907     for contributing to the discussion
12908 **** This will be formatted as a beamer note                       :B_note:
12909      :PROPERTIES:
12910      :BEAMER_env: note
12911      :END:
12912 ** Frame 2 (where we will not use columns)
12913 *** Request
12914     Please test this stuff!
12915 @end example
12917 @node HTML Export
12918 @section HTML Export
12920 @cindex HTML export
12922 Org mode contains an HTML exporter with extensive HTML formatting
12923 compatible with XHTML 1.0 strict standard.
12925 @menu
12926 * HTML export commands::         Invoking HTML export.
12927 * HTML specific export settings:: Settings for HTML export.
12928 * HTML doctypes::                Exporting various (X)HTML flavors.
12929 * HTML preamble and postamble::  Inserting preamble and postamble.
12930 * Quoting HTML tags::            Using direct HTML in Org files.
12931 * Links in HTML export::         Inserting and formatting links.
12932 * Tables in HTML export::        How to modify the formatting of tables.
12933 * Images in HTML export::        How to insert figures into HTML output.
12934 * Math formatting in HTML export:: Beautiful math also on the web.
12935 * Text areas in HTML export::    An alternate way to show an example.
12936 * CSS support::                  Changing the appearance of the output.
12937 * JavaScript support::           Info and folding in a web browser.
12938 @end menu
12940 @node HTML export commands
12941 @subsection HTML export commands
12943 @table @asis
12944 @item @kbd{C-c C-e h h} (@code{org-html-export-to-html})
12945 @kindex C-c C-e h h
12946 @kindex C-c C-e h o
12947 @findex org-html-export-to-html
12949 Export as HTML file with a @samp{.html} extension.  For @samp{myfile.org},
12950 Org exports to @samp{myfile.html}, overwriting without warning.
12951 @{@{@{kbd@{C-c C-e h o)@}@}@} exports to HTML and opens it in a web
12952 browser.
12954 @item @kbd{C-c C-e h H} (@code{org-html-export-as-html})
12955 @kindex C-c C-e h H
12956 @findex org-html-export-as-html
12958 Exports to a temporary buffer.  Does not create a file.
12959 @end table
12961 @node HTML specific export settings
12962 @subsection HTML specific export settings
12964 HTML export has a number of keywords, similar to the general options
12965 settings described in @ref{Export Settings}.
12967 @table @asis
12968 @item @samp{DESCRIPTION}
12969 @cindex @samp{DESCRIPTION}, keyword
12970 This is the document's description, which the HTML exporter
12971 inserts it as a HTML meta tag in the HTML file.  For long
12972 descriptions, use multiple @samp{DESCRIPTION} lines.  The exporter
12973 takes care of wrapping the lines properly.
12975 @item @samp{HTML_DOCTYPE}
12976 @cindex @samp{HTML_DOCTYPE}, keyword
12977 @vindex org-html-doctype
12978 Specify the document type, for example: HTML5
12979 (@code{org-html-doctype}).
12981 @item @samp{HTML_CONTAINER}
12982 @cindex @samp{HTML_CONTAINER}, keyword
12983 @vindex org-html-container-element
12984 Specify the HTML container, such as @samp{div}, for wrapping sections
12985 and elements (@code{org-html-container-element}).
12987 @item @samp{HTML_LINK_HOME}
12988 @cindex @samp{HTML_LINK_HOME}, keyword
12989 @vindex org-html-link-home
12990 The URL for home link (@code{org-html-link-home}).
12992 @item @samp{HTML_LINK_UP}
12993 @cindex @samp{HTML_LINK_UP}, keyword
12994 @vindex org-html-link-up
12995 The URL for the up link of exported HTML pages
12996 (@code{org-html-link-up}).
12998 @item @samp{HTML_MATHJAX}
12999 @cindex @samp{HTML_MATHJAX}, keyword
13000 @vindex org-html-mathjax-options
13001 Options for MathJax (@code{org-html-mathjax-options}).  MathJax is
13002 used to typeset @LaTeX{} math in HTML documents.  See @ref{Math formatting in HTML export}, for an example.
13004 @item @samp{HTML_HEAD}
13005 @cindex @samp{HTML_HEAD}, keyword
13006 @vindex org-html-head
13007 Arbitrary lines for appending to the HTML document's head
13008 (@code{org-html-head}).
13010 @item @samp{HTML_HEAD_EXTRA}
13011 @cindex @samp{HTML_HEAD_EXTRA}, keyword
13012 @vindex org-html-head-extra
13013 More arbitrary lines for appending to the HTML document's head
13014 (@code{org-html-head-extra}).
13016 @item @samp{KEYWORDS}
13017 @cindex @samp{KEYWORDS}, keyword
13018 Keywords to describe the document's content.  HTML exporter
13019 inserts these keywords as HTML meta tags.  For long keywords, use
13020 multiple @samp{KEYWORDS} lines.
13022 @item @samp{LATEX_HEADER}
13023 @cindex @samp{LATEX_HEADER}, keyword
13024 Arbitrary lines for appending to the preamble; HTML exporter
13025 appends when transcoding @LaTeX{} fragments to images (see @ref{Math formatting in HTML export}).
13027 @item @samp{SUBTITLE}
13028 @cindex @samp{SUBTITLE}, keyword
13029 The document's subtitle.  HTML exporter formats subtitle if
13030 document type is @samp{HTML5} and the CSS has a @samp{subtitle} class.
13031 @end table
13033 Some of these keywords are explained in more detail in the following
13034 sections of the manual.
13036 @node HTML doctypes
13037 @subsection HTML doctypes
13039 Org can export to various (X)HTML flavors.
13041 @vindex org-html-doctype
13042 @vindex org-html-doctype-alist
13043 Set the @code{org-html-doctype} variable for different (X)HTML variants.
13044 Depending on the variant, the HTML exporter adjusts the syntax of HTML
13045 conversion accordingly.  Org includes the following ready-made
13046 variants:
13048 @itemize
13049 @item
13050 @code{"html4-strict"}
13051 @item
13052 @code{"html4-transitional"}
13053 @item
13054 @code{"html4-frameset"}
13055 @item
13056 @code{"xhtml-strict"}
13057 @item
13058 @code{"xhtml-transitional"}
13059 @item
13060 @code{"xhtml-frameset"}
13061 @item
13062 @code{"xhtml-11"}
13063 @item
13064 @code{"html5"}
13065 @item
13066 @code{"xhtml5"}
13067 @end itemize
13069 @noindent
13070 See the variable @code{org-html-doctype-alist} for details.  The default is
13071 @code{"xhtml-strict"}.
13073 @vindex org-html-html5-fancy
13074 @cindex @samp{HTML5}, export new elements
13075 Org's HTML exporter does not by default enable new block elements
13076 introduced with the HTML5 standard.  To enable them, set
13077 @code{org-html-html5-fancy} to non-@code{nil}.  Or use an @samp{OPTIONS} line in the
13078 file to set @samp{html5-fancy}.
13080 HTML5 documents can now have arbitrary @samp{#+BEGIN} @dots{} @samp{#+END} blocks.
13081 For example:
13083 @example
13084 #+BEGIN_aside
13085   Lorem ipsum
13086 #+END_aside
13087 @end example
13089 @noindent
13090 exports to:
13092 @example
13093 <aside>
13094   <p>Lorem ipsum</p>
13095 </aside>
13096 @end example
13098 @noindent
13099 while this:
13101 @example
13102 #+ATTR_HTML: :controls controls :width 350
13103 #+BEGIN_video
13104 #+HTML: <source src="movie.mp4" type="video/mp4">
13105 #+HTML: <source src="movie.ogg" type="video/ogg">
13106 Your browser does not support the video tag.
13107 #+END_video
13108 @end example
13110 @noindent
13111 exports to:
13113 @example
13114 <video controls="controls" width="350">
13115   <source src="movie.mp4" type="video/mp4">
13116     <source src="movie.ogg" type="video/ogg">
13117       <p>Your browser does not support the video tag.</p>
13118 </video>
13119 @end example
13121 @vindex org-html-html5-elements
13122 When special blocks do not have a corresponding HTML5 element, the
13123 HTML exporter reverts to standard translation (see
13124 @code{org-html-html5-elements}).  For example, @samp{#+BEGIN_lederhosen} exports
13125 to @code{<div class="lederhosen">}.
13127 Special blocks cannot have headlines.  For the HTML exporter to wrap
13128 the headline and its contents in @code{<section>} or @code{<article>} tags, set
13129 the @samp{HTML_CONTAINER} property for the headline.
13131 @node HTML preamble and postamble
13132 @subsection HTML preamble and postamble
13134 @vindex org-html-preamble
13135 @vindex org-html-postamble
13136 @vindex org-html-preamble-format
13137 @vindex org-html-postamble-format
13138 @vindex org-html-validation-link
13139 @vindex org-export-creator-string
13140 @vindex org-export-time-stamp-file
13142 The HTML exporter has delineations for preamble and postamble.  The
13143 default value for @code{org-html-preamble} is @code{t}, which makes the HTML
13144 exporter insert the preamble.  See the variable
13145 @code{org-html-preamble-format} for the format string.
13147 Set @code{org-html-preamble} to a string to override the default format
13148 string.  If the string is a function, the HTML exporter expects the
13149 function to return a string upon execution.  The HTML exporter inserts
13150 this string in the preamble.  The HTML exporter does not insert
13151 a preamble if @code{org-html-preamble} is set @code{nil}.
13153 The default value for @code{org-html-postamble} is @code{auto}, which makes the
13154 HTML exporter build a postamble from looking up author's name, email
13155 address, creator's name, and date.  Set @code{org-html-postamble} to @code{t} to
13156 insert the postamble in the format specified in the
13157 @code{org-html-postamble-format} variable.  The HTML exporter does not
13158 insert a postamble if @code{org-html-postamble} is set to @code{nil}.
13160 @node Quoting HTML tags
13161 @subsection Quoting HTML tags
13163 The HTML export back-end transforms @samp{<} and @samp{>} to @samp{&lt;} and @samp{&gt;}.
13165 To include raw HTML code in the Org file so the HTML export back-end
13166 can insert that HTML code in the output, use this inline syntax:
13167 @samp{@@@@html:...@@@@}.  For example:
13169 @example
13170 @@@@html:<b>@@@@bold text@@@@html:</b>@@@@
13171 @end example
13173 @cindex @samp{HTML}, keyword
13174 @cindex @samp{BEGIN_EXPORT html}
13175 For larger raw HTML code blocks, use these HTML export code blocks:
13177 @example
13178 #+HTML: Literal HTML code for export
13180 #+BEGIN_EXPORT html
13181   All lines between these markers are exported literally
13182 #+END_EXPORT
13183 @end example
13185 @node Links in HTML export
13186 @subsection Links in HTML export
13188 @cindex links, in HTML export
13189 @cindex internal links, in HTML export
13190 @cindex external links, in HTML export
13192 The HTML export back-end transforms Org's internal links (see
13193 @ref{Internal Links}) to equivalent HTML links in the output.  The back-end
13194 similarly handles Org's automatic links created by radio targets (see
13195 @ref{Radio Targets}) similarly.  For Org links to external files, the
13196 back-end transforms the links to @emph{relative} paths.
13198 @vindex org-html-link-org-files-as-html
13199 For Org links to other @samp{.org} files, the back-end automatically
13200 changes the file extension to @samp{.html} and makes file paths relative.
13201 If the @samp{.org} files have an equivalent @samp{.html} version at the same
13202 location, then the converted links should work without any further
13203 manual intervention.  However, to disable this automatic path
13204 translation, set @code{org-html-link-org-files-as-html} to @code{nil}.  When
13205 disabled, the HTML export back-end substitutes the ID-based links in
13206 the HTML output.  For more about linking files when publishing to
13207 a directory, see @ref{Publishing links}.
13209 Org files can also have special directives to the HTML export
13210 back-end.  For example, by using @samp{#+ATTR_HTML} lines to specify new
13211 format attributes to @code{<a>} or @code{<img>} tags.  This example shows
13212 changing the link's title and style:
13214 @cindex @samp{ATTR_HTML}, keyword
13215 @example
13216 #+ATTR_HTML: :title The Org mode homepage :style color:red;
13217 [[https://orgmode.org]]
13218 @end example
13220 @node Tables in HTML export
13221 @subsection Tables in HTML export
13223 @cindex tables, in HTML
13224 @vindex org-export-html-table-tag
13226 The HTML export back-end uses @code{org-html-table-default-attributes} when
13227 exporting Org tables to HTML.  By default, the exporter does not draw
13228 frames and cell borders.  To change for this for a table, use the
13229 following lines before the table in the Org file:
13231 @cindex @samp{CAPTION}, keyword
13232 @cindex @samp{ATTR_HTML}, keyword
13233 @example
13234 #+CAPTION: This is a table with lines around and between cells
13235 #+ATTR_HTML: border="2" rules="all" frame="border"
13236 @end example
13238 The HTML export back-end preserves column groupings in Org tables (see
13239 @ref{Column Groups}) when exporting to HTML.
13241 Additional options for customizing tables for HTML export.
13243 @table @asis
13244 @item @code{org-html-table-align-individual-fields}
13245 @vindex org-html-table-align-individual-fields
13246 Non-@code{nil} attaches style attributes for alignment to each table
13247 field.
13249 @item @code{org-html-table-caption-above}
13250 @vindex org-html-table-caption-above
13251 Non-@code{nil} places caption string at the beginning of the table.
13253 @item @code{org-html-table-data-tags}
13254 @vindex org-html-table-data-tags
13255 Opening and ending tags for table data fields.
13257 @item @code{org-html-table-default-attributes}
13258 @vindex org-html-table-default-attributes
13259 Default attributes and values for table tags.
13261 @item @code{org-html-table-header-tags}
13262 @vindex org-html-table-header-tags
13263 Opening and ending tags for table's header fields.
13265 @item @code{org-html-table-row-tags}
13266 @vindex org-html-table-row-tags
13267 Opening and ending tags for table rows.
13269 @item @code{org-html-table-use-header-tags-for-first-column}
13270 @vindex org-html-table-use-header-tags-for-first-column
13271 Non-@code{nil} formats column one in tables with header tags.
13272 @end table
13274 @node Images in HTML export
13275 @subsection Images in HTML export
13277 @cindex images, inline in HTML
13278 @cindex inlining images in HTML
13280 The HTML export back-end has features to convert Org image links to
13281 HTML inline images and HTML clickable image links.
13283 @vindex org-html-inline-images
13284 When the link in the Org file has no description, the HTML export
13285 back-end by default in-lines that image.  For example:
13286 @samp{[[file:myimg.jpg]]} is in-lined, while @samp{[[file:myimg.jpg][the image]]} links to the text,
13287 @samp{the image}.  For more details, see the variable
13288 @code{org-html-inline-images}.
13290 On the other hand, if the description part of the Org link is itself
13291 another link, such as @samp{file:} or @samp{http:} URL pointing to an image, the
13292 HTML export back-end in-lines this image and links to the main image.
13293 This Org syntax enables the back-end to link low-resolution thumbnail
13294 to the high-resolution version of the image, as shown in this example:
13296 @example
13297 [[file:highres.jpg][file:thumb.jpg]]
13298 @end example
13300 To change attributes of in-lined images, use @samp{#+ATTR_HTML} lines in
13301 the Org file.  This example shows realignment to right, and adds @code{alt}
13302 and @code{title} attributes in support of text viewers and modern web
13303 accessibility standards.
13305 @cindex @samp{CAPTION}, keyword
13306 @cindex @samp{ATTR_HTML}, keyword
13307 @example
13308 #+CAPTION: A black cat stalking a spider
13309 #+ATTR_HTML: :alt cat/spider image :title Action! :align right
13310 [[./img/a.jpg]]
13311 @end example
13313 @noindent
13314 The HTML export back-end copies the @samp{http} links from the Org file as
13317 @node Math formatting in HTML export
13318 @subsection Math formatting in HTML export
13320 @cindex MathJax
13321 @cindex dvipng
13322 @cindex dvisvgm
13323 @cindex ImageMagick
13325 @vindex org-html-mathjax-options~
13326 @LaTeX{} math snippets (see @ref{@LaTeX{} fragments}) can be displayed in two
13327 different ways on HTML pages.  The default is to use the @uref{http://www.mathjax.org, MathJax},
13328 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
13329 @uref{http://www.mathjax.org, MathJax}.}.  Some MathJax
13330 display options can be configured via @code{org-html-mathjax-options}, or
13331 in the buffer.  For example, with the following settings,
13333 @example
13334 #+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
13335 #+HTML_MATHJAX: cancel.js noErrors.js
13336 @end example
13338 @noindent
13339 equation labels are displayed on the left margin and equations are
13340 five em from the left margin.  In addition, it loads the two MathJax
13341 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
13342 about extensions.}.
13344 @vindex org-html-mathjax-template
13345 See the docstring of @code{org-html-mathjax-options} for all supported
13346 variables.  The MathJax template can be configure via
13347 @code{org-html-mathjax-template}.
13349 If you prefer, you can also request that @LaTeX{} fragments are processed
13350 into small images that will be inserted into the browser page.  Before
13351 the availability of MathJax, this was the default method for Org
13352 files.  This method requires that the dvipng program, dvisvgm or
13353 ImageMagick suite is available on your system.  You can still get this
13354 processing with
13356 @example
13357 #+OPTIONS: tex:dvipng
13358 @end example
13360 @example
13361 #+OPTIONS: tex:dvisvgm
13362 @end example
13364 @noindent
13367 @example
13368 #+OPTIONS: tex:imagemagick
13369 @end example
13371 @node Text areas in HTML export
13372 @subsection Text areas in HTML export
13374 @cindex text areas, in HTML
13375 Before Org mode's Babel, one popular approach to publishing code in
13376 HTML was by using @samp{:textarea}.  The advantage of this approach was
13377 that copying and pasting was built into browsers with simple
13378 JavaScript commands.  Even editing before pasting was made simple.
13380 The HTML export back-end can create such text areas.  It requires an
13381 @samp{#+ATTR_HTML} line as shown in the example below with the @samp{:textarea}
13382 option.  This must be followed by either an example or a source code
13383 block.  Other Org block types do not honor the @samp{:textarea} option.
13385 By default, the HTML export back-end creates a text area 80 characters
13386 wide and height just enough to fit the content.  Override these
13387 defaults with @samp{:width} and @samp{:height} options on the @samp{#+ATTR_HTML}
13388 line.
13390 @example
13391 #+ATTR_HTML: :textarea t :width 40
13392 #+BEGIN_EXAMPLE
13393   (defun org-xor (a b)
13394      "Exclusive or."
13395      (if a (not b) b))
13396 #+END_EXAMPLE
13397 @end example
13399 @node CSS support
13400 @subsection CSS support
13402 @cindex CSS, for HTML export
13403 @cindex HTML export, CSS
13405 @vindex org-export-html-todo-kwd-class-prefix
13406 @vindex org-export-html-tag-class-prefix
13407 You can modify the CSS style definitions for the exported file.  The
13408 HTML exporter assigns the following special CSS classes@footnote{If the classes on TODO keywords and tags lead to conflicts,
13409 use the variables @code{org-html-todo-kwd-class-prefix} and
13410 @code{org-html-tag-class-prefix} to make them unique.} to
13411 appropriate parts of the document---your style specifications may
13412 change these, in addition to any of the standard classes like for
13413 headlines, tables, etc.
13415 @multitable {aaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
13416 @item @code{p.author}
13417 @tab author information, including email
13418 @item @code{p.date}
13419 @tab publishing date
13420 @item @code{p.creator}
13421 @tab creator info, about org mode version
13422 @item @code{.title}
13423 @tab document title
13424 @item @code{.subtitle}
13425 @tab document subtitle
13426 @item @code{.todo}
13427 @tab TODO keywords, all not-done states
13428 @item @code{.done}
13429 @tab the DONE keywords, all states that count as done
13430 @item @code{.WAITING}
13431 @tab each TODO keyword also uses a class named after itself
13432 @item @code{.timestamp}
13433 @tab timestamp
13434 @item @code{.timestamp-kwd}
13435 @tab keyword associated with a timestamp, like @samp{SCHEDULED}
13436 @item @code{.timestamp-wrapper}
13437 @tab span around keyword plus timestamp
13438 @item @code{.tag}
13439 @tab tag in a headline
13440 @item @code{._HOME}
13441 @tab each tag uses itself as a class, ``@@'' replaced by ``_''
13442 @item @code{.target}
13443 @tab target for links
13444 @item @code{.linenr}
13445 @tab the line number in a code example
13446 @item @code{.code-highlighted}
13447 @tab for highlighting referenced code lines
13448 @item @code{div.outline-N}
13449 @tab div for outline level N (headline plus text)
13450 @item @code{div.outline-text-N}
13451 @tab extra div for text at outline level N
13452 @item @code{.section-number-N}
13453 @tab section number in headlines, different for each level
13454 @item @code{.figure-number}
13455 @tab label like ``Figure 1:''
13456 @item @code{.table-number}
13457 @tab label like ``Table 1:''
13458 @item @code{.listing-number}
13459 @tab label like ``Listing 1:''
13460 @item @code{div.figure}
13461 @tab how to format an in-lined image
13462 @item @code{pre.src}
13463 @tab formatted source code
13464 @item @code{pre.example}
13465 @tab normal example
13466 @item @code{p.verse}
13467 @tab verse paragraph
13468 @item @code{div.footnotes}
13469 @tab footnote section headline
13470 @item @code{p.footnote}
13471 @tab footnote definition paragraph, containing a footnote
13472 @item @code{.footref}
13473 @tab a footnote reference number (always a <sup>)
13474 @item @code{.footnum}
13475 @tab footnote number in footnote definition (always <sup>)
13476 @item @code{.org-svg}
13477 @tab default class for a linked @samp{.svg} image
13478 @end multitable
13480 @vindex org-html-style-default
13481 @vindex org-html-head
13482 @vindex org-html-head-extra
13483 @cindex @samp{HTML_INCLUDE_STYLE}, keyword
13484 The HTML export back-end includes a compact default style in each
13485 exported HTML file.  To override the default style with another style,
13486 use these keywords in the Org file.  They will replace the global
13487 defaults the HTML exporter uses.
13489 @cindex @samp{HTML_HEAD}, keyword
13490 @cindex @samp{HTML_HEAD_EXTRA}, keyword
13491 @example
13492 #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
13493 #+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
13494 @end example
13496 @vindex org-html-head-include-default-style
13497 To just turn off the default style, customize
13498 @code{org-html-head-include-default-style} variable, or use this option
13499 line in the Org file.
13501 @cindex @samp{html-style}, @samp{OPTIONS} item
13502 @example
13503 #+OPTIONS: html-style:nil
13504 @end example
13506 For longer style definitions, either use several @samp{HTML_HEAD} and
13507 @samp{HTML_HEAD_EXTRA} keywords, or use @code{<style> ... </style>} blocks
13508 around them.  Both of these approaches can avoid referring to an
13509 external file.
13511 @cindex @samp{HTML_CONTAINER_CLASS}, property
13512 In order to add styles to a sub-tree, use the @samp{HTML_CONTAINER_CLASS}
13513 property to assign a class to the tree.  In order to specify CSS
13514 styles for a particular headline, you can use the id specified in
13515 a @samp{CUSTOM_ID} property.
13517 Never change the @code{org-html-style-default} constant.  Instead use other
13518 simpler ways of customizing as described above.
13520 @node JavaScript support
13521 @subsection JavaScript supported display of web pages
13523 Sebastian Rose has written a JavaScript program especially designed to
13524 enhance the web viewing experience of HTML files created with Org.
13525 This program enhances large files in two different ways of viewing.
13526 One is an @emph{Info}-like mode where each section is displayed separately
13527 and navigation can be done with the @kbd{n} and @kbd{p}
13528 keys, and some other keys as well, press @kbd{?} for an overview
13529 of the available keys.  The second one has a @emph{folding} view, much like
13530 Org provides inside Emacs.  The script is available at
13531 @uref{https://orgmode.org/org-info.js} and the documentation at
13532 @uref{https://orgmode.org/worg/code/org-info-js/}.  The script is hosted on
13533 @uref{https://orgmode.org}, but for reliability, prefer installing it on your
13534 own web server.
13536 To use this program, just add this line to the Org file:
13538 @cindex @samp{INFOJS_OPT}, keyword
13539 @example
13540 #+INFOJS_OPT: view:info toc:nil
13541 @end example
13543 @noindent
13544 The HTML header now has the code needed to automatically invoke the
13545 script.  For setting options, use the syntax from the above line for
13546 options described below:
13548 @table @asis
13549 @item @samp{path:}
13550 The path to the script.  The default is to grab the script from
13551 @uref{https://orgmode.org/org-info.js}, but you might want to have
13552 a local copy and use a path like @samp{../scripts/org-info.js}.
13554 @item @samp{view:}
13555 Initial view when the website is first shown.  Possible values are:
13557 @multitable {aaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
13558 @item @samp{info}
13559 @tab Info-like interface with one section per page
13560 @item @samp{overview}
13561 @tab Folding interface, initially showing only top-level
13562 @item @samp{content}
13563 @tab Folding interface, starting with all headlines visible
13564 @item @samp{showall}
13565 @tab Folding interface, all headlines and text visible
13566 @end multitable
13568 @item @samp{sdepth:}
13569 Maximum headline level still considered as an independent section
13570 for info and folding modes.  The default is taken from
13571 @code{org-export-headline-levels}, i.e., the @samp{H} switch in @samp{OPTIONS}.
13572 If this is smaller than in @code{org-export-headline-levels}, each
13573 info/folding section can still contain child headlines.
13575 @item @samp{toc:}
13576 Should the table of contents @emph{initially} be visible?  Even when
13577 @samp{nil}, you can always get to the ``toc'' with @kbd{i}.
13579 @item @samp{tdepth:}
13580 The depth of the table of contents.  The defaults are taken from
13581 the variables @code{org-export-headline-levels} and
13582 @code{org-export-with-toc}.
13584 @item @samp{ftoc:}
13585 Does the CSS of the page specify a fixed position for the ``toc''?
13586 If yes, the toc is displayed as a section.
13588 @item @samp{ltoc:}
13589 Should there be short contents (children) in each section?  Make
13590 this @samp{above} if the section should be above initial text.
13592 @item @samp{mouse:}
13593 Headings are highlighted when the mouse is over them.  Should be
13594 @samp{underline} (default) or a background color like @samp{#cccccc}.
13596 @item @samp{buttons:}
13597 Should view-toggle buttons be everywhere?  When @samp{nil} (the
13598 default), only one such button is present.
13599 @end table
13601 @noindent
13602 @vindex org-infojs-options
13603 @vindex org-export-html-use-infojs
13604 You can choose default values for these options by customizing the
13605 variable @code{org-infojs-options}.  If you always want to apply the script
13606 to your pages, configure the variable @code{org-export-html-use-infojs}.
13608 @node @LaTeX{} Export
13609 @section @LaTeX{} Export
13611 @cindex @LaTeX{} export
13612 @cindex PDF export
13614 The @LaTeX{} export back-end can handle complex documents, incorporate
13615 standard or custom @LaTeX{} document classes, generate documents using
13616 alternate @LaTeX{} engines, and produce fully linked PDF files with
13617 indexes, bibliographies, and tables of contents, destined for
13618 interactive online viewing or high-quality print publication.
13620 While the details are covered in-depth in this section, here are some
13621 quick references to variables for the impatient: for engines, see
13622 @code{org-latex-compiler}; for build sequences, see
13623 @code{org-latex-pdf-process}; for packages, see
13624 @code{org-latex-default-packages-alist} and @code{org-latex-packages-alist}.
13626 An important note about the @LaTeX{} export back-end: it is sensitive to
13627 blank lines in the Org document.  That's because @LaTeX{} itself depends
13628 on blank lines to tell apart syntactical elements, such as paragraphs.
13630 @menu
13631 * @LaTeX{}/PDF export commands:: For producing @LaTeX{} and PDF documents.
13632 * @LaTeX{} specific export settings:: Unique to this @LaTeX{} back-end.
13633 * @LaTeX{} header and sectioning:: Setting up the export file structure.
13634 * Quoting @LaTeX{} code::        Incorporating literal @LaTeX{} code.
13635 * Tables in @LaTeX{} export::    Options for exporting tables to @LaTeX{}.
13636 * Images in @LaTeX{} export::    How to insert figures into @LaTeX{} output.
13637 * Plain lists in @LaTeX{} export:: Attributes specific to lists.
13638 * Source blocks in @LaTeX{} export:: Attributes specific to source code blocks.
13639 * Example blocks in @LaTeX{} export:: Attributes specific to example blocks.
13640 * Special blocks in @LaTeX{} export:: Attributes specific to special blocks.
13641 * Horizontal rules in @LaTeX{} export:: Attributes specific to horizontal rules.
13642 @end menu
13644 @node @LaTeX{}/PDF export commands
13645 @subsection @LaTeX{}/PDF export commands
13647 @table @asis
13648 @item @kbd{C-c C-e l l} (@code{org-latex-export-to-latex})
13649 @kindex C-c C-e l l
13650 @findex org-latex-export-to-latex~
13651 Export to a @LaTeX{} file with a @samp{.tex} extension.  For
13652 @samp{myfile.org}, Org exports to @samp{myfile.tex}, overwriting without
13653 warning.
13655 @item @kbd{C-c C-e l L} (@code{org-latex-export-as-latex})
13656 @kindex C-c C-e l L
13657 @findex org-latex-export-as-latex
13658 Export to a temporary buffer.  Do not create a file.
13660 @item @kbd{C-c C-e l p} (@code{org-latex-export-to-pdf})
13661 @kindex C-c C-e l p
13662 @findex org-latex-export-to-pdf
13663 Export as @LaTeX{} file and convert it to PDF file.
13665 @item @kbd{C-c C-e l o}
13666 @kindex C-c C-e l o
13667 Export as @LaTeX{} file and convert it to PDF, then open the PDF
13668 using the default viewer.
13670 @item @kbd{M-x org-export-region-as-latex}
13671 Convert the region to @LaTeX{} under the assumption that it was in Org
13672 mode syntax before.  This is a global command that can be invoked in
13673 any buffer.
13674 @end table
13676 @vindex org-latex-compiler
13677 @vindex org-latex-bibtex-compiler
13678 @vindex org-latex-default-packages-alist
13679 @cindex pdflatex
13680 @cindex xelatex
13681 @cindex lualatex
13682 @cindex @samp{LATEX_COMPILER}, keyword
13683 The @LaTeX{} export back-end can use any of these @LaTeX{} engines:
13684 @samp{pdflatex}, @samp{xelatex}, and @samp{lualatex}.  These engines compile @LaTeX{}
13685 files with different compilers, packages, and output options.  The
13686 @LaTeX{} export back-end finds the compiler version to use from
13687 @code{org-latex-compiler} variable or the @samp{#+LATEX_COMPILER} keyword in the
13688 Org file.  See the docstring for the
13689 @code{org-latex-default-packages-alist} for loading packages with certain
13690 compilers.  Also see @code{org-latex-bibtex-compiler} to set the
13691 bibliography compiler@footnote{This does not allow setting different bibliography compilers
13692 for different files.  However, ``smart'' @LaTeX{} compilation systems, such
13693 as latexmk, can select the correct bibliography compiler.}.
13695 @node @LaTeX{} specific export settings
13696 @subsection @LaTeX{} specific export settings
13698 The @LaTeX{} export back-end has several additional keywords for
13699 customizing @LaTeX{} output.  Setting these keywords works similar to the
13700 general options (see @ref{Export Settings}).
13702 @table @asis
13703 @item @samp{DESCRIPTION}
13704 @cindex @samp{DESCRIPTION}, keyword
13705 @vindex org-latex-hyperref-template
13706 @vindex org-latex-title-command
13707 The document's description.  The description along with author
13708 name, keywords, and related file metadata are inserted in the
13709 output file by the hyperref package.  See
13710 @code{org-latex-hyperref-template} for customizing metadata items.
13711 See @code{org-latex-title-command} for typesetting description into
13712 the document's front matter.  Use multiple @samp{DESCRIPTION} keywords
13713 for long descriptions.
13715 @item @samp{LATEX_CLASS}
13716 @cindex @samp{LATEX_CLASS}, keyword
13717 @vindex org-latex-default-class
13718 @vindex org-latex-classes
13719 This is @LaTeX{} document class, such as @emph{article}, @emph{report},
13720 @emph{book}, and so on, which contain predefined preamble and headline
13721 level mapping that the @LaTeX{} export back-end needs.  The back-end
13722 reads the default class name from the @code{org-latex-default-class}
13723 variable.  Org has @emph{article} as the default class.  A valid
13724 default class must be an element of @code{org-latex-classes}.
13726 @item @samp{LATEX_CLASS_OPTIONS}
13727 @cindex @samp{LATEX_CLASS_OPTIONS}, keyword
13728 Options the @LaTeX{} export back-end uses when calling the @LaTeX{}
13729 document class.
13731 @item @samp{LATEX_COMPILER}
13732 @cindex @samp{LATEX_COMPILER}, keyword
13733 @vindex org-latex-compiler
13734 The compiler, such as @samp{pdflatex}, @samp{xelatex}, @samp{lualatex}, for
13735 producing the PDF.  See @code{org-latex-compiler}.
13737 @item @samp{LATEX_HEADER}
13738 @itemx @samp{LATEX_HEADER_EXTRA}
13739 @cindex @samp{LATEX_HEADER}, keyword
13740 @cindex @samp{LATEX_HEADER_EXTRA}, keyword
13741 @vindex org-latex-classes
13742 Arbitrary lines to add to the document's preamble, before the
13743 hyperref settings.  See @code{org-latex-classes} for adjusting the
13744 structure and order of the @LaTeX{} headers.
13746 @item @samp{KEYWORDS}
13747 @cindex @samp{KEYWORDS}, keyword
13748 @vindex org-latex-hyperref-template
13749 @vindex org-latex-title-command
13750 The keywords for the document.  The description along with author
13751 name, keywords, and related file metadata are inserted in the
13752 output file by the hyperref package.  See
13753 @code{org-latex-hyperref-template} for customizing metadata items.
13754 See @code{org-latex-title-command} for typesetting description into
13755 the document's front matter.  Use multiple @samp{KEYWORDS} lines if
13756 necessary.
13758 @item @samp{SUBTITLE}
13759 @cindex @samp{SUBTITLE}, keyword
13760 @vindex org-latex-subtitle-separate
13761 @vindex org-latex-subtitle-format
13762 The document's subtitle.  It is typeset as per
13763 @code{org-latex-subtitle-format}.  If @code{org-latex-subtitle-separate} is
13764 non-@code{nil}, it is typed as part of the @code{\title} macro.  See
13765 @code{org-latex-hyperref-template} for customizing metadata items.
13766 See @code{org-latex-title-command} for typesetting description
13767 into the document's front matter.
13768 @end table
13770 The following sections have further details.
13772 @node @LaTeX{} header and sectioning
13773 @subsection @LaTeX{} header and sectioning structure
13775 @cindex @LaTeX{} class
13776 @cindex @LaTeX{} sectioning structure
13777 @cindex @LaTeX{} header
13778 @cindex header, for @LaTeX{} files
13779 @cindex sectioning structure, for @LaTeX{} export
13781 The @LaTeX{} export back-end converts the first three of Org's outline
13782 levels into @LaTeX{} headlines.  The remaining Org levels are exported as
13783 lists.  To change this globally for the cut-off point between levels
13784 and lists, (see @ref{Export Settings}).
13786 By default, the @LaTeX{} export back-end uses the @emph{article} class.
13788 @vindex org-latex-default-class
13789 @vindex org-latex-classes
13790 @vindex org-latex-default-packages-alist
13791 @vindex org-latex-packages-alist
13792 To change the default class globally, edit @code{org-latex-default-class}.
13793 To change the default class locally in an Org file, add option lines
13794 @samp{#+LATEX_CLASS: myclass}.  To change the default class for just a part
13795 of the Org file, set a sub-tree property, @samp{EXPORT_LATEX_CLASS}.  The
13796 class name entered here must be valid member of @code{org-latex-classes}.
13797 This variable defines a header template for each class into which the
13798 exporter splices the values of @code{org-latex-default-packages-alist} and
13799 @code{org-latex-packages-alist}.  Use the same three variables to define
13800 custom sectioning or custom classes.
13802 @cindex @samp{LATEX_CLASS}, keyword
13803 @cindex @samp{LATEX_CLASS_OPTIONS}, keyword
13804 @cindex @samp{EXPORT_LATEX_CLASS}, property
13805 @cindex @samp{EXPORT_LATEX_CLASS_OPTIONS}, property
13806 The @LaTeX{} export back-end sends the @samp{LATEX_CLASS_OPTIONS} keyword and
13807 @samp{EXPORT_LATEX_CLASS_OPTIONS} property as options to the @LaTeX{}
13808 @code{\documentclass} macro.  The options and the syntax for specifying
13809 them, including enclosing them in square brackets, follow @LaTeX{}
13810 conventions.
13812 @example
13813 #+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside,twocolumn]
13814 @end example
13816 @cindex @samp{LATEX_HEADER}, keyword
13817 @cindex @samp{LATEX_HEADER_EXTRA}, keyword
13818 The @LaTeX{} export back-end appends values from @samp{LATEX_HEADER} and
13819 @samp{LATEX_HEADER_EXTRA} keywords to the @LaTeX{} header.  The docstring for
13820 @code{org-latex-classes} explains in more detail.  Also note that @LaTeX{}
13821 export back-end does not append @samp{LATEX_HEADER_EXTRA} to the header
13822 when previewing @LaTeX{} snippets (see @ref{Previewing @LaTeX{} fragments}).
13824 A sample Org file with the above headers:
13826 @example
13827 #+LATEX_CLASS: article
13828 #+LATEX_CLASS_OPTIONS: [a4paper]
13829 #+LATEX_HEADER: \usepackage@{xyz@}
13831 * Headline 1
13832   some text
13833 * Headline 2
13834   some more text
13835 @end example
13837 @node Quoting @LaTeX{} code
13838 @subsection Quoting @LaTeX{} code
13840 The @LaTeX{} export back-end can insert any arbitrary @LaTeX{} code, see
13841 @ref{Embedded @LaTeX{}}.  There are three ways to embed such code in the Org
13842 file and they all use different quoting syntax.
13844 @cindex inline, in @LaTeX{} export
13845 Inserting in-line quoted with @@ symbols:
13847 @example
13848 Code embedded in-line @@@@latex:any arbitrary LaTeX code@@@@ in a paragraph.
13849 @end example
13851 @cindex @samp{LATEX}, keyword
13852 Inserting as one or more keyword lines in the Org file:
13854 @example
13855 #+LATEX: any arbitrary LaTeX code
13856 @end example
13858 @cindex @samp{BEGIN_EXPORT latex}
13859 Inserting as an export block in the Org file, where the back-end
13860 exports any code between begin and end markers:
13862 @example
13863 #+BEGIN_EXPORT latex
13864   any arbitrary LaTeX code
13865 #+END_EXPORT
13866 @end example
13868 @node Tables in @LaTeX{} export
13869 @subsection Tables in @LaTeX{} export
13871 @cindex tables, in @LaTeX{} export
13873 The @LaTeX{} export back-end can pass several @LaTeX{} attributes for table
13874 contents and layout.  Besides specifying label and caption (see
13875 @ref{Images and Tables}), the other valid @LaTeX{} attributes include:
13877 @table @asis
13878 @item @samp{:mode}
13879 @vindex org-latex-default-table-mode
13880 The @LaTeX{} export back-end wraps the table differently depending
13881 on the mode for accurate rendering of math symbols.  Mode is
13882 either @samp{table}, @samp{math}, @samp{inline-math} or @samp{verbatim}.
13884 For @samp{math} or @samp{inline-math} mode, @LaTeX{} export back-end wraps the
13885 table in a math environment, but every cell in it is exported
13886 as-is.  The @LaTeX{} export back-end determines the default mode
13887 from @code{org-latex-default-table-mode}.  The @LaTeX{} export back-end
13888 merges contiguous tables in the same mode into a single
13889 environment.
13891 @item @samp{:environment}
13892 @vindex org-latex-default-table-environment
13893 Set the default @LaTeX{} table environment for the @LaTeX{} export
13894 back-end to use when exporting Org tables.  Common @LaTeX{} table
13895 environments are provided by these packages: tabularx, longtable,
13896 array, tabu, and bmatrix.  For packages, such as tabularx and
13897 tabu, or any newer replacements, include them in the
13898 @code{org-latex-packages-alist} variable so the @LaTeX{} export back-end
13899 can insert the appropriate load package headers in the converted
13900 @LaTeX{} file.  Look in the docstring for the
13901 @code{org-latex-packages-alist} variable for configuring these
13902 packages for @LaTeX{} snippet previews, if any.
13904 @item @samp{:caption}
13905 Use @samp{CAPTION} keyword to set a simple caption for a table (see
13906 @ref{Images and Tables}).  For custom captions, use @samp{:caption}
13907 attribute, which accepts raw @LaTeX{} code.  @samp{:caption} value
13908 overrides @samp{CAPTION} value.
13910 @item @samp{:float}
13911 @itemx @samp{:placement}
13912 The table environments by default are not floats in @LaTeX{}.  To
13913 make them floating objects use @samp{:float} with one of the following
13914 options: @samp{sideways}, @samp{multicolumn}, @samp{t}, and @samp{nil}.
13916 @LaTeX{} floats can also have additional layout @samp{:placement}
13917 attributes.  These are the usual @samp{[h t b p ! H]} permissions
13918 specified in square brackets.  Note that for @samp{:float sideways}
13919 tables, the @LaTeX{} export back-end ignores @samp{:placement}
13920 attributes.
13922 @item @samp{:align}
13923 @itemx @samp{:font}
13924 @itemx @samp{:width}
13925 The @LaTeX{} export back-end uses these attributes for regular
13926 tables to set their alignments, fonts, and widths.
13928 @item @samp{:spread}
13929 When @samp{:spread} is non-@code{nil}, the @LaTeX{} export back-end spreads or
13930 shrinks the table by the @samp{:width} for tabu and longtabu
13931 environments.  @samp{:spread} has no effect if @samp{:width} is not set.
13933 @item @samp{:booktabs}
13934 @itemx @samp{:center}
13935 @itemx @samp{:rmlines}
13936 @vindex org-latex-tables-booktabs
13937 @vindex org-latex-tables-centered
13938 All three commands are toggles.  @samp{:booktabs} brings in modern
13939 typesetting enhancements to regular tables.  The booktabs package
13940 has to be loaded through @code{org-latex-packages-alist}.  @samp{:center}
13941 is for centering the table.  @samp{:rmlines} removes all but the very
13942 first horizontal line made of ASCII characters from ``table.el''
13943 tables only.
13945 @item @samp{:math-prefix}
13946 @itemx @samp{:math-suffix}
13947 @itemx @samp{:math-arguments}
13948 The @LaTeX{} export back-end inserts @samp{:math-prefix} string value in
13949 a math environment before the table.  The @LaTeX{} export back-end
13950 inserts @samp{:math-suffix} string value in a math environment after
13951 the table.  The @LaTeX{} export back-end inserts @samp{:math-arguments}
13952 string value between the macro name and the table's contents.
13953 @samp{:math-arguments} comes in use for matrix macros that require
13954 more than one argument, such as @samp{qbordermatrix}.
13955 @end table
13957 @LaTeX{} table attributes help formatting tables for a wide range of
13958 situations, such as matrix product or spanning multiple pages:
13960 @example
13961 #+ATTR_LATEX: :environment longtable :align l|lp@{3cm@}r|l
13962 | ... | ... |
13963 | ... | ... |
13965 #+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
13966 | a | b |
13967 | c | d |
13968 #+ATTR_LATEX: :mode math :environment bmatrix
13969 | 1 | 2 |
13970 | 3 | 4 |
13971 @end example
13973 Set the caption with the @LaTeX{} command
13974 @samp{\bicaption@{HeadingA@}@{HeadingB@}}:
13976 @example
13977 #+ATTR_LATEX: :caption \bicaption@{HeadingA@}@{HeadingB@}
13978 | ... | ... |
13979 | ... | ... |
13980 @end example
13982 @node Images in @LaTeX{} export
13983 @subsection Images in @LaTeX{} export
13985 @cindex images, inline in LaTeX
13986 @cindex inlining images in LaTeX
13987 @cindex @samp{ATTR_LATEX}, keyword
13989 The @LaTeX{} export back-end processes image links in Org files that do
13990 not have descriptions, such as these links @samp{[[file:img.jpg]]} or
13991 @samp{[[./img.jpg]]}, as direct image insertions in the final PDF output.  In
13992 the PDF, they are no longer links but actual images embedded on the
13993 page.  The @LaTeX{} export back-end uses @samp{\includegraphics} macro to
13994 insert the image.  But for TikZ (@uref{http://sourceforge.net/projects/pgf/})
13995 images, the back-end uses an @code{\input} macro wrapped within
13996 a @code{tikzpicture} environment.
13998 For specifying image @samp{:width}, @samp{:height}, and other @samp{:options}, use
13999 this syntax:
14001 @example
14002 #+ATTR_LATEX: :width 5cm :options angle=90
14003 [[./img/sed-hr4049.pdf]]
14004 @end example
14006 For custom commands for captions, use the @samp{:caption} attribute.  It
14007 overrides the default @samp{#+CAPTION} value:
14009 @example
14010 #+ATTR_LATEX: :caption \bicaption@{HeadingA@}@{HeadingB@}
14011 [[./img/sed-hr4049.pdf]]
14012 @end example
14014 When captions follow the method as described in @ref{Images and Tables},
14015 the @LaTeX{} export back-end wraps the picture in a floating @samp{figure}
14016 environment.  To float an image without specifying a caption, set the
14017 @samp{:float} attribute to one of the following:
14019 @table @asis
14020 @item @samp{t}
14021 For a standard @samp{figure} environment; used by default whenever an
14022 image has a caption.
14024 @item @samp{multicolumn}
14025 To span the image across multiple columns of a page; the back-end
14026 wraps the image in a @samp{figure*} environment.
14028 @item @samp{wrap}
14029 For text to flow around the image on the right; the figure
14030 occupies the left half of the page.
14032 @item @samp{sideways}
14033 For a new page with the image sideways, rotated ninety degrees,
14034 in a @samp{sidewaysfigure} environment; overrides @samp{:placement}
14035 setting.
14037 @item @samp{nil}
14038 To avoid a @samp{:float} even if using a caption.
14039 @end table
14041 @noindent
14042 Use the @samp{placement} attribute to modify a floating environment's
14043 placement.
14045 @example
14046 #+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement @{r@}@{0.4\textwidth@}
14047 [[./img/hst.png]]
14048 @end example
14050 @vindex org-latex-images-centered
14051 @cindex center image in LaTeX export
14052 @cindex image, centering in LaTeX export
14053 The @LaTeX{} export back-end centers all images by default.  Setting
14054 @samp{:center} to @samp{nil} disables centering.  To disable centering globally,
14055 set @code{org-latex-images-centered} to @samp{t}.
14057 Set the @samp{:comment-include} attribute to non-@code{nil} value for the @LaTeX{}
14058 export back-end to comment out the @samp{\includegraphics} macro.
14060 @node Plain lists in @LaTeX{} export
14061 @subsection Plain lists in @LaTeX{} export
14063 @cindex plain lists, in @LaTeX{} export
14064 @cindex @samp{ATTR_LATEX}, keyword
14065 The @LaTeX{} export back-end accepts the @samp{environment} and @samp{options}
14066 attributes for plain lists.  Both attributes work together for
14067 customizing lists, as shown in the examples:
14069 @example
14070 #+LATEX_HEADER: \usepackage[inline]@{enumitem@}
14071 Some ways to say "Hello":
14072 #+ATTR_LATEX: :environment itemize*
14073 #+ATTR_LATEX: :options [label=@{@}, itemjoin=@{,@}, itemjoin*=@{, and@}]
14074 - Hola
14075 - Bonjour
14076 - Guten Tag.
14077 @end example
14079 Since @LaTeX{} supports only four levels of nesting for lists, use an
14080 external package, such as @samp{enumitem} in @LaTeX{}, for levels deeper than
14081 four:
14083 @example
14084 #+LATEX_HEADER: \usepackage@{enumitem@}
14085 #+LATEX_HEADER: \renewlist@{itemize@}@{itemize@}@{9@}
14086 #+LATEX_HEADER: \setlist[itemize]@{label=$\circ$@}
14087 - One
14088   - Two
14089     - Three
14090       - Four
14091         - Five
14092 @end example
14094 @node Source blocks in @LaTeX{} export
14095 @subsection Source blocks in @LaTeX{} export
14097 @cindex source blocks, in @LaTeX{} export
14098 @cindex @samp{ATTR_LATEX}, keyword
14100 The @LaTeX{} export back-end can make source code blocks into floating
14101 objects through the attributes @samp{:float} and @samp{:options}.  For @samp{:float}:
14103 @table @asis
14104 @item @samp{t}
14105 Makes a source block float; by default floats any source block
14106 with a caption.
14108 @item @samp{multicolumn}
14109 Spans the source block across multiple columns of a page.
14111 @item @samp{nil}
14112 Avoids a @samp{:float} even if using a caption; useful for source code
14113 blocks that may not fit on a page.
14114 @end table
14116 @example
14117 #+ATTR_LATEX: :float nil
14118 #+BEGIN_SRC emacs-lisp
14119   Lisp code that may not fit in a single page.
14120 #+END_SRC
14121 @end example
14123 @vindex org-latex-listings-options
14124 @vindex org-latex-minted-options
14125 The @LaTeX{} export back-end passes string values in @samp{:options} to @LaTeX{}
14126 packages for customization of that specific source block.  In the
14127 example below, the @samp{:options} are set for Minted.  Minted is a source
14128 code highlighting @LaTeX{} package with many configurable options.
14130 @example
14131 #+ATTR_LATEX: :options commentstyle=\bfseries
14132 #+BEGIN_SRC emacs-lisp
14133   (defun Fib (n)
14134     (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
14135 #+END_SRC
14136 @end example
14138 To apply similar configuration options for all source blocks in
14139 a file, use the @code{org-latex-listings-options} and
14140 @code{org-latex-minted-options} variables.
14142 @node Example blocks in @LaTeX{} export
14143 @subsection Example blocks in @LaTeX{} export
14145 @cindex example blocks, in @LaTeX{} export
14146 @cindex verbatim blocks, in @LaTeX{} export
14147 @cindex @samp{ATTR_LATEX}, keyword
14149 The @LaTeX{} export back-end wraps the contents of example blocks in
14150 a @samp{verbatim} environment.  To change this behavior to use another
14151 environment globally, specify an appropriate export filter (see
14152 @ref{Advanced Configuration}).  To change this behavior to use another
14153 environment for each block, use the @samp{:environment} parameter to
14154 specify a custom environment.
14156 @example
14157 #+ATTR_LATEX: :environment myverbatim
14158 #+BEGIN_EXAMPLE
14159   This sentence is false.
14160 #+END_EXAMPLE
14161 @end example
14163 @node Special blocks in @LaTeX{} export
14164 @subsection Special blocks in @LaTeX{} export
14166 @cindex special blocks, in @LaTeX{} export
14167 @cindex abstract, in @LaTeX{} export
14168 @cindex proof, in @LaTeX{} export
14169 @cindex @samp{ATTR_LATEX}, keyword
14171 For other special blocks in the Org file, the @LaTeX{} export back-end
14172 makes a special environment of the same name.  The back-end also takes
14173 @samp{:options}, if any, and appends as-is to that environment's opening
14174 string.  For example:
14176 @example
14177 #+BEGIN_abstract
14178   We demonstrate how to solve the Syracuse problem.
14179 #+END_abstract
14181 #+ATTR_LATEX: :options [Proof of important theorem]
14182 #+BEGIN_proof
14183   ...
14184   Therefore, any even number greater than 2 is the sum of two primes.
14185 #+END_proof
14186 @end example
14188 @noindent
14189 exports to
14191 @example
14192 \begin@{abstract@}
14193   We demonstrate how to solve the Syracuse problem.
14194 \end@{abstract@}
14196 \begin@{proof@}[Proof of important theorem]
14197   ...
14198   Therefore, any even number greater than 2 is the sum of two primes.
14199 \end@{proof@}
14200 @end example
14202 If you need to insert a specific caption command, use @samp{:caption}
14203 attribute.  It overrides standard @samp{CAPTION} value, if any.  For
14204 example:
14206 @example
14207 #+ATTR_LATEX: :caption \MyCaption@{HeadingA@}
14208 #+BEGIN_proof
14209   ...
14210 #+END_proof
14211 @end example
14213 @node Horizontal rules in @LaTeX{} export
14214 @subsection Horizontal rules in @LaTeX{} export
14216 @cindex horizontal rules, in @LaTeX{} export
14217 @cindex @samp{ATTR_LATEX}, keyword
14219 The @LaTeX{} export back-end converts horizontal rules by the specified
14220 @samp{:width} and @samp{:thickness} attributes.  For example:
14222 @example
14223 #+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt
14224 -----
14225 @end example
14227 @node Markdown Export
14228 @section Markdown Export
14230 @cindex Markdown export
14232 The Markdown export back-end, ``md'', converts an Org file to a Markdown
14233 format, as defined at @uref{http://daringfireball.net/projects/markdown/}.
14235 Since ``md'' is built on top of the HTML back-end, any Org constructs
14236 not supported by Markdown, such as tables, the underlying ``html''
14237 back-end (see @ref{HTML Export}) converts them.
14239 @anchor{Markdown export commands}
14240 @subheading Markdown export commands
14242 @table @asis
14243 @item @kbd{C-c C-e m m} (@code{org-md-export-to-markdown})
14244 @kindex C-c C-c m m
14245 @findex org-md-export-to-markdown
14246 Export to a text file with Markdown syntax.  For @samp{myfile.org},
14247 Org exports to @samp{myfile.md}, overwritten without warning.
14249 @item @kbd{C-c C-e m M} (@code{org-md-export-as-markdown})
14250 @kindex C-c C-c m M
14251 @findex org-md-export-as-markdown
14252 Export to a temporary buffer.  Does not create a file.
14254 @item @kbd{C-c C-e m o}
14255 @kindex C-c C-e m o
14256 Export as a text file with Markdown syntax, then open it.
14257 @end table
14259 @anchor{Header and sectioning structure (1)}
14260 @subheading Header and sectioning structure
14262 @vindex org-md-headline-style
14263 Based on @code{org-md-headline-style}, Markdown export can generate
14264 headlines of both @emph{atx} and @emph{setext} types.  @emph{atx} limits headline
14265 levels to two whereas @emph{setext} limits headline levels to six.  Beyond
14266 these limits, the export back-end converts headlines to lists.  To set
14267 a limit to a level before the absolute limit (see @ref{Export Settings}).
14269 @node OpenDocument Text Export
14270 @section OpenDocument Text Export
14272 @cindex ODT
14273 @cindex OpenDocument
14274 @cindex export, OpenDocument
14275 @cindex LibreOffice
14277 The ODT export back-end handles creating of OpenDocument Text (ODT)
14278 format.  Documents created by this exporter use the
14279 @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
14280 (OpenDocument) Version 1.2}.} and are compatible
14281 with LibreOffice 3.4.
14283 @menu
14284 * Pre-requisites for ODT export:: Required packages.
14285 * ODT export commands::          Invoking export.
14286 * ODT specific export settings:: Configuration options.
14287 * Extending ODT export::         Producing DOC, PDF files.
14288 * Applying custom styles::       Styling the output.
14289 * Links in ODT export::          Handling and formatting links.
14290 * Tables in ODT export::         Org tables conversions.
14291 * Images in ODT export::         Inserting images.
14292 * Math formatting in ODT export:: Formatting @LaTeX{} fragments.
14293 * Labels and captions in ODT export:: Rendering objects.
14294 * Literal examples in ODT export:: For source code and example blocks.
14295 * Advanced topics in ODT export:: For power users.
14296 @end menu
14298 @node Pre-requisites for ODT export
14299 @subsection Pre-requisites for ODT export
14301 @cindex zip
14303 The ODT export back-end relies on the zip program to create the final
14304 compressed ODT output.  Check if @samp{zip} is locally available and
14305 executable.  Without it, export cannot finish.
14307 @node ODT export commands
14308 @subsection ODT export commands
14310 @table @asis
14311 @item @kbd{C-c C-e o o} (@code{org-export-to-odt})
14312 @kindex C-c C-e o o
14313 @findex org-export-to-odt
14314 Export as OpenDocument Text file.
14316 @cindex @samp{EXPORT_FILE_NAME}, property
14317 @vindex org-odt-preferred-output-format
14319 If @code{org-odt-preferred-output-format} is specified, the ODT export
14320 back-end automatically converts the exported file to that format.
14322 For @samp{myfile.org}, Org exports to @samp{myfile.odt}, overwriting
14323 without warning.  The ODT export back-end exports a region only
14324 if a region was active.
14326 If the selected region is a single tree, the ODT export back-end
14327 makes the tree head the document title.  Incidentally, @kbd{C-c @@} selects the current sub-tree.  If the tree head entry has,
14328 or inherits, an @samp{EXPORT_FILE_NAME} property, the ODT export
14329 back-end uses that for file name.
14331 @item @kbd{C-c C-e o O}
14332 @kindex C-c C-e o O
14333 Export as an OpenDocument Text file and open the resulting file.
14335 @vindex org-export-odt-preferred-output-format
14336 If @code{org-export-odt-preferred-output-format} is specified, open
14337 the converted file instead.  See @ref{Automatically exporting to other formats}.
14338 @end table
14340 @node ODT specific export settings
14341 @subsection ODT specific export settings
14343 The ODT export back-end has several additional keywords for
14344 customizing ODT output.  Setting these keywords works similar to the
14345 general options (see @ref{Export Settings}).
14347 @table @asis
14348 @item @samp{DESCRIPTION}
14349 @cindex @samp{DESCRIPTION}, keyword
14350 This is the document's description, which the ODT export back-end
14351 inserts as document metadata.  For long descriptions, use
14352 multiple lines, prefixed with @samp{DESCRIPTION}.
14354 @item @samp{KEYWORDS}
14355 @cindex @samp{KEYWORDS}, keyword
14356 The keywords for the document.  The ODT export back-end inserts
14357 the description along with author name, keywords, and related
14358 file metadata as metadata in the output file.  Use multiple
14359 @samp{KEYWORDS} if necessary.
14361 @item @samp{ODT_STYLES_FILE}
14362 @cindex @samp{ODT_STYLES_FILE}, keyword
14363 @vindex org-odt-styles-file
14364 The ODT export back-end uses the @code{org-odt-styles-file} by
14365 default.  See @ref{Applying custom styles} for details.
14367 @item @samp{SUBTITLE}
14368 @cindex @samp{SUBTITLE}, keyword
14369 The document subtitle.
14370 @end table
14372 @node Extending ODT export
14373 @subsection Extending ODT export
14375 The ODT export back-end can produce documents in other formats besides
14376 ODT using a specialized ODT converter process.  Its common interface
14377 works with popular converters to produce formats such as @samp{doc}, or
14378 convert a document from one format, say @samp{csv}, to another format, say
14379 @samp{xls}.
14381 @cindex @file{unoconv}
14382 @vindex org-odt-convert-process
14383 Customize @code{org-odt-convert-process} variable to point to @samp{unoconv},
14384 which is the ODT's preferred converter.  Working installations of
14385 LibreOffice would already have @samp{unoconv} installed.  Alternatively,
14386 other converters may be substituted here.  See @ref{Configuring a document converter}.
14388 @anchor{Automatically exporting to other formats}
14389 @subsubheading Automatically exporting to other formats
14391 @vindex org-odt-preferred-output-format
14392 If ODT format is just an intermediate step to get to other formats,
14393 such as @samp{doc}, @samp{docx}, @samp{rtf}, or @samp{pdf}, etc., then extend the ODT
14394 export back-end to directly produce that format.  Specify the final
14395 format in the @code{org-odt-preferred-output-format} variable.  This is one
14396 way to extend (see @ref{ODT export commands}).
14398 @anchor{Converting between document formats}
14399 @subsubheading Converting between document formats
14401 The Org export back-end is made to be inter-operable with a wide range
14402 of text document format converters.  Newer generation converters, such
14403 as LibreOffice and Pandoc, can handle hundreds of formats at once.
14404 Org provides a consistent interaction with whatever converter is
14405 installed.  Here are some generic commands:
14407 @table @asis
14408 @item @kbd{M-x org-odt-convert}
14409 @findex org-odt-convert
14410 Convert an existing document from one format to another.  With
14411 a prefix argument, opens the newly produced file.
14412 @end table
14414 @node Applying custom styles
14415 @subsection Applying custom styles
14417 @cindex styles, custom
14418 @cindex template, custom
14420 The ODT export back-end comes with many OpenDocument styles (see
14421 @ref{Working with OpenDocument style files}).  To expand or further
14422 customize these built-in style sheets, either edit the style sheets
14423 directly or generate them using an application such as LibreOffice.
14424 The example here shows creating a style using LibreOffice.
14426 @anchor{Applying custom styles the easy way}
14427 @subsubheading Applying custom styles: the easy way
14429 @enumerate
14430 @item
14431 Create a sample @samp{example.org} file with settings as shown below,
14432 and export it to ODT format.
14434 @example
14435 #+OPTIONS: H:10 num:t
14436 @end example
14438 @item
14439 Open the above @samp{example.odt} using LibreOffice.  Use the @emph{Stylist}
14440 to locate the target styles, which typically have the ``Org'' prefix.
14441 Open one, modify, and save as either OpenDocument Text (ODT) or
14442 OpenDocument Template (OTT) file.
14444 @item
14445 @vindex org-odt-styles-file
14446 Customize the variable @code{org-odt-styles-file} and point it to the
14447 newly created file.  For additional configuration options, see
14448 @ref{x-overriding-factory-styles, , Overriding factory styles}.
14450 @cindex @samp{ODT_STYLES_FILE}, keyword
14451 To apply an ODT style to a particular file, use the
14452 @samp{ODT_STYLES_FILE} keyword as shown in the example below:
14454 @example
14455 #+ODT_STYLES_FILE: "/path/to/example.ott"
14456 @end example
14458 @noindent
14461 @example
14462 #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
14463 @end example
14464 @end enumerate
14466 @anchor{Using third-party styles and templates}
14467 @subsubheading Using third-party styles and templates
14469 The ODT export back-end relies on many templates and style names.
14470 Using third-party styles and templates can lead to mismatches.
14471 Templates derived from built in ODT templates and styles seem to have
14472 fewer problems.
14474 @node Links in ODT export
14475 @subsection Links in ODT export
14477 @cindex links, in ODT export
14479 ODT exporter creates native cross-references for internal links.  It
14480 creates Internet-style links for all other links.
14482 A link with no description and pointing to a regular, un-itemized,
14483 outline heading is replaced with a cross-reference and section number
14484 of the heading.
14486 A @samp{\ref@{label@}}-style reference to an image, table etc., is replaced
14487 with a cross-reference and sequence number of the labeled entity.  See
14488 @ref{Labels and captions in ODT export}.
14490 @node Tables in ODT export
14491 @subsection Tables in ODT export
14493 @cindex tables, in ODT export
14495 The ODT export back-end handles native Org mode tables (see @ref{Tables})
14496 and simple @samp{table.el} tables.  Complex @samp{table.el} tables having column
14497 or row spans are not supported.  Such tables are stripped from the
14498 exported document.
14500 By default, the ODT export back-end exports a table with top and
14501 bottom frames and with ruled lines separating row and column groups
14502 (see @ref{Column Groups}).  All tables are typeset to occupy the same
14503 width.  The ODT export back-end honors any table alignments and
14504 relative widths for columns (see @ref{Column Width and Alignment}).
14506 Note that the ODT export back-end interprets column widths as weighted
14507 ratios, the default weight being 1.
14509 @cindex @samp{ATTR_ODT}, keyword
14510 Specifying @samp{:rel-width} property on an @samp{ATTR_ODT} line controls the
14511 width of the table.  For example:
14513 @example
14514 #+ATTR_ODT: :rel-width 50
14515 | Area/Month    |   Jan |   Feb |   Mar |   Sum |
14516 |---------------+-------+-------+-------+-------|
14517 | /             |     < |       |       |     < |
14518 | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
14519 | North America |     1 |    21 |   926 |   948 |
14520 | Middle East   |     6 |    75 |   844 |   925 |
14521 | Asia Pacific  |     9 |    27 |   790 |   826 |
14522 |---------------+-------+-------+-------+-------|
14523 | Sum           |    16 |   123 |  2560 |  2699 |
14524 @end example
14526 On export, the above table takes 50% of text width area.  The exporter
14527 sizes the columns in the ratio: 13:5:5:5:6.  The first column is
14528 left-aligned and rest of the columns, right-aligned.  Vertical rules
14529 separate the header and the last column.  Horizontal rules separate
14530 the header and the last row.
14532 For even more customization, create custom table styles and associate
14533 them with a table using the @samp{ATTR_ODT} keyword.  See @ref{Customizing tables in ODT export}.
14535 @node Images in ODT export
14536 @subsection Images in ODT export
14538 @cindex images, embedding in ODT
14539 @cindex embedding images in ODT
14541 @anchor{Embedding images}
14542 @subsubheading Embedding images
14544 The ODT export back-end processes image links in Org files that do not
14545 have descriptions, such as these links @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]},
14546 as direct image insertions in the final output.  Either of these
14547 examples works:
14549 @example
14550 [[file:img.png]]
14551 @end example
14553 @example
14554 [[./img.png]]
14555 @end example
14557 @anchor{Embedding clickable images}
14558 @subsubheading Embedding clickable images
14560 For clickable images, provide a link whose description is another link
14561 to an image file.  For example, to embed an image
14562 @samp{org-mode-unicorn.png} which when clicked jumps to @uref{https://orgmode.org}
14563 website, do the following
14565 @example
14566 [[https://orgmode.org][./org-mode-unicorn.png]]
14567 @end example
14569 @anchor{Sizing and scaling of embedded images}
14570 @subsubheading Sizing and scaling of embedded images
14572 @cindex @samp{ATTR_ODT}, keyword
14574 Control the size and scale of the embedded images with the @samp{ATTR_ODT}
14575 attribute.
14577 @cindex identify, ImageMagick
14578 @vindex org-odt-pixels-per-inch
14579 The ODT export back-end starts with establishing the size of the image
14580 in the final document.  The dimensions of this size are measured in
14581 centimeters.  The back-end then queries the image file for its
14582 dimensions measured in pixels.  For this measurement, the back-end
14583 relies on ImageMagick's identify program or Emacs @code{create-image} and
14584 @code{image-size} API.  ImageMagick is the preferred choice for large file
14585 sizes or frequent batch operations.  The back-end then converts the
14586 pixel dimensions using @code{org-odt-pixels-per-inch} into the familiar 72
14587 dpi or 96 dpi.  The default value for this is in
14588 @code{display-pixels-per-inch}, which can be tweaked for better results
14589 based on the capabilities of the output device.  Here are some common
14590 image scaling operations:
14592 @table @asis
14593 @item Explicitly size the image
14594 To embed @samp{img.png} as a 10 cm x 10 cm image, do the following:
14596 @example
14597 #+ATTR_ODT: :width 10 :height 10
14598 [[./img.png]]
14599 @end example
14601 @item Scale the image
14602 To embed @samp{img.png} at half its size, do the following:
14604 @example
14605 #+ATTR_ODT: :scale 0.5
14606 [[./img.png]]
14607 @end example
14609 @item Scale the image to a specific width
14610 To embed @samp{img.png} with a width of 10 cm while retaining the
14611 original height:width ratio, do the following:
14613 @example
14614 #+ATTR_ODT: :width 10
14615 [[./img.png]]
14616 @end example
14618 @item Scale the image to a specific height
14619 To embed @samp{img.png} with a height of 10 cm while retaining the
14620 original height:width ratio, do the following:
14622 @example
14623 #+ATTR_ODT: :height 10
14624 [[./img.png]]
14625 @end example
14626 @end table
14628 @anchor{Anchoring of images}
14629 @subsubheading Anchoring of images
14631 @cindex @samp{ATTR_ODT}, keyword
14632 The ODT export back-end can anchor images to @samp{"as-char"},
14633 @samp{"paragraph"}, or @samp{"page"}.  Set the preferred anchor using the
14634 @samp{:anchor} property of the @samp{ATTR_ODT} line.
14636 To create an image that is anchored to a page:
14638 @example
14639 #+ATTR_ODT: :anchor "page"
14640 [[./img.png]]
14641 @end example
14643 @node Math formatting in ODT export
14644 @subsection Math formatting in ODT export
14646 The ODT exporter has special support for handling math.
14648 @menu
14649 * @LaTeX{} math snippets::       Embedding in @LaTeX{} format.
14650 * MathML and OpenDocument formula files:: Embedding in native format.
14651 @end menu
14653 @node @LaTeX{} math snippets
14654 @subsubsection @LaTeX{} math snippets
14656 @LaTeX{} math snippets (see @ref{@LaTeX{} fragments}) can be embedded in the ODT
14657 document in one of the following ways:
14659 @table @asis
14660 @item MathML
14661 @cindex MathML
14662 Add this line to the Org file.  This option is activated on
14663 a per-file basis.
14665 @example
14666 #+OPTIONS: tex:t
14667 @end example
14669 With this option, @LaTeX{} fragments are first converted into MathML
14670 fragments using an external @LaTeX{}-to-MathML converter program.
14671 The resulting MathML fragments are then embedded as an
14672 OpenDocument Formula in the exported document.
14674 @vindex org-latex-to-mathml-convert-command
14675 @vindex org-latex-to-mathml-jar-file
14676 You can specify the @LaTeX{}-to-MathML converter by customizing the
14677 variables @code{org-latex-to-mathml-convert-command} and
14678 @code{org-latex-to-mathml-jar-file}.
14680 If you prefer to use MathToWeb@footnote{See @uref{http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl, MathToWeb}.} as your converter, you can
14681 configure the above variables as shown below.
14683 @lisp
14684 (setq org-latex-to-mathml-convert-command
14685       "java -jar %j -unicode -force -df %o %I"
14686       org-latex-to-mathml-jar-file
14687       "/path/to/mathtoweb.jar")
14688 @end lisp
14690 To use @LaTeX{}​ML@footnote{See @uref{http://dlmf.nist.gov/LaTeXML/}.} use
14692 @lisp
14693 (setq org-latex-to-mathml-convert-command
14694       "latexmlmath \"%i\" --presentationmathml=%o")
14695 @end lisp
14697 To quickly verify the reliability of the @LaTeX{}-to-MathML
14698 converter, use the following commands:
14700 @table @asis
14701 @item @kbd{M-x org-export-as-odf}
14702 Convert a @LaTeX{} math snippet to an OpenDocument formula
14703 (@samp{.odf}) file.
14705 @item @kbd{M-x org-export-as-odf-and-open}
14706 Convert a @LaTeX{} math snippet to an OpenDocument formula
14707 (@samp{.odf}) file and open the formula file with the
14708 system-registered application.
14709 @end table
14711 @item PNG images
14712 @cindex dvipng
14713 @cindex dvisvgm
14714 @cindex ImageMagick
14715 Add this line to the Org file.  This option is activated on
14716 a per-file basis.
14718 @example
14719 #+OPTIONS: tex:dvipng
14720 @end example
14722 @example
14723 #+OPTIONS: tex:dvisvgm
14724 @end example
14726 @noindent
14729 @example
14730 #+OPTIONS: tex:imagemagick
14731 @end example
14733 Under this option, @LaTeX{} fragments are processed into PNG or SVG
14734 images and the resulting images are embedded in the exported
14735 document.  This method requires dvipng program, dvisvgm or
14736 ImageMagick programs.
14737 @end table
14739 @node MathML and OpenDocument formula files
14740 @subsubsection MathML and OpenDocument formula files
14742 When embedding @LaTeX{} math snippets in ODT documents is not reliable,
14743 there is one more option to try.  Embed an equation by linking to its
14744 MathML (@samp{.mml}) source or its OpenDocument formula (@samp{.odf}) file as
14745 shown below:
14747 @example
14748 [[./equation.mml]]
14749 @end example
14751 @noindent
14754 @example
14755 [[./equation.odf]]
14756 @end example
14758 @node Labels and captions in ODT export
14759 @subsection Labels and captions in ODT export
14761 ODT format handles labeling and captioning of objects based on their
14762 types.  Inline images, tables, @LaTeX{} fragments, and Math formulas are
14763 numbered and captioned separately.  Each object also gets a unique
14764 sequence number based on its order of first appearance in the Org
14765 file.  Each category has its own sequence.  A caption is just a label
14766 applied to these objects.
14768 @example
14769 #+CAPTION: Bell curve
14770 #+NAME:   fig:SED-HR4049
14771 [[./img/a.png]]
14772 @end example
14774 When rendered, it may show as follows in the exported document:
14776 @example
14777 Figure 2: Bell curve
14778 @end example
14780 @vindex org-odt-category-map-alist
14781 To modify the category component of the caption, customize the option
14782 @code{org-odt-category-map-alist}.  For example, to tag embedded images
14783 with the string ``Illustration'' instead of the default string ``Figure'',
14784 use the following setting:
14786 @lisp
14787 (setq org-odt-category-map-alist
14788       '(("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))
14789 @end lisp
14791 With the above modification, the previous example changes to:
14793 @example
14794 Illustration 2: Bell curve
14795 @end example
14797 @node Literal examples in ODT export
14798 @subsection Literal examples in ODT export
14800 The ODT export back-end supports literal examples (see @ref{Literal Examples}) with full fontification.  Internally, the ODT export
14801 back-end relies on @samp{htmlfontify.el} to generate the style definitions
14802 needed for fancy listings.  The auto-generated styles get @samp{OrgSrc}
14803 prefix and inherit colors from the faces used by Emacs Font Lock
14804 library for that source language.
14806 @vindex org-odt-fontify-srcblocks
14807 For custom fontification styles, customize the
14808 @code{org-odt-create-custom-styles-for-srcblocks} option.
14810 @vindex org-odt-create-custom-styles-for-srcblocks
14811 To turn off fontification of literal examples, customize the
14812 @code{org-odt-fontify-srcblocks} option.
14814 @node Advanced topics in ODT export
14815 @subsection Advanced topics in ODT export
14817 The ODT export back-end has extensive features useful for power users
14818 and frequent uses of ODT formats.
14820 @anchor{Configuring a document converter}
14821 @subsubheading Configuring a document converter
14823 @cindex convert
14824 @cindex doc, docx, rtf
14825 @cindex converter
14827 The ODT export back-end works with popular converters with little or
14828 no extra configuration.  See @ref{Extending ODT export}.  The following is
14829 for unsupported converters or tweaking existing defaults.
14831 @table @asis
14832 @item Register the converter
14833 @vindex org-export-odt-convert-processes
14834 Add the name of the converter to the @code{org-odt-convert-processes}
14835 variable.  Note that it also requires how the converter is
14836 invoked on the command line.  See the variable's docstring for
14837 details.
14839 @item Configure its capabilities
14840 @vindex org-export-odt-convert-capabilities
14841 Specify which formats the converter can handle by customizing the
14842 variable @code{org-odt-convert-capabilities}.  Use the entry for the
14843 default values in this variable for configuring the new
14844 converter.  Also see its docstring for details.
14846 @item Choose the converter
14847 @vindex org-export-odt-convert-process
14848 Select the newly added converter as the preferred one by
14849 customizing the option @code{org-odt-convert-process}.
14850 @end table
14852 @anchor{Working with OpenDocument style files}
14853 @subsubheading Working with OpenDocument style files
14855 @cindex styles, custom
14856 @cindex template, custom
14858 This section explores the internals of the ODT exporter; the means by which
14859 it produces styled documents; the use of automatic and custom OpenDocument
14860 styles.
14862 The ODT exporter relies on two files for generating its output.  These
14863 files are bundled with the distribution under the directory pointed to
14864 by the variable @code{org-odt-styles-dir}.  The two files are:
14866 @table @asis
14867 @item @samp{OrgOdtStyles.xml} @anchor{x-orgodtstyles-xml}
14868 This file contributes to the @samp{styles.xml} file of the final ODT
14869 document.  This file gets modified for the following purposes:
14871 @enumerate
14872 @item
14873 To control outline numbering based on user settings;
14875 @item
14876 To add styles generated by @samp{htmlfontify.el} for fontification of
14877 code blocks.
14878 @end enumerate
14880 @item @samp{OrgOdtContentTemplate.xml} @anchor{x-orgodtcontenttemplate-xml}
14881 This file contributes to the @samp{content.xml} file of the final ODT
14882 document.  The contents of the Org outline are inserted between the
14883 @samp{<office:text>} @dots{} @samp{</office:text>} elements of this file.
14885 Apart from serving as a template file for the final @samp{content.xml},
14886 the file serves the following purposes:
14888 @enumerate
14889 @item
14890 It contains automatic styles for formatting of tables which are
14891 referenced by the exporter;
14893 @item
14894 It contains @samp{<text:sequence-decl>} @dots{} @samp{</text:sequence-decl>}
14895 elements that control numbering of tables, images, equations, and
14896 similar entities.
14897 @end enumerate
14898 @end table
14900 @anchor{x-overriding-factory-styles} The following two variables control
14901 the location from where the ODT exporter picks up the custom styles
14902 and content template files.  Customize these variables to override the
14903 factory styles used by the exporter.
14905 @table @asis
14906 @item @code{org-odt-styles-file}
14907 The ODT export back-end uses the file pointed to by this
14908 variable, such as @samp{styles.xml}, for the final output.  It can
14909 take one of the following values:
14911 @table @asis
14912 @item @samp{FILE.xml}
14913 Use this file instead of the default @samp{styles.xml}
14915 @item @samp{FILE.odt} or @samp{FILE.ott}
14916 Use the @samp{styles.xml} contained in the specified OpenDocument
14917 Text or Template file
14919 @item @samp{FILE.odt} or @samp{FILE.ott} and a subset of included files
14920 Use the @samp{styles.xml} contained in the specified OpenDocument
14921 Text or Template file.  Additionally extract the specified
14922 member files and embed those within the final ODT document.
14924 Use this option if the @samp{styles.xml} file references additional
14925 files like header and footer images.
14927 @item @code{nil}
14928 Use the default @samp{styles.xml}.
14929 @end table
14931 @item @code{org-odt-content-template-file}
14932 Use this variable to specify the blank @samp{content.xml} used in the
14933 final output.
14934 @end table
14936 @anchor{Creating one-off styles}
14937 @subsubheading Creating one-off styles
14939 The ODT export back-end can read embedded raw OpenDocument XML from
14940 the Org file.  Such direct formatting is useful for one-off instances.
14942 @table @asis
14943 @item Embedding ODT tags as part of regular text
14944 Enclose OpenDocument syntax in @samp{@@@@odt:...@@@@} for inline markup.
14945 For example, to highlight a region of text do the following:
14947 @example
14948 @@@@odt:<text:span text:style-name="Highlight">This is highlighted
14949 text</text:span>@@@@.  But this is regular text.
14950 @end example
14952 @strong{Hint:} To see the above example in action, edit the @samp{styles.xml}
14953 (see @ref{x-orgodtstyles-xml, , Factory styles}) and add a custom @emph{Highlight} style as shown
14954 below:
14956 @example
14957 <style:style style:name="Highlight" style:family="text">
14958   <style:text-properties fo:background-color="#ff0000"/>
14959 </style:style>
14960 @end example
14962 @item Embedding a one-line OpenDocument XML
14963 @cindex @samp{ODT}, keyword
14964 The ODT export back-end can read one-liner options with @samp{#+ODT:}
14965 in the Org file.  For example, to force a page break:
14967 @example
14968 #+ODT: <text:p text:style-name="PageBreak"/>
14969 @end example
14971 @strong{Hint:} To see the above example in action, edit your
14972 @samp{styles.xml} (see @ref{x-orgodtstyles-xml, , Factory styles}) and add a custom @samp{PageBreak}
14973 style as shown below.
14975 @example
14976 <style:style style:name="PageBreak" style:family="paragraph"
14977              style:parent-style-name="Text_20_body">
14978   <style:paragraph-properties fo:break-before="page"/>
14979 </style:style>
14980 @end example
14982 @item Embedding a block of OpenDocument XML
14983 The ODT export back-end can also read ODT export blocks for
14984 OpenDocument XML.  Such blocks use the @samp{#+BEGIN_EXPORT odt}
14985 @dots{} @samp{#+END_EXPORT} constructs.
14987 For example, to create a one-off paragraph that uses bold text,
14988 do the following:
14990 @example
14991 #+BEGIN_EXPORT odt
14992   <text:p text:style-name="Text_20_body_20_bold">
14993   This paragraph is specially formatted and uses bold text.
14994   </text:p>
14995 #+END_EXPORT
14996 @end example
14997 @end table
14999 @anchor{Customizing tables in ODT export}
15000 @subsubheading Customizing tables in ODT export
15002 @cindex tables, in ODT export
15003 @cindex @samp{ATTR_ODT}, keyword
15005 Override the default table format by specifying a custom table style
15006 with the @samp{#+ATTR_ODT} line.  For a discussion on default formatting of
15007 tables, see @ref{Tables in ODT export}.
15009 This feature closely mimics the way table templates are defined in the
15010 OpenDocument-v1.2 specification.@footnote{@uref{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html, OpenDocument-v1.2 Specification}}
15012 @vindex org-odt-table-styles
15013 For quick preview of this feature, install the settings below and export the
15014 table that follows:
15016 @lisp
15017 (setq org-export-odt-table-styles
15018       (append org-export-odt-table-styles
15019               '(("TableWithHeaderRowAndColumn" "Custom"
15020                  ((use-first-row-styles . t)
15021                   (use-first-column-styles . t)))
15022                 ("TableWithFirstRowandLastRow" "Custom"
15023                  ((use-first-row-styles . t)
15024                   (use-last-row-styles . t))))))
15025 @end lisp
15027 @example
15028 #+ATTR_ODT: :style TableWithHeaderRowAndColumn
15029 | Name  | Phone | Age |
15030 | Peter |  1234 |  17 |
15031 | Anna  |  4321 |  25 |
15032 @end example
15034 The example above used @samp{Custom} template and installed two table
15035 styles @samp{TableWithHeaderRowAndColumn} and
15036 @samp{TableWithFirstRowandLastRow}.  @strong{Important:} The OpenDocument styles
15037 needed for producing the above template were pre-defined.  They are
15038 available in the section marked @samp{Custom Table Template} in
15039 @samp{OrgOdtContentTemplate.xml} (see @ref{x-orgodtcontenttemplate-xml, , Factory styles}).  For adding new
15040 templates, define new styles there.
15042 To use this feature proceed as follows:
15044 @enumerate
15045 @item
15046 Create a table template@footnote{See the @samp{<table:table-template>} element of the
15047 OpenDocument-v1.2 specification.}.
15049 A table template is set of @samp{table-cell} and @samp{paragraph} styles for
15050 each of the following table cell categories:
15052 @itemize
15053 @item
15054 Body
15055 @item
15056 First column
15057 @item
15058 Last column
15059 @item
15060 First row
15061 @item
15062 Last row
15063 @item
15064 Even row
15065 @item
15066 Odd row
15067 @item
15068 Even column
15069 @item
15070 Odd Column
15071 @end itemize
15073 The names for the above styles must be chosen based on the name of
15074 the table template using a well-defined convention.
15076 The naming convention is better illustrated with an example.  For
15077 a table template with the name @samp{Custom}, the needed style names are
15078 listed in the following table.
15080 @multitable {aaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
15081 @headitem Cell type
15082 @tab Cell style
15083 @tab Paragraph style
15084 @item Body
15085 @tab @samp{CustomTableCell}
15086 @tab @samp{CustomTableParagraph}
15087 @item First column
15088 @tab @samp{CustomFirstColumnTableCell}
15089 @tab @samp{CustomFirstColumnTableParagraph}
15090 @item Last column
15091 @tab @samp{CustomLastColumnTableCell}
15092 @tab @samp{CustomLastColumnTableParagraph}
15093 @item First row
15094 @tab @samp{CustomFirstRowTableCell}
15095 @tab @samp{CustomFirstRowTableParagraph}
15096 @item Last row
15097 @tab @samp{CustomLastRowTableCell}
15098 @tab @samp{CustomLastRowTableParagraph}
15099 @item Even row
15100 @tab @samp{CustomEvenRowTableCell}
15101 @tab @samp{CustomEvenRowTableParagraph}
15102 @item Odd row
15103 @tab @samp{CustomOddRowTableCell}
15104 @tab @samp{CustomOddRowTableParagraph}
15105 @item Even column
15106 @tab @samp{CustomEvenColumnTableCell}
15107 @tab @samp{CustomEvenColumnTableParagraph}
15108 @item Odd column
15109 @tab @samp{CustomOddColumnTableCell}
15110 @tab @samp{CustomOddColumnTableParagraph}
15111 @end multitable
15113 To create a table template with the name @samp{Custom}, define the above
15114 styles in the @samp{<office:automatic-styles>} @dots{}
15115 @samp{</office:automatic-styles>} element of the content template file
15116 (see @ref{x-orgodtcontenttemplate-xml, , Factory styles}).
15118 @item
15119 Define a table style@footnote{See the attributes @samp{table:template-name},
15120 @samp{table:use-first-row-styles}, @samp{table:use-last-row-styles},
15121 @samp{table:use-first-column-styles}, @samp{table:use-last-column-styles},
15122 @samp{table:use-banding-rows-styles}, and @samp{table:use-banding-column-styles}
15123 of the @samp{<table:table>} element in the OpenDocument-v1.2 specification.}.
15125 @vindex org-odt-table-styles
15126 To define a table style, create an entry for the style in the
15127 variable @code{org-odt-table-styles} and specify the following:
15129 @itemize
15130 @item
15131 the name of the table template created in step (1),
15132 @item
15133 the set of cell styles in that template that are to be activated.
15134 @end itemize
15136 For example, the entry below defines two different table styles
15137 @samp{TableWithHeaderRowAndColumn} and @samp{TableWithFirstRowandLastRow}
15138 based on the same template @samp{Custom}.  The styles achieve their
15139 intended effect by selectively activating the individual cell
15140 styles in that template.
15142 @lisp
15143 (setq org-export-odt-table-styles
15144       (append org-export-odt-table-styles
15145               '(("TableWithHeaderRowAndColumn" "Custom"
15146                  ((use-first-row-styles . t)
15147                   (use-first-column-styles . t)))
15148                 ("TableWithFirstRowandLastRow" "Custom"
15149                  ((use-first-row-styles . t)
15150                   (use-last-row-styles . t))))))
15151 @end lisp
15153 @item
15154 Associate a table with the table style.
15156 To do this, specify the table style created in step (2) as part of
15157 the @samp{ATTR_ODT} line as shown below.
15159 @example
15160 #+ATTR_ODT: :style TableWithHeaderRowAndColumn
15161 | Name  | Phone | Age |
15162 | Peter |  1234 |  17 |
15163 | Anna  |  4321 |  25 |
15164 @end example
15165 @end enumerate
15167 @anchor{Validating OpenDocument XML}
15168 @subsubheading Validating OpenDocument XML
15170 Sometimes ODT format files may not open due to @samp{.odt} file corruption.
15171 To verify if such a file is corrupt, validate it against the
15172 OpenDocument Relax NG Compact (RNC) syntax schema.  But first the
15173 @samp{.odt} files have to be decompressed using @samp{zip}.  Note that @samp{.odt}
15174 files are ZIP archives: @ref{File Archives,,,emacs,}.  The contents of
15175 ODT files are in XML.  For general help with validation---and
15176 schema-sensitive editing---of XML files:
15177 @ref{Introduction,,,nxml-mode,}.
15179 @vindex org-export-odt-schema-dir
15180 Customize @code{org-odt-schema-dir} to point to a directory with
15181 OpenDocument RNC files and the needed schema-locating rules.  The ODT
15182 export back-end takes care of updating the
15183 @code{rng-schema-locating-files}.
15185 @node Org Export
15186 @section Org Export
15188 @cindex Org export
15189 @emph{org} export back-end creates a normalized version of the Org document
15190 in current buffer.  The exporter evaluates Babel code (see @ref{Evaluating Code Blocks}) and removes content specific to other back-ends.
15192 @anchor{Org export commands}
15193 @subheading Org export commands
15195 @table @asis
15196 @item @kbd{C-c C-e O o} (@code{org-org-export-to-org})
15197 @kindex C-c C-e O o
15198 @findex org-org-export-to-org
15199 Export as an Org file with a @samp{.org} extension.  For @samp{myfile.org},
15200 Org exports to @samp{myfile.org.org}, overwriting without warning.
15202 @item @kbd{C-c C-e O v} (~~)
15203 @kindex C-c C-e O v
15204 Export to an Org file, then open it.
15205 @end table
15207 @node Texinfo Export
15208 @section Texinfo Export
15210 @menu
15211 * Texinfo export commands::      Invoking commands.
15212 * Texinfo specific export settings:: Setting the environment.
15213 * Texinfo file header::          Generating the header.
15214 * Texinfo title and copyright page:: Creating preamble pages.
15215 * Info directory file::          Installing a manual in Info file hierarchy.
15216 * Headings and sectioning structure:: Building document structure.
15217 * Indices::                      Creating indices.
15218 * Quoting Texinfo code::         Incorporating literal Texinfo code.
15219 * Plain lists in Texinfo export:: List attributes.
15220 * Tables in Texinfo export::     Table attributes.
15221 * Images in Texinfo export::     Image attributes.
15222 * Special blocks in Texinfo export:: Special block attributes.
15223 * A Texinfo example::            Processing Org to Texinfo.
15224 @end menu
15226 @node Texinfo export commands
15227 @subsection Texinfo export commands
15229 @table @asis
15230 @item @kbd{C-c C-e i t} (@code{org-texinfo-export-to-texinfo})
15231 @kindex C-c C-e i t
15232 @findex org-texinfo-export-to-texinfo
15233 Export as a Texinfo file with @samp{.texi} extension.  For
15234 @samp{myfile.org}, Org exports to @samp{myfile.texi}, overwriting without
15235 warning.
15237 @item @kbd{C-c C-e i i} (@code{org-texinfo-export-to-info})
15238 @kindex C-c C-e i i
15239 @findex org-texinfo-export-to-info
15240 @vindex org-texinfo-info-process
15241 Export to Texinfo format first and then process it to make an
15242 Info file.  To generate other formats, such as DocBook, customize
15243 the @code{org-texinfo-info-process} variable.
15244 @end table
15246 @node Texinfo specific export settings
15247 @subsection Texinfo specific export settings
15249 The Texinfo export back-end has several additional keywords for
15250 customizing Texinfo output.  Setting these keywords works similar to
15251 the general options (see @ref{Export Settings}).
15253 @table @asis
15254 @item @samp{SUBTITLE}
15255 @cindex @samp{SUBTITLE}, keyword
15256 The document subtitle.
15258 @item @samp{SUBAUTHOR}
15259 @cindex @samp{SUBAUTHOR}, keyword
15260 Additional authors for the document.
15262 @item @samp{TEXINFO_FILENAME}
15263 @cindex @samp{TEXINFO_FILENAME}, keyword
15264 The Texinfo filename.
15266 @item @samp{TEXINFO_CLASS}
15267 @cindex @samp{TEXINFO_CLASS}, keyword
15268 @vindex org-texinfo-default-class
15269 The default document class (@code{org-texinfo-default-class}), which
15270 must be a member of @code{org-texinfo-classes}.
15272 @item @samp{TEXINFO_HEADER}
15273 @cindex @samp{TEXINFO_HEADER}, keyword
15274 Arbitrary lines inserted at the end of the header.
15276 @item @samp{TEXINFO_POST_HEADER}
15277 @cindex @samp{TEXINFO_POST_HEADER}, keyword
15278 Arbitrary lines inserted after the end of the header.
15280 @item @samp{TEXINFO_DIR_CATEGORY}
15281 @cindex @samp{TEXINFO_DIR_CATEGORY}, keyword
15282 The directory category of the document.
15284 @item @samp{TEXINFO_DIR_TITLE}
15285 @cindex @samp{TEXINFO_DIR_TITLE}, keyword
15286 The directory title of the document.
15288 @item @samp{TEXINFO_DIR_DESC}
15289 @cindex @samp{TEXINFO_DIR_DESC}, keyword
15290 The directory description of the document.
15292 @item @samp{TEXINFO_PRINTED_TITLE}
15293 @cindex @samp{TEXINFO_PRINTED_TITLE}, keyword
15294 The printed title of the document.
15295 @end table
15297 @node Texinfo file header
15298 @subsection Texinfo file header
15300 @cindex @samp{TEXINFO_FILENAME}, keyword
15301 After creating the header for a Texinfo file, the Texinfo back-end
15302 automatically generates a name and destination path for the Info file.
15303 To override this default with a more sensible path and name, specify
15304 the @samp{TEXINFO_FILENAME} keyword.
15306 @vindex org-texinfo-coding-system
15307 @cindex @samp{TEXINFO_HEADER}, keyword
15308 Along with the output's file name, the Texinfo header also contains
15309 language details (see @ref{Export Settings}) and encoding system as set in
15310 the @code{org-texinfo-coding-system} variable.  Insert @samp{TEXINFO_HEADER}
15311 keywords for each additional command in the header, for example:
15313 @example
15314 #+TEXINFO_HEADER: @@synindex
15315 @end example
15317 @cindex @samp{TEXINFO_CLASS}, keyword
15318 @vindex org-texinfo-classes
15319 Instead of repeatedly installing the same set of commands, define
15320 a class in @code{org-texinfo-classes} once, and then activate it in the
15321 document by setting the @samp{TEXINFO_CLASS} keyword to that class.
15323 @node Texinfo title and copyright page
15324 @subsection Texinfo title and copyright page
15326 @cindex @samp{TEXINFO_PRINTED_TITLE}, keyword
15327 The default template for hard copy output has a title page with
15328 @samp{TITLE} and @samp{AUTHOR} keywords (see @ref{Export Settings}).  To replace the
15329 regular title with something different for the printed version, use
15330 the @samp{TEXINFO_PRINTED_TITLE} and @samp{SUBTITLE} keywords.  Both expect raw
15331 Texinfo code for setting their values.
15333 @cindex @samp{SUBAUTHOR}, keyword
15334 If one @samp{AUTHOR} line is not sufficient, add multiple @samp{SUBAUTHOR}
15335 keywords.  They have to be set in raw Texinfo code.
15337 @example
15338 #+AUTHOR: Jane Smith
15339 #+SUBAUTHOR: John Doe
15340 #+TEXINFO_PRINTED_TITLE: This Long Title@@@@inlinefmt@{tex,@@*@} Is Broken in @@TeX@{@}
15341 @end example
15343 @cindex @samp{COPYING}, property
15344 Copying material is defined in a dedicated headline with a non-@code{nil}
15345 @samp{COPYING} property.  The back-end inserts the contents within
15346 a @samp{@@copying} command at the beginning of the document.  The heading
15347 itself does not appear in the structure of the document.
15349 Copyright information is printed on the back of the title page.
15351 @example
15352 * Legalese
15353   :PROPERTIES:
15354   :COPYING: t
15355   :END:
15357   This is a short example of a complete Texinfo file, version 1.0.
15359   Copyright \copy 2016 Free Software Foundation, Inc.
15360 @end example
15362 @node Info directory file
15363 @subsection Info directory file
15365 @cindex @samp{dir} file, in Texinfo export
15366 @cindex Info directory file, in Texinfo export
15367 @cindex @code{install-info}, in Texinfo export
15369 @cindex @samp{TEXINFO_DIR_CATEGORY}, keyword
15370 @cindex @samp{TEXINFO_DIR_TITLE}, keyword
15371 @cindex @samp{TEXINFO_DIR_DESC}, keyword
15372 The end result of the Texinfo export process is the creation of an
15373 Info file.  This Info file's metadata has variables for category,
15374 title, and description: @samp{TEXINFO_DIR_CATEGORY}, @samp{TEXINFO_DIR_TITLE},
15375 and @samp{TEXINFO_DIR_DESC} keywords that establish where in the Info
15376 hierarchy the file fits.
15378 Here is an example that writes to the Info directory file:
15380 @example
15381 #+TEXINFO_DIR_CATEGORY: Emacs
15382 #+TEXINFO_DIR_TITLE: Org Mode: (org)
15383 #+TEXINFO_DIR_DESC: Outline-based notes management and organizer
15384 @end example
15386 @node Headings and sectioning structure
15387 @subsection Headings and sectioning structure
15389 @vindex org-texinfo-classes
15390 @vindex org-texinfo-default-class
15391 @cindex @samp{TEXINFO_CLASS}, keyword
15392 The Texinfo export back-end uses a pre-defined scheme to convert Org
15393 headlines to equivalent Texinfo structuring commands.  A scheme like
15394 this maps top-level headlines to numbered chapters tagged as
15395 @code{@@chapter} and lower-level headlines to unnumbered chapters tagged as
15396 @code{@@unnumbered}.  To override such mappings to introduce @code{@@part} or
15397 other Texinfo structuring commands, define a new class in
15398 @code{org-texinfo-classes}.  Activate the new class with the
15399 @samp{TEXINFO_CLASS} keyword.  When no new class is defined and activated,
15400 the Texinfo export back-end defaults to the
15401 @code{org-texinfo-default-class}.
15403 If an Org headline's level has no associated Texinfo structuring
15404 command, or is below a certain threshold (see @ref{Export Settings}), then
15405 the Texinfo export back-end makes it into a list item.
15407 @cindex @samp{APPENDIX}, property
15408 The Texinfo export back-end makes any headline with a non-@code{nil}
15409 @samp{APPENDIX} property into an appendix.  This happens independent of the
15410 Org headline level or the @samp{TEXINFO_CLASS} keyword.
15412 @cindex @samp{ALT_TITLE}, property
15413 @cindex @samp{DESCRIPTION}, property
15414 The Texinfo export back-end creates a menu entry after the Org
15415 headline for each regular sectioning structure.  To override this with
15416 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
15417 @samp{DESCRIPTION} property.  Here's an example that uses both to override
15418 the default menu entry:
15420 @example
15421 * Controlling Screen Display
15422   :PROPERTIES:
15423   :ALT_TITLE: Display
15424   :DESCRIPTION: Controlling Screen Display
15425   :END:
15426 @end example
15428 @cindex Top node, in Texinfo export
15429 The text before the first headline belongs to the @emph{Top} node, i.e.,
15430 the node in which a reader enters an Info manual.  As such, it is
15431 expected not to appear in printed output generated from the @samp{.texi}
15432 file.  See @ref{The Top Node,,,texinfo,}, for more information.
15434 @node Indices
15435 @subsection Indices
15437 @cindex @samp{CINDEX}, keyword
15438 @cindex concept index, in Texinfo export
15439 @cindex @samp{FINDEX}, keyword
15440 @cindex function index, in Texinfo export
15441 @cindex @samp{KINDEX}, keyword
15442 @cindex keystroke index, in Texinfo export
15443 @cindex @samp{PINDEX}, keyword
15444 @cindex program index, in Texinfo export
15445 @cindex @samp{TINDEX}, keyword
15446 @cindex data type index, in Texinfo export
15447 @cindex @samp{VINDEX}, keyword
15448 @cindex variable index, in Texinfo export
15449 The Texinfo export back-end recognizes these indexing keywords if used
15450 in the Org file: @samp{CINDEX}, @samp{FINDEX}, @samp{KINDEX}, @samp{PINDEX}, @samp{TINDEX} and
15451 @samp{VINDEX}.  Write their value as verbatim Texinfo code; in particular,
15452 @samp{@{}, @samp{@}} and @samp{@@} characters need to be escaped with @samp{@@} if they do not
15453 belong to a Texinfo command.
15455 @example
15456 #+CINDEX: Defining indexing entries
15457 @end example
15459 @cindex @samp{INDEX}, property
15460 For the back-end to generate an index entry for a headline, set the
15461 @samp{INDEX} property to @samp{cp} or @samp{vr}.  These abbreviations come from
15462 Texinfo that stand for concept index and variable index.  The Texinfo
15463 manual has abbreviations for all other kinds of indexes.  The back-end
15464 exports the headline as an unnumbered chapter or section command, and
15465 then inserts the index after its contents.
15467 @example
15468 * Concept Index
15469   :PROPERTIES:
15470   :INDEX: cp
15471   :END:
15472 @end example
15474 @node Quoting Texinfo code
15475 @subsection Quoting Texinfo code
15477 Use any of the following three methods to insert or escape raw Texinfo
15478 code:
15480 @cindex @samp{TEXINFO}, keyword
15481 @cindex @samp{BEGIN_EXPORT texinfo}
15482 @example
15483 Richard @@@@texinfo:@@sc@{@@@@Stallman@@@@texinfo:@}@@@@ commence' GNU.
15485 #+TEXINFO: @@need800
15486 This paragraph is preceded by...
15488 #+BEGIN_EXPORT texinfo
15489   @@auindex Johnson, Mark
15490   @@auindex Lakoff, George
15491 #+END_EXPORT
15492 @end example
15494 @node Plain lists in Texinfo export
15495 @subsection Plain lists in Texinfo export
15497 @cindex @samp{ATTR_TEXINFO}, keyword
15498 @cindex two-column tables, in Texinfo export
15500 @cindex table types, in Texinfo export
15501 The Texinfo export back-end by default converts description lists in
15502 the Org file using the default command @samp{@@table}, which results in
15503 a table with two columns.  To change this behavior, specify
15504 @samp{:table-type} with @samp{ftable} or @samp{vtable} attributes.  For more
15505 information, see @ref{Two-column Tables,,,texinfo,}.
15507 @vindex org-texinfo-table-default-markup
15508 The Texinfo export back-end by default also applies a text highlight
15509 based on the defaults stored in @code{org-texinfo-table-default-markup}.
15510 To override the default highlight command, specify another one with
15511 the @samp{:indic} attribute.
15513 @cindex multiple items in Texinfo lists
15514 Org syntax is limited to one entry per list item.  Nevertheless, the
15515 Texinfo export back-end can split that entry according to any text
15516 provided through the @samp{:sep} attribute.  Each part then becomes a new
15517 entry in the first column of the table.
15519 The following example illustrates all the attributes above:
15521 @example
15522 #+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
15523 - foo, bar :: This is the common text for variables foo and bar.
15524 @end example
15526 @noindent
15527 becomes
15529 @example
15530 @@vtable @@asis
15531 @@item foo
15532 @@itemx bar
15533 This is the common text for variables foo and bar.
15534 @@end table
15535 @end example
15537 @node Tables in Texinfo export
15538 @subsection Tables in Texinfo export
15540 @cindex @samp{ATTR_TEXINFO}, keyword
15541 When exporting tables, the Texinfo export back-end uses the widest
15542 cell width in each column.  To override this and instead specify as
15543 fractions of line length, use the @samp{:columns} attribute.  See example
15544 below.
15546 @example
15547 #+ATTR_TEXINFO: :columns .5 .5
15548 | a cell | another cell |
15549 @end example
15551 @node Images in Texinfo export
15552 @subsection Images in Texinfo export
15554 @cindex @samp{ATTR_TEXINFO}, keyword
15555 Insert a file link to the image in the Org file, and the Texinfo
15556 export back-end inserts the image.  These links must have the usual
15557 supported image extensions and no descriptions.  To scale the image,
15558 use @samp{:width} and @samp{:height} attributes.  For alternate text, use @samp{:alt}
15559 and specify the text using Texinfo code, as shown in the example:
15561 @example
15562 #+ATTR_TEXINFO: :width 1in :alt Alternate @@i@{text@}
15563 [[ridt.pdf]]
15564 @end example
15566 @node Special blocks in Texinfo export
15567 @subsection Special blocks in Texinfo export
15569 @cindex @samp{ATTR_TEXINFO}, keyword
15571 The Texinfo export back-end converts special blocks to commands with
15572 the same name.  It also adds any @samp{:options} attributes to the end of
15573 the command, as shown in this example:
15575 @example
15576 #+ATTR_TEXINFO: :options org-org-export-to-org ...
15577 #+BEGIN_defun
15578   A somewhat obsessive function name.
15579 #+END_defun
15580 @end example
15582 @noindent
15583 becomes
15585 @example
15586 @@defun org-org-export-to-org ...
15587   A somewhat obsessive function name.
15588 @@end defun
15589 @end example
15591 @node A Texinfo example
15592 @subsection A Texinfo example
15594 Here is a more detailed example Org file.  See
15595 @ref{GNU Sample Texts,,,texinfo,} for an equivalent example using
15596 Texinfo code.
15598 @example
15599 #+TITLE: GNU Sample @{@{@{version@}@}@}
15600 #+SUBTITLE: for version @{@{@{version@}@}@}, @{@{@{updated@}@}@}
15601 #+AUTHOR: A.U. Thor
15602 #+EMAIL: bug-sample@@gnu.org
15604 #+OPTIONS: ':t toc:t author:t email:t
15605 #+LANGUAGE: en
15607 #+MACRO: version 2.0
15608 #+MACRO: updated last updated 4 March 2014
15610 #+TEXINFO_FILENAME: sample.info
15611 #+TEXINFO_HEADER: @@syncodeindex pg cp
15613 #+TEXINFO_DIR_CATEGORY: Texinfo documentation system
15614 #+TEXINFO_DIR_TITLE: sample: (sample)
15615 #+TEXINFO_DIR_DESC: Invoking sample
15617 #+TEXINFO_PRINTED_TITLE: GNU Sample
15619 This manual is for GNU Sample (version @{@{@{version@}@}@},
15620 @{@{@{updated@}@}@}).
15622 * Copying
15623   :PROPERTIES:
15624   :COPYING:  t
15625   :END:
15627   This manual is for GNU Sample (version @{@{@{version@}@}@},
15628   @{@{@{updated@}@}@}), which is an example in the Texinfo documentation.
15630   Copyright \copy 2016 Free Software Foundation, Inc.
15632   #+BEGIN_QUOTE
15633   Permission is granted to copy, distribute and/or modify this
15634   document under the terms of the GNU Free Documentation License,
15635   Version 1.3 or any later version published by the Free Software
15636   Foundation; with no Invariant Sections, with no Front-Cover Texts,
15637   and with no Back-Cover Texts.  A copy of the license is included in
15638   the section entitled "GNU Free Documentation License".
15639   #+END_QUOTE
15641 * Invoking sample
15643   #+PINDEX: sample
15644   #+CINDEX: invoking @@command@{sample@}
15646   This is a sample manual.  There is no sample program to invoke, but
15647   if there were, you could see its basic usage and command line
15648   options here.
15650 * GNU Free Documentation License
15651   :PROPERTIES:
15652   :APPENDIX: t
15653   :END:
15655   #+TEXINFO: @@include fdl.texi
15657 * Index
15658   :PROPERTIES:
15659   :INDEX:    cp
15660   :END:
15661 @end example
15663 @node iCalendar Export
15664 @section iCalendar Export
15666 @cindex iCalendar export
15668 A large part of Org mode's interoperability success is its ability to
15669 easily export to or import from external applications.  The iCalendar
15670 export back-end takes calendar data from Org files and exports to the
15671 standard iCalendar format.
15673 @vindex org-icalendar-include-todo
15674 @vindex org-icalendar-use-deadline
15675 @vindex org-icalendar-use-scheduled
15676 The iCalendar export back-end can also incorporate TODO entries based
15677 on the configuration of the @code{org-icalendar-include-todo} variable.
15678 The back-end exports plain timestamps as @samp{VEVENT}, TODO items as
15679 @samp{VTODO}, and also create events from deadlines that are in non-TODO
15680 items.  The back-end uses the deadlines and scheduling dates in Org
15681 TODO items for setting the start and due dates for the iCalendar TODO
15682 entry.  Consult the @code{org-icalendar-use-deadline} and
15683 @code{org-icalendar-use-scheduled} variables for more details.
15685 @vindex org-icalendar-categories
15686 @vindex org-icalendar-alarm-time
15687 For tags on the headline, the iCalendar export back-end makes them
15688 into iCalendar categories.  To tweak the inheritance of tags and TODO
15689 states, configure the variable @code{org-icalendar-categories}.  To assign
15690 clock alarms based on time, configure the @code{org-icalendar-alarm-time}
15691 variable.
15693 @vindex org-icalendar-store-UID
15694 @cindex @samp{ID}, property
15695 The iCalendar format standard requires globally unique identifier---or
15696 UID---for each entry.  The iCalendar export back-end creates UIDs
15697 during export.  To save a copy of the UID in the Org file set the
15698 variable @code{org-icalendar-store-UID}.  The back-end looks for the @samp{ID}
15699 property of the entry for re-using the same UID for subsequent
15700 exports.
15702 Since a single Org entry can result in multiple iCalendar
15703 entries---timestamp, deadline, scheduled item, or TODO item---Org adds
15704 prefixes to the UID, depending on which part of the Org entry
15705 triggered the creation of the iCalendar entry.  Prefixing ensures UIDs
15706 remains unique, yet enable synchronization programs trace the
15707 connections.
15709 @table @asis
15710 @item @kbd{C-c C-e c f} (@code{org-icalendar-export-to-ics})
15711 @kindex C-c C-e c f
15712 @findex org-icalendar-export-to-ics
15713 Create iCalendar entries from the current Org buffer and store
15714 them in the same directory, using a file extension @samp{.ics}.
15716 @item @kbd{C-c C-e c a} (@code{org-icalendar-export-agenda-files})
15717 @kindex C-c C-e c a
15718 @findex org-icalendar-export-agenda-files
15719 Create iCalendar entries from Org files in @code{org-agenda-files} and
15720 store in a separate iCalendar file for each Org file.
15722 @item @kbd{C-c C-e c c} (@code{org-icalendar-combine-agenda-files})
15723 @kindex C-c C-e c c
15724 @findex org-icalendar-combine-agenda-files
15725 @vindex org-icalendar-combined-agenda-file
15726 Create a combined iCalendar file from Org files in
15727 @code{org-agenda-files} and write it to
15728 @code{org-icalendar-combined-agenda-file} file name.
15729 @end table
15731 @cindex @samp{SUMMARY}, property
15732 @cindex @samp{DESCRIPTION}, property
15733 @cindex @samp{LOCATION}, property
15734 @cindex @samp{TIMEZONE}, property
15735 The iCalendar export back-end includes @samp{SUMMARY}, @samp{DESCRIPTION},
15736 @samp{LOCATION} and @samp{TIMEZONE} properties from the Org entries when
15737 exporting.  To force the back-end to inherit the @samp{LOCATION} and
15738 @samp{TIMEZONE} properties, configure the @code{org-use-property-inheritance}
15739 variable.
15741 @vindex org-icalendar-include-body
15742 When Org entries do not have @samp{SUMMARY}, @samp{DESCRIPTION} and @samp{LOCATION}
15743 properties, the iCalendar export back-end derives the summary from the
15744 headline, and derives the description from the body of the Org item.
15745 The @code{org-icalendar-include-body} variable limits the maximum number of
15746 characters of the content are turned into its description.
15748 The @samp{TIMEZONE} property can be used to specify a per-entry time zone,
15749 and is applied to any entry with timestamp information.  Time zones
15750 should be specified as per the IANA time zone database format, e.g.,
15751 @samp{Asia/Almaty}.  Alternately, the property value can be @samp{UTC}, to force
15752 UTC time for this entry only.
15754 Exporting to iCalendar format depends in large part on the
15755 capabilities of the destination application.  Some are more lenient
15756 than others.  Consult the Org mode FAQ for advice on specific
15757 applications.
15759 @node Other Built-in Back-ends
15760 @section Other Built-in Back-ends
15762 Other export back-ends included with Org are:
15764 @itemize
15765 @item
15766 @samp{ox-man.el}: Export to a man page.
15767 @end itemize
15769 To activate such back-ends, either customize @code{org-export-backends} or
15770 load directly with @code{(require 'ox-man)}.  On successful load, the
15771 back-end adds new keys in the export dispatcher (see @ref{The Export Dispatcher}).
15773 Follow the comment section of such files, for example, @samp{ox-man.el},
15774 for usage and configuration details.
15776 @node Advanced Configuration
15777 @section Advanced Configuration
15781 @anchor{Hooks}
15782 @subheading Hooks
15784 @vindex org-export-before-processing-hook
15785 @vindex org-export-before-parsing-hook
15786 The export process executes two hooks before the actual exporting
15787 begins.  The first hook, @code{org-export-before-processing-hook}, runs
15788 before any expansions of macros, Babel code, and include keywords in
15789 the buffer.  The second hook, @code{org-export-before-parsing-hook}, runs
15790 before the buffer is parsed.
15792 Functions added to these hooks are called with a single argument: the
15793 export back-end actually used, as a symbol.  You may use them for
15794 heavy duty structural modifications of the document.  For example, you
15795 can remove every headline in the buffer during export like this:
15797 @lisp
15798 (defun my-headline-removal (backend)
15799   "Remove all headlines in the current buffer.
15800 BACKEND is the export back-end being used, as a symbol."
15801   (org-map-entries
15802    (lambda () (delete-region (point) (line-beginning-position 2)))))
15804 (add-hook 'org-export-before-parsing-hook 'my-headline-removal)
15805 @end lisp
15807 @anchor{Filters}
15808 @subheading Filters
15810 @cindex Filters, exporting
15811 Filters are lists of functions to be applied to certain parts for
15812 a given back-end.  The output from the first function in the filter is
15813 passed on to the next function in the filter.  The final output is the
15814 output from the final function in the filter.
15816 The Org export process has many filter sets applicable to different
15817 types of objects, plain text, parse trees, export options, and final
15818 output formats.  The filters are named after the element type or
15819 object type: @code{org-export-filter-TYPE-functions}, where @var{TYPE}
15820 is the type targeted by the filter.  Valid types are:
15822 @multitable @columnfractions 0.33 0.33 0.33
15823 @item body
15824 @tab bold
15825 @tab babel-call
15826 @item center-block
15827 @tab clock
15828 @tab code
15829 @item diary-sexp
15830 @tab drawer
15831 @tab dynamic-block
15832 @item entity
15833 @tab example-block
15834 @tab export-block
15835 @item export-snippet
15836 @tab final-output
15837 @tab fixed-width
15838 @item footnote-definition
15839 @tab footnote-reference
15840 @tab headline
15841 @item horizontal-rule
15842 @tab inline-babel-call
15843 @tab inline-src-block
15844 @item inlinetask
15845 @tab italic
15846 @tab item
15847 @item keyword
15848 @tab latex-environment
15849 @tab latex-fragment
15850 @item line-break
15851 @tab link
15852 @tab node-property
15853 @item options
15854 @tab paragraph
15855 @tab parse-tree
15856 @item plain-list
15857 @tab plain-text
15858 @tab planning
15859 @item property-drawer
15860 @tab quote-block
15861 @tab radio-target
15862 @item section
15863 @tab special-block
15864 @tab src-block
15865 @item statistics-cookie
15866 @tab strike-through
15867 @tab subscript
15868 @item superscript
15869 @tab table
15870 @tab table-cell
15871 @item table-row
15872 @tab target
15873 @tab timestamp
15874 @item underline
15875 @tab verbatim
15876 @tab verse-block
15877 @end multitable
15879 Here is an example filter that replaces non-breaking spaces @code{ } in the
15880 Org buffer with @samp{~} for the @LaTeX{} back-end.
15882 @lisp
15883 (defun my-latex-filter-nobreaks (text backend info)
15884   "Ensure \" \" are properly handled in LaTeX export."
15885   (when (org-export-derived-backend-p backend 'latex)
15886     (replace-regexp-in-string " " "~" text)))
15888 (add-to-list 'org-export-filter-plain-text-functions
15889              'my-latex-filter-nobreaks)
15890 @end lisp
15892 A filter requires three arguments: the code to be transformed, the
15893 name of the back-end, and some optional information about the export
15894 process.  The third argument can be safely ignored.  Note the use of
15895 @code{org-export-derived-backend-p} predicate that tests for @emph{latex}
15896 back-end or any other back-end, such as @emph{beamer}, derived from
15897 @emph{latex}.
15899 @anchor{Defining filters for individual files}
15900 @subheading Defining filters for individual files
15902 The Org export can filter not just for back-ends, but also for
15903 specific files through the @samp{BIND} keyword.  Here is an example with
15904 two filters; one removes brackets from time stamps, and the other
15905 removes strike-through text.  The filter functions are defined in
15906 a code block in the same Org file, which is a handy location for
15907 debugging.
15909 @example
15910 #+BIND: org-export-filter-timestamp-functions (tmp-f-timestamp)
15911 #+BIND: org-export-filter-strike-through-functions (tmp-f-strike-through)
15912 #+BEGIN_SRC emacs-lisp :exports results :results none
15913   (defun tmp-f-timestamp (s backend info)
15914     (replace-regexp-in-string "&[lg]t;\\|[][]" "" s))
15915   (defun tmp-f-strike-through (s backend info) "")
15916 #+END_SRC
15917 @end example
15919 @anchor{Extending an existing back-end}
15920 @subheading Extending an existing back-end
15922 Some parts of the conversion process can be extended for certain
15923 elements so as to introduce a new or revised translation.  That is how
15924 the HTML export back-end was extended to handle Markdown format.  The
15925 extensions work seamlessly so any aspect of filtering not done by the
15926 extended back-end is handled by the original back-end.  Of all the
15927 export customization in Org, extending is very powerful as it operates
15928 at the parser level.
15930 For this example, make the @emph{ascii} back-end display the language used
15931 in a source code block.  Also make it display only when some attribute
15932 is non-@code{nil}, like the following:
15934 @example
15935 #+ATTR_ASCII: :language t
15936 @end example
15938 Then extend ASCII back-end with a custom ``my-ascii'' back-end.
15940 @lisp
15941 (defun my-ascii-src-block (src-block contents info)
15942   "Transcode a SRC-BLOCK element from Org to ASCII.
15943 CONTENTS is nil.  INFO is a plist used as a communication
15944 channel."
15945   (if (not (org-export-read-attribute :attr_ascii src-block :language))
15946       (org-export-with-backend 'ascii src-block contents info)
15947     (concat
15948      (format ",--[ %s ]--\n%s`----"
15949              (org-element-property :language src-block)
15950              (replace-regexp-in-string
15951               "^" "| "
15952               (org-element-normalize-string
15953                (org-export-format-code-default src-block info)))))))
15955 (org-export-define-derived-backend 'my-ascii 'ascii
15956   :translate-alist '((src-block . my-ascii-src-block)))
15957 @end lisp
15959 The @code{my-ascii-src-block} function looks at the attribute above the
15960 current element.  If not true, hands over to @emph{ascii} back-end.  If
15961 true, which it is in this example, it creates a box around the code
15962 and leaves room for the inserting a string for language.  The last
15963 form creates the new back-end that springs to action only when
15964 translating @code{src-block} type elements.
15966 To use the newly defined back-end, evaluate the following from an Org
15967 buffer:
15969 @lisp
15970 (org-export-to-buffer 'my-ascii "*Org MY-ASCII Export*")
15971 @end lisp
15973 Further steps to consider would be an interactive function,
15974 self-installing an item in the export dispatcher menu, and other
15975 user-friendly improvements.
15977 @node Export in Foreign Buffers
15978 @section Export in Foreign Buffers
15980 The export back-ends in Org often include commands to convert selected
15981 regions.  A convenient feature of this in-place conversion is that the
15982 exported output replaces the original source.  Here are such
15983 functions:
15985 @table @asis
15986 @item @code{org-html-convert-region-to-html}
15987 @findex org-html-convert-region-to-html
15988 Convert the selected region into HTML.
15990 @item @code{org-latex-convert-region-to-latex}
15991 @findex org-latex-convert-region-to-latex
15992 Convert the selected region into @LaTeX{}.
15994 @item @code{org-texinfo-convert-region-to-texinfo}
15995 @findex org-texinfo-convert-region-to-texinfo
15996 Convert the selected region into Texinfo.
15998 @item @code{org-md-convert-region-to-md}
15999 @findex org-md-convert-region-to-md
16000 Convert the selected region into Markdown.
16001 @end table
16003 In-place conversions are particularly handy for quick conversion of
16004 tables and lists in foreign buffers.  For example, turn on the minor
16005 mode @kbd{M-x orgstruct-mode} in an HTML buffer, then use the
16006 convenient Org keyboard commands to create a list, select it, and
16007 covert it to HTML with @kbd{M-x org-html-convert-region-to-html}.
16009 @node Publishing
16010 @chapter Publishing
16012 @cindex publishing
16014 Org includes a publishing management system that allows you to
16015 configure automatic HTML conversion of @emph{projects} composed of
16016 interlinked Org files.  You can also configure Org to automatically
16017 upload your exported HTML pages and related attachments, such as
16018 images and source code files, to a web server.
16020 You can also use Org to convert files into PDF, or even combine HTML
16021 and PDF conversion so that files are available in both formats on the
16022 server.
16024 Publishing has been contributed to Org by David O'Toole.
16026 @menu
16027 * Configuration::                Defining projects.
16028 * Uploading Files::              How to get files up on the server.
16029 * Sample Configuration::         Example projects.
16030 * Triggering Publication::       Publication commands.
16031 @end menu
16033 @node Configuration
16034 @section Configuration
16036 Publishing needs significant configuration to specify files,
16037 destination and many other properties of a project.
16039 @menu
16040 * Project alist::                The central configuration variable.
16041 * Sources and destinations::     From here to there.
16042 * Selecting files::              What files are part of the project?
16043 * Publishing action::            Setting the function doing the publishing.
16044 * Publishing options::           Tweaking HTML/@LaTeX{} export.
16045 * Publishing links::             Which links keep working after publishing?
16046 * Site map::                     Generating a list of all pages.
16047 * Generating an index::          An index that reaches across pages.
16048 @end menu
16050 @node Project alist
16051 @subsection The variable @code{org-publish-project-alist}
16053 @cindex projects, for publishing
16055 @vindex org-publish-project-alist
16056 Publishing is configured almost entirely through setting the value of
16057 one variable, called @code{org-publish-project-alist}.  Each element of the
16058 list configures one project, and may be in one of the two following
16059 forms:
16061 @lisp
16062 ("project-name" :property value :property value ...)
16063 @end lisp
16065 @noindent
16066 i.e., a well-formed property list with alternating keys and values,
16069 @lisp
16070 ("project-name" :components ("project-name" "project-name" ...))
16071 @end lisp
16073 In both cases, projects are configured by specifying property values.
16074 A project defines the set of files that are to be published, as well
16075 as the publishing configuration to use when publishing those files.
16076 When a project takes the second form listed above, the individual
16077 members of the @code{:components} property are taken to be sub-projects,
16078 which group together files requiring different publishing options.
16079 When you publish such a ``meta-project'', all the components are also
16080 published, in the sequence given.
16082 @node Sources and destinations
16083 @subsection Sources and destinations for files
16085 @cindex directories, for publishing
16087 Most properties are optional, but some should always be set.  In
16088 particular, Org needs to know where to look for source files, and
16089 where to put published files.
16091 @table @asis
16092 @item @code{:base-directory}
16093 Directory containing publishing source files.
16095 @item @code{:publishing-directory}
16096 Directory where output files are published.  You can directly
16097 publish to a webserver using a file name syntax appropriate for
16098 the Emacs tramp package.  Or you can publish to a local directory
16099 and use external tools to upload your website (see @ref{Uploading Files}).
16101 @item @code{:preparation-function}
16102 Function or list of functions to be called before starting the
16103 publishing process, for example, to run @samp{make} for updating files
16104 to be published.  Each preparation function is called with
16105 a single argument, the project property list.
16107 @item @code{:completion-function}
16108 Function or list of functions called after finishing the
16109 publishing process, for example, to change permissions of the
16110 resulting files.  Each completion function is called with
16111 a single argument, the project property list.
16112 @end table
16114 @node Selecting files
16115 @subsection Selecting files
16117 @cindex files, selecting for publishing
16119 By default, all files with extension @samp{.org} in the base directory are
16120 considered part of the project.  This can be modified by setting the
16121 following properties
16123 @table @asis
16124 @item @code{:base-extension}
16125 Extension---without the dot---of source files.  This actually
16126 is a regular expression.  Set this to the symbol @code{any} if you
16127 want to get all files in @code{:base-directory}, even without
16128 extension.
16130 @item @code{:exclude}
16131 Regular expression to match file names that should not be published,
16132 even though they have been selected on the basis of their extension.
16134 @item @code{:include}
16135 List of files to be included regardless of @code{:base-extension} and
16136 @code{:exclude}.
16138 @item @code{:recursive}
16139 Non-@code{nil} means, check base-directory recursively for files to
16140 publish.
16141 @end table
16143 @node Publishing action
16144 @subsection Publishing action
16146 @cindex action, for publishing
16148 Publishing means that a file is copied to the destination directory
16149 and possibly transformed in the process.  The default transformation
16150 is to export Org files as HTML files, and this is done by the function
16151 @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
16152 @code{org-publish-org-to-pdf}, or as ASCII, Texinfo, etc., using the
16153 corresponding functions.
16155 If you want to publish the Org file as an @samp{.org} file but with
16156 @emph{archived}, @emph{commented}, and @emph{tag-excluded} trees removed, use
16157 @code{org-publish-org-to-org}.  This produces @samp{file.org} and put it in the
16158 publishing directory.  If you want a htmlized version of this file,
16159 set the parameter @code{:htmlized-source} to @code{t}.  It produces
16160 @samp{file.org.html} in the publishing directory@footnote{If the publishing directory is the same as the source
16161 directory, @samp{file.org} is exported as @samp{file.org.org}, so you probably
16162 do not want to do this.}.
16164 Other files like images only need to be copied to the publishing
16165 destination; for this you can use @code{org-publish-attachment}.  For
16166 non-Org files, you always need to specify the publishing function:
16168 @table @asis
16169 @item @code{:publishing-function}
16170 Function executing the publication of a file.  This may also be
16171 a list of functions, which are all called in turn.
16173 @item @code{:plain-source}
16174 Non-@code{nil} means, publish plain source.
16176 @item @code{:htmlized-source}
16177 Non-@code{nil} means, publish htmlized source.
16178 @end table
16180 The function must accept three arguments: a property list containing
16181 at least a @code{:publishing-directory} property, the name of the file to
16182 be published, and the path to the publishing directory of the output
16183 file.  It should take the specified file, make the necessary
16184 transformation, if any, and place the result into the destination
16185 folder.
16187 @node Publishing options
16188 @subsection Options for the exporters
16190 @cindex options, for publishing
16191 @cindex publishing options
16193 The property list can be used to set many export options for the HTML
16194 and @LaTeX{} exporters.  In most cases, these properties correspond to
16195 user variables in Org.  The table below lists these properties along
16196 with the variable they belong to.  See the documentation string for
16197 the respective variable for details.
16199 @vindex org-publish-project-alist
16200 When a property is given a value in @code{org-publish-project-alist}, its
16201 setting overrides the value of the corresponding user variable, if
16202 any, during publishing.  Options set within a file (see @ref{Export Settings}), however, override everything.
16204 @anchor{Generic properties}
16205 @subsubheading Generic properties
16207 @multitable {aaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16208 @item @code{:archived-trees}
16209 @tab @code{org-export-with-archived-trees}
16210 @item @code{:exclude-tags}
16211 @tab @code{org-export-exclude-tags}
16212 @item @code{:headline-levels}
16213 @tab @code{org-export-headline-levels}
16214 @item @code{:language}
16215 @tab @code{org-export-default-language}
16216 @item @code{:preserve-breaks}
16217 @tab @code{org-export-preserve-breaks}
16218 @item @code{:section-numbers}
16219 @tab @code{org-export-with-section-numbers}
16220 @item @code{:select-tags}
16221 @tab @code{org-export-select-tags}
16222 @item @code{:with-author}
16223 @tab @code{org-export-with-author}
16224 @item @code{:with-broken-links}
16225 @tab @code{org-export-with-broken-links}
16226 @item @code{:with-clocks}
16227 @tab @code{org-export-with-clocks}
16228 @item @code{:with-creator}
16229 @tab @code{org-export-with-creator}
16230 @item @code{:with-date}
16231 @tab @code{org-export-with-date}
16232 @item @code{:with-drawers}
16233 @tab @code{org-export-with-drawers}
16234 @item @code{:with-email}
16235 @tab @code{org-export-with-email}
16236 @item @code{:with-emphasize}
16237 @tab @code{org-export-with-emphasize}
16238 @item @code{:with-fixed-width}
16239 @tab @code{org-export-with-fixed-width}
16240 @item @code{:with-footnotes}
16241 @tab @code{org-export-with-footnotes}
16242 @item @code{:with-latex}
16243 @tab @code{org-export-with-latex}
16244 @item @code{:with-planning}
16245 @tab @code{org-export-with-planning}
16246 @item @code{:with-priority}
16247 @tab @code{org-export-with-priority}
16248 @item @code{:with-properties}
16249 @tab @code{org-export-with-properties}
16250 @item @code{:with-special-strings}
16251 @tab @code{org-export-with-special-strings}
16252 @item @code{:with-sub-superscript}
16253 @tab @code{org-export-with-sub-superscripts}
16254 @item @code{:with-tables}
16255 @tab @code{org-export-with-tables}
16256 @item @code{:with-tags}
16257 @tab @code{org-export-with-tags}
16258 @item @code{:with-tasks}
16259 @tab @code{org-export-with-tasks}
16260 @item @code{:with-timestamps}
16261 @tab @code{org-export-with-timestamps}
16262 @item @code{:with-title}
16263 @tab @code{org-export-with-title}
16264 @item @code{:with-toc}
16265 @tab @code{org-export-with-toc}
16266 @item @code{:with-todo-keywords}
16267 @tab @code{org-export-with-todo-keywords}
16268 @end multitable
16270 @anchor{ASCII specific properties}
16271 @subsubheading ASCII specific properties
16273 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16274 @item @code{:ascii-bullets}
16275 @tab @code{org-ascii-bullets}
16276 @item @code{:ascii-caption-above}
16277 @tab @code{org-ascii-caption-above}
16278 @item @code{:ascii-charset}
16279 @tab @code{org-ascii-charset}
16280 @item @code{:ascii-global-margin}
16281 @tab @code{org-ascii-global-margin}
16282 @item @code{:ascii-format-drawer-function}
16283 @tab @code{org-ascii-format-drawer-function}
16284 @item @code{:ascii-format-inlinetask-function}
16285 @tab @code{org-ascii-format-inlinetask-function}
16286 @item @code{:ascii-headline-spacing}
16287 @tab @code{org-ascii-headline-spacing}
16288 @item @code{:ascii-indented-line-width}
16289 @tab @code{org-ascii-indented-line-width}
16290 @item @code{:ascii-inlinetask-width}
16291 @tab @code{org-ascii-inlinetask-width}
16292 @item @code{:ascii-inner-margin}
16293 @tab @code{org-ascii-inner-margin}
16294 @item @code{:ascii-links-to-notes}
16295 @tab @code{org-ascii-links-to-notes}
16296 @item @code{:ascii-list-margin}
16297 @tab @code{org-ascii-list-margin}
16298 @item @code{:ascii-paragraph-spacing}
16299 @tab @code{org-ascii-paragraph-spacing}
16300 @item @code{:ascii-quote-margin}
16301 @tab @code{org-ascii-quote-margin}
16302 @item @code{:ascii-table-keep-all-vertical-lines}
16303 @tab @code{org-ascii-table-keep-all-vertical-lines}
16304 @item @code{:ascii-table-use-ascii-art}
16305 @tab @code{org-ascii-table-use-ascii-art}
16306 @item @code{:ascii-table-widen-columns}
16307 @tab @code{org-ascii-table-widen-columns}
16308 @item @code{:ascii-text-width}
16309 @tab @code{org-ascii-text-width}
16310 @item @code{:ascii-underline}
16311 @tab @code{org-ascii-underline}
16312 @item @code{:ascii-verbatim-format}
16313 @tab @code{org-ascii-verbatim-format}
16314 @end multitable
16316 @anchor{Beamer specific properties}
16317 @subsubheading Beamer specific properties
16319 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16320 @item @code{:beamer-theme}
16321 @tab @code{org-beamer-theme}
16322 @item @code{:beamer-column-view-format}
16323 @tab @code{org-beamer-column-view-format}
16324 @item @code{:beamer-environments-extra}
16325 @tab @code{org-beamer-environments-extra}
16326 @item @code{:beamer-frame-default-options}
16327 @tab @code{org-beamer-frame-default-options}
16328 @item @code{:beamer-outline-frame-options}
16329 @tab @code{org-beamer-outline-frame-options}
16330 @item @code{:beamer-outline-frame-title}
16331 @tab @code{org-beamer-outline-frame-title}
16332 @item @code{:beamer-subtitle-format}
16333 @tab @code{org-beamer-subtitle-format}
16334 @end multitable
16336 @anchor{HTML specific properties}
16337 @subsubheading HTML specific properties
16339 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16340 @item @code{:html-allow-name-attribute-in-anchors}
16341 @tab @code{org-html-allow-name-attribute-in-anchors}
16342 @item @code{:html-checkbox-type}
16343 @tab @code{org-html-checkbox-type}
16344 @item @code{:html-container}
16345 @tab @code{org-html-container-element}
16346 @item @code{:html-divs}
16347 @tab @code{org-html-divs}
16348 @item @code{:html-doctype}
16349 @tab @code{org-html-doctype}
16350 @item @code{:html-extension}
16351 @tab @code{org-html-extension}
16352 @item @code{:html-footnote-format}
16353 @tab @code{org-html-footnote-format}
16354 @item @code{:html-footnote-separator}
16355 @tab @code{org-html-footnote-separator}
16356 @item @code{:html-footnotes-section}
16357 @tab @code{org-html-footnotes-section}
16358 @item @code{:html-format-drawer-function}
16359 @tab @code{org-html-format-drawer-function}
16360 @item @code{:html-format-headline-function}
16361 @tab @code{org-html-format-headline-function}
16362 @item @code{:html-format-inlinetask-function}
16363 @tab @code{org-html-format-inlinetask-function}
16364 @item @code{:html-head-extra}
16365 @tab @code{org-html-head-extra}
16366 @item @code{:html-head-include-default-style}
16367 @tab @code{org-html-head-include-default-style}
16368 @item @code{:html-head-include-scripts}
16369 @tab @code{org-html-head-include-scripts}
16370 @item @code{:html-head}
16371 @tab @code{org-html-head}
16372 @item @code{:html-home/up-format}
16373 @tab @code{org-html-home/up-format}
16374 @item @code{:html-html5-fancy}
16375 @tab @code{org-html-html5-fancy}
16376 @item @code{:html-indent}
16377 @tab @code{org-html-indent}
16378 @item @code{:html-infojs-options}
16379 @tab @code{org-html-infojs-options}
16380 @item @code{:html-infojs-template}
16381 @tab @code{org-html-infojs-template}
16382 @item @code{:html-inline-image-rules}
16383 @tab @code{org-html-inline-image-rules}
16384 @item @code{:html-inline-images}
16385 @tab @code{org-html-inline-images}
16386 @item @code{:html-link-home}
16387 @tab @code{org-html-link-home}
16388 @item @code{:html-link-org-files-as-html}
16389 @tab @code{org-html-link-org-files-as-html}
16390 @item @code{:html-link-up}
16391 @tab @code{org-html-link-up}
16392 @item @code{:html-link-use-abs-url}
16393 @tab @code{org-html-link-use-abs-url}
16394 @item @code{:html-mathjax-options}
16395 @tab @code{org-html-mathjax-options}
16396 @item @code{:html-mathjax-template}
16397 @tab @code{org-html-mathjax-template}
16398 @item @code{:html-metadata-timestamp-format}
16399 @tab @code{org-html-metadata-timestamp-format}
16400 @item @code{:html-postamble-format}
16401 @tab @code{org-html-postamble-format}
16402 @item @code{:html-postamble}
16403 @tab @code{org-html-postamble}
16404 @item @code{:html-preamble-format}
16405 @tab @code{org-html-preamble-format}
16406 @item @code{:html-preamble}
16407 @tab @code{org-html-preamble}
16408 @item @code{:html-table-align-individual-field}
16409 @tab @code{de@{org-html-table-align-individual-fields}
16410 @item @code{:html-table-attributes}
16411 @tab @code{org-html-table-default-attributes}
16412 @item @code{:html-table-caption-above}
16413 @tab @code{org-html-table-caption-above}
16414 @item @code{:html-table-data-tags}
16415 @tab @code{org-html-table-data-tags}
16416 @item @code{:html-table-header-tags}
16417 @tab @code{org-html-table-header-tags}
16418 @item @code{:html-table-row-tags}
16419 @tab @code{org-html-table-row-tags}
16420 @item @code{:html-table-use-header-tags-for-first-column}
16421 @tab @code{org-html-table-use-header-tags-for-first-column}
16422 @item @code{:html-tag-class-prefix}
16423 @tab @code{org-html-tag-class-prefix}
16424 @item @code{:html-text-markup-alist}
16425 @tab @code{org-html-text-markup-alist}
16426 @item @code{:html-todo-kwd-class-prefix}
16427 @tab @code{org-html-todo-kwd-class-prefix}
16428 @item @code{:html-toplevel-hlevel}
16429 @tab @code{org-html-toplevel-hlevel}
16430 @item @code{:html-use-infojs}
16431 @tab @code{org-html-use-infojs}
16432 @item @code{:html-validation-link}
16433 @tab @code{org-html-validation-link}
16434 @item @code{:html-viewport}
16435 @tab @code{org-html-viewport}
16436 @item @code{:html-xml-declaration}
16437 @tab @code{org-html-xml-declaration}
16438 @end multitable
16440 @anchor{@LaTeX{} specific properties}
16441 @subsubheading @LaTeX{} specific properties
16443 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16444 @item @code{:latex-active-timestamp-format}
16445 @tab @code{org-latex-active-timestamp-format}
16446 @item @code{:latex-caption-above}
16447 @tab @code{org-latex-caption-above}
16448 @item @code{:latex-classes}
16449 @tab @code{org-latex-classes}
16450 @item @code{:latex-class}
16451 @tab @code{org-latex-default-class}
16452 @item @code{:latex-compiler}
16453 @tab @code{org-latex-compiler}
16454 @item @code{:latex-default-figure-position}
16455 @tab @code{org-latex-default-figure-position}
16456 @item @code{:latex-default-table-environment}
16457 @tab @code{org-latex-default-table-environment}
16458 @item @code{:latex-default-table-mode}
16459 @tab @code{org-latex-default-table-mode}
16460 @item @code{:latex-diary-timestamp-format}
16461 @tab @code{org-latex-diary-timestamp-format}
16462 @item @code{:latex-footnote-defined-format}
16463 @tab @code{org-latex-footnote-defined-format}
16464 @item @code{:latex-footnote-separator}
16465 @tab @code{org-latex-footnote-separator}
16466 @item @code{:latex-format-drawer-function}
16467 @tab @code{org-latex-format-drawer-function}
16468 @item @code{:latex-format-headline-function}
16469 @tab @code{org-latex-format-headline-function}
16470 @item @code{:latex-format-inlinetask-function}
16471 @tab @code{org-latex-format-inlinetask-function}
16472 @item @code{:latex-hyperref-template}
16473 @tab @code{org-latex-hyperref-template}
16474 @item @code{:latex-image-default-height}
16475 @tab @code{org-latex-image-default-height}
16476 @item @code{:latex-image-default-option}
16477 @tab @code{org-latex-image-default-option}
16478 @item @code{:latex-image-default-width}
16479 @tab @code{org-latex-image-default-width}
16480 @item @code{:latex-images-centered}
16481 @tab @code{org-latex-images-centered}
16482 @item @code{:latex-inactive-timestamp-format}
16483 @tab @code{org-latex-inactive-timestamp-format}
16484 @item @code{:latex-inline-image-rules}
16485 @tab @code{org-latex-inline-image-rules}
16486 @item @code{:latex-link-with-unknown-path-format}
16487 @tab @code{org-latex-link-with-unknown-path-format}
16488 @item @code{:latex-listings-langs}
16489 @tab @code{org-latex-listings-langs}
16490 @item @code{:latex-listings-options}
16491 @tab @code{org-latex-listings-options}
16492 @item @code{:latex-listings}
16493 @tab @code{org-latex-listings}
16494 @item @code{:latex-minted-langs}
16495 @tab @code{org-latex-minted-langs}
16496 @item @code{:latex-minted-options}
16497 @tab @code{org-latex-minted-options}
16498 @item @code{:latex-prefer-user-labels}
16499 @tab @code{org-latex-prefer-user-labels}
16500 @item @code{:latex-subtitle-format}
16501 @tab @code{org-latex-subtitle-format}
16502 @item @code{:latex-subtitle-separate}
16503 @tab @code{org-latex-subtitle-separate}
16504 @item @code{:latex-table-scientific-notation}
16505 @tab @code{org-latex-table-scientific-notation}
16506 @item @code{:latex-tables-booktabs}
16507 @tab @code{org-latex-tables-booktabs}
16508 @item @code{:latex-tables-centered}
16509 @tab @code{org-latex-tables-centered}
16510 @item @code{:latex-text-markup-alist}
16511 @tab @code{org-latex-text-markup-alist}
16512 @item @code{:latex-title-command}
16513 @tab @code{org-latex-title-command}
16514 @item @code{:latex-toc-command}
16515 @tab @code{org-latex-toc-command}
16516 @end multitable
16518 @anchor{Markdown specific properties}
16519 @subsubheading Markdown specific properties
16521 @multitable {aaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaa}
16522 @item @code{:md-footnote-format}
16523 @tab @code{org-md-footnote-format}
16524 @item @code{:md-footnotes-section}
16525 @tab @code{org-md-footnotes-section}
16526 @item @code{:md-headline-style}
16527 @tab @code{org-md-headline-style}
16528 @end multitable
16530 @anchor{ODT specific properties}
16531 @subsubheading ODT specific properties
16533 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16534 @item @code{:odt-content-template-file}
16535 @tab @code{org-odt-content-template-file}
16536 @item @code{:odt-display-outline-level}
16537 @tab @code{org-odt-display-outline-level}
16538 @item @code{:odt-fontify-srcblocks}
16539 @tab @code{org-odt-fontify-srcblocks}
16540 @item @code{:odt-format-drawer-function}
16541 @tab @code{org-odt-format-drawer-function}
16542 @item @code{:odt-format-headline-function}
16543 @tab @code{org-odt-format-headline-function}
16544 @item @code{:odt-format-inlinetask-function}
16545 @tab @code{org-odt-format-inlinetask-function}
16546 @item @code{:odt-inline-formula-rules}
16547 @tab @code{org-odt-inline-formula-rules}
16548 @item @code{:odt-inline-image-rules}
16549 @tab @code{org-odt-inline-image-rules}
16550 @item @code{:odt-pixels-per-inch}
16551 @tab @code{org-odt-pixels-per-inch}
16552 @item @code{:odt-styles-file}
16553 @tab @code{org-odt-styles-file}
16554 @item @code{:odt-table-styles}
16555 @tab @code{org-odt-table-styles}
16556 @item @code{:odt-use-date-fields}
16557 @tab @code{org-odt-use-date-fields}
16558 @end multitable
16560 @anchor{Texinfo specific properties}
16561 @subsubheading Texinfo specific properties
16563 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16564 @item @code{:texinfo-active-timestamp-format}
16565 @tab @code{org-texinfo-active-timestamp-format}
16566 @item @code{:texinfo-classes}
16567 @tab @code{org-texinfo-classes}
16568 @item @code{:texinfo-class}
16569 @tab @code{org-texinfo-default-class}
16570 @item @code{:texinfo-table-default-markup}
16571 @tab @code{org-texinfo-table-default-markup}
16572 @item @code{:texinfo-diary-timestamp-format}
16573 @tab @code{org-texinfo-diary-timestamp-format}
16574 @item @code{:texinfo-filename}
16575 @tab @code{org-texinfo-filename}
16576 @item @code{:texinfo-format-drawer-function}
16577 @tab @code{org-texinfo-format-drawer-function}
16578 @item @code{:texinfo-format-headline-function}
16579 @tab @code{org-texinfo-format-headline-function}
16580 @item @code{:texinfo-format-inlinetask-function}
16581 @tab @code{org-texinfo-format-inlinetask-function}
16582 @item @code{:texinfo-inactive-timestamp-format}
16583 @tab @code{org-texinfo-inactive-timestamp-format}
16584 @item @code{:texinfo-link-with-unknown-path-format}
16585 @tab @code{org-texinfo-link-with-unknown-path-format}
16586 @item @code{:texinfo-node-description-column}
16587 @tab @code{org-texinfo-node-description-column}
16588 @item @code{:texinfo-table-scientific-notation}
16589 @tab @code{org-texinfo-table-scientific-notation}
16590 @item @code{:texinfo-tables-verbatim}
16591 @tab @code{org-texinfo-tables-verbatim}
16592 @item @code{:texinfo-text-markup-alist}
16593 @tab @code{org-texinfo-text-markup-alist}
16594 @end multitable
16596 @node Publishing links
16597 @subsection Publishing links
16599 @cindex links, publishing
16601 To create a link from one Org file to another, you would use something
16602 like @samp{[[file:foo.org][The foo]]} or simply @samp{[[file:foo.org]]} (see @ref{External Links}).  When
16603 published, this link becomes a link to @samp{foo.html}.  You can thus
16604 interlink the pages of your ``Org web'' project and the links will work
16605 as expected when you publish them to HTML.  If you also publish the
16606 Org source file and want to link to it, use an @samp{http} link instead of
16607 a @samp{file:} link, because @samp{file} links are converted to link to the
16608 corresponding @samp{.html} file.
16610 You may also link to related files, such as images.  Provided you are
16611 careful with relative file names, and provided you have also
16612 configured Org to upload the related files, these links will work too.
16613 See @ref{Complex example}, for an example of this
16614 usage.
16616 Eventually, links between published documents can contain some search
16617 options (see @ref{Search Options}), which will be resolved to
16618 the appropriate location in the linked file.  For example, once
16619 published to HTML, the following links all point to a dedicated anchor
16620 in @samp{foo.html}.
16622 @example
16623 [[file:foo.org::*heading]]
16624 [[file:foo.org::#custom-id]]
16625 [[file:foo.org::target]]
16626 @end example
16628 @node Site map
16629 @subsection Generating a sitemap
16631 @cindex sitemap, of published pages
16633 The following properties may be used to control publishing of
16634 a map of files for a given project.
16636 @table @asis
16637 @item @code{:auto-sitemap}
16638 When non-@code{nil}, publish a sitemap during
16639 @code{org-publish-current-project} or @code{org-publish-all}.
16641 @item @code{:sitemap-filename}
16642 Filename for output of sitemap.  Defaults to @samp{sitemap.org}, which
16643 becomes @samp{sitemap.html}.
16645 @item @code{:sitemap-title}
16646 Title of sitemap page.  Defaults to name of file.
16648 @item @code{:sitemap-format-entry}
16649 @findex org-publish-find-date
16650 @findex org-publish-find-property
16651 @findex org-publish-find-title
16652 With this option one can tell how a site-map entry is formatted
16653 in the site-map.  It is a function called with three arguments:
16654 the file or directory name relative to base directory of the
16655 project, the site-map style and the current project.  It is
16656 expected to return a string.  Default value turns file names into
16657 links and use document titles as descriptions.  For specific
16658 formatting needs, one can use @code{org-publish-find-date},
16659 @code{org-publish-find-title} and @code{org-publish-find-property}, to
16660 retrieve additional information about published documents.
16662 @item @code{:sitemap-function}
16663 Plug-in function to use for generation of the sitemap.  It is
16664 called with two arguments: the title of the site-map and
16665 a representation of the files and directories involved in the
16666 project as a nested list, which can further be transformed using
16667 @code{org-list-to-generic}, @code{org-list-to-subtree} and alike.  Default
16668 value generates a plain list of links to all files in the
16669 project.
16671 @item @code{:sitemap-sort-folders}
16672 Where folders should appear in the sitemap.  Set this to @code{first}
16673 (default) or @code{last} to display folders first or last,
16674 respectively.  When set to @code{ignore}, folders are ignored
16675 altogether.  Any other value mixes files and folders.  This
16676 variable has no effect when site-map style is @code{tree}.
16678 @item @code{:sitemap-sort-files}
16679 How the files are sorted in the site map.  Set this to
16680 @code{alphabetically} (default), @code{chronologically} or
16681 @code{anti-chronologically}.  @code{chronologically} sorts the files with
16682 older date first while @code{anti-chronologically} sorts the files
16683 with newer date first.  @code{alphabetically} sorts the files
16684 alphabetically.  The date of a file is retrieved with
16685 @code{org-publish-find-date}.
16687 @item @code{:sitemap-ignore-case}
16688 Should sorting be case-sensitive?  Default @code{nil}.
16690 @item @code{:sitemap-file-entry-format}
16691 With this option one can tell how a sitemap's entry is formatted
16692 in the sitemap.  This is a format string with some escape
16693 sequences: @code{%t} stands for the title of the file, @code{%a} stands for
16694 the author of the file and @code{%d} stands for the date of the file.
16695 The date is retrieved with the @code{org-publish-find-date} function
16696 and formatted with @code{org-publish-sitemap-date-format}.  Default
16697 @code{%t}.
16699 @item @code{:sitemap-date-format}
16700 Format string for the @code{format-time-string} function that tells
16701 how a sitemap entry's date is to be formatted.  This property
16702 bypasses @code{org-publish-sitemap-date-format} which defaults to
16703 @code{%Y-%m-%d}.
16704 @end table
16706 @node Generating an index
16707 @subsection Generating an index
16709 @cindex index, in a publishing project
16711 Org mode can generate an index across the files of a publishing project.
16713 @table @asis
16714 @item @code{:makeindex}
16715 When non-@code{nil}, generate in index in the file @samp{theindex.org} and
16716 publish it as @samp{theindex.html}.
16717 @end table
16719 The file is created when first publishing a project with the
16720 @code{:makeindex} set.  The file only contains a statement @samp{#+INCLUDE:
16721 "theindex.inc"}.  You can then build around this include statement by
16722 adding a title, style information, etc.
16724 @cindex @samp{INDEX}, keyword
16725 Index entries are specified with @samp{INDEX} keyword.  An entry that
16726 contains an exclamation mark creates a sub item.
16728 @example
16729 *** Curriculum Vitae
16730 #+INDEX: CV
16731 #+INDEX: Application!CV
16732 @end example
16734 @node Uploading Files
16735 @section Uploading Files
16737 @cindex rsync
16738 @cindex unison
16740 For those people already utilizing third party sync tools such as
16741 Rsync or Unison, it might be preferable not to use the built-in remote
16742 publishing facilities of Org mode which rely heavily on Tramp.  Tramp,
16743 while very useful and powerful, tends not to be so efficient for
16744 multiple file transfer and has been known to cause problems under
16745 heavy usage.
16747 Specialized synchronization utilities offer several advantages.  In
16748 addition to timestamp comparison, they also do content and
16749 permissions/attribute checks.  For this reason you might prefer to
16750 publish your web to a local directory---possibly even @emph{in place} with
16751 your Org files---and then use Unison or Rsync to do the
16752 synchronization with the remote host.
16754 Since Unison, for example, can be configured as to which files to
16755 transfer to a certain remote destination, it can greatly simplify the
16756 project publishing definition.  Simply keep all files in the correct
16757 location, process your Org files with @code{org-publish} and let the
16758 synchronization tool do the rest.  You do not need, in this scenario,
16759 to include attachments such as JPG, CSS or PNG files in the project
16760 definition since the third-party tool syncs them.
16762 Publishing to a local directory is also much faster than to a remote
16763 one, so that you can afford more easily to republish entire projects.
16764 If you set @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the
16765 main benefit of re-including any changed external files such as source
16766 example files you might include with @samp{INCLUDE} keyword.  The timestamp
16767 mechanism in Org is not smart enough to detect if included files have
16768 been modified.
16770 @node Sample Configuration
16771 @section Sample Configuration
16773 Below we provide two example configurations.  The first one is
16774 a simple project publishing only a set of Org files.  The second
16775 example is more complex, with a multi-component project.
16777 @menu
16778 * Simple example::               One-component publishing.
16779 * Complex example::              A multi-component publishing example.
16780 @end menu
16782 @node Simple example
16783 @subsection Example: simple publishing configuration
16785 This example publishes a set of Org files to the @samp{public_html}
16786 directory on the local machine.
16788 @lisp
16789 (setq org-publish-project-alist
16790       '(("org"
16791          :base-directory "~/org/"
16792          :publishing-directory "~/public_html"
16793          :section-numbers nil
16794          :table-of-contents nil
16795          :style "<link rel=\"stylesheet\"
16796                 href=\"../other/mystyle.css\"
16797                 type=\"text/css\"/>")))
16798 @end lisp
16800 @node Complex example
16801 @subsection Example: complex publishing configuration
16803 This more complicated example publishes an entire website, including
16804 Org files converted to HTML, image files, Emacs Lisp source code, and
16805 style sheets.  The publishing directory is remote and private files
16806 are excluded.
16808 To ensure that links are preserved, care should be taken to replicate
16809 your directory structure on the web server, and to use relative file
16810 paths.  For example, if your Org files are kept in @samp{~/org/} and your
16811 publishable images in @samp{~/images/}, you would link to an image with
16813 @example
16814 file:../images/myimage.png
16815 @end example
16817 On the web server, the relative path to the image should be the same.
16818 You can accomplish this by setting up an @samp{images/} folder in the right
16819 place on the web server, and publishing images to it.
16821 @lisp
16822 (setq org-publish-project-alist
16823       '(("orgfiles"
16824          :base-directory "~/org/"
16825          :base-extension "org"
16826          :publishing-directory "/ssh:user@@host:~/html/notebook/"
16827          :publishing-function org-html-publish-to-html
16828          :exclude "PrivatePage.org" ;; regexp
16829          :headline-levels 3
16830          :section-numbers nil
16831          :with-toc nil
16832          :html-head "<link rel=\"stylesheet\"
16833                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
16834          :html-preamble t)
16836         ("images"
16837          :base-directory "~/images/"
16838          :base-extension "jpg\\|gif\\|png"
16839          :publishing-directory "/ssh:user@@host:~/html/images/"
16840          :publishing-function org-publish-attachment)
16842         ("other"
16843          :base-directory "~/other/"
16844          :base-extension "css\\|el"
16845          :publishing-directory "/ssh:user@@host:~/html/other/"
16846          :publishing-function org-publish-attachment)
16847         ("website" :components ("orgfiles" "images" "other"))))
16848 @end lisp
16850 @node Triggering Publication
16851 @section Triggering Publication
16853 Once properly configured, Org can publish with the following commands:
16855 @table @asis
16856 @item @kbd{C-c C-e X} (@code{org-publish})
16857 @kindex C-c C-e X
16858 @findex org-publish
16859 Prompt for a specific project and publish all files that belong
16860 to it.
16862 @item @kbd{C-c C-e P} (@code{org-publish-current-project})
16863 @kindex C-c C-e P
16864 @findex org-publish-current-project
16865 Publish the project containing the current file.
16867 @item @kbd{C-c C-e F} (@code{org-publish-current-file})
16868 @kindex C-c C-e F
16869 @findex org-publish-current-file
16870 Publish only the current file.
16872 @item @kbd{C-c C-e E} (@code{org-publish-all})
16873 @kindex C-c C-e E
16874 @findex org-publish-all
16875 Publish every project.
16876 @end table
16878 @vindex org-publish-use-timestamps-flag
16879 Org uses timestamps to track when a file has changed.  The above
16880 functions normally only publish changed files.  You can override this
16881 and force publishing of all files by giving a prefix argument to any
16882 of the commands above, or by customizing the variable
16883 @code{org-publish-use-timestamps-flag}.  This may be necessary in
16884 particular if files include other files via @samp{SETUPFILE} or @samp{INCLUDE}
16885 keywords.
16887 @node Working with Source Code
16888 @chapter Working with Source Code
16890 @cindex source code, working with
16892 Source code here refers to any plain text collection of computer
16893 instructions, possibly with comments, written using a human-readable
16894 programming language.  Org can manage source code in an Org document
16895 when the source code is identified with begin and end markers.
16896 Working with source code begins with identifying source code blocks.
16897 A source code block can be placed almost anywhere in an Org document;
16898 it is not restricted to the preamble or the end of the document.
16899 However, Org cannot manage a source code block if it is placed inside
16900 an Org comment or within a fixed width section.
16902 Here is an example source code block in the Emacs Lisp language:
16904 @example
16905 #+BEGIN_SRC emacs-lisp
16906   (defun org-xor (a b)
16907      "Exclusive or."
16908      (if a (not b) b))
16909 #+END_SRC
16910 @end example
16912 Org can manage the source code in the block delimited by @samp{#+BEGIN_SRC}
16913 @dots{} @samp{#+END_SRC} in several ways that can simplify housekeeping tasks
16914 essential to modern source code maintenance.  Org can edit, format,
16915 extract, export, and publish source code blocks.  Org can also compile
16916 and execute a source code block, then capture the results.  The Org
16917 mode literature sometimes refers to source code blocks as @emph{live code}
16918 blocks because they can alter the content of the Org document or the
16919 material that it exports.  Users can control how live they want each
16920 source code block by tweaking the header arguments (see @ref{Using Header Arguments}) for compiling, execution, extraction, and
16921 exporting.
16923 Source code blocks are one of many Org block types, which also include
16924 @samp{quote}, @samp{export}, @samp{verse}, @samp{latex}, @samp{example}, and @samp{verbatim}.  This
16925 section pertains to blocks between @samp{#+BEGIN_SRC} and @samp{#+END_SRC}.
16927 For editing and formatting a source code block, Org uses an
16928 appropriate Emacs major mode that includes features specifically
16929 designed for source code in that language.
16931 Org can extract one or more source code blocks and write them to one
16932 or more source files---a process known as @emph{tangling} in literate
16933 programming terminology.
16935 For exporting and publishing, Org's back-ends can format a source code
16936 block appropriately, often with native syntax highlighting.
16938 For executing and compiling a source code block, the user can
16939 configure Org to select the appropriate compiler.  Org provides
16940 facilities to collect the result of the execution or compiler output,
16941 insert it into the Org document, and/or export it.  In addition to
16942 text results, Org can insert links to other data types, including
16943 audio, video, and graphics.  Org can also link a compiler error
16944 message to the appropriate line in the source code block.
16946 An important feature of Org's management of source code blocks is the
16947 ability to pass variables, functions, and results to one another using
16948 a common syntax for source code blocks in any language.  Although most
16949 literate programming facilities are restricted to one language or
16950 another, Org's language-agnostic approach lets the literate programmer
16951 match each programming task with the appropriate computer language and
16952 to mix them all together in a single Org document.  This
16953 interoperability among languages explains why Org's source code
16954 management facility was named @emph{Org Babel} by its originators, Eric
16955 Schulte and Dan Davison.
16957 Org mode fulfills the promise of easy verification and maintenance of
16958 publishing reproducible research by keeping text, data, code,
16959 configuration settings of the execution environment, the results of
16960 the execution, and associated narratives, claims, references, and
16961 internal and external links in a single Org document.
16963 Details of Org's facilities for working with source code are described
16964 in the following sections.
16966 @menu
16967 * Structure of Code Blocks::     Code block syntax described.
16968 * Using Header Arguments::       Different ways to set header arguments.
16969 * Environment of a Code Block::  Arguments, sessions, working directory...
16970 * Evaluating Code Blocks::       Place results of evaluation in the Org buffer.
16971 * Results of Evaluation::        Choosing a results type, post-processing...
16972 * Exporting Code Blocks::        Export contents and/or results.
16973 * Extracting Source Code::       Create pure source code files.
16974 * Languages::                    List of supported code block languages.
16975 * Editing Source Code::          Language major-mode editing.
16976 * Noweb Reference Syntax::       Literate programming in Org mode.
16977 * Library of Babel::             Use and contribute to a library of useful code blocks.
16978 * Key bindings and Useful Functions:: Work quickly with code blocks.
16979 * Batch Execution::              Call functions from the command line.
16980 @end menu
16982 @node Structure of Code Blocks
16983 @section Structure of Code Blocks
16985 @cindex code block, structure
16986 @cindex source code, block structure
16987 @cindex @samp{NAME} keyword, in source blocks
16988 @cindex @samp{BEGIN_SRC}
16990 Org offers two ways to structure source code in Org documents: in
16991 a source code block, and directly inline.  Both specifications are
16992 shown below.
16994 A source code block conforms to this structure:
16996 @example
16997 #+NAME: <name>
16998 #+BEGIN_SRC <language> <switches> <header arguments>
16999   <body>
17000 #+END_SRC
17001 @end example
17003 Do not be put-off by having to remember the source block syntax.  Org
17004 mode offers a command for wrapping existing text in a block (see
17005 @ref{Structure Templates}).  Org also works with other completion systems
17006 in Emacs, some of which predate Org and have custom domain-specific
17007 languages for defining templates.  Regular use of templates reduces
17008 errors, increases accuracy, and maintains consistency.
17010 @cindex source code, inline
17011 An inline code block conforms to this structure:
17013 @example
17014 src_<language>@{<body>@}
17015 @end example
17017 @noindent
17020 @example
17021 src_<language>[<header arguments>]@{<body>@}
17022 @end example
17024 @table @asis
17025 @item @samp{#+NAME: <name>}
17026 Optional.  Names the source block so it can be called, like
17027 a function, from other source blocks or inline code to evaluate
17028 or to capture the results.  Code from other blocks, other files,
17029 and from table formulas (see @ref{The spreadsheet}) can use the name
17030 to reference a source block.  This naming serves the same purpose
17031 as naming Org tables.  Org mode requires unique names.  For
17032 duplicate names, Org mode's behavior is undefined.
17034 @item @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}
17035 Mandatory.  They mark the start and end of a block that Org
17036 requires.  The @samp{#+BEGIN_SRC} line takes additional arguments, as
17037 described next.
17039 @item @samp{<language>}
17040 @cindex language, in code blocks
17041 Mandatory.  It is the identifier of the source code language in
17042 the block.  See @ref{Languages}, for identifiers of supported
17043 languages.
17045 @item @samp{<switches>}
17046 @cindex switches, in code blocks
17047 Optional.  Switches provide finer control of the code execution,
17048 export, and format (see the discussion of switches in @ref{Literal Examples}).
17050 @item @samp{<header arguments>}
17051 @cindex header arguments, in code blocks
17052 Optional.  Heading arguments control many aspects of evaluation,
17053 export and tangling of code blocks (see @ref{Using Header Arguments}).
17054 Using Org's properties feature, header arguments can be
17055 selectively applied to the entire buffer or specific sub-trees of
17056 the Org document.
17058 @item @samp{<body>}
17059 Source code in the dialect of the specified language identifier.
17060 @end table
17062 @node Using Header Arguments
17063 @section Using Header Arguments
17065 Org comes with many header arguments common to all languages.  New
17066 header arguments are added for specific languages as they become
17067 available for use in source code blocks.  A header argument is
17068 specified with an initial colon followed by the argument's name in
17069 lowercase.
17071 Since header arguments can be set in several ways, Org prioritizes
17072 them in case of overlaps or conflicts by giving local settings
17073 a higher priority.  Header values in function calls, for example,
17074 override header values from global defaults.
17076 @anchor{System-wide header arguments}
17077 @subheading System-wide header arguments
17079 @vindex org-babel-default-header-args
17081 @vindex org-babel-default-header-args
17082 System-wide values of header arguments can be specified by customizing
17083 the @code{org-babel-default-header-args} variable, which defaults to the
17084 following values:
17086 @example
17087 :session    => "none"
17088 :results    => "replace"
17089 :exports    => "code"
17090 :cache      => "no"
17091 :noweb      => "no"
17092 @end example
17094 The example below sets @samp{:noweb} header arguments to @samp{yes}, which makes
17095 Org expand @samp{:noweb} references by default.
17097 @lisp
17098 (setq org-babel-default-header-args
17099       (cons '(:noweb . "yes")
17100             (assq-delete-all :noweb org-babel-default-header-args)))
17101 @end lisp
17103 @cindex language specific default header arguments
17104 @cindex default header arguments per language
17105 Each language can have separate default header arguments by
17106 customizing the variable @code{org-babel-default-header-args:<LANG>}, where
17107 @var{<LANG>} is the name of the language.  For details, see the
17108 language-specific online documentation at
17109 @uref{https://orgmode.org/worg/org-contrib/babel/}.
17111 @anchor{Header arguments in Org mode properties}
17112 @subheading Header arguments in Org mode properties
17114 For header arguments applicable to the buffer, use @samp{PROPERTY} keyword
17115 anywhere in the Org file (see @ref{Property Syntax}).
17117 The following example makes all the R code blocks execute in the same
17118 session.  Setting @samp{:results} to @samp{silent} ignores the results of
17119 executions for all blocks, not just R code blocks; no results inserted
17120 for any block.
17122 @example
17123 #+PROPERTY: header-args:R  :session *R*
17124 #+PROPERTY: header-args    :results silent
17125 @end example
17127 @vindex org-use-property-inheritance
17128 Header arguments set through Org's property drawers (see @ref{Property Syntax}) apply at the sub-tree level on down.  Since these property
17129 drawers can appear anywhere in the file hierarchy, Org uses outermost
17130 call or source block to resolve the values.  Org ignores
17131 @code{org-use-property-inheritance} setting.
17133 In this example, @samp{:cache} defaults to @samp{yes} for all code blocks in the
17134 sub-tree.
17136 @example
17137 * sample header
17138   :PROPERTIES:
17139   :header-args:    :cache yes
17140   :END:
17141 @end example
17143 @kindex C-c C-x p
17144 @findex org-set-property
17145 Properties defined through @code{org-set-property} function, bound to
17146 @kbd{C-c C-x p}, apply to all active languages.  They override
17147 properties set in @code{org-babel-default-header-args}.
17149 @cindex language specific header arguments properties
17150 @cindex header arguments per language
17151 Language-specific header arguments are also read from properties
17152 @samp{header-args:<LANG>} where @var{<LANG>} is the language
17153 identifier.  For example,
17155 @example
17156 * Heading
17157   :PROPERTIES:
17158   :header-args:clojure:    :session *clojure-1*
17159   :header-args:R:          :session *R*
17160   :END:
17161 ** Subheading
17162   :PROPERTIES:
17163   :header-args:clojure:    :session *clojure-2*
17164   :END:
17165 @end example
17167 @noindent
17168 would force separate sessions for Clojure blocks in @samp{Heading} and
17169 @samp{Subheading}, but use the same session for all R blocks.  Blocks in
17170 @samp{Subheading} inherit settings from @samp{Heading}.
17172 @anchor{Code block specific header arguments}
17173 @subheading Code block specific header arguments
17175 Header arguments are most commonly set at the source code block level,
17176 on the @samp{#+BEGIN_SRC} line.  Arguments set at this level take
17177 precedence over those set in the @code{org-babel-default-header-args}
17178 variable, and also those set as header properties.
17180 In the following example, setting @samp{:results} to @samp{silent} makes it
17181 ignore results of the code execution.  Setting @samp{:exports} to @samp{code}
17182 exports only the body of the code block to HTML or @LaTeX{}.
17184 @example
17185 #+NAME: factorial
17186 #+BEGIN_SRC haskell :results silent :exports code :var n=0
17187   fac 0 = 1
17188   fac n = n * fac (n-1)
17189 #+END_SRC
17190 @end example
17192 The same header arguments in an inline code block:
17194 @example
17195 src_haskell[:exports both]@{fac 5@}
17196 @end example
17198 @cindex @samp{HEADER}, keyword
17199 Code block header arguments can span multiple lines using @samp{#+HEADER:}
17200 on each line.  Note that Org currently accepts the plural spelling of
17201 @samp{#+HEADER:} only as a convenience for backward-compatibility.  It may
17202 be removed at some point.
17204 Multi-line header arguments on an unnamed code block:
17206 @example
17207 #+HEADER: :var data1=1
17208 #+BEGIN_SRC emacs-lisp :var data2=2
17209    (message "data1:%S, data2:%S" data1 data2)
17210 #+END_SRC
17212 #+RESULTS:
17213 : data1:1, data2:2
17214 @end example
17216 Multi-line header arguments on a named code block:
17218 @example
17219 #+NAME: named-block
17220 #+HEADER: :var data=2
17221 #+BEGIN_SRC emacs-lisp
17222   (message "data:%S" data)
17223 #+END_SRC
17225 #+RESULTS: named-block
17226   : data:2
17227 @end example
17229 @anchor{Header arguments in function calls}
17230 @subheading Header arguments in function calls
17232 Header arguments in function calls are the most specific and override
17233 all other settings in case of an overlap.  They get the highest
17234 priority.  Two @samp{#+CALL:} examples are shown below.  For the complete
17235 syntax of @samp{CALL} keyword, see @ref{Evaluating Code Blocks}.
17237 In this example, @samp{:exports results} header argument is applied to the
17238 evaluation of the @samp{#+CALL:} line.
17240 @example
17241 #+CALL: factorial(n=5) :exports results
17242 @end example
17244 In this example, @samp{:session special} header argument is applied to the
17245 evaluation of @samp{factorial} code block.
17247 @example
17248 #+CALL: factorial[:session special](n=5)
17249 @end example
17251 @node Environment of a Code Block
17252 @section Environment of a Code Block
17256 @anchor{Passing arguments}
17257 @subheading Passing arguments
17259 @cindex passing arguments to code blocks
17260 @cindex arguments, in code blocks
17261 @cindex @samp{var}, header argument
17262 Use @samp{var} for passing arguments to source code blocks.  The specifics
17263 of variables in code blocks vary by the source language and are
17264 covered in the language-specific documentation.  The syntax for @samp{var},
17265 however, is the same for all languages.  This includes declaring
17266 a variable, and assigning a default value.
17268 The following syntax is used to pass arguments to code blocks using
17269 the @samp{var} header argument.
17271 @example
17272 :var NAME=ASSIGN
17273 @end example
17275 @noindent
17276 @var{NAME} is the name of the variable bound in the code block
17277 body.  @var{ASSIGN} is a literal value, such as a string,
17278 a number, a reference to a table, a list, a literal example, another
17279 code block---with or without arguments---or the results of evaluating
17280 a code block.
17282 Here are examples of passing values by reference:
17284 @table @asis
17285 @item table
17286 A table named with a @samp{NAME} keyword.
17288 @example
17289 #+NAME: example-table
17290 | 1 |
17291 | 2 |
17292 | 3 |
17293 | 4 |
17295 #+NAME: table-length
17296 #+BEGIN_SRC emacs-lisp :var table=example-table
17297   (length table)
17298 #+END_SRC
17300 #+RESULTS: table-length
17301 : 4
17302 @end example
17304 When passing a table, you can treat specially the row, or the
17305 column, containing labels for the columns, or the rows, in the
17306 table.
17308 @cindex @samp{colnames}, header argument
17309 The @samp{colnames} header argument accepts @samp{yes}, @samp{no}, or @samp{nil}
17310 values.  The default value is @samp{nil}: if an input table has column
17311 names---because the second row is a horizontal rule---then Org
17312 removes the column names, processes the table, puts back the
17313 column names, and then writes the table to the results block.
17314 Using @samp{yes}, Org does the same to the first row, even if the
17315 initial table does not contain any horizontal rule.  When set to
17316 @samp{no}, Org does not pre-process column names at all.
17318 @example
17319 #+NAME: less-cols
17320 | a |
17321 |---|
17322 | b |
17323 | c |
17325 #+BEGIN_SRC python :var tab=less-cols :colnames nil
17326   return [[val + '*' for val in row] for row in tab]
17327 #+END_SRC
17329 #+RESULTS:
17330 | a  |
17331 |----|
17332 | b* |
17333 | c* |
17334 @end example
17336 @cindex @samp{rownames}, header argument
17337 Similarly, the @samp{rownames} header argument can take two values:
17338 @samp{yes} or @samp{no}.  When set to @samp{yes}, Org removes the first column,
17339 processes the table, puts back the first column, and then writes
17340 the table to the results block.  The default is @samp{no}, which means
17341 Org does not pre-process the first column.  Note that Emacs Lisp
17342 code blocks ignore @samp{rownames} header argument because of the ease
17343 of table-handling in Emacs.
17345 @example
17346 #+NAME: with-rownames
17347 | one | 1 | 2 | 3 | 4 |  5 |
17348 | two | 6 | 7 | 8 | 9 | 10 |
17350 #+BEGIN_SRC python :var tab=with-rownames :rownames yes
17351   return [[val + 10 for val in row] for row in tab]
17352 #+END_SRC
17354 #+RESULTS:
17355 | one | 11 | 12 | 13 | 14 | 15 |
17356 | two | 16 | 17 | 18 | 19 | 20 |
17357 @end example
17359 @item list
17360 A simple named list.
17362 @example
17363 #+NAME: example-list
17364 - simple
17365   - not
17366   - nested
17367 - list
17369 #+BEGIN_SRC emacs-lisp :var x=example-list
17370   (print x)
17371 #+END_SRC
17373 #+RESULTS:
17374 | simple | list |
17375 @end example
17377 Note that only the top level list items are passed along.  Nested
17378 list items are ignored.
17380 @item code block without arguments
17381 A code block name, as assigned by @samp{NAME} keyword from the example
17382 above, optionally followed by parentheses.
17384 @example
17385 #+BEGIN_SRC emacs-lisp :var length=table-length()
17386   (* 2 length)
17387 #+END_SRC
17389 #+RESULTS:
17390 : 8
17391 @end example
17393 @item code block with arguments
17394 A code block name, as assigned by @samp{NAME} keyword, followed by
17395 parentheses and optional arguments passed within the parentheses.
17397 @example
17398 #+NAME: double
17399 #+BEGIN_SRC emacs-lisp :var input=8
17400   (* 2 input)
17401 #+END_SRC
17403 #+RESULTS: double
17404 : 16
17406 #+NAME: squared
17407 #+BEGIN_SRC emacs-lisp :var input=double(input=1)
17408   (* input input)
17409 #+END_SRC
17411 #+RESULTS: squared
17412 : 4
17413 @end example
17415 @item literal example
17416 A literal example block named with a @samp{NAME} keyword.
17418 @example
17419 #+NAME: literal-example
17420 #+BEGIN_EXAMPLE
17421   A literal example
17422   on two lines
17423 #+END_EXAMPLE
17425 #+NAME: read-literal-example
17426 #+BEGIN_SRC emacs-lisp :var x=literal-example
17427   (concatenate #'string x " for you.")
17428 #+END_SRC
17430 #+RESULTS: read-literal-example
17431 : A literal example
17432 : on two lines for you.
17433 @end example
17434 @end table
17436 Indexing variable values enables referencing portions of a variable.
17437 Indexes are 0 based with negative values counting backwards from the
17438 end.  If an index is separated by commas then each subsequent section
17439 indexes as the next dimension.  Note that this indexing occurs
17440 @emph{before} other table-related header arguments are applied, such as
17441 @samp{hlines}, @samp{colnames} and @samp{rownames}.  The following example assigns
17442 the last cell of the first row the table @samp{example-table} to the
17443 variable @samp{data}:
17445 @example
17446 #+NAME: example-table
17447 | 1 | a |
17448 | 2 | b |
17449 | 3 | c |
17450 | 4 | d |
17452 #+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
17453   data
17454 #+END_SRC
17456 #+RESULTS:
17457 : a
17458 @end example
17460 Two integers separated by a colon reference a range of variable
17461 values.  In that case the entire inclusive range is referenced.  For
17462 example the following assigns the middle three rows of @samp{example-table}
17463 to @samp{data}.
17465 @example
17466 #+NAME: example-table
17467 | 1 | a |
17468 | 2 | b |
17469 | 3 | c |
17470 | 4 | d |
17471 | 5 | 3 |
17473 #+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
17474   data
17475 #+END_SRC
17477 #+RESULTS:
17478 | 2 | b |
17479 | 3 | c |
17480 | 4 | d |
17481 @end example
17483 To pick the entire range, use an empty index, or the single character
17484 @samp{*}.  @samp{0:-1} does the same thing.  Example below shows how to
17485 reference the first column only.
17487 @example
17488 #+NAME: example-table
17489 | 1 | a |
17490 | 2 | b |
17491 | 3 | c |
17492 | 4 | d |
17494 #+BEGIN_SRC emacs-lisp :var data=example-table[,0]
17495   data
17496 #+END_SRC
17498 #+RESULTS:
17499 | 1 | 2 | 3 | 4 |
17500 @end example
17502 Index referencing can be used for tables and code blocks.  Index
17503 referencing can handle any number of dimensions.  Commas delimit
17504 multiple dimensions, as shown below.
17506 @example
17507 #+NAME: 3D
17508 #+BEGIN_SRC emacs-lisp
17509   '(((1  2  3)  (4  5  6)  (7  8  9))
17510     ((10 11 12) (13 14 15) (16 17 18))
17511     ((19 20 21) (22 23 24) (25 26 27)))
17512 #+END_SRC
17514 #+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
17515   data
17516 #+END_SRC
17518 #+RESULTS:
17519 | 11 | 14 | 17 |
17520 @end example
17522 Note that row names and column names are not removed prior to variable
17523 indexing.  You need to take them into account, even when @samp{colnames} or
17524 @samp{rownames} header arguments remove them.
17526 Emacs lisp code can also set the values for variables.  To
17527 differentiate a value from Lisp code, Org interprets any value
17528 starting with @samp{(}, @samp{[}, @samp{'} or @samp{`} as Emacs Lisp code.  The result of
17529 evaluating that code is then assigned to the value of that variable.
17530 The following example shows how to reliably query and pass the file
17531 name of the Org mode buffer to a code block using headers.  We need
17532 reliability here because the file's name could change once the code in
17533 the block starts executing.
17535 @example
17536 #+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
17537   wc -w $filename
17538 #+END_SRC
17539 @end example
17541 Note that values read from tables and lists are not mistakenly
17542 evaluated as Emacs Lisp code, as illustrated in the following example.
17544 @example
17545 #+NAME: table
17546 | (a b c) |
17548 #+HEADER: :var data=table[0,0]
17549 #+BEGIN_SRC perl
17550   $data
17551 #+END_SRC
17553 #+RESULTS:
17554 : (a b c)
17555 @end example
17557 @anchor{Using sessions}
17558 @subheading Using sessions
17560 @cindex using sessions in code blocks
17561 @cindex @samp{session}, header argument
17562 Two code blocks can share the same environment.  The @samp{session} header
17563 argument is for running multiple source code blocks under one session.
17564 Org runs code blocks with the same session name in the same
17565 interpreter process.
17567 @table @asis
17568 @item @samp{none}
17569 Default.  Each code block gets a new interpreter process to
17570 execute.  The process terminates once the block is evaluated.
17572 @item @var{STRING}
17573 Any string besides @samp{none} turns that string into the name of that
17574 session.  For example, @samp{:session STRING} names it @samp{STRING}.  If
17575 @samp{session} has no value, then the session name is derived from the
17576 source language identifier.  Subsequent blocks with the same
17577 source code language use the same session.  Depending on the
17578 language, state variables, code from other blocks, and the
17579 overall interpreted environment may be shared.  Some interpreted
17580 languages support concurrent sessions when subsequent source code
17581 language blocks change session names.
17582 @end table
17584 Only languages that provide interactive evaluation can have session
17585 support.  Not all languages provide this support, such as C and ditaa.
17586 Even languages, such as Python and Haskell, that do support
17587 interactive evaluation impose limitations on allowable language
17588 constructs that can run interactively.  Org inherits those limitations
17589 for those code blocks running in a session.
17591 @anchor{Choosing a working directory}
17592 @subheading Choosing a working directory
17594 @cindex working directory, in a code block
17595 @cindex @samp{dir}, header argument
17596 The @samp{dir} header argument specifies the default directory during code
17597 block execution.  If it is absent, then the directory associated with
17598 the current buffer is used.  In other words, supplying @samp{:dir PATH}
17599 temporarily has the same effect as changing the current directory with
17600 @kbd{M-x cd PATH}, and then not setting @samp{dir}.  Under the
17601 surface, @samp{dir} simply sets the value of the Emacs variable
17602 @code{default-directory}.
17604 For example, to save the plot file in the @samp{Work/} folder of the home
17605 directory---notice tilde is expanded:
17607 @example
17608 #+BEGIN_SRC R :file myplot.png :dir ~/Work
17609   matplot(matrix(rnorm(100), 10), type="l")
17610 #+END_SRC
17611 @end example
17613 To evaluate the code block on a remote machine, supply a remote
17614 directory name using Tramp syntax.  For example:
17616 @example
17617 #+BEGIN_SRC R :file plot.png :dir /scp:dand@@yakuba.princeton.edu:
17618   plot(1:10, main=system("hostname", intern=TRUE))
17619 #+END_SRC
17620 @end example
17622 Org first captures the text results as usual for insertion in the Org
17623 file.  Then Org also inserts a link to the remote file, thanks to
17624 Emacs Tramp.  Org constructs the remote path to the file name from
17625 @samp{dir} and @code{default-directory}, as illustrated here:
17627 @example
17628 [[file:/scp:dand@@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
17629 @end example
17631 When @samp{dir} is used with @samp{session}, Org sets the starting directory for
17632 a new session.  But Org does not alter the directory of an already
17633 existing session.
17635 Do not use @samp{dir} with @samp{:exports results} or with @samp{:exports both} to
17636 avoid Org inserting incorrect links to remote files.  That is because
17637 Org does not expand @code{default directory} to avoid some underlying
17638 portability issues.
17640 @anchor{Inserting headers and footers}
17641 @subheading Inserting headers and footers
17643 @cindex headers, in code blocks
17644 @cindex footers, in code blocks
17645 @cindex @samp{prologue}, header argument
17646 The @samp{prologue} header argument is for appending to the top of the code
17647 block for execution, like a reset instruction.  For example, you may
17648 use @samp{:prologue "reset"} in a Gnuplot code block or, for every such
17649 block:
17651 @lisp
17652 (add-to-list 'org-babel-default-header-args:gnuplot
17653              '((:prologue . "reset")))
17655 @end lisp
17657 @cindex @samp{epilogue}, header argument
17658 Likewise, the value of the @samp{epilogue} header argument is for appending
17659 to the end of the code block for execution.
17661 @node Evaluating Code Blocks
17662 @section Evaluating Code Blocks
17664 @cindex code block, evaluating
17665 @cindex source code, evaluating
17666 @cindex @samp{RESULTS}, keyword
17668 A note about security: With code evaluation comes the risk of harm.
17669 Org safeguards by prompting for user's permission before executing any
17670 code in the source block.  To customize this safeguard, or disable it,
17671 see @ref{Code Evaluation Security}.
17673 @anchor{How to evaluate source code}
17674 @subheading How to evaluate source code
17676 Org captures the results of the code block evaluation and inserts them
17677 in the Org file, right after the code block.  The insertion point is
17678 after a newline and the @samp{RESULTS} keyword.  Org creates the @samp{RESULTS}
17679 keyword if one is not already there.
17681 By default, Org enables only Emacs Lisp code blocks for execution.
17682 See @ref{Languages} to enable other languages.
17684 @kindex C-c C-c
17685 @kindex C-c C-v e
17686 @findex org-babel-execute-src-block
17687 Org provides many ways to execute code blocks.  @kbd{C-c C-c} or
17688 @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
17689 to remove code evaluation from the @kbd{C-c C-c} key binding.} calls the
17690 @code{org-babel-execute-src-block} function, which executes the code in the
17691 block, collects the results, and inserts them in the buffer.
17693 @cindex @samp{CALL}, keyword
17694 @vindex org-babel-inline-result-wrap
17695 By calling a named code block@footnote{Actually, the constructs @samp{call_<name>()} and @samp{src_<lang>@{@}}
17696 are not evaluated when they appear in a keyword line---i.e. lines
17697 starting with @samp{#+KEYWORD:}, see @ref{In-buffer Settings}.} from an Org mode buffer or
17698 a table.  Org can call the named code blocks from the current Org mode
17699 buffer or from the ``Library of Babel'' (see @ref{Library of Babel}).
17701 The syntax for @samp{CALL} keyword is:
17703 @example
17704 #+CALL: <name>(<arguments>)
17705 #+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
17706 @end example
17708 The syntax for inline named code blocks is:
17710 @example
17711 ... call_<name>(<arguments>) ...
17712 ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
17713 @end example
17715 When inline syntax is used, the result is wrapped based on the
17716 variable @code{org-babel-inline-result-wrap}, which by default is set to
17717 @code{"=%s="} to produce verbatim text suitable for markup.
17719 @table @asis
17720 @item @samp{<name>}
17721 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
17722 located in another file, start @samp{<name>} with the file name
17723 followed by a colon. For example, in order to execute a block
17724 named @samp{clear-data} in @samp{file.org}, you can write the following:
17726 @example
17727 #+CALL: file.org:clear-data()
17728 @end example
17730 @item @samp{<arguments>}
17731 Org passes arguments to the code block using standard function
17732 call syntax.  For example, a @samp{#+CALL:} line that passes @samp{4} to
17733 a code block named @samp{double}, which declares the header argument
17734 @samp{:var n=2}, would be written as:
17736 @example
17737 #+CALL: double(n=4)
17738 @end example
17740 @noindent
17741 Note how this function call syntax is different from the header
17742 argument syntax.
17744 @item @samp{<inside header arguments>}
17745 Org passes inside header arguments to the named code block using
17746 the header argument syntax.  Inside header arguments apply to
17747 code block evaluation.  For example, @samp{[:results output]} collects
17748 results printed to stdout during code execution of that block.
17749 Note how this header argument syntax is different from the
17750 function call syntax.
17752 @item @samp{<end header arguments>}
17753 End header arguments affect the results returned by the code
17754 block.  For example, @samp{:results html} wraps the results in
17755 a @samp{#+BEGIN_EXPORT html} block before inserting the results in the
17756 Org buffer.
17757 @end table
17759 @anchor{Limit code block evaluation}
17760 @subheading Limit code block evaluation
17762 @cindex @samp{eval}, header argument
17763 @cindex control code block evaluation
17764 The @samp{eval} header argument can limit evaluation of specific code
17765 blocks and @samp{CALL} keyword.  It is useful for protection against
17766 evaluating untrusted code blocks by prompting for a confirmation.
17768 @table @asis
17769 @item @samp{never} or @samp{no}
17770 Org never evaluates the source code.
17772 @item @samp{query}
17773 Org prompts the user for permission to evaluate the source code.
17775 @item @samp{never-export} or @samp{no-export}
17776 Org does not evaluate the source code when exporting, yet the
17777 user can evaluate it interactively.
17779 @item @samp{query-export}
17780 Org prompts the user for permission to evaluate the source code
17781 during export.
17782 @end table
17784 If @samp{eval} header argument is not set, then Org determines whether to
17785 evaluate the source code from the @code{org-confirm-babel-evaluate}
17786 variable (see @ref{Code Evaluation Security}).
17788 @anchor{Cache results of evaluation}
17789 @subheading Cache results of evaluation
17791 @cindex @samp{cache}, header argument
17792 @cindex cache results of code evaluation
17793 The @samp{cache} header argument is for caching results of evaluating code
17794 blocks.  Caching results can avoid re-evaluating a code block that
17795 have not changed since the previous run.  To benefit from the cache
17796 and avoid redundant evaluations, the source block must have a result
17797 already present in the buffer, and neither the header
17798 arguments---including the value of @samp{var} references---nor the text of
17799 the block itself has changed since the result was last computed.  This
17800 feature greatly helps avoid long-running calculations.  For some edge
17801 cases, however, the cached results may not be reliable.
17803 The caching feature is best for when code blocks are pure functions,
17804 that is functions that return the same value for the same input
17805 arguments (see @ref{Environment of a Code Block}), and that do not have
17806 side effects, and do not rely on external variables other than the
17807 input arguments.  Functions that depend on a timer, file system
17808 objects, and random number generators are clearly unsuitable for
17809 caching.
17811 A note of warning: when @samp{cache} is used in a session, caching may
17812 cause unexpected results.
17814 When the caching mechanism tests for any source code changes, it does
17815 not expand Noweb style references (see @ref{Noweb Reference Syntax}).  For
17816 reasons why, see @uref{http://thread.gmane.org/gmane.emacs.orgmode/79046}.
17818 The @samp{cache} header argument can have one of two values: @samp{yes} or @samp{no}.
17820 @table @asis
17821 @item @samp{no}
17822 Default.  No caching of results; code block evaluated every
17823 time.
17825 @item @samp{yes}
17826 Whether to run the code or return the cached results is
17827 determined by comparing the SHA1 hash value of the combined code
17828 block and arguments passed to it.  This hash value is packed on
17829 the @samp{#+RESULTS:} line from previous evaluation.  When hash values
17830 match, Org does not evaluate the code block.  When hash values
17831 mismatch, Org evaluates the code block, inserts the results,
17832 recalculates the hash value, and updates @samp{#+RESULTS:} line.
17833 @end table
17835 In this example, both functions are cached.  But @samp{caller} runs only if
17836 the result from @samp{random} has changed since the last run.
17838 @example
17839 #+NAME: random
17840 #+BEGIN_SRC R :cache yes
17841   runif(1)
17842 #+END_SRC
17844 #+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
17845 0.4659510825295
17847 #+NAME: caller
17848 #+BEGIN_SRC emacs-lisp :var x=random :cache yes
17849   x
17850 #+END_SRC
17852 #+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
17853 0.254227238707244
17854 @end example
17856 @node Results of Evaluation
17857 @section Results of Evaluation
17859 @cindex code block, results of evaluation
17860 @cindex source code, results of evaluation
17862 @cindex @samp{results}, header argument
17863 How Org handles results of a code block execution depends on many
17864 header arguments working together.  The primary determinant, however,
17865 is the @samp{results} header argument.  It accepts four classes of options.
17866 Each code block can take only one option per class:
17868 @table @asis
17869 @item collection
17870 For how the results should be collected from the code block;
17872 @item type
17873 For which type of result the code block will return; affects how
17874 Org processes and inserts results in the Org buffer;
17876 @item format
17877 For the result; affects how Org processes and inserts results in
17878 the Org buffer;
17880 @item handling
17881 For processing results after evaluation of the code block;
17882 @end table
17884 @anchor{Collection}
17885 @subheading Collection
17887 Collection options specify the results.  Choose one of the options;
17888 they are mutually exclusive.
17890 @table @asis
17891 @item @samp{value}
17892 Default.  Functional mode.  Org gets the value by wrapping the
17893 code in a function definition in the language of the source
17894 block.  That is why when using @samp{:results value}, code should
17895 execute like a function and return a value.  For languages like
17896 Python, an explicit @code{return} statement is mandatory when using
17897 @samp{:results value}.  Result is the value returned by the last
17898 statement in the code block.
17900 When evaluating the code block in a session (see @ref{Environment of a Code Block}), Org passes the code to an interpreter running as
17901 an interactive Emacs inferior process. Org gets the value from
17902 the source code interpreter's last statement output.  Org has to
17903 use language-specific methods to obtain the value.  For example,
17904 from the variable @code{_} in Python and Ruby, and the value of
17905 @code{.Last.value} in R.
17907 @item @samp{output}
17908 Scripting mode.  Org passes the code to an external process
17909 running the interpreter.  Org returns the contents of the
17910 standard output stream as text results.
17912 When using a session, Org passes the code to the interpreter
17913 running as an interactive Emacs inferior process.  Org
17914 concatenates any text output from the interpreter and returns the
17915 collection as a result.
17917 Note that this collection is not the same as that would be
17918 collected from stdout of a non-interactive interpreter running as
17919 an external process.  Compare for example these two blocks:
17921 @example
17922 #+BEGIN_SRC python :results output
17923   print "hello"
17924   2
17925   print "bye"
17926 #+END_SRC
17928 #+RESULTS:
17929 : hello
17930 : bye
17931 @end example
17933 In the above non-session mode, the ``2'' is not printed; so it does
17934 not appear in results.
17936 @example
17937 #+BEGIN_SRC python :results output :session
17938   print "hello"
17939   2
17940   print "bye"
17941 #+END_SRC
17943 #+RESULTS:
17944 : hello
17945 : 2
17946 : bye
17947 @end example
17949 In the above session, the interactive interpreter receives and
17950 prints ``2''.  Results show that.
17951 @end table
17953 @anchor{Type}
17954 @subheading Type
17956 Type tells what result types to expect from the execution of the code
17957 block.  Choose one of the options; they are mutually exclusive.  The
17958 default behavior is to automatically determine the result type.
17960 @table @asis
17961 @item @samp{table}
17962 @itemx @samp{vector}
17963 Interpret the results as an Org table.  If the result is a single
17964 value, create a table with one row and one column.  Usage
17965 example: @samp{:results value table}.
17967 @cindex @samp{hlines}, header argument
17968 In-between each table row or below the table headings, sometimes
17969 results have horizontal lines, which are also known as ``hlines''.
17970 The @samp{hlines} argument with the default @samp{no} value strips such
17971 lines from the input table.  For most code, this is desirable, or
17972 else those @samp{hline} symbols raise unbound variable errors.
17973 A @samp{yes} accepts such lines, as demonstrated in the following
17974 example.
17976 @example
17977 #+NAME: many-cols
17978 | a | b | c |
17979 |---+---+---|
17980 | d | e | f |
17981 |---+---+---|
17982 | g | h | i |
17984 #+NAME: no-hline
17985 #+BEGIN_SRC python :var tab=many-cols :hlines no
17986   return tab
17987 #+END_SRC
17989 #+RESULTS: no-hline
17990 | a | b | c |
17991 | d | e | f |
17992 | g | h | i |
17994 #+NAME: hlines
17995 #+BEGIN_SRC python :var tab=many-cols :hlines yes
17996   return tab
17997 #+END_SRC
17999 #+RESULTS: hlines
18000 | a | b | c |
18001 |---+---+---|
18002 | d | e | f |
18003 |---+---+---|
18004 | g | h | i |
18005 @end example
18007 @item @samp{list}
18008 Interpret the results as an Org list.  If the result is a single
18009 value, create a list of one element.
18011 @item @samp{scalar}
18012 @itemx @samp{verbatim}
18013 Interpret literally and insert as quoted text.  Do not create
18014 a table.  Usage example: @samp{:results value verbatim}.
18016 @item @samp{file}
18017 Interpret as a filename.  Save the results of execution of the
18018 code block to that file, then insert a link to it.  You can
18019 control both the filename and the description associated to the
18020 link.
18022 @cindex @samp{file}, header argument
18023 @cindex @samp{output-dir}, header argument
18024 Org first tries to generate the filename from the value of the
18025 @samp{file} header argument and the directory specified using the
18026 @samp{output-dir} header arguments.  If @samp{output-dir} is not specified,
18027 Org assumes it is the current directory.
18029 @example
18030 #+BEGIN_SRC asymptote :results value file :file circle.pdf :output-dir img/
18031   size(2cm);
18032   draw(unitcircle);
18033 #+END_SRC
18034 @end example
18036 @cindex @samp{file-ext}, header argument
18037 If @samp{file} is missing, Org generates the base name of the output
18038 file from the name of the code block, and its extension from the
18039 @samp{file-ext} header argument.  In that case, both the name and the
18040 extension are mandatory.
18042 @example
18043 #+name: circle
18044 #+BEGIN_SRC asymptote :results value file :file-ext pdf
18045   size(2cm);
18046   draw(unitcircle);
18047 #+END_SRC
18048 @end example
18050 @cindex @samp{file-desc}, header argument
18051 The @samp{file-desc} header argument defines the description (see
18052 @ref{Link Format}) for the link.  If @samp{file-desc} has no value, Org
18053 uses the generated file name for both the ``link'' and
18054 ``description'' parts of the link.
18055 @end table
18057 @anchor{Format}
18058 @subheading Format
18060 Format pertains to the type of the result returned by the code block.
18061 Choose one of the options; they are mutually exclusive.  The default
18062 follows from the type specified above.
18064 @table @asis
18065 @item @samp{raw}
18066 Interpreted as raw Org mode.  Inserted directly into the buffer.
18067 Aligned if it is a table.  Usage example: @samp{:results value raw}.
18069 @item @samp{org}
18070 Results enclosed in a @samp{BEGIN_SRC org} block.  For comma-escape,
18071 either @kbd{@key{TAB}} in the block, or export the file.  Usage
18072 example: @samp{:results value org}.
18074 @item @samp{html}
18075 Results enclosed in a @samp{BEGIN_EXPORT html} block.  Usage example:
18076 @samp{:results value html}.
18078 @item @samp{latex}
18079 Results enclosed in a @samp{BEGIN_EXPORT latex} block.  Usage example:
18080 @samp{:results value latex}.
18082 @item @samp{code}
18083 Result enclosed in a code block.  Useful for parsing.  Usage
18084 example: @samp{:results value code}.
18086 @item @samp{pp}
18087 Result converted to pretty-print source code.  Enclosed in a code
18088 block.  Languages supported: Emacs Lisp, Python, and Ruby.  Usage
18089 example: @samp{:results value pp}.
18091 @item @samp{drawer}
18092 Result wrapped in a @samp{RESULTS} drawer.  Useful for containing
18093 @samp{raw} or @samp{org} results for later scripting and automated
18094 processing.  Usage example: @samp{:results value drawer}.
18095 @end table
18097 @anchor{Handling}
18098 @subheading Handling
18100 Handling options after collecting the results.
18102 @table @asis
18103 @item @samp{silent}
18104 Do not insert results in the Org mode buffer, but echo them in
18105 the minibuffer.  Usage example: @samp{:results output silent}.
18107 @item @samp{replace}
18108 Default.  Insert results in the Org buffer.  Remove previous
18109 results.  Usage example: @samp{:results output replace}.
18111 @item @samp{append}
18112 Append results to the Org buffer.  Latest results are at the
18113 bottom.  Does not remove previous results.  Usage example:
18114 @samp{:results output append}.
18116 @item @samp{prepend}
18117 Prepend results to the Org buffer.  Latest results are at the
18118 top.  Does not remove previous results.  Usage example: @samp{:results
18119      output prepend}.
18120 @end table
18122 @anchor{Post-processing}
18123 @subheading Post-processing
18125 @cindex @samp{post}, header argument
18126 @cindex @samp{*this*}, in @samp{post} header argument
18127 The @samp{post} header argument is for post-processing results from block
18128 evaluation.  When @samp{post} has any value, Org binds the results to
18129 @code{*this*} variable for easy passing to @samp{var} header argument
18130 specifications (see @ref{Environment of a Code Block}).  That makes results
18131 available to other code blocks, or even for direct Emacs Lisp code
18132 execution.
18134 The following two examples illustrate @samp{post} header argument in
18135 action.  The first one shows how to attach an @samp{ATTR_LATEX} keyword
18136 using @samp{post}.
18138 @example
18139 #+NAME: attr_wrap
18140 #+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output
18141   echo "#+ATTR_LATEX: :width $width"
18142   echo "$data"
18143 #+END_SRC
18145 #+HEADER: :file /tmp/it.png
18146 #+BEGIN_SRC dot :post attr_wrap(width="5cm", data=*this*) :results drawer
18147   digraph@{
18148           a -> b;
18149           b -> c;
18150           c -> a;
18151   @}
18152 #+end_src
18154 #+RESULTS:
18155 :RESULTS:
18156 #+ATTR_LATEX :width 5cm
18157 [[file:/tmp/it.png]]
18158 :END:
18159 @end example
18161 The second example shows use of @samp{colnames} header argument in @samp{post}
18162 to pass data between code blocks.
18164 @example
18165 #+NAME: round-tbl
18166 #+BEGIN_SRC emacs-lisp :var tbl="" fmt="%.3f"
18167   (mapcar (lambda (row)
18168             (mapcar (lambda (cell)
18169                       (if (numberp cell)
18170                           (format fmt cell)
18171                         cell))
18172                     row))
18173           tbl)
18174 #+end_src
18176 #+BEGIN_SRC R :colnames yes :post round-tbl[:colnames yes](*this*)
18177   set.seed(42)
18178   data.frame(foo=rnorm(1))
18179 #+END_SRC
18181 #+RESULTS:
18182 |   foo |
18183 |-------|
18184 | 1.371 |
18185 @end example
18187 @node Exporting Code Blocks
18188 @section Exporting Code Blocks
18190 @cindex code block, exporting
18191 @cindex source code, exporting
18193 It is possible to export the @emph{code} of code blocks, the @emph{results} of
18194 code block evaluation, @emph{both} the code and the results of code block
18195 evaluation, or @emph{none}.  Org defaults to exporting @emph{code} for most
18196 languages.  For some languages, such as ditaa, Org defaults to
18197 @emph{results}.  To export just the body of code blocks, see @ref{Literal Examples}.  To selectively export sub-trees of an Org document, see
18198 @ref{Exporting}.
18200 @cindex @samp{export}, header argument
18201 The @samp{exports} header argument is to specify if that part of the Org
18202 file is exported to, say, HTML or @LaTeX{} formats.
18204 @table @asis
18205 @item @samp{code}
18206 The default.  The body of code is included into the exported
18207 file.  Example: @samp{:exports code}.
18209 @item @samp{results}
18210 The results of evaluation of the code is included in the exported
18211 file.  Example: @samp{:exports results}.
18213 @item @samp{both}
18214 Both the code and results of evaluation are included in the
18215 exported file.  Example: @samp{:exports both}.
18217 @item @samp{none}
18218 Neither the code nor the results of evaluation is included in the
18219 exported file.  Whether the code is evaluated at all depends on
18220 other options.  Example: @samp{:exports none}.
18221 @end table
18223 @vindex org-export-use-babel
18224 To stop Org from evaluating code blocks to speed exports, use the
18225 header argument @samp{:eval never-export} (see @ref{Evaluating Code Blocks}).
18226 To stop Org from evaluating code blocks for greater security, set the
18227 @code{org-export-use-babel} variable to @code{nil}, but understand that header
18228 arguments will have no effect.
18230 Turning off evaluation comes in handy when batch processing.  For
18231 example, markup languages for wikis, which have a high risk of
18232 untrusted code.  Stopping code block evaluation also stops evaluation
18233 of all header arguments of the code block.  This may not be desirable
18234 in some circumstances.  So during export, to allow evaluation of just
18235 the header arguments but not any code evaluation in the source block,
18236 set @samp{:eval never-export} (see @ref{Evaluating Code Blocks}).
18238 Org never evaluates code blocks in commented sub-trees when exporting
18239 (see @ref{Comment Lines}).  On the other hand, Org does evaluate code
18240 blocks in sub-trees excluded from export (see @ref{Export Settings}).
18242 @node Extracting Source Code
18243 @section Extracting Source Code
18245 @cindex tangling
18246 @cindex source code, extracting
18247 @cindex code block, extracting source code
18249 Extracting source code from code blocks is a basic task in literate
18250 programming.  Org has features to make this easy.  In literate
18251 programming parlance, documents on creation are @emph{woven} with code and
18252 documentation, and on export, the code is tangled for execution by
18253 a computer.  Org facilitates weaving and tangling for producing,
18254 maintaining, sharing, and exporting literate programming documents.
18255 Org provides extensive customization options for extracting source
18256 code.
18258 When Org tangles code blocks, it expands, merges, and transforms them.
18259 Then Org recomposes them into one or more separate files, as
18260 configured through the options.  During this tangling process, Org
18261 expands variables in the source code, and resolves any Noweb style
18262 references (see @ref{Noweb Reference Syntax}).
18264 @anchor{Header arguments}
18265 @subheading Header arguments
18267 @cindex @samp{tangle}, header argument
18268 The @samp{tangle} header argument specifies if the code block is exported
18269 to source file(s).
18271 @table @asis
18272 @item @samp{yes}
18273 Export the code block to source file.  The file name for the
18274 source file is derived from the name of the Org file, and the
18275 file extension is derived from the source code language
18276 identifier.  Example: @samp{:tangle yes}.
18278 @item @samp{no}
18279 The default.  Do not extract the code in a source code file.
18280 Example: @samp{:tangle no}.
18282 @item @var{FILENAME}
18283 Export the code block to source file whose file name is derived
18284 from any string passed to the @samp{tangle} header argument.  Org
18285 derives the file name as being relative to the directory of the
18286 Org file's location.  Example: @samp{:tangle FILENAME}.
18287 @end table
18289 @cindex @samp{mkdirp}, header argument
18290 The @samp{mkdirp} header argument creates parent directories for tangled
18291 files if the directory does not exist.  @samp{yes} enables directory
18292 creation and @samp{no} inhibits directory creation.
18294 @cindex @samp{comments}, header argument
18295 The @samp{comments} header argument controls inserting comments into
18296 tangled files.  These are above and beyond whatever comments may
18297 already exist in the code block.
18299 @table @asis
18300 @item @samp{no}
18301 The default.  Do not insert any extra comments during tangling.
18303 @item @samp{link}
18304 Wrap the code block in comments.  Include links pointing back to
18305 the place in the Org file from where the code was tangled.
18307 @item @samp{yes}
18308 Kept for backward compatibility; same as @samp{link}.
18310 @item @samp{org}
18311 Nearest headline text from Org file is inserted as comment.  The
18312 exact text that is inserted is picked from the leading context of
18313 the source block.
18315 @item @samp{both}
18316 Includes both @samp{link} and @samp{org} options.
18318 @item @samp{noweb}
18319 Includes @samp{link} option, expands Noweb references (see @ref{Noweb Reference Syntax}), and wraps them in link comments inside the
18320 body of the code block.
18321 @end table
18323 @cindex @samp{padline}, header argument
18324 The @samp{padline} header argument controls insertion of newlines to pad
18325 source code in the tangled file.
18327 @table @asis
18328 @item @samp{yes}
18329 Default.  Insert a newline before and after each code block in
18330 the tangled file.
18332 @item @samp{no}
18333 Do not insert newlines to pad the tangled code blocks.
18334 @end table
18336 @cindex @samp{shebang}, header argument
18337 The @samp{shebang} header argument can turn results into executable script
18338 files.  By setting it to a string value---for example, @samp{:shebang
18339 "#!/bin/bash"}---Org inserts that string as the first line of the
18340 tangled file that the code block is extracted to.  Org then turns on
18341 the tangled file's executable permission.
18343 @cindex @samp{no-expand}, header argument
18344 By default Org expands code blocks during tangling.  The @samp{no-expand}
18345 header argument turns off such expansions.  Note that one side-effect
18346 of expansion by @code{org-babel-expand-src-block} also assigns values (see
18347 @ref{Environment of a Code Block}) to variables.  Expansions also replace
18348 Noweb references with their targets (see @ref{Noweb Reference Syntax}).
18349 Some of these expansions may cause premature assignment, hence this
18350 option.  This option makes a difference only for tangling.  It has no
18351 effect when exporting since code blocks for execution have to be
18352 expanded anyway.
18354 @anchor{Functions}
18355 @subheading Functions
18357 @table @asis
18358 @item @code{org-babel-tangle}
18359 @findex org-babel-tangle
18360 @kindex C-c C-v t
18361 Tangle the current file.  Bound to @kbd{C-c C-v t}.
18363 With prefix argument only tangle the current code block.
18365 @item @code{org-babel-tangle-file}
18366 @findex org-babel-tangle-file
18367 @kindex C-c C-v f
18368 Choose a file to tangle.  Bound to @kbd{C-c C-v f}.
18369 @end table
18371 @anchor{Hooks (1)}
18372 @subheading Hooks
18374 @table @asis
18375 @item @code{org-babel-post-tangle-hook}
18376 @vindex org-babel-post-tangle-hook
18377 This hook is run from within code files tangled by
18378 @code{org-babel-tangle}, making it suitable for post-processing,
18379 compilation, and evaluation of code in the tangled files.
18380 @end table
18382 @anchor{Jumping between code and Org}
18383 @subheading Jumping between code and Org
18385 @findex org-babel-tangle-jump-to-org
18386 Debuggers normally link errors and messages back to the source code.
18387 But for tangled files, we want to link back to the Org file, not to
18388 the tangled source file.  To make this extra jump, Org uses
18389 @code{org-babel-tangle-jump-to-org} function with two additional source
18390 code block header arguments:
18392 @enumerate
18393 @item
18394 Set @samp{padline} to true---this is the default setting.
18395 @item
18396 Set @samp{comments} to @samp{link}, which makes Org insert links to the Org
18397 file.
18398 @end enumerate
18400 @node Languages
18401 @section Languages
18403 @cindex babel, languages
18404 @cindex source code, languages
18405 @cindex code block, languages
18407 Code blocks in the following languages are supported.
18409 @multitable {aaaaaaaaaa} {aaaaaaaaaa} {aaaaaaaaaaaaaa} {aaaaaaaaaa}
18410 @headitem Language
18411 @tab Identifier
18412 @tab Language
18413 @tab Identifier
18414 @item Asymptote
18415 @tab asymptote
18416 @tab Awk
18417 @tab awk
18418 @item C
18419 @tab C
18420 @tab C++
18421 @tab C++
18422 @item Clojure
18423 @tab clojure
18424 @tab CSS
18425 @tab css
18426 @item D
18427 @tab d
18428 @tab ditaa
18429 @tab ditaa
18430 @item Graphviz
18431 @tab dot
18432 @tab Emacs Calc
18433 @tab calc
18434 @item Emacs Lisp
18435 @tab emacs-lisp
18436 @tab Fortran
18437 @tab fortran
18438 @item Gnuplot
18439 @tab gnuplot
18440 @tab Haskell
18441 @tab haskell
18442 @item Java
18443 @tab java
18444 @tab Javascript
18445 @tab js
18446 @item @LaTeX{}
18447 @tab latex
18448 @tab Ledger
18449 @tab ledger
18450 @item Lisp
18451 @tab lisp
18452 @tab Lilypond
18453 @tab lilypond
18454 @item Lua
18455 @tab lua
18456 @tab MATLAB
18457 @tab matlab
18458 @item Mscgen
18459 @tab mscgen
18460 @tab Objective Caml
18461 @tab ocaml
18462 @item Octave
18463 @tab octave
18464 @tab Org mode
18465 @tab org
18466 @item Oz
18467 @tab oz
18468 @tab Perl
18469 @tab perl
18470 @item Plantuml
18471 @tab plantuml
18472 @tab Processing.js
18473 @tab processing
18474 @item Python
18475 @tab python
18476 @tab R
18477 @tab R
18478 @item Ruby
18479 @tab ruby
18480 @tab Sass
18481 @tab sass
18482 @item Scheme
18483 @tab scheme
18484 @tab GNU Screen
18485 @tab screen
18486 @item Sed
18487 @tab sed
18488 @tab shell
18489 @tab sh
18490 @item SQL
18491 @tab sql
18492 @tab SQLite
18493 @tab sqlite
18494 @item Vala
18495 @tab vala
18496 @tab 
18497 @tab 
18498 @end multitable
18500 Additional documentation for some languages is at
18501 @uref{https://orgmode.org/worg/org-contrib/babel/languages.html}.
18503 @vindex org-babel-load-languages
18504 By default, only Emacs Lisp is enabled for evaluation.  To enable or
18505 disable other languages, customize the @code{org-babel-load-languages}
18506 variable either through the Emacs customization interface, or by
18507 adding code to the init file as shown next.
18509 In this example, evaluation is disabled for Emacs Lisp, and enabled
18510 for R.
18512 @lisp
18513 (org-babel-do-load-languages
18514  'org-babel-load-languages
18515  '((emacs-lisp . nil)
18516    (R . t)))
18517 @end lisp
18519 Note that this is not the only way to enable a language.  Org also
18520 enables languages when loaded with @code{require} statement.  For example,
18521 the following enables execution of Clojure code blocks:
18523 @lisp
18524 (require 'ob-clojure)
18525 @end lisp
18527 @node Editing Source Code
18528 @section Editing Source Code
18530 @cindex code block, editing
18531 @cindex source code, editing
18533 @kindex C-c '
18534 Use @kbd{C-c '} to edit the current code block.  It opens a new
18535 major-mode edit buffer containing the body of the source code block,
18536 ready for any edits.  Use @kbd{C-c '} again to close the buffer
18537 and return to the Org buffer.
18539 @kindex C-x C-s
18540 @vindex org-edit-src-auto-save-idle-delay
18541 @cindex auto-save, in code block editing
18542 @kbd{C-x C-s} saves the buffer and updates the contents of the
18543 Org buffer.  Set @code{org-edit-src-auto-save-idle-delay} to save the base
18544 buffer after a certain idle delay time.  Set
18545 @code{org-edit-src-turn-on-auto-save} to auto-save this buffer into
18546 a separate file using Auto-save mode.
18548 While editing the source code in the major mode, the Org Src minor
18549 mode remains active.  It provides these customization variables as
18550 described below.  For even more variables, look in the customization
18551 group @code{org-edit-structure}.
18553 @table @asis
18554 @item @code{org-src-lang-modes}
18555 @vindex org-src-lang-modes
18556 If an Emacs major-mode named @code{<LANG>-mode} exists, where
18557 @var{<LANG>} is the language identifier from code block's
18558 header line, then the edit buffer uses that major mode.  Use this
18559 variable to arbitrarily map language identifiers to major modes.
18561 @item @code{org-src-window-setup}
18562 @vindex org-src-window-setup
18563 For specifying Emacs window arrangement when the new edit buffer
18564 is created.
18566 @item @code{org-src-preserve-indentation}
18567 @cindex indentation, in code blocks
18568 @vindex org-src-preserve-indentation
18569 Default is @code{nil}.  Source code is indented.  This indentation
18570 applies during export or tangling, and depending on the context,
18571 may alter leading spaces and tabs.  When non-@code{nil}, source code
18572 is aligned with the leftmost column.  No lines are modified
18573 during export or tangling, which is very useful for white-space
18574 sensitive languages, such as Python.
18576 @item @code{org-src-ask-before-returning-to-edit-buffer}
18577 @vindex org-src-ask-before-returning-to-edit-buffer
18578 When @code{nil}, Org returns to the edit buffer without further
18579 prompts.  The default prompts for a confirmation.
18580 @end table
18582 @vindex org-src-fontify-natively
18583 @vindex org-src-block-faces
18584 Set @code{org-src-fontify-natively} to non-@code{nil} to turn on native code
18585 fontification in the @emph{Org} buffer.  Fontification of code blocks can
18586 give visual separation of text and code on the display page.  To
18587 further customize the appearance of @code{org-block} for specific
18588 languages, customize @code{org-src-block-faces}.  The following example
18589 shades the background of regular blocks, and colors source blocks only
18590 for Python and Emacs Lisp languages.
18592 @lisp
18593 (require 'color)
18594 (set-face-attribute 'org-block nil :background
18595                     (color-darken-name
18596                      (face-attribute 'default :background) 3))
18598 (setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF"))
18599                             ("python" (:background "#E5FFB8"))))
18600 @end lisp
18602 @node Noweb Reference Syntax
18603 @section Noweb Reference Syntax
18605 @cindex code block, Noweb reference
18606 @cindex syntax, Noweb
18607 @cindex source code, Noweb reference
18609 Org supports named blocks in Noweb@footnote{For Noweb literate programming details, see
18610 @uref{http://www.cs.tufts.edu/~nr/noweb/}.} style syntax:
18612 @example
18613 <<CODE-BLOCK-ID>>
18614 @end example
18616 Org can replace the construct with the source code, or the results of
18617 evaluation, of the code block identified as @var{CODE-BLOCK-ID}.
18619 @cindex @samp{noweb}, header argument
18620 The @samp{noweb} header argument controls expansion of Noweb syntax
18621 references.  Expansions occur when source code blocks are evaluated,
18622 tangled, or exported.
18624 @table @asis
18625 @item @samp{no}
18626 Default.  No expansion of Noweb syntax references in the body of
18627 the code when evaluating, tangling, or exporting.
18629 @item @samp{yes}
18630 Expansion of Noweb syntax references in the body of the code
18631 block when evaluating, tangling, or exporting.
18633 @item @samp{tangle}
18634 Expansion of Noweb syntax references in the body of the code
18635 block when tangling.  No expansion when evaluating or exporting.
18637 @item @samp{no-export}
18638 Expansion of Noweb syntax references in the body of the code
18639 block when evaluating or tangling.  No expansion when exporting.
18641 @item @samp{strip-export}
18642 Expansion of Noweb syntax references in the body of the code
18643 block when expanding prior to evaluating or tangling.  Removes
18644 Noweb syntax references when exporting.
18646 @item @samp{eval}
18647 Expansion of Noweb syntax references in the body of the code
18648 block only before evaluating.
18649 @end table
18651 In the following example,
18653 @example
18654 #+NAME: initialization
18655 #+BEGIN_SRC emacs-lisp
18656   (setq sentence "Never a foot too far, even.")
18657 #+END_SRC
18659 #+BEGIN_SRC emacs-lisp :noweb yes
18660   <<initialization>>
18661   (reverse sentence)
18662 #+END_SRC
18663 @end example
18665 @noindent
18666 the second code block is expanded as
18668 @example
18669 #+BEGIN_SRC emacs-lisp :noweb yes
18670   (setq sentence "Never a foot too far, even.")
18671   (reverse sentence)
18672 #+END_SRC
18673 @end example
18675 Noweb insertions honor prefix characters that appear before the Noweb
18676 syntax reference.  This behavior is illustrated in the following
18677 example.  Because the @samp{<<example>>} Noweb reference appears behind the
18678 SQL comment syntax, each line of the expanded Noweb reference is
18679 commented.  With:
18681 @example
18682 #+NAME: example
18683 #+BEGIN_SRC text
18684   this is the
18685   multi-line body of example
18686 #+END_SRC
18687 @end example
18689 @noindent
18690 this code block:
18692 @example
18693 #+BEGIN_SRC sql :noweb yes
18694  ---<<example>>
18695 #+END_SRC
18696 @end example
18698 @noindent
18699 expands to:
18701 @example
18702 #+BEGIN_SRC sql :noweb yes
18703  ---this is the
18704  ---multi-line body of example
18705 #+END_SRC
18706 @end example
18708 Since this change does not affect Noweb replacement text without
18709 newlines in them, inline Noweb references are acceptable.
18711 This feature can also be used for management of indentation in
18712 exported code snippets.  With:
18714 @example
18715 #+NAME: if-true
18716 #+BEGIN_SRC python :exports none
18717   print('do things when true')
18718 #+end_src
18720 #+name: if-false
18721 #+begin_src python :exports none
18722   print('do things when false')
18723 #+end_src
18724 @end example
18726 @noindent
18727 this code block:
18729 @example
18730 #+begin_src python :noweb yes :results output
18731   if true:
18732       <<if-true>>
18733   else:
18734       <<if-false>>
18735 #+end_src
18736 @end example
18738 @noindent
18739 expands to:
18741 @example
18742 if true:
18743     print('do things when true')
18744 else:
18745     print('do things when false')
18746 @end example
18748 @cindex @samp{noweb-ref}, header argument
18749 When expanding Noweb style references, Org concatenates code blocks by
18750 matching the reference name to either the code block name or, if none
18751 is found, to the @samp{noweb-ref} header argument.
18753 For simple concatenation, set this @samp{noweb-ref} header argument at the
18754 sub-tree or file level.  In the example Org file shown next, the body
18755 of the source code in each block is extracted for concatenation to
18756 a pure code file when tangled.
18758 @example
18759 #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
18760   <<fullest-disk>>
18761 #+END_SRC
18762 * the mount point of the fullest disk
18763   :PROPERTIES:
18764   :header-args: :noweb-ref fullest-disk
18765   :END:
18767 ** query all mounted disks
18768 #+BEGIN_SRC sh
18769   df \
18770 #+END_SRC
18772 ** strip the header row
18773 #+BEGIN_SRC sh
18774   |sed '1d' \
18775 #+END_SRC
18777 ** output mount point of fullest disk
18778 #+BEGIN_SRC sh
18779   |awk '@{if (u < +$5) @{u = +$5; m = $6@}@} END @{print m@}'
18780 #+END_SRC
18781 @end example
18783 @cindex @samp{noweb-sep}, header argument
18784 By default a newline separates each noweb reference concatenation.  To
18785 change this newline separator, edit the @samp{noweb-sep} header argument.
18787 Eventually, Org can include the results of a code block rather than
18788 its body.  To that effect, append parentheses, possibly including
18789 arguments, to the code block name, as shown below.
18791 @example
18792 <<code-block-name(optional arguments)>>
18793 @end example
18795 Note that when using the above approach to a code block's results, the
18796 code block name set by @samp{NAME} keyword is required; the reference set
18797 by @samp{noweb-ref} does not work in that case.
18799 Here is an example that demonstrates how the exported content changes
18800 when Noweb style references are used with parentheses versus without.
18801 With:
18803 @example
18804 #+NAME: some-code
18805 #+BEGIN_SRC python :var num=0 :results output :exports none
18806   print(num*10)
18807 #+END_SRC
18808 @end example
18810 @noindent
18811 this code block:
18813 @example
18814 #+BEGIN_SRC text :noweb yes
18815   <<some-code>>
18816 #+END_SRC
18817 @end example
18819 @noindent
18820 expands to:
18822 @example
18823 print(num*10)
18824 @end example
18826 Below, a similar Noweb style reference is used, but with parentheses,
18827 while setting a variable @samp{num} to 10:
18829 @example
18830 #+BEGIN_SRC text :noweb yes
18831   <<some-code(num=10)>>
18832 #+END_SRC
18833 @end example
18835 @noindent
18836 Note that now the expansion contains the results of the code block
18837 @samp{some-code}, not the code block itself:
18839 @example
18841 @end example
18843 @node Library of Babel
18844 @section Library of Babel
18846 @cindex babel, library of
18847 @cindex source code, library
18848 @cindex code block, library
18850 The ``Library of Babel'' is a collection of code blocks.  Like
18851 a function library, these code blocks can be called from other Org
18852 files.  A collection of useful code blocks is available on @uref{https://orgmode.org/worg/library-of-babel.html, Worg}.  For
18853 remote code block evaluation syntax, see @ref{Evaluating Code Blocks}.
18855 @kindex C-c C-v i
18856 @findex org-babel-lob-ingest
18857 For any user to add code to the library, first save the code in
18858 regular code blocks of an Org file, and then load the Org file with
18859 @code{org-babel-lob-ingest}, which is bound to @kbd{C-c C-v i}.
18861 @node Key bindings and Useful Functions
18862 @section Key bindings and Useful Functions
18864 @cindex code block, key bindings
18866 Many common Org mode key sequences are re-bound depending on
18867 the context.
18869 Active key bindings in code blocks:
18871 @kindex C-c C-c
18872 @findex org-babel-execute-src-block
18873 @kindex C-c C-o
18874 @findex org-babel-open-src-block-result
18875 @kindex M-UP
18876 @findex org-babel-load-in-session
18877 @kindex M-DOWN
18878 @findex org-babel-pop-to-session
18879 @multitable @columnfractions 0.2 0.55
18880 @headitem Key binding
18881 @tab Function
18882 @item @kbd{C-c C-c}
18883 @tab @code{org-babel-execute-src-block}
18884 @item @kbd{C-c C-o}
18885 @tab @code{org-babel-open-src-block-result}
18886 @item @kbd{M-@key{UP}}
18887 @tab @code{org-babel-load-in-session}
18888 @item @kbd{M-@key{DOWN}}
18889 @tab @code{org-babel-pop-to-session}
18890 @end multitable
18892 Active key bindings in Org mode buffer:
18894 @kindex C-c C-v p
18895 @kindex C-c C-v C-p
18896 @kindex C-c C-v n
18897 @kindex C-c C-v C-n
18898 @kindex C-c C-v e
18899 @kindex C-c C-v C-e
18900 @kindex C-c C-v o
18901 @kindex C-c C-v C-o
18902 @kindex C-c C-v v
18903 @kindex C-c C-v C-v
18904 @kindex C-c C-v u
18905 @kindex C-c C-v C-u
18906 @kindex C-c C-v g
18907 @kindex C-c C-v C-g
18908 @kindex C-c C-v r
18909 @kindex C-c C-v C-r
18910 @kindex C-c C-v b
18911 @kindex C-c C-v C-b
18912 @kindex C-c C-v s
18913 @kindex C-c C-v C-s
18914 @kindex C-c C-v d
18915 @kindex C-c C-v C-d
18916 @kindex C-c C-v t
18917 @kindex C-c C-v C-t
18918 @kindex C-c C-v f
18919 @kindex C-c C-v C-f
18920 @kindex C-c C-v c
18921 @kindex C-c C-v C-c
18922 @kindex C-c C-v j
18923 @kindex C-c C-v C-j
18924 @kindex C-c C-v l
18925 @kindex C-c C-v C-l
18926 @kindex C-c C-v i
18927 @kindex C-c C-v C-i
18928 @kindex C-c C-v I
18929 @kindex C-c C-v C-I
18930 @kindex C-c C-v z
18931 @kindex C-c C-v C-z
18932 @kindex C-c C-v a
18933 @kindex C-c C-v C-a
18934 @kindex C-c C-v h
18935 @kindex C-c C-v C-h
18936 @kindex C-c C-v x
18937 @kindex C-c C-v C-x
18938 @findex org-babel-previous-src-block
18939 @findex org-babel-next-src-block
18940 @findex org-babel-execute-maybe
18941 @findex org-babel-open-src-block-result
18942 @findex org-babel-expand-src-block
18943 @findex org-babel-goto-src-block-head
18944 @findex org-babel-goto-named-src-block
18945 @findex org-babel-goto-named-result
18946 @findex org-babel-execute-buffer
18947 @findex org-babel-execute-subtree
18948 @findex org-babel-demarcate-block
18949 @findex org-babel-tangle
18950 @findex org-babel-tangle-file
18951 @findex org-babel-check-src-block
18952 @findex org-babel-insert-header-arg
18953 @findex org-babel-load-in-session
18954 @findex org-babel-lob-ingest
18955 @findex org-babel-view-src-block-info
18956 @findex org-babel-switch-to-session-with-code
18957 @findex org-babel-sha1-hash
18958 @findex org-babel-describe-bindings
18959 @findex org-babel-do-key-sequence-in-edit-buffer
18960 @multitable @columnfractions 0.45 0.55
18961 @headitem Key binding
18962 @tab Function
18963 @item @kbd{C-c C-v p} or @kbd{C-c C-v C-p}
18964 @tab @code{org-babel-previous-src-block}
18965 @item @kbd{C-c C-v n} or @kbd{C-c C-v C-n}
18966 @tab @code{org-babel-next-src-block}
18967 @item @kbd{C-c C-v e} or @kbd{C-c C-v C-e}
18968 @tab @code{org-babel-execute-maybe}
18969 @item @kbd{C-c C-v o} or @kbd{C-c C-v C-o}
18970 @tab @code{org-babel-open-src-block-result}
18971 @item @kbd{C-c C-v v} or @kbd{C-c C-v C-v}
18972 @tab @code{org-babel-expand-src-block}
18973 @item @kbd{C-c C-v u} or @kbd{C-c C-v C-u}
18974 @tab @code{org-babel-goto-src-block-head}
18975 @item @kbd{C-c C-v g} or @kbd{C-c C-v C-g}
18976 @tab @code{org-babel-goto-named-src-block}
18977 @item @kbd{C-c C-v r} or @kbd{C-c C-v C-r}
18978 @tab @code{org-babel-goto-named-result}
18979 @item @kbd{C-c C-v b} or @kbd{C-c C-v C-b}
18980 @tab @code{org-babel-execute-buffer}
18981 @item @kbd{C-c C-v s} or @kbd{C-c C-v C-s}
18982 @tab @code{org-babel-execute-subtree}
18983 @item @kbd{C-c C-v d} or @kbd{C-c C-v C-d}
18984 @tab @code{org-babel-demarcate-block}
18985 @item @kbd{C-c C-v t} or @kbd{C-c C-v C-t}
18986 @tab @code{org-babel-tangle}
18987 @item @kbd{C-c C-v f} or @kbd{C-c C-v C-f}
18988 @tab @code{org-babel-tangle-file}
18989 @item @kbd{C-c C-v c} or @kbd{C-c C-v C-c}
18990 @tab @code{org-babel-check-src-block}
18991 @item @kbd{C-c C-v j} or @kbd{C-c C-v C-j}
18992 @tab @code{org-babel-insert-header-arg}
18993 @item @kbd{C-c C-v l} or @kbd{C-c C-v C-l}
18994 @tab @code{org-babel-load-in-session}
18995 @item @kbd{C-c C-v i} or @kbd{C-c C-v C-i}
18996 @tab @code{org-babel-lob-ingest}
18997 @item @kbd{C-c C-v I} or @kbd{C-c C-v C-I}
18998 @tab @code{org-babel-view-src-block-info}
18999 @item @kbd{C-c C-v z} or @kbd{C-c C-v C-z}
19000 @tab @code{org-babel-switch-to-session-with-code}
19001 @item @kbd{C-c C-v a} or @kbd{C-c C-v C-a}
19002 @tab @code{org-babel-sha1-hash}
19003 @item @kbd{C-c C-v h} or @kbd{C-c C-v C-h}
19004 @tab @code{org-babel-describe-bindings}
19005 @item @kbd{C-c C-v x} or @kbd{C-c C-v C-x}
19006 @tab @code{org-babel-do-key-sequence-in-edit-buffer}
19007 @end multitable
19009 @node Batch Execution
19010 @section Batch Execution
19012 @cindex code block, batch execution
19013 @cindex source code, batch execution
19015 Org mode features, including working with source code facilities can
19016 be invoked from the command line.  This enables building shell scripts
19017 for batch processing, running automated system tasks, and expanding
19018 Org mode's usefulness.
19020 The sample script shows batch processing of multiple files using
19021 @code{org-babel-tangle}.
19023 @example
19024 #!/bin/sh
19025 # Tangle files with Org mode
19027 emacs -Q --batch --eval "
19028     (progn
19029       (require 'ob-tangle)
19030       (dolist (file command-line-args-left)
19031         (with-current-buffer (find-file-noselect file)
19032           (org-babel-tangle))))
19033   " "$@@"
19034 @end example
19036 @node Miscellaneous
19037 @chapter Miscellaneous
19039 @menu
19040 * Completion::                   M-@key{TAB} guesses completions.
19041 * Structure Templates::          Quick insertion of structural elements.
19042 * Speed Keys::                   Electric commands at the beginning of a headline.
19043 * Code Evaluation Security::     Org files evaluate in-line code.
19044 * Customization::                Adapting Org to your taste.
19045 * In-buffer Settings::           Overview of keywords.
19046 * The Very Busy @kbd{C-c C-c} Key:: When in doubt, press @kbd{C-c C-c}.
19047 * Clean View::                   Getting rid of leading stars in the outline.
19048 * TTY Keys::                     Using Org on a tty.
19049 * Interaction::                  With other Emacs packages.
19050 * Org Crypt::                    Encrypting Org files.
19051 @end menu
19053 @node Completion
19054 @section Completion
19056 @cindex completion, of @TeX{} symbols
19057 @cindex completion, of TODO keywords
19058 @cindex completion, of dictionary words
19059 @cindex completion, of option keywords
19060 @cindex completion, of tags
19061 @cindex completion, of property keys
19062 @cindex completion, of link abbreviations
19063 @cindex @TeX{} symbol completion
19064 @cindex TODO keywords completion
19065 @cindex dictionary word completion
19066 @cindex option keyword completion
19067 @cindex tag completion
19068 @cindex link abbreviations, completion of
19070 Org has in-buffer completions.  Unlike minibuffer completions, which
19071 are useful for quick command interactions, Org's in-buffer completions
19072 are more suitable for content creation in Org documents.  Type one or
19073 more letters and invoke the hot key to complete the text in-place.
19074 Depending on the context and the keys, Org offers different types of
19075 completions.  No minibuffer is involved.  Such mode-specific hot keys
19076 have become an integral part of Emacs and Org provides several
19077 shortcuts.
19079 @table @asis
19080 @item @kbd{M-@key{TAB}}
19081 @kindex M-TAB
19083 Complete word at point.
19085 @itemize
19086 @item
19087 At the beginning of a headline, complete TODO keywords.
19089 @item
19090 After @samp{\}, complete @TeX{} symbols supported by the exporter.
19092 @item
19093 After @samp{*}, complete headlines in the current buffer so that
19094 they can be used in search links like:
19096 @example
19097 [[*find this headline]]
19098 @end example
19100 @item
19101 After @samp{:} in a headline, complete tags.  Org deduces the list
19102 of tags from the @samp{TAGS} in-buffer option (see @ref{Setting Tags}),
19103 the variable @code{org-tag-alist}, or from all tags used in the
19104 current buffer.
19106 @item
19107 After @samp{:} and not in a headline, complete property keys.  The
19108 list of keys is constructed dynamically from all keys used in
19109 the current buffer.
19111 @item
19112 After @samp{[}, complete link abbreviations (see @ref{Link Abbreviations}).
19114 @item
19115 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
19116 file-specific @samp{OPTIONS}.  After option keyword is complete,
19117 pressing @kbd{M-@key{TAB}} again inserts example settings for
19118 this keyword.
19120 @item
19121 After @samp{STARTUP} keyword, complete startup items.
19123 @item
19124 When point is anywhere else, complete dictionary words using
19125 Ispell.
19126 @end itemize
19127 @end table
19129 @node Structure Templates
19130 @section Structure Templates
19132 @cindex template insertion
19133 @cindex insertion, of templates
19135 With just a few keystrokes, it is possible to insert empty structural
19136 blocks, such as @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}, or to wrap existing
19137 text in such a block.
19139 @table @asis
19140 @item @kbd{C-c C-x w} (@code{org-insert-structure-template})
19141 Prompt for a type of block structure, and insert the block at
19142 point.  If the region is active, it is wrapped in the block.
19143 First prompts the user for a key, which is used to look up
19144 a structure type from the values below.  If the key is
19145 @kbd{@key{TAB}}, the user is prompted to enter a type.
19146 @end table
19148 @vindex org-structure-template-alist
19149 Available structure types are defined in
19150 @code{org-structure-template-alist}, see the docstring for adding or
19151 changing values.
19153 @cindex Tempo
19154 @cindex template expansion
19155 @cindex insertion, of templates
19156 @vindex org-tempo-keywords-alist
19157 @vindex org-structure-template-alist
19158 Org Tempo expands snippets to structures defined in
19159 @code{org-structure-template-alist} and @code{org-tempo-keywords-alist}.  For
19160 example, @kbd{< s @key{TAB}} creates a code block.  Enable it by
19161 customizing @code{org-modules} or add @code{(require 'org-tempo)} to your Emacs
19162 init file@footnote{For more information, please refer to the commentary section
19163 in @samp{org-tempo.el}.}.
19166 @multitable @columnfractions 0.1 0.9
19167 @item @kbd{a}
19168 @tab @samp{#+BEGIN_EXPORT ascii} @dots{} @samp{#+END_EXPORT}
19169 @item @kbd{c}
19170 @tab @samp{#+BEGIN_CENTER} @dots{} @samp{#+END_CENTER}
19171 @item @kbd{C}
19172 @tab @samp{#+BEGIN_COMMENT} @dots{} @samp{#+END_COMMENT}
19173 @item @kbd{e}
19174 @tab @samp{#+BEGIN_EXAMPLE} @dots{} @samp{#+END_EXAMPLE}
19175 @item @kbd{h}
19176 @tab @samp{#+BEGIN_EXPORT html} @dots{} @samp{#+END_EXPORT}
19177 @item @kbd{l}
19178 @tab @samp{#+BEGIN_EXPORT latex} @dots{} @samp{#+END_EXPORT}
19179 @item @kbd{q}
19180 @tab @samp{#+BEGIN_QUOTE} @dots{} @samp{#+END_QUOTE}
19181 @item @kbd{s}
19182 @tab @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}
19183 @item @kbd{v}
19184 @tab @samp{#+BEGIN_VERSE} @dots{} @samp{#+END_VERSE}
19185 @end multitable
19187 @node Speed Keys
19188 @section Speed Keys
19190 @cindex speed keys
19192 Single keystrokes can execute custom commands in an Org file when the
19193 cursor is on a headline.  Without the extra burden of a meta or
19194 modifier key, Speed Keys can speed navigation or execute custom
19195 commands.  Besides faster navigation, Speed Keys may come in handy on
19196 small mobile devices that do not have full keyboards.  Speed Keys may
19197 also work on TTY devices known for their problems when entering Emacs
19198 key chords.
19200 @vindex org-use-speed-commands
19201 By default, Org has Speed Keys disabled.  To activate Speed Keys, set
19202 the variable @code{org-use-speed-commands} to a non-@code{nil} value.  To
19203 trigger a Speed Key, the cursor must be at the beginning of an Org
19204 headline, before any of the stars.
19206 @vindex org-speed-commands-user
19207 @findex org-speed-command-help
19208 Org comes with a pre-defined list of Speed Keys.  To add or modify
19209 Speed Keys, customize the variable, @code{org-speed-commands-user}.  For
19210 more details, see the variable's docstring.  With Speed Keys
19211 activated, @kbd{M-x org-speed-command-help}, or @kbd{?} when
19212 cursor is at the beginning of an Org headline, shows currently active
19213 Speed Keys, including the user-defined ones.
19215 @node Code Evaluation Security
19216 @section Code Evaluation and Security Issues
19218 Unlike plain text, running code comes with risk.  Each @samp{src} code
19219 block, in terms of risk, is equivalent to an executable file.  Org
19220 therefore puts a few confirmation prompts by default.  This is to
19221 alert the casual user from accidentally running untrusted code.
19223 For users who do not run code blocks or write code regularly, Org's
19224 default settings should suffice.  However, some users may want to
19225 tweak the prompts for fewer interruptions.  To weigh the risks of
19226 automatic execution of code blocks, here are some details about code
19227 evaluation.
19229 Org evaluates code in the following circumstances:
19231 @table @asis
19232 @item @emph{Source code blocks}
19233 Org evaluates @samp{src} code blocks in an Org file during export.
19234 Org also evaluates a @samp{src} code block with the @kbd{C-c C-c}
19235 key chord.  Users exporting or running code blocks must load
19236 files only from trusted sources.  Be wary of customizing
19237 variables that remove or alter default security measures.
19239 @defopt org-confirm-babel-evaluate
19240 When @code{t}, Org prompts the user for confirmation before executing
19241 each code block.  When @code{nil}, Org executes code blocks without
19242 prompting the user for confirmation.  When this option is set to
19243 a custom function, Org invokes the function with these two
19244 arguments: the source code language and the body of the code
19245 block.  The custom function must return either a @code{t} or @code{nil},
19246 which determines if the user is prompted.  Each source code
19247 language can be handled separately through this function
19248 argument.
19249 @end defopt
19251 For example, here is how to execute ditaa code blocks without
19252 prompting:
19254 @lisp
19255 (defun my-org-confirm-babel-evaluate (lang body)
19256   (not (string= lang "ditaa")))  ;don't ask for ditaa
19257 (setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
19258 @end lisp
19260 @item @emph{Following @samp{shell} and @samp{elisp} links}
19261 Org has two link types that can directly evaluate code (see
19262 @ref{External Links}).  Because such code is not visible, these links
19263 have a potential risk.  Org therefore prompts the user when it
19264 encounters such links.  The customization variables are:
19266 @defopt org-confirm-shell-link-function
19267 Function that prompts the user before executing a shell link.
19268 @end defopt
19270 @defopt org-confirm-elisp-link-function
19271 Function that prompts the user before executing an Emacs Lisp link.
19272 @end defopt
19274 @item @emph{Formulas in tables}
19275 Formulas in tables (see @ref{The spreadsheet}) are code that is
19276 evaluated either by the Calc interpreter, or by the Emacs Lisp
19277 interpreter.
19278 @end table
19280 @node Customization
19281 @section Customization
19283 @cindex customization
19284 @cindex options, for customization
19285 @cindex variables, for customization
19287 Org has more than 500 variables for customization.  They can be
19288 accessed through the usual @kbd{M-x org-customize} command.  Or
19289 through the Org menu: Org @arrow{} Customization @arrow{} Browse Org Group.
19291 Org also has per-file settings for some variables (see @ref{In-buffer Settings}).
19293 @node In-buffer Settings
19294 @section Summary of In-Buffer Settings
19296 @cindex in-buffer settings
19297 @cindex special keywords
19299 In-buffer settings start with @samp{#+}, followed by a keyword, a colon,
19300 and then a word for each setting.  Org accepts multiple settings on
19301 the same line.  Org also accepts multiple lines for a keyword.  This
19302 manual describes these settings throughout.  A summary follows here.
19304 @cindex refresh set-up
19305 @kbd{C-c C-c} activates any changes to the in-buffer settings.
19306 Closing and reopening the Org file in Emacs also activates the
19307 changes.
19309 @table @asis
19310 @item @samp{#+ARCHIVE: %s_done}
19311 @cindex @samp{ARCHIVE}, keyword
19312 @vindex org-archive-location
19313 Sets the archive location of the agenda file.  The corresponding
19314 variable is @code{org-archive-location}.
19316 @item @samp{#+CATEGORY}
19317 @cindex @samp{CATEGORY}, keyword
19318 Sets the category of the agenda file, which applies to the entire
19319 document.
19321 @item @samp{#+COLUMNS: %25ITEM ...}
19322 @cindex @samp{COLUMNS}, property
19323 Set the default format for columns view.  This format applies
19324 when columns view is invoked in locations where no @samp{COLUMNS}
19325 property applies.
19327 @item @samp{#+CONSTANTS: name1=value1 ...}
19328 @cindex @samp{CONSTANTS}, keyword
19329 @vindex org-table-formula-constants
19330 @vindex org-table-formula
19331 Set file-local values for constants that table formulas can use.
19332 This line sets the local variable
19333 @code{org-table-formula-constants-local}.  The global version of this
19334 variable is @code{org-table-formula-constants}.
19336 @item @samp{#+FILETAGS: :tag1:tag2:tag3:}
19337 @cindex @samp{FILETAGS}, keyword
19338 Set tags that all entries in the file inherit from, including the
19339 top-level entries.
19341 @item @samp{#+LINK: linkword replace}
19342 @cindex @samp{LINK}, keyword
19343 @vindex org-link-abbrev-alist
19344 Each line specifies one abbreviation for one link.  Use multiple
19345 @samp{LINK} keywords for more, see @ref{Link Abbreviations}.  The
19346 corresponding variable is @code{org-link-abbrev-alist}.
19348 @item @samp{#+PRIORITIES: highest lowest default}
19349 @cindex @samp{PRIORITIES}, keyword
19350 @vindex org-highest-priority
19351 @vindex org-lowest-priority
19352 @vindex org-default-priority
19353 This line sets the limits and the default for the priorities.
19354 All three must be either letters A--Z or numbers 0--9.  The
19355 highest priority must have a lower ASCII number than the lowest
19356 priority.
19358 @item @samp{#+PROPERTY: Property_Name Value}
19359 @cindex @samp{PROPERTY}, keyword
19360 This line sets a default inheritance value for entries in the
19361 current buffer, most useful for specifying the allowed values of
19362 a property.
19364 @item @samp{#+SETUPFILE: file}
19365 @cindex @samp{SETUPFILE}, keyword
19366 The setup file or a URL pointing to such file is for additional
19367 in-buffer settings.  Org loads this file and parses it for any
19368 settings in it only when Org opens the main file.  If URL is
19369 specified, the contents are downloaded and stored in a temporary
19370 file cache.  @kbd{C-c C-c} on the settings line parses and
19371 loads the file, and also resets the temporary file cache.  Org
19372 also parses and loads the document during normal exporting
19373 process.  Org parses the contents of this document as if it was
19374 included in the buffer.  It can be another Org file.  To visit
19375 the file---not a URL---use @kbd{C-c '} while the cursor is
19376 on the line with the file name.
19378 @item @samp{#+STARTUP:}
19379 @cindex @samp{STARTUP}, keyword
19380 Startup options Org uses when first visiting a file.
19382 @vindex org-startup-folded
19383 The first set of options deals with the initial visibility of the
19384 outline tree.  The corresponding variable for global default
19385 settings is @code{org-startup-folded} with a default value of @code{t},
19386 which is the same as @code{overview}.
19388 @table @asis
19389 @item @samp{overview}
19390 Top-level headlines only.
19392 @item @samp{content}
19393 All headlines.
19395 @item @samp{showall}
19396 No folding on any entry.
19398 @item @samp{showeverything}
19399 Show even drawer contents.
19400 @end table
19402 @vindex org-startup-indented
19403 Dynamic virtual indentation is controlled by the variable
19404 @code{org-startup-indented}.@footnote{Note that @code{org-indent-mode} also sets the @code{wrap-prefix}
19405 property, such that @code{visual-line-mode} (or purely setting @code{word-wrap})
19406 wraps long lines (including headlines) correctly indented.}
19408 @table @asis
19409 @item @samp{indent}
19410 Start with @code{org-indent-mode} turned on.
19412 @item @samp{noindent}
19413 Start with @code{org-indent-mode} turned off.
19414 @end table
19416 @vindex org-startup-align-all-tables
19417 Aligns tables consistently upon visiting a file.  The corresponding
19418 variable is @code{org-startup-align-all-tables} with @code{nil} as default
19419 value.
19421 @table @asis
19422 @item @samp{align}
19423 Align all tables.
19425 @item @samp{noalign}
19426 Do not align tables on startup.
19427 @end table
19429 @vindex org-startup-shrink-all-tables
19430 Shrink table columns with a width cookie.  The corresponding
19431 variable is @code{org-startup-shrink-all-tables} with @code{nil} as default
19432 value.
19434 @vindex org-startup-with-inline-images
19435 When visiting a file, inline images can be automatically displayed.
19436 The corresponding variable is @code{org-startup-with-inline-images},
19437 with a default value @code{nil} to avoid delays when visiting a file.
19439 @table @asis
19440 @item @samp{inlineimages}
19441 Show inline images.
19443 @item @samp{noinlineimages}
19444 Do not show inline images on startup.
19445 @end table
19447 @vindex org-log-done
19448 @vindex org-log-note-clock-out
19449 @vindex org-log-repeat
19450 Logging the closing and reopening of TODO items and clock
19451 intervals can be configured using these options (see variables
19452 @code{org-log-done}, @code{org-log-note-clock-out}, and @code{org-log-repeat}).
19454 @table @asis
19455 @item @samp{logdone}
19456 Record a timestamp when an item is marked DONE.
19458 @item @samp{lognotedone}
19459 Record timestamp and a note when DONE.
19461 @item @samp{nologdone}
19462 Do not record when items are marked DONE.
19464 @item @samp{logrepeat}
19465 Record a time when reinstating a repeating item.
19467 @item @samp{lognoterepeat}
19468 Record a note when reinstating a repeating item.
19470 @item @samp{nologrepeat}
19471 Do not record when reinstating repeating item.
19473 @item @samp{lognoteclock-out}
19474 Record a note when clocking out.
19476 @item @samp{nolognoteclock-out}
19477 Do not record a note when clocking out.
19479 @item @samp{logreschedule}
19480 Record a timestamp when scheduling time changes.
19482 @item @samp{lognotereschedule}
19483 Record a note when scheduling time changes.
19485 @item @samp{nologreschedule}
19486 Do not record when a scheduling date changes.
19488 @item @samp{logredeadline}
19489 Record a timestamp when deadline changes.
19491 @item @samp{lognoteredeadline}
19492 Record a note when deadline changes.
19494 @item @samp{nologredeadline}
19495 Do not record when a deadline date changes.
19497 @item @samp{logrefile}
19498 Record a timestamp when refiling.
19500 @item @samp{lognoterefile}
19501 Record a note when refiling.
19503 @item @samp{nologrefile}
19504 Do not record when refiling.
19505 @end table
19507 @vindex org-hide-leading-stars
19508 @vindex org-odd-levels-only
19509 Here are the options for hiding leading stars in outline headings,
19510 and for indenting outlines.  The corresponding variables are
19511 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with
19512 a default setting @code{nil} (meaning @samp{showstars} and @samp{oddeven}).
19514 @table @asis
19515 @item @samp{hidestars}
19516 Make all but one of the stars starting a headline invisible.
19518 @item @samp{showstars}
19519 Show all stars starting a headline.
19521 @item @samp{indent}
19522 Virtual indentation according to outline level.
19524 @item @samp{noindent}
19525 No virtual indentation according to outline level.
19527 @item @samp{odd}
19528 Allow only odd outline levels (1, 3, @dots{}).
19530 @item @samp{oddeven}
19531 Allow all outline levels.
19532 @end table
19534 @vindex org-put-time-stamp-overlays
19535 @vindex org-time-stamp-overlay-formats
19536 To turn on custom format overlays over timestamps (variables
19537 @code{org-put-time-stamp-overlays} and @code{org-time-stamp-overlay-formats}),
19538 use:
19540 @table @asis
19541 @item @samp{customtime}
19542 Overlay custom time format.
19543 @end table
19545 @vindex constants-unit-system
19546 The following options influence the table spreadsheet (variable
19547 @code{constants-unit-system}).
19549 @table @asis
19550 @item @samp{constcgs}
19551 @samp{constants.el} should use the c-g-s unit system.
19553 @item @samp{constSI}
19554 @samp{constants.el} should use the SI unit system.
19555 @end table
19557 @vindex org-footnote-define-inline
19558 @vindex org-footnote-auto-label
19559 @vindex org-footnote-auto-adjust
19560 To influence footnote settings, use the following keywords.  The
19561 corresponding variables are @code{org-footnote-define-inline},
19562 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
19564 @table @asis
19565 @item @samp{fninline}
19566 Define footnotes inline.
19568 @item @samp{fnnoinline}
19569 Define footnotes in separate section.
19571 @item @samp{fnlocal}
19572 Define footnotes near first reference, but not inline.
19574 @item @samp{fnprompt}
19575 Prompt for footnote labels.
19577 @item @samp{fnauto}
19578 Create @samp{[fn:1]}-like labels automatically (default).
19580 @item @samp{fnconfirm}
19581 Offer automatic label for editing or confirmation.
19583 @item @samp{fnadjust}
19584 Automatically renumber and sort footnotes.
19586 @item @samp{nofnadjust}
19587 Do not renumber and sort automatically.
19588 @end table
19590 @vindex org-hide-block-startup
19591 To hide blocks on startup, use these keywords.  The corresponding
19592 variable is @code{org-hide-block-startup}.
19594 @table @asis
19595 @item @samp{hideblocks}
19596 Hide all begin/end blocks on startup.
19598 @item @samp{nohideblocks}
19599 Do not hide blocks on startup.
19600 @end table
19602 @vindex org-pretty-entities
19603 The display of entities as UTF-8 characters is governed by the
19604 variable @code{org-pretty-entities} and the keywords
19606 @table @asis
19607 @item @samp{entitiespretty}
19608 Show entities as UTF-8 characters where possible.
19610 @item @samp{entitiesplain}
19611 Leave entities plain.
19612 @end table
19614 @item @samp{#+TAGS: TAG1(c1) TAG2(c2)}
19615 @cindex @samp{TAGS}, keyword
19616 @vindex org-tag-alist
19617 These lines (several such lines are allowed) specify the valid
19618 tags in this file, and (potentially) the corresponding @emph{fast tag
19619 selection} keys.  The corresponding variable is @code{org-tag-alist}.
19621 @item @samp{#+TODO:}
19622 @itemx @samp{#+SEQ_TODO:}
19623 @itemx @samp{#+TYP_TODO:}
19624 @cindex @samp{SEQ_TODO}, keyword
19625 @cindex @samp{TODO}, keyword
19626 @cindex @samp{TYP_TODO}, keyword
19627 @vindex org-todo-keywords
19628 These lines set the TODO keywords and their interpretation in the
19629 current file.  The corresponding variable is @code{org-todo-keywords}.
19630 @end table
19632 @node The Very Busy @kbd{C-c C-c} Key
19633 @section The Very Busy @kbd{C-c C-c} Key
19635 @kindex C-c C-c
19636 @cindex @kbd{C-c C-c}, overview
19638 The @kbd{C-c C-c} key in Org serves many purposes depending on
19639 the context.  It is probably the most over-worked, multi-purpose key
19640 combination in Org.  Its uses are well documented throughout this
19641 manual, but here is a consolidated list for easy reference.
19643 @itemize
19644 @item
19645 If any highlights shown in the buffer from the creation of a sparse
19646 tree, or from clock display, remove such highlights.
19648 @item
19649 If the cursor is in one of the special @samp{KEYWORD} lines, scan the
19650 buffer for these lines and update the information.  Also reset the
19651 Org file cache used to temporary store the contents of URLs used as
19652 values for keywords like @samp{SETUPFILE}.
19654 @item
19655 If the cursor is inside a table, realign the table.  The table
19656 realigns even if automatic table editor is turned off.
19658 @item
19659 If the cursor is on a @samp{TBLFM} keyword, re-apply the formulas to the
19660 entire table.
19662 @item
19663 If the current buffer is a capture buffer, close the note and file
19664 it.  With a prefix argument, also jump to the target location after
19665 saving the note.
19667 @item
19668 If the cursor is on a @samp{<<<target>>>}, update radio targets and
19669 corresponding links in this buffer.
19671 @item
19672 If the cursor is on a property line or at the start or end of
19673 a property drawer, offer property commands.
19675 @item
19676 If the cursor is at a footnote reference, go to the corresponding
19677 definition, and @emph{vice versa}.
19679 @item
19680 If the cursor is on a statistics cookie, update it.
19682 @item
19683 If the cursor is in a plain list item with a checkbox, toggle the
19684 status of the checkbox.
19686 @item
19687 If the cursor is on a numbered item in a plain list, renumber the
19688 ordered list.
19690 @item
19691 If the cursor is on the @samp{#+BEGIN} line of a dynamic block, the block
19692 is updated.
19694 @item
19695 If the cursor is at a timestamp, fix the day name in the timestamp.
19696 @end itemize
19698 @node Clean View
19699 @section A Cleaner Outline View
19701 @cindex hiding leading stars
19702 @cindex dynamic indentation
19703 @cindex odd-levels-only outlines
19704 @cindex clean outline view
19706 Org's default outline with stars and no indents can become too
19707 cluttered for short documents.  For @emph{book-like} long documents, the
19708 effect is not as noticeable.  Org provides an alternate stars and
19709 indentation scheme, as shown on the right in the following table.  It
19710 uses only one star and indents text to line with the heading:
19712 @example
19713 * Top level headline             |    * Top level headline
19714 ** Second level                  |      * Second level
19715 *** Third level                  |        * Third level
19716     some text                    |          some text
19717 *** Third level                  |        * Third level
19718     more text                    |          more text
19719 * Another top level headline     |    * Another top level headline
19720 @end example
19722 @noindent
19723 @cindex Indent mode
19724 @findex org-indent-mode
19725 To turn this mode on, use the minor mode, @code{org-indent-mode}.  Text
19726 lines that are not headlines are prefixed with spaces to vertically
19727 align with the headline text@footnote{The @code{org-indent-mode} also sets the @code{wrap-prefix} correctly
19728 for indenting and wrapping long lines of headlines or text.  This
19729 minor mode handles @code{visual-line-mode} and directly applied settings
19730 through @code{word-wrap}.}.
19732 @vindex org-indent-indentation-per-level
19733 To make more horizontal space, the headlines are shifted by two stars.
19734 This can be configured by the @code{org-indent-indentation-per-level}
19735 variable.  Only one star on each headline is visible, the rest are
19736 masked with the same font color as the background.
19738 Note that turning on @code{org-indent-mode} sets @code{org-hide-leading-stars}
19739 to @code{t} and @code{org-adapt-indentation} to @code{nil}.
19741 @vindex org-startup-indented
19742 To globally turn on @code{org-indent-mode} for all files, customize the
19743 variable @code{org-startup-indented}.
19745 To turn on indenting for individual files, use @samp{STARTUP} keyword as
19746 follows:
19748 @example
19749 #+STARTUP: indent
19750 @end example
19752 Indent on startup makes Org use hard spaces to align text with
19753 headings as shown in examples below.
19755 @table @asis
19756 @item @emph{Indentation of text below headlines}
19757 Indent text to align with the headline.
19759 @example
19760 *** Third level
19761     more text, now indented
19762 @end example
19764 @vindex org-adapt-indentation
19765 Org supports this with paragraph filling, line wrapping, and
19766 structure editing, preserving or adapting the indentation as
19767 appropriate@footnote{Also see the variable @code{org-adapt-indentation}.}.
19769 @item @emph{Hiding leading stars}
19770 @vindex org-hide-leading-stars
19771 Org can make leading stars invisible.  For global preference,
19772 configure the variable @code{org-hide-leading-stars}.  For per-file
19773 preference, use these file @samp{STARTUP} options:
19775 @example
19776 #+STARTUP: hidestars
19777 #+STARTUP: showstars
19778 @end example
19780 With stars hidden, the tree is shown as:
19782 @example
19783 * Top level headline
19784  * Second level
19785   * Third level
19786   ...
19787 @end example
19789 @noindent
19790 @vindex org-hide, face
19791 Because Org makes the font color the same as the background color
19792 to hide to stars, sometimes @code{org-hide} face may need tweaking to
19793 get the effect right.  For some black and white combinations,
19794 @code{grey90} on a white background might mask the stars better.
19796 @item @emph{Odd levels}
19797 @vindex org-odd-levels-only
19798 Using stars for only odd levels, 1, 3, 5, @dots{}, can also clean up
19799 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
19800 on.}.
19801 For Org to properly handle this cleaner structure during edits
19802 and exports, configure the variable @code{org-odd-levels-only}.  To
19803 set this per-file, use either one of the following lines:
19805 @example
19806 #+STARTUP: odd
19807 #+STARTUP: oddeven
19808 @end example
19810 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}.
19811 @end table
19813 @node TTY Keys
19814 @section Using Org on a TTY
19816 @cindex tty key bindings
19818 Org provides alternative key bindings for TTY and modern mobile
19819 devices that cannot handle cursor keys and complex modifier key
19820 chords.  Some of these workarounds may be more cumbersome than
19821 necessary.  Users should look into customizing these further based on
19822 their usage needs.  For example, the normal @kbd{S-<cursor>} for
19823 editing timestamp might be better with @kbd{C-c .} chord.
19825 @multitable @columnfractions 0.2 0.28 0.15 0.21
19826 @headitem Default
19827 @tab Alternative 1
19828 @tab Speed key
19829 @tab Alternative 2
19830 @item @kbd{S-@key{TAB}}
19831 @tab @kbd{C-u @key{TAB}}
19832 @tab @kbd{C}
19833 @tab 
19834 @item @kbd{M-@key{LEFT}}
19835 @tab @kbd{C-c C-x l}
19836 @tab @kbd{l}
19837 @tab @kbd{Esc @key{LEFT}}
19838 @item @kbd{M-S-@key{LEFT}}
19839 @tab @kbd{C-c C-x L}
19840 @tab @kbd{L}
19841 @tab 
19842 @item @kbd{M-@key{RIGHT}}
19843 @tab @kbd{C-c C-x r}
19844 @tab @kbd{r}
19845 @tab @kbd{Esc @key{RIGHT}}
19846 @item @kbd{M-S-@key{RIGHT}}
19847 @tab @kbd{C-c C-x R}
19848 @tab @kbd{R}
19849 @tab 
19850 @item @kbd{M-@key{UP}}
19851 @tab @kbd{C-c C-x u}
19852 @tab 
19853 @tab @kbd{Esc @key{UP}}
19854 @item @kbd{M-S-@key{UP}}
19855 @tab @kbd{C-c C-x U}
19856 @tab @kbd{U}
19857 @tab 
19858 @item @kbd{M-@key{DOWN}}
19859 @tab @kbd{C-c C-x d}
19860 @tab 
19861 @tab @kbd{Esc @key{DOWN}}
19862 @item @kbd{M-S-@key{DOWN}}
19863 @tab @kbd{C-c C-x D}
19864 @tab @kbd{D}
19865 @tab 
19866 @item @kbd{S-@key{RET}}
19867 @tab @kbd{C-c C-x c}
19868 @tab 
19869 @tab 
19870 @item @kbd{M-@key{RET}}
19871 @tab @kbd{C-c C-x m}
19872 @tab 
19873 @tab @kbd{Esc @key{RET}}
19874 @item @kbd{M-S-@key{RET}}
19875 @tab @kbd{C-c C-x M}
19876 @tab 
19877 @tab 
19878 @item @kbd{S-@key{LEFT}}
19879 @tab @kbd{C-c @key{LEFT}}
19880 @tab 
19881 @tab 
19882 @item @kbd{S-@key{RIGHT}}
19883 @tab @kbd{C-c @key{RIGHT}}
19884 @tab 
19885 @tab 
19886 @item @kbd{S-@key{UP}}
19887 @tab @kbd{C-c @key{UP}}
19888 @tab 
19889 @tab 
19890 @item @kbd{S-@key{DOWN}}
19891 @tab @kbd{C-c @key{DOWN}}
19892 @tab 
19893 @tab 
19894 @item @kbd{C-S-@key{LEFT}}
19895 @tab @kbd{C-c C-x @key{LEFT}}
19896 @tab 
19897 @tab 
19898 @item @kbd{C-S-@key{RIGHT}}
19899 @tab @kbd{C-c C-x @key{RIGHT}}
19900 @tab 
19901 @tab 
19902 @end multitable
19904 @node Interaction
19905 @section Interaction with Other Packages
19907 @cindex packages, interaction with other
19909 Org's compatibility and the level of interaction with other Emacs
19910 packages are documented here.
19912 @menu
19913 * Cooperation::                  Packages Org cooperates with.
19914 * Conflicts::                    Packages that lead to conflicts.
19915 @end menu
19917 @node Cooperation
19918 @subsection Packages that Org cooperates with
19920 @table @asis
19921 @item @samp{calc.el} by Dave Gillespie
19922 @cindex @file{calc.el}
19924 Org uses the Calc package for implementing spreadsheet
19925 functionality in its tables (see @ref{The spreadsheet}).  Org also
19926 uses Calc for embedded calculations.  See @ref{Embedded Mode,GNU Emacs Calc Manual,,calc,}.
19928 @item @samp{constants.el} by Carsten Dominik
19929 @cindex @file{constants.el}
19930 @vindex org-table-formula-constants
19932 Org can use names for constants in formulas in tables.  Org can
19933 also use calculation suffixes for units, such as @samp{M} for @samp{Mega}.
19934 For a standard collection of such constants, install the
19935 @samp{constants} package.  Install version 2.0 of this package,
19936 available at @uref{http://www.astro.uva.nl/~dominik/Tools}.  Org checks
19937 if the function @code{constants-get} has been autoloaded.
19938 Installation instructions are in the file @samp{constants.el}.
19940 @item @samp{cdlatex.el} by Carsten Dominik
19941 @cindex @file{cdlatex.el}
19943 Org mode can make use of the CD@LaTeX{} package to efficiently enter
19944 @LaTeX{} fragments into Org files.  See @ref{CD@LaTeX{} mode}.
19946 @item @samp{imenu.el} by Ake Stenhoff and Lars Lindberg
19947 @cindex @file{imenu.el}
19949 Imenu creates dynamic menus based on an index of items in a file.
19950 Org mode supports Imenu menus.  Enable it with a mode hook as
19951 follows:
19953 @lisp
19954 (add-hook 'org-mode-hook
19955           (lambda () (imenu-add-to-menubar "Imenu")))
19956 @end lisp
19958 @vindex org-imenu-depth
19959 By default the index is two levels deep---you can modify the
19960 depth using the option @code{org-imenu-depth}.
19962 @item @samp{speedbar.el} by Eric M. Ludlam
19963 @cindex @file{speedbar.el}
19965 Speedbar package creates a special Emacs frame for displaying
19966 files and index items in files.  Org mode supports Speedbar;
19967 users can drill into Org files directly from the Speedbar.  The
19968 @kbd{<} in the Speedbar frame tweaks the agenda commands to
19969 that file or to a subtree.
19971 @item @samp{table.el} by Takaaki Ota
19972 @cindex table editor, @file{table.el}
19973 @cindex @file{table.el}
19975 Complex ASCII tables with automatic line wrapping, column- and
19976 row-spanning, and alignment can be created using the Emacs table
19977 package by Takaaki Ota.  Org mode recognizes such tables and
19978 exports them properly.  @kbd{C-c '} to edit these tables in
19979 a special buffer, much like Org's code blocks.  Because of
19980 interference with other Org mode functionality, Takaaki Ota
19981 tables cannot be edited directly in the Org buffer.
19983 @table @asis
19984 @item @kbd{C-c '} (@code{org-edit-special})
19985 @kindex C-c '
19986 @findex org-edit-special
19987 Edit a @samp{table.el} table.  Works when the cursor is in
19988 a @samp{table.el} table.
19990 @item @kbd{C-c ~​} (@code{org-table-create-with-table.el})
19991 @kindex C-c ~
19992 @findex org-table-create-with-table.el
19993 Insert a @samp{table.el} table.  If there is already a table at
19994 point, this command converts it between the @samp{table.el}
19995 format and the Org mode format.  See the documentation
19996 string of the command @code{org-convert-table} for the
19997 restrictions under which this is possible.
19998 @end table
19999 @end table
20001 @node Conflicts
20002 @subsection Packages that conflict with Org mode
20004 @cindex shift-selection-mode
20005 @vindex org-support-shift-select
20006 In Emacs, @code{shift-selection-mode} combines cursor motions with shift
20007 key to enlarge regions.  Emacs sets this mode by default.  This
20008 conflicts with Org's use of @kbd{S-<cursor>} commands to change
20009 timestamps, TODO keywords, priorities, and item bullet types, etc.
20010 Since @kbd{S-<cursor>} commands outside of specific contexts do
20011 not do anything, Org offers the variable @code{org-support-shift-select}
20012 for customization.  Org mode accommodates shift selection by (i)
20013 making it available outside of the special contexts where special
20014 commands apply, and (ii) extending an existing active region even if
20015 the cursor moves across a special context.
20017 @table @asis
20018 @item @samp{cua.el} by Kim. F. Storm
20019 @cindex @file{cua.el}
20020 @vindex org-replace-disputed-keys
20021 Org key bindings conflict with @kbd{S-<cursor>} keys used by
20022 CUA mode.  For Org to relinquish these bindings to CUA mode,
20023 configure the variable @code{org-replace-disputed-keys}.  When set,
20024 Org moves the following key bindings in Org files, and in the
20025 agenda buffer---but not during date selection.
20027 @multitable @columnfractions 0.4 0.4
20028 @item @kbd{S-@key{UP}}      @result{}  @kbd{M-p}
20029 @tab @kbd{S-@key{DOWN}}     @result{}  @kbd{M-n}
20030 @item @kbd{S-@key{LEFT}}    @result{}  @kbd{M--}
20031 @tab @kbd{S-@key{RIGHT}}    @result{}  @kbd{M-+}
20032 @item @kbd{C-S-@key{LEFT}}  @result{}  @kbd{M-S--}
20033 @tab @kbd{C-S-@key{RIGHT}}  @result{}  @kbd{M-S-+}
20034 @end multitable
20036 @vindex org-disputed-keys
20037 Yes, these are unfortunately more difficult to remember.  If you
20038 want to have other replacement keys, look at the variable
20039 @code{org-disputed-keys}.
20041 @item @samp{ecomplete.el} by Lars Magne Ingebrigtsen
20042 @cindex @file{ecomplete.el}
20043 Ecomplete provides ``electric'' address completion in address
20044 header lines in message buffers.  Sadly Orgtbl mode cuts
20045 Ecomplete's power supply: no completion happens when Orgtbl mode
20046 is enabled in message buffers while entering text in address
20047 header lines.  If one wants to use ecomplete one should @emph{not}
20048 follow the advice to automagically turn on Orgtbl mode in message
20049 buffers (see @ref{Orgtbl Mode}), but instead---after
20050 filling in the message headers---turn on Orgtbl mode manually
20051 when needed in the messages body.
20053 @item @samp{filladapt.el} by Kyle Jones
20054 @cindex @file{filladapt.el}
20055 Org mode tries to do the right thing when filling paragraphs,
20056 list items and other elements.  Many users reported problems
20057 using both @samp{filladapt.el} and Org mode, so a safe thing to do is
20058 to disable filladapt like this:
20060 @lisp
20061 (add-hook 'org-mode-hook 'turn-off-filladapt-mode)
20062 @end lisp
20064 @item @samp{viper.el} by Michael Kifer
20065 @cindex @file{viper.el}
20066 @kindex C-c /
20068 Viper uses @kbd{C-c /} and therefore makes this key not
20069 access the corresponding Org mode command @code{org-sparse-tree}.  You
20070 need to find another key for this command, or override the key in
20071 @code{viper-vi-global-user-map} with
20073 @lisp
20074 (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
20075 @end lisp
20077 @item @samp{windmove.el} by Hovav Shacham
20078 @cindex @file{windmove.el}
20080 This package also uses the @kbd{S-<cursor>} keys, so
20081 everything written in the paragraph above about CUA mode also
20082 applies here.  If you want to make the windmove function active
20083 in locations where Org mode does not have special functionality
20084 on @kbd{S-<cursor>}, add this to your configuration:
20086 @lisp
20087 ;; Make windmove work in Org mode:
20088 (add-hook 'org-shiftup-final-hook 'windmove-up)
20089 (add-hook 'org-shiftleft-final-hook 'windmove-left)
20090 (add-hook 'org-shiftdown-final-hook 'windmove-down)
20091 (add-hook 'org-shiftright-final-hook 'windmove-right)
20092 @end lisp
20094 @item @samp{yasnippet.el}
20095 @cindex @file{yasnippet.el}
20096 The way Org mode binds the @kbd{@key{TAB}} key (binding to @code{[tab]}
20097 instead of @code{"\t"}) overrules YASnippet's access to this key.  The
20098 following code fixed this problem:
20100 @lisp
20101 (add-hook 'org-mode-hook
20102           (lambda ()
20103             (setq-local yas/trigger-key [tab])
20104             (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
20105 @end lisp
20107 The latest version of YASnippet does not play well with Org mode.
20108 If the above code does not fix the conflict, start by defining
20109 the following function:
20111 @lisp
20112 (defun yas/org-very-safe-expand ()
20113   (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
20114 @end lisp
20116 Then, tell Org mode to use that function:
20118 @lisp
20119 (add-hook 'org-mode-hook
20120           (lambda ()
20121             (make-variable-buffer-local 'yas/trigger-key)
20122             (setq yas/trigger-key [tab])
20123             (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
20124             (define-key yas/keymap [tab] 'yas/next-field)))
20125 @end lisp
20126 @end table
20128 @node Org Crypt
20129 @section Org Crypt
20131 Org Crypt encrypts the text of an entry, but not the headline, or
20132 properties.  Behind the scene, it uses the Emacs EasyPG library to
20133 encrypt and decrypt files.
20135 @vindex org-crypt-tag-matcher
20136 Any text below a headline that has a @samp{crypt} tag is automatically
20137 encrypted when the file is saved.  To use a different tag, customize
20138 the @code{org-crypt-tag-matcher} setting.
20140 Here is a suggestion for Org Crypt settings in Emacs init file:
20142 @lisp
20143 (require 'org-crypt)
20144 (org-crypt-use-before-save-magic)
20145 (setq org-tags-exclude-from-inheritance '("crypt"))
20147 (setq org-crypt-key nil)
20148 ;; GPG key to use for encryption
20149 ;; Either the Key ID or set to nil to use symmetric encryption.
20151 (setq auto-save-default nil)
20152 ;; Auto-saving does not cooperate with org-crypt.el: so you need to
20153 ;; turn it off if you plan to use org-crypt.el quite often.  Otherwise,
20154 ;; you'll get an (annoying) message each time you start Org.
20156 ;; To turn it off only locally, you can insert this:
20158 ;; # -*- buffer-auto-save-file-name: nil; -*-
20159 @end lisp
20161 Excluding the @samp{crypt} tag from inheritance prevents already encrypted
20162 text from being encrypted again.
20164 @node Hacking
20165 @appendix Hacking
20167 @cindex hacking
20169 This appendix describes some ways a user can extend the functionality
20170 of Org.
20172 @menu
20173 * Hooks: Hooks (2).              How to reach into Org's internals.
20174 * Add-on Packages::              Available extensions.
20175 * Adding Hyperlink Types::       New custom link types.
20176 * Adding Export Back-ends::      How to write new export back-ends.
20177 * Tables in Arbitrary Syntax::   Orgtbl for LaTeX and other programs.
20178 * Dynamic Blocks::               Automatically filled blocks.
20179 * Special Agenda Views::         Customized views.
20180 * Speeding Up Your Agendas::     Tips on how to speed up your agendas.
20181 * Extracting Agenda Information:: Post-processing agenda information.
20182 * Using the Property API::       Writing programs that use entry properties.
20183 * Using the Mapping API::        Mapping over all or selected entries.
20184 @end menu
20186 @node Hooks (2)
20187 @appendixsec Hooks
20189 @cindex hooks
20191 Org has a large number of hook variables for adding functionality.
20192 This appendix illustrates using a few.  A complete list of hooks with
20193 documentation is maintained by the Worg project at
20194 @uref{https://orgmode.org/worg/doc.html#hooks}.
20196 @node Add-on Packages
20197 @appendixsec Add-on Packages
20199 @cindex add-on packages
20201 Various authors wrote a large number of add-on packages for Org.
20203 These packages are not part of Emacs, but they are distributed as
20204 contributed packages with the separate release available at
20205 @uref{https://orgmode.org}.  See the @samp{contrib/README} file in the source code
20206 directory for a list of contributed files.  Worg page with more
20207 information is at: @uref{https://orgmode.org/worg/org-contrib/}.
20209 @node Adding Hyperlink Types
20210 @appendixsec Adding Hyperlink Types
20212 @cindex hyperlinks, adding new types
20214 Org has many built-in hyperlink types (see @ref{Hyperlinks}), and an
20215 interface for adding new link types.  The following example shows the
20216 process of adding Org links to Unix man pages, which look like this
20218 @example
20219 [[man:printf][The printf manual]]
20220 @end example
20222 @noindent
20223 The following @samp{org-man.el} file implements it
20225 @lisp
20226 ;;; org-man.el - Support for links to man pages in Org mode
20227 (require 'org)
20229 (org-link-set-parameters "man"
20230                          :follow org-man-command
20231                          :export #'org-man-export
20232                          :store #'org-man-store-link)
20234 (defcustom org-man-command 'man
20235   "The Emacs command to be used to display a man page."
20236   :group 'org-link
20237   :type '(choice (const man) (const woman)))
20239 (defun org-man-store-link ()
20240   "Store a link to a man page."
20241   (when (memq major-mode '(Man-mode woman-mode))
20242     ;; This is a man page, we do make this link.
20243     (let* ((page (org-man-get-page-name))
20244            (link (concat "man:" page))
20245            (description (format "Man page for %s" page)))
20246       (org-store-link-props
20247        :type "man"
20248        :link link
20249        :description description))))
20251 (defun org-man-get-page-name ()
20252   "Extract the page name from the buffer name."
20253   ;; This works for both `Man-mode' and `woman-mode'.
20254   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
20255       (match-string 1 (buffer-name))
20256     (error "Cannot create link to this man page")))
20258 (defun org-man-export (link description format)
20259   "Export a man page link from Org files."
20260   (let ((path (format "http://man.he.net/?topic=%s&section=all" link))
20261         (desc (or description link)))
20262     (pcase format
20263       (`html (format "<a target=\"_blank\" href=\"%s\">%s</a>" path desc))
20264       (`latex (format "\\href@{%s@}@{%s@}" path desc))
20265       (`texinfo (format "@@uref@{%s,%s@}" path desc))
20266       (`ascii (format "%s (%s)" desc path))
20267       (t path))))
20269 (provide 'org-man)
20270 ;;; org-man.el ends here
20271 @end lisp
20273 @noindent
20274 To activate links to man pages in Org, enter this in the Emacs init
20275 file:
20277 @lisp
20278 (require 'org-man)
20279 @end lisp
20281 @noindent
20282 A review of @samp{org-man.el}:
20284 @enumerate
20285 @item
20286 First, @code{(require 'org)} ensures @samp{org.el} is loaded.
20288 @item
20289 @findex org-link-set-parameters
20290 @vindex org-link-parameters
20291 Then @code{org-link-set-parameters} defines a new link type with @samp{man}
20292 prefix and associates functions for following, exporting and
20293 storing such links.  See the variable @code{org-link-parameters} for
20294 a complete list of possible associations.
20296 @item
20297 The rest of the file implements necessary variables and functions.
20299 For example, @code{org-man-store-link} is responsible for storing a link
20300 when @code{org-store-link} (see @ref{Handling Links}) is called from a buffer
20301 displaying a man page.  It first checks if the @code{major-mode} is
20302 appropriate.  If check fails, the function returns @code{nil}, which
20303 means it isn't responsible for creating a link to the current
20304 buffer.  Otherwise the function makes a link string by combining
20305 the @samp{man:} prefix with the man topic.  It also provides a default
20306 description.  The function @code{org-insert-link} can insert it back
20307 into an Org buffer later on.
20308 @end enumerate
20310 @node Adding Export Back-ends
20311 @appendixsec Adding Export Back-ends
20313 @cindex Export, writing back-ends
20315 Org's export engine makes it easy for writing new back-ends.  The
20316 framework on which the engine was built makes it easy to derive new
20317 back-ends from existing ones.
20319 @findex org-export-define-backend
20320 @findex org-export-define-derived-backend
20321 The two main entry points to the export engine are:
20322 @code{org-export-define-backend} and @code{org-export-define-derived-backend}.
20323 To grok these functions, see @samp{ox-latex.el} for an example of defining
20324 a new back-end from scratch, and @samp{ox-beamer.el} for an example of
20325 deriving from an existing engine.
20327 For creating a new back-end from scratch, first set its name as
20328 a symbol in an alist consisting of elements and export functions.  To
20329 make the back-end visible to the export dispatcher, set @code{:menu-entry}
20330 keyword.  For export options specific to this back-end, set the
20331 @code{:options-alist}.
20333 For creating a new back-end from an existing one, set
20334 @code{:translate-alist} to an alist of export functions.  This alist
20335 replaces the parent back-end functions.
20337 For complete documentation, see @uref{https://orgmode.org/worg/dev/org-export-reference.html, the Org Export Reference on Worg}.
20339 @node Tables in Arbitrary Syntax
20340 @appendixsec Tables in Arbitrary Syntax
20342 @cindex tables, in other modes
20343 @cindex lists, in other modes
20344 @cindex Orgtbl mode
20346 Due to Org's success in handling tables with Orgtbl, a frequently
20347 requested feature is the use of Org's table functions in other modes,
20348 e.g., @LaTeX{}.  This would be hard to do in a general way without
20349 complicated customization nightmares.  Moreover, that would take Org
20350 away from its simplicity roots that Orgtbl has proven.  There is,
20351 however, an alternate approach to accomplishing the same.
20353 This approach involves implementing a custom @emph{translate} function that
20354 operates on a native Org @emph{source table} to produce a table in another
20355 format.  This strategy would keep the excellently working Orgtbl
20356 simple and isolate complications, if any, confined to the translate
20357 function.  To add more alien table formats, we just add more translate
20358 functions.  Also the burden of developing custom translate functions
20359 for new table formats is in the hands of those who know those formats
20360 best.
20362 @menu
20363 * Radio tables::                 Sending and receiving radio tables.
20364 * A @LaTeX{} example::           Step by step, almost a tutorial.
20365 * Translator functions::         Copy and modify.
20366 @end menu
20368 @node Radio tables
20369 @appendixsubsec Radio tables
20371 @cindex radio tables
20373 Radio tables are target locations for translated tables that are not near
20374 their source.  Org finds the target location and inserts the translated
20375 table.
20377 The key to finding the target location is the magic words @samp{BEGIN/END
20378 RECEIVE ORGTBL}.  They have to appear as comments in the current mode.
20379 If the mode is C, then:
20381 @example
20382 /* BEGIN RECEIVE ORGTBL table_name */
20383 /* END RECEIVE ORGTBL table_name */
20384 @end example
20386 @noindent
20387 At the location of source, Org needs a special line to direct Orgtbl
20388 to translate and to find the target for inserting the translated
20389 table.  For example:
20391 @cindex @samp{ORGTBL}, keyword
20392 @example
20393 #+ORGTBL: SEND table_name translation_function arguments ...
20394 @end example
20396 @noindent
20397 @samp{table_name} is the table's reference name, which is also used in the
20398 receiver lines, and the @samp{translation_function} is the Lisp function
20399 that translates.  This line, in addition, may also contain alternating
20400 key and value arguments at the end.  The translation function gets
20401 these values as a property list.  A few standard parameters are
20402 already recognized and acted upon before the translation function is
20403 called:
20405 @table @asis
20406 @item @samp{:skip N}
20407 Skip the first N lines of the table.  Hlines do count; include
20408 them if they are to be skipped.
20410 @item @samp{:skipcols (n1 n2 ...)}
20411 List of columns to be skipped.  First Org automatically discards
20412 columns with calculation marks and then sends the table to the
20413 translator function, which then skips columns as specified in
20414 @samp{skipcols}.
20415 @end table
20417 @noindent
20418 To keep the source table intact in the buffer without being disturbed
20419 when the source file is compiled or otherwise being worked on, use one
20420 of these strategies:
20422 @itemize
20423 @item
20424 Place the table in a block comment.  For example, in C mode you
20425 could wrap the table between @samp{/*} and @samp{*/} lines.
20427 @item
20428 Put the table after an ``end'' statement.  For example @code{\bye} in @TeX{}
20429 and @code{\end@{document@}} in @LaTeX{}.
20431 @item
20432 Comment and un-comment each line of the table during edits.  The
20433 @kbd{M-x orgtbl-toggle-comment} command makes toggling easy.
20434 @end itemize
20436 @node A @LaTeX{} example
20437 @appendixsubsec A @LaTeX{} example of radio tables
20439 @cindex @LaTeX{}, and Orgtbl mode
20441 To wrap a source table in @LaTeX{}, use the @samp{comment} environment
20442 provided by @samp{comment.sty}@footnote{@uref{https://ctan.org/tex-archive/macros/latex/contrib/comment?lang=en}}.  To activate it, put
20443 @code{\usepackage@{comment@}} in the document header.  Orgtbl mode inserts
20444 a radio table skeleton@footnote{Because @samp{LEVEL=2} has 3 stars, @samp{LEVEL=3} has 4 stars, and so
20445 on.} with the command @kbd{M-x orgtbl-insert-radio-table}, which prompts for a table name.  For
20446 example, if @samp{salesfigures} is the name, the template inserts:
20448 @example
20449 % BEGIN RECEIVE ORGTBL salesfigures
20450 % END RECEIVE ORGTBL salesfigures
20451 \begin@{comment@}
20452 #+ORGTBL: SEND salesfigures orgtbl-to-latex
20453 | | |
20454 \end@{comment@}
20455 @end example
20457 @vindex LaTeX-verbatim-environments
20458 @noindent
20459 The line @samp{#+ORGTBL: SEND} tells Orgtbl mode to use the function
20460 @code{orgtbl-to-latex} to convert the table to @LaTeX{} format, then insert
20461 the table at the target (receive) location named @samp{salesfigures}.  Now
20462 the table is ready for data entry.  It can even use spreadsheet
20463 features@footnote{If the @samp{TBLFM} keyword contains an odd number of dollar
20464 characters, this may cause problems with Font Lock in @LaTeX{} mode.  As
20465 shown in the example you can fix this by adding an extra line inside
20466 the @samp{comment} environment that is used to balance the dollar
20467 expressions.  If you are using AUC@TeX{} with the font-latex library,
20468 a much better solution is to add the @samp{comment} environment to the
20469 variable @code{LaTeX-verbatim-environments}.}:
20471 @example
20472 % BEGIN RECEIVE ORGTBL salesfigures
20473 % END RECEIVE ORGTBL salesfigures
20474 \begin@{comment@}
20475 #+ORGTBL: SEND salesfigures orgtbl-to-latex
20476 | Month | Days | Nr sold | per day |
20477 |-------+------+---------+---------|
20478 | Jan   |   23 |      55 |     2.4 |
20479 | Feb   |   21 |      16 |     0.8 |
20480 | March |   22 |     278 |    12.6 |
20481 #+TBLFM: $4=$3/$2;%.1f
20482 % $ (optional extra dollar to keep Font Lock happy, see footnote)
20483 \end@{comment@}
20484 @end example
20486 @noindent
20487 After editing, @kbd{C-c C-c} inserts the translated table at the
20488 target location, between the two marker lines.
20490 For hand-made custom tables, note that the translator needs to skip
20491 the first two lines of the source table.  Also the command has to
20492 @emph{splice} out the target table without the header and footer.
20494 @example
20495 \begin@{tabular@}@{lrrr@}
20496 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
20497 % BEGIN RECEIVE ORGTBL salesfigures
20498 % END RECEIVE ORGTBL salesfigures
20499 \end@{tabular@}
20501 \begin@{comment@}
20502 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
20503 | Month | Days | Nr sold | per day |
20504 |-------+------+---------+---------|
20505 | Jan   |   23 |      55 |     2.4 |
20506 | Feb   |   21 |      16 |     0.8 |
20507 | March |   22 |     278 |    12.6 |
20508 #+TBLFM: $4=$3/$2;%.1f
20509 \end@{comment@}
20510 @end example
20512 The @LaTeX{} translator function @code{orgtbl-to-latex} is already part of
20513 Orgtbl mode and uses a @samp{tabular} environment to typeset the table and
20514 marks horizontal lines with @code{\hline}.  For additional parameters to
20515 control output, see @ref{Translator functions}:
20517 @table @asis
20518 @item @code{:splice nil/t}
20519 When non-@code{nil}, return only table body lines; not wrapped in
20520 tabular environment.  Default is @code{nil}.
20522 @item @code{:fmt FMT}
20523 Format to warp each field.  It should contain @samp{%s} for the
20524 original field value.  For example, to wrap each field value in
20525 dollar symbol, you could use @samp{:fmt "$%s$"}.  Format can also wrap
20526 a property list with column numbers and formats, for example
20527 @samp{:fmt (2 "$%s$" 4 "%s\\%%")}.  In place of a string, a function
20528 of one argument can be used; the function must return a formatted
20529 string.
20531 @item @code{:efmt EFMT}
20532 Format numbers as exponentials.  The spec should have @samp{%s} twice
20533 for inserting mantissa and exponent, for example
20534 @samp{"%s\\times10^@{%s@}"}.  This may also be a property list with
20535 column numbers and formats, for example @samp{:efmt (2
20536      "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
20537 @var{EFMT} has been applied to a value, @var{FMT}---see
20538 above---is also be applied.  Functions with two arguments can be
20539 supplied instead of strings.  By default, no special formatting
20540 is applied.
20541 @end table
20543 @node Translator functions
20544 @appendixsubsec Translator functions
20546 @cindex HTML, and Orgtbl mode
20547 @cindex translator function
20549 @findex orgtbl-to-csv
20550 @findex orgtbl-to-tsv
20551 @findex orgtbl-to-latex
20552 @findex orgtbl-to-html
20553 @findex orgtbl-to-texinfo
20554 @findex orgtbl-to-unicode
20555 @findex orgtbl-to-orgtbl
20556 @findex orgtbl-to-generic
20557 Orgtbl mode has built-in translator functions: @code{orgtbl-to-csv}
20558 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values),
20559 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, @code{orgtbl-to-texinfo},
20560 @code{orgtbl-to-unicode} and @code{orgtbl-to-orgtbl}.  They use the generic
20561 translator, @code{orgtbl-to-generic}, which delegates translations to
20562 various export back-ends.
20564 Properties passed to the function through the @samp{ORGTBL SEND} line take
20565 precedence over properties defined inside the function.  For example,
20566 this overrides the default @LaTeX{} line endings, @code{\\}, with @code{\\[2mm]}:
20568 @example
20569 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
20570 @end example
20572 For a new language translator, define a converter function.  It can be
20573 a generic function, such as shown in this example.  It marks
20574 a beginning and ending of a table with @samp{!BTBL!} and @samp{!ETBL!};
20575 a beginning and ending of lines with @samp{!BL!} and @samp{!EL!}; and uses a TAB
20576 for a field separator:
20578 @lisp
20579 (defun orgtbl-to-language (table params)
20580   "Convert the orgtbl-mode TABLE to language."
20581   (orgtbl-to-generic
20582    table
20583    (org-combine-plists
20584     '(:tstart "!BTBL!" :tend "!ETBL!" :lstart "!BL!" :lend "!EL!" :sep "\t")
20585     params)))
20586 @end lisp
20588 @noindent
20589 The documentation for the @code{orgtbl-to-generic} function shows
20590 a complete list of parameters, each of which can be passed through to
20591 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function using
20592 that generic function.
20594 For complicated translations the generic translator function could be
20595 replaced by a custom translator function.  Such a custom function must
20596 take two arguments and return a single string containing the formatted
20597 table.  The first argument is the table whose lines are a list of
20598 fields or the symbol @code{hline}.  The second argument is the property
20599 list consisting of parameters specified in the @samp{#+ORGTBL: SEND} line.
20600 Please share your translator functions by posting them to the Org
20601 users mailing list, at @email{emacs-orgmode@@gnu.org}.
20603 @node Dynamic Blocks
20604 @appendixsec Dynamic Blocks
20606 @cindex dynamic blocks
20608 Org supports @emph{dynamic blocks} in Org documents.  They are inserted
20609 with begin and end markers like any other code block, but the contents
20610 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
20611 @ref{Clocking Work Time}).
20613 Dynamic blocks can have names and function parameters.  The syntax is
20614 similar to source code block specifications:
20616 @example
20617 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
20618   ...
20619 #+END:
20620 @end example
20622 These commands update dynamic blocks:
20624 @table @asis
20625 @item @kbd{C-c C-x C-u} (@code{org-dblock-update})
20626 @kindex C-c C-x C-u
20627 @findex org-dblock-update
20628 Update dynamic block at point.
20630 @item @kbd{C-u C-c C-x C-u}
20631 @kindex C-u C-c C-x C-u
20632 Update all dynamic blocks in the current file.
20633 @end table
20635 Before updating a dynamic block, Org removes content between the
20636 @samp{BEGIN} and @samp{END} markers.  Org then reads the parameters on the
20637 @samp{BEGIN} line for passing to the writer function.  If the function
20638 expects to access the removed content, then Org expects an extra
20639 parameter, @samp{:content}, on the @samp{BEGIN} line.
20641 The syntax for naming a writer function with a dynamic block labelled
20642 @samp{myblock} is: @code{org-dblock-write:myblock}.  Parameters come from the
20643 @samp{BEGIN} line.
20645 The following is an example of a dynamic block and a block writer function
20646 that updates the time when the function was last run:
20648 @example
20649 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
20650   ...
20651 #+END:
20652 @end example
20654 @noindent
20655 The dynamic block's writer function:
20657 @lisp
20658 (defun org-dblock-write:block-update-time (params)
20659   (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
20660     (insert "Last block update at: "
20661             (format-time-string fmt))))
20662 @end lisp
20664 To keep dynamic blocks up-to-date in an Org file, use the function,
20665 @code{org-update-all-dblocks} in hook, such as @code{before-save-hook}.  The
20666 @code{org-update-all-dblocks} function does not run if the file is not in
20667 Org mode.
20669 @findex org-narrow-to-block
20670 Dynamic blocks, like any other block, can be narrowed with
20671 @code{org-narrow-to-block}.
20673 @node Special Agenda Views
20674 @appendixsec Special Agenda Views
20676 @cindex agenda views, user-defined
20678 @vindex org-agenda-skip-function
20679 @vindex org-agenda-skip-function-global
20680 Org provides a special hook to further limit items in agenda views:
20681 @code{agenda}, @code{agenda*}@footnote{The @code{agenda*} view is the same as @code{agenda} except that it
20682 only considers @emph{appointments}, i.e., scheduled and deadline items that
20683 have a time specification @samp{[h]h:mm} in their time-stamps.}, @code{todo}, @code{alltodo}, @code{tags}, @code{tags-todo},
20684 @code{tags-tree}.  Specify a custom function that tests inclusion of every
20685 matched item in the view.  This function can also skip as much as is
20686 needed.
20688 For a global condition applicable to agenda views, use the
20689 @code{org-agenda-skip-function-global} variable.  Org uses a global
20690 condition with @code{org-agenda-skip-function} for custom searching.
20692 This example defines a function for a custom view showing TODO items
20693 with @samp{waiting} status.  Manually this is a multi-step search process,
20694 but with a custom view, this can be automated as follows:
20696 The custom function searches the subtree for the @samp{waiting} tag and
20697 returns @code{nil} on match.  Otherwise it gives the location from where
20698 the search continues.
20700 @lisp
20701 (defun my-skip-unless-waiting ()
20702   "Skip trees that are not waiting"
20703   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
20704     (if (re-search-forward ":waiting:" subtree-end t)
20705         nil          ; tag found, do not skip
20706       subtree-end))) ; tag not found, continue after end of subtree
20707 @end lisp
20709 To use this custom function in a custom agenda command:
20711 @lisp
20712 (org-add-agenda-custom-command
20713  '("b" todo "PROJECT"
20714    ((org-agenda-skip-function 'my-skip-unless-waiting)
20715     (org-agenda-overriding-header "Projects waiting for something: "))))
20716 @end lisp
20718 @vindex org-agenda-overriding-header
20719 Note that this also binds @code{org-agenda-overriding-header} to a more
20720 meaningful string suitable for the agenda view.
20722 @vindex org-odd-levels-only
20723 @vindex org-agenda-skip-function
20724 Search for entries with a limit set on levels for the custom search.
20725 This is a general approach to creating custom searches in Org.  To
20726 include all levels, use @samp{LEVEL>0}@footnote{Note that, for @code{org-odd-levels-only}, a level number
20727 corresponds to order in the hierarchy, not to the number of stars.}.  Then to selectively pick
20728 the matched entries, use @code{org-agenda-skip-function}, which also
20729 accepts Lisp forms, such as @code{org-agenda-skip-entry-if} and
20730 @code{org-agenda-skip-subtree-if}.  For example:
20732 @table @asis
20733 @item @code{(org-agenda-skip-entry-if 'scheduled)}
20734 Skip current entry if it has been scheduled.
20736 @item @code{(org-agenda-skip-entry-if 'notscheduled)}
20737 Skip current entry if it has not been scheduled.
20739 @item @code{(org-agenda-skip-entry-if 'deadline)}
20740 Skip current entry if it has a deadline.
20742 @item @code{(org-agenda-skip-entry-if 'scheduled 'deadline)}
20743 Skip current entry if it has a deadline, or if it is scheduled.
20745 @item @code{(org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))}
20746 Skip current entry if the TODO keyword is TODO or WAITING.
20748 @item @code{(org-agenda-skip-entry-if 'todo 'done)}
20749 Skip current entry if the TODO keyword marks a DONE state.
20751 @item @code{(org-agenda-skip-entry-if 'timestamp)}
20752 Skip current entry if it has any timestamp, may also be deadline
20753 or scheduled.
20755 @item @code{(org-agenda-skip-entry-if 'regexp "regular expression")}
20756 Skip current entry if the regular expression matches in the
20757 entry.
20759 @item @code{(org-agenda-skip-entry-if 'notregexp "regular expression")}
20760 Skip current entry unless the regular expression matches.
20762 @item @code{(org-agenda-skip-subtree-if 'regexp "regular expression")}
20763 Same as above, but check and skip the entire subtree.
20764 @end table
20766 The following is an example of a search for @samp{waiting} without the
20767 special function:
20769 @lisp
20770 (org-add-agenda-custom-command
20771  '("b" todo "PROJECT"
20772    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
20773                                 'regexp ":waiting:"))
20774     (org-agenda-overriding-header "Projects waiting for something: "))))
20775 @end lisp
20777 @node Speeding Up Your Agendas
20778 @appendixsec Speeding Up Your Agendas
20780 @cindex agenda views, optimization
20782 Some agenda commands slow down when the Org files grow in size or
20783 number.  Here are tips to speed up:
20785 @itemize
20786 @item
20787 Reduce the number of Org agenda files to avoid slowdowns due to hard drive
20788 accesses.
20790 @item
20791 Reduce the number of DONE and archived headlines so agenda
20792 operations that skip over these can finish faster.
20794 @item
20795 Do not dim blocked tasks:
20796 @vindex org-agenda-dim-blocked-tasks
20798 @lisp
20799 (setq org-agenda-dim-blocked-tasks nil)
20800 @end lisp
20802 @item
20803 Stop preparing agenda buffers on startup:
20804 @vindex org-startup-folded
20805 @vindex org-agenda-inhibit-startup
20807 @lisp
20808 (setq org-agenda-inhibit-startup nil)
20809 @end lisp
20811 @item
20812 Disable tag inheritance for agendas:
20813 @vindex org-agenda-show-inherited-tags
20814 @vindex org-agenda-use-tag-inheritance
20816 @lisp
20817 (setq org-agenda-use-tag-inheritance nil)
20818 @end lisp
20819 @end itemize
20821 These options can be applied to selected agenda views.  For more
20822 details about generation of agenda views, see the docstrings for the
20823 relevant variables, and this @uref{https://orgmode.org/worg/agenda-optimization.html, dedicated Worg page} for agenda
20824 optimization.
20826 @node Extracting Agenda Information
20827 @appendixsec Extracting Agenda Information
20829 @cindex agenda, pipe
20830 @cindex scripts, for agenda processing
20832 Org provides commands to access agendas through Emacs batch mode.
20833 Through this command-line interface, agendas are automated for further
20834 processing or printing.
20836 @vindex org-agenda-custom-commands
20837 @findex org-batch-agenda
20838 @code{org-batch-agenda} creates an agenda view in ASCII and outputs to
20839 standard output.  This command takes one string parameter.  When
20840 string consists of a single character, Org uses it as a key to
20841 @code{org-agenda-custom-commands}.  These are the same ones available
20842 through the agenda dispatcher (see @ref{Agenda Dispatcher}).
20844 This example command line directly prints the TODO list to the printer:
20846 @example
20847 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
20848 @end example
20850 When the string parameter length is two or more characters, Org
20851 matches it with tags/TODO strings.  For example, this example command
20852 line prints items tagged with @samp{shop}, but excludes items tagged with
20853 @samp{NewYork}:
20855 @example
20856 emacs -batch -l ~/.emacs                                      \
20857       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
20858 @end example
20860 @noindent
20861 An example showing on-the-fly parameter modifications:
20863 @example
20864 emacs -batch -l ~/.emacs                                      \
20865    -eval '(org-batch-agenda "a"                               \
20866            org-agenda-span (quote month)                      \
20867            org-agenda-include-diary nil                       \
20868            org-agenda-files (quote ("~/org/project.org")))'   \
20869    | lpr
20870 @end example
20872 @noindent
20873 which produces an agenda for the next 30 days from just the
20874 @samp{~/org/projects.org} file.
20876 @findex org-batch-agenda-csv
20877 For structured processing of agenda output, use @code{org-batch-agenda-csv}
20878 with the following fields:
20880 @table @asis
20881 @item category
20882 The category of the item
20883 @item head
20884 The headline, without TODO keyword, TAGS and PRIORITY
20885 @item type
20886 The type of the agenda entry, can be
20888 @multitable {aaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
20889 @item @code{todo}
20890 @tab selected in TODO match
20891 @item @code{tagsmatch}
20892 @tab selected in tags match
20893 @item @code{diary}
20894 @tab imported from diary
20895 @item @code{deadline}
20896 @tab a deadline
20897 @item @code{scheduled}
20898 @tab scheduled
20899 @item @code{timestamp}
20900 @tab appointment, selected by timestamp
20901 @item @code{closed}
20902 @tab entry was closed on date
20903 @item @code{upcoming-deadline}
20904 @tab warning about nearing deadline
20905 @item @code{past-scheduled}
20906 @tab forwarded scheduled item
20907 @item @code{block}
20908 @tab entry has date block including date
20909 @end multitable
20911 @item todo
20912 The TODO keyword, if any
20913 @item tags
20914 All tags including inherited ones, separated by colons
20915 @item date
20916 The relevant date, like @samp{2007-2-14}
20917 @item time
20918 The time, like @samp{15:00-16:50}
20919 @item extra
20920 String with extra planning info
20921 @item priority-l
20922 The priority letter if any was given
20923 @item priority-n
20924 The computed numerical priority
20925 @end table
20927 @noindent
20928 If the selection of the agenda item was based on a timestamp,
20929 including those items with @samp{DEADLINE} and @samp{SCHEDULED} keywords, then
20930 Org includes date and time in the output.
20932 If the selection of the agenda item was based on a timestamp  (or
20933 deadline/scheduled), then Org includes date and time in the output.
20935 Here is an example of a post-processing script in Perl.  It takes the
20936 CSV output from Emacs and prints with a checkbox:
20938 @example
20939 #!/usr/bin/perl
20941 # define the Emacs command to run
20942 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
20944 # run it and capture the output
20945 $agenda = qx@{$cmd 2>/dev/null@};
20947 # loop over all lines
20948 foreach $line (split(/\n/,$agenda)) @{
20949     # get the individual values
20950     ($category,$head,$type,$todo,$tags,$date,$time,$extra,
20951      $priority_l,$priority_n) = split(/,/,$line);
20952     # process and print
20953     print "[ ] $head\n";
20955 @end example
20957 @node Using the Property API
20958 @appendixsec Using the Property API
20960 @cindex API, for properties
20961 @cindex properties, API
20963 Here is a description of the functions that can be used to work with
20964 properties.
20966 @defun org-entry-properties &optional pom which
20967 Get all properties of the entry at point-or-marker @var{POM}.
20968 This includes the TODO keyword, the tags, time strings for deadline,
20969 scheduled, and clocking, and any additional properties defined in the
20970 entry.  The return value is an alist.  Keys may occur multiple times
20971 if the property key was used several times.  @var{POM} may also
20972 be @code{nil}, in which case the current entry is used.  If
20973 @var{WHICH} is @code{nil} or @code{all}, get all properties.  If
20974 @var{WHICH} is @code{special} or @code{standard}, only get that subclass.
20975 @end defun
20977 @vindex org-use-property-inheritance
20978 @findex org-insert-property-drawer
20979 @defun org-entry-get pom property &optional inherit
20980 Get value of @var{PROPERTY} for entry at point-or-marker
20981 @var{POM}.  By default, this only looks at properties defined
20982 locally in the entry.  If @var{INHERIT} is non-@code{nil} and the
20983 entry does not have the property, then also check higher levels of the
20984 hierarchy.  If @var{INHERIT} is the symbol @code{selective}, use
20985 inheritance if and only if the setting of
20986 @code{org-use-property-inheritance} selects @var{PROPERTY} for
20987 inheritance.
20988 @end defun
20990 @defun org-entry-delete pom property
20991 Delete the property @var{PROPERTY} from entry at point-or-marker
20992 @var{POM}.
20993 @end defun
20995 @defun org-entry-put pom property value
20996 Set @var{PROPERTY} to @var{VALUES} for entry at
20997 point-or-marker POM.
20998 @end defun
21000 @defun org-buffer-property-keys &optional include-specials
21001 Get all property keys in the current buffer.
21002 @end defun
21004 @defun org-insert-property-drawer
21005 Insert a property drawer for the current entry.  Also
21006 @end defun
21008 @defun org-entry-put-multivalued-property pom property &rest values
21009 Set @var{PROPERTY} at point-or-marker @var{POM} to
21010 @var{VALUES}.  @var{VALUES} should be a list of strings.
21011 They are concatenated, with spaces as separators.
21012 @end defun
21014 @defun org-entry-get-multivalued-property pom property
21015 Treat the value of the property @var{PROPERTY} as
21016 a whitespace-separated list of values and return the values as a list
21017 of strings.
21018 @end defun
21020 @defun org-entry-add-to-multivalued-property pom property value
21021 Treat the value of the property @var{PROPERTY} as
21022 a whitespace-separated list of values and make sure that
21023 @var{VALUE} is in this list.
21024 @end defun
21026 @defun org-entry-remove-from-multivalued-property pom property value
21027 Treat the value of the property @var{PROPERTY} as
21028 a whitespace-separated list of values and make sure that
21029 @var{VALUE} is @emph{not} in this list.
21030 @end defun
21032 @defun org-entry-member-in-multivalued-property pom property value
21033 Treat the value of the property @var{PROPERTY} as
21034 a whitespace-separated list of values and check if @var{VALUE} is
21035 in this list.
21036 @end defun
21038 @defopt org-property-allowed-value-functions
21039 Hook for functions supplying allowed values for a specific property.
21040 The functions must take a single argument, the name of the property,
21041 and return a flat list of allowed values.  If @samp{:ETC} is one of the
21042 values, use the values as completion help, but allow also other values
21043 to be entered.  The functions must return @code{nil} if they are not
21044 responsible for this property.
21045 @end defopt
21047 @node Using the Mapping API
21048 @appendixsec Using the Mapping API
21050 @cindex API, for mapping
21051 @cindex mapping entries, API
21053 Org has sophisticated mapping capabilities to find all entries
21054 satisfying certain criteria.  Internally, this functionality is used
21055 to produce agenda views, but there is also an API that can be used to
21056 execute arbitrary functions for each or selected entries.  The main
21057 entry point for this API is:
21059 @defun org-map-entries func &optional match scope &rest skip
21060 Call @{@{@{(var(FUNC))@}@}@} at each headline selected by @var{MATCH}
21061 in @var{SCOPE}.
21063 @var{FUNC} is a function or a Lisp form.  With the cursor
21064 positioned at the beginning of the headline, call the function without
21065 arguments.  Org returns an alist of return values of calls to the
21066 function.
21068 To avoid preserving point, Org wraps the call to @var{FUNC} in
21069 save-excursion form.  After evaluation, Org moves the cursor to the
21070 end of the line that was just processed.  Search continues from that
21071 point forward.  This may not always work as expected under some
21072 conditions, such as if the current sub-tree was removed by a previous
21073 archiving operation.  In such rare circumstances, Org skips the next
21074 entry entirely when it should not.  To stop Org from such skips, make
21075 @var{FUNC} set the variable @code{org-map-continue-from} to a specific
21076 buffer position.
21078 @var{MATCH} is a tags/property/TODO match.  Org iterates only
21079 matched headlines.  Org iterates over all headlines when
21080 @var{MATCH} is @code{nil} or @code{t}.
21082 @var{SCOPE} determines the scope of this command.  It can be any
21085 @table @asis
21086 @item @code{nil}
21087 The current buffer, respecting the restriction, if any.
21089 @item @code{tree}
21090 The subtree started with the entry at point.
21092 @item @code{region}
21093 The entries within the active region, if any.
21095 @item @code{file}
21096 The current buffer, without restriction.
21098 @item @code{file-with-archives}
21099 The current buffer, and any archives associated with it.
21101 @item @code{agenda}
21102 All agenda files.
21104 @item @code{agenda-with-archives}
21105 All agenda files with any archive files associated with them.
21107 @item @code{(file1 file2 ...)}
21108 If this is a list, all files in the list are scanned.
21109 @end table
21111 @noindent
21112 The remaining arguments are treated as settings for the scanner's
21113 skipping facilities.  Valid arguments are:
21115 @table @asis
21116 @item @code{archive}
21117 Skip trees with the archive tag.
21119 @item @code{comment}
21120 Skip trees with the COMMENT keyword.
21122 @item function or Lisp form
21123 @vindex org-agenda-skip-function
21124 Used as value for @code{org-agenda-skip-function}, so whenever the
21125 function returns @code{t}, @var{FUNC} is called for that entry
21126 and search continues from the point where the function leaves it.
21127 @end table
21128 @end defun
21130 The mapping routine can call any arbitrary function, even functions
21131 that change meta data or query the property API (see @ref{Using the Property API}).  Here are some handy functions:
21133 @defun org-todo &optional arg
21134 Change the TODO state of the entry.  See the docstring of the
21135 functions for the many possible values for the argument
21136 @var{ARG}.
21137 @end defun
21139 @defun org-priority &optional action
21140 Change the priority of the entry.  See the docstring of this function
21141 for the possible values for @var{ACTION}.
21142 @end defun
21144 @defun org-toggle-tag tag &optional onoff
21145 Toggle the tag @var{TAG} in the current entry.  Setting
21146 @var{ONOFF} to either @code{on} or @code{off} does not toggle tag, but
21147 ensure that it is either on or off.
21148 @end defun
21150 @defun org-promote
21151 Promote the current entry.
21152 @end defun
21154 @defun org-demote
21155 Demote the current entry.
21156 @end defun
21158 This example turns all entries tagged with @samp{TOMORROW} into TODO
21159 entries with keyword @samp{UPCOMING}.  Org ignores entries in comment trees
21160 and archive trees.
21162 @lisp
21163 (org-map-entries '(org-todo "UPCOMING")
21164                  "+TOMORROW" 'file 'archive 'comment)
21165 @end lisp
21167 The following example counts the number of entries with TODO keyword
21168 @samp{WAITING}, in all agenda files.
21170 @lisp
21171 (length (org-map-entries t "/+WAITING" 'agenda))
21172 @end lisp
21174 @node MobileOrg
21175 @appendix MobileOrg
21177 @cindex iPhone
21178 @cindex smartphone
21179 @cindex android
21180 @cindex MobileOrg
21182 MobileOrg is a companion mobile app that runs on iOS and Android
21183 devices.  MobileOrg enables offline-views and capture support for an
21184 Org mode system that is rooted on a ``real'' computer.  MobileOrg can
21185 record changes to existing entries.
21187 The @uref{https://github.com/MobileOrg/, iOS implementation} for the @emph{iPhone/iPod Touch/iPad} series of
21188 devices, was started by Richard Moreland and is now in the hands of
21189 Sean Escriva.  Android users should check out @uref{http://wiki.github.com/matburt/mobileorg-android/, MobileOrg Android} by
21190 Matt Jones.  Though the two implementations are not identical, they
21191 offer similar features.
21193 This appendix describes Org's support for agenda view formats
21194 compatible with MobileOrg.  It also describes synchronizing changes,
21195 such as to notes, between MobileOrg and the computer.
21197 To change tags and TODO states in MobileOrg, first customize the
21198 variables @code{org-todo-keywords} and @code{org-tag-alist}.  These should cover
21199 all the important tags and TODO keywords, even if Org files use only
21200 some of them.  Though MobileOrg has in-buffer settings, it understands
21201 TODO states @emph{sets} (see @ref{Per-file keywords}) and
21202 @emph{mutually exclusive} tags (see @ref{Setting Tags}) only for those set in
21203 these variables.
21205 @menu
21206 * Setting Up the Staging Area::  For the mobile device.
21207 * Pushing to MobileOrg::         Uploading Org files and agendas.
21208 * Pulling from MobileOrg::       Integrating captured and flagged items.
21209 @end menu
21211 @node Setting Up the Staging Area
21212 @appendixsec Setting Up the Staging Area
21214 MobileOrg needs access to a file directory on a server to interact
21215 with Emacs.  With a public server, consider encrypting the files.
21216 MobileOrg version 1.5 supports encryption for the iPhone.  Org also
21217 requires @samp{openssl} installed on the local computer.  To turn on
21218 encryption, set the same password in MobileOrg and in Emacs.  Set the
21219 password in the variable @code{org-mobile-use-encryption}@footnote{If Emacs is configured for safe storing of passwords, then
21220 configure the variable, @code{org-mobile-encryption-password}; please read
21221 the docstring of that variable.}.  Note
21222 that even after MobileOrg encrypts the file contents, the file name
21223 remains visible on the file systems of the local computer, the server,
21224 and the mobile device.
21226 For a server to host files, consider options like @uref{http://dropbox.com, Dropbox.com}
21227 account@footnote{An alternative is to use a WebDAV server.  MobileOrg
21228 documentation has details of WebDAV server configuration.  Additional
21229 help is at this @uref{https://orgmode.org/worg/org-faq.html#mobileorg_webdav, FAQ entry}.}.  On first connection, MobileOrg creates a directory
21230 @samp{MobileOrg} on Dropbox.  Pass its location to Emacs through an
21231 initialisation file variable as follows:
21233 @lisp
21234 (setq org-mobile-directory "~/Dropbox/MobileOrg")
21235 @end lisp
21237 Org copies files to the above directory for MobileOrg.  Org also uses
21238 the same directory for sharing notes between Org and MobileOrg.
21240 @node Pushing to MobileOrg
21241 @appendixsec Pushing to MobileOrg
21243 @vindex org-mobile-files
21244 @vindex org-directory
21245 Org pushes files listed in @code{org-mobile-files} to
21246 @code{org-mobile-directory}.  Files include agenda files (as listed in
21247 @code{org-agenda-files}).  Customize @code{org-mobile-files} to add other files.
21248 File names are staged with paths relative to @code{org-directory}, so all
21249 files should be inside this directory@footnote{Symbolic links in @code{org-directory} need to have the same name
21250 as their targets.}.
21252 Push creates a special Org file @samp{agendas.org} with custom agenda views
21253 defined by the user@footnote{While creating the agendas, Org mode forces ID properties on
21254 all referenced entries, so that these entries can be uniquely
21255 identified if MobileOrg flags them for further action.  To avoid
21256 setting properties configure the variable
21257 @code{org-mobile-force-id-on-agenda-items} to @code{nil}.  Org mode then relies
21258 on outline paths, assuming they are unique.}.
21260 Finally, Org writes the file @samp{index.org}, containing links to other
21261 files.  MobileOrg reads this file first from the server to determine
21262 what other files to download for agendas.  For faster downloads,
21263 MobileOrg only reads files whose checksums@footnote{Checksums are stored automatically in the file
21264 @samp{checksums.dat}.} have changed.
21266 @node Pulling from MobileOrg
21267 @appendixsec Pulling from MobileOrg
21269 When MobileOrg synchronizes with the server, it pulls the Org files
21270 for viewing.  It then appends to the file @samp{mobileorg.org} on the
21271 server the captured entries, pointers to flagged and changed entries.
21272 Org integrates its data in an inbox file format.
21274 @enumerate
21275 @item
21276 @vindex org-mobile-inbox-for-pull
21277 Org moves all entries found in @samp{mobileorg.org}@footnote{The file will be empty after this operation.} and appends
21278 them to the file pointed to by the variable
21279 @code{org-mobile-inbox-for-pull}.  Each captured entry and each editing
21280 event is a top-level entry in the inbox file.
21282 @item
21283 After moving the entries, Org attempts changes to MobileOrg.  Some
21284 changes are applied directly and without user interaction.
21285 Examples include changes to tags, TODO state, headline and body
21286 text.  Entries for further action are tagged as @samp{FLAGGED}.  Org
21287 marks entries with problems with an error message in the inbox.
21288 They have to be resolved manually.
21290 @item
21291 Org generates an agenda view for flagged entries for user
21292 intervention to clean up.  For notes stored in flagged entries,
21293 MobileOrg displays them in the echo area when the cursor is on the
21294 corresponding agenda item.
21296 @table @asis
21297 @item @kbd{?}
21298 @kindex ?
21300 Pressing @kbd{?} displays the entire flagged note in
21301 another window.  Org also pushes it to the kill ring.  To
21302 store flagged note as a normal note, use @kbd{? z C-y C-c C-c}.  Pressing@kbd{?} twice does these things: first
21303 it removes the @samp{FLAGGED} tag; second, it removes the flagged
21304 note from the property drawer; third, it signals that manual
21305 editing of the flagged entry is now finished.
21306 @end table
21307 @end enumerate
21309 @kindex ? @r{(Agenda dispatcher)}
21310 From the agenda dispatcher, @kbd{?} returns to the view to finish
21311 processing flagged entries.  Note that these entries may not be the
21312 most recent since MobileOrg searches files that were last pulled.  To
21313 get an updated agenda view with changes since the last pull, pull
21314 again.
21316 @node History and Acknowledgments
21317 @appendix History and Acknowledgments
21321 @anchor{From Carsten}
21322 @appendixsec From Carsten
21324 Org was born in 2003, out of frustration over the user interface of
21325 the Emacs Outline mode.  I was trying to organize my notes and
21326 projects, and using Emacs seemed to be the natural way to go.
21327 However, having to remember eleven different commands with two or
21328 three keys per command, only to hide and show parts of the outline
21329 tree, that seemed entirely unacceptable to me.  Also, when using
21330 outlines to take notes, I constantly wanted to restructure the tree,
21331 organizing it parallel to my thoughts and plans.  @emph{Visibility cycling}
21332 and @emph{structure editing} were originally implemented in the package
21333 @samp{outline-magic.el}, but quickly moved to the more general @samp{org.el}.
21334 As this environment became comfortable for project planning, the next
21335 step was adding @emph{TODO entries}, basic @emph{timestamps}, and @emph{table
21336 support}.  These areas highlighted the two main goals that Org still
21337 has today: to be a new, outline-based, plain text mode with innovative
21338 and intuitive editing features, and to incorporate project planning
21339 functionality directly into a notes file.
21341 Since the first release, literally thousands of emails to me or to the
21342 @email{emacs-orgmode@@gnu.org, mailing list} have provided a constant stream of bug reports, feedback,
21343 new ideas, and sometimes patches and add-on code.  Many thanks to
21344 everyone who has helped to improve this package.  I am trying to keep
21345 here a list of the people who had significant influence in shaping one
21346 or more aspects of Org.  The list may not be complete, if I have
21347 forgotten someone, please accept my apologies and let me know.
21349 Before I get to this list, a few special mentions are in order:
21351 @table @asis
21352 @item Bastien Guerry
21353 Bastien has written a large number of extensions to Org (most of
21354 them integrated into the core by now), including the @LaTeX{}
21355 exporter and the plain list parser.  His support during the early
21356 days was central to the success of this project.  Bastien also
21357 invented Worg, helped establishing the Web presence of Org, and
21358 sponsored hosting costs for the orgmode.org website.  Bastien
21359 stepped in as maintainer of Org between 2011 and 2013, at a time
21360 when I desperately needed a break.
21362 @item Eric Schulte and Dan Davison
21363 Eric and Dan are jointly responsible for the Org Babel system,
21364 which turns Org into a multi-language environment for evaluating
21365 code and doing literate programming and reproducible research.
21366 This has become one of Org's killer features that define what Org
21367 is today.
21369 @item John Wiegley
21370 John has contributed a number of great ideas and patches directly
21371 to Org, including the attachment system (@samp{org-attach.el}),
21372 integration with Apple Mail (@samp{org-mac-message.el}), hierarchical
21373 dependencies of TODO items, habit tracking (@samp{org-habits.el}), and
21374 encryption (@samp{org-crypt.el}).  Also, the capture system is really
21375 an extended copy of his great @samp{remember.el}.
21377 @item Sebastian Rose
21378 Without Sebastian, the HTML/XHTML publishing of Org would be the
21379 pitiful work of an ignorant amateur.  Sebastian has pushed this
21380 part of Org onto a much higher level.  He also wrote
21381 @samp{org-info.js}, a Java script for displaying webpages derived from
21382 Org using an Info-like or a folding interface with single-key
21383 navigation.
21384 @end table
21386 @noindent
21387 See below for the full list of contributions! Again, please let me
21388 know what I am missing here!
21390 @anchor{From Bastien}
21391 @appendixsec From Bastien
21393 I (Bastien) have been maintaining Org between 2011 and 2013.  This
21394 appendix would not be complete without adding a few more
21395 acknowledgments and thanks.
21397 I am first grateful to Carsten for his trust while handing me over the
21398 maintainership of Org.  His unremitting support is what really helped
21399 me getting more confident over time, with both the community and the
21400 code.
21402 When I took over maintainership, I knew I would have to make Org more
21403 collaborative than ever, as I would have to rely on people that are
21404 more knowledgeable than I am on many parts of the code.  Here is
21405 a list of the persons I could rely on, they should really be
21406 considered co-maintainers, either of the code or the community:
21408 @table @asis
21409 @item Eric Schulte
21410 Eric is maintaining the Babel parts of Org.  His reactivity here
21411 kept me away from worrying about possible bugs here and let me
21412 focus on other parts.
21414 @item Nicolas Goaziou
21415 Nicolas is maintaining the consistency of the deepest parts of
21416 Org.  His work on @samp{org-element.el} and @samp{ox.el} has been
21417 outstanding, and it opened the doors for many new ideas and
21418 features.  He rewrote many of the old exporters to use the new
21419 export engine, and helped with documenting this major change.
21420 More importantly (if that's possible), he has been more than
21421 reliable during all the work done for Org 8.0, and always very
21422 reactive on the mailing list.
21424 @item Achim Gratz
21425 Achim rewrote the building process of Org, turning some @emph{ad hoc}
21426 tools into a flexible and conceptually clean process.  He
21427 patiently coped with the many hiccups that such a change can
21428 create for users.
21430 @item Nick Dokos
21431 The Org mode mailing list would not be such a nice place without
21432 Nick, who patiently helped users so many times.  It is impossible
21433 to overestimate such a great help, and the list would not be so
21434 active without him.
21435 @end table
21437 I received support from so many users that it is clearly impossible to
21438 be fair when shortlisting a few of them, but Org's history would not
21439 be complete if the ones above were not mentioned in this manual.
21441 @anchor{List of Contributions}
21442 @appendixsec List of Contributions
21444 @itemize
21445 @item
21446 Russel Adams came up with the idea for drawers.
21448 @item
21449 Thomas Baumann wrote @samp{org-bbdb.el} and @samp{org-mhe.el}.
21451 @item
21452 Christophe Bataillon created the great unicorn logo that we use on
21453 the Org mode website.
21455 @item
21456 Alex Bochannek provided a patch for rounding timestamps.
21458 @item
21459 Jan Böcker wrote @samp{org-docview.el}.
21461 @item
21462 Brad Bozarth showed how to pull RSS feed data into Org files.
21464 @item
21465 Tom Breton wrote @samp{org-choose.el}.
21467 @item
21468 Charles Cave's suggestion sparked the implementation of templates
21469 for Remember, which are now templates for capture.
21471 @item
21472 Pavel Chalmoviansky influenced the agenda treatment of items with
21473 specified time.
21475 @item
21476 Gregory Chernov patched support for Lisp forms into table
21477 calculations and improved XEmacs compatibility, in particular by
21478 porting @samp{nouline.el} to XEmacs.
21480 @item
21481 Sacha Chua suggested copying some linking code from Planner.
21483 @item
21484 Baoqiu Cui contributed the DocBook exporter.
21486 @item
21487 Eddward DeVilla proposed and tested checkbox statistics.  He also
21488 came up with the idea of properties, and that there should be an API
21489 for them.
21491 @item
21492 Nick Dokos tracked down several nasty bugs.
21494 @item
21495 Kees Dullemond used to edit projects lists directly in HTML and so
21496 inspired some of the early development, including HTML export.  He
21497 also asked for a way to narrow wide table columns.
21499 @item
21500 Thomas S. Dye contributed documentation on Worg and helped
21501 integrating the Org Babel documentation into the manual.
21503 @item
21504 Christian Egli converted the documentation into Texinfo format,
21505 inspired the agenda, patched CSS formatting into the HTML exporter,
21506 and wrote @samp{org-taskjuggler.el}.
21508 @item
21509 David Emery provided a patch for custom CSS support in exported HTML
21510 agendas.
21512 @item
21513 Nic Ferrier contributed mailcap and XOXO support.
21515 @item
21516 Miguel A.  Figueroa-Villanueva implemented hierarchical checkboxes.
21518 @item
21519 John Foerch figured out how to make incremental search show context
21520 around a match in a hidden outline tree.
21522 @item
21523 Raimar Finken wrote @samp{org-git-line.el}.
21525 @item
21526 Mikael Fornius works as a mailing list moderator.
21528 @item
21529 Austin Frank works as a mailing list moderator.
21531 @item
21532 Eric Fraga drove the development of Beamer export with ideas and
21533 testing.
21535 @item
21536 Barry Gidden did proofreading the manual in preparation for the book
21537 publication through Network Theory Ltd.
21539 @item
21540 Niels Giesen had the idea to automatically archive DONE trees.
21542 @item
21543 Nicolas Goaziou rewrote much of the plain list code.
21545 @item
21546 Kai Grossjohann pointed out key-binding conflicts with other
21547 packages.
21549 @item
21550 Brian Gough of Network Theory Ltd publishes the Org mode manual as
21551 a book.
21553 @item
21554 Bernt Hansen has driven much of the support for auto-repeating
21555 tasks, task state change logging, and the clocktable.  His clear
21556 explanations have been critical when we started to adopt the Git
21557 version control system.
21559 @item
21560 Manuel Hermenegildo has contributed various ideas, small fixes and
21561 patches.
21563 @item
21564 Phil Jackson wrote @samp{org-irc.el}.
21566 @item
21567 Scott Jaderholm proposed footnotes, control over whitespace between
21568 folded entries, and column view for properties.
21570 @item
21571 Matt Jones wrote MobileOrg Android.
21573 @item
21574 Tokuya Kameshima wrote @samp{org-wl.el} and @samp{org-mew.el}.
21576 @item
21577 Shidai Liu (``Leo'') asked for embedded @LaTeX{} and tested it.  He also
21578 provided frequent feedback and some patches.
21580 @item
21581 Matt Lundin has proposed last-row references for table formulas and
21582 named invisible anchors.  He has also worked a lot on the FAQ.
21584 @item
21585 David Maus wrote @samp{org-atom.el}, maintains the issues file for Org,
21586 and is a prolific contributor on the mailing list with competent
21587 replies, small fixes and patches.
21589 @item
21590 Jason F. McBrayer suggested agenda export to CSV format.
21592 @item
21593 Max Mikhanosha came up with the idea of refiling.
21595 @item
21596 Dmitri Minaev sent a patch to set priority limits on a per-file
21597 basis.
21599 @item
21600 Stefan Monnier provided a patch to keep the Emacs Lisp compiler
21601 happy.
21603 @item
21604 Richard Moreland wrote MobileOrg for the iPhone.
21606 @item
21607 Rick Moynihan proposed allowing multiple TODO sequences in a file
21608 and being able to quickly restrict the agenda to a subtree.
21610 @item
21611 Todd Neal provided patches for links to Info files and Elisp forms.
21613 @item
21614 Greg Newman refreshed the unicorn logo into its current form.
21616 @item
21617 Tim O'Callaghan suggested in-file links, search options for general
21618 file links, and tags.
21620 @item
21621 Osamu Okano wrote @samp{orgcard2ref.pl}, a Perl program to create a text
21622 version of the reference card.
21624 @item
21625 Takeshi Okano translated the manual and David O'Toole's tutorial
21626 into Japanese.
21628 @item
21629 Oliver Oppitz suggested multi-state TODO items.
21631 @item
21632 Scott Otterson sparked the introduction of descriptive text for
21633 links, among other things.
21635 @item
21636 Pete Phillips helped during the development of the TAGS feature,
21637 and provided frequent feedback.
21639 @item
21640 Martin Pohlack provided the code snippet to bundle character
21641 insertion into bundles of 20 for undo.
21643 @item
21644 T.V. Raman reported bugs and suggested improvements.
21646 @item
21647 Matthias Rempe (Oelde) provided ideas, Windows support, and quality
21648 control.
21650 @item
21651 Paul Rivier provided the basic implementation of named footnotes.
21652 He also acted as mailing list moderator for some time.
21654 @item
21655 Kevin Rogers contributed code to access VM files on remote hosts.
21657 @item
21658 Frank Ruell solved the mystery of the @samp{keymapp nil} bug, a conflict
21659 with @samp{allout.el}.
21661 @item
21662 Jason Riedy generalized the send-receive mechanism for Orgtbl
21663 tables with extensive patches.
21665 @item
21666 Philip Rooke created the Org reference card, provided lots of
21667 feedback, developed and applied standards to the Org documentation.
21669 @item
21670 Christian Schlauer proposed angular brackets around links, among
21671 other things.
21673 @item
21674 Paul Sexton wrote @samp{org-ctags.el}.
21676 @item
21677 Tom Shannon's @samp{organizer-mode.el} inspired linking to VM/BBDB/Gnus.
21679 @item
21680 Ilya Shlyakhter proposed the Archive Sibling, line numbering in
21681 literal examples, and remote highlighting for referenced code lines.
21683 @item
21684 Stathis Sideris wrote the @samp{ditaa.jar} ASCII to PNG converter that is
21685 now packaged into Org's @samp{contrib/} directory.
21687 @item
21688 Daniel Sinder came up with the idea of internal archiving by locking
21689 subtrees.
21691 @item
21692 Dale Smith proposed link abbreviations.
21694 @item
21695 James TD Smith has contributed a large number of patches for
21696 useful tweaks and features.
21698 @item
21699 Adam Spiers asked for global linking commands, inspired the link
21700 extension system, added support for Mairix, and proposed the mapping
21701 API.
21703 @item
21704 Ulf Stegemann created the table to translate special symbols to
21705 HTML, @LaTeX{}, UTF-8, Latin-1 and ASCII.
21707 @item
21708 Andy Stewart contributed code to @samp{org-w3m.el}, to copy
21709 HTML content with links transformation to Org syntax.
21711 @item
21712 David O'Toole wrote @samp{org-publish.el} and drafted the
21713 manual chapter about publishing.
21715 @item
21716 Jambunathan K. contributed the ODT exporter.
21718 @item
21719 Sebastien Vauban reported many issues with @LaTeX{} and Beamer export
21720 and enabled source code highlighting in Gnus.
21722 @item
21723 Stefan Vollmar organized a video-recorded talk at the
21724 Max-Planck-Institute for Neurology.  He also inspired the creation
21725 of a concept index for HTML export.
21727 @item
21728 Jürgen Vollmer contributed code generating the table of contents in
21729 HTML output.
21731 @item
21732 Samuel Wales has provided important feedback and bug reports.
21734 @item
21735 Chris Wallace provided a patch implementing the @samp{QUOTE} block.
21737 @item
21738 David Wainberg suggested archiving, and improvements to the
21739 linking system.
21741 @item
21742 Carsten Wimmer suggested some changes and helped fix a bug in
21743 linking to Gnus.
21745 @item
21746 Roland Winkler requested additional key bindings to make Org work on
21747 a TTY.
21749 @item
21750 Piotr Zielinski wrote @samp{org-mouse.el}, proposed agenda
21751 blocks and contributed various ideas and code snippets.
21753 @item
21754 Marco Wahl wrote @samp{org-eww.el}.
21755 @end itemize
21757 @node GNU Free Documentation License
21758 @appendix GNU Free Documentation License
21760 @include doclicense.texi
21762 @node Main Index
21763 @chapter Main Index
21765 @printindex cp
21767 @node Key Index
21768 @chapter Key Index
21770 @printindex ky
21772 @node Command and Function Index
21773 @chapter Command and Function Index
21775 @printindex fn
21777 @node Variable Index
21778 @chapter Variable Index
21780 This is not a complete index of variables and faces, only the ones
21781 that are mentioned in the manual.  For a more complete list, use
21782 @kbd{M-x org-customize} and then click yourself through the tree.
21784 @printindex vr
21786 @bye