org-manual: Sync with maint
[org-mode/org-tableheadings.git] / doc / org.texi
blob39dbafdfbae3ee9eadfcc77af4d4e2800b98163c
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:
2304 a tool-tip window then shows the full contents of the field.
2305 Alternatively, @kbd{C-h .} (@code{display-local-help}) reveals them,
2306 too.  For convenience, any change near the shrunk part of a column
2307 expands it.
2309 @vindex org-startup-shrink-all-tables
2310 Setting the option @code{org-startup-shrink-all-tables} shrinks all columns
2311 containing a width cookie in a file the moment it is visited.  You can
2312 also set this option on a per-file basis with:
2314 @example
2315 #+STARTUP: shrink
2316 @end example
2318 If you would like to overrule the automatic alignment of number-rich
2319 columns to the right and of string-rich columns to the left, you can
2320 use @samp{<r>}, @samp{<c>} or @samp{<l>} in a similar fashion.  You may also combine
2321 alignment and field width like this: @samp{<r10>}.
2323 Lines which only contain these formatting cookies are removed
2324 automatically upon exporting the document.
2326 @node Column Groups
2327 @section Column Groups
2329 @cindex grouping columns in tables
2331 When Org exports tables, it does so by default without vertical lines
2332 because that is visually more satisfying in general.  Occasionally
2333 however, vertical lines can be useful to structure a table into groups
2334 of columns, much like horizontal lines can do for groups of rows.  In
2335 order to specify column groups, you can use a special row where the
2336 first field contains only @samp{/}.  The further fields can either contain
2337 @samp{<} to indicate that this column should start a group, @samp{>} to indicate
2338 the end of a column, or @samp{<>} (no space between @samp{<} and @samp{>}) to make
2339 a column a group of its own.  Upon export, boundaries between column
2340 groups are marked with vertical lines.  Here is an example:
2342 @example
2343 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2344 |---+-----+-----+-----+---------+------------|
2345 | / |  <  |     |  >  |       < |          > |
2346 | 1 |  1  |  1  |  1  |       1 |          1 |
2347 | 2 |  4  |  8  | 16  |  1.4142 |     1.1892 |
2348 | 3 |  9  | 27  | 81  |  1.7321 |     1.3161 |
2349 |---+-----+-----+-----+---------+------------|
2350 #+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
2351 @end example
2353 It is also sufficient to just insert the column group starters after
2354 every vertical line you would like to have:
2356 @example
2357 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2358 |---+-----+-----+-----+---------+------------|
2359 | / | <   |     |     | <       |            |
2360 @end example
2362 @node Orgtbl Mode
2363 @section The Orgtbl Minor Mode
2365 @cindex Orgtbl mode
2366 @cindex minor mode for tables
2368 @findex orgtbl-mode
2369 If you like the intuitive way the Org table editor works, you might
2370 also want to use it in other modes like Text mode or Mail mode.  The
2371 minor mode Orgtbl mode makes this possible.  You can always toggle the
2372 mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
2373 example in Message mode, use
2375 @lisp
2376 (add-hook 'message-mode-hook 'turn-on-orgtbl)
2377 @end lisp
2379 Furthermore, with some special setup, it is possible to maintain
2380 tables in arbitrary syntax with Orgtbl mode.  For example, it is
2381 possible to construct @LaTeX{} tables with the underlying ease and power
2382 of Orgtbl mode, including spreadsheet capabilities.  For details, see
2383 @ref{Tables in Arbitrary Syntax}.
2385 @node The spreadsheet
2386 @section The spreadsheet
2388 @cindex calculations, in tables
2389 @cindex spreadsheet capabilities
2390 @cindex Calc package
2392 The table editor makes use of the Emacs Calc package to implement
2393 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms
2394 to derive fields from other fields.  While fully featured, Org's
2395 implementation is not identical to other spreadsheets.  For example,
2396 Org knows the concept of a @emph{column formula} that will be applied to
2397 all non-header fields in a column without having to copy the formula
2398 to each relevant field.  There is also a formula debugger, and
2399 a formula editor with features for highlighting fields in the table
2400 corresponding to the references at the point in the formula, moving
2401 these references by arrow keys.
2403 @menu
2404 * References::                   How to refer to another field or range.
2405 * Formula syntax for Calc::      Using Calc to compute stuff.
2406 * Formula syntax for Lisp::      Writing formulas in Emacs Lisp.
2407 * Durations and time values::    How to compute durations and time values.
2408 * Field and range formulas::     Formula for specific (ranges of) fields.
2409 * Column formulas::              Formulas valid for an entire column.
2410 * Lookup functions::             Lookup functions for searching tables.
2411 * Editing and debugging formulas:: Fixing formulas.
2412 * Updating the table::           Recomputing all dependent fields.
2413 * Advanced features::            Field and column names, automatic recalculation...
2414 @end menu
2416 @node References
2417 @subsection References
2419 @cindex references
2421 To compute fields in the table from other fields, formulas must
2422 reference other fields or ranges.  In Org, fields can be referenced by
2423 name, by absolute coordinates, and by relative coordinates.  To find
2424 out what the coordinates of a field are, press @kbd{C-c ?} in
2425 that field, or press @kbd{C-c @}} to toggle the display of a grid.
2427 @anchor{Field references}
2428 @subsubheading Field references
2430 @cindex field references
2431 @cindex references, to fields
2432 Formulas can reference the value of another field in two ways.  Like
2433 in any other spreadsheet, you may reference fields with
2434 a letter/number combination like @samp{B3}, meaning the second field in the
2435 third row.  However, Org prefers to use another, more general
2436 representation that looks like this:@footnote{Org understands references typed by the user as @samp{B4}, but it
2437 does not use this syntax when offering a formula for editing.  You can
2438 customize this behavior using the variable
2439 @code{org-table-use-standard-references}.}
2441 @example
2442 @@ROW$COLUMN
2443 @end example
2445 Column specifications can be absolute like @samp{$1}, @samp{$2}, @dots{}, @samp{$N}, or
2446 relative to the current column, i.e., the column of the field which is
2447 being computed, like @samp{$+1} or @samp{$-2}.  @samp{$<} and @samp{$>} are immutable
2448 references to the first and last column, respectively, and you can use
2449 @samp{$>>>} to indicate the third column from the right.
2451 The row specification only counts data lines and ignores horizontal
2452 separator lines, or ``hlines''.  Like with columns, you can use absolute
2453 row numbers @samp{@@1}, @samp{@@2}, @dots{}, @samp{@@N}, and row numbers relative to the
2454 current row like @samp{@@+3} or @samp{@@-1}.  @samp{@@<} and @samp{@@>} are immutable
2455 references the first and last row in the table, respectively.  You may
2456 also specify the row relative to one of the hlines: @samp{@@I} refers to the
2457 first hline, @samp{@@II} to the second, etc.  @samp{@@-I} refers to the first such
2458 line above the current line, @samp{@@+I} to the first such line below the
2459 current line.  You can also write @samp{@@III+2} which is the second data
2460 line after the third hline in the table.
2462 @samp{@@0} and @samp{$0} refer to the current row and column, respectively, i.e.,
2463 to the row/column for the field being computed.  Also, if you omit
2464 either the column or the row part of the reference, the current
2465 row/column is implied.
2467 Org's references with @emph{unsigned} numbers are fixed references in the
2468 sense that if you use the same reference in the formula for two
2469 different fields, the same field is referenced each time.  Org's
2470 references with @emph{signed} numbers are floating references because the
2471 same reference operator can reference different fields depending on
2472 the field being calculated by the formula.
2474 Here are a few examples:
2476 @multitable @columnfractions 0.2 0.8
2477 @item @samp{@@2$3}
2478 @tab 2nd row, 3rd column (same as @samp{C2})
2479 @item @samp{$5}
2480 @tab column 5 in the current row (same as @samp{E&})
2481 @item @samp{@@2}
2482 @tab current column, row 2
2483 @item @samp{@@-1$-3}
2484 @tab field one row up, three columns to the left
2485 @item @samp{@@-I$2}
2486 @tab field just under hline above current row, column 2
2487 @item @samp{@@>$5}
2488 @tab field in the last row, in column 5
2489 @end multitable
2491 @anchor{Range references}
2492 @subsubheading Range references
2494 @cindex range references
2495 @cindex references, to ranges
2496 You may reference a rectangular range of fields by specifying two
2497 field references connected by two dots @samp{..}.  If both fields are in
2498 the current row, you may simply use @samp{$2..$7}, but if at least one
2499 field is in a different row, you need to use the general @samp{@@ROW$COLUMN}
2500 format at least for the first field, i.e., the reference must start
2501 with @samp{@@} in order to be interpreted correctly.  Examples:
2503 @multitable @columnfractions 0.2 0.8
2504 @item @samp{$1..$3}
2505 @tab first three fields in the current row
2506 @item @samp{$P..$Q}
2507 @tab range, using column names (see @ref{Advanced features})
2508 @item @samp{$<<<..$>>}
2509 @tab start in third column, continue to the last but one
2510 @item @samp{@@2$1..@@4$3}
2511 @tab six fields between these two fields (same as @samp{A2..C4})
2512 @item @samp{@@-1$-2..@@-1}
2513 @tab 3 fields in the row above, starting from 2 columns on the left
2514 @item @samp{@@I..II}
2515 @tab between first and second hline, short for @samp{@@I..@@II}
2516 @end multitable
2518 @noindent
2519 Range references return a vector of values that can be fed into Calc
2520 vector functions.  Empty fields in ranges are normally suppressed, so
2521 that the vector contains only the non-empty fields.  For other options
2522 with the mode switches @samp{E}, @samp{N} and examples, see @ref{Formula syntax for Calc}.
2524 @anchor{Field coordinates in formulas}
2525 @subsubheading Field coordinates in formulas
2527 @cindex field coordinates
2528 @cindex coordinates, of field
2529 @cindex row, of field coordinates
2530 @cindex column, of field coordinates
2531 @vindex org-table-current-column
2532 @vindex org-table-current-dline
2533 One of the very first actions during evaluation of Calc formulas and
2534 Lisp formulas is to substitute @samp{@@#} and @samp{$#} in the formula with the
2535 row or column number of the field where the current result will go to.
2536 The traditional Lisp formula equivalents are @code{org-table-current-dline}
2537 and @code{org-table-current-column}.  Examples:
2539 @table @asis
2540 @item @samp{if(@@# % 2, $#, string(""))}
2541 Insert column number on odd rows, set field to empty on even
2542 rows.
2544 @item @samp{$2 = '(identity remote(FOO, @@@@#$1))}
2545 Copy text or values of each row of column 1 of the table named
2546 @var{FOO} into column 2 of the current table.
2548 @item @samp{@@3 = 2 * remote(FOO, @@@@1$$#)}
2549 Insert the doubled value of each column of row 1 of the table
2550 named @var{FOO} into row 3 of the current table.
2551 @end table
2553 @noindent
2554 For the second and third examples, table @var{FOO} must have at
2555 least as many rows or columns as the current table.  Note that this is
2556 inefficient@footnote{The computation time scales as O(N^2) because table
2557 @var{FOO} is parsed for each field to be copied.} for large number of rows.
2559 @anchor{Named references}
2560 @subsubheading Named references
2562 @cindex named references
2563 @cindex references, named
2564 @cindex name, of column or field
2565 @cindex constants, in calculations
2566 @cindex @samp{CONSTANTS}, keyword
2567 @vindex org-table-formula-constants
2569 @samp{$name} is interpreted as the name of a column, parameter or constant.
2570 Constants are defined globally through the variable
2571 @code{org-table-formula-constants}, and locally---for the file---through
2572 a line like this example:
2574 @example
2575 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2576 @end example
2578 @noindent
2579 @vindex constants-unit-system
2580 @pindex constants.el
2581 Also, properties (see @ref{Properties and Columns}) can be used as
2582 constants in table formulas: for a property @samp{Xyz} use the name
2583 @samp{$PROP_Xyz}, and the property will be searched in the current outline
2584 entry and in the hierarchy above it.  If you have the @samp{constants.el}
2585 package, it will also be used to resolve constants, including natural
2586 constants like @samp{$h} for Planck's constant, and units like @samp{$km} for
2587 kilometers@footnote{The file @samp{constants.el} can supply the values of constants in
2588 two different unit systems, @samp{SI} and @samp{cgs}.  Which one is used depends
2589 on the value of the variable @code{constants-unit-system}.  You can use the
2590 @samp{STARTUP} options @samp{constSI} and @samp{constcgs} to set this value for the
2591 current buffer.}.  Column names and parameters can be specified in
2592 special table lines.  These are described below, see @ref{Advanced features}.  All names must start with a letter, and further consist
2593 of letters and numbers.
2595 @anchor{Remote references}
2596 @subsubheading Remote references
2598 @cindex remote references
2599 @cindex references, remote
2600 @cindex references, to a different table
2601 @cindex name, of column or field
2602 @cindex @samp{NAME}, keyword
2603 You may also reference constants, fields and ranges from a different
2604 table, either in the current file or even in a different file.  The
2605 syntax is
2607 @example
2608 remote(NAME,REF)
2609 @end example
2611 @noindent
2612 where @var{NAME} can be the name of a table in the current file
2613 as set by a @samp{#+NAME:} line before the table.  It can also be the ID of
2614 an entry, even in a different file, and the reference then refers to
2615 the first table in that entry.  @var{REF} is an absolute field or
2616 range reference as described above for example @samp{@@3$3} or @samp{$somename},
2617 valid in the referenced table.
2619 @cindex table indirection
2620 When @var{NAME} has the format @samp{@@ROW$COLUMN}, it is substituted
2621 with the name or ID found in this field of the current table.  For
2622 example @samp{remote($1, @@@@>$2)} @result{} @samp{remote(year_2013, @@@@>$1)}.  The format
2623 @samp{B3} is not supported because it can not be distinguished from a plain
2624 table name or ID.
2626 @node Formula syntax for Calc
2627 @subsection Formula syntax for Calc
2629 @cindex formula syntax, Calc
2630 @cindex syntax, of formulas
2632 A formula can be any algebraic expression understood by the Emacs Calc
2633 package.  Note that Calc has the non-standard convention that @samp{/} has
2634 lower precedence than @samp{*}, so that @samp{a/b*c} is interpreted as
2635 @samp{(a/(b*c))}.  Before evaluation by @code{calc-eval} (see @ref{Calling Calc from Your Programs,Calling Calc from
2636 Your Lisp Programs,,calc,}), variable substitution takes place according to
2637 the rules described above.
2639 @cindex vectors, in table calculations
2640 The range vectors can be directly fed into the Calc vector functions
2641 like @code{vmean} and @code{vsum}.
2643 @cindex format specifier, in spreadsheet
2644 @cindex mode, for Calc
2645 @vindex org-calc-default-modes
2646 A formula can contain an optional mode string after a semicolon.  This
2647 string consists of flags to influence Calc and other modes during
2648 execution.  By default, Org uses the standard Calc modes (precision
2649 12, angular units degrees, fraction and symbolic modes off).  The
2650 display format, however, has been changed to @code{(float 8)} to keep
2651 tables compact.  The default settings can be configured using the
2652 variable @code{org-calc-default-modes}.
2654 @table @asis
2655 @item @samp{p20}
2656 Set the internal Calc calculation precision to 20 digits.
2658 @item @samp{n3}, @samp{s3}, @samp{e2}, @samp{f4}
2659 Normal, scientific, engineering or fixed format of the result of
2660 Calc passed back to Org.  Calc formatting is unlimited in
2661 precision as long as the Calc calculation precision is greater.
2663 @item @samp{D}, @samp{R}
2664 Degree and radian angle modes of Calc.
2666 @item @samp{F}, @samp{S}
2667 Fraction and symbolic modes of Calc.
2669 @item @samp{T}, @samp{t}, @samp{U}
2670 Duration computations in Calc or Lisp, @ref{Durations and time values}.
2672 @item @samp{E}
2673 If and how to consider empty fields.  Without @samp{E} empty fields in
2674 range references are suppressed so that the Calc vector or Lisp
2675 list contains only the non-empty fields.  With @samp{E} the empty
2676 fields are kept.  For empty fields in ranges or empty field
2677 references the value @samp{nan} (not a number) is used in Calc
2678 formulas and the empty string is used for Lisp formulas.  Add @samp{N}
2679 to use 0 instead for both formula types.  For the value of
2680 a field the mode @samp{N} has higher precedence than @samp{E}.
2682 @item @samp{N}
2683 Interpret all fields as numbers, use 0 for non-numbers.  See the
2684 next section to see how this is essential for computations with
2685 Lisp formulas.  In Calc formulas it is used only occasionally
2686 because there number strings are already interpreted as numbers
2687 without @samp{N}.
2689 @item @samp{L}
2690 Literal, for Lisp formulas only.  See the next section.
2691 @end table
2693 @noindent
2694 Unless you use large integer numbers or high-precision calculation and
2695 display for floating point numbers you may alternatively provide
2696 a @code{printf} format specifier to reformat the Calc result after it has
2697 been passed back to Org instead of letting Calc already do the
2698 formatting@footnote{The printf reformatting is limited in precision because the
2699 value passed to it is converted into an ``integer'' or ``double''.  The
2700 ``integer'' is limited in size by truncating the signed value to 32
2701 bits.  The ``double'' is limited in precision to 64 bits overall which
2702 leaves approximately 16 significant decimal digits.}.  A few examples:
2704 @multitable {aaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
2705 @item @samp{$1+$2}
2706 @tab Sum of first and second field
2707 @item @samp{$1+$2;%.2f}
2708 @tab Same, format result to two decimals
2709 @item @samp{exp($2)+exp($1)}
2710 @tab Math functions can be used
2711 @item @samp{$0;%.1f}
2712 @tab Reformat current cell to 1 decimal
2713 @item @samp{($3-32)*5/9}
2714 @tab Degrees F @arrow{} C conversion
2715 @item @samp{$c/$1/$cm}
2716 @tab Hz @arrow{} cm conversion, using @samp{constants.el}
2717 @item @samp{tan($1);Dp3s1}
2718 @tab Compute in degrees, precision 3, display SCI 1
2719 @item @samp{sin($1);Dp3%.1e}
2720 @tab Same, but use @code{printf} specifier for display
2721 @item @samp{vmean($2..$7)}
2722 @tab Compute column range mean, using vector function
2723 @item @samp{vmean($2..$7);EN}
2724 @tab Same, but treat empty fields as 0
2725 @item @samp{taylor($3,x=7,2)}
2726 @tab Taylor series of $3, at x=7, second degree
2727 @end multitable
2729 Calc also contains a complete set of logical operations (see @ref{Logical Operations,Logical
2730 Operations,,calc,}).  For example
2732 @table @asis
2733 @item @samp{if($1 < 20, teen, string(""))}
2734 @samp{"teen"} if age @samp{$1} is less than 20, else the Org table result
2735 field is set to empty with the empty string.
2737 @item @samp{if("$1" =} ``nan'' || ``$2'' @samp{= "nan", string(""), $1 + $2); E f-1}
2738 Sum of the first two columns.  When at least one of the input
2739 fields is empty the Org table result field is set to empty.  @samp{E}
2740 is required to not convert empty fields to 0.  @samp{f-1} is an
2741 optional Calc format string similar to @samp{%.1f} but leaves empty
2742 results empty.
2744 @item @samp{if(typeof(vmean($1..$7)) =} 12, string(``''), vmean($1..$7); E=
2745 Mean value of a range unless there is any empty field.  Every
2746 field in the range that is empty is replaced by @samp{nan} which lets
2747 @samp{vmean} result in @samp{nan}.  Then @samp{typeof =} 12= detects the @samp{nan}
2748 from @code{vmean} and the Org table result field is set to empty.  Use
2749 this when the sample set is expected to never have missing
2750 values.
2752 @item @samp{if("$1..$7" =} ``[]'', string(``''), vmean($1..$7))=
2753 Mean value of a range with empty fields skipped.  Every field in
2754 the range that is empty is skipped.  When all fields in the range
2755 are empty the mean value is not defined and the Org table result
2756 field is set to empty.  Use this when the sample set can have
2757 a variable size.
2759 @item @samp{vmean($1..$7); EN}
2760 To complete the example before: Mean value of a range with empty
2761 fields counting as samples with value 0.  Use this only when
2762 incomplete sample sets should be padded with 0 to the full size.
2763 @end table
2765 You can add your own Calc functions defined in Emacs Lisp with
2766 @code{defmath} and use them in formula syntax for Calc.
2768 @node Formula syntax for Lisp
2769 @subsection Emacs Lisp forms as formulas
2771 @cindex Lisp forms, as table formulas
2773 It is also possible to write a formula in Emacs Lisp.  This can be
2774 useful for string manipulation and control structures, if Calc's
2775 functionality is not enough.
2777 If a formula starts with a single-quote followed by an opening
2778 parenthesis, then it is evaluated as a Lisp form.  The evaluation
2779 should return either a string or a number.  Just as with Calc
2780 formulas, you can specify modes and a @code{printf} format after
2781 a semicolon.
2783 With Emacs Lisp forms, you need to be conscious about the way field
2784 references are interpolated into the form.  By default, a reference is
2785 interpolated as a Lisp string (in double-quotes) containing the field.
2786 If you provide the @samp{N} mode switch, all referenced elements are
2787 numbers---non-number fields will be zero---and interpolated as Lisp
2788 numbers, without quotes.  If you provide the @samp{L} flag, all fields are
2789 interpolated literally, without quotes.  I.e., if you want a reference
2790 to be interpreted as a string by the Lisp form, enclose the reference
2791 operator itself in double-quotes, like @samp{"$3"}.  Ranges are inserted as
2792 space-separated fields, so you can embed them in list or vector
2793 syntax.
2795 Here are a few examples---note how the @samp{N} mode is used when we do
2796 computations in Lisp:
2798 @table @asis
2799 @item @samp{'(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))}
2800 Swap the first two characters of the content of column 1.
2802 @item @samp{'(+ $1 $2);N}
2803 Add columns 1 and 2, equivalent to Calc's @samp{$1+$2}.
2805 @item @samp{'(apply '+ '($1..$4));N}
2806 Compute the sum of columns 1 to 4, like Calc's @samp{vsum($1..$4)}.
2807 @end table
2809 @node Durations and time values
2810 @subsection Durations and time values
2812 @cindex Duration, computing
2813 @cindex Time, computing
2814 @vindex org-table-duration-custom-format
2816 If you want to compute time values use the @samp{T}, @samp{t}, or @samp{U} flag,
2817 either in Calc formulas or Elisp formulas:
2819 @example
2820 |  Task 1 |   Task 2 |    Total |
2821 |---------+----------+----------|
2822 |    2:12 |     1:47 | 03:59:00 |
2823 |    2:12 |     1:47 |    03:59 |
2824 | 3:02:20 | -2:07:00 |     0.92 |
2825 #+TBLFM: @@2$3=$1+$2;T::@@3$3=$1+$2;U::@@4$3=$1+$2;t
2826 @end example
2828 Input duration values must be of the form @samp{HH:MM[:SS]}, where seconds
2829 are optional.  With the @samp{T} flag, computed durations are displayed as
2830 @samp{HH:MM:SS} (see the first formula above).  With the @samp{U} flag, seconds
2831 are omitted so that the result is only @samp{HH:MM} (see second formula
2832 above).  Zero-padding of the hours field depends upon the value of the
2833 variable @code{org-table-duration-hour-zero-padding}.
2835 With the @samp{t} flag, computed durations are displayed according to the
2836 value of the option @code{org-table-duration-custom-format}, which defaults
2837 to @code{hours} and displays the result as a fraction of hours (see the
2838 third formula in the example above).
2840 Negative duration values can be manipulated as well, and integers are
2841 considered as seconds in addition and subtraction.
2843 @node Field and range formulas
2844 @subsection Field and range formulas
2846 @cindex field formula
2847 @cindex range formula
2848 @cindex formula, for individual table field
2849 @cindex formula, for range of fields
2851 To assign a formula to a particular field, type it directly into the
2852 field, preceded by @samp{:=}, for example @samp{vsum(@@II..III)}.  When you press
2853 @kbd{@key{TAB}} or @kbd{@key{RET}} or @kbd{C-c C-c} with the cursor
2854 still in the field, the formula is stored as the formula for this
2855 field, evaluated, and the current field is replaced with the result.
2857 @cindex @samp{TBLFM}, keyword
2858 Formulas are stored in a special @samp{TBLFM} keyword located directly
2859 below the table.  If you type the equation in the fourth field of the
2860 third data line in the table, the formula looks like @samp{@@3$4=$1+$2}.
2861 When inserting/deleting/swapping column and rows with the appropriate
2862 commands, @emph{absolute references} (but not relative ones) in stored
2863 formulas are modified in order to still reference the same field.  To
2864 avoid this from happening, in particular in range references, anchor
2865 ranges at the table borders (using @samp{@@<}, @samp{@@>}, @samp{$<}, @samp{$>}), or at
2866 hlines using the @samp{@@I} notation.  Automatic adaptation of field
2867 references does of course not happen if you edit the table structure
2868 with normal editing commands---then you must fix the equations
2869 yourself.
2871 Instead of typing an equation into the field, you may also use the
2872 following command
2874 @table @asis
2875 @item @kbd{C-u C-c =} (@code{org-table-eval-formula})
2876 @kindex C-u C-c =
2877 @findex org-table-eval-formula
2878 Install a new formula for the current field.  The command prompts
2879 for a formula with default taken from the @samp{TBLFM} keyword,
2880 applies it to the current field, and stores it.
2881 @end table
2883 The left-hand side of a formula can also be a special expression in
2884 order to assign the formula to a number of different fields.  There is
2885 no keyboard shortcut to enter such range formulas.  To add them, use
2886 the formula editor (see @ref{Editing and debugging formulas}) or edit the
2887 @samp{TBLFM} keyword directly.
2889 @table @asis
2890 @item @samp{$2=}
2891 Column formula, valid for the entire column.  This is so common
2892 that Org treats these formulas in a special way, see @ref{Column formulas}.
2894 @item @code{@@3=}
2895 Row formula, applies to all fields in the specified row.  @samp{@@>=}
2896 means the last row.
2898 @item @samp{@@1$2..@@4$3=}
2899 Range formula, applies to all fields in the given rectangular
2900 range.  This can also be used to assign a formula to some but not
2901 all fields in a row.
2903 @item @samp{$NAME=}
2904 Named field, see @ref{Advanced features}.
2905 @end table
2907 @node Column formulas
2908 @subsection Column formulas
2910 @cindex column formula
2911 @cindex formula, for table column
2913 When you assign a formula to a simple column reference like @samp{$3=}, the
2914 same formula is used in all fields of that column, with the following
2915 very convenient exceptions: (i) If the table contains horizontal
2916 separator hlines with rows above and below, everything before the
2917 first such hline is considered part of the table @emph{header} and is not
2918 modified by column formulas.  Therefore a header is mandatory when you
2919 use column formulas and want to add hlines to group rows, like for
2920 example to separate a total row at the bottom from the summand rows
2921 above.  (ii) Fields that already get a value from a field/range
2922 formula are left alone by column formulas.  These conditions make
2923 column formulas very easy to use.
2925 To assign a formula to a column, type it directly into any field in
2926 the column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2927 @kbd{@key{TAB}} or @kbd{@key{RET}} or @kbd{C-c C-c} with the cursor
2928 still in the field, the formula is stored as the formula for the
2929 current column, evaluated and the current field replaced with the
2930 result.  If the field contains only @samp{=}, the previously stored formula
2931 for this column is used.  For each column, Org only remembers the most
2932 recently used formula.  In the @samp{TBLFM} keyword, column formulas look
2933 like @samp{$4=$1+$2}.  The left-hand side of a column formula can not be
2934 the name of column, it must be the numeric column reference or @samp{$>}.
2936 Instead of typing an equation into the field, you may also use the
2937 following command:
2939 @table @asis
2940 @item @kbd{C-c =} (@code{org-table-eval-formula})
2941 @kindex C-c =
2942 @findex org-table-eval-formula
2943 Install a new formula for the current column and replace current
2944 field with the result of the formula.  The command prompts for
2945 a formula, with default taken from the @samp{TBLFM} keyword, applies
2946 it to the current field and stores it.  With a numeric prefix
2947 argument, e.g., @kbd{C-5 C-c =}, the command applies it to
2948 that many consecutive fields in the current column.
2949 @end table
2951 @node Lookup functions
2952 @subsection Lookup functions
2954 @cindex lookup functions in tables
2955 @cindex table lookup functions
2957 Org has three predefined Emacs Lisp functions for lookups in tables.
2959 @table @asis
2960 @item @code{(org-lookup-first VAL S-LIST R-LIST &optional PREDICATE)}
2961 @findex org-lookup-first
2962 Searches for the first element @var{S} in list
2963 @var{S-LIST} for which
2964 @lisp
2965 (PREDICATE VAL S)
2966 @end lisp
2967 is non-@code{nil}; returns the value from the corresponding position
2968 in list @var{R-LIST}.  The default @var{PREDICATE} is
2969 @code{equal}.  Note that the parameters @var{VAL} and
2970 @var{S} are passed to @var{PREDICATE} in the same order
2971 as the corresponding parameters are in the call to
2972 @code{org-lookup-first}, where @var{VAL} precedes
2973 @var{S-LIST}.  If @var{R-LIST} is @code{nil}, the matching
2974 element @var{S} of @var{S-LIST} is returned.
2976 @item @code{(org-lookup-last VAL S-LIST R-LIST &optional PREDICATE)}
2977 @findex org-lookup-last
2978 Similar to @code{org-lookup-first} above, but searches for the @emph{last}
2979 element for which @var{PREDICATE} is non-@code{nil}.
2981 @item @code{(org-lookup-all VAL S-LIST R-LIST &optional PREDICATE)}
2982 @findex org-lookup-all
2983 Similar to @code{org-lookup-first}, but searches for @emph{all} elements
2984 for which @var{PREDICATE} is non-@code{nil}, and returns @emph{all}
2985 corresponding values.  This function can not be used by itself in
2986 a formula, because it returns a list of values.  However,
2987 powerful lookups can be built when this function is combined with
2988 other Emacs Lisp functions.
2989 @end table
2991 If the ranges used in these functions contain empty fields, the @samp{E}
2992 mode for the formula should usually be specified: otherwise empty
2993 fields are not included in @var{S-LIST} and/or @var{R-LIST}
2994 which can, for example, result in an incorrect mapping from an element
2995 of @var{S-LIST} to the corresponding element of
2996 @var{R-LIST}.
2998 These three functions can be used to implement associative arrays,
2999 count matching cells, rank results, group data, etc.  For practical
3000 examples see @uref{https://orgmode.org/worg/org-tutorials/org-lookups.html, this tutorial on Worg}.
3002 @node Editing and debugging formulas
3003 @subsection Editing and debugging formulas
3005 @cindex formula editing
3006 @cindex editing, of table formulas
3008 @vindex org-table-use-standard-references
3009 You can edit individual formulas in the minibuffer or directly in the
3010 field.  Org can also prepare a special buffer with all active formulas
3011 of a table.  When offering a formula for editing, Org converts
3012 references to the standard format (like @samp{B3} or @samp{D&}) if possible.  If
3013 you prefer to only work with the internal format (like @samp{@@3$2} or
3014 @samp{$4}), configure the variable @code{org-table-use-standard-references}.
3016 @table @asis
3017 @item @kbd{C-c =} or @kbd{C-u C-c =} (@code{org-table-eval-formula})
3018 @kindex C-c =
3019 @kindex C-u C-c =
3020 @findex org-table-eval-formula
3021 Edit the formula associated with the current column/field in the
3022 minibuffer.  See @ref{Column formulas}, and @ref{Field and range formulas}.
3024 @item @kbd{C-u C-u C-c =} (@code{org-table-eval-formula})
3025 @kindex C-u C-u C-c =
3026 @findex org-table-eval-formula
3027 Re-insert the active formula (either a field formula, or a column
3028 formula) into the current field, so that you can edit it directly
3029 in the field.  The advantage over editing in the minibuffer is
3030 that you can use the command @kbd{C-c ?}.
3032 @item @kbd{C-c ?} (@code{org-table-field-info})
3033 @kindex C-c ?
3034 @findex org-table-field-info
3035 While editing a formula in a table field, highlight the field(s)
3036 referenced by the reference at the cursor position in the
3037 formula.
3039 @item @kbd{C-c @}} (@code{org-table-toggle-coordinate-overlays})
3040 @kindex C-c @}
3041 @findex org-table-toggle-coordinate-overlays
3042 Toggle the display of row and column numbers for a table, using
3043 overlays.  These are updated each time the table is aligned; you
3044 can force it with @kbd{C-c C-c}.
3046 @item @kbd{C-c @{} (@code{org-table-toggle-formula-debugger})
3047 @kindex C-c @{
3048 @findex org-table-toggle-formula-debugger
3049 Toggle the formula debugger on and off.  See below.
3051 @item @kbd{C-c '} (@code{org-table-edit-formulas})
3052 @kindex C-c '
3053 @findex org-table-edit-formulas
3054 Edit all formulas for the current table in a special buffer,
3055 where the formulas are displayed one per line.  If the current
3056 field has an active formula, the cursor in the formula editor
3057 marks it.  While inside the special buffer, Org automatically
3058 highlights any field or range reference at the cursor position.
3059 You may edit, remove and add formulas, and use the following
3060 commands:
3062 @table @asis
3063 @item @kbd{C-c C-c} or @kbd{C-x C-s} (@code{org-table-fedit-finish})
3064 @kindex C-x C-s
3065 @kindex C-c C-c
3066 @findex org-table-fedit-finish
3067 Exit the formula editor and store the modified formulas.  With
3068 @kbd{C-u} prefix, also apply the new formulas to the
3069 entire table.
3071 @item @kbd{C-c C-q} (@code{org-table-fedit-abort})
3072 @kindex C-c C-q
3073 @findex org-table-fedit-abort
3074 Exit the formula editor without installing changes.
3076 @item @kbd{C-c C-r} (@code{org-table-fedit-toggle-ref-type})
3077 @kindex C-c C-r
3078 @findex org-table-fedit-toggle-ref-type
3079 Toggle all references in the formula editor between standard
3080 (like @samp{B3}) and internal (like @samp{@@3$2}).
3082 @item @kbd{@key{TAB}} (@code{org-table-fedit-lisp-indent})
3083 @kindex TAB
3084 @findex org-table-fedit-lisp-indent
3085 Pretty-print or indent Lisp formula at point.  When in a line
3086 containing a Lisp formula, format the formula according to
3087 Emacs Lisp rules.  Another @kbd{@key{TAB}} collapses the formula
3088 back again.  In the open formula, @kbd{@key{TAB}} re-indents
3089 just like in Emacs Lisp mode.
3091 @item @kbd{M-@key{TAB}} (@code{lisp-complete-symbol})
3092 @kindex M-TAB
3093 @findex lisp-complete-symbol
3094 Complete Lisp symbols, just like in Emacs Lisp mode.
3096 @item @kbd{S-@key{UP}}, @kbd{S-@key{DOWN}}, @kbd{S-@key{LEFT}}, @kbd{S-@key{RIGHT}}
3097 @kindex S-UP
3098 @kindex S-DOWN
3099 @kindex S-LEFT
3100 @kindex S-RIGHT
3101 @findex org-table-fedit-ref-up
3102 @findex org-table-fedit-ref-down
3103 @findex org-table-fedit-ref-left
3104 @findex org-table-fedit-ref-right
3105 Shift the reference at point.  For example, if the reference
3106 is @samp{B3} and you press @kbd{S-@key{RIGHT}}, it becomes @samp{C3}.
3107 This also works for relative references and for hline
3108 references.
3110 @item @kbd{M-S-@key{UP}} (@code{org-table-fedit-line-up})
3111 @kindex M-S-UP
3112 @findex org-table-fedit-line-up
3113 Move the test line for column formulas up in the Org buffer.
3115 @item @kbd{M-S-@key{DOWN}} (@code{org-table-fedit-line-down})
3116 @kindex M-S-DOWN
3117 @findex org-table-fedit-line-down
3118 Move the test line for column formulas down in the Org buffer.
3120 @item @kbd{M-@key{UP}} (@code{org-table-fedit-scroll-up})
3121 @kindex M-UP
3122 @findex org-table-fedit-scroll-up
3123 Scroll up the window displaying the table.
3125 @item @kbd{M-@key{DOWN}} (@code{org-table-fedit-scroll-down})
3126 @kindex M-DOWN
3127 @findex org-table-fedit-scroll-down
3128 Scroll down the window displaying the table.
3130 @item @kbd{C-c @}}
3131 @kindex C-c @}
3132 @findex org-table-toggle-coordinate-overlays
3133 Turn the coordinate grid in the table on and off.
3134 @end table
3135 @end table
3137 Making a table field blank does not remove the formula associated with
3138 the field, because that is stored in a different line---the @samp{TBLFM}
3139 keyword line.  During the next recalculation, the field will be filled
3140 again.  To remove a formula from a field, you have to give an empty
3141 reply when prompted for the formula, or to edit the @samp{TBLFM} keyword.
3143 @kindex C-c C-c
3144 You may edit the @samp{TBLFM} keyword directly and re-apply the changed
3145 equations with @kbd{C-c C-c} in that line or with the normal
3146 recalculation commands in the table.
3148 @anchor{Using multiple @samp{TBLFM} lines}
3149 @subsubheading Using multiple @samp{TBLFM} lines
3151 @cindex multiple formula lines
3152 @cindex @samp{TBLFM} keywords, multiple
3153 @cindex @samp{TBLFM}, switching
3155 @kindex C-c C-c
3156 You may apply the formula temporarily.  This is useful when you switch
3157 the formula.  Place multiple @samp{TBLFM} keywords right after the table,
3158 and then press @kbd{C-c C-c} on the formula to apply.  Here is an
3159 example:
3161 @example
3162 | x | y |
3163 |---+---|
3164 | 1 |   |
3165 | 2 |   |
3166 #+TBLFM: $2=$1*1
3167 #+TBLFM: $2=$1*2
3168 @end example
3170 @noindent
3171 Pressing @kbd{C-c C-c} in the line of @samp{#+TBLFM: $2=$1*2} yields:
3173 @example
3174 | x | y |
3175 |---+---|
3176 | 1 | 2 |
3177 | 2 | 4 |
3178 #+TBLFM: $2=$1*1
3179 #+TBLFM: $2=$1*2
3180 @end example
3182 @noindent
3183 Note: If you recalculate this table, with @kbd{C-u C-c *}, for
3184 example, you get the following result of applying only the first
3185 @samp{TBLFM} keyword.
3187 @example
3188 | x | y |
3189 |---+---|
3190 | 1 | 1 |
3191 | 2 | 2 |
3192 #+TBLFM: $2=$1*1
3193 #+TBLFM: $2=$1*2
3194 @end example
3196 @anchor{Debugging formulas}
3197 @subsubheading Debugging formulas
3199 @cindex formula debugging
3200 @cindex debugging, of table formulas
3202 When the evaluation of a formula leads to an error, the field content
3203 becomes the string @samp{#ERROR}.  If you would like to see what is going
3204 on during variable substitution and calculation in order to find
3205 a bug, turn on formula debugging in the Tbl menu and repeat the
3206 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in
3207 a field.  Detailed information are displayed.
3209 @node Updating the table
3210 @subsection Updating the table
3212 @cindex recomputing table fields
3213 @cindex updating, table
3215 Recalculation of a table is normally not automatic, but needs to be
3216 triggered by a command.  To make recalculation at least
3217 semi-automatic, see @ref{Advanced features}.
3219 In order to recalculate a line of a table or the entire table, use the
3220 following commands:
3222 @table @asis
3223 @item @kbd{C-c *} (@code{org-table-recalculate})
3224 @kindex C-c *
3225 @findex org-table-recalculate
3226 Recalculate the current row by first applying the stored column
3227 formulas from left to right, and all field/range formulas in the
3228 current row.
3230 @item @kbd{C-u C-c *} or @kbd{C-u C-c C-c}
3231 @kindex C-u C-c *
3232 @kindex C-u C-c C-c
3233 Recompute the entire table, line by line.  Any lines before the
3234 first hline are left alone, assuming that these are part of the
3235 table header.
3237 @item @kbd{C-u C-u C-c *} or @kbd{C-u C-u C-c C-c} (@code{org-table-iterate})
3238 @kindex C-u C-u C-c *
3239 @kindex C-u C-u C-c C-c
3240 @findex org-table-iterate
3241 Iterate the table by recomputing it until no further changes
3242 occur.  This may be necessary if some computed fields use the
3243 value of other fields that are computed @emph{later} in the
3244 calculation sequence.
3246 @item @kbd{M-x org-table-recalculate-buffer-tables}
3247 @findex org-table-recalculate-buffer-tables
3248 Recompute all tables in the current buffer.
3250 @item @kbd{M-x org-table-iterate-buffer-tables}
3251 @findex org-table-iterate-buffer-tables
3252 Iterate all tables in the current buffer, in order to converge
3253 table-to-table dependencies.
3254 @end table
3256 @node Advanced features
3257 @subsection Advanced features
3259 If you want the recalculation of fields to happen automatically, or if
3260 you want to be able to assign @emph{names}@footnote{Such names must start with an alphabetic character and use
3261 only alphanumeric/underscore characters.} to fields and columns,
3262 you need to reserve the first column of the table for special marking
3263 characters.
3265 @table @asis
3266 @item @kbd{C-#} (@code{org-table-rotate-recalc-marks})
3267 @kindex C-#
3268 @findex org-table-rotate-recalc-marks
3269 Rotate the calculation mark in first column through the states
3270 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region, change all
3271 marks in the region.
3272 @end table
3274 Here is an example of a table that collects exam results of students
3275 and makes use of these features:
3277 @example
3278 |---+---------+--------+--------+--------+-------+------|
3279 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
3280 |---+---------+--------+--------+--------+-------+------|
3281 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
3282 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
3283 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
3284 |---+---------+--------+--------+--------+-------+------|
3285 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
3286 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
3287 |---+---------+--------+--------+--------+-------+------|
3288 |   | Average |        |        |        |  25.0 |      |
3289 | ^ |         |        |        |        |    at |      |
3290 | $ | max=50  |        |        |        |       |      |
3291 |---+---------+--------+--------+--------+-------+------|
3292 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
3293 @end example
3295 @noindent
3296 @strong{Important}: please note that for these special tables, recalculating
3297 the table with @kbd{C-u C-c *} only affects rows that are marked
3298 @samp{#} or @samp{*}, and fields that have a formula assigned to the field
3299 itself.  The column formulas are not applied in rows with empty first
3300 field.
3302 @cindex marking characters, tables
3303 The marking characters have the following meaning:
3305 @table @asis
3306 @item @samp{!}
3307 The fields in this line define names for the columns, so that you
3308 may refer to a column as @samp{$Tot} instead of @samp{$6}.
3310 @item @samp{^}
3311 This row defines names for the fields @emph{above} the row.  With such
3312 a definition, any formula in the table may use @samp{$m1} to refer to
3313 the value @samp{10}.  Also, if you assign a formula to a names field,
3314 it is stored as @samp{$name = ...}.
3316 @item @samp{_}
3317 Similar to @samp{^}, but defines names for the fields in the row
3318 @emph{below}.
3320 @item @samp{$}
3321 Fields in this row can define @emph{parameters} for formulas.  For
3322 example, if a field in a @samp{$} row contains @samp{max=50}, then formulas
3323 in this table can refer to the value 50 using @samp{$max}.  Parameters
3324 work exactly like constants, only that they can be defined on
3325 a per-table basis.
3327 @item @samp{#}
3328 Fields in this row are automatically recalculated when pressing
3329 @kbd{@key{TAB}} or @kbd{@key{RET}} or @kbd{S-@key{TAB}} in this row.
3330 Also, this row is selected for a global recalculation with
3331 @kbd{C-u C-c *}.  Unmarked lines are left alone by this
3332 command.
3334 @item @samp{*}
3335 Selects this line for global recalculation with @kbd{C-u C-c *}, but not for automatic recalculation.  Use this when
3336 automatic recalculation slows down editing too much.
3338 @item @samp{/}
3339 Do not export this line.  Useful for lines that contain the
3340 narrowing @samp{<N>} markers or column group markers.
3341 @end table
3343 Finally, just to whet your appetite for what can be done with the
3344 fantastic Calc package, here is a table that computes the Taylor
3345 series of degree n at location x for a couple of functions.
3347 @example
3348 |---+-------------+---+-----+--------------------------------------|
3349 |   | Func        | n | x   | Result                               |
3350 |---+-------------+---+-----+--------------------------------------|
3351 | # | exp(x)      | 1 | x   | 1 + x                                |
3352 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
3353 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
3354 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
3355 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
3356 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
3357 |---+-------------+---+-----+--------------------------------------|
3358 #+TBLFM: $5=taylor($2,$4,$3);n3
3359 @end example
3361 @node Org Plot
3362 @section Org Plot
3364 @cindex graph, in tables
3365 @cindex plot tables using Gnuplot
3367 Org Plot can produce graphs of information stored in Org tables,
3368 either graphically or in ASCII art.
3370 @anchor{Graphical plots using Gnuplot}
3371 @subheading Graphical plots using Gnuplot
3373 @cindex @samp{PLOT}, keyword
3374 Org Plot can produce 2D and 3D graphs of information stored in Org
3375 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
3376 that you have both Gnuplot and Gnuplot mode installed on your system,
3377 then call @kbd{C-c " g} or @kbd{M-x org-plot/gnuplot} on the
3378 following table.
3380 @example
3381 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
3382 | Sede      | Max cites | H-index |
3383 |-----------+-----------+---------|
3384 | Chile     |    257.72 |   21.39 |
3385 | Leeds     |    165.77 |   19.68 |
3386 | Sao Paolo |     71.00 |   11.50 |
3387 | Stockholm |    134.19 |   14.33 |
3388 | Morelia   |    257.56 |   17.67 |
3389 @end example
3391 Notice that Org Plot is smart enough to apply the table's headers as
3392 labels.  Further control over the labels, type, content, and
3393 appearance of plots can be exercised through the @samp{PLOT} keyword
3394 preceding a table.  See below for a complete list of Org Plot options.
3395 For more information and examples see the @uref{https://orgmode.org/worg/org-tutorials/org-plot.html, Org Plot tutorial}.
3397 @anchor{Plot options}
3398 @subsubheading Plot options
3400 @table @asis
3401 @item @samp{set}
3402 Specify any Gnuplot option to be set when graphing.
3404 @item @samp{title}
3405 Specify the title of the plot.
3407 @item @samp{ind}
3408 Specify which column of the table to use as the @samp{x} axis.
3410 @item @samp{deps}
3411 Specify the columns to graph as a Lisp style list, surrounded by
3412 parentheses and separated by spaces for example @samp{dep:(3 4)} to
3413 graph the third and fourth columns.  Defaults to graphing all
3414 other columns aside from the @samp{ind} column.
3416 @item @samp{type}
3417 Specify whether the plot is @samp{2d}, @samp{3d}, or @samp{grid}.
3419 @item @samp{with}
3420 Specify a @samp{with} option to be inserted for every column being
3421 plotted, e.g., @samp{lines}, @samp{points}, @samp{boxes}, @samp{impulses}.  Defaults
3422 to @samp{lines}.
3424 @item @samp{file}
3425 If you want to plot to a file, specify
3426 @samp{"path/to/desired/output-file"}.
3428 @item @samp{labels}
3429 List of labels to be used for the @samp{deps}.  Defaults to the column
3430 headers if they exist.
3432 @item @samp{line}
3433 Specify an entire line to be inserted in the Gnuplot script.
3435 @item @samp{map}
3436 When plotting @samp{3d} or @samp{grid} types, set this to @samp{t} to graph
3437 a flat mapping rather than a @samp{3d} slope.
3439 @item @samp{timefmt}
3440 Specify format of Org mode timestamps as they will be parsed by
3441 Gnuplot.  Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
3443 @item @samp{script}
3444 If you want total control, you can specify a script file---place
3445 the file name between double-quotes---which will be used to plot.
3446 Before plotting, every instance of @samp{$datafile} in the specified
3447 script will be replaced with the path to the generated data file.
3448 Note: even if you set this option, you may still want to specify
3449 the plot type, as that can impact the content of the data file.
3450 @end table
3452 @anchor{ASCII bar plots}
3453 @subheading ASCII bar plots
3455 While the cursor is on a column, typing @kbd{C-c `` a} or
3456 @kbd{M-x orgtbl-ascii-plot} create a new column containing an
3457 ASCII-art bars plot.  The plot is implemented through a regular column
3458 formula.  When the source column changes, the bar plot may be updated
3459 by refreshing the table, for example typing @kbd{C-u C-c *}.
3461 @example
3462 | Sede          | Max cites |              |
3463 |---------------+-----------+--------------|
3464 | Chile         |    257.72 | WWWWWWWWWWWW |
3465 | Leeds         |    165.77 | WWWWWWWh     |
3466 | Sao Paolo     |     71.00 | WWW;         |
3467 | Stockholm     |    134.19 | WWWWWW:      |
3468 | Morelia       |    257.56 | WWWWWWWWWWWH |
3469 | Rochefourchat |      0.00 |              |
3470 #+TBLFM: $3='(orgtbl-ascii-draw $2 0.0 257.72 12)
3471 @end example
3473 The formula is an Elisp call.
3475 @defun orgtbl-ascii-draw value min max &optional width
3476 Draw an ASCII bar in a table.
3478 @var{VALUE} is the value to plot.
3480 @var{MIN} is the value displayed as an empty bar.  @var{MAX}
3481 is the value filling all the @var{WIDTH}.  Sources values outside
3482 this range are displayed as @samp{too small} or @samp{too large}.
3484 @var{WIDTH} is the number of characters of the bar plot.  It
3485 defaults to @samp{12}.
3486 @end defun
3488 @node Hyperlinks
3489 @chapter Hyperlinks
3491 @cindex hyperlinks
3493 Like HTML, Org provides links inside a file, external links to
3494 other files, Usenet articles, emails, and much more.
3496 @menu
3497 * Link Format::                  How links in Org are formatted.
3498 * Internal Links::               Links to other places in the current file.
3499 * Radio Targets::                Make targets trigger links in plain text.
3500 * External Links::               URL-like links to the world.
3501 * Handling Links::               Creating, inserting and following.
3502 * Using Links Outside Org::      Linking from my C source code?
3503 * Link Abbreviations::           Shortcuts for writing complex links.
3504 * Search Options::               Linking to a specific location.
3505 * Custom Searches::              When the default search is not enough.
3506 @end menu
3508 @node Link Format
3509 @section Link Format
3511 @cindex link format
3512 @cindex format, of links
3514 Org recognizes plain URL-like links and activate them as clickable
3515 links.  The general link format, however, looks like this:
3517 @example
3518 [[LINK][DESCRIPTION]]
3519 @end example
3521 @noindent
3522 or alternatively
3524 @example
3525 [[LINK]]
3526 @end example
3528 @noindent
3529 Once a link in the buffer is complete (all brackets present), Org
3530 changes the display so that @samp{DESCRIPTION} is displayed instead of
3531 @samp{[[LINK][DESCRIPTION]]} and @samp{LINK} is displayed instead of @samp{[[LINK]]}.  Links are be
3532 highlighted in the face @code{org-link}, which by default is an underlined
3533 face.  You can directly edit the visible part of a link.  Note that
3534 this can be either the LINK part, if there is no description, or the
3535 @var{DESCRIPTION} part.  To edit also the invisible
3536 @var{LINK} part, use @kbd{C-c C-l} with the cursor on the
3537 link.
3539 If you place the cursor at the beginning or just behind the end of the
3540 displayed text and press @kbd{@key{BS}}, you remove
3541 the---invisible---bracket at that location.  This makes the link
3542 incomplete and the internals are again displayed as plain text.
3543 Inserting the missing bracket hides the link internals again.  To show
3544 the internal structure of all links, use the menu: Org @arrow{} Hyperlinks @arrow{}
3545 Literal links.
3547 @node Internal Links
3548 @section Internal Links
3550 @cindex internal links
3551 @cindex links, internal
3552 @cindex targets, for links
3554 @cindex @samp{CUSTOM_ID}, property
3555 If the link does not look like a URL, it is considered to be internal
3556 in the current file.  The most important case is a link like
3557 @samp{[[#my-custom-id]]} which links to the entry with the @samp{CUSTOM_ID} property
3558 @samp{my-custom-id}.  You are responsible yourself to make sure these
3559 custom IDs are unique in a file.
3561 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]} lead to a text search in
3562 the current file.
3564 The link can be followed with @kbd{C-c C-o} when the cursor is on
3565 the link, or with a mouse click (see @ref{Handling Links}).  Links to
3566 custom IDs point to the corresponding headline.  The preferred match
3567 for a text link is a @emph{dedicated target}: the same string in double
3568 angular brackets, like @samp{<<My Target>>}.
3570 @cindex @samp{NAME}, keyword
3571 If no dedicated target exists, the link tries to match the exact name
3572 of an element within the buffer.  Naming is done with the @samp{NAME}
3573 keyword, which has to be put in the line before the element it refers
3574 to, as in the following example
3576 @example
3577 #+NAME: My Target
3578 | a  | table      |
3579 |----+------------|
3580 | of | four cells |
3581 @end example
3583 If none of the above succeeds, Org searches for a headline that is
3584 exactly the link text but may also include a TODO keyword and
3585 tags@footnote{To insert a link targeting a headline, in-buffer completion
3586 can be used.  Just type a star followed by a few optional letters into
3587 the buffer and press @kbd{M-@key{TAB}}.  All headlines in the current
3588 buffer are offered as completions.}.
3590 During export, internal links are used to mark objects and assign them
3591 a number.  Marked objects are then referenced by links pointing to
3592 them.  In particular, links without a description appear as the number
3593 assigned to the marked object@footnote{When targeting a @samp{NAME} keyword, @samp{CAPTION} keyword is
3594 mandatory in order to get proper numbering (see @ref{Images and Tables}).}.  In the following excerpt from
3595 an Org buffer
3597 @example
3598 1. one item
3599 2. <<target>>another item
3600 Here we refer to item [[target]].
3601 @end example
3603 @noindent
3604 The last sentence will appear as @samp{Here we refer to item 2} when
3605 exported.
3607 In non-Org files, the search looks for the words in the link text.  In
3608 the above example the search would be for @samp{target}.
3610 Following a link pushes a mark onto Org's own mark ring.  You can
3611 return to the previous position with @kbd{C-c &}.  Using this
3612 command several times in direct succession goes back to positions
3613 recorded earlier.
3615 @node Radio Targets
3616 @section Radio Targets
3618 @cindex radio targets
3619 @cindex targets, radio
3620 @cindex links, radio targets
3622 Org can automatically turn any occurrences of certain target names in
3623 normal text into a link.  So without explicitly creating a link, the
3624 text connects to the target radioing its position.  Radio targets are
3625 enclosed by triple angular brackets.  For example, a target @samp{<<<My
3626 Target>>>} causes each occurrence of @samp{my target} in normal text to
3627 become activated as a link.  The Org file is scanned automatically for
3628 radio targets only when the file is first loaded into Emacs.  To
3629 update the target list during editing, press @kbd{C-c C-c} with
3630 the cursor on or at a target.
3632 @node External Links
3633 @section External Links
3635 @cindex links, external
3636 @cindex external links
3637 @cindex Gnus links
3638 @cindex BBDB links
3639 @cindex irc links
3640 @cindex URL links
3641 @cindex file links
3642 @cindex Rmail links
3643 @cindex MH-E links
3644 @cindex Usenet links
3645 @cindex shell links
3646 @cindex Info links
3647 @cindex Elisp links
3649 Org supports links to files, websites, Usenet and email messages, BBDB
3650 database entries and links to both IRC conversations and their logs.
3651 External links are URL-like locators.  They start with a short
3652 identifying string followed by a colon.  There can be no space after
3653 the colon.  The following list shows examples for each link type.
3655 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
3656 @item @samp{http://www.astro.uva.nl/=dominik}
3657 @tab on the web
3658 @item @samp{doi:10.1000/182}
3659 @tab DOI for an electronic resource
3660 @item @samp{file:/home/dominik/images/jupiter.jpg}
3661 @tab file, absolute path
3662 @item @samp{/home/dominik/images/jupiter.jpg}
3663 @tab same as above
3664 @item @samp{file:papers/last.pdf}
3665 @tab file, relative path
3666 @item @samp{./papers/last.pdf}
3667 @tab same as above
3668 @item @samp{file:/ssh:me@@some.where:papers/last.pdf}
3669 @tab file, path on remote machine
3670 @item @samp{/ssh:me@@some.where:papers/last.pdf}
3671 @tab same as above
3672 @item @samp{file:sometextfile::NNN}
3673 @tab file, jump to line number
3674 @item @samp{file:projects.org}
3675 @tab another Org file
3676 @item @samp{file:projects.org::some words}
3677 @tab text search in Org file@footnote{The actual behavior of the search depends on the value of the
3678 variable @code{org-link-search-must-match-exact-headline}.  If its value is
3679 @code{nil}, then a fuzzy text search is done.  If it is @code{t}, then only the
3680 exact headline is matched, ignoring spaces and statistic cookies.  If
3681 the value is @code{query-to-create}, then an exact headline is searched; if
3682 it is not found, then the user is queried to create it.}
3683 @item @samp{file:projects.org::*task title}
3684 @tab heading search in Org file
3685 @item @samp{file+sys:/path/to/file}
3686 @tab open via OS, like double-click
3687 @item @samp{file+emacs:/path/to/file}
3688 @tab force opening by Emacs
3689 @item @samp{docview:papers/last.pdf::NNN}
3690 @tab open in doc-view mode at page
3691 @item @samp{id:B7423F4D-2E8A-471B-8810-C40F074717E9}
3692 @tab Link to heading by ID
3693 @item @samp{news:comp.emacs}
3694 @tab Usenet link
3695 @item @samp{mailto:adent@@galaxy.net}
3696 @tab Mail link
3697 @item @samp{mhe:folder}
3698 @tab MH-E folder link
3699 @item @samp{mhe:folder#id}
3700 @tab MH-E message link
3701 @item @samp{rmail:folder}
3702 @tab Rmail folder link
3703 @item @samp{rmail:folder#id}
3704 @tab Rmail message link
3705 @item @samp{gnus:group}
3706 @tab Gnus group link
3707 @item @samp{gnus:group#id}
3708 @tab Gnus article link
3709 @item @samp{bbdb:R.*Stallman}
3710 @tab BBDB link (with regexp)
3711 @item @samp{irc:/irc.com/#emacs/bob}
3712 @tab IRC link
3713 @item @samp{info:org#External links}
3714 @tab Info node link
3715 @item @samp{shell:ls *.org}
3716 @tab A shell command
3717 @item @samp{elisp:org-agenda}
3718 @tab Interactive Elisp command
3719 @item @samp{elisp:(find-file-other-frame "Elisp.org")}
3720 @tab Elisp form to evaluate
3721 @end multitable
3723 @cindex VM links
3724 @cindex Wanderlust links
3725 On top of these built-in link types, some are available through the
3726 @samp{contrib/} directory (see @ref{Installation}).  For example, these links to
3727 VM or Wanderlust messages are available when you load the
3728 corresponding libraries from the @samp{contrib/} directory:
3730 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaa}
3731 @item @samp{vm:folder}
3732 @tab VM folder link
3733 @item @samp{vm:folder#id}
3734 @tab VM message link
3735 @item @samp{vm://myself@@some.where.org/folder#id}
3736 @tab VM on remote machine
3737 @item @samp{vm-imap:account:folder}
3738 @tab VM IMAP folder link
3739 @item @samp{vm-imap:account:folder#id}
3740 @tab VM IMAP message link
3741 @item @samp{wl:folder}
3742 @tab Wanderlust folder link
3743 @item @samp{wl:folder#id}
3744 @tab Wanderlust message link
3745 @end multitable
3747 For customizing Org to add new link types, see @ref{Adding Hyperlink Types}.
3749 A link should be enclosed in double brackets and may contain
3750 a descriptive text to be displayed instead of the URL (see @ref{Link Format}), for example:
3752 @example
3753 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
3754 @end example
3756 @noindent
3757 If the description is a file name or URL that points to an image, HTML
3758 export (see @ref{HTML Export}) inlines the image as a clickable button.  If
3759 there is no description at all and the link points to an image, that
3760 image is inlined into the exported HTML file.
3762 @cindex square brackets, around links
3763 @cindex angular brackets, around links
3764 @cindex plain text external links
3765 Org also finds external links in the normal text and activates them as
3766 links.  If spaces must be part of the link (for example in
3767 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities about
3768 the end of the link, enclose them in square or angular brackets.
3770 @node Handling Links
3771 @section Handling Links
3773 @cindex links, handling
3775 Org provides methods to create a link in the correct syntax, to insert
3776 it into an Org file, and to follow the link.
3778 @findex org-store-link
3779 @cindex storing links
3780 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
3781 to a widely available key (see @ref{Activation}).  It stores a link to the
3782 current location.  The link is stored for later insertion into an Org
3783 buffer---see below.  What kind of link is created depends on the
3784 current buffer:
3786 @table @asis
3787 @item @emph{Org mode buffers}
3788 For Org files, if there is a @samp{<<target>>} at the cursor, the link
3789 points to the target.  Otherwise it points to the current
3790 headline, which is also the description@footnote{If the headline contains a timestamp, it is removed from the
3791 link, which results in a wrong link---you should avoid putting
3792 a timestamp in the headline.}.
3794 @vindex org-link-to-org-use-id
3795 @cindex @samp{CUSTOM_ID}, property
3796 @cindex @samp{ID}, property
3797 If the headline has a @samp{CUSTOM_ID} property, store a link to this
3798 custom ID.  In addition or alternatively, depending on the value
3799 of @code{org-link-to-org-use-id}, create and/or use a globally unique
3800 ID property for the link@footnote{The Org Id library must first be loaded, either through
3801 @code{org-customize}, by enabling @code{id} in @code{org-modules}, or by adding
3802 @code{(require 'org-id)} in your Emacs init file.}.  So using this command in Org
3803 buffers potentially creates two links: a human-readable link from
3804 the custom ID, and one that is globally unique and works even if
3805 the entry is moved from file to file.  Later, when inserting the
3806 link, you need to decide which one to use.
3808 @item @emph{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}
3809 Pretty much all Emacs mail clients are supported.  The link
3810 points to the current article, or, in some Gnus buffers, to the
3811 group.  The description is constructed from the author and the
3812 subject.
3814 @item @emph{Web browsers: W3, W3M and EWW}
3815 Here the link is the current URL, with the page title as
3816 description.
3818 @item @emph{Contacts: BBDB}
3819 Links created in a BBDB buffer point to the current entry.
3821 @item @emph{Chat: IRC}
3822 @vindex org-irc-links-to-logs
3823 For IRC links, if the variable @code{org-irc-link-to-logs} is
3824 non-@code{nil}, create a @samp{file} style link to the relevant point in
3825 the logs for the current conversation.  Otherwise store an @samp{irc}
3826 style link to the user/channel/server under the point.
3828 @item @emph{Other files}
3829 For any other file, the link points to the file, with a search
3830 string (see @ref{Search Options}) pointing to the
3831 contents of the current line.  If there is an active region, the
3832 selected words form the basis of the search string.  If the
3833 automatically created link is not working correctly or accurately
3834 enough, you can write custom functions to select the search
3835 string and to do the search for particular file types (see
3836 @ref{Custom Searches}).
3838 You can also define dedicated links to other files.  See @ref{Adding Hyperlink Types}.
3840 @item @emph{Agenda view}
3841 When the cursor is in an agenda view, the created link points to
3842 the entry referenced by the current line.
3843 @end table
3845 From an Org buffer, the following commands create, navigate or, more
3846 generally, act on links.
3848 @table @asis
3849 @item @kbd{C-c C-l} (@code{org-insert-link})
3850 @kindex C-c C-l
3851 @findex org-insert-link
3852 @cindex link completion
3853 @cindex completion, of links
3854 @cindex inserting links
3855 @vindex org-keep-stored-link-after-insertion
3856 Insert a link@footnote{Note that you do not have to use this command to insert
3857 a link.  Links in Org are plain text, and you can type or paste them
3858 straight into the buffer.  By using this command, the links are
3859 automatically enclosed in double brackets, and you will be asked for
3860 the optional descriptive text.}.  This prompts for a link to be inserted
3861 into the buffer.  You can just type a link, using text for an
3862 internal link, or one of the link type prefixes mentioned in the
3863 examples above.  The link is inserted into the buffer, along with
3864 a descriptive text@footnote{After insertion of a stored link, the link will be removed
3865 from the list of stored links.  To keep it in the list later use, use
3866 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or
3867 configure the option @code{org-keep-stored-link-after-insertion}.}.  If some text was selected at this
3868 time, it becomes the default description.
3870 @table @asis
3871 @item @emph{Inserting stored links}
3872 All links stored during the current session are part of the
3873 history for this prompt, so you can access them with
3874 @kbd{@key{UP}} and @kbd{@key{DOWN}} (or @kbd{M-p},
3875 @kbd{M-n}).
3877 @item @emph{Completion support}
3878 Completion with @kbd{@key{TAB}} helps you to insert valid link
3879 prefixes like @samp{http} or @samp{ftp}, including the prefixes defined
3880 through link abbreviations (see @ref{Link Abbreviations}).  If you
3881 press @kbd{@key{RET}} after inserting only the prefix, Org
3882 offers specific completion support for some link types@footnote{This works if a function has been defined in the @code{:complete}
3883 property of a link in @code{org-link-parameters}.}.
3884 For example, if you type @kbd{f i l e @key{RET}}---alternative
3885 access: @kbd{C-u C-c C-l}, see below---Org offers file
3886 name completion, and after @kbd{b b d b @key{RET}} you can
3887 complete contact names.
3888 @end table
3890 @item @kbd{C-u C-c C-l}
3891 @cindex file name completion
3892 @cindex completion, of file names
3893 @kindex C-u C-c C-l
3894 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix
3895 argument, insert a link to a file.  You may use file name
3896 completion to select the name of the file.  The path to the file
3897 is inserted relative to the directory of the current Org file, if
3898 the linked file is in the current directory or in a sub-directory
3899 of it, or if the path is written relative to the current
3900 directory using @samp{../}.  Otherwise an absolute path is used, if
3901 possible with @samp{~/} for your home directory.  You can force an
3902 absolute path with two @kbd{C-u} prefixes.
3904 @item @kbd{C-c C-l} (with cursor on existing link)
3905 @cindex following links
3906 When the cursor is on an existing link, @kbd{C-c C-l} allows
3907 you to edit the link and description parts of the link.
3909 @item @kbd{C-c C-o} (@code{org-open-at-point})
3910 @kindex C-c C-o
3911 @findex org-open-at-point
3912 @vindex org-file-apps
3913 Open link at point.  This launches a web browser for URL (using
3914 @code{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB
3915 for the corresponding links, and execute the command in a shell
3916 link.  When the cursor is on an internal link, this command runs
3917 the corresponding search.  When the cursor is on a TAG list in
3918 a headline, it creates the corresponding TAGS view.  If the
3919 cursor is on a timestamp, it compiles the agenda for that date.
3920 Furthermore, it visits text and remote files in @samp{file} links with
3921 Emacs and select a suitable application for local non-text files.
3922 Classification of files is based on file extension only.  See
3923 option @code{org-file-apps}.  If you want to override the default
3924 application and visit the file with Emacs, use a @kbd{C-u}
3925 prefix.  If you want to avoid opening in Emacs, use a @kbd{C-u C-u} prefix.
3927 @vindex org-link-frame-setup
3928 If the cursor is on a headline, but not on a link, offer all
3929 links in the headline and entry text.  If you want to setup the
3930 frame configuration for following links, customize
3931 @code{org-link-frame-setup}.
3933 @item @kbd{@key{RET}}
3934 @vindex org-return-follows-link
3935 @kindex RET
3936 When @code{org-return-follows-link} is set, @kbd{@key{RET}} also
3937 follows the link at point.
3939 @item @kbd{mouse-2} or @kbd{mouse-1}
3940 @kindex mouse-2
3941 @kindex mouse-1
3942 On links, @kbd{mouse-1} and @kbd{mouse-2} opens the
3943 link just as @kbd{C-c C-o} does.
3945 @item @kbd{mouse-3}
3946 @vindex org-display-internal-link-with-indirect-buffer
3947 @kindex mouse-3
3948 Like @kbd{mouse-2}, but force file links to be opened with
3949 Emacs, and internal links to be displayed in another
3950 window@footnote{See the variable @code{org-display-internal-link-with-indirect-buffer}.}.
3952 @item @kbd{C-c C-x C-v} (@code{org-toggle-inline-images})
3953 @cindex inlining images
3954 @cindex images, inlining
3955 @vindex org-startup-with-inline-images
3956 @kindex C-c C-x C-v
3957 @findex org-toggle-inline-images
3958 Toggle the inline display of linked images.  Normally this only
3959 inlines images that have no description part in the link, i.e.,
3960 images that are inlined during export.  When called with a prefix
3961 argument, also display images that do have a link description.
3962 You can ask for inline images to be displayed at startup by
3963 configuring the variable @code{org-startup-with-inline-images}@footnote{The variable @code{org-startup-with-inline-images} can be set
3964 within a buffer with the @samp{STARTUP} options @samp{inlineimages} and
3965 @samp{noinlineimages}.}.
3967 @item @kbd{C-c %} (@code{org-mark-ring-push})
3968 @kindex C-c %
3969 @findex org-mark-ring-push
3970 @cindex mark ring
3971 Push the current position onto the mark ring, to be able to
3972 return easily.  Commands following an internal link do this
3973 automatically.
3975 @item @kbd{C-c &} (@code{org-mark-ring-goto})
3976 @kindex C-c &
3977 @findex org-mark-ring-goto
3978 @cindex links, returning to
3979 Jump back to a recorded position.  A position is recorded by the
3980 commands following internal links, and by @kbd{C-c %}.
3981 Using this command several times in direct succession moves
3982 through a ring of previously recorded positions.
3984 @item @kbd{C-c C-x C-n} (@code{org-next-link})
3985 @itemx @kbd{C-c C-x C-p} (@code{org-previous-link})
3986 @kindex C-c C-x C-p
3987 @findex org-previous-link
3988 @kindex C-c C-x C-n
3989 @findex org-next-link
3990 @cindex links, finding next/previous
3991 Move forward/backward to the next link in the buffer.  At the
3992 limit of the buffer, the search fails once, and then wraps
3993 around.  The key bindings for this are really too long; you might
3994 want to bind this also to @kbd{M-n} and @kbd{M-p}.
3996 @lisp
3997 (add-hook 'org-load-hook
3998           (lambda ()
3999             (define-key org-mode-map "\M-n" 'org-next-link)
4000             (define-key org-mode-map "\M-p" 'org-previous-link)))
4001 @end lisp
4002 @end table
4004 @node Using Links Outside Org
4005 @section Using Links Outside Org
4007 @findex org-insert-link-global
4008 @findex org-open-at-point-global
4009 You can insert and follow links that have Org syntax not only in Org,
4010 but in any Emacs buffer.  For this, Org provides two functions:
4011 @code{org-insert-link-global} and @code{org-open-at-point-global}.
4013 You might want to bind them to globally available keys.  See
4014 @ref{Activation} for some advice.
4016 @node Link Abbreviations
4017 @section Link Abbreviations
4019 @cindex link abbreviations
4020 @cindex abbreviation, links
4022 Long URL can be cumbersome to type, and often many similar links are
4023 needed in a document.  For this you can use link abbreviations.  An
4024 abbreviated link looks like this
4026 @example
4027 [[linkword:tag][description]]
4028 @end example
4030 @noindent
4031 @vindex org-link-abbrev-alist
4032 where the tag is optional.  The @emph{linkword} must be a word, starting
4033 with a letter, followed by letters, numbers, @samp{-}, and @samp{_}.
4034 Abbreviations are resolved according to the information in the
4035 variable @code{org-link-abbrev-alist} that relates the linkwords to
4036 replacement text.  Here is an example:
4038 @lisp
4039 (setq org-link-abbrev-alist
4040       '(("bugzilla"  . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
4041         ("url-to-ja" . "http://translate.google.fr/translate?sl=en&tl=ja&u=%h")
4042         ("google"    . "http://www.google.com/search?q=")
4043         ("gmap"      . "http://maps.google.com/maps?q=%s")
4044         ("omap"      . "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")
4045         ("ads"       . "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?author=%s&db_key=AST")))
4046 @end lisp
4048 If the replacement text contains the string @samp{%s}, it is replaced with
4049 the tag.  Using @samp{%h} instead of @samp{%s} percent-encodes the tag (see the
4050 example above, where we need to encode the URL parameter).  Using
4051 @samp{%(my-function)} passes the tag to a custom function, and replace it
4052 by the resulting string.
4054 If the replacement text do not contain any specifier, it is simply
4055 appended to the string in order to create the link.
4057 Instead of a string, you may also specify a function that will be
4058 called with the tag as the only argument to create the link.
4060 With the above setting, you could link to a specific bug with
4061 @samp{[[bugzilla:129]]}, search the web for @samp{OrgMode} with @samp{[[google:OrgMode]]},
4062 show the map location of the Free Software Foundation @samp{[[gmap:51
4063 Franklin Street, Boston]]} or of Carsten office @samp{[[omap:Science Park 904,
4064 Amsterdam, The Netherlands]]} and find out what the Org author is doing
4065 besides Emacs hacking with @samp{[[ads:Dominik,C]]}.
4067 If you need special abbreviations just for a single Org buffer, you
4068 can define them in the file with
4070 @cindex @samp{LINK}, keyword
4071 @example
4072 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
4073 #+LINK: google    http://www.google.com/search?q=%s
4074 @end example
4076 @noindent
4077 In-buffer completion (see @ref{Completion}) can be used after @samp{[} to
4078 complete link abbreviations.  You may also define a function that
4079 implements special (e.g., completion) support for inserting such
4080 a link with @kbd{C-c C-l}.  Such a function should not accept any
4081 arguments, and return the full link with prefix.  You can set the link
4082 completion function like this:
4084 @lisp
4085 (org-link-set-parameter "type" :complete #'some-completion-function)
4086 @end lisp
4088 @node Search Options
4089 @section Search Options in File Links
4091 @cindex search option in file links
4092 @cindex file links, searching
4094 File links can contain additional information to make Emacs jump to
4095 a particular location in the file when following a link.  This can be
4096 a line number or a search option after a double colon@footnote{For backward compatibility, line numbers can also follow a
4097 single colon.}.  For
4098 example, when the command @code{org-store-link} creates a link (see
4099 @ref{Handling Links}) to a file, it encodes the words in the current line
4100 as a search string that can be used to find this line back later when
4101 following the link with @kbd{C-c C-o}.
4103 Here is the syntax of the different ways to attach a search to a file
4104 link, together with an explanation:
4106 @example
4107 [[file:~/code/main.c::255]]
4108 [[file:~/xx.org::My Target]]
4109 [[file:~/xx.org::*My Target]]
4110 [[file:~/xx.org::#my-custom-id]]
4111 [[file:~/xx.org::/regexp/]]
4112 @end example
4114 @table @asis
4115 @item @samp{255}
4116 Jump to line 255.
4118 @item @samp{My Target}
4119 Search for a link target @samp{<<My Target>>}, or do a text search for
4120 @samp{my target}, similar to the search in internal links, see
4121 @ref{Internal Links}.  In HTML export (see @ref{HTML Export}), such a file
4122 link becomes a HTML reference to the corresponding named anchor
4123 in the linked file.
4125 @item @samp{*My Target}
4126 In an Org file, restrict search to headlines.
4128 @item @samp{#my-custom-id}
4129 Link to a heading with a @samp{CUSTOM_ID} property
4131 @item @samp{/REGEXP/}
4132 Do a regular expression search for @var{REGEXP}.  This uses
4133 the Emacs command @code{occur} to list all matches in a separate
4134 window.  If the target file is in Org mode, @code{org-occur} is used
4135 to create a sparse tree with the matches.
4136 @end table
4138 As a degenerate case, a file link with an empty file name can be used
4139 to search the current file.  For example, @samp{[[file:::find me]]} does
4140 a search for @samp{find me} in the current file, just as @samp{[[find me]]} would.
4142 @node Custom Searches
4143 @section Custom Searches
4145 @cindex custom search strings
4146 @cindex search strings, custom
4148 The default mechanism for creating search strings and for doing the
4149 actual search related to a file link may not work correctly in all
4150 cases.  For example, Bib@TeX{} database files have many entries like
4151 @code{year="1993"} which would not result in good search strings, because
4152 the only unique identification for a Bib@TeX{} entry is the citation key.
4154 @vindex org-create-file-search-functions
4155 @vindex org-execute-file-search-functions
4156 If you come across such a problem, you can write custom functions to
4157 set the right search string for a particular file type, and to do the
4158 search for the string in the file.  Using @code{add-hook}, these functions
4159 need to be added to the hook variables
4160 @code{org-create-file-search-functions} and
4161 @code{org-execute-file-search-functions}.  See the docstring for these
4162 variables for more information.  Org actually uses this mechanism for
4163 Bib@TeX{} database files, and you can use the corresponding code as an
4164 implementation example.  See the file @samp{org-bibtex.el}.
4166 @node TODO Items
4167 @chapter TODO Items
4169 @cindex TODO items
4171 Org mode does not maintain TODO lists as separate documents@footnote{Of course, you can make a document that contains only long
4172 lists of TODO items, but this is not required.}.
4173 Instead, TODO items are an integral part of the notes file, because
4174 TODO items usually come up while taking notes!  With Org mode, simply
4175 mark any entry in a tree as being a TODO item.  In this way,
4176 information is not duplicated, and the entire context from which the
4177 TODO item emerged is always present.
4179 Of course, this technique for managing TODO items scatters them
4180 throughout your notes file.  Org mode compensates for this by
4181 providing methods to give you an overview of all the things that you
4182 have to do.
4184 @menu
4185 * TODO Basics::                  Marking and displaying TODO entries.
4186 * TODO Extensions::              Workflow and assignments.
4187 * Progress Logging::             Dates and notes for progress.
4188 * Priorities::                   Some things are more important than others.
4189 * Breaking Down Tasks::          Splitting a task into manageable pieces.
4190 * Checkboxes::                   Tick-off lists.
4191 @end menu
4193 @node TODO Basics
4194 @section Basic TODO Functionality
4196 Any headline becomes a TODO item when it starts with the word @samp{TODO},
4197 for example:
4199 @example
4200 *** TODO Write letter to Sam Fortune
4201 @end example
4203 @noindent
4204 The most important commands to work with TODO entries are:
4206 @table @asis
4207 @item @kbd{C-c C-t} (@code{org-todo})
4208 @kindex C-c C-t
4209 @cindex cycling, of TODO states
4210 Rotate the TODO state of the current item among
4212 @example
4213 ,-> (unmarked) -> TODO -> DONE --.
4214 '--------------------------------'
4215 @end example
4217 If TODO keywords have fast access keys (see @ref{Fast access to TODO states}), prompt for a TODO keyword through the fast
4218 selection interface; this is the default behavior when
4219 @code{org-use-fast-todo-selection} is non-@code{nil}.
4221 The same rotation can also be done ``remotely'' from the timeline
4222 and agenda buffers with the @kbd{t} command key (see
4223 @ref{Agenda Commands}).
4225 @item @kbd{C-u C-c C-t}
4226 @kindex C-u C-c C-t
4227 When TODO keywords have no selection keys, select a specific
4228 keyword using completion; otherwise force cycling through TODO
4229 states with no prompt.  When @code{org-use-fast-todo-selection} is set
4230 to @code{prefix}, use the fast selection interface.
4232 @item @kbd{S-@key{RIGHT}} @kbd{S-@key{LEFT}}
4233 @kindex S-RIGHT
4234 @kindex S-LEFT
4235 @vindex org-treat-S-cursor-todo-selection-as-state-change
4236 Select the following/preceding TODO state, similar to cycling.
4237 Useful mostly if more than two TODO states are possible (see
4238 @ref{TODO Extensions}).  See also @ref{Conflicts}, for a discussion of the interaction with
4239 @code{shift-selection-mode}.  See also the variable
4240 @code{org-treat-S-cursor-todo-selection-as-state-change}.
4242 @item @kbd{C-c / t} (@code{org-show-todo-tree})
4243 @kindex C-c / t
4244 @cindex sparse tree, for TODO
4245 @vindex org-todo-keywords
4246 @findex org-show-todo-tree
4247 View TODO items in a @emph{sparse tree} (see @ref{Sparse Trees}).  Folds
4248 the entire buffer, but shows all TODO items---with not-DONE
4249 state---and the headings hierarchy above them.  With a prefix
4250 argument, or by using @kbd{C-c / T}, search for a specific
4251 TODO.  You are prompted for the keyword, and you can also give
4252 a list of keywords like @samp{KWD1|KWD2|...} to list entries that
4253 match any one of these keywords.  With a numeric prefix argument
4254 N, show the tree for the Nth keyword in the variable
4255 @code{org-todo-keywords}.  With two prefix arguments, find all TODO
4256 states, both un-done and done.
4258 @item @kbd{C-c a t} (@code{org-todo-list})
4259 @kindex C-c a t
4260 Show the global TODO list.  Collects the TODO items (with
4261 not-DONE states) from all agenda files (see @ref{Agenda Views}) into
4262 a single buffer.  The new buffer is in Org Agenda mode, which
4263 provides commands to examine and manipulate the TODO entries from
4264 the new buffer (see @ref{Agenda Commands}).  See @ref{Global TODO list}, for more information.
4266 @item @kbd{S-M-@key{RET}} (@code{org-insert-todo-heading})
4267 @kindex S-M-RET
4268 @findex org-insert-todo-heading
4269 Insert a new TODO entry below the current one.
4270 @end table
4272 @vindex org-todo-state-tags-triggers
4273 @noindent
4274 Changing a TODO state can also trigger tag changes.  See the docstring
4275 of the option @code{org-todo-state-tags-triggers} for details.
4277 @node TODO Extensions
4278 @section Extended Use of TODO Keywords
4280 @cindex extended TODO keywords
4282 @vindex org-todo-keywords
4283 By default, marked TODO entries have one of only two states: TODO and
4284 DONE.  Org mode allows you to classify TODO items in more complex ways
4285 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With special
4286 setup, the TODO keyword system can work differently in different
4287 files.
4289 Note that @emph{tags} are another way to classify headlines in general and
4290 TODO items in particular (see @ref{Tags}).
4292 @menu
4293 * Workflow states::              From TODO to DONE in steps.
4294 * TODO types::                   I do this, Fred does the rest.
4295 * Multiple sets in one file::    Mixing it all, still finding your way.
4296 * Fast access to TODO states::   Single letter selection of state.
4297 * Per-file keywords::            Different files, different requirements.
4298 * Faces for TODO keywords::      Highlighting states.
4299 * TODO dependencies::            When one task needs to wait for others.
4300 @end menu
4302 @node Workflow states
4303 @subsection TODO keywords as workflow states
4305 @cindex TODO workflow
4306 @cindex workflow states as TODO keywords
4308 You can use TODO keywords to indicate different @emph{sequential} states in
4309 the process of working on an item, for example@footnote{Changing the variable @code{org-todo-keywords} only becomes
4310 effective after restarting Org mode in a buffer.}:
4312 @lisp
4313 (setq org-todo-keywords
4314       '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
4315 @end lisp
4317 The vertical bar separates the TODO keywords (states that @emph{need
4318 action}) from the DONE states (which need @emph{no further action}).  If
4319 you do not provide the separator bar, the last state is used as the
4320 DONE state.
4322 @cindex completion, of TODO keywords
4323 With this setup, the command @kbd{C-c C-t} cycles an entry from
4324 @samp{TODO} to @samp{FEEDBACK}, then to @samp{VERIFY}, and finally to @samp{DONE} and
4325 @samp{DELEGATED}.  You may also use a numeric prefix argument to quickly
4326 select a specific state.  For example @kbd{C-3 C-c C-t} changes
4327 the state immediately to @samp{VERIFY}.  Or you can use @kbd{S-@key{LEFT}}
4328 to go backward through the sequence.  If you define many keywords, you
4329 can use in-buffer completion (see @ref{Completion}) or even a special
4330 one-key selection scheme (see @ref{Fast access to TODO states}) to insert
4331 these words into the buffer.  Changing a TODO state can be logged with
4332 a timestamp, see @ref{Tracking TODO state changes}, for more information.
4334 @node TODO types
4335 @subsection TODO keywords as types
4337 @cindex TODO types
4338 @cindex names as TODO keywords
4339 @cindex types as TODO keywords
4341 The second possibility is to use TODO keywords to indicate different
4342 @emph{types} of action items.  For example, you might want to indicate that
4343 items are for ``work'' or ``home''.  Or, when you work with several people
4344 on a single project, you might want to assign action items directly to
4345 persons, by using their names as TODO keywords.  This would be set up
4346 like this:
4348 @lisp
4349 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
4350 @end lisp
4352 In this case, different keywords do not indicate a sequence, but
4353 rather different types.  So the normal work flow would be to assign
4354 a task to a person, and later to mark it DONE.  Org mode supports this
4355 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
4356 and agenda buffers.}.  When used several times in succession, it still
4357 cycles through all names, in order to first select the right type for
4358 a task.  But when you return to the item after some time and execute
4359 @kbd{C-c C-t} again, it will switch from any name directly to
4360 @samp{DONE}.  Use prefix arguments or completion to quickly select
4361 a specific name.  You can also review the items of a specific TODO
4362 type in a sparse tree by using a numeric prefix to @kbd{C-c / t}.
4363 For example, to see all things Lucy has to do, you would use
4364 @kbd{C-3 C-c / t}.  To collect Lucy's items from all agenda files
4365 into a single buffer, you would use the numeric prefix argument as
4366 well when creating the global TODO list: @kbd{C-3 C-c a t}.
4368 @node Multiple sets in one file
4369 @subsection Multiple keyword sets in one file
4371 @cindex TODO keyword sets
4373 Sometimes you may want to use different sets of TODO keywords in
4374 parallel.  For example, you may want to have the basic TODO/DONE, but
4375 also a workflow for bug fixing, and a separate state indicating that
4376 an item has been canceled---so it is not DONE, but also does not
4377 require action.  Your setup would then look like this:
4379 @lisp
4380 (setq org-todo-keywords
4381       '((sequence "TODO" "|" "DONE")
4382         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
4383         (sequence "|" "CANCELED")))
4384 @end lisp
4386 The keywords should all be different, this helps Org mode to keep
4387 track of which subsequence should be used for a given entry.  In this
4388 setup, @kbd{C-c C-t} only operates within a subsequence, so it
4389 switches from @samp{DONE} to (nothing) to @samp{TODO}, and from @samp{FIXED} to
4390 (nothing) to @samp{REPORT}.  Therefore you need a mechanism to initially
4391 select the correct sequence.  Besides the obvious ways like typing
4392 a keyword or using completion, you may also apply the following
4393 commands:
4395 @table @asis
4396 @item @kbd{C-u C-u C-c C-t}
4397 @itemx @kbd{C-S-@key{RIGHT}}
4398 @itemx @kbd{C-S-@key{LEFT}}
4399 @kindex C-S-RIGHT
4400 @kindex C-S-LEFT
4401 @kindex C-u C-u C-c C-t
4402 These keys jump from one TODO subset to the next.  In the above
4403 example, @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{RIGHT}} would
4404 jump from @samp{TODO} or @samp{DONE} to @samp{REPORT}, and any of the words in
4405 the second row to @samp{CANCELED}.  Note that the @kbd{C-S-} key
4406 binding conflict with @code{shift-selection-mode} (see @ref{Conflicts}).
4408 @item @kbd{S-@key{RIGHT}}
4409 @itemx @kbd{S-@key{LEFT}}
4410 @kindex S-RIGHT
4411 @kindex S-LEFT
4412 @kbd{S-@key{LEFT}} and @kbd{S-@key{RIGHT}} walk through @emph{all}
4413 keywords from all sets, so for example @kbd{S-@key{RIGHT}} would
4414 switch from @samp{DONE} to @samp{REPORT} in the example above.  For
4415 a discussion of the interaction with @code{shift-selection-mode}, see
4416 @ref{Conflicts}.
4417 @end table
4419 @node Fast access to TODO states
4420 @subsection Fast access to TODO states
4422 If you would like to quickly change an entry to an arbitrary TODO
4423 state instead of cycling through the states, you can set up keys for
4424 single-letter access to the states.  This is done by adding the
4425 selection character after each keyword, in parentheses@footnote{All characters are allowed except @samp{@@}, @samp{^} and @samp{!}, which have
4426 a special meaning here.}.  For
4427 example:
4429 @lisp
4430 (setq org-todo-keywords
4431       '((sequence "TODO(t)" "|" "DONE(d)")
4432         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
4433         (sequence "|" "CANCELED(c)")))
4434 @end lisp
4436 @vindex org-fast-tag-selection-include-todo
4437 If you then press @kbd{C-c C-t} followed by the selection key,
4438 the entry is switched to this state.  @kbd{@key{SPC}} can be used to
4439 remove any TODO keyword from an entry@footnote{Check also the variable @code{org-fast-tag-selection-include-todo},
4440 it allows you to change the TODO state through the tags interface
4441 (@ref{Setting Tags}), in case you like to mingle the two concepts.  Note
4442 that this means you need to come up with unique keys across both sets
4443 of keywords.}.
4445 @node Per-file keywords
4446 @subsection Setting up keywords for individual files
4448 @cindex keyword options
4449 @cindex per-file keywords
4450 @cindex @samp{TODO}, keyword
4451 @cindex @samp{TYP_TODO}, keyword
4452 @cindex @samp{SEQ_TODO}, keyword
4454 It can be very useful to use different aspects of the TODO mechanism
4455 in different files.  For file-local settings, you need to add special
4456 lines to the file which set the keywords and interpretation for that
4457 file only.  For example, to set one of the two examples discussed
4458 above, you need one of the following lines, starting in column zero
4459 anywhere in the file:
4461 @example
4462 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
4463 @end example
4465 @noindent
4466 you may also write @samp{#+SEQ_TODO} to be explicit about the
4467 interpretation, but it means the same as @samp{#+TODO}, or
4469 @example
4470 #+TYP_TODO: Fred Sara Lucy Mike | DONE
4471 @end example
4473 A setup for using several sets in parallel would be:
4475 @example
4476 #+TODO: TODO | DONE
4477 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
4478 #+TODO: | CANCELED
4479 @end example
4481 @cindex completion, of option keywords
4482 @kindex M-TAB
4483 @noindent
4484 To make sure you are using the correct keyword, type @samp{#+} into the
4485 buffer and then use @kbd{M-@key{TAB}} completion.
4487 @cindex DONE, final TODO keyword
4488 Remember that the keywords after the vertical bar---or the last
4489 keyword if no bar is there---must always mean that the item is DONE,
4490 although you may use a different word.  After changing one of these
4491 lines, use @kbd{C-c C-c} with the cursor still in the line to
4492 make the changes known to Org mode@footnote{Org mode parses these lines only when Org mode is activated
4493 after visiting a file.  @kbd{C-c C-c} with the cursor in a line
4494 starting with @samp{#+} is simply restarting Org mode for the current
4495 buffer.}.
4497 @node Faces for TODO keywords
4498 @subsection Faces for TODO keywords
4500 @cindex faces, for TODO keywords
4502 @vindex org-todo, face
4503 @vindex org-done, face
4504 @vindex org-todo-keyword-faces
4505 Org mode highlights TODO keywords with special faces: @code{org-todo} for
4506 keywords indicating that an item still has to be acted upon, and
4507 @code{org-done} for keywords indicating that an item is finished.  If you
4508 are using more than two different states, you might want to use
4509 special faces for some of them.  This can be done using the variable
4510 @code{org-todo-keyword-faces}.  For example:
4512 @lisp
4513 (setq org-todo-keyword-faces
4514       '(("TODO" . org-warning) ("STARTED" . "yellow")
4515         ("CANCELED" . (:foreground "blue" :weight bold))))
4516 @end lisp
4518 @vindex org-faces-easy-properties
4519 While using a list with face properties as shown for @samp{CANCELED}
4520 @emph{should} work, this does not always seem to be the case.  If
4521 necessary, define a special face and use that.  A string is
4522 interpreted as a color.  The variable @code{org-faces-easy-properties}
4523 determines if that color is interpreted as a foreground or
4524 a background color.
4526 @node TODO dependencies
4527 @subsection TODO dependencies
4529 @cindex TODO dependencies
4530 @cindex dependencies, of TODO states
4532 @vindex org-enforce-todo-dependencies
4533 @cindex @samp{ORDERED}, property
4534 The structure of Org files---hierarchy and lists---makes it easy to
4535 define TODO dependencies.  Usually, a parent TODO task should not be
4536 marked DONE until all subtasks, defined as children tasks, are marked
4537 as DONE.  And sometimes there is a logical sequence to a number of
4538 (sub)tasks, so that one task cannot be acted upon before all siblings
4539 above it are done.  If you customize the variable
4540 @code{org-enforce-todo-dependencies}, Org blocks entries from changing
4541 state to DONE while they have children that are not DONE.
4542 Furthermore, if an entry has a property @samp{ORDERED}, each of its
4543 children is blocked until all earlier siblings are marked DONE.  Here
4544 is an example:
4546 @example
4547 * TODO Blocked until (two) is done
4548 ** DONE one
4549 ** TODO two
4551 * Parent
4552 :PROPERTIES:
4553 :ORDERED:  t
4554 :END:
4555 ** TODO a
4556 ** TODO b, needs to wait for (a)
4557 ** TODO c, needs to wait for (a) and (b)
4558 @end example
4560 @cindex TODO dependencies, NOBLOCKING
4561 @cindex NOBLOCKING, property
4562 You can ensure an entry is never blocked by using the @samp{NOBLOCKING}
4563 property:
4565 @example
4566 * This entry is never blocked
4567 :PROPERTIES:
4568 :NOBLOCKING: t
4569 :END:
4570 @end example
4572 @table @asis
4573 @item @kbd{C-c C-x o} (@code{org-toggle-ordered-property})
4574 @kindex C-c C-x o
4575 @findex org-toggle-ordered-property
4576 @vindex org-track-ordered-property-with-tag
4577 Toggle the @samp{ORDERED} property of the current entry.  A property
4578 is used for this behavior because this should be local to the
4579 current entry, not inherited like a tag.  However, if you would
4580 like to @emph{track} the value of this property with a tag for better
4581 visibility, customize the variable
4582 @code{org-track-ordered-property-with-tag}.
4584 @item @kbd{C-u C-u C-u C-c C-t}
4585 @kindex C-u C-u C-u C-c C-t
4586 Change TODO state, circumventing any state blocking.
4587 @end table
4589 @vindex org-agenda-dim-blocked-tasks
4590 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
4591 that cannot be closed because of such dependencies are shown in
4592 a dimmed font or even made invisible in agenda views (see @ref{Agenda Views}).
4594 @cindex checkboxes and TODO dependencies
4595 @vindex org-enforce-todo-dependencies
4596 You can also block changes of TODO states by looking at checkboxes
4597 (see @ref{Checkboxes}).  If you set the variable
4598 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
4599 checkboxes is blocked from switching to DONE.
4601 If you need more complex dependency structures, for example
4602 dependencies between entries in different trees or files, check out
4603 the contributed module @samp{org-depend.el}.
4605 @node Progress Logging
4606 @section Progress Logging
4608 @cindex progress logging
4609 @cindex logging, of progress
4611 Org mode can automatically record a timestamp and possibly a note when
4612 you mark a TODO item as DONE, or even each time you change the state
4613 of a TODO item.  This system is highly configurable, settings can be
4614 on a per-keyword basis and can be localized to a file or even
4615 a subtree.  For information on how to clock working time for a task,
4616 see @ref{Clocking Work Time}.
4618 @menu
4619 * Closing items::                When was this entry marked DONE?
4620 * Tracking TODO state changes::  When did the status change?
4621 * Tracking your habits::         How consistent have you been?
4622 @end menu
4624 @node Closing items
4625 @subsection Closing items
4627 The most basic logging is to keep track of @emph{when} a certain TODO item
4628 was finished.  This is achieved with@footnote{The corresponding in-buffer setting is: @samp{#+STARTUP: logdone}.}
4630 @lisp
4631 (setq org-log-done 'time)
4632 @end lisp
4634 @vindex org-closed-keep-when-no-todo
4635 @noindent
4636 Then each time you turn an entry from a TODO (not-done) state into any
4637 of the DONE states, a line @samp{CLOSED: [timestamp]} is inserted just
4638 after the headline.  If you turn the entry back into a TODO item
4639 through further state cycling, that line is removed again.  If you
4640 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
4641 @code{org-closed-keep-when-no-todo} to non-@code{nil}.  If you want to record
4642 a note along with the timestamp, use@footnote{The corresponding in-buffer setting is: @samp{#+STARTUP:
4643 lognotedone}.}
4645 @lisp
4646 (setq org-log-done 'note)
4647 @end lisp
4649 @noindent
4650 You are then be prompted for a note, and that note is stored below the
4651 entry with a @samp{Closing Note} heading.
4653 @node Tracking TODO state changes
4654 @subsection Tracking TODO state changes
4656 @cindex drawer, for state change recording
4658 @vindex org-log-states-order-reversed
4659 @vindex org-log-into-drawer
4660 @cindex @samp{LOG_INTO_DRAWER}, property
4661 When TODO keywords are used as workflow states (see @ref{Workflow states, , *Workflow states}),
4662 you might want to keep track of when a state change occurred and maybe
4663 take a note about this change.  You can either record just
4664 a timestamp, or a time-stamped note for a change.  These records are
4665 inserted after the headline as an itemized list, newest first@footnote{See the variable @code{org-log-states-order-reversed}.}.
4666 When taking a lot of notes, you might want to get the notes out of the
4667 way into a drawer (see @ref{Drawers}).  Customize the variable
4668 @code{org-log-into-drawer} to get this behavior---the recommended drawer
4669 for this is called @samp{LOGBOOK}@footnote{Note that the @samp{LOGBOOK} drawer is unfolded when pressing
4670 @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
4671 setting of this variable for a subtree by setting a @samp{LOG_INTO_DRAWER}
4672 property.
4674 Since it is normally too much to record a note for every state, Org
4675 mode expects configuration on a per-keyword basis for this.  This is
4676 achieved by adding special markers @samp{!} (for a timestamp) or @samp{@@} (for
4677 a note with timestamp) in parentheses after each keyword.  For
4678 example, with the setting
4680 @lisp
4681 (setq org-todo-keywords
4682       '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
4683 @end lisp
4685 @noindent
4686 to record a timestamp without a note for TODO keywords configured with
4687 @samp{@@}, just type @kbd{C-c C-c} to enter a blank note when prompted.
4689 @vindex org-log-done
4690 @noindent
4691 You not only define global TODO keywords and fast access keys, but
4692 also request that a time is recorded when the entry is set to @samp{DONE},
4693 and that a note is recorded when switching to @samp{WAIT} or
4694 @samp{CANCELED}@footnote{It is possible that Org mode records two timestamps when you
4695 are using both @code{org-log-done} and state change logging.  However, it
4696 never prompts for two notes: if you have configured both, the state
4697 change recording note takes precedence and cancel the closing note.}.  The setting for @samp{WAIT} is even more special: the
4698 @samp{!} after the slash means that in addition to the note taken when
4699 entering the state, a timestamp should be recorded when @emph{leaving} the
4700 @samp{WAIT} state, if and only if the @emph{target} state does not configure
4701 logging for entering it.  So it has no effect when switching from
4702 @samp{WAIT} to @samp{DONE}, because @samp{DONE} is configured to record a timestamp
4703 only.  But when switching from @samp{WAIT} back to @samp{TODO}, the @samp{/!} in the
4704 @samp{WAIT} setting now triggers a timestamp even though @samp{TODO} has no
4705 logging configured.
4707 You can use the exact same syntax for setting logging preferences local
4708 to a buffer:
4710 @example
4711 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
4712 @end example
4714 @cindex @samp{LOGGING}, property
4715 In order to define logging settings that are local to a subtree or
4716 a single item, define a @samp{LOGGING} property in this entry.  Any
4717 non-empty @samp{LOGGING} property resets all logging settings to @code{nil}.
4718 You may then turn on logging for this specific tree using @samp{STARTUP}
4719 keywords like @samp{lognotedone} or @samp{logrepeat}, as well as adding state
4720 specific settings like @samp{TODO(!)}.  For example:
4722 @example
4723 * TODO Log each state with only a time
4724   :PROPERTIES:
4725   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
4726   :END:
4727 * TODO Only log when switching to WAIT, and when repeating
4728   :PROPERTIES:
4729   :LOGGING: WAIT(@@) logrepeat
4730   :END:
4731 * TODO No logging at all
4732   :PROPERTIES:
4733   :LOGGING: nil
4734   :END:
4735 @end example
4737 @node Tracking your habits
4738 @subsection Tracking your habits
4740 @cindex habits
4741 @cindex STYLE, property
4743 Org has the ability to track the consistency of a special category of
4744 TODO, called ``habits.''  A habit has the following properties:
4746 @enumerate
4747 @item
4748 You have enabled the @code{habits} module by customizing the variable
4749 @code{org-modules}.
4751 @item
4752 The habit is a TODO item, with a TODO keyword representing an open
4753 state.
4755 @item
4756 The property @samp{STYLE} is set to the value @samp{habit}.
4758 @item
4759 The TODO has a scheduled date, usually with a @samp{.+} style repeat
4760 interval.  A @samp{++} style may be appropriate for habits with time
4761 constraints, e.g., must be done on weekends, or a @samp{+} style for an
4762 unusual habit that can have a backlog, e.g., weekly reports.
4764 @item
4765 The TODO may also have minimum and maximum ranges specified by
4766 using the syntax @samp{.+2d/3d}, which says that you want to do the task
4767 at least every three days, but at most every two days.
4769 @item
4770 You must also have state logging for the DONE state enabled (see
4771 @ref{Tracking TODO state changes}), in order for historical data to be
4772 represented in the consistency graph.  If it is not enabled it is
4773 not an error, but the consistency graphs are largely meaningless.
4774 @end enumerate
4776 To give you an idea of what the above rules look like in action, here's an
4777 actual habit with some history:
4779 @example
4780 ** TODO Shave
4781    SCHEDULED: <2009-10-17 Sat .+2d/4d>
4782    :PROPERTIES:
4783    :STYLE:    habit
4784    :LAST_REPEAT: [2009-10-19 Mon 00:36]
4785    :END:
4786    - State "DONE"       from "TODO"       [2009-10-15 Thu]
4787    - State "DONE"       from "TODO"       [2009-10-12 Mon]
4788    - State "DONE"       from "TODO"       [2009-10-10 Sat]
4789    - State "DONE"       from "TODO"       [2009-10-04 Sun]
4790    - State "DONE"       from "TODO"       [2009-10-02 Fri]
4791    - State "DONE"       from "TODO"       [2009-09-29 Tue]
4792    - State "DONE"       from "TODO"       [2009-09-25 Fri]
4793    - State "DONE"       from "TODO"       [2009-09-19 Sat]
4794    - State "DONE"       from "TODO"       [2009-09-16 Wed]
4795    - State "DONE"       from "TODO"       [2009-09-12 Sat]
4796 @end example
4798 What this habit says is: I want to shave at most every 2 days---given
4799 by the @samp{SCHEDULED} date and repeat interval---and at least every
4800 4 days.  If today is the 15th, then the habit first appears in the
4801 agenda on Oct 17, after the minimum of 2 days has elapsed, and will
4802 appear overdue on Oct 19, after four days have elapsed.
4804 What's really useful about habits is that they are displayed along
4805 with a consistency graph, to show how consistent you've been at
4806 getting that task done in the past.  This graph shows every day that
4807 the task was done over the past three weeks, with colors for each day.
4808 The colors used are:
4810 @table @asis
4811 @item Blue
4812 If the task was not to be done yet on that day.
4813 @item Green
4814 If the task could have been done on that day.
4815 @item Yellow
4816 If the task was going to be overdue the next day.
4817 @item Red
4818 If the task was overdue on that day.
4819 @end table
4821 In addition to coloring each day, the day is also marked with an
4822 asterisk if the task was actually done that day, and an exclamation
4823 mark to show where the current day falls in the graph.
4825 There are several configuration variables that can be used to change
4826 the way habits are displayed in the agenda.
4828 @table @asis
4829 @item @code{org-habit-graph-column}
4830 @vindex org-habit-graph-column
4831 The buffer column at which the consistency graph should be drawn.
4832 This overwrites any text in that column, so it is a good idea to
4833 keep your habits' titles brief and to the point.
4835 @item @code{org-habit-preceding-days}
4836 @vindex org-habit-preceding-days
4837 The amount of history, in days before today, to appear in
4838 consistency graphs.
4840 @item @code{org-habit-following-days}
4841 @vindex org-habit-following-days
4842 The number of days after today that appear in consistency graphs.
4844 @item @code{org-habit-show-habits-only-for-today}
4845 @vindex org-habit-show-habits-only-for-today
4846 If non-@code{nil}, only show habits in today's agenda view.  This is
4847 set to true by default.
4848 @end table
4850 Lastly, pressing @kbd{K} in the agenda buffer causes habits to
4851 temporarily be disabled and do not appear at all.  Press @kbd{K}
4852 again to bring them back.  They are also subject to tag filtering, if
4853 you have habits which should only be done in certain contexts, for
4854 example.
4856 @node Priorities
4857 @section Priorities
4859 @cindex priorities
4860 @cindex priority cookie
4862 If you use Org mode extensively, you may end up with enough TODO items
4863 that it starts to make sense to prioritize them.  Prioritizing can be
4864 done by placing a @emph{priority cookie} into the headline of a TODO item,
4865 like this
4867 @example
4868 *** TODO [#A] Write letter to Sam Fortune
4869 @end example
4871 @vindex org-priority-faces
4872 @noindent
4873 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and @samp{C}.
4874 @samp{A} is the highest priority.  An entry without a cookie is treated
4875 just like priority @samp{B}.  Priorities make a difference only for sorting
4876 in the agenda (see @ref{Weekly/daily agenda}); outside the agenda, they
4877 have no inherent meaning to Org mode.  The cookies can be highlighted
4878 with special faces by customizing the variable @code{org-priority-faces}.
4880 Priorities can be attached to any outline node; they do not need to be
4881 TODO items.
4883 @table @asis
4884 @item @kbd{C-c ,} (@code{org-priority})
4885 @kindex C-c ,
4886 @findex org-priority
4887 Set the priority of the current headline.  The command prompts
4888 for a priority character @samp{A}, @samp{B} or @samp{C}.  When you press
4889 @kbd{@key{SPC}} instead, the priority cookie is removed from the
4890 headline.  The priorities can also be changed ``remotely'' from the
4891 timeline and agenda buffer with the @kbd{,} command (see
4892 @ref{Agenda Commands}).
4894 @item @kbd{S-@key{UP}} (@code{org-priority-up})
4895 @itemx @kbd{S-@key{DOWN}} (@code{org-priority-down})
4896 @kindex S-UP
4897 @kindex S-DOWN
4898 @findex org-priority-up
4899 @findex org-priority-down
4900 @vindex org-priority-start-cycle-with-default
4901 Increase/decrease priority of current headline@footnote{See also the option @code{org-priority-start-cycle-with-default}.}.  Note that
4902 these keys are also used to modify timestamps (see @ref{Creating Timestamps}).  See also @ref{Conflicts}, for
4903 a discussion of the interaction with @code{shift-selection-mode}.
4904 @end table
4906 @vindex org-highest-priority
4907 @vindex org-lowest-priority
4908 @vindex org-default-priority
4909 You can change the range of allowed priorities by setting the
4910 variables @code{org-highest-priority}, @code{org-lowest-priority}, and
4911 @code{org-default-priority}.  For an individual buffer, you may set these
4912 values (highest, lowest, default) like this (please make sure that the
4913 highest priority is earlier in the alphabet than the lowest priority):
4915 @cindex @samp{PRIORITIES}, keyword
4916 @example
4917 #+PRIORITIES: A C B
4918 @end example
4920 @node Breaking Down Tasks
4921 @section Breaking Down Tasks into Subtasks
4923 @cindex tasks, breaking down
4924 @cindex statistics, for TODO items
4926 @vindex org-agenda-todo-list-sublevels
4927 It is often advisable to break down large tasks into smaller,
4928 manageable subtasks.  You can do this by creating an outline tree
4929 below a TODO item, with detailed subtasks on the tree@footnote{To keep subtasks out of the global TODO list, see the
4930 @code{org-agenda-todo-list-sublevels}.}.  To keep
4931 the overview over the fraction of subtasks that are already completed,
4932 insert either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies
4933 are updated each time the TODO status of a child changes, or when
4934 pressing @kbd{C-c C-c} on the cookie.  For example:
4936 @example
4937 * Organize Party [33%]
4938 ** TODO Call people [1/2]
4939 *** TODO Peter
4940 *** DONE Sarah
4941 ** TODO Buy food
4942 ** DONE Talk to neighbor
4943 @end example
4945 @cindex @samp{COOKIE_DATA}, property
4946 If a heading has both checkboxes and TODO children below it, the
4947 meaning of the statistics cookie become ambiguous.  Set the property
4948 @samp{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve this issue.
4950 @vindex org-hierarchical-todo-statistics
4951 If you would like to have the statistics cookie count any TODO entries
4952 in the subtree (not just direct children), configure the variable
4953 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
4954 include the word @samp{recursive} into the value of the @samp{COOKIE_DATA}
4955 property.
4957 @example
4958 * Parent capturing statistics [2/20]
4959   :PROPERTIES:
4960   :COOKIE_DATA: todo recursive
4961   :END:
4962 @end example
4964 If you would like a TODO entry to automatically change to DONE when
4965 all children are done, you can use the following setup:
4967 @lisp
4968 (defun org-summary-todo (n-done n-not-done)
4969   "Switch entry to DONE when all subentries are done, to TODO otherwise."
4970   (let (org-log-done org-log-states)   ; turn off logging
4971     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
4973 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
4974 @end lisp
4976 Another possibility is the use of checkboxes to identify (a hierarchy
4977 of) a large number of subtasks (see @ref{Checkboxes}).
4979 @node Checkboxes
4980 @section Checkboxes
4982 @cindex checkboxes
4984 @vindex org-list-automatic-rules
4985 Every item in a plain list@footnote{With the exception of description lists.  But you can allow it
4986 by modifying @code{org-list-automatic-rules} accordingly.} (see @ref{Plain Lists}) can be made into
4987 a checkbox by starting it with the string @samp{[ ]}.  This feature is
4988 similar to TODO items (see @ref{TODO Items}), but is more lightweight.
4989 Checkboxes are not included into the global TODO list, so they are
4990 often great to split a task into a number of simple steps.  Or you can
4991 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
4992 @samp{org-mouse.el}).
4994 Here is an example of a checkbox list.
4996 @example
4997 * TODO Organize party [2/4]
4998   - [-] call people [1/3]
4999     - [ ] Peter
5000     - [X] Sarah
5001     - [ ] Sam
5002   - [X] order food
5003   - [ ] think about what music to play
5004   - [X] talk to the neighbors
5005 @end example
5007 Checkboxes work hierarchically, so if a checkbox item has children
5008 that are checkboxes, toggling one of the children checkboxes makes the
5009 parent checkbox reflect if none, some, or all of the children are
5010 checked.
5012 @cindex statistics, for checkboxes
5013 @cindex checkbox statistics
5014 @cindex @samp{COOKIE_DATA}, property
5015 @vindex org-hierarchical-checkbox-statistics
5016 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
5017 indicating how many checkboxes present in this entry have been checked
5018 off, and the total number of checkboxes present.  This can give you an
5019 idea on how many checkboxes remain, even without opening a folded
5020 entry.  The cookies can be placed into a headline or into (the first
5021 line of) a plain list item.  Each cookie covers checkboxes of direct
5022 children structurally below the headline/item on which the cookie
5023 appears@footnote{Set the variable @code{org-hierarchical-checkbox-statistics} if you
5024 want such cookies to count all checkboxes below the cookie, not just
5025 those belonging to direct children.}.  You have to insert the cookie yourself by typing
5026 either @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as
5027 in the examples above.  With @samp{[%]} you get information about the
5028 percentage of checkboxes checked (in the above example, this would be
5029 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can count
5030 either checkboxes below the heading or TODO states of children, and it
5031 displays whatever was changed last.  Set the property @samp{COOKIE_DATA} to
5032 either @samp{checkbox} or @samp{todo} to resolve this issue.
5034 @cindex blocking, of checkboxes
5035 @cindex checkbox blocking
5036 @cindex @samp{ORDERED}, property
5037 If the current outline node has an @samp{ORDERED} property, checkboxes must
5038 be checked off in sequence, and an error is thrown if you try to check
5039 off a box while there are unchecked boxes above it.
5041 @noindent
5042 The following commands work with checkboxes:
5044 @table @asis
5045 @item @kbd{C-c C-c} (@code{org-toggle-checkbox})
5046 @kindex C-c C-c
5047 @findex org-toggle-checkbox
5048 Toggle checkbox status or---with prefix argument---checkbox
5049 presence at point.  With a single prefix argument, add an empty
5050 checkbox or remove the current one@footnote{@kbd{C-u C-c C-c} on the @emph{first} item of a list with no
5051 checkbox adds checkboxes to the rest of the list.}.  With a double prefix
5052 argument, set it to @samp{[-]}, which is considered to be an
5053 intermediate state.
5055 @item @kbd{C-c C-x C-b} (@code{org-toggle-checkbox})
5056 @kindex C-c C-x C-b
5057 Toggle checkbox status or---with prefix argument---checkbox
5058 presence at point.  With double prefix argument, set it to @samp{[-]},
5059 which is considered to be an intermediate state.
5061 @itemize
5062 @item
5063 If there is an active region, toggle the first checkbox in the
5064 region and set all remaining boxes to the same status as the
5065 first.  With a prefix argument, add or remove the checkbox for
5066 all items in the region.
5068 @item
5069 If the cursor is in a headline, toggle checkboxes in the region
5070 between this headline and the next---so @emph{not} the entire
5071 subtree.
5073 @item
5074 If there is no active region, just toggle the checkbox at
5075 point.
5076 @end itemize
5078 @item @kbd{M-S-@key{RET}} (@code{org-insert-todo-heading})
5079 @kindex M-S-RET
5080 @findex org-insert-todo-heading
5081 Insert a new item with a checkbox.  This works only if the cursor
5082 is already in a plain list item (see @ref{Plain Lists}).
5084 @item @kbd{C-c C-x o} (@code{org-toggle-ordered-property})
5085 @kindex C-c C-x o
5086 @findex org-toggle-ordered-property
5087 @vindex org-track-ordered-property-with-tag
5088 Toggle the @samp{ORDERED} property of the entry, to toggle if
5089 checkboxes must be checked off in sequence.  A property is used
5090 for this behavior because this should be local to the current
5091 entry, not inherited like a tag.  However, if you would like to
5092 @emph{track} the value of this property with a tag for better
5093 visibility, customize @code{org-track-ordered-property-with-tag}.
5095 @item @kbd{C-c #} (@code{org-update-statistics-cookies})
5096 @kindex C-c #
5097 @findex org-update-statistics-cookies
5098 Update the statistics cookie in the current outline entry.  When
5099 called with a @kbd{C-u} prefix, update the entire file.
5100 Checkbox statistic cookies are updated automatically if you
5101 toggle checkboxes with @kbd{C-c C-c} and make new ones with
5102 @kbd{M-S-@key{RET}}.  TODO statistics cookies update when changing
5103 TODO states.  If you delete boxes/entries or add/change them by
5104 hand, use this command to get things back into sync.
5105 @end table
5107 @node Tags
5108 @chapter Tags
5110 @cindex tags
5111 @cindex headline tagging
5112 @cindex matching, tags
5113 @cindex sparse tree, tag based
5115 An excellent way to implement labels and contexts for
5116 cross-correlating information is to assign @emph{tags} to headlines.  Org
5117 mode has extensive support for tags.
5119 @vindex org-tag-faces
5120 Every headline can contain a list of tags; they occur at the end of
5121 the headline.  Tags are normal words containing letters, numbers, @samp{_},
5122 and @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
5123 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.  Tags
5124 by default are in bold face with the same color as the headline.  You
5125 may specify special faces for specific tags using the variable
5126 @code{org-tag-faces}, in much the same way as you can for TODO keywords
5127 (see @ref{Faces for TODO keywords}).
5129 @menu
5130 * Tag Inheritance::              Tags use the tree structure of an outline.
5131 * Setting Tags::                 How to assign tags to a headline.
5132 * Tag Hierarchy::                Create a hierarchy of tags.
5133 * Tag Searches::                 Searching for combinations of tags.
5134 @end menu
5136 @node Tag Inheritance
5137 @section Tag Inheritance
5139 @cindex tag inheritance
5140 @cindex inheritance, of tags
5141 @cindex sublevels, inclusion into tags match
5143 @emph{Tags} make use of the hierarchical structure of outline trees.  If
5144 a heading has a certain tag, all subheadings inherit the tag as well.
5145 For example, in the list
5147 @example
5148 * Meeting with the French group      :work:
5149 ** Summary by Frank                  :boss:notes:
5150 *** TODO Prepare slides for him      :action:
5151 @end example
5153 @noindent
5154 the final heading has the tags @samp{work}, @samp{boss}, @samp{notes}, and @samp{action}
5155 even though the final heading is not explicitly marked with those
5156 tags.  You can also set tags that all entries in a file should inherit
5157 just as if these tags were defined in a hypothetical level zero that
5158 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.}
5160 @cindex @samp{FILETAGS}, keyword
5161 @example
5162 #+FILETAGS: :Peter:Boss:Secret:
5163 @end example
5165 @vindex org-use-tag-inheritance
5166 @vindex org-tags-exclude-from-inheritance
5167 @noindent
5168 To limit tag inheritance to specific tags, or to turn it off entirely,
5169 use the variables @code{org-use-tag-inheritance} and
5170 @code{org-tags-exclude-from-inheritance}.
5172 @vindex org-tags-match-list-sublevels
5173 When a headline matches during a tags search while tag inheritance is
5174 turned on, all the sublevels in the same tree---for a simple match
5175 form---match as well@footnote{This is only true if the search does not involve more complex
5176 tests including properties (see @ref{Property Searches}).}.  The list of matches may then become
5177 very long.  If you only want to see the first tags match in a subtree,
5178 configure the variable @code{org-tags-match-list-sublevels} (not
5179 recommended).
5181 @vindex org-agenda-use-tag-inheritance
5182 Tag inheritance is relevant when the agenda search tries to match
5183 a tag, either in the @code{tags} or @code{tags-todo} agenda types.  In other
5184 agenda types, @code{org-use-tag-inheritance} has no effect.  Still, you may
5185 want to have your tags correctly set in the agenda, so that tag
5186 filtering works fine, with inherited tags.  Set
5187 @code{org-agenda-use-tag-inheritance} to control this: the default value
5188 includes all agenda types, but setting this to @code{nil} can really speed
5189 up agenda generation.
5191 @node Setting Tags
5192 @section Setting Tags
5194 @cindex setting tags
5195 @cindex tags, setting
5197 @kindex M-TAB
5198 Tags can simply be typed into the buffer at the end of a headline.
5199 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
5200 also a special command for inserting tags:
5202 @table @asis
5203 @item @kbd{C-c C-q} (@code{org-set-tags-command})
5204 @kindex C-c C-q
5205 @findex org-set-tags-command
5206 @cindex completion, of tags
5207 @vindex org-tags-column
5208 Enter new tags for the current headline.  Org mode either offers
5209 completion or a special single-key interface for setting tags,
5210 see below.  After pressing @kbd{@key{RET}}, the tags are inserted
5211 and aligned to @code{org-tags-column}.  When called with
5212 a @kbd{C-u} prefix, all tags in the current buffer are
5213 aligned to that column, just to make things look nice.  Tags are
5214 automatically realigned after promotion, demotion, and TODO state
5215 changes (see @ref{TODO Basics}).
5217 @item @kbd{C-c C-c} (@code{org-set-tags-command})
5218 @kindex C-c C-c
5219 When the cursor is in a headline, this does the same as
5220 @kbd{C-c C-q}.
5221 @end table
5223 @vindex org-tag-alist
5224 Org supports tag insertion based on a @emph{list of tags}.  By default this
5225 list is constructed dynamically, containing all tags currently used in
5226 the buffer.  You may also globally specify a hard list of tags with
5227 the variable @code{org-tag-alist}.  Finally you can set the default tags
5228 for a given file with lines like
5230 @cindex @samp{TAGS}, keyword
5231 @example
5232 #+TAGS: @@work @@home @@tennisclub
5233 #+TAGS: laptop car pc sailboat
5234 @end example
5236 If you have globally defined your preferred set of tags using the
5237 variable @code{org-tag-alist}, but would like to use a dynamic tag list in
5238 a specific file, add an empty @samp{TAGS} keyword to that file:
5240 @example
5241 #+TAGS:
5242 @end example
5244 @vindex org-tag-persistent-alist
5245 If you have a preferred set of tags that you would like to use in
5246 every file, in addition to those defined on a per-file basis by @samp{TAGS}
5247 keyword, then you may specify a list of tags with the variable
5248 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
5249 by adding a @samp{STARTUP} keyword to that file:
5251 @example
5252 #+STARTUP: noptag
5253 @end example
5255 By default Org mode uses the standard minibuffer completion facilities
5256 for entering tags.  However, it also implements another, quicker, tag
5257 selection method called @emph{fast tag selection}.  This allows you to
5258 select and deselect tags with just a single key press.  For this to
5259 work well you should assign unique letters to most of your commonly
5260 used tags.  You can do this globally by configuring the variable
5261 @code{org-tag-alist} in your Emacs init file.  For example, you may find
5262 the need to tag many items in different files with @samp{@@home}.  In this
5263 case you can set something like:
5265 @lisp
5266 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
5267 @end lisp
5269 @noindent
5270 If the tag is only relevant to the file you are working on, then you
5271 can instead set the @samp{TAGS} keyword as:
5273 @example
5274 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
5275 @end example
5277 @noindent
5278 The tags interface shows the available tags in a splash window.  If
5279 you want to start a new line after a specific tag, insert @samp{\n} into
5280 the tag list
5282 @example
5283 #+TAGS: @@work(w) @@home(h) @@tennisclub(t) \n laptop(l) pc(p)
5284 @end example
5286 @noindent
5287 or write them in two lines:
5289 @example
5290 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
5291 #+TAGS: laptop(l)  pc(p)
5292 @end example
5294 @noindent
5295 You can also group together tags that are mutually exclusive by using
5296 braces, as in:
5298 @example
5299 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
5300 @end example
5302 @noindent
5303 you indicate that at most one of @samp{@@work}, @samp{@@home}, and @samp{@@tennisclub}
5304 should be selected.  Multiple such groups are allowed.
5306 @noindent
5307 Do not forget to press @kbd{C-c C-c} with the cursor in one of
5308 these lines to activate any changes.
5310 @noindent
5311 To set these mutually exclusive groups in the variable
5312 @code{org-tags-alist}, you must use the dummy tags @code{:startgroup} and
5313 @code{:endgroup} instead of the braces.  Similarly, you can use @code{:newline}
5314 to indicate a line break.  The previous example would be set globally
5315 by the following configuration:
5317 @lisp
5318 (setq org-tag-alist '((:startgroup . nil)
5319                       ("@@work" . ?w) ("@@home" . ?h)
5320                       ("@@tennisclub" . ?t)
5321                       (:endgroup . nil)
5322                       ("laptop" . ?l) ("pc" . ?p)))
5323 @end lisp
5325 If at least one tag has a selection key then pressing @kbd{C-c C-c} automatically presents you with a special interface, listing
5326 inherited tags, the tags of the current headline, and a list of all
5327 valid tags with corresponding keys@footnote{Keys are automatically assigned to tags that have no
5328 configured keys.}.
5330 Pressing keys assigned to tags adds or removes them from the list of
5331 tags in the current line.  Selecting a tag in a group of mutually
5332 exclusive tags turns off any other tag from that group.
5334 In this interface, you can also use the following special keys:
5336 @table @asis
5337 @item @kbd{@key{TAB}}
5338 @kindex TAB
5339 Enter a tag in the minibuffer, even if the tag is not in the
5340 predefined list.  You can complete on all tags present in the
5341 buffer.  You can also add several tags: just separate them with
5342 a comma.
5344 @item @kbd{@key{SPC}}
5345 @kindex SPC
5346 Clear all tags for this line.
5348 @item @kbd{@key{RET}}
5349 @kindex RET
5350 Accept the modified set.
5352 @item @kbd{C-g}
5353 @kindex C-g
5354 Abort without installing changes.
5356 @item @kbd{q}
5357 @kindex q
5358 If @kbd{q} is not assigned to a tag, it aborts like
5359 @kbd{C-g}.
5361 @item @kbd{!}
5362 @kindex !
5363 Turn off groups of mutually exclusive tags.  Use this to (as an
5364 exception) assign several tags from such a group.
5366 @item @kbd{C-c}
5367 @kindex C-c C-c
5368 Toggle auto-exit after the next change (see below).  If you are
5369 using expert mode, the first @kbd{C-c} displays the
5370 selection window.
5371 @end table
5373 @noindent
5374 This method lets you assign tags to a headline with very few keys.
5375 With the above setup, you could clear the current tags and set
5376 @samp{@@home}, @samp{laptop} and @samp{pc} tags with just the following keys:
5377 @kbd{C-c C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to @samp{@@work}
5378 would be done with @kbd{C-c C-c w @key{RET}} or alternatively with
5379 @kbd{C-c C-c C-c w}.  Adding the non-predefined tag @samp{Sarah} could
5380 be done with @kbd{C-c C-c @key{TAB} S a r a h @key{RET}}.
5382 @vindex org-fast-tag-selection-single-key
5383 If you find that most of the time you need only a single key press to
5384 modify your list of tags, set the variable
5385 @code{org-fast-tag-selection-single-key}.  Then you no longer have to press
5386 @kbd{@key{RET}} to exit fast tag selection---it exits after the first
5387 change.  If you then occasionally need more keys, press @kbd{C-c}
5388 to turn off auto-exit for the current tag selection process (in
5389 effect: start selection with @kbd{C-c C-c C-c} instead of
5390 @kbd{C-c C-c}).  If you set the variable to the value @code{expert},
5391 the special window is not even shown for single-key tag selection, it
5392 comes up only when you press an extra @kbd{C-c}.
5394 @node Tag Hierarchy
5395 @section Tag Hierarchy
5397 @cindex group tags
5398 @cindex tags, groups
5399 @cindex tags hierarchy
5401 Tags can be defined in hierarchies.  A tag can be defined as a @emph{group
5402 tag} for a set of other tags.  The group tag can be seen as the
5403 ``broader term'' for its set of tags.  Defining multiple group tags and
5404 nesting them creates a tag hierarchy.
5406 One use-case is to create a taxonomy of terms (tags) that can be used
5407 to classify nodes in a document or set of documents.
5409 When you search for a group tag, it return matches for all members in
5410 the group and its subgroups.  In an agenda view, filtering by a group
5411 tag displays or hide headlines tagged with at least one of the members
5412 of the group or any of its subgroups.  This makes tag searches and
5413 filters even more flexible.
5415 You can set group tags by using brackets and inserting a colon between
5416 the group tag and its related tags---beware that all whitespaces are
5417 mandatory so that Org can parse this line correctly:
5419 @example
5420 #+TAGS: [ GTD : Control Persp ]
5421 @end example
5423 In this example, @samp{GTD} is the group tag and it is related to two other
5424 tags: @samp{Control}, @samp{Persp}.  Defining @samp{Control} and @samp{Persp} as group
5425 tags creates an hierarchy of tags:
5427 @example
5428 #+TAGS: [ Control : Context Task ]
5429 #+TAGS: [ Persp : Vision Goal AOF Project ]
5430 @end example
5432 That can conceptually be seen as a hierarchy of tags:
5434 @itemize
5435 @item
5436 @samp{GTD}
5437 @itemize
5438 @item
5439 @samp{Persp}
5440 @itemize
5441 @item
5442 @samp{Vision}
5443 @item
5444 @samp{Goal}
5445 @item
5446 @samp{AOF}
5447 @item
5448 @samp{Project}
5449 @end itemize
5450 @item
5451 @samp{Control}
5452 @itemize
5453 @item
5454 @samp{Context}
5455 @item
5456 @samp{Task}
5457 @end itemize
5458 @end itemize
5459 @end itemize
5461 You can use the @code{:startgrouptag}, @code{:grouptags} and @code{:endgrouptag}
5462 keyword directly when setting @code{org-tag-alist} directly:
5464 @lisp
5465 (setq org-tag-alist '((:startgrouptag)
5466                       ("GTD")
5467                       (:grouptags)
5468                       ("Control")
5469                       ("Persp")
5470                       (:endgrouptag)
5471                       (:startgrouptag)
5472                       ("Control")
5473                       (:grouptags)
5474                       ("Context")
5475                       ("Task")
5476                       (:endgrouptag)))
5477 @end lisp
5479 The tags in a group can be mutually exclusive if using the same group
5480 syntax as is used for grouping mutually exclusive tags together; using
5481 curly brackets.
5483 @example
5484 #+TAGS: @{ Context : @@Home @@Work @@Call @}
5485 @end example
5487 When setting @code{org-tag-alist} you can use @code{:startgroup} and @code{:endgroup}
5488 instead of @code{:startgrouptag} and @code{:endgrouptag} to make the tags
5489 mutually exclusive.
5491 Furthermore, the members of a group tag can also be regular
5492 expressions, creating the possibility of a more dynamic and rule-based
5493 tag structure.  The regular expressions in the group must be specified
5494 within curly brackets.  Here is an expanded example:
5496 @example
5497 #+TAGS: [ Vision : @{V@@.+@} ]
5498 #+TAGS: [ Goal : @{G@@.+@} ]
5499 #+TAGS: [ AOF : @{AOF@@.+@} ]
5500 #+TAGS: [ Project : @{P@@.+@} ]
5501 @end example
5503 Searching for the tag @samp{Project} now lists all tags also including
5504 regular expression matches for @samp{P@@.+}, and similarly for tag searches
5505 on @samp{Vision}, @samp{Goal} and @samp{AOF}.  For example, this would work well for
5506 a project tagged with a common project-identifier,
5507 e.g. @samp{P@@2014_OrgTags}.
5509 @kindex C-c C-x q
5510 @findex org-toggle-tags-groups
5511 @vindex org-group-tags
5512 If you want to ignore group tags temporarily, toggle group tags
5513 support with @code{org-toggle-tags-groups}, bound to @kbd{C-c C-x q}.
5514 If you want to disable tag groups completely, set @code{org-group-tags} to
5515 @code{nil}.
5517 @node Tag Searches
5518 @section Tag Searches
5520 @cindex tag searches
5521 @cindex searching for tags
5523 Once a system of tags has been set up, it can be used to collect
5524 related information into special lists.
5526 @table @asis
5527 @item @kbd{C-c / m} or @kbd{C-c \} (@code{org-match-sparse-tree})
5528 @kindex C-c / m
5529 @kindex C-c \
5530 @findex org-match-sparse-tree
5531 Create a sparse tree with all headlines matching a tags search.
5532 With a @kbd{C-u} prefix argument, ignore headlines that are
5533 not a TODO line.
5535 @item @kbd{C-c a m} (@code{org-tags-view})
5536 @kindex C-c a m
5537 @findex org-tags-view
5538 Create a global list of tag matches from all agenda files.  See
5539 @ref{Matching tags and properties}.
5541 @item @kbd{C-c a M} (@code{org-tags-view})
5542 @kindex C-c a M
5543 @vindex org-tags-match-list-sublevels
5544 Create a global list of tag matches from all agenda files, but
5545 check only TODO items and force checking subitems (see the option
5546 @code{org-tags-match-list-sublevels}).
5547 @end table
5549 These commands all prompt for a match string which allows basic
5550 Boolean logic like @samp{+boss+urgent-project1}, to find entries with tags
5551 @samp{boss} and @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find
5552 entries which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of
5553 the search string is rich and allows also matching against TODO
5554 keywords, entry levels and properties.  For a complete description
5555 with many examples, see @ref{Matching tags and properties}.
5557 @node Properties and Columns
5558 @chapter Properties and Columns
5560 @cindex properties
5562 A property is a key-value pair associated with an entry.  Properties
5563 can be set so they are associated with a single entry, with every
5564 entry in a tree, or with every entry in an Org file.
5566 There are two main applications for properties in Org mode.  First,
5567 properties are like tags, but with a value.  Imagine maintaining
5568 a file where you document bugs and plan releases for a piece of
5569 software.  Instead of using tags like @samp{release_1}, @samp{release_2}, you
5570 can use a property, say @samp{Release}, that in different subtrees has
5571 different values, such as @samp{1.0} or @samp{2.0}.  Second, you can use
5572 properties to implement (very basic) database capabilities in an Org
5573 buffer.  Imagine keeping track of your music CDs, where properties
5574 could be things such as the album, artist, date of release, number of
5575 tracks, and so on.
5577 Properties can be conveniently edited and viewed in column view (see
5578 @ref{Column View}).
5580 @menu
5581 * Property Syntax::              How properties are spelled out.
5582 * Special Properties::           Access to other Org mode features.
5583 * Property Searches::            Matching property values.
5584 * Property Inheritance::         Passing values down a tree.
5585 * Column View::                  Tabular viewing and editing.
5586 @end menu
5588 @node Property Syntax
5589 @section Property Syntax
5591 @cindex property syntax
5592 @cindex drawer, for properties
5594 Properties are key--value pairs.  When they are associated with
5595 a single entry or with a tree they need to be inserted into a special
5596 drawer (see @ref{Drawers}) with the name @samp{PROPERTIES}, which has to be
5597 located right below a headline, and its planning line (see @ref{Deadlines and Scheduling}) when applicable.  Each property is specified on
5598 a single line, with the key---surrounded by colons---first, and the
5599 value after it.  Keys are case-insensitive.  Here is an example:
5601 @example
5602 * CD collection
5603 ** Classic
5604 *** Goldberg Variations
5605     :PROPERTIES:
5606     :Title:     Goldberg Variations
5607     :Composer:  J.S. Bach
5608     :Artist:    Glen Gould
5609     :Publisher: Deutsche Grammophon
5610     :NDisks:    1
5611     :END:
5612 @end example
5614 Depending on the value of @code{org-use-property-inheritance}, a property
5615 set this way is associated either with a single entry, or with the
5616 sub-tree defined by the entry, see @ref{Property Inheritance}.
5618 You may define the allowed values for a particular property @samp{Xyz} by
5619 setting a property @samp{Xyz_ALL}.  This special property is @emph{inherited},
5620 so if you set it in a level 1 entry, it applies to the entire tree.
5621 When allowed values are defined, setting the corresponding property
5622 becomes easier and is less prone to typing errors.  For the example
5623 with the CD collection, we can pre-define publishers and the number of
5624 disks in a box like this:
5626 @example
5627 * CD collection
5628   :PROPERTIES:
5629   :NDisks_ALL:  1 2 3 4
5630   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
5631   :END:
5632 @end example
5634 If you want to set properties that can be inherited by any entry in
5635 a file, use a line like:
5637 @cindex @samp{_ALL} suffix, in properties
5638 @cindex @samp{PROPERTY}, keyword
5639 @example
5640 #+PROPERTY: NDisks_ALL 1 2 3 4
5641 @end example
5643 @cindex @samp{+} suffix, in properties
5644 If you want to add to the value of an existing property, append a @samp{+}
5645 to the property name.  The following results in the property @samp{var}
5646 having the value @samp{foo=1 bar=2}.
5648 @example
5649 #+PROPERTY: var  foo=1
5650 #+PROPERTY: var+ bar=2
5651 @end example
5653 It is also possible to add to the values of inherited properties.  The
5654 following results in the @samp{Genres} property having the value @samp{Classic
5655 Baroque} under the @samp{Goldberg Variations} subtree.
5657 @example
5658 * CD collection
5659 ** Classic
5660     :PROPERTIES:
5661     :Genres: Classic
5662     :END:
5663 *** Goldberg Variations
5664     :PROPERTIES:
5665     :Title:     Goldberg Variations
5666     :Composer:  J.S. Bach
5667     :Artist:    Glen Gould
5668     :Publisher: Deutsche Grammophon
5669     :NDisks:    1
5670     :Genres+:   Baroque
5671     :END:
5672 @end example
5674 Note that a property can only have one entry per drawer.
5676 @vindex org-global-properties
5677 Property values set with the global variable @code{org-global-properties}
5678 can be inherited by all entries in all Org files.
5680 @noindent
5681 The following commands help to work with properties:
5683 @table @asis
5684 @item @kbd{M-@key{TAB}} (@code{pcomplete})
5685 @kindex M-TAB
5686 @findex pcomplete
5687 After an initial colon in a line, complete property keys.  All
5688 keys used in the current file are offered as possible
5689 completions.
5691 @item @kbd{C-c C-x p} (@code{org-set-property})
5692 @kindex C-c C-x p
5693 @findex org-set-property
5694 Set a property.  This prompts for a property name and a value.
5695 If necessary, the property drawer is created as well.
5697 @item @kbd{C-u M-x org-insert-drawer}
5698 @findex org-insert-drawer
5699 Insert a property drawer into the current entry.  The drawer is
5700 inserted early in the entry, but after the lines with planning
5701 information like deadlines.
5703 @item @kbd{C-c C-c} (@code{org-property-action})
5704 @kindex C-c C-c
5705 @findex org-property-action
5706 With the cursor in a property drawer, this executes property
5707 commands.
5709 @item @kbd{C-c C-c s} (@code{org-set-property})
5710 @kindex C-c C-c s
5711 @findex org-set-property
5712 Set a property in the current entry.  Both the property and the value
5713 can be inserted using completion.
5715 @item @kbd{S-@key{RIGHT}} (@code{org-property-next-allowed-values})
5716 @itemx @kbd{S-@key{LEFT}} (@code{org-property-previous-allowed-value})
5717 @kindex S-RIGHT
5718 @kindex S-LEFT
5719 Switch property at point to the next/previous allowed value.
5721 @item @kbd{C-c C-c d} (@code{org-delete-property})
5722 @kindex C-c C-c d
5723 @findex org-delete-property
5724 Remove a property from the current entry.
5726 @item @kbd{C-c C-c D} (@code{org-delete-property-globally})
5727 @kindex C-c C-c D
5728 @findex org-delete-property-globally
5729 Globally remove a property, from all entries in the current file.
5731 @item @kbd{C-c C-c c} (@code{org-compute-property-at-point})
5732 @kindex C-c C-c c
5733 @findex org-compute-property-at-point
5734 Compute the property at point, using the operator and scope from
5735 the nearest column format definition.
5736 @end table
5738 @node Special Properties
5739 @section Special Properties
5741 @cindex properties, special
5743 Special properties provide an alternative access method to Org mode
5744 features, like the TODO state or the priority of an entry, discussed
5745 in the previous chapters.  This interface exists so that you can
5746 include these states in a column view (see @ref{Column View}), or to use
5747 them in queries.  The following property names are special and should
5748 not be used as keys in the properties drawer:
5750 @cindex @samp{ALLTAGS}, special property
5751 @cindex @samp{BLOCKED}, special property
5752 @cindex @samp{CLOCKSUM}, special property
5753 @cindex @samp{CLOCKSUM_T}, special property
5754 @cindex @samp{CLOSED}, special property
5755 @cindex @samp{DEADLINE}, special property
5756 @cindex @samp{FILE}, special property
5757 @cindex @samp{ITEM}, special property
5758 @cindex @samp{PRIORITY}, special property
5759 @cindex @samp{SCHEDULED}, special property
5760 @cindex @samp{TAGS}, special property
5761 @cindex @samp{TIMESTAMP}, special property
5762 @cindex @samp{TIMESTAMP_IA}, special property
5763 @cindex @samp{TODO}, special property
5764 @multitable {aaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
5765 @item @samp{ALLTAGS}
5766 @tab All tags, including inherited ones.
5767 @item @samp{BLOCKED}
5768 @tab @code{t} if task is currently blocked by children or siblings.
5769 @item @samp{CATEGORY}
5770 @tab The category of an entry.
5771 @item @samp{CLOCKSUM}
5772 @tab The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}
5773 @item 
5774 @tab must be run first to compute the values in the current buffer.
5775 @item @samp{CLOCKSUM_T}
5776 @tab The sum of CLOCK intervals in the subtree for today.
5777 @item 
5778 @tab @code{org-clock-sum-today} must be run first to compute the
5779 @item 
5780 @tab values in the current buffer.
5781 @item @samp{CLOSED}
5782 @tab When was this entry closed?
5783 @item @samp{DEADLINE}
5784 @tab The deadline time string, without the angular brackets.
5785 @item @samp{FILE}
5786 @tab The filename the entry is located in.
5787 @item @samp{ITEM}
5788 @tab The headline of the entry.
5789 @item @samp{PRIORITY}
5790 @tab The priority of the entry, a string with a single letter.
5791 @item @samp{SCHEDULED}
5792 @tab The scheduling timestamp, without the angular brackets.
5793 @item @samp{TAGS}
5794 @tab The tags defined directly in the headline.
5795 @item @samp{TIMESTAMP}
5796 @tab The first keyword-less timestamp in the entry.
5797 @item @samp{TIMESTAMP_IA}
5798 @tab The first inactive timestamp in the entry.
5799 @item @samp{TODO}
5800 @tab The TODO keyword of the entry.
5801 @end multitable
5803 @node Property Searches
5804 @section Property Searches
5806 @cindex properties, searching
5807 @cindex searching, of properties
5809 To create sparse trees and special lists with selection based on
5810 properties, the same commands are used as for tag searches (see @ref{Tag Searches}).
5812 @table @asis
5813 @item @kbd{C-c / m} or @kbd{C-c \} (@code{org-match-sparse-tree})
5814 @kindex C-c / m
5815 @kindex C-c \
5816 @findex org-match-sparse-tree
5817 Create a sparse tree with all matching entries.  With
5818 a @kbd{C-u} prefix argument, ignore headlines that are not
5819 a TODO line.
5821 @item @kbd{C-c a m}, @code{org-tags-view}
5822 @kindex C-c a m
5823 Create a global list of tag/property matches from all agenda
5824 files.
5826 @item @kbd{C-c a M} (@code{org-tags-view})
5827 @kindex C-c a M
5828 @findex org-tags-view
5829 @vindex org-tags-match-list-sublevels
5830 Create a global list of tag matches from all agenda files, but
5831 check only TODO items and force checking of subitems (see the
5832 option @code{org-tags-match-list-sublevels}).
5833 @end table
5835 The syntax for the search string is described in @ref{Matching tags and properties}.
5837 There is also a special command for creating sparse trees based on a
5838 single property:
5840 @table @asis
5841 @item @kbd{C-c / p}
5842 @kindex C-c / p
5843 Create a sparse tree based on the value of a property.  This
5844 first prompts for the name of a property, and then for a value.
5845 A sparse tree is created with all entries that define this
5846 property with the given value.  If you enclose the value in curly
5847 braces, it is interpreted as a regular expression and matched
5848 against the property values.
5849 @end table
5851 @node Property Inheritance
5852 @section Property Inheritance
5854 @cindex properties, inheritance
5855 @cindex inheritance, of properties
5857 @vindex org-use-property-inheritance
5858 The outline structure of Org documents lends itself to an inheritance
5859 model of properties: if the parent in a tree has a certain property,
5860 the children can inherit this property.  Org mode does not turn this
5861 on by default, because it can slow down property searches
5862 significantly and is often not needed.  However, if you find
5863 inheritance useful, you can turn it on by setting the variable
5864 @code{org-use-property-inheritance}.  It may be set to @code{t} to make all
5865 properties inherited from the parent, to a list of properties that
5866 should be inherited, or to a regular expression that matches inherited
5867 properties.  If a property has the value @code{nil}, this is interpreted as
5868 an explicit un-define of the property, so that inheritance search
5869 stops at this value and returns @code{nil}.
5871 Org mode has a few properties for which inheritance is hard-coded, at
5872 least for the special applications for which they are used:
5874 @table @asis
5875 @item @code{COLUMNS}
5876 @cindex @samp{COLUMNS}, property
5877 The @samp{COLUMNS} property defines the format of column view (see
5878 @ref{Column View}).  It is inherited in the sense that the level where
5879 a @samp{COLUMNS} property is defined is used as the starting point for
5880 a column view table, independently of the location in the subtree
5881 from where columns view is turned on.
5883 @item @code{CATEGORY}
5884 @cindex @samp{CATEGORY}, property
5885 For agenda view, a category set through a @samp{CATEGORY} property
5886 applies to the entire subtree.
5888 @item @code{ARCHIVE}
5889 @cindex @samp{ARCHIVE}, property
5890 For archiving, the @samp{ARCHIVE} property may define the archive
5891 location for the entire subtree (see @ref{Moving subtrees}).
5893 @item @code{LOGGING}
5894 @cindex @samp{LOGGING}, property
5895 The @samp{LOGGING} property may define logging settings for an entry
5896 or a subtree (see @ref{Tracking TODO state changes}).
5897 @end table
5899 @node Column View
5900 @section Column View
5902 A great way to view and edit properties in an outline tree is @emph{column
5903 view}.  In column view, each outline node is turned into a table row.
5904 Columns in this table provide access to properties of the entries.
5905 Org mode implements columns by overlaying a tabular structure over the
5906 headline of each item.  While the headlines have been turned into
5907 a table row, you can still change the visibility of the outline tree.
5908 For example, you get a compact table by switching to ``contents''
5909 view---@kbd{S-@key{TAB}} @kbd{S-@key{TAB}}, or simply @kbd{c}
5910 while column view is active---but you can still open, read, and edit
5911 the entry below each headline.  Or, you can switch to column view
5912 after executing a sparse tree command and in this way get a table only
5913 for the selected items.  Column view also works in agenda buffers (see
5914 @ref{Agenda Views}) where queries have collected selected items, possibly
5915 from a number of files.
5917 @menu
5918 * Defining columns::             The COLUMNS format property.
5919 * Using column view::            How to create and use column view.
5920 * Capturing column view::        A dynamic block for column view.
5921 @end menu
5923 @node Defining columns
5924 @subsection Defining columns
5926 @cindex column view, for properties
5927 @cindex properties, column view
5929 Setting up a column view first requires defining the columns.  This is
5930 done by defining a column format line.
5932 @menu
5933 * Scope of column definitions::  Where defined, where valid?
5934 * Column attributes::            Appearance and content of a column.
5935 @end menu
5937 @node Scope of column definitions
5938 @subsubsection Scope of column definitions
5940 To define a column format for an entire file, use a line like:
5942 @cindex @samp{COLUMNS}, keyword
5943 @example
5944 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5945 @end example
5947 To specify a format that only applies to a specific tree, add
5948 a @samp{COLUMNS} property to the top node of that tree, for example:
5950 @example
5951 ** Top node for columns view
5952    :PROPERTIES:
5953    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5954    :END:
5955 @end example
5957 If a @samp{COLUMNS} property is present in an entry, it defines columns for
5958 the entry itself, and for the entire subtree below it.  Since the
5959 column definition is part of the hierarchical structure of the
5960 document, you can define columns on level 1 that are general enough
5961 for all sublevels, and more specific columns further down, when you
5962 edit a deeper part of the tree.
5964 @node Column attributes
5965 @subsubsection Column attributes
5967 A column definition sets the attributes of a column.  The general
5968 definition looks like this:
5970 @example
5971 %[WIDTH]PROPERTY[(TITLE)][@{SUMMARY-TYPE@}]
5972 @end example
5974 @noindent
5975 Except for the percent sign and the property name, all items are
5976 optional.  The individual parts have the following meaning:
5978 @table @asis
5979 @item @var{WIDTH}
5980 An integer specifying the width of the column in characters.  If
5981 omitted, the width is determined automatically.
5983 @item @var{PROPERTY}
5984 The property that should be edited in this column.  Special
5985 properties representing meta data are allowed here as well (see
5986 @ref{Special Properties}).
5988 @item @var{TITLE}
5989 The header text for the column.  If omitted, the property name is
5990 used.
5992 @item @var{SUMMARY-TYPE}
5993 The summary type.  If specified, the column values for parent
5994 nodes are computed from the children@footnote{If more than one summary type applies to the same property,
5995 the parent values are computed according to the first of them.}.
5997 Supported summary types are:
5999 @multitable {aaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
6000 @item @samp{+}
6001 @tab Sum numbers in this column.
6002 @item @samp{+;%.1f}
6003 @tab Like @samp{+}, but format result with @samp{%.1f}.
6004 @item @samp{$}
6005 @tab Currency, short for @samp{+;%.2f}.
6006 @item @samp{min}
6007 @tab Smallest number in column.
6008 @item @samp{max}
6009 @tab Largest number.
6010 @item @samp{mean}
6011 @tab Arithmetic mean of numbers.
6012 @item @samp{X}
6013 @tab Checkbox status, @samp{[X]} if all children are @samp{[X]}.
6014 @item @samp{X/}
6015 @tab Checkbox status, @samp{[n/m]}.
6016 @item @samp{X%}
6017 @tab Checkbox status, @samp{[n%]}.
6018 @item @samp{:}
6019 @tab Sum times, HH:MM, plain numbers are hours.
6020 @item @samp{:min}
6021 @tab Smallest time value in column.
6022 @item @samp{:max}
6023 @tab Largest time value.
6024 @item @samp{:mean}
6025 @tab Arithmetic mean of time values.
6026 @item @samp{@@min}
6027 @tab Minimum age@footnote{An age is defined as a duration, using effort modifiers
6028 defined in @code{org-effort-durations}, e.g., @samp{3d 1h}.  If any value in the
6029 column is as such, the summary is also an effort duration.} (in days/hours/mins/seconds).
6030 @item @samp{@@max}
6031 @tab Maximum age (in days/hours/mins/seconds).
6032 @item @samp{@@mean}
6033 @tab Arithmetic mean of ages (in days/hours/mins/seconds).
6034 @item @samp{est+}
6035 @tab Add low-high estimates.
6036 @end multitable
6038 @noindent
6039 @vindex org-columns-summary-types
6040 You can also define custom summary types by setting
6041 @code{org-columns-summary-types}.
6042 @end table
6044 The @samp{est+} summary type requires further explanation.  It is used for
6045 combining estimates, expressed as low-high ranges.  For example,
6046 instead of estimating a particular task will take 5 days, you might
6047 estimate it as 5--6 days if you're fairly confident you know how much
6048 work is required, or 1--10 days if you do not really know what needs
6049 to be done.  Both ranges average at 5.5 days, but the first represents
6050 a more predictable delivery.
6052 When combining a set of such estimates, simply adding the lows and
6053 highs produces an unrealistically wide result.  Instead, @samp{est+} adds
6054 the statistical mean and variance of the sub-tasks, generating a final
6055 estimate from the sum.  For example, suppose you had ten tasks, each
6056 of which was estimated at 0.5 to 2 days of work.  Straight addition
6057 produces an estimate of 5 to 20 days, representing what to expect if
6058 everything goes either extremely well or extremely poorly.  In
6059 contrast, @samp{est+} estimates the full job more realistically, at 10--15
6060 days.
6062 Here is an example for a complete columns definition, along with
6063 allowed values@footnote{Please note that the @samp{COLUMNS} definition must be on a single
6064 line; it is wrapped here only because of formatting constraints.}.
6066 @example
6067 :COLUMNS:  %25ITEM %9Approved(Approved?)@{X@} %Owner %11Status \
6068                    %10Time_Estimate@{:@} %CLOCKSUM %CLOCKSUM_T
6069 :Owner_ALL:    Tammy Mark Karl Lisa Don
6070 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
6071 :Approved_ALL: "[ ]" "[X]"
6072 @end example
6074 @noindent
6075 The first column, @samp{%25ITEM}, means the first 25 characters of the item
6076 itself, i.e., of the headline.  You probably always should start the
6077 column definition with the @samp{ITEM} specifier.  The other specifiers
6078 create columns @samp{Owner} with a list of names as allowed values, for
6079 @samp{Status} with four different possible values, and for a checkbox field
6080 @samp{Approved}.  When no width is given after the @samp{%} character, the
6081 column is exactly as wide as it needs to be in order to fully display
6082 all values.  The @samp{Approved} column does have a modified title
6083 (@samp{Approved?}, with a question mark).  Summaries are created for the
6084 @samp{Time_Estimate} column by adding time duration expressions like HH:MM,
6085 and for the @samp{Approved} column, by providing an @samp{[X]} status if all
6086 children have been checked.  The @samp{CLOCKSUM} and @samp{CLOCKSUM_T} columns
6087 are special, they lists the sums of CLOCK intervals in the subtree,
6088 either for all clocks or just for today.
6090 @node Using column view
6091 @subsection Using column view
6095 @anchor{Turning column view on or off}
6096 @subsubheading Turning column view on or off
6098 @table @asis
6099 @item @kbd{C-c C-x C-c} (@code{org-columns})
6100 @kindex C-c C-x C-c
6101 @vindex org-columns
6102 @vindex org-columns-default-format
6103 Turn on column view.  If the cursor is before the first headline
6104 in the file, column view is turned on for the entire file, using
6105 the @samp{#+COLUMNS} definition.  If the cursor is somewhere inside
6106 the outline, this command searches the hierarchy, up from point,
6107 for a @samp{COLUMNS} property that defines a format.  When one is
6108 found, the column view table is established for the tree starting
6109 at the entry that contains the @samp{COLUMNS} property.  If no such
6110 property is found, the format is taken from the @samp{#+COLUMNS} line
6111 or from the variable @code{org-columns-default-format}, and column
6112 view is established for the current entry and its subtree.
6114 @item @kbd{r} or @kbd{g} (@code{org-columns-redo})
6115 @kindex r
6116 @kindex g
6117 @findex org-columns-redo
6118 Recreate the column view, to include recent changes made in the
6119 buffer.
6121 @item @kbd{q} (@code{org-columns-quit})
6122 @kindex q
6123 @findex org-columns-quit
6124 Exit column view.
6125 @end table
6127 @anchor{Editing values}
6128 @subsubheading Editing values
6130 @table @asis
6131 @item @kbd{@key{LEFT}}, @kbd{@key{RIGHT}}, @kbd{@key{UP}}, @kbd{@key{DOWN}}
6132 Move through the column view from field to field.
6134 @item @kbd{1..9,0}
6135 @kindex 1..9,0
6136 Directly select the Nth allowed value, @kbd{0} selects the
6137 10th value.
6139 @item @kbd{n} or @kbd{S-@key{RIGHT}} (@code{org-columns-next-allowed-value})
6140 @itemx @kbd{p} or @kbd{S-@key{LEFT}} (@code{org-columns-previous-allowed-value})
6141 @kindex n
6142 @kindex S-RIGHT
6143 @kindex p
6144 @kindex S-LEFT
6145 @findex org-columns-next-allowed-value
6146 @findex org-columns-previous-allowed-value
6147 Switch to the next/previous allowed value of the field.  For
6148 this, you have to have specified allowed values for a property.
6150 @item @kbd{e} (@code{org-columns-edit-value})
6151 @kindex e
6152 @findex org-columns-edit-value
6153 Edit the property at point.  For the special properties, this
6154 invokes the same interface that you normally use to change that
6155 property.  For example, the tag completion or fast selection
6156 interface pops up when editing a @samp{TAGS} property.
6158 @item @kbd{C-c C-c} (@code{org-columns-set-tags-or-toggle})
6159 @kindex C-c C-c
6160 @findex org-columns-set-tags-or-toggle
6161 When there is a checkbox at point, toggle it.
6163 @item @kbd{v} (@code{org-columns-show-value})
6164 @kindex v
6165 @findex org-columns-show-value
6166 View the full value of this property.  This is useful if the
6167 width of the column is smaller than that of the value.
6169 @item @kbd{a} (@code{org-columns-edit-allowed})
6170 @kindex a
6171 @findex org-columns-edit-allowed
6172 Edit the list of allowed values for this property.  If the list
6173 is found in the hierarchy, the modified values is stored there.
6174 If no list is found, the new value is stored in the first entry
6175 that is part of the current column view.
6176 @end table
6178 @anchor{Modifying column view on-the-fly}
6179 @subsubheading Modifying column view on-the-fly:
6181 @table @asis
6182 @item @kbd{<} (@code{org-columns-narrow})
6183 @itemx @kbd{>} (@code{org-columns-widen})
6184 @kindex <
6185 @kindex >
6186 @findex org-columns-narrow
6187 @findex org-columns-widen
6188 Make the column narrower/wider by one character.
6190 @item @kbd{S-M-@key{RIGHT}} (@code{org-columns-new})
6191 @kindex S-M-RIGHT
6192 @findex org-columns-new
6193 Insert a new column, to the left of the current column.
6195 @item @kbd{S-M-@key{LEFT}} (@code{org-columns-delete})
6196 @kindex S-M-LEFT
6197 @findex org-columns-delete
6198 Delete the current column.
6199 @end table
6201 @node Capturing column view
6202 @subsection Capturing column view
6204 Since column view is just an overlay over a buffer, it cannot be
6205 exported or printed directly.  If you want to capture a column view,
6206 use a @samp{columnview} dynamic block (see @ref{Dynamic Blocks}).  The frame of
6207 this block looks like this:
6209 @cindex @samp{BEGIN columnview}
6210 @example
6211 * The column view
6212 #+BEGIN: columnview :hlines 1 :id "label"
6214 #+END:
6215 @end example
6217 @noindent
6218 This dynamic block has the following parameters:
6220 @table @asis
6221 @item @samp{:id}
6222 This is the most important parameter.  Column view is a feature
6223 that is often localized to a certain (sub)tree, and the capture
6224 block might be at a different location in the file.  To identify
6225 the tree whose view to capture, you can use four values:
6227 @table @asis
6228 @item @samp{local}
6229 Use the tree in which the capture block is located.
6231 @item @samp{global}
6232 Make a global view, including all headings in the file.
6234 @item @samp{file:FILENAME}
6235 Run column view at the top of the @var{FILENAME} file
6237 @item @samp{LABEL}
6238 @cindex @samp{ID}, property
6239 Call column view in the tree that has an @samp{ID} property with
6240 the value @var{LABEL}.  You can use @kbd{M-x org-id-copy} to create a globally unique ID for the
6241 current entry and copy it to the kill-ring.
6242 @end table
6244 @item @samp{:hlines}
6245 When @code{t}, insert an hline after every line.  When a number N,
6246 insert an hline before each headline with level @code{<= N}.
6248 @item @samp{:vlines}
6249 When non-@code{nil}, force column groups to get vertical lines.
6251 @item @samp{:maxlevel}
6252 When set to a number, do not capture entries below this level.
6254 @item @samp{:skip-empty-rows}
6255 When non-@code{nil}, skip rows where the only non-empty specifier of
6256 the column view is @samp{ITEM}.
6258 @item @samp{:indent}
6259 When non-@code{nil}, indent each @samp{ITEM} field according to its level.
6260 @end table
6262 @noindent
6263 The following commands insert or update the dynamic block:
6265 @table @asis
6266 @item @kbd{C-c C-x i} (@code{org-insert-columns-dblock})
6267 @kindex C-c C-x i
6268 @findex org-insert-columns-dblock
6269 Insert a dynamic block capturing a column view.  Prompt for the
6270 scope or ID of the view.
6272 @item @kbd{C-c C-c} @kbd{C-c C-x C-u} (@code{org-dblock-update})
6273 @kindex C-c C-c
6274 @kindex C-c C-x C-u
6275 @findex org-dblock-update
6276 Update dynamic block at point.  The cursor needs to be in the
6277 @samp{#+BEGIN} line of the dynamic block.
6279 @item @kbd{C-u C-c C-x C-u} (@code{org-update-all-dblocks})
6280 @kindex C-u C-c C-x C-u
6281 Update all dynamic blocks (see @ref{Dynamic Blocks}).  This is useful
6282 if you have several clock table blocks, column-capturing blocks
6283 or other dynamic blocks in a buffer.
6284 @end table
6286 You can add formulas to the column view table and you may add plotting
6287 instructions in front of the table---these survive an update of the
6288 block.  If there is a @samp{TBLFM} keyword after the table, the table is
6289 recalculated automatically after an update.
6291 An alternative way to capture and process property values into a table
6292 is provided by Eric Schulte's @samp{org-collector.el} which is
6293 a contributed package@footnote{Contributed packages are not part of Emacs, but are
6294 distributed with the main distribution of Org---visit
6295 @uref{https://orgmode.org}.}.  It provides a general API to collect
6296 properties from entries in a certain scope, and arbitrary Lisp
6297 expressions to process these values before inserting them into a table
6298 or a dynamic block.
6300 @node Dates and Times
6301 @chapter Dates and Times
6303 @cindex dates
6304 @cindex times
6305 @cindex timestamp
6306 @cindex date stamp
6308 To assist project planning, TODO items can be labeled with a date
6309 and/or a time.  The specially formatted string carrying the date and
6310 time information is called a @emph{timestamp} in Org mode.  This may be
6311 a little confusing because timestamp is often used as indicating when
6312 something was created or last changed.  However, in Org mode this term
6313 is used in a much wider sense.
6315 @menu
6316 * Timestamps::                   Assigning a time to a tree entry.
6317 * Creating Timestamps::          Commands to insert timestamps.
6318 * Deadlines and Scheduling::     Planning your work.
6319 * Clocking Work Time::           Tracking how long you spend on a task.
6320 * Effort Estimates::             Planning work effort in advance.
6321 * Timers::                       Notes with a running timer.
6322 @end menu
6324 @node Timestamps
6325 @section Timestamps, Deadlines and Scheduling
6327 @cindex timestamps
6328 @cindex ranges, time
6329 @cindex date stamps
6330 @cindex deadlines
6331 @cindex scheduling
6333 A timestamp is a specification of a date (possibly with a time or
6334 a range of times) in a special format, either @samp{<2003-09-16 Tue>} or
6335 @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
6336 date/time format.  To use an alternative format, see @ref{Custom time format}.  The day name is optional when you type the date yourself.
6337 However, any date inserted or modified by Org adds that day name, for
6338 reading convenience.}.
6339 A timestamp can appear anywhere in the headline or body of an Org tree
6340 entry.  Its presence causes entries to be shown on specific dates in
6341 the agenda (see @ref{Weekly/daily agenda}).  We distinguish:
6343 @table @asis
6344 @item Plain timestamp; Event; Appointment
6345 @cindex timestamp
6346 @cindex appointment
6347 A simple timestamp just assigns a date/time to an item.  This is
6348 just like writing down an appointment or event in a paper agenda.
6349 In the timeline and agenda displays, the headline of an entry
6350 associated with a plain timestamp is shown exactly on that date.
6352 @example
6353 * Meet Peter at the movies
6354   <2006-11-01 Wed 19:15>
6355 * Discussion on climate change
6356   <2006-11-02 Thu 20:00-22:00>
6357 @end example
6359 @item Timestamp with repeater interval
6360 @cindex timestamp, with repeater interval
6361 A timestamp may contain a @emph{repeater interval}, indicating that it
6362 applies not only on the given date, but again and again after
6363 a certain interval of N days (d), weeks (w), months (m), or years
6364 (y).  The following shows up in the agenda every Wednesday:
6366 @example
6367 * Pick up Sam at school
6368   <2007-05-16 Wed 12:30 +1w>
6369 @end example
6371 @item Diary-style sexp entries
6372 @cindex diary style timestamps
6373 @cindex sexp timestamps
6374 For more complex date specifications, Org mode supports using the
6375 special sexp diary entries implemented in the Emacs
6376 calendar/diary package@footnote{When working with the standard diary sexp functions, you need
6377 to be very careful with the order of the arguments.  That order
6378 depends evilly on the variable @code{calendar-date-style}.  For example, to
6379 specify a date December 12, 2005, the call might look like
6380 @samp{(diary-date 12 1 2005)} or @samp{(diary-date 1 12 2005)} or @samp{(diary-date
6381 2005 12 1)}, depending on the settings.  This has been the source of
6382 much confusion.  Org mode users can resort to special versions of
6383 these functions like @code{org-date} or @code{org-anniversary}.  These work just
6384 like the corresponding @code{diary-} functions, but with stable ISO order
6385 of arguments (year, month, day) wherever applicable, independent of
6386 the value of @code{calendar-date-style}.}.  For example, with optional time:
6388 @example
6389 * 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
6390   <%%(org-float t 4 2)>
6391 @end example
6393 @item Time/Date range
6394 @cindex timerange
6395 @cindex date range
6396 Two timestamps connected by @samp{--} denote a range.  The headline is
6397 shown on the first and last day of the range, and on any dates
6398 that are displayed and fall in the range.  Here is an example:
6400 @example
6401 ** Meeting in Amsterdam
6402    <2004-08-23 Mon>--<2004-08-26 Thu>
6403 @end example
6405 @item Inactive timestamp
6406 @cindex timestamp, inactive
6407 @cindex inactive timestamp
6408 Just like a plain timestamp, but with square brackets instead of
6409 angular ones.  These timestamps are inactive in the sense that
6410 they do @emph{not} trigger an entry to show up in the agenda.
6412 @example
6413 * Gillian comes late for the fifth time
6414   [2006-11-01 Wed]
6415 @end example
6416 @end table
6418 @node Creating Timestamps
6419 @section Creating Timestamps
6421 For Org mode to recognize timestamps, they need to be in the specific
6422 format.  All commands listed below produce timestamps in the correct
6423 format.
6425 @table @asis
6426 @item @kbd{C-c .} (@code{org-time-stamp})
6427 @kindex C-c .
6428 @findex org-time-stamp
6429 Prompt for a date and insert a corresponding timestamp.  When the
6430 cursor is at an existing timestamp in the buffer, the command is
6431 used to modify this timestamp instead of inserting a new one.
6432 When this command is used twice in succession, a time range is
6433 inserted.
6435 @kindex C-u C-c .
6436 @vindex org-time-stamp-rounding-minutes
6437 When called with a prefix argument, use the alternative format
6438 which contains date and time.  The default time can be rounded to
6439 multiples of 5 minutes.  See the option
6440 @code{org-time-stamp-rounding-minutes}.
6442 @kindex C-u C-u C-c .
6443 With two prefix arguments, insert an active timestamp with the
6444 current time without prompting.
6446 @item @kbd{C-c !} (@code{org-time-stamp-inactive})
6447 @kindex C-c !
6448 @kindex C-u C-c !
6449 @kindex C-u C-u C-c !
6450 @findex org-time-stamp-inactive
6451 Like @kbd{C-c .}, but insert an inactive timestamp that does
6452 not cause an agenda entry.
6454 @item @kbd{C-c C-c}
6455 @kindex C-c C-c
6456 Normalize timestamp, insert or fix day name if missing or wrong.
6458 @item @kbd{C-c <} (@code{org-date-from-calendar})
6459 @kindex C-c <
6460 @findex org-date-from-calendar
6461 Insert a timestamp corresponding to the cursor date in the
6462 calendar.
6464 @item @kbd{C-c >} (@code{org-goto-calendar})
6465 @kindex C-c >
6466 @findex org-goto-calendar
6467 Access the Emacs calendar for the current date.  If there is
6468 a timestamp in the current line, go to the corresponding date
6469 instead.
6471 @item @kbd{C-c C-o} (@code{org-open-at-point})
6472 @kindex C-c C-o
6473 @findex org-open-at-point
6474 Access the agenda for the date given by the timestamp or -range
6475 at point (see @ref{Weekly/daily agenda}).
6477 @item @kbd{S-@key{LEFT}} (@code{org-timestamp-down-day})
6478 @itemx @kbd{S-@key{RIGHT}} (@code{org-timestamp-up-day})
6479 @kindex S-LEFT
6480 @kindex S-RIGHT
6481 @findex org-timestamp-down-day
6482 @findex org-timestamp-up-day
6483 Change date at cursor by one day.  These key bindings conflict
6484 with shift-selection and related modes (see @ref{Conflicts}).
6486 @item @kbd{S-@key{UP}} (@code{org-timestamp-up})
6487 @itemx @kbd{S-@key{DOWN}} (@code{org-timestamp-down})
6488 @kindex S-UP
6489 @kindex S-DOWN
6490 Change the item under the cursor in a timestamp.  The cursor can
6491 be on a year, month, day, hour or minute.  When the timestamp
6492 contains a time range like @samp{15:30-16:30}, modifying the first
6493 time also shifts the second, shifting the time block with
6494 constant length.  To change the length, modify the second time.
6495 Note that if the cursor is in a headline and not at a timestamp,
6496 these same keys modify the priority of an item.  (see
6497 @ref{Priorities}).  The key bindings also conflict with
6498 shift-selection and related modes (see @ref{Conflicts}).
6500 @item @kbd{C-c C-y} (@code{org-evaluate-time-range})
6501 @kindex C-c C-y
6502 @findex org-evaluate-time-range
6503 @cindex evaluate time range
6504 Evaluate a time range by computing the difference between start
6505 and end.  With a prefix argument, insert result after the time
6506 range (in a table: into the following column).
6507 @end table
6509 @menu
6510 * The date/time prompt::         How Org mode helps you enter dates and times.
6511 * Custom time format::           Making dates look different.
6512 @end menu
6514 @node The date/time prompt
6515 @subsection The date/time prompt
6517 @cindex date, reading in minibuffer
6518 @cindex time, reading in minibuffer
6520 @vindex org-read-date-prefer-future
6521 When Org mode prompts for a date/time, the default is shown in default
6522 date/time format, and the prompt therefore seems to ask for a specific
6523 format.  But it in fact accepts date/time information in a variety of
6524 formats.  Generally, the information should start at the beginning of
6525 the string.  Org mode finds whatever information is in there and
6526 derives anything you have not specified from the @emph{default date and
6527 time}.  The default is usually the current date and time, but when
6528 modifying an existing timestamp, or when entering the second stamp of
6529 a range, it is taken from the stamp in the buffer.  When filling in
6530 information, Org mode assumes that most of the time you want to enter
6531 a date in the future: if you omit the month/year and the given
6532 day/month is @emph{before} today, it assumes that you mean a future
6533 date@footnote{See the variable @code{org-read-date-prefer-future}.  You may set
6534 that variable to the symbol @code{time} to even make a time before now
6535 shift the date to tomorrow.}.  If the date has been automatically shifted into the
6536 future, the time prompt shows this with @samp{(=>F)}.
6538 For example, let's assume that today is @strong{June 13, 2006}.  Here is how
6539 various inputs are interpreted, the items filled in by Org mode are in
6540 @strong{bold}.
6542 @multitable {aaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
6543 @item @samp{3-2-5}
6544 @tab @result{} 2003-02-05
6545 @item @samp{2/5/3}
6546 @tab @result{} 2003-02-05
6547 @item @samp{14}
6548 @tab @result{} @strong{2006}-@strong{06}-14
6549 @item @samp{12}
6550 @tab @result{} @strong{2006}-@strong{07}-12
6551 @item @samp{2/5}
6552 @tab @result{} @strong{2007}-02-05
6553 @item @samp{Fri}
6554 @tab @result{} nearest Friday (default date or later)
6555 @item @samp{sep 15}
6556 @tab @result{} @strong{2006}-09-15
6557 @item @samp{feb 15}
6558 @tab @result{} @strong{2007}-02-15
6559 @item @samp{sep 12 9}
6560 @tab @result{} 2009-09-12
6561 @item @samp{12:45}
6562 @tab @result{} @strong{2006}-@strong{06}-@strong{13} 12:45
6563 @item @samp{22 sept 0:34}
6564 @tab @result{} @strong{2006}-09-22 0:34
6565 @item @samp{w4}
6566 @tab @result{} ISO week for of the current year @strong{2006}
6567 @item @samp{2012 w4 fri}
6568 @tab @result{} Friday of ISO week 4 in 2012
6569 @item @samp{2012-w04-5}
6570 @tab @result{} Same as above
6571 @end multitable
6573 Furthermore you can specify a relative date by giving, as the @emph{first}
6574 thing in the input: a plus/minus sign, a number and a letter---@samp{d},
6575 @samp{w}, @samp{m} or @samp{y}---to indicate change in days, weeks, months, or
6576 years.  With a single plus or minus, the date is always relative to
6577 today.  With a double plus or minus, it is relative to the default
6578 date.  If instead of a single letter, you use the abbreviation of day
6579 name, the date is the Nth such day, e.g.:
6581 @multitable {aaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
6582 @item @samp{+0}
6583 @tab @result{} today
6584 @item @samp{.}
6585 @tab @result{} today
6586 @item @samp{+4d}
6587 @tab @result{} four days from today
6588 @item @samp{+4}
6589 @tab @result{} same as +4d
6590 @item @samp{+2w}
6591 @tab @result{} two weeks from today
6592 @item @samp{++5}
6593 @tab @result{} five days from default date
6594 @item @samp{+2tue}
6595 @tab @result{} second Tuesday from now
6596 @end multitable
6598 @vindex parse-time-months
6599 @vindex parse-time-weekdays
6600 The function understands English month and weekday abbreviations.  If
6601 you want to use un-abbreviated names and/or other languages, configure
6602 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
6604 @vindex org-read-date-force-compatible-dates
6605 Not all dates can be represented in a given Emacs implementation.  By
6606 default Org mode forces dates into the compatibility range 1970--2037
6607 which works on all Emacs implementations.  If you want to use dates
6608 outside of this range, read the docstring of the variable
6609 @code{org-read-date-force-compatible-dates}.
6611 You can specify a time range by giving start and end times or by
6612 giving a start time and a duration (in HH:MM format).  Use one or two
6613 dash(es) as the separator in the former case and use @samp{+} as the
6614 separator in the latter case, e.g.:
6616 @multitable {aaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaa}
6617 @item @samp{11am-1:15pm}
6618 @tab @result{} 11:00-13:15
6619 @item @samp{11am--1:15pm}
6620 @tab @result{} same as above
6621 @item @samp{11am+2:15}
6622 @tab @result{} same as above
6623 @end multitable
6625 @cindex calendar, for selecting date
6626 @vindex org-popup-calendar-for-date-prompt
6627 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If you do not need/want the calendar, configure the variable
6628 @code{org-popup-calendar-for-date-prompt}.}.
6629 When you exit the date prompt, either by clicking on a date in the
6630 calendar, or by pressing @kbd{@key{RET}}, the date selected in the
6631 calendar is combined with the information entered at the prompt.  You
6632 can control the calendar fully from the minibuffer:
6634 @kindex <
6635 @kindex >
6636 @kindex M-v
6637 @kindex C-v
6638 @kindex mouse-1
6639 @kindex S-RIGHT
6640 @kindex S-LEFT
6641 @kindex S-DOWN
6642 @kindex S-UP
6643 @kindex M-S-RIGHT
6644 @kindex M-S-LEFT
6645 @kindex RET
6646 @multitable @columnfractions 0.25 0.55
6647 @item @kbd{@key{RET}}
6648 @tab Choose date at cursor in calendar.
6649 @item @kbd{mouse-1}
6650 @tab Select date by clicking on it.
6651 @item @kbd{S-@key{RIGHT}}
6652 @tab One day forward.
6653 @item @kbd{S-@key{LEFT}}
6654 @tab One day backward.
6655 @item @kbd{S-@key{DOWN}}
6656 @tab One week forward.
6657 @item @kbd{S-@key{UP}}
6658 @tab One week backward.
6659 @item @kbd{M-S-@key{RIGHT}}
6660 @tab One month forward.
6661 @item @kbd{M-S-@key{LEFT}}
6662 @tab One month backward.
6663 @item @kbd{>}
6664 @tab Scroll calendar forward by one month.
6665 @item @kbd{<}
6666 @tab Scroll calendar backward by one month.
6667 @item @kbd{M-v}
6668 @tab Scroll calendar forward by 3 months.
6669 @item @kbd{C-v}
6670 @tab Scroll calendar backward by 3 months.
6671 @end multitable
6673 @vindex org-read-date-display-live
6674 The actions of the date/time prompt may seem complex, but I assure you
6675 they will grow on you, and you will start getting annoyed by pretty
6676 much any other way of entering a date/time out there.  To help you
6677 understand what is going on, the current interpretation of your input
6678 is displayed live in the minibuffer@footnote{If you find this distracting, turn off the display with
6679 @code{org-read-date-display-live}.}.
6681 @node Custom time format
6682 @subsection Custom time format
6684 @cindex custom date/time format
6685 @cindex time format, custom
6686 @cindex date format, custom
6688 @vindex org-display-custom-times
6689 @vindex org-time-stamp-custom-formats
6690 Org mode uses the standard ISO notation for dates and times as it is
6691 defined in ISO 8601.  If you cannot get used to this and require
6692 another representation of date and time to keep you happy, you can get
6693 it by customizing the variables @code{org-display-custom-times} and
6694 @code{org-time-stamp-custom-formats}.
6696 @table @asis
6697 @item @kbd{C-c C-x C-t} (@code{org-toggle-time-stamp-overlays})
6698 @kindex C-c C-x C-t
6699 @findex org-toggle-time-stamp-overlays
6700 Toggle the display of custom formats for dates and times.
6701 @end table
6703 @noindent
6704 Org mode needs the default format for scanning, so the custom
6705 date/time format does not @emph{replace} the default format.  Instead, it
6706 is put @emph{over} the default format using text properties.  This has the
6707 following consequences:
6709 @itemize
6710 @item
6711 You cannot place the cursor onto a timestamp anymore, only before or
6712 after.
6714 @item
6715 The @kbd{S-@key{UP}} and @kbd{S-@key{DOWN}} keys can no longer be used
6716 to adjust each component of a timestamp.  If the cursor is at the
6717 beginning of the stamp, @kbd{S-@key{UP}} and @kbd{S-@key{DOWN}} change
6718 the stamp by one day, just like @kbd{S-@key{LEFT}}
6719 @kbd{S-@key{RIGHT}}.  At the end of the stamp, change the time by one
6720 minute.
6722 @item
6723 If the timestamp contains a range of clock times or a repeater,
6724 these are not overlaid, but remain in the buffer as they were.
6726 @item
6727 When you delete a timestamp character-by-character, it only
6728 disappears from the buffer after @emph{all} (invisible) characters
6729 belonging to the ISO timestamp have been removed.
6731 @item
6732 If the custom timestamp format is longer than the default and you
6733 are using dates in tables, table alignment will be messed up.  If
6734 the custom format is shorter, things do work as expected.
6735 @end itemize
6737 @node Deadlines and Scheduling
6738 @section Deadlines and Scheduling
6740 A timestamp may be preceded by special keywords to facilitate
6741 planning.  Both the timestamp and the keyword have to be positioned
6742 immediately after the task they refer to.
6744 @table @asis
6745 @item @samp{DEADLINE}
6746 @cindex @samp{DEADLINE}
6747 Meaning: the task (most likely a TODO item, though not
6748 necessarily) is supposed to be finished on that date.
6750 @vindex org-deadline-warning-days
6751 On the deadline date, the task is listed in the agenda.  In
6752 addition, the agenda for @emph{today} carries a warning about the
6753 approaching or missed deadline, starting
6754 @code{org-deadline-warning-days} before the due date, and continuing
6755 until the entry is marked DONE.  An example:
6757 @example
6758 *** TODO write article about the Earth for the Guide
6759     DEADLINE: <2004-02-29 Sun>
6760     The editor in charge is [[bbdb:Ford Prefect]]
6761 @end example
6763 @vindex org-agenda-skip-deadline-prewarning-if-scheduled
6764 You can specify a different lead time for warnings for a specific
6765 deadlines using the following syntax.  Here is an example with
6766 a warning period of 5 days @samp{DEADLINE: <2004-02-29 Sun -5d>}.
6767 This warning is deactivated if the task gets scheduled and you
6768 set @code{org-agenda-skip-deadline-prewarning-if-scheduled} to @code{t}.
6770 @item @samp{SCHEDULED}
6771 @cindex @samp{SCHEDULED}
6772 Meaning: you are planning to start working on that task on the
6773 given date.
6775 @vindex org-agenda-skip-scheduled-if-done
6776 The headline is listed under the given date@footnote{It will still be listed on that date after it has been marked
6777 DONE.  If you do not like this, set the variable
6778 @code{org-agenda-skip-scheduled-if-done}.}.  In addition,
6779 a reminder that the scheduled date has passed is present in the
6780 compilation for @emph{today}, until the entry is marked DONE, i.e.,
6781 the task is automatically forwarded until completed.
6783 @example
6784 *** TODO Call Trillian for a date on New Years Eve.
6785     SCHEDULED: <2004-12-25 Sat>
6786 @end example
6788 @vindex org-scheduled-delay-days
6789 @vindex org-agenda-skip-scheduled-delay-if-deadline
6790 If you want to @emph{delay} the display of this task in the agenda,
6791 use @samp{SCHEDULED: <2004-12-25 Sat -2d>}: the task is still
6792 scheduled on the 25th but will appear two days later.  In case
6793 the task contains a repeater, the delay is considered to affect
6794 all occurrences; if you want the delay to only affect the first
6795 scheduled occurrence of the task, use @samp{--2d} instead.  See
6796 @code{org-scheduled-delay-days} and
6797 @code{org-agenda-skip-scheduled-delay-if-deadline} for details on how
6798 to control this globally or per agenda.
6800 @noindent
6801 @strong{Important:} Scheduling an item in Org mode should @emph{not} be
6802 understood in the same way that we understand @emph{scheduling
6803 a meeting}.  Setting a date for a meeting is just a simple
6804 appointment, you should mark this entry with a simple plain
6805 timestamp, to get this item shown on the date where it applies.
6806 This is a frequent misunderstanding by Org users.  In Org mode,
6807 @emph{scheduling} means setting a date when you want to start working
6808 on an action item.
6809 @end table
6811 You may use timestamps with repeaters in scheduling and deadline
6812 entries.  Org mode issues early and late warnings based on the
6813 assumption that the timestamp represents the @emph{nearest instance} of the
6814 repeater.  However, the use of diary S-exp entries like
6816 @example
6817 <%%(org-float t 42)>
6818 @end example
6820 @noindent
6821 in scheduling and deadline timestamps is limited.  Org mode does not
6822 know enough about the internals of each S-exp function to issue early
6823 and late warnings.  However, it shows the item on each day where the
6824 S-exp entry matches.
6826 @menu
6827 * Inserting deadline/schedule::  Planning items.
6828 * Repeated tasks::               Items that show up again and again.
6829 @end menu
6831 @node Inserting deadline/schedule
6832 @subsection Inserting deadlines or schedules
6834 The following commands allow you to quickly insert a deadline or to
6835 schedule an item:@footnote{The @samp{SCHEDULED} and @samp{DEADLINE} dates are inserted on the line
6836 right below the headline.  Do not put any text between this line and
6837 the headline.}
6839 @table @asis
6840 @item @kbd{C-c C-d} (@code{org-deadline})
6841 @kindex C-c C-d
6842 @findex org-deadline
6843 @vindex org-log-redeadline
6844 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion
6845 happens in the line directly following the headline.  Remove any
6846 @samp{CLOSED} timestamp .  When called with a prefix argument, also
6847 remove any existing deadline from the entry.  Depending on the
6848 variable @code{org-log-redeadline}, take a note when changing an
6849 existing deadline@footnote{Note the corresponding @samp{STARTUP} options @samp{logredeadline},
6850 @samp{lognoteredeadline}, and @samp{nologredeadline}.}.
6852 @item @kbd{C-c C-s} (@code{org-schedule})
6853 @kindex C-c C-s
6854 @findex org-schedule
6855 @vindex org-log-reschedule
6856 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion
6857 happens in the line directly following the headline.  Remove any
6858 @samp{CLOSED} timestamp.  When called with a prefix argument, also
6859 remove the scheduling date from the entry.  Depending on the
6860 variable @code{org-log-reschedule}, take a note when changing an
6861 existing scheduling time@footnote{Note the corresponding @samp{STARTUP} options @samp{logreschedule},
6862 @samp{lognotereschedule}, and @samp{nologreschedule}.}.
6864 @item @kbd{C-c C-x C-k} (@code{org-mark-entry-for-agenda-action})
6865 @kindex C-c C-x C-k
6866 @kindex k a
6867 @kindex k s
6868 @findex org-mark-entry-for-agenda-action
6869 Mark the current entry for agenda action.  After you have marked
6870 the entry like this, you can open the agenda or the calendar to
6871 find an appropriate date.  With the cursor on the selected date,
6872 press @kbd{k s} or @kbd{k d} to schedule the marked
6873 item.
6875 @item @kbd{C-c / d} (@code{org-check-deadlines})
6876 @kindex C-c / d
6877 @findex org-check-deadlines
6878 @cindex sparse tree, for deadlines
6879 @vindex org-deadline-warning-days
6880 Create a sparse tree with all deadlines that are either past-due,
6881 or which will become due within @code{org-deadline-warning-days}.
6882 With @kbd{C-u} prefix, show all deadlines in the file.  With
6883 a numeric prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows all deadlines due tomorrow.
6885 @item @kbd{C-c / b}, @code{org-check-before-date}
6886 @kindex C-c / b
6887 @findex org-check-before-date
6888 Sparse tree for deadlines and scheduled items before a given
6889 date.
6891 @item @kbd{C-c / a}, @code{org-check-after-date}
6892 @kindex C-c / a
6893 @findex org-check-after-date
6894 Sparse tree for deadlines and scheduled items after a given date.
6895 @end table
6897 Note that @code{org-schedule} and @code{org-deadline} supports setting the date
6898 by indicating a relative time e.g., @samp{+1d} sets the date to the next
6899 day after today, and @samp{--1w} sets the date to the previous week before
6900 any current timestamp.
6902 @node Repeated tasks
6903 @subsection Repeated tasks
6905 @cindex tasks, repeated
6906 @cindex repeated tasks
6908 Some tasks need to be repeated again and again.  Org mode helps to
6909 organize such tasks using a so-called repeater in a @samp{DEADLINE},
6910 @samp{SCHEDULED}, or plain timestamp.  In the following example:
6912 @example
6913 ** TODO Pay the rent
6914    DEADLINE: <2005-10-01 Sat +1m>
6915 @end example
6917 noindent
6918 the @samp{+1m} is a repeater; the intended interpretation is that the task
6919 has a deadline on @samp{<2005-10-01>} and repeats itself every (one) month
6920 starting from that time.  You can use yearly, monthly, weekly, daily
6921 and hourly repeat cookies by using the @code{y/w/m/d/h} letters.  If you
6922 need both a repeater and a special warning period in a deadline entry,
6923 the repeater should come first and the warning period last: @samp{DEADLINE:
6924 <2005-10-01 Sat +1m -3d>}.
6926 @vindex org-todo-repeat-to-state
6927 Deadlines and scheduled items produce entries in the agenda when they
6928 are over-due, so it is important to be able to mark such an entry as
6929 completed once you have done so.  When you mark a @samp{DEADLINE} or
6930 a @samp{SCHEDULED} with the TODO keyword @samp{DONE}, it no longer produces
6931 entries in the agenda.  The problem with this is, however, is that
6932 then also the @emph{next} instance of the repeated entry will not be
6933 active.  Org mode deals with this in the following way: when you try
6934 to mark such an entry DONE, using @kbd{C-c C-t}, it shifts the
6935 base date of the repeating timestamp by the repeater interval, and
6936 immediately sets the entry state back to TODO@footnote{In fact, the target state is taken from, in this sequence, the
6937 @samp{REPEAT_TO_STATE} property, the variable @code{org-todo-repeat-to-state} if
6938 it is a string, the previous TODO state if @code{org-todo-repeat-to-state}
6939 is @code{t}, or the first state of the TODO state sequence.}.  In the example
6940 above, setting the state to DONE would actually switch the date like
6941 this:
6943 @example
6944 ** TODO Pay the rent
6945    DEADLINE: <2005-11-01 Tue +1m>
6946 @end example
6948 To mark a task with a repeater as DONE, use @kbd{C-- 1 C-c C-t},
6949 i.e., @code{org-todo} with a numeric prefix argument of @samp{-1}.
6951 @vindex org-log-repeat
6952 A timestamp@footnote{You can change this using the option @code{org-log-repeat}, or the
6953 @samp{STARTUP} options @samp{logrepeat}, @samp{lognoterepeat}, and @samp{nologrepeat}.
6954 With @samp{lognoterepeat}, you will also be prompted for a note.} is added under the deadline, to keep a record that
6955 you actually acted on the previous instance of this deadline.
6957 As a consequence of shifting the base date, this entry is no longer
6958 visible in the agenda when checking past dates, but all future
6959 instances will be visible.
6961 With the @samp{+1m} cookie, the date shift is always exactly one month.  So
6962 if you have not paid the rent for three months, marking this entry
6963 DONE still keeps it as an overdue deadline.  Depending on the task,
6964 this may not be the best way to handle it.  For example, if you forgot
6965 to call your father for 3 weeks, it does not make sense to call him
6966 3 times in a single day to make up for it.  Finally, there are tasks
6967 like changing batteries which should always repeat a certain time
6968 @emph{after} the last time you did it.  For these tasks, Org mode has
6969 special repeaters @samp{++} and @samp{.+}.  For example:
6971 @example
6972 ** TODO Call Father
6973    DEADLINE: <2008-02-10 Sun ++1w>
6974    Marking this DONE shifts the date by at least one week, but also
6975    by as many weeks as it takes to get this date into the future.
6976    However, it stays on a Sunday, even if you called and marked it
6977    done on Saturday.
6979 ** TODO Empty kitchen trash
6980    DEADLINE: <2008-02-08 Fri 20:00 ++1d>
6981    Marking this DONE shifts the date by at least one day, and also
6982    by as many days as it takes to get the timestamp into the future.
6983    Since there is a time in the timestamp, the next deadline in the
6984    future will be on today's date if you complete the task before
6985    20:00.
6987 ** TODO Check the batteries in the smoke detectors
6988    DEADLINE: <2005-11-01 Tue .+1m>
6989    Marking this DONE will shift the date to one month after today.
6990 @end example
6992 @vindex org-agenda-skip-scheduled-if-deadline-is-shown
6993 You may have both scheduling and deadline information for a specific
6994 task.  If the repeater is set for the scheduling information only, you
6995 probably want the repeater to be ignored after the deadline.  If so,
6996 set the variable @code{org-agenda-skip-scheduled-if-deadline-is-shown} to
6997 @code{repeated-after-deadline}.  However, any scheduling information
6998 without a repeater is no longer relevant once the task is done, and
6999 thus, removed upon repeating the task.  If you want both scheduling
7000 and deadline information to repeat after the same interval, set the
7001 same repeater for both timestamps.
7003 An alternative to using a repeater is to create a number of copies of
7004 a task subtree, with dates shifted in each copy.  The command
7005 @kbd{C-c C-x c} was created for this purpose; it is described in
7006 @ref{Structure Editing}.
7008 @node Clocking Work Time
7009 @section Clocking Work Time
7011 @cindex clocking time
7012 @cindex time clocking
7014 Org mode allows you to clock the time you spend on specific tasks in
7015 a project.  When you start working on an item, you can start the
7016 clock.  When you stop working on that task, or when you mark the task
7017 done, the clock is stopped and the corresponding time interval is
7018 recorded.  It also computes the total time spent on each
7019 subtree@footnote{Clocking only works if all headings are indented with less
7020 than 30 stars.  This is a hard-coded limitation of @code{lmax} in
7021 @code{org-clock-sum}.} of a project.  And it remembers a history or tasks
7022 recently clocked, to that you can jump quickly between a number of
7023 tasks absorbing your time.
7025 To save the clock history across Emacs sessions, use:
7027 @lisp
7028 (setq org-clock-persist 'history)
7029 (org-clock-persistence-insinuate)
7030 @end lisp
7032 @vindex org-clock-persist
7033 When you clock into a new task after resuming Emacs, the incomplete
7034 clock@footnote{To resume the clock under the assumption that you have worked
7035 on this task while outside Emacs, use @code{(setq org-clock-persist t)}.} is retrieved (see @ref{Resolving idle time (1)}) and you are
7036 prompted about what to do with it.
7038 @menu
7039 * Clocking commands::            Starting and stopping a clock.
7040 * The clock table::              Detailed reports.
7041 * Resolving idle time::          Resolving time when you've been idle.
7042 @end menu
7044 @node Clocking commands
7045 @subsection Clocking commands
7047 @table @asis
7048 @item @kbd{C-c C-x C-i} (@code{org-clock-in})
7049 @kindex C-c C-x C-i
7050 @findex org-clock-in
7051 @vindex org-clock-into-drawer
7052 @vindex org-clock-continuously
7053 @cindex @samp{LOG_INTO_DRAWER}, property
7054 Start the clock on the current item (clock-in).  This inserts the
7055 CLOCK keyword together with a timestamp.  If this is not the
7056 first clocking of this item, the multiple CLOCK lines are wrapped
7057 into a @samp{LOGBOOK} drawer (see also the variable
7058 @code{org-clock-into-drawer}).  You can also overrule the setting of
7059 this variable for a subtree by setting a @samp{CLOCK_INTO_DRAWER} or
7060 @samp{LOG_INTO_DRAWER} property.  When called with a @kbd{C-u}
7061 prefix argument, select the task from a list of recently clocked
7062 tasks.  With two @kbd{C-u C-u} prefixes, clock into the task
7063 at point and mark it as the default task; the default task is
7064 always be available with letter @kbd{d} when selecting
7065 a clocking task.  With three @kbd{C-u C-u C-u} prefixes,
7066 force continuous clocking by starting the clock when the last
7067 clock stopped.
7069 @cindex @samp{CLOCK_MODELINE_TOTAL}, property
7070 @cindex @samp{LAST_REPEAT}, property
7071 @vindex org-clock-mode-line-total
7072 @vindex org-clock-in-prepare-hook
7073 While the clock is running, Org shows the current clocking time
7074 in the mode line, along with the title of the task.  The clock
7075 time shown is all time ever clocked for this task and its
7076 children.  If the task has an effort estimate (see @ref{Effort Estimates}), the mode line displays the current clocking time
7077 against it@footnote{To add an effort estimate ``on the fly'', hook a function doing
7078 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
7079 task@footnote{The last reset of the task is recorded by the @samp{LAST_REPEAT}
7080 property.}.  You can exercise more control over show time with
7081 the @samp{CLOCK_MODELINE_TOTAL} property.  It may have the values
7082 @samp{current} to show only the current clocking instance, @samp{today} to
7083 show all time clocked on this tasks today---see also the
7084 variable @code{org-extend-today-until}, @code{all} to include all time, or
7085 @code{auto} which is the default@footnote{See also the variable @code{org-clock-mode-line-total}.}.  Clicking with
7086 @kbd{mouse-1} onto the mode line entry pops up a menu with
7087 clocking options.
7089 @item @kbd{C-c C-x C-o} (@code{org-clock-out})
7090 @kindex C-c C-x C-o
7091 @findex org-clock-out
7092 @vindex org-log-note-clock-out
7093 Stop the clock (clock-out).  This inserts another timestamp at
7094 the same location where the clock was last started.  It also
7095 directly computes the resulting time in inserts it after the time
7096 range as @samp{=>HH:MM}.  See the variable @code{org-log-note-clock-out}
7097 for the possibility to record an additional note together with
7098 the clock-out timestamp@footnote{The corresponding in-buffer setting is: @samp{#+STARTUP:
7099 lognoteclock-out}.}.
7101 @item @kbd{C-c C-x C-x} (@code{org-clock-in-last})
7102 @kindex C-c C-x C-x
7103 @findex org-clock-in-last
7104 @vindex org-clock-continuously
7105 Re-clock the last clocked task.  With one @kbd{C-u} prefix
7106 argument, select the task from the clock history.  With two
7107 @kbd{C-u} prefixes, force continuous clocking by starting
7108 the clock when the last clock stopped.
7110 @item @kbd{C-c C-x C-e} (@code{org-clock-modify-effort-estimate})
7111 @kindex C-c C-x C-e
7112 @findex org-clock-modify-effort-estimate
7113 Update the effort estimate for the current clock task.
7115 @item @kbd{C-c C-c} or @kbd{C-c C-y} (@code{org-evaluate-time-range})
7116 @kindex C-c C-c
7117 @kindex C-c C-y
7118 @findex org-evaluate-time-range
7119 Recompute the time interval after changing one of the timestamps.
7120 This is only necessary if you edit the timestamps directly.  If
7121 you change them with @kbd{S-<cursor>} keys, the update is
7122 automatic.
7124 @item @kbd{C-S-@key{UP}} (@code{org-clock-timestamps-up})
7125 @itemx @kbd{C-S-@key{DOWN}} (@code{org-clock-timestamps-down})
7126 @kindex C-S-UP
7127 @findex org-clock-timestamps-up
7128 @kindex C-S-DOWN
7129 @findex org-clock-timestamps-down
7130 On CLOCK log lines, increase/decrease both timestamps so that the
7131 clock duration keeps the same value.
7133 @item @kbd{S-M-@key{UP}} (@code{org-timestamp-up})
7134 @itemx @kbd{S-M-@key{DOWN}} (@code{org-timestamp-down})
7135 @kindex S-M-UP
7136 @findex org-clock-timestamp-up
7137 @kindex S-M-DOWN
7138 @findex org-clock-timestamp-down
7139 On @samp{CLOCK} log lines, increase/decrease the timestamp at point
7140 and the one of the previous, or the next, clock timestamp by the
7141 same duration.  For example, if you hit @kbd{S-M-@key{UP}} to
7142 increase a clocked-out timestamp by five minutes, then the
7143 clocked-in timestamp of the next clock is increased by five
7144 minutes.
7146 @item @kbd{C-c C-t} (@code{org-todo})
7147 @kindex C-c C-t
7148 @findex org-todo
7149 Changing the TODO state of an item to DONE automatically stops
7150 the clock if it is running in this same item.
7152 @item @kbd{C-c C-x C-q} (@code{org-clock-cancel})
7153 @kindex C-c C-x C-q
7154 @findex org-clock-cancel
7155 Cancel the current clock.  This is useful if a clock was started
7156 by mistake, or if you ended up working on something else.
7158 @item @kbd{C-c C-x C-j} (@code{org-clock-goto})
7159 @kindex C-c C-x C-j
7160 @findex or-clock-goto
7161 Jump to the headline of the currently clocked in task.  With
7162 a @kbd{C-u} prefix argument, select the target task from
7163 a list of recently clocked tasks.
7165 @item @kbd{C-c C-x C-d} (@code{org-clock-display})
7166 @kindex C-c C-x C-d
7167 @findex org-clock-display
7168 @vindex org-remove-highlights-with-change
7169 Display time summaries for each subtree in the current buffer.
7170 This puts overlays at the end of each headline, showing the total
7171 time recorded under that heading, including the time of any
7172 subheadings.  You can use visibility cycling to study the tree,
7173 but the overlays disappear when you change the buffer (see
7174 variable @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
7175 @end table
7177 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
7178 a day.
7180 @strong{Important:} note that both @code{org-clock-out} and @code{org-clock-in-last}
7181 can have a global keybinding and do not modify the window disposition.
7183 @node The clock table
7184 @subsection The clock table
7186 @cindex clocktable, dynamic block
7187 @cindex report, of clocked time
7189 Org mode can produce quite complex reports based on the time clocking
7190 information.  Such a report is called a @emph{clock table}, because it is
7191 formatted as one or several Org tables.
7193 @table @asis
7194 @item @kbd{C-c C-x C-r} (@code{org-clock-report})
7195 @kindex C-c C-x C-r
7196 @findex org-clock-report
7197 Insert a dynamic block (see @ref{Dynamic Blocks}) containing a clock
7198 report as an Org mode table into the current file.  When the
7199 cursor is at an existing clock table, just update it.  When
7200 called with a prefix argument, jump to the first clock report in
7201 the current document and update it.  The clock table includes
7202 archived trees.
7204 @item @kbd{C-c C-c} or @kbd{C-c C-x C-u} (@code{org-dblock-update})
7205 @kindex C-c C-c
7206 @kindex C-c C-x C-u
7207 @findex org-dblock-update
7208 Update dynamic block at point.  The cursor needs to be in the
7209 @samp{BEGIN} line of the dynamic block.
7211 @item @kbd{C-u C-c C-x C-u}
7212 @kindex C-u C-c C-x C-u
7213 Update all dynamic blocks (see @ref{Dynamic Blocks}).  This is useful
7214 if you have several clock table blocks in a buffer.
7216 @item @kbd{S-@key{LEFT}}
7217 @itemx @kbd{S-@key{RIGHT}} (@code{org-clocktable-try-shift})
7218 @kindex S-LEFT
7219 @kindex S-RIGHT
7220 @findex org-clocktable-try-shift
7221 Shift the current @samp{:block} interval and update the table.  The
7222 cursor needs to be in the @samp{#+BEGIN: clocktable} line for this
7223 command.  If @samp{:block} is @samp{today}, it is shifted to @samp{today-1},
7224 etc.
7225 @end table
7227 Here is an example of the frame for a clock table as it is inserted
7228 into the buffer with the @kbd{C-c C-x C-r} command:
7230 @cindex @samp{BEGIN clocktable}
7231 @example
7232 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
7233 #+END: clocktable
7234 @end example
7236 @noindent
7237 @vindex org-clocktable-defaults
7238 The @samp{#+BEGIN} line and specify a number of options to define the
7239 scope, structure, and formatting of the report.  Defaults for all
7240 these options can be configured in the variable
7241 @code{org-clocktable-defaults}.
7243 @noindent
7244 First there are options that determine which clock entries are to
7245 be selected:
7247 @table @asis
7248 @item :maxlevel
7249 Maximum level depth to which times are listed in the table.
7250 Clocks at deeper levels are summed into the upper level.
7252 @item :scope
7253 The scope to consider.  This can be any of the following:
7255 @multitable {aaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
7256 @item @code{nil}
7257 @tab the current buffer or narrowed region
7258 @item @code{file}
7259 @tab the full current buffer
7260 @item @code{subtree}
7261 @tab the subtree where the clocktable is located
7262 @item @code{treeN}
7263 @tab the surrounding level N tree, for example @samp{tree3}
7264 @item @code{tree}
7265 @tab the surrounding level 1 tree
7266 @item @code{agenda}
7267 @tab all agenda files
7268 @item @samp{("file" ...)}
7269 @tab scan these files
7270 @item @samp{FUNCTION}
7271 @tab scan files returned by calling FUNCTION with no argument
7272 @item @code{file-with-archives}
7273 @tab current file and its archives
7274 @item @code{agenda-with-archives}
7275 @tab all agenda files, including archives
7276 @end multitable
7278 @item :block
7279 The time block to consider.  This block is specified either
7280 absolutely, or relative to the current time and may be any of
7281 these formats:
7283 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaa}
7284 @item @samp{2007-12-31}
7285 @tab New year eve 2007
7286 @item @samp{2007-12}
7287 @tab December 2007
7288 @item @samp{2007-W50}
7289 @tab ISO-week 50 in 2007
7290 @item @samp{2007-Q2}
7291 @tab 2nd quarter in 2007
7292 @item @samp{2007}
7293 @tab the year 2007
7294 @item @code{today}, @code{yesterday}, @code{today-N}
7295 @tab a relative day
7296 @item @code{thisweek}, @code{lastweek}, @code{thisweek-N}
7297 @tab a relative week
7298 @item @code{thismonth}, @code{lastmonth}, @code{thismonth-N}
7299 @tab a relative month
7300 @item @code{thisyear}, @code{lastyear}, @code{thisyear-N}
7301 @tab a relative year
7302 @item @code{untilnow}
7303 @tab all clocked time ever
7304 @end multitable
7306 @vindex org-clock-display-default-range
7307 When this option is not set, Org falls back to the value in
7308 @code{org-clock-display-default-range}, which defaults to the current
7309 year.
7311 Use @kbd{S-@key{LEFT}} or @kbd{S-@key{RIGHT}} to shift the time
7312 interval.
7314 @item :tstart
7315 A time string specifying when to start considering times.
7316 Relative times like @samp{"<-2w>"} can also be used.  See @ref{Matching tags and properties} for relative time syntax.
7318 @item :tend 
7319 A time string specifying when to stop considering times.
7320 Relative times like @samp{"<now>"} can also be used.  See @ref{Matching tags and properties} for relative time syntax.
7322 @item wstart
7323 The starting day of the week.  The default is 1 for Monday.
7325 @item mstart
7326 The starting day of the month.  The default is 1 for the first.
7328 @item :step
7329 Set to @code{week} or @code{day} to split the table into chunks.  To use
7330 this, @code{:block} or @code{:tstart}, @code{:tend} are needed.
7332 @item :stepskip0
7333 Do not show steps that have zero time.
7335 @item :fileskip0
7336 Do not show table sections from files which did not contribute.
7338 @item :tags
7339 A tags match to select entries that should contribute.  See
7340 @ref{Matching tags and properties} for the match syntax.
7341 @end table
7343 @findex org-clocktable-write-default
7344 Then there are options that determine the formatting of the table.
7345 There options are interpreted by the function
7346 @code{org-clocktable-write-default}, but you can specify your own function
7347 using the @samp{:formatter} parameter.
7349 @table @asis
7350 @item :emphasize
7351 When @code{t}, emphasize level one and level two items.
7353 @item :lang
7354 Language@footnote{Language terms can be set through the variable
7355 @code{org-clock-clocktable-language-setup}.} to use for descriptive cells like ``Task''.
7357 @item :link
7358 Link the item headlines in the table to their origins.
7360 @item :narrow
7361 An integer to limit the width of the headline column in the Org
7362 table.  If you write it like @samp{50!}, then the headline is also
7363 shortened in export.
7365 @item :indent
7366 Indent each headline field according to its level.
7368 @item :tcolumns
7369 Number of columns to be used for times.  If this is smaller than
7370 @samp{:maxlevel}, lower levels are lumped into one column.
7372 @item :level
7373 Should a level number column be included?
7375 @item :sort
7376 A cons cell containing the column to sort and a sorting type.
7377 E.g., @samp{:sort (1 . ?a)} sorts the first column alphabetically.
7379 @item :compact
7380 Abbreviation for @samp{:level nil :indent t :narrow 40! :tcolumns 1}.
7381 All are overwritten except if there is an explicit @samp{:narrow}.
7383 @item :timestamp
7384 A timestamp for the entry, when available.  Look for SCHEDULED,
7385 DEADLINE, TIMESTAMP and TIMESTAMP_IA special properties (see
7386 @ref{Special Properties}), in this order.
7388 @item :properties
7389 List of properties shown in the table.  Each property gets its
7390 own column.
7392 @item :inherit-props
7393 When this flag is non-@code{nil}, the values for @samp{:properties} are
7394 inherited.
7396 @item :formula
7397 Content of a @samp{TBLFM} keyword to be added and evaluated.  As
7398 a special case, @samp{:formula %} adds a column with % time.  If you
7399 do not specify a formula here, any existing formula below the
7400 clock table survives updates and is evaluated.
7402 @item :formatter
7403 A function to format clock data and insert it into the buffer.
7404 @end table
7406 To get a clock summary of the current level 1 tree, for the current
7407 day, you could write:
7409 @example
7410 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
7411 #+END: clocktable
7412 @end example
7414 @noindent
7415 To use a specific time range you could write@footnote{Note that all parameters must be specified in a single
7416 line---the line is broken here only to fit it into the manual.}
7418 @example
7419 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
7420                     :tend "<2006-08-10 Thu 12:00>"
7421 #+END: clocktable
7422 @end example
7424 A range starting a week ago and ending right now could be written as
7426 @example
7427 #+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
7428 #+END: clocktable
7429 @end example
7431 A summary of the current subtree with % times would be:
7433 @example
7434 #+BEGIN: clocktable :scope subtree :link t :formula %
7435 #+END: clocktable
7436 @end example
7438 A horizontally compact representation of everything clocked during
7439 last week would be:
7441 @example
7442 #+BEGIN: clocktable :scope agenda :block lastweek :compact t
7443 #+END: clocktable
7444 @end example
7446 @node Resolving idle time
7447 @subsection Resolving idle time and continuous clocking
7451 @anchor{Resolving idle time (1)}
7452 @subsubheading Resolving idle time
7454 @cindex resolve idle time
7455 @cindex idle, resolve, dangling
7457 If you clock in on a work item, and then walk away from your
7458 computer---perhaps to take a phone call---you often need to
7459 ``resolve'' the time you were away by either subtracting it from the
7460 current clock, or applying it to another one.
7462 @vindex org-clock-idle-time
7463 @vindex org-clock-x11idle-program-name
7464 By customizing the variable @code{org-clock-idle-time} to some integer,
7465 such as 10 or 15, Emacs can alert you when you get back to your
7466 computer after being idle for that many minutes@footnote{On computers using macOS, idleness is based on actual user
7467 idleness, not just Emacs' idle time.  For X11, you can install
7468 a utility program @samp{x11idle.c}, available in the @samp{contrib/scripts/}
7469 directory of the Org Git distribution, or install the xprintidle
7470 package and set it to the variable @code{org-clock-x11idle-program-name} if
7471 you are running Debian, to get the same general treatment of idleness.
7472 On other systems, idle time refers to Emacs idle time only.}, and ask what
7473 you want to do with the idle time.  There will be a question waiting
7474 for you when you get back, indicating how much idle time has passed
7475 constantly updated with the current amount, as well as a set of
7476 choices to correct the discrepancy:
7478 @table @asis
7479 @item @kbd{k}
7480 @kindex k
7481 To keep some or all of the minutes and stay clocked in, press
7482 @kbd{k}.  Org asks how many of the minutes to keep.  Press
7483 @kbd{@key{RET}} to keep them all, effectively changing nothing, or
7484 enter a number to keep that many minutes.
7486 @item @kbd{K}
7487 @kindex K
7488 If you use the shift key and press @kbd{K}, it keeps however
7489 many minutes you request and then immediately clock out of that
7490 task.  If you keep all of the minutes, this is the same as just
7491 clocking out of the current task.
7493 @item @kbd{s}
7494 @kindex s
7495 To keep none of the minutes, use @kbd{s} to subtract all the
7496 away time from the clock, and then check back in from the moment
7497 you returned.
7499 @item @kbd{S}
7500 @kindex S
7501 To keep none of the minutes and just clock out at the start of
7502 the away time, use the shift key and press @kbd{S}.
7503 Remember that using shift always leave you clocked out, no matter
7504 which option you choose.
7506 @item @kbd{C}
7507 @kindex C
7508 To cancel the clock altogether, use @kbd{C}.  Note that if
7509 instead of canceling you subtract the away time, and the
7510 resulting clock amount is less than a minute, the clock is still
7511 canceled rather than cluttering up the log with an empty entry.
7512 @end table
7514 What if you subtracted those away minutes from the current clock, and
7515 now want to apply them to a new clock?  Simply clock in to any task
7516 immediately after the subtraction.  Org will notice that you have
7517 subtracted time ``on the books'', so to speak, and will ask if you want
7518 to apply those minutes to the next task you clock in on.
7520 There is one other instance when this clock resolution magic occurs.
7521 Say you were clocked in and hacking away, and suddenly your cat chased
7522 a mouse who scared a hamster that crashed into your UPS's power
7523 button!  You suddenly lose all your buffers, but thanks to auto-save
7524 you still have your recent Org mode changes, including your last clock
7527 If you restart Emacs and clock into any task, Org will notice that you
7528 have a dangling clock which was never clocked out from your last
7529 session.  Using that clock's starting time as the beginning of the
7530 unaccounted-for period, Org will ask how you want to resolve that
7531 time.  The logic and behavior is identical to dealing with away time
7532 due to idleness; it is just happening due to a recovery event rather
7533 than a set amount of idle time.
7535 You can also check all the files visited by your Org agenda for
7536 dangling clocks at any time using @kbd{M-x org-resolve-clocks @key{RET}} (or @kbd{C-c C-x C-z}).
7538 @anchor{Continuous clocking}
7539 @subsubheading Continuous clocking
7541 @cindex continuous clocking
7543 @vindex org-clock-continuously
7544 You may want to start clocking from the time when you clocked out the
7545 previous task.  To enable this systematically, set
7546 @code{org-clock-continuously} to non-@code{nil}.  Each time you clock in, Org
7547 retrieves the clock-out time of the last clocked entry for this
7548 session, and start the new clock from there.
7550 If you only want this from time to time, use three universal prefix
7551 arguments with @code{org-clock-in} and two @kbd{C-u C-u} with
7552 @code{org-clock-in-last}.
7554 @node Effort Estimates
7555 @section Effort Estimates
7557 @cindex effort estimates
7558 @cindex @samp{EFFORT}, property
7559 @vindex org-effort-property
7561 If you want to plan your work in a very detailed way, or if you need
7562 to produce offers with quotations of the estimated work effort, you
7563 may want to assign effort estimates to entries.  If you are also
7564 clocking your work, you may later want to compare the planned effort
7565 with the actual working time, a great way to improve planning
7566 estimates.  Effort estimates are stored in a special property
7567 @samp{EFFORT}.  You can set the effort for an entry with the following
7568 commands:
7570 @table @asis
7571 @item @kbd{C-c C-x e}  (@code{org-set-effort})
7572 @kindex C-c C-x e
7573 @findex org-set-effort
7574 Set the effort estimate for the current entry.  With a prefix
7575 argument, set it to the next allowed value---see below.  This
7576 command is also accessible from the agenda with the @kbd{e}
7577 key.
7579 @item @kbd{C-c C-x C-e} (@code{org-clock-modify-effort-estimate})
7580 @kindex C-c C-x C-e
7581 @findex org-clock-modify-effort-estimate
7582 Modify the effort estimate of the item currently being clocked.
7583 @end table
7585 Clearly the best way to work with effort estimates is through column
7586 view (see @ref{Column View}).  You should start by setting up discrete
7587 values for effort estimates, and a @samp{COLUMNS} format that displays
7588 these values together with clock sums---if you want to clock your
7589 time.  For a specific buffer you can use:
7591 @example
7592 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
7593 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
7594 @end example
7596 noindent
7597 @vindex org-global-properties
7598 @vindex org-columns-default-format
7599 or, even better, you can set up these values globally by customizing
7600 the variables @code{org-global-properties} and
7601 @code{org-columns-default-format}.  In particular if you want to use this
7602 setup also in the agenda, a global setup may be advised.
7604 The way to assign estimates to individual items is then to switch to
7605 column mode, and to use @kbd{S-@key{RIGHT}} and @kbd{S-@key{LEFT}} to
7606 change the value.  The values you enter are immediately summed up in
7607 the hierarchy.  In the column next to it, any clocked time is
7608 displayed.
7610 @vindex org-agenda-columns-add-appointments-to-effort-sum
7611 If you switch to column view in the daily/weekly agenda, the effort
7612 column summarizes the estimated work effort for each day@footnote{Please note the pitfalls of summing hierarchical data in
7613 a flat list (@ref{Agenda Column View}).}, and
7614 you can use this to find space in your schedule.  To get an overview
7615 of the entire part of the day that is committed, you can set the
7616 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
7617 appointments on a day that take place over a specified time interval
7618 are then also added to the load estimate of the day.
7620 Effort estimates can be used in secondary agenda filtering that is
7621 triggered with the @kbd{/} key in the agenda (see @ref{Agenda Commands}).  If you have these estimates defined consistently,
7622 two or three key presses narrow down the list to stuff that fits into
7623 an available time slot.
7625 @node Timers
7626 @section Taking Notes with a Relative Timer
7628 @cindex relative timer
7629 @cindex countdown timer
7631 Org provides two types of timers.  There is a relative timer that
7632 counts up, which can be useful when taking notes during, for example,
7633 a meeting or a video viewing.  There is also a countdown timer.
7635 The relative and countdown are started with separate commands.
7637 @table @asis
7638 @item @kbd{C-c C-x 0} (@code{org-timer-start})
7639 @kindex C-c C-x 0
7640 @findex org-timer-start
7641 Start or reset the relative timer.  By default, the timer is set
7642 to 0.  When called with a @kbd{C-u} prefix, prompt the user
7643 for a starting offset.  If there is a timer string at point, this
7644 is taken as the default, providing a convenient way to restart
7645 taking notes after a break in the process.  When called with
7646 a double prefix argument @kbd{C-u C-u}, change all timer
7647 strings in the active region by a certain amount.  This can be
7648 used to fix timer strings if the timer was not started at exactly
7649 the right moment.
7651 @item @kbd{C-c C-x ;} (@code{org-timer-set-timer})
7652 @kindex C-c C-x ;
7653 @findex org-timer-set-timer
7654 @vindex org-timer-default-timer
7655 Start a countdown timer.  The user is prompted for a duration.
7656 @code{org-timer-default-timer} sets the default countdown value.
7657 Giving a numeric prefix argument overrides this default value.
7658 This command is available as @kbd{;} in agenda buffers.
7659 @end table
7661 Once started, relative and countdown timers are controlled with the
7662 same commands.
7664 @table @asis
7665 @item @kbd{C-c C-x .} (@code{org-timer})
7666 @kindex C-c C-x .
7667 @findex org-timer
7668 Insert a relative time into the buffer.  The first time you use
7669 this, the timer starts.  Using a prefix argument restarts it.
7671 @item @kbd{C-c C-x -} (@code{org-timer-item})
7672 @kindex C-c C-x -
7673 @findex org-timer-item
7674 Insert a description list item with the current relative time.
7675 With a prefix argument, first reset the timer to 0.
7677 @item @kbd{M-@key{RET}} (@code{org-insert-heading})
7678 @kindex M-RET
7679 @findex org-insert-heading
7680 Once the timer list is started, you can also use
7681 @kbd{M-@key{RET}} to insert new timer items.
7683 @item @kbd{C-c C-x ,} (@code{org-timer-pause-or-continue})
7684 @kindex C-c C-x ,
7685 @findex org-timer-pause-or-continue
7686 Pause the timer, or continue it if it is already paused.
7688 @item @kbd{C-c C-x _} (@code{org-timer-stop})
7689 @kindex C-c C-x _
7690 @findex org-timer-stop
7691 Stop the timer.  After this, you can only start a new timer, not
7692 continue the old one.  This command also removes the timer from
7693 the mode line.
7694 @end table
7696 @node Capture Refile Archive
7697 @chapter Capture, Refile, Archive
7699 @cindex capture
7701 An important part of any organization system is the ability to quickly
7702 capture new ideas and tasks, and to associate reference material with
7703 them.  Org does this using a process called @emph{capture}.  It also can
7704 store files related to a task (@emph{attachments}) in a special directory.
7705 Once in the system, tasks and projects need to be moved around.
7706 Moving completed project trees to an archive file keeps the system
7707 compact and fast.
7709 @menu
7710 * Capture::                      Capturing new stuff.
7711 * Attachments::                  Add files to tasks.
7712 * RSS Feeds::                    Getting input from RSS feeds.
7713 * Protocols::                    External access to Emacs and Org.
7714 * Refile and Copy::              Moving/copying a tree from one place to another.
7715 * Archiving::                    What to do with finished products.
7716 @end menu
7718 @node Capture
7719 @section Capture
7721 @cindex capture
7723 Capture lets you quickly store notes with little interruption of your
7724 work flow.  Org's method for capturing new items is heavily inspired
7725 by John Wiegley's excellent Remember package.
7727 @menu
7728 * Setting up capture::           Where notes will be stored.
7729 * Using capture::                Commands to invoke and terminate capture.
7730 * Capture templates::            Define the outline of different note types.
7731 @end menu
7733 @node Setting up capture
7734 @subsection Setting up capture
7736 The following customization sets a default target file for notes.
7738 @vindex org-default-notes-file
7739 @lisp
7740 (setq org-default-notes-file (concat org-directory "/notes.org"))
7741 @end lisp
7743 You may also define a global key for capturing new material (see
7744 @ref{Activation}).
7746 @node Using capture
7747 @subsection Using capture
7749 @table @asis
7750 @item @kbd{M-x org-capture} (@code{org-capture})
7751 @findex org-capture
7752 @cindex date tree
7753 Display the capture templates menu.  If you have templates
7754 defined (see @ref{Capture templates}), it offers these templates for
7755 selection or use a new Org outline node as the default template.
7756 It inserts the template into the target file and switch to an
7757 indirect buffer narrowed to this new node.  You may then insert
7758 the information you want.
7760 @item @kbd{C-c C-c} (@code{org-capture-finalize})
7761 @kindex C-c C-c @r{(Capture buffer)}
7762 @findex org-capture-finalize
7763 Once you have finished entering information into the capture
7764 buffer, @kbd{C-c C-c} returns you to the window
7765 configuration before the capture process, so that you can resume
7766 your work without further distraction.  When called with a prefix
7767 argument, finalize and then jump to the captured item.
7769 @item @kbd{C-c C-w} (@code{org-capture-refile})
7770 @kindex C-c C-w @r{(Capture buffer)}
7771 @findex org-capture-refile
7772 Finalize the capture process by refiling the note to a different
7773 place (see @ref{Refile and Copy}).  Please realize that this is
7774 a normal refiling command that will be executed---so the cursor
7775 position at the moment you run this command is important.  If you
7776 have inserted a tree with a parent and children, first move the
7777 cursor back to the parent.  Any prefix argument given to this
7778 command is passed on to the @code{org-refile} command.
7780 @item @kbd{C-c C-k} (@code{org-capture-kill})
7781 @kindex C-c C-k @r{(Capture buffer)}
7782 @findex org-capture-kill
7783 Abort the capture process and return to the previous state.
7784 @end table
7786 @kindex k c @r{(Agenda)}
7787 You can also call @code{org-capture} in a special way from the agenda,
7788 using the @kbd{k c} key combination.  With this access, any
7789 timestamps inserted by the selected capture template defaults to the
7790 cursor date in the agenda, rather than to the current date.
7792 To find the locations of the last stored capture, use @code{org-capture}
7793 with prefix commands:
7795 @table @asis
7796 @item @kbd{C-u M-x org-capture}
7797 Visit the target location of a capture template.  You get to
7798 select the template in the usual way.
7800 @item @kbd{C-u C-u M-x org-capture}
7801 Visit the last stored capture item in its buffer.
7802 @end table
7804 @vindex org-capture-bookmark
7805 @vindex org-capture-last-stored
7806 You can also jump to the bookmark @code{org-capture-last-stored}, which is
7807 automatically created unless you set @code{org-capture-bookmark} to @code{nil}.
7809 To insert the capture at point in an Org buffer, call @code{org-capture}
7810 with a @code{C-0} prefix argument.
7812 @node Capture templates
7813 @subsection Capture templates
7815 @cindex templates, for Capture
7817 You can use templates for different types of capture items, and for
7818 different target locations.  The easiest way to create such templates
7819 is through the customize interface.
7821 @table @asis
7822 @item @kbd{C}
7823 @kindex C @r{(Capture menu}
7824 @vindex org-capture-templates
7825 Customize the variable @code{org-capture-templates}.
7826 @end table
7828 Before we give the formal description of template definitions, let's
7829 look at an example.  Say you would like to use one template to create
7830 general TODO entries, and you want to put these entries under the
7831 heading @samp{Tasks} in your file @samp{~/org/gtd.org}.  Also, a date tree in
7832 the file @samp{journal.org} should capture journal entries.  A possible
7833 configuration would look like:
7835 @lisp
7836 (setq org-capture-templates
7837       '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
7838          "* TODO %?\n  %i\n  %a")
7839         ("j" "Journal" entry (file+datetree "~/org/journal.org")
7840          "* %?\nEntered on %U\n  %i\n  %a")))
7841 @end lisp
7843 @noindent
7844 If you then press @kbd{t} from the capture menu, Org will prepare
7845 the template for you like this:
7847 @example
7848 * TODO
7849   [[file:LINK TO WHERE YOU INITIATED CAPTURE]]
7850 @end example
7852 @noindent
7853 During expansion of the template, @code{%a} has been replaced by a link to
7854 the location from where you called the capture command.  This can be
7855 extremely useful for deriving tasks from emails, for example.  You
7856 fill in the task definition, press @kbd{C-c C-c} and Org returns
7857 you to the same place where you started the capture process.
7859 To define special keys to capture to a particular template without
7860 going through the interactive template selection, you can create your
7861 key binding like this:
7863 @lisp
7864 (define-key global-map "\C-cx"
7865   (lambda () (interactive) (org-capture nil "x")))
7866 @end lisp
7868 @menu
7869 * Template elements::            What is needed for a complete template entry.
7870 * Template expansion::           Filling in information about time and context.
7871 * Templates in contexts::        Only show a template in a specific context.
7872 @end menu
7874 @node Template elements
7875 @subsubsection Template elements
7877 Now lets look at the elements of a template definition.  Each entry in
7878 @code{org-capture-templates} is a list with the following items:
7880 @table @asis
7881 @item keys
7882 The keys that selects the template, as a string, characters only,
7883 for example @samp{"a"}, for a template to be selected with a single
7884 key, or @samp{"bt"} for selection with two keys.  When using several
7885 keys, keys using the same prefix key must be sequential in the
7886 list and preceded by a 2-element entry explaining the prefix key,
7887 for example:
7889 @lisp
7890 ("b" "Templates for marking stuff to buy")
7891 @end lisp
7893 @noindent
7894 If you do not define a template for the @kbd{C} key, this
7895 key opens the Customize buffer for this complex variable.
7897 @item description
7898 A short string describing the template, shown during selection.
7900 @item type
7901 The type of entry, a symbol.  Valid values are:
7903 @table @asis
7904 @item @code{entry}
7905 An Org mode node, with a headline.  Will be filed as the child
7906 of the target entry or as a top-level entry.  The target file
7907 should be an Org file.
7909 @item @code{item}
7910 A plain list item, placed in the first plain list at the
7911 target location.  Again the target file should be an Org
7912 file.
7914 @item @code{checkitem}
7915 A checkbox item.  This only differs from the plain list item
7916 by the default template.
7918 @item @code{table-line}
7919 A new line in the first table at the target location.  Where
7920 exactly the line will be inserted depends on the properties
7921 @code{:prepend} and @code{:table-line-pos} (see below).
7923 @item @code{plain}
7924 Text to be inserted as it is.
7925 @end table
7927 @item target
7928 @vindex org-default-notes-file
7929 @vindex org-directory
7930 Specification of where the captured item should be placed.  In
7931 Org files, targets usually define a node.  Entries will become
7932 children of this node.  Other types will be added to the table or
7933 list in the body of this node.  Most target specifications
7934 contain a file name.  If that file name is the empty string, it
7935 defaults to @code{org-default-notes-file}.  A file can also be given
7936 as a variable or as a function called with no argument.  When an
7937 absolute path is not specified for a target, it is taken as
7938 relative to @code{org-directory}.
7940 Valid values are:
7942 @table @asis
7943 @item @samp{(file "path/to/file")}
7944 Text will be placed at the beginning or end of that file.
7946 @item @samp{(id "id of existing org entry")}
7947 Filing as child of this entry, or in the body of the entry.
7949 @item @samp{(file+headline "filename" "node headline")}
7950 Fast configuration if the target heading is unique in the file.
7952 @item @samp{(file+olp "filename" "Level 1 heading" "Level 2" ...)}
7953 For non-unique headings, the full path is safer.
7955 @item @samp{(file+regexp "filename" "regexp to find location")}
7956 Use a regular expression to position the cursor.
7958 @item @samp{(file+olp+datetree "filename" [ "Level 1 heading" ...])}
7959 This target@footnote{Org used to offer four different targets for date/week tree
7960 capture.  Now, Org automatically translates these to use
7961 @code{file+olp+datetree}, applying the @code{:time-prompt} and @code{:tree-type}
7962 properties.  Please rewrite your date/week-tree targets using
7963 @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
7964 level, months or ISO weeks as sublevels and then dates on the lowest
7965 level.  Tags are allowed in the tree structure.} for
7966 today's date.  If the optional outline path is given, the tree
7967 will be built under the node it is pointing to, instead of at
7968 top level.  Check out the @code{:time-prompt} and @code{:tree-type}
7969 properties below for additional options.
7971 @item @code{(file+function "filename" function-finding-location)}
7972 A function to find the right location in the file.
7974 @item @code{(clock)}
7975 File to the entry that is currently being clocked.
7977 @item @code{(function function-finding-location)}
7978 Most general way: write your own function which both visits the
7979 file and moves point to the right location.
7980 @end table
7982 @item template
7983 The template for creating the capture item.  If you leave this
7984 empty, an appropriate default template will be used.  Otherwise
7985 this is a string with escape codes, which will be replaced
7986 depending on time and context of the capture call.  The string
7987 with escapes may be loaded from a template file, using the
7988 special syntax @samp{(file "template filename")}.  See below for more
7989 details.
7991 @item properties
7992 The rest of the entry is a property list of additional options.
7993 Recognized properties are:
7995 @table @asis
7996 @item @code{:prepend}
7997 Normally new captured information will be appended at the
7998 target location (last child, last table line, last list item,
7999 @dots{}).  Setting this property changes that.
8001 @item @code{:immediate-finish}
8002 When set, do not offer to edit the information, just file it
8003 away immediately.  This makes sense if the template only needs
8004 information that can be added automatically.
8006 @item @code{:empty-lines}
8007 Set this to the number of lines to insert before and after the
8008 new item.  Default 0, and the only other common value is 1.
8010 @item @code{:clock-in}
8011 Start the clock in this item.
8013 @item @code{:clock-keep}
8014 Keep the clock running when filing the captured entry.
8016 @item @code{:clock-resume}
8017 If starting the capture interrupted a clock, restart that clock
8018 when finished with the capture.  Note that @code{:clock-keep} has
8019 precedence over @code{:clock-resume}.  When setting both to
8020 non-@code{nil}, the current clock will run and the previous one will
8021 not be resumed.
8023 @item @code{:time-prompt}
8024 Prompt for a date/time to be used for date/week trees and when
8025 filling the template.  Without this property, capture uses the
8026 current date and time.  Even if this property has not been set,
8027 you can force the same behavior by calling @code{org-capture} with
8028 a @kbd{C-1} prefix argument.
8030 @item @code{:tree-type}
8031 When @code{week}, make a week tree instead of the month tree, i.e.,
8032 place the headings for each day under a heading with the
8033 current ISO week.
8035 @item @code{:unnarrowed}
8036 Do not narrow the target buffer, simply show the full buffer.  Default
8037 is to narrow it so that you only see the new material.
8039 @item @code{:table-line-pos}
8040 Specification of the location in the table where the new line
8041 should be inserted.  It should be a string like @samp{II-3} meaning
8042 that the new line should become the third line before the
8043 second horizontal separator line.
8045 @item @code{:kill-buffer}
8046 If the target file was not yet visited when capture was invoked, kill
8047 the buffer again after capture is completed.
8048 @end table
8049 @end table
8051 @node Template expansion
8052 @subsubsection Template expansion
8054 In the template itself, special ``%-escapes''@footnote{If you need one of these sequences literally, escape the @samp{%}
8055 with a backslash.} allow dynamic
8056 insertion of content.  The templates are expanded in the order given
8057 here:
8059 @table @asis
8060 @item @code{%[FILE]}
8061 Insert the contents of the file given by @var{FILE}.
8063 @item @code{%(SEXP)}
8064 Evaluate Elisp SEXP and replace with the result.  The
8065 @var{SEXP} must return a string.
8067 @item @code{%<FORMAT>}
8068 The result of format-time-string on the @var{FORMAT}
8069 specification.
8071 @item @code{%t}
8072 Timestamp, date only.
8074 @item @code{%T}
8075 Timestamp, with date and time.
8077 @item @code{%u}, @code{%U}
8078 Like @code{%t}, @code{%T} above, but inactive timestamps.
8080 @item @code{%i}
8081 Initial content, the region when capture is called while the
8082 region is active.  The entire text will be indented like @code{%i}
8083 itself.
8085 @item @code{%a}
8086 Annotation, normally the link created with @code{org-store-link}.
8088 @item @code{%A}
8089 Like @code{%a}, but prompt for the description part.
8091 @item @code{%l}
8092 Like @code{%a}, but only insert the literal link.
8094 @item @code{%c}
8095 Current kill ring head.
8097 @item @code{%x}
8098 Content of the X clipboard.
8100 @item @code{%k}
8101 Title of the currently clocked task.
8103 @item @code{%K}
8104 Link to the currently clocked task.
8106 @item @code{%n}
8107 User name (taken from @code{user-full-name}).
8109 @item @code{%f}
8110 File visited by current buffer when org-capture was called.
8112 @item @code{%F}
8113 Full path of the file or directory visited by current buffer.
8115 @item @code{%:keyword}
8116 Specific information for certain link types, see below.
8118 @item @code{%^g}
8119 Prompt for tags, with completion on tags in target file.
8121 @item @code{%^G}
8122 Prompt for tags, with completion all tags in all agenda files.
8124 @item @code{%^t}
8125 Like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}.  You may
8126 define a prompt like @code{%^@{Birthday@}t}.
8128 @item @code{%^C}
8129 Interactive selection of which kill or clip to use.
8131 @item @code{%^L}
8132 Like @code{%^C}, but insert as link.
8134 @item @code{%^@{PROP@}p}
8135 Prompt the user for a value for property PROP.
8137 @item @code{%^@{PROMPT@}}
8138 Prompt the user for a string and replace this sequence with it.
8139 You may specify a default value and a completion table with
8140 @code{%^@{prompt|default|completion2|completion3...@}}.  The arrow keys
8141 access a prompt-specific history.
8143 @item @code{%\n}
8144 Insert the text entered at the Nth @code{%^@{PROMPT@}}, where N is
8145 a number, starting from 1.
8147 @item @code{%?}
8148 After completing the template, position cursor here.
8149 @end table
8151 @noindent
8152 @vindex org-store-link-props
8153 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
8154 accessed in capture templates in a similar way.}:
8156 @vindex org-from-is-user-regexp
8157 @multitable {aaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
8158 @headitem Link type
8159 @tab Available keywords
8160 @item bbdb
8161 @tab @code{%:name}, @code{%:company}
8162 @item irc
8163 @tab @code{%:server}, @code{%:port}, @code{%:nick}
8164 @item mh, rmail
8165 @tab @code{%:type}, @code{%:subject}, @code{%:message-id}
8166 @item 
8167 @tab @code{%:from}, @code{%:fromname}, @code{%:fromaddress}
8168 @item 
8169 @tab @code{%:to}, @code{%:toname}, @code{%:toaddress}
8170 @item 
8171 @tab @code{%:date} (message date header field)
8172 @item 
8173 @tab @code{%:date-timestamp} (date as active timestamp)
8174 @item 
8175 @tab @code{%:date-timestamp-inactive} (date as inactive timestamp)
8176 @item 
8177 @tab @code{%:fromto} (either ``to NAME'' or ``from NAME'')@footnote{This is always the other, not the user.  See the variable
8178 @code{org-from-is-user-regexp}.}
8179 @item gnus
8180 @tab @code{%:group}, for messages also all email fields
8181 @item w3, w3m
8182 @tab @code{%:url}
8183 @item info
8184 @tab @code{%:file}, @code{%:node}
8185 @item calendar
8186 @tab @code{%:date}
8187 @item org-protocol
8188 @tab @code{%:link}, @code{%:description}, @code{%:annotation}
8189 @end multitable
8191 @node Templates in contexts
8192 @subsubsection Templates in contexts
8194 @vindex org-capture-templates-contexts
8195 To control whether a capture template should be accessible from
8196 a specific context, you can customize
8197 @code{org-capture-templates-contexts}.  Let's say, for example, that you
8198 have a capture template ``p'' for storing Gnus emails containing
8199 patches.  Then you would configure this option like this:
8201 @lisp
8202 (setq org-capture-templates-contexts
8203       '(("p" (in-mode . "message-mode"))))
8204 @end lisp
8206 You can also tell that the command key @kbd{p} should refer to
8207 another template.  In that case, add this command key like this:
8209 @lisp
8210 (setq org-capture-templates-contexts
8211       '(("p" "q" (in-mode . "message-mode"))))
8212 @end lisp
8214 See the docstring of the variable for more information.
8216 @node Attachments
8217 @section Attachments
8219 @cindex attachments
8220 @vindex org-attach-directory
8222 It is often useful to associate reference material with an outline
8223 node/task.  Small chunks of plain text can simply be stored in the
8224 subtree of a project.  Hyperlinks (see @ref{Hyperlinks}) can establish
8225 associations with files that live elsewhere on your computer or in the
8226 cloud, like emails or source code files belonging to a project.
8227 Another method is @emph{attachments}, which are files located in
8228 a directory belonging to an outline node.  Org uses directories named
8229 by the unique ID of each entry.  These directories are located in the
8230 @code{data} directory which lives in the same directory where your Org file
8231 lives@footnote{If you move entries or Org files from one directory to
8232 another, you may want to configure @code{org-attach-directory} to contain
8233 an absolute path.}.  If you initialize this directory with @samp{git init}, Org
8234 automatically commits changes when it sees them.  The attachment
8235 system has been contributed to Org by John Wiegley.
8237 In cases where it seems better to do so, you can attach a directory of
8238 your choice to an entry.  You can also make children inherit the
8239 attachment directory from a parent, so that an entire subtree uses the
8240 same attached directory.
8242 @noindent
8243 The following commands deal with attachments:
8245 @table @asis
8246 @item @kbd{C-c C-a} (@code{org-attach})
8247 @kindex C-c C-a
8248 @findex org-attach
8249 The dispatcher for commands related to the attachment system.
8250 After these keys, a list of commands is displayed and you must
8251 press an additional key to select a command:
8253 @table @asis
8254 @item @kbd{a} (@code{org-attach-attach})
8255 @kindex C-c C-a a
8256 @findex org-attach-attach
8257 @vindex org-attach-method
8258 Select a file and move it into the task's attachment
8259 directory.  The file is copied, moved, or linked, depending
8260 on @code{org-attach-method}.  Note that hard links are not
8261 supported on all systems.
8263 @item @kbd{c}/@kbd{m}/@kbd{l}
8264 @kindex C-c C-a c
8265 @kindex C-c C-a m
8266 @kindex C-c C-a l
8267 Attach a file using the copy/move/link method.  Note that
8268 hard links are not supported on all systems.
8270 @item @kbd{n} (@code{org-attach-new})
8271 @kindex C-c C-a n
8272 @findex org-attach-new
8273 Create a new attachment as an Emacs buffer.
8275 @item @kbd{z} (@code{org-attach-sync})
8276 @kindex C-c C-a z
8277 @findex org-attach-sync
8278 Synchronize the current task with its attachment directory, in case
8279 you added attachments yourself.
8281 @item @kbd{o} (@code{org-attach-open})
8282 @kindex C-c C-a o
8283 @findex org-attach-open
8284 @vindex org-file-apps
8285 Open current task's attachment.  If there is more than one,
8286 prompt for a file name first.  Opening follows the rules set
8287 by @code{org-file-apps}.  For more details, see the information
8288 on following hyperlinks (see @ref{Handling Links}).
8290 @item @kbd{O} (@code{org-attach-open-in-emacs})
8291 @kindex C-c C-a O
8292 @findex org-attach-open-in-emacs
8293 Also open the attachment, but force opening the file in
8294 Emacs.
8296 @item @kbd{f} (@code{org-attach-reveal})
8297 @kindex C-c C-a f
8298 @findex org-attach-reveal
8299 Open the current task's attachment directory.
8301 @item @kbd{F} (@code{org-attach-reveal-in-emacs})
8302 @kindex C-c C-a F
8303 @findex org-attach-reveal-in-emacs
8304 Also open the directory, but force using Dired in Emacs.
8306 @item @kbd{d} (@code{org-attach-delete-one})
8307 @kindex C-c C-a d
8308 Select and delete a single attachment.
8310 @item @kbd{D} (@code{org-attach-delete-all})
8311 @kindex C-c C-a D
8312 Delete all of a task's attachments.  A safer way is to open
8313 the directory in Dired and delete from there.
8315 @item @kbd{s} (@code{org-attach-set-directory})
8316 @kindex C-c C-a s
8317 @cindex @samp{ATTACH_DIR}, property
8318 Set a specific directory as the entry's attachment
8319 directory.  This works by putting the directory path into
8320 the @samp{ATTACH_DIR} property.
8322 @item @kbd{i} (@code{org-attach-set-inherit})
8323 @kindex C-c C-a i
8324 @cindex @samp{ATTACH_DIR_INHERIT}, property
8325 Set the @samp{ATTACH_DIR_INHERIT} property, so that children use
8326 the same directory for attachments as the parent does.
8327 @end table
8328 @end table
8330 @cindex attach from Dired
8331 @findex org-attach-dired-to-subtree
8332 It is possible to attach files to a subtree from a Dired buffer.  To
8333 use this feature, have one window in Dired mode containing the file(s)
8334 to be attached and another window with point in the subtree that shall
8335 get the attachments.  In the Dired window, with point on a file,
8336 @kbd{M-x org-attach-dired-to-subtree} attaches the file to the
8337 subtree using the attachment method set by variable
8338 @code{org-attach-method}.  When files are marked in the Dired window then
8339 all marked files get attached.
8341 Add the following lines to the Emacs init file to have @kbd{C-c C-x a} attach files in Dired buffers.
8343 @lisp
8344 (add-hook 'dired-mode-hook
8345           (lambda ()
8346             (define-key dired-mode-map
8347               (kbd "C-c C-x a")
8348               #'org-attach-dired-to-subtree))))
8349 @end lisp
8351 The following code shows how to bind the previous command with
8352 a specific attachment method.
8354 @lisp
8355 (add-hook 'dired-mode-hook
8356           (lambda ()
8357             (define-key dired-mode-map (kbd "C-c C-x c")
8358               (lambda ()
8359                 (interactive)
8360                 (let ((org-attach-method 'cp))
8361                   (call-interactively #'org-attach-dired-to-subtree))))))
8362 @end lisp
8364 @node RSS Feeds
8365 @section RSS Feeds
8367 @cindex RSS feeds
8368 @cindex Atom feeds
8370 Org can add and change entries based on information found in RSS feeds
8371 and Atom feeds.  You could use this to make a task out of each new
8372 podcast in a podcast feed.  Or you could use a phone-based
8373 note-creating service on the web to import tasks into Org.  To access
8374 feeds, configure the variable @code{org-feed-alist}.  The docstring of this
8375 variable has detailed information.  With the following
8377 @lisp
8378 (setq org-feed-alist
8379       '(("Slashdot"
8380          "http://rss.slashdot.org/Slashdot/slashdot"
8381          "~/txt/org/feeds.org" "Slashdot Entries")))
8382 @end lisp
8384 @noindent
8385 new items from the feed provided by @samp{rss.slashdot.org} result in new
8386 entries in the file @samp{~/org/feeds.org} under the heading @samp{Slashdot
8387 Entries}, whenever the following command is used:
8389 @table @asis
8390 @item @kbd{C-c C-x g} (@code{org-feed-update-all})
8391 @kindex C-c C-x g
8392 Collect items from the feeds configured in @code{org-feed-alist} and
8393 act upon them.
8395 @item @kbd{C-c C-x G} (@code{org-feed-goto-inbox})
8396 @kindex C-c C-x G
8397 Prompt for a feed name and go to the inbox configured for this feed.
8398 @end table
8400 Under the same headline, Org creates a drawer @samp{FEEDSTATUS} in which it
8401 stores information about the status of items in the feed, to avoid
8402 adding the same item several times.
8404 For more information, including how to read atom feeds, see
8405 @samp{org-feed.el} and the docstring of @code{org-feed-alist}.
8407 @node Protocols
8408 @section Protocols for External Access
8410 @cindex protocols, for external access
8412 Org protocol is a means to trigger custom actions in Emacs from
8413 external applications.  Any application that supports calling external
8414 programs with an URL as argument may be used with this functionality.
8415 For example, you can configure bookmarks in your web browser to send
8416 a link to the current page to Org and create a note from it using
8417 capture (see @ref{Capture}).  You can also create a bookmark that tells
8418 Emacs to open the local source file of a remote website you are
8419 browsing.
8421 @cindex Org protocol, set-up
8422 @cindex Installing Org protocol
8423 In order to use Org protocol from an application, you need to register
8424 @samp{org-protocol://} as a valid scheme-handler.  External calls are
8425 passed to Emacs through the @samp{emacsclient} command, so you also need to
8426 ensure an Emacs server is running.  More precisely, when the
8427 application calls
8429 @example
8430 emacsclient org-protocol://PROTOCOL?key1=val1&key2=val2
8431 @end example
8433 @noindent
8434 Emacs calls the handler associated to @var{PROTOCOL} with
8435 argument @samp{(:key1 val1 :key2 val2)}.
8437 @cindex protocol, new protocol
8438 @cindex defining new protocols
8439 Org protocol comes with three predefined protocols, detailed in the
8440 following sections.  Configure @code{org-protocol-protocol-alist} to define
8441 your own.
8443 @menu
8444 * @code{store-link} protocol::   Store a link, push URL to kill-ring.
8445 * @code{capture} protocol::      Fill a buffer with external information.
8446 * @code{open-source} protocol::  Edit published contents.
8447 @end menu
8449 @node @code{store-link} protocol
8450 @subsection @code{store-link} protocol
8452 @cindex store-link protocol
8453 @cindex protocol, store-link
8455 Using @code{store-link} handler, you can copy links, insertable through
8456 @kbd{M-x org-insert-link} or yanking thereafter.  More precisely,
8457 the command
8459 @example
8460 emacsclient org-protocol://store-link?url=URL&title=TITLE
8461 @end example
8463 @noindent
8464 stores the following link:
8466 @example
8467 [[URL][TITLE]]
8468 @end example
8470 In addition, @var{URL} is pushed on the kill-ring for yanking.
8471 You need to encode @var{URL} and @var{TITLE} if they contain
8472 slashes, and probably quote those for the shell.
8474 To use this feature from a browser, add a bookmark with an arbitrary
8475 name, e.g., @samp{Org: store-link} and enter this as @emph{Location}:
8477 @example
8478 javascript:location.href='org-protocol://store-link?url='+
8479       encodeURIComponent(location.href);
8480 @end example
8482 @node @code{capture} protocol
8483 @subsection @code{capture} protocol
8485 @cindex capture protocol
8486 @cindex protocol, capture
8488 Activating ``capture'' handler pops up a @samp{Capture} buffer and fills the
8489 capture template associated to the @samp{X} key with them.
8491 @example
8492 emacsclient org-protocol://capture?template=X?url=URL?title=TITLE?body=BODY
8493 @end example
8495 To use this feature, add a bookmark with an arbitrary name, e.g.
8496 @samp{Org: capture} and enter this as @samp{Location}:
8498 @example
8499 javascript:location.href='org-protocol://capture?template=x'+
8500       '&url='+encodeURIComponent(window.location.href)+
8501       '&title='+encodeURIComponent(document.title)+
8502       '&body='+encodeURIComponent(window.getSelection());
8503 @end example
8505 @vindex org-protocol-default-template-key
8506 The result depends on the capture template used, which is set in the
8507 bookmark itself, as in the example above, or in
8508 @code{org-protocol-default-template-key}.
8510 The following template placeholders are available:
8512 @example
8513 %:link          The URL
8514 %:description   The webpage title
8515 %:annotation    Equivalent to [[%:link][%:description]]
8516 %i              The selected text
8517 @end example
8519 @node @code{open-source} protocol
8520 @subsection @code{open-source} protocol
8522 @cindex open-source protocol
8523 @cindex protocol, open-source
8525 The @code{open-source} handler is designed to help with editing local
8526 sources when reading a document.  To that effect, you can use
8527 a bookmark with the following location:
8529 @example
8530 javascript:location.href='org-protocol://open-source?&url='+
8531       encodeURIComponent(location.href)
8532 @end example
8534 @vindex org-protocol-project-alist
8535 The variable @code{org-protocol-project-alist} maps URLs to local file
8536 names, by stripping URL parameters from the end and replacing the
8537 @code{:base-url} with @code{:working-directory} and @code{:online-suffix} with
8538 @code{:working-suffix}.  For example, assuming you own a local copy of
8539 @samp{https://orgmode.org/worg/} contents at @samp{/home/user/worg}, you can set
8540 @code{org-protocol-project-alist} to the following
8542 @lisp
8543 (setq org-protocol-project-alist
8544       '(("Worg"
8545          :base-url "https://orgmode.org/worg/"
8546          :working-directory "/home/user/worg/"
8547          :online-suffix ".html"
8548          :working-suffix ".org")))
8549 @end lisp
8551 @noindent
8552 If you are now browsing
8553 @samp{https://orgmode.org/worg/org-contrib/org-protocol.html} and find
8554 a typo or have an idea about how to enhance the documentation, simply
8555 click the bookmark and start editing.
8557 @cindex rewritten URL in open-source protocol
8558 @cindex protocol, open-source rewritten URL
8559 However, such mapping may not yield the desired results.  Suppose you
8560 maintain an online store located at @samp{http://example.com/}.  The local
8561 sources reside in @samp{/home/user/example/}.  It is common practice to
8562 serve all products in such a store through one file and rewrite URLs
8563 that do not match an existing file on the server.  That way, a request
8564 to @samp{http://example.com/print/posters.html} might be rewritten on the
8565 server to something like
8566 @samp{http://example.com/shop/products.php/posters.html.php}.  The
8567 @code{open-source} handler probably cannot find a file named
8568 @samp{/home/user/example/print/posters.html.php} and fails.
8570 Such an entry in @code{org-protocol-project-alist} may hold an additional
8571 property @code{:rewrites}.  This property is a list of cons cells, each of
8572 which maps a regular expression to a path relative to the
8573 @code{:working-directory}.
8575 Now map the URL to the path @samp{/home/user/example/products.php} by
8576 adding @code{:rewrites} rules like this:
8578 @lisp
8579 (setq org-protocol-project-alist
8580       '(("example.com"
8581          :base-url "http://example.com/"
8582          :working-directory "/home/user/example/"
8583          :online-suffix ".php"
8584          :working-suffix ".php"
8585          :rewrites (("example.com/print/" . "products.php")
8586                     ("example.com/$" . "index.php")))))
8587 @end lisp
8589 @noindent
8590 Since @samp{example.com/$} is used as a regular expression, it maps
8591 @samp{http://example.com/}, @samp{https://example.com},
8592 @samp{http://www.example.com/} and similar to
8593 @samp{/home/user/example/index.php}.
8595 The @code{:rewrites} rules are searched as a last resort if and only if no
8596 existing file name is matched.
8598 @cindex protocol, open-source, set-up mapping
8599 @cindex mappings in open-source protocol
8600 @findex org-protocol-create
8601 @findex org-protocol-create-for-org
8602 Two functions can help you filling @code{org-protocol-project-alist} with
8603 valid contents: @code{org-protocol-create} and
8604 @code{org-protocol-create-for-org}.  The latter is of use if you're editing
8605 an Org file that is part of a publishing project.
8607 @node Refile and Copy
8608 @section Refile and Copy
8610 @cindex refiling notes
8611 @cindex copying notes
8613 When reviewing the captured data, you may want to refile or to copy
8614 some of the entries into a different list, for example into a project.
8615 Cutting, finding the right location, and then pasting the note is
8616 cumbersome.  To simplify this process, you can use the following
8617 special command:
8619 @table @asis
8620 @item @kbd{C-c M-w} (@code{org-copy})
8621 @kindex C-c M-w
8622 @findex org-copy
8623 Copying works like refiling, except that the original note is not
8624 deleted.
8626 @item @kbd{C-c C-w} (@code{org-refile})
8627 @kindex C-c C-w
8628 @findex org-refile
8629 @vindex org-reverse-note-order
8630 @vindex org-refile-targets
8631 @vindex org-refile-use-outline-path
8632 @vindex org-outline-path-complete-in-steps
8633 @vindex org-refile-allow-creating-parent-nodes
8634 @vindex org-log-refile
8635 Refile the entry or region at point.  This command offers
8636 possible locations for refiling the entry and lets you select one
8637 with completion.  The item (or all items in the region) is filed
8638 below the target heading as a subitem.  Depending on
8639 @code{org-reverse-note-order}, it is either the first or last subitem.
8641 By default, all level 1 headlines in the current buffer are
8642 considered to be targets, but you can have more complex
8643 definitions across a number of files.  See the variable
8644 @code{org-refile-targets} for details.  If you would like to select
8645 a location via a file-path-like completion along the outline
8646 path, see the variables @code{org-refile-use-outline-path} and
8647 @code{org-outline-path-complete-in-steps}.  If you would like to be
8648 able to create new nodes as new parents for refiling on the fly,
8649 check the variable @code{org-refile-allow-creating-parent-nodes}.
8650 When the variable @code{org-log-refile}@footnote{Note the corresponding @samp{STARTUP} options @samp{logrefile},
8651 @samp{lognoterefile}, and @samp{nologrefile}.} is set, a timestamp or
8652 a note is recorded whenever an entry is refiled.
8654 @item @kbd{C-u C-c C-w}
8655 @kindex C-u C-c C-w
8656 Use the refile interface to jump to a heading.
8658 @item @kbd{C-u C-u C-c C-w} (@code{org-refile-goto-last-stored})
8659 @kindex C-u C-u C-c C-w
8660 @findex org-refile-goto-last-stored
8661 Jump to the location where @code{org-refile} last moved a tree to.
8663 @item @kbd{C-2 C-c C-w}
8664 @kindex C-2 C-c C-w
8665 Refile as the child of the item currently being clocked.
8667 @item @kbd{C-3 C-c C-w}
8668 @kindex C-3 C-c C-w
8669 @vindex org-refile-keep
8670 Refile and keep the entry in place.  Also see @code{org-refile-keep}
8671 to make this the default behavior, and beware that this may
8672 result in duplicated @code{ID} properties.
8674 @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})
8675 @kindex C-u C-u C-u C-c C-w
8676 @kindex C-0 C-c C-w
8677 @findex org-refile-cache-clear
8678 @vindex org-refile-use-cache
8679 Clear the target cache.  Caching of refile targets can be turned
8680 on by setting @code{org-refile-use-cache}.  To make the command see
8681 new possible targets, you have to clear the cache with this
8682 command.
8683 @end table
8685 @node Archiving
8686 @section Archiving
8688 @cindex archiving
8690 When a project represented by a (sub)tree is finished, you may want to
8691 move the tree out of the way and to stop it from contributing to the
8692 agenda.  Archiving is important to keep your working files compact and
8693 global searches like the construction of agenda views fast.
8695 @table @asis
8696 @item @kbd{C-c C-x C-a} (@code{org-archive-subtree-default})
8697 @kindex C-c C-x C-a
8698 @findex org-archive-subtree-default
8699 @vindex org-archive-default-command
8700 Archive the current entry using the command specified in the
8701 variable @code{org-archive-default-command}.
8702 @end table
8704 @menu
8705 * Moving subtrees::              Moving a tree to an archive file.
8706 * Internal archiving::           Switch off a tree but keep it in the file.
8707 @end menu
8709 @node Moving subtrees
8710 @subsection Moving a tree to an archive file
8712 @cindex external archiving
8714 The most common archiving action is to move a project tree to another
8715 file, the archive file.
8717 @table @asis
8718 @item @kbd{C-c C-x C-s} or short @kbd{C-c $} (@code{org-archive-subtree})
8719 @kindex C-c C-x C-s
8720 @kindex C-c $
8721 @findex org-archive-subtree
8722 @vindex org-archive-location
8723 Archive the subtree starting at the cursor position to the
8724 location given by @code{org-archive-location}.
8726 @item @kbd{C-u C-c C-x C-s}
8727 @kindex C-u C-c C-x C-s
8728 Check if any direct children of the current headline could be
8729 moved to the archive.  To do this, check each subtree for open
8730 TODO entries.  If none is found, the command offers to move it to
8731 the archive location.  If the cursor is @emph{not} on a headline when
8732 this command is invoked, check level 1 trees.
8734 @item @kbd{C-u C-u C-c C-x C-s}
8735 @kindex C-u C-u C-c C-x C-s
8736 As above, but check subtree for timestamps instead of TODO
8737 entries.  The command offers to archive the subtree if it @emph{does}
8738 contain a timestamp, and that timestamp is in the past.
8739 @end table
8741 @cindex archive locations
8742 The default archive location is a file in the same directory as the
8743 current file, with the name derived by appending @samp{_archive} to the
8744 current file name.  You can also choose what heading to file archived
8745 items under, with the possibility to add them to a datetree in a file.
8746 For information and examples on how to specify the file and the
8747 heading, see the documentation string of the variable
8748 @code{org-archive-location}.
8750 There is also an in-buffer option for setting this variable, for
8751 example:
8753 @cindex @samp{ARCHIVE}, keyword
8754 @example
8755 #+ARCHIVE: %s_done::
8756 @end example
8758 @noindent
8759 @cindex ARCHIVE, property
8760 If you would like to have a special archive location for a single
8761 entry or a (sub)tree, give the entry an @samp{ARCHIVE} property with the
8762 location as the value (see @ref{Properties and Columns}).
8764 @vindex org-archive-save-context-info
8765 When a subtree is moved, it receives a number of special properties
8766 that record context information like the file from where the entry
8767 came, its outline path the archiving time etc.  Configure the variable
8768 @code{org-archive-save-context-info} to adjust the amount of information
8769 added.
8771 @node Internal archiving
8772 @subsection Internal archiving
8774 @cindex @samp{ARCHIVE}, tag
8775 If you want to just switch off---for agenda views---certain subtrees
8776 without moving them to a different file, you can use the @samp{ARCHIVE}
8777 tag.
8779 A headline that is marked with the @samp{ARCHIVE} tag (see @ref{Tags}) stays at
8780 its location in the outline tree, but behaves in the following way:
8782 @itemize
8783 @item
8784 @vindex org-cycle-open-archived-trees
8785 It does not open when you attempt to do so with a visibility cycling
8786 command (see @ref{Visibility Cycling}).  You can force cycling archived
8787 subtrees with @kbd{C-@key{TAB}}, or by setting the option
8788 @code{org-cycle-open-archived-trees}.  Also normal outline commands, like
8789 @code{outline-show-all}, open archived subtrees.
8791 @item
8792 @vindex org-sparse-tree-open-archived-trees
8793 During sparse tree construction (see @ref{Sparse Trees}), matches in
8794 archived subtrees are not exposed, unless you configure the option
8795 @code{org-sparse-tree-open-archived-trees}.
8797 @item
8798 @vindex org-agenda-skip-archived-trees
8799 During agenda view construction (see @ref{Agenda Views}), the content of
8800 archived trees is ignored unless you configure the option
8801 @code{org-agenda-skip-archived-trees}, in which case these trees are
8802 always included.  In the agenda you can press @kbd{v a} to get
8803 archives temporarily included.
8805 @item
8806 @vindex org-export-with-archived-trees
8807 Archived trees are not exported (see @ref{Exporting}), only the headline
8808 is.  Configure the details using the variable
8809 @code{org-export-with-archived-trees}.
8811 @item
8812 @vindex org-columns-skip-archived-trees
8813 Archived trees are excluded from column view unless the variable
8814 @code{org-columns-skip-archived-trees} is configured to @code{nil}.
8815 @end itemize
8817 The following commands help manage the @samp{ARCHIVE} tag:
8819 @table @asis
8820 @item @kbd{C-c C-x a} (@code{org-toggle-archive-tag})
8821 @kindex C-c C-x a
8822 @findex org-toggle-archive-tag
8823 Toggle the archive tag for the current headline.  When the tag is
8824 set, the headline changes to a shadowed face, and the subtree
8825 below it is hidden.
8827 @item @kbd{C-u C-c C-x a}
8828 @kindex C-u C-c C-x a
8829 Check if any direct children of the current headline should be
8830 archived.  To do this, check each subtree for open TODO entries.
8831 If none is found, the command offers to set the @samp{ARCHIVE} tag for
8832 the child.  If the cursor is @emph{not} on a headline when this
8833 command is invoked, check the level 1 trees.
8835 @item @kbd{C-@key{TAB}}, @code{org-force-cycle-archived}
8836 @kindex C-TAB
8837 Cycle a tree even if it is tagged with @samp{ARCHIVE}.
8839 @item @kbd{C-c C-x A} (@code{org-archive-to-archive-sibling})
8840 @kindex C-c C-x A
8841 @findex org-archive-to-archive-sibling
8842 Move the current entry to the @emph{Archive Sibling}.  This is
8843 a sibling of the entry with the heading @samp{Archive} and the archive
8844 tag.  The entry becomes a child of that sibling and in this way
8845 retains a lot of its original context, including inherited tags
8846 and approximate position in the outline.
8847 @end table
8849 @node Agenda Views
8850 @chapter Agenda Views
8852 @cindex agenda views
8854 Due to the way Org works, TODO items, time-stamped items, and tagged
8855 headlines can be scattered throughout a file or even a number of
8856 files.  To get an overview of open action items, or of events that are
8857 important for a particular date, this information must be collected,
8858 sorted and displayed in an organized way.
8860 Org can select items based on various criteria and display them in
8861 a separate buffer.  Seven different view types are provided:
8863 @itemize
8864 @item
8865 an @emph{agenda} that is like a calendar and shows information for
8866 specific dates,
8868 @item
8869 a @emph{TODO list} that covers all unfinished action items,
8871 @item
8872 a @emph{match view}, showings headlines based on the tags, properties,
8873 and TODO state associated with them,
8875 @item
8876 a @emph{timeline view} that shows all events in a single Org file, in
8877 time-sorted view,
8879 @item
8880 a @emph{text search view} that shows all entries from multiple files that
8881 contain specified keywords,
8883 @item
8884 a @emph{stuck projects view} showing projects that currently do not move
8885 along, and
8887 @item
8888 @emph{custom views} that are special searches and combinations of
8889 different views.
8890 @end itemize
8892 @noindent
8893 The extracted information is displayed in a special @emph{agenda buffer}.
8894 This buffer is read-only, but provides commands to visit the
8895 corresponding locations in the original Org files, and even to edit
8896 these files remotely.
8898 @vindex org-agenda-skip-comment-trees
8899 @vindex org-agenda-skip-archived-trees
8900 @cindex commented entries, in agenda views
8901 @cindex archived entries, in agenda views
8902 By default, the report ignores commented (see @ref{Comment Lines}) and
8903 archived (see @ref{Internal archiving}) entries.  You can override this by
8904 setting @code{org-agenda-skip-comment-trees} and
8905 @code{org-agenda-skip-archived-trees} to @code{nil}.
8907 @vindex org-agenda-window-setup
8908 @vindex org-agenda-restore-windows-after-quit
8909 Two variables control how the agenda buffer is displayed and whether
8910 the window configuration is restored when the agenda exits:
8911 @code{org-agenda-window-setup} and @code{org-agenda-restore-windows-after-quit}.
8913 @menu
8914 * Agenda Files::                 Files being searched for agenda information.
8915 * Agenda Dispatcher::            Keyboard access to agenda views.
8916 * Built-in Agenda Views::        What is available out of the box?
8917 * Presentation and Sorting::     How agenda items are prepared for display.
8918 * Agenda Commands::              Remote editing of Org trees.
8919 * Custom Agenda Views::          Defining special searches and views.
8920 * Exporting Agenda Views::       Writing a view to a file.
8921 * Agenda Column View::           Using column view for collected entries.
8922 @end menu
8924 @node Agenda Files
8925 @section Agenda Files
8927 @cindex agenda files
8928 @cindex files for agenda
8930 @vindex org-agenda-files
8931 The information to be shown is normally collected from all @emph{agenda
8932 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
8933 name, then the list of agenda files in maintained in that external
8934 file.}.
8935 If a directory is part of this list, all files with the extension
8936 @samp{.org} in this directory are part of the list.
8938 Thus, even if you only work with a single Org file, that file should
8939 be put into the list@footnote{When using the dispatcher, pressing @kbd{<} before
8940 selecting a command actually limits the command to the current file,
8941 and ignores @code{org-agenda-files} until the next dispatcher command.}.  You can customize @code{org-agenda-files},
8942 but the easiest way to maintain it is through the following commands
8944 @table @asis
8945 @item @kbd{C-c [} (@code{org-agenda-file-to-front})
8946 @kindex C-c [
8947 @findex org-agenda-file-to-front
8948 @cindex files, adding to agenda list
8949 Add current file to the list of agenda files.  The file is added
8950 to the front of the list.  If it was already in the list, it is
8951 moved to the front.  With a prefix argument, file is added/moved
8952 to the end.
8954 @item @kbd{C-c ]} (@code{org-remove-file})
8955 @kindex C-c ]
8956 @findex org-remove-file
8957 Remove current file from the list of agenda files.
8959 @item @kbd{C-'}
8960 @itemx @kbd{C-,} (@code{org-cycle-agenda-files})
8961 @kindex C-'
8962 @kindex C-,
8963 @findex org-cycle-agenda-files
8964 @cindex cycling, of agenda files
8965 Cycle through agenda file list, visiting one file after the other.
8967 @item @kbd{M-x org-switchb}
8968 @findex org-switchb
8969 Command to use an iswitchb-like interface to switch to and
8970 between Org buffers.
8971 @end table
8973 @noindent
8974 The Org menu contains the current list of files and can be used to
8975 visit any of them.
8977 If you would like to focus the agenda temporarily on a file not in
8978 this list, or on just one file in the list, or even on only a subtree
8979 in a file, then this can be done in different ways.  For a single
8980 agenda command, you may press @kbd{<} once or several times in
8981 the dispatcher (see @ref{Agenda Dispatcher}).  To restrict the agenda
8982 scope for an extended period, use the following commands:
8984 @table @asis
8985 @item @kbd{C-c C-x <} (@code{org-agenda-set-restriction-lock})
8986 @kindex C-c C-x <
8987 @findex org-agenda-set-restriction-lock
8988 Permanently restrict the agenda to the current subtree.  When
8989 called with a prefix argument, or with the cursor before the
8990 first headline in a file, set the agenda scope to the entire
8991 file.  This restriction remains in effect until removed with
8992 @kbd{C-c C-x >}, or by typing either @kbd{<} or
8993 @kbd{>} in the agenda dispatcher.  If there is a window
8994 displaying an agenda view, the new restriction takes effect
8995 immediately.
8997 @item @kbd{C-c C-x >} (@code{org-agenda-remove-restriction-lock})
8998 @kindex C-c C-x >
8999 @findex org-agenda-remove-restriction-lock
9000 Remove the permanent restriction created by @kbd{C-c C-x <}.
9001 @end table
9003 @noindent
9004 When working with @samp{speedbar.el}, you can use the following commands in
9005 the Speedbar frame:
9007 @table @asis
9008 @item @kbd{<} (@code{org-speedbar-set-agenda-restriction})
9009 @findex org-speedbar-set-agenda-restriction
9010 Permanently restrict the agenda to the item---either an Org file
9011 or a subtree in such a file---at the cursor in the Speedbar
9012 frame.  If there is a window displaying an agenda view, the new
9013 restriction takes effect immediately.
9015 @item @kbd{>} (@code{org-agenda-remove-restriction-lock})
9016 @findex org-agenda-remove-restriction-lock
9017 Lift the restriction.
9018 @end table
9020 @node Agenda Dispatcher
9021 @section The Agenda Dispatcher
9023 @cindex agenda dispatcher
9024 @cindex dispatching agenda commands
9026 The views are created through a dispatcher, accessible with @kbd{M-x org-agenda}, or, better, bound to a global key (see @ref{Activation}).
9027 It displays a menu from which an additional letter is required to
9028 execute a command.  The dispatcher offers the following default
9029 commands:
9031 @table @asis
9032 @item @kbd{a}
9033 Create the calendar-like agenda (see @ref{Weekly/daily agenda}).
9035 @item @kbd{t} or @kbd{T}
9036 Create a list of all TODO items (see @ref{Global TODO list}).
9038 @item @kbd{m} or @kbd{M}
9039 Create a list of headlines matching a given expression (see
9040 @ref{Matching tags and properties}).
9042 @item @kbd{s}
9043 @kindex s @r{(Agenda dispatcher)}
9044 Create a list of entries selected by a boolean expression of
9045 keywords and/or regular expressions that must or must not occur
9046 in the entry.
9048 @item @kbd{/}
9049 @kindex / @r{(Agenda dispatcher)}
9050 @vindex org-agenda-text-search-extra-files
9051 Search for a regular expression in all agenda files and
9052 additionally in the files listed in
9053 @code{org-agenda-text-search-extra-files}.  This uses the Emacs
9054 command @code{multi-occur}.  A prefix argument can be used to specify
9055 the number of context lines for each match, default is
9056 @enumerate
9057 @item
9058 @end enumerate
9060 @item @kbd{#} or @kbd{!}
9061 Create a list of stuck projects (see @ref{Stuck projects}).
9063 @item @kbd{<}
9064 @kindex < @r{(Agenda dispatcher)}
9065 Restrict an agenda command to the current buffer@footnote{For backward compatibility, you can also press @kbd{1} to
9066 restrict to the current buffer.}.  After
9067 pressing @kbd{<}, you still need to press the character
9068 selecting the command.
9070 @item @kbd{< <}
9071 @kindex < < @r{(Agenda dispatcher)}
9072 If there is an active region, restrict the following agenda
9073 command to the region.  Otherwise, restrict it to the current
9074 subtree@footnote{For backward compatibility, you can also press @kbd{0} to
9075 restrict to the current region/subtree.}.  After pressing @kbd{< <}, you still need to
9076 press the character selecting the command.
9078 @item @kbd{*}
9079 @kindex * @r{(Agenda dispatcher)}
9080 @vindex org-agenda-sticky
9081 @findex org-toggle-sticky-agenda
9082 Toggle sticky agenda views.  By default, Org maintains only
9083 a single agenda buffer and rebuilds it each time you change the
9084 view, to make sure everything is always up to date.  If you
9085 switch between views often and the build time bothers you, you
9086 can turn on sticky agenda buffers (make this the default by
9087 customizing the variable @code{org-agenda-sticky}).  With sticky
9088 agendas, the dispatcher only switches to the selected view, you
9089 need to update it by hand with @kbd{r} or @kbd{g}.  You
9090 can toggle sticky agenda view any time with
9091 @code{org-toggle-sticky-agenda}.
9092 @end table
9094 You can also define custom commands that are accessible through the
9095 dispatcher, just like the default commands.  This includes the
9096 possibility to create extended agenda buffers that contain several
9097 blocks together, for example the weekly agenda, the global TODO list
9098 and a number of special tags matches.  See @ref{Custom Agenda Views}.
9100 @node Built-in Agenda Views
9101 @section The Built-in Agenda Views
9103 In this section we describe the built-in views.
9105 @menu
9106 * Weekly/daily agenda::          The calendar page with current tasks.
9107 * Global TODO list::             All unfinished action items.
9108 * Matching tags and properties:: Structured information with fine-tuned search.
9109 * Search view::                  Find entries by searching for text.
9110 * Stuck projects::               Find projects you need to review.
9111 @end menu
9113 @node Weekly/daily agenda
9114 @subsection Weekly/daily agenda
9116 @cindex agenda
9117 @cindex weekly agenda
9118 @cindex daily agenda
9120 The purpose of the weekly/daily @emph{agenda} is to act like a page of
9121 a paper agenda, showing all the tasks for the current week or day.
9123 @table @asis
9124 @item @kbd{M-x org-agenda a} (@code{org-agenda-list})
9125 @kindex a @r{(Agenda dispatcher)}
9126 @findex org-agenda-list
9127 @cindex org-agenda, command
9128 Compile an agenda for the current week from a list of Org files.
9129 The agenda shows the entries for each day.  With a numeric prefix
9130 argument@footnote{For backward compatibility, the universal prefix argument
9131 @kbd{C-u} causes all TODO entries to be listed before the agenda.
9132 This feature is deprecated, use the dedicated TODO list, or a block
9133 agenda instead (see @ref{Block agenda}).}---like @kbd{C-u 2 1 M-x org-agenda a}---you
9134 may set the number of days to be displayed.
9135 @end table
9137 @vindex org-agenda-span
9138 @vindex org-agenda-start-day
9139 @vindex org-agenda-start-on-weekday
9140 The default number of days displayed in the agenda is set by the
9141 variable @code{org-agenda-span}.  This variable can be set to any number of
9142 days you want to see by default in the agenda, or to a span name, such
9143 a @code{day}, @code{week}, @code{month} or @code{year}.  For weekly agendas, the default
9144 is to start on the previous Monday (see
9145 @code{org-agenda-start-on-weekday}).  You can also set the start date using
9146 a date shift: @code{(setq org-agenda-start-day "+10d")} starts the agenda
9147 ten days from today in the future.
9149 Remote editing from the agenda buffer means, for example, that you can
9150 change the dates of deadlines and appointments from the agenda buffer.
9151 The commands available in the Agenda buffer are listed in @ref{Agenda Commands}.
9153 @anchor{Calendar/Diary integration}
9154 @subsubheading Calendar/Diary integration
9156 @cindex calendar integration
9157 @cindex diary integration
9159 Emacs contains the calendar and diary by Edward M. Reingold.  The
9160 calendar displays a three-month calendar with holidays from different
9161 countries and cultures.  The diary allows you to keep track of
9162 anniversaries, lunar phases, sunrise/set, recurrent appointments
9163 (weekly, monthly) and more.  In this way, it is quite complementary to
9164 Org.  It can be very useful to combine output from Org with the diary.
9166 In order to include entries from the Emacs diary into Org mode's
9167 agenda, you only need to customize the variable
9169 @lisp
9170 (setq org-agenda-include-diary t)
9171 @end lisp
9173 @noindent
9174 After that, everything happens automatically.  All diary entries
9175 including holidays, anniversaries, etc., are included in the agenda
9176 buffer created by Org mode.  @kbd{@key{SPC}}, @kbd{@key{TAB}}, and
9177 @kbd{@key{RET}} can be used from the agenda buffer to jump to the diary
9178 file in order to edit existing diary entries.  The @kbd{i}
9179 command to insert new entries for the current date works in the agenda
9180 buffer, as well as the commands @kbd{S}, @kbd{M}, and
9181 @kbd{C} to display Sunrise/Sunset times, show lunar phases and to
9182 convert to other calendars, respectively.  @kbd{c} can be used to
9183 switch back and forth between calendar and agenda.
9185 If you are using the diary only for S-exp entries and holidays, it is
9186 faster to not use the above setting, but instead to copy or even move
9187 the entries into an Org file.  Org mode evaluates diary-style sexp
9188 entries, and does it faster because there is no overhead for first
9189 creating the diary display.  Note that the sexp entries must start at
9190 the left margin, no whitespace is allowed before them, as seen in the
9191 following segment of an Org file:@footnote{The variable @code{org-anniversary} used in the example is just
9192 like @code{diary-anniversary}, but the argument order is always according
9193 to ISO and therefore independent of the value of
9194 @code{calendar-date-style}.}
9196 @example
9197 * Holidays
9198   :PROPERTIES:
9199   :CATEGORY: Holiday
9200   :END:
9201 %%(org-calendar-holiday)   ; special function for holiday names
9203 * Birthdays
9204   :PROPERTIES:
9205   :CATEGORY: Ann
9206   :END:
9207 %%(org-anniversary 1956  5 14) Arthur Dent is %d years old
9208 %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
9209 @end example
9211 @anchor{Anniversaries from BBDB}
9212 @subsubheading Anniversaries from BBDB
9214 @cindex BBDB, anniversaries
9215 @cindex anniversaries, from BBDB
9217 @findex org-bbdb-anniversaries
9218 If you are using the Insidious Big Brother Database to store your
9219 contacts, you very likely prefer to store anniversaries in BBDB rather
9220 than in a separate Org or diary file.  Org supports this and can show
9221 BBDB anniversaries as part of the agenda.  All you need to do is to
9222 add the following to one of your agenda files:
9224 @example
9225 * Anniversaries
9226   :PROPERTIES:
9227   :CATEGORY: Anniv
9228   :END:
9229 %%(org-bbdb-anniversaries)
9230 @end example
9232 You can then go ahead and define anniversaries for a BBDB record.
9233 Basically, you need to press @kbd{C-o anniversary @key{RET}} with the
9234 cursor in a BBDB record and then add the date in the format
9235 @samp{YYYY-MM-DD} or @samp{MM-DD}, followed by a space and the class of the
9236 anniversary (@samp{birthday}, @samp{wedding}, or a format string).  If you omit
9237 the class, it defaults to @samp{birthday}.  Here are a few examples, the
9238 header for the file @samp{org-bbdb.el} contains more detailed information.
9240 @example
9241 1973-06-22
9242 06-22
9243 1955-08-02 wedding
9244 2008-04-14 %s released version 6.01 of Org mode, %d years ago
9245 @end example
9247 After a change to BBDB, or for the first agenda display during an
9248 Emacs session, the agenda display suffers a short delay as Org updates
9249 its hash with anniversaries.  However, from then on things will be
9250 very fast, much faster in fact than a long list of
9251 @samp{%%(diary-anniversary)} entries in an Org or Diary file.
9253 @findex org-bbdb-anniversaries-future
9254 If you would like to see upcoming anniversaries with a bit of
9255 forewarning, you can use the following instead:
9257 @example
9258 * Anniversaries
9259   :PROPERTIES:
9260   :CATEGORY: Anniv
9261   :END:
9262 %%(org-bbdb-anniversaries-future 3)
9263 @end example
9265 That will give you three days' warning: on the anniversary date itself
9266 and the two days prior.  The argument is optional: if omitted, it
9267 defaults to 7.
9269 @anchor{Appointment reminders}
9270 @subsubheading Appointment reminders
9272 @cindex @file{appt.el}
9273 @cindex appointment reminders
9274 @cindex appointment
9275 @cindex reminders
9277 @cindex APPT_WARNTIME, keyword
9278 Org can interact with Emacs appointments notification facility.  To
9279 add the appointments of your agenda files, use the command
9280 @code{org-agenda-to-appt}.  This command lets you filter through the list
9281 of your appointments and add only those belonging to a specific
9282 category or matching a regular expression.  It also reads
9283 a @samp{APPT_WARNTIME} property which overrides the value of
9284 @code{appt-message-warning-time} for this appointment.  See the docstring
9285 for details.
9287 @node Global TODO list
9288 @subsection The global TODO list
9290 @cindex global TODO list
9291 @cindex TODO list, global
9293 The global TODO list contains all unfinished TODO items formatted and
9294 collected into a single place.
9296 @table @asis
9297 @item @kbd{M-x org-agenda t} (@code{org-todo-list})
9298 @kindex t @r{(Agenda dispatcher)}
9299 @findex org-todo-list
9300 Show the global TODO list.  This collects the TODO items from all
9301 agenda files (see @ref{Agenda Views}) into a single buffer.  By
9302 default, this lists items with a state the is not a DONE state.
9303 The buffer is in @code{agenda-mode}, so there are commands to examine
9304 and manipulate the TODO entries directly from that buffer (see
9305 @ref{Agenda Commands}).
9307 @item @kbd{M-x org-agenda T} (@code{org-todo-list})
9308 @kindex T @r{(Agenda dispatcher)}
9309 @findex org-todo-list
9310 @cindex TODO keyword matching
9311 @vindex org-todo-keywords
9312 Like the above, but allows selection of a specific TODO keyword.
9313 You can also do this by specifying a prefix argument to
9314 @kbd{t}.  You are prompted for a keyword, and you may also
9315 specify several keywords by separating them with @samp{|} as the
9316 boolean OR operator.  With a numeric prefix, the Nth keyword in
9317 @code{org-todo-keywords} is selected.
9319 @kindex r
9320 The @kbd{r} key in the agenda buffer regenerates it, and you
9321 can give a prefix argument to this command to change the selected
9322 TODO keyword, for example @kbd{3 r}.  If you often need
9323 a search for a specific keyword, define a custom command for it
9324 (see @ref{Agenda Dispatcher}).
9326 Matching specific TODO keywords can also be done as part of
9327 a tags search (see @ref{Tag Searches}).
9328 @end table
9330 Remote editing of TODO items means that you can change the state of
9331 a TODO entry with a single key press.  The commands available in the
9332 TODO list are described in @ref{Agenda Commands}.
9334 @cindex sublevels, inclusion into TODO list
9335 Normally the global TODO list simply shows all headlines with TODO
9336 keywords.  This list can become very long.  There are two ways to keep
9337 it more compact:
9339 @itemize
9340 @item
9341 @vindex org-agenda-todo-ignore-scheduled
9342 @vindex org-agenda-todo-ignore-deadlines
9343 @vindex org-agenda-todo-ignore-timestamp
9344 @vindex org-agenda-todo-ignore-with-date
9345 Some people view a TODO item that has been @emph{scheduled} for execution
9346 or have a @emph{deadline} (see @ref{Timestamps}) as
9347 no longer @emph{open}.  Configure the variables
9348 @code{org-agenda-todo-ignore-scheduled},
9349 @code{org-agenda-todo-ignore-deadlines},
9350 @code{org-agenda-todo-ignore-timestamp} and/or
9351 @code{org-agenda-todo-ignore-with-date} to exclude such items from the
9352 global TODO list.
9354 @item
9355 @vindex org-agenda-todo-list-sublevels
9356 TODO items may have sublevels to break up the task into subtasks.
9357 In such cases it may be enough to list only the highest level TODO
9358 headline and omit the sublevels from the global list.  Configure the
9359 variable @code{org-agenda-todo-list-sublevels} to get this behavior.
9360 @end itemize
9362 @node Matching tags and properties
9363 @subsection Matching tags and properties
9365 @cindex matching, of tags
9366 @cindex matching, of properties
9367 @cindex tags view
9368 @cindex match view
9370 If headlines in the agenda files are marked with @emph{tags} (see @ref{Tags}),
9371 or have properties (see @ref{Properties and Columns}), you can select
9372 headlines based on this metadata and collect them into an agenda
9373 buffer.  The match syntax described here also applies when creating
9374 sparse trees with @kbd{C-c / m}.
9376 @table @asis
9377 @item @kbd{M-x org-agenda m} (@code{org-tags-view})
9378 @kindex m @r{(Agenda dispatcher)}
9379 @findex org-tags-view
9380 Produce a list of all headlines that match a given set of tags.
9381 The command prompts for a selection criterion, which is a boolean
9382 logic expression with tags, like @samp{+work+urgent-withboss} or
9383 @samp{work|home} (see @ref{Tags}).  If you often need a specific search,
9384 define a custom command for it (see @ref{Agenda Dispatcher}).
9386 @item @kbd{M-x org-agenda M} (@code{org-tags-view})
9387 @kindex M @r{(Agenda dispatcher)}
9388 @findex org-tags-view
9389 @vindex org-tags-match-list-sublevels
9390 @vindex org-agenda-tags-todo-honor-ignore-options
9391 Like @kbd{m}, but only select headlines that are also TODO
9392 items and force checking subitems (see the variable
9393 @code{org-tags-match-list-sublevels}).  To exclude scheduled/deadline
9394 items, see the variable
9395 @code{org-agenda-tags-todo-honor-ignore-options}.  Matching specific
9396 TODO keywords together with a tags match is also possible, see
9397 @ref{Tag Searches}.
9398 @end table
9400 The commands available in the tags list are described in @ref{Agenda Commands}.
9402 @cindex boolean logic, for agenda searches
9403 A search string can use Boolean operators @samp{&} for AND and @samp{|} for OR.
9404 @samp{&} binds more strongly than @samp{|}.  Parentheses are currently not
9405 implemented.  Each element in the search is either a tag, a regular
9406 expression matching tags, or an expression like @samp{PROPERTY OPERATOR
9407 VALUE} with a comparison operator, accessing a property value.  Each
9408 element may be preceded by @samp{-} to select against it, and @samp{+} is
9409 syntactic sugar for positive selection.  The AND operator @samp{&} is
9410 optional when @samp{+} or @samp{-} is present.  Here are some examples, using
9411 only tags.
9413 @table @asis
9414 @item @code{+work-boss}
9415 Select headlines tagged @samp{work}, but discard those also tagged
9416 @samp{boss}.
9418 @item @code{work|laptop}
9419 Selects lines tagged @samp{work} or @samp{laptop}.
9421 @item @code{work|laptop+night}
9422 Like before, but require the @samp{laptop} lines to be tagged
9423 also @samp{night}.
9424 @end table
9426 @cindex regular expressions, with tags search
9427 Instead of a tag, you may also specify a regular expression enclosed
9428 in curly braces.  For example, @samp{work+@{^boss.*@}} matches headlines that
9429 contain the tag @samp{:work:} and any tag @emph{starting} with @samp{boss}.
9431 @cindex group tags, as regular expressions
9432 Group tags (see @ref{Tag Hierarchy}) are expanded as regular expressions.
9433 E.g., if @samp{work} is a group tag for the group @samp{:work:lab:conf:}, then
9434 searching for @samp{work} also searches for @samp{@{\(?:work\|lab\|conf\)@}} and
9435 searching for @samp{-work} searches for all headlines but those with one of
9436 the tags in the group (i.e., @samp{-@{\(?:work\|lab\|conf\)@}}).
9438 @cindex TODO keyword matching, with tags search
9439 @cindex level, for tags/property match
9440 @cindex category, for tags/property match
9441 @vindex org-odd-levels-only
9442 You may also test for properties (see @ref{Properties and Columns}) at the
9443 same time as matching tags.  The properties may be real properties, or
9444 special properties that represent other metadata (see @ref{Special Properties}).  For example, the property @samp{TODO} represents the TODO
9445 keyword of the entry.  Or, the property @samp{LEVEL} represents the level
9446 of an entry.  So searching @samp{+LEVEL=3+boss-TODO​="DONE"} lists all level
9447 three headlines that have the tag @samp{boss} and are @emph{not} marked with the
9448 TODO keyword @samp{DONE}.  In buffers with @code{org-odd-levels-only} set,
9449 @samp{LEVEL} does not count the number of stars, but @samp{LEVEL=2} corresponds
9450 to 3 stars etc.
9452 Here are more examples:
9454 @table @asis
9455 @item @samp{work+TODO​="WAITING"}
9456 Select @samp{work}-tagged TODO lines with the specific TODO keyword
9457 @samp{WAITING}.
9459 @item @samp{work+TODO​="WAITING"|home+TODO​="WAITING"}
9460 Waiting tasks both at work and at home.
9461 @end table
9463 When matching properties, a number of different operators can be used
9464 to test the value of a property.  Here is a complex example:
9466 @example
9467 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2
9468          +With=@{Sarah|Denny@}+SCHEDULED>="<2008-10-11>"
9469 @end example
9471 @noindent
9472 The type of comparison depends on how the comparison value is written:
9474 @itemize
9475 @item
9476 If the comparison value is a plain number, a numerical comparison is
9477 done, and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=}, @samp{>=}, and
9478 @samp{<>}.
9480 @item
9481 If the comparison value is enclosed in double-quotes, a string
9482 comparison is done, and the same operators are allowed.
9484 @item
9485 If the comparison value is enclosed in double-quotes @emph{and} angular
9486 brackets (like @samp{DEADLINE<​="<2008-12-24 18:30>"}), both values are
9487 assumed to be date/time specifications in the standard Org way, and
9488 the comparison is done accordingly.  Valid values also include
9489 @samp{"<now>"} for now (including time), @samp{"<today>"}, and @samp{"<tomorrow>"}
9490 for these days at 0:00 hours, i.e., without a time specification.
9491 You can also use strings like @samp{"<+5d>"} or @samp{"<-2m>"} with units @samp{d},
9492 @samp{w}, @samp{m}, and @samp{y} for day, week, month, and year, respectively.
9494 @item
9495 If the comparison value is enclosed in curly braces, a regexp match
9496 is performed, with @samp{=} meaning that the regexp matches the property
9497 value, and @samp{<>} meaning that it does not match.
9498 @end itemize
9500 So the search string in the example finds entries tagged @samp{work} but
9501 not @samp{boss}, which also have a priority value @samp{A}, a @samp{Coffee} property
9502 with the value @samp{unlimited}, an @samp{EFFORT} property that is numerically
9503 smaller than 2, a @samp{With} property that is matched by the regular
9504 expression @samp{Sarah|Denny}, and that are scheduled on or after October
9505 11, 2008.
9507 You can configure Org mode to use property inheritance during
9508 a search, but beware that this can slow down searches considerably.
9509 See @ref{Property Inheritance}, for details.
9511 For backward compatibility, and also for typing speed, there is also
9512 a different way to test TODO states in a search.  For this, terminate
9513 the tags/property part of the search string (which may include several
9514 terms connected with @samp{|}) with a @samp{/} and then specify a Boolean
9515 expression just for TODO keywords.  The syntax is then similar to that
9516 for tags, but should be applied with care: for example, a positive
9517 selection on several TODO keywords cannot meaningfully be combined
9518 with boolean AND.  However, @emph{negative selection} combined with AND can
9519 be meaningful.  To make sure that only lines are checked that actually
9520 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
9521 with @samp{!}.  Using @kbd{M-x org-agenda M} or @samp{/!} does not match
9522 TODO keywords in a DONE state.  Examples:
9524 @table @asis
9525 @item @samp{work/WAITING}
9526 Same as @samp{work+TODO​="WAITING"}.
9528 @item @samp{work/!-WAITING-NEXT}
9529 Select @samp{work}-tagged TODO lines that are neither @samp{WAITING} nor
9530 @samp{NEXT}.
9532 @item @samp{work/!+WAITING|+NEXT}
9533 Select @samp{work}-tagged TODO lines that are either @samp{WAITING} or
9534 @samp{NEXT}.
9535 @end table
9537 @node Search view
9538 @subsection Search view
9540 @cindex search view
9541 @cindex text search
9542 @cindex searching, for text
9544 This agenda view is a general text search facility for Org mode
9545 entries.  It is particularly useful to find notes.
9547 @table @asis
9548 @item @kbd{M-x org-agenda s} (@code{org-search-view})
9549 @kindex s @r{(Agenda dispatcher)}
9550 @findex org-search-view
9551 This is a special search that lets you select entries by matching
9552 a substring or specific words using a boolean logic.
9553 @end table
9555 For example, the search string @samp{computer equipment} matches entries
9556 that contain @samp{computer equipment} as a substring, even if the two
9557 words are separated by more space or a line break.
9559 Search view can also search for specific keywords in the entry, using
9560 Boolean logic.  The search string @samp{+computer
9561 +wifi -ethernet -@{8\.11[bg]@}} matches note entries that contain the
9562 keywords @samp{computer} and @samp{wifi}, but not the keyword @samp{ethernet}, and
9563 which are also not matched by the regular expression @samp{8\.11[bg]},
9564 meaning to exclude both @samp{8.11b} and @samp{8.11g}.  The first @samp{+} is
9565 necessary to turn on boolean search, other @samp{+} characters are
9566 optional.  For more details, see the docstring of the command
9567 @code{org-search-view}.
9569 You can incrementally adjust a boolean search with the following keys
9571 @multitable @columnfractions 0.1 0.6
9572 @item @kbd{[}
9573 @tab Add a positive search word
9574 @item @kbd{]}
9575 @tab Add a negative search word
9576 @item @kbd{@{}
9577 @tab Add a positive regular expression
9578 @item @kbd{@}}
9579 @tab Add a negative regular expression
9580 @end multitable
9582 @vindex org-agenda-text-search-extra-files
9583 Note that in addition to the agenda files, this command also searches
9584 the files listed in @code{org-agenda-text-search-extra-files}.
9586 @node Stuck projects
9587 @subsection Stuck projects
9589 @pindex GTD, Getting Things Done
9591 If you are following a system like David Allen's GTD to organize your
9592 work, one of the ``duties'' you have is a regular review to make sure
9593 that all projects move along.  A @emph{stuck} project is a project that has
9594 no defined next actions, so it never shows up in the TODO lists Org
9595 mode produces.  During the review, you need to identify such projects
9596 and define next actions for them.
9598 @table @asis
9599 @item @kbd{M-x org-agenda #} (@code{org-agenda-list-stuck-projects})
9600 @kindex # @r{(Agenda dispatcher)}
9601 @findex org-agenda-list-stuck-projects
9602 List projects that are stuck.
9604 @item @kbd{M-x org-agenda !}
9605 @kindex ! @r{(Agenda dispatcher)}
9606 @vindex org-stuck-projects
9607 Customize the variable @code{org-stuck-projects} to define what
9608 a stuck project is and how to find it.
9609 @end table
9611 You almost certainly need to configure this view before it works for
9612 you.  The built-in default assumes that all your projects are level-2
9613 headlines, and that a project is not stuck if it has at least one
9614 entry marked with a TODO keyword @samp{TODO} or @samp{NEXT} or @samp{NEXTACTION}.
9616 Let's assume that you, in your own way of using Org mode, identify
9617 projects with a tag @samp{:PROJECT:}, and that you use a TODO keyword
9618 @samp{MAYBE} to indicate a project that should not be considered yet.
9619 Let's further assume that the TODO keyword @samp{DONE} marks finished
9620 projects, and that @samp{NEXT} and @samp{TODO} indicate next actions.  The tag
9621 @samp{:@@shop:} indicates shopping and is a next action even without the
9622 NEXT tag.  Finally, if the project contains the special word @samp{IGNORE}
9623 anywhere, it should not be listed either.  In this case you would
9624 start by identifying eligible projects with a tags/TODO match (see
9625 @ref{Tag Searches}) @samp{+PROJECT/-MAYBE-DONE}, and then check for @samp{TODO},
9626 @samp{NEXT}, @samp{@@shop}, and @samp{IGNORE} in the subtree to identify projects that
9627 are not stuck.  The correct customization for this is:
9629 @lisp
9630 (setq org-stuck-projects
9631       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@shop")
9632         "\\<IGNORE\\>"))
9633 @end lisp
9635 Note that if a project is identified as non-stuck, the subtree of this
9636 entry is searched for stuck projects.
9638 @node Presentation and Sorting
9639 @section Presentation and Sorting
9641 @cindex presentation, of agenda items
9643 @vindex org-agenda-prefix-format
9644 @vindex org-agenda-tags-column
9645 Before displaying items in an agenda view, Org mode visually prepares
9646 the items and sorts them.  Each item occupies a single line.  The line
9647 starts with a @emph{prefix} that contains the @emph{category} (see @ref{Categories})
9648 of the item and other important information.  You can customize in
9649 which column tags are displayed through @code{org-agenda-tags-column}.  You
9650 can also customize the prefix using the option
9651 @code{org-agenda-prefix-format}.  This prefix is followed by a cleaned-up
9652 version of the outline headline associated with the item.
9654 @menu
9655 * Categories::                   Not all tasks are equal.
9656 * Time-of-day specifications::   How the agenda knows the time.
9657 * Sorting of agenda items::      The order of things.
9658 * Filtering/limiting agenda times:: Dynamically narrow the agenda.
9659 @end menu
9661 @node Categories
9662 @subsection Categories
9664 @cindex category
9665 @cindex @samp{CATEGORY}, keyword
9667 The category is a broad label assigned to each agenda item.  By
9668 default, the category is simply derived from the file name, but you
9669 can also specify it with a special line in the buffer, like
9670 this:
9672 @example
9673 #+CATEGORY: Thesis
9674 @end example
9676 @noindent
9677 @cindex @samp{CATEGORY}, property
9678 If you would like to have a special category for a single entry or
9679 a (sub)tree, give the entry a @samp{CATEGORY} property with the special
9680 category you want to apply as the value.
9682 @noindent
9683 The display in the agenda buffer looks best if the category is not
9684 longer than 10 characters.
9686 @noindent
9687 @vindex org-agenda-category-icon-alist
9688 You can set up icons for category by customizing the
9689 @code{org-agenda-category-icon-alist} variable.
9691 @node Time-of-day specifications
9692 @subsection Time-of-day specifications
9694 @cindex time-of-day specification
9696 Org mode checks each agenda item for a time-of-day specification.  The
9697 time can be part of the timestamp that triggered inclusion into the
9698 agenda, for example
9700 @example
9701 <2005-05-10 Tue 19:00>
9702 @end example
9704 @noindent
9705 Time ranges can be specified with two timestamps:
9707 @example
9708 <2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>
9709 @end example
9711 In the headline of the entry itself, a time(range) may also appear as
9712 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda integrates
9713 the Emacs diary (see @ref{Weekly/daily agenda}), time specifications in
9714 diary entries are recognized as well.
9716 For agenda display, Org mode extracts the time and displays it in
9717 a standard 24 hour format as part of the prefix.  The example times in
9718 the previous paragraphs would end up in the agenda like this:
9720 @example
9721  8:30-13:00 Arthur Dent lies in front of the bulldozer
9722 12:45...... Ford Prefect arrives and takes Arthur to the pub
9723 19:00...... The Vogon reads his poem
9724 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9725 @end example
9727 @cindex time grid
9728 If the agenda is in single-day mode, or for the display of today, the
9729 timed entries are embedded in a time grid, like
9731 @example
9732  8:00...... ------------------
9733  8:30-13:00 Arthur Dent lies in front of the bulldozer
9734 10:00...... ------------------
9735 12:00...... ------------------
9736 12:45...... Ford Prefect arrives and takes Arthur to the pub
9737 14:00...... ------------------
9738 16:00...... ------------------
9739 18:00...... ------------------
9740 19:00...... The Vogon reads his poem
9741 20:00...... ------------------
9742 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9743 @end example
9745 @vindex org-agenda-use-time-grid
9746 @vindex org-agenda-time-grid
9747 The time grid can be turned on and off with the variable
9748 @code{org-agenda-use-time-grid}, and can be configured with
9749 @code{org-agenda-time-grid}.
9751 @node Sorting of agenda items
9752 @subsection Sorting of agenda items
9754 @cindex sorting, of agenda items
9755 @cindex priorities, of agenda items
9757 Before being inserted into a view, the items are sorted.  How this is
9758 done depends on the type of view.
9760 @itemize
9761 @item
9762 @vindex org-agenda-files
9763 For the daily/weekly agenda, the items for each day are sorted.  The
9764 default order is to first collect all items containing an explicit
9765 time-of-day specification.  These entries are shown at the beginning
9766 of the list, as a @emph{schedule} for the day.  After that, items remain
9767 grouped in categories, in the sequence given by @code{org-agenda-files}.
9768 Within each category, items are sorted by priority (see
9769 @ref{Priorities}), which is composed of the base priority (2000 for
9770 priority @samp{A}, 1000 for @samp{B}, and 0 for @samp{C}), plus additional
9771 increments for overdue scheduled or deadline items.
9773 @item
9774 For the TODO list, items remain in the order of categories, but
9775 within each category, sorting takes place according to priority (see
9776 @ref{Priorities}).  The priority used for sorting derives from the
9777 priority cookie, with additions depending on how close an item is to
9778 its due or scheduled date.
9780 @item
9781 For tags matches, items are not sorted at all, but just appear in
9782 the sequence in which they are found in the agenda files.
9783 @end itemize
9785 @vindex org-agenda-sorting-strategy
9786 Sorting can be customized using the variable
9787 @code{org-agenda-sorting-strategy}, and may also include criteria based on
9788 the estimated effort of an entry (see @ref{Effort Estimates}).
9790 @node Filtering/limiting agenda times
9791 @subsection Filtering/limiting agenda times
9793 Agenda built-in or customized commands are statically defined.  Agenda
9794 filters and limits provide two ways of dynamically narrowing down the
9795 list of agenda entries: @emph{filters} and @emph{limits}.  Filters only act on
9796 the display of the items, while limits take effect before the list of
9797 agenda entries is built.  Filters are more often used interactively,
9798 while limits are mostly useful when defined as local variables within
9799 custom agenda commands.
9801 @anchor{Filtering in the agenda}
9802 @subsubheading Filtering in the agenda
9804 @cindex agenda filtering
9805 @cindex filtering entries, in agenda
9806 @cindex tag filtering, in agenda
9807 @cindex category filtering, in agenda
9808 @cindex top headline filtering, in agenda
9809 @cindex effort filtering, in agenda
9810 @cindex query editing, in agenda
9812 @table @asis
9813 @item @kbd{/} (@code{org-agenda-filter-by-tag})
9814 @findex org-agenda-filter-by-tag
9815 @vindex org-agenda-tag-filter-preset
9816 Filter the agenda view with respect to a tag and/or effort
9817 estimates.  The difference between this and a custom agenda
9818 command is that filtering is very fast, so that you can switch
9819 quickly between different filters without having to recreate the
9820 agenda.@footnote{Custom commands can preset a filter by binding the variable
9821 @code{org-agenda-tag-filter-preset} as an option.  This filter is then
9822 applied to the view and persists as a basic filter through refreshes
9823 and more secondary filtering.  The filter is a global property of the
9824 entire agenda view---in a block agenda, you should only set this in
9825 the global options section, not in the section of an individual block.}
9827 You are prompted for a tag selection letter; @kbd{@key{SPC}} means
9828 any tag at all.  Pressing @kbd{@key{TAB}} at that prompt offers
9829 completion to select a tag, including any tags that do not have
9830 a selection character.  The command then hides all entries that
9831 do not contain or inherit this tag.  When called with prefix
9832 argument, remove the entries that @emph{do} have the tag.  A second
9833 @kbd{/} at the prompt turns off the filter and shows any
9834 hidden entries.  Pressing @kbd{+} or @kbd{-} switches
9835 between filtering and excluding the next tag.
9837 @vindex org-agenda-auto-exclude-function
9838 Org also supports automatic, context-aware tag filtering.  If the
9839 variable @code{org-agenda-auto-exclude-function} is set to
9840 a user-defined function, that function can decide which tags
9841 should be excluded from the agenda automatically.  Once this is
9842 set, the @kbd{/} command then accepts @kbd{@key{RET}} as
9843 a sub-option key and runs the auto exclusion logic.  For example,
9844 let's say you use a @samp{Net} tag to identify tasks which need
9845 network access, an @samp{Errand} tag for errands in town, and a @samp{Call}
9846 tag for making phone calls.  You could auto-exclude these tags
9847 based on the availability of the Internet, and outside of
9848 business hours, with something like this:
9850 @lisp
9851 (defun org-my-auto-exclude-function (tag)
9852   (and (cond
9853         ((string= tag "Net")
9854          (/= 0 (call-process "/sbin/ping" nil nil nil
9855                              "-c1" "-q" "-t1" "mail.gnu.org")))
9856         ((or (string= tag "Errand") (string= tag "Call"))
9857          (let ((hour (nth 2 (decode-time))))
9858            (or (< hour 8) (> hour 21)))))
9859        (concat "-" tag)))
9861 (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
9862 @end lisp
9864 @item @kbd{<} (@code{org-agenda-filter-by-category})
9865 @findex org-agenda-filter-by-category
9866 Filter the current agenda view with respect to the category of
9867 the item at point.  Pressing @kbd{<} another time removes
9868 this filter.  When called with a prefix argument exclude the
9869 category of the item at point from the agenda.
9871 @vindex org-agenda-category-filter-preset
9872 You can add a filter preset in custom agenda commands through the
9873 option @code{org-agenda-category-filter-preset}.  See @ref{Setting options}.
9875 @item @kbd{^} (@code{org-agenda-filter-by-top-headline})
9876 @findex org-agenda-filter-by-top-headline
9877 Filter the current agenda view and only display the siblings and
9878 the parent headline of the one at point.
9880 @item @kbd{=} (@code{org-agenda-filter-by-regexp})
9881 @findex org-agenda-filter-by-regexp
9882 Filter the agenda view by a regular expression: only show agenda
9883 entries matching the regular expression the user entered.  When
9884 called with a prefix argument, it filters @emph{out} entries matching
9885 the regexp.  With two universal prefix arguments, it removes all
9886 the regexp filters, which can be accumulated.
9888 @vindex org-agenda-regexp-filter-preset
9889 You can add a filter preset in custom agenda commands through the
9890 option @code{org-agenda-regexp-filter-preset}.  See @ref{Setting options}.
9892 @item @kbd{_} (@code{org-agenda-filter-by-effort})
9893 @findex org-agenda-filter-by-effort
9894 Filter the agenda view with respect to effort estimates.  You
9895 first need to set up allowed efforts globally, for example
9897 @lisp
9898 (setq org-global-properties
9899       '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
9900 @end lisp
9902 @vindex org-sort-agenda-noeffort-is-high
9903 You can then filter for an effort by first typing an operator,
9904 one of @kbd{<}, @kbd{>} and @kbd{=}, and then the
9905 one-digit index of an effort estimate in your array of allowed
9906 values, where @kbd{0} means the 10th value.  The filter then
9907 restricts to entries with effort smaller-or-equal, equal, or
9908 larger-or-equal than the selected value.  For application of the
9909 operator, entries without a defined effort are treated according
9910 to the value of @code{org-sort-agenda-noeffort-is-high}.
9912 When called with a prefix argument, it removes entries matching
9913 the condition.  With two universal prefix arguments, it clears
9914 effort filters, which can be accumulated.
9916 @vindex org-agenda-effort-filter-preset
9917 You can add a filter preset in custom agenda commands through the
9918 option @code{org-agenda-effort-filter-preset}.  See @ref{Setting options}.
9920 @item @kbd{|} (@code{org-agenda-filter-remove-all})
9921 Remove all filters in the current agenda view.
9922 @end table
9924 @anchor{Setting limits for the agenda}
9925 @subsubheading Setting limits for the agenda
9927 @cindex limits, in agenda
9929 Here is a list of options that you can set, either globally, or
9930 locally in your custom agenda views (see @ref{Custom Agenda Views}).
9932 @table @asis
9933 @item @code{org-agenda-max-entries}
9934 @vindex org-agenda-max-entries
9935 Limit the number of entries.
9937 @item @code{org-agenda-max-effort}
9938 @vindex org-agenda-max-effort
9939 Limit the duration of accumulated efforts (as minutes).
9941 @item @code{org-agenda-max-todos}
9942 @vindex org-agenda-max-todos
9943 Limit the number of entries with TODO keywords.
9945 @item @code{org-agenda-max-tags}
9946 @vindex org-agenda-max-tags
9947 Limit the number of tagged entries.
9948 @end table
9950 When set to a positive integer, each option excludes entries from
9951 other categories: for example, @code{(setq org-agenda-max-effort 100)}
9952 limits the agenda to 100 minutes of effort and exclude any entry that
9953 has no effort property.  If you want to include entries with no effort
9954 property, use a negative value for @code{org-agenda-max-effort}.  One
9955 useful setup is to use @code{org-agenda-max-entries} locally in a custom
9956 command.  For example, this custom command displays the next five
9957 entries with a @samp{NEXT} TODO keyword.
9959 @lisp
9960 (setq org-agenda-custom-commands
9961       '(("n" todo "NEXT"
9962          ((org-agenda-max-entries 5)))))
9963 @end lisp
9965 Once you mark one of these five entry as DONE, rebuilding the agenda
9966 will again the next five entries again, including the first entry that
9967 was excluded so far.
9969 You can also dynamically set temporary limits, which are lost when
9970 rebuilding the agenda:
9972 @table @asis
9973 @item @kbd{~} (@code{org-agenda-limit-interactively})
9974 @findex org-agenda-limit-interactively
9975 This prompts for the type of limit to apply and its value.
9976 @end table
9978 @node Agenda Commands
9979 @section Commands in the Agenda Buffer
9981 @cindex commands, in agenda buffer
9983 Entries in the agenda buffer are linked back to the Org file or diary
9984 file where they originate.  You are not allowed to edit the agenda
9985 buffer itself, but commands are provided to show and jump to the
9986 original entry location, and to edit the Org files ``remotely'' from the
9987 agenda buffer.  In this way, all information is stored only once,
9988 removing the risk that your agenda and note files may diverge.
9990 Some commands can be executed with mouse clicks on agenda lines.  For
9991 the other commands, the cursor needs to be in the desired line.
9993 @anchor{Motion (1)}
9994 @subheading Motion
9996 @cindex motion commands in agenda
9998 @table @asis
9999 @item @kbd{n} (@code{org-agenda-next-line})
10000 @kindex n
10001 @findex org-agenda-next-line
10002 Next line (same as @kbd{@key{DOWN}} and @kbd{C-n}).
10004 @item @kbd{p} (@code{org-agenda-previous-line})
10005 @kindex p
10006 @findex org-agenda-previous-line
10007 Previous line (same as @kbd{@key{UP}} and @kbd{C-p}).
10008 @end table
10010 @anchor{View/Go to Org file}
10011 @subheading View/Go to Org file
10013 @cindex view file commands in agenda
10015 @table @asis
10016 @item @kbd{@key{SPC}} or @kbd{mouse-3} (@code{org-agenda-show-and-scroll-up})
10017 @kindex SPC
10018 @kindex mouse-3
10019 @findex org-agenda-show-and-scroll-up
10020 Display the original location of the item in another window.
10021 With a prefix argument, make sure that drawers stay folded.
10023 @item @kbd{L} (@code{org-agenda-recenter})
10024 @findex org-agenda-recenter
10025 Display original location and recenter that window.
10027 @item @kbd{@key{TAB}} or @kbd{mouse-2} (@code{org-agenda-goto})
10028 @kindex TAB
10029 @kindex mouse-2
10030 @findex org-agenda-goto
10031 Go to the original location of the item in another window.
10033 @item @kbd{@key{RET}} (@code{org-agenda-switch-to})
10034 @kindex RET
10035 @findex org-agenda-switch-to
10036 Go to the original location of the item and delete other windows.
10038 @item @kbd{F} (@code{org-agenda-follow-mode})
10039 @kindex F
10040 @findex org-agenda-follow-mode
10041 @vindex org-agenda-start-with-follow-mode
10042 Toggle Follow mode.  In Follow mode, as you move the cursor
10043 through the agenda buffer, the other window always shows the
10044 corresponding location in the Org file.  The initial setting for
10045 this mode in new agenda buffers can be set with the variable
10046 @code{org-agenda-start-with-follow-mode}.
10048 @item @kbd{C-c C-x b} (@code{org-agenda-tree-to-indirect-buffer})
10049 @kindex C-c C-x b
10050 @findex org-agenda-tree-to-indirect-buffer
10051 Display the entire subtree of the current item in an indirect
10052 buffer.  With a numeric prefix argument N, go up to level N and
10053 then take that tree.  If N is negative, go up that many levels.
10054 With a @kbd{C-u} prefix, do not remove the previously used
10055 indirect buffer.
10057 @item @kbd{C-c C-o} (@code{org-agenda-open-link})
10058 @kindex C-c C-o
10059 @findex org-agenda-open-link
10060 Follow a link in the entry.  This offers a selection of any links
10061 in the text belonging to the referenced Org node.  If there is
10062 only one link, follow it without a selection prompt.
10063 @end table
10065 @anchor{Change display}
10066 @subheading Change display
10068 @cindex change agenda display
10069 @cindex display changing, in agenda
10071 @table @asis
10072 @item @kbd{A}
10073 @kindex A
10074 Interactively select another agenda view and append it to the
10075 current view.
10077 @item @kbd{o}
10078 @kindex o
10079 Delete other windows.
10081 @item @kbd{v d} or short @kbd{d} (@code{org-agenda-day-view})
10082 @kindex v d
10083 @kindex d
10084 @findex org-agenda-day-view
10085 Switch to day view.  When switching to day view, this setting
10086 becomes the default for subsequent agenda refreshes.  A numeric
10087 prefix argument may be used to jump directly to a specific day of
10088 the year.  For example, @kbd{32 d} jumps to February 1st.
10089 When setting day view, a year may be encoded in the prefix
10090 argument as well.  For example, @kbd{200712 d} jumps to
10091 January 12, 2007.  If such a year specification has only one or
10092 two digits, it is expanded into one of the 30 next years or the
10093 last 69 years.
10095 @item @kbd{v w} or short @kbd{w} (@code{org-agenda-week-view})
10096 @kindex v w
10097 @kindex w
10098 @findex org-agenda-week-view
10099 Switch to week view.  When switching week view, this setting
10100 becomes the default for subsequent agenda refreshes.  A numeric
10101 prefix argument may be used to jump directly to a specific day of
10102 the ISO week.  For example @kbd{9 w} to ISO week number 9.
10103 When setting week view, a year may be encoded in the prefix
10104 argument as well.  For example, @kbd{200712 w} jumps to week
10105 12 in 2007.  If such a year specification has only one or two
10106 digits, it is expanded into one of the 30 next years or the last
10107 69 years.
10109 @item @kbd{v m} (@code{org-agenda-month-view})
10110 @kindex v m
10111 @findex org-agenda-month-view
10112 Switch to month view.  Because month views are slow to create,
10113 they do not become the default for subsequent agenda refreshes.
10114 A numeric prefix argument may be used to jump directly to
10115 a specific day of the month.  When setting month view, a year may
10116 be encoded in the prefix argument as well.  For example,
10117 @kbd{200712 m} jumps to December, 2007.  If such a year
10118 specification has only one or two digits, it is expanded into one
10119 of the 30 next years or the last 69 years.
10121 @item @kbd{v y} (@code{org-agenda-year-view})
10122 @kindex v y
10123 @findex org-agenda-year-view
10124 Switch to year view.  Because year views are slow to create, they
10125 do not become the default for subsequent agenda refreshes.
10126 A numeric prefix argument may be used to jump directly to
10127 a specific day of the year.
10129 @item @kbd{v @key{SPC}} (@code{org-agenda-reset-view})
10130 @kindex v SPC
10131 @findex org-agenda-reset-view
10132 @vindex org-agenda-span
10133 Reset the current view to @code{org-agenda-span}.
10135 @item @kbd{f} (@code{org-agenda-later})
10136 @kindex f
10137 @findex org-agenda-later
10138 Go forward in time to display the span following the current one.
10139 For example, if the display covers a week, switch to the
10140 following week.  With a prefix argument, repeat that many times.
10142 @item @kbd{b} (@code{org-agenda-earlier})
10143 @kindex b
10144 @findex org-agenda-earlier
10145 Go backward in time to display earlier dates.
10147 @item @kbd{.} (@code{org-agenda-goto-today})
10148 @kindex .
10149 @findex org-agenda-goto-today
10150 Go to today.
10152 @item @kbd{j} (@code{org-agenda-goto-date})
10153 @kindex j
10154 @findex org-agenda-goto-date
10155 Prompt for a date and go there.
10157 @item @kbd{J} (@code{org-agenda-clock-goto})
10158 @kindex J
10159 @findex org-agenda-clock-goto
10160 Go to the currently clocked-in task @emph{in the agenda buffer}.
10162 @item @kbd{D} (@code{org-agenda-toggle-diary})
10163 @kindex D
10164 @findex org-agenda-toggle-diary
10165 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
10167 @item @kbd{v l} or @kbd{v L} or short @kbd{l} (@code{org-agenda-log-mode})
10168 @kindex v l
10169 @kindex l
10170 @kindex v L
10171 @findex org-agenda-log-mode
10172 @vindex org-log-done
10173 @vindex org-agenda-log-mode-items
10174 Toggle Logbook mode.  In Logbook mode, entries that were marked
10175 DONE while logging was on (see the variable @code{org-log-done}) are
10176 shown in the agenda, as are entries that have been clocked on
10177 that day.  You can configure the entry types that should be
10178 included in log mode using the variable
10179 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u}
10180 prefix, show all possible logbook entries, including state
10181 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}.
10183 @item @kbd{v [} or short @kbd{[} (@code{org-agenda-manipulate-query-add})
10184 @kindex v [
10185 @kindex [
10186 @findex org-agenda-manipulate-query-add
10187 Include inactive timestamps into the current view.  Only for
10188 weekly/daily agenda and timeline views.
10190 @item @kbd{v a} (@code{org-agenda-archives-mode})
10191 @kindex v a
10192 @findex org-agenda-archives-mode
10193 Toggle Archives mode.  In Archives mode, trees that are archived
10194 (see @ref{Internal archiving}) are also scanned when producing the
10195 agenda.  To exit archives mode, press @kbd{v a} again.
10197 @item @kbd{v A}
10198 @kindex v A
10199 Toggle Archives mode.  Include all archive files as well.
10201 @item @kbd{v R} or short @kbd{R} (@code{org-agenda-clockreport-mode})
10202 @kindex v R
10203 @kindex R
10204 @findex org-agenda-clockreport-mode
10205 @vindex org-agenda-start-with-clockreport-mode
10206 @vindex org-clock-report-include-clocking-task
10207 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly
10208 agenda always shows a table with the clocked times for the time
10209 span and file scope covered by the current agenda view.  The
10210 initial setting for this mode in new agenda buffers can be set
10211 with the variable @code{org-agenda-start-with-clockreport-mode}.  By
10212 using a prefix argument when toggling this mode (i.e., @kbd{C-u R}), the clock table does not show contributions from entries
10213 that are hidden by agenda filtering@footnote{Only tags filtering is respected here, effort filtering is
10214 ignored.}.  See also the
10215 variable @code{org-clock-report-include-clocking-task}.
10217 @item @kbd{v c}
10218 @kindex v c
10219 @vindex org-agenda-clock-consistency-checks
10220 Show overlapping clock entries, clocking gaps, and other clocking
10221 problems in the current agenda range.  You can then visit
10222 clocking lines and fix them manually.  See the variable
10223 @code{org-agenda-clock-consistency-checks} for information on how to
10224 customize the definition of what constituted a clocking problem.
10225 To return to normal agenda display, press @kbd{l} to exit
10226 Logbook mode.
10228 @item @kbd{v E} or short @kbd{E} (@code{org-agenda-entry-text-mode})
10229 @kindex v E
10230 @kindex E
10231 @findex org-agenda-entry-text-mode
10232 @vindex org-agenda-start-with-entry-text-mode
10233 @vindex org-agenda-entry-text-maxlines
10234 Toggle entry text mode.  In entry text mode, a number of lines
10235 from the Org outline node referenced by an agenda line are
10236 displayed below the line.  The maximum number of lines is given
10237 by the variable @code{org-agenda-entry-text-maxlines}.  Calling this
10238 command with a numeric prefix argument temporarily modifies that
10239 number to the prefix value.
10241 @item @kbd{G} (@code{org-agenda-toggle-time-grid})
10242 @kindex G
10243 @vindex org-agenda-use-time-grid
10244 @vindex org-agenda-time-grid
10245 Toggle the time grid on and off.  See also the variables
10246 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
10248 @item @kbd{r} (@code{org-agenda-redo})
10249 @itemx @kbd{g}
10250 @kindex r
10251 @kindex g
10252 @findex org-agenda-redo
10253 Recreate the agenda buffer, for example to reflect the changes
10254 after modification of the timestamps of items with
10255 @kbd{S-@key{LEFT}} and @kbd{S-@key{RIGHT}}.  When the
10256 buffer is the global TODO list, a prefix argument is interpreted
10257 to create a selective list for a specific TODO keyword.
10259 @item @kbd{C-x C-s} or short @kbd{s} (@code{org-save-all-org-buffers})
10260 @kindex C-x C-s
10261 @findex org-save-all-org-buffers
10262 @kindex s
10263 Save all Org buffers in the current Emacs session, and also the
10264 locations of IDs.
10266 @item @kbd{C-c C-x C-c} (@code{org-agenda-columns})
10267 @kindex C-c C-x C-c
10268 @findex org-agenda-columns
10269 @vindex org-columns-default-format
10270 Invoke column view (see @ref{Column View}) in the agenda buffer.  The
10271 column view format is taken from the entry at point, or, if there
10272 is no entry at point, from the first entry in the agenda view.
10273 So whatever the format for that entry would be in the original
10274 buffer (taken from a property, from a @samp{COLUMNS} keyword, or from
10275 the default variable @code{org-columns-default-format}) is used in the
10276 agenda.
10278 @item @kbd{C-c C-x >} (@code{org-agenda-remove-restriction-lock})
10279 @kindex C-c C-x >
10280 @findex org-agenda-remove-restriction-lock
10281 Remove the restriction lock on the agenda, if it is currently
10282 restricted to a file or subtree (see @ref{Agenda Files}).
10284 @item @kbd{M-@key{UP}} (@code{org-agenda-drag-line-backward})
10285 @kindex M-UP
10286 @findex org-agenda-drag-line-backward
10287 Drag the line at point backward one line.  With a numeric prefix
10288 argument, drag backward by that many lines.
10290 Moving agenda lines does not persist after an agenda refresh and
10291 does not modify the contributing Org files.
10293 @item @kbd{M-@key{DOWN}} (@code{org-agenda-drag-line-forward})
10294 @kindex M-DOWN
10295 @findex org-agenda-drag-line-forward
10296 Drag the line at point forward one line.  With a numeric prefix
10297 argument, drag forward by that many lines.
10298 @end table
10300 @anchor{Remote editing}
10301 @subheading Remote editing
10303 @cindex remote editing, from agenda
10305 @table @asis
10306 @item @kbd{0--9}
10307 Digit argument.
10309 @item @kbd{C-_} (@code{org-agenda-undo})
10310 @kindex C-_
10311 @findex org-agenda-undo
10312 @cindex undoing remote-editing events
10313 @cindex remote editing, undo
10314 Undo a change due to a remote editing command.  The change is
10315 undone both in the agenda buffer and in the remote buffer.
10317 @item @kbd{t} (@code{org-agenda-todo})
10318 @kindex t
10319 @findex org-agenda-todo
10320 Change the TODO state of the item, both in the agenda and in the
10321 original Org file.
10323 @item @kbd{C-S-@key{RIGHT}} (@code{org-agenda-todo-nextset})
10324 @kindex C-S-RIGHT
10325 @findex org-agenda-todo-nextset
10326 Switch to the next set of TODO keywords.
10328 @item @kbd{C-S-@key{LEFT}}, @code{org-agenda-todo-previousset}
10329 @kindex C-S-LEFT
10330 Switch to the previous set of TODO keywords.
10332 @item @kbd{C-k} (@code{org-agenda-kill})
10333 @kindex C-k
10334 @findex org-agenda-kill
10335 @vindex org-agenda-confirm-kill
10336 Delete the current agenda item along with the entire subtree
10337 belonging to it in the original Org file.  If the text to be
10338 deleted remotely is longer than one line, the kill needs to be
10339 confirmed by the user.  See variable @code{org-agenda-confirm-kill}.
10341 @item @kbd{C-c C-w} (@code{org-agenda-refile})
10342 @kindex C-c C-w
10343 @findex org-agenda-refile
10344 Refile the entry at point.
10346 @item @kbd{C-c C-x C-a} or short @kbd{a} (@code{org-agenda-archive-default-with-confirmation})
10347 @kindex C-c C-x C-a
10348 @kindex a
10349 @findex org-agenda-archive-default-with-confirmation
10350 @vindex org-archive-default-command
10351 Archive the subtree corresponding to the entry at point using the
10352 default archiving command set in @code{org-archive-default-command}.
10353 When using the @kbd{a} key, confirmation is required.
10355 @item @kbd{C-c C-x a} (@code{org-agenda-toggle-archive-tag})
10356 @kindex C-c C-x a
10357 @findex org-agenda-toggle-archive-tag
10358 Toggle the archive tag (see @ref{Internal archiving}) for the current
10359 headline.
10361 @item @kbd{C-c C-x A} (@code{org-agenda-archive-to-archive-sibling})
10362 @kindex C-c C-x A
10363 @findex org-agenda-archive-to-archive-sibling
10364 Move the subtree corresponding to the current entry to its
10365 @emph{archive sibling}.
10367 @item @kbd{C-c C-x C-s} or short @kbd{$} (@code{org-agenda-archive})
10368 @kindex C-c C-x C-s
10369 @kindex $
10370 @findex org-agenda-archive
10371 Archive the subtree corresponding to the current headline.  This
10372 means the entry is moved to the configured archive location, most
10373 likely a different file.
10375 @item @kbd{T} (@code{org-agenda-show-tags})
10376 @kindex T
10377 @findex org-agenda-show-tags
10378 @vindex org-agenda-show-inherited-tags
10379 Show all tags associated with the current item.  This is useful
10380 if you have turned off @code{org-agenda-show-inherited-tags}, but
10381 still want to see all tags of a headline occasionally.
10383 @item @kbd{:} (@code{org-agenda-set-tags})
10384 @kindex :
10385 @findex org-agenda-set-tags
10386 Set tags for the current headline.  If there is an active region
10387 in the agenda, change a tag for all headings in the region.
10389 @item @kbd{,} (@code{org-agenda-priority})
10390 @kindex ,
10391 @findex org-agenda-priority
10392 Set the priority for the current item.  Org mode prompts for the
10393 priority character.  If you reply with @kbd{@key{SPC}}, the
10394 priority cookie is removed from the entry.
10396 @item @kbd{P} (@code{org-agenda-show-priority})
10397 @kindex P
10398 @findex org-agenda-show-priority
10399 Display weighted priority of current item.
10401 @item @kbd{+} or @kbd{S-@key{UP}} (@code{org-agenda-priority-up})
10402 @kindex +
10403 @kindex S-UP
10404 @findex org-agenda-priority-up
10405 Increase the priority of the current item.  The priority is
10406 changed in the original buffer, but the agenda is not resorted.
10407 Use the @kbd{r} key for this.
10409 @item @kbd{-} or @kbd{S-@key{DOWN}} (@code{org-agenda-priority-down})
10410 @kindex -
10411 @kindex S-DOWN
10412 @findex org-agenda-priority-down
10413 Decrease the priority of the current item.
10415 @item @kbd{C-c C-z} or short @kbd{z} (@code{org-agenda-add-note})
10416 @kindex z
10417 @kindex C-c C-z
10418 @findex org-agenda-add-note
10419 @vindex org-log-into-drawer
10420 Add a note to the entry.  This note is recorded, and then filed
10421 to the same location where state change notes are put.  Depending
10422 on @code{org-log-into-drawer}, this may be inside a drawer.
10424 @item @kbd{C-c C-a} (@code{org-attach})
10425 @kindex C-c C-a
10426 @findex org-attach
10427 Dispatcher for all command related to attachments.
10429 @item @kbd{C-c C-s} (@code{org-agenda-schedule})
10430 @kindex C-c C-s
10431 @findex org-agenda-schedule
10432 Schedule this item.  With a prefix argument, remove the
10433 scheduling timestamp
10435 @item @kbd{C-c C-d} (@code{org-agenda-deadline})
10436 @kindex C-c C-d
10437 @findex org-agenda-deadline
10438 Set a deadline for this item.  With a prefix argument, remove the
10439 deadline.
10441 @item @kbd{S-@key{RIGHT}} (@code{org-agenda-do-date-later})
10442 @kindex S-RIGHT
10443 @findex org-agenda-do-date-later
10444 Change the timestamp associated with the current line by one day
10445 into the future.  If the date is in the past, the first call to
10446 this command moves it to today.  With a numeric prefix argument,
10447 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}
10448 prefix, change the time by one hour.  If you immediately repeat
10449 the command, it will continue to change hours even without the
10450 prefix argument.  With a double @kbd{C-u C-u} prefix, do the
10451 same for changing minutes.  The stamp is changed in the original
10452 Org file, but the change is not directly reflected in the agenda
10453 buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
10455 @item @kbd{S-@key{LEFT}} (@code{org-agenda-do-date-earlier})
10456 @kindex S-LEFT
10457 @findex org-agenda-do-date-earlier
10458 Change the timestamp associated with the current line by one day
10459 into the past.
10461 @item @kbd{>} (@code{org-agenda-date-prompt})
10462 @kindex >
10463 @findex org-agenda-date-prompt
10464 Change the timestamp associated with the current line.  The key
10465 @kbd{>} has been chosen, because it is the same as
10466 @kbd{S-.}  on my keyboard.
10468 @item @kbd{I} (@code{org-agenda-clock-in})
10469 @kindex I
10470 @findex org-agenda-clock-in
10471 Start the clock on the current item.  If a clock is running
10472 already, it is stopped first.
10474 @item @kbd{O} (@code{org-agenda-clock-out})
10475 @kindex O
10476 @findex org-agenda-clock-out
10477 Stop the previously started clock.
10479 @item @kbd{X} (@code{org-agenda-clock-cancel})
10480 @kindex X
10481 @findex org-agenda-clock-cancel
10482 Cancel the currently running clock.
10484 @item @kbd{J} (@code{org-agenda-clock-goto})
10485 @kindex J
10486 @findex org-agenda-clock-goto
10487 Jump to the running clock in another window.
10489 @item @kbd{k} (@code{org-agenda-capture})
10490 @kindex k
10491 @findex org-agenda-capture
10492 @cindex capturing, from agenda
10493 @vindex org-capture-use-agenda-date
10494 Like @code{org-capture}, but use the date at point as the default date
10495 for the capture template.  See @code{org-capture-use-agenda-date} to
10496 make this the default behavior of @code{org-capture}.
10497 @end table
10499 @anchor{Bulk remote editing selected entries}
10500 @subheading Bulk remote editing selected entries
10502 @cindex remote editing, bulk, from agenda
10503 @vindex org-agenda-bulk-custom-functions
10505 @table @asis
10506 @item @kbd{m} (@code{org-agenda-bulk-mark})
10507 @kindex m
10508 @findex org-agenda-bulk-mark
10510 Mark the entry at point for bulk action.  If there is an active
10511 region in the agenda, mark the entries in the region.  With
10512 numeric prefix argument, mark that many successive entries.
10514 @item @kbd{*} (@code{org-agenda-bulk-mark-all})
10515 @kindex *
10516 @findex org-agenda-bulk-mark-all
10518 Mark all visible agenda entries for bulk action.
10520 @item @kbd{u} (@code{org-agenda-bulk-unmark})
10521 @kindex u
10522 @findex org-agenda-bulk-unmark
10524 Unmark entry for bulk action.
10526 @item @kbd{U} (@code{org-agenda-bulk-remove-all-marks})
10527 @kindex U
10528 @findex org-agenda-bulk-remove-all-marks
10530 Unmark all marked entries for bulk action.
10532 @item @kbd{M-m} (@code{org-agenda-bulk-toggle})
10533 @kindex M-m
10534 @findex org-agenda-bulk-toggle
10536 Toggle mark of the entry at point for bulk action.
10538 @item @kbd{M-*} (@code{org-agenda-bulk-toggle-all})
10539 @kindex M-*
10540 @findex org-agenda-bulk-toggle-all
10542 Mark entries matching a regular expression for bulk action.
10544 @item @kbd{%} (@code{org-agenda-bulk-mark-regexp})
10545 @kindex %
10546 @findex org-agenda-bulk-mark-regexp
10548 Mark entries matching a regular expression for bulk action.
10550 @item @kbd{B} (@code{org-agenda-bulk-action})
10551 @kindex B
10552 @findex org-agenda-bulk-action
10553 @vindex org-agenda-bulk-persistent-marks
10555 Bulk action: act on all marked entries in the agenda.  This
10556 prompts for another key to select the action to be applied.  The
10557 prefix argument to @kbd{B} is passed through to the
10558 @kbd{s} and @kbd{d} commands, to bulk-remove these
10559 special timestamps.  By default, marks are removed after the
10560 bulk.  If you want them to persist, set
10561 @code{org-agenda-bulk-persistent-marks} to @code{t} or hit @kbd{p} at
10562 the prompt.
10564 @table @asis
10565 @item @kbd{*}
10566 Toggle persistent marks.
10568 @item @kbd{$}
10569 Archive all selected entries.
10571 @item @kbd{A}
10572 Archive entries by moving them to their respective archive
10573 siblings.
10575 @item @kbd{t}
10576 Change TODO state.  This prompts for a single TODO keyword and
10577 changes the state of all selected entries, bypassing blocking
10578 and suppressing logging notes---but not timestamps.
10580 @item @kbd{+}
10581 Add a tag to all selected entries.
10583 @item @kbd{-}
10584 Remove a tag from all selected entries.
10586 @item @kbd{s}
10587 Schedule all items to a new date.  To shift existing schedule
10588 dates by a fixed number of days, use something starting with
10589 double plus at the prompt, for example @samp{++8d} or @samp{++2w}.
10591 @item @kbd{d}
10592 Set deadline to a specific date.
10594 @item @kbd{r}
10595 Prompt for a single refile target and move all entries.  The
10596 entries are no longer in the agenda; refresh (@kbd{g}) to
10597 bring them back.
10599 @item @kbd{S}
10600 Reschedule randomly into the coming N days.  N is prompted for.
10601 With a prefix argument (@kbd{C-u B S}), scatter only
10602 across weekdays.
10604 @item @kbd{f}
10605 @vindex org-agenda-bulk-custom-functions
10606 Apply a function@footnote{You can also create persistent custom functions through
10607 @code{org-agenda-bulk-custom-functions}.} to marked entries.  For example, the
10608 function below sets the @samp{CATEGORY} property of the entries to
10609 @samp{web}.
10611 @lisp
10612 (defun set-category ()
10613   (interactive "P")
10614   (let ((marker (or (org-get-at-bol 'org-hd-marker)
10615                     (org-agenda-error))))
10616     (org-with-point-at marker
10617       (org-back-to-heading t)
10618       (org-set-property "CATEGORY" "web"))))
10619 @end lisp
10620 @end table
10621 @end table
10623 @anchor{Calendar commands}
10624 @subheading Calendar commands
10626 @cindex calendar commands, from agenda
10628 @table @asis
10629 @item @kbd{c} (@code{org-agenda-goto-calendar})
10630 @kindex c
10631 @findex org-agenda-goto-calendar
10632 Open the Emacs calendar and move to the date at the agenda
10633 cursor.
10635 @item @kbd{c} (@code{org-calendar-goto-agenda})
10636 @kindex c
10637 @findex org-calendar-goto-agenda
10638 When in the calendar, compute and show the Org agenda for the
10639 date at the cursor.
10641 @item @kbd{i} (@code{org-agenda-diary-entry})
10642 @kindex i
10643 @findex org-agenda-diary-entry
10645 @cindex diary entries, creating from agenda
10646 Insert a new entry into the diary, using the date at the cursor
10647 and (for block entries) the date at the mark.  This adds to the
10648 Emacs diary file@footnote{This file is parsed for the agenda when
10649 @code{org-agenda-include-diary} is set.}, in a way similar to the @kbd{i}
10650 command in the calendar.  The diary file pops up in another
10651 window, where you can add the entry.
10653 @vindex org-agenda-diary-file
10654 If you configure @code{org-agenda-diary-file} to point to an Org file,
10655 Org creates entries in that file instead.  Most entries are
10656 stored in a date-based outline tree that will later make it easy
10657 to archive appointments from previous months/years.  The tree is
10658 built under an entry with a @samp{DATE_TREE} property, or else with
10659 years as top-level entries.  Emacs prompts you for the entry
10660 text---if you specify it, the entry is created in
10661 @code{org-agenda-diary-file} without further interaction.  If you
10662 directly press @kbd{@key{RET}} at the prompt without typing text,
10663 the target file is shown in another window for you to finish the
10664 entry there.  See also the @kbd{k r} command.
10666 @item @kbd{M} (@code{org-agenda-phases-of-moon})
10667 @kindex M
10668 @findex org-agenda-phases-of-moon
10669 Show the phases of the moon for the three months around current
10670 date.
10672 @item @kbd{S} (@code{org-agenda-sunrise-sunset})
10673 @kindex S
10674 @findex org-agenda-sunrise-sunset
10675 Show sunrise and sunset times.  The geographical location must be
10676 set with calendar variables, see the documentation for the Emacs
10677 calendar.
10679 @item @kbd{C} (@code{org-agenda-convert-date})
10680 @kindex C
10681 @findex org-agenda-convert-date
10682 Convert the date at cursor into many other cultural and historic
10683 calendars.
10685 @item @kbd{H} (@code{org-agenda-holidays})
10686 @kindex H
10687 @findex org-agenda-holidays
10688 Show holidays for three months around the cursor date.
10689 @end table
10691 @anchor{Quit and exit}
10692 @subheading Quit and exit
10694 @table @asis
10695 @item @kbd{q} (@code{org-agenda-quit})
10696 @kindex q
10697 @findex org-agenda-quit
10699 Quit agenda, remove the agenda buffer.
10701 @item @kbd{x} (@code{org-agenda-exit})
10702 @kindex x
10703 @findex org-agenda-exit
10705 @cindex agenda files, removing buffers
10706 Exit agenda, remove the agenda buffer and all buffers loaded by
10707 Emacs for the compilation of the agenda.  Buffers created by the
10708 user to visit Org files are not removed.
10709 @end table
10711 @node Custom Agenda Views
10712 @section Custom Agenda Views
10714 @cindex custom agenda views
10715 @cindex agenda views, custom
10717 Custom agenda commands serve two purposes: to store and quickly access
10718 frequently used TODO and tags searches, and to create special
10719 composite agenda buffers.  Custom agenda commands are accessible
10720 through the dispatcher (see @ref{Agenda Dispatcher}), just like the
10721 default commands.
10723 @menu
10724 * Storing searches::             Type once, use often.
10725 * Block agenda::                 All the stuff you need in a single buffer.
10726 * Setting options::              Changing the rules.
10727 @end menu
10729 @node Storing searches
10730 @subsection Storing searches
10732 The first application of custom searches is the definition of keyboard
10733 shortcuts for frequently used searches, either creating an agenda
10734 buffer, or a sparse tree (the latter covering of course only the
10735 current buffer).
10737 @kindex C @r{(Agenda dispatcher)}
10738 @vindex org-agenda-custom-commands
10739 @cindex agenda views, main example
10740 @cindex agenda, as an agenda views
10741 @cindex agenda*, as an agenda views
10742 @cindex tags, as an agenda view
10743 @cindex todo, as an agenda view
10744 @cindex tags-todo
10745 @cindex todo-tree
10746 @cindex occur-tree
10747 @cindex tags-tree
10748 Custom commands are configured in the variable
10749 @code{org-agenda-custom-commands}.  You can customize this variable, for
10750 example by pressing @kbd{C} from the agenda dispatcher (see @ref{Agenda Dispatcher}).  You can also directly set it with Emacs Lisp in
10751 the Emacs init file.  The following example contains all valid agenda
10752 views:
10754 @lisp
10755 (setq org-agenda-custom-commands
10756       '(("x" agenda)
10757         ("y" agenda*)
10758         ("w" todo "WAITING")
10759         ("W" todo-tree "WAITING")
10760         ("u" tags "+boss-urgent")
10761         ("v" tags-todo "+boss-urgent")
10762         ("U" tags-tree "+boss-urgent")
10763         ("f" occur-tree "\\<FIXME\\>")
10764         ("h" . "HOME+Name tags searches") ;description for "h" prefix
10765         ("hl" tags "+home+Lisa")
10766         ("hp" tags "+home+Peter")
10767         ("hk" tags "+home+Kim")))
10768 @end lisp
10770 @noindent
10771 The initial string in each entry defines the keys you have to press
10772 after the dispatcher command in order to access the command.  Usually
10773 this will be just a single character, but if you have many similar
10774 commands, you can also define two-letter combinations where the first
10775 character is the same in several combinations and serves as a prefix
10776 key@footnote{You can provide a description for a prefix key by inserting
10777 a cons cell with the prefix and the description.}.  The second parameter is the search type, followed by the
10778 string or regular expression to be used for the matching.  The example
10779 above will therefore define:
10781 @table @asis
10782 @item @kbd{x}
10783 as a global search for agenda entries planned@footnote{@emph{Planned} means here that these entries have some planning
10784 information attached to them, like a time-stamp, a scheduled or
10785 a deadline string.  See @code{org-agenda-entry-types} on how to set what
10786 planning information is taken into account.} this
10787 week/day.
10789 @item @kbd{y}
10790 as the same search, but only for entries with an hour
10791 specification like @samp{[h]h:mm}---think of them as appointments.
10793 @item @kbd{w}
10794 as a global search for TODO entries with @samp{WAITING} as the TODO
10795 keyword.
10797 @item @kbd{W}
10798 as the same search, but only in the current buffer and displaying
10799 the results as a sparse tree.
10801 @item @kbd{u}
10802 as a global tags search for headlines tagged @samp{boss} but not
10803 @samp{urgent}.
10805 @item @kbd{v}
10806 The same search, but limiting it to headlines that are also TODO
10807 items.
10809 @item @kbd{U}
10810 as the same search, but only in the current buffer and displaying
10811 the result as a sparse tree.
10813 @item @kbd{f}
10814 to create a sparse tree (again, current buffer only) with all
10815 entries containing the word @samp{FIXME}.
10817 @item @kbd{h}
10818 as a prefix command for a @samp{HOME} tags search where you have to
10819 press an additional key (@kbd{l}, @kbd{p} or
10820 @kbd{k}) to select a name (Lisa, Peter, or Kim) as
10821 additional tag to match.
10822 @end table
10824 Note that @code{*-tree} agenda views need to be called from an Org buffer
10825 as they operate on the current buffer only.
10827 @node Block agenda
10828 @subsection Block agenda
10830 @cindex block agenda
10831 @cindex agenda, with block views
10833 Another possibility is the construction of agenda views that comprise
10834 the results of @emph{several} commands, each of which creates a block in
10835 the agenda buffer.  The available commands include @code{agenda} for the
10836 daily or weekly agenda (as created with @kbd{a}) , @code{alltodo} for
10837 the global TODO list (as constructed with @kbd{t}), and the
10838 matching commands discussed above: @code{todo}, @code{tags}, and @code{tags-todo}.
10839 Here are two examples:
10841 @lisp
10842 (setq org-agenda-custom-commands
10843       '(("h" "Agenda and Home-related tasks"
10844          ((agenda "")
10845           (tags-todo "home")
10846           (tags "garden")))
10847         ("o" "Agenda and Office-related tasks"
10848          ((agenda "")
10849           (tags-todo "work")
10850           (tags "office")))))
10851 @end lisp
10853 @noindent
10854 This defines @kbd{h} to create a multi-block view for stuff you
10855 need to attend to at home.  The resulting agenda buffer contains your
10856 agenda for the current week, all TODO items that carry the tag @samp{home},
10857 and also all lines tagged with @samp{garden}.  Finally the command
10858 @kbd{o} provides a similar view for office tasks.
10860 @node Setting options
10861 @subsection Setting options for custom commands
10863 @cindex options, for custom agenda views
10865 @vindex org-agenda-custom-commands
10866 Org mode contains a number of variables regulating agenda construction
10867 and display.  The global variables define the behavior for all agenda
10868 commands, including the custom commands.  However, if you want to
10869 change some settings just for a single custom view, you can do so.
10870 Setting options requires inserting a list of variable names and values
10871 at the right spot in @code{org-agenda-custom-commands}.  For example:
10873 @lisp
10874 (setq org-agenda-custom-commands
10875       '(("w" todo "WAITING"
10876          ((org-agenda-sorting-strategy '(priority-down))
10877           (org-agenda-prefix-format "  Mixed: ")))
10878         ("U" tags-tree "+boss-urgent"
10879          ((org-show-context-detail 'minimal)))
10880         ("N" search ""
10881          ((org-agenda-files '("~org/notes.org"))
10882           (org-agenda-text-search-extra-files nil)))))
10883 @end lisp
10885 @noindent
10886 Now the @kbd{w} command sorts the collected entries only by
10887 priority, and the prefix format is modified to just say @samp{Mixed:}
10888 instead of giving the category of the entry.  The sparse tags tree of
10889 @kbd{U} now turns out ultra-compact, because neither the headline
10890 hierarchy above the match, nor the headline following the match are
10891 shown.  The command @kbd{N} does a text search limited to only
10892 a single file.
10894 For command sets creating a block agenda, @code{org-agenda-custom-commands}
10895 has two separate spots for setting options.  You can add options that
10896 should be valid for just a single command in the set, and options that
10897 should be valid for all commands in the set.  The former are just
10898 added to the command entry; the latter must come after the list of
10899 command entries.  Going back to the block agenda example (see @ref{Block agenda}), let's change the sorting strategy for the @kbd{h}
10900 commands to @code{priority-down}, but let's sort the results for GARDEN
10901 tags query in the opposite order, @code{priority-up}.  This would look like
10902 this:
10904 @lisp
10905 (setq org-agenda-custom-commands
10906       '(("h" "Agenda and Home-related tasks"
10907          ((agenda)
10908           (tags-todo "home")
10909           (tags "garden"
10910                 ((org-agenda-sorting-strategy '(priority-up)))))
10911          ((org-agenda-sorting-strategy '(priority-down))))
10912         ("o" "Agenda and Office-related tasks"
10913          ((agenda)
10914           (tags-todo "work")
10915           (tags "office")))))
10916 @end lisp
10918 As you see, the values and parentheses setting is a little complex.
10919 When in doubt, use the customize interface to set this variable---it
10920 fully supports its structure.  Just one caveat: when setting options
10921 in this interface, the @emph{values} are just Lisp expressions.  So if the
10922 value is a string, you need to add the double-quotes around the value
10923 yourself.
10925 @vindex org-agenda-custom-commands-contexts
10926 To control whether an agenda command should be accessible from
10927 a specific context, you can customize
10928 @code{org-agenda-custom-commands-contexts}.  Let's say for example that you
10929 have an agenda command @kbd{o} displaying a view that you only
10930 need when reading emails.  Then you would configure this option like
10931 this:
10933 @lisp
10934 (setq org-agenda-custom-commands-contexts
10935       '(("o" (in-mode . "message-mode"))))
10936 @end lisp
10938 You can also tell that the command key @kbd{o} should refer to
10939 another command key @kbd{r}.  In that case, add this command key
10940 like this:
10942 @lisp
10943 (setq org-agenda-custom-commands-contexts
10944       '(("o" "r" (in-mode . "message-mode"))))
10945 @end lisp
10947 See the docstring of the variable for more information.
10949 @node Exporting Agenda Views
10950 @section Exporting Agenda Views
10952 @cindex agenda views, exporting
10954 If you are away from your computer, it can be very useful to have
10955 a printed version of some agenda views to carry around.  Org mode can
10956 export custom agenda views as plain text, HTML@footnote{For HTML you need to install Hrvoje Niksic's @samp{htmlize.el}
10957 from @uref{https://github.com/hniksic/emacs-htmlize, Hrvoje Niksic's repository}.}, Postscript,
10958 PDF@footnote{To create PDF output, the Ghostscript ps2pdf utility must be
10959 installed on the system.  Selecting a PDF file also creates the
10960 postscript file.}, and iCalendar files.  If you want to do this only
10961 occasionally, use the following command:
10963 @table @asis
10964 @item @kbd{C-x C-w} (@code{org-agenda-write})
10965 @kindex C-x C-w
10966 @findex org-agenda-write
10967 @cindex exporting agenda views
10968 @cindex agenda views, exporting
10970 @vindex org-agenda-exporter-settings
10971 Write the agenda view to a file.
10972 @end table
10974 If you need to export certain agenda views frequently, you can
10975 associate any custom agenda command with a list of output file
10976 names@footnote{If you want to store standard views like the weekly agenda or
10977 the global TODO list as well, you need to define custom commands for
10978 them in order to be able to specify file names.}.  Here is an example that first defines custom commands
10979 for the agenda and the global TODO list, together with a number of
10980 files to which to export them.  Then we define two block agenda
10981 commands and specify file names for them as well.  File names can be
10982 relative to the current working directory, or absolute.
10984 @lisp
10985 (setq org-agenda-custom-commands
10986       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
10987         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
10988         ("h" "Agenda and Home-related tasks"
10989          ((agenda "")
10990           (tags-todo "home")
10991           (tags "garden"))
10992          nil
10993          ("~/views/home.html"))
10994         ("o" "Agenda and Office-related tasks"
10995          ((agenda)
10996           (tags-todo "work")
10997           (tags "office"))
10998          nil
10999          ("~/views/office.ps" "~/calendars/office.ics"))))
11000 @end lisp
11002 The extension of the file name determines the type of export.  If it
11003 is @samp{.html}, Org mode uses the htmlize package to convert the buffer to
11004 HTML and save it to this file name.  If the extension is @samp{.ps},
11005 @code{ps-print-buffer-with-faces} is used to produce Postscript output.  If
11006 the extension is @samp{.ics}, iCalendar export is run export over all files
11007 that were used to construct the agenda, and limit the export to
11008 entries listed in the agenda.  Any other extension produces a plain
11009 ASCII file.
11011 The export files are @emph{not} created when you use one of those
11012 commands interactively because this might use too much overhead.
11013 Instead, there is a special command to produce @emph{all} specified
11014 files in one step:
11016 @table @asis
11017 @item @kbd{e} (@code{org-store-agenda-views})
11018 @kindex e @r{(Agenda dispatcher)}
11019 @findex org-store-agenda-views
11020 Export all agenda views that have export file names associated
11021 with them.
11022 @end table
11024 You can use the options section of the custom agenda commands to also
11025 set options for the export commands.  For example:
11027 @lisp
11028 (setq org-agenda-custom-commands
11029       '(("X" agenda ""
11030          ((ps-number-of-columns 2)
11031           (ps-landscape-mode t)
11032           (org-agenda-prefix-format " [ ] ")
11033           (org-agenda-with-colors nil)
11034           (org-agenda-remove-tags t))
11035          ("theagenda.ps"))))
11036 @end lisp
11038 @noindent
11039 @vindex org-agenda-exporter-settings
11040 This command sets two options for the Postscript exporter, to make it
11041 print in two columns in landscape format---the resulting page can be
11042 cut in two and then used in a paper agenda.  The remaining settings
11043 modify the agenda prefix to omit category and scheduling information,
11044 and instead include a checkbox to check off items.  We also remove the
11045 tags to make the lines compact, and we do not want to use colors for
11046 the black-and-white printer.  Settings specified in
11047 @code{org-agenda-exporter-settings} also apply, e.g.,
11049 @lisp
11050 (setq org-agenda-exporter-settings
11051       '((ps-number-of-columns 2)
11052         (ps-landscape-mode t)
11053         (org-agenda-add-entry-text-maxlines 5)
11054         (htmlize-output-type 'css)))
11055 @end lisp
11057 @noindent
11058 but the settings in @code{org-agenda-custom-commands} take precedence.
11060 @noindent
11061 From the command line you may also use:
11063 @example
11064 emacs -eval (org-batch-store-agenda-views) -kill
11065 @end example
11067 @noindent
11068 or, if you need to modify some parameters@footnote{Quoting depends on the system you use, please check the FAQ
11069 for examples.}
11071 @example
11072 emacs -eval '(org-batch-store-agenda-views                      \
11073               org-agenda-span (quote month)                     \
11074               org-agenda-start-day "2007-11-01"                 \
11075               org-agenda-include-diary nil                      \
11076               org-agenda-files (quote ("~/org/project.org")))'  \
11077       -kill
11078 @end example
11080 @noindent
11081 which creates the agenda views restricted to the file
11082 @samp{~/org/project.org}, without diary entries and with a 30-day extent.
11084 You can also extract agenda information in a way that allows further
11085 processing by other programs.  See @ref{Extracting Agenda Information}, for
11086 more information.
11088 @node Agenda Column View
11089 @section Using Column View in the Agenda
11091 @cindex column view, in agenda
11092 @cindex agenda, column view
11094 Column view (see @ref{Column View}) is normally used to view and edit
11095 properties embedded in the hierarchical structure of an Org file.  It
11096 can be quite useful to use column view also from the agenda, where
11097 entries are collected by certain criteria.
11099 @table @asis
11100 @item @kbd{C-c C-x C-c} (@code{org-agenda-columns})
11101 @kindex C-c C-x C-c
11102 @findex org-agenda-columns
11104 Turn on column view in the agenda.
11105 @end table
11107 To understand how to use this properly, it is important to realize
11108 that the entries in the agenda are no longer in their proper outline
11109 environment.  This causes the following issues:
11111 @enumerate
11112 @item
11113 @vindex org-columns-default-format
11114 @vindex org-overriding-columns-format
11115 Org needs to make a decision which columns format to use.  Since
11116 the entries in the agenda are collected from different files, and
11117 different files may have different columns formats, this is
11118 a non-trivial problem.  Org first checks if the variable
11119 @code{org-agenda-overriding-columns-format} is currently set, and if so,
11120 takes the format from there.  Otherwise it takes the format
11121 associated with the first item in the agenda, or, if that item does
11122 not have a specific format (defined in a property, or in its file),
11123 it uses @code{org-columns-default-format}.
11125 @item
11126 @cindex @samp{CLOCKSUM}, special property
11127 If any of the columns has a summary type defined (see @ref{Column attributes}), turning on column view in the agenda visits all
11128 relevant agenda files and make sure that the computations of this
11129 property are up to date.  This is also true for the special
11130 @samp{CLOCKSUM} property.  Org then sums the values displayed in the
11131 agenda.  In the daily/weekly agenda, the sums cover a single day;
11132 in all other views they cover the entire block.
11134 It is important to realize that the agenda may show the same entry
11135 @emph{twice}---for example as scheduled and as a deadline---and it may
11136 show two entries from the same hierarchy (for example a @emph{parent}
11137 and its @emph{child}).  In these cases, the summation in the agenda
11138 leads to incorrect results because some values count double.
11140 @item
11141 When the column view in the agenda shows the @samp{CLOCKSUM} property,
11142 that is always the entire clocked time for this item.  So even in
11143 the daily/weekly agenda, the clocksum listed in column view may
11144 originate from times outside the current view.  This has the
11145 advantage that you can compare these values with a column listing
11146 the planned total effort for a task---one of the major
11147 applications for column view in the agenda.  If you want
11148 information about clocked time in the displayed period use clock
11149 table mode (press @kbd{R} in the agenda).
11151 @item
11152 @cindex @samp{CLOCKSUM_T}, special property
11153 When the column view in the agenda shows the @samp{CLOCKSUM_T} property,
11154 that is always today's clocked time for this item.  So even in the
11155 weekly agenda, the clocksum listed in column view only originates
11156 from today.  This lets you compare the time you spent on a task for
11157 today, with the time already spent---via @samp{CLOCKSUM}---and with
11158 the planned total effort for it.
11159 @end enumerate
11161 @node Markup
11162 @chapter Markup for Rich Export
11164 When exporting Org documents, the exporter tries to reflect the
11165 structure of the document as accurately as possible in the back-end.
11166 Since export targets like HTML and @LaTeX{} allow much richer formatting,
11167 Org mode has rules on how to prepare text for rich export.  This
11168 section summarizes the markup rules used in an Org mode buffer.
11170 @menu
11171 * Paragraphs::                   The basic unit of text.
11172 * Emphasis and Monospace::       Bold, italic, etc.
11173 * Horizontal Rules::             Make a line.
11174 * Images and Tables::            Images, tables and caption mechanism.
11175 * Literal Examples::             Source code examples with special formatting.
11176 * Special Symbols::              Greek letters and other symbols.
11177 * Subscripts and Superscripts::  Simple syntax for raising/lowering text.
11178 * Embedded @LaTeX{}::            LaTeX can be freely used inside Org documents.
11179 @end menu
11181 @node Paragraphs
11182 @section Paragraphs
11184 @cindex paragraphs, markup rules
11186 Paragraphs are separated by at least one empty line.  If you need to
11187 enforce a line break within a paragraph, use @code{\\} at the end of
11188 a line.
11190 To preserve the line breaks, indentation and blank lines in a region,
11191 but otherwise use normal formatting, you can use this construct, which
11192 can also be used to format poetry.
11194 @cindex @samp{BEGIN_VERSE}
11195 @cindex verse blocks
11196 @example
11197 #+BEGIN_VERSE
11198  Great clouds overhead
11199  Tiny black birds rise and fall
11200  Snow covers Emacs
11202     ---AlexSchroeder
11203 #+END_VERSE
11204 @end example
11206 When quoting a passage from another document, it is customary to
11207 format this as a paragraph that is indented on both the left and the
11208 right margin.  You can include quotations in Org documents like this:
11210 @cindex @samp{BEGIN_QUOTE}
11211 @cindex quote blocks
11212 @example
11213 #+BEGIN_QUOTE
11214 Everything should be made as simple as possible,
11215 but not any simpler ---Albert Einstein
11216 #+END_QUOTE
11217 @end example
11219 If you would like to center some text, do it like this:
11221 @cindex @samp{BEGIN_CENTER}
11222 @cindex center blocks
11223 @example
11224 #+BEGIN_CENTER
11225 Everything should be made as simple as possible, \\
11226 but not any simpler
11227 #+END_CENTER
11228 @end example
11230 @node Emphasis and Monospace
11231 @section Emphasis and Monospace
11233 @cindex underlined text, markup rules
11234 @cindex bold text, markup rules
11235 @cindex italic text, markup rules
11236 @cindex verbatim text, markup rules
11237 @cindex code text, markup rules
11238 @cindex strike-through text, markup rules
11240 You can make words @samp{*bold*}, @samp{/italic/}, @samp{_underlined_}, @samp{=verbatim=}
11241 and @samp{~code~}, and, if you must, @samp{+strike-through+}.  Text in the code
11242 and verbatim string is not processed for Org mode specific syntax; it
11243 is exported verbatim.
11245 @vindex org-fontify-emphasized-text
11246 To turn off fontification for marked up text, you can set
11247 @code{org-fontify-emphasized-text} to @code{nil}.  To narrow down the list of
11248 available markup syntax, you can customize @code{org-emphasis-alist}.
11250 @node Horizontal Rules
11251 @section Horizontal Rules
11253 @cindex horizontal rules, markup rules
11255 A line consisting of only dashes, and at least 5 of them, is exported
11256 as a horizontal line.
11258 @node Images and Tables
11259 @section Images and Tables
11261 @cindex tables, markup rules
11262 @cindex @samp{CAPTION}, keyword
11263 @cindex @samp{NAME}, keyword
11265 Both the native Org mode tables (see @ref{Tables}) and tables formatted
11266 with the @samp{table.el} package are exported properly.  For Org mode
11267 tables, the lines before the first horizontal separator line become
11268 table header lines.  You can use the following lines somewhere before
11269 the table to assign a caption and a label for cross references, and in
11270 the text you can refer to the object with @samp{[[tab:basic-data]]} (see
11271 @ref{Internal Links}):
11273 @example
11274 #+CAPTION: This is the caption for the next table (or link)
11275 #+NAME:   tab:basic-data
11276 | ... | ... |
11277 |-----+-----|
11278 @end example
11280 Optionally, the caption can take the form:
11282 @example
11283 #+CAPTION[Caption for list of tables]: Caption for table.
11284 @end example
11286 @cindex inlined images, markup rules
11287 Some back-ends allow you to directly include images into the exported
11288 document.  Org does this, if a link to an image file does not have
11289 a description part, for example @samp{[[./img/a.jpg]]}.  If you wish to define
11290 a caption for the image and maybe a label for internal cross
11291 references, make sure that the link is on a line by itself and precede
11292 it with @samp{CAPTION} and @samp{NAME} keywords as follows:
11294 @example
11295 #+CAPTION: This is the caption for the next figure link (or table)
11296 #+NAME:   fig:SED-HR4049
11297 [[./img/a.jpg]]
11298 @end example
11300 @noindent
11301 Such images can be displayed within the buffer.  See @ref{Handling Links, , the discussion of
11302 image links}.
11304 Even though images and tables are prominent examples of captioned
11305 structures, the same caption mechanism can apply to many
11306 others---e.g., @LaTeX{} equations, source code blocks.  Depending on the
11307 export back-end, those may or may not be handled.
11309 @node Literal Examples
11310 @section Literal Examples
11312 @cindex literal examples, markup
11313 @cindex code line references, markup
11315 You can include literal examples that should not be subjected to
11316 markup.  Such examples are typeset in monospace, so this is well
11317 suited for source code and similar examples.
11319 @cindex @samp{BEGIN_EXAMPLE}
11320 @cindex example block
11321 @example
11322 #+BEGIN_EXAMPLE
11323   Some example from a text file.
11324 #+END_EXAMPLE
11325 @end example
11327 Note that such blocks may be @emph{indented} in order to align nicely with
11328 indented text and in particular with plain list structure (see
11329 @ref{Plain Lists}).  For simplicity when using small examples, you can
11330 also start the example lines with a colon followed by a space.  There
11331 may also be additional whitespace before the colon:
11333 @example
11334 Here is an example
11335    : Some example from a text file.
11336 @end example
11338 @cindex formatting source code, markup rules
11339 @vindex org-latex-listings
11340 If the example is source code from a programming language, or any
11341 other text that can be marked up by Font Lock in Emacs, you can ask
11342 for the example to look like the fontified Emacs buffer@footnote{This works automatically for the HTML backend (it requires
11343 version 1.34 of the @samp{htmlize.el} package, which you need to install).
11344 Fontified code chunks in @LaTeX{} can be achieved using either the
11345 listings package or the @uref{https://github.com/gpoore/minted, minted} package.  Refer to
11346 @code{org-export-latex-listings} for details.}.  This
11347 is done with the code block, where you also need to specify the name
11348 of the major mode that should be used to fontify the example@footnote{Source code in code blocks may also be evaluated either
11349 interactively or on export.  See @ref{Working with Source Code} for more
11350 information on evaluating code blocks.},
11351 see @ref{Structure Templates} for shortcuts to easily insert code blocks.
11353 @cindex @samp{BEGIN_SRC}
11354 @cindex src block
11355 @example
11356 #+BEGIN_SRC emacs-lisp
11357   (defun org-xor (a b)
11358     "Exclusive or."
11359     (if a (not b) b))
11360  #+END_SRC
11361 @end example
11363 Both in @samp{example} and in @samp{src} snippets, you can add a @samp{-n} switch to
11364 the end of the @samp{#+BEGIN} line, to get the lines of the example
11365 numbered.  The @samp{-n} takes an optional numeric argument specifying the
11366 starting line number of the block.  If you use a @samp{+n} switch, the
11367 numbering from the previous numbered snippet is continued in the
11368 current one.  The @samp{+n} switch can also take a numeric argument.  This
11369 adds the value of the argument to the last line of the previous block
11370 to determine the starting line number.
11372 @example
11373 #+BEGIN_SRC emacs-lisp -n 20
11374   ;; This exports with line number 20.
11375   (message "This is line 21")
11376 #+END_SRC
11378 #+BEGIN_SRC emacs-lisp +n 10
11379   ;; This is listed as line 31.
11380   (message "This is line 32")
11381 #+END_SRC
11382 @end example
11384 In literal examples, Org interprets strings like @samp{(ref:name)} as
11385 labels, and use them as targets for special hyperlinks like
11386 @samp{[[(name)]]}---i.e., the reference name enclosed in single parenthesis.
11387 In HTML, hovering the mouse over such a link remote-highlights the
11388 corresponding code line, which is kind of cool.
11390 You can also add a @samp{-r} switch which @emph{removes} the labels from the
11391 source code@footnote{Adding @samp{-k} to @samp{-n -r} @emph{keeps} the labels in the source code
11392 while using line numbers for the links, which might be useful to
11393 explain those in an Org mode example code.}.  With the @samp{-n} switch, links to these references
11394 are labeled by the line numbers from the code listing.  Otherwise
11395 links use the labels with no parentheses.  Here is an example:
11397 @example
11398 #+BEGIN_SRC emacs-lisp -n -r
11399   (save-excursion                 (ref:sc)
11400      (goto-char (point-min))      (ref:jump)
11401 #+END_SRC
11402 In line [[(sc)]] we remember the current position. [[(jump)][Line (jump)]]
11403 jumps to point-min.
11404 @end example
11406 @cindex indentation, in source blocks
11407 Finally, you can use @samp{-i} to preserve the indentation of a specific
11408 code block (see @ref{Editing Source Code}).
11410 @vindex org-coderef-label-format
11411 If the syntax for the label format conflicts with the language syntax,
11412 use a @samp{-l} switch to change the format, for example
11414 @example
11415 #+BEGIN_SRC pascal -n -r -l "((%s))"
11416 @end example
11418 @noindent
11419 See also the variable @code{org-coderef-label-format}.
11421 HTML export also allows examples to be published as text areas (see
11422 @ref{Text areas in HTML export}).
11424 Because the @samp{#+BEGIN} @dots{} @samp{#+END} patterns need to be added so often,
11425 a shortcut is provided (see @ref{Structure Templates}).
11427 @table @asis
11428 @item @kbd{C-c '} (@code{org-edit-special})
11429 @kindex C-c '
11430 @findex org-edit-special
11431 Edit the source code example at point in its native mode.  This
11432 works by switching to a temporary buffer with the source code.
11433 You need to exit by pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*}, @samp{,*}, @samp{#+} and @samp{,#+} get
11434 a comma prepended, to keep them from being interpreted by Org as
11435 outline nodes or special syntax.  These commas are stripped when
11436 editing with @kbd{C-c '}, and also before export.}.  The
11437 edited version then replaces the old version in the Org buffer.
11438 Fixed-width regions---where each line starts with a colon
11439 followed by a space---are edited using @code{artist-mode}@footnote{You may select a different-mode with the variable
11440 @code{org-edit-fixed-width-region-mode}.} to
11441 allow creating ASCII drawings easily.  Using this command in an
11442 empty line creates a new fixed-width region.
11443 @end table
11445 @cindex storing link, in a source code buffer
11446 Calling @code{org-store-link} (see @ref{Handling Links}) while editing a source
11447 code example in a temporary buffer created with @kbd{C-c '}
11448 prompts for a label.  Make sure that it is unique in the current
11449 buffer, and insert it with the proper formatting like @samp{(ref:label)} at
11450 the end of the current line.  Then the label is stored as a link
11451 @samp{(label)}, for retrieval with @kbd{C-c C-l}.
11453 @node Special Symbols
11454 @section Special Symbols
11456 @cindex math symbols
11457 @cindex special symbols
11458 @cindex @TeX{} macros
11459 @cindex @LaTeX{} fragments, markup rules
11460 @cindex HTML entities
11461 @cindex @LaTeX{} entities
11463 You can use @LaTeX{}-like syntax to insert special symbols---named
11464 entities---like @samp{\alpha} to indicate the Greek letter, or @samp{\to} to indicate
11465 an arrow.  Completion for these symbols is available, just type @samp{\}
11466 and maybe a few letters, and press @kbd{M-@key{TAB}} to see possible
11467 completions.  If you need such a symbol inside a word, terminate it
11468 with a pair of curly brackets.  For example
11470 @example
11471 Pro tip: Given a circle \Gamma of diameter d, the length of its
11472 circumference is \pi@{@}d.
11473 @end example
11475 @findex org-entities-help
11476 @vindex org-entities-user
11477 A large number of entities is provided, with names taken from both
11478 HTML and @LaTeX{}; you can comfortably browse the complete list from
11479 a dedicated buffer using the command @code{org-entities-help}.  It is also
11480 possible to provide your own special symbols in the variable
11481 @code{org-entities-user}.
11483 During export, these symbols are transformed into the native format of
11484 the exporter back-end.  Strings like @samp{\alpha} are exported as @samp{&alpha;} in
11485 the HTML output, and as @samp{\(\alpha\)} in the @LaTeX{} output.  Similarly, @samp{\nbsp}
11486 becomes @samp{&nbsp;} in HTML and @samp{~} in @LaTeX{}.
11488 @cindex escaping characters
11489 Entities may also be used as a way to escape markup in an Org
11490 document, e.g., @samp{\under@{@}not underlined\under} exports as @samp{_not underlined_}.
11492 @cindex special symbols, in-buffer display
11493 If you would like to see entities displayed as UTF-8 characters, use
11494 the following command@footnote{You can turn this on by default by setting the variable
11495 @code{org-pretty-entities}, or on a per-file base with the @samp{STARTUP} option
11496 @samp{entitiespretty}.}:
11498 @table @asis
11499 @item @kbd{C-c C-x \} (@code{org-toggle-pretty-entities})
11500 @kindex C-c C-x \
11501 @findex org-toggle-pretty-entities
11503 Toggle display of entities as UTF-8 characters.  This does not
11504 change the buffer content which remains plain ASCII, but it
11505 overlays the UTF-8 character for display purposes only.
11506 @end table
11508 @cindex shy hyphen, special symbol
11509 @cindex dash, special symbol
11510 @cindex ellipsis, special symbol
11511 In addition to regular entities defined above, Org exports in
11512 a special way@footnote{This behavior can be disabled with @samp{-} export setting (see
11513 @ref{Export Settings}).} the following commonly used character
11514 combinations: @samp{\-} is treated as a shy hyphen, @samp{--} and @samp{---} are
11515 converted into dashes, and @samp{...} becomes a compact set of dots.
11517 @node Subscripts and Superscripts
11518 @section Subscripts and Superscripts
11520 @cindex subscript
11521 @cindex superscript
11523 @samp{^} and @samp{_} are used to indicate super- and subscripts.  To increase
11524 the readability of ASCII text, it is not necessary, but OK, to
11525 surround multi-character sub- and superscripts with curly braces.  For
11526 example
11528 @example
11529 The radius of the sun is R_sun = 6.96 x 10^8 m.  On the other hand,
11530 the radius of Alpha Centauri is R_@{Alpha Centauri@} = 1.28 x R_@{sun@}.
11531 @end example
11533 @vindex org-use-sub-superscripts
11534 If you write a text where the underscore is often used in a different
11535 context, Org's convention to always interpret these as subscripts can
11536 get in your way.  Configure the variable @code{org-use-sub-superscripts} to
11537 change this convention.  For example, when setting this variable to
11538 @code{@{@}}, @samp{a_b} is not interpreted as a subscript, but @samp{a_@{b@}} is.
11540 @table @asis
11541 @item @kbd{C-c C-x \} (@code{org-toggle-pretty-entities~})
11542 @kindex C-c C-x \
11543 @findex org-toggle-pretty-entities
11545 In addition to showing entities as UTF-8 characters, this command
11546 also formats sub- and superscripts in a WYSIWYM way.
11547 @end table
11549 @node Embedded @LaTeX{}
11550 @section Embedded @LaTeX{}
11552 @cindex @TeX{} interpretation
11553 @cindex @LaTeX{} interpretation
11555 Plain ASCII is normally sufficient for almost all note taking.
11556 Exceptions include scientific notes, which often require mathematical
11557 symbols and the occasional formula.  @LaTeX{}@footnote{@LaTeX{} is a macro system based on Donald@tie{}E.@tie{}Knuth's @TeX{}
11558 system.  Many of the features described here as ``@LaTeX{}'' are really
11559 from @TeX{}, but for simplicity I am blurring this distinction.} is widely used to
11560 typeset scientific documents.  Org mode supports embedding @LaTeX{} code
11561 into its files, because many academics are used to writing and reading
11562 @LaTeX{} source code, and because it can be readily processed to produce
11563 pretty output for a number of export back-ends.
11565 @menu
11566 * @LaTeX{} fragments::           Complex formulas made easy.
11567 * Previewing @LaTeX{} fragments:: What will this snippet look like?
11568 * CD@LaTeX{} mode::              Speed up entering of formulas.
11569 @end menu
11571 @node @LaTeX{} fragments
11572 @subsection @LaTeX{} fragments
11574 @cindex @LaTeX{} fragments
11576 @vindex org-format-latex-header
11577 Org mode can contain @LaTeX{} math fragments, and it supports ways to
11578 process these for several export back-ends.  When exporting to @LaTeX{},
11579 the code is left as it is.  When exporting to HTML, Org can use either
11580 @uref{http://www.mathjax.org, MathJax} (see @ref{Math formatting in HTML export}) or transcode the math
11581 into images (see @ref{Previewing @LaTeX{} fragments}).
11583 @LaTeX{} fragments do not need any special marking at all.  The following
11584 snippets are identified as @LaTeX{} source code:
11586 @itemize
11587 @item
11588 Environments of any kind@footnote{When MathJax is used, only the environments recognized by
11589 MathJax are processed.  When dvipng, dvisvgm, or ImageMagick suite is
11590 used to create images, any @LaTeX{} environment is handled.}.  The only requirement is that the
11591 @samp{\begin} statement appears on a new line, preceded by only
11592 whitespace.
11594 @item
11595 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts
11596 with currency specifications, single @samp{$} characters are only
11597 recognized as math delimiters if the enclosed text contains at most
11598 two line breaks, is directly attached to the @samp{$} characters with no
11599 whitespace in between, and if the closing @samp{$} is followed by
11600 whitespace, punctuation or a dash.  For the other delimiters, there
11601 is no such restriction, so when in doubt, use @samp{\(...\)} as inline
11602 math delimiters.
11603 @end itemize
11605 @noindent
11606 For example:
11608 @example
11609 \begin@{equation@}                        % arbitrary environments,
11610 x=\sqrt@{b@}                              % even tables, figures
11611 \end@{equation@}                          % etc
11613 If $a^2=b$ and \( b=2 \), then the solution must be
11614 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
11615 @end example
11617 @vindex org-export-with-latex
11618 @LaTeX{} processing can be configured with the variable
11619 @code{org-export-with-latex}.  The default setting is @code{t} which means
11620 MathJax for HTML, and no processing for ASCII and @LaTeX{} back-ends.
11621 You can also set this variable on a per-file basis using one of these
11622 lines:
11624 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
11625 @item @samp{#+OPTIONS: tex:t}
11626 @tab Do the right thing automatically (MathJax)
11627 @item @samp{#+OPTIONS: tex:nil}
11628 @tab Do not process @LaTeX{} fragments at all
11629 @item @samp{#+OPTIONS: tex:verbatim}
11630 @tab Verbatim export, for jsMath or so
11631 @end multitable
11633 @node Previewing @LaTeX{} fragments
11634 @subsection Previewing @LaTeX{} fragments
11636 @cindex @LaTeX{} fragments, preview
11638 @vindex org-preview-latex-default-process
11639 If you have a working @LaTeX{} installation and @samp{dvipng}, @samp{dvisvgm} or
11640 @samp{convert} installed@footnote{These are respectively available at
11641 @uref{http://sourceforge.net/projects/dvipng/}, @uref{http://dvisvgm.bplaced.net/}
11642 and from the ImageMagick suite.  Choose the converter by setting the
11643 variable @code{org-preview-latex-default-process} accordingly.}, @LaTeX{} fragments can be processed to
11644 produce images of the typeset expressions to be used for inclusion
11645 while exporting to HTML (see @ref{@LaTeX{} fragments}), or for inline
11646 previewing within Org mode.
11648 @vindex org-format-latex-options
11649 @vindex org-format-latex-header
11650 You can customize the variables @code{org-format-latex-options} and
11651 @code{org-format-latex-header} to influence some aspects of the preview.
11652 In particular, the @code{:scale} (and for HTML export, @code{:html-scale})
11653 property of the former can be used to adjust the size of the preview
11654 images.
11656 @table @asis
11657 @item @kbd{C-c C-x C-l} (@code{org-toggle-latex-fragment})
11658 @kindex C-c C-x C-l
11659 @findex org-toggle-latex-fragment
11661 Produce a preview image of the @LaTeX{} fragment at point and
11662 overlay it over the source code.  If there is no fragment at
11663 point, process all fragments in the current entry (between two
11664 headlines).  When called with a prefix argument, process the
11665 entire subtree.  When called with two prefix arguments, or when
11666 the cursor is before the first headline, process the entire
11667 buffer.
11668 @end table
11670 @vindex org-startup-with-latex-preview
11671 You can turn on the previewing of all @LaTeX{} fragments in a file with
11673 @example
11674 #+STARTUP: latexpreview
11675 @end example
11677 To disable it, simply use
11679 @example
11680 #+STARTUP: nolatexpreview
11681 @end example
11683 @node CD@LaTeX{} mode
11684 @subsection Using CD@LaTeX{} to enter math
11686 @cindex CD@LaTeX{}
11688 CD@LaTeX{} mode is a minor mode that is normally used in combination with
11689 a major @LaTeX{} mode like AUC@TeX{} in order to speed-up insertion of
11690 environments and math templates.  Inside Org mode, you can make use of
11691 some of the features of CD@LaTeX{} mode.  You need to install
11692 @samp{cdlatex.el} and @samp{texmathp.el} (the latter comes also with AUC@TeX{})
11693 from @uref{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.  Do not use
11694 CD@LaTeX{} mode itself under Org mode, but use the light version
11695 @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it on for the
11696 current buffer with @kbd{M-x org-cdlatex-mode}, or for all Org
11697 files with
11699 @lisp
11700 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
11701 @end lisp
11703 When this mode is enabled, the following features are present (for
11704 more details see the documentation of CD@LaTeX{} mode):
11706 @table @asis
11707 @item @kbd{C-c @{}
11708 @kindex C-c @{
11710 Insert an environment template.
11712 @item @kbd{@key{TAB}}
11713 @kindex TAB
11715 The @kbd{@key{TAB}} key expands the template if the cursor is
11716 inside a @LaTeX{} fragment@footnote{Org mode has a method to test if the cursor is inside such
11717 a fragment, see the documentation of the function
11718 @code{org-inside-LaTeX-fragment-p}.}.  For example, @kbd{@key{TAB}}
11719 expands @samp{fr} to @samp{\frac@{@}@{@}} and position the cursor correctly
11720 inside the first brace.  Another @kbd{@key{TAB}} gets you into the
11721 second brace.
11723 Even outside fragments, @kbd{@key{TAB}} expands environment
11724 abbreviations at the beginning of a line.  For example, if you
11725 write @samp{equ} at the beginning of a line and press @kbd{@key{TAB}},
11726 this abbreviation is expanded to an @samp{equation} environment.  To
11727 get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
11729 @item @kbd{^}
11730 @itemx @kbd{_}
11731 @kindex _
11732 @kindex ^
11733 @vindex cdlatex-simplify-sub-super-scripts
11735 Pressing @kbd{_} and @kbd{^} inside a @LaTeX{} fragment
11736 inserts these characters together with a pair of braces.  If you
11737 use @kbd{@key{TAB}} to move out of the braces, and if the braces
11738 surround only a single character or macro, they are removed again
11739 (depending on the variable @code{cdlatex-simplify-sub-super-scripts}).
11741 @item @kbd{`}
11742 @kindex `
11744 Pressing the backquote followed by a character inserts math
11745 macros, also outside @LaTeX{} fragments.  If you wait more than 1.5
11746 seconds after the backquote, a help window pops up.
11748 @item @kbd{'}
11749 @kindex '
11751 Pressing the single-quote followed by another character modifies
11752 the symbol before point with an accent or a font.  If you wait
11753 more than 1.5 seconds after the single-quote, a help window pops
11754 up.  Character modification works only inside @LaTeX{} fragments;
11755 outside the quote is normal.
11756 @end table
11758 @node Exporting
11759 @chapter Exporting
11761 @cindex exporting
11763 Sometimes, you may want to pretty print your notes, publish them on
11764 the web or even share them with people not using Org.  In these cases,
11765 the Org export facilities can be used to convert your documents to
11766 a variety of other formats, while retaining as much structure (see
11767 @ref{Document Structure}) and markup (see @ref{Markup}) as
11768 possible.
11770 @cindex export back-end
11771 Libraries responsible for such translation are called back-ends.  Org
11772 ships with the following ones
11774 @itemize
11775 @item
11776 @emph{ascii} (ASCII format)
11777 @item
11778 @emph{beamer} (@LaTeX{} Beamer format)
11779 @item
11780 @emph{html} (HTML format)
11781 @item
11782 @emph{icalendar} (iCalendar format)
11783 @item
11784 @emph{latex} (@LaTeX{} format)
11785 @item
11786 @emph{md} (Markdown format)
11787 @item
11788 @emph{odt} (OpenDocument Text format)
11789 @item
11790 @emph{org} (Org format)
11791 @item
11792 @emph{texinfo} (Texinfo format)
11793 @item
11794 @emph{man} (Man page format)
11795 @end itemize
11797 @noindent
11798 Org also uses additional libraries located in @samp{contrib/} directory
11799 (see @ref{Installation}).  Users can install additional export libraries
11800 for additional formats from the Emacs packaging system.  For easy
11801 discovery, these packages have a common naming scheme: @code{ox-NAME},
11802 where @var{NAME} is one of the formats.  For example,
11803 @code{ox-koma-letter} @emph{koma-letter} back-end.
11805 @vindex org-export-backends
11806 Org loads back-ends for the following formats by default: ASCII, HTML,
11807 iCalendar, @LaTeX{} and ODT.  Org can load additional back-ends either of
11808 two ways: through the @code{org-export-backends} variable configuration;
11809 or, by requiring the library in the Emacs init file like this:
11811 @lisp
11812 (require 'ox-md)
11813 @end lisp
11815 @menu
11816 * The Export Dispatcher::        The main interface.
11817 * Export Settings::              Common export settings.
11818 * Table of Contents::            The if and where of the table of contents.
11819 * Include Files::                Include additional files into a document.
11820 * Macro Replacement::            Use macros to create templates.
11821 * Comment Lines::                What will not be exported.
11822 * ASCII/Latin-1/UTF-8 export::   Exporting to flat files with encoding.
11823 * Beamer Export::
11824 * HTML Export::                  Exporting to HTML.
11825 * @LaTeX{} Export::              Exporting to @LaTeX{} and processing to PDF.
11826 * Markdown Export::              Exporting to Markdown.
11827 * OpenDocument Text Export::     Exporting to OpenDocument Text.
11828 * Org Export::                   Exporting to Org.
11829 * Texinfo Export::               Exporting to Texinfo.
11830 * iCalendar Export::             Exporting to iCalendar.
11831 * Other Built-in Back-ends::     Exporting to a man page.
11832 * Advanced Configuration::       Fine-tuning the export output.
11833 * Export in Foreign Buffers::    Author tables and lists in Org syntax.
11834 @end menu
11836 @node The Export Dispatcher
11837 @section The Export Dispatcher
11839 @cindex dispatcher, for export commands
11840 @cindex Export, dispatcher
11842 The export dispatcher is the main interface for Org's exports.
11843 A hierarchical menu presents the currently configured export formats.
11844 Options are shown as easy toggle switches on the same screen.
11846 @vindex org-export-dispatch-use-expert-ui
11847 Org also has a minimal prompt interface for the export dispatcher.
11848 When the variable @code{org-export-dispatch-use-expert-ui} is set to
11849 a non-@code{nil} value, Org prompts in the minibuffer.  To switch back to
11850 the hierarchical menu, press @kbd{?}.
11852 @table @asis
11853 @item @kbd{C-c C-e} (@code{org-export})
11854 @kindex C-c C-e
11855 @findex org-export
11857 Invokes the export dispatcher interface.  The options show
11858 default settings.  The @kbd{C-u} prefix argument preserves
11859 options from the previous export, including any sub-tree
11860 selections.
11861 @end table
11863 Org exports the entire buffer by default.  If the Org buffer has an
11864 active region, then Org exports just that region.
11866 Within the dispatcher interface, the following key combinations can
11867 further alter what is exported, and how.
11869 @table @asis
11870 @item @kbd{C-a}
11871 @kindex C-c C-e C-a
11873 Toggle asynchronous export.  Asynchronous export uses an external
11874 Emacs process with a specially configured initialization file to
11875 complete the exporting process in the background thereby
11876 releasing the current interface.  This is particularly useful
11877 when exporting long documents.
11879 Output from an asynchronous export is saved on the ``the export
11880 stack''.  To view this stack, call the export dispatcher with
11881 a double @kbd{C-u} prefix argument.  If already in the
11882 export dispatcher menu, @kbd{&} displays the stack.
11884 @vindex org-export-async-init-file
11885 To make the background export process the default, customize the
11886 variable, @code{org-export-in-background}.  Additionally, you can set
11887 the initialization file used by the background process with
11888 @code{org-export-async-init-file}.
11890 @vindex org-export-in-background
11891 You can make asynchronous export the default by setting
11892 @code{org-export-in-background}.
11894 @item @kbd{C-b}
11895 @kindex C-c C-e C-b
11897 Toggle body-only export.  Useful for excluding headers and
11898 footers in the export.  Affects only those back-end formats that
11899 have such sections---like @samp{<head>...</head>} in HTML.
11901 @item @{@{@{kbd(C-s@}@}@}
11902 @kindex C-c C-e C-s
11904 Toggle sub-tree export.  When turned on, Org exports only the
11905 sub-tree starting from the cursor position at the time the export
11906 dispatcher was invoked.  Org uses the top heading of this
11907 sub-tree as the document's title.  If the cursor is not on
11908 a heading, Org uses the nearest enclosing header.  If the cursor
11909 is in the document preamble, Org signals an error and aborts
11910 export.
11912 @vindex org-export-initial-scope
11913 To make the sub-tree export the default, customize the variable
11914 @code{org-export-initial-scope}.
11916 @item @kbd{C-v}
11917 @kindex C-c C-e C-v
11919 Toggle visible-only export.  Useful for exporting only visible
11920 parts of an Org document by adjusting outline visibility
11921 settings.
11922 @end table
11924 @node Export Settings
11925 @section Export Settings
11927 @cindex options, for export
11928 @cindex Export, settings
11930 @cindex @samp{OPTIONS}, keyword
11931 Export options can be set: globally with variables; for an individual
11932 file by making variables buffer-local with in-buffer settings (see
11933 @ref{In-buffer Settings}), by setting individual keywords, or by
11934 specifying them in a compact form with the @samp{OPTIONS} keyword; or for
11935 a tree by setting properties (see @ref{Properties and Columns}).  Options
11936 set at a specific level override options set at a more general level.
11938 @cindex SETUPFILE, keyword
11939 In-buffer settings may appear anywhere in the file, either directly or
11940 indirectly through a file included using @samp{#+SETUPFILE: filename or
11941 URL} syntax.  Option keyword sets tailored to a particular back-end
11942 can be inserted from the export dispatcher (see @ref{The Export Dispatcher}) using the @samp{Insert template} command by pressing
11943 @kbd{#}.  To insert keywords individually, a good way to make
11944 sure the keyword is correct is to type @samp{#+} and then to use
11945 @kbd{M-@key{TAB}}@footnote{Many desktops intercept @kbd{M-@key{TAB}} to switch windows.
11946 Use @kbd{C-M-i} or @kbd{@key{ESC} @key{TAB}} instead.} for completion.
11948 The export keywords available for every back-end, and their equivalent
11949 global variables, include:
11951 @table @asis
11952 @item @samp{AUTHOR}
11953 @cindex @samp{AUTHOR}, keyword
11954 @vindex user-full-name
11955 The document author (@code{user-full-name}).
11957 @item @samp{CREATOR}
11958 @cindex @samp{CREATOR}, keyword
11959 @vindex org-expot-creator-string
11960 Entity responsible for output generation
11961 (@code{org-export-creator-string}).
11963 @item @samp{DATE}
11964 @cindex @samp{DATE}, keyword
11965 @vindex org-export-date-timestamp-format
11966 A date or a time-stamp@footnote{The variable @code{org-export-date-timestamp-format} defines how
11967 this timestamp are exported.}.
11969 @item @samp{EMAIL}
11970 @cindex @samp{EMAIL}, keyword
11971 @vindex user-mail-address
11972 The email address (@code{user-mail-address}).
11974 @item @samp{LANGUAGE}
11975 @cindex @samp{LANGUAGE}, keyword
11976 @vindex org-export-default-language
11977 Language to use for translating certain strings
11978 (@code{org-export-default-language}).  With @samp{#+LANGUAGE: fr}, for
11979 example, Org translates @samp{Table of contents} to the French @samp{Table
11980      des matières}.
11982 @item @samp{SELECT_TAGS}
11983 @cindex @samp{SELECT_TAGS}, keyword
11984 @vindex org-export-select-tags
11985 The default value is @code{("export")}.  When a tree is tagged with
11986 @samp{export} (@code{org-export-select-tags}), Org selects that tree and
11987 its sub-trees for export.  Org excludes trees with @samp{noexport}
11988 tags, see below.  When selectively exporting files with @samp{export}
11989 tags set, Org does not export any text that appears before the
11990 first headline.
11992 @item @samp{EXCLUDE_TAGS}
11993 @cindex @samp{EXCLUDE_TAGS}, keyword
11994 @vindex org-export-exclude-tags
11995 The default value is @code{("noexport")}.  When a tree is tagged with
11996 @samp{noexport} (@code{org-export-exclude-tags}), Org excludes that tree
11997 and its sub-trees from export.  Entries tagged with @samp{noexport}
11998 are unconditionally excluded from the export, even if they have
11999 an @samp{export} tag.  Even if a sub-tree is not exported, Org
12000 executes any code blocks contained there.
12002 @item @samp{TITLE}
12003 @cindex @samp{TITLE}, keyword
12004 @cindex document title
12005 Org displays this title.  For long titles, use multiple @samp{#+TITLE}
12006 lines.
12008 @item @samp{EXPORT_FILE_NAME}
12009 @cindex @samp{EXPORT_FILE_NAME}, keyword
12010 The name of the output file to be generated.  Otherwise, Org
12011 generates the file name based on the buffer name and the
12012 extension based on the back-end format.
12013 @end table
12015 The @samp{OPTIONS} keyword is a compact form.  To configure multiple
12016 options, use several @samp{OPTIONS} lines.  @samp{OPTIONS} recognizes the
12017 following arguments.
12019 @table @asis
12020 @item @code{'}
12021 @vindex org-export-with-smart-quotes
12022 Toggle smart quotes (@code{org-export-with-smart-quotes}).  Depending
12023 on the language used, when activated, Org treats pairs of double
12024 quotes as primary quotes, pairs of single quotes as secondary
12025 quotes, and single quote marks as apostrophes.
12027 @item @code{*}
12028 @vindex org-export-with-emphasize
12029 Toggle emphasized text (@code{org-export-with-emphasize}).
12031 @item @code{-}
12032 @vindex org-export-with-special-strings
12033 Toggle conversion of special strings
12034 (@code{org-export-with-special-strings}).
12036 @item @code{:}
12037 @vindex org-export-with-fixed-width
12038 Toggle fixed-width sections (@code{org-export-with-fixed-width}).
12040 @item @code{<}
12041 @vindex org-export-with-timestamps
12042 Toggle inclusion of time/date active/inactive stamps
12043 (@code{org-export-with-timestamps}).
12045 @item @code{\n}
12046 @vindex org-export-preserve-breaks
12047 Toggles whether to preserve line breaks
12048 (@code{org-export-preserve-breaks}).
12050 @item @code{^}
12051 @vindex org-export-with-sub-superscripts
12052 Toggle @TeX{}-like syntax for sub- and superscripts.  If you write
12053 @samp{^:@{@}}, @samp{a_@{b@}} is interpreted, but the simple @samp{a_b} is left as
12054 it is (@code{org-export-with-sub-superscripts}).
12056 @item @code{arch}
12057 @vindex org-export-with-archived-trees
12058 Configure how archived trees are exported.  When set to
12059 @code{headline}, the export process skips the contents and processes
12060 only the headlines (@code{org-export-with-archived-trees}).
12062 @item @code{author}
12063 @vindex org-export-with-author
12064 Toggle inclusion of author name into exported file
12065 (@code{org-export-with-author}).
12067 @item @code{broken-links}
12068 @vindex org-export-with-broken-links
12069 Toggles if Org should continue exporting upon finding a broken
12070 internal link.  When set to @code{mark}, Org clearly marks the problem
12071 link in the output (@code{org-export-with-broken-links}).
12073 @item @code{c}
12074 @vindex org-export-with-clocks
12075 Toggle inclusion of CLOCK keywords (@code{org-export-with-clocks}).
12077 @item @code{creator}
12078 @vindex org-export-with-creator
12079 Toggle inclusion of creator information in the exported file
12080 (@code{org-export-with-creator}).
12082 @item @code{d}
12083 @vindex org-export-with-drawers
12084 Toggles inclusion of drawers, or list of drawers to include, or
12085 list of drawers to exclude (@code{org-export-with-drawers}).
12087 @item @code{date}
12088 @vindex org-export-with-date
12089 Toggle inclusion of a date into exported file
12090 (@code{org-export-with-date}).
12092 @item @code{e}
12093 @vindex org-export-with-entities
12094 Toggle inclusion of entities (@code{org-export-with-entities}).
12096 @item @code{email}
12097 @vindex org-export-with-email
12098 Toggle inclusion of the author's e-mail into exported file
12099 (@code{org-export-with-email}).
12101 @item @code{f}
12102 @vindex org-export-with-footnotes
12103 Toggle the inclusion of footnotes (@code{org-export-with-footnotes}).
12105 @item @code{H}
12106 @vindex org-export-headline-levels
12107 Set the number of headline levels for export
12108 (@code{org-export-headline-levels}).  Below that level, headlines are
12109 treated differently.  In most back-ends, they become list items.
12111 @item @code{inline}
12112 @vindex org-export-with-inlinetasks
12113 Toggle inclusion of inlinetasks (@code{org-export-with-inlinetasks}).
12115 @item @code{num}
12116 @vindex org-export-with-section-numbers
12117 @cindex @samp{UNNUMBERED}, property
12118 Toggle section-numbers (@code{org-export-with-section-numbers}).  When
12119 set to number N, Org numbers only those headlines at level N or
12120 above.  Set @samp{UNNUMBERED} property to non-@code{nil} to disable
12121 numbering of heading and subheadings entirely.  Moreover, when
12122 the value is @samp{notoc} the headline, and all its children, do not
12123 appear in the table of contents either (see @ref{Table of Contents}).
12125 @item @code{p}
12126 @vindex org-export-with-planning
12127 Toggle export of planning information
12128 (@code{org-export-with-planning}).  ``Planning information'' comes from
12129 lines located right after the headline and contain any
12130 combination of these cookies: @samp{SCHEDULED}, @samp{DEADLINE}, or
12131 @samp{CLOSED}.
12133 @item @code{pri}
12134 @vindex org-export-with-priority
12135 Toggle inclusion of priority cookies
12136 (@code{org-export-with-priority}).
12138 @item @code{prop}
12139 @vindex org-export-with-properties
12140 Toggle inclusion of property drawers, or list the properties to
12141 include (@code{org-export-with-properties}).
12143 @item @code{stat}
12144 @vindex org-export-with-statistics-cookies
12145 Toggle inclusion of statistics cookies
12146 (@code{org-export-with-statistics-cookies}).
12148 @item @code{tags}
12149 @vindex org-export-with-tags
12150 Toggle inclusion of tags, may also be @code{not-in-toc}
12151 (@code{org-export-with-tags}).
12153 @item @code{tasks}
12154 @vindex org-export-with-tasks
12155 Toggle inclusion of tasks (TODO items); or @code{nil} to remove all
12156 tasks; or @code{todo} to remove DONE tasks; or list the keywords to
12157 keep (@code{org-export-with-tasks}).
12159 @item @code{tex}
12160 @vindex org-export-with-latex
12161 @code{nil} does not export; @code{t} exports; @code{verbatim} keeps everything
12162 in verbatim (@code{org-export-with-latex}).
12164 @item @code{timestamp}
12165 @vindex org-export-time-stamp-file
12166 Toggle inclusion of the creation time in the exported file
12167 (@code{org-export-time-stamp-file}).
12169 @item @code{title}
12170 @vindex org-export-with-title
12171 Toggle inclusion of title (@code{org-export-with-title}).
12173 @item @code{toc}
12174 @vindex org-export-with-toc
12175 Toggle inclusion of the table of contents, or set the level limit
12176 (@code{org-export-with-toc}).
12178 @item @code{todo}
12179 @vindex org-export-with-todo-keywords
12180 Toggle inclusion of TODO keywords into exported text
12181 (@code{org-export-with-todo-keywords}).
12183 @item @code{|}
12184 @vindex org-export-with-tables
12185 Toggle inclusion of tables (@code{org-export-with-tables}).
12186 @end table
12188 When exporting sub-trees, special node properties in them can override
12189 the above keywords.  They are special because they have an @samp{EXPORT_}
12190 prefix.  For example, @samp{DATE} and @samp{EXPORT_FILE_NAME} keywords become,
12191 respectively, @samp{EXPORT_DATE} and @samp{EXPORT_FILE_NAME}.  Except for
12192 @samp{SETUPFILE}, all other keywords listed above have an @samp{EXPORT_}
12193 equivalent.
12195 @cindex @samp{BIND}, keyword
12196 @vindex org-export-allow-bind-keywords
12197 If @code{org-export-allow-bind-keywords} is non-@code{nil}, Emacs variables can
12198 become buffer-local during export by using the @samp{BIND} keyword.  Its
12199 syntax is @samp{#+BIND: variable value}.  This is particularly useful for
12200 in-buffer settings that cannot be changed using keywords.
12202 @node Table of Contents
12203 @section Table of Contents
12205 @cindex table of contents
12206 @cindex list of tables
12207 @cindex list of listings
12209 @cindex @samp{toc}, in @samp{OPTIONS} keyword
12210 @vindex org-export-with-toc
12211 The table of contents includes all headlines in the document.  Its
12212 depth is therefore the same as the headline levels in the file.  If
12213 you need to use a different depth, or turn it off entirely, set the
12214 @code{org-export-with-toc} variable accordingly.  You can achieve the same
12215 on a per file basis, using the following @samp{toc} item in @samp{OPTIONS}
12216 keyword:
12218 @example
12219 #+OPTIONS: toc:2          (only include two levels in TOC)
12220 #+OPTIONS: toc:nil        (no default TOC at all)
12221 @end example
12223 @cindex excluding entries from table of contents
12224 @cindex table of contents, exclude entries
12225 Org includes both numbered and unnumbered headlines in the table of
12226 contents@footnote{At the moment, some export back-ends do not obey this
12227 specification.  For example, @LaTeX{} export excludes every unnumbered
12228 headline from the table of contents.}.  If you need to exclude an unnumbered headline,
12229 along with all its children, set the @samp{UNNUMBERED} property to @samp{notoc}
12230 value.
12232 @example
12233 * Subtree not numbered, not in table of contents either
12234   :PROPERTIES:
12235   :UNNUMBERED: notoc
12236   :END:
12237 @end example
12239 @cindex @samp{TOC}, keyword
12240 Org normally inserts the table of contents directly before the first
12241 headline of the file.  To move the table of contents to a different
12242 location, first turn off the default with @code{org-export-with-toc}
12243 variable or with @samp{#+OPTIONS: toc:nil}.  Then insert @samp{#+TOC: headlines
12244 N} at the desired location(s).
12246 @example
12247 #+OPTIONS: toc:nil
12249 #+TOC: headlines 2
12250 @end example
12252 To adjust the table of contents depth for a specific section of the
12253 Org document, append an additional @samp{local} parameter.  This parameter
12254 becomes a relative depth for the current level.  The following example
12255 inserts a local table of contents, with direct children only.
12257 @example
12258 * Section
12259 #+TOC: headlines 1 local
12260 @end example
12262 Note that for this feature to work properly in @LaTeX{} export, the Org
12263 file requires the inclusion of the titletoc package.  Because of
12264 compatibility issues, titletoc has to be loaded @emph{before} hyperref.
12265 Customize the @code{org-latex-default-packages-alist} variable.
12267 Use the @samp{TOC} keyword to generate list of tables---respectively, all
12268 listings---with captions.
12270 @example
12271 #+TOC: listings
12272 #+TOC: tables
12273 @end example
12275 @cindex @samp{ALT_TITLE}, property
12276 Normally Org uses the headline for its entry in the table of contents.
12277 But with @samp{ALT_TITLE} property, a different entry can be specified for
12278 the table of contents.
12280 @node Include Files
12281 @section Include Files
12283 @cindex include files, during export
12284 @cindex Export, include files
12285 @cindex @samp{INCLUDE}, keyword
12287 During export, you can include the content of another file.  For
12288 example, to include your @samp{.emacs} file, you could use:
12290 @example
12291 #+INCLUDE: "~/.emacs" src emacs-lisp
12292 @end example
12294 @noindent
12295 The optional second and third parameter are the markup (e.g., @samp{quote},
12296 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the language for
12297 formatting the contents.  The markup is optional; if it is not given,
12298 assume text is in Org syntax and process it normally.  The @samp{INCLUDE}
12299 keyword also allows additional parameters @samp{:prefix1} and @samp{:prefix} to
12300 specify prefixes for the first line and for each following line,
12301 @samp{:minlevel} in order to get Org mode content demoted to a specified
12302 level, as well as any options accepted by the selected markup.  For
12303 example, to include a file as an item, use:
12305 @example
12306 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
12307 @end example
12309 You can also include a portion of a file by specifying a lines range
12310 using the @samp{:lines} parameter.  The line at the upper end of the range
12311 is not included.  The start and/or the end of the range may be omitted
12312 to use the obvious defaults.
12314 @table @asis
12315 @item @samp{#+INCLUDE: "~/.emacs" :lines "5-10"}
12316 Include lines 5 to 10, 10 excluded.
12318 @item @samp{#+INCLUDE: "~/.emacs" :lines "-10"} 
12319 Include lines 1 to 10, 10 excluded.
12321 @item @samp{#+INCLUDE: "~/.emacs" :lines "10-"} 
12322 Include lines from 10 to EOF.
12323 @end table
12325 You can visit the file being included with the following command.
12327 @table @asis
12328 @item @kbd{C-c '} (@code{org-edit~special})
12329 @kindex C-c '
12330 @findex org-edit-special
12332 Visit the include file at point.
12333 @end table
12335 @node Macro Replacement
12336 @section Macro Replacement
12338 @cindex macro replacement, during export
12339 @cindex @samp{MACRO}, keyword
12341 @vindex org-export-global-macros
12342 Macros replace text snippets during export.  Macros are defined
12343 globally in @code{org-export-global-macros}, or document-wise with the
12344 following syntax:
12346 @example
12347 #+MACRO: name   replacement text; $1, $2 are arguments
12348 @end example
12350 @noindent
12351 which can be referenced using @samp{@{@{@{name(arg1, arg2)@}@}@}}@footnote{Since commas separate the arguments, commas within arguments
12352 have to be escaped with the backslash character.  So only those
12353 backslash characters before a comma need escaping with another
12354 backslash character.}.  For
12355 example
12357 @example
12358 #+MACRO: poem The rose is $1, The violet's $2. Life's ordered: Org assists you.
12359 @{@{@{poem(red,blue)@}@}@}
12360 @end example
12362 @noindent
12363 becomes
12365 @example
12366 The rose is red, The violet's blue. Life's ordered: Org assists you.
12367 @end example
12369 As a special case, Org parses any replacement text starting with
12370 @samp{(eval} as an Emacs Lisp expression and evaluates it accordingly.
12371 Within such templates, arguments become strings.  Thus, the following
12372 macro
12374 @example
12375 #+MACRO: gnucheck (eval (concat "GNU/" (capitalize $1)))
12376 @end example
12378 @noindent
12379 turns @samp{@{@{@{gnucheck(linux)@}@}@}} into @samp{GNU/Linux} during export.
12381 Org recognizes macro references in following Org markup areas:
12382 paragraphs, headlines, verse blocks, tables cells and lists.  Org also
12383 recognizes macro references in keywords, such as @samp{CAPTION}, @samp{TITLE},
12384 @samp{AUTHOR}, @samp{DATE}, and for some back-end specific export options.
12386 Org comes with following pre-defined macros:
12388 @table @asis
12389 @item @samp{@{@{@{keyword(NAME)@}@}@}}
12390 @itemx @samp{@{@{@{title@}@}@}}
12391 @itemx @samp{@{@{@{author@}@}@}}
12392 @itemx @samp{@{@{@{email@}@}@}}
12393 @cindex @samp{keyword}, macro
12394 @cindex @samp{title}, macro
12395 @cindex @samp{author}, macro
12396 @cindex @samp{email}, macro
12397 The @samp{keyword} macro collects all values from @var{NAME}
12398 keywords throughout the buffer, separated with white space.
12399 @samp{title}, @samp{author} and @samp{email} macros are shortcuts for,
12400 respectively, @samp{@{@{@{keyword(TITLE)@}@}@}}, @samp{@{@{@{keyword(AUTHOR)@}@}@}} and
12401 @samp{@{@{@{keyword(EMAIL)@}@}@}}.
12403 @item @samp{@{@{@{date@}@}@}}
12404 @itemx @samp{@{@{@{date(FORMAT)@}@}@}}
12405 @cindex @samp{date}, macro
12406 This macro refers to the @samp{DATE} keyword.  @var{FORMAT} is an
12407 optional argument to the @samp{date} macro that is used only if @samp{DATE}
12408 is a single timestamp.  @var{FORMAT} should be a format
12409 string understood by @code{format-time-string}.
12411 @item @samp{@{@{@{time(FORMAT)@}@}@}}
12412 @itemx @samp{@{@{@{modification-time(FORMAT, VC)@}@}@}}
12413 @cindex @samp{time}, macro
12414 @cindex @samp{modification-time}, macro
12415 These macros refer to the document's date and time of export and
12416 date and time of modification.  @var{FORMAT} is a string
12417 understood by @code{format-time-string}.  If the second argument to
12418 the @code{modification-time} macro is non-@code{nil}, Org uses @samp{vc.el} to
12419 retrieve the document's modification time from the version
12420 control system.  Otherwise Org reads the file attributes.
12422 @item @samp{@{@{@{input-file@}@}@}}
12423 @cindex @samp{input-file}, macro
12424 This macro refers to the filename of the exported file.
12426 @item @samp{@{@{@{property(PROPERTY-NAME)@}@}@}}
12427 @itemx @samp{@{@{@{property(PROPERTY-NAME, SEARCH OPTION)@}@}@}}
12428 @cindex @samp{property}, macro
12429 This macro returns the value of property @var{PROPERTY-NAME}
12430 in the current entry.  If @var{SEARCH-OPTION} (see @ref{Search Options}) refers to a remote entry, use it instead.
12432 @item @samp{@{@{@{n@}@}@}}
12433 @itemx @samp{@{@{@{n(NAME)@}@}@}}
12434 @itemx @samp{@{@{@{n(NAME, ACTION)@}@}@}}
12435 @cindex @samp{n}, macro
12436 @cindex counter, macro
12437 This macro implements custom counters by returning the number of
12438 times the macro has been expanded so far while exporting the
12439 buffer.  You can create more than one counter using different
12440 @var{NAME} values.  If @var{ACTION} is @samp{-}, previous
12441 value of the counter is held, i.e., the specified counter is not
12442 incremented.  If the value is a number, the specified counter is
12443 set to that value.  If it is any other non-empty string, the
12444 specified counter is reset to 1.  You may leave @var{NAME}
12445 empty to reset the default counter.
12446 @end table
12448 @vindex org-hide-macro-markers
12449 The surrounding brackets can be made invisible by setting
12450 @code{org-hide-macro-markers} non-@code{nil}.
12452 Org expands macros at the very beginning of the export process.
12454 @node Comment Lines
12455 @section Comment Lines
12457 @cindex exporting, not
12459 @cindex comment lines
12460 Lines starting with zero or more whitespace characters followed by one
12461 @samp{#} and a whitespace are treated as comments and, as such, are not
12462 exported.
12464 @cindex @samp{BEGIN_COMMENT}
12465 @cindex comment block
12466 Likewise, regions surrounded by @samp{#+BEGIN_COMMENT} @dots{} @samp{#+END_COMMENT}
12467 are not exported.
12469 @cindex comment trees
12470 Finally, a @samp{COMMENT} keyword at the beginning of an entry, but after
12471 any other keyword or priority cookie, comments out the entire subtree.
12472 In this case, the subtree is not exported and no code block within it
12473 is executed either@footnote{For a less drastic behavior, consider using a select tag (see
12474 @ref{Export Settings}) instead.}.  The command below helps changing the
12475 comment status of a headline.
12477 @table @asis
12478 @item @kbd{C-c ;} (@code{org-toggle-comment})
12479 @kindex C-c ;
12480 @findex org-toggle-comment
12482 Toggle the @samp{COMMENT} keyword at the beginning of an entry.
12483 @end table
12485 @node ASCII/Latin-1/UTF-8 export
12486 @section ASCII/Latin-1/UTF-8 export
12488 @cindex ASCII export
12489 @cindex Latin-1 export
12490 @cindex UTF-8 export
12492 ASCII export produces an output file containing only plain ASCII
12493 characters.  This is the simplest and most direct text output.  It
12494 does not contain any Org markup.  Latin-1 and UTF-8 export use
12495 additional characters and symbols available in these encoding
12496 standards.  All three of these export formats offer the most basic of
12497 text output for maximum portability.
12499 @vindex org-ascii-text-width
12500 On export, Org fills and justifies text according to the text width
12501 set in @code{org-ascii-text-width}.
12503 @vindex org-ascii-links-to-notes
12504 Org exports links using a footnote-like style where the descriptive
12505 part is in the text and the link is in a note before the next heading.
12506 See the variable @code{org-ascii-links-to-notes} for details.
12508 @anchor{ASCII export commands}
12509 @subheading ASCII export commands
12511 @table @asis
12512 @item @kbd{C-c C-e t a} (@code{org-ascii-export-to-ascii})
12513 @itemx @kbd{C-c C-e t l}
12514 @itemx @kbd{C-c C-e t u}
12515 @kindex C-c C-e t a
12516 @kindex C-c C-e t l
12517 @kindex C-c C-e t u
12518 @findex org-ascii-export-to-ascii
12520 Export as an ASCII file with a @samp{.txt} extension.  For
12521 @samp{myfile.org}, Org exports to @samp{myfile.txt}, overwriting without
12522 warning.  For @samp{myfile.txt}, Org exports to @samp{myfile.txt.txt} in
12523 order to prevent data loss.
12524 @end table
12526 @table @asis
12527 @item @kbd{C-c C-e t A} (@code{org-ascii-export-to-ascii})
12528 @itemx @kbd{C-c C-e t L}
12529 @itemx @kbd{C-c C-e t U}
12530 @kindex C-c C-e t A
12531 @kindex C-c C-e t L
12532 @kindex C-c C-e t U
12533 @findex org-ascii-export-to-ascii
12535 Export to a temporary buffer.  Does not create a file.
12536 @end table
12538 @anchor{ASCII specific export settings}
12539 @subheading ASCII specific export settings
12541 The ASCII export back-end has one extra keyword for customizing ASCII
12542 output.  Setting this keyword works similar to the general options
12543 (see @ref{Export Settings}).
12545 @table @asis
12546 @item @samp{SUBTITLE}
12547 @cindex @samp{SUBTITLE}, keyword
12548 The document subtitle.  For long subtitles, use multiple
12549 @samp{#+SUBTITLE} lines in the Org file.  Org prints them on one
12550 continuous line, wrapping into multiple lines if necessary.
12551 @end table
12553 @anchor{Header and sectioning structure}
12554 @subheading Header and sectioning structure
12556 Org converts the first three outline levels into headlines for ASCII
12557 export.  The remaining levels are turned into lists.  To change this
12558 cut-off point where levels become lists, see @ref{Export Settings}.
12560 @anchor{Quoting ASCII text}
12561 @subheading Quoting ASCII text
12563 To insert text within the Org file by the ASCII back-end, use one the
12564 following constructs, inline, keyword, or export block:
12566 @cindex @samp{ASCII}, keyword
12567 @cindex @samp{BEGIN_EXPORT ascii}
12568 @example
12569 Inline text @@@@ascii:and additional text@@@@ within a paragraph.
12571 #+ASCII: Some text
12573 #+BEGIN_EXPORT ascii
12574 Org exports text in this block only when using ASCII back-end.
12575 #+END_EXPORT
12576 @end example
12578 @anchor{ASCII specific attributes}
12579 @subheading ASCII specific attributes
12581 @cindex @samp{ATTR_ASCII}, keyword
12582 @cindex horizontal rules, in ASCII export
12584 ASCII back-end recognizes only one attribute, @code{:width}, which
12585 specifies the width of an horizontal rule in number of characters.
12586 The keyword and syntax for specifying widths is:
12588 @example
12589 #+ATTR_ASCII: :width 10
12590 -----
12591 @end example
12593 @anchor{ASCII special blocks}
12594 @subheading ASCII special blocks
12596 @cindex special blocks, in ASCII export
12597 @cindex @samp{BEGIN_JUSTIFYLEFT}
12598 @cindex @samp{BEGIN_JUSTIFYRIGHT}
12600 Besides @samp{#+BEGIN_CENTER} blocks (see @ref{Paragraphs}), ASCII back-end has
12601 these two left and right justification blocks:
12603 @example
12604 #+BEGIN_JUSTIFYLEFT
12605 It's just a jump to the left...
12606 #+END_JUSTIFYLEFT
12608 #+BEGIN_JUSTIFYRIGHT
12609 ...and then a step to the right.
12610 #+END_JUSTIFYRIGHT
12611 @end example
12613 @node Beamer Export
12614 @section Beamer Export
12616 @cindex Beamer export
12618 Org uses Beamer export to convert an Org file tree structure into
12619 high-quality interactive slides for presentations.  Beamer is a @LaTeX{}
12620 document class for creating presentations in PDF, HTML, and other
12621 popular display formats.
12623 @menu
12624 * Beamer export commands::       For creating Beamer documents.
12625 * Beamer specific export settings:: For customizing Beamer export.
12626 * Frames and Blocks in Beamer::  For composing Beamer slides.
12627 * Beamer specific syntax::       For using in Org documents.
12628 * Editing support::              Editing support.
12629 * A Beamer example::             A complete presentation.
12630 @end menu
12632 @node Beamer export commands
12633 @subsection Beamer export commands
12635 @table @asis
12636 @item @kbd{C-c C-e l b} (@code{org-beamer-export-to-latex})
12637 @kindex C-c C-e l b
12638 @findex org-beamer-export-to-latex
12640 Export as @LaTeX{} file with a @samp{.tex} extension.  For @samp{myfile.org},
12641 Org exports to @samp{myfile.tex}, overwriting without warning.
12643 @item @kbd{C-c C-e l B} (@code{org-beamer-export-as-latex})
12644 @kindex C-c C-e l B
12645 @findex org-beamer-export-as-latex
12647 Export to a temporary buffer.  Does not create a file.
12649 @item @kbd{C-c C-e l P} (@code{org-beamer-export-to-pdf})
12650 @kindex C-c C-e l P
12651 @findex org-beamer-export-to-pdf
12653 Export as @LaTeX{} file and then convert it to PDF format.
12655 @item @kbd{C-c C-e l O}
12656 @kindex C-c C-e l O
12658 Export as @LaTeX{} file, convert it to PDF format, and then open the
12659 PDF file.
12660 @end table
12662 @node Beamer specific export settings
12663 @subsection Beamer specific export settings
12665 Beamer export back-end has several additional keywords for customizing
12666 Beamer output.  These keywords work similar to the general options
12667 settings (see @ref{Export Settings}).
12669 @table @asis
12670 @item @samp{BEAMER_THEME}
12671 @cindex @samp{BEAMER_THEME}, keyword
12672 @vindex org-beamer-theme
12673 The Beamer layout theme (@code{org-beamer-theme}).  Use square
12674 brackets for options.  For example:
12676 @example
12677 #+BEAMER_THEME: Rochester [height=20pt]
12678 @end example
12680 @item @samp{BEAMER_FONT_THEME}
12681 @cindex @samp{BEAMER_FONT_THEME}, keyword
12682 The Beamer font theme.
12684 @item @samp{BEAMER_INNER_THEME}
12685 @cindex @samp{BEAMER_INNER_THEME}, keyword
12686 The Beamer inner theme.
12688 @item @samp{BEAMER_OUTER_THEME}
12689 @cindex @samp{BEAMER_OUTER_THEME}, keyword
12690 The Beamer outer theme.
12692 @item @samp{BEAMER_HEADER}
12693 @cindex @samp{BEAMER_HEADER}, keyword
12694 Arbitrary lines inserted in the preamble, just before the
12695 @samp{hyperref} settings.
12697 @item @samp{DESCRIPTION}
12698 @cindex @samp{DESCRIPTION}, keyword
12699 The document description.  For long descriptions, use multiple
12700 @samp{DESCRIPTION} keywords.  By default, @samp{hyperref} inserts
12701 @samp{DESCRIPTION} as metadata.  Use @code{org-latex-hyperref-template} to
12702 configure document metadata.  Use @code{org-latex-title-command} to
12703 configure typesetting of description as part of front matter.
12705 @item @samp{KEYWORDS}
12706 @cindex @samp{KEYWORDS}, keyword
12707 The keywords for defining the contents of the document.  Use
12708 multiple @samp{KEYWORDS} lines if necessary.  By default, @samp{hyperref}
12709 inserts @samp{KEYWORDS} as metadata.  Use
12710 @code{org-latex-hyperref-template} to configure document metadata.
12711 Use @code{org-latex-title-command} to configure typesetting of
12712 keywords as part of front matter.
12714 @item @samp{SUBTITLE}
12715 @cindex @samp{SUBTITLE}, keyword
12716 Document's subtitle.  For typesetting, use
12717 @code{org-beamer-subtitle-format} string.  Use
12718 @code{org-latex-hyperref-template} to configure document metadata.
12719 Use @code{org-latex-title-command} to configure typesetting of
12720 subtitle as part of front matter.
12721 @end table
12723 @node Frames and Blocks in Beamer
12724 @subsection Frames and Blocks in Beamer
12726 Org transforms heading levels into Beamer's sectioning elements,
12727 frames and blocks.  Any Org tree with a not-too-deep-level nesting
12728 should in principle be exportable as a Beamer presentation.
12730 @itemize
12731 @item
12732 @vindex org-beamer-frame-level
12733 Org headlines become Beamer frames when the heading level in Org is
12734 equal to @code{org-beamer-frame-level} or @samp{H} value in a @samp{OPTIONS} line
12735 (see @ref{Export Settings}).
12737 @cindex @samp{BEAMER_ENV}, property
12738 Org overrides headlines to frames conversion for the current tree of
12739 an Org file if it encounters the @samp{BEAMER_ENV} property set to
12740 @samp{frame} or @samp{fullframe}.  Org ignores whatever
12741 @code{org-beamer-frame-level} happens to be for that headline level in
12742 the Org tree.  In Beamer terminology, a full frame is a frame
12743 without its title.
12745 @item
12746 Org exports a Beamer frame's objects as block environments.  Org can
12747 enforce wrapping in special block types when @samp{BEAMER_ENV} property
12748 is set@footnote{If @samp{BEAMER_ENV} is set, Org export adds @samp{B_environment} tag
12749 to make it visible.  The tag serves as a visual aid and has no
12750 semantic relevance.}.  For valid values see
12751 @code{org-beamer-environments-default}.  To add more values, see
12752 @code{org-beamer-environments-extra}.
12753 @vindex org-beamer-environments-default
12754 @vindex org-beamer-environments-extra
12756 @item
12757 @cindex @samp{BEAMER_REF}, property
12758 If @samp{BEAMER_ENV} is set to @samp{appendix}, Org exports the entry as an
12759 appendix.  When set to @samp{note}, Org exports the entry as a note
12760 within the frame or between frames, depending on the entry's heading
12761 level.  When set to @samp{noteNH}, Org exports the entry as a note
12762 without its title.  When set to @samp{againframe}, Org exports the entry
12763 with @samp{\againframe} command, which makes setting the @samp{BEAMER_REF}
12764 property mandatory because @samp{\againframe} needs frame to resume.
12766 When @samp{ignoreheading} is set, Org export ignores the entry's headline
12767 but not its content.  This is useful for inserting content between
12768 frames.  It is also useful for properly closing a @samp{column}
12769 environment.  @@end itemize
12771 @cindex @samp{BEAMER_ACT}, property
12772 @cindex @samp{BEAMER_OPT}, property
12773 When @samp{BEAMER_ACT} is set for a headline, Org export translates that
12774 headline as an overlay or action specification.  When enclosed in
12775 square brackets, Org export makes the overlay specification
12776 a default.  Use @samp{BEAMER_OPT} to set any options applicable to the
12777 current Beamer frame or block.  The Beamer export back-end wraps
12778 with appropriate angular or square brackets.  It also adds the
12779 @samp{fragile} option for any code that may require a verbatim block.
12781 @cindex @samp{BEAMER_COL}, property
12782 To create a column on the Beamer slide, use the @samp{BEAMER_COL}
12783 property for its headline in the Org file.  Set the value of
12784 @samp{BEAMER_COL} to a decimal number representing the fraction of the
12785 total text width.  Beamer export uses this value to set the column's
12786 width and fills the column with the contents of the Org entry.  If
12787 the Org entry has no specific environment defined, Beamer export
12788 ignores the heading.  If the Org entry has a defined environment,
12789 Beamer export uses the heading as title.  Behind the scenes, Beamer
12790 export automatically handles @LaTeX{} column separations for contiguous
12791 headlines.  To manually adjust them for any unique configurations
12792 needs, use the @samp{BEAMER_ENV} property.
12793 @end itemize
12795 @node Beamer specific syntax
12796 @subsection Beamer specific syntax
12798 Since Org's Beamer export back-end is an extension of the @LaTeX{}
12799 back-end, it recognizes other @LaTeX{} specific syntax---for example,
12800 @samp{#+LATEX:} or @samp{#+ATTR_LATEX:}.  See @ref{@LaTeX{} Export}, for details.
12802 Beamer export wraps the table of contents generated with @samp{toc:t}
12803 @samp{OPTION} keyword in a @samp{frame} environment.  Beamer export does not
12804 wrap the table of contents generated with @samp{TOC} keyword (see @ref{Table of Contents}).  Use square brackets for specifying options.
12806 @example
12807 #+TOC: headlines [currentsection]
12808 @end example
12810 Insert Beamer-specific code using the following constructs:
12812 @cindex @samp{BEAMER}, keyword
12813 @cindex @samp{BEGIN_EXPORT beamer}
12814 @example
12815 #+BEAMER: \pause
12817 #+BEGIN_EXPORT beamer
12818   Only Beamer export back-end exports this.
12819 #+END_BEAMER
12821 Text @@@@beamer:some code@@@@ within a paragraph.
12822 @end example
12824 Inline constructs, such as the last one above, are useful for adding
12825 overlay specifications to objects with @code{bold}, @code{item}, @code{link},
12826 @code{radio-target} and @code{target} types.  Enclose the value in angular
12827 brackets and place the specification at the beginning of the object as
12828 shown in this example:
12830 @example
12831 A *@@@@beamer:<2->@@@@useful* feature
12832 @end example
12834 @cindex @samp{ATTR_BEAMER}, keyword
12835 Beamer export recognizes the @samp{ATTR_BEAMER} keyword with the following
12836 attributes from Beamer configurations: @samp{:environment} for changing
12837 local Beamer environment, @samp{:overlay} for specifying Beamer overlays in
12838 angular or square brackets, and @samp{:options} for inserting optional
12839 arguments.
12841 @example
12842 #+ATTR_BEAMER: :environment nonindentlist
12843 - item 1, not indented
12844 - item 2, not indented
12845 - item 3, not indented
12846 @end example
12848 @example
12849 #+ATTR_BEAMER: :overlay <+->
12850 - item 1
12851 - item 2
12852 @end example
12854 @example
12855 #+ATTR_BEAMER: :options [Lagrange]
12856 Let $G$ be a finite group, and let $H$ be
12857 a subgroup of $G$.  Then the order of $H$ divides the order of $G$.
12858 @end example
12860 @node Editing support
12861 @subsection Editing support
12863 The @code{org-beamer-mode} is a special minor mode for faster editing of
12864 Beamer documents.
12866 @example
12867 #+STARTUP: beamer
12868 @end example
12870 @table @asis
12871 @item @kbd{C-c C-b} (@code{org-beamer-select-environment})
12872 @kindex C-c C-b
12873 @findex org-beamer-select-environment
12875 The @code{org-beamer-mode} provides this key for quicker selections in
12876 Beamer normal environments, and for selecting the @samp{BEAMER_COL}
12877 property.
12878 @end table
12880 @node A Beamer example
12881 @subsection A Beamer example
12883 Here is an example of an Org document ready for Beamer export.
12885 @example
12886 ;#+TITLE: Example Presentation
12887 ;#+AUTHOR: Carsten Dominik
12888 ;#+OPTIONS: H:2 toc:t num:t
12889 ;#+LATEX_CLASS: beamer
12890 ;#+LATEX_CLASS_OPTIONS: [presentation]
12891 ;#+BEAMER_THEME: Madrid
12892 ;#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) %8BEAMER_OPT(Opt)
12894 * This is the first structural section
12896 ** Frame 1
12897 *** Thanks to Eric Fraga                                           :B_block:
12898     :PROPERTIES:
12899     :BEAMER_COL: 0.48
12900     :BEAMER_ENV: block
12901     :END:
12902     for the first viable Beamer setup in Org
12903 *** Thanks to everyone else                                        :B_block:
12904     :PROPERTIES:
12905     :BEAMER_COL: 0.48
12906     :BEAMER_ACT: <2->
12907     :BEAMER_ENV: block
12908     :END:
12909     for contributing to the discussion
12910 **** This will be formatted as a beamer note                       :B_note:
12911      :PROPERTIES:
12912      :BEAMER_env: note
12913      :END:
12914 ** Frame 2 (where we will not use columns)
12915 *** Request
12916     Please test this stuff!
12917 @end example
12919 @node HTML Export
12920 @section HTML Export
12922 @cindex HTML export
12924 Org mode contains an HTML exporter with extensive HTML formatting
12925 compatible with XHTML 1.0 strict standard.
12927 @menu
12928 * HTML export commands::         Invoking HTML export.
12929 * HTML specific export settings:: Settings for HTML export.
12930 * HTML doctypes::                Exporting various (X)HTML flavors.
12931 * HTML preamble and postamble::  Inserting preamble and postamble.
12932 * Quoting HTML tags::            Using direct HTML in Org files.
12933 * Links in HTML export::         Inserting and formatting links.
12934 * Tables in HTML export::        How to modify the formatting of tables.
12935 * Images in HTML export::        How to insert figures into HTML output.
12936 * Math formatting in HTML export:: Beautiful math also on the web.
12937 * Text areas in HTML export::    An alternate way to show an example.
12938 * CSS support::                  Changing the appearance of the output.
12939 * JavaScript support::           Info and folding in a web browser.
12940 @end menu
12942 @node HTML export commands
12943 @subsection HTML export commands
12945 @table @asis
12946 @item @kbd{C-c C-e h h} (@code{org-html-export-to-html})
12947 @kindex C-c C-e h h
12948 @kindex C-c C-e h o
12949 @findex org-html-export-to-html
12951 Export as HTML file with a @samp{.html} extension.  For @samp{myfile.org},
12952 Org exports to @samp{myfile.html}, overwriting without warning.
12953 @{@{@{kbd@{C-c C-e h o)@}@}@} exports to HTML and opens it in a web
12954 browser.
12956 @item @kbd{C-c C-e h H} (@code{org-html-export-as-html})
12957 @kindex C-c C-e h H
12958 @findex org-html-export-as-html
12960 Exports to a temporary buffer.  Does not create a file.
12961 @end table
12963 @node HTML specific export settings
12964 @subsection HTML specific export settings
12966 HTML export has a number of keywords, similar to the general options
12967 settings described in @ref{Export Settings}.
12969 @table @asis
12970 @item @samp{DESCRIPTION}
12971 @cindex @samp{DESCRIPTION}, keyword
12972 This is the document's description, which the HTML exporter
12973 inserts it as a HTML meta tag in the HTML file.  For long
12974 descriptions, use multiple @samp{DESCRIPTION} lines.  The exporter
12975 takes care of wrapping the lines properly.
12977 @item @samp{HTML_DOCTYPE}
12978 @cindex @samp{HTML_DOCTYPE}, keyword
12979 @vindex org-html-doctype
12980 Specify the document type, for example: HTML5
12981 (@code{org-html-doctype}).
12983 @item @samp{HTML_CONTAINER}
12984 @cindex @samp{HTML_CONTAINER}, keyword
12985 @vindex org-html-container-element
12986 Specify the HTML container, such as @samp{div}, for wrapping sections
12987 and elements (@code{org-html-container-element}).
12989 @item @samp{HTML_LINK_HOME}
12990 @cindex @samp{HTML_LINK_HOME}, keyword
12991 @vindex org-html-link-home
12992 The URL for home link (@code{org-html-link-home}).
12994 @item @samp{HTML_LINK_UP}
12995 @cindex @samp{HTML_LINK_UP}, keyword
12996 @vindex org-html-link-up
12997 The URL for the up link of exported HTML pages
12998 (@code{org-html-link-up}).
13000 @item @samp{HTML_MATHJAX}
13001 @cindex @samp{HTML_MATHJAX}, keyword
13002 @vindex org-html-mathjax-options
13003 Options for MathJax (@code{org-html-mathjax-options}).  MathJax is
13004 used to typeset @LaTeX{} math in HTML documents.  See @ref{Math formatting in HTML export}, for an example.
13006 @item @samp{HTML_HEAD}
13007 @cindex @samp{HTML_HEAD}, keyword
13008 @vindex org-html-head
13009 Arbitrary lines for appending to the HTML document's head
13010 (@code{org-html-head}).
13012 @item @samp{HTML_HEAD_EXTRA}
13013 @cindex @samp{HTML_HEAD_EXTRA}, keyword
13014 @vindex org-html-head-extra
13015 More arbitrary lines for appending to the HTML document's head
13016 (@code{org-html-head-extra}).
13018 @item @samp{KEYWORDS}
13019 @cindex @samp{KEYWORDS}, keyword
13020 Keywords to describe the document's content.  HTML exporter
13021 inserts these keywords as HTML meta tags.  For long keywords, use
13022 multiple @samp{KEYWORDS} lines.
13024 @item @samp{LATEX_HEADER}
13025 @cindex @samp{LATEX_HEADER}, keyword
13026 Arbitrary lines for appending to the preamble; HTML exporter
13027 appends when transcoding @LaTeX{} fragments to images (see @ref{Math formatting in HTML export}).
13029 @item @samp{SUBTITLE}
13030 @cindex @samp{SUBTITLE}, keyword
13031 The document's subtitle.  HTML exporter formats subtitle if
13032 document type is @samp{HTML5} and the CSS has a @samp{subtitle} class.
13033 @end table
13035 Some of these keywords are explained in more detail in the following
13036 sections of the manual.
13038 @node HTML doctypes
13039 @subsection HTML doctypes
13041 Org can export to various (X)HTML flavors.
13043 @vindex org-html-doctype
13044 @vindex org-html-doctype-alist
13045 Set the @code{org-html-doctype} variable for different (X)HTML variants.
13046 Depending on the variant, the HTML exporter adjusts the syntax of HTML
13047 conversion accordingly.  Org includes the following ready-made
13048 variants:
13050 @itemize
13051 @item
13052 @code{"html4-strict"}
13053 @item
13054 @code{"html4-transitional"}
13055 @item
13056 @code{"html4-frameset"}
13057 @item
13058 @code{"xhtml-strict"}
13059 @item
13060 @code{"xhtml-transitional"}
13061 @item
13062 @code{"xhtml-frameset"}
13063 @item
13064 @code{"xhtml-11"}
13065 @item
13066 @code{"html5"}
13067 @item
13068 @code{"xhtml5"}
13069 @end itemize
13071 @noindent
13072 See the variable @code{org-html-doctype-alist} for details.  The default is
13073 @code{"xhtml-strict"}.
13075 @vindex org-html-html5-fancy
13076 @cindex @samp{HTML5}, export new elements
13077 Org's HTML exporter does not by default enable new block elements
13078 introduced with the HTML5 standard.  To enable them, set
13079 @code{org-html-html5-fancy} to non-@code{nil}.  Or use an @samp{OPTIONS} line in the
13080 file to set @samp{html5-fancy}.
13082 HTML5 documents can now have arbitrary @samp{#+BEGIN} @dots{} @samp{#+END} blocks.
13083 For example:
13085 @example
13086 #+BEGIN_aside
13087   Lorem ipsum
13088 #+END_aside
13089 @end example
13091 @noindent
13092 exports to:
13094 @example
13095 <aside>
13096   <p>Lorem ipsum</p>
13097 </aside>
13098 @end example
13100 @noindent
13101 while this:
13103 @example
13104 #+ATTR_HTML: :controls controls :width 350
13105 #+BEGIN_video
13106 #+HTML: <source src="movie.mp4" type="video/mp4">
13107 #+HTML: <source src="movie.ogg" type="video/ogg">
13108 Your browser does not support the video tag.
13109 #+END_video
13110 @end example
13112 @noindent
13113 exports to:
13115 @example
13116 <video controls="controls" width="350">
13117   <source src="movie.mp4" type="video/mp4">
13118     <source src="movie.ogg" type="video/ogg">
13119       <p>Your browser does not support the video tag.</p>
13120 </video>
13121 @end example
13123 @vindex org-html-html5-elements
13124 When special blocks do not have a corresponding HTML5 element, the
13125 HTML exporter reverts to standard translation (see
13126 @code{org-html-html5-elements}).  For example, @samp{#+BEGIN_lederhosen} exports
13127 to @code{<div class="lederhosen">}.
13129 Special blocks cannot have headlines.  For the HTML exporter to wrap
13130 the headline and its contents in @code{<section>} or @code{<article>} tags, set
13131 the @samp{HTML_CONTAINER} property for the headline.
13133 @node HTML preamble and postamble
13134 @subsection HTML preamble and postamble
13136 @vindex org-html-preamble
13137 @vindex org-html-postamble
13138 @vindex org-html-preamble-format
13139 @vindex org-html-postamble-format
13140 @vindex org-html-validation-link
13141 @vindex org-export-creator-string
13142 @vindex org-export-time-stamp-file
13144 The HTML exporter has delineations for preamble and postamble.  The
13145 default value for @code{org-html-preamble} is @code{t}, which makes the HTML
13146 exporter insert the preamble.  See the variable
13147 @code{org-html-preamble-format} for the format string.
13149 Set @code{org-html-preamble} to a string to override the default format
13150 string.  If the string is a function, the HTML exporter expects the
13151 function to return a string upon execution.  The HTML exporter inserts
13152 this string in the preamble.  The HTML exporter does not insert
13153 a preamble if @code{org-html-preamble} is set @code{nil}.
13155 The default value for @code{org-html-postamble} is @code{auto}, which makes the
13156 HTML exporter build a postamble from looking up author's name, email
13157 address, creator's name, and date.  Set @code{org-html-postamble} to @code{t} to
13158 insert the postamble in the format specified in the
13159 @code{org-html-postamble-format} variable.  The HTML exporter does not
13160 insert a postamble if @code{org-html-postamble} is set to @code{nil}.
13162 @node Quoting HTML tags
13163 @subsection Quoting HTML tags
13165 The HTML export back-end transforms @samp{<} and @samp{>} to @samp{&lt;} and @samp{&gt;}.
13167 To include raw HTML code in the Org file so the HTML export back-end
13168 can insert that HTML code in the output, use this inline syntax:
13169 @samp{@@@@html:...@@@@}.  For example:
13171 @example
13172 @@@@html:<b>@@@@bold text@@@@html:</b>@@@@
13173 @end example
13175 @cindex @samp{HTML}, keyword
13176 @cindex @samp{BEGIN_EXPORT html}
13177 For larger raw HTML code blocks, use these HTML export code blocks:
13179 @example
13180 #+HTML: Literal HTML code for export
13182 #+BEGIN_EXPORT html
13183   All lines between these markers are exported literally
13184 #+END_EXPORT
13185 @end example
13187 @node Links in HTML export
13188 @subsection Links in HTML export
13190 @cindex links, in HTML export
13191 @cindex internal links, in HTML export
13192 @cindex external links, in HTML export
13194 The HTML export back-end transforms Org's internal links (see
13195 @ref{Internal Links}) to equivalent HTML links in the output.  The back-end
13196 similarly handles Org's automatic links created by radio targets (see
13197 @ref{Radio Targets}) similarly.  For Org links to external files, the
13198 back-end transforms the links to @emph{relative} paths.
13200 @vindex org-html-link-org-files-as-html
13201 For Org links to other @samp{.org} files, the back-end automatically
13202 changes the file extension to @samp{.html} and makes file paths relative.
13203 If the @samp{.org} files have an equivalent @samp{.html} version at the same
13204 location, then the converted links should work without any further
13205 manual intervention.  However, to disable this automatic path
13206 translation, set @code{org-html-link-org-files-as-html} to @code{nil}.  When
13207 disabled, the HTML export back-end substitutes the ID-based links in
13208 the HTML output.  For more about linking files when publishing to
13209 a directory, see @ref{Publishing links}.
13211 Org files can also have special directives to the HTML export
13212 back-end.  For example, by using @samp{#+ATTR_HTML} lines to specify new
13213 format attributes to @code{<a>} or @code{<img>} tags.  This example shows
13214 changing the link's title and style:
13216 @cindex @samp{ATTR_HTML}, keyword
13217 @example
13218 #+ATTR_HTML: :title The Org mode homepage :style color:red;
13219 [[https://orgmode.org]]
13220 @end example
13222 @node Tables in HTML export
13223 @subsection Tables in HTML export
13225 @cindex tables, in HTML
13226 @vindex org-export-html-table-tag
13228 The HTML export back-end uses @code{org-html-table-default-attributes} when
13229 exporting Org tables to HTML.  By default, the exporter does not draw
13230 frames and cell borders.  To change for this for a table, use the
13231 following lines before the table in the Org file:
13233 @cindex @samp{CAPTION}, keyword
13234 @cindex @samp{ATTR_HTML}, keyword
13235 @example
13236 #+CAPTION: This is a table with lines around and between cells
13237 #+ATTR_HTML: border="2" rules="all" frame="border"
13238 @end example
13240 The HTML export back-end preserves column groupings in Org tables (see
13241 @ref{Column Groups}) when exporting to HTML.
13243 Additional options for customizing tables for HTML export.
13245 @table @asis
13246 @item @code{org-html-table-align-individual-fields}
13247 @vindex org-html-table-align-individual-fields
13248 Non-@code{nil} attaches style attributes for alignment to each table
13249 field.
13251 @item @code{org-html-table-caption-above}
13252 @vindex org-html-table-caption-above
13253 Non-@code{nil} places caption string at the beginning of the table.
13255 @item @code{org-html-table-data-tags}
13256 @vindex org-html-table-data-tags
13257 Opening and ending tags for table data fields.
13259 @item @code{org-html-table-default-attributes}
13260 @vindex org-html-table-default-attributes
13261 Default attributes and values for table tags.
13263 @item @code{org-html-table-header-tags}
13264 @vindex org-html-table-header-tags
13265 Opening and ending tags for table's header fields.
13267 @item @code{org-html-table-row-tags}
13268 @vindex org-html-table-row-tags
13269 Opening and ending tags for table rows.
13271 @item @code{org-html-table-use-header-tags-for-first-column}
13272 @vindex org-html-table-use-header-tags-for-first-column
13273 Non-@code{nil} formats column one in tables with header tags.
13274 @end table
13276 @node Images in HTML export
13277 @subsection Images in HTML export
13279 @cindex images, inline in HTML
13280 @cindex inlining images in HTML
13282 The HTML export back-end has features to convert Org image links to
13283 HTML inline images and HTML clickable image links.
13285 @vindex org-html-inline-images
13286 When the link in the Org file has no description, the HTML export
13287 back-end by default in-lines that image.  For example:
13288 @samp{[[file:myimg.jpg]]} is in-lined, while @samp{[[file:myimg.jpg][the image]]} links to the text,
13289 @samp{the image}.  For more details, see the variable
13290 @code{org-html-inline-images}.
13292 On the other hand, if the description part of the Org link is itself
13293 another link, such as @samp{file:} or @samp{http:} URL pointing to an image, the
13294 HTML export back-end in-lines this image and links to the main image.
13295 This Org syntax enables the back-end to link low-resolution thumbnail
13296 to the high-resolution version of the image, as shown in this example:
13298 @example
13299 [[file:highres.jpg][file:thumb.jpg]]
13300 @end example
13302 To change attributes of in-lined images, use @samp{#+ATTR_HTML} lines in
13303 the Org file.  This example shows realignment to right, and adds @code{alt}
13304 and @code{title} attributes in support of text viewers and modern web
13305 accessibility standards.
13307 @cindex @samp{CAPTION}, keyword
13308 @cindex @samp{ATTR_HTML}, keyword
13309 @example
13310 #+CAPTION: A black cat stalking a spider
13311 #+ATTR_HTML: :alt cat/spider image :title Action! :align right
13312 [[./img/a.jpg]]
13313 @end example
13315 @noindent
13316 The HTML export back-end copies the @samp{http} links from the Org file as
13319 @node Math formatting in HTML export
13320 @subsection Math formatting in HTML export
13322 @cindex MathJax
13323 @cindex dvipng
13324 @cindex dvisvgm
13325 @cindex ImageMagick
13327 @vindex org-html-mathjax-options~
13328 @LaTeX{} math snippets (see @ref{@LaTeX{} fragments}) can be displayed in two
13329 different ways on HTML pages.  The default is to use the @uref{http://www.mathjax.org, MathJax},
13330 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
13331 @uref{http://www.mathjax.org, MathJax}.}.  Some MathJax
13332 display options can be configured via @code{org-html-mathjax-options}, or
13333 in the buffer.  For example, with the following settings,
13335 @example
13336 #+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
13337 #+HTML_MATHJAX: cancel.js noErrors.js
13338 @end example
13340 @noindent
13341 equation labels are displayed on the left margin and equations are
13342 five em from the left margin.  In addition, it loads the two MathJax
13343 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
13344 about extensions.}.
13346 @vindex org-html-mathjax-template
13347 See the docstring of @code{org-html-mathjax-options} for all supported
13348 variables.  The MathJax template can be configure via
13349 @code{org-html-mathjax-template}.
13351 If you prefer, you can also request that @LaTeX{} fragments are processed
13352 into small images that will be inserted into the browser page.  Before
13353 the availability of MathJax, this was the default method for Org
13354 files.  This method requires that the dvipng program, dvisvgm or
13355 ImageMagick suite is available on your system.  You can still get this
13356 processing with
13358 @example
13359 #+OPTIONS: tex:dvipng
13360 @end example
13362 @example
13363 #+OPTIONS: tex:dvisvgm
13364 @end example
13366 @noindent
13369 @example
13370 #+OPTIONS: tex:imagemagick
13371 @end example
13373 @node Text areas in HTML export
13374 @subsection Text areas in HTML export
13376 @cindex text areas, in HTML
13377 Before Org mode's Babel, one popular approach to publishing code in
13378 HTML was by using @samp{:textarea}.  The advantage of this approach was
13379 that copying and pasting was built into browsers with simple
13380 JavaScript commands.  Even editing before pasting was made simple.
13382 The HTML export back-end can create such text areas.  It requires an
13383 @samp{#+ATTR_HTML} line as shown in the example below with the @samp{:textarea}
13384 option.  This must be followed by either an example or a source code
13385 block.  Other Org block types do not honor the @samp{:textarea} option.
13387 By default, the HTML export back-end creates a text area 80 characters
13388 wide and height just enough to fit the content.  Override these
13389 defaults with @samp{:width} and @samp{:height} options on the @samp{#+ATTR_HTML}
13390 line.
13392 @example
13393 #+ATTR_HTML: :textarea t :width 40
13394 #+BEGIN_EXAMPLE
13395   (defun org-xor (a b)
13396      "Exclusive or."
13397      (if a (not b) b))
13398 #+END_EXAMPLE
13399 @end example
13401 @node CSS support
13402 @subsection CSS support
13404 @cindex CSS, for HTML export
13405 @cindex HTML export, CSS
13407 @vindex org-export-html-todo-kwd-class-prefix
13408 @vindex org-export-html-tag-class-prefix
13409 You can modify the CSS style definitions for the exported file.  The
13410 HTML exporter assigns the following special CSS classes@footnote{If the classes on TODO keywords and tags lead to conflicts,
13411 use the variables @code{org-html-todo-kwd-class-prefix} and
13412 @code{org-html-tag-class-prefix} to make them unique.} to
13413 appropriate parts of the document---your style specifications may
13414 change these, in addition to any of the standard classes like for
13415 headlines, tables, etc.
13417 @multitable {aaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
13418 @item @code{p.author}
13419 @tab author information, including email
13420 @item @code{p.date}
13421 @tab publishing date
13422 @item @code{p.creator}
13423 @tab creator info, about org mode version
13424 @item @code{.title}
13425 @tab document title
13426 @item @code{.subtitle}
13427 @tab document subtitle
13428 @item @code{.todo}
13429 @tab TODO keywords, all not-done states
13430 @item @code{.done}
13431 @tab the DONE keywords, all states that count as done
13432 @item @code{.WAITING}
13433 @tab each TODO keyword also uses a class named after itself
13434 @item @code{.timestamp}
13435 @tab timestamp
13436 @item @code{.timestamp-kwd}
13437 @tab keyword associated with a timestamp, like @samp{SCHEDULED}
13438 @item @code{.timestamp-wrapper}
13439 @tab span around keyword plus timestamp
13440 @item @code{.tag}
13441 @tab tag in a headline
13442 @item @code{._HOME}
13443 @tab each tag uses itself as a class, ``@@'' replaced by ``_''
13444 @item @code{.target}
13445 @tab target for links
13446 @item @code{.linenr}
13447 @tab the line number in a code example
13448 @item @code{.code-highlighted}
13449 @tab for highlighting referenced code lines
13450 @item @code{div.outline-N}
13451 @tab div for outline level N (headline plus text)
13452 @item @code{div.outline-text-N}
13453 @tab extra div for text at outline level N
13454 @item @code{.section-number-N}
13455 @tab section number in headlines, different for each level
13456 @item @code{.figure-number}
13457 @tab label like ``Figure 1:''
13458 @item @code{.table-number}
13459 @tab label like ``Table 1:''
13460 @item @code{.listing-number}
13461 @tab label like ``Listing 1:''
13462 @item @code{div.figure}
13463 @tab how to format an in-lined image
13464 @item @code{pre.src}
13465 @tab formatted source code
13466 @item @code{pre.example}
13467 @tab normal example
13468 @item @code{p.verse}
13469 @tab verse paragraph
13470 @item @code{div.footnotes}
13471 @tab footnote section headline
13472 @item @code{p.footnote}
13473 @tab footnote definition paragraph, containing a footnote
13474 @item @code{.footref}
13475 @tab a footnote reference number (always a <sup>)
13476 @item @code{.footnum}
13477 @tab footnote number in footnote definition (always <sup>)
13478 @item @code{.org-svg}
13479 @tab default class for a linked @samp{.svg} image
13480 @end multitable
13482 @vindex org-html-style-default
13483 @vindex org-html-head
13484 @vindex org-html-head-extra
13485 @cindex @samp{HTML_INCLUDE_STYLE}, keyword
13486 The HTML export back-end includes a compact default style in each
13487 exported HTML file.  To override the default style with another style,
13488 use these keywords in the Org file.  They will replace the global
13489 defaults the HTML exporter uses.
13491 @cindex @samp{HTML_HEAD}, keyword
13492 @cindex @samp{HTML_HEAD_EXTRA}, keyword
13493 @example
13494 #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
13495 #+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
13496 @end example
13498 @vindex org-html-head-include-default-style
13499 To just turn off the default style, customize
13500 @code{org-html-head-include-default-style} variable, or use this option
13501 line in the Org file.
13503 @cindex @samp{html-style}, @samp{OPTIONS} item
13504 @example
13505 #+OPTIONS: html-style:nil
13506 @end example
13508 For longer style definitions, either use several @samp{HTML_HEAD} and
13509 @samp{HTML_HEAD_EXTRA} keywords, or use @code{<style> ... </style>} blocks
13510 around them.  Both of these approaches can avoid referring to an
13511 external file.
13513 @cindex @samp{HTML_CONTAINER_CLASS}, property
13514 In order to add styles to a sub-tree, use the @samp{HTML_CONTAINER_CLASS}
13515 property to assign a class to the tree.  In order to specify CSS
13516 styles for a particular headline, you can use the id specified in
13517 a @samp{CUSTOM_ID} property.
13519 Never change the @code{org-html-style-default} constant.  Instead use other
13520 simpler ways of customizing as described above.
13522 @node JavaScript support
13523 @subsection JavaScript supported display of web pages
13525 Sebastian Rose has written a JavaScript program especially designed to
13526 enhance the web viewing experience of HTML files created with Org.
13527 This program enhances large files in two different ways of viewing.
13528 One is an @emph{Info}-like mode where each section is displayed separately
13529 and navigation can be done with the @kbd{n} and @kbd{p}
13530 keys, and some other keys as well, press @kbd{?} for an overview
13531 of the available keys.  The second one has a @emph{folding} view, much like
13532 Org provides inside Emacs.  The script is available at
13533 @uref{https://orgmode.org/org-info.js} and the documentation at
13534 @uref{https://orgmode.org/worg/code/org-info-js/}.  The script is hosted on
13535 @uref{https://orgmode.org}, but for reliability, prefer installing it on your
13536 own web server.
13538 To use this program, just add this line to the Org file:
13540 @cindex @samp{INFOJS_OPT}, keyword
13541 @example
13542 #+INFOJS_OPT: view:info toc:nil
13543 @end example
13545 @noindent
13546 The HTML header now has the code needed to automatically invoke the
13547 script.  For setting options, use the syntax from the above line for
13548 options described below:
13550 @table @asis
13551 @item @samp{path:}
13552 The path to the script.  The default is to grab the script from
13553 @uref{https://orgmode.org/org-info.js}, but you might want to have
13554 a local copy and use a path like @samp{../scripts/org-info.js}.
13556 @item @samp{view:}
13557 Initial view when the website is first shown.  Possible values are:
13559 @multitable {aaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
13560 @item @samp{info}
13561 @tab Info-like interface with one section per page
13562 @item @samp{overview}
13563 @tab Folding interface, initially showing only top-level
13564 @item @samp{content}
13565 @tab Folding interface, starting with all headlines visible
13566 @item @samp{showall}
13567 @tab Folding interface, all headlines and text visible
13568 @end multitable
13570 @item @samp{sdepth:}
13571 Maximum headline level still considered as an independent section
13572 for info and folding modes.  The default is taken from
13573 @code{org-export-headline-levels}, i.e., the @samp{H} switch in @samp{OPTIONS}.
13574 If this is smaller than in @code{org-export-headline-levels}, each
13575 info/folding section can still contain child headlines.
13577 @item @samp{toc:}
13578 Should the table of contents @emph{initially} be visible?  Even when
13579 @samp{nil}, you can always get to the ``toc'' with @kbd{i}.
13581 @item @samp{tdepth:}
13582 The depth of the table of contents.  The defaults are taken from
13583 the variables @code{org-export-headline-levels} and
13584 @code{org-export-with-toc}.
13586 @item @samp{ftoc:}
13587 Does the CSS of the page specify a fixed position for the ``toc''?
13588 If yes, the toc is displayed as a section.
13590 @item @samp{ltoc:}
13591 Should there be short contents (children) in each section?  Make
13592 this @samp{above} if the section should be above initial text.
13594 @item @samp{mouse:}
13595 Headings are highlighted when the mouse is over them.  Should be
13596 @samp{underline} (default) or a background color like @samp{#cccccc}.
13598 @item @samp{buttons:}
13599 Should view-toggle buttons be everywhere?  When @samp{nil} (the
13600 default), only one such button is present.
13601 @end table
13603 @noindent
13604 @vindex org-infojs-options
13605 @vindex org-export-html-use-infojs
13606 You can choose default values for these options by customizing the
13607 variable @code{org-infojs-options}.  If you always want to apply the script
13608 to your pages, configure the variable @code{org-export-html-use-infojs}.
13610 @node @LaTeX{} Export
13611 @section @LaTeX{} Export
13613 @cindex @LaTeX{} export
13614 @cindex PDF export
13616 The @LaTeX{} export back-end can handle complex documents, incorporate
13617 standard or custom @LaTeX{} document classes, generate documents using
13618 alternate @LaTeX{} engines, and produce fully linked PDF files with
13619 indexes, bibliographies, and tables of contents, destined for
13620 interactive online viewing or high-quality print publication.
13622 While the details are covered in-depth in this section, here are some
13623 quick references to variables for the impatient: for engines, see
13624 @code{org-latex-compiler}; for build sequences, see
13625 @code{org-latex-pdf-process}; for packages, see
13626 @code{org-latex-default-packages-alist} and @code{org-latex-packages-alist}.
13628 An important note about the @LaTeX{} export back-end: it is sensitive to
13629 blank lines in the Org document.  That's because @LaTeX{} itself depends
13630 on blank lines to tell apart syntactical elements, such as paragraphs.
13632 @menu
13633 * @LaTeX{}/PDF export commands:: For producing @LaTeX{} and PDF documents.
13634 * @LaTeX{} specific export settings:: Unique to this @LaTeX{} back-end.
13635 * @LaTeX{} header and sectioning:: Setting up the export file structure.
13636 * Quoting @LaTeX{} code::        Incorporating literal @LaTeX{} code.
13637 * Tables in @LaTeX{} export::    Options for exporting tables to @LaTeX{}.
13638 * Images in @LaTeX{} export::    How to insert figures into @LaTeX{} output.
13639 * Plain lists in @LaTeX{} export:: Attributes specific to lists.
13640 * Source blocks in @LaTeX{} export:: Attributes specific to source code blocks.
13641 * Example blocks in @LaTeX{} export:: Attributes specific to example blocks.
13642 * Special blocks in @LaTeX{} export:: Attributes specific to special blocks.
13643 * Horizontal rules in @LaTeX{} export:: Attributes specific to horizontal rules.
13644 @end menu
13646 @node @LaTeX{}/PDF export commands
13647 @subsection @LaTeX{}/PDF export commands
13649 @table @asis
13650 @item @kbd{C-c C-e l l} (@code{org-latex-export-to-latex})
13651 @kindex C-c C-e l l
13652 @findex org-latex-export-to-latex~
13653 Export to a @LaTeX{} file with a @samp{.tex} extension.  For
13654 @samp{myfile.org}, Org exports to @samp{myfile.tex}, overwriting without
13655 warning.
13657 @item @kbd{C-c C-e l L} (@code{org-latex-export-as-latex})
13658 @kindex C-c C-e l L
13659 @findex org-latex-export-as-latex
13660 Export to a temporary buffer.  Do not create a file.
13662 @item @kbd{C-c C-e l p} (@code{org-latex-export-to-pdf})
13663 @kindex C-c C-e l p
13664 @findex org-latex-export-to-pdf
13665 Export as @LaTeX{} file and convert it to PDF file.
13667 @item @kbd{C-c C-e l o}
13668 @kindex C-c C-e l o
13669 Export as @LaTeX{} file and convert it to PDF, then open the PDF
13670 using the default viewer.
13672 @item @kbd{M-x org-export-region-as-latex}
13673 Convert the region to @LaTeX{} under the assumption that it was in Org
13674 mode syntax before.  This is a global command that can be invoked in
13675 any buffer.
13676 @end table
13678 @vindex org-latex-compiler
13679 @vindex org-latex-bibtex-compiler
13680 @vindex org-latex-default-packages-alist
13681 @cindex pdflatex
13682 @cindex xelatex
13683 @cindex lualatex
13684 @cindex @samp{LATEX_COMPILER}, keyword
13685 The @LaTeX{} export back-end can use any of these @LaTeX{} engines:
13686 @samp{pdflatex}, @samp{xelatex}, and @samp{lualatex}.  These engines compile @LaTeX{}
13687 files with different compilers, packages, and output options.  The
13688 @LaTeX{} export back-end finds the compiler version to use from
13689 @code{org-latex-compiler} variable or the @samp{#+LATEX_COMPILER} keyword in the
13690 Org file.  See the docstring for the
13691 @code{org-latex-default-packages-alist} for loading packages with certain
13692 compilers.  Also see @code{org-latex-bibtex-compiler} to set the
13693 bibliography compiler@footnote{This does not allow setting different bibliography compilers
13694 for different files.  However, ``smart'' @LaTeX{} compilation systems, such
13695 as latexmk, can select the correct bibliography compiler.}.
13697 @node @LaTeX{} specific export settings
13698 @subsection @LaTeX{} specific export settings
13700 The @LaTeX{} export back-end has several additional keywords for
13701 customizing @LaTeX{} output.  Setting these keywords works similar to the
13702 general options (see @ref{Export Settings}).
13704 @table @asis
13705 @item @samp{DESCRIPTION}
13706 @cindex @samp{DESCRIPTION}, keyword
13707 @vindex org-latex-hyperref-template
13708 @vindex org-latex-title-command
13709 The document's description.  The description along with author
13710 name, keywords, and related file metadata are inserted in the
13711 output file by the hyperref package.  See
13712 @code{org-latex-hyperref-template} for customizing metadata items.
13713 See @code{org-latex-title-command} for typesetting description into
13714 the document's front matter.  Use multiple @samp{DESCRIPTION} keywords
13715 for long descriptions.
13717 @item @samp{LATEX_CLASS}
13718 @cindex @samp{LATEX_CLASS}, keyword
13719 @vindex org-latex-default-class
13720 @vindex org-latex-classes
13721 This is @LaTeX{} document class, such as @emph{article}, @emph{report},
13722 @emph{book}, and so on, which contain predefined preamble and headline
13723 level mapping that the @LaTeX{} export back-end needs.  The back-end
13724 reads the default class name from the @code{org-latex-default-class}
13725 variable.  Org has @emph{article} as the default class.  A valid
13726 default class must be an element of @code{org-latex-classes}.
13728 @item @samp{LATEX_CLASS_OPTIONS}
13729 @cindex @samp{LATEX_CLASS_OPTIONS}, keyword
13730 Options the @LaTeX{} export back-end uses when calling the @LaTeX{}
13731 document class.
13733 @item @samp{LATEX_COMPILER}
13734 @cindex @samp{LATEX_COMPILER}, keyword
13735 @vindex org-latex-compiler
13736 The compiler, such as @samp{pdflatex}, @samp{xelatex}, @samp{lualatex}, for
13737 producing the PDF.  See @code{org-latex-compiler}.
13739 @item @samp{LATEX_HEADER}
13740 @itemx @samp{LATEX_HEADER_EXTRA}
13741 @cindex @samp{LATEX_HEADER}, keyword
13742 @cindex @samp{LATEX_HEADER_EXTRA}, keyword
13743 @vindex org-latex-classes
13744 Arbitrary lines to add to the document's preamble, before the
13745 hyperref settings.  See @code{org-latex-classes} for adjusting the
13746 structure and order of the @LaTeX{} headers.
13748 @item @samp{KEYWORDS}
13749 @cindex @samp{KEYWORDS}, keyword
13750 @vindex org-latex-hyperref-template
13751 @vindex org-latex-title-command
13752 The keywords for the document.  The description along with author
13753 name, keywords, and related file metadata are inserted in the
13754 output file by the hyperref package.  See
13755 @code{org-latex-hyperref-template} for customizing metadata items.
13756 See @code{org-latex-title-command} for typesetting description into
13757 the document's front matter.  Use multiple @samp{KEYWORDS} lines if
13758 necessary.
13760 @item @samp{SUBTITLE}
13761 @cindex @samp{SUBTITLE}, keyword
13762 @vindex org-latex-subtitle-separate
13763 @vindex org-latex-subtitle-format
13764 The document's subtitle.  It is typeset as per
13765 @code{org-latex-subtitle-format}.  If @code{org-latex-subtitle-separate} is
13766 non-@code{nil}, it is typed as part of the @code{\title} macro.  See
13767 @code{org-latex-hyperref-template} for customizing metadata items.
13768 See @code{org-latex-title-command} for typesetting description
13769 into the document's front matter.
13770 @end table
13772 The following sections have further details.
13774 @node @LaTeX{} header and sectioning
13775 @subsection @LaTeX{} header and sectioning structure
13777 @cindex @LaTeX{} class
13778 @cindex @LaTeX{} sectioning structure
13779 @cindex @LaTeX{} header
13780 @cindex header, for @LaTeX{} files
13781 @cindex sectioning structure, for @LaTeX{} export
13783 The @LaTeX{} export back-end converts the first three of Org's outline
13784 levels into @LaTeX{} headlines.  The remaining Org levels are exported as
13785 lists.  To change this globally for the cut-off point between levels
13786 and lists, (see @ref{Export Settings}).
13788 By default, the @LaTeX{} export back-end uses the @emph{article} class.
13790 @vindex org-latex-default-class
13791 @vindex org-latex-classes
13792 @vindex org-latex-default-packages-alist
13793 @vindex org-latex-packages-alist
13794 To change the default class globally, edit @code{org-latex-default-class}.
13795 To change the default class locally in an Org file, add option lines
13796 @samp{#+LATEX_CLASS: myclass}.  To change the default class for just a part
13797 of the Org file, set a sub-tree property, @samp{EXPORT_LATEX_CLASS}.  The
13798 class name entered here must be valid member of @code{org-latex-classes}.
13799 This variable defines a header template for each class into which the
13800 exporter splices the values of @code{org-latex-default-packages-alist} and
13801 @code{org-latex-packages-alist}.  Use the same three variables to define
13802 custom sectioning or custom classes.
13804 @cindex @samp{LATEX_CLASS}, keyword
13805 @cindex @samp{LATEX_CLASS_OPTIONS}, keyword
13806 @cindex @samp{EXPORT_LATEX_CLASS}, property
13807 @cindex @samp{EXPORT_LATEX_CLASS_OPTIONS}, property
13808 The @LaTeX{} export back-end sends the @samp{LATEX_CLASS_OPTIONS} keyword and
13809 @samp{EXPORT_LATEX_CLASS_OPTIONS} property as options to the @LaTeX{}
13810 @code{\documentclass} macro.  The options and the syntax for specifying
13811 them, including enclosing them in square brackets, follow @LaTeX{}
13812 conventions.
13814 @example
13815 #+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside,twocolumn]
13816 @end example
13818 @cindex @samp{LATEX_HEADER}, keyword
13819 @cindex @samp{LATEX_HEADER_EXTRA}, keyword
13820 The @LaTeX{} export back-end appends values from @samp{LATEX_HEADER} and
13821 @samp{LATEX_HEADER_EXTRA} keywords to the @LaTeX{} header.  The docstring for
13822 @code{org-latex-classes} explains in more detail.  Also note that @LaTeX{}
13823 export back-end does not append @samp{LATEX_HEADER_EXTRA} to the header
13824 when previewing @LaTeX{} snippets (see @ref{Previewing @LaTeX{} fragments}).
13826 A sample Org file with the above headers:
13828 @example
13829 #+LATEX_CLASS: article
13830 #+LATEX_CLASS_OPTIONS: [a4paper]
13831 #+LATEX_HEADER: \usepackage@{xyz@}
13833 * Headline 1
13834   some text
13835 * Headline 2
13836   some more text
13837 @end example
13839 @node Quoting @LaTeX{} code
13840 @subsection Quoting @LaTeX{} code
13842 The @LaTeX{} export back-end can insert any arbitrary @LaTeX{} code, see
13843 @ref{Embedded @LaTeX{}}.  There are three ways to embed such code in the Org
13844 file and they all use different quoting syntax.
13846 @cindex inline, in @LaTeX{} export
13847 Inserting in-line quoted with @@ symbols:
13849 @example
13850 Code embedded in-line @@@@latex:any arbitrary LaTeX code@@@@ in a paragraph.
13851 @end example
13853 @cindex @samp{LATEX}, keyword
13854 Inserting as one or more keyword lines in the Org file:
13856 @example
13857 #+LATEX: any arbitrary LaTeX code
13858 @end example
13860 @cindex @samp{BEGIN_EXPORT latex}
13861 Inserting as an export block in the Org file, where the back-end
13862 exports any code between begin and end markers:
13864 @example
13865 #+BEGIN_EXPORT latex
13866   any arbitrary LaTeX code
13867 #+END_EXPORT
13868 @end example
13870 @node Tables in @LaTeX{} export
13871 @subsection Tables in @LaTeX{} export
13873 @cindex tables, in @LaTeX{} export
13875 The @LaTeX{} export back-end can pass several @LaTeX{} attributes for table
13876 contents and layout.  Besides specifying label and caption (see
13877 @ref{Images and Tables}), the other valid @LaTeX{} attributes include:
13879 @table @asis
13880 @item @samp{:mode}
13881 @vindex org-latex-default-table-mode
13882 The @LaTeX{} export back-end wraps the table differently depending
13883 on the mode for accurate rendering of math symbols.  Mode is
13884 either @samp{table}, @samp{math}, @samp{inline-math} or @samp{verbatim}.
13886 For @samp{math} or @samp{inline-math} mode, @LaTeX{} export back-end wraps the
13887 table in a math environment, but every cell in it is exported
13888 as-is.  The @LaTeX{} export back-end determines the default mode
13889 from @code{org-latex-default-table-mode}.  The @LaTeX{} export back-end
13890 merges contiguous tables in the same mode into a single
13891 environment.
13893 @item @samp{:environment}
13894 @vindex org-latex-default-table-environment
13895 Set the default @LaTeX{} table environment for the @LaTeX{} export
13896 back-end to use when exporting Org tables.  Common @LaTeX{} table
13897 environments are provided by these packages: tabularx, longtable,
13898 array, tabu, and bmatrix.  For packages, such as tabularx and
13899 tabu, or any newer replacements, include them in the
13900 @code{org-latex-packages-alist} variable so the @LaTeX{} export back-end
13901 can insert the appropriate load package headers in the converted
13902 @LaTeX{} file.  Look in the docstring for the
13903 @code{org-latex-packages-alist} variable for configuring these
13904 packages for @LaTeX{} snippet previews, if any.
13906 @item @samp{:caption}
13907 Use @samp{CAPTION} keyword to set a simple caption for a table (see
13908 @ref{Images and Tables}).  For custom captions, use @samp{:caption}
13909 attribute, which accepts raw @LaTeX{} code.  @samp{:caption} value
13910 overrides @samp{CAPTION} value.
13912 @item @samp{:float}
13913 @itemx @samp{:placement}
13914 The table environments by default are not floats in @LaTeX{}.  To
13915 make them floating objects use @samp{:float} with one of the following
13916 options: @samp{sideways}, @samp{multicolumn}, @samp{t}, and @samp{nil}.
13918 @LaTeX{} floats can also have additional layout @samp{:placement}
13919 attributes.  These are the usual @samp{[h t b p ! H]} permissions
13920 specified in square brackets.  Note that for @samp{:float sideways}
13921 tables, the @LaTeX{} export back-end ignores @samp{:placement}
13922 attributes.
13924 @item @samp{:align}
13925 @itemx @samp{:font}
13926 @itemx @samp{:width}
13927 The @LaTeX{} export back-end uses these attributes for regular
13928 tables to set their alignments, fonts, and widths.
13930 @item @samp{:spread}
13931 When @samp{:spread} is non-@code{nil}, the @LaTeX{} export back-end spreads or
13932 shrinks the table by the @samp{:width} for tabu and longtabu
13933 environments.  @samp{:spread} has no effect if @samp{:width} is not set.
13935 @item @samp{:booktabs}
13936 @itemx @samp{:center}
13937 @itemx @samp{:rmlines}
13938 @vindex org-latex-tables-booktabs
13939 @vindex org-latex-tables-centered
13940 All three commands are toggles.  @samp{:booktabs} brings in modern
13941 typesetting enhancements to regular tables.  The booktabs package
13942 has to be loaded through @code{org-latex-packages-alist}.  @samp{:center}
13943 is for centering the table.  @samp{:rmlines} removes all but the very
13944 first horizontal line made of ASCII characters from ``table.el''
13945 tables only.
13947 @item @samp{:math-prefix}
13948 @itemx @samp{:math-suffix}
13949 @itemx @samp{:math-arguments}
13950 The @LaTeX{} export back-end inserts @samp{:math-prefix} string value in
13951 a math environment before the table.  The @LaTeX{} export back-end
13952 inserts @samp{:math-suffix} string value in a math environment after
13953 the table.  The @LaTeX{} export back-end inserts @samp{:math-arguments}
13954 string value between the macro name and the table's contents.
13955 @samp{:math-arguments} comes in use for matrix macros that require
13956 more than one argument, such as @samp{qbordermatrix}.
13957 @end table
13959 @LaTeX{} table attributes help formatting tables for a wide range of
13960 situations, such as matrix product or spanning multiple pages:
13962 @example
13963 #+ATTR_LATEX: :environment longtable :align l|lp@{3cm@}r|l
13964 | ... | ... |
13965 | ... | ... |
13967 #+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
13968 | a | b |
13969 | c | d |
13970 #+ATTR_LATEX: :mode math :environment bmatrix
13971 | 1 | 2 |
13972 | 3 | 4 |
13973 @end example
13975 Set the caption with the @LaTeX{} command
13976 @samp{\bicaption@{HeadingA@}@{HeadingB@}}:
13978 @example
13979 #+ATTR_LATEX: :caption \bicaption@{HeadingA@}@{HeadingB@}
13980 | ... | ... |
13981 | ... | ... |
13982 @end example
13984 @node Images in @LaTeX{} export
13985 @subsection Images in @LaTeX{} export
13987 @cindex images, inline in LaTeX
13988 @cindex inlining images in LaTeX
13989 @cindex @samp{ATTR_LATEX}, keyword
13991 The @LaTeX{} export back-end processes image links in Org files that do
13992 not have descriptions, such as these links @samp{[[file:img.jpg]]} or
13993 @samp{[[./img.jpg]]}, as direct image insertions in the final PDF output.  In
13994 the PDF, they are no longer links but actual images embedded on the
13995 page.  The @LaTeX{} export back-end uses @samp{\includegraphics} macro to
13996 insert the image.  But for TikZ (@uref{http://sourceforge.net/projects/pgf/})
13997 images, the back-end uses an @code{\input} macro wrapped within
13998 a @code{tikzpicture} environment.
14000 For specifying image @samp{:width}, @samp{:height}, and other @samp{:options}, use
14001 this syntax:
14003 @example
14004 #+ATTR_LATEX: :width 5cm :options angle=90
14005 [[./img/sed-hr4049.pdf]]
14006 @end example
14008 For custom commands for captions, use the @samp{:caption} attribute.  It
14009 overrides the default @samp{#+CAPTION} value:
14011 @example
14012 #+ATTR_LATEX: :caption \bicaption@{HeadingA@}@{HeadingB@}
14013 [[./img/sed-hr4049.pdf]]
14014 @end example
14016 When captions follow the method as described in @ref{Images and Tables},
14017 the @LaTeX{} export back-end wraps the picture in a floating @samp{figure}
14018 environment.  To float an image without specifying a caption, set the
14019 @samp{:float} attribute to one of the following:
14021 @table @asis
14022 @item @samp{t}
14023 For a standard @samp{figure} environment; used by default whenever an
14024 image has a caption.
14026 @item @samp{multicolumn}
14027 To span the image across multiple columns of a page; the back-end
14028 wraps the image in a @samp{figure*} environment.
14030 @item @samp{wrap}
14031 For text to flow around the image on the right; the figure
14032 occupies the left half of the page.
14034 @item @samp{sideways}
14035 For a new page with the image sideways, rotated ninety degrees,
14036 in a @samp{sidewaysfigure} environment; overrides @samp{:placement}
14037 setting.
14039 @item @samp{nil}
14040 To avoid a @samp{:float} even if using a caption.
14041 @end table
14043 @noindent
14044 Use the @samp{placement} attribute to modify a floating environment's
14045 placement.
14047 @example
14048 #+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement @{r@}@{0.4\textwidth@}
14049 [[./img/hst.png]]
14050 @end example
14052 @vindex org-latex-images-centered
14053 @cindex center image in LaTeX export
14054 @cindex image, centering in LaTeX export
14055 The @LaTeX{} export back-end centers all images by default.  Setting
14056 @samp{:center} to @samp{nil} disables centering.  To disable centering globally,
14057 set @code{org-latex-images-centered} to @samp{t}.
14059 Set the @samp{:comment-include} attribute to non-@code{nil} value for the @LaTeX{}
14060 export back-end to comment out the @samp{\includegraphics} macro.
14062 @node Plain lists in @LaTeX{} export
14063 @subsection Plain lists in @LaTeX{} export
14065 @cindex plain lists, in @LaTeX{} export
14066 @cindex @samp{ATTR_LATEX}, keyword
14067 The @LaTeX{} export back-end accepts the @samp{environment} and @samp{options}
14068 attributes for plain lists.  Both attributes work together for
14069 customizing lists, as shown in the examples:
14071 @example
14072 #+LATEX_HEADER: \usepackage[inline]@{enumitem@}
14073 Some ways to say "Hello":
14074 #+ATTR_LATEX: :environment itemize*
14075 #+ATTR_LATEX: :options [label=@{@}, itemjoin=@{,@}, itemjoin*=@{, and@}]
14076 - Hola
14077 - Bonjour
14078 - Guten Tag.
14079 @end example
14081 Since @LaTeX{} supports only four levels of nesting for lists, use an
14082 external package, such as @samp{enumitem} in @LaTeX{}, for levels deeper than
14083 four:
14085 @example
14086 #+LATEX_HEADER: \usepackage@{enumitem@}
14087 #+LATEX_HEADER: \renewlist@{itemize@}@{itemize@}@{9@}
14088 #+LATEX_HEADER: \setlist[itemize]@{label=$\circ$@}
14089 - One
14090   - Two
14091     - Three
14092       - Four
14093         - Five
14094 @end example
14096 @node Source blocks in @LaTeX{} export
14097 @subsection Source blocks in @LaTeX{} export
14099 @cindex source blocks, in @LaTeX{} export
14100 @cindex @samp{ATTR_LATEX}, keyword
14102 The @LaTeX{} export back-end can make source code blocks into floating
14103 objects through the attributes @samp{:float} and @samp{:options}.  For @samp{:float}:
14105 @table @asis
14106 @item @samp{t}
14107 Makes a source block float; by default floats any source block
14108 with a caption.
14110 @item @samp{multicolumn}
14111 Spans the source block across multiple columns of a page.
14113 @item @samp{nil}
14114 Avoids a @samp{:float} even if using a caption; useful for source code
14115 blocks that may not fit on a page.
14116 @end table
14118 @example
14119 #+ATTR_LATEX: :float nil
14120 #+BEGIN_SRC emacs-lisp
14121   Lisp code that may not fit in a single page.
14122 #+END_SRC
14123 @end example
14125 @vindex org-latex-listings-options
14126 @vindex org-latex-minted-options
14127 The @LaTeX{} export back-end passes string values in @samp{:options} to @LaTeX{}
14128 packages for customization of that specific source block.  In the
14129 example below, the @samp{:options} are set for Minted.  Minted is a source
14130 code highlighting @LaTeX{} package with many configurable options.
14132 @example
14133 #+ATTR_LATEX: :options commentstyle=\bfseries
14134 #+BEGIN_SRC emacs-lisp
14135   (defun Fib (n)
14136     (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
14137 #+END_SRC
14138 @end example
14140 To apply similar configuration options for all source blocks in
14141 a file, use the @code{org-latex-listings-options} and
14142 @code{org-latex-minted-options} variables.
14144 @node Example blocks in @LaTeX{} export
14145 @subsection Example blocks in @LaTeX{} export
14147 @cindex example blocks, in @LaTeX{} export
14148 @cindex verbatim blocks, in @LaTeX{} export
14149 @cindex @samp{ATTR_LATEX}, keyword
14151 The @LaTeX{} export back-end wraps the contents of example blocks in
14152 a @samp{verbatim} environment.  To change this behavior to use another
14153 environment globally, specify an appropriate export filter (see
14154 @ref{Advanced Configuration}).  To change this behavior to use another
14155 environment for each block, use the @samp{:environment} parameter to
14156 specify a custom environment.
14158 @example
14159 #+ATTR_LATEX: :environment myverbatim
14160 #+BEGIN_EXAMPLE
14161   This sentence is false.
14162 #+END_EXAMPLE
14163 @end example
14165 @node Special blocks in @LaTeX{} export
14166 @subsection Special blocks in @LaTeX{} export
14168 @cindex special blocks, in @LaTeX{} export
14169 @cindex abstract, in @LaTeX{} export
14170 @cindex proof, in @LaTeX{} export
14171 @cindex @samp{ATTR_LATEX}, keyword
14173 For other special blocks in the Org file, the @LaTeX{} export back-end
14174 makes a special environment of the same name.  The back-end also takes
14175 @samp{:options}, if any, and appends as-is to that environment's opening
14176 string.  For example:
14178 @example
14179 #+BEGIN_abstract
14180   We demonstrate how to solve the Syracuse problem.
14181 #+END_abstract
14183 #+ATTR_LATEX: :options [Proof of important theorem]
14184 #+BEGIN_proof
14185   ...
14186   Therefore, any even number greater than 2 is the sum of two primes.
14187 #+END_proof
14188 @end example
14190 @noindent
14191 exports to
14193 @example
14194 \begin@{abstract@}
14195   We demonstrate how to solve the Syracuse problem.
14196 \end@{abstract@}
14198 \begin@{proof@}[Proof of important theorem]
14199   ...
14200   Therefore, any even number greater than 2 is the sum of two primes.
14201 \end@{proof@}
14202 @end example
14204 If you need to insert a specific caption command, use @samp{:caption}
14205 attribute.  It overrides standard @samp{CAPTION} value, if any.  For
14206 example:
14208 @example
14209 #+ATTR_LATEX: :caption \MyCaption@{HeadingA@}
14210 #+BEGIN_proof
14211   ...
14212 #+END_proof
14213 @end example
14215 @node Horizontal rules in @LaTeX{} export
14216 @subsection Horizontal rules in @LaTeX{} export
14218 @cindex horizontal rules, in @LaTeX{} export
14219 @cindex @samp{ATTR_LATEX}, keyword
14221 The @LaTeX{} export back-end converts horizontal rules by the specified
14222 @samp{:width} and @samp{:thickness} attributes.  For example:
14224 @example
14225 #+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt
14226 -----
14227 @end example
14229 @node Markdown Export
14230 @section Markdown Export
14232 @cindex Markdown export
14234 The Markdown export back-end, ``md'', converts an Org file to Markdown
14235 format, as defined at @uref{http://daringfireball.net/projects/markdown/}.
14237 Since it is built on top of the HTML back-end (see @ref{HTML Export}), it
14238 converts every Org construct not defined in Markdown syntax, such as
14239 tables, to HTML.
14241 @anchor{Markdown export commands}
14242 @subheading Markdown export commands
14244 @table @asis
14245 @item @kbd{C-c C-e m m} (@code{org-md-export-to-markdown})
14246 @kindex C-c C-c m m
14247 @findex org-md-export-to-markdown
14248 Export to a text file with Markdown syntax.  For @samp{myfile.org},
14249 Org exports to @samp{myfile.md}, overwritten without warning.
14251 @item @kbd{C-c C-e m M} (@code{org-md-export-as-markdown})
14252 @kindex C-c C-c m M
14253 @findex org-md-export-as-markdown
14254 Export to a temporary buffer.  Does not create a file.
14256 @item @kbd{C-c C-e m o}
14257 @kindex C-c C-e m o
14258 Export as a text file with Markdown syntax, then open it.
14259 @end table
14261 @anchor{Header and sectioning structure (1)}
14262 @subheading Header and sectioning structure
14264 @vindex org-md-headline-style
14265 Based on @code{org-md-headline-style}, Markdown export can generate
14266 headlines of both @emph{atx} and @emph{setext} types.  @emph{atx} limits headline
14267 levels to two whereas @emph{setext} limits headline levels to six.  Beyond
14268 these limits, the export back-end converts headlines to lists.  To set
14269 a limit to a level before the absolute limit (see @ref{Export Settings}).
14271 @node OpenDocument Text Export
14272 @section OpenDocument Text Export
14274 @cindex ODT
14275 @cindex OpenDocument
14276 @cindex export, OpenDocument
14277 @cindex LibreOffice
14279 The ODT export back-end handles creating of OpenDocument Text (ODT)
14280 format.  Documents created by this exporter use the
14281 @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
14282 (OpenDocument) Version 1.2}.} and are compatible
14283 with LibreOffice 3.4.
14285 @menu
14286 * Pre-requisites for ODT export:: Required packages.
14287 * ODT export commands::          Invoking export.
14288 * ODT specific export settings:: Configuration options.
14289 * Extending ODT export::         Producing DOC, PDF files.
14290 * Applying custom styles::       Styling the output.
14291 * Links in ODT export::          Handling and formatting links.
14292 * Tables in ODT export::         Org tables conversions.
14293 * Images in ODT export::         Inserting images.
14294 * Math formatting in ODT export:: Formatting @LaTeX{} fragments.
14295 * Labels and captions in ODT export:: Rendering objects.
14296 * Literal examples in ODT export:: For source code and example blocks.
14297 * Advanced topics in ODT export:: For power users.
14298 @end menu
14300 @node Pre-requisites for ODT export
14301 @subsection Pre-requisites for ODT export
14303 @cindex zip
14305 The ODT export back-end relies on the zip program to create the final
14306 compressed ODT output.  Check if @samp{zip} is locally available and
14307 executable.  Without it, export cannot finish.
14309 @node ODT export commands
14310 @subsection ODT export commands
14312 @table @asis
14313 @item @kbd{C-c C-e o o} (@code{org-export-to-odt})
14314 @kindex C-c C-e o o
14315 @findex org-export-to-odt
14316 Export as OpenDocument Text file.
14318 @cindex @samp{EXPORT_FILE_NAME}, property
14319 @vindex org-odt-preferred-output-format
14321 If @code{org-odt-preferred-output-format} is specified, the ODT export
14322 back-end automatically converts the exported file to that format.
14324 For @samp{myfile.org}, Org exports to @samp{myfile.odt}, overwriting
14325 without warning.  The ODT export back-end exports a region only
14326 if a region was active.
14328 If the selected region is a single tree, the ODT export back-end
14329 makes the tree head the document title.  Incidentally, @kbd{C-c @@} selects the current sub-tree.  If the tree head entry has,
14330 or inherits, an @samp{EXPORT_FILE_NAME} property, the ODT export
14331 back-end uses that for file name.
14333 @item @kbd{C-c C-e o O}
14334 @kindex C-c C-e o O
14335 Export as an OpenDocument Text file and open the resulting file.
14337 @vindex org-export-odt-preferred-output-format
14338 If @code{org-export-odt-preferred-output-format} is specified, open
14339 the converted file instead.  See @ref{Automatically exporting to other formats}.
14340 @end table
14342 @node ODT specific export settings
14343 @subsection ODT specific export settings
14345 The ODT export back-end has several additional keywords for
14346 customizing ODT output.  Setting these keywords works similar to the
14347 general options (see @ref{Export Settings}).
14349 @table @asis
14350 @item @samp{DESCRIPTION}
14351 @cindex @samp{DESCRIPTION}, keyword
14352 This is the document's description, which the ODT export back-end
14353 inserts as document metadata.  For long descriptions, use
14354 multiple lines, prefixed with @samp{DESCRIPTION}.
14356 @item @samp{KEYWORDS}
14357 @cindex @samp{KEYWORDS}, keyword
14358 The keywords for the document.  The ODT export back-end inserts
14359 the description along with author name, keywords, and related
14360 file metadata as metadata in the output file.  Use multiple
14361 @samp{KEYWORDS} if necessary.
14363 @item @samp{ODT_STYLES_FILE}
14364 @cindex @samp{ODT_STYLES_FILE}, keyword
14365 @vindex org-odt-styles-file
14366 The ODT export back-end uses the @code{org-odt-styles-file} by
14367 default.  See @ref{Applying custom styles} for details.
14369 @item @samp{SUBTITLE}
14370 @cindex @samp{SUBTITLE}, keyword
14371 The document subtitle.
14372 @end table
14374 @node Extending ODT export
14375 @subsection Extending ODT export
14377 The ODT export back-end can produce documents in other formats besides
14378 ODT using a specialized ODT converter process.  Its common interface
14379 works with popular converters to produce formats such as @samp{doc}, or
14380 convert a document from one format, say @samp{csv}, to another format, say
14381 @samp{xls}.
14383 @cindex @file{unoconv}
14384 @vindex org-odt-convert-process
14385 Customize @code{org-odt-convert-process} variable to point to @samp{unoconv},
14386 which is the ODT's preferred converter.  Working installations of
14387 LibreOffice would already have @samp{unoconv} installed.  Alternatively,
14388 other converters may be substituted here.  See @ref{Configuring a document converter}.
14390 @anchor{Automatically exporting to other formats}
14391 @subsubheading Automatically exporting to other formats
14393 @vindex org-odt-preferred-output-format
14394 If ODT format is just an intermediate step to get to other formats,
14395 such as @samp{doc}, @samp{docx}, @samp{rtf}, or @samp{pdf}, etc., then extend the ODT
14396 export back-end to directly produce that format.  Specify the final
14397 format in the @code{org-odt-preferred-output-format} variable.  This is one
14398 way to extend (see @ref{ODT export commands}).
14400 @anchor{Converting between document formats}
14401 @subsubheading Converting between document formats
14403 The Org export back-end is made to be inter-operable with a wide range
14404 of text document format converters.  Newer generation converters, such
14405 as LibreOffice and Pandoc, can handle hundreds of formats at once.
14406 Org provides a consistent interaction with whatever converter is
14407 installed.  Here are some generic commands:
14409 @table @asis
14410 @item @kbd{M-x org-odt-convert}
14411 @findex org-odt-convert
14412 Convert an existing document from one format to another.  With
14413 a prefix argument, opens the newly produced file.
14414 @end table
14416 @node Applying custom styles
14417 @subsection Applying custom styles
14419 @cindex styles, custom
14420 @cindex template, custom
14422 The ODT export back-end comes with many OpenDocument styles (see
14423 @ref{Working with OpenDocument style files}).  To expand or further
14424 customize these built-in style sheets, either edit the style sheets
14425 directly or generate them using an application such as LibreOffice.
14426 The example here shows creating a style using LibreOffice.
14428 @anchor{Applying custom styles the easy way}
14429 @subsubheading Applying custom styles: the easy way
14431 @enumerate
14432 @item
14433 Create a sample @samp{example.org} file with settings as shown below,
14434 and export it to ODT format.
14436 @example
14437 #+OPTIONS: H:10 num:t
14438 @end example
14440 @item
14441 Open the above @samp{example.odt} using LibreOffice.  Use the @emph{Stylist}
14442 to locate the target styles, which typically have the ``Org'' prefix.
14443 Open one, modify, and save as either OpenDocument Text (ODT) or
14444 OpenDocument Template (OTT) file.
14446 @item
14447 @vindex org-odt-styles-file
14448 Customize the variable @code{org-odt-styles-file} and point it to the
14449 newly created file.  For additional configuration options, see
14450 @ref{x-overriding-factory-styles, , Overriding factory styles}.
14452 @cindex @samp{ODT_STYLES_FILE}, keyword
14453 To apply an ODT style to a particular file, use the
14454 @samp{ODT_STYLES_FILE} keyword as shown in the example below:
14456 @example
14457 #+ODT_STYLES_FILE: "/path/to/example.ott"
14458 @end example
14460 @noindent
14463 @example
14464 #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
14465 @end example
14466 @end enumerate
14468 @anchor{Using third-party styles and templates}
14469 @subsubheading Using third-party styles and templates
14471 The ODT export back-end relies on many templates and style names.
14472 Using third-party styles and templates can lead to mismatches.
14473 Templates derived from built in ODT templates and styles seem to have
14474 fewer problems.
14476 @node Links in ODT export
14477 @subsection Links in ODT export
14479 @cindex links, in ODT export
14481 ODT exporter creates native cross-references for internal links.  It
14482 creates Internet-style links for all other links.
14484 A link with no description and pointing to a regular, un-itemized,
14485 outline heading is replaced with a cross-reference and section number
14486 of the heading.
14488 A @samp{\ref@{label@}}-style reference to an image, table etc., is replaced
14489 with a cross-reference and sequence number of the labeled entity.  See
14490 @ref{Labels and captions in ODT export}.
14492 @node Tables in ODT export
14493 @subsection Tables in ODT export
14495 @cindex tables, in ODT export
14497 The ODT export back-end handles native Org mode tables (see @ref{Tables})
14498 and simple @samp{table.el} tables.  Complex @samp{table.el} tables having column
14499 or row spans are not supported.  Such tables are stripped from the
14500 exported document.
14502 By default, the ODT export back-end exports a table with top and
14503 bottom frames and with ruled lines separating row and column groups
14504 (see @ref{Column Groups}).  All tables are typeset to occupy the same
14505 width.  The ODT export back-end honors any table alignments and
14506 relative widths for columns (see @ref{Column Width and Alignment}).
14508 Note that the ODT export back-end interprets column widths as weighted
14509 ratios, the default weight being 1.
14511 @cindex @samp{ATTR_ODT}, keyword
14512 Specifying @samp{:rel-width} property on an @samp{ATTR_ODT} line controls the
14513 width of the table.  For example:
14515 @example
14516 #+ATTR_ODT: :rel-width 50
14517 | Area/Month    |   Jan |   Feb |   Mar |   Sum |
14518 |---------------+-------+-------+-------+-------|
14519 | /             |     < |       |       |     < |
14520 | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
14521 | North America |     1 |    21 |   926 |   948 |
14522 | Middle East   |     6 |    75 |   844 |   925 |
14523 | Asia Pacific  |     9 |    27 |   790 |   826 |
14524 |---------------+-------+-------+-------+-------|
14525 | Sum           |    16 |   123 |  2560 |  2699 |
14526 @end example
14528 On export, the above table takes 50% of text width area.  The exporter
14529 sizes the columns in the ratio: 13:5:5:5:6.  The first column is
14530 left-aligned and rest of the columns, right-aligned.  Vertical rules
14531 separate the header and the last column.  Horizontal rules separate
14532 the header and the last row.
14534 For even more customization, create custom table styles and associate
14535 them with a table using the @samp{ATTR_ODT} keyword.  See @ref{Customizing tables in ODT export}.
14537 @node Images in ODT export
14538 @subsection Images in ODT export
14540 @cindex images, embedding in ODT
14541 @cindex embedding images in ODT
14543 @anchor{Embedding images}
14544 @subsubheading Embedding images
14546 The ODT export back-end processes image links in Org files that do not
14547 have descriptions, such as these links @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]},
14548 as direct image insertions in the final output.  Either of these
14549 examples works:
14551 @example
14552 [[file:img.png]]
14553 @end example
14555 @example
14556 [[./img.png]]
14557 @end example
14559 @anchor{Embedding clickable images}
14560 @subsubheading Embedding clickable images
14562 For clickable images, provide a link whose description is another link
14563 to an image file.  For example, to embed an image
14564 @samp{org-mode-unicorn.png} which when clicked jumps to @uref{https://orgmode.org}
14565 website, do the following
14567 @example
14568 [[https://orgmode.org][./org-mode-unicorn.png]]
14569 @end example
14571 @anchor{Sizing and scaling of embedded images}
14572 @subsubheading Sizing and scaling of embedded images
14574 @cindex @samp{ATTR_ODT}, keyword
14576 Control the size and scale of the embedded images with the @samp{ATTR_ODT}
14577 attribute.
14579 @cindex identify, ImageMagick
14580 @vindex org-odt-pixels-per-inch
14581 The ODT export back-end starts with establishing the size of the image
14582 in the final document.  The dimensions of this size are measured in
14583 centimeters.  The back-end then queries the image file for its
14584 dimensions measured in pixels.  For this measurement, the back-end
14585 relies on ImageMagick's identify program or Emacs @code{create-image} and
14586 @code{image-size} API.  ImageMagick is the preferred choice for large file
14587 sizes or frequent batch operations.  The back-end then converts the
14588 pixel dimensions using @code{org-odt-pixels-per-inch} into the familiar 72
14589 dpi or 96 dpi.  The default value for this is in
14590 @code{display-pixels-per-inch}, which can be tweaked for better results
14591 based on the capabilities of the output device.  Here are some common
14592 image scaling operations:
14594 @table @asis
14595 @item Explicitly size the image
14596 To embed @samp{img.png} as a 10 cm x 10 cm image, do the following:
14598 @example
14599 #+ATTR_ODT: :width 10 :height 10
14600 [[./img.png]]
14601 @end example
14603 @item Scale the image
14604 To embed @samp{img.png} at half its size, do the following:
14606 @example
14607 #+ATTR_ODT: :scale 0.5
14608 [[./img.png]]
14609 @end example
14611 @item Scale the image to a specific width
14612 To embed @samp{img.png} with a width of 10 cm while retaining the
14613 original height:width ratio, do the following:
14615 @example
14616 #+ATTR_ODT: :width 10
14617 [[./img.png]]
14618 @end example
14620 @item Scale the image to a specific height
14621 To embed @samp{img.png} with a height of 10 cm while retaining the
14622 original height:width ratio, do the following:
14624 @example
14625 #+ATTR_ODT: :height 10
14626 [[./img.png]]
14627 @end example
14628 @end table
14630 @anchor{Anchoring of images}
14631 @subsubheading Anchoring of images
14633 @cindex @samp{ATTR_ODT}, keyword
14634 The ODT export back-end can anchor images to @samp{"as-char"},
14635 @samp{"paragraph"}, or @samp{"page"}.  Set the preferred anchor using the
14636 @samp{:anchor} property of the @samp{ATTR_ODT} line.
14638 To create an image that is anchored to a page:
14640 @example
14641 #+ATTR_ODT: :anchor "page"
14642 [[./img.png]]
14643 @end example
14645 @node Math formatting in ODT export
14646 @subsection Math formatting in ODT export
14648 The ODT exporter has special support for handling math.
14650 @menu
14651 * @LaTeX{} math snippets::       Embedding in @LaTeX{} format.
14652 * MathML and OpenDocument formula files:: Embedding in native format.
14653 @end menu
14655 @node @LaTeX{} math snippets
14656 @subsubsection @LaTeX{} math snippets
14658 @LaTeX{} math snippets (see @ref{@LaTeX{} fragments}) can be embedded in the ODT
14659 document in one of the following ways:
14661 @table @asis
14662 @item MathML
14663 @cindex MathML
14664 Add this line to the Org file.  This option is activated on
14665 a per-file basis.
14667 @example
14668 #+OPTIONS: tex:t
14669 @end example
14671 With this option, @LaTeX{} fragments are first converted into MathML
14672 fragments using an external @LaTeX{}-to-MathML converter program.
14673 The resulting MathML fragments are then embedded as an
14674 OpenDocument Formula in the exported document.
14676 @vindex org-latex-to-mathml-convert-command
14677 @vindex org-latex-to-mathml-jar-file
14678 You can specify the @LaTeX{}-to-MathML converter by customizing the
14679 variables @code{org-latex-to-mathml-convert-command} and
14680 @code{org-latex-to-mathml-jar-file}.
14682 If you prefer to use MathToWeb@footnote{See @uref{http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl, MathToWeb}.} as your converter, you can
14683 configure the above variables as shown below.
14685 @lisp
14686 (setq org-latex-to-mathml-convert-command
14687       "java -jar %j -unicode -force -df %o %I"
14688       org-latex-to-mathml-jar-file
14689       "/path/to/mathtoweb.jar")
14690 @end lisp
14692 To use @LaTeX{}​ML@footnote{See @uref{http://dlmf.nist.gov/LaTeXML/}.} use
14694 @lisp
14695 (setq org-latex-to-mathml-convert-command
14696       "latexmlmath \"%i\" --presentationmathml=%o")
14697 @end lisp
14699 To quickly verify the reliability of the @LaTeX{}-to-MathML
14700 converter, use the following commands:
14702 @table @asis
14703 @item @kbd{M-x org-export-as-odf}
14704 Convert a @LaTeX{} math snippet to an OpenDocument formula
14705 (@samp{.odf}) file.
14707 @item @kbd{M-x org-export-as-odf-and-open}
14708 Convert a @LaTeX{} math snippet to an OpenDocument formula
14709 (@samp{.odf}) file and open the formula file with the
14710 system-registered application.
14711 @end table
14713 @item PNG images
14714 @cindex dvipng
14715 @cindex dvisvgm
14716 @cindex ImageMagick
14717 Add this line to the Org file.  This option is activated on
14718 a per-file basis.
14720 @example
14721 #+OPTIONS: tex:dvipng
14722 @end example
14724 @example
14725 #+OPTIONS: tex:dvisvgm
14726 @end example
14728 @noindent
14731 @example
14732 #+OPTIONS: tex:imagemagick
14733 @end example
14735 Under this option, @LaTeX{} fragments are processed into PNG or SVG
14736 images and the resulting images are embedded in the exported
14737 document.  This method requires dvipng program, dvisvgm or
14738 ImageMagick programs.
14739 @end table
14741 @node MathML and OpenDocument formula files
14742 @subsubsection MathML and OpenDocument formula files
14744 When embedding @LaTeX{} math snippets in ODT documents is not reliable,
14745 there is one more option to try.  Embed an equation by linking to its
14746 MathML (@samp{.mml}) source or its OpenDocument formula (@samp{.odf}) file as
14747 shown below:
14749 @example
14750 [[./equation.mml]]
14751 @end example
14753 @noindent
14756 @example
14757 [[./equation.odf]]
14758 @end example
14760 @node Labels and captions in ODT export
14761 @subsection Labels and captions in ODT export
14763 ODT format handles labeling and captioning of objects based on their
14764 types.  Inline images, tables, @LaTeX{} fragments, and Math formulas are
14765 numbered and captioned separately.  Each object also gets a unique
14766 sequence number based on its order of first appearance in the Org
14767 file.  Each category has its own sequence.  A caption is just a label
14768 applied to these objects.
14770 @example
14771 #+CAPTION: Bell curve
14772 #+NAME:   fig:SED-HR4049
14773 [[./img/a.png]]
14774 @end example
14776 When rendered, it may show as follows in the exported document:
14778 @example
14779 Figure 2: Bell curve
14780 @end example
14782 @vindex org-odt-category-map-alist
14783 To modify the category component of the caption, customize the option
14784 @code{org-odt-category-map-alist}.  For example, to tag embedded images
14785 with the string ``Illustration'' instead of the default string ``Figure'',
14786 use the following setting:
14788 @lisp
14789 (setq org-odt-category-map-alist
14790       '(("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))
14791 @end lisp
14793 With the above modification, the previous example changes to:
14795 @example
14796 Illustration 2: Bell curve
14797 @end example
14799 @node Literal examples in ODT export
14800 @subsection Literal examples in ODT export
14802 The ODT export back-end supports literal examples (see @ref{Literal Examples}) with full fontification.  Internally, the ODT export
14803 back-end relies on @samp{htmlfontify.el} to generate the style definitions
14804 needed for fancy listings.  The auto-generated styles get @samp{OrgSrc}
14805 prefix and inherit colors from the faces used by Emacs Font Lock
14806 library for that source language.
14808 @vindex org-odt-fontify-srcblocks
14809 For custom fontification styles, customize the
14810 @code{org-odt-create-custom-styles-for-srcblocks} option.
14812 @vindex org-odt-create-custom-styles-for-srcblocks
14813 To turn off fontification of literal examples, customize the
14814 @code{org-odt-fontify-srcblocks} option.
14816 @node Advanced topics in ODT export
14817 @subsection Advanced topics in ODT export
14819 The ODT export back-end has extensive features useful for power users
14820 and frequent uses of ODT formats.
14822 @anchor{Configuring a document converter}
14823 @subsubheading Configuring a document converter
14825 @cindex convert
14826 @cindex doc, docx, rtf
14827 @cindex converter
14829 The ODT export back-end works with popular converters with little or
14830 no extra configuration.  See @ref{Extending ODT export}.  The following is
14831 for unsupported converters or tweaking existing defaults.
14833 @table @asis
14834 @item Register the converter
14835 @vindex org-export-odt-convert-processes
14836 Add the name of the converter to the @code{org-odt-convert-processes}
14837 variable.  Note that it also requires how the converter is
14838 invoked on the command line.  See the variable's docstring for
14839 details.
14841 @item Configure its capabilities
14842 @vindex org-export-odt-convert-capabilities
14843 Specify which formats the converter can handle by customizing the
14844 variable @code{org-odt-convert-capabilities}.  Use the entry for the
14845 default values in this variable for configuring the new
14846 converter.  Also see its docstring for details.
14848 @item Choose the converter
14849 @vindex org-export-odt-convert-process
14850 Select the newly added converter as the preferred one by
14851 customizing the option @code{org-odt-convert-process}.
14852 @end table
14854 @anchor{Working with OpenDocument style files}
14855 @subsubheading Working with OpenDocument style files
14857 @cindex styles, custom
14858 @cindex template, custom
14860 This section explores the internals of the ODT exporter; the means by which
14861 it produces styled documents; the use of automatic and custom OpenDocument
14862 styles.
14864 The ODT exporter relies on two files for generating its output.  These
14865 files are bundled with the distribution under the directory pointed to
14866 by the variable @code{org-odt-styles-dir}.  The two files are:
14868 @table @asis
14869 @item @samp{OrgOdtStyles.xml} @anchor{x-orgodtstyles-xml}
14870 This file contributes to the @samp{styles.xml} file of the final ODT
14871 document.  This file gets modified for the following purposes:
14873 @enumerate
14874 @item
14875 To control outline numbering based on user settings;
14877 @item
14878 To add styles generated by @samp{htmlfontify.el} for fontification of
14879 code blocks.
14880 @end enumerate
14882 @item @samp{OrgOdtContentTemplate.xml} @anchor{x-orgodtcontenttemplate-xml}
14883 This file contributes to the @samp{content.xml} file of the final ODT
14884 document.  The contents of the Org outline are inserted between the
14885 @samp{<office:text>} @dots{} @samp{</office:text>} elements of this file.
14887 Apart from serving as a template file for the final @samp{content.xml},
14888 the file serves the following purposes:
14890 @enumerate
14891 @item
14892 It contains automatic styles for formatting of tables which are
14893 referenced by the exporter;
14895 @item
14896 It contains @samp{<text:sequence-decl>} @dots{} @samp{</text:sequence-decl>}
14897 elements that control numbering of tables, images, equations, and
14898 similar entities.
14899 @end enumerate
14900 @end table
14902 @anchor{x-overriding-factory-styles} The following two variables control
14903 the location from where the ODT exporter picks up the custom styles
14904 and content template files.  Customize these variables to override the
14905 factory styles used by the exporter.
14907 @table @asis
14908 @item @code{org-odt-styles-file}
14909 The ODT export back-end uses the file pointed to by this
14910 variable, such as @samp{styles.xml}, for the final output.  It can
14911 take one of the following values:
14913 @table @asis
14914 @item @samp{FILE.xml}
14915 Use this file instead of the default @samp{styles.xml}
14917 @item @samp{FILE.odt} or @samp{FILE.ott}
14918 Use the @samp{styles.xml} contained in the specified OpenDocument
14919 Text or Template file
14921 @item @samp{FILE.odt} or @samp{FILE.ott} and a subset of included files
14922 Use the @samp{styles.xml} contained in the specified OpenDocument
14923 Text or Template file.  Additionally extract the specified
14924 member files and embed those within the final ODT document.
14926 Use this option if the @samp{styles.xml} file references additional
14927 files like header and footer images.
14929 @item @code{nil}
14930 Use the default @samp{styles.xml}.
14931 @end table
14933 @item @code{org-odt-content-template-file}
14934 Use this variable to specify the blank @samp{content.xml} used in the
14935 final output.
14936 @end table
14938 @anchor{Creating one-off styles}
14939 @subsubheading Creating one-off styles
14941 The ODT export back-end can read embedded raw OpenDocument XML from
14942 the Org file.  Such direct formatting is useful for one-off instances.
14944 @table @asis
14945 @item Embedding ODT tags as part of regular text
14946 Enclose OpenDocument syntax in @samp{@@@@odt:...@@@@} for inline markup.
14947 For example, to highlight a region of text do the following:
14949 @example
14950 @@@@odt:<text:span text:style-name="Highlight">This is highlighted
14951 text</text:span>@@@@.  But this is regular text.
14952 @end example
14954 @strong{Hint:} To see the above example in action, edit the @samp{styles.xml}
14955 (see @ref{x-orgodtstyles-xml, , Factory styles}) and add a custom @emph{Highlight} style as shown
14956 below:
14958 @example
14959 <style:style style:name="Highlight" style:family="text">
14960   <style:text-properties fo:background-color="#ff0000"/>
14961 </style:style>
14962 @end example
14964 @item Embedding a one-line OpenDocument XML
14965 @cindex @samp{ODT}, keyword
14966 The ODT export back-end can read one-liner options with @samp{#+ODT:}
14967 in the Org file.  For example, to force a page break:
14969 @example
14970 #+ODT: <text:p text:style-name="PageBreak"/>
14971 @end example
14973 @strong{Hint:} To see the above example in action, edit your
14974 @samp{styles.xml} (see @ref{x-orgodtstyles-xml, , Factory styles}) and add a custom @samp{PageBreak}
14975 style as shown below.
14977 @example
14978 <style:style style:name="PageBreak" style:family="paragraph"
14979              style:parent-style-name="Text_20_body">
14980   <style:paragraph-properties fo:break-before="page"/>
14981 </style:style>
14982 @end example
14984 @item Embedding a block of OpenDocument XML
14985 The ODT export back-end can also read ODT export blocks for
14986 OpenDocument XML.  Such blocks use the @samp{#+BEGIN_EXPORT odt}
14987 @dots{} @samp{#+END_EXPORT} constructs.
14989 For example, to create a one-off paragraph that uses bold text,
14990 do the following:
14992 @example
14993 #+BEGIN_EXPORT odt
14994   <text:p text:style-name="Text_20_body_20_bold">
14995   This paragraph is specially formatted and uses bold text.
14996   </text:p>
14997 #+END_EXPORT
14998 @end example
14999 @end table
15001 @anchor{Customizing tables in ODT export}
15002 @subsubheading Customizing tables in ODT export
15004 @cindex tables, in ODT export
15005 @cindex @samp{ATTR_ODT}, keyword
15007 Override the default table format by specifying a custom table style
15008 with the @samp{#+ATTR_ODT} line.  For a discussion on default formatting of
15009 tables, see @ref{Tables in ODT export}.
15011 This feature closely mimics the way table templates are defined in the
15012 OpenDocument-v1.2 specification.@footnote{@uref{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html, OpenDocument-v1.2 Specification}}
15014 @vindex org-odt-table-styles
15015 For quick preview of this feature, install the settings below and export the
15016 table that follows:
15018 @lisp
15019 (setq org-export-odt-table-styles
15020       (append org-export-odt-table-styles
15021               '(("TableWithHeaderRowAndColumn" "Custom"
15022                  ((use-first-row-styles . t)
15023                   (use-first-column-styles . t)))
15024                 ("TableWithFirstRowandLastRow" "Custom"
15025                  ((use-first-row-styles . t)
15026                   (use-last-row-styles . t))))))
15027 @end lisp
15029 @example
15030 #+ATTR_ODT: :style TableWithHeaderRowAndColumn
15031 | Name  | Phone | Age |
15032 | Peter |  1234 |  17 |
15033 | Anna  |  4321 |  25 |
15034 @end example
15036 The example above used @samp{Custom} template and installed two table
15037 styles @samp{TableWithHeaderRowAndColumn} and
15038 @samp{TableWithFirstRowandLastRow}.  @strong{Important:} The OpenDocument styles
15039 needed for producing the above template were pre-defined.  They are
15040 available in the section marked @samp{Custom Table Template} in
15041 @samp{OrgOdtContentTemplate.xml} (see @ref{x-orgodtcontenttemplate-xml, , Factory styles}).  For adding new
15042 templates, define new styles there.
15044 To use this feature proceed as follows:
15046 @enumerate
15047 @item
15048 Create a table template@footnote{See the @samp{<table:table-template>} element of the
15049 OpenDocument-v1.2 specification.}.
15051 A table template is set of @samp{table-cell} and @samp{paragraph} styles for
15052 each of the following table cell categories:
15054 @itemize
15055 @item
15056 Body
15057 @item
15058 First column
15059 @item
15060 Last column
15061 @item
15062 First row
15063 @item
15064 Last row
15065 @item
15066 Even row
15067 @item
15068 Odd row
15069 @item
15070 Even column
15071 @item
15072 Odd Column
15073 @end itemize
15075 The names for the above styles must be chosen based on the name of
15076 the table template using a well-defined convention.
15078 The naming convention is better illustrated with an example.  For
15079 a table template with the name @samp{Custom}, the needed style names are
15080 listed in the following table.
15082 @multitable {aaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
15083 @headitem Cell type
15084 @tab Cell style
15085 @tab Paragraph style
15086 @item Body
15087 @tab @samp{CustomTableCell}
15088 @tab @samp{CustomTableParagraph}
15089 @item First column
15090 @tab @samp{CustomFirstColumnTableCell}
15091 @tab @samp{CustomFirstColumnTableParagraph}
15092 @item Last column
15093 @tab @samp{CustomLastColumnTableCell}
15094 @tab @samp{CustomLastColumnTableParagraph}
15095 @item First row
15096 @tab @samp{CustomFirstRowTableCell}
15097 @tab @samp{CustomFirstRowTableParagraph}
15098 @item Last row
15099 @tab @samp{CustomLastRowTableCell}
15100 @tab @samp{CustomLastRowTableParagraph}
15101 @item Even row
15102 @tab @samp{CustomEvenRowTableCell}
15103 @tab @samp{CustomEvenRowTableParagraph}
15104 @item Odd row
15105 @tab @samp{CustomOddRowTableCell}
15106 @tab @samp{CustomOddRowTableParagraph}
15107 @item Even column
15108 @tab @samp{CustomEvenColumnTableCell}
15109 @tab @samp{CustomEvenColumnTableParagraph}
15110 @item Odd column
15111 @tab @samp{CustomOddColumnTableCell}
15112 @tab @samp{CustomOddColumnTableParagraph}
15113 @end multitable
15115 To create a table template with the name @samp{Custom}, define the above
15116 styles in the @samp{<office:automatic-styles>} @dots{}
15117 @samp{</office:automatic-styles>} element of the content template file
15118 (see @ref{x-orgodtcontenttemplate-xml, , Factory styles}).
15120 @item
15121 Define a table style@footnote{See the attributes @samp{table:template-name},
15122 @samp{table:use-first-row-styles}, @samp{table:use-last-row-styles},
15123 @samp{table:use-first-column-styles}, @samp{table:use-last-column-styles},
15124 @samp{table:use-banding-rows-styles}, and @samp{table:use-banding-column-styles}
15125 of the @samp{<table:table>} element in the OpenDocument-v1.2 specification.}.
15127 @vindex org-odt-table-styles
15128 To define a table style, create an entry for the style in the
15129 variable @code{org-odt-table-styles} and specify the following:
15131 @itemize
15132 @item
15133 the name of the table template created in step (1),
15134 @item
15135 the set of cell styles in that template that are to be activated.
15136 @end itemize
15138 For example, the entry below defines two different table styles
15139 @samp{TableWithHeaderRowAndColumn} and @samp{TableWithFirstRowandLastRow}
15140 based on the same template @samp{Custom}.  The styles achieve their
15141 intended effect by selectively activating the individual cell
15142 styles in that template.
15144 @lisp
15145 (setq org-export-odt-table-styles
15146       (append org-export-odt-table-styles
15147               '(("TableWithHeaderRowAndColumn" "Custom"
15148                  ((use-first-row-styles . t)
15149                   (use-first-column-styles . t)))
15150                 ("TableWithFirstRowandLastRow" "Custom"
15151                  ((use-first-row-styles . t)
15152                   (use-last-row-styles . t))))))
15153 @end lisp
15155 @item
15156 Associate a table with the table style.
15158 To do this, specify the table style created in step (2) as part of
15159 the @samp{ATTR_ODT} line as shown below.
15161 @example
15162 #+ATTR_ODT: :style TableWithHeaderRowAndColumn
15163 | Name  | Phone | Age |
15164 | Peter |  1234 |  17 |
15165 | Anna  |  4321 |  25 |
15166 @end example
15167 @end enumerate
15169 @anchor{Validating OpenDocument XML}
15170 @subsubheading Validating OpenDocument XML
15172 Sometimes ODT format files may not open due to @samp{.odt} file corruption.
15173 To verify if such a file is corrupt, validate it against the
15174 OpenDocument Relax NG Compact (RNC) syntax schema.  But first the
15175 @samp{.odt} files have to be decompressed using @samp{zip}.  Note that @samp{.odt}
15176 files are ZIP archives: @ref{File Archives,,,emacs,}.  The contents of
15177 ODT files are in XML.  For general help with validation---and
15178 schema-sensitive editing---of XML files:
15179 @ref{Introduction,,,nxml-mode,}.
15181 @vindex org-export-odt-schema-dir
15182 Customize @code{org-odt-schema-dir} to point to a directory with
15183 OpenDocument RNC files and the needed schema-locating rules.  The ODT
15184 export back-end takes care of updating the
15185 @code{rng-schema-locating-files}.
15187 @node Org Export
15188 @section Org Export
15190 @cindex Org export
15191 @emph{org} export back-end creates a normalized version of the Org document
15192 in current buffer.  The exporter evaluates Babel code (see @ref{Evaluating Code Blocks}) and removes content specific to other back-ends.
15194 @anchor{Org export commands}
15195 @subheading Org export commands
15197 @table @asis
15198 @item @kbd{C-c C-e O o} (@code{org-org-export-to-org})
15199 @kindex C-c C-e O o
15200 @findex org-org-export-to-org
15201 Export as an Org file with a @samp{.org} extension.  For @samp{myfile.org},
15202 Org exports to @samp{myfile.org.org}, overwriting without warning.
15204 @item @kbd{C-c C-e O v} (~~)
15205 @kindex C-c C-e O v
15206 Export to an Org file, then open it.
15207 @end table
15209 @node Texinfo Export
15210 @section Texinfo Export
15212 @menu
15213 * Texinfo export commands::      Invoking commands.
15214 * Texinfo specific export settings:: Setting the environment.
15215 * Texinfo file header::          Generating the header.
15216 * Texinfo title and copyright page:: Creating preamble pages.
15217 * Info directory file::          Installing a manual in Info file hierarchy.
15218 * Headings and sectioning structure:: Building document structure.
15219 * Indices::                      Creating indices.
15220 * Quoting Texinfo code::         Incorporating literal Texinfo code.
15221 * Plain lists in Texinfo export:: List attributes.
15222 * Tables in Texinfo export::     Table attributes.
15223 * Images in Texinfo export::     Image attributes.
15224 * Special blocks in Texinfo export:: Special block attributes.
15225 * A Texinfo example::            Processing Org to Texinfo.
15226 @end menu
15228 @node Texinfo export commands
15229 @subsection Texinfo export commands
15231 @table @asis
15232 @item @kbd{C-c C-e i t} (@code{org-texinfo-export-to-texinfo})
15233 @kindex C-c C-e i t
15234 @findex org-texinfo-export-to-texinfo
15235 Export as a Texinfo file with @samp{.texi} extension.  For
15236 @samp{myfile.org}, Org exports to @samp{myfile.texi}, overwriting without
15237 warning.
15239 @item @kbd{C-c C-e i i} (@code{org-texinfo-export-to-info})
15240 @kindex C-c C-e i i
15241 @findex org-texinfo-export-to-info
15242 @vindex org-texinfo-info-process
15243 Export to Texinfo format first and then process it to make an
15244 Info file.  To generate other formats, such as DocBook, customize
15245 the @code{org-texinfo-info-process} variable.
15246 @end table
15248 @node Texinfo specific export settings
15249 @subsection Texinfo specific export settings
15251 The Texinfo export back-end has several additional keywords for
15252 customizing Texinfo output.  Setting these keywords works similar to
15253 the general options (see @ref{Export Settings}).
15255 @table @asis
15256 @item @samp{SUBTITLE}
15257 @cindex @samp{SUBTITLE}, keyword
15258 The document subtitle.
15260 @item @samp{SUBAUTHOR}
15261 @cindex @samp{SUBAUTHOR}, keyword
15262 Additional authors for the document.
15264 @item @samp{TEXINFO_FILENAME}
15265 @cindex @samp{TEXINFO_FILENAME}, keyword
15266 The Texinfo filename.
15268 @item @samp{TEXINFO_CLASS}
15269 @cindex @samp{TEXINFO_CLASS}, keyword
15270 @vindex org-texinfo-default-class
15271 The default document class (@code{org-texinfo-default-class}), which
15272 must be a member of @code{org-texinfo-classes}.
15274 @item @samp{TEXINFO_HEADER}
15275 @cindex @samp{TEXINFO_HEADER}, keyword
15276 Arbitrary lines inserted at the end of the header.
15278 @item @samp{TEXINFO_POST_HEADER}
15279 @cindex @samp{TEXINFO_POST_HEADER}, keyword
15280 Arbitrary lines inserted after the end of the header.
15282 @item @samp{TEXINFO_DIR_CATEGORY}
15283 @cindex @samp{TEXINFO_DIR_CATEGORY}, keyword
15284 The directory category of the document.
15286 @item @samp{TEXINFO_DIR_TITLE}
15287 @cindex @samp{TEXINFO_DIR_TITLE}, keyword
15288 The directory title of the document.
15290 @item @samp{TEXINFO_DIR_DESC}
15291 @cindex @samp{TEXINFO_DIR_DESC}, keyword
15292 The directory description of the document.
15294 @item @samp{TEXINFO_PRINTED_TITLE}
15295 @cindex @samp{TEXINFO_PRINTED_TITLE}, keyword
15296 The printed title of the document.
15297 @end table
15299 @node Texinfo file header
15300 @subsection Texinfo file header
15302 @cindex @samp{TEXINFO_FILENAME}, keyword
15303 After creating the header for a Texinfo file, the Texinfo back-end
15304 automatically generates a name and destination path for the Info file.
15305 To override this default with a more sensible path and name, specify
15306 the @samp{TEXINFO_FILENAME} keyword.
15308 @vindex org-texinfo-coding-system
15309 @cindex @samp{TEXINFO_HEADER}, keyword
15310 Along with the output's file name, the Texinfo header also contains
15311 language details (see @ref{Export Settings}) and encoding system as set in
15312 the @code{org-texinfo-coding-system} variable.  Insert @samp{TEXINFO_HEADER}
15313 keywords for each additional command in the header, for example:
15315 @example
15316 #+TEXINFO_HEADER: @@synindex
15317 @end example
15319 @cindex @samp{TEXINFO_CLASS}, keyword
15320 @vindex org-texinfo-classes
15321 Instead of repeatedly installing the same set of commands, define
15322 a class in @code{org-texinfo-classes} once, and then activate it in the
15323 document by setting the @samp{TEXINFO_CLASS} keyword to that class.
15325 @node Texinfo title and copyright page
15326 @subsection Texinfo title and copyright page
15328 @cindex @samp{TEXINFO_PRINTED_TITLE}, keyword
15329 The default template for hard copy output has a title page with
15330 @samp{TITLE} and @samp{AUTHOR} keywords (see @ref{Export Settings}).  To replace the
15331 regular title with something different for the printed version, use
15332 the @samp{TEXINFO_PRINTED_TITLE} and @samp{SUBTITLE} keywords.  Both expect raw
15333 Texinfo code for setting their values.
15335 @cindex @samp{SUBAUTHOR}, keyword
15336 If one @samp{AUTHOR} line is not sufficient, add multiple @samp{SUBAUTHOR}
15337 keywords.  They have to be set in raw Texinfo code.
15339 @example
15340 #+AUTHOR: Jane Smith
15341 #+SUBAUTHOR: John Doe
15342 #+TEXINFO_PRINTED_TITLE: This Long Title@@@@inlinefmt@{tex,@@*@} Is Broken in @@TeX@{@}
15343 @end example
15345 @cindex @samp{COPYING}, property
15346 Copying material is defined in a dedicated headline with a non-@code{nil}
15347 @samp{COPYING} property.  The back-end inserts the contents within
15348 a @samp{@@copying} command at the beginning of the document.  The heading
15349 itself does not appear in the structure of the document.
15351 Copyright information is printed on the back of the title page.
15353 @example
15354 * Legalese
15355   :PROPERTIES:
15356   :COPYING: t
15357   :END:
15359   This is a short example of a complete Texinfo file, version 1.0.
15361   Copyright \copy 2016 Free Software Foundation, Inc.
15362 @end example
15364 @node Info directory file
15365 @subsection Info directory file
15367 @cindex @samp{dir} file, in Texinfo export
15368 @cindex Info directory file, in Texinfo export
15369 @cindex @code{install-info}, in Texinfo export
15371 @cindex @samp{TEXINFO_DIR_CATEGORY}, keyword
15372 @cindex @samp{TEXINFO_DIR_TITLE}, keyword
15373 @cindex @samp{TEXINFO_DIR_DESC}, keyword
15374 The end result of the Texinfo export process is the creation of an
15375 Info file.  This Info file's metadata has variables for category,
15376 title, and description: @samp{TEXINFO_DIR_CATEGORY}, @samp{TEXINFO_DIR_TITLE},
15377 and @samp{TEXINFO_DIR_DESC} keywords that establish where in the Info
15378 hierarchy the file fits.
15380 Here is an example that writes to the Info directory file:
15382 @example
15383 #+TEXINFO_DIR_CATEGORY: Emacs
15384 #+TEXINFO_DIR_TITLE: Org Mode: (org)
15385 #+TEXINFO_DIR_DESC: Outline-based notes management and organizer
15386 @end example
15388 @node Headings and sectioning structure
15389 @subsection Headings and sectioning structure
15391 @vindex org-texinfo-classes
15392 @vindex org-texinfo-default-class
15393 @cindex @samp{TEXINFO_CLASS}, keyword
15394 The Texinfo export back-end uses a pre-defined scheme to convert Org
15395 headlines to equivalent Texinfo structuring commands.  A scheme like
15396 this maps top-level headlines to numbered chapters tagged as
15397 @code{@@chapter} and lower-level headlines to unnumbered chapters tagged as
15398 @code{@@unnumbered}.  To override such mappings to introduce @code{@@part} or
15399 other Texinfo structuring commands, define a new class in
15400 @code{org-texinfo-classes}.  Activate the new class with the
15401 @samp{TEXINFO_CLASS} keyword.  When no new class is defined and activated,
15402 the Texinfo export back-end defaults to the
15403 @code{org-texinfo-default-class}.
15405 If an Org headline's level has no associated Texinfo structuring
15406 command, or is below a certain threshold (see @ref{Export Settings}), then
15407 the Texinfo export back-end makes it into a list item.
15409 @cindex @samp{APPENDIX}, property
15410 The Texinfo export back-end makes any headline with a non-@code{nil}
15411 @samp{APPENDIX} property into an appendix.  This happens independent of the
15412 Org headline level or the @samp{TEXINFO_CLASS} keyword.
15414 @cindex @samp{ALT_TITLE}, property
15415 @cindex @samp{DESCRIPTION}, property
15416 The Texinfo export back-end creates a menu entry after the Org
15417 headline for each regular sectioning structure.  To override this with
15418 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
15419 @samp{DESCRIPTION} property.  Here's an example that uses both to override
15420 the default menu entry:
15422 @example
15423 * Controlling Screen Display
15424   :PROPERTIES:
15425   :ALT_TITLE: Display
15426   :DESCRIPTION: Controlling Screen Display
15427   :END:
15428 @end example
15430 @cindex Top node, in Texinfo export
15431 The text before the first headline belongs to the @emph{Top} node, i.e.,
15432 the node in which a reader enters an Info manual.  As such, it is
15433 expected not to appear in printed output generated from the @samp{.texi}
15434 file.  See @ref{The Top Node,,,texinfo,}, for more information.
15436 @node Indices
15437 @subsection Indices
15439 @cindex @samp{CINDEX}, keyword
15440 @cindex concept index, in Texinfo export
15441 @cindex @samp{FINDEX}, keyword
15442 @cindex function index, in Texinfo export
15443 @cindex @samp{KINDEX}, keyword
15444 @cindex keystroke index, in Texinfo export
15445 @cindex @samp{PINDEX}, keyword
15446 @cindex program index, in Texinfo export
15447 @cindex @samp{TINDEX}, keyword
15448 @cindex data type index, in Texinfo export
15449 @cindex @samp{VINDEX}, keyword
15450 @cindex variable index, in Texinfo export
15451 The Texinfo export back-end recognizes these indexing keywords if used
15452 in the Org file: @samp{CINDEX}, @samp{FINDEX}, @samp{KINDEX}, @samp{PINDEX}, @samp{TINDEX} and
15453 @samp{VINDEX}.  Write their value as verbatim Texinfo code; in particular,
15454 @samp{@{}, @samp{@}} and @samp{@@} characters need to be escaped with @samp{@@} if they do not
15455 belong to a Texinfo command.
15457 @example
15458 #+CINDEX: Defining indexing entries
15459 @end example
15461 @cindex @samp{INDEX}, property
15462 For the back-end to generate an index entry for a headline, set the
15463 @samp{INDEX} property to @samp{cp} or @samp{vr}.  These abbreviations come from
15464 Texinfo that stand for concept index and variable index.  The Texinfo
15465 manual has abbreviations for all other kinds of indexes.  The back-end
15466 exports the headline as an unnumbered chapter or section command, and
15467 then inserts the index after its contents.
15469 @example
15470 * Concept Index
15471   :PROPERTIES:
15472   :INDEX: cp
15473   :END:
15474 @end example
15476 @node Quoting Texinfo code
15477 @subsection Quoting Texinfo code
15479 Use any of the following three methods to insert or escape raw Texinfo
15480 code:
15482 @cindex @samp{TEXINFO}, keyword
15483 @cindex @samp{BEGIN_EXPORT texinfo}
15484 @example
15485 Richard @@@@texinfo:@@sc@{@@@@Stallman@@@@texinfo:@}@@@@ commence' GNU.
15487 #+TEXINFO: @@need800
15488 This paragraph is preceded by...
15490 #+BEGIN_EXPORT texinfo
15491   @@auindex Johnson, Mark
15492   @@auindex Lakoff, George
15493 #+END_EXPORT
15494 @end example
15496 @node Plain lists in Texinfo export
15497 @subsection Plain lists in Texinfo export
15499 @cindex @samp{ATTR_TEXINFO}, keyword
15500 @cindex two-column tables, in Texinfo export
15502 @cindex table types, in Texinfo export
15503 The Texinfo export back-end by default converts description lists in
15504 the Org file using the default command @samp{@@table}, which results in
15505 a table with two columns.  To change this behavior, specify
15506 @samp{:table-type} with @samp{ftable} or @samp{vtable} attributes.  For more
15507 information, see @ref{Two-column Tables,,,texinfo,}.
15509 @vindex org-texinfo-table-default-markup
15510 The Texinfo export back-end by default also applies a text highlight
15511 based on the defaults stored in @code{org-texinfo-table-default-markup}.
15512 To override the default highlight command, specify another one with
15513 the @samp{:indic} attribute.
15515 @cindex multiple items in Texinfo lists
15516 Org syntax is limited to one entry per list item.  Nevertheless, the
15517 Texinfo export back-end can split that entry according to any text
15518 provided through the @samp{:sep} attribute.  Each part then becomes a new
15519 entry in the first column of the table.
15521 The following example illustrates all the attributes above:
15523 @example
15524 #+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
15525 - foo, bar :: This is the common text for variables foo and bar.
15526 @end example
15528 @noindent
15529 becomes
15531 @example
15532 @@vtable @@asis
15533 @@item foo
15534 @@itemx bar
15535 This is the common text for variables foo and bar.
15536 @@end table
15537 @end example
15539 @node Tables in Texinfo export
15540 @subsection Tables in Texinfo export
15542 @cindex @samp{ATTR_TEXINFO}, keyword
15543 When exporting tables, the Texinfo export back-end uses the widest
15544 cell width in each column.  To override this and instead specify as
15545 fractions of line length, use the @samp{:columns} attribute.  See example
15546 below.
15548 @example
15549 #+ATTR_TEXINFO: :columns .5 .5
15550 | a cell | another cell |
15551 @end example
15553 @node Images in Texinfo export
15554 @subsection Images in Texinfo export
15556 @cindex @samp{ATTR_TEXINFO}, keyword
15557 Insert a file link to the image in the Org file, and the Texinfo
15558 export back-end inserts the image.  These links must have the usual
15559 supported image extensions and no descriptions.  To scale the image,
15560 use @samp{:width} and @samp{:height} attributes.  For alternate text, use @samp{:alt}
15561 and specify the text using Texinfo code, as shown in the example:
15563 @example
15564 #+ATTR_TEXINFO: :width 1in :alt Alternate @@i@{text@}
15565 [[ridt.pdf]]
15566 @end example
15568 @node Special blocks in Texinfo export
15569 @subsection Special blocks in Texinfo export
15571 @cindex @samp{ATTR_TEXINFO}, keyword
15573 The Texinfo export back-end converts special blocks to commands with
15574 the same name.  It also adds any @samp{:options} attributes to the end of
15575 the command, as shown in this example:
15577 @example
15578 #+ATTR_TEXINFO: :options org-org-export-to-org ...
15579 #+BEGIN_defun
15580   A somewhat obsessive function name.
15581 #+END_defun
15582 @end example
15584 @noindent
15585 becomes
15587 @example
15588 @@defun org-org-export-to-org ...
15589   A somewhat obsessive function name.
15590 @@end defun
15591 @end example
15593 @node A Texinfo example
15594 @subsection A Texinfo example
15596 Here is a more detailed example Org file.  See
15597 @ref{GNU Sample Texts,,,texinfo,} for an equivalent example using
15598 Texinfo code.
15600 @example
15601 #+TITLE: GNU Sample @{@{@{version@}@}@}
15602 #+SUBTITLE: for version @{@{@{version@}@}@}, @{@{@{updated@}@}@}
15603 #+AUTHOR: A.U. Thor
15604 #+EMAIL: bug-sample@@gnu.org
15606 #+OPTIONS: ':t toc:t author:t email:t
15607 #+LANGUAGE: en
15609 #+MACRO: version 2.0
15610 #+MACRO: updated last updated 4 March 2014
15612 #+TEXINFO_FILENAME: sample.info
15613 #+TEXINFO_HEADER: @@syncodeindex pg cp
15615 #+TEXINFO_DIR_CATEGORY: Texinfo documentation system
15616 #+TEXINFO_DIR_TITLE: sample: (sample)
15617 #+TEXINFO_DIR_DESC: Invoking sample
15619 #+TEXINFO_PRINTED_TITLE: GNU Sample
15621 This manual is for GNU Sample (version @{@{@{version@}@}@},
15622 @{@{@{updated@}@}@}).
15624 * Copying
15625   :PROPERTIES:
15626   :COPYING:  t
15627   :END:
15629   This manual is for GNU Sample (version @{@{@{version@}@}@},
15630   @{@{@{updated@}@}@}), which is an example in the Texinfo documentation.
15632   Copyright \copy 2016 Free Software Foundation, Inc.
15634   #+BEGIN_QUOTE
15635   Permission is granted to copy, distribute and/or modify this
15636   document under the terms of the GNU Free Documentation License,
15637   Version 1.3 or any later version published by the Free Software
15638   Foundation; with no Invariant Sections, with no Front-Cover Texts,
15639   and with no Back-Cover Texts.  A copy of the license is included in
15640   the section entitled "GNU Free Documentation License".
15641   #+END_QUOTE
15643 * Invoking sample
15645   #+PINDEX: sample
15646   #+CINDEX: invoking @@command@{sample@}
15648   This is a sample manual.  There is no sample program to invoke, but
15649   if there were, you could see its basic usage and command line
15650   options here.
15652 * GNU Free Documentation License
15653   :PROPERTIES:
15654   :APPENDIX: t
15655   :END:
15657   #+TEXINFO: @@include fdl.texi
15659 * Index
15660   :PROPERTIES:
15661   :INDEX:    cp
15662   :END:
15663 @end example
15665 @node iCalendar Export
15666 @section iCalendar Export
15668 @cindex iCalendar export
15670 A large part of Org mode's interoperability success is its ability to
15671 easily export to or import from external applications.  The iCalendar
15672 export back-end takes calendar data from Org files and exports to the
15673 standard iCalendar format.
15675 @vindex org-icalendar-include-todo
15676 @vindex org-icalendar-use-deadline
15677 @vindex org-icalendar-use-scheduled
15678 The iCalendar export back-end can also incorporate TODO entries based
15679 on the configuration of the @code{org-icalendar-include-todo} variable.
15680 The back-end exports plain timestamps as @samp{VEVENT}, TODO items as
15681 @samp{VTODO}, and also create events from deadlines that are in non-TODO
15682 items.  The back-end uses the deadlines and scheduling dates in Org
15683 TODO items for setting the start and due dates for the iCalendar TODO
15684 entry.  Consult the @code{org-icalendar-use-deadline} and
15685 @code{org-icalendar-use-scheduled} variables for more details.
15687 @vindex org-icalendar-categories
15688 @vindex org-icalendar-alarm-time
15689 For tags on the headline, the iCalendar export back-end makes them
15690 into iCalendar categories.  To tweak the inheritance of tags and TODO
15691 states, configure the variable @code{org-icalendar-categories}.  To assign
15692 clock alarms based on time, configure the @code{org-icalendar-alarm-time}
15693 variable.
15695 @vindex org-icalendar-store-UID
15696 @cindex @samp{ID}, property
15697 The iCalendar format standard requires globally unique identifier---or
15698 UID---for each entry.  The iCalendar export back-end creates UIDs
15699 during export.  To save a copy of the UID in the Org file set the
15700 variable @code{org-icalendar-store-UID}.  The back-end looks for the @samp{ID}
15701 property of the entry for re-using the same UID for subsequent
15702 exports.
15704 Since a single Org entry can result in multiple iCalendar
15705 entries---timestamp, deadline, scheduled item, or TODO item---Org adds
15706 prefixes to the UID, depending on which part of the Org entry
15707 triggered the creation of the iCalendar entry.  Prefixing ensures UIDs
15708 remains unique, yet enable synchronization programs trace the
15709 connections.
15711 @table @asis
15712 @item @kbd{C-c C-e c f} (@code{org-icalendar-export-to-ics})
15713 @kindex C-c C-e c f
15714 @findex org-icalendar-export-to-ics
15715 Create iCalendar entries from the current Org buffer and store
15716 them in the same directory, using a file extension @samp{.ics}.
15718 @item @kbd{C-c C-e c a} (@code{org-icalendar-export-agenda-files})
15719 @kindex C-c C-e c a
15720 @findex org-icalendar-export-agenda-files
15721 Create iCalendar entries from Org files in @code{org-agenda-files} and
15722 store in a separate iCalendar file for each Org file.
15724 @item @kbd{C-c C-e c c} (@code{org-icalendar-combine-agenda-files})
15725 @kindex C-c C-e c c
15726 @findex org-icalendar-combine-agenda-files
15727 @vindex org-icalendar-combined-agenda-file
15728 Create a combined iCalendar file from Org files in
15729 @code{org-agenda-files} and write it to
15730 @code{org-icalendar-combined-agenda-file} file name.
15731 @end table
15733 @cindex @samp{SUMMARY}, property
15734 @cindex @samp{DESCRIPTION}, property
15735 @cindex @samp{LOCATION}, property
15736 @cindex @samp{TIMEZONE}, property
15737 The iCalendar export back-end includes @samp{SUMMARY}, @samp{DESCRIPTION},
15738 @samp{LOCATION} and @samp{TIMEZONE} properties from the Org entries when
15739 exporting.  To force the back-end to inherit the @samp{LOCATION} and
15740 @samp{TIMEZONE} properties, configure the @code{org-use-property-inheritance}
15741 variable.
15743 @vindex org-icalendar-include-body
15744 When Org entries do not have @samp{SUMMARY}, @samp{DESCRIPTION} and @samp{LOCATION}
15745 properties, the iCalendar export back-end derives the summary from the
15746 headline, and derives the description from the body of the Org item.
15747 The @code{org-icalendar-include-body} variable limits the maximum number of
15748 characters of the content are turned into its description.
15750 The @samp{TIMEZONE} property can be used to specify a per-entry time zone,
15751 and is applied to any entry with timestamp information.  Time zones
15752 should be specified as per the IANA time zone database format, e.g.,
15753 @samp{Asia/Almaty}.  Alternately, the property value can be @samp{UTC}, to force
15754 UTC time for this entry only.
15756 Exporting to iCalendar format depends in large part on the
15757 capabilities of the destination application.  Some are more lenient
15758 than others.  Consult the Org mode FAQ for advice on specific
15759 applications.
15761 @node Other Built-in Back-ends
15762 @section Other Built-in Back-ends
15764 Other export back-ends included with Org are:
15766 @itemize
15767 @item
15768 @samp{ox-man.el}: Export to a man page.
15769 @end itemize
15771 To activate such back-ends, either customize @code{org-export-backends} or
15772 load directly with @code{(require 'ox-man)}.  On successful load, the
15773 back-end adds new keys in the export dispatcher (see @ref{The Export Dispatcher}).
15775 Follow the comment section of such files, for example, @samp{ox-man.el},
15776 for usage and configuration details.
15778 @node Advanced Configuration
15779 @section Advanced Configuration
15783 @anchor{Hooks}
15784 @subheading Hooks
15786 @vindex org-export-before-processing-hook
15787 @vindex org-export-before-parsing-hook
15788 The export process executes two hooks before the actual exporting
15789 begins.  The first hook, @code{org-export-before-processing-hook}, runs
15790 before any expansions of macros, Babel code, and include keywords in
15791 the buffer.  The second hook, @code{org-export-before-parsing-hook}, runs
15792 before the buffer is parsed.
15794 Functions added to these hooks are called with a single argument: the
15795 export back-end actually used, as a symbol.  You may use them for
15796 heavy duty structural modifications of the document.  For example, you
15797 can remove every headline in the buffer during export like this:
15799 @lisp
15800 (defun my-headline-removal (backend)
15801   "Remove all headlines in the current buffer.
15802 BACKEND is the export back-end being used, as a symbol."
15803   (org-map-entries
15804    (lambda () (delete-region (point) (line-beginning-position 2)))))
15806 (add-hook 'org-export-before-parsing-hook 'my-headline-removal)
15807 @end lisp
15809 @anchor{Filters}
15810 @subheading Filters
15812 @cindex Filters, exporting
15813 Filters are lists of functions to be applied to certain parts for
15814 a given back-end.  The output from the first function in the filter is
15815 passed on to the next function in the filter.  The final output is the
15816 output from the final function in the filter.
15818 The Org export process has many filter sets applicable to different
15819 types of objects, plain text, parse trees, export options, and final
15820 output formats.  The filters are named after the element type or
15821 object type: @code{org-export-filter-TYPE-functions}, where @var{TYPE}
15822 is the type targeted by the filter.  Valid types are:
15824 @multitable @columnfractions 0.33 0.33 0.33
15825 @item body
15826 @tab bold
15827 @tab babel-call
15828 @item center-block
15829 @tab clock
15830 @tab code
15831 @item diary-sexp
15832 @tab drawer
15833 @tab dynamic-block
15834 @item entity
15835 @tab example-block
15836 @tab export-block
15837 @item export-snippet
15838 @tab final-output
15839 @tab fixed-width
15840 @item footnote-definition
15841 @tab footnote-reference
15842 @tab headline
15843 @item horizontal-rule
15844 @tab inline-babel-call
15845 @tab inline-src-block
15846 @item inlinetask
15847 @tab italic
15848 @tab item
15849 @item keyword
15850 @tab latex-environment
15851 @tab latex-fragment
15852 @item line-break
15853 @tab link
15854 @tab node-property
15855 @item options
15856 @tab paragraph
15857 @tab parse-tree
15858 @item plain-list
15859 @tab plain-text
15860 @tab planning
15861 @item property-drawer
15862 @tab quote-block
15863 @tab radio-target
15864 @item section
15865 @tab special-block
15866 @tab src-block
15867 @item statistics-cookie
15868 @tab strike-through
15869 @tab subscript
15870 @item superscript
15871 @tab table
15872 @tab table-cell
15873 @item table-row
15874 @tab target
15875 @tab timestamp
15876 @item underline
15877 @tab verbatim
15878 @tab verse-block
15879 @end multitable
15881 Here is an example filter that replaces non-breaking spaces @code{ } in the
15882 Org buffer with @samp{~} for the @LaTeX{} back-end.
15884 @lisp
15885 (defun my-latex-filter-nobreaks (text backend info)
15886   "Ensure \" \" are properly handled in LaTeX export."
15887   (when (org-export-derived-backend-p backend 'latex)
15888     (replace-regexp-in-string " " "~" text)))
15890 (add-to-list 'org-export-filter-plain-text-functions
15891              'my-latex-filter-nobreaks)
15892 @end lisp
15894 A filter requires three arguments: the code to be transformed, the
15895 name of the back-end, and some optional information about the export
15896 process.  The third argument can be safely ignored.  Note the use of
15897 @code{org-export-derived-backend-p} predicate that tests for @emph{latex}
15898 back-end or any other back-end, such as @emph{beamer}, derived from
15899 @emph{latex}.
15901 @anchor{Defining filters for individual files}
15902 @subheading Defining filters for individual files
15904 The Org export can filter not just for back-ends, but also for
15905 specific files through the @samp{BIND} keyword.  Here is an example with
15906 two filters; one removes brackets from time stamps, and the other
15907 removes strike-through text.  The filter functions are defined in
15908 a code block in the same Org file, which is a handy location for
15909 debugging.
15911 @example
15912 #+BIND: org-export-filter-timestamp-functions (tmp-f-timestamp)
15913 #+BIND: org-export-filter-strike-through-functions (tmp-f-strike-through)
15914 #+BEGIN_SRC emacs-lisp :exports results :results none
15915   (defun tmp-f-timestamp (s backend info)
15916     (replace-regexp-in-string "&[lg]t;\\|[][]" "" s))
15917   (defun tmp-f-strike-through (s backend info) "")
15918 #+END_SRC
15919 @end example
15921 @anchor{Extending an existing back-end}
15922 @subheading Extending an existing back-end
15924 Some parts of the conversion process can be extended for certain
15925 elements so as to introduce a new or revised translation.  That is how
15926 the HTML export back-end was extended to handle Markdown format.  The
15927 extensions work seamlessly so any aspect of filtering not done by the
15928 extended back-end is handled by the original back-end.  Of all the
15929 export customization in Org, extending is very powerful as it operates
15930 at the parser level.
15932 For this example, make the @emph{ascii} back-end display the language used
15933 in a source code block.  Also make it display only when some attribute
15934 is non-@code{nil}, like the following:
15936 @example
15937 #+ATTR_ASCII: :language t
15938 @end example
15940 Then extend ASCII back-end with a custom ``my-ascii'' back-end.
15942 @lisp
15943 (defun my-ascii-src-block (src-block contents info)
15944   "Transcode a SRC-BLOCK element from Org to ASCII.
15945 CONTENTS is nil.  INFO is a plist used as a communication
15946 channel."
15947   (if (not (org-export-read-attribute :attr_ascii src-block :language))
15948       (org-export-with-backend 'ascii src-block contents info)
15949     (concat
15950      (format ",--[ %s ]--\n%s`----"
15951              (org-element-property :language src-block)
15952              (replace-regexp-in-string
15953               "^" "| "
15954               (org-element-normalize-string
15955                (org-export-format-code-default src-block info)))))))
15957 (org-export-define-derived-backend 'my-ascii 'ascii
15958   :translate-alist '((src-block . my-ascii-src-block)))
15959 @end lisp
15961 The @code{my-ascii-src-block} function looks at the attribute above the
15962 current element.  If not true, hands over to @emph{ascii} back-end.  If
15963 true, which it is in this example, it creates a box around the code
15964 and leaves room for the inserting a string for language.  The last
15965 form creates the new back-end that springs to action only when
15966 translating @code{src-block} type elements.
15968 To use the newly defined back-end, evaluate the following from an Org
15969 buffer:
15971 @lisp
15972 (org-export-to-buffer 'my-ascii "*Org MY-ASCII Export*")
15973 @end lisp
15975 Further steps to consider would be an interactive function,
15976 self-installing an item in the export dispatcher menu, and other
15977 user-friendly improvements.
15979 @node Export in Foreign Buffers
15980 @section Export in Foreign Buffers
15982 The export back-ends in Org often include commands to convert selected
15983 regions.  A convenient feature of this in-place conversion is that the
15984 exported output replaces the original source.  Here are such
15985 functions:
15987 @table @asis
15988 @item @code{org-html-convert-region-to-html}
15989 @findex org-html-convert-region-to-html
15990 Convert the selected region into HTML.
15992 @item @code{org-latex-convert-region-to-latex}
15993 @findex org-latex-convert-region-to-latex
15994 Convert the selected region into @LaTeX{}.
15996 @item @code{org-texinfo-convert-region-to-texinfo}
15997 @findex org-texinfo-convert-region-to-texinfo
15998 Convert the selected region into Texinfo.
16000 @item @code{org-md-convert-region-to-md}
16001 @findex org-md-convert-region-to-md
16002 Convert the selected region into Markdown.
16003 @end table
16005 In-place conversions are particularly handy for quick conversion of
16006 tables and lists in foreign buffers.  For example, turn on the minor
16007 mode @kbd{M-x orgstruct-mode} in an HTML buffer, then use the
16008 convenient Org keyboard commands to create a list, select it, and
16009 covert it to HTML with @kbd{M-x org-html-convert-region-to-html}.
16011 @node Publishing
16012 @chapter Publishing
16014 @cindex publishing
16016 Org includes a publishing management system that allows you to
16017 configure automatic HTML conversion of @emph{projects} composed of
16018 interlinked Org files.  You can also configure Org to automatically
16019 upload your exported HTML pages and related attachments, such as
16020 images and source code files, to a web server.
16022 You can also use Org to convert files into PDF, or even combine HTML
16023 and PDF conversion so that files are available in both formats on the
16024 server.
16026 Publishing has been contributed to Org by David O'Toole.
16028 @menu
16029 * Configuration::                Defining projects.
16030 * Uploading Files::              How to get files up on the server.
16031 * Sample Configuration::         Example projects.
16032 * Triggering Publication::       Publication commands.
16033 @end menu
16035 @node Configuration
16036 @section Configuration
16038 Publishing needs significant configuration to specify files,
16039 destination and many other properties of a project.
16041 @menu
16042 * Project alist::                The central configuration variable.
16043 * Sources and destinations::     From here to there.
16044 * Selecting files::              What files are part of the project?
16045 * Publishing action::            Setting the function doing the publishing.
16046 * Publishing options::           Tweaking HTML/@LaTeX{} export.
16047 * Publishing links::             Which links keep working after publishing?
16048 * Site map::                     Generating a list of all pages.
16049 * Generating an index::          An index that reaches across pages.
16050 @end menu
16052 @node Project alist
16053 @subsection The variable @code{org-publish-project-alist}
16055 @cindex projects, for publishing
16057 @vindex org-publish-project-alist
16058 Publishing is configured almost entirely through setting the value of
16059 one variable, called @code{org-publish-project-alist}.  Each element of the
16060 list configures one project, and may be in one of the two following
16061 forms:
16063 @lisp
16064 ("project-name" :property value :property value ...)
16065 @end lisp
16067 @noindent
16068 i.e., a well-formed property list with alternating keys and values,
16071 @lisp
16072 ("project-name" :components ("project-name" "project-name" ...))
16073 @end lisp
16075 In both cases, projects are configured by specifying property values.
16076 A project defines the set of files that are to be published, as well
16077 as the publishing configuration to use when publishing those files.
16078 When a project takes the second form listed above, the individual
16079 members of the @code{:components} property are taken to be sub-projects,
16080 which group together files requiring different publishing options.
16081 When you publish such a ``meta-project'', all the components are also
16082 published, in the sequence given.
16084 @node Sources and destinations
16085 @subsection Sources and destinations for files
16087 @cindex directories, for publishing
16089 Most properties are optional, but some should always be set.  In
16090 particular, Org needs to know where to look for source files, and
16091 where to put published files.
16093 @table @asis
16094 @item @code{:base-directory}
16095 Directory containing publishing source files.
16097 @item @code{:publishing-directory}
16098 Directory where output files are published.  You can directly
16099 publish to a webserver using a file name syntax appropriate for
16100 the Emacs tramp package.  Or you can publish to a local directory
16101 and use external tools to upload your website (see @ref{Uploading Files}).
16103 @item @code{:preparation-function}
16104 Function or list of functions to be called before starting the
16105 publishing process, for example, to run @samp{make} for updating files
16106 to be published.  Each preparation function is called with
16107 a single argument, the project property list.
16109 @item @code{:completion-function}
16110 Function or list of functions called after finishing the
16111 publishing process, for example, to change permissions of the
16112 resulting files.  Each completion function is called with
16113 a single argument, the project property list.
16114 @end table
16116 @node Selecting files
16117 @subsection Selecting files
16119 @cindex files, selecting for publishing
16121 By default, all files with extension @samp{.org} in the base directory are
16122 considered part of the project.  This can be modified by setting the
16123 following properties
16125 @table @asis
16126 @item @code{:base-extension}
16127 Extension---without the dot---of source files.  This actually
16128 is a regular expression.  Set this to the symbol @code{any} if you
16129 want to get all files in @code{:base-directory}, even without
16130 extension.
16132 @item @code{:exclude}
16133 Regular expression to match file names that should not be published,
16134 even though they have been selected on the basis of their extension.
16136 @item @code{:include}
16137 List of files to be included regardless of @code{:base-extension} and
16138 @code{:exclude}.
16140 @item @code{:recursive}
16141 Non-@code{nil} means, check base-directory recursively for files to
16142 publish.
16143 @end table
16145 @node Publishing action
16146 @subsection Publishing action
16148 @cindex action, for publishing
16150 Publishing means that a file is copied to the destination directory
16151 and possibly transformed in the process.  The default transformation
16152 is to export Org files as HTML files, and this is done by the function
16153 @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
16154 @code{org-publish-org-to-pdf}, or as ASCII, Texinfo, etc., using the
16155 corresponding functions.
16157 If you want to publish the Org file as an @samp{.org} file but with
16158 @emph{archived}, @emph{commented}, and @emph{tag-excluded} trees removed, use
16159 @code{org-publish-org-to-org}.  This produces @samp{file.org} and put it in the
16160 publishing directory.  If you want a htmlized version of this file,
16161 set the parameter @code{:htmlized-source} to @code{t}.  It produces
16162 @samp{file.org.html} in the publishing directory@footnote{If the publishing directory is the same as the source
16163 directory, @samp{file.org} is exported as @samp{file.org.org}, so you probably
16164 do not want to do this.}.
16166 Other files like images only need to be copied to the publishing
16167 destination; for this you can use @code{org-publish-attachment}.  For
16168 non-Org files, you always need to specify the publishing function:
16170 @table @asis
16171 @item @code{:publishing-function}
16172 Function executing the publication of a file.  This may also be
16173 a list of functions, which are all called in turn.
16175 @item @code{:plain-source}
16176 Non-@code{nil} means, publish plain source.
16178 @item @code{:htmlized-source}
16179 Non-@code{nil} means, publish htmlized source.
16180 @end table
16182 The function must accept three arguments: a property list containing
16183 at least a @code{:publishing-directory} property, the name of the file to
16184 be published, and the path to the publishing directory of the output
16185 file.  It should take the specified file, make the necessary
16186 transformation, if any, and place the result into the destination
16187 folder.
16189 @node Publishing options
16190 @subsection Options for the exporters
16192 @cindex options, for publishing
16193 @cindex publishing options
16195 The property list can be used to set many export options for the HTML
16196 and @LaTeX{} exporters.  In most cases, these properties correspond to
16197 user variables in Org.  The table below lists these properties along
16198 with the variable they belong to.  See the documentation string for
16199 the respective variable for details.
16201 @vindex org-publish-project-alist
16202 When a property is given a value in @code{org-publish-project-alist}, its
16203 setting overrides the value of the corresponding user variable, if
16204 any, during publishing.  Options set within a file (see @ref{Export Settings}), however, override everything.
16206 @anchor{Generic properties}
16207 @subsubheading Generic properties
16209 @multitable {aaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16210 @item @code{:archived-trees}
16211 @tab @code{org-export-with-archived-trees}
16212 @item @code{:exclude-tags}
16213 @tab @code{org-export-exclude-tags}
16214 @item @code{:headline-levels}
16215 @tab @code{org-export-headline-levels}
16216 @item @code{:language}
16217 @tab @code{org-export-default-language}
16218 @item @code{:preserve-breaks}
16219 @tab @code{org-export-preserve-breaks}
16220 @item @code{:section-numbers}
16221 @tab @code{org-export-with-section-numbers}
16222 @item @code{:select-tags}
16223 @tab @code{org-export-select-tags}
16224 @item @code{:with-author}
16225 @tab @code{org-export-with-author}
16226 @item @code{:with-broken-links}
16227 @tab @code{org-export-with-broken-links}
16228 @item @code{:with-clocks}
16229 @tab @code{org-export-with-clocks}
16230 @item @code{:with-creator}
16231 @tab @code{org-export-with-creator}
16232 @item @code{:with-date}
16233 @tab @code{org-export-with-date}
16234 @item @code{:with-drawers}
16235 @tab @code{org-export-with-drawers}
16236 @item @code{:with-email}
16237 @tab @code{org-export-with-email}
16238 @item @code{:with-emphasize}
16239 @tab @code{org-export-with-emphasize}
16240 @item @code{:with-fixed-width}
16241 @tab @code{org-export-with-fixed-width}
16242 @item @code{:with-footnotes}
16243 @tab @code{org-export-with-footnotes}
16244 @item @code{:with-latex}
16245 @tab @code{org-export-with-latex}
16246 @item @code{:with-planning}
16247 @tab @code{org-export-with-planning}
16248 @item @code{:with-priority}
16249 @tab @code{org-export-with-priority}
16250 @item @code{:with-properties}
16251 @tab @code{org-export-with-properties}
16252 @item @code{:with-special-strings}
16253 @tab @code{org-export-with-special-strings}
16254 @item @code{:with-sub-superscript}
16255 @tab @code{org-export-with-sub-superscripts}
16256 @item @code{:with-tables}
16257 @tab @code{org-export-with-tables}
16258 @item @code{:with-tags}
16259 @tab @code{org-export-with-tags}
16260 @item @code{:with-tasks}
16261 @tab @code{org-export-with-tasks}
16262 @item @code{:with-timestamps}
16263 @tab @code{org-export-with-timestamps}
16264 @item @code{:with-title}
16265 @tab @code{org-export-with-title}
16266 @item @code{:with-toc}
16267 @tab @code{org-export-with-toc}
16268 @item @code{:with-todo-keywords}
16269 @tab @code{org-export-with-todo-keywords}
16270 @end multitable
16272 @anchor{ASCII specific properties}
16273 @subsubheading ASCII specific properties
16275 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16276 @item @code{:ascii-bullets}
16277 @tab @code{org-ascii-bullets}
16278 @item @code{:ascii-caption-above}
16279 @tab @code{org-ascii-caption-above}
16280 @item @code{:ascii-charset}
16281 @tab @code{org-ascii-charset}
16282 @item @code{:ascii-global-margin}
16283 @tab @code{org-ascii-global-margin}
16284 @item @code{:ascii-format-drawer-function}
16285 @tab @code{org-ascii-format-drawer-function}
16286 @item @code{:ascii-format-inlinetask-function}
16287 @tab @code{org-ascii-format-inlinetask-function}
16288 @item @code{:ascii-headline-spacing}
16289 @tab @code{org-ascii-headline-spacing}
16290 @item @code{:ascii-indented-line-width}
16291 @tab @code{org-ascii-indented-line-width}
16292 @item @code{:ascii-inlinetask-width}
16293 @tab @code{org-ascii-inlinetask-width}
16294 @item @code{:ascii-inner-margin}
16295 @tab @code{org-ascii-inner-margin}
16296 @item @code{:ascii-links-to-notes}
16297 @tab @code{org-ascii-links-to-notes}
16298 @item @code{:ascii-list-margin}
16299 @tab @code{org-ascii-list-margin}
16300 @item @code{:ascii-paragraph-spacing}
16301 @tab @code{org-ascii-paragraph-spacing}
16302 @item @code{:ascii-quote-margin}
16303 @tab @code{org-ascii-quote-margin}
16304 @item @code{:ascii-table-keep-all-vertical-lines}
16305 @tab @code{org-ascii-table-keep-all-vertical-lines}
16306 @item @code{:ascii-table-use-ascii-art}
16307 @tab @code{org-ascii-table-use-ascii-art}
16308 @item @code{:ascii-table-widen-columns}
16309 @tab @code{org-ascii-table-widen-columns}
16310 @item @code{:ascii-text-width}
16311 @tab @code{org-ascii-text-width}
16312 @item @code{:ascii-underline}
16313 @tab @code{org-ascii-underline}
16314 @item @code{:ascii-verbatim-format}
16315 @tab @code{org-ascii-verbatim-format}
16316 @end multitable
16318 @anchor{Beamer specific properties}
16319 @subsubheading Beamer specific properties
16321 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16322 @item @code{:beamer-theme}
16323 @tab @code{org-beamer-theme}
16324 @item @code{:beamer-column-view-format}
16325 @tab @code{org-beamer-column-view-format}
16326 @item @code{:beamer-environments-extra}
16327 @tab @code{org-beamer-environments-extra}
16328 @item @code{:beamer-frame-default-options}
16329 @tab @code{org-beamer-frame-default-options}
16330 @item @code{:beamer-outline-frame-options}
16331 @tab @code{org-beamer-outline-frame-options}
16332 @item @code{:beamer-outline-frame-title}
16333 @tab @code{org-beamer-outline-frame-title}
16334 @item @code{:beamer-subtitle-format}
16335 @tab @code{org-beamer-subtitle-format}
16336 @end multitable
16338 @anchor{HTML specific properties}
16339 @subsubheading HTML specific properties
16341 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16342 @item @code{:html-allow-name-attribute-in-anchors}
16343 @tab @code{org-html-allow-name-attribute-in-anchors}
16344 @item @code{:html-checkbox-type}
16345 @tab @code{org-html-checkbox-type}
16346 @item @code{:html-container}
16347 @tab @code{org-html-container-element}
16348 @item @code{:html-divs}
16349 @tab @code{org-html-divs}
16350 @item @code{:html-doctype}
16351 @tab @code{org-html-doctype}
16352 @item @code{:html-extension}
16353 @tab @code{org-html-extension}
16354 @item @code{:html-footnote-format}
16355 @tab @code{org-html-footnote-format}
16356 @item @code{:html-footnote-separator}
16357 @tab @code{org-html-footnote-separator}
16358 @item @code{:html-footnotes-section}
16359 @tab @code{org-html-footnotes-section}
16360 @item @code{:html-format-drawer-function}
16361 @tab @code{org-html-format-drawer-function}
16362 @item @code{:html-format-headline-function}
16363 @tab @code{org-html-format-headline-function}
16364 @item @code{:html-format-inlinetask-function}
16365 @tab @code{org-html-format-inlinetask-function}
16366 @item @code{:html-head-extra}
16367 @tab @code{org-html-head-extra}
16368 @item @code{:html-head-include-default-style}
16369 @tab @code{org-html-head-include-default-style}
16370 @item @code{:html-head-include-scripts}
16371 @tab @code{org-html-head-include-scripts}
16372 @item @code{:html-head}
16373 @tab @code{org-html-head}
16374 @item @code{:html-home/up-format}
16375 @tab @code{org-html-home/up-format}
16376 @item @code{:html-html5-fancy}
16377 @tab @code{org-html-html5-fancy}
16378 @item @code{:html-indent}
16379 @tab @code{org-html-indent}
16380 @item @code{:html-infojs-options}
16381 @tab @code{org-html-infojs-options}
16382 @item @code{:html-infojs-template}
16383 @tab @code{org-html-infojs-template}
16384 @item @code{:html-inline-image-rules}
16385 @tab @code{org-html-inline-image-rules}
16386 @item @code{:html-inline-images}
16387 @tab @code{org-html-inline-images}
16388 @item @code{:html-link-home}
16389 @tab @code{org-html-link-home}
16390 @item @code{:html-link-org-files-as-html}
16391 @tab @code{org-html-link-org-files-as-html}
16392 @item @code{:html-link-up}
16393 @tab @code{org-html-link-up}
16394 @item @code{:html-link-use-abs-url}
16395 @tab @code{org-html-link-use-abs-url}
16396 @item @code{:html-mathjax-options}
16397 @tab @code{org-html-mathjax-options}
16398 @item @code{:html-mathjax-template}
16399 @tab @code{org-html-mathjax-template}
16400 @item @code{:html-metadata-timestamp-format}
16401 @tab @code{org-html-metadata-timestamp-format}
16402 @item @code{:html-postamble-format}
16403 @tab @code{org-html-postamble-format}
16404 @item @code{:html-postamble}
16405 @tab @code{org-html-postamble}
16406 @item @code{:html-preamble-format}
16407 @tab @code{org-html-preamble-format}
16408 @item @code{:html-preamble}
16409 @tab @code{org-html-preamble}
16410 @item @code{:html-table-align-individual-field}
16411 @tab @code{de@{org-html-table-align-individual-fields}
16412 @item @code{:html-table-attributes}
16413 @tab @code{org-html-table-default-attributes}
16414 @item @code{:html-table-caption-above}
16415 @tab @code{org-html-table-caption-above}
16416 @item @code{:html-table-data-tags}
16417 @tab @code{org-html-table-data-tags}
16418 @item @code{:html-table-header-tags}
16419 @tab @code{org-html-table-header-tags}
16420 @item @code{:html-table-row-tags}
16421 @tab @code{org-html-table-row-tags}
16422 @item @code{:html-table-use-header-tags-for-first-column}
16423 @tab @code{org-html-table-use-header-tags-for-first-column}
16424 @item @code{:html-tag-class-prefix}
16425 @tab @code{org-html-tag-class-prefix}
16426 @item @code{:html-text-markup-alist}
16427 @tab @code{org-html-text-markup-alist}
16428 @item @code{:html-todo-kwd-class-prefix}
16429 @tab @code{org-html-todo-kwd-class-prefix}
16430 @item @code{:html-toplevel-hlevel}
16431 @tab @code{org-html-toplevel-hlevel}
16432 @item @code{:html-use-infojs}
16433 @tab @code{org-html-use-infojs}
16434 @item @code{:html-validation-link}
16435 @tab @code{org-html-validation-link}
16436 @item @code{:html-viewport}
16437 @tab @code{org-html-viewport}
16438 @item @code{:html-xml-declaration}
16439 @tab @code{org-html-xml-declaration}
16440 @end multitable
16442 @anchor{@LaTeX{} specific properties}
16443 @subsubheading @LaTeX{} specific properties
16445 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16446 @item @code{:latex-active-timestamp-format}
16447 @tab @code{org-latex-active-timestamp-format}
16448 @item @code{:latex-caption-above}
16449 @tab @code{org-latex-caption-above}
16450 @item @code{:latex-classes}
16451 @tab @code{org-latex-classes}
16452 @item @code{:latex-class}
16453 @tab @code{org-latex-default-class}
16454 @item @code{:latex-compiler}
16455 @tab @code{org-latex-compiler}
16456 @item @code{:latex-default-figure-position}
16457 @tab @code{org-latex-default-figure-position}
16458 @item @code{:latex-default-table-environment}
16459 @tab @code{org-latex-default-table-environment}
16460 @item @code{:latex-default-table-mode}
16461 @tab @code{org-latex-default-table-mode}
16462 @item @code{:latex-diary-timestamp-format}
16463 @tab @code{org-latex-diary-timestamp-format}
16464 @item @code{:latex-footnote-defined-format}
16465 @tab @code{org-latex-footnote-defined-format}
16466 @item @code{:latex-footnote-separator}
16467 @tab @code{org-latex-footnote-separator}
16468 @item @code{:latex-format-drawer-function}
16469 @tab @code{org-latex-format-drawer-function}
16470 @item @code{:latex-format-headline-function}
16471 @tab @code{org-latex-format-headline-function}
16472 @item @code{:latex-format-inlinetask-function}
16473 @tab @code{org-latex-format-inlinetask-function}
16474 @item @code{:latex-hyperref-template}
16475 @tab @code{org-latex-hyperref-template}
16476 @item @code{:latex-image-default-height}
16477 @tab @code{org-latex-image-default-height}
16478 @item @code{:latex-image-default-option}
16479 @tab @code{org-latex-image-default-option}
16480 @item @code{:latex-image-default-width}
16481 @tab @code{org-latex-image-default-width}
16482 @item @code{:latex-images-centered}
16483 @tab @code{org-latex-images-centered}
16484 @item @code{:latex-inactive-timestamp-format}
16485 @tab @code{org-latex-inactive-timestamp-format}
16486 @item @code{:latex-inline-image-rules}
16487 @tab @code{org-latex-inline-image-rules}
16488 @item @code{:latex-link-with-unknown-path-format}
16489 @tab @code{org-latex-link-with-unknown-path-format}
16490 @item @code{:latex-listings-langs}
16491 @tab @code{org-latex-listings-langs}
16492 @item @code{:latex-listings-options}
16493 @tab @code{org-latex-listings-options}
16494 @item @code{:latex-listings}
16495 @tab @code{org-latex-listings}
16496 @item @code{:latex-minted-langs}
16497 @tab @code{org-latex-minted-langs}
16498 @item @code{:latex-minted-options}
16499 @tab @code{org-latex-minted-options}
16500 @item @code{:latex-prefer-user-labels}
16501 @tab @code{org-latex-prefer-user-labels}
16502 @item @code{:latex-subtitle-format}
16503 @tab @code{org-latex-subtitle-format}
16504 @item @code{:latex-subtitle-separate}
16505 @tab @code{org-latex-subtitle-separate}
16506 @item @code{:latex-table-scientific-notation}
16507 @tab @code{org-latex-table-scientific-notation}
16508 @item @code{:latex-tables-booktabs}
16509 @tab @code{org-latex-tables-booktabs}
16510 @item @code{:latex-tables-centered}
16511 @tab @code{org-latex-tables-centered}
16512 @item @code{:latex-text-markup-alist}
16513 @tab @code{org-latex-text-markup-alist}
16514 @item @code{:latex-title-command}
16515 @tab @code{org-latex-title-command}
16516 @item @code{:latex-toc-command}
16517 @tab @code{org-latex-toc-command}
16518 @end multitable
16520 @anchor{Markdown specific properties}
16521 @subsubheading Markdown specific properties
16523 @multitable {aaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaa}
16524 @item @code{:md-footnote-format}
16525 @tab @code{org-md-footnote-format}
16526 @item @code{:md-footnotes-section}
16527 @tab @code{org-md-footnotes-section}
16528 @item @code{:md-headline-style}
16529 @tab @code{org-md-headline-style}
16530 @end multitable
16532 @anchor{ODT specific properties}
16533 @subsubheading ODT specific properties
16535 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16536 @item @code{:odt-content-template-file}
16537 @tab @code{org-odt-content-template-file}
16538 @item @code{:odt-display-outline-level}
16539 @tab @code{org-odt-display-outline-level}
16540 @item @code{:odt-fontify-srcblocks}
16541 @tab @code{org-odt-fontify-srcblocks}
16542 @item @code{:odt-format-drawer-function}
16543 @tab @code{org-odt-format-drawer-function}
16544 @item @code{:odt-format-headline-function}
16545 @tab @code{org-odt-format-headline-function}
16546 @item @code{:odt-format-inlinetask-function}
16547 @tab @code{org-odt-format-inlinetask-function}
16548 @item @code{:odt-inline-formula-rules}
16549 @tab @code{org-odt-inline-formula-rules}
16550 @item @code{:odt-inline-image-rules}
16551 @tab @code{org-odt-inline-image-rules}
16552 @item @code{:odt-pixels-per-inch}
16553 @tab @code{org-odt-pixels-per-inch}
16554 @item @code{:odt-styles-file}
16555 @tab @code{org-odt-styles-file}
16556 @item @code{:odt-table-styles}
16557 @tab @code{org-odt-table-styles}
16558 @item @code{:odt-use-date-fields}
16559 @tab @code{org-odt-use-date-fields}
16560 @end multitable
16562 @anchor{Texinfo specific properties}
16563 @subsubheading Texinfo specific properties
16565 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16566 @item @code{:texinfo-active-timestamp-format}
16567 @tab @code{org-texinfo-active-timestamp-format}
16568 @item @code{:texinfo-classes}
16569 @tab @code{org-texinfo-classes}
16570 @item @code{:texinfo-class}
16571 @tab @code{org-texinfo-default-class}
16572 @item @code{:texinfo-table-default-markup}
16573 @tab @code{org-texinfo-table-default-markup}
16574 @item @code{:texinfo-diary-timestamp-format}
16575 @tab @code{org-texinfo-diary-timestamp-format}
16576 @item @code{:texinfo-filename}
16577 @tab @code{org-texinfo-filename}
16578 @item @code{:texinfo-format-drawer-function}
16579 @tab @code{org-texinfo-format-drawer-function}
16580 @item @code{:texinfo-format-headline-function}
16581 @tab @code{org-texinfo-format-headline-function}
16582 @item @code{:texinfo-format-inlinetask-function}
16583 @tab @code{org-texinfo-format-inlinetask-function}
16584 @item @code{:texinfo-inactive-timestamp-format}
16585 @tab @code{org-texinfo-inactive-timestamp-format}
16586 @item @code{:texinfo-link-with-unknown-path-format}
16587 @tab @code{org-texinfo-link-with-unknown-path-format}
16588 @item @code{:texinfo-node-description-column}
16589 @tab @code{org-texinfo-node-description-column}
16590 @item @code{:texinfo-table-scientific-notation}
16591 @tab @code{org-texinfo-table-scientific-notation}
16592 @item @code{:texinfo-tables-verbatim}
16593 @tab @code{org-texinfo-tables-verbatim}
16594 @item @code{:texinfo-text-markup-alist}
16595 @tab @code{org-texinfo-text-markup-alist}
16596 @end multitable
16598 @node Publishing links
16599 @subsection Publishing links
16601 @cindex links, publishing
16603 To create a link from one Org file to another, you would use something
16604 like @samp{[[file:foo.org][The foo]]} or simply @samp{[[file:foo.org]]} (see @ref{External Links}).  When
16605 published, this link becomes a link to @samp{foo.html}.  You can thus
16606 interlink the pages of your ``Org web'' project and the links will work
16607 as expected when you publish them to HTML.  If you also publish the
16608 Org source file and want to link to it, use an @samp{http} link instead of
16609 a @samp{file:} link, because @samp{file} links are converted to link to the
16610 corresponding @samp{.html} file.
16612 You may also link to related files, such as images.  Provided you are
16613 careful with relative file names, and provided you have also
16614 configured Org to upload the related files, these links will work too.
16615 See @ref{Complex example}, for an example of this
16616 usage.
16618 Eventually, links between published documents can contain some search
16619 options (see @ref{Search Options}), which will be resolved to
16620 the appropriate location in the linked file.  For example, once
16621 published to HTML, the following links all point to a dedicated anchor
16622 in @samp{foo.html}.
16624 @example
16625 [[file:foo.org::*heading]]
16626 [[file:foo.org::#custom-id]]
16627 [[file:foo.org::target]]
16628 @end example
16630 @node Site map
16631 @subsection Generating a sitemap
16633 @cindex sitemap, of published pages
16635 The following properties may be used to control publishing of
16636 a map of files for a given project.
16638 @table @asis
16639 @item @code{:auto-sitemap}
16640 When non-@code{nil}, publish a sitemap during
16641 @code{org-publish-current-project} or @code{org-publish-all}.
16643 @item @code{:sitemap-filename}
16644 Filename for output of sitemap.  Defaults to @samp{sitemap.org}, which
16645 becomes @samp{sitemap.html}.
16647 @item @code{:sitemap-title}
16648 Title of sitemap page.  Defaults to name of file.
16650 @item @code{:sitemap-format-entry}
16651 @findex org-publish-find-date
16652 @findex org-publish-find-property
16653 @findex org-publish-find-title
16654 With this option one can tell how a site-map entry is formatted
16655 in the site-map.  It is a function called with three arguments:
16656 the file or directory name relative to base directory of the
16657 project, the site-map style and the current project.  It is
16658 expected to return a string.  Default value turns file names into
16659 links and use document titles as descriptions.  For specific
16660 formatting needs, one can use @code{org-publish-find-date},
16661 @code{org-publish-find-title} and @code{org-publish-find-property}, to
16662 retrieve additional information about published documents.
16664 @item @code{:sitemap-function}
16665 Plug-in function to use for generation of the sitemap.  It is
16666 called with two arguments: the title of the site-map and
16667 a representation of the files and directories involved in the
16668 project as a nested list, which can further be transformed using
16669 @code{org-list-to-generic}, @code{org-list-to-subtree} and alike.  Default
16670 value generates a plain list of links to all files in the
16671 project.
16673 @item @code{:sitemap-sort-folders}
16674 Where folders should appear in the sitemap.  Set this to @code{first}
16675 (default) or @code{last} to display folders first or last,
16676 respectively.  When set to @code{ignore}, folders are ignored
16677 altogether.  Any other value mixes files and folders.  This
16678 variable has no effect when site-map style is @code{tree}.
16680 @item @code{:sitemap-sort-files}
16681 How the files are sorted in the site map.  Set this to
16682 @code{alphabetically} (default), @code{chronologically} or
16683 @code{anti-chronologically}.  @code{chronologically} sorts the files with
16684 older date first while @code{anti-chronologically} sorts the files
16685 with newer date first.  @code{alphabetically} sorts the files
16686 alphabetically.  The date of a file is retrieved with
16687 @code{org-publish-find-date}.
16689 @item @code{:sitemap-ignore-case}
16690 Should sorting be case-sensitive?  Default @code{nil}.
16692 @item @code{:sitemap-file-entry-format}
16693 With this option one can tell how a sitemap's entry is formatted
16694 in the sitemap.  This is a format string with some escape
16695 sequences: @code{%t} stands for the title of the file, @code{%a} stands for
16696 the author of the file and @code{%d} stands for the date of the file.
16697 The date is retrieved with the @code{org-publish-find-date} function
16698 and formatted with @code{org-publish-sitemap-date-format}.  Default
16699 @code{%t}.
16701 @item @code{:sitemap-date-format}
16702 Format string for the @code{format-time-string} function that tells
16703 how a sitemap entry's date is to be formatted.  This property
16704 bypasses @code{org-publish-sitemap-date-format} which defaults to
16705 @code{%Y-%m-%d}.
16706 @end table
16708 @node Generating an index
16709 @subsection Generating an index
16711 @cindex index, in a publishing project
16713 Org mode can generate an index across the files of a publishing project.
16715 @table @asis
16716 @item @code{:makeindex}
16717 When non-@code{nil}, generate in index in the file @samp{theindex.org} and
16718 publish it as @samp{theindex.html}.
16719 @end table
16721 The file is created when first publishing a project with the
16722 @code{:makeindex} set.  The file only contains a statement @samp{#+INCLUDE:
16723 "theindex.inc"}.  You can then build around this include statement by
16724 adding a title, style information, etc.
16726 @cindex @samp{INDEX}, keyword
16727 Index entries are specified with @samp{INDEX} keyword.  An entry that
16728 contains an exclamation mark creates a sub item.
16730 @example
16731 *** Curriculum Vitae
16732 #+INDEX: CV
16733 #+INDEX: Application!CV
16734 @end example
16736 @node Uploading Files
16737 @section Uploading Files
16739 @cindex rsync
16740 @cindex unison
16742 For those people already utilizing third party sync tools such as
16743 Rsync or Unison, it might be preferable not to use the built-in remote
16744 publishing facilities of Org mode which rely heavily on Tramp.  Tramp,
16745 while very useful and powerful, tends not to be so efficient for
16746 multiple file transfer and has been known to cause problems under
16747 heavy usage.
16749 Specialized synchronization utilities offer several advantages.  In
16750 addition to timestamp comparison, they also do content and
16751 permissions/attribute checks.  For this reason you might prefer to
16752 publish your web to a local directory---possibly even @emph{in place} with
16753 your Org files---and then use Unison or Rsync to do the
16754 synchronization with the remote host.
16756 Since Unison, for example, can be configured as to which files to
16757 transfer to a certain remote destination, it can greatly simplify the
16758 project publishing definition.  Simply keep all files in the correct
16759 location, process your Org files with @code{org-publish} and let the
16760 synchronization tool do the rest.  You do not need, in this scenario,
16761 to include attachments such as JPG, CSS or PNG files in the project
16762 definition since the third-party tool syncs them.
16764 Publishing to a local directory is also much faster than to a remote
16765 one, so that you can afford more easily to republish entire projects.
16766 If you set @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the
16767 main benefit of re-including any changed external files such as source
16768 example files you might include with @samp{INCLUDE} keyword.  The timestamp
16769 mechanism in Org is not smart enough to detect if included files have
16770 been modified.
16772 @node Sample Configuration
16773 @section Sample Configuration
16775 Below we provide two example configurations.  The first one is
16776 a simple project publishing only a set of Org files.  The second
16777 example is more complex, with a multi-component project.
16779 @menu
16780 * Simple example::               One-component publishing.
16781 * Complex example::              A multi-component publishing example.
16782 @end menu
16784 @node Simple example
16785 @subsection Example: simple publishing configuration
16787 This example publishes a set of Org files to the @samp{public_html}
16788 directory on the local machine.
16790 @lisp
16791 (setq org-publish-project-alist
16792       '(("org"
16793          :base-directory "~/org/"
16794          :publishing-directory "~/public_html"
16795          :section-numbers nil
16796          :table-of-contents nil
16797          :style "<link rel=\"stylesheet\"
16798                 href=\"../other/mystyle.css\"
16799                 type=\"text/css\"/>")))
16800 @end lisp
16802 @node Complex example
16803 @subsection Example: complex publishing configuration
16805 This more complicated example publishes an entire website, including
16806 Org files converted to HTML, image files, Emacs Lisp source code, and
16807 style sheets.  The publishing directory is remote and private files
16808 are excluded.
16810 To ensure that links are preserved, care should be taken to replicate
16811 your directory structure on the web server, and to use relative file
16812 paths.  For example, if your Org files are kept in @samp{~/org/} and your
16813 publishable images in @samp{~/images/}, you would link to an image with
16815 @example
16816 file:../images/myimage.png
16817 @end example
16819 On the web server, the relative path to the image should be the same.
16820 You can accomplish this by setting up an @samp{images/} folder in the right
16821 place on the web server, and publishing images to it.
16823 @lisp
16824 (setq org-publish-project-alist
16825       '(("orgfiles"
16826          :base-directory "~/org/"
16827          :base-extension "org"
16828          :publishing-directory "/ssh:user@@host:~/html/notebook/"
16829          :publishing-function org-html-publish-to-html
16830          :exclude "PrivatePage.org" ;; regexp
16831          :headline-levels 3
16832          :section-numbers nil
16833          :with-toc nil
16834          :html-head "<link rel=\"stylesheet\"
16835                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
16836          :html-preamble t)
16838         ("images"
16839          :base-directory "~/images/"
16840          :base-extension "jpg\\|gif\\|png"
16841          :publishing-directory "/ssh:user@@host:~/html/images/"
16842          :publishing-function org-publish-attachment)
16844         ("other"
16845          :base-directory "~/other/"
16846          :base-extension "css\\|el"
16847          :publishing-directory "/ssh:user@@host:~/html/other/"
16848          :publishing-function org-publish-attachment)
16849         ("website" :components ("orgfiles" "images" "other"))))
16850 @end lisp
16852 @node Triggering Publication
16853 @section Triggering Publication
16855 Once properly configured, Org can publish with the following commands:
16857 @table @asis
16858 @item @kbd{C-c C-e X} (@code{org-publish})
16859 @kindex C-c C-e X
16860 @findex org-publish
16861 Prompt for a specific project and publish all files that belong
16862 to it.
16864 @item @kbd{C-c C-e P} (@code{org-publish-current-project})
16865 @kindex C-c C-e P
16866 @findex org-publish-current-project
16867 Publish the project containing the current file.
16869 @item @kbd{C-c C-e F} (@code{org-publish-current-file})
16870 @kindex C-c C-e F
16871 @findex org-publish-current-file
16872 Publish only the current file.
16874 @item @kbd{C-c C-e E} (@code{org-publish-all})
16875 @kindex C-c C-e E
16876 @findex org-publish-all
16877 Publish every project.
16878 @end table
16880 @vindex org-publish-use-timestamps-flag
16881 Org uses timestamps to track when a file has changed.  The above
16882 functions normally only publish changed files.  You can override this
16883 and force publishing of all files by giving a prefix argument to any
16884 of the commands above, or by customizing the variable
16885 @code{org-publish-use-timestamps-flag}.  This may be necessary in
16886 particular if files include other files via @samp{SETUPFILE} or @samp{INCLUDE}
16887 keywords.
16889 @node Working with Source Code
16890 @chapter Working with Source Code
16892 @cindex source code, working with
16894 Source code here refers to any plain text collection of computer
16895 instructions, possibly with comments, written using a human-readable
16896 programming language.  Org can manage source code in an Org document
16897 when the source code is identified with begin and end markers.
16898 Working with source code begins with identifying source code blocks.
16899 A source code block can be placed almost anywhere in an Org document;
16900 it is not restricted to the preamble or the end of the document.
16901 However, Org cannot manage a source code block if it is placed inside
16902 an Org comment or within a fixed width section.
16904 Here is an example source code block in the Emacs Lisp language:
16906 @example
16907 #+BEGIN_SRC emacs-lisp
16908   (defun org-xor (a b)
16909      "Exclusive or."
16910      (if a (not b) b))
16911 #+END_SRC
16912 @end example
16914 Org can manage the source code in the block delimited by @samp{#+BEGIN_SRC}
16915 @dots{} @samp{#+END_SRC} in several ways that can simplify housekeeping tasks
16916 essential to modern source code maintenance.  Org can edit, format,
16917 extract, export, and publish source code blocks.  Org can also compile
16918 and execute a source code block, then capture the results.  The Org
16919 mode literature sometimes refers to source code blocks as @emph{live code}
16920 blocks because they can alter the content of the Org document or the
16921 material that it exports.  Users can control how live they want each
16922 source code block by tweaking the header arguments (see @ref{Using Header Arguments}) for compiling, execution, extraction, and
16923 exporting.
16925 Source code blocks are one of many Org block types, which also include
16926 @samp{quote}, @samp{export}, @samp{verse}, @samp{latex}, @samp{example}, and @samp{verbatim}.  This
16927 section pertains to blocks between @samp{#+BEGIN_SRC} and @samp{#+END_SRC}.
16929 For editing and formatting a source code block, Org uses an
16930 appropriate Emacs major mode that includes features specifically
16931 designed for source code in that language.
16933 Org can extract one or more source code blocks and write them to one
16934 or more source files---a process known as @emph{tangling} in literate
16935 programming terminology.
16937 For exporting and publishing, Org's back-ends can format a source code
16938 block appropriately, often with native syntax highlighting.
16940 For executing and compiling a source code block, the user can
16941 configure Org to select the appropriate compiler.  Org provides
16942 facilities to collect the result of the execution or compiler output,
16943 insert it into the Org document, and/or export it.  In addition to
16944 text results, Org can insert links to other data types, including
16945 audio, video, and graphics.  Org can also link a compiler error
16946 message to the appropriate line in the source code block.
16948 An important feature of Org's management of source code blocks is the
16949 ability to pass variables, functions, and results to one another using
16950 a common syntax for source code blocks in any language.  Although most
16951 literate programming facilities are restricted to one language or
16952 another, Org's language-agnostic approach lets the literate programmer
16953 match each programming task with the appropriate computer language and
16954 to mix them all together in a single Org document.  This
16955 interoperability among languages explains why Org's source code
16956 management facility was named @emph{Org Babel} by its originators, Eric
16957 Schulte and Dan Davison.
16959 Org mode fulfills the promise of easy verification and maintenance of
16960 publishing reproducible research by keeping text, data, code,
16961 configuration settings of the execution environment, the results of
16962 the execution, and associated narratives, claims, references, and
16963 internal and external links in a single Org document.
16965 Details of Org's facilities for working with source code are described
16966 in the following sections.
16968 @menu
16969 * Structure of Code Blocks::     Code block syntax described.
16970 * Using Header Arguments::       Different ways to set header arguments.
16971 * Environment of a Code Block::  Arguments, sessions, working directory...
16972 * Evaluating Code Blocks::       Place results of evaluation in the Org buffer.
16973 * Results of Evaluation::        Choosing a results type, post-processing...
16974 * Exporting Code Blocks::        Export contents and/or results.
16975 * Extracting Source Code::       Create pure source code files.
16976 * Languages::                    List of supported code block languages.
16977 * Editing Source Code::          Language major-mode editing.
16978 * Noweb Reference Syntax::       Literate programming in Org mode.
16979 * Library of Babel::             Use and contribute to a library of useful code blocks.
16980 * Key bindings and Useful Functions:: Work quickly with code blocks.
16981 * Batch Execution::              Call functions from the command line.
16982 @end menu
16984 @node Structure of Code Blocks
16985 @section Structure of Code Blocks
16987 @cindex code block, structure
16988 @cindex source code, block structure
16989 @cindex @samp{NAME} keyword, in source blocks
16990 @cindex @samp{BEGIN_SRC}
16992 Org offers two ways to structure source code in Org documents: in
16993 a source code block, and directly inline.  Both specifications are
16994 shown below.
16996 A source code block conforms to this structure:
16998 @example
16999 #+NAME: <name>
17000 #+BEGIN_SRC <language> <switches> <header arguments>
17001   <body>
17002 #+END_SRC
17003 @end example
17005 Do not be put-off by having to remember the source block syntax.  Org
17006 mode offers a command for wrapping existing text in a block (see
17007 @ref{Structure Templates}).  Org also works with other completion systems
17008 in Emacs, some of which predate Org and have custom domain-specific
17009 languages for defining templates.  Regular use of templates reduces
17010 errors, increases accuracy, and maintains consistency.
17012 @cindex source code, inline
17013 An inline code block conforms to this structure:
17015 @example
17016 src_<language>@{<body>@}
17017 @end example
17019 @noindent
17022 @example
17023 src_<language>[<header arguments>]@{<body>@}
17024 @end example
17026 @table @asis
17027 @item @samp{#+NAME: <name>}
17028 Optional.  Names the source block so it can be called, like
17029 a function, from other source blocks or inline code to evaluate
17030 or to capture the results.  Code from other blocks, other files,
17031 and from table formulas (see @ref{The spreadsheet}) can use the name
17032 to reference a source block.  This naming serves the same purpose
17033 as naming Org tables.  Org mode requires unique names.  For
17034 duplicate names, Org mode's behavior is undefined.
17036 @item @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}
17037 Mandatory.  They mark the start and end of a block that Org
17038 requires.  The @samp{#+BEGIN_SRC} line takes additional arguments, as
17039 described next.
17041 @item @samp{<language>}
17042 @cindex language, in code blocks
17043 Mandatory.  It is the identifier of the source code language in
17044 the block.  See @ref{Languages}, for identifiers of supported
17045 languages.
17047 @item @samp{<switches>}
17048 @cindex switches, in code blocks
17049 Optional.  Switches provide finer control of the code execution,
17050 export, and format (see the discussion of switches in @ref{Literal Examples}).
17052 @item @samp{<header arguments>}
17053 @cindex header arguments, in code blocks
17054 Optional.  Heading arguments control many aspects of evaluation,
17055 export and tangling of code blocks (see @ref{Using Header Arguments}).
17056 Using Org's properties feature, header arguments can be
17057 selectively applied to the entire buffer or specific sub-trees of
17058 the Org document.
17060 @item @samp{<body>}
17061 Source code in the dialect of the specified language identifier.
17062 @end table
17064 @node Using Header Arguments
17065 @section Using Header Arguments
17067 Org comes with many header arguments common to all languages.  New
17068 header arguments are added for specific languages as they become
17069 available for use in source code blocks.  A header argument is
17070 specified with an initial colon followed by the argument's name in
17071 lowercase.
17073 Since header arguments can be set in several ways, Org prioritizes
17074 them in case of overlaps or conflicts by giving local settings
17075 a higher priority.  Header values in function calls, for example,
17076 override header values from global defaults.
17078 @anchor{System-wide header arguments}
17079 @subheading System-wide header arguments
17081 @vindex org-babel-default-header-args
17083 @vindex org-babel-default-header-args
17084 System-wide values of header arguments can be specified by customizing
17085 the @code{org-babel-default-header-args} variable, which defaults to the
17086 following values:
17088 @example
17089 :session    => "none"
17090 :results    => "replace"
17091 :exports    => "code"
17092 :cache      => "no"
17093 :noweb      => "no"
17094 @end example
17096 The example below sets @samp{:noweb} header arguments to @samp{yes}, which makes
17097 Org expand @samp{:noweb} references by default.
17099 @lisp
17100 (setq org-babel-default-header-args
17101       (cons '(:noweb . "yes")
17102             (assq-delete-all :noweb org-babel-default-header-args)))
17103 @end lisp
17105 @cindex language specific default header arguments
17106 @cindex default header arguments per language
17107 Each language can have separate default header arguments by
17108 customizing the variable @code{org-babel-default-header-args:<LANG>}, where
17109 @var{<LANG>} is the name of the language.  For details, see the
17110 language-specific online documentation at
17111 @uref{https://orgmode.org/worg/org-contrib/babel/}.
17113 @anchor{Header arguments in Org mode properties}
17114 @subheading Header arguments in Org mode properties
17116 For header arguments applicable to the buffer, use @samp{PROPERTY} keyword
17117 anywhere in the Org file (see @ref{Property Syntax}).
17119 The following example makes all the R code blocks execute in the same
17120 session.  Setting @samp{:results} to @samp{silent} ignores the results of
17121 executions for all blocks, not just R code blocks; no results inserted
17122 for any block.
17124 @example
17125 #+PROPERTY: header-args:R  :session *R*
17126 #+PROPERTY: header-args    :results silent
17127 @end example
17129 @vindex org-use-property-inheritance
17130 Header arguments set through Org's property drawers (see @ref{Property Syntax}) apply at the sub-tree level on down.  Since these property
17131 drawers can appear anywhere in the file hierarchy, Org uses outermost
17132 call or source block to resolve the values.  Org ignores
17133 @code{org-use-property-inheritance} setting.
17135 In this example, @samp{:cache} defaults to @samp{yes} for all code blocks in the
17136 sub-tree.
17138 @example
17139 * sample header
17140   :PROPERTIES:
17141   :header-args:    :cache yes
17142   :END:
17143 @end example
17145 @kindex C-c C-x p
17146 @findex org-set-property
17147 Properties defined through @code{org-set-property} function, bound to
17148 @kbd{C-c C-x p}, apply to all active languages.  They override
17149 properties set in @code{org-babel-default-header-args}.
17151 @cindex language specific header arguments properties
17152 @cindex header arguments per language
17153 Language-specific header arguments are also read from properties
17154 @samp{header-args:<LANG>} where @var{<LANG>} is the language
17155 identifier.  For example,
17157 @example
17158 * Heading
17159   :PROPERTIES:
17160   :header-args:clojure:    :session *clojure-1*
17161   :header-args:R:          :session *R*
17162   :END:
17163 ** Subheading
17164   :PROPERTIES:
17165   :header-args:clojure:    :session *clojure-2*
17166   :END:
17167 @end example
17169 @noindent
17170 would force separate sessions for Clojure blocks in @samp{Heading} and
17171 @samp{Subheading}, but use the same session for all R blocks.  Blocks in
17172 @samp{Subheading} inherit settings from @samp{Heading}.
17174 @anchor{Code block specific header arguments}
17175 @subheading Code block specific header arguments
17177 Header arguments are most commonly set at the source code block level,
17178 on the @samp{#+BEGIN_SRC} line.  Arguments set at this level take
17179 precedence over those set in the @code{org-babel-default-header-args}
17180 variable, and also those set as header properties.
17182 In the following example, setting @samp{:results} to @samp{silent} makes it
17183 ignore results of the code execution.  Setting @samp{:exports} to @samp{code}
17184 exports only the body of the code block to HTML or @LaTeX{}.
17186 @example
17187 #+NAME: factorial
17188 #+BEGIN_SRC haskell :results silent :exports code :var n=0
17189   fac 0 = 1
17190   fac n = n * fac (n-1)
17191 #+END_SRC
17192 @end example
17194 The same header arguments in an inline code block:
17196 @example
17197 src_haskell[:exports both]@{fac 5@}
17198 @end example
17200 @cindex @samp{HEADER}, keyword
17201 Code block header arguments can span multiple lines using @samp{#+HEADER:}
17202 on each line.  Note that Org currently accepts the plural spelling of
17203 @samp{#+HEADER:} only as a convenience for backward-compatibility.  It may
17204 be removed at some point.
17206 Multi-line header arguments on an unnamed code block:
17208 @example
17209 #+HEADER: :var data1=1
17210 #+BEGIN_SRC emacs-lisp :var data2=2
17211    (message "data1:%S, data2:%S" data1 data2)
17212 #+END_SRC
17214 #+RESULTS:
17215 : data1:1, data2:2
17216 @end example
17218 Multi-line header arguments on a named code block:
17220 @example
17221 #+NAME: named-block
17222 #+HEADER: :var data=2
17223 #+BEGIN_SRC emacs-lisp
17224   (message "data:%S" data)
17225 #+END_SRC
17227 #+RESULTS: named-block
17228   : data:2
17229 @end example
17231 @anchor{Header arguments in function calls}
17232 @subheading Header arguments in function calls
17234 Header arguments in function calls are the most specific and override
17235 all other settings in case of an overlap.  They get the highest
17236 priority.  Two @samp{#+CALL:} examples are shown below.  For the complete
17237 syntax of @samp{CALL} keyword, see @ref{Evaluating Code Blocks}.
17239 In this example, @samp{:exports results} header argument is applied to the
17240 evaluation of the @samp{#+CALL:} line.
17242 @example
17243 #+CALL: factorial(n=5) :exports results
17244 @end example
17246 In this example, @samp{:session special} header argument is applied to the
17247 evaluation of @samp{factorial} code block.
17249 @example
17250 #+CALL: factorial[:session special](n=5)
17251 @end example
17253 @node Environment of a Code Block
17254 @section Environment of a Code Block
17258 @anchor{Passing arguments}
17259 @subheading Passing arguments
17261 @cindex passing arguments to code blocks
17262 @cindex arguments, in code blocks
17263 @cindex @samp{var}, header argument
17264 Use @samp{var} for passing arguments to source code blocks.  The specifics
17265 of variables in code blocks vary by the source language and are
17266 covered in the language-specific documentation.  The syntax for @samp{var},
17267 however, is the same for all languages.  This includes declaring
17268 a variable, and assigning a default value.
17270 The following syntax is used to pass arguments to code blocks using
17271 the @samp{var} header argument.
17273 @example
17274 :var NAME=ASSIGN
17275 @end example
17277 @noindent
17278 @var{NAME} is the name of the variable bound in the code block
17279 body.  @var{ASSIGN} is a literal value, such as a string,
17280 a number, a reference to a table, a list, a literal example, another
17281 code block---with or without arguments---or the results of evaluating
17282 a code block.
17284 Here are examples of passing values by reference:
17286 @table @asis
17287 @item table
17288 A table named with a @samp{NAME} keyword.
17290 @example
17291 #+NAME: example-table
17292 | 1 |
17293 | 2 |
17294 | 3 |
17295 | 4 |
17297 #+NAME: table-length
17298 #+BEGIN_SRC emacs-lisp :var table=example-table
17299   (length table)
17300 #+END_SRC
17302 #+RESULTS: table-length
17303 : 4
17304 @end example
17306 When passing a table, you can treat specially the row, or the
17307 column, containing labels for the columns, or the rows, in the
17308 table.
17310 @cindex @samp{colnames}, header argument
17311 The @samp{colnames} header argument accepts @samp{yes}, @samp{no}, or @samp{nil}
17312 values.  The default value is @samp{nil}: if an input table has column
17313 names---because the second row is a horizontal rule---then Org
17314 removes the column names, processes the table, puts back the
17315 column names, and then writes the table to the results block.
17316 Using @samp{yes}, Org does the same to the first row, even if the
17317 initial table does not contain any horizontal rule.  When set to
17318 @samp{no}, Org does not pre-process column names at all.
17320 @example
17321 #+NAME: less-cols
17322 | a |
17323 |---|
17324 | b |
17325 | c |
17327 #+BEGIN_SRC python :var tab=less-cols :colnames nil
17328   return [[val + '*' for val in row] for row in tab]
17329 #+END_SRC
17331 #+RESULTS:
17332 | a  |
17333 |----|
17334 | b* |
17335 | c* |
17336 @end example
17338 @cindex @samp{rownames}, header argument
17339 Similarly, the @samp{rownames} header argument can take two values:
17340 @samp{yes} or @samp{no}.  When set to @samp{yes}, Org removes the first column,
17341 processes the table, puts back the first column, and then writes
17342 the table to the results block.  The default is @samp{no}, which means
17343 Org does not pre-process the first column.  Note that Emacs Lisp
17344 code blocks ignore @samp{rownames} header argument because of the ease
17345 of table-handling in Emacs.
17347 @example
17348 #+NAME: with-rownames
17349 | one | 1 | 2 | 3 | 4 |  5 |
17350 | two | 6 | 7 | 8 | 9 | 10 |
17352 #+BEGIN_SRC python :var tab=with-rownames :rownames yes
17353   return [[val + 10 for val in row] for row in tab]
17354 #+END_SRC
17356 #+RESULTS:
17357 | one | 11 | 12 | 13 | 14 | 15 |
17358 | two | 16 | 17 | 18 | 19 | 20 |
17359 @end example
17361 @item list
17362 A simple named list.
17364 @example
17365 #+NAME: example-list
17366 - simple
17367   - not
17368   - nested
17369 - list
17371 #+BEGIN_SRC emacs-lisp :var x=example-list
17372   (print x)
17373 #+END_SRC
17375 #+RESULTS:
17376 | simple | list |
17377 @end example
17379 Note that only the top level list items are passed along.  Nested
17380 list items are ignored.
17382 @item code block without arguments
17383 A code block name, as assigned by @samp{NAME} keyword from the example
17384 above, optionally followed by parentheses.
17386 @example
17387 #+BEGIN_SRC emacs-lisp :var length=table-length()
17388   (* 2 length)
17389 #+END_SRC
17391 #+RESULTS:
17392 : 8
17393 @end example
17395 @item code block with arguments
17396 A code block name, as assigned by @samp{NAME} keyword, followed by
17397 parentheses and optional arguments passed within the parentheses.
17399 @example
17400 #+NAME: double
17401 #+BEGIN_SRC emacs-lisp :var input=8
17402   (* 2 input)
17403 #+END_SRC
17405 #+RESULTS: double
17406 : 16
17408 #+NAME: squared
17409 #+BEGIN_SRC emacs-lisp :var input=double(input=1)
17410   (* input input)
17411 #+END_SRC
17413 #+RESULTS: squared
17414 : 4
17415 @end example
17417 @item literal example
17418 A literal example block named with a @samp{NAME} keyword.
17420 @example
17421 #+NAME: literal-example
17422 #+BEGIN_EXAMPLE
17423   A literal example
17424   on two lines
17425 #+END_EXAMPLE
17427 #+NAME: read-literal-example
17428 #+BEGIN_SRC emacs-lisp :var x=literal-example
17429   (concatenate #'string x " for you.")
17430 #+END_SRC
17432 #+RESULTS: read-literal-example
17433 : A literal example
17434 : on two lines for you.
17435 @end example
17436 @end table
17438 Indexing variable values enables referencing portions of a variable.
17439 Indexes are 0 based with negative values counting backwards from the
17440 end.  If an index is separated by commas then each subsequent section
17441 indexes as the next dimension.  Note that this indexing occurs
17442 @emph{before} other table-related header arguments are applied, such as
17443 @samp{hlines}, @samp{colnames} and @samp{rownames}.  The following example assigns
17444 the last cell of the first row the table @samp{example-table} to the
17445 variable @samp{data}:
17447 @example
17448 #+NAME: example-table
17449 | 1 | a |
17450 | 2 | b |
17451 | 3 | c |
17452 | 4 | d |
17454 #+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
17455   data
17456 #+END_SRC
17458 #+RESULTS:
17459 : a
17460 @end example
17462 Two integers separated by a colon reference a range of variable
17463 values.  In that case the entire inclusive range is referenced.  For
17464 example the following assigns the middle three rows of @samp{example-table}
17465 to @samp{data}.
17467 @example
17468 #+NAME: example-table
17469 | 1 | a |
17470 | 2 | b |
17471 | 3 | c |
17472 | 4 | d |
17473 | 5 | 3 |
17475 #+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
17476   data
17477 #+END_SRC
17479 #+RESULTS:
17480 | 2 | b |
17481 | 3 | c |
17482 | 4 | d |
17483 @end example
17485 To pick the entire range, use an empty index, or the single character
17486 @samp{*}.  @samp{0:-1} does the same thing.  Example below shows how to
17487 reference the first column only.
17489 @example
17490 #+NAME: example-table
17491 | 1 | a |
17492 | 2 | b |
17493 | 3 | c |
17494 | 4 | d |
17496 #+BEGIN_SRC emacs-lisp :var data=example-table[,0]
17497   data
17498 #+END_SRC
17500 #+RESULTS:
17501 | 1 | 2 | 3 | 4 |
17502 @end example
17504 Index referencing can be used for tables and code blocks.  Index
17505 referencing can handle any number of dimensions.  Commas delimit
17506 multiple dimensions, as shown below.
17508 @example
17509 #+NAME: 3D
17510 #+BEGIN_SRC emacs-lisp
17511   '(((1  2  3)  (4  5  6)  (7  8  9))
17512     ((10 11 12) (13 14 15) (16 17 18))
17513     ((19 20 21) (22 23 24) (25 26 27)))
17514 #+END_SRC
17516 #+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
17517   data
17518 #+END_SRC
17520 #+RESULTS:
17521 | 11 | 14 | 17 |
17522 @end example
17524 Note that row names and column names are not removed prior to variable
17525 indexing.  You need to take them into account, even when @samp{colnames} or
17526 @samp{rownames} header arguments remove them.
17528 Emacs lisp code can also set the values for variables.  To
17529 differentiate a value from Lisp code, Org interprets any value
17530 starting with @samp{(}, @samp{[}, @samp{'} or @samp{`} as Emacs Lisp code.  The result of
17531 evaluating that code is then assigned to the value of that variable.
17532 The following example shows how to reliably query and pass the file
17533 name of the Org mode buffer to a code block using headers.  We need
17534 reliability here because the file's name could change once the code in
17535 the block starts executing.
17537 @example
17538 #+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
17539   wc -w $filename
17540 #+END_SRC
17541 @end example
17543 Note that values read from tables and lists are not mistakenly
17544 evaluated as Emacs Lisp code, as illustrated in the following example.
17546 @example
17547 #+NAME: table
17548 | (a b c) |
17550 #+HEADER: :var data=table[0,0]
17551 #+BEGIN_SRC perl
17552   $data
17553 #+END_SRC
17555 #+RESULTS:
17556 : (a b c)
17557 @end example
17559 @anchor{Using sessions}
17560 @subheading Using sessions
17562 @cindex using sessions in code blocks
17563 @cindex @samp{session}, header argument
17564 Two code blocks can share the same environment.  The @samp{session} header
17565 argument is for running multiple source code blocks under one session.
17566 Org runs code blocks with the same session name in the same
17567 interpreter process.
17569 @table @asis
17570 @item @samp{none}
17571 Default.  Each code block gets a new interpreter process to
17572 execute.  The process terminates once the block is evaluated.
17574 @item @var{STRING}
17575 Any string besides @samp{none} turns that string into the name of that
17576 session.  For example, @samp{:session STRING} names it @samp{STRING}.  If
17577 @samp{session} has no value, then the session name is derived from the
17578 source language identifier.  Subsequent blocks with the same
17579 source code language use the same session.  Depending on the
17580 language, state variables, code from other blocks, and the
17581 overall interpreted environment may be shared.  Some interpreted
17582 languages support concurrent sessions when subsequent source code
17583 language blocks change session names.
17584 @end table
17586 Only languages that provide interactive evaluation can have session
17587 support.  Not all languages provide this support, such as C and ditaa.
17588 Even languages, such as Python and Haskell, that do support
17589 interactive evaluation impose limitations on allowable language
17590 constructs that can run interactively.  Org inherits those limitations
17591 for those code blocks running in a session.
17593 @anchor{Choosing a working directory}
17594 @subheading Choosing a working directory
17596 @cindex working directory, in a code block
17597 @cindex @samp{dir}, header argument
17598 The @samp{dir} header argument specifies the default directory during code
17599 block execution.  If it is absent, then the directory associated with
17600 the current buffer is used.  In other words, supplying @samp{:dir PATH}
17601 temporarily has the same effect as changing the current directory with
17602 @kbd{M-x cd PATH}, and then not setting @samp{dir}.  Under the
17603 surface, @samp{dir} simply sets the value of the Emacs variable
17604 @code{default-directory}.
17606 For example, to save the plot file in the @samp{Work/} folder of the home
17607 directory---notice tilde is expanded:
17609 @example
17610 #+BEGIN_SRC R :file myplot.png :dir ~/Work
17611   matplot(matrix(rnorm(100), 10), type="l")
17612 #+END_SRC
17613 @end example
17615 To evaluate the code block on a remote machine, supply a remote
17616 directory name using Tramp syntax.  For example:
17618 @example
17619 #+BEGIN_SRC R :file plot.png :dir /scp:dand@@yakuba.princeton.edu:
17620   plot(1:10, main=system("hostname", intern=TRUE))
17621 #+END_SRC
17622 @end example
17624 Org first captures the text results as usual for insertion in the Org
17625 file.  Then Org also inserts a link to the remote file, thanks to
17626 Emacs Tramp.  Org constructs the remote path to the file name from
17627 @samp{dir} and @code{default-directory}, as illustrated here:
17629 @example
17630 [[file:/scp:dand@@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
17631 @end example
17633 When @samp{dir} is used with @samp{session}, Org sets the starting directory for
17634 a new session.  But Org does not alter the directory of an already
17635 existing session.
17637 Do not use @samp{dir} with @samp{:exports results} or with @samp{:exports both} to
17638 avoid Org inserting incorrect links to remote files.  That is because
17639 Org does not expand @code{default directory} to avoid some underlying
17640 portability issues.
17642 @anchor{Inserting headers and footers}
17643 @subheading Inserting headers and footers
17645 @cindex headers, in code blocks
17646 @cindex footers, in code blocks
17647 @cindex @samp{prologue}, header argument
17648 The @samp{prologue} header argument is for appending to the top of the code
17649 block for execution, like a reset instruction.  For example, you may
17650 use @samp{:prologue "reset"} in a Gnuplot code block or, for every such
17651 block:
17653 @lisp
17654 (add-to-list 'org-babel-default-header-args:gnuplot
17655              '((:prologue . "reset")))
17657 @end lisp
17659 @cindex @samp{epilogue}, header argument
17660 Likewise, the value of the @samp{epilogue} header argument is for appending
17661 to the end of the code block for execution.
17663 @node Evaluating Code Blocks
17664 @section Evaluating Code Blocks
17666 @cindex code block, evaluating
17667 @cindex source code, evaluating
17668 @cindex @samp{RESULTS}, keyword
17670 A note about security: With code evaluation comes the risk of harm.
17671 Org safeguards by prompting for user's permission before executing any
17672 code in the source block.  To customize this safeguard, or disable it,
17673 see @ref{Code Evaluation Security}.
17675 @anchor{How to evaluate source code}
17676 @subheading How to evaluate source code
17678 Org captures the results of the code block evaluation and inserts them
17679 in the Org file, right after the code block.  The insertion point is
17680 after a newline and the @samp{RESULTS} keyword.  Org creates the @samp{RESULTS}
17681 keyword if one is not already there.
17683 By default, Org enables only Emacs Lisp code blocks for execution.
17684 See @ref{Languages} to enable other languages.
17686 @kindex C-c C-c
17687 @kindex C-c C-v e
17688 @findex org-babel-execute-src-block
17689 Org provides many ways to execute code blocks.  @kbd{C-c C-c} or
17690 @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
17691 to remove code evaluation from the @kbd{C-c C-c} key binding.} calls the
17692 @code{org-babel-execute-src-block} function, which executes the code in the
17693 block, collects the results, and inserts them in the buffer.
17695 @cindex @samp{CALL}, keyword
17696 @vindex org-babel-inline-result-wrap
17697 By calling a named code block@footnote{Actually, the constructs @samp{call_<name>()} and @samp{src_<lang>@{@}}
17698 are not evaluated when they appear in a keyword line---i.e. lines
17699 starting with @samp{#+KEYWORD:}, see @ref{In-buffer Settings}.} from an Org mode buffer or
17700 a table.  Org can call the named code blocks from the current Org mode
17701 buffer or from the ``Library of Babel'' (see @ref{Library of Babel}).
17703 The syntax for @samp{CALL} keyword is:
17705 @example
17706 #+CALL: <name>(<arguments>)
17707 #+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
17708 @end example
17710 The syntax for inline named code blocks is:
17712 @example
17713 ... call_<name>(<arguments>) ...
17714 ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
17715 @end example
17717 When inline syntax is used, the result is wrapped based on the
17718 variable @code{org-babel-inline-result-wrap}, which by default is set to
17719 @code{"=%s="} to produce verbatim text suitable for markup.
17721 @table @asis
17722 @item @samp{<name>}
17723 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
17724 located in another file, start @samp{<name>} with the file name
17725 followed by a colon. For example, in order to execute a block
17726 named @samp{clear-data} in @samp{file.org}, you can write the following:
17728 @example
17729 #+CALL: file.org:clear-data()
17730 @end example
17732 @item @samp{<arguments>}
17733 Org passes arguments to the code block using standard function
17734 call syntax.  For example, a @samp{#+CALL:} line that passes @samp{4} to
17735 a code block named @samp{double}, which declares the header argument
17736 @samp{:var n=2}, would be written as:
17738 @example
17739 #+CALL: double(n=4)
17740 @end example
17742 @noindent
17743 Note how this function call syntax is different from the header
17744 argument syntax.
17746 @item @samp{<inside header arguments>}
17747 Org passes inside header arguments to the named code block using
17748 the header argument syntax.  Inside header arguments apply to
17749 code block evaluation.  For example, @samp{[:results output]} collects
17750 results printed to stdout during code execution of that block.
17751 Note how this header argument syntax is different from the
17752 function call syntax.
17754 @item @samp{<end header arguments>}
17755 End header arguments affect the results returned by the code
17756 block.  For example, @samp{:results html} wraps the results in
17757 a @samp{#+BEGIN_EXPORT html} block before inserting the results in the
17758 Org buffer.
17759 @end table
17761 @anchor{Limit code block evaluation}
17762 @subheading Limit code block evaluation
17764 @cindex @samp{eval}, header argument
17765 @cindex control code block evaluation
17766 The @samp{eval} header argument can limit evaluation of specific code
17767 blocks and @samp{CALL} keyword.  It is useful for protection against
17768 evaluating untrusted code blocks by prompting for a confirmation.
17770 @table @asis
17771 @item @samp{never} or @samp{no}
17772 Org never evaluates the source code.
17774 @item @samp{query}
17775 Org prompts the user for permission to evaluate the source code.
17777 @item @samp{never-export} or @samp{no-export}
17778 Org does not evaluate the source code when exporting, yet the
17779 user can evaluate it interactively.
17781 @item @samp{query-export}
17782 Org prompts the user for permission to evaluate the source code
17783 during export.
17784 @end table
17786 If @samp{eval} header argument is not set, then Org determines whether to
17787 evaluate the source code from the @code{org-confirm-babel-evaluate}
17788 variable (see @ref{Code Evaluation Security}).
17790 @anchor{Cache results of evaluation}
17791 @subheading Cache results of evaluation
17793 @cindex @samp{cache}, header argument
17794 @cindex cache results of code evaluation
17795 The @samp{cache} header argument is for caching results of evaluating code
17796 blocks.  Caching results can avoid re-evaluating a code block that
17797 have not changed since the previous run.  To benefit from the cache
17798 and avoid redundant evaluations, the source block must have a result
17799 already present in the buffer, and neither the header
17800 arguments---including the value of @samp{var} references---nor the text of
17801 the block itself has changed since the result was last computed.  This
17802 feature greatly helps avoid long-running calculations.  For some edge
17803 cases, however, the cached results may not be reliable.
17805 The caching feature is best for when code blocks are pure functions,
17806 that is functions that return the same value for the same input
17807 arguments (see @ref{Environment of a Code Block}), and that do not have
17808 side effects, and do not rely on external variables other than the
17809 input arguments.  Functions that depend on a timer, file system
17810 objects, and random number generators are clearly unsuitable for
17811 caching.
17813 A note of warning: when @samp{cache} is used in a session, caching may
17814 cause unexpected results.
17816 When the caching mechanism tests for any source code changes, it does
17817 not expand Noweb style references (see @ref{Noweb Reference Syntax}).  For
17818 reasons why, see @uref{http://thread.gmane.org/gmane.emacs.orgmode/79046}.
17820 The @samp{cache} header argument can have one of two values: @samp{yes} or @samp{no}.
17822 @table @asis
17823 @item @samp{no}
17824 Default.  No caching of results; code block evaluated every
17825 time.
17827 @item @samp{yes}
17828 Whether to run the code or return the cached results is
17829 determined by comparing the SHA1 hash value of the combined code
17830 block and arguments passed to it.  This hash value is packed on
17831 the @samp{#+RESULTS:} line from previous evaluation.  When hash values
17832 match, Org does not evaluate the code block.  When hash values
17833 mismatch, Org evaluates the code block, inserts the results,
17834 recalculates the hash value, and updates @samp{#+RESULTS:} line.
17835 @end table
17837 In this example, both functions are cached.  But @samp{caller} runs only if
17838 the result from @samp{random} has changed since the last run.
17840 @example
17841 #+NAME: random
17842 #+BEGIN_SRC R :cache yes
17843   runif(1)
17844 #+END_SRC
17846 #+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
17847 0.4659510825295
17849 #+NAME: caller
17850 #+BEGIN_SRC emacs-lisp :var x=random :cache yes
17851   x
17852 #+END_SRC
17854 #+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
17855 0.254227238707244
17856 @end example
17858 @node Results of Evaluation
17859 @section Results of Evaluation
17861 @cindex code block, results of evaluation
17862 @cindex source code, results of evaluation
17864 @cindex @samp{results}, header argument
17865 How Org handles results of a code block execution depends on many
17866 header arguments working together.  The primary determinant, however,
17867 is the @samp{results} header argument.  It accepts four classes of options.
17868 Each code block can take only one option per class:
17870 @table @asis
17871 @item collection
17872 For how the results should be collected from the code block;
17874 @item type
17875 For which type of result the code block will return; affects how
17876 Org processes and inserts results in the Org buffer;
17878 @item format
17879 For the result; affects how Org processes and inserts results in
17880 the Org buffer;
17882 @item handling
17883 For processing results after evaluation of the code block;
17884 @end table
17886 @anchor{Collection}
17887 @subheading Collection
17889 Collection options specify the results.  Choose one of the options;
17890 they are mutually exclusive.
17892 @table @asis
17893 @item @samp{value}
17894 Default.  Functional mode.  Org gets the value by wrapping the
17895 code in a function definition in the language of the source
17896 block.  That is why when using @samp{:results value}, code should
17897 execute like a function and return a value.  For languages like
17898 Python, an explicit @code{return} statement is mandatory when using
17899 @samp{:results value}.  Result is the value returned by the last
17900 statement in the code block.
17902 When evaluating the code block in a session (see @ref{Environment of a Code Block}), Org passes the code to an interpreter running as
17903 an interactive Emacs inferior process. Org gets the value from
17904 the source code interpreter's last statement output.  Org has to
17905 use language-specific methods to obtain the value.  For example,
17906 from the variable @code{_} in Python and Ruby, and the value of
17907 @code{.Last.value} in R.
17909 @item @samp{output}
17910 Scripting mode.  Org passes the code to an external process
17911 running the interpreter.  Org returns the contents of the
17912 standard output stream as text results.
17914 When using a session, Org passes the code to the interpreter
17915 running as an interactive Emacs inferior process.  Org
17916 concatenates any text output from the interpreter and returns the
17917 collection as a result.
17919 Note that this collection is not the same as that would be
17920 collected from stdout of a non-interactive interpreter running as
17921 an external process.  Compare for example these two blocks:
17923 @example
17924 #+BEGIN_SRC python :results output
17925   print "hello"
17926   2
17927   print "bye"
17928 #+END_SRC
17930 #+RESULTS:
17931 : hello
17932 : bye
17933 @end example
17935 In the above non-session mode, the ``2'' is not printed; so it does
17936 not appear in results.
17938 @example
17939 #+BEGIN_SRC python :results output :session
17940   print "hello"
17941   2
17942   print "bye"
17943 #+END_SRC
17945 #+RESULTS:
17946 : hello
17947 : 2
17948 : bye
17949 @end example
17951 In the above session, the interactive interpreter receives and
17952 prints ``2''.  Results show that.
17953 @end table
17955 @anchor{Type}
17956 @subheading Type
17958 Type tells what result types to expect from the execution of the code
17959 block.  Choose one of the options; they are mutually exclusive.  The
17960 default behavior is to automatically determine the result type.
17962 @table @asis
17963 @item @samp{table}
17964 @itemx @samp{vector}
17965 Interpret the results as an Org table.  If the result is a single
17966 value, create a table with one row and one column.  Usage
17967 example: @samp{:results value table}.
17969 @cindex @samp{hlines}, header argument
17970 In-between each table row or below the table headings, sometimes
17971 results have horizontal lines, which are also known as ``hlines''.
17972 The @samp{hlines} argument with the default @samp{no} value strips such
17973 lines from the input table.  For most code, this is desirable, or
17974 else those @samp{hline} symbols raise unbound variable errors.
17975 A @samp{yes} accepts such lines, as demonstrated in the following
17976 example.
17978 @example
17979 #+NAME: many-cols
17980 | a | b | c |
17981 |---+---+---|
17982 | d | e | f |
17983 |---+---+---|
17984 | g | h | i |
17986 #+NAME: no-hline
17987 #+BEGIN_SRC python :var tab=many-cols :hlines no
17988   return tab
17989 #+END_SRC
17991 #+RESULTS: no-hline
17992 | a | b | c |
17993 | d | e | f |
17994 | g | h | i |
17996 #+NAME: hlines
17997 #+BEGIN_SRC python :var tab=many-cols :hlines yes
17998   return tab
17999 #+END_SRC
18001 #+RESULTS: hlines
18002 | a | b | c |
18003 |---+---+---|
18004 | d | e | f |
18005 |---+---+---|
18006 | g | h | i |
18007 @end example
18009 @item @samp{list}
18010 Interpret the results as an Org list.  If the result is a single
18011 value, create a list of one element.
18013 @item @samp{scalar}
18014 @itemx @samp{verbatim}
18015 Interpret literally and insert as quoted text.  Do not create
18016 a table.  Usage example: @samp{:results value verbatim}.
18018 @item @samp{file}
18019 Interpret as a filename.  Save the results of execution of the
18020 code block to that file, then insert a link to it.  You can
18021 control both the filename and the description associated to the
18022 link.
18024 @cindex @samp{file}, header argument
18025 @cindex @samp{output-dir}, header argument
18026 Org first tries to generate the filename from the value of the
18027 @samp{file} header argument and the directory specified using the
18028 @samp{output-dir} header arguments.  If @samp{output-dir} is not specified,
18029 Org assumes it is the current directory.
18031 @example
18032 #+BEGIN_SRC asymptote :results value file :file circle.pdf :output-dir img/
18033   size(2cm);
18034   draw(unitcircle);
18035 #+END_SRC
18036 @end example
18038 @cindex @samp{file-ext}, header argument
18039 If @samp{file} is missing, Org generates the base name of the output
18040 file from the name of the code block, and its extension from the
18041 @samp{file-ext} header argument.  In that case, both the name and the
18042 extension are mandatory.
18044 @example
18045 #+name: circle
18046 #+BEGIN_SRC asymptote :results value file :file-ext pdf
18047   size(2cm);
18048   draw(unitcircle);
18049 #+END_SRC
18050 @end example
18052 @cindex @samp{file-desc}, header argument
18053 The @samp{file-desc} header argument defines the description (see
18054 @ref{Link Format}) for the link.  If @samp{file-desc} has no value, Org
18055 uses the generated file name for both the ``link'' and
18056 ``description'' parts of the link.
18057 @end table
18059 @anchor{Format}
18060 @subheading Format
18062 Format pertains to the type of the result returned by the code block.
18063 Choose one of the options; they are mutually exclusive.  The default
18064 follows from the type specified above.
18066 @table @asis
18067 @item @samp{code}
18068 Result enclosed in a code block.  Useful for parsing.  Usage
18069 example: @samp{:results value code}.
18071 @item @samp{drawer}
18072 Result wrapped in a @samp{RESULTS} drawer.  Useful for containing
18073 @samp{raw} or @samp{org} results for later scripting and automated
18074 processing.  Usage example: @samp{:results value drawer}.
18076 @item @samp{html}
18077 Results enclosed in a @samp{BEGIN_EXPORT html} block.  Usage example:
18078 @samp{:results value html}.
18080 @item @samp{latex}
18081 Results enclosed in a @samp{BEGIN_EXPORT latex} block.  Usage example:
18082 @samp{:results value latex}.
18084 @item @samp{link}
18085 @itemx @samp{graphics}
18086 Result is a link to the file specified in @samp{:file} header
18087 argument.  However, unlike plain @samp{:file}, nothing is written to
18088 the disk.  The block is used for its side-effects only, as in the
18089 following example:
18091 @example
18092 #+begin_src shell :results link :file "download.tar.gz"
18093 wget -c "http://example.com/download.tar.gz"
18094 #+end_src
18095 @end example
18097 @item @samp{org}
18098 Results enclosed in a @samp{BEGIN_SRC org} block.  For comma-escape,
18099 either @kbd{@key{TAB}} in the block, or export the file.  Usage
18100 example: @samp{:results value org}.
18102 @item @samp{pp}
18103 Result converted to pretty-print source code.  Enclosed in a code
18104 block.  Languages supported: Emacs Lisp, Python, and Ruby.  Usage
18105 example: @samp{:results value pp}.
18107 @item @samp{raw}
18108 Interpreted as raw Org mode.  Inserted directly into the buffer.
18109 Aligned if it is a table.  Usage example: @samp{:results value raw}.
18110 @end table
18112 @anchor{Handling}
18113 @subheading Handling
18115 Handling options after collecting the results.
18117 @table @asis
18118 @item @samp{silent}
18119 Do not insert results in the Org mode buffer, but echo them in
18120 the minibuffer.  Usage example: @samp{:results output silent}.
18122 @item @samp{replace}
18123 Default.  Insert results in the Org buffer.  Remove previous
18124 results.  Usage example: @samp{:results output replace}.
18126 @item @samp{append}
18127 Append results to the Org buffer.  Latest results are at the
18128 bottom.  Does not remove previous results.  Usage example:
18129 @samp{:results output append}.
18131 @item @samp{prepend}
18132 Prepend results to the Org buffer.  Latest results are at the
18133 top.  Does not remove previous results.  Usage example: @samp{:results
18134      output prepend}.
18135 @end table
18137 @anchor{Post-processing}
18138 @subheading Post-processing
18140 @cindex @samp{post}, header argument
18141 @cindex @samp{*this*}, in @samp{post} header argument
18142 The @samp{post} header argument is for post-processing results from block
18143 evaluation.  When @samp{post} has any value, Org binds the results to
18144 @code{*this*} variable for easy passing to @samp{var} header argument
18145 specifications (see @ref{Environment of a Code Block}).  That makes results
18146 available to other code blocks, or even for direct Emacs Lisp code
18147 execution.
18149 The following two examples illustrate @samp{post} header argument in
18150 action.  The first one shows how to attach an @samp{ATTR_LATEX} keyword
18151 using @samp{post}.
18153 @example
18154 #+NAME: attr_wrap
18155 #+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output
18156   echo "#+ATTR_LATEX: :width $width"
18157   echo "$data"
18158 #+END_SRC
18160 #+HEADER: :file /tmp/it.png
18161 #+BEGIN_SRC dot :post attr_wrap(width="5cm", data=*this*) :results drawer
18162   digraph@{
18163           a -> b;
18164           b -> c;
18165           c -> a;
18166   @}
18167 #+end_src
18169 #+RESULTS:
18170 :RESULTS:
18171 #+ATTR_LATEX :width 5cm
18172 [[file:/tmp/it.png]]
18173 :END:
18174 @end example
18176 The second example shows use of @samp{colnames} header argument in @samp{post}
18177 to pass data between code blocks.
18179 @example
18180 #+NAME: round-tbl
18181 #+BEGIN_SRC emacs-lisp :var tbl="" fmt="%.3f"
18182   (mapcar (lambda (row)
18183             (mapcar (lambda (cell)
18184                       (if (numberp cell)
18185                           (format fmt cell)
18186                         cell))
18187                     row))
18188           tbl)
18189 #+end_src
18191 #+BEGIN_SRC R :colnames yes :post round-tbl[:colnames yes](*this*)
18192   set.seed(42)
18193   data.frame(foo=rnorm(1))
18194 #+END_SRC
18196 #+RESULTS:
18197 |   foo |
18198 |-------|
18199 | 1.371 |
18200 @end example
18202 @node Exporting Code Blocks
18203 @section Exporting Code Blocks
18205 @cindex code block, exporting
18206 @cindex source code, exporting
18208 It is possible to export the @emph{code} of code blocks, the @emph{results} of
18209 code block evaluation, @emph{both} the code and the results of code block
18210 evaluation, or @emph{none}.  Org defaults to exporting @emph{code} for most
18211 languages.  For some languages, such as ditaa, Org defaults to
18212 @emph{results}.  To export just the body of code blocks, see @ref{Literal Examples}.  To selectively export sub-trees of an Org document, see
18213 @ref{Exporting}.
18215 @cindex @samp{export}, header argument
18216 The @samp{exports} header argument is to specify if that part of the Org
18217 file is exported to, say, HTML or @LaTeX{} formats.
18219 @table @asis
18220 @item @samp{code}
18221 The default.  The body of code is included into the exported
18222 file.  Example: @samp{:exports code}.
18224 @item @samp{results}
18225 The results of evaluation of the code is included in the exported
18226 file.  Example: @samp{:exports results}.
18228 @item @samp{both}
18229 Both the code and results of evaluation are included in the
18230 exported file.  Example: @samp{:exports both}.
18232 @item @samp{none}
18233 Neither the code nor the results of evaluation is included in the
18234 exported file.  Whether the code is evaluated at all depends on
18235 other options.  Example: @samp{:exports none}.
18236 @end table
18238 @vindex org-export-use-babel
18239 To stop Org from evaluating code blocks to speed exports, use the
18240 header argument @samp{:eval never-export} (see @ref{Evaluating Code Blocks}).
18241 To stop Org from evaluating code blocks for greater security, set the
18242 @code{org-export-use-babel} variable to @code{nil}, but understand that header
18243 arguments will have no effect.
18245 Turning off evaluation comes in handy when batch processing.  For
18246 example, markup languages for wikis, which have a high risk of
18247 untrusted code.  Stopping code block evaluation also stops evaluation
18248 of all header arguments of the code block.  This may not be desirable
18249 in some circumstances.  So during export, to allow evaluation of just
18250 the header arguments but not any code evaluation in the source block,
18251 set @samp{:eval never-export} (see @ref{Evaluating Code Blocks}).
18253 Org never evaluates code blocks in commented sub-trees when exporting
18254 (see @ref{Comment Lines}).  On the other hand, Org does evaluate code
18255 blocks in sub-trees excluded from export (see @ref{Export Settings}).
18257 @node Extracting Source Code
18258 @section Extracting Source Code
18260 @cindex tangling
18261 @cindex source code, extracting
18262 @cindex code block, extracting source code
18264 Extracting source code from code blocks is a basic task in literate
18265 programming.  Org has features to make this easy.  In literate
18266 programming parlance, documents on creation are @emph{woven} with code and
18267 documentation, and on export, the code is tangled for execution by
18268 a computer.  Org facilitates weaving and tangling for producing,
18269 maintaining, sharing, and exporting literate programming documents.
18270 Org provides extensive customization options for extracting source
18271 code.
18273 When Org tangles code blocks, it expands, merges, and transforms them.
18274 Then Org recomposes them into one or more separate files, as
18275 configured through the options.  During this tangling process, Org
18276 expands variables in the source code, and resolves any Noweb style
18277 references (see @ref{Noweb Reference Syntax}).
18279 @anchor{Header arguments}
18280 @subheading Header arguments
18282 @cindex @samp{tangle}, header argument
18283 The @samp{tangle} header argument specifies if the code block is exported
18284 to source file(s).
18286 @table @asis
18287 @item @samp{yes}
18288 Export the code block to source file.  The file name for the
18289 source file is derived from the name of the Org file, and the
18290 file extension is derived from the source code language
18291 identifier.  Example: @samp{:tangle yes}.
18293 @item @samp{no}
18294 The default.  Do not extract the code in a source code file.
18295 Example: @samp{:tangle no}.
18297 @item @var{FILENAME}
18298 Export the code block to source file whose file name is derived
18299 from any string passed to the @samp{tangle} header argument.  Org
18300 derives the file name as being relative to the directory of the
18301 Org file's location.  Example: @samp{:tangle FILENAME}.
18302 @end table
18304 @cindex @samp{mkdirp}, header argument
18305 The @samp{mkdirp} header argument creates parent directories for tangled
18306 files if the directory does not exist.  @samp{yes} enables directory
18307 creation and @samp{no} inhibits directory creation.
18309 @cindex @samp{comments}, header argument
18310 The @samp{comments} header argument controls inserting comments into
18311 tangled files.  These are above and beyond whatever comments may
18312 already exist in the code block.
18314 @table @asis
18315 @item @samp{no}
18316 The default.  Do not insert any extra comments during tangling.
18318 @item @samp{link}
18319 Wrap the code block in comments.  Include links pointing back to
18320 the place in the Org file from where the code was tangled.
18322 @item @samp{yes}
18323 Kept for backward compatibility; same as @samp{link}.
18325 @item @samp{org}
18326 Nearest headline text from Org file is inserted as comment.  The
18327 exact text that is inserted is picked from the leading context of
18328 the source block.
18330 @item @samp{both}
18331 Includes both @samp{link} and @samp{org} options.
18333 @item @samp{noweb}
18334 Includes @samp{link} option, expands Noweb references (see @ref{Noweb Reference Syntax}), and wraps them in link comments inside the
18335 body of the code block.
18336 @end table
18338 @cindex @samp{padline}, header argument
18339 The @samp{padline} header argument controls insertion of newlines to pad
18340 source code in the tangled file.
18342 @table @asis
18343 @item @samp{yes}
18344 Default.  Insert a newline before and after each code block in
18345 the tangled file.
18347 @item @samp{no}
18348 Do not insert newlines to pad the tangled code blocks.
18349 @end table
18351 @cindex @samp{shebang}, header argument
18352 The @samp{shebang} header argument can turn results into executable script
18353 files.  By setting it to a string value---for example, @samp{:shebang
18354 "#!/bin/bash"}---Org inserts that string as the first line of the
18355 tangled file that the code block is extracted to.  Org then turns on
18356 the tangled file's executable permission.
18358 @cindex @samp{no-expand}, header argument
18359 By default Org expands code blocks during tangling.  The @samp{no-expand}
18360 header argument turns off such expansions.  Note that one side-effect
18361 of expansion by @code{org-babel-expand-src-block} also assigns values (see
18362 @ref{Environment of a Code Block}) to variables.  Expansions also replace
18363 Noweb references with their targets (see @ref{Noweb Reference Syntax}).
18364 Some of these expansions may cause premature assignment, hence this
18365 option.  This option makes a difference only for tangling.  It has no
18366 effect when exporting since code blocks for execution have to be
18367 expanded anyway.
18369 @anchor{Functions}
18370 @subheading Functions
18372 @table @asis
18373 @item @code{org-babel-tangle}
18374 @findex org-babel-tangle
18375 @kindex C-c C-v t
18376 Tangle the current file.  Bound to @kbd{C-c C-v t}.
18378 With prefix argument only tangle the current code block.
18380 @item @code{org-babel-tangle-file}
18381 @findex org-babel-tangle-file
18382 @kindex C-c C-v f
18383 Choose a file to tangle.  Bound to @kbd{C-c C-v f}.
18384 @end table
18386 @anchor{Hooks (1)}
18387 @subheading Hooks
18389 @table @asis
18390 @item @code{org-babel-post-tangle-hook}
18391 @vindex org-babel-post-tangle-hook
18392 This hook is run from within code files tangled by
18393 @code{org-babel-tangle}, making it suitable for post-processing,
18394 compilation, and evaluation of code in the tangled files.
18395 @end table
18397 @anchor{Jumping between code and Org}
18398 @subheading Jumping between code and Org
18400 @findex org-babel-tangle-jump-to-org
18401 Debuggers normally link errors and messages back to the source code.
18402 But for tangled files, we want to link back to the Org file, not to
18403 the tangled source file.  To make this extra jump, Org uses
18404 @code{org-babel-tangle-jump-to-org} function with two additional source
18405 code block header arguments:
18407 @enumerate
18408 @item
18409 Set @samp{padline} to true---this is the default setting.
18410 @item
18411 Set @samp{comments} to @samp{link}, which makes Org insert links to the Org
18412 file.
18413 @end enumerate
18415 @node Languages
18416 @section Languages
18418 @cindex babel, languages
18419 @cindex source code, languages
18420 @cindex code block, languages
18422 Code blocks in the following languages are supported.
18424 @multitable {aaaaaaaaaa} {aaaaaaaaaa} {aaaaaaaaaaaaaa} {aaaaaaaaaa}
18425 @headitem Language
18426 @tab Identifier
18427 @tab Language
18428 @tab Identifier
18429 @item Asymptote
18430 @tab asymptote
18431 @tab Awk
18432 @tab awk
18433 @item C
18434 @tab C
18435 @tab C++
18436 @tab C++
18437 @item Clojure
18438 @tab clojure
18439 @tab CSS
18440 @tab css
18441 @item D
18442 @tab d
18443 @tab ditaa
18444 @tab ditaa
18445 @item Graphviz
18446 @tab dot
18447 @tab Emacs Calc
18448 @tab calc
18449 @item Emacs Lisp
18450 @tab emacs-lisp
18451 @tab Fortran
18452 @tab fortran
18453 @item Gnuplot
18454 @tab gnuplot
18455 @tab Haskell
18456 @tab haskell
18457 @item Java
18458 @tab java
18459 @tab Javascript
18460 @tab js
18461 @item @LaTeX{}
18462 @tab latex
18463 @tab Ledger
18464 @tab ledger
18465 @item Lisp
18466 @tab lisp
18467 @tab Lilypond
18468 @tab lilypond
18469 @item Lua
18470 @tab lua
18471 @tab MATLAB
18472 @tab matlab
18473 @item Mscgen
18474 @tab mscgen
18475 @tab Objective Caml
18476 @tab ocaml
18477 @item Octave
18478 @tab octave
18479 @tab Org mode
18480 @tab org
18481 @item Oz
18482 @tab oz
18483 @tab Perl
18484 @tab perl
18485 @item Plantuml
18486 @tab plantuml
18487 @tab Processing.js
18488 @tab processing
18489 @item Python
18490 @tab python
18491 @tab R
18492 @tab R
18493 @item Ruby
18494 @tab ruby
18495 @tab Sass
18496 @tab sass
18497 @item Scheme
18498 @tab scheme
18499 @tab GNU Screen
18500 @tab screen
18501 @item Sed
18502 @tab sed
18503 @tab shell
18504 @tab sh
18505 @item SQL
18506 @tab sql
18507 @tab SQLite
18508 @tab sqlite
18509 @item Vala
18510 @tab vala
18511 @tab 
18512 @tab 
18513 @end multitable
18515 Additional documentation for some languages is at
18516 @uref{https://orgmode.org/worg/org-contrib/babel/languages.html}.
18518 @vindex org-babel-load-languages
18519 By default, only Emacs Lisp is enabled for evaluation.  To enable or
18520 disable other languages, customize the @code{org-babel-load-languages}
18521 variable either through the Emacs customization interface, or by
18522 adding code to the init file as shown next.
18524 In this example, evaluation is disabled for Emacs Lisp, and enabled
18525 for R.
18527 @lisp
18528 (org-babel-do-load-languages
18529  'org-babel-load-languages
18530  '((emacs-lisp . nil)
18531    (R . t)))
18532 @end lisp
18534 Note that this is not the only way to enable a language.  Org also
18535 enables languages when loaded with @code{require} statement.  For example,
18536 the following enables execution of Clojure code blocks:
18538 @lisp
18539 (require 'ob-clojure)
18540 @end lisp
18542 @node Editing Source Code
18543 @section Editing Source Code
18545 @cindex code block, editing
18546 @cindex source code, editing
18548 @kindex C-c '
18549 Use @kbd{C-c '} to edit the current code block.  It opens a new
18550 major-mode edit buffer containing the body of the source code block,
18551 ready for any edits.  Use @kbd{C-c '} again to close the buffer
18552 and return to the Org buffer.
18554 @kindex C-x C-s
18555 @vindex org-edit-src-auto-save-idle-delay
18556 @cindex auto-save, in code block editing
18557 @kbd{C-x C-s} saves the buffer and updates the contents of the
18558 Org buffer.  Set @code{org-edit-src-auto-save-idle-delay} to save the base
18559 buffer after a certain idle delay time.  Set
18560 @code{org-edit-src-turn-on-auto-save} to auto-save this buffer into
18561 a separate file using Auto-save mode.
18563 While editing the source code in the major mode, the Org Src minor
18564 mode remains active.  It provides these customization variables as
18565 described below.  For even more variables, look in the customization
18566 group @code{org-edit-structure}.
18568 @table @asis
18569 @item @code{org-src-lang-modes}
18570 @vindex org-src-lang-modes
18571 If an Emacs major-mode named @code{<LANG>-mode} exists, where
18572 @var{<LANG>} is the language identifier from code block's
18573 header line, then the edit buffer uses that major mode.  Use this
18574 variable to arbitrarily map language identifiers to major modes.
18576 @item @code{org-src-window-setup}
18577 @vindex org-src-window-setup
18578 For specifying Emacs window arrangement when the new edit buffer
18579 is created.
18581 @item @code{org-src-preserve-indentation}
18582 @cindex indentation, in code blocks
18583 @vindex org-src-preserve-indentation
18584 Default is @code{nil}.  Source code is indented.  This indentation
18585 applies during export or tangling, and depending on the context,
18586 may alter leading spaces and tabs.  When non-@code{nil}, source code
18587 is aligned with the leftmost column.  No lines are modified
18588 during export or tangling, which is very useful for white-space
18589 sensitive languages, such as Python.
18591 @item @code{org-src-ask-before-returning-to-edit-buffer}
18592 @vindex org-src-ask-before-returning-to-edit-buffer
18593 When @code{nil}, Org returns to the edit buffer without further
18594 prompts.  The default prompts for a confirmation.
18595 @end table
18597 @vindex org-src-fontify-natively
18598 @vindex org-src-block-faces
18599 Set @code{org-src-fontify-natively} to non-@code{nil} to turn on native code
18600 fontification in the @emph{Org} buffer.  Fontification of code blocks can
18601 give visual separation of text and code on the display page.  To
18602 further customize the appearance of @code{org-block} for specific
18603 languages, customize @code{org-src-block-faces}.  The following example
18604 shades the background of regular blocks, and colors source blocks only
18605 for Python and Emacs Lisp languages.
18607 @lisp
18608 (require 'color)
18609 (set-face-attribute 'org-block nil :background
18610                     (color-darken-name
18611                      (face-attribute 'default :background) 3))
18613 (setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF"))
18614                             ("python" (:background "#E5FFB8"))))
18615 @end lisp
18617 @node Noweb Reference Syntax
18618 @section Noweb Reference Syntax
18620 @cindex code block, Noweb reference
18621 @cindex syntax, Noweb
18622 @cindex source code, Noweb reference
18624 Org supports named blocks in Noweb@footnote{For Noweb literate programming details, see
18625 @uref{http://www.cs.tufts.edu/~nr/noweb/}.} style syntax:
18627 @example
18628 <<CODE-BLOCK-ID>>
18629 @end example
18631 Org can replace the construct with the source code, or the results of
18632 evaluation, of the code block identified as @var{CODE-BLOCK-ID}.
18634 @cindex @samp{noweb}, header argument
18635 The @samp{noweb} header argument controls expansion of Noweb syntax
18636 references.  Expansions occur when source code blocks are evaluated,
18637 tangled, or exported.
18639 @table @asis
18640 @item @samp{no}
18641 Default.  No expansion of Noweb syntax references in the body of
18642 the code when evaluating, tangling, or exporting.
18644 @item @samp{yes}
18645 Expansion of Noweb syntax references in the body of the code
18646 block when evaluating, tangling, or exporting.
18648 @item @samp{tangle}
18649 Expansion of Noweb syntax references in the body of the code
18650 block when tangling.  No expansion when evaluating or exporting.
18652 @item @samp{no-export}
18653 Expansion of Noweb syntax references in the body of the code
18654 block when evaluating or tangling.  No expansion when exporting.
18656 @item @samp{strip-export}
18657 Expansion of Noweb syntax references in the body of the code
18658 block when expanding prior to evaluating or tangling.  Removes
18659 Noweb syntax references when exporting.
18661 @item @samp{eval}
18662 Expansion of Noweb syntax references in the body of the code
18663 block only before evaluating.
18664 @end table
18666 In the following example,
18668 @example
18669 #+NAME: initialization
18670 #+BEGIN_SRC emacs-lisp
18671   (setq sentence "Never a foot too far, even.")
18672 #+END_SRC
18674 #+BEGIN_SRC emacs-lisp :noweb yes
18675   <<initialization>>
18676   (reverse sentence)
18677 #+END_SRC
18678 @end example
18680 @noindent
18681 the second code block is expanded as
18683 @example
18684 #+BEGIN_SRC emacs-lisp :noweb yes
18685   (setq sentence "Never a foot too far, even.")
18686   (reverse sentence)
18687 #+END_SRC
18688 @end example
18690 Noweb insertions honor prefix characters that appear before the Noweb
18691 syntax reference.  This behavior is illustrated in the following
18692 example.  Because the @samp{<<example>>} Noweb reference appears behind the
18693 SQL comment syntax, each line of the expanded Noweb reference is
18694 commented.  With:
18696 @example
18697 #+NAME: example
18698 #+BEGIN_SRC text
18699   this is the
18700   multi-line body of example
18701 #+END_SRC
18702 @end example
18704 @noindent
18705 this code block:
18707 @example
18708 #+BEGIN_SRC sql :noweb yes
18709  ---<<example>>
18710 #+END_SRC
18711 @end example
18713 @noindent
18714 expands to:
18716 @example
18717 #+BEGIN_SRC sql :noweb yes
18718  ---this is the
18719  ---multi-line body of example
18720 #+END_SRC
18721 @end example
18723 Since this change does not affect Noweb replacement text without
18724 newlines in them, inline Noweb references are acceptable.
18726 This feature can also be used for management of indentation in
18727 exported code snippets.  With:
18729 @example
18730 #+NAME: if-true
18731 #+BEGIN_SRC python :exports none
18732   print('do things when true')
18733 #+end_src
18735 #+name: if-false
18736 #+begin_src python :exports none
18737   print('do things when false')
18738 #+end_src
18739 @end example
18741 @noindent
18742 this code block:
18744 @example
18745 #+begin_src python :noweb yes :results output
18746   if true:
18747       <<if-true>>
18748   else:
18749       <<if-false>>
18750 #+end_src
18751 @end example
18753 @noindent
18754 expands to:
18756 @example
18757 if true:
18758     print('do things when true')
18759 else:
18760     print('do things when false')
18761 @end example
18763 @cindex @samp{noweb-ref}, header argument
18764 When expanding Noweb style references, Org concatenates code blocks by
18765 matching the reference name to either the code block name or, if none
18766 is found, to the @samp{noweb-ref} header argument.
18768 For simple concatenation, set this @samp{noweb-ref} header argument at the
18769 sub-tree or file level.  In the example Org file shown next, the body
18770 of the source code in each block is extracted for concatenation to
18771 a pure code file when tangled.
18773 @example
18774 #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
18775   <<fullest-disk>>
18776 #+END_SRC
18777 * the mount point of the fullest disk
18778   :PROPERTIES:
18779   :header-args: :noweb-ref fullest-disk
18780   :END:
18782 ** query all mounted disks
18783 #+BEGIN_SRC sh
18784   df \
18785 #+END_SRC
18787 ** strip the header row
18788 #+BEGIN_SRC sh
18789   |sed '1d' \
18790 #+END_SRC
18792 ** output mount point of fullest disk
18793 #+BEGIN_SRC sh
18794   |awk '@{if (u < +$5) @{u = +$5; m = $6@}@} END @{print m@}'
18795 #+END_SRC
18796 @end example
18798 @cindex @samp{noweb-sep}, header argument
18799 By default a newline separates each noweb reference concatenation.  To
18800 change this newline separator, edit the @samp{noweb-sep} header argument.
18802 Eventually, Org can include the results of a code block rather than
18803 its body.  To that effect, append parentheses, possibly including
18804 arguments, to the code block name, as shown below.
18806 @example
18807 <<code-block-name(optional arguments)>>
18808 @end example
18810 Note that when using the above approach to a code block's results, the
18811 code block name set by @samp{NAME} keyword is required; the reference set
18812 by @samp{noweb-ref} does not work in that case.
18814 Here is an example that demonstrates how the exported content changes
18815 when Noweb style references are used with parentheses versus without.
18816 With:
18818 @example
18819 #+NAME: some-code
18820 #+BEGIN_SRC python :var num=0 :results output :exports none
18821   print(num*10)
18822 #+END_SRC
18823 @end example
18825 @noindent
18826 this code block:
18828 @example
18829 #+BEGIN_SRC text :noweb yes
18830   <<some-code>>
18831 #+END_SRC
18832 @end example
18834 @noindent
18835 expands to:
18837 @example
18838 print(num*10)
18839 @end example
18841 Below, a similar Noweb style reference is used, but with parentheses,
18842 while setting a variable @samp{num} to 10:
18844 @example
18845 #+BEGIN_SRC text :noweb yes
18846   <<some-code(num=10)>>
18847 #+END_SRC
18848 @end example
18850 @noindent
18851 Note that now the expansion contains the results of the code block
18852 @samp{some-code}, not the code block itself:
18854 @example
18856 @end example
18858 @node Library of Babel
18859 @section Library of Babel
18861 @cindex babel, library of
18862 @cindex source code, library
18863 @cindex code block, library
18865 The ``Library of Babel'' is a collection of code blocks.  Like
18866 a function library, these code blocks can be called from other Org
18867 files.  A collection of useful code blocks is available on @uref{https://orgmode.org/worg/library-of-babel.html, Worg}.  For
18868 remote code block evaluation syntax, see @ref{Evaluating Code Blocks}.
18870 @kindex C-c C-v i
18871 @findex org-babel-lob-ingest
18872 For any user to add code to the library, first save the code in
18873 regular code blocks of an Org file, and then load the Org file with
18874 @code{org-babel-lob-ingest}, which is bound to @kbd{C-c C-v i}.
18876 @node Key bindings and Useful Functions
18877 @section Key bindings and Useful Functions
18879 @cindex code block, key bindings
18881 Many common Org mode key sequences are re-bound depending on
18882 the context.
18884 Active key bindings in code blocks:
18886 @kindex C-c C-c
18887 @findex org-babel-execute-src-block
18888 @kindex C-c C-o
18889 @findex org-babel-open-src-block-result
18890 @kindex M-UP
18891 @findex org-babel-load-in-session
18892 @kindex M-DOWN
18893 @findex org-babel-pop-to-session
18894 @multitable @columnfractions 0.2 0.55
18895 @headitem Key binding
18896 @tab Function
18897 @item @kbd{C-c C-c}
18898 @tab @code{org-babel-execute-src-block}
18899 @item @kbd{C-c C-o}
18900 @tab @code{org-babel-open-src-block-result}
18901 @item @kbd{M-@key{UP}}
18902 @tab @code{org-babel-load-in-session}
18903 @item @kbd{M-@key{DOWN}}
18904 @tab @code{org-babel-pop-to-session}
18905 @end multitable
18907 Active key bindings in Org mode buffer:
18909 @kindex C-c C-v p
18910 @kindex C-c C-v C-p
18911 @kindex C-c C-v n
18912 @kindex C-c C-v C-n
18913 @kindex C-c C-v e
18914 @kindex C-c C-v C-e
18915 @kindex C-c C-v o
18916 @kindex C-c C-v C-o
18917 @kindex C-c C-v v
18918 @kindex C-c C-v C-v
18919 @kindex C-c C-v u
18920 @kindex C-c C-v C-u
18921 @kindex C-c C-v g
18922 @kindex C-c C-v C-g
18923 @kindex C-c C-v r
18924 @kindex C-c C-v C-r
18925 @kindex C-c C-v b
18926 @kindex C-c C-v C-b
18927 @kindex C-c C-v s
18928 @kindex C-c C-v C-s
18929 @kindex C-c C-v d
18930 @kindex C-c C-v C-d
18931 @kindex C-c C-v t
18932 @kindex C-c C-v C-t
18933 @kindex C-c C-v f
18934 @kindex C-c C-v C-f
18935 @kindex C-c C-v c
18936 @kindex C-c C-v C-c
18937 @kindex C-c C-v j
18938 @kindex C-c C-v C-j
18939 @kindex C-c C-v l
18940 @kindex C-c C-v C-l
18941 @kindex C-c C-v i
18942 @kindex C-c C-v C-i
18943 @kindex C-c C-v I
18944 @kindex C-c C-v C-I
18945 @kindex C-c C-v z
18946 @kindex C-c C-v C-z
18947 @kindex C-c C-v a
18948 @kindex C-c C-v C-a
18949 @kindex C-c C-v h
18950 @kindex C-c C-v C-h
18951 @kindex C-c C-v x
18952 @kindex C-c C-v C-x
18953 @findex org-babel-previous-src-block
18954 @findex org-babel-next-src-block
18955 @findex org-babel-execute-maybe
18956 @findex org-babel-open-src-block-result
18957 @findex org-babel-expand-src-block
18958 @findex org-babel-goto-src-block-head
18959 @findex org-babel-goto-named-src-block
18960 @findex org-babel-goto-named-result
18961 @findex org-babel-execute-buffer
18962 @findex org-babel-execute-subtree
18963 @findex org-babel-demarcate-block
18964 @findex org-babel-tangle
18965 @findex org-babel-tangle-file
18966 @findex org-babel-check-src-block
18967 @findex org-babel-insert-header-arg
18968 @findex org-babel-load-in-session
18969 @findex org-babel-lob-ingest
18970 @findex org-babel-view-src-block-info
18971 @findex org-babel-switch-to-session-with-code
18972 @findex org-babel-sha1-hash
18973 @findex org-babel-describe-bindings
18974 @findex org-babel-do-key-sequence-in-edit-buffer
18975 @multitable @columnfractions 0.45 0.55
18976 @headitem Key binding
18977 @tab Function
18978 @item @kbd{C-c C-v p} or @kbd{C-c C-v C-p}
18979 @tab @code{org-babel-previous-src-block}
18980 @item @kbd{C-c C-v n} or @kbd{C-c C-v C-n}
18981 @tab @code{org-babel-next-src-block}
18982 @item @kbd{C-c C-v e} or @kbd{C-c C-v C-e}
18983 @tab @code{org-babel-execute-maybe}
18984 @item @kbd{C-c C-v o} or @kbd{C-c C-v C-o}
18985 @tab @code{org-babel-open-src-block-result}
18986 @item @kbd{C-c C-v v} or @kbd{C-c C-v C-v}
18987 @tab @code{org-babel-expand-src-block}
18988 @item @kbd{C-c C-v u} or @kbd{C-c C-v C-u}
18989 @tab @code{org-babel-goto-src-block-head}
18990 @item @kbd{C-c C-v g} or @kbd{C-c C-v C-g}
18991 @tab @code{org-babel-goto-named-src-block}
18992 @item @kbd{C-c C-v r} or @kbd{C-c C-v C-r}
18993 @tab @code{org-babel-goto-named-result}
18994 @item @kbd{C-c C-v b} or @kbd{C-c C-v C-b}
18995 @tab @code{org-babel-execute-buffer}
18996 @item @kbd{C-c C-v s} or @kbd{C-c C-v C-s}
18997 @tab @code{org-babel-execute-subtree}
18998 @item @kbd{C-c C-v d} or @kbd{C-c C-v C-d}
18999 @tab @code{org-babel-demarcate-block}
19000 @item @kbd{C-c C-v t} or @kbd{C-c C-v C-t}
19001 @tab @code{org-babel-tangle}
19002 @item @kbd{C-c C-v f} or @kbd{C-c C-v C-f}
19003 @tab @code{org-babel-tangle-file}
19004 @item @kbd{C-c C-v c} or @kbd{C-c C-v C-c}
19005 @tab @code{org-babel-check-src-block}
19006 @item @kbd{C-c C-v j} or @kbd{C-c C-v C-j}
19007 @tab @code{org-babel-insert-header-arg}
19008 @item @kbd{C-c C-v l} or @kbd{C-c C-v C-l}
19009 @tab @code{org-babel-load-in-session}
19010 @item @kbd{C-c C-v i} or @kbd{C-c C-v C-i}
19011 @tab @code{org-babel-lob-ingest}
19012 @item @kbd{C-c C-v I} or @kbd{C-c C-v C-I}
19013 @tab @code{org-babel-view-src-block-info}
19014 @item @kbd{C-c C-v z} or @kbd{C-c C-v C-z}
19015 @tab @code{org-babel-switch-to-session-with-code}
19016 @item @kbd{C-c C-v a} or @kbd{C-c C-v C-a}
19017 @tab @code{org-babel-sha1-hash}
19018 @item @kbd{C-c C-v h} or @kbd{C-c C-v C-h}
19019 @tab @code{org-babel-describe-bindings}
19020 @item @kbd{C-c C-v x} or @kbd{C-c C-v C-x}
19021 @tab @code{org-babel-do-key-sequence-in-edit-buffer}
19022 @end multitable
19024 @node Batch Execution
19025 @section Batch Execution
19027 @cindex code block, batch execution
19028 @cindex source code, batch execution
19030 Org mode features, including working with source code facilities can
19031 be invoked from the command line.  This enables building shell scripts
19032 for batch processing, running automated system tasks, and expanding
19033 Org mode's usefulness.
19035 The sample script shows batch processing of multiple files using
19036 @code{org-babel-tangle}.
19038 @example
19039 #!/bin/sh
19040 # Tangle files with Org mode
19042 emacs -Q --batch --eval "
19043     (progn
19044       (require 'ob-tangle)
19045       (dolist (file command-line-args-left)
19046         (with-current-buffer (find-file-noselect file)
19047           (org-babel-tangle))))
19048   " "$@@"
19049 @end example
19051 @node Miscellaneous
19052 @chapter Miscellaneous
19054 @menu
19055 * Completion::                   M-@key{TAB} guesses completions.
19056 * Structure Templates::          Quick insertion of structural elements.
19057 * Speed Keys::                   Electric commands at the beginning of a headline.
19058 * Code Evaluation Security::     Org files evaluate in-line code.
19059 * Customization::                Adapting Org to your taste.
19060 * In-buffer Settings::           Overview of keywords.
19061 * The Very Busy @kbd{C-c C-c} Key:: When in doubt, press @kbd{C-c C-c}.
19062 * Clean View::                   Getting rid of leading stars in the outline.
19063 * TTY Keys::                     Using Org on a tty.
19064 * Interaction::                  With other Emacs packages.
19065 * Org Crypt::                    Encrypting Org files.
19066 @end menu
19068 @node Completion
19069 @section Completion
19071 @cindex completion, of @TeX{} symbols
19072 @cindex completion, of TODO keywords
19073 @cindex completion, of dictionary words
19074 @cindex completion, of option keywords
19075 @cindex completion, of tags
19076 @cindex completion, of property keys
19077 @cindex completion, of link abbreviations
19078 @cindex @TeX{} symbol completion
19079 @cindex TODO keywords completion
19080 @cindex dictionary word completion
19081 @cindex option keyword completion
19082 @cindex tag completion
19083 @cindex link abbreviations, completion of
19085 Org has in-buffer completions.  Unlike minibuffer completions, which
19086 are useful for quick command interactions, Org's in-buffer completions
19087 are more suitable for content creation in Org documents.  Type one or
19088 more letters and invoke the hot key to complete the text in-place.
19089 Depending on the context and the keys, Org offers different types of
19090 completions.  No minibuffer is involved.  Such mode-specific hot keys
19091 have become an integral part of Emacs and Org provides several
19092 shortcuts.
19094 @table @asis
19095 @item @kbd{M-@key{TAB}}
19096 @kindex M-TAB
19098 Complete word at point.
19100 @itemize
19101 @item
19102 At the beginning of a headline, complete TODO keywords.
19104 @item
19105 After @samp{\}, complete @TeX{} symbols supported by the exporter.
19107 @item
19108 After @samp{*}, complete headlines in the current buffer so that
19109 they can be used in search links like:
19111 @example
19112 [[*find this headline]]
19113 @end example
19115 @item
19116 After @samp{:} in a headline, complete tags.  Org deduces the list
19117 of tags from the @samp{TAGS} in-buffer option (see @ref{Setting Tags}),
19118 the variable @code{org-tag-alist}, or from all tags used in the
19119 current buffer.
19121 @item
19122 After @samp{:} and not in a headline, complete property keys.  The
19123 list of keys is constructed dynamically from all keys used in
19124 the current buffer.
19126 @item
19127 After @samp{[}, complete link abbreviations (see @ref{Link Abbreviations}).
19129 @item
19130 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
19131 file-specific @samp{OPTIONS}.  After option keyword is complete,
19132 pressing @kbd{M-@key{TAB}} again inserts example settings for
19133 this keyword.
19135 @item
19136 After @samp{STARTUP} keyword, complete startup items.
19138 @item
19139 When point is anywhere else, complete dictionary words using
19140 Ispell.
19141 @end itemize
19142 @end table
19144 @node Structure Templates
19145 @section Structure Templates
19147 @cindex template insertion
19148 @cindex insertion, of templates
19150 With just a few keystrokes, it is possible to insert empty structural
19151 blocks, such as @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}, or to wrap existing
19152 text in such a block.
19154 @table @asis
19155 @item @kbd{C-c C-,} (@code{org-insert-structure-template})
19156 @findex org-insert-structure-template
19157 @kindex C-c C-,
19158 Prompt for a type of block structure, and insert the block at
19159 point.  If the region is active, it is wrapped in the block.
19160 First prompts the user for keys, which are used to look up
19161 a structure type from the variable below.  If the key is
19162 @kbd{@key{TAB}}, @kbd{@key{RET}}, or @kbd{@key{SPC}}, the user is
19163 prompted to enter a block type.
19164 @end table
19166 @vindex org-structure-template-alist
19167 Available structure types are defined in
19168 @code{org-structure-template-alist}, see the docstring for adding or
19169 changing values.
19171 @cindex Tempo
19172 @cindex template expansion
19173 @cindex insertion, of templates
19174 @vindex org-tempo-keywords-alist
19175 Org Tempo expands snippets to structures defined in
19176 @code{org-structure-template-alist} and @code{org-tempo-keywords-alist}.  For
19177 example, @kbd{< s @key{TAB}} creates a code block.  Enable it by
19178 customizing @code{org-modules} or add @code{(require 'org-tempo)} to your Emacs
19179 init file@footnote{For more information, please refer to the commentary section
19180 in @samp{org-tempo.el}.}.
19183 @multitable @columnfractions 0.1 0.9
19184 @item @kbd{a}
19185 @tab @samp{#+BEGIN_EXPORT ascii} @dots{} @samp{#+END_EXPORT}
19186 @item @kbd{c}
19187 @tab @samp{#+BEGIN_CENTER} @dots{} @samp{#+END_CENTER}
19188 @item @kbd{C}
19189 @tab @samp{#+BEGIN_COMMENT} @dots{} @samp{#+END_COMMENT}
19190 @item @kbd{e}
19191 @tab @samp{#+BEGIN_EXAMPLE} @dots{} @samp{#+END_EXAMPLE}
19192 @item @kbd{h}
19193 @tab @samp{#+BEGIN_EXPORT html} @dots{} @samp{#+END_EXPORT}
19194 @item @kbd{l}
19195 @tab @samp{#+BEGIN_EXPORT latex} @dots{} @samp{#+END_EXPORT}
19196 @item @kbd{q}
19197 @tab @samp{#+BEGIN_QUOTE} @dots{} @samp{#+END_QUOTE}
19198 @item @kbd{s}
19199 @tab @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}
19200 @item @kbd{v}
19201 @tab @samp{#+BEGIN_VERSE} @dots{} @samp{#+END_VERSE}
19202 @end multitable
19204 @node Speed Keys
19205 @section Speed Keys
19207 @cindex speed keys
19209 Single keystrokes can execute custom commands in an Org file when the
19210 cursor is on a headline.  Without the extra burden of a meta or
19211 modifier key, Speed Keys can speed navigation or execute custom
19212 commands.  Besides faster navigation, Speed Keys may come in handy on
19213 small mobile devices that do not have full keyboards.  Speed Keys may
19214 also work on TTY devices known for their problems when entering Emacs
19215 key chords.
19217 @vindex org-use-speed-commands
19218 By default, Org has Speed Keys disabled.  To activate Speed Keys, set
19219 the variable @code{org-use-speed-commands} to a non-@code{nil} value.  To
19220 trigger a Speed Key, the cursor must be at the beginning of an Org
19221 headline, before any of the stars.
19223 @vindex org-speed-commands-user
19224 @findex org-speed-command-help
19225 Org comes with a pre-defined list of Speed Keys.  To add or modify
19226 Speed Keys, customize the variable, @code{org-speed-commands-user}.  For
19227 more details, see the variable's docstring.  With Speed Keys
19228 activated, @kbd{M-x org-speed-command-help}, or @kbd{?} when
19229 cursor is at the beginning of an Org headline, shows currently active
19230 Speed Keys, including the user-defined ones.
19232 @node Code Evaluation Security
19233 @section Code Evaluation and Security Issues
19235 Unlike plain text, running code comes with risk.  Each @samp{src} code
19236 block, in terms of risk, is equivalent to an executable file.  Org
19237 therefore puts a few confirmation prompts by default.  This is to
19238 alert the casual user from accidentally running untrusted code.
19240 For users who do not run code blocks or write code regularly, Org's
19241 default settings should suffice.  However, some users may want to
19242 tweak the prompts for fewer interruptions.  To weigh the risks of
19243 automatic execution of code blocks, here are some details about code
19244 evaluation.
19246 Org evaluates code in the following circumstances:
19248 @table @asis
19249 @item @emph{Source code blocks}
19250 Org evaluates @samp{src} code blocks in an Org file during export.
19251 Org also evaluates a @samp{src} code block with the @kbd{C-c C-c}
19252 key chord.  Users exporting or running code blocks must load
19253 files only from trusted sources.  Be wary of customizing
19254 variables that remove or alter default security measures.
19256 @defopt org-confirm-babel-evaluate
19257 When @code{t}, Org prompts the user for confirmation before executing
19258 each code block.  When @code{nil}, Org executes code blocks without
19259 prompting the user for confirmation.  When this option is set to
19260 a custom function, Org invokes the function with these two
19261 arguments: the source code language and the body of the code
19262 block.  The custom function must return either a @code{t} or @code{nil},
19263 which determines if the user is prompted.  Each source code
19264 language can be handled separately through this function
19265 argument.
19266 @end defopt
19268 For example, here is how to execute ditaa code blocks without
19269 prompting:
19271 @lisp
19272 (defun my-org-confirm-babel-evaluate (lang body)
19273   (not (string= lang "ditaa")))  ;don't ask for ditaa
19274 (setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
19275 @end lisp
19277 @item @emph{Following @samp{shell} and @samp{elisp} links}
19278 Org has two link types that can directly evaluate code (see
19279 @ref{External Links}).  Because such code is not visible, these links
19280 have a potential risk.  Org therefore prompts the user when it
19281 encounters such links.  The customization variables are:
19283 @defopt org-confirm-shell-link-function
19284 Function that prompts the user before executing a shell link.
19285 @end defopt
19287 @defopt org-confirm-elisp-link-function
19288 Function that prompts the user before executing an Emacs Lisp link.
19289 @end defopt
19291 @item @emph{Formulas in tables}
19292 Formulas in tables (see @ref{The spreadsheet}) are code that is
19293 evaluated either by the Calc interpreter, or by the Emacs Lisp
19294 interpreter.
19295 @end table
19297 @node Customization
19298 @section Customization
19300 @cindex customization
19301 @cindex options, for customization
19302 @cindex variables, for customization
19304 Org has more than 500 variables for customization.  They can be
19305 accessed through the usual @kbd{M-x org-customize} command.  Or
19306 through the Org menu: Org @arrow{} Customization @arrow{} Browse Org Group.
19308 Org also has per-file settings for some variables (see @ref{In-buffer Settings}).
19310 @node In-buffer Settings
19311 @section Summary of In-Buffer Settings
19313 @cindex in-buffer settings
19314 @cindex special keywords
19316 In-buffer settings start with @samp{#+}, followed by a keyword, a colon,
19317 and then a word for each setting.  Org accepts multiple settings on
19318 the same line.  Org also accepts multiple lines for a keyword.  This
19319 manual describes these settings throughout.  A summary follows here.
19321 @cindex refresh set-up
19322 @kbd{C-c C-c} activates any changes to the in-buffer settings.
19323 Closing and reopening the Org file in Emacs also activates the
19324 changes.
19326 @table @asis
19327 @item @samp{#+ARCHIVE: %s_done}
19328 @cindex @samp{ARCHIVE}, keyword
19329 @vindex org-archive-location
19330 Sets the archive location of the agenda file.  The corresponding
19331 variable is @code{org-archive-location}.
19333 @item @samp{#+CATEGORY}
19334 @cindex @samp{CATEGORY}, keyword
19335 Sets the category of the agenda file, which applies to the entire
19336 document.
19338 @item @samp{#+COLUMNS: %25ITEM ...}
19339 @cindex @samp{COLUMNS}, property
19340 Set the default format for columns view.  This format applies
19341 when columns view is invoked in locations where no @samp{COLUMNS}
19342 property applies.
19344 @item @samp{#+CONSTANTS: name1=value1 ...}
19345 @cindex @samp{CONSTANTS}, keyword
19346 @vindex org-table-formula-constants
19347 @vindex org-table-formula
19348 Set file-local values for constants that table formulas can use.
19349 This line sets the local variable
19350 @code{org-table-formula-constants-local}.  The global version of this
19351 variable is @code{org-table-formula-constants}.
19353 @item @samp{#+FILETAGS: :tag1:tag2:tag3:}
19354 @cindex @samp{FILETAGS}, keyword
19355 Set tags that all entries in the file inherit from, including the
19356 top-level entries.
19358 @item @samp{#+LINK: linkword replace}
19359 @cindex @samp{LINK}, keyword
19360 @vindex org-link-abbrev-alist
19361 Each line specifies one abbreviation for one link.  Use multiple
19362 @samp{LINK} keywords for more, see @ref{Link Abbreviations}.  The
19363 corresponding variable is @code{org-link-abbrev-alist}.
19365 @item @samp{#+PRIORITIES: highest lowest default}
19366 @cindex @samp{PRIORITIES}, keyword
19367 @vindex org-highest-priority
19368 @vindex org-lowest-priority
19369 @vindex org-default-priority
19370 This line sets the limits and the default for the priorities.
19371 All three must be either letters A--Z or numbers 0--9.  The
19372 highest priority must have a lower ASCII number than the lowest
19373 priority.
19375 @item @samp{#+PROPERTY: Property_Name Value}
19376 @cindex @samp{PROPERTY}, keyword
19377 This line sets a default inheritance value for entries in the
19378 current buffer, most useful for specifying the allowed values of
19379 a property.
19381 @item @samp{#+SETUPFILE: file}
19382 @cindex @samp{SETUPFILE}, keyword
19383 The setup file or a URL pointing to such file is for additional
19384 in-buffer settings.  Org loads this file and parses it for any
19385 settings in it only when Org opens the main file.  If URL is
19386 specified, the contents are downloaded and stored in a temporary
19387 file cache.  @kbd{C-c C-c} on the settings line parses and
19388 loads the file, and also resets the temporary file cache.  Org
19389 also parses and loads the document during normal exporting
19390 process.  Org parses the contents of this document as if it was
19391 included in the buffer.  It can be another Org file.  To visit
19392 the file---not a URL---use @kbd{C-c '} while the cursor is
19393 on the line with the file name.
19395 @item @samp{#+STARTUP:}
19396 @cindex @samp{STARTUP}, keyword
19397 Startup options Org uses when first visiting a file.
19399 @vindex org-startup-folded
19400 The first set of options deals with the initial visibility of the
19401 outline tree.  The corresponding variable for global default
19402 settings is @code{org-startup-folded} with a default value of @code{t},
19403 which is the same as @code{overview}.
19405 @table @asis
19406 @item @samp{overview}
19407 Top-level headlines only.
19409 @item @samp{content}
19410 All headlines.
19412 @item @samp{showall}
19413 No folding on any entry.
19415 @item @samp{showeverything}
19416 Show even drawer contents.
19417 @end table
19419 @vindex org-startup-indented
19420 Dynamic virtual indentation is controlled by the variable
19421 @code{org-startup-indented}.@footnote{Note that @code{org-indent-mode} also sets the @code{wrap-prefix}
19422 property, such that @code{visual-line-mode} (or purely setting @code{word-wrap})
19423 wraps long lines (including headlines) correctly indented.}
19425 @table @asis
19426 @item @samp{indent}
19427 Start with @code{org-indent-mode} turned on.
19429 @item @samp{noindent}
19430 Start with @code{org-indent-mode} turned off.
19431 @end table
19433 @vindex org-startup-align-all-tables
19434 Aligns tables consistently upon visiting a file.  The corresponding
19435 variable is @code{org-startup-align-all-tables} with @code{nil} as default
19436 value.
19438 @table @asis
19439 @item @samp{align}
19440 Align all tables.
19442 @item @samp{noalign}
19443 Do not align tables on startup.
19444 @end table
19446 @vindex org-startup-shrink-all-tables
19447 Shrink table columns with a width cookie.  The corresponding
19448 variable is @code{org-startup-shrink-all-tables} with @code{nil} as default
19449 value.
19451 @vindex org-startup-with-inline-images
19452 When visiting a file, inline images can be automatically displayed.
19453 The corresponding variable is @code{org-startup-with-inline-images},
19454 with a default value @code{nil} to avoid delays when visiting a file.
19456 @table @asis
19457 @item @samp{inlineimages}
19458 Show inline images.
19460 @item @samp{noinlineimages}
19461 Do not show inline images on startup.
19462 @end table
19464 @vindex org-log-done
19465 @vindex org-log-note-clock-out
19466 @vindex org-log-repeat
19467 Logging the closing and reopening of TODO items and clock
19468 intervals can be configured using these options (see variables
19469 @code{org-log-done}, @code{org-log-note-clock-out}, and @code{org-log-repeat}).
19471 @table @asis
19472 @item @samp{logdone}
19473 Record a timestamp when an item is marked DONE.
19475 @item @samp{lognotedone}
19476 Record timestamp and a note when DONE.
19478 @item @samp{nologdone}
19479 Do not record when items are marked DONE.
19481 @item @samp{logrepeat}
19482 Record a time when reinstating a repeating item.
19484 @item @samp{lognoterepeat}
19485 Record a note when reinstating a repeating item.
19487 @item @samp{nologrepeat}
19488 Do not record when reinstating repeating item.
19490 @item @samp{lognoteclock-out}
19491 Record a note when clocking out.
19493 @item @samp{nolognoteclock-out}
19494 Do not record a note when clocking out.
19496 @item @samp{logreschedule}
19497 Record a timestamp when scheduling time changes.
19499 @item @samp{lognotereschedule}
19500 Record a note when scheduling time changes.
19502 @item @samp{nologreschedule}
19503 Do not record when a scheduling date changes.
19505 @item @samp{logredeadline}
19506 Record a timestamp when deadline changes.
19508 @item @samp{lognoteredeadline}
19509 Record a note when deadline changes.
19511 @item @samp{nologredeadline}
19512 Do not record when a deadline date changes.
19514 @item @samp{logrefile}
19515 Record a timestamp when refiling.
19517 @item @samp{lognoterefile}
19518 Record a note when refiling.
19520 @item @samp{nologrefile}
19521 Do not record when refiling.
19522 @end table
19524 @vindex org-hide-leading-stars
19525 @vindex org-odd-levels-only
19526 Here are the options for hiding leading stars in outline headings,
19527 and for indenting outlines.  The corresponding variables are
19528 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with
19529 a default setting @code{nil} (meaning @samp{showstars} and @samp{oddeven}).
19531 @table @asis
19532 @item @samp{hidestars}
19533 Make all but one of the stars starting a headline invisible.
19535 @item @samp{showstars}
19536 Show all stars starting a headline.
19538 @item @samp{indent}
19539 Virtual indentation according to outline level.
19541 @item @samp{noindent}
19542 No virtual indentation according to outline level.
19544 @item @samp{odd}
19545 Allow only odd outline levels (1, 3, @dots{}).
19547 @item @samp{oddeven}
19548 Allow all outline levels.
19549 @end table
19551 @vindex org-put-time-stamp-overlays
19552 @vindex org-time-stamp-overlay-formats
19553 To turn on custom format overlays over timestamps (variables
19554 @code{org-put-time-stamp-overlays} and @code{org-time-stamp-overlay-formats}),
19555 use:
19557 @table @asis
19558 @item @samp{customtime}
19559 Overlay custom time format.
19560 @end table
19562 @vindex constants-unit-system
19563 The following options influence the table spreadsheet (variable
19564 @code{constants-unit-system}).
19566 @table @asis
19567 @item @samp{constcgs}
19568 @samp{constants.el} should use the c-g-s unit system.
19570 @item @samp{constSI}
19571 @samp{constants.el} should use the SI unit system.
19572 @end table
19574 @vindex org-footnote-define-inline
19575 @vindex org-footnote-auto-label
19576 @vindex org-footnote-auto-adjust
19577 To influence footnote settings, use the following keywords.  The
19578 corresponding variables are @code{org-footnote-define-inline},
19579 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
19581 @table @asis
19582 @item @samp{fninline}
19583 Define footnotes inline.
19585 @item @samp{fnnoinline}
19586 Define footnotes in separate section.
19588 @item @samp{fnlocal}
19589 Define footnotes near first reference, but not inline.
19591 @item @samp{fnprompt}
19592 Prompt for footnote labels.
19594 @item @samp{fnauto}
19595 Create @samp{[fn:1]}-like labels automatically (default).
19597 @item @samp{fnconfirm}
19598 Offer automatic label for editing or confirmation.
19600 @item @samp{fnadjust}
19601 Automatically renumber and sort footnotes.
19603 @item @samp{nofnadjust}
19604 Do not renumber and sort automatically.
19605 @end table
19607 @vindex org-hide-block-startup
19608 To hide blocks on startup, use these keywords.  The corresponding
19609 variable is @code{org-hide-block-startup}.
19611 @table @asis
19612 @item @samp{hideblocks}
19613 Hide all begin/end blocks on startup.
19615 @item @samp{nohideblocks}
19616 Do not hide blocks on startup.
19617 @end table
19619 @vindex org-pretty-entities
19620 The display of entities as UTF-8 characters is governed by the
19621 variable @code{org-pretty-entities} and the keywords
19623 @table @asis
19624 @item @samp{entitiespretty}
19625 Show entities as UTF-8 characters where possible.
19627 @item @samp{entitiesplain}
19628 Leave entities plain.
19629 @end table
19631 @item @samp{#+TAGS: TAG1(c1) TAG2(c2)}
19632 @cindex @samp{TAGS}, keyword
19633 @vindex org-tag-alist
19634 These lines (several such lines are allowed) specify the valid
19635 tags in this file, and (potentially) the corresponding @emph{fast tag
19636 selection} keys.  The corresponding variable is @code{org-tag-alist}.
19638 @item @samp{#+TODO:}
19639 @itemx @samp{#+SEQ_TODO:}
19640 @itemx @samp{#+TYP_TODO:}
19641 @cindex @samp{SEQ_TODO}, keyword
19642 @cindex @samp{TODO}, keyword
19643 @cindex @samp{TYP_TODO}, keyword
19644 @vindex org-todo-keywords
19645 These lines set the TODO keywords and their interpretation in the
19646 current file.  The corresponding variable is @code{org-todo-keywords}.
19647 @end table
19649 @node The Very Busy @kbd{C-c C-c} Key
19650 @section The Very Busy @kbd{C-c C-c} Key
19652 @kindex C-c C-c
19653 @cindex @kbd{C-c C-c}, overview
19655 The @kbd{C-c C-c} key in Org serves many purposes depending on
19656 the context.  It is probably the most over-worked, multi-purpose key
19657 combination in Org.  Its uses are well documented throughout this
19658 manual, but here is a consolidated list for easy reference.
19660 @itemize
19661 @item
19662 If any highlights shown in the buffer from the creation of a sparse
19663 tree, or from clock display, remove such highlights.
19665 @item
19666 If the cursor is in one of the special @samp{KEYWORD} lines, scan the
19667 buffer for these lines and update the information.  Also reset the
19668 Org file cache used to temporary store the contents of URLs used as
19669 values for keywords like @samp{SETUPFILE}.
19671 @item
19672 If the cursor is inside a table, realign the table.  The table
19673 realigns even if automatic table editor is turned off.
19675 @item
19676 If the cursor is on a @samp{TBLFM} keyword, re-apply the formulas to the
19677 entire table.
19679 @item
19680 If the current buffer is a capture buffer, close the note and file
19681 it.  With a prefix argument, also jump to the target location after
19682 saving the note.
19684 @item
19685 If the cursor is on a @samp{<<<target>>>}, update radio targets and
19686 corresponding links in this buffer.
19688 @item
19689 If the cursor is on a property line or at the start or end of
19690 a property drawer, offer property commands.
19692 @item
19693 If the cursor is at a footnote reference, go to the corresponding
19694 definition, and @emph{vice versa}.
19696 @item
19697 If the cursor is on a statistics cookie, update it.
19699 @item
19700 If the cursor is in a plain list item with a checkbox, toggle the
19701 status of the checkbox.
19703 @item
19704 If the cursor is on a numbered item in a plain list, renumber the
19705 ordered list.
19707 @item
19708 If the cursor is on the @samp{#+BEGIN} line of a dynamic block, the block
19709 is updated.
19711 @item
19712 If the cursor is at a timestamp, fix the day name in the timestamp.
19713 @end itemize
19715 @node Clean View
19716 @section A Cleaner Outline View
19718 @cindex hiding leading stars
19719 @cindex dynamic indentation
19720 @cindex odd-levels-only outlines
19721 @cindex clean outline view
19723 Org's default outline with stars and no indents can become too
19724 cluttered for short documents.  For @emph{book-like} long documents, the
19725 effect is not as noticeable.  Org provides an alternate stars and
19726 indentation scheme, as shown on the right in the following table.  It
19727 uses only one star and indents text to line with the heading:
19729 @example
19730 * Top level headline             |    * Top level headline
19731 ** Second level                  |      * Second level
19732 *** Third level                  |        * Third level
19733     some text                    |          some text
19734 *** Third level                  |        * Third level
19735     more text                    |          more text
19736 * Another top level headline     |    * Another top level headline
19737 @end example
19739 @noindent
19740 @cindex Indent mode
19741 @findex org-indent-mode
19742 To turn this mode on, use the minor mode, @code{org-indent-mode}.  Text
19743 lines that are not headlines are prefixed with spaces to vertically
19744 align with the headline text@footnote{The @code{org-indent-mode} also sets the @code{wrap-prefix} correctly
19745 for indenting and wrapping long lines of headlines or text.  This
19746 minor mode handles @code{visual-line-mode} and directly applied settings
19747 through @code{word-wrap}.}.
19749 @vindex org-indent-indentation-per-level
19750 To make more horizontal space, the headlines are shifted by two stars.
19751 This can be configured by the @code{org-indent-indentation-per-level}
19752 variable.  Only one star on each headline is visible, the rest are
19753 masked with the same font color as the background.
19755 Note that turning on @code{org-indent-mode} sets @code{org-hide-leading-stars}
19756 to @code{t} and @code{org-adapt-indentation} to @code{nil}.
19758 @vindex org-startup-indented
19759 To globally turn on @code{org-indent-mode} for all files, customize the
19760 variable @code{org-startup-indented}.
19762 To turn on indenting for individual files, use @samp{STARTUP} keyword as
19763 follows:
19765 @example
19766 #+STARTUP: indent
19767 @end example
19769 Indent on startup makes Org use hard spaces to align text with
19770 headings as shown in examples below.
19772 @table @asis
19773 @item @emph{Indentation of text below headlines}
19774 Indent text to align with the headline.
19776 @example
19777 *** Third level
19778     more text, now indented
19779 @end example
19781 @vindex org-adapt-indentation
19782 Org supports this with paragraph filling, line wrapping, and
19783 structure editing, preserving or adapting the indentation as
19784 appropriate@footnote{Also see the variable @code{org-adapt-indentation}.}.
19786 @item @emph{Hiding leading stars}
19787 @vindex org-hide-leading-stars
19788 Org can make leading stars invisible.  For global preference,
19789 configure the variable @code{org-hide-leading-stars}.  For per-file
19790 preference, use these file @samp{STARTUP} options:
19792 @example
19793 #+STARTUP: hidestars
19794 #+STARTUP: showstars
19795 @end example
19797 With stars hidden, the tree is shown as:
19799 @example
19800 * Top level headline
19801  * Second level
19802   * Third level
19803   ...
19804 @end example
19806 @noindent
19807 @vindex org-hide, face
19808 Because Org makes the font color the same as the background color
19809 to hide to stars, sometimes @code{org-hide} face may need tweaking to
19810 get the effect right.  For some black and white combinations,
19811 @code{grey90} on a white background might mask the stars better.
19813 @item @emph{Odd levels}
19814 @vindex org-odd-levels-only
19815 Using stars for only odd levels, 1, 3, 5, @dots{}, can also clean up
19816 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
19817 on.}.
19818 For Org to properly handle this cleaner structure during edits
19819 and exports, configure the variable @code{org-odd-levels-only}.  To
19820 set this per-file, use either one of the following lines:
19822 @example
19823 #+STARTUP: odd
19824 #+STARTUP: oddeven
19825 @end example
19827 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}.
19828 @end table
19830 @node TTY Keys
19831 @section Using Org on a TTY
19833 @cindex tty key bindings
19835 Org provides alternative key bindings for TTY and modern mobile
19836 devices that cannot handle cursor keys and complex modifier key
19837 chords.  Some of these workarounds may be more cumbersome than
19838 necessary.  Users should look into customizing these further based on
19839 their usage needs.  For example, the normal @kbd{S-<cursor>} for
19840 editing timestamp might be better with @kbd{C-c .} chord.
19842 @multitable @columnfractions 0.2 0.28 0.15 0.21
19843 @headitem Default
19844 @tab Alternative 1
19845 @tab Speed key
19846 @tab Alternative 2
19847 @item @kbd{S-@key{TAB}}
19848 @tab @kbd{C-u @key{TAB}}
19849 @tab @kbd{C}
19850 @tab 
19851 @item @kbd{M-@key{LEFT}}
19852 @tab @kbd{C-c C-x l}
19853 @tab @kbd{l}
19854 @tab @kbd{Esc @key{LEFT}}
19855 @item @kbd{M-S-@key{LEFT}}
19856 @tab @kbd{C-c C-x L}
19857 @tab @kbd{L}
19858 @tab 
19859 @item @kbd{M-@key{RIGHT}}
19860 @tab @kbd{C-c C-x r}
19861 @tab @kbd{r}
19862 @tab @kbd{Esc @key{RIGHT}}
19863 @item @kbd{M-S-@key{RIGHT}}
19864 @tab @kbd{C-c C-x R}
19865 @tab @kbd{R}
19866 @tab 
19867 @item @kbd{M-@key{UP}}
19868 @tab @kbd{C-c C-x u}
19869 @tab 
19870 @tab @kbd{Esc @key{UP}}
19871 @item @kbd{M-S-@key{UP}}
19872 @tab @kbd{C-c C-x U}
19873 @tab @kbd{U}
19874 @tab 
19875 @item @kbd{M-@key{DOWN}}
19876 @tab @kbd{C-c C-x d}
19877 @tab 
19878 @tab @kbd{Esc @key{DOWN}}
19879 @item @kbd{M-S-@key{DOWN}}
19880 @tab @kbd{C-c C-x D}
19881 @tab @kbd{D}
19882 @tab 
19883 @item @kbd{S-@key{RET}}
19884 @tab @kbd{C-c C-x c}
19885 @tab 
19886 @tab 
19887 @item @kbd{M-@key{RET}}
19888 @tab @kbd{C-c C-x m}
19889 @tab 
19890 @tab @kbd{Esc @key{RET}}
19891 @item @kbd{M-S-@key{RET}}
19892 @tab @kbd{C-c C-x M}
19893 @tab 
19894 @tab 
19895 @item @kbd{S-@key{LEFT}}
19896 @tab @kbd{C-c @key{LEFT}}
19897 @tab 
19898 @tab 
19899 @item @kbd{S-@key{RIGHT}}
19900 @tab @kbd{C-c @key{RIGHT}}
19901 @tab 
19902 @tab 
19903 @item @kbd{S-@key{UP}}
19904 @tab @kbd{C-c @key{UP}}
19905 @tab 
19906 @tab 
19907 @item @kbd{S-@key{DOWN}}
19908 @tab @kbd{C-c @key{DOWN}}
19909 @tab 
19910 @tab 
19911 @item @kbd{C-S-@key{LEFT}}
19912 @tab @kbd{C-c C-x @key{LEFT}}
19913 @tab 
19914 @tab 
19915 @item @kbd{C-S-@key{RIGHT}}
19916 @tab @kbd{C-c C-x @key{RIGHT}}
19917 @tab 
19918 @tab 
19919 @end multitable
19921 @node Interaction
19922 @section Interaction with Other Packages
19924 @cindex packages, interaction with other
19926 Org's compatibility and the level of interaction with other Emacs
19927 packages are documented here.
19929 @menu
19930 * Cooperation::                  Packages Org cooperates with.
19931 * Conflicts::                    Packages that lead to conflicts.
19932 @end menu
19934 @node Cooperation
19935 @subsection Packages that Org cooperates with
19937 @table @asis
19938 @item @samp{calc.el} by Dave Gillespie
19939 @cindex @file{calc.el}
19941 Org uses the Calc package for implementing spreadsheet
19942 functionality in its tables (see @ref{The spreadsheet}).  Org also
19943 uses Calc for embedded calculations.  See @ref{Embedded Mode,GNU Emacs Calc Manual,,calc,}.
19945 @item @samp{constants.el} by Carsten Dominik
19946 @cindex @file{constants.el}
19947 @vindex org-table-formula-constants
19949 Org can use names for constants in formulas in tables.  Org can
19950 also use calculation suffixes for units, such as @samp{M} for @samp{Mega}.
19951 For a standard collection of such constants, install the
19952 @samp{constants} package.  Install version 2.0 of this package,
19953 available at @uref{http://www.astro.uva.nl/~dominik/Tools}.  Org checks
19954 if the function @code{constants-get} has been autoloaded.
19955 Installation instructions are in the file @samp{constants.el}.
19957 @item @samp{cdlatex.el} by Carsten Dominik
19958 @cindex @file{cdlatex.el}
19960 Org mode can make use of the CD@LaTeX{} package to efficiently enter
19961 @LaTeX{} fragments into Org files.  See @ref{CD@LaTeX{} mode}.
19963 @item @samp{imenu.el} by Ake Stenhoff and Lars Lindberg
19964 @cindex @file{imenu.el}
19966 Imenu creates dynamic menus based on an index of items in a file.
19967 Org mode supports Imenu menus.  Enable it with a mode hook as
19968 follows:
19970 @lisp
19971 (add-hook 'org-mode-hook
19972           (lambda () (imenu-add-to-menubar "Imenu")))
19973 @end lisp
19975 @vindex org-imenu-depth
19976 By default the index is two levels deep---you can modify the
19977 depth using the option @code{org-imenu-depth}.
19979 @item @samp{speedbar.el} by Eric M. Ludlam
19980 @cindex @file{speedbar.el}
19982 Speedbar package creates a special Emacs frame for displaying
19983 files and index items in files.  Org mode supports Speedbar;
19984 users can drill into Org files directly from the Speedbar.  The
19985 @kbd{<} in the Speedbar frame tweaks the agenda commands to
19986 that file or to a subtree.
19988 @item @samp{table.el} by Takaaki Ota
19989 @cindex table editor, @file{table.el}
19990 @cindex @file{table.el}
19992 Complex ASCII tables with automatic line wrapping, column- and
19993 row-spanning, and alignment can be created using the Emacs table
19994 package by Takaaki Ota.  Org mode recognizes such tables and
19995 exports them properly.  @kbd{C-c '} to edit these tables in
19996 a special buffer, much like Org's code blocks.  Because of
19997 interference with other Org mode functionality, Takaaki Ota
19998 tables cannot be edited directly in the Org buffer.
20000 @table @asis
20001 @item @kbd{C-c '} (@code{org-edit-special})
20002 @kindex C-c '
20003 @findex org-edit-special
20004 Edit a @samp{table.el} table.  Works when the cursor is in
20005 a @samp{table.el} table.
20007 @item @kbd{C-c ~​} (@code{org-table-create-with-table.el})
20008 @kindex C-c ~
20009 @findex org-table-create-with-table.el
20010 Insert a @samp{table.el} table.  If there is already a table at
20011 point, this command converts it between the @samp{table.el}
20012 format and the Org mode format.  See the documentation
20013 string of the command @code{org-convert-table} for the
20014 restrictions under which this is possible.
20015 @end table
20016 @end table
20018 @node Conflicts
20019 @subsection Packages that conflict with Org mode
20021 @cindex shift-selection-mode
20022 @vindex org-support-shift-select
20023 In Emacs, @code{shift-selection-mode} combines cursor motions with shift
20024 key to enlarge regions.  Emacs sets this mode by default.  This
20025 conflicts with Org's use of @kbd{S-<cursor>} commands to change
20026 timestamps, TODO keywords, priorities, and item bullet types, etc.
20027 Since @kbd{S-<cursor>} commands outside of specific contexts do
20028 not do anything, Org offers the variable @code{org-support-shift-select}
20029 for customization.  Org mode accommodates shift selection by (i)
20030 making it available outside of the special contexts where special
20031 commands apply, and (ii) extending an existing active region even if
20032 the cursor moves across a special context.
20034 @table @asis
20035 @item @samp{cua.el} by Kim. F. Storm
20036 @cindex @file{cua.el}
20037 @vindex org-replace-disputed-keys
20038 Org key bindings conflict with @kbd{S-<cursor>} keys used by
20039 CUA mode.  For Org to relinquish these bindings to CUA mode,
20040 configure the variable @code{org-replace-disputed-keys}.  When set,
20041 Org moves the following key bindings in Org files, and in the
20042 agenda buffer---but not during date selection.
20044 @multitable @columnfractions 0.4 0.4
20045 @item @kbd{S-@key{UP}}      @result{}  @kbd{M-p}
20046 @tab @kbd{S-@key{DOWN}}     @result{}  @kbd{M-n}
20047 @item @kbd{S-@key{LEFT}}    @result{}  @kbd{M--}
20048 @tab @kbd{S-@key{RIGHT}}    @result{}  @kbd{M-+}
20049 @item @kbd{C-S-@key{LEFT}}  @result{}  @kbd{M-S--}
20050 @tab @kbd{C-S-@key{RIGHT}}  @result{}  @kbd{M-S-+}
20051 @end multitable
20053 @vindex org-disputed-keys
20054 Yes, these are unfortunately more difficult to remember.  If you
20055 want to have other replacement keys, look at the variable
20056 @code{org-disputed-keys}.
20058 @item @samp{ecomplete.el} by Lars Magne Ingebrigtsen
20059 @cindex @file{ecomplete.el}
20060 Ecomplete provides ``electric'' address completion in address
20061 header lines in message buffers.  Sadly Orgtbl mode cuts
20062 Ecomplete's power supply: no completion happens when Orgtbl mode
20063 is enabled in message buffers while entering text in address
20064 header lines.  If one wants to use ecomplete one should @emph{not}
20065 follow the advice to automagically turn on Orgtbl mode in message
20066 buffers (see @ref{Orgtbl Mode}), but instead---after
20067 filling in the message headers---turn on Orgtbl mode manually
20068 when needed in the messages body.
20070 @item @samp{filladapt.el} by Kyle Jones
20071 @cindex @file{filladapt.el}
20072 Org mode tries to do the right thing when filling paragraphs,
20073 list items and other elements.  Many users reported problems
20074 using both @samp{filladapt.el} and Org mode, so a safe thing to do is
20075 to disable filladapt like this:
20077 @lisp
20078 (add-hook 'org-mode-hook 'turn-off-filladapt-mode)
20079 @end lisp
20081 @item @samp{viper.el} by Michael Kifer
20082 @cindex @file{viper.el}
20083 @kindex C-c /
20085 Viper uses @kbd{C-c /} and therefore makes this key not
20086 access the corresponding Org mode command @code{org-sparse-tree}.  You
20087 need to find another key for this command, or override the key in
20088 @code{viper-vi-global-user-map} with
20090 @lisp
20091 (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
20092 @end lisp
20094 @item @samp{windmove.el} by Hovav Shacham
20095 @cindex @file{windmove.el}
20097 This package also uses the @kbd{S-<cursor>} keys, so
20098 everything written in the paragraph above about CUA mode also
20099 applies here.  If you want to make the windmove function active
20100 in locations where Org mode does not have special functionality
20101 on @kbd{S-<cursor>}, add this to your configuration:
20103 @lisp
20104 ;; Make windmove work in Org mode:
20105 (add-hook 'org-shiftup-final-hook 'windmove-up)
20106 (add-hook 'org-shiftleft-final-hook 'windmove-left)
20107 (add-hook 'org-shiftdown-final-hook 'windmove-down)
20108 (add-hook 'org-shiftright-final-hook 'windmove-right)
20109 @end lisp
20111 @item @samp{yasnippet.el}
20112 @cindex @file{yasnippet.el}
20113 The way Org mode binds the @kbd{@key{TAB}} key (binding to @code{[tab]}
20114 instead of @code{"\t"}) overrules YASnippet's access to this key.  The
20115 following code fixed this problem:
20117 @lisp
20118 (add-hook 'org-mode-hook
20119           (lambda ()
20120             (setq-local yas/trigger-key [tab])
20121             (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
20122 @end lisp
20124 The latest version of YASnippet does not play well with Org mode.
20125 If the above code does not fix the conflict, start by defining
20126 the following function:
20128 @lisp
20129 (defun yas/org-very-safe-expand ()
20130   (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
20131 @end lisp
20133 Then, tell Org mode to use that function:
20135 @lisp
20136 (add-hook 'org-mode-hook
20137           (lambda ()
20138             (make-variable-buffer-local 'yas/trigger-key)
20139             (setq yas/trigger-key [tab])
20140             (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
20141             (define-key yas/keymap [tab] 'yas/next-field)))
20142 @end lisp
20143 @end table
20145 @node Org Crypt
20146 @section Org Crypt
20148 Org Crypt encrypts the text of an entry, but not the headline, or
20149 properties.  Behind the scene, it uses the Emacs EasyPG library to
20150 encrypt and decrypt files.
20152 @vindex org-crypt-tag-matcher
20153 Any text below a headline that has a @samp{crypt} tag is automatically
20154 encrypted when the file is saved.  To use a different tag, customize
20155 the @code{org-crypt-tag-matcher} setting.
20157 Here is a suggestion for Org Crypt settings in Emacs init file:
20159 @lisp
20160 (require 'org-crypt)
20161 (org-crypt-use-before-save-magic)
20162 (setq org-tags-exclude-from-inheritance '("crypt"))
20164 (setq org-crypt-key nil)
20165 ;; GPG key to use for encryption
20166 ;; Either the Key ID or set to nil to use symmetric encryption.
20168 (setq auto-save-default nil)
20169 ;; Auto-saving does not cooperate with org-crypt.el: so you need to
20170 ;; turn it off if you plan to use org-crypt.el quite often.  Otherwise,
20171 ;; you'll get an (annoying) message each time you start Org.
20173 ;; To turn it off only locally, you can insert this:
20175 ;; # -*- buffer-auto-save-file-name: nil; -*-
20176 @end lisp
20178 Excluding the @samp{crypt} tag from inheritance prevents already encrypted
20179 text from being encrypted again.
20181 @node Hacking
20182 @appendix Hacking
20184 @cindex hacking
20186 This appendix describes some ways a user can extend the functionality
20187 of Org.
20189 @menu
20190 * Hooks: Hooks (2).              How to reach into Org's internals.
20191 * Add-on Packages::              Available extensions.
20192 * Adding Hyperlink Types::       New custom link types.
20193 * Adding Export Back-ends::      How to write new export back-ends.
20194 * Tables in Arbitrary Syntax::   Orgtbl for LaTeX and other programs.
20195 * Dynamic Blocks::               Automatically filled blocks.
20196 * Special Agenda Views::         Customized views.
20197 * Speeding Up Your Agendas::     Tips on how to speed up your agendas.
20198 * Extracting Agenda Information:: Post-processing agenda information.
20199 * Using the Property API::       Writing programs that use entry properties.
20200 * Using the Mapping API::        Mapping over all or selected entries.
20201 @end menu
20203 @node Hooks (2)
20204 @appendixsec Hooks
20206 @cindex hooks
20208 Org has a large number of hook variables for adding functionality.
20209 This appendix illustrates using a few.  A complete list of hooks with
20210 documentation is maintained by the Worg project at
20211 @uref{https://orgmode.org/worg/doc.html#hooks}.
20213 @node Add-on Packages
20214 @appendixsec Add-on Packages
20216 @cindex add-on packages
20218 Various authors wrote a large number of add-on packages for Org.
20220 These packages are not part of Emacs, but they are distributed as
20221 contributed packages with the separate release available at
20222 @uref{https://orgmode.org}.  See the @samp{contrib/README} file in the source code
20223 directory for a list of contributed files.  Worg page with more
20224 information is at: @uref{https://orgmode.org/worg/org-contrib/}.
20226 @node Adding Hyperlink Types
20227 @appendixsec Adding Hyperlink Types
20229 @cindex hyperlinks, adding new types
20231 Org has many built-in hyperlink types (see @ref{Hyperlinks}), and an
20232 interface for adding new link types.  The following example shows the
20233 process of adding Org links to Unix man pages, which look like this
20235 @example
20236 [[man:printf][The printf manual]]
20237 @end example
20239 @noindent
20240 The following @samp{org-man.el} file implements it
20242 @lisp
20243 ;;; org-man.el - Support for links to man pages in Org mode
20244 (require 'org)
20246 (org-link-set-parameters "man"
20247                          :follow org-man-command
20248                          :export #'org-man-export
20249                          :store #'org-man-store-link)
20251 (defcustom org-man-command 'man
20252   "The Emacs command to be used to display a man page."
20253   :group 'org-link
20254   :type '(choice (const man) (const woman)))
20256 (defun org-man-store-link ()
20257   "Store a link to a man page."
20258   (when (memq major-mode '(Man-mode woman-mode))
20259     ;; This is a man page, we do make this link.
20260     (let* ((page (org-man-get-page-name))
20261            (link (concat "man:" page))
20262            (description (format "Man page for %s" page)))
20263       (org-store-link-props
20264        :type "man"
20265        :link link
20266        :description description))))
20268 (defun org-man-get-page-name ()
20269   "Extract the page name from the buffer name."
20270   ;; This works for both `Man-mode' and `woman-mode'.
20271   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
20272       (match-string 1 (buffer-name))
20273     (error "Cannot create link to this man page")))
20275 (defun org-man-export (link description format)
20276   "Export a man page link from Org files."
20277   (let ((path (format "http://man.he.net/?topic=%s&section=all" link))
20278         (desc (or description link)))
20279     (pcase format
20280       (`html (format "<a target=\"_blank\" href=\"%s\">%s</a>" path desc))
20281       (`latex (format "\\href@{%s@}@{%s@}" path desc))
20282       (`texinfo (format "@@uref@{%s,%s@}" path desc))
20283       (`ascii (format "%s (%s)" desc path))
20284       (t path))))
20286 (provide 'org-man)
20287 ;;; org-man.el ends here
20288 @end lisp
20290 @noindent
20291 To activate links to man pages in Org, enter this in the Emacs init
20292 file:
20294 @lisp
20295 (require 'org-man)
20296 @end lisp
20298 @noindent
20299 A review of @samp{org-man.el}:
20301 @enumerate
20302 @item
20303 First, @code{(require 'org)} ensures @samp{org.el} is loaded.
20305 @item
20306 @findex org-link-set-parameters
20307 @vindex org-link-parameters
20308 Then @code{org-link-set-parameters} defines a new link type with @samp{man}
20309 prefix and associates functions for following, exporting and
20310 storing such links.  See the variable @code{org-link-parameters} for
20311 a complete list of possible associations.
20313 @item
20314 The rest of the file implements necessary variables and functions.
20316 For example, @code{org-man-store-link} is responsible for storing a link
20317 when @code{org-store-link} (see @ref{Handling Links}) is called from a buffer
20318 displaying a man page.  It first checks if the @code{major-mode} is
20319 appropriate.  If check fails, the function returns @code{nil}, which
20320 means it isn't responsible for creating a link to the current
20321 buffer.  Otherwise the function makes a link string by combining
20322 the @samp{man:} prefix with the man topic.  It also provides a default
20323 description.  The function @code{org-insert-link} can insert it back
20324 into an Org buffer later on.
20325 @end enumerate
20327 @node Adding Export Back-ends
20328 @appendixsec Adding Export Back-ends
20330 @cindex Export, writing back-ends
20332 Org's export engine makes it easy for writing new back-ends.  The
20333 framework on which the engine was built makes it easy to derive new
20334 back-ends from existing ones.
20336 @findex org-export-define-backend
20337 @findex org-export-define-derived-backend
20338 The two main entry points to the export engine are:
20339 @code{org-export-define-backend} and @code{org-export-define-derived-backend}.
20340 To grok these functions, see @samp{ox-latex.el} for an example of defining
20341 a new back-end from scratch, and @samp{ox-beamer.el} for an example of
20342 deriving from an existing engine.
20344 For creating a new back-end from scratch, first set its name as
20345 a symbol in an alist consisting of elements and export functions.  To
20346 make the back-end visible to the export dispatcher, set @code{:menu-entry}
20347 keyword.  For export options specific to this back-end, set the
20348 @code{:options-alist}.
20350 For creating a new back-end from an existing one, set
20351 @code{:translate-alist} to an alist of export functions.  This alist
20352 replaces the parent back-end functions.
20354 For complete documentation, see @uref{https://orgmode.org/worg/dev/org-export-reference.html, the Org Export Reference on Worg}.
20356 @node Tables in Arbitrary Syntax
20357 @appendixsec Tables in Arbitrary Syntax
20359 @cindex tables, in other modes
20360 @cindex lists, in other modes
20361 @cindex Orgtbl mode
20363 Due to Org's success in handling tables with Orgtbl, a frequently
20364 requested feature is the use of Org's table functions in other modes,
20365 e.g., @LaTeX{}.  This would be hard to do in a general way without
20366 complicated customization nightmares.  Moreover, that would take Org
20367 away from its simplicity roots that Orgtbl has proven.  There is,
20368 however, an alternate approach to accomplishing the same.
20370 This approach involves implementing a custom @emph{translate} function that
20371 operates on a native Org @emph{source table} to produce a table in another
20372 format.  This strategy would keep the excellently working Orgtbl
20373 simple and isolate complications, if any, confined to the translate
20374 function.  To add more alien table formats, we just add more translate
20375 functions.  Also the burden of developing custom translate functions
20376 for new table formats is in the hands of those who know those formats
20377 best.
20379 @menu
20380 * Radio tables::                 Sending and receiving radio tables.
20381 * A @LaTeX{} example::           Step by step, almost a tutorial.
20382 * Translator functions::         Copy and modify.
20383 @end menu
20385 @node Radio tables
20386 @appendixsubsec Radio tables
20388 @cindex radio tables
20390 Radio tables are target locations for translated tables that are not near
20391 their source.  Org finds the target location and inserts the translated
20392 table.
20394 The key to finding the target location is the magic words @samp{BEGIN/END
20395 RECEIVE ORGTBL}.  They have to appear as comments in the current mode.
20396 If the mode is C, then:
20398 @example
20399 /* BEGIN RECEIVE ORGTBL table_name */
20400 /* END RECEIVE ORGTBL table_name */
20401 @end example
20403 @noindent
20404 At the location of source, Org needs a special line to direct Orgtbl
20405 to translate and to find the target for inserting the translated
20406 table.  For example:
20408 @cindex @samp{ORGTBL}, keyword
20409 @example
20410 #+ORGTBL: SEND table_name translation_function arguments ...
20411 @end example
20413 @noindent
20414 @samp{table_name} is the table's reference name, which is also used in the
20415 receiver lines, and the @samp{translation_function} is the Lisp function
20416 that translates.  This line, in addition, may also contain alternating
20417 key and value arguments at the end.  The translation function gets
20418 these values as a property list.  A few standard parameters are
20419 already recognized and acted upon before the translation function is
20420 called:
20422 @table @asis
20423 @item @samp{:skip N}
20424 Skip the first N lines of the table.  Hlines do count; include
20425 them if they are to be skipped.
20427 @item @samp{:skipcols (n1 n2 ...)}
20428 List of columns to be skipped.  First Org automatically discards
20429 columns with calculation marks and then sends the table to the
20430 translator function, which then skips columns as specified in
20431 @samp{skipcols}.
20432 @end table
20434 @noindent
20435 To keep the source table intact in the buffer without being disturbed
20436 when the source file is compiled or otherwise being worked on, use one
20437 of these strategies:
20439 @itemize
20440 @item
20441 Place the table in a block comment.  For example, in C mode you
20442 could wrap the table between @samp{/*} and @samp{*/} lines.
20444 @item
20445 Put the table after an ``end'' statement.  For example @code{\bye} in @TeX{}
20446 and @code{\end@{document@}} in @LaTeX{}.
20448 @item
20449 Comment and un-comment each line of the table during edits.  The
20450 @kbd{M-x orgtbl-toggle-comment} command makes toggling easy.
20451 @end itemize
20453 @node A @LaTeX{} example
20454 @appendixsubsec A @LaTeX{} example of radio tables
20456 @cindex @LaTeX{}, and Orgtbl mode
20458 To wrap a source table in @LaTeX{}, use the @samp{comment} environment
20459 provided by @samp{comment.sty}@footnote{@uref{https://ctan.org/tex-archive/macros/latex/contrib/comment?lang=en}}.  To activate it, put
20460 @code{\usepackage@{comment@}} in the document header.  Orgtbl mode inserts
20461 a radio table skeleton@footnote{Because @samp{LEVEL=2} has 3 stars, @samp{LEVEL=3} has 4 stars, and so
20462 on.} with the command @kbd{M-x orgtbl-insert-radio-table}, which prompts for a table name.  For
20463 example, if @samp{salesfigures} is the name, the template inserts:
20465 @example
20466 % BEGIN RECEIVE ORGTBL salesfigures
20467 % END RECEIVE ORGTBL salesfigures
20468 \begin@{comment@}
20469 #+ORGTBL: SEND salesfigures orgtbl-to-latex
20470 | | |
20471 \end@{comment@}
20472 @end example
20474 @vindex LaTeX-verbatim-environments
20475 @noindent
20476 The line @samp{#+ORGTBL: SEND} tells Orgtbl mode to use the function
20477 @code{orgtbl-to-latex} to convert the table to @LaTeX{} format, then insert
20478 the table at the target (receive) location named @samp{salesfigures}.  Now
20479 the table is ready for data entry.  It can even use spreadsheet
20480 features@footnote{If the @samp{TBLFM} keyword contains an odd number of dollar
20481 characters, this may cause problems with Font Lock in @LaTeX{} mode.  As
20482 shown in the example you can fix this by adding an extra line inside
20483 the @samp{comment} environment that is used to balance the dollar
20484 expressions.  If you are using AUC@TeX{} with the font-latex library,
20485 a much better solution is to add the @samp{comment} environment to the
20486 variable @code{LaTeX-verbatim-environments}.}:
20488 @example
20489 % BEGIN RECEIVE ORGTBL salesfigures
20490 % END RECEIVE ORGTBL salesfigures
20491 \begin@{comment@}
20492 #+ORGTBL: SEND salesfigures orgtbl-to-latex
20493 | Month | Days | Nr sold | per day |
20494 |-------+------+---------+---------|
20495 | Jan   |   23 |      55 |     2.4 |
20496 | Feb   |   21 |      16 |     0.8 |
20497 | March |   22 |     278 |    12.6 |
20498 #+TBLFM: $4=$3/$2;%.1f
20499 % $ (optional extra dollar to keep Font Lock happy, see footnote)
20500 \end@{comment@}
20501 @end example
20503 @noindent
20504 After editing, @kbd{C-c C-c} inserts the translated table at the
20505 target location, between the two marker lines.
20507 For hand-made custom tables, note that the translator needs to skip
20508 the first two lines of the source table.  Also the command has to
20509 @emph{splice} out the target table without the header and footer.
20511 @example
20512 \begin@{tabular@}@{lrrr@}
20513 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
20514 % BEGIN RECEIVE ORGTBL salesfigures
20515 % END RECEIVE ORGTBL salesfigures
20516 \end@{tabular@}
20518 \begin@{comment@}
20519 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
20520 | Month | Days | Nr sold | per day |
20521 |-------+------+---------+---------|
20522 | Jan   |   23 |      55 |     2.4 |
20523 | Feb   |   21 |      16 |     0.8 |
20524 | March |   22 |     278 |    12.6 |
20525 #+TBLFM: $4=$3/$2;%.1f
20526 \end@{comment@}
20527 @end example
20529 The @LaTeX{} translator function @code{orgtbl-to-latex} is already part of
20530 Orgtbl mode and uses a @samp{tabular} environment to typeset the table and
20531 marks horizontal lines with @code{\hline}.  For additional parameters to
20532 control output, see @ref{Translator functions}:
20534 @table @asis
20535 @item @code{:splice nil/t}
20536 When non-@code{nil}, return only table body lines; not wrapped in
20537 tabular environment.  Default is @code{nil}.
20539 @item @code{:fmt FMT}
20540 Format to warp each field.  It should contain @samp{%s} for the
20541 original field value.  For example, to wrap each field value in
20542 dollar symbol, you could use @samp{:fmt "$%s$"}.  Format can also wrap
20543 a property list with column numbers and formats, for example
20544 @samp{:fmt (2 "$%s$" 4 "%s\\%%")}.  In place of a string, a function
20545 of one argument can be used; the function must return a formatted
20546 string.
20548 @item @code{:efmt EFMT}
20549 Format numbers as exponentials.  The spec should have @samp{%s} twice
20550 for inserting mantissa and exponent, for example
20551 @samp{"%s\\times10^@{%s@}"}.  This may also be a property list with
20552 column numbers and formats, for example @samp{:efmt (2
20553      "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
20554 @var{EFMT} has been applied to a value, @var{FMT}---see
20555 above---is also be applied.  Functions with two arguments can be
20556 supplied instead of strings.  By default, no special formatting
20557 is applied.
20558 @end table
20560 @node Translator functions
20561 @appendixsubsec Translator functions
20563 @cindex HTML, and Orgtbl mode
20564 @cindex translator function
20566 @findex orgtbl-to-csv
20567 @findex orgtbl-to-tsv
20568 @findex orgtbl-to-latex
20569 @findex orgtbl-to-html
20570 @findex orgtbl-to-texinfo
20571 @findex orgtbl-to-unicode
20572 @findex orgtbl-to-orgtbl
20573 @findex orgtbl-to-generic
20574 Orgtbl mode has built-in translator functions: @code{orgtbl-to-csv}
20575 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values),
20576 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, @code{orgtbl-to-texinfo},
20577 @code{orgtbl-to-unicode} and @code{orgtbl-to-orgtbl}.  They use the generic
20578 translator, @code{orgtbl-to-generic}, which delegates translations to
20579 various export back-ends.
20581 Properties passed to the function through the @samp{ORGTBL SEND} line take
20582 precedence over properties defined inside the function.  For example,
20583 this overrides the default @LaTeX{} line endings, @code{\\}, with @code{\\[2mm]}:
20585 @example
20586 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
20587 @end example
20589 For a new language translator, define a converter function.  It can be
20590 a generic function, such as shown in this example.  It marks
20591 a beginning and ending of a table with @samp{!BTBL!} and @samp{!ETBL!};
20592 a beginning and ending of lines with @samp{!BL!} and @samp{!EL!}; and uses a TAB
20593 for a field separator:
20595 @lisp
20596 (defun orgtbl-to-language (table params)
20597   "Convert the orgtbl-mode TABLE to language."
20598   (orgtbl-to-generic
20599    table
20600    (org-combine-plists
20601     '(:tstart "!BTBL!" :tend "!ETBL!" :lstart "!BL!" :lend "!EL!" :sep "\t")
20602     params)))
20603 @end lisp
20605 @noindent
20606 The documentation for the @code{orgtbl-to-generic} function shows
20607 a complete list of parameters, each of which can be passed through to
20608 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function using
20609 that generic function.
20611 For complicated translations the generic translator function could be
20612 replaced by a custom translator function.  Such a custom function must
20613 take two arguments and return a single string containing the formatted
20614 table.  The first argument is the table whose lines are a list of
20615 fields or the symbol @code{hline}.  The second argument is the property
20616 list consisting of parameters specified in the @samp{#+ORGTBL: SEND} line.
20617 Please share your translator functions by posting them to the Org
20618 users mailing list, at @email{emacs-orgmode@@gnu.org}.
20620 @node Dynamic Blocks
20621 @appendixsec Dynamic Blocks
20623 @cindex dynamic blocks
20625 Org supports @emph{dynamic blocks} in Org documents.  They are inserted
20626 with begin and end markers like any other code block, but the contents
20627 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
20628 @ref{Clocking Work Time}).
20630 Dynamic blocks can have names and function parameters.  The syntax is
20631 similar to source code block specifications:
20633 @example
20634 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
20635   ...
20636 #+END:
20637 @end example
20639 These commands update dynamic blocks:
20641 @table @asis
20642 @item @kbd{C-c C-x C-u} (@code{org-dblock-update})
20643 @kindex C-c C-x C-u
20644 @findex org-dblock-update
20645 Update dynamic block at point.
20647 @item @kbd{C-u C-c C-x C-u}
20648 @kindex C-u C-c C-x C-u
20649 Update all dynamic blocks in the current file.
20650 @end table
20652 Before updating a dynamic block, Org removes content between the
20653 @samp{BEGIN} and @samp{END} markers.  Org then reads the parameters on the
20654 @samp{BEGIN} line for passing to the writer function.  If the function
20655 expects to access the removed content, then Org expects an extra
20656 parameter, @samp{:content}, on the @samp{BEGIN} line.
20658 The syntax for naming a writer function with a dynamic block labelled
20659 @samp{myblock} is: @code{org-dblock-write:myblock}.  Parameters come from the
20660 @samp{BEGIN} line.
20662 The following is an example of a dynamic block and a block writer function
20663 that updates the time when the function was last run:
20665 @example
20666 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
20667   ...
20668 #+END:
20669 @end example
20671 @noindent
20672 The dynamic block's writer function:
20674 @lisp
20675 (defun org-dblock-write:block-update-time (params)
20676   (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
20677     (insert "Last block update at: "
20678             (format-time-string fmt))))
20679 @end lisp
20681 To keep dynamic blocks up-to-date in an Org file, use the function,
20682 @code{org-update-all-dblocks} in hook, such as @code{before-save-hook}.  The
20683 @code{org-update-all-dblocks} function does not run if the file is not in
20684 Org mode.
20686 @findex org-narrow-to-block
20687 Dynamic blocks, like any other block, can be narrowed with
20688 @code{org-narrow-to-block}.
20690 @node Special Agenda Views
20691 @appendixsec Special Agenda Views
20693 @cindex agenda views, user-defined
20695 @vindex org-agenda-skip-function
20696 @vindex org-agenda-skip-function-global
20697 Org provides a special hook to further limit items in agenda views:
20698 @code{agenda}, @code{agenda*}@footnote{The @code{agenda*} view is the same as @code{agenda} except that it
20699 only considers @emph{appointments}, i.e., scheduled and deadline items that
20700 have a time specification @samp{[h]h:mm} in their time-stamps.}, @code{todo}, @code{alltodo}, @code{tags}, @code{tags-todo},
20701 @code{tags-tree}.  Specify a custom function that tests inclusion of every
20702 matched item in the view.  This function can also skip as much as is
20703 needed.
20705 For a global condition applicable to agenda views, use the
20706 @code{org-agenda-skip-function-global} variable.  Org uses a global
20707 condition with @code{org-agenda-skip-function} for custom searching.
20709 This example defines a function for a custom view showing TODO items
20710 with @samp{waiting} status.  Manually this is a multi-step search process,
20711 but with a custom view, this can be automated as follows:
20713 The custom function searches the subtree for the @samp{waiting} tag and
20714 returns @code{nil} on match.  Otherwise it gives the location from where
20715 the search continues.
20717 @lisp
20718 (defun my-skip-unless-waiting ()
20719   "Skip trees that are not waiting"
20720   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
20721     (if (re-search-forward ":waiting:" subtree-end t)
20722         nil          ; tag found, do not skip
20723       subtree-end))) ; tag not found, continue after end of subtree
20724 @end lisp
20726 To use this custom function in a custom agenda command:
20728 @lisp
20729 (org-add-agenda-custom-command
20730  '("b" todo "PROJECT"
20731    ((org-agenda-skip-function 'my-skip-unless-waiting)
20732     (org-agenda-overriding-header "Projects waiting for something: "))))
20733 @end lisp
20735 @vindex org-agenda-overriding-header
20736 Note that this also binds @code{org-agenda-overriding-header} to a more
20737 meaningful string suitable for the agenda view.
20739 @vindex org-odd-levels-only
20740 @vindex org-agenda-skip-function
20741 Search for entries with a limit set on levels for the custom search.
20742 This is a general approach to creating custom searches in Org.  To
20743 include all levels, use @samp{LEVEL>0}@footnote{Note that, for @code{org-odd-levels-only}, a level number
20744 corresponds to order in the hierarchy, not to the number of stars.}.  Then to selectively pick
20745 the matched entries, use @code{org-agenda-skip-function}, which also
20746 accepts Lisp forms, such as @code{org-agenda-skip-entry-if} and
20747 @code{org-agenda-skip-subtree-if}.  For example:
20749 @table @asis
20750 @item @code{(org-agenda-skip-entry-if 'scheduled)}
20751 Skip current entry if it has been scheduled.
20753 @item @code{(org-agenda-skip-entry-if 'notscheduled)}
20754 Skip current entry if it has not been scheduled.
20756 @item @code{(org-agenda-skip-entry-if 'deadline)}
20757 Skip current entry if it has a deadline.
20759 @item @code{(org-agenda-skip-entry-if 'scheduled 'deadline)}
20760 Skip current entry if it has a deadline, or if it is scheduled.
20762 @item @code{(org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))}
20763 Skip current entry if the TODO keyword is TODO or WAITING.
20765 @item @code{(org-agenda-skip-entry-if 'todo 'done)}
20766 Skip current entry if the TODO keyword marks a DONE state.
20768 @item @code{(org-agenda-skip-entry-if 'timestamp)}
20769 Skip current entry if it has any timestamp, may also be deadline
20770 or scheduled.
20772 @item @code{(org-agenda-skip-entry-if 'regexp "regular expression")}
20773 Skip current entry if the regular expression matches in the
20774 entry.
20776 @item @code{(org-agenda-skip-entry-if 'notregexp "regular expression")}
20777 Skip current entry unless the regular expression matches.
20779 @item @code{(org-agenda-skip-subtree-if 'regexp "regular expression")}
20780 Same as above, but check and skip the entire subtree.
20781 @end table
20783 The following is an example of a search for @samp{waiting} without the
20784 special function:
20786 @lisp
20787 (org-add-agenda-custom-command
20788  '("b" todo "PROJECT"
20789    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
20790                                 'regexp ":waiting:"))
20791     (org-agenda-overriding-header "Projects waiting for something: "))))
20792 @end lisp
20794 @node Speeding Up Your Agendas
20795 @appendixsec Speeding Up Your Agendas
20797 @cindex agenda views, optimization
20799 Some agenda commands slow down when the Org files grow in size or
20800 number.  Here are tips to speed up:
20802 @itemize
20803 @item
20804 Reduce the number of Org agenda files to avoid slowdowns due to hard drive
20805 accesses.
20807 @item
20808 Reduce the number of DONE and archived headlines so agenda
20809 operations that skip over these can finish faster.
20811 @item
20812 Do not dim blocked tasks:
20813 @vindex org-agenda-dim-blocked-tasks
20815 @lisp
20816 (setq org-agenda-dim-blocked-tasks nil)
20817 @end lisp
20819 @item
20820 Stop preparing agenda buffers on startup:
20821 @vindex org-startup-folded
20822 @vindex org-agenda-inhibit-startup
20824 @lisp
20825 (setq org-agenda-inhibit-startup nil)
20826 @end lisp
20828 @item
20829 Disable tag inheritance for agendas:
20830 @vindex org-agenda-show-inherited-tags
20831 @vindex org-agenda-use-tag-inheritance
20833 @lisp
20834 (setq org-agenda-use-tag-inheritance nil)
20835 @end lisp
20836 @end itemize
20838 These options can be applied to selected agenda views.  For more
20839 details about generation of agenda views, see the docstrings for the
20840 relevant variables, and this @uref{https://orgmode.org/worg/agenda-optimization.html, dedicated Worg page} for agenda
20841 optimization.
20843 @node Extracting Agenda Information
20844 @appendixsec Extracting Agenda Information
20846 @cindex agenda, pipe
20847 @cindex scripts, for agenda processing
20849 Org provides commands to access agendas through Emacs batch mode.
20850 Through this command-line interface, agendas are automated for further
20851 processing or printing.
20853 @vindex org-agenda-custom-commands
20854 @findex org-batch-agenda
20855 @code{org-batch-agenda} creates an agenda view in ASCII and outputs to
20856 standard output.  This command takes one string parameter.  When
20857 string consists of a single character, Org uses it as a key to
20858 @code{org-agenda-custom-commands}.  These are the same ones available
20859 through the agenda dispatcher (see @ref{Agenda Dispatcher}).
20861 This example command line directly prints the TODO list to the printer:
20863 @example
20864 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
20865 @end example
20867 When the string parameter length is two or more characters, Org
20868 matches it with tags/TODO strings.  For example, this example command
20869 line prints items tagged with @samp{shop}, but excludes items tagged with
20870 @samp{NewYork}:
20872 @example
20873 emacs -batch -l ~/.emacs                                      \
20874       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
20875 @end example
20877 @noindent
20878 An example showing on-the-fly parameter modifications:
20880 @example
20881 emacs -batch -l ~/.emacs                                      \
20882    -eval '(org-batch-agenda "a"                               \
20883            org-agenda-span (quote month)                      \
20884            org-agenda-include-diary nil                       \
20885            org-agenda-files (quote ("~/org/project.org")))'   \
20886    | lpr
20887 @end example
20889 @noindent
20890 which produces an agenda for the next 30 days from just the
20891 @samp{~/org/projects.org} file.
20893 @findex org-batch-agenda-csv
20894 For structured processing of agenda output, use @code{org-batch-agenda-csv}
20895 with the following fields:
20897 @table @asis
20898 @item category
20899 The category of the item
20900 @item head
20901 The headline, without TODO keyword, TAGS and PRIORITY
20902 @item type
20903 The type of the agenda entry, can be
20905 @multitable {aaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
20906 @item @code{todo}
20907 @tab selected in TODO match
20908 @item @code{tagsmatch}
20909 @tab selected in tags match
20910 @item @code{diary}
20911 @tab imported from diary
20912 @item @code{deadline}
20913 @tab a deadline
20914 @item @code{scheduled}
20915 @tab scheduled
20916 @item @code{timestamp}
20917 @tab appointment, selected by timestamp
20918 @item @code{closed}
20919 @tab entry was closed on date
20920 @item @code{upcoming-deadline}
20921 @tab warning about nearing deadline
20922 @item @code{past-scheduled}
20923 @tab forwarded scheduled item
20924 @item @code{block}
20925 @tab entry has date block including date
20926 @end multitable
20928 @item todo
20929 The TODO keyword, if any
20930 @item tags
20931 All tags including inherited ones, separated by colons
20932 @item date
20933 The relevant date, like @samp{2007-2-14}
20934 @item time
20935 The time, like @samp{15:00-16:50}
20936 @item extra
20937 String with extra planning info
20938 @item priority-l
20939 The priority letter if any was given
20940 @item priority-n
20941 The computed numerical priority
20942 @end table
20944 @noindent
20945 If the selection of the agenda item was based on a timestamp,
20946 including those items with @samp{DEADLINE} and @samp{SCHEDULED} keywords, then
20947 Org includes date and time in the output.
20949 If the selection of the agenda item was based on a timestamp  (or
20950 deadline/scheduled), then Org includes date and time in the output.
20952 Here is an example of a post-processing script in Perl.  It takes the
20953 CSV output from Emacs and prints with a checkbox:
20955 @example
20956 #!/usr/bin/perl
20958 # define the Emacs command to run
20959 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
20961 # run it and capture the output
20962 $agenda = qx@{$cmd 2>/dev/null@};
20964 # loop over all lines
20965 foreach $line (split(/\n/,$agenda)) @{
20966     # get the individual values
20967     ($category,$head,$type,$todo,$tags,$date,$time,$extra,
20968      $priority_l,$priority_n) = split(/,/,$line);
20969     # process and print
20970     print "[ ] $head\n";
20972 @end example
20974 @node Using the Property API
20975 @appendixsec Using the Property API
20977 @cindex API, for properties
20978 @cindex properties, API
20980 Here is a description of the functions that can be used to work with
20981 properties.
20983 @defun org-entry-properties &optional pom which
20984 Get all properties of the entry at point-or-marker @var{POM}.
20985 This includes the TODO keyword, the tags, time strings for deadline,
20986 scheduled, and clocking, and any additional properties defined in the
20987 entry.  The return value is an alist.  Keys may occur multiple times
20988 if the property key was used several times.  @var{POM} may also
20989 be @code{nil}, in which case the current entry is used.  If
20990 @var{WHICH} is @code{nil} or @code{all}, get all properties.  If
20991 @var{WHICH} is @code{special} or @code{standard}, only get that subclass.
20992 @end defun
20994 @vindex org-use-property-inheritance
20995 @findex org-insert-property-drawer
20996 @defun org-entry-get pom property &optional inherit
20997 Get value of @var{PROPERTY} for entry at point-or-marker
20998 @var{POM}.  By default, this only looks at properties defined
20999 locally in the entry.  If @var{INHERIT} is non-@code{nil} and the
21000 entry does not have the property, then also check higher levels of the
21001 hierarchy.  If @var{INHERIT} is the symbol @code{selective}, use
21002 inheritance if and only if the setting of
21003 @code{org-use-property-inheritance} selects @var{PROPERTY} for
21004 inheritance.
21005 @end defun
21007 @defun org-entry-delete pom property
21008 Delete the property @var{PROPERTY} from entry at point-or-marker
21009 @var{POM}.
21010 @end defun
21012 @defun org-entry-put pom property value
21013 Set @var{PROPERTY} to @var{VALUES} for entry at
21014 point-or-marker POM.
21015 @end defun
21017 @defun org-buffer-property-keys &optional include-specials
21018 Get all property keys in the current buffer.
21019 @end defun
21021 @defun org-insert-property-drawer
21022 Insert a property drawer for the current entry.  Also
21023 @end defun
21025 @defun org-entry-put-multivalued-property pom property &rest values
21026 Set @var{PROPERTY} at point-or-marker @var{POM} to
21027 @var{VALUES}.  @var{VALUES} should be a list of strings.
21028 They are concatenated, with spaces as separators.
21029 @end defun
21031 @defun org-entry-get-multivalued-property pom property
21032 Treat the value of the property @var{PROPERTY} as
21033 a whitespace-separated list of values and return the values as a list
21034 of strings.
21035 @end defun
21037 @defun org-entry-add-to-multivalued-property pom property value
21038 Treat the value of the property @var{PROPERTY} as
21039 a whitespace-separated list of values and make sure that
21040 @var{VALUE} is in this list.
21041 @end defun
21043 @defun org-entry-remove-from-multivalued-property pom property value
21044 Treat the value of the property @var{PROPERTY} as
21045 a whitespace-separated list of values and make sure that
21046 @var{VALUE} is @emph{not} in this list.
21047 @end defun
21049 @defun org-entry-member-in-multivalued-property pom property value
21050 Treat the value of the property @var{PROPERTY} as
21051 a whitespace-separated list of values and check if @var{VALUE} is
21052 in this list.
21053 @end defun
21055 @defopt org-property-allowed-value-functions
21056 Hook for functions supplying allowed values for a specific property.
21057 The functions must take a single argument, the name of the property,
21058 and return a flat list of allowed values.  If @samp{:ETC} is one of the
21059 values, use the values as completion help, but allow also other values
21060 to be entered.  The functions must return @code{nil} if they are not
21061 responsible for this property.
21062 @end defopt
21064 @node Using the Mapping API
21065 @appendixsec Using the Mapping API
21067 @cindex API, for mapping
21068 @cindex mapping entries, API
21070 Org has sophisticated mapping capabilities to find all entries
21071 satisfying certain criteria.  Internally, this functionality is used
21072 to produce agenda views, but there is also an API that can be used to
21073 execute arbitrary functions for each or selected entries.  The main
21074 entry point for this API is:
21076 @defun org-map-entries func &optional match scope &rest skip
21077 Call @{@{@{(var(FUNC))@}@}@} at each headline selected by @var{MATCH}
21078 in @var{SCOPE}.
21080 @var{FUNC} is a function or a Lisp form.  With the cursor
21081 positioned at the beginning of the headline, call the function without
21082 arguments.  Org returns an alist of return values of calls to the
21083 function.
21085 To avoid preserving point, Org wraps the call to @var{FUNC} in
21086 save-excursion form.  After evaluation, Org moves the cursor to the
21087 end of the line that was just processed.  Search continues from that
21088 point forward.  This may not always work as expected under some
21089 conditions, such as if the current sub-tree was removed by a previous
21090 archiving operation.  In such rare circumstances, Org skips the next
21091 entry entirely when it should not.  To stop Org from such skips, make
21092 @var{FUNC} set the variable @code{org-map-continue-from} to a specific
21093 buffer position.
21095 @var{MATCH} is a tags/property/TODO match.  Org iterates only
21096 matched headlines.  Org iterates over all headlines when
21097 @var{MATCH} is @code{nil} or @code{t}.
21099 @var{SCOPE} determines the scope of this command.  It can be any
21102 @table @asis
21103 @item @code{nil}
21104 The current buffer, respecting the restriction, if any.
21106 @item @code{tree}
21107 The subtree started with the entry at point.
21109 @item @code{region}
21110 The entries within the active region, if any.
21112 @item @code{file}
21113 The current buffer, without restriction.
21115 @item @code{file-with-archives}
21116 The current buffer, and any archives associated with it.
21118 @item @code{agenda}
21119 All agenda files.
21121 @item @code{agenda-with-archives}
21122 All agenda files with any archive files associated with them.
21124 @item @code{(file1 file2 ...)}
21125 If this is a list, all files in the list are scanned.
21126 @end table
21128 @noindent
21129 The remaining arguments are treated as settings for the scanner's
21130 skipping facilities.  Valid arguments are:
21132 @table @asis
21133 @item @code{archive}
21134 Skip trees with the archive tag.
21136 @item @code{comment}
21137 Skip trees with the COMMENT keyword.
21139 @item function or Lisp form
21140 @vindex org-agenda-skip-function
21141 Used as value for @code{org-agenda-skip-function}, so whenever the
21142 function returns @code{t}, @var{FUNC} is called for that entry
21143 and search continues from the point where the function leaves it.
21144 @end table
21145 @end defun
21147 The mapping routine can call any arbitrary function, even functions
21148 that change meta data or query the property API (see @ref{Using the Property API}).  Here are some handy functions:
21150 @defun org-todo &optional arg
21151 Change the TODO state of the entry.  See the docstring of the
21152 functions for the many possible values for the argument
21153 @var{ARG}.
21154 @end defun
21156 @defun org-priority &optional action
21157 Change the priority of the entry.  See the docstring of this function
21158 for the possible values for @var{ACTION}.
21159 @end defun
21161 @defun org-toggle-tag tag &optional onoff
21162 Toggle the tag @var{TAG} in the current entry.  Setting
21163 @var{ONOFF} to either @code{on} or @code{off} does not toggle tag, but
21164 ensure that it is either on or off.
21165 @end defun
21167 @defun org-promote
21168 Promote the current entry.
21169 @end defun
21171 @defun org-demote
21172 Demote the current entry.
21173 @end defun
21175 This example turns all entries tagged with @samp{TOMORROW} into TODO
21176 entries with keyword @samp{UPCOMING}.  Org ignores entries in comment trees
21177 and archive trees.
21179 @lisp
21180 (org-map-entries '(org-todo "UPCOMING")
21181                  "+TOMORROW" 'file 'archive 'comment)
21182 @end lisp
21184 The following example counts the number of entries with TODO keyword
21185 @samp{WAITING}, in all agenda files.
21187 @lisp
21188 (length (org-map-entries t "/+WAITING" 'agenda))
21189 @end lisp
21191 @node MobileOrg
21192 @appendix MobileOrg
21194 @cindex iPhone
21195 @cindex smartphone
21196 @cindex android
21197 @cindex MobileOrg
21199 MobileOrg is a companion mobile app that runs on iOS and Android
21200 devices.  MobileOrg enables offline-views and capture support for an
21201 Org mode system that is rooted on a ``real'' computer.  MobileOrg can
21202 record changes to existing entries.
21204 The @uref{https://github.com/MobileOrg/, iOS implementation} for the @emph{iPhone/iPod Touch/iPad} series of
21205 devices, was started by Richard Moreland and is now in the hands of
21206 Sean Escriva.  Android users should check out @uref{http://wiki.github.com/matburt/mobileorg-android/, MobileOrg Android} by
21207 Matt Jones.  Though the two implementations are not identical, they
21208 offer similar features.
21210 This appendix describes Org's support for agenda view formats
21211 compatible with MobileOrg.  It also describes synchronizing changes,
21212 such as to notes, between MobileOrg and the computer.
21214 To change tags and TODO states in MobileOrg, first customize the
21215 variables @code{org-todo-keywords} and @code{org-tag-alist}.  These should cover
21216 all the important tags and TODO keywords, even if Org files use only
21217 some of them.  Though MobileOrg has in-buffer settings, it understands
21218 TODO states @emph{sets} (see @ref{Per-file keywords}) and
21219 @emph{mutually exclusive} tags (see @ref{Setting Tags}) only for those set in
21220 these variables.
21222 @menu
21223 * Setting Up the Staging Area::  For the mobile device.
21224 * Pushing to MobileOrg::         Uploading Org files and agendas.
21225 * Pulling from MobileOrg::       Integrating captured and flagged items.
21226 @end menu
21228 @node Setting Up the Staging Area
21229 @appendixsec Setting Up the Staging Area
21231 MobileOrg needs access to a file directory on a server to interact
21232 with Emacs.  With a public server, consider encrypting the files.
21233 MobileOrg version 1.5 supports encryption for the iPhone.  Org also
21234 requires @samp{openssl} installed on the local computer.  To turn on
21235 encryption, set the same password in MobileOrg and in Emacs.  Set the
21236 password in the variable @code{org-mobile-use-encryption}@footnote{If Emacs is configured for safe storing of passwords, then
21237 configure the variable, @code{org-mobile-encryption-password}; please read
21238 the docstring of that variable.}.  Note
21239 that even after MobileOrg encrypts the file contents, the file name
21240 remains visible on the file systems of the local computer, the server,
21241 and the mobile device.
21243 For a server to host files, consider options like @uref{http://dropbox.com, Dropbox.com}
21244 account@footnote{An alternative is to use a WebDAV server.  MobileOrg
21245 documentation has details of WebDAV server configuration.  Additional
21246 help is at this @uref{https://orgmode.org/worg/org-faq.html#mobileorg_webdav, FAQ entry}.}.  On first connection, MobileOrg creates a directory
21247 @samp{MobileOrg} on Dropbox.  Pass its location to Emacs through an
21248 initialisation file variable as follows:
21250 @lisp
21251 (setq org-mobile-directory "~/Dropbox/MobileOrg")
21252 @end lisp
21254 Org copies files to the above directory for MobileOrg.  Org also uses
21255 the same directory for sharing notes between Org and MobileOrg.
21257 @node Pushing to MobileOrg
21258 @appendixsec Pushing to MobileOrg
21260 @vindex org-mobile-files
21261 @vindex org-directory
21262 Org pushes files listed in @code{org-mobile-files} to
21263 @code{org-mobile-directory}.  Files include agenda files (as listed in
21264 @code{org-agenda-files}).  Customize @code{org-mobile-files} to add other files.
21265 File names are staged with paths relative to @code{org-directory}, so all
21266 files should be inside this directory@footnote{Symbolic links in @code{org-directory} need to have the same name
21267 as their targets.}.
21269 Push creates a special Org file @samp{agendas.org} with custom agenda views
21270 defined by the user@footnote{While creating the agendas, Org mode forces ID properties on
21271 all referenced entries, so that these entries can be uniquely
21272 identified if MobileOrg flags them for further action.  To avoid
21273 setting properties configure the variable
21274 @code{org-mobile-force-id-on-agenda-items} to @code{nil}.  Org mode then relies
21275 on outline paths, assuming they are unique.}.
21277 Finally, Org writes the file @samp{index.org}, containing links to other
21278 files.  MobileOrg reads this file first from the server to determine
21279 what other files to download for agendas.  For faster downloads,
21280 MobileOrg only reads files whose checksums@footnote{Checksums are stored automatically in the file
21281 @samp{checksums.dat}.} have changed.
21283 @node Pulling from MobileOrg
21284 @appendixsec Pulling from MobileOrg
21286 When MobileOrg synchronizes with the server, it pulls the Org files
21287 for viewing.  It then appends to the file @samp{mobileorg.org} on the
21288 server the captured entries, pointers to flagged and changed entries.
21289 Org integrates its data in an inbox file format.
21291 @enumerate
21292 @item
21293 @vindex org-mobile-inbox-for-pull
21294 Org moves all entries found in @samp{mobileorg.org}@footnote{The file will be empty after this operation.} and appends
21295 them to the file pointed to by the variable
21296 @code{org-mobile-inbox-for-pull}.  Each captured entry and each editing
21297 event is a top-level entry in the inbox file.
21299 @item
21300 After moving the entries, Org attempts changes to MobileOrg.  Some
21301 changes are applied directly and without user interaction.
21302 Examples include changes to tags, TODO state, headline and body
21303 text.  Entries for further action are tagged as @samp{FLAGGED}.  Org
21304 marks entries with problems with an error message in the inbox.
21305 They have to be resolved manually.
21307 @item
21308 Org generates an agenda view for flagged entries for user
21309 intervention to clean up.  For notes stored in flagged entries,
21310 MobileOrg displays them in the echo area when the cursor is on the
21311 corresponding agenda item.
21313 @table @asis
21314 @item @kbd{?}
21315 @kindex ?
21317 Pressing @kbd{?} displays the entire flagged note in
21318 another window.  Org also pushes it to the kill ring.  To
21319 store flagged note as a normal note, use @kbd{? z C-y C-c C-c}.  Pressing@kbd{?} twice does these things: first
21320 it removes the @samp{FLAGGED} tag; second, it removes the flagged
21321 note from the property drawer; third, it signals that manual
21322 editing of the flagged entry is now finished.
21323 @end table
21324 @end enumerate
21326 @kindex ? @r{(Agenda dispatcher)}
21327 From the agenda dispatcher, @kbd{?} returns to the view to finish
21328 processing flagged entries.  Note that these entries may not be the
21329 most recent since MobileOrg searches files that were last pulled.  To
21330 get an updated agenda view with changes since the last pull, pull
21331 again.
21333 @node History and Acknowledgments
21334 @appendix History and Acknowledgments
21338 @anchor{From Carsten}
21339 @appendixsec From Carsten
21341 Org was born in 2003, out of frustration over the user interface of
21342 the Emacs Outline mode.  I was trying to organize my notes and
21343 projects, and using Emacs seemed to be the natural way to go.
21344 However, having to remember eleven different commands with two or
21345 three keys per command, only to hide and show parts of the outline
21346 tree, that seemed entirely unacceptable to me.  Also, when using
21347 outlines to take notes, I constantly wanted to restructure the tree,
21348 organizing it parallel to my thoughts and plans.  @emph{Visibility cycling}
21349 and @emph{structure editing} were originally implemented in the package
21350 @samp{outline-magic.el}, but quickly moved to the more general @samp{org.el}.
21351 As this environment became comfortable for project planning, the next
21352 step was adding @emph{TODO entries}, basic @emph{timestamps}, and @emph{table
21353 support}.  These areas highlighted the two main goals that Org still
21354 has today: to be a new, outline-based, plain text mode with innovative
21355 and intuitive editing features, and to incorporate project planning
21356 functionality directly into a notes file.
21358 Since the first release, literally thousands of emails to me or to the
21359 @email{emacs-orgmode@@gnu.org, mailing list} have provided a constant stream of bug reports, feedback,
21360 new ideas, and sometimes patches and add-on code.  Many thanks to
21361 everyone who has helped to improve this package.  I am trying to keep
21362 here a list of the people who had significant influence in shaping one
21363 or more aspects of Org.  The list may not be complete, if I have
21364 forgotten someone, please accept my apologies and let me know.
21366 Before I get to this list, a few special mentions are in order:
21368 @table @asis
21369 @item Bastien Guerry
21370 Bastien has written a large number of extensions to Org (most of
21371 them integrated into the core by now), including the @LaTeX{}
21372 exporter and the plain list parser.  His support during the early
21373 days was central to the success of this project.  Bastien also
21374 invented Worg, helped establishing the Web presence of Org, and
21375 sponsored hosting costs for the orgmode.org website.  Bastien
21376 stepped in as maintainer of Org between 2011 and 2013, at a time
21377 when I desperately needed a break.
21379 @item Eric Schulte and Dan Davison
21380 Eric and Dan are jointly responsible for the Org Babel system,
21381 which turns Org into a multi-language environment for evaluating
21382 code and doing literate programming and reproducible research.
21383 This has become one of Org's killer features that define what Org
21384 is today.
21386 @item John Wiegley
21387 John has contributed a number of great ideas and patches directly
21388 to Org, including the attachment system (@samp{org-attach.el}),
21389 integration with Apple Mail (@samp{org-mac-message.el}), hierarchical
21390 dependencies of TODO items, habit tracking (@samp{org-habits.el}), and
21391 encryption (@samp{org-crypt.el}).  Also, the capture system is really
21392 an extended copy of his great @samp{remember.el}.
21394 @item Sebastian Rose
21395 Without Sebastian, the HTML/XHTML publishing of Org would be the
21396 pitiful work of an ignorant amateur.  Sebastian has pushed this
21397 part of Org onto a much higher level.  He also wrote
21398 @samp{org-info.js}, a Java script for displaying webpages derived from
21399 Org using an Info-like or a folding interface with single-key
21400 navigation.
21401 @end table
21403 @noindent
21404 See below for the full list of contributions! Again, please let me
21405 know what I am missing here!
21407 @anchor{From Bastien}
21408 @appendixsec From Bastien
21410 I (Bastien) have been maintaining Org between 2011 and 2013.  This
21411 appendix would not be complete without adding a few more
21412 acknowledgments and thanks.
21414 I am first grateful to Carsten for his trust while handing me over the
21415 maintainership of Org.  His unremitting support is what really helped
21416 me getting more confident over time, with both the community and the
21417 code.
21419 When I took over maintainership, I knew I would have to make Org more
21420 collaborative than ever, as I would have to rely on people that are
21421 more knowledgeable than I am on many parts of the code.  Here is
21422 a list of the persons I could rely on, they should really be
21423 considered co-maintainers, either of the code or the community:
21425 @table @asis
21426 @item Eric Schulte
21427 Eric is maintaining the Babel parts of Org.  His reactivity here
21428 kept me away from worrying about possible bugs here and let me
21429 focus on other parts.
21431 @item Nicolas Goaziou
21432 Nicolas is maintaining the consistency of the deepest parts of
21433 Org.  His work on @samp{org-element.el} and @samp{ox.el} has been
21434 outstanding, and it opened the doors for many new ideas and
21435 features.  He rewrote many of the old exporters to use the new
21436 export engine, and helped with documenting this major change.
21437 More importantly (if that's possible), he has been more than
21438 reliable during all the work done for Org 8.0, and always very
21439 reactive on the mailing list.
21441 @item Achim Gratz
21442 Achim rewrote the building process of Org, turning some @emph{ad hoc}
21443 tools into a flexible and conceptually clean process.  He
21444 patiently coped with the many hiccups that such a change can
21445 create for users.
21447 @item Nick Dokos
21448 The Org mode mailing list would not be such a nice place without
21449 Nick, who patiently helped users so many times.  It is impossible
21450 to overestimate such a great help, and the list would not be so
21451 active without him.
21452 @end table
21454 I received support from so many users that it is clearly impossible to
21455 be fair when shortlisting a few of them, but Org's history would not
21456 be complete if the ones above were not mentioned in this manual.
21458 @anchor{List of Contributions}
21459 @appendixsec List of Contributions
21461 @itemize
21462 @item
21463 Russel Adams came up with the idea for drawers.
21465 @item
21466 Thomas Baumann wrote @samp{org-bbdb.el} and @samp{org-mhe.el}.
21468 @item
21469 Christophe Bataillon created the great unicorn logo that we use on
21470 the Org mode website.
21472 @item
21473 Alex Bochannek provided a patch for rounding timestamps.
21475 @item
21476 Jan Böcker wrote @samp{org-docview.el}.
21478 @item
21479 Brad Bozarth showed how to pull RSS feed data into Org files.
21481 @item
21482 Tom Breton wrote @samp{org-choose.el}.
21484 @item
21485 Charles Cave's suggestion sparked the implementation of templates
21486 for Remember, which are now templates for capture.
21488 @item
21489 Pavel Chalmoviansky influenced the agenda treatment of items with
21490 specified time.
21492 @item
21493 Gregory Chernov patched support for Lisp forms into table
21494 calculations and improved XEmacs compatibility, in particular by
21495 porting @samp{nouline.el} to XEmacs.
21497 @item
21498 Sacha Chua suggested copying some linking code from Planner.
21500 @item
21501 Baoqiu Cui contributed the DocBook exporter.
21503 @item
21504 Eddward DeVilla proposed and tested checkbox statistics.  He also
21505 came up with the idea of properties, and that there should be an API
21506 for them.
21508 @item
21509 Nick Dokos tracked down several nasty bugs.
21511 @item
21512 Kees Dullemond used to edit projects lists directly in HTML and so
21513 inspired some of the early development, including HTML export.  He
21514 also asked for a way to narrow wide table columns.
21516 @item
21517 Thomas S. Dye contributed documentation on Worg and helped
21518 integrating the Org Babel documentation into the manual.
21520 @item
21521 Christian Egli converted the documentation into Texinfo format,
21522 inspired the agenda, patched CSS formatting into the HTML exporter,
21523 and wrote @samp{org-taskjuggler.el}.
21525 @item
21526 David Emery provided a patch for custom CSS support in exported HTML
21527 agendas.
21529 @item
21530 Nic Ferrier contributed mailcap and XOXO support.
21532 @item
21533 Miguel A.  Figueroa-Villanueva implemented hierarchical checkboxes.
21535 @item
21536 John Foerch figured out how to make incremental search show context
21537 around a match in a hidden outline tree.
21539 @item
21540 Raimar Finken wrote @samp{org-git-line.el}.
21542 @item
21543 Mikael Fornius works as a mailing list moderator.
21545 @item
21546 Austin Frank works as a mailing list moderator.
21548 @item
21549 Eric Fraga drove the development of Beamer export with ideas and
21550 testing.
21552 @item
21553 Barry Gidden did proofreading the manual in preparation for the book
21554 publication through Network Theory Ltd.
21556 @item
21557 Niels Giesen had the idea to automatically archive DONE trees.
21559 @item
21560 Nicolas Goaziou rewrote much of the plain list code.
21562 @item
21563 Kai Grossjohann pointed out key-binding conflicts with other
21564 packages.
21566 @item
21567 Brian Gough of Network Theory Ltd publishes the Org mode manual as
21568 a book.
21570 @item
21571 Bernt Hansen has driven much of the support for auto-repeating
21572 tasks, task state change logging, and the clocktable.  His clear
21573 explanations have been critical when we started to adopt the Git
21574 version control system.
21576 @item
21577 Manuel Hermenegildo has contributed various ideas, small fixes and
21578 patches.
21580 @item
21581 Phil Jackson wrote @samp{org-irc.el}.
21583 @item
21584 Scott Jaderholm proposed footnotes, control over whitespace between
21585 folded entries, and column view for properties.
21587 @item
21588 Matt Jones wrote MobileOrg Android.
21590 @item
21591 Tokuya Kameshima wrote @samp{org-wl.el} and @samp{org-mew.el}.
21593 @item
21594 Shidai Liu (``Leo'') asked for embedded @LaTeX{} and tested it.  He also
21595 provided frequent feedback and some patches.
21597 @item
21598 Matt Lundin has proposed last-row references for table formulas and
21599 named invisible anchors.  He has also worked a lot on the FAQ.
21601 @item
21602 David Maus wrote @samp{org-atom.el}, maintains the issues file for Org,
21603 and is a prolific contributor on the mailing list with competent
21604 replies, small fixes and patches.
21606 @item
21607 Jason F. McBrayer suggested agenda export to CSV format.
21609 @item
21610 Max Mikhanosha came up with the idea of refiling.
21612 @item
21613 Dmitri Minaev sent a patch to set priority limits on a per-file
21614 basis.
21616 @item
21617 Stefan Monnier provided a patch to keep the Emacs Lisp compiler
21618 happy.
21620 @item
21621 Richard Moreland wrote MobileOrg for the iPhone.
21623 @item
21624 Rick Moynihan proposed allowing multiple TODO sequences in a file
21625 and being able to quickly restrict the agenda to a subtree.
21627 @item
21628 Todd Neal provided patches for links to Info files and Elisp forms.
21630 @item
21631 Greg Newman refreshed the unicorn logo into its current form.
21633 @item
21634 Tim O'Callaghan suggested in-file links, search options for general
21635 file links, and tags.
21637 @item
21638 Osamu Okano wrote @samp{orgcard2ref.pl}, a Perl program to create a text
21639 version of the reference card.
21641 @item
21642 Takeshi Okano translated the manual and David O'Toole's tutorial
21643 into Japanese.
21645 @item
21646 Oliver Oppitz suggested multi-state TODO items.
21648 @item
21649 Scott Otterson sparked the introduction of descriptive text for
21650 links, among other things.
21652 @item
21653 Pete Phillips helped during the development of the TAGS feature,
21654 and provided frequent feedback.
21656 @item
21657 Martin Pohlack provided the code snippet to bundle character
21658 insertion into bundles of 20 for undo.
21660 @item
21661 T.V. Raman reported bugs and suggested improvements.
21663 @item
21664 Matthias Rempe (Oelde) provided ideas, Windows support, and quality
21665 control.
21667 @item
21668 Paul Rivier provided the basic implementation of named footnotes.
21669 He also acted as mailing list moderator for some time.
21671 @item
21672 Kevin Rogers contributed code to access VM files on remote hosts.
21674 @item
21675 Frank Ruell solved the mystery of the @samp{keymapp nil} bug, a conflict
21676 with @samp{allout.el}.
21678 @item
21679 Jason Riedy generalized the send-receive mechanism for Orgtbl
21680 tables with extensive patches.
21682 @item
21683 Philip Rooke created the Org reference card, provided lots of
21684 feedback, developed and applied standards to the Org documentation.
21686 @item
21687 Christian Schlauer proposed angular brackets around links, among
21688 other things.
21690 @item
21691 Paul Sexton wrote @samp{org-ctags.el}.
21693 @item
21694 Tom Shannon's @samp{organizer-mode.el} inspired linking to VM/BBDB/Gnus.
21696 @item
21697 Ilya Shlyakhter proposed the Archive Sibling, line numbering in
21698 literal examples, and remote highlighting for referenced code lines.
21700 @item
21701 Stathis Sideris wrote the @samp{ditaa.jar} ASCII to PNG converter that is
21702 now packaged into Org's @samp{contrib/} directory.
21704 @item
21705 Daniel Sinder came up with the idea of internal archiving by locking
21706 subtrees.
21708 @item
21709 Dale Smith proposed link abbreviations.
21711 @item
21712 James TD Smith has contributed a large number of patches for
21713 useful tweaks and features.
21715 @item
21716 Adam Spiers asked for global linking commands, inspired the link
21717 extension system, added support for Mairix, and proposed the mapping
21718 API.
21720 @item
21721 Ulf Stegemann created the table to translate special symbols to
21722 HTML, @LaTeX{}, UTF-8, Latin-1 and ASCII.
21724 @item
21725 Andy Stewart contributed code to @samp{org-w3m.el}, to copy
21726 HTML content with links transformation to Org syntax.
21728 @item
21729 David O'Toole wrote @samp{org-publish.el} and drafted the
21730 manual chapter about publishing.
21732 @item
21733 Jambunathan K. contributed the ODT exporter.
21735 @item
21736 Sebastien Vauban reported many issues with @LaTeX{} and Beamer export
21737 and enabled source code highlighting in Gnus.
21739 @item
21740 Stefan Vollmar organized a video-recorded talk at the
21741 Max-Planck-Institute for Neurology.  He also inspired the creation
21742 of a concept index for HTML export.
21744 @item
21745 Jürgen Vollmer contributed code generating the table of contents in
21746 HTML output.
21748 @item
21749 Samuel Wales has provided important feedback and bug reports.
21751 @item
21752 Chris Wallace provided a patch implementing the @samp{QUOTE} block.
21754 @item
21755 David Wainberg suggested archiving, and improvements to the
21756 linking system.
21758 @item
21759 Carsten Wimmer suggested some changes and helped fix a bug in
21760 linking to Gnus.
21762 @item
21763 Roland Winkler requested additional key bindings to make Org work on
21764 a TTY.
21766 @item
21767 Piotr Zielinski wrote @samp{org-mouse.el}, proposed agenda
21768 blocks and contributed various ideas and code snippets.
21770 @item
21771 Marco Wahl wrote @samp{org-eww.el}.
21772 @end itemize
21774 @node GNU Free Documentation License
21775 @appendix GNU Free Documentation License
21777 @include doclicense.texi
21779 @node Main Index
21780 @chapter Main Index
21782 @printindex cp
21784 @node Key Index
21785 @chapter Key Index
21787 @printindex ky
21789 @node Command and Function Index
21790 @chapter Command and Function Index
21792 @printindex fn
21794 @node Variable Index
21795 @chapter Variable Index
21797 This is not a complete index of variables and faces, only the ones
21798 that are mentioned in the manual.  For a more complete list, use
21799 @kbd{M-x org-customize} and then click yourself through the tree.
21801 @printindex vr
21803 @bye