org-manual: Improve list of Babel languages
[org-mode/org-tableheadings.git] / doc / org.texi
blobb2bb0ca96afec6ef2d66c9b2be4e2f321ccdd829
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 @vindex org-agenda-search-headline-for-time
9712 In the headline of the entry itself, a time(range)---like @samp{12:45} or
9713 a @samp{8:30-1pm}---may also appear as plain text@footnote{You can, however, disable this by setting
9714 @code{org-agenda-search-headline-for-time} variable to a @code{nil} value.}.
9716 If the agenda integrates the Emacs diary (see @ref{Weekly/daily agenda}),
9717 time specifications in diary entries are recognized as well.
9719 For agenda display, Org mode extracts the time and displays it in
9720 a standard 24 hour format as part of the prefix.  The example times in
9721 the previous paragraphs would end up in the agenda like this:
9723 @example
9724  8:30-13:00 Arthur Dent lies in front of the bulldozer
9725 12:45...... Ford Prefect arrives and takes Arthur to the pub
9726 19:00...... The Vogon reads his poem
9727 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9728 @end example
9730 @cindex time grid
9731 If the agenda is in single-day mode, or for the display of today, the
9732 timed entries are embedded in a time grid, like
9734 @example
9735  8:00...... ------------------
9736  8:30-13:00 Arthur Dent lies in front of the bulldozer
9737 10:00...... ------------------
9738 12:00...... ------------------
9739 12:45...... Ford Prefect arrives and takes Arthur to the pub
9740 14:00...... ------------------
9741 16:00...... ------------------
9742 18:00...... ------------------
9743 19:00...... The Vogon reads his poem
9744 20:00...... ------------------
9745 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9746 @end example
9748 @vindex org-agenda-use-time-grid
9749 @vindex org-agenda-time-grid
9750 The time grid can be turned on and off with the variable
9751 @code{org-agenda-use-time-grid}, and can be configured with
9752 @code{org-agenda-time-grid}.
9754 @node Sorting of agenda items
9755 @subsection Sorting of agenda items
9757 @cindex sorting, of agenda items
9758 @cindex priorities, of agenda items
9760 Before being inserted into a view, the items are sorted.  How this is
9761 done depends on the type of view.
9763 @itemize
9764 @item
9765 @vindex org-agenda-files
9766 For the daily/weekly agenda, the items for each day are sorted.  The
9767 default order is to first collect all items containing an explicit
9768 time-of-day specification.  These entries are shown at the beginning
9769 of the list, as a @emph{schedule} for the day.  After that, items remain
9770 grouped in categories, in the sequence given by @code{org-agenda-files}.
9771 Within each category, items are sorted by priority (see
9772 @ref{Priorities}), which is composed of the base priority (2000 for
9773 priority @samp{A}, 1000 for @samp{B}, and 0 for @samp{C}), plus additional
9774 increments for overdue scheduled or deadline items.
9776 @item
9777 For the TODO list, items remain in the order of categories, but
9778 within each category, sorting takes place according to priority (see
9779 @ref{Priorities}).  The priority used for sorting derives from the
9780 priority cookie, with additions depending on how close an item is to
9781 its due or scheduled date.
9783 @item
9784 For tags matches, items are not sorted at all, but just appear in
9785 the sequence in which they are found in the agenda files.
9786 @end itemize
9788 @vindex org-agenda-sorting-strategy
9789 Sorting can be customized using the variable
9790 @code{org-agenda-sorting-strategy}, and may also include criteria based on
9791 the estimated effort of an entry (see @ref{Effort Estimates}).
9793 @node Filtering/limiting agenda times
9794 @subsection Filtering/limiting agenda times
9796 Agenda built-in or customized commands are statically defined.  Agenda
9797 filters and limits provide two ways of dynamically narrowing down the
9798 list of agenda entries: @emph{filters} and @emph{limits}.  Filters only act on
9799 the display of the items, while limits take effect before the list of
9800 agenda entries is built.  Filters are more often used interactively,
9801 while limits are mostly useful when defined as local variables within
9802 custom agenda commands.
9804 @anchor{Filtering in the agenda}
9805 @subsubheading Filtering in the agenda
9807 @cindex agenda filtering
9808 @cindex filtering entries, in agenda
9809 @cindex tag filtering, in agenda
9810 @cindex category filtering, in agenda
9811 @cindex top headline filtering, in agenda
9812 @cindex effort filtering, in agenda
9813 @cindex query editing, in agenda
9815 @table @asis
9816 @item @kbd{/} (@code{org-agenda-filter-by-tag})
9817 @findex org-agenda-filter-by-tag
9818 @vindex org-agenda-tag-filter-preset
9819 Filter the agenda view with respect to a tag and/or effort
9820 estimates.  The difference between this and a custom agenda
9821 command is that filtering is very fast, so that you can switch
9822 quickly between different filters without having to recreate the
9823 agenda.@footnote{Custom commands can preset a filter by binding the variable
9824 @code{org-agenda-tag-filter-preset} as an option.  This filter is then
9825 applied to the view and persists as a basic filter through refreshes
9826 and more secondary filtering.  The filter is a global property of the
9827 entire agenda view---in a block agenda, you should only set this in
9828 the global options section, not in the section of an individual block.}
9830 You are prompted for a tag selection letter; @kbd{@key{SPC}} means
9831 any tag at all.  Pressing @kbd{@key{TAB}} at that prompt offers
9832 completion to select a tag, including any tags that do not have
9833 a selection character.  The command then hides all entries that
9834 do not contain or inherit this tag.  When called with prefix
9835 argument, remove the entries that @emph{do} have the tag.  A second
9836 @kbd{/} at the prompt turns off the filter and shows any
9837 hidden entries.  Pressing @kbd{+} or @kbd{-} switches
9838 between filtering and excluding the next tag.
9840 @vindex org-agenda-auto-exclude-function
9841 Org also supports automatic, context-aware tag filtering.  If the
9842 variable @code{org-agenda-auto-exclude-function} is set to
9843 a user-defined function, that function can decide which tags
9844 should be excluded from the agenda automatically.  Once this is
9845 set, the @kbd{/} command then accepts @kbd{@key{RET}} as
9846 a sub-option key and runs the auto exclusion logic.  For example,
9847 let's say you use a @samp{Net} tag to identify tasks which need
9848 network access, an @samp{Errand} tag for errands in town, and a @samp{Call}
9849 tag for making phone calls.  You could auto-exclude these tags
9850 based on the availability of the Internet, and outside of
9851 business hours, with something like this:
9853 @lisp
9854 (defun org-my-auto-exclude-function (tag)
9855   (and (cond
9856         ((string= tag "Net")
9857          (/= 0 (call-process "/sbin/ping" nil nil nil
9858                              "-c1" "-q" "-t1" "mail.gnu.org")))
9859         ((or (string= tag "Errand") (string= tag "Call"))
9860          (let ((hour (nth 2 (decode-time))))
9861            (or (< hour 8) (> hour 21)))))
9862        (concat "-" tag)))
9864 (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
9865 @end lisp
9867 @item @kbd{<} (@code{org-agenda-filter-by-category})
9868 @findex org-agenda-filter-by-category
9869 Filter the current agenda view with respect to the category of
9870 the item at point.  Pressing @kbd{<} another time removes
9871 this filter.  When called with a prefix argument exclude the
9872 category of the item at point from the agenda.
9874 @vindex org-agenda-category-filter-preset
9875 You can add a filter preset in custom agenda commands through the
9876 option @code{org-agenda-category-filter-preset}.  See @ref{Setting options}.
9878 @item @kbd{^} (@code{org-agenda-filter-by-top-headline})
9879 @findex org-agenda-filter-by-top-headline
9880 Filter the current agenda view and only display the siblings and
9881 the parent headline of the one at point.
9883 @item @kbd{=} (@code{org-agenda-filter-by-regexp})
9884 @findex org-agenda-filter-by-regexp
9885 Filter the agenda view by a regular expression: only show agenda
9886 entries matching the regular expression the user entered.  When
9887 called with a prefix argument, it filters @emph{out} entries matching
9888 the regexp.  With two universal prefix arguments, it removes all
9889 the regexp filters, which can be accumulated.
9891 @vindex org-agenda-regexp-filter-preset
9892 You can add a filter preset in custom agenda commands through the
9893 option @code{org-agenda-regexp-filter-preset}.  See @ref{Setting options}.
9895 @item @kbd{_} (@code{org-agenda-filter-by-effort})
9896 @findex org-agenda-filter-by-effort
9897 Filter the agenda view with respect to effort estimates.  You
9898 first need to set up allowed efforts globally, for example
9900 @lisp
9901 (setq org-global-properties
9902       '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
9903 @end lisp
9905 @vindex org-sort-agenda-noeffort-is-high
9906 You can then filter for an effort by first typing an operator,
9907 one of @kbd{<}, @kbd{>} and @kbd{=}, and then the
9908 one-digit index of an effort estimate in your array of allowed
9909 values, where @kbd{0} means the 10th value.  The filter then
9910 restricts to entries with effort smaller-or-equal, equal, or
9911 larger-or-equal than the selected value.  For application of the
9912 operator, entries without a defined effort are treated according
9913 to the value of @code{org-sort-agenda-noeffort-is-high}.
9915 When called with a prefix argument, it removes entries matching
9916 the condition.  With two universal prefix arguments, it clears
9917 effort filters, which can be accumulated.
9919 @vindex org-agenda-effort-filter-preset
9920 You can add a filter preset in custom agenda commands through the
9921 option @code{org-agenda-effort-filter-preset}.  See @ref{Setting options}.
9923 @item @kbd{|} (@code{org-agenda-filter-remove-all})
9924 Remove all filters in the current agenda view.
9925 @end table
9927 @anchor{Setting limits for the agenda}
9928 @subsubheading Setting limits for the agenda
9930 @cindex limits, in agenda
9932 Here is a list of options that you can set, either globally, or
9933 locally in your custom agenda views (see @ref{Custom Agenda Views}).
9935 @table @asis
9936 @item @code{org-agenda-max-entries}
9937 @vindex org-agenda-max-entries
9938 Limit the number of entries.
9940 @item @code{org-agenda-max-effort}
9941 @vindex org-agenda-max-effort
9942 Limit the duration of accumulated efforts (as minutes).
9944 @item @code{org-agenda-max-todos}
9945 @vindex org-agenda-max-todos
9946 Limit the number of entries with TODO keywords.
9948 @item @code{org-agenda-max-tags}
9949 @vindex org-agenda-max-tags
9950 Limit the number of tagged entries.
9951 @end table
9953 When set to a positive integer, each option excludes entries from
9954 other categories: for example, @code{(setq org-agenda-max-effort 100)}
9955 limits the agenda to 100 minutes of effort and exclude any entry that
9956 has no effort property.  If you want to include entries with no effort
9957 property, use a negative value for @code{org-agenda-max-effort}.  One
9958 useful setup is to use @code{org-agenda-max-entries} locally in a custom
9959 command.  For example, this custom command displays the next five
9960 entries with a @samp{NEXT} TODO keyword.
9962 @lisp
9963 (setq org-agenda-custom-commands
9964       '(("n" todo "NEXT"
9965          ((org-agenda-max-entries 5)))))
9966 @end lisp
9968 Once you mark one of these five entry as DONE, rebuilding the agenda
9969 will again the next five entries again, including the first entry that
9970 was excluded so far.
9972 You can also dynamically set temporary limits, which are lost when
9973 rebuilding the agenda:
9975 @table @asis
9976 @item @kbd{~} (@code{org-agenda-limit-interactively})
9977 @findex org-agenda-limit-interactively
9978 This prompts for the type of limit to apply and its value.
9979 @end table
9981 @node Agenda Commands
9982 @section Commands in the Agenda Buffer
9984 @cindex commands, in agenda buffer
9986 Entries in the agenda buffer are linked back to the Org file or diary
9987 file where they originate.  You are not allowed to edit the agenda
9988 buffer itself, but commands are provided to show and jump to the
9989 original entry location, and to edit the Org files ``remotely'' from the
9990 agenda buffer.  In this way, all information is stored only once,
9991 removing the risk that your agenda and note files may diverge.
9993 Some commands can be executed with mouse clicks on agenda lines.  For
9994 the other commands, the cursor needs to be in the desired line.
9996 @anchor{Motion (1)}
9997 @subheading Motion
9999 @cindex motion commands in agenda
10001 @table @asis
10002 @item @kbd{n} (@code{org-agenda-next-line})
10003 @kindex n
10004 @findex org-agenda-next-line
10005 Next line (same as @kbd{@key{DOWN}} and @kbd{C-n}).
10007 @item @kbd{p} (@code{org-agenda-previous-line})
10008 @kindex p
10009 @findex org-agenda-previous-line
10010 Previous line (same as @kbd{@key{UP}} and @kbd{C-p}).
10011 @end table
10013 @anchor{View/Go to Org file}
10014 @subheading View/Go to Org file
10016 @cindex view file commands in agenda
10018 @table @asis
10019 @item @kbd{@key{SPC}} or @kbd{mouse-3} (@code{org-agenda-show-and-scroll-up})
10020 @kindex SPC
10021 @kindex mouse-3
10022 @findex org-agenda-show-and-scroll-up
10023 Display the original location of the item in another window.
10024 With a prefix argument, make sure that drawers stay folded.
10026 @item @kbd{L} (@code{org-agenda-recenter})
10027 @findex org-agenda-recenter
10028 Display original location and recenter that window.
10030 @item @kbd{@key{TAB}} or @kbd{mouse-2} (@code{org-agenda-goto})
10031 @kindex TAB
10032 @kindex mouse-2
10033 @findex org-agenda-goto
10034 Go to the original location of the item in another window.
10036 @item @kbd{@key{RET}} (@code{org-agenda-switch-to})
10037 @kindex RET
10038 @findex org-agenda-switch-to
10039 Go to the original location of the item and delete other windows.
10041 @item @kbd{F} (@code{org-agenda-follow-mode})
10042 @kindex F
10043 @findex org-agenda-follow-mode
10044 @vindex org-agenda-start-with-follow-mode
10045 Toggle Follow mode.  In Follow mode, as you move the cursor
10046 through the agenda buffer, the other window always shows the
10047 corresponding location in the Org file.  The initial setting for
10048 this mode in new agenda buffers can be set with the variable
10049 @code{org-agenda-start-with-follow-mode}.
10051 @item @kbd{C-c C-x b} (@code{org-agenda-tree-to-indirect-buffer})
10052 @kindex C-c C-x b
10053 @findex org-agenda-tree-to-indirect-buffer
10054 Display the entire subtree of the current item in an indirect
10055 buffer.  With a numeric prefix argument N, go up to level N and
10056 then take that tree.  If N is negative, go up that many levels.
10057 With a @kbd{C-u} prefix, do not remove the previously used
10058 indirect buffer.
10060 @item @kbd{C-c C-o} (@code{org-agenda-open-link})
10061 @kindex C-c C-o
10062 @findex org-agenda-open-link
10063 Follow a link in the entry.  This offers a selection of any links
10064 in the text belonging to the referenced Org node.  If there is
10065 only one link, follow it without a selection prompt.
10066 @end table
10068 @anchor{Change display}
10069 @subheading Change display
10071 @cindex change agenda display
10072 @cindex display changing, in agenda
10074 @table @asis
10075 @item @kbd{A}
10076 @kindex A
10077 Interactively select another agenda view and append it to the
10078 current view.
10080 @item @kbd{o}
10081 @kindex o
10082 Delete other windows.
10084 @item @kbd{v d} or short @kbd{d} (@code{org-agenda-day-view})
10085 @kindex v d
10086 @kindex d
10087 @findex org-agenda-day-view
10088 Switch to day view.  When switching to day view, this setting
10089 becomes the default for subsequent agenda refreshes.  A numeric
10090 prefix argument may be used to jump directly to a specific day of
10091 the year.  For example, @kbd{32 d} jumps to February 1st.
10092 When setting day view, a year may be encoded in the prefix
10093 argument as well.  For example, @kbd{200712 d} jumps to
10094 January 12, 2007.  If such a year specification has only one or
10095 two digits, it is expanded into one of the 30 next years or the
10096 last 69 years.
10098 @item @kbd{v w} or short @kbd{w} (@code{org-agenda-week-view})
10099 @kindex v w
10100 @kindex w
10101 @findex org-agenda-week-view
10102 Switch to week view.  When switching week view, this setting
10103 becomes the default for subsequent agenda refreshes.  A numeric
10104 prefix argument may be used to jump directly to a specific day of
10105 the ISO week.  For example @kbd{9 w} to ISO week number 9.
10106 When setting week view, a year may be encoded in the prefix
10107 argument as well.  For example, @kbd{200712 w} jumps to week
10108 12 in 2007.  If such a year specification has only one or two
10109 digits, it is expanded into one of the 30 next years or the last
10110 69 years.
10112 @item @kbd{v m} (@code{org-agenda-month-view})
10113 @kindex v m
10114 @findex org-agenda-month-view
10115 Switch to month view.  Because month views are slow to create,
10116 they do not become the default for subsequent agenda refreshes.
10117 A numeric prefix argument may be used to jump directly to
10118 a specific day of the month.  When setting month view, a year may
10119 be encoded in the prefix argument as well.  For example,
10120 @kbd{200712 m} jumps to December, 2007.  If such a year
10121 specification has only one or two digits, it is expanded into one
10122 of the 30 next years or the last 69 years.
10124 @item @kbd{v y} (@code{org-agenda-year-view})
10125 @kindex v y
10126 @findex org-agenda-year-view
10127 Switch to year view.  Because year views are slow to create, they
10128 do not become the default for subsequent agenda refreshes.
10129 A numeric prefix argument may be used to jump directly to
10130 a specific day of the year.
10132 @item @kbd{v @key{SPC}} (@code{org-agenda-reset-view})
10133 @kindex v SPC
10134 @findex org-agenda-reset-view
10135 @vindex org-agenda-span
10136 Reset the current view to @code{org-agenda-span}.
10138 @item @kbd{f} (@code{org-agenda-later})
10139 @kindex f
10140 @findex org-agenda-later
10141 Go forward in time to display the span following the current one.
10142 For example, if the display covers a week, switch to the
10143 following week.  With a prefix argument, repeat that many times.
10145 @item @kbd{b} (@code{org-agenda-earlier})
10146 @kindex b
10147 @findex org-agenda-earlier
10148 Go backward in time to display earlier dates.
10150 @item @kbd{.} (@code{org-agenda-goto-today})
10151 @kindex .
10152 @findex org-agenda-goto-today
10153 Go to today.
10155 @item @kbd{j} (@code{org-agenda-goto-date})
10156 @kindex j
10157 @findex org-agenda-goto-date
10158 Prompt for a date and go there.
10160 @item @kbd{J} (@code{org-agenda-clock-goto})
10161 @kindex J
10162 @findex org-agenda-clock-goto
10163 Go to the currently clocked-in task @emph{in the agenda buffer}.
10165 @item @kbd{D} (@code{org-agenda-toggle-diary})
10166 @kindex D
10167 @findex org-agenda-toggle-diary
10168 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
10170 @item @kbd{v l} or @kbd{v L} or short @kbd{l} (@code{org-agenda-log-mode})
10171 @kindex v l
10172 @kindex l
10173 @kindex v L
10174 @findex org-agenda-log-mode
10175 @vindex org-log-done
10176 @vindex org-agenda-log-mode-items
10177 Toggle Logbook mode.  In Logbook mode, entries that were marked
10178 DONE while logging was on (see the variable @code{org-log-done}) are
10179 shown in the agenda, as are entries that have been clocked on
10180 that day.  You can configure the entry types that should be
10181 included in log mode using the variable
10182 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u}
10183 prefix, show all possible logbook entries, including state
10184 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}.
10186 @item @kbd{v [} or short @kbd{[} (@code{org-agenda-manipulate-query-add})
10187 @kindex v [
10188 @kindex [
10189 @findex org-agenda-manipulate-query-add
10190 Include inactive timestamps into the current view.  Only for
10191 weekly/daily agenda and timeline views.
10193 @item @kbd{v a} (@code{org-agenda-archives-mode})
10194 @kindex v a
10195 @findex org-agenda-archives-mode
10196 Toggle Archives mode.  In Archives mode, trees that are archived
10197 (see @ref{Internal archiving}) are also scanned when producing the
10198 agenda.  To exit archives mode, press @kbd{v a} again.
10200 @item @kbd{v A}
10201 @kindex v A
10202 Toggle Archives mode.  Include all archive files as well.
10204 @item @kbd{v R} or short @kbd{R} (@code{org-agenda-clockreport-mode})
10205 @kindex v R
10206 @kindex R
10207 @findex org-agenda-clockreport-mode
10208 @vindex org-agenda-start-with-clockreport-mode
10209 @vindex org-clock-report-include-clocking-task
10210 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly
10211 agenda always shows a table with the clocked times for the time
10212 span and file scope covered by the current agenda view.  The
10213 initial setting for this mode in new agenda buffers can be set
10214 with the variable @code{org-agenda-start-with-clockreport-mode}.  By
10215 using a prefix argument when toggling this mode (i.e., @kbd{C-u R}), the clock table does not show contributions from entries
10216 that are hidden by agenda filtering@footnote{Only tags filtering is respected here, effort filtering is
10217 ignored.}.  See also the
10218 variable @code{org-clock-report-include-clocking-task}.
10220 @item @kbd{v c}
10221 @kindex v c
10222 @vindex org-agenda-clock-consistency-checks
10223 Show overlapping clock entries, clocking gaps, and other clocking
10224 problems in the current agenda range.  You can then visit
10225 clocking lines and fix them manually.  See the variable
10226 @code{org-agenda-clock-consistency-checks} for information on how to
10227 customize the definition of what constituted a clocking problem.
10228 To return to normal agenda display, press @kbd{l} to exit
10229 Logbook mode.
10231 @item @kbd{v E} or short @kbd{E} (@code{org-agenda-entry-text-mode})
10232 @kindex v E
10233 @kindex E
10234 @findex org-agenda-entry-text-mode
10235 @vindex org-agenda-start-with-entry-text-mode
10236 @vindex org-agenda-entry-text-maxlines
10237 Toggle entry text mode.  In entry text mode, a number of lines
10238 from the Org outline node referenced by an agenda line are
10239 displayed below the line.  The maximum number of lines is given
10240 by the variable @code{org-agenda-entry-text-maxlines}.  Calling this
10241 command with a numeric prefix argument temporarily modifies that
10242 number to the prefix value.
10244 @item @kbd{G} (@code{org-agenda-toggle-time-grid})
10245 @kindex G
10246 @vindex org-agenda-use-time-grid
10247 @vindex org-agenda-time-grid
10248 Toggle the time grid on and off.  See also the variables
10249 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
10251 @item @kbd{r} (@code{org-agenda-redo})
10252 @itemx @kbd{g}
10253 @kindex r
10254 @kindex g
10255 @findex org-agenda-redo
10256 Recreate the agenda buffer, for example to reflect the changes
10257 after modification of the timestamps of items with
10258 @kbd{S-@key{LEFT}} and @kbd{S-@key{RIGHT}}.  When the
10259 buffer is the global TODO list, a prefix argument is interpreted
10260 to create a selective list for a specific TODO keyword.
10262 @item @kbd{C-x C-s} or short @kbd{s} (@code{org-save-all-org-buffers})
10263 @kindex C-x C-s
10264 @findex org-save-all-org-buffers
10265 @kindex s
10266 Save all Org buffers in the current Emacs session, and also the
10267 locations of IDs.
10269 @item @kbd{C-c C-x C-c} (@code{org-agenda-columns})
10270 @kindex C-c C-x C-c
10271 @findex org-agenda-columns
10272 @vindex org-columns-default-format
10273 Invoke column view (see @ref{Column View}) in the agenda buffer.  The
10274 column view format is taken from the entry at point, or, if there
10275 is no entry at point, from the first entry in the agenda view.
10276 So whatever the format for that entry would be in the original
10277 buffer (taken from a property, from a @samp{COLUMNS} keyword, or from
10278 the default variable @code{org-columns-default-format}) is used in the
10279 agenda.
10281 @item @kbd{C-c C-x >} (@code{org-agenda-remove-restriction-lock})
10282 @kindex C-c C-x >
10283 @findex org-agenda-remove-restriction-lock
10284 Remove the restriction lock on the agenda, if it is currently
10285 restricted to a file or subtree (see @ref{Agenda Files}).
10287 @item @kbd{M-@key{UP}} (@code{org-agenda-drag-line-backward})
10288 @kindex M-UP
10289 @findex org-agenda-drag-line-backward
10290 Drag the line at point backward one line.  With a numeric prefix
10291 argument, drag backward by that many lines.
10293 Moving agenda lines does not persist after an agenda refresh and
10294 does not modify the contributing Org files.
10296 @item @kbd{M-@key{DOWN}} (@code{org-agenda-drag-line-forward})
10297 @kindex M-DOWN
10298 @findex org-agenda-drag-line-forward
10299 Drag the line at point forward one line.  With a numeric prefix
10300 argument, drag forward by that many lines.
10301 @end table
10303 @anchor{Remote editing}
10304 @subheading Remote editing
10306 @cindex remote editing, from agenda
10308 @table @asis
10309 @item @kbd{0--9}
10310 Digit argument.
10312 @item @kbd{C-_} (@code{org-agenda-undo})
10313 @kindex C-_
10314 @findex org-agenda-undo
10315 @cindex undoing remote-editing events
10316 @cindex remote editing, undo
10317 Undo a change due to a remote editing command.  The change is
10318 undone both in the agenda buffer and in the remote buffer.
10320 @item @kbd{t} (@code{org-agenda-todo})
10321 @kindex t
10322 @findex org-agenda-todo
10323 Change the TODO state of the item, both in the agenda and in the
10324 original Org file.
10326 @item @kbd{C-S-@key{RIGHT}} (@code{org-agenda-todo-nextset})
10327 @kindex C-S-RIGHT
10328 @findex org-agenda-todo-nextset
10329 Switch to the next set of TODO keywords.
10331 @item @kbd{C-S-@key{LEFT}}, @code{org-agenda-todo-previousset}
10332 @kindex C-S-LEFT
10333 Switch to the previous set of TODO keywords.
10335 @item @kbd{C-k} (@code{org-agenda-kill})
10336 @kindex C-k
10337 @findex org-agenda-kill
10338 @vindex org-agenda-confirm-kill
10339 Delete the current agenda item along with the entire subtree
10340 belonging to it in the original Org file.  If the text to be
10341 deleted remotely is longer than one line, the kill needs to be
10342 confirmed by the user.  See variable @code{org-agenda-confirm-kill}.
10344 @item @kbd{C-c C-w} (@code{org-agenda-refile})
10345 @kindex C-c C-w
10346 @findex org-agenda-refile
10347 Refile the entry at point.
10349 @item @kbd{C-c C-x C-a} or short @kbd{a} (@code{org-agenda-archive-default-with-confirmation})
10350 @kindex C-c C-x C-a
10351 @kindex a
10352 @findex org-agenda-archive-default-with-confirmation
10353 @vindex org-archive-default-command
10354 Archive the subtree corresponding to the entry at point using the
10355 default archiving command set in @code{org-archive-default-command}.
10356 When using the @kbd{a} key, confirmation is required.
10358 @item @kbd{C-c C-x a} (@code{org-agenda-toggle-archive-tag})
10359 @kindex C-c C-x a
10360 @findex org-agenda-toggle-archive-tag
10361 Toggle the archive tag (see @ref{Internal archiving}) for the current
10362 headline.
10364 @item @kbd{C-c C-x A} (@code{org-agenda-archive-to-archive-sibling})
10365 @kindex C-c C-x A
10366 @findex org-agenda-archive-to-archive-sibling
10367 Move the subtree corresponding to the current entry to its
10368 @emph{archive sibling}.
10370 @item @kbd{C-c C-x C-s} or short @kbd{$} (@code{org-agenda-archive})
10371 @kindex C-c C-x C-s
10372 @kindex $
10373 @findex org-agenda-archive
10374 Archive the subtree corresponding to the current headline.  This
10375 means the entry is moved to the configured archive location, most
10376 likely a different file.
10378 @item @kbd{T} (@code{org-agenda-show-tags})
10379 @kindex T
10380 @findex org-agenda-show-tags
10381 @vindex org-agenda-show-inherited-tags
10382 Show all tags associated with the current item.  This is useful
10383 if you have turned off @code{org-agenda-show-inherited-tags}, but
10384 still want to see all tags of a headline occasionally.
10386 @item @kbd{:} (@code{org-agenda-set-tags})
10387 @kindex :
10388 @findex org-agenda-set-tags
10389 Set tags for the current headline.  If there is an active region
10390 in the agenda, change a tag for all headings in the region.
10392 @item @kbd{,} (@code{org-agenda-priority})
10393 @kindex ,
10394 @findex org-agenda-priority
10395 Set the priority for the current item.  Org mode prompts for the
10396 priority character.  If you reply with @kbd{@key{SPC}}, the
10397 priority cookie is removed from the entry.
10399 @item @kbd{P} (@code{org-agenda-show-priority})
10400 @kindex P
10401 @findex org-agenda-show-priority
10402 Display weighted priority of current item.
10404 @item @kbd{+} or @kbd{S-@key{UP}} (@code{org-agenda-priority-up})
10405 @kindex +
10406 @kindex S-UP
10407 @findex org-agenda-priority-up
10408 Increase the priority of the current item.  The priority is
10409 changed in the original buffer, but the agenda is not resorted.
10410 Use the @kbd{r} key for this.
10412 @item @kbd{-} or @kbd{S-@key{DOWN}} (@code{org-agenda-priority-down})
10413 @kindex -
10414 @kindex S-DOWN
10415 @findex org-agenda-priority-down
10416 Decrease the priority of the current item.
10418 @item @kbd{C-c C-z} or short @kbd{z} (@code{org-agenda-add-note})
10419 @kindex z
10420 @kindex C-c C-z
10421 @findex org-agenda-add-note
10422 @vindex org-log-into-drawer
10423 Add a note to the entry.  This note is recorded, and then filed
10424 to the same location where state change notes are put.  Depending
10425 on @code{org-log-into-drawer}, this may be inside a drawer.
10427 @item @kbd{C-c C-a} (@code{org-attach})
10428 @kindex C-c C-a
10429 @findex org-attach
10430 Dispatcher for all command related to attachments.
10432 @item @kbd{C-c C-s} (@code{org-agenda-schedule})
10433 @kindex C-c C-s
10434 @findex org-agenda-schedule
10435 Schedule this item.  With a prefix argument, remove the
10436 scheduling timestamp
10438 @item @kbd{C-c C-d} (@code{org-agenda-deadline})
10439 @kindex C-c C-d
10440 @findex org-agenda-deadline
10441 Set a deadline for this item.  With a prefix argument, remove the
10442 deadline.
10444 @item @kbd{S-@key{RIGHT}} (@code{org-agenda-do-date-later})
10445 @kindex S-RIGHT
10446 @findex org-agenda-do-date-later
10447 Change the timestamp associated with the current line by one day
10448 into the future.  If the date is in the past, the first call to
10449 this command moves it to today.  With a numeric prefix argument,
10450 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}
10451 prefix, change the time by one hour.  If you immediately repeat
10452 the command, it will continue to change hours even without the
10453 prefix argument.  With a double @kbd{C-u C-u} prefix, do the
10454 same for changing minutes.  The stamp is changed in the original
10455 Org file, but the change is not directly reflected in the agenda
10456 buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
10458 @item @kbd{S-@key{LEFT}} (@code{org-agenda-do-date-earlier})
10459 @kindex S-LEFT
10460 @findex org-agenda-do-date-earlier
10461 Change the timestamp associated with the current line by one day
10462 into the past.
10464 @item @kbd{>} (@code{org-agenda-date-prompt})
10465 @kindex >
10466 @findex org-agenda-date-prompt
10467 Change the timestamp associated with the current line.  The key
10468 @kbd{>} has been chosen, because it is the same as
10469 @kbd{S-.}  on my keyboard.
10471 @item @kbd{I} (@code{org-agenda-clock-in})
10472 @kindex I
10473 @findex org-agenda-clock-in
10474 Start the clock on the current item.  If a clock is running
10475 already, it is stopped first.
10477 @item @kbd{O} (@code{org-agenda-clock-out})
10478 @kindex O
10479 @findex org-agenda-clock-out
10480 Stop the previously started clock.
10482 @item @kbd{X} (@code{org-agenda-clock-cancel})
10483 @kindex X
10484 @findex org-agenda-clock-cancel
10485 Cancel the currently running clock.
10487 @item @kbd{J} (@code{org-agenda-clock-goto})
10488 @kindex J
10489 @findex org-agenda-clock-goto
10490 Jump to the running clock in another window.
10492 @item @kbd{k} (@code{org-agenda-capture})
10493 @kindex k
10494 @findex org-agenda-capture
10495 @cindex capturing, from agenda
10496 @vindex org-capture-use-agenda-date
10497 Like @code{org-capture}, but use the date at point as the default date
10498 for the capture template.  See @code{org-capture-use-agenda-date} to
10499 make this the default behavior of @code{org-capture}.
10500 @end table
10502 @anchor{Bulk remote editing selected entries}
10503 @subheading Bulk remote editing selected entries
10505 @cindex remote editing, bulk, from agenda
10506 @vindex org-agenda-bulk-custom-functions
10508 @table @asis
10509 @item @kbd{m} (@code{org-agenda-bulk-mark})
10510 @kindex m
10511 @findex org-agenda-bulk-mark
10513 Mark the entry at point for bulk action.  If there is an active
10514 region in the agenda, mark the entries in the region.  With
10515 numeric prefix argument, mark that many successive entries.
10517 @item @kbd{*} (@code{org-agenda-bulk-mark-all})
10518 @kindex *
10519 @findex org-agenda-bulk-mark-all
10521 Mark all visible agenda entries for bulk action.
10523 @item @kbd{u} (@code{org-agenda-bulk-unmark})
10524 @kindex u
10525 @findex org-agenda-bulk-unmark
10527 Unmark entry for bulk action.
10529 @item @kbd{U} (@code{org-agenda-bulk-remove-all-marks})
10530 @kindex U
10531 @findex org-agenda-bulk-remove-all-marks
10533 Unmark all marked entries for bulk action.
10535 @item @kbd{M-m} (@code{org-agenda-bulk-toggle})
10536 @kindex M-m
10537 @findex org-agenda-bulk-toggle
10539 Toggle mark of the entry at point for bulk action.
10541 @item @kbd{M-*} (@code{org-agenda-bulk-toggle-all})
10542 @kindex M-*
10543 @findex org-agenda-bulk-toggle-all
10545 Mark entries matching a regular expression for bulk action.
10547 @item @kbd{%} (@code{org-agenda-bulk-mark-regexp})
10548 @kindex %
10549 @findex org-agenda-bulk-mark-regexp
10551 Mark entries matching a regular expression for bulk action.
10553 @item @kbd{B} (@code{org-agenda-bulk-action})
10554 @kindex B
10555 @findex org-agenda-bulk-action
10556 @vindex org-agenda-bulk-persistent-marks
10558 Bulk action: act on all marked entries in the agenda.  This
10559 prompts for another key to select the action to be applied.  The
10560 prefix argument to @kbd{B} is passed through to the
10561 @kbd{s} and @kbd{d} commands, to bulk-remove these
10562 special timestamps.  By default, marks are removed after the
10563 bulk.  If you want them to persist, set
10564 @code{org-agenda-bulk-persistent-marks} to @code{t} or hit @kbd{p} at
10565 the prompt.
10567 @table @asis
10568 @item @kbd{*}
10569 Toggle persistent marks.
10571 @item @kbd{$}
10572 Archive all selected entries.
10574 @item @kbd{A}
10575 Archive entries by moving them to their respective archive
10576 siblings.
10578 @item @kbd{t}
10579 Change TODO state.  This prompts for a single TODO keyword and
10580 changes the state of all selected entries, bypassing blocking
10581 and suppressing logging notes---but not timestamps.
10583 @item @kbd{+}
10584 Add a tag to all selected entries.
10586 @item @kbd{-}
10587 Remove a tag from all selected entries.
10589 @item @kbd{s}
10590 Schedule all items to a new date.  To shift existing schedule
10591 dates by a fixed number of days, use something starting with
10592 double plus at the prompt, for example @samp{++8d} or @samp{++2w}.
10594 @item @kbd{d}
10595 Set deadline to a specific date.
10597 @item @kbd{r}
10598 Prompt for a single refile target and move all entries.  The
10599 entries are no longer in the agenda; refresh (@kbd{g}) to
10600 bring them back.
10602 @item @kbd{S}
10603 Reschedule randomly into the coming N days.  N is prompted for.
10604 With a prefix argument (@kbd{C-u B S}), scatter only
10605 across weekdays.
10607 @item @kbd{f}
10608 @vindex org-agenda-bulk-custom-functions
10609 Apply a function@footnote{You can also create persistent custom functions through
10610 @code{org-agenda-bulk-custom-functions}.} to marked entries.  For example, the
10611 function below sets the @samp{CATEGORY} property of the entries to
10612 @samp{web}.
10614 @lisp
10615 (defun set-category ()
10616   (interactive "P")
10617   (let ((marker (or (org-get-at-bol 'org-hd-marker)
10618                     (org-agenda-error))))
10619     (org-with-point-at marker
10620       (org-back-to-heading t)
10621       (org-set-property "CATEGORY" "web"))))
10622 @end lisp
10623 @end table
10624 @end table
10626 @anchor{Calendar commands}
10627 @subheading Calendar commands
10629 @cindex calendar commands, from agenda
10631 @table @asis
10632 @item @kbd{c} (@code{org-agenda-goto-calendar})
10633 @kindex c
10634 @findex org-agenda-goto-calendar
10635 Open the Emacs calendar and move to the date at the agenda
10636 cursor.
10638 @item @kbd{c} (@code{org-calendar-goto-agenda})
10639 @kindex c
10640 @findex org-calendar-goto-agenda
10641 When in the calendar, compute and show the Org agenda for the
10642 date at the cursor.
10644 @item @kbd{i} (@code{org-agenda-diary-entry})
10645 @kindex i
10646 @findex org-agenda-diary-entry
10648 @cindex diary entries, creating from agenda
10649 Insert a new entry into the diary, using the date at the cursor
10650 and (for block entries) the date at the mark.  This adds to the
10651 Emacs diary file@footnote{This file is parsed for the agenda when
10652 @code{org-agenda-include-diary} is set.}, in a way similar to the @kbd{i}
10653 command in the calendar.  The diary file pops up in another
10654 window, where you can add the entry.
10656 @vindex org-agenda-diary-file
10657 If you configure @code{org-agenda-diary-file} to point to an Org file,
10658 Org creates entries in that file instead.  Most entries are
10659 stored in a date-based outline tree that will later make it easy
10660 to archive appointments from previous months/years.  The tree is
10661 built under an entry with a @samp{DATE_TREE} property, or else with
10662 years as top-level entries.  Emacs prompts you for the entry
10663 text---if you specify it, the entry is created in
10664 @code{org-agenda-diary-file} without further interaction.  If you
10665 directly press @kbd{@key{RET}} at the prompt without typing text,
10666 the target file is shown in another window for you to finish the
10667 entry there.  See also the @kbd{k r} command.
10669 @item @kbd{M} (@code{org-agenda-phases-of-moon})
10670 @kindex M
10671 @findex org-agenda-phases-of-moon
10672 Show the phases of the moon for the three months around current
10673 date.
10675 @item @kbd{S} (@code{org-agenda-sunrise-sunset})
10676 @kindex S
10677 @findex org-agenda-sunrise-sunset
10678 Show sunrise and sunset times.  The geographical location must be
10679 set with calendar variables, see the documentation for the Emacs
10680 calendar.
10682 @item @kbd{C} (@code{org-agenda-convert-date})
10683 @kindex C
10684 @findex org-agenda-convert-date
10685 Convert the date at cursor into many other cultural and historic
10686 calendars.
10688 @item @kbd{H} (@code{org-agenda-holidays})
10689 @kindex H
10690 @findex org-agenda-holidays
10691 Show holidays for three months around the cursor date.
10692 @end table
10694 @anchor{Quit and exit}
10695 @subheading Quit and exit
10697 @table @asis
10698 @item @kbd{q} (@code{org-agenda-quit})
10699 @kindex q
10700 @findex org-agenda-quit
10702 Quit agenda, remove the agenda buffer.
10704 @item @kbd{x} (@code{org-agenda-exit})
10705 @kindex x
10706 @findex org-agenda-exit
10708 @cindex agenda files, removing buffers
10709 Exit agenda, remove the agenda buffer and all buffers loaded by
10710 Emacs for the compilation of the agenda.  Buffers created by the
10711 user to visit Org files are not removed.
10712 @end table
10714 @node Custom Agenda Views
10715 @section Custom Agenda Views
10717 @cindex custom agenda views
10718 @cindex agenda views, custom
10720 Custom agenda commands serve two purposes: to store and quickly access
10721 frequently used TODO and tags searches, and to create special
10722 composite agenda buffers.  Custom agenda commands are accessible
10723 through the dispatcher (see @ref{Agenda Dispatcher}), just like the
10724 default commands.
10726 @menu
10727 * Storing searches::             Type once, use often.
10728 * Block agenda::                 All the stuff you need in a single buffer.
10729 * Setting options::              Changing the rules.
10730 @end menu
10732 @node Storing searches
10733 @subsection Storing searches
10735 The first application of custom searches is the definition of keyboard
10736 shortcuts for frequently used searches, either creating an agenda
10737 buffer, or a sparse tree (the latter covering of course only the
10738 current buffer).
10740 @kindex C @r{(Agenda dispatcher)}
10741 @vindex org-agenda-custom-commands
10742 @cindex agenda views, main example
10743 @cindex agenda, as an agenda views
10744 @cindex agenda*, as an agenda views
10745 @cindex tags, as an agenda view
10746 @cindex todo, as an agenda view
10747 @cindex tags-todo
10748 @cindex todo-tree
10749 @cindex occur-tree
10750 @cindex tags-tree
10751 Custom commands are configured in the variable
10752 @code{org-agenda-custom-commands}.  You can customize this variable, for
10753 example by pressing @kbd{C} from the agenda dispatcher (see @ref{Agenda Dispatcher}).  You can also directly set it with Emacs Lisp in
10754 the Emacs init file.  The following example contains all valid agenda
10755 views:
10757 @lisp
10758 (setq org-agenda-custom-commands
10759       '(("x" agenda)
10760         ("y" agenda*)
10761         ("w" todo "WAITING")
10762         ("W" todo-tree "WAITING")
10763         ("u" tags "+boss-urgent")
10764         ("v" tags-todo "+boss-urgent")
10765         ("U" tags-tree "+boss-urgent")
10766         ("f" occur-tree "\\<FIXME\\>")
10767         ("h" . "HOME+Name tags searches") ;description for "h" prefix
10768         ("hl" tags "+home+Lisa")
10769         ("hp" tags "+home+Peter")
10770         ("hk" tags "+home+Kim")))
10771 @end lisp
10773 @noindent
10774 The initial string in each entry defines the keys you have to press
10775 after the dispatcher command in order to access the command.  Usually
10776 this will be just a single character, but if you have many similar
10777 commands, you can also define two-letter combinations where the first
10778 character is the same in several combinations and serves as a prefix
10779 key@footnote{You can provide a description for a prefix key by inserting
10780 a cons cell with the prefix and the description.}.  The second parameter is the search type, followed by the
10781 string or regular expression to be used for the matching.  The example
10782 above will therefore define:
10784 @table @asis
10785 @item @kbd{x}
10786 as a global search for agenda entries planned@footnote{@emph{Planned} means here that these entries have some planning
10787 information attached to them, like a time-stamp, a scheduled or
10788 a deadline string.  See @code{org-agenda-entry-types} on how to set what
10789 planning information is taken into account.} this
10790 week/day.
10792 @item @kbd{y}
10793 as the same search, but only for entries with an hour
10794 specification like @samp{[h]h:mm}---think of them as appointments.
10796 @item @kbd{w}
10797 as a global search for TODO entries with @samp{WAITING} as the TODO
10798 keyword.
10800 @item @kbd{W}
10801 as the same search, but only in the current buffer and displaying
10802 the results as a sparse tree.
10804 @item @kbd{u}
10805 as a global tags search for headlines tagged @samp{boss} but not
10806 @samp{urgent}.
10808 @item @kbd{v}
10809 The same search, but limiting it to headlines that are also TODO
10810 items.
10812 @item @kbd{U}
10813 as the same search, but only in the current buffer and displaying
10814 the result as a sparse tree.
10816 @item @kbd{f}
10817 to create a sparse tree (again, current buffer only) with all
10818 entries containing the word @samp{FIXME}.
10820 @item @kbd{h}
10821 as a prefix command for a @samp{HOME} tags search where you have to
10822 press an additional key (@kbd{l}, @kbd{p} or
10823 @kbd{k}) to select a name (Lisa, Peter, or Kim) as
10824 additional tag to match.
10825 @end table
10827 Note that @code{*-tree} agenda views need to be called from an Org buffer
10828 as they operate on the current buffer only.
10830 @node Block agenda
10831 @subsection Block agenda
10833 @cindex block agenda
10834 @cindex agenda, with block views
10836 Another possibility is the construction of agenda views that comprise
10837 the results of @emph{several} commands, each of which creates a block in
10838 the agenda buffer.  The available commands include @code{agenda} for the
10839 daily or weekly agenda (as created with @kbd{a}) , @code{alltodo} for
10840 the global TODO list (as constructed with @kbd{t}), and the
10841 matching commands discussed above: @code{todo}, @code{tags}, and @code{tags-todo}.
10842 Here are two examples:
10844 @lisp
10845 (setq org-agenda-custom-commands
10846       '(("h" "Agenda and Home-related tasks"
10847          ((agenda "")
10848           (tags-todo "home")
10849           (tags "garden")))
10850         ("o" "Agenda and Office-related tasks"
10851          ((agenda "")
10852           (tags-todo "work")
10853           (tags "office")))))
10854 @end lisp
10856 @noindent
10857 This defines @kbd{h} to create a multi-block view for stuff you
10858 need to attend to at home.  The resulting agenda buffer contains your
10859 agenda for the current week, all TODO items that carry the tag @samp{home},
10860 and also all lines tagged with @samp{garden}.  Finally the command
10861 @kbd{o} provides a similar view for office tasks.
10863 @node Setting options
10864 @subsection Setting options for custom commands
10866 @cindex options, for custom agenda views
10868 @vindex org-agenda-custom-commands
10869 Org mode contains a number of variables regulating agenda construction
10870 and display.  The global variables define the behavior for all agenda
10871 commands, including the custom commands.  However, if you want to
10872 change some settings just for a single custom view, you can do so.
10873 Setting options requires inserting a list of variable names and values
10874 at the right spot in @code{org-agenda-custom-commands}.  For example:
10876 @lisp
10877 (setq org-agenda-custom-commands
10878       '(("w" todo "WAITING"
10879          ((org-agenda-sorting-strategy '(priority-down))
10880           (org-agenda-prefix-format "  Mixed: ")))
10881         ("U" tags-tree "+boss-urgent"
10882          ((org-show-context-detail 'minimal)))
10883         ("N" search ""
10884          ((org-agenda-files '("~org/notes.org"))
10885           (org-agenda-text-search-extra-files nil)))))
10886 @end lisp
10888 @noindent
10889 Now the @kbd{w} command sorts the collected entries only by
10890 priority, and the prefix format is modified to just say @samp{Mixed:}
10891 instead of giving the category of the entry.  The sparse tags tree of
10892 @kbd{U} now turns out ultra-compact, because neither the headline
10893 hierarchy above the match, nor the headline following the match are
10894 shown.  The command @kbd{N} does a text search limited to only
10895 a single file.
10897 For command sets creating a block agenda, @code{org-agenda-custom-commands}
10898 has two separate spots for setting options.  You can add options that
10899 should be valid for just a single command in the set, and options that
10900 should be valid for all commands in the set.  The former are just
10901 added to the command entry; the latter must come after the list of
10902 command entries.  Going back to the block agenda example (see @ref{Block agenda}), let's change the sorting strategy for the @kbd{h}
10903 commands to @code{priority-down}, but let's sort the results for GARDEN
10904 tags query in the opposite order, @code{priority-up}.  This would look like
10905 this:
10907 @lisp
10908 (setq org-agenda-custom-commands
10909       '(("h" "Agenda and Home-related tasks"
10910          ((agenda)
10911           (tags-todo "home")
10912           (tags "garden"
10913                 ((org-agenda-sorting-strategy '(priority-up)))))
10914          ((org-agenda-sorting-strategy '(priority-down))))
10915         ("o" "Agenda and Office-related tasks"
10916          ((agenda)
10917           (tags-todo "work")
10918           (tags "office")))))
10919 @end lisp
10921 As you see, the values and parentheses setting is a little complex.
10922 When in doubt, use the customize interface to set this variable---it
10923 fully supports its structure.  Just one caveat: when setting options
10924 in this interface, the @emph{values} are just Lisp expressions.  So if the
10925 value is a string, you need to add the double-quotes around the value
10926 yourself.
10928 @vindex org-agenda-custom-commands-contexts
10929 To control whether an agenda command should be accessible from
10930 a specific context, you can customize
10931 @code{org-agenda-custom-commands-contexts}.  Let's say for example that you
10932 have an agenda command @kbd{o} displaying a view that you only
10933 need when reading emails.  Then you would configure this option like
10934 this:
10936 @lisp
10937 (setq org-agenda-custom-commands-contexts
10938       '(("o" (in-mode . "message-mode"))))
10939 @end lisp
10941 You can also tell that the command key @kbd{o} should refer to
10942 another command key @kbd{r}.  In that case, add this command key
10943 like this:
10945 @lisp
10946 (setq org-agenda-custom-commands-contexts
10947       '(("o" "r" (in-mode . "message-mode"))))
10948 @end lisp
10950 See the docstring of the variable for more information.
10952 @node Exporting Agenda Views
10953 @section Exporting Agenda Views
10955 @cindex agenda views, exporting
10957 If you are away from your computer, it can be very useful to have
10958 a printed version of some agenda views to carry around.  Org mode can
10959 export custom agenda views as plain text, HTML@footnote{For HTML you need to install Hrvoje Niksic's @samp{htmlize.el}
10960 from @uref{https://github.com/hniksic/emacs-htmlize, Hrvoje Niksic's repository}.}, Postscript,
10961 PDF@footnote{To create PDF output, the Ghostscript ps2pdf utility must be
10962 installed on the system.  Selecting a PDF file also creates the
10963 postscript file.}, and iCalendar files.  If you want to do this only
10964 occasionally, use the following command:
10966 @table @asis
10967 @item @kbd{C-x C-w} (@code{org-agenda-write})
10968 @kindex C-x C-w
10969 @findex org-agenda-write
10970 @cindex exporting agenda views
10971 @cindex agenda views, exporting
10973 @vindex org-agenda-exporter-settings
10974 Write the agenda view to a file.
10975 @end table
10977 If you need to export certain agenda views frequently, you can
10978 associate any custom agenda command with a list of output file
10979 names@footnote{If you want to store standard views like the weekly agenda or
10980 the global TODO list as well, you need to define custom commands for
10981 them in order to be able to specify file names.}.  Here is an example that first defines custom commands
10982 for the agenda and the global TODO list, together with a number of
10983 files to which to export them.  Then we define two block agenda
10984 commands and specify file names for them as well.  File names can be
10985 relative to the current working directory, or absolute.
10987 @lisp
10988 (setq org-agenda-custom-commands
10989       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
10990         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
10991         ("h" "Agenda and Home-related tasks"
10992          ((agenda "")
10993           (tags-todo "home")
10994           (tags "garden"))
10995          nil
10996          ("~/views/home.html"))
10997         ("o" "Agenda and Office-related tasks"
10998          ((agenda)
10999           (tags-todo "work")
11000           (tags "office"))
11001          nil
11002          ("~/views/office.ps" "~/calendars/office.ics"))))
11003 @end lisp
11005 The extension of the file name determines the type of export.  If it
11006 is @samp{.html}, Org mode uses the htmlize package to convert the buffer to
11007 HTML and save it to this file name.  If the extension is @samp{.ps},
11008 @code{ps-print-buffer-with-faces} is used to produce Postscript output.  If
11009 the extension is @samp{.ics}, iCalendar export is run export over all files
11010 that were used to construct the agenda, and limit the export to
11011 entries listed in the agenda.  Any other extension produces a plain
11012 ASCII file.
11014 The export files are @emph{not} created when you use one of those
11015 commands interactively because this might use too much overhead.
11016 Instead, there is a special command to produce @emph{all} specified
11017 files in one step:
11019 @table @asis
11020 @item @kbd{e} (@code{org-store-agenda-views})
11021 @kindex e @r{(Agenda dispatcher)}
11022 @findex org-store-agenda-views
11023 Export all agenda views that have export file names associated
11024 with them.
11025 @end table
11027 You can use the options section of the custom agenda commands to also
11028 set options for the export commands.  For example:
11030 @lisp
11031 (setq org-agenda-custom-commands
11032       '(("X" agenda ""
11033          ((ps-number-of-columns 2)
11034           (ps-landscape-mode t)
11035           (org-agenda-prefix-format " [ ] ")
11036           (org-agenda-with-colors nil)
11037           (org-agenda-remove-tags t))
11038          ("theagenda.ps"))))
11039 @end lisp
11041 @noindent
11042 @vindex org-agenda-exporter-settings
11043 This command sets two options for the Postscript exporter, to make it
11044 print in two columns in landscape format---the resulting page can be
11045 cut in two and then used in a paper agenda.  The remaining settings
11046 modify the agenda prefix to omit category and scheduling information,
11047 and instead include a checkbox to check off items.  We also remove the
11048 tags to make the lines compact, and we do not want to use colors for
11049 the black-and-white printer.  Settings specified in
11050 @code{org-agenda-exporter-settings} also apply, e.g.,
11052 @lisp
11053 (setq org-agenda-exporter-settings
11054       '((ps-number-of-columns 2)
11055         (ps-landscape-mode t)
11056         (org-agenda-add-entry-text-maxlines 5)
11057         (htmlize-output-type 'css)))
11058 @end lisp
11060 @noindent
11061 but the settings in @code{org-agenda-custom-commands} take precedence.
11063 @noindent
11064 From the command line you may also use:
11066 @example
11067 emacs -eval (org-batch-store-agenda-views) -kill
11068 @end example
11070 @noindent
11071 or, if you need to modify some parameters@footnote{Quoting depends on the system you use, please check the FAQ
11072 for examples.}
11074 @example
11075 emacs -eval '(org-batch-store-agenda-views                      \
11076               org-agenda-span (quote month)                     \
11077               org-agenda-start-day "2007-11-01"                 \
11078               org-agenda-include-diary nil                      \
11079               org-agenda-files (quote ("~/org/project.org")))'  \
11080       -kill
11081 @end example
11083 @noindent
11084 which creates the agenda views restricted to the file
11085 @samp{~/org/project.org}, without diary entries and with a 30-day extent.
11087 You can also extract agenda information in a way that allows further
11088 processing by other programs.  See @ref{Extracting Agenda Information}, for
11089 more information.
11091 @node Agenda Column View
11092 @section Using Column View in the Agenda
11094 @cindex column view, in agenda
11095 @cindex agenda, column view
11097 Column view (see @ref{Column View}) is normally used to view and edit
11098 properties embedded in the hierarchical structure of an Org file.  It
11099 can be quite useful to use column view also from the agenda, where
11100 entries are collected by certain criteria.
11102 @table @asis
11103 @item @kbd{C-c C-x C-c} (@code{org-agenda-columns})
11104 @kindex C-c C-x C-c
11105 @findex org-agenda-columns
11107 Turn on column view in the agenda.
11108 @end table
11110 To understand how to use this properly, it is important to realize
11111 that the entries in the agenda are no longer in their proper outline
11112 environment.  This causes the following issues:
11114 @enumerate
11115 @item
11116 @vindex org-columns-default-format
11117 @vindex org-overriding-columns-format
11118 Org needs to make a decision which columns format to use.  Since
11119 the entries in the agenda are collected from different files, and
11120 different files may have different columns formats, this is
11121 a non-trivial problem.  Org first checks if the variable
11122 @code{org-agenda-overriding-columns-format} is currently set, and if so,
11123 takes the format from there.  Otherwise it takes the format
11124 associated with the first item in the agenda, or, if that item does
11125 not have a specific format (defined in a property, or in its file),
11126 it uses @code{org-columns-default-format}.
11128 @item
11129 @cindex @samp{CLOCKSUM}, special property
11130 If any of the columns has a summary type defined (see @ref{Column attributes}), turning on column view in the agenda visits all
11131 relevant agenda files and make sure that the computations of this
11132 property are up to date.  This is also true for the special
11133 @samp{CLOCKSUM} property.  Org then sums the values displayed in the
11134 agenda.  In the daily/weekly agenda, the sums cover a single day;
11135 in all other views they cover the entire block.
11137 It is important to realize that the agenda may show the same entry
11138 @emph{twice}---for example as scheduled and as a deadline---and it may
11139 show two entries from the same hierarchy (for example a @emph{parent}
11140 and its @emph{child}).  In these cases, the summation in the agenda
11141 leads to incorrect results because some values count double.
11143 @item
11144 When the column view in the agenda shows the @samp{CLOCKSUM} property,
11145 that is always the entire clocked time for this item.  So even in
11146 the daily/weekly agenda, the clocksum listed in column view may
11147 originate from times outside the current view.  This has the
11148 advantage that you can compare these values with a column listing
11149 the planned total effort for a task---one of the major
11150 applications for column view in the agenda.  If you want
11151 information about clocked time in the displayed period use clock
11152 table mode (press @kbd{R} in the agenda).
11154 @item
11155 @cindex @samp{CLOCKSUM_T}, special property
11156 When the column view in the agenda shows the @samp{CLOCKSUM_T} property,
11157 that is always today's clocked time for this item.  So even in the
11158 weekly agenda, the clocksum listed in column view only originates
11159 from today.  This lets you compare the time you spent on a task for
11160 today, with the time already spent---via @samp{CLOCKSUM}---and with
11161 the planned total effort for it.
11162 @end enumerate
11164 @node Markup
11165 @chapter Markup for Rich Export
11167 When exporting Org documents, the exporter tries to reflect the
11168 structure of the document as accurately as possible in the back-end.
11169 Since export targets like HTML and @LaTeX{} allow much richer formatting,
11170 Org mode has rules on how to prepare text for rich export.  This
11171 section summarizes the markup rules used in an Org mode buffer.
11173 @menu
11174 * Paragraphs::                   The basic unit of text.
11175 * Emphasis and Monospace::       Bold, italic, etc.
11176 * Horizontal Rules::             Make a line.
11177 * Images and Tables::            Images, tables and caption mechanism.
11178 * Literal Examples::             Source code examples with special formatting.
11179 * Special Symbols::              Greek letters and other symbols.
11180 * Subscripts and Superscripts::  Simple syntax for raising/lowering text.
11181 * Embedded @LaTeX{}::            LaTeX can be freely used inside Org documents.
11182 @end menu
11184 @node Paragraphs
11185 @section Paragraphs
11187 @cindex paragraphs, markup rules
11189 Paragraphs are separated by at least one empty line.  If you need to
11190 enforce a line break within a paragraph, use @code{\\} at the end of
11191 a line.
11193 To preserve the line breaks, indentation and blank lines in a region,
11194 but otherwise use normal formatting, you can use this construct, which
11195 can also be used to format poetry.
11197 @cindex @samp{BEGIN_VERSE}
11198 @cindex verse blocks
11199 @example
11200 #+BEGIN_VERSE
11201  Great clouds overhead
11202  Tiny black birds rise and fall
11203  Snow covers Emacs
11205     ---AlexSchroeder
11206 #+END_VERSE
11207 @end example
11209 When quoting a passage from another document, it is customary to
11210 format this as a paragraph that is indented on both the left and the
11211 right margin.  You can include quotations in Org documents like this:
11213 @cindex @samp{BEGIN_QUOTE}
11214 @cindex quote blocks
11215 @example
11216 #+BEGIN_QUOTE
11217 Everything should be made as simple as possible,
11218 but not any simpler ---Albert Einstein
11219 #+END_QUOTE
11220 @end example
11222 If you would like to center some text, do it like this:
11224 @cindex @samp{BEGIN_CENTER}
11225 @cindex center blocks
11226 @example
11227 #+BEGIN_CENTER
11228 Everything should be made as simple as possible, \\
11229 but not any simpler
11230 #+END_CENTER
11231 @end example
11233 @node Emphasis and Monospace
11234 @section Emphasis and Monospace
11236 @cindex underlined text, markup rules
11237 @cindex bold text, markup rules
11238 @cindex italic text, markup rules
11239 @cindex verbatim text, markup rules
11240 @cindex code text, markup rules
11241 @cindex strike-through text, markup rules
11243 You can make words @samp{*bold*}, @samp{/italic/}, @samp{_underlined_}, @samp{=verbatim=}
11244 and @samp{~code~}, and, if you must, @samp{+strike-through+}.  Text in the code
11245 and verbatim string is not processed for Org mode specific syntax; it
11246 is exported verbatim.
11248 @vindex org-fontify-emphasized-text
11249 To turn off fontification for marked up text, you can set
11250 @code{org-fontify-emphasized-text} to @code{nil}.  To narrow down the list of
11251 available markup syntax, you can customize @code{org-emphasis-alist}.
11253 @node Horizontal Rules
11254 @section Horizontal Rules
11256 @cindex horizontal rules, markup rules
11258 A line consisting of only dashes, and at least 5 of them, is exported
11259 as a horizontal line.
11261 @node Images and Tables
11262 @section Images and Tables
11264 @cindex tables, markup rules
11265 @cindex @samp{CAPTION}, keyword
11266 @cindex @samp{NAME}, keyword
11268 Both the native Org mode tables (see @ref{Tables}) and tables formatted
11269 with the @samp{table.el} package are exported properly.  For Org mode
11270 tables, the lines before the first horizontal separator line become
11271 table header lines.  You can use the following lines somewhere before
11272 the table to assign a caption and a label for cross references, and in
11273 the text you can refer to the object with @samp{[[tab:basic-data]]} (see
11274 @ref{Internal Links}):
11276 @example
11277 #+CAPTION: This is the caption for the next table (or link)
11278 #+NAME:   tab:basic-data
11279 | ... | ... |
11280 |-----+-----|
11281 @end example
11283 Optionally, the caption can take the form:
11285 @example
11286 #+CAPTION[Caption for list of tables]: Caption for table.
11287 @end example
11289 @cindex inlined images, markup rules
11290 Some back-ends allow you to directly include images into the exported
11291 document.  Org does this, if a link to an image file does not have
11292 a description part, for example @samp{[[./img/a.jpg]]}.  If you wish to define
11293 a caption for the image and maybe a label for internal cross
11294 references, make sure that the link is on a line by itself and precede
11295 it with @samp{CAPTION} and @samp{NAME} keywords as follows:
11297 @example
11298 #+CAPTION: This is the caption for the next figure link (or table)
11299 #+NAME:   fig:SED-HR4049
11300 [[./img/a.jpg]]
11301 @end example
11303 @noindent
11304 Such images can be displayed within the buffer.  See @ref{Handling Links, , the discussion of
11305 image links}.
11307 Even though images and tables are prominent examples of captioned
11308 structures, the same caption mechanism can apply to many
11309 others---e.g., @LaTeX{} equations, source code blocks.  Depending on the
11310 export back-end, those may or may not be handled.
11312 @node Literal Examples
11313 @section Literal Examples
11315 @cindex literal examples, markup
11316 @cindex code line references, markup
11318 You can include literal examples that should not be subjected to
11319 markup.  Such examples are typeset in monospace, so this is well
11320 suited for source code and similar examples.
11322 @cindex @samp{BEGIN_EXAMPLE}
11323 @cindex example block
11324 @example
11325 #+BEGIN_EXAMPLE
11326   Some example from a text file.
11327 #+END_EXAMPLE
11328 @end example
11330 Note that such blocks may be @emph{indented} in order to align nicely with
11331 indented text and in particular with plain list structure (see
11332 @ref{Plain Lists}).  For simplicity when using small examples, you can
11333 also start the example lines with a colon followed by a space.  There
11334 may also be additional whitespace before the colon:
11336 @example
11337 Here is an example
11338    : Some example from a text file.
11339 @end example
11341 @cindex formatting source code, markup rules
11342 @vindex org-latex-listings
11343 If the example is source code from a programming language, or any
11344 other text that can be marked up by Font Lock in Emacs, you can ask
11345 for the example to look like the fontified Emacs buffer@footnote{This works automatically for the HTML backend (it requires
11346 version 1.34 of the @samp{htmlize.el} package, which you need to install).
11347 Fontified code chunks in @LaTeX{} can be achieved using either the
11348 listings package or the @uref{https://github.com/gpoore/minted, minted} package.  Refer to
11349 @code{org-export-latex-listings} for details.}.  This
11350 is done with the code block, where you also need to specify the name
11351 of the major mode that should be used to fontify the example@footnote{Source code in code blocks may also be evaluated either
11352 interactively or on export.  See @ref{Working with Source Code} for more
11353 information on evaluating code blocks.},
11354 see @ref{Structure Templates} for shortcuts to easily insert code blocks.
11356 @cindex @samp{BEGIN_SRC}
11357 @cindex src block
11358 @example
11359 #+BEGIN_SRC emacs-lisp
11360   (defun org-xor (a b)
11361     "Exclusive or."
11362     (if a (not b) b))
11363  #+END_SRC
11364 @end example
11366 Both in @samp{example} and in @samp{src} snippets, you can add a @samp{-n} switch to
11367 the end of the @samp{#+BEGIN} line, to get the lines of the example
11368 numbered.  The @samp{-n} takes an optional numeric argument specifying the
11369 starting line number of the block.  If you use a @samp{+n} switch, the
11370 numbering from the previous numbered snippet is continued in the
11371 current one.  The @samp{+n} switch can also take a numeric argument.  This
11372 adds the value of the argument to the last line of the previous block
11373 to determine the starting line number.
11375 @example
11376 #+BEGIN_SRC emacs-lisp -n 20
11377   ;; This exports with line number 20.
11378   (message "This is line 21")
11379 #+END_SRC
11381 #+BEGIN_SRC emacs-lisp +n 10
11382   ;; This is listed as line 31.
11383   (message "This is line 32")
11384 #+END_SRC
11385 @end example
11387 In literal examples, Org interprets strings like @samp{(ref:name)} as
11388 labels, and use them as targets for special hyperlinks like
11389 @samp{[[(name)]]}---i.e., the reference name enclosed in single parenthesis.
11390 In HTML, hovering the mouse over such a link remote-highlights the
11391 corresponding code line, which is kind of cool.
11393 You can also add a @samp{-r} switch which @emph{removes} the labels from the
11394 source code@footnote{Adding @samp{-k} to @samp{-n -r} @emph{keeps} the labels in the source code
11395 while using line numbers for the links, which might be useful to
11396 explain those in an Org mode example code.}.  With the @samp{-n} switch, links to these references
11397 are labeled by the line numbers from the code listing.  Otherwise
11398 links use the labels with no parentheses.  Here is an example:
11400 @example
11401 #+BEGIN_SRC emacs-lisp -n -r
11402   (save-excursion                 (ref:sc)
11403      (goto-char (point-min))      (ref:jump)
11404 #+END_SRC
11405 In line [[(sc)]] we remember the current position. [[(jump)][Line (jump)]]
11406 jumps to point-min.
11407 @end example
11409 @cindex indentation, in source blocks
11410 Finally, you can use @samp{-i} to preserve the indentation of a specific
11411 code block (see @ref{Editing Source Code}).
11413 @vindex org-coderef-label-format
11414 If the syntax for the label format conflicts with the language syntax,
11415 use a @samp{-l} switch to change the format, for example
11417 @example
11418 #+BEGIN_SRC pascal -n -r -l "((%s))"
11419 @end example
11421 @noindent
11422 See also the variable @code{org-coderef-label-format}.
11424 HTML export also allows examples to be published as text areas (see
11425 @ref{Text areas in HTML export}).
11427 Because the @samp{#+BEGIN} @dots{} @samp{#+END} patterns need to be added so often,
11428 a shortcut is provided (see @ref{Structure Templates}).
11430 @table @asis
11431 @item @kbd{C-c '} (@code{org-edit-special})
11432 @kindex C-c '
11433 @findex org-edit-special
11434 Edit the source code example at point in its native mode.  This
11435 works by switching to a temporary buffer with the source code.
11436 You need to exit by pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*}, @samp{,*}, @samp{#+} and @samp{,#+} get
11437 a comma prepended, to keep them from being interpreted by Org as
11438 outline nodes or special syntax.  These commas are stripped when
11439 editing with @kbd{C-c '}, and also before export.}.  The
11440 edited version then replaces the old version in the Org buffer.
11441 Fixed-width regions---where each line starts with a colon
11442 followed by a space---are edited using @code{artist-mode}@footnote{You may select a different-mode with the variable
11443 @code{org-edit-fixed-width-region-mode}.} to
11444 allow creating ASCII drawings easily.  Using this command in an
11445 empty line creates a new fixed-width region.
11446 @end table
11448 @cindex storing link, in a source code buffer
11449 Calling @code{org-store-link} (see @ref{Handling Links}) while editing a source
11450 code example in a temporary buffer created with @kbd{C-c '}
11451 prompts for a label.  Make sure that it is unique in the current
11452 buffer, and insert it with the proper formatting like @samp{(ref:label)} at
11453 the end of the current line.  Then the label is stored as a link
11454 @samp{(label)}, for retrieval with @kbd{C-c C-l}.
11456 @node Special Symbols
11457 @section Special Symbols
11459 @cindex math symbols
11460 @cindex special symbols
11461 @cindex @TeX{} macros
11462 @cindex @LaTeX{} fragments, markup rules
11463 @cindex HTML entities
11464 @cindex @LaTeX{} entities
11466 You can use @LaTeX{}-like syntax to insert special symbols---named
11467 entities---like @samp{\alpha} to indicate the Greek letter, or @samp{\to} to indicate
11468 an arrow.  Completion for these symbols is available, just type @samp{\}
11469 and maybe a few letters, and press @kbd{M-@key{TAB}} to see possible
11470 completions.  If you need such a symbol inside a word, terminate it
11471 with a pair of curly brackets.  For example
11473 @example
11474 Pro tip: Given a circle \Gamma of diameter d, the length of its
11475 circumference is \pi@{@}d.
11476 @end example
11478 @findex org-entities-help
11479 @vindex org-entities-user
11480 A large number of entities is provided, with names taken from both
11481 HTML and @LaTeX{}; you can comfortably browse the complete list from
11482 a dedicated buffer using the command @code{org-entities-help}.  It is also
11483 possible to provide your own special symbols in the variable
11484 @code{org-entities-user}.
11486 During export, these symbols are transformed into the native format of
11487 the exporter back-end.  Strings like @samp{\alpha} are exported as @samp{&alpha;} in
11488 the HTML output, and as @samp{\(\alpha\)} in the @LaTeX{} output.  Similarly, @samp{\nbsp}
11489 becomes @samp{&nbsp;} in HTML and @samp{~} in @LaTeX{}.
11491 @cindex escaping characters
11492 Entities may also be used as a way to escape markup in an Org
11493 document, e.g., @samp{\under@{@}not underlined\under} exports as @samp{_not underlined_}.
11495 @cindex special symbols, in-buffer display
11496 If you would like to see entities displayed as UTF-8 characters, use
11497 the following command@footnote{You can turn this on by default by setting the variable
11498 @code{org-pretty-entities}, or on a per-file base with the @samp{STARTUP} option
11499 @samp{entitiespretty}.}:
11501 @table @asis
11502 @item @kbd{C-c C-x \} (@code{org-toggle-pretty-entities})
11503 @kindex C-c C-x \
11504 @findex org-toggle-pretty-entities
11506 Toggle display of entities as UTF-8 characters.  This does not
11507 change the buffer content which remains plain ASCII, but it
11508 overlays the UTF-8 character for display purposes only.
11509 @end table
11511 @cindex shy hyphen, special symbol
11512 @cindex dash, special symbol
11513 @cindex ellipsis, special symbol
11514 In addition to regular entities defined above, Org exports in
11515 a special way@footnote{This behavior can be disabled with @samp{-} export setting (see
11516 @ref{Export Settings}).} the following commonly used character
11517 combinations: @samp{\-} is treated as a shy hyphen, @samp{--} and @samp{---} are
11518 converted into dashes, and @samp{...} becomes a compact set of dots.
11520 @node Subscripts and Superscripts
11521 @section Subscripts and Superscripts
11523 @cindex subscript
11524 @cindex superscript
11526 @samp{^} and @samp{_} are used to indicate super- and subscripts.  To increase
11527 the readability of ASCII text, it is not necessary, but OK, to
11528 surround multi-character sub- and superscripts with curly braces.  For
11529 example
11531 @example
11532 The radius of the sun is R_sun = 6.96 x 10^8 m.  On the other hand,
11533 the radius of Alpha Centauri is R_@{Alpha Centauri@} = 1.28 x R_@{sun@}.
11534 @end example
11536 @vindex org-use-sub-superscripts
11537 If you write a text where the underscore is often used in a different
11538 context, Org's convention to always interpret these as subscripts can
11539 get in your way.  Configure the variable @code{org-use-sub-superscripts} to
11540 change this convention.  For example, when setting this variable to
11541 @code{@{@}}, @samp{a_b} is not interpreted as a subscript, but @samp{a_@{b@}} is.
11543 @table @asis
11544 @item @kbd{C-c C-x \} (@code{org-toggle-pretty-entities~})
11545 @kindex C-c C-x \
11546 @findex org-toggle-pretty-entities
11548 In addition to showing entities as UTF-8 characters, this command
11549 also formats sub- and superscripts in a WYSIWYM way.
11550 @end table
11552 @node Embedded @LaTeX{}
11553 @section Embedded @LaTeX{}
11555 @cindex @TeX{} interpretation
11556 @cindex @LaTeX{} interpretation
11558 Plain ASCII is normally sufficient for almost all note taking.
11559 Exceptions include scientific notes, which often require mathematical
11560 symbols and the occasional formula.  @LaTeX{}@footnote{@LaTeX{} is a macro system based on Donald@tie{}E.@tie{}Knuth's @TeX{}
11561 system.  Many of the features described here as ``@LaTeX{}'' are really
11562 from @TeX{}, but for simplicity I am blurring this distinction.} is widely used to
11563 typeset scientific documents.  Org mode supports embedding @LaTeX{} code
11564 into its files, because many academics are used to writing and reading
11565 @LaTeX{} source code, and because it can be readily processed to produce
11566 pretty output for a number of export back-ends.
11568 @menu
11569 * @LaTeX{} fragments::           Complex formulas made easy.
11570 * Previewing @LaTeX{} fragments:: What will this snippet look like?
11571 * CD@LaTeX{} mode::              Speed up entering of formulas.
11572 @end menu
11574 @node @LaTeX{} fragments
11575 @subsection @LaTeX{} fragments
11577 @cindex @LaTeX{} fragments
11579 @vindex org-format-latex-header
11580 Org mode can contain @LaTeX{} math fragments, and it supports ways to
11581 process these for several export back-ends.  When exporting to @LaTeX{},
11582 the code is left as it is.  When exporting to HTML, Org can use either
11583 @uref{http://www.mathjax.org, MathJax} (see @ref{Math formatting in HTML export}) or transcode the math
11584 into images (see @ref{Previewing @LaTeX{} fragments}).
11586 @LaTeX{} fragments do not need any special marking at all.  The following
11587 snippets are identified as @LaTeX{} source code:
11589 @itemize
11590 @item
11591 Environments of any kind@footnote{When MathJax is used, only the environments recognized by
11592 MathJax are processed.  When dvipng, dvisvgm, or ImageMagick suite is
11593 used to create images, any @LaTeX{} environment is handled.}.  The only requirement is that the
11594 @samp{\begin} statement appears on a new line, preceded by only
11595 whitespace.
11597 @item
11598 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts
11599 with currency specifications, single @samp{$} characters are only
11600 recognized as math delimiters if the enclosed text contains at most
11601 two line breaks, is directly attached to the @samp{$} characters with no
11602 whitespace in between, and if the closing @samp{$} is followed by
11603 whitespace, punctuation or a dash.  For the other delimiters, there
11604 is no such restriction, so when in doubt, use @samp{\(...\)} as inline
11605 math delimiters.
11606 @end itemize
11608 @noindent
11609 For example:
11611 @example
11612 \begin@{equation@}                        % arbitrary environments,
11613 x=\sqrt@{b@}                              % even tables, figures
11614 \end@{equation@}                          % etc
11616 If $a^2=b$ and \( b=2 \), then the solution must be
11617 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
11618 @end example
11620 @vindex org-export-with-latex
11621 @LaTeX{} processing can be configured with the variable
11622 @code{org-export-with-latex}.  The default setting is @code{t} which means
11623 MathJax for HTML, and no processing for ASCII and @LaTeX{} back-ends.
11624 You can also set this variable on a per-file basis using one of these
11625 lines:
11627 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
11628 @item @samp{#+OPTIONS: tex:t}
11629 @tab Do the right thing automatically (MathJax)
11630 @item @samp{#+OPTIONS: tex:nil}
11631 @tab Do not process @LaTeX{} fragments at all
11632 @item @samp{#+OPTIONS: tex:verbatim}
11633 @tab Verbatim export, for jsMath or so
11634 @end multitable
11636 @node Previewing @LaTeX{} fragments
11637 @subsection Previewing @LaTeX{} fragments
11639 @cindex @LaTeX{} fragments, preview
11641 @vindex org-preview-latex-default-process
11642 If you have a working @LaTeX{} installation and @samp{dvipng}, @samp{dvisvgm} or
11643 @samp{convert} installed@footnote{These are respectively available at
11644 @uref{http://sourceforge.net/projects/dvipng/}, @uref{http://dvisvgm.bplaced.net/}
11645 and from the ImageMagick suite.  Choose the converter by setting the
11646 variable @code{org-preview-latex-default-process} accordingly.}, @LaTeX{} fragments can be processed to
11647 produce images of the typeset expressions to be used for inclusion
11648 while exporting to HTML (see @ref{@LaTeX{} fragments}), or for inline
11649 previewing within Org mode.
11651 @vindex org-format-latex-options
11652 @vindex org-format-latex-header
11653 You can customize the variables @code{org-format-latex-options} and
11654 @code{org-format-latex-header} to influence some aspects of the preview.
11655 In particular, the @code{:scale} (and for HTML export, @code{:html-scale})
11656 property of the former can be used to adjust the size of the preview
11657 images.
11659 @table @asis
11660 @item @kbd{C-c C-x C-l} (@code{org-toggle-latex-fragment})
11661 @kindex C-c C-x C-l
11662 @findex org-toggle-latex-fragment
11664 Produce a preview image of the @LaTeX{} fragment at point and
11665 overlay it over the source code.  If there is no fragment at
11666 point, process all fragments in the current entry (between two
11667 headlines).  When called with a prefix argument, process the
11668 entire subtree.  When called with two prefix arguments, or when
11669 the cursor is before the first headline, process the entire
11670 buffer.
11671 @end table
11673 @vindex org-startup-with-latex-preview
11674 You can turn on the previewing of all @LaTeX{} fragments in a file with
11676 @example
11677 #+STARTUP: latexpreview
11678 @end example
11680 To disable it, simply use
11682 @example
11683 #+STARTUP: nolatexpreview
11684 @end example
11686 @node CD@LaTeX{} mode
11687 @subsection Using CD@LaTeX{} to enter math
11689 @cindex CD@LaTeX{}
11691 CD@LaTeX{} mode is a minor mode that is normally used in combination with
11692 a major @LaTeX{} mode like AUC@TeX{} in order to speed-up insertion of
11693 environments and math templates.  Inside Org mode, you can make use of
11694 some of the features of CD@LaTeX{} mode.  You need to install
11695 @samp{cdlatex.el} and @samp{texmathp.el} (the latter comes also with AUC@TeX{})
11696 from @uref{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.  Do not use
11697 CD@LaTeX{} mode itself under Org mode, but use the light version
11698 @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it on for the
11699 current buffer with @kbd{M-x org-cdlatex-mode}, or for all Org
11700 files with
11702 @lisp
11703 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
11704 @end lisp
11706 When this mode is enabled, the following features are present (for
11707 more details see the documentation of CD@LaTeX{} mode):
11709 @table @asis
11710 @item @kbd{C-c @{}
11711 @kindex C-c @{
11713 Insert an environment template.
11715 @item @kbd{@key{TAB}}
11716 @kindex TAB
11718 The @kbd{@key{TAB}} key expands the template if the cursor is
11719 inside a @LaTeX{} fragment@footnote{Org mode has a method to test if the cursor is inside such
11720 a fragment, see the documentation of the function
11721 @code{org-inside-LaTeX-fragment-p}.}.  For example, @kbd{@key{TAB}}
11722 expands @samp{fr} to @samp{\frac@{@}@{@}} and position the cursor correctly
11723 inside the first brace.  Another @kbd{@key{TAB}} gets you into the
11724 second brace.
11726 Even outside fragments, @kbd{@key{TAB}} expands environment
11727 abbreviations at the beginning of a line.  For example, if you
11728 write @samp{equ} at the beginning of a line and press @kbd{@key{TAB}},
11729 this abbreviation is expanded to an @samp{equation} environment.  To
11730 get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
11732 @item @kbd{^}
11733 @itemx @kbd{_}
11734 @kindex _
11735 @kindex ^
11736 @vindex cdlatex-simplify-sub-super-scripts
11738 Pressing @kbd{_} and @kbd{^} inside a @LaTeX{} fragment
11739 inserts these characters together with a pair of braces.  If you
11740 use @kbd{@key{TAB}} to move out of the braces, and if the braces
11741 surround only a single character or macro, they are removed again
11742 (depending on the variable @code{cdlatex-simplify-sub-super-scripts}).
11744 @item @kbd{`}
11745 @kindex `
11747 Pressing the backquote followed by a character inserts math
11748 macros, also outside @LaTeX{} fragments.  If you wait more than 1.5
11749 seconds after the backquote, a help window pops up.
11751 @item @kbd{'}
11752 @kindex '
11754 Pressing the single-quote followed by another character modifies
11755 the symbol before point with an accent or a font.  If you wait
11756 more than 1.5 seconds after the single-quote, a help window pops
11757 up.  Character modification works only inside @LaTeX{} fragments;
11758 outside the quote is normal.
11759 @end table
11761 @node Exporting
11762 @chapter Exporting
11764 @cindex exporting
11766 Sometimes, you may want to pretty print your notes, publish them on
11767 the web or even share them with people not using Org.  In these cases,
11768 the Org export facilities can be used to convert your documents to
11769 a variety of other formats, while retaining as much structure (see
11770 @ref{Document Structure}) and markup (see @ref{Markup}) as
11771 possible.
11773 @cindex export back-end
11774 Libraries responsible for such translation are called back-ends.  Org
11775 ships with the following ones
11777 @itemize
11778 @item
11779 @emph{ascii} (ASCII format)
11780 @item
11781 @emph{beamer} (@LaTeX{} Beamer format)
11782 @item
11783 @emph{html} (HTML format)
11784 @item
11785 @emph{icalendar} (iCalendar format)
11786 @item
11787 @emph{latex} (@LaTeX{} format)
11788 @item
11789 @emph{md} (Markdown format)
11790 @item
11791 @emph{odt} (OpenDocument Text format)
11792 @item
11793 @emph{org} (Org format)
11794 @item
11795 @emph{texinfo} (Texinfo format)
11796 @item
11797 @emph{man} (Man page format)
11798 @end itemize
11800 @noindent
11801 Org also uses additional libraries located in @samp{contrib/} directory
11802 (see @ref{Installation}).  Users can install additional export libraries
11803 for additional formats from the Emacs packaging system.  For easy
11804 discovery, these packages have a common naming scheme: @code{ox-NAME},
11805 where @var{NAME} is one of the formats.  For example,
11806 @code{ox-koma-letter} @emph{koma-letter} back-end.
11808 @vindex org-export-backends
11809 Org loads back-ends for the following formats by default: ASCII, HTML,
11810 iCalendar, @LaTeX{} and ODT.  Org can load additional back-ends either of
11811 two ways: through the @code{org-export-backends} variable configuration;
11812 or, by requiring the library in the Emacs init file like this:
11814 @lisp
11815 (require 'ox-md)
11816 @end lisp
11818 @menu
11819 * The Export Dispatcher::        The main interface.
11820 * Export Settings::              Common export settings.
11821 * Table of Contents::            The if and where of the table of contents.
11822 * Include Files::                Include additional files into a document.
11823 * Macro Replacement::            Use macros to create templates.
11824 * Comment Lines::                What will not be exported.
11825 * ASCII/Latin-1/UTF-8 export::   Exporting to flat files with encoding.
11826 * Beamer Export::
11827 * HTML Export::                  Exporting to HTML.
11828 * @LaTeX{} Export::              Exporting to @LaTeX{} and processing to PDF.
11829 * Markdown Export::              Exporting to Markdown.
11830 * OpenDocument Text Export::     Exporting to OpenDocument Text.
11831 * Org Export::                   Exporting to Org.
11832 * Texinfo Export::               Exporting to Texinfo.
11833 * iCalendar Export::             Exporting to iCalendar.
11834 * Other Built-in Back-ends::     Exporting to a man page.
11835 * Advanced Configuration::       Fine-tuning the export output.
11836 * Export in Foreign Buffers::    Author tables and lists in Org syntax.
11837 @end menu
11839 @node The Export Dispatcher
11840 @section The Export Dispatcher
11842 @cindex dispatcher, for export commands
11843 @cindex Export, dispatcher
11845 The export dispatcher is the main interface for Org's exports.
11846 A hierarchical menu presents the currently configured export formats.
11847 Options are shown as easy toggle switches on the same screen.
11849 @vindex org-export-dispatch-use-expert-ui
11850 Org also has a minimal prompt interface for the export dispatcher.
11851 When the variable @code{org-export-dispatch-use-expert-ui} is set to
11852 a non-@code{nil} value, Org prompts in the minibuffer.  To switch back to
11853 the hierarchical menu, press @kbd{?}.
11855 @table @asis
11856 @item @kbd{C-c C-e} (@code{org-export})
11857 @kindex C-c C-e
11858 @findex org-export
11860 Invokes the export dispatcher interface.  The options show
11861 default settings.  The @kbd{C-u} prefix argument preserves
11862 options from the previous export, including any sub-tree
11863 selections.
11864 @end table
11866 Org exports the entire buffer by default.  If the Org buffer has an
11867 active region, then Org exports just that region.
11869 Within the dispatcher interface, the following key combinations can
11870 further alter what is exported, and how.
11872 @table @asis
11873 @item @kbd{C-a}
11874 @kindex C-c C-e C-a
11876 Toggle asynchronous export.  Asynchronous export uses an external
11877 Emacs process with a specially configured initialization file to
11878 complete the exporting process in the background thereby
11879 releasing the current interface.  This is particularly useful
11880 when exporting long documents.
11882 Output from an asynchronous export is saved on the ``the export
11883 stack''.  To view this stack, call the export dispatcher with
11884 a double @kbd{C-u} prefix argument.  If already in the
11885 export dispatcher menu, @kbd{&} displays the stack.
11887 @vindex org-export-async-init-file
11888 To make the background export process the default, customize the
11889 variable, @code{org-export-in-background}.  Additionally, you can set
11890 the initialization file used by the background process with
11891 @code{org-export-async-init-file}.
11893 @vindex org-export-in-background
11894 You can make asynchronous export the default by setting
11895 @code{org-export-in-background}.
11897 @item @kbd{C-b}
11898 @kindex C-c C-e C-b
11900 Toggle body-only export.  Useful for excluding headers and
11901 footers in the export.  Affects only those back-end formats that
11902 have such sections---like @samp{<head>...</head>} in HTML.
11904 @item @{@{@{kbd(C-s@}@}@}
11905 @kindex C-c C-e C-s
11907 Toggle sub-tree export.  When turned on, Org exports only the
11908 sub-tree starting from the cursor position at the time the export
11909 dispatcher was invoked.  Org uses the top heading of this
11910 sub-tree as the document's title.  If the cursor is not on
11911 a heading, Org uses the nearest enclosing header.  If the cursor
11912 is in the document preamble, Org signals an error and aborts
11913 export.
11915 @vindex org-export-initial-scope
11916 To make the sub-tree export the default, customize the variable
11917 @code{org-export-initial-scope}.
11919 @item @kbd{C-v}
11920 @kindex C-c C-e C-v
11922 Toggle visible-only export.  Useful for exporting only visible
11923 parts of an Org document by adjusting outline visibility
11924 settings.
11925 @end table
11927 @node Export Settings
11928 @section Export Settings
11930 @cindex options, for export
11931 @cindex Export, settings
11933 @cindex @samp{OPTIONS}, keyword
11934 Export options can be set: globally with variables; for an individual
11935 file by making variables buffer-local with in-buffer settings (see
11936 @ref{In-buffer Settings}), by setting individual keywords, or by
11937 specifying them in a compact form with the @samp{OPTIONS} keyword; or for
11938 a tree by setting properties (see @ref{Properties and Columns}).  Options
11939 set at a specific level override options set at a more general level.
11941 @cindex SETUPFILE, keyword
11942 In-buffer settings may appear anywhere in the file, either directly or
11943 indirectly through a file included using @samp{#+SETUPFILE: filename or
11944 URL} syntax.  Option keyword sets tailored to a particular back-end
11945 can be inserted from the export dispatcher (see @ref{The Export Dispatcher}) using the @samp{Insert template} command by pressing
11946 @kbd{#}.  To insert keywords individually, a good way to make
11947 sure the keyword is correct is to type @samp{#+} and then to use
11948 @kbd{M-@key{TAB}}@footnote{Many desktops intercept @kbd{M-@key{TAB}} to switch windows.
11949 Use @kbd{C-M-i} or @kbd{@key{ESC} @key{TAB}} instead.} for completion.
11951 The export keywords available for every back-end, and their equivalent
11952 global variables, include:
11954 @table @asis
11955 @item @samp{AUTHOR}
11956 @cindex @samp{AUTHOR}, keyword
11957 @vindex user-full-name
11958 The document author (@code{user-full-name}).
11960 @item @samp{CREATOR}
11961 @cindex @samp{CREATOR}, keyword
11962 @vindex org-expot-creator-string
11963 Entity responsible for output generation
11964 (@code{org-export-creator-string}).
11966 @item @samp{DATE}
11967 @cindex @samp{DATE}, keyword
11968 @vindex org-export-date-timestamp-format
11969 A date or a time-stamp@footnote{The variable @code{org-export-date-timestamp-format} defines how
11970 this timestamp are exported.}.
11972 @item @samp{EMAIL}
11973 @cindex @samp{EMAIL}, keyword
11974 @vindex user-mail-address
11975 The email address (@code{user-mail-address}).
11977 @item @samp{LANGUAGE}
11978 @cindex @samp{LANGUAGE}, keyword
11979 @vindex org-export-default-language
11980 Language to use for translating certain strings
11981 (@code{org-export-default-language}).  With @samp{#+LANGUAGE: fr}, for
11982 example, Org translates @samp{Table of contents} to the French @samp{Table
11983      des matières}.
11985 @item @samp{SELECT_TAGS}
11986 @cindex @samp{SELECT_TAGS}, keyword
11987 @vindex org-export-select-tags
11988 The default value is @code{("export")}.  When a tree is tagged with
11989 @samp{export} (@code{org-export-select-tags}), Org selects that tree and
11990 its sub-trees for export.  Org excludes trees with @samp{noexport}
11991 tags, see below.  When selectively exporting files with @samp{export}
11992 tags set, Org does not export any text that appears before the
11993 first headline.
11995 @item @samp{EXCLUDE_TAGS}
11996 @cindex @samp{EXCLUDE_TAGS}, keyword
11997 @vindex org-export-exclude-tags
11998 The default value is @code{("noexport")}.  When a tree is tagged with
11999 @samp{noexport} (@code{org-export-exclude-tags}), Org excludes that tree
12000 and its sub-trees from export.  Entries tagged with @samp{noexport}
12001 are unconditionally excluded from the export, even if they have
12002 an @samp{export} tag.  Even if a sub-tree is not exported, Org
12003 executes any code blocks contained there.
12005 @item @samp{TITLE}
12006 @cindex @samp{TITLE}, keyword
12007 @cindex document title
12008 Org displays this title.  For long titles, use multiple @samp{#+TITLE}
12009 lines.
12011 @item @samp{EXPORT_FILE_NAME}
12012 @cindex @samp{EXPORT_FILE_NAME}, keyword
12013 The name of the output file to be generated.  Otherwise, Org
12014 generates the file name based on the buffer name and the
12015 extension based on the back-end format.
12016 @end table
12018 The @samp{OPTIONS} keyword is a compact form.  To configure multiple
12019 options, use several @samp{OPTIONS} lines.  @samp{OPTIONS} recognizes the
12020 following arguments.
12022 @table @asis
12023 @item @code{'}
12024 @vindex org-export-with-smart-quotes
12025 Toggle smart quotes (@code{org-export-with-smart-quotes}).  Depending
12026 on the language used, when activated, Org treats pairs of double
12027 quotes as primary quotes, pairs of single quotes as secondary
12028 quotes, and single quote marks as apostrophes.
12030 @item @code{*}
12031 @vindex org-export-with-emphasize
12032 Toggle emphasized text (@code{org-export-with-emphasize}).
12034 @item @code{-}
12035 @vindex org-export-with-special-strings
12036 Toggle conversion of special strings
12037 (@code{org-export-with-special-strings}).
12039 @item @code{:}
12040 @vindex org-export-with-fixed-width
12041 Toggle fixed-width sections (@code{org-export-with-fixed-width}).
12043 @item @code{<}
12044 @vindex org-export-with-timestamps
12045 Toggle inclusion of time/date active/inactive stamps
12046 (@code{org-export-with-timestamps}).
12048 @item @code{\n}
12049 @vindex org-export-preserve-breaks
12050 Toggles whether to preserve line breaks
12051 (@code{org-export-preserve-breaks}).
12053 @item @code{^}
12054 @vindex org-export-with-sub-superscripts
12055 Toggle @TeX{}-like syntax for sub- and superscripts.  If you write
12056 @samp{^:@{@}}, @samp{a_@{b@}} is interpreted, but the simple @samp{a_b} is left as
12057 it is (@code{org-export-with-sub-superscripts}).
12059 @item @code{arch}
12060 @vindex org-export-with-archived-trees
12061 Configure how archived trees are exported.  When set to
12062 @code{headline}, the export process skips the contents and processes
12063 only the headlines (@code{org-export-with-archived-trees}).
12065 @item @code{author}
12066 @vindex org-export-with-author
12067 Toggle inclusion of author name into exported file
12068 (@code{org-export-with-author}).
12070 @item @code{broken-links}
12071 @vindex org-export-with-broken-links
12072 Toggles if Org should continue exporting upon finding a broken
12073 internal link.  When set to @code{mark}, Org clearly marks the problem
12074 link in the output (@code{org-export-with-broken-links}).
12076 @item @code{c}
12077 @vindex org-export-with-clocks
12078 Toggle inclusion of CLOCK keywords (@code{org-export-with-clocks}).
12080 @item @code{creator}
12081 @vindex org-export-with-creator
12082 Toggle inclusion of creator information in the exported file
12083 (@code{org-export-with-creator}).
12085 @item @code{d}
12086 @vindex org-export-with-drawers
12087 Toggles inclusion of drawers, or list of drawers to include, or
12088 list of drawers to exclude (@code{org-export-with-drawers}).
12090 @item @code{date}
12091 @vindex org-export-with-date
12092 Toggle inclusion of a date into exported file
12093 (@code{org-export-with-date}).
12095 @item @code{e}
12096 @vindex org-export-with-entities
12097 Toggle inclusion of entities (@code{org-export-with-entities}).
12099 @item @code{email}
12100 @vindex org-export-with-email
12101 Toggle inclusion of the author's e-mail into exported file
12102 (@code{org-export-with-email}).
12104 @item @code{f}
12105 @vindex org-export-with-footnotes
12106 Toggle the inclusion of footnotes (@code{org-export-with-footnotes}).
12108 @item @code{H}
12109 @vindex org-export-headline-levels
12110 Set the number of headline levels for export
12111 (@code{org-export-headline-levels}).  Below that level, headlines are
12112 treated differently.  In most back-ends, they become list items.
12114 @item @code{inline}
12115 @vindex org-export-with-inlinetasks
12116 Toggle inclusion of inlinetasks (@code{org-export-with-inlinetasks}).
12118 @item @code{num}
12119 @vindex org-export-with-section-numbers
12120 @cindex @samp{UNNUMBERED}, property
12121 Toggle section-numbers (@code{org-export-with-section-numbers}).  When
12122 set to number N, Org numbers only those headlines at level N or
12123 above.  Set @samp{UNNUMBERED} property to non-@code{nil} to disable
12124 numbering of heading and subheadings entirely.  Moreover, when
12125 the value is @samp{notoc} the headline, and all its children, do not
12126 appear in the table of contents either (see @ref{Table of Contents}).
12128 @item @code{p}
12129 @vindex org-export-with-planning
12130 Toggle export of planning information
12131 (@code{org-export-with-planning}).  ``Planning information'' comes from
12132 lines located right after the headline and contain any
12133 combination of these cookies: @samp{SCHEDULED}, @samp{DEADLINE}, or
12134 @samp{CLOSED}.
12136 @item @code{pri}
12137 @vindex org-export-with-priority
12138 Toggle inclusion of priority cookies
12139 (@code{org-export-with-priority}).
12141 @item @code{prop}
12142 @vindex org-export-with-properties
12143 Toggle inclusion of property drawers, or list the properties to
12144 include (@code{org-export-with-properties}).
12146 @item @code{stat}
12147 @vindex org-export-with-statistics-cookies
12148 Toggle inclusion of statistics cookies
12149 (@code{org-export-with-statistics-cookies}).
12151 @item @code{tags}
12152 @vindex org-export-with-tags
12153 Toggle inclusion of tags, may also be @code{not-in-toc}
12154 (@code{org-export-with-tags}).
12156 @item @code{tasks}
12157 @vindex org-export-with-tasks
12158 Toggle inclusion of tasks (TODO items); or @code{nil} to remove all
12159 tasks; or @code{todo} to remove DONE tasks; or list the keywords to
12160 keep (@code{org-export-with-tasks}).
12162 @item @code{tex}
12163 @vindex org-export-with-latex
12164 @code{nil} does not export; @code{t} exports; @code{verbatim} keeps everything
12165 in verbatim (@code{org-export-with-latex}).
12167 @item @code{timestamp}
12168 @vindex org-export-time-stamp-file
12169 Toggle inclusion of the creation time in the exported file
12170 (@code{org-export-time-stamp-file}).
12172 @item @code{title}
12173 @vindex org-export-with-title
12174 Toggle inclusion of title (@code{org-export-with-title}).
12176 @item @code{toc}
12177 @vindex org-export-with-toc
12178 Toggle inclusion of the table of contents, or set the level limit
12179 (@code{org-export-with-toc}).
12181 @item @code{todo}
12182 @vindex org-export-with-todo-keywords
12183 Toggle inclusion of TODO keywords into exported text
12184 (@code{org-export-with-todo-keywords}).
12186 @item @code{|}
12187 @vindex org-export-with-tables
12188 Toggle inclusion of tables (@code{org-export-with-tables}).
12189 @end table
12191 When exporting sub-trees, special node properties in them can override
12192 the above keywords.  They are special because they have an @samp{EXPORT_}
12193 prefix.  For example, @samp{DATE} and @samp{EXPORT_FILE_NAME} keywords become,
12194 respectively, @samp{EXPORT_DATE} and @samp{EXPORT_FILE_NAME}.  Except for
12195 @samp{SETUPFILE}, all other keywords listed above have an @samp{EXPORT_}
12196 equivalent.
12198 @cindex @samp{BIND}, keyword
12199 @vindex org-export-allow-bind-keywords
12200 If @code{org-export-allow-bind-keywords} is non-@code{nil}, Emacs variables can
12201 become buffer-local during export by using the @samp{BIND} keyword.  Its
12202 syntax is @samp{#+BIND: variable value}.  This is particularly useful for
12203 in-buffer settings that cannot be changed using keywords.
12205 @node Table of Contents
12206 @section Table of Contents
12208 @cindex table of contents
12209 @cindex list of tables
12210 @cindex list of listings
12212 @cindex @samp{toc}, in @samp{OPTIONS} keyword
12213 @vindex org-export-with-toc
12214 The table of contents includes all headlines in the document.  Its
12215 depth is therefore the same as the headline levels in the file.  If
12216 you need to use a different depth, or turn it off entirely, set the
12217 @code{org-export-with-toc} variable accordingly.  You can achieve the same
12218 on a per file basis, using the following @samp{toc} item in @samp{OPTIONS}
12219 keyword:
12221 @example
12222 #+OPTIONS: toc:2          (only include two levels in TOC)
12223 #+OPTIONS: toc:nil        (no default TOC at all)
12224 @end example
12226 @cindex excluding entries from table of contents
12227 @cindex table of contents, exclude entries
12228 Org includes both numbered and unnumbered headlines in the table of
12229 contents@footnote{At the moment, some export back-ends do not obey this
12230 specification.  For example, @LaTeX{} export excludes every unnumbered
12231 headline from the table of contents.}.  If you need to exclude an unnumbered headline,
12232 along with all its children, set the @samp{UNNUMBERED} property to @samp{notoc}
12233 value.
12235 @example
12236 * Subtree not numbered, not in table of contents either
12237   :PROPERTIES:
12238   :UNNUMBERED: notoc
12239   :END:
12240 @end example
12242 @cindex @samp{TOC}, keyword
12243 Org normally inserts the table of contents directly before the first
12244 headline of the file.  To move the table of contents to a different
12245 location, first turn off the default with @code{org-export-with-toc}
12246 variable or with @samp{#+OPTIONS: toc:nil}.  Then insert @samp{#+TOC: headlines
12247 N} at the desired location(s).
12249 @example
12250 #+OPTIONS: toc:nil
12252 #+TOC: headlines 2
12253 @end example
12255 To adjust the table of contents depth for a specific section of the
12256 Org document, append an additional @samp{local} parameter.  This parameter
12257 becomes a relative depth for the current level.  The following example
12258 inserts a local table of contents, with direct children only.
12260 @example
12261 * Section
12262 #+TOC: headlines 1 local
12263 @end example
12265 Note that for this feature to work properly in @LaTeX{} export, the Org
12266 file requires the inclusion of the titletoc package.  Because of
12267 compatibility issues, titletoc has to be loaded @emph{before} hyperref.
12268 Customize the @code{org-latex-default-packages-alist} variable.
12270 Use the @samp{TOC} keyword to generate list of tables---respectively, all
12271 listings---with captions.
12273 @example
12274 #+TOC: listings
12275 #+TOC: tables
12276 @end example
12278 @cindex @samp{ALT_TITLE}, property
12279 Normally Org uses the headline for its entry in the table of contents.
12280 But with @samp{ALT_TITLE} property, a different entry can be specified for
12281 the table of contents.
12283 @node Include Files
12284 @section Include Files
12286 @cindex include files, during export
12287 @cindex Export, include files
12288 @cindex @samp{INCLUDE}, keyword
12290 During export, you can include the content of another file.  For
12291 example, to include your @samp{.emacs} file, you could use:
12293 @example
12294 #+INCLUDE: "~/.emacs" src emacs-lisp
12295 @end example
12297 @noindent
12298 The optional second and third parameter are the markup (e.g., @samp{quote},
12299 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the language for
12300 formatting the contents.  The markup is optional; if it is not given,
12301 assume text is in Org syntax and process it normally.  The @samp{INCLUDE}
12302 keyword also allows additional parameters @samp{:prefix1} and @samp{:prefix} to
12303 specify prefixes for the first line and for each following line,
12304 @samp{:minlevel} in order to get Org mode content demoted to a specified
12305 level, as well as any options accepted by the selected markup.  For
12306 example, to include a file as an item, use:
12308 @example
12309 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
12310 @end example
12312 You can also include a portion of a file by specifying a lines range
12313 using the @samp{:lines} parameter.  The line at the upper end of the range
12314 is not included.  The start and/or the end of the range may be omitted
12315 to use the obvious defaults.
12317 @table @asis
12318 @item @samp{#+INCLUDE: "~/.emacs" :lines "5-10"}
12319 Include lines 5 to 10, 10 excluded.
12321 @item @samp{#+INCLUDE: "~/.emacs" :lines "-10"} 
12322 Include lines 1 to 10, 10 excluded.
12324 @item @samp{#+INCLUDE: "~/.emacs" :lines "10-"} 
12325 Include lines from 10 to EOF.
12326 @end table
12328 You can visit the file being included with the following command.
12330 @table @asis
12331 @item @kbd{C-c '} (@code{org-edit~special})
12332 @kindex C-c '
12333 @findex org-edit-special
12335 Visit the include file at point.
12336 @end table
12338 @node Macro Replacement
12339 @section Macro Replacement
12341 @cindex macro replacement, during export
12342 @cindex @samp{MACRO}, keyword
12344 @vindex org-export-global-macros
12345 Macros replace text snippets during export.  Macros are defined
12346 globally in @code{org-export-global-macros}, or document-wise with the
12347 following syntax:
12349 @example
12350 #+MACRO: name   replacement text; $1, $2 are arguments
12351 @end example
12353 @noindent
12354 which can be referenced using @samp{@{@{@{name(arg1, arg2)@}@}@}}@footnote{Since commas separate the arguments, commas within arguments
12355 have to be escaped with the backslash character.  So only those
12356 backslash characters before a comma need escaping with another
12357 backslash character.}.  For
12358 example
12360 @example
12361 #+MACRO: poem The rose is $1, The violet's $2. Life's ordered: Org assists you.
12362 @{@{@{poem(red,blue)@}@}@}
12363 @end example
12365 @noindent
12366 becomes
12368 @example
12369 The rose is red, The violet's blue. Life's ordered: Org assists you.
12370 @end example
12372 As a special case, Org parses any replacement text starting with
12373 @samp{(eval} as an Emacs Lisp expression and evaluates it accordingly.
12374 Within such templates, arguments become strings.  Thus, the following
12375 macro
12377 @example
12378 #+MACRO: gnucheck (eval (concat "GNU/" (capitalize $1)))
12379 @end example
12381 @noindent
12382 turns @samp{@{@{@{gnucheck(linux)@}@}@}} into @samp{GNU/Linux} during export.
12384 Org recognizes macro references in following Org markup areas:
12385 paragraphs, headlines, verse blocks, tables cells and lists.  Org also
12386 recognizes macro references in keywords, such as @samp{CAPTION}, @samp{TITLE},
12387 @samp{AUTHOR}, @samp{DATE}, and for some back-end specific export options.
12389 Org comes with following pre-defined macros:
12391 @table @asis
12392 @item @samp{@{@{@{keyword(NAME)@}@}@}}
12393 @itemx @samp{@{@{@{title@}@}@}}
12394 @itemx @samp{@{@{@{author@}@}@}}
12395 @itemx @samp{@{@{@{email@}@}@}}
12396 @cindex @samp{keyword}, macro
12397 @cindex @samp{title}, macro
12398 @cindex @samp{author}, macro
12399 @cindex @samp{email}, macro
12400 The @samp{keyword} macro collects all values from @var{NAME}
12401 keywords throughout the buffer, separated with white space.
12402 @samp{title}, @samp{author} and @samp{email} macros are shortcuts for,
12403 respectively, @samp{@{@{@{keyword(TITLE)@}@}@}}, @samp{@{@{@{keyword(AUTHOR)@}@}@}} and
12404 @samp{@{@{@{keyword(EMAIL)@}@}@}}.
12406 @item @samp{@{@{@{date@}@}@}}
12407 @itemx @samp{@{@{@{date(FORMAT)@}@}@}}
12408 @cindex @samp{date}, macro
12409 This macro refers to the @samp{DATE} keyword.  @var{FORMAT} is an
12410 optional argument to the @samp{date} macro that is used only if @samp{DATE}
12411 is a single timestamp.  @var{FORMAT} should be a format
12412 string understood by @code{format-time-string}.
12414 @item @samp{@{@{@{time(FORMAT)@}@}@}}
12415 @itemx @samp{@{@{@{modification-time(FORMAT, VC)@}@}@}}
12416 @cindex @samp{time}, macro
12417 @cindex @samp{modification-time}, macro
12418 These macros refer to the document's date and time of export and
12419 date and time of modification.  @var{FORMAT} is a string
12420 understood by @code{format-time-string}.  If the second argument to
12421 the @code{modification-time} macro is non-@code{nil}, Org uses @samp{vc.el} to
12422 retrieve the document's modification time from the version
12423 control system.  Otherwise Org reads the file attributes.
12425 @item @samp{@{@{@{input-file@}@}@}}
12426 @cindex @samp{input-file}, macro
12427 This macro refers to the filename of the exported file.
12429 @item @samp{@{@{@{property(PROPERTY-NAME)@}@}@}}
12430 @itemx @samp{@{@{@{property(PROPERTY-NAME, SEARCH OPTION)@}@}@}}
12431 @cindex @samp{property}, macro
12432 This macro returns the value of property @var{PROPERTY-NAME}
12433 in the current entry.  If @var{SEARCH-OPTION} (see @ref{Search Options}) refers to a remote entry, use it instead.
12435 @item @samp{@{@{@{n@}@}@}}
12436 @itemx @samp{@{@{@{n(NAME)@}@}@}}
12437 @itemx @samp{@{@{@{n(NAME, ACTION)@}@}@}}
12438 @cindex @samp{n}, macro
12439 @cindex counter, macro
12440 This macro implements custom counters by returning the number of
12441 times the macro has been expanded so far while exporting the
12442 buffer.  You can create more than one counter using different
12443 @var{NAME} values.  If @var{ACTION} is @samp{-}, previous
12444 value of the counter is held, i.e., the specified counter is not
12445 incremented.  If the value is a number, the specified counter is
12446 set to that value.  If it is any other non-empty string, the
12447 specified counter is reset to 1.  You may leave @var{NAME}
12448 empty to reset the default counter.
12449 @end table
12451 @vindex org-hide-macro-markers
12452 The surrounding brackets can be made invisible by setting
12453 @code{org-hide-macro-markers} non-@code{nil}.
12455 Org expands macros at the very beginning of the export process.
12457 @node Comment Lines
12458 @section Comment Lines
12460 @cindex exporting, not
12462 @cindex comment lines
12463 Lines starting with zero or more whitespace characters followed by one
12464 @samp{#} and a whitespace are treated as comments and, as such, are not
12465 exported.
12467 @cindex @samp{BEGIN_COMMENT}
12468 @cindex comment block
12469 Likewise, regions surrounded by @samp{#+BEGIN_COMMENT} @dots{} @samp{#+END_COMMENT}
12470 are not exported.
12472 @cindex comment trees
12473 Finally, a @samp{COMMENT} keyword at the beginning of an entry, but after
12474 any other keyword or priority cookie, comments out the entire subtree.
12475 In this case, the subtree is not exported and no code block within it
12476 is executed either@footnote{For a less drastic behavior, consider using a select tag (see
12477 @ref{Export Settings}) instead.}.  The command below helps changing the
12478 comment status of a headline.
12480 @table @asis
12481 @item @kbd{C-c ;} (@code{org-toggle-comment})
12482 @kindex C-c ;
12483 @findex org-toggle-comment
12485 Toggle the @samp{COMMENT} keyword at the beginning of an entry.
12486 @end table
12488 @node ASCII/Latin-1/UTF-8 export
12489 @section ASCII/Latin-1/UTF-8 export
12491 @cindex ASCII export
12492 @cindex Latin-1 export
12493 @cindex UTF-8 export
12495 ASCII export produces an output file containing only plain ASCII
12496 characters.  This is the simplest and most direct text output.  It
12497 does not contain any Org markup.  Latin-1 and UTF-8 export use
12498 additional characters and symbols available in these encoding
12499 standards.  All three of these export formats offer the most basic of
12500 text output for maximum portability.
12502 @vindex org-ascii-text-width
12503 On export, Org fills and justifies text according to the text width
12504 set in @code{org-ascii-text-width}.
12506 @vindex org-ascii-links-to-notes
12507 Org exports links using a footnote-like style where the descriptive
12508 part is in the text and the link is in a note before the next heading.
12509 See the variable @code{org-ascii-links-to-notes} for details.
12511 @anchor{ASCII export commands}
12512 @subheading ASCII export commands
12514 @table @asis
12515 @item @kbd{C-c C-e t a} (@code{org-ascii-export-to-ascii})
12516 @itemx @kbd{C-c C-e t l}
12517 @itemx @kbd{C-c C-e t u}
12518 @kindex C-c C-e t a
12519 @kindex C-c C-e t l
12520 @kindex C-c C-e t u
12521 @findex org-ascii-export-to-ascii
12523 Export as an ASCII file with a @samp{.txt} extension.  For
12524 @samp{myfile.org}, Org exports to @samp{myfile.txt}, overwriting without
12525 warning.  For @samp{myfile.txt}, Org exports to @samp{myfile.txt.txt} in
12526 order to prevent data loss.
12527 @end table
12529 @table @asis
12530 @item @kbd{C-c C-e t A} (@code{org-ascii-export-to-ascii})
12531 @itemx @kbd{C-c C-e t L}
12532 @itemx @kbd{C-c C-e t U}
12533 @kindex C-c C-e t A
12534 @kindex C-c C-e t L
12535 @kindex C-c C-e t U
12536 @findex org-ascii-export-to-ascii
12538 Export to a temporary buffer.  Does not create a file.
12539 @end table
12541 @anchor{ASCII specific export settings}
12542 @subheading ASCII specific export settings
12544 The ASCII export back-end has one extra keyword for customizing ASCII
12545 output.  Setting this keyword works similar to the general options
12546 (see @ref{Export Settings}).
12548 @table @asis
12549 @item @samp{SUBTITLE}
12550 @cindex @samp{SUBTITLE}, keyword
12551 The document subtitle.  For long subtitles, use multiple
12552 @samp{#+SUBTITLE} lines in the Org file.  Org prints them on one
12553 continuous line, wrapping into multiple lines if necessary.
12554 @end table
12556 @anchor{Header and sectioning structure}
12557 @subheading Header and sectioning structure
12559 Org converts the first three outline levels into headlines for ASCII
12560 export.  The remaining levels are turned into lists.  To change this
12561 cut-off point where levels become lists, see @ref{Export Settings}.
12563 @anchor{Quoting ASCII text}
12564 @subheading Quoting ASCII text
12566 To insert text within the Org file by the ASCII back-end, use one the
12567 following constructs, inline, keyword, or export block:
12569 @cindex @samp{ASCII}, keyword
12570 @cindex @samp{BEGIN_EXPORT ascii}
12571 @example
12572 Inline text @@@@ascii:and additional text@@@@ within a paragraph.
12574 #+ASCII: Some text
12576 #+BEGIN_EXPORT ascii
12577 Org exports text in this block only when using ASCII back-end.
12578 #+END_EXPORT
12579 @end example
12581 @anchor{ASCII specific attributes}
12582 @subheading ASCII specific attributes
12584 @cindex @samp{ATTR_ASCII}, keyword
12585 @cindex horizontal rules, in ASCII export
12587 ASCII back-end recognizes only one attribute, @code{:width}, which
12588 specifies the width of an horizontal rule in number of characters.
12589 The keyword and syntax for specifying widths is:
12591 @example
12592 #+ATTR_ASCII: :width 10
12593 -----
12594 @end example
12596 @anchor{ASCII special blocks}
12597 @subheading ASCII special blocks
12599 @cindex special blocks, in ASCII export
12600 @cindex @samp{BEGIN_JUSTIFYLEFT}
12601 @cindex @samp{BEGIN_JUSTIFYRIGHT}
12603 Besides @samp{#+BEGIN_CENTER} blocks (see @ref{Paragraphs}), ASCII back-end has
12604 these two left and right justification blocks:
12606 @example
12607 #+BEGIN_JUSTIFYLEFT
12608 It's just a jump to the left...
12609 #+END_JUSTIFYLEFT
12611 #+BEGIN_JUSTIFYRIGHT
12612 ...and then a step to the right.
12613 #+END_JUSTIFYRIGHT
12614 @end example
12616 @node Beamer Export
12617 @section Beamer Export
12619 @cindex Beamer export
12621 Org uses Beamer export to convert an Org file tree structure into
12622 high-quality interactive slides for presentations.  Beamer is a @LaTeX{}
12623 document class for creating presentations in PDF, HTML, and other
12624 popular display formats.
12626 @menu
12627 * Beamer export commands::       For creating Beamer documents.
12628 * Beamer specific export settings:: For customizing Beamer export.
12629 * Frames and Blocks in Beamer::  For composing Beamer slides.
12630 * Beamer specific syntax::       For using in Org documents.
12631 * Editing support::              Editing support.
12632 * A Beamer example::             A complete presentation.
12633 @end menu
12635 @node Beamer export commands
12636 @subsection Beamer export commands
12638 @table @asis
12639 @item @kbd{C-c C-e l b} (@code{org-beamer-export-to-latex})
12640 @kindex C-c C-e l b
12641 @findex org-beamer-export-to-latex
12643 Export as @LaTeX{} file with a @samp{.tex} extension.  For @samp{myfile.org},
12644 Org exports to @samp{myfile.tex}, overwriting without warning.
12646 @item @kbd{C-c C-e l B} (@code{org-beamer-export-as-latex})
12647 @kindex C-c C-e l B
12648 @findex org-beamer-export-as-latex
12650 Export to a temporary buffer.  Does not create a file.
12652 @item @kbd{C-c C-e l P} (@code{org-beamer-export-to-pdf})
12653 @kindex C-c C-e l P
12654 @findex org-beamer-export-to-pdf
12656 Export as @LaTeX{} file and then convert it to PDF format.
12658 @item @kbd{C-c C-e l O}
12659 @kindex C-c C-e l O
12661 Export as @LaTeX{} file, convert it to PDF format, and then open the
12662 PDF file.
12663 @end table
12665 @node Beamer specific export settings
12666 @subsection Beamer specific export settings
12668 Beamer export back-end has several additional keywords for customizing
12669 Beamer output.  These keywords work similar to the general options
12670 settings (see @ref{Export Settings}).
12672 @table @asis
12673 @item @samp{BEAMER_THEME}
12674 @cindex @samp{BEAMER_THEME}, keyword
12675 @vindex org-beamer-theme
12676 The Beamer layout theme (@code{org-beamer-theme}).  Use square
12677 brackets for options.  For example:
12679 @example
12680 #+BEAMER_THEME: Rochester [height=20pt]
12681 @end example
12683 @item @samp{BEAMER_FONT_THEME}
12684 @cindex @samp{BEAMER_FONT_THEME}, keyword
12685 The Beamer font theme.
12687 @item @samp{BEAMER_INNER_THEME}
12688 @cindex @samp{BEAMER_INNER_THEME}, keyword
12689 The Beamer inner theme.
12691 @item @samp{BEAMER_OUTER_THEME}
12692 @cindex @samp{BEAMER_OUTER_THEME}, keyword
12693 The Beamer outer theme.
12695 @item @samp{BEAMER_HEADER}
12696 @cindex @samp{BEAMER_HEADER}, keyword
12697 Arbitrary lines inserted in the preamble, just before the
12698 @samp{hyperref} settings.
12700 @item @samp{DESCRIPTION}
12701 @cindex @samp{DESCRIPTION}, keyword
12702 The document description.  For long descriptions, use multiple
12703 @samp{DESCRIPTION} keywords.  By default, @samp{hyperref} inserts
12704 @samp{DESCRIPTION} as metadata.  Use @code{org-latex-hyperref-template} to
12705 configure document metadata.  Use @code{org-latex-title-command} to
12706 configure typesetting of description as part of front matter.
12708 @item @samp{KEYWORDS}
12709 @cindex @samp{KEYWORDS}, keyword
12710 The keywords for defining the contents of the document.  Use
12711 multiple @samp{KEYWORDS} lines if necessary.  By default, @samp{hyperref}
12712 inserts @samp{KEYWORDS} as metadata.  Use
12713 @code{org-latex-hyperref-template} to configure document metadata.
12714 Use @code{org-latex-title-command} to configure typesetting of
12715 keywords as part of front matter.
12717 @item @samp{SUBTITLE}
12718 @cindex @samp{SUBTITLE}, keyword
12719 Document's subtitle.  For typesetting, use
12720 @code{org-beamer-subtitle-format} string.  Use
12721 @code{org-latex-hyperref-template} to configure document metadata.
12722 Use @code{org-latex-title-command} to configure typesetting of
12723 subtitle as part of front matter.
12724 @end table
12726 @node Frames and Blocks in Beamer
12727 @subsection Frames and Blocks in Beamer
12729 Org transforms heading levels into Beamer's sectioning elements,
12730 frames and blocks.  Any Org tree with a not-too-deep-level nesting
12731 should in principle be exportable as a Beamer presentation.
12733 @itemize
12734 @item
12735 @vindex org-beamer-frame-level
12736 Org headlines become Beamer frames when the heading level in Org is
12737 equal to @code{org-beamer-frame-level} or @samp{H} value in a @samp{OPTIONS} line
12738 (see @ref{Export Settings}).
12740 @cindex @samp{BEAMER_ENV}, property
12741 Org overrides headlines to frames conversion for the current tree of
12742 an Org file if it encounters the @samp{BEAMER_ENV} property set to
12743 @samp{frame} or @samp{fullframe}.  Org ignores whatever
12744 @code{org-beamer-frame-level} happens to be for that headline level in
12745 the Org tree.  In Beamer terminology, a full frame is a frame
12746 without its title.
12748 @item
12749 Org exports a Beamer frame's objects as block environments.  Org can
12750 enforce wrapping in special block types when @samp{BEAMER_ENV} property
12751 is set@footnote{If @samp{BEAMER_ENV} is set, Org export adds @samp{B_environment} tag
12752 to make it visible.  The tag serves as a visual aid and has no
12753 semantic relevance.}.  For valid values see
12754 @code{org-beamer-environments-default}.  To add more values, see
12755 @code{org-beamer-environments-extra}.
12756 @vindex org-beamer-environments-default
12757 @vindex org-beamer-environments-extra
12759 @item
12760 @cindex @samp{BEAMER_REF}, property
12761 If @samp{BEAMER_ENV} is set to @samp{appendix}, Org exports the entry as an
12762 appendix.  When set to @samp{note}, Org exports the entry as a note
12763 within the frame or between frames, depending on the entry's heading
12764 level.  When set to @samp{noteNH}, Org exports the entry as a note
12765 without its title.  When set to @samp{againframe}, Org exports the entry
12766 with @samp{\againframe} command, which makes setting the @samp{BEAMER_REF}
12767 property mandatory because @samp{\againframe} needs frame to resume.
12769 When @samp{ignoreheading} is set, Org export ignores the entry's headline
12770 but not its content.  This is useful for inserting content between
12771 frames.  It is also useful for properly closing a @samp{column}
12772 environment.  @@end itemize
12774 @cindex @samp{BEAMER_ACT}, property
12775 @cindex @samp{BEAMER_OPT}, property
12776 When @samp{BEAMER_ACT} is set for a headline, Org export translates that
12777 headline as an overlay or action specification.  When enclosed in
12778 square brackets, Org export makes the overlay specification
12779 a default.  Use @samp{BEAMER_OPT} to set any options applicable to the
12780 current Beamer frame or block.  The Beamer export back-end wraps
12781 with appropriate angular or square brackets.  It also adds the
12782 @samp{fragile} option for any code that may require a verbatim block.
12784 @cindex @samp{BEAMER_COL}, property
12785 To create a column on the Beamer slide, use the @samp{BEAMER_COL}
12786 property for its headline in the Org file.  Set the value of
12787 @samp{BEAMER_COL} to a decimal number representing the fraction of the
12788 total text width.  Beamer export uses this value to set the column's
12789 width and fills the column with the contents of the Org entry.  If
12790 the Org entry has no specific environment defined, Beamer export
12791 ignores the heading.  If the Org entry has a defined environment,
12792 Beamer export uses the heading as title.  Behind the scenes, Beamer
12793 export automatically handles @LaTeX{} column separations for contiguous
12794 headlines.  To manually adjust them for any unique configurations
12795 needs, use the @samp{BEAMER_ENV} property.
12796 @end itemize
12798 @node Beamer specific syntax
12799 @subsection Beamer specific syntax
12801 Since Org's Beamer export back-end is an extension of the @LaTeX{}
12802 back-end, it recognizes other @LaTeX{} specific syntax---for example,
12803 @samp{#+LATEX:} or @samp{#+ATTR_LATEX:}.  See @ref{@LaTeX{} Export}, for details.
12805 Beamer export wraps the table of contents generated with @samp{toc:t}
12806 @samp{OPTION} keyword in a @samp{frame} environment.  Beamer export does not
12807 wrap the table of contents generated with @samp{TOC} keyword (see @ref{Table of Contents}).  Use square brackets for specifying options.
12809 @example
12810 #+TOC: headlines [currentsection]
12811 @end example
12813 Insert Beamer-specific code using the following constructs:
12815 @cindex @samp{BEAMER}, keyword
12816 @cindex @samp{BEGIN_EXPORT beamer}
12817 @example
12818 #+BEAMER: \pause
12820 #+BEGIN_EXPORT beamer
12821   Only Beamer export back-end exports this.
12822 #+END_BEAMER
12824 Text @@@@beamer:some code@@@@ within a paragraph.
12825 @end example
12827 Inline constructs, such as the last one above, are useful for adding
12828 overlay specifications to objects with @code{bold}, @code{item}, @code{link},
12829 @code{radio-target} and @code{target} types.  Enclose the value in angular
12830 brackets and place the specification at the beginning of the object as
12831 shown in this example:
12833 @example
12834 A *@@@@beamer:<2->@@@@useful* feature
12835 @end example
12837 @cindex @samp{ATTR_BEAMER}, keyword
12838 Beamer export recognizes the @samp{ATTR_BEAMER} keyword with the following
12839 attributes from Beamer configurations: @samp{:environment} for changing
12840 local Beamer environment, @samp{:overlay} for specifying Beamer overlays in
12841 angular or square brackets, and @samp{:options} for inserting optional
12842 arguments.
12844 @example
12845 #+ATTR_BEAMER: :environment nonindentlist
12846 - item 1, not indented
12847 - item 2, not indented
12848 - item 3, not indented
12849 @end example
12851 @example
12852 #+ATTR_BEAMER: :overlay <+->
12853 - item 1
12854 - item 2
12855 @end example
12857 @example
12858 #+ATTR_BEAMER: :options [Lagrange]
12859 Let $G$ be a finite group, and let $H$ be
12860 a subgroup of $G$.  Then the order of $H$ divides the order of $G$.
12861 @end example
12863 @node Editing support
12864 @subsection Editing support
12866 The @code{org-beamer-mode} is a special minor mode for faster editing of
12867 Beamer documents.
12869 @example
12870 #+STARTUP: beamer
12871 @end example
12873 @table @asis
12874 @item @kbd{C-c C-b} (@code{org-beamer-select-environment})
12875 @kindex C-c C-b
12876 @findex org-beamer-select-environment
12878 The @code{org-beamer-mode} provides this key for quicker selections in
12879 Beamer normal environments, and for selecting the @samp{BEAMER_COL}
12880 property.
12881 @end table
12883 @node A Beamer example
12884 @subsection A Beamer example
12886 Here is an example of an Org document ready for Beamer export.
12888 @example
12889 ;#+TITLE: Example Presentation
12890 ;#+AUTHOR: Carsten Dominik
12891 ;#+OPTIONS: H:2 toc:t num:t
12892 ;#+LATEX_CLASS: beamer
12893 ;#+LATEX_CLASS_OPTIONS: [presentation]
12894 ;#+BEAMER_THEME: Madrid
12895 ;#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) %8BEAMER_OPT(Opt)
12897 * This is the first structural section
12899 ** Frame 1
12900 *** Thanks to Eric Fraga                                           :B_block:
12901     :PROPERTIES:
12902     :BEAMER_COL: 0.48
12903     :BEAMER_ENV: block
12904     :END:
12905     for the first viable Beamer setup in Org
12906 *** Thanks to everyone else                                        :B_block:
12907     :PROPERTIES:
12908     :BEAMER_COL: 0.48
12909     :BEAMER_ACT: <2->
12910     :BEAMER_ENV: block
12911     :END:
12912     for contributing to the discussion
12913 **** This will be formatted as a beamer note                       :B_note:
12914      :PROPERTIES:
12915      :BEAMER_env: note
12916      :END:
12917 ** Frame 2 (where we will not use columns)
12918 *** Request
12919     Please test this stuff!
12920 @end example
12922 @node HTML Export
12923 @section HTML Export
12925 @cindex HTML export
12927 Org mode contains an HTML exporter with extensive HTML formatting
12928 compatible with XHTML 1.0 strict standard.
12930 @menu
12931 * HTML export commands::         Invoking HTML export.
12932 * HTML specific export settings:: Settings for HTML export.
12933 * HTML doctypes::                Exporting various (X)HTML flavors.
12934 * HTML preamble and postamble::  Inserting preamble and postamble.
12935 * Quoting HTML tags::            Using direct HTML in Org files.
12936 * Links in HTML export::         Inserting and formatting links.
12937 * Tables in HTML export::        How to modify the formatting of tables.
12938 * Images in HTML export::        How to insert figures into HTML output.
12939 * Math formatting in HTML export:: Beautiful math also on the web.
12940 * Text areas in HTML export::    An alternate way to show an example.
12941 * CSS support::                  Changing the appearance of the output.
12942 * JavaScript support::           Info and folding in a web browser.
12943 @end menu
12945 @node HTML export commands
12946 @subsection HTML export commands
12948 @table @asis
12949 @item @kbd{C-c C-e h h} (@code{org-html-export-to-html})
12950 @kindex C-c C-e h h
12951 @kindex C-c C-e h o
12952 @findex org-html-export-to-html
12954 Export as HTML file with a @samp{.html} extension.  For @samp{myfile.org},
12955 Org exports to @samp{myfile.html}, overwriting without warning.
12956 @{@{@{kbd@{C-c C-e h o)@}@}@} exports to HTML and opens it in a web
12957 browser.
12959 @item @kbd{C-c C-e h H} (@code{org-html-export-as-html})
12960 @kindex C-c C-e h H
12961 @findex org-html-export-as-html
12963 Exports to a temporary buffer.  Does not create a file.
12964 @end table
12966 @node HTML specific export settings
12967 @subsection HTML specific export settings
12969 HTML export has a number of keywords, similar to the general options
12970 settings described in @ref{Export Settings}.
12972 @table @asis
12973 @item @samp{DESCRIPTION}
12974 @cindex @samp{DESCRIPTION}, keyword
12975 This is the document's description, which the HTML exporter
12976 inserts it as a HTML meta tag in the HTML file.  For long
12977 descriptions, use multiple @samp{DESCRIPTION} lines.  The exporter
12978 takes care of wrapping the lines properly.
12980 @item @samp{HTML_DOCTYPE}
12981 @cindex @samp{HTML_DOCTYPE}, keyword
12982 @vindex org-html-doctype
12983 Specify the document type, for example: HTML5
12984 (@code{org-html-doctype}).
12986 @item @samp{HTML_CONTAINER}
12987 @cindex @samp{HTML_CONTAINER}, keyword
12988 @vindex org-html-container-element
12989 Specify the HTML container, such as @samp{div}, for wrapping sections
12990 and elements (@code{org-html-container-element}).
12992 @item @samp{HTML_LINK_HOME}
12993 @cindex @samp{HTML_LINK_HOME}, keyword
12994 @vindex org-html-link-home
12995 The URL for home link (@code{org-html-link-home}).
12997 @item @samp{HTML_LINK_UP}
12998 @cindex @samp{HTML_LINK_UP}, keyword
12999 @vindex org-html-link-up
13000 The URL for the up link of exported HTML pages
13001 (@code{org-html-link-up}).
13003 @item @samp{HTML_MATHJAX}
13004 @cindex @samp{HTML_MATHJAX}, keyword
13005 @vindex org-html-mathjax-options
13006 Options for MathJax (@code{org-html-mathjax-options}).  MathJax is
13007 used to typeset @LaTeX{} math in HTML documents.  See @ref{Math formatting in HTML export}, for an example.
13009 @item @samp{HTML_HEAD}
13010 @cindex @samp{HTML_HEAD}, keyword
13011 @vindex org-html-head
13012 Arbitrary lines for appending to the HTML document's head
13013 (@code{org-html-head}).
13015 @item @samp{HTML_HEAD_EXTRA}
13016 @cindex @samp{HTML_HEAD_EXTRA}, keyword
13017 @vindex org-html-head-extra
13018 More arbitrary lines for appending to the HTML document's head
13019 (@code{org-html-head-extra}).
13021 @item @samp{KEYWORDS}
13022 @cindex @samp{KEYWORDS}, keyword
13023 Keywords to describe the document's content.  HTML exporter
13024 inserts these keywords as HTML meta tags.  For long keywords, use
13025 multiple @samp{KEYWORDS} lines.
13027 @item @samp{LATEX_HEADER}
13028 @cindex @samp{LATEX_HEADER}, keyword
13029 Arbitrary lines for appending to the preamble; HTML exporter
13030 appends when transcoding @LaTeX{} fragments to images (see @ref{Math formatting in HTML export}).
13032 @item @samp{SUBTITLE}
13033 @cindex @samp{SUBTITLE}, keyword
13034 The document's subtitle.  HTML exporter formats subtitle if
13035 document type is @samp{HTML5} and the CSS has a @samp{subtitle} class.
13036 @end table
13038 Some of these keywords are explained in more detail in the following
13039 sections of the manual.
13041 @node HTML doctypes
13042 @subsection HTML doctypes
13044 Org can export to various (X)HTML flavors.
13046 @vindex org-html-doctype
13047 @vindex org-html-doctype-alist
13048 Set the @code{org-html-doctype} variable for different (X)HTML variants.
13049 Depending on the variant, the HTML exporter adjusts the syntax of HTML
13050 conversion accordingly.  Org includes the following ready-made
13051 variants:
13053 @itemize
13054 @item
13055 @code{"html4-strict"}
13056 @item
13057 @code{"html4-transitional"}
13058 @item
13059 @code{"html4-frameset"}
13060 @item
13061 @code{"xhtml-strict"}
13062 @item
13063 @code{"xhtml-transitional"}
13064 @item
13065 @code{"xhtml-frameset"}
13066 @item
13067 @code{"xhtml-11"}
13068 @item
13069 @code{"html5"}
13070 @item
13071 @code{"xhtml5"}
13072 @end itemize
13074 @noindent
13075 See the variable @code{org-html-doctype-alist} for details.  The default is
13076 @code{"xhtml-strict"}.
13078 @vindex org-html-html5-fancy
13079 @cindex @samp{HTML5}, export new elements
13080 Org's HTML exporter does not by default enable new block elements
13081 introduced with the HTML5 standard.  To enable them, set
13082 @code{org-html-html5-fancy} to non-@code{nil}.  Or use an @samp{OPTIONS} line in the
13083 file to set @samp{html5-fancy}.
13085 HTML5 documents can now have arbitrary @samp{#+BEGIN} @dots{} @samp{#+END} blocks.
13086 For example:
13088 @example
13089 #+BEGIN_aside
13090   Lorem ipsum
13091 #+END_aside
13092 @end example
13094 @noindent
13095 exports to:
13097 @example
13098 <aside>
13099   <p>Lorem ipsum</p>
13100 </aside>
13101 @end example
13103 @noindent
13104 while this:
13106 @example
13107 #+ATTR_HTML: :controls controls :width 350
13108 #+BEGIN_video
13109 #+HTML: <source src="movie.mp4" type="video/mp4">
13110 #+HTML: <source src="movie.ogg" type="video/ogg">
13111 Your browser does not support the video tag.
13112 #+END_video
13113 @end example
13115 @noindent
13116 exports to:
13118 @example
13119 <video controls="controls" width="350">
13120   <source src="movie.mp4" type="video/mp4">
13121     <source src="movie.ogg" type="video/ogg">
13122       <p>Your browser does not support the video tag.</p>
13123 </video>
13124 @end example
13126 @vindex org-html-html5-elements
13127 When special blocks do not have a corresponding HTML5 element, the
13128 HTML exporter reverts to standard translation (see
13129 @code{org-html-html5-elements}).  For example, @samp{#+BEGIN_lederhosen} exports
13130 to @code{<div class="lederhosen">}.
13132 Special blocks cannot have headlines.  For the HTML exporter to wrap
13133 the headline and its contents in @code{<section>} or @code{<article>} tags, set
13134 the @samp{HTML_CONTAINER} property for the headline.
13136 @node HTML preamble and postamble
13137 @subsection HTML preamble and postamble
13139 @vindex org-html-preamble
13140 @vindex org-html-postamble
13141 @vindex org-html-preamble-format
13142 @vindex org-html-postamble-format
13143 @vindex org-html-validation-link
13144 @vindex org-export-creator-string
13145 @vindex org-export-time-stamp-file
13147 The HTML exporter has delineations for preamble and postamble.  The
13148 default value for @code{org-html-preamble} is @code{t}, which makes the HTML
13149 exporter insert the preamble.  See the variable
13150 @code{org-html-preamble-format} for the format string.
13152 Set @code{org-html-preamble} to a string to override the default format
13153 string.  If the string is a function, the HTML exporter expects the
13154 function to return a string upon execution.  The HTML exporter inserts
13155 this string in the preamble.  The HTML exporter does not insert
13156 a preamble if @code{org-html-preamble} is set @code{nil}.
13158 The default value for @code{org-html-postamble} is @code{auto}, which makes the
13159 HTML exporter build a postamble from looking up author's name, email
13160 address, creator's name, and date.  Set @code{org-html-postamble} to @code{t} to
13161 insert the postamble in the format specified in the
13162 @code{org-html-postamble-format} variable.  The HTML exporter does not
13163 insert a postamble if @code{org-html-postamble} is set to @code{nil}.
13165 @node Quoting HTML tags
13166 @subsection Quoting HTML tags
13168 The HTML export back-end transforms @samp{<} and @samp{>} to @samp{&lt;} and @samp{&gt;}.
13170 To include raw HTML code in the Org file so the HTML export back-end
13171 can insert that HTML code in the output, use this inline syntax:
13172 @samp{@@@@html:...@@@@}.  For example:
13174 @example
13175 @@@@html:<b>@@@@bold text@@@@html:</b>@@@@
13176 @end example
13178 @cindex @samp{HTML}, keyword
13179 @cindex @samp{BEGIN_EXPORT html}
13180 For larger raw HTML code blocks, use these HTML export code blocks:
13182 @example
13183 #+HTML: Literal HTML code for export
13185 #+BEGIN_EXPORT html
13186   All lines between these markers are exported literally
13187 #+END_EXPORT
13188 @end example
13190 @node Links in HTML export
13191 @subsection Links in HTML export
13193 @cindex links, in HTML export
13194 @cindex internal links, in HTML export
13195 @cindex external links, in HTML export
13197 The HTML export back-end transforms Org's internal links (see
13198 @ref{Internal Links}) to equivalent HTML links in the output.  The back-end
13199 similarly handles Org's automatic links created by radio targets (see
13200 @ref{Radio Targets}) similarly.  For Org links to external files, the
13201 back-end transforms the links to @emph{relative} paths.
13203 @vindex org-html-link-org-files-as-html
13204 For Org links to other @samp{.org} files, the back-end automatically
13205 changes the file extension to @samp{.html} and makes file paths relative.
13206 If the @samp{.org} files have an equivalent @samp{.html} version at the same
13207 location, then the converted links should work without any further
13208 manual intervention.  However, to disable this automatic path
13209 translation, set @code{org-html-link-org-files-as-html} to @code{nil}.  When
13210 disabled, the HTML export back-end substitutes the ID-based links in
13211 the HTML output.  For more about linking files when publishing to
13212 a directory, see @ref{Publishing links}.
13214 Org files can also have special directives to the HTML export
13215 back-end.  For example, by using @samp{#+ATTR_HTML} lines to specify new
13216 format attributes to @code{<a>} or @code{<img>} tags.  This example shows
13217 changing the link's title and style:
13219 @cindex @samp{ATTR_HTML}, keyword
13220 @example
13221 #+ATTR_HTML: :title The Org mode homepage :style color:red;
13222 [[https://orgmode.org]]
13223 @end example
13225 @node Tables in HTML export
13226 @subsection Tables in HTML export
13228 @cindex tables, in HTML
13229 @vindex org-export-html-table-tag
13231 The HTML export back-end uses @code{org-html-table-default-attributes} when
13232 exporting Org tables to HTML.  By default, the exporter does not draw
13233 frames and cell borders.  To change for this for a table, use the
13234 following lines before the table in the Org file:
13236 @cindex @samp{CAPTION}, keyword
13237 @cindex @samp{ATTR_HTML}, keyword
13238 @example
13239 #+CAPTION: This is a table with lines around and between cells
13240 #+ATTR_HTML: border="2" rules="all" frame="border"
13241 @end example
13243 The HTML export back-end preserves column groupings in Org tables (see
13244 @ref{Column Groups}) when exporting to HTML.
13246 Additional options for customizing tables for HTML export.
13248 @table @asis
13249 @item @code{org-html-table-align-individual-fields}
13250 @vindex org-html-table-align-individual-fields
13251 Non-@code{nil} attaches style attributes for alignment to each table
13252 field.
13254 @item @code{org-html-table-caption-above}
13255 @vindex org-html-table-caption-above
13256 Non-@code{nil} places caption string at the beginning of the table.
13258 @item @code{org-html-table-data-tags}
13259 @vindex org-html-table-data-tags
13260 Opening and ending tags for table data fields.
13262 @item @code{org-html-table-default-attributes}
13263 @vindex org-html-table-default-attributes
13264 Default attributes and values for table tags.
13266 @item @code{org-html-table-header-tags}
13267 @vindex org-html-table-header-tags
13268 Opening and ending tags for table's header fields.
13270 @item @code{org-html-table-row-tags}
13271 @vindex org-html-table-row-tags
13272 Opening and ending tags for table rows.
13274 @item @code{org-html-table-use-header-tags-for-first-column}
13275 @vindex org-html-table-use-header-tags-for-first-column
13276 Non-@code{nil} formats column one in tables with header tags.
13277 @end table
13279 @node Images in HTML export
13280 @subsection Images in HTML export
13282 @cindex images, inline in HTML
13283 @cindex inlining images in HTML
13285 The HTML export back-end has features to convert Org image links to
13286 HTML inline images and HTML clickable image links.
13288 @vindex org-html-inline-images
13289 When the link in the Org file has no description, the HTML export
13290 back-end by default in-lines that image.  For example:
13291 @samp{[[file:myimg.jpg]]} is in-lined, while @samp{[[file:myimg.jpg][the image]]} links to the text,
13292 @samp{the image}.  For more details, see the variable
13293 @code{org-html-inline-images}.
13295 On the other hand, if the description part of the Org link is itself
13296 another link, such as @samp{file:} or @samp{http:} URL pointing to an image, the
13297 HTML export back-end in-lines this image and links to the main image.
13298 This Org syntax enables the back-end to link low-resolution thumbnail
13299 to the high-resolution version of the image, as shown in this example:
13301 @example
13302 [[file:highres.jpg][file:thumb.jpg]]
13303 @end example
13305 To change attributes of in-lined images, use @samp{#+ATTR_HTML} lines in
13306 the Org file.  This example shows realignment to right, and adds @code{alt}
13307 and @code{title} attributes in support of text viewers and modern web
13308 accessibility standards.
13310 @cindex @samp{CAPTION}, keyword
13311 @cindex @samp{ATTR_HTML}, keyword
13312 @example
13313 #+CAPTION: A black cat stalking a spider
13314 #+ATTR_HTML: :alt cat/spider image :title Action! :align right
13315 [[./img/a.jpg]]
13316 @end example
13318 @noindent
13319 The HTML export back-end copies the @samp{http} links from the Org file as
13322 @node Math formatting in HTML export
13323 @subsection Math formatting in HTML export
13325 @cindex MathJax
13326 @cindex dvipng
13327 @cindex dvisvgm
13328 @cindex ImageMagick
13330 @vindex org-html-mathjax-options~
13331 @LaTeX{} math snippets (see @ref{@LaTeX{} fragments}) can be displayed in two
13332 different ways on HTML pages.  The default is to use the @uref{http://www.mathjax.org, MathJax},
13333 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
13334 @uref{http://www.mathjax.org, MathJax}.}.  Some MathJax
13335 display options can be configured via @code{org-html-mathjax-options}, or
13336 in the buffer.  For example, with the following settings,
13338 @example
13339 #+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
13340 #+HTML_MATHJAX: cancel.js noErrors.js
13341 @end example
13343 @noindent
13344 equation labels are displayed on the left margin and equations are
13345 five em from the left margin.  In addition, it loads the two MathJax
13346 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
13347 about extensions.}.
13349 @vindex org-html-mathjax-template
13350 See the docstring of @code{org-html-mathjax-options} for all supported
13351 variables.  The MathJax template can be configure via
13352 @code{org-html-mathjax-template}.
13354 If you prefer, you can also request that @LaTeX{} fragments are processed
13355 into small images that will be inserted into the browser page.  Before
13356 the availability of MathJax, this was the default method for Org
13357 files.  This method requires that the dvipng program, dvisvgm or
13358 ImageMagick suite is available on your system.  You can still get this
13359 processing with
13361 @example
13362 #+OPTIONS: tex:dvipng
13363 @end example
13365 @example
13366 #+OPTIONS: tex:dvisvgm
13367 @end example
13369 @noindent
13372 @example
13373 #+OPTIONS: tex:imagemagick
13374 @end example
13376 @node Text areas in HTML export
13377 @subsection Text areas in HTML export
13379 @cindex text areas, in HTML
13380 Before Org mode's Babel, one popular approach to publishing code in
13381 HTML was by using @samp{:textarea}.  The advantage of this approach was
13382 that copying and pasting was built into browsers with simple
13383 JavaScript commands.  Even editing before pasting was made simple.
13385 The HTML export back-end can create such text areas.  It requires an
13386 @samp{#+ATTR_HTML} line as shown in the example below with the @samp{:textarea}
13387 option.  This must be followed by either an example or a source code
13388 block.  Other Org block types do not honor the @samp{:textarea} option.
13390 By default, the HTML export back-end creates a text area 80 characters
13391 wide and height just enough to fit the content.  Override these
13392 defaults with @samp{:width} and @samp{:height} options on the @samp{#+ATTR_HTML}
13393 line.
13395 @example
13396 #+ATTR_HTML: :textarea t :width 40
13397 #+BEGIN_EXAMPLE
13398   (defun org-xor (a b)
13399      "Exclusive or."
13400      (if a (not b) b))
13401 #+END_EXAMPLE
13402 @end example
13404 @node CSS support
13405 @subsection CSS support
13407 @cindex CSS, for HTML export
13408 @cindex HTML export, CSS
13410 @vindex org-export-html-todo-kwd-class-prefix
13411 @vindex org-export-html-tag-class-prefix
13412 You can modify the CSS style definitions for the exported file.  The
13413 HTML exporter assigns the following special CSS classes@footnote{If the classes on TODO keywords and tags lead to conflicts,
13414 use the variables @code{org-html-todo-kwd-class-prefix} and
13415 @code{org-html-tag-class-prefix} to make them unique.} to
13416 appropriate parts of the document---your style specifications may
13417 change these, in addition to any of the standard classes like for
13418 headlines, tables, etc.
13420 @multitable {aaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
13421 @item @code{p.author}
13422 @tab author information, including email
13423 @item @code{p.date}
13424 @tab publishing date
13425 @item @code{p.creator}
13426 @tab creator info, about org mode version
13427 @item @code{.title}
13428 @tab document title
13429 @item @code{.subtitle}
13430 @tab document subtitle
13431 @item @code{.todo}
13432 @tab TODO keywords, all not-done states
13433 @item @code{.done}
13434 @tab the DONE keywords, all states that count as done
13435 @item @code{.WAITING}
13436 @tab each TODO keyword also uses a class named after itself
13437 @item @code{.timestamp}
13438 @tab timestamp
13439 @item @code{.timestamp-kwd}
13440 @tab keyword associated with a timestamp, like @samp{SCHEDULED}
13441 @item @code{.timestamp-wrapper}
13442 @tab span around keyword plus timestamp
13443 @item @code{.tag}
13444 @tab tag in a headline
13445 @item @code{._HOME}
13446 @tab each tag uses itself as a class, ``@@'' replaced by ``_''
13447 @item @code{.target}
13448 @tab target for links
13449 @item @code{.linenr}
13450 @tab the line number in a code example
13451 @item @code{.code-highlighted}
13452 @tab for highlighting referenced code lines
13453 @item @code{div.outline-N}
13454 @tab div for outline level N (headline plus text)
13455 @item @code{div.outline-text-N}
13456 @tab extra div for text at outline level N
13457 @item @code{.section-number-N}
13458 @tab section number in headlines, different for each level
13459 @item @code{.figure-number}
13460 @tab label like ``Figure 1:''
13461 @item @code{.table-number}
13462 @tab label like ``Table 1:''
13463 @item @code{.listing-number}
13464 @tab label like ``Listing 1:''
13465 @item @code{div.figure}
13466 @tab how to format an in-lined image
13467 @item @code{pre.src}
13468 @tab formatted source code
13469 @item @code{pre.example}
13470 @tab normal example
13471 @item @code{p.verse}
13472 @tab verse paragraph
13473 @item @code{div.footnotes}
13474 @tab footnote section headline
13475 @item @code{p.footnote}
13476 @tab footnote definition paragraph, containing a footnote
13477 @item @code{.footref}
13478 @tab a footnote reference number (always a <sup>)
13479 @item @code{.footnum}
13480 @tab footnote number in footnote definition (always <sup>)
13481 @item @code{.org-svg}
13482 @tab default class for a linked @samp{.svg} image
13483 @end multitable
13485 @vindex org-html-style-default
13486 @vindex org-html-head
13487 @vindex org-html-head-extra
13488 @cindex @samp{HTML_INCLUDE_STYLE}, keyword
13489 The HTML export back-end includes a compact default style in each
13490 exported HTML file.  To override the default style with another style,
13491 use these keywords in the Org file.  They will replace the global
13492 defaults the HTML exporter uses.
13494 @cindex @samp{HTML_HEAD}, keyword
13495 @cindex @samp{HTML_HEAD_EXTRA}, keyword
13496 @example
13497 #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
13498 #+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
13499 @end example
13501 @vindex org-html-head-include-default-style
13502 To just turn off the default style, customize
13503 @code{org-html-head-include-default-style} variable, or use this option
13504 line in the Org file.
13506 @cindex @samp{html-style}, @samp{OPTIONS} item
13507 @example
13508 #+OPTIONS: html-style:nil
13509 @end example
13511 For longer style definitions, either use several @samp{HTML_HEAD} and
13512 @samp{HTML_HEAD_EXTRA} keywords, or use @code{<style> ... </style>} blocks
13513 around them.  Both of these approaches can avoid referring to an
13514 external file.
13516 @cindex @samp{HTML_CONTAINER_CLASS}, property
13517 In order to add styles to a sub-tree, use the @samp{HTML_CONTAINER_CLASS}
13518 property to assign a class to the tree.  In order to specify CSS
13519 styles for a particular headline, you can use the id specified in
13520 a @samp{CUSTOM_ID} property.
13522 Never change the @code{org-html-style-default} constant.  Instead use other
13523 simpler ways of customizing as described above.
13525 @node JavaScript support
13526 @subsection JavaScript supported display of web pages
13528 Sebastian Rose has written a JavaScript program especially designed to
13529 enhance the web viewing experience of HTML files created with Org.
13530 This program enhances large files in two different ways of viewing.
13531 One is an @emph{Info}-like mode where each section is displayed separately
13532 and navigation can be done with the @kbd{n} and @kbd{p}
13533 keys, and some other keys as well, press @kbd{?} for an overview
13534 of the available keys.  The second one has a @emph{folding} view, much like
13535 Org provides inside Emacs.  The script is available at
13536 @uref{https://orgmode.org/org-info.js} and the documentation at
13537 @uref{https://orgmode.org/worg/code/org-info-js/}.  The script is hosted on
13538 @uref{https://orgmode.org}, but for reliability, prefer installing it on your
13539 own web server.
13541 To use this program, just add this line to the Org file:
13543 @cindex @samp{INFOJS_OPT}, keyword
13544 @example
13545 #+INFOJS_OPT: view:info toc:nil
13546 @end example
13548 @noindent
13549 The HTML header now has the code needed to automatically invoke the
13550 script.  For setting options, use the syntax from the above line for
13551 options described below:
13553 @table @asis
13554 @item @samp{path:}
13555 The path to the script.  The default is to grab the script from
13556 @uref{https://orgmode.org/org-info.js}, but you might want to have
13557 a local copy and use a path like @samp{../scripts/org-info.js}.
13559 @item @samp{view:}
13560 Initial view when the website is first shown.  Possible values are:
13562 @multitable {aaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
13563 @item @samp{info}
13564 @tab Info-like interface with one section per page
13565 @item @samp{overview}
13566 @tab Folding interface, initially showing only top-level
13567 @item @samp{content}
13568 @tab Folding interface, starting with all headlines visible
13569 @item @samp{showall}
13570 @tab Folding interface, all headlines and text visible
13571 @end multitable
13573 @item @samp{sdepth:}
13574 Maximum headline level still considered as an independent section
13575 for info and folding modes.  The default is taken from
13576 @code{org-export-headline-levels}, i.e., the @samp{H} switch in @samp{OPTIONS}.
13577 If this is smaller than in @code{org-export-headline-levels}, each
13578 info/folding section can still contain child headlines.
13580 @item @samp{toc:}
13581 Should the table of contents @emph{initially} be visible?  Even when
13582 @samp{nil}, you can always get to the ``toc'' with @kbd{i}.
13584 @item @samp{tdepth:}
13585 The depth of the table of contents.  The defaults are taken from
13586 the variables @code{org-export-headline-levels} and
13587 @code{org-export-with-toc}.
13589 @item @samp{ftoc:}
13590 Does the CSS of the page specify a fixed position for the ``toc''?
13591 If yes, the toc is displayed as a section.
13593 @item @samp{ltoc:}
13594 Should there be short contents (children) in each section?  Make
13595 this @samp{above} if the section should be above initial text.
13597 @item @samp{mouse:}
13598 Headings are highlighted when the mouse is over them.  Should be
13599 @samp{underline} (default) or a background color like @samp{#cccccc}.
13601 @item @samp{buttons:}
13602 Should view-toggle buttons be everywhere?  When @samp{nil} (the
13603 default), only one such button is present.
13604 @end table
13606 @noindent
13607 @vindex org-infojs-options
13608 @vindex org-export-html-use-infojs
13609 You can choose default values for these options by customizing the
13610 variable @code{org-infojs-options}.  If you always want to apply the script
13611 to your pages, configure the variable @code{org-export-html-use-infojs}.
13613 @node @LaTeX{} Export
13614 @section @LaTeX{} Export
13616 @cindex @LaTeX{} export
13617 @cindex PDF export
13619 The @LaTeX{} export back-end can handle complex documents, incorporate
13620 standard or custom @LaTeX{} document classes, generate documents using
13621 alternate @LaTeX{} engines, and produce fully linked PDF files with
13622 indexes, bibliographies, and tables of contents, destined for
13623 interactive online viewing or high-quality print publication.
13625 While the details are covered in-depth in this section, here are some
13626 quick references to variables for the impatient: for engines, see
13627 @code{org-latex-compiler}; for build sequences, see
13628 @code{org-latex-pdf-process}; for packages, see
13629 @code{org-latex-default-packages-alist} and @code{org-latex-packages-alist}.
13631 An important note about the @LaTeX{} export back-end: it is sensitive to
13632 blank lines in the Org document.  That's because @LaTeX{} itself depends
13633 on blank lines to tell apart syntactical elements, such as paragraphs.
13635 @menu
13636 * @LaTeX{}/PDF export commands:: For producing @LaTeX{} and PDF documents.
13637 * @LaTeX{} specific export settings:: Unique to this @LaTeX{} back-end.
13638 * @LaTeX{} header and sectioning:: Setting up the export file structure.
13639 * Quoting @LaTeX{} code::        Incorporating literal @LaTeX{} code.
13640 * Tables in @LaTeX{} export::    Options for exporting tables to @LaTeX{}.
13641 * Images in @LaTeX{} export::    How to insert figures into @LaTeX{} output.
13642 * Plain lists in @LaTeX{} export:: Attributes specific to lists.
13643 * Source blocks in @LaTeX{} export:: Attributes specific to source code blocks.
13644 * Example blocks in @LaTeX{} export:: Attributes specific to example blocks.
13645 * Special blocks in @LaTeX{} export:: Attributes specific to special blocks.
13646 * Horizontal rules in @LaTeX{} export:: Attributes specific to horizontal rules.
13647 @end menu
13649 @node @LaTeX{}/PDF export commands
13650 @subsection @LaTeX{}/PDF export commands
13652 @table @asis
13653 @item @kbd{C-c C-e l l} (@code{org-latex-export-to-latex})
13654 @kindex C-c C-e l l
13655 @findex org-latex-export-to-latex~
13656 Export to a @LaTeX{} file with a @samp{.tex} extension.  For
13657 @samp{myfile.org}, Org exports to @samp{myfile.tex}, overwriting without
13658 warning.
13660 @item @kbd{C-c C-e l L} (@code{org-latex-export-as-latex})
13661 @kindex C-c C-e l L
13662 @findex org-latex-export-as-latex
13663 Export to a temporary buffer.  Do not create a file.
13665 @item @kbd{C-c C-e l p} (@code{org-latex-export-to-pdf})
13666 @kindex C-c C-e l p
13667 @findex org-latex-export-to-pdf
13668 Export as @LaTeX{} file and convert it to PDF file.
13670 @item @kbd{C-c C-e l o}
13671 @kindex C-c C-e l o
13672 Export as @LaTeX{} file and convert it to PDF, then open the PDF
13673 using the default viewer.
13675 @item @kbd{M-x org-export-region-as-latex}
13676 Convert the region to @LaTeX{} under the assumption that it was in Org
13677 mode syntax before.  This is a global command that can be invoked in
13678 any buffer.
13679 @end table
13681 @vindex org-latex-compiler
13682 @vindex org-latex-bibtex-compiler
13683 @vindex org-latex-default-packages-alist
13684 @cindex pdflatex
13685 @cindex xelatex
13686 @cindex lualatex
13687 @cindex @samp{LATEX_COMPILER}, keyword
13688 The @LaTeX{} export back-end can use any of these @LaTeX{} engines:
13689 @samp{pdflatex}, @samp{xelatex}, and @samp{lualatex}.  These engines compile @LaTeX{}
13690 files with different compilers, packages, and output options.  The
13691 @LaTeX{} export back-end finds the compiler version to use from
13692 @code{org-latex-compiler} variable or the @samp{#+LATEX_COMPILER} keyword in the
13693 Org file.  See the docstring for the
13694 @code{org-latex-default-packages-alist} for loading packages with certain
13695 compilers.  Also see @code{org-latex-bibtex-compiler} to set the
13696 bibliography compiler@footnote{This does not allow setting different bibliography compilers
13697 for different files.  However, ``smart'' @LaTeX{} compilation systems, such
13698 as latexmk, can select the correct bibliography compiler.}.
13700 @node @LaTeX{} specific export settings
13701 @subsection @LaTeX{} specific export settings
13703 The @LaTeX{} export back-end has several additional keywords for
13704 customizing @LaTeX{} output.  Setting these keywords works similar to the
13705 general options (see @ref{Export Settings}).
13707 @table @asis
13708 @item @samp{DESCRIPTION}
13709 @cindex @samp{DESCRIPTION}, keyword
13710 @vindex org-latex-hyperref-template
13711 @vindex org-latex-title-command
13712 The document's description.  The description along with author
13713 name, keywords, and related file metadata are inserted in the
13714 output file by the hyperref package.  See
13715 @code{org-latex-hyperref-template} for customizing metadata items.
13716 See @code{org-latex-title-command} for typesetting description into
13717 the document's front matter.  Use multiple @samp{DESCRIPTION} keywords
13718 for long descriptions.
13720 @item @samp{LATEX_CLASS}
13721 @cindex @samp{LATEX_CLASS}, keyword
13722 @vindex org-latex-default-class
13723 @vindex org-latex-classes
13724 This is @LaTeX{} document class, such as @emph{article}, @emph{report},
13725 @emph{book}, and so on, which contain predefined preamble and headline
13726 level mapping that the @LaTeX{} export back-end needs.  The back-end
13727 reads the default class name from the @code{org-latex-default-class}
13728 variable.  Org has @emph{article} as the default class.  A valid
13729 default class must be an element of @code{org-latex-classes}.
13731 @item @samp{LATEX_CLASS_OPTIONS}
13732 @cindex @samp{LATEX_CLASS_OPTIONS}, keyword
13733 Options the @LaTeX{} export back-end uses when calling the @LaTeX{}
13734 document class.
13736 @item @samp{LATEX_COMPILER}
13737 @cindex @samp{LATEX_COMPILER}, keyword
13738 @vindex org-latex-compiler
13739 The compiler, such as @samp{pdflatex}, @samp{xelatex}, @samp{lualatex}, for
13740 producing the PDF.  See @code{org-latex-compiler}.
13742 @item @samp{LATEX_HEADER}
13743 @itemx @samp{LATEX_HEADER_EXTRA}
13744 @cindex @samp{LATEX_HEADER}, keyword
13745 @cindex @samp{LATEX_HEADER_EXTRA}, keyword
13746 @vindex org-latex-classes
13747 Arbitrary lines to add to the document's preamble, before the
13748 hyperref settings.  See @code{org-latex-classes} for adjusting the
13749 structure and order of the @LaTeX{} headers.
13751 @item @samp{KEYWORDS}
13752 @cindex @samp{KEYWORDS}, keyword
13753 @vindex org-latex-hyperref-template
13754 @vindex org-latex-title-command
13755 The keywords for the document.  The description along with author
13756 name, keywords, and related file metadata are inserted in the
13757 output file by the hyperref package.  See
13758 @code{org-latex-hyperref-template} for customizing metadata items.
13759 See @code{org-latex-title-command} for typesetting description into
13760 the document's front matter.  Use multiple @samp{KEYWORDS} lines if
13761 necessary.
13763 @item @samp{SUBTITLE}
13764 @cindex @samp{SUBTITLE}, keyword
13765 @vindex org-latex-subtitle-separate
13766 @vindex org-latex-subtitle-format
13767 The document's subtitle.  It is typeset as per
13768 @code{org-latex-subtitle-format}.  If @code{org-latex-subtitle-separate} is
13769 non-@code{nil}, it is typed as part of the @code{\title} macro.  See
13770 @code{org-latex-hyperref-template} for customizing metadata items.
13771 See @code{org-latex-title-command} for typesetting description
13772 into the document's front matter.
13773 @end table
13775 The following sections have further details.
13777 @node @LaTeX{} header and sectioning
13778 @subsection @LaTeX{} header and sectioning structure
13780 @cindex @LaTeX{} class
13781 @cindex @LaTeX{} sectioning structure
13782 @cindex @LaTeX{} header
13783 @cindex header, for @LaTeX{} files
13784 @cindex sectioning structure, for @LaTeX{} export
13786 The @LaTeX{} export back-end converts the first three of Org's outline
13787 levels into @LaTeX{} headlines.  The remaining Org levels are exported as
13788 lists.  To change this globally for the cut-off point between levels
13789 and lists, (see @ref{Export Settings}).
13791 By default, the @LaTeX{} export back-end uses the @emph{article} class.
13793 @vindex org-latex-default-class
13794 @vindex org-latex-classes
13795 @vindex org-latex-default-packages-alist
13796 @vindex org-latex-packages-alist
13797 To change the default class globally, edit @code{org-latex-default-class}.
13798 To change the default class locally in an Org file, add option lines
13799 @samp{#+LATEX_CLASS: myclass}.  To change the default class for just a part
13800 of the Org file, set a sub-tree property, @samp{EXPORT_LATEX_CLASS}.  The
13801 class name entered here must be valid member of @code{org-latex-classes}.
13802 This variable defines a header template for each class into which the
13803 exporter splices the values of @code{org-latex-default-packages-alist} and
13804 @code{org-latex-packages-alist}.  Use the same three variables to define
13805 custom sectioning or custom classes.
13807 @cindex @samp{LATEX_CLASS}, keyword
13808 @cindex @samp{LATEX_CLASS_OPTIONS}, keyword
13809 @cindex @samp{EXPORT_LATEX_CLASS}, property
13810 @cindex @samp{EXPORT_LATEX_CLASS_OPTIONS}, property
13811 The @LaTeX{} export back-end sends the @samp{LATEX_CLASS_OPTIONS} keyword and
13812 @samp{EXPORT_LATEX_CLASS_OPTIONS} property as options to the @LaTeX{}
13813 @code{\documentclass} macro.  The options and the syntax for specifying
13814 them, including enclosing them in square brackets, follow @LaTeX{}
13815 conventions.
13817 @example
13818 #+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside,twocolumn]
13819 @end example
13821 @cindex @samp{LATEX_HEADER}, keyword
13822 @cindex @samp{LATEX_HEADER_EXTRA}, keyword
13823 The @LaTeX{} export back-end appends values from @samp{LATEX_HEADER} and
13824 @samp{LATEX_HEADER_EXTRA} keywords to the @LaTeX{} header.  The docstring for
13825 @code{org-latex-classes} explains in more detail.  Also note that @LaTeX{}
13826 export back-end does not append @samp{LATEX_HEADER_EXTRA} to the header
13827 when previewing @LaTeX{} snippets (see @ref{Previewing @LaTeX{} fragments}).
13829 A sample Org file with the above headers:
13831 @example
13832 #+LATEX_CLASS: article
13833 #+LATEX_CLASS_OPTIONS: [a4paper]
13834 #+LATEX_HEADER: \usepackage@{xyz@}
13836 * Headline 1
13837   some text
13838 * Headline 2
13839   some more text
13840 @end example
13842 @node Quoting @LaTeX{} code
13843 @subsection Quoting @LaTeX{} code
13845 The @LaTeX{} export back-end can insert any arbitrary @LaTeX{} code, see
13846 @ref{Embedded @LaTeX{}}.  There are three ways to embed such code in the Org
13847 file and they all use different quoting syntax.
13849 @cindex inline, in @LaTeX{} export
13850 Inserting in-line quoted with @@ symbols:
13852 @example
13853 Code embedded in-line @@@@latex:any arbitrary LaTeX code@@@@ in a paragraph.
13854 @end example
13856 @cindex @samp{LATEX}, keyword
13857 Inserting as one or more keyword lines in the Org file:
13859 @example
13860 #+LATEX: any arbitrary LaTeX code
13861 @end example
13863 @cindex @samp{BEGIN_EXPORT latex}
13864 Inserting as an export block in the Org file, where the back-end
13865 exports any code between begin and end markers:
13867 @example
13868 #+BEGIN_EXPORT latex
13869   any arbitrary LaTeX code
13870 #+END_EXPORT
13871 @end example
13873 @node Tables in @LaTeX{} export
13874 @subsection Tables in @LaTeX{} export
13876 @cindex tables, in @LaTeX{} export
13878 The @LaTeX{} export back-end can pass several @LaTeX{} attributes for table
13879 contents and layout.  Besides specifying label and caption (see
13880 @ref{Images and Tables}), the other valid @LaTeX{} attributes include:
13882 @table @asis
13883 @item @samp{:mode}
13884 @vindex org-latex-default-table-mode
13885 The @LaTeX{} export back-end wraps the table differently depending
13886 on the mode for accurate rendering of math symbols.  Mode is
13887 either @samp{table}, @samp{math}, @samp{inline-math} or @samp{verbatim}.
13889 For @samp{math} or @samp{inline-math} mode, @LaTeX{} export back-end wraps the
13890 table in a math environment, but every cell in it is exported
13891 as-is.  The @LaTeX{} export back-end determines the default mode
13892 from @code{org-latex-default-table-mode}.  The @LaTeX{} export back-end
13893 merges contiguous tables in the same mode into a single
13894 environment.
13896 @item @samp{:environment}
13897 @vindex org-latex-default-table-environment
13898 Set the default @LaTeX{} table environment for the @LaTeX{} export
13899 back-end to use when exporting Org tables.  Common @LaTeX{} table
13900 environments are provided by these packages: tabularx, longtable,
13901 array, tabu, and bmatrix.  For packages, such as tabularx and
13902 tabu, or any newer replacements, include them in the
13903 @code{org-latex-packages-alist} variable so the @LaTeX{} export back-end
13904 can insert the appropriate load package headers in the converted
13905 @LaTeX{} file.  Look in the docstring for the
13906 @code{org-latex-packages-alist} variable for configuring these
13907 packages for @LaTeX{} snippet previews, if any.
13909 @item @samp{:caption}
13910 Use @samp{CAPTION} keyword to set a simple caption for a table (see
13911 @ref{Images and Tables}).  For custom captions, use @samp{:caption}
13912 attribute, which accepts raw @LaTeX{} code.  @samp{:caption} value
13913 overrides @samp{CAPTION} value.
13915 @item @samp{:float}
13916 @itemx @samp{:placement}
13917 The table environments by default are not floats in @LaTeX{}.  To
13918 make them floating objects use @samp{:float} with one of the following
13919 options: @samp{sideways}, @samp{multicolumn}, @samp{t}, and @samp{nil}.
13921 @LaTeX{} floats can also have additional layout @samp{:placement}
13922 attributes.  These are the usual @samp{[h t b p ! H]} permissions
13923 specified in square brackets.  Note that for @samp{:float sideways}
13924 tables, the @LaTeX{} export back-end ignores @samp{:placement}
13925 attributes.
13927 @item @samp{:align}
13928 @itemx @samp{:font}
13929 @itemx @samp{:width}
13930 The @LaTeX{} export back-end uses these attributes for regular
13931 tables to set their alignments, fonts, and widths.
13933 @item @samp{:spread}
13934 When @samp{:spread} is non-@code{nil}, the @LaTeX{} export back-end spreads or
13935 shrinks the table by the @samp{:width} for tabu and longtabu
13936 environments.  @samp{:spread} has no effect if @samp{:width} is not set.
13938 @item @samp{:booktabs}
13939 @itemx @samp{:center}
13940 @itemx @samp{:rmlines}
13941 @vindex org-latex-tables-booktabs
13942 @vindex org-latex-tables-centered
13943 All three commands are toggles.  @samp{:booktabs} brings in modern
13944 typesetting enhancements to regular tables.  The booktabs package
13945 has to be loaded through @code{org-latex-packages-alist}.  @samp{:center}
13946 is for centering the table.  @samp{:rmlines} removes all but the very
13947 first horizontal line made of ASCII characters from ``table.el''
13948 tables only.
13950 @item @samp{:math-prefix}
13951 @itemx @samp{:math-suffix}
13952 @itemx @samp{:math-arguments}
13953 The @LaTeX{} export back-end inserts @samp{:math-prefix} string value in
13954 a math environment before the table.  The @LaTeX{} export back-end
13955 inserts @samp{:math-suffix} string value in a math environment after
13956 the table.  The @LaTeX{} export back-end inserts @samp{:math-arguments}
13957 string value between the macro name and the table's contents.
13958 @samp{:math-arguments} comes in use for matrix macros that require
13959 more than one argument, such as @samp{qbordermatrix}.
13960 @end table
13962 @LaTeX{} table attributes help formatting tables for a wide range of
13963 situations, such as matrix product or spanning multiple pages:
13965 @example
13966 #+ATTR_LATEX: :environment longtable :align l|lp@{3cm@}r|l
13967 | ... | ... |
13968 | ... | ... |
13970 #+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
13971 | a | b |
13972 | c | d |
13973 #+ATTR_LATEX: :mode math :environment bmatrix
13974 | 1 | 2 |
13975 | 3 | 4 |
13976 @end example
13978 Set the caption with the @LaTeX{} command
13979 @samp{\bicaption@{HeadingA@}@{HeadingB@}}:
13981 @example
13982 #+ATTR_LATEX: :caption \bicaption@{HeadingA@}@{HeadingB@}
13983 | ... | ... |
13984 | ... | ... |
13985 @end example
13987 @node Images in @LaTeX{} export
13988 @subsection Images in @LaTeX{} export
13990 @cindex images, inline in LaTeX
13991 @cindex inlining images in LaTeX
13992 @cindex @samp{ATTR_LATEX}, keyword
13994 The @LaTeX{} export back-end processes image links in Org files that do
13995 not have descriptions, such as these links @samp{[[file:img.jpg]]} or
13996 @samp{[[./img.jpg]]}, as direct image insertions in the final PDF output.  In
13997 the PDF, they are no longer links but actual images embedded on the
13998 page.  The @LaTeX{} export back-end uses @samp{\includegraphics} macro to
13999 insert the image.  But for TikZ (@uref{http://sourceforge.net/projects/pgf/})
14000 images, the back-end uses an @code{\input} macro wrapped within
14001 a @code{tikzpicture} environment.
14003 For specifying image @samp{:width}, @samp{:height}, and other @samp{:options}, use
14004 this syntax:
14006 @example
14007 #+ATTR_LATEX: :width 5cm :options angle=90
14008 [[./img/sed-hr4049.pdf]]
14009 @end example
14011 For custom commands for captions, use the @samp{:caption} attribute.  It
14012 overrides the default @samp{#+CAPTION} value:
14014 @example
14015 #+ATTR_LATEX: :caption \bicaption@{HeadingA@}@{HeadingB@}
14016 [[./img/sed-hr4049.pdf]]
14017 @end example
14019 When captions follow the method as described in @ref{Images and Tables},
14020 the @LaTeX{} export back-end wraps the picture in a floating @samp{figure}
14021 environment.  To float an image without specifying a caption, set the
14022 @samp{:float} attribute to one of the following:
14024 @table @asis
14025 @item @samp{t}
14026 For a standard @samp{figure} environment; used by default whenever an
14027 image has a caption.
14029 @item @samp{multicolumn}
14030 To span the image across multiple columns of a page; the back-end
14031 wraps the image in a @samp{figure*} environment.
14033 @item @samp{wrap}
14034 For text to flow around the image on the right; the figure
14035 occupies the left half of the page.
14037 @item @samp{sideways}
14038 For a new page with the image sideways, rotated ninety degrees,
14039 in a @samp{sidewaysfigure} environment; overrides @samp{:placement}
14040 setting.
14042 @item @samp{nil}
14043 To avoid a @samp{:float} even if using a caption.
14044 @end table
14046 @noindent
14047 Use the @samp{placement} attribute to modify a floating environment's
14048 placement.
14050 @example
14051 #+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement @{r@}@{0.4\textwidth@}
14052 [[./img/hst.png]]
14053 @end example
14055 @vindex org-latex-images-centered
14056 @cindex center image in LaTeX export
14057 @cindex image, centering in LaTeX export
14058 The @LaTeX{} export back-end centers all images by default.  Setting
14059 @samp{:center} to @samp{nil} disables centering.  To disable centering globally,
14060 set @code{org-latex-images-centered} to @samp{t}.
14062 Set the @samp{:comment-include} attribute to non-@code{nil} value for the @LaTeX{}
14063 export back-end to comment out the @samp{\includegraphics} macro.
14065 @node Plain lists in @LaTeX{} export
14066 @subsection Plain lists in @LaTeX{} export
14068 @cindex plain lists, in @LaTeX{} export
14069 @cindex @samp{ATTR_LATEX}, keyword
14070 The @LaTeX{} export back-end accepts the @samp{environment} and @samp{options}
14071 attributes for plain lists.  Both attributes work together for
14072 customizing lists, as shown in the examples:
14074 @example
14075 #+LATEX_HEADER: \usepackage[inline]@{enumitem@}
14076 Some ways to say "Hello":
14077 #+ATTR_LATEX: :environment itemize*
14078 #+ATTR_LATEX: :options [label=@{@}, itemjoin=@{,@}, itemjoin*=@{, and@}]
14079 - Hola
14080 - Bonjour
14081 - Guten Tag.
14082 @end example
14084 Since @LaTeX{} supports only four levels of nesting for lists, use an
14085 external package, such as @samp{enumitem} in @LaTeX{}, for levels deeper than
14086 four:
14088 @example
14089 #+LATEX_HEADER: \usepackage@{enumitem@}
14090 #+LATEX_HEADER: \renewlist@{itemize@}@{itemize@}@{9@}
14091 #+LATEX_HEADER: \setlist[itemize]@{label=$\circ$@}
14092 - One
14093   - Two
14094     - Three
14095       - Four
14096         - Five
14097 @end example
14099 @node Source blocks in @LaTeX{} export
14100 @subsection Source blocks in @LaTeX{} export
14102 @cindex source blocks, in @LaTeX{} export
14103 @cindex @samp{ATTR_LATEX}, keyword
14105 The @LaTeX{} export back-end can make source code blocks into floating
14106 objects through the attributes @samp{:float} and @samp{:options}.  For @samp{:float}:
14108 @table @asis
14109 @item @samp{t}
14110 Makes a source block float; by default floats any source block
14111 with a caption.
14113 @item @samp{multicolumn}
14114 Spans the source block across multiple columns of a page.
14116 @item @samp{nil}
14117 Avoids a @samp{:float} even if using a caption; useful for source code
14118 blocks that may not fit on a page.
14119 @end table
14121 @example
14122 #+ATTR_LATEX: :float nil
14123 #+BEGIN_SRC emacs-lisp
14124   Lisp code that may not fit in a single page.
14125 #+END_SRC
14126 @end example
14128 @vindex org-latex-listings-options
14129 @vindex org-latex-minted-options
14130 The @LaTeX{} export back-end passes string values in @samp{:options} to @LaTeX{}
14131 packages for customization of that specific source block.  In the
14132 example below, the @samp{:options} are set for Minted.  Minted is a source
14133 code highlighting @LaTeX{} package with many configurable options.
14135 @example
14136 #+ATTR_LATEX: :options commentstyle=\bfseries
14137 #+BEGIN_SRC emacs-lisp
14138   (defun Fib (n)
14139     (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
14140 #+END_SRC
14141 @end example
14143 To apply similar configuration options for all source blocks in
14144 a file, use the @code{org-latex-listings-options} and
14145 @code{org-latex-minted-options} variables.
14147 @node Example blocks in @LaTeX{} export
14148 @subsection Example blocks in @LaTeX{} export
14150 @cindex example blocks, in @LaTeX{} export
14151 @cindex verbatim blocks, in @LaTeX{} export
14152 @cindex @samp{ATTR_LATEX}, keyword
14154 The @LaTeX{} export back-end wraps the contents of example blocks in
14155 a @samp{verbatim} environment.  To change this behavior to use another
14156 environment globally, specify an appropriate export filter (see
14157 @ref{Advanced Configuration}).  To change this behavior to use another
14158 environment for each block, use the @samp{:environment} parameter to
14159 specify a custom environment.
14161 @example
14162 #+ATTR_LATEX: :environment myverbatim
14163 #+BEGIN_EXAMPLE
14164   This sentence is false.
14165 #+END_EXAMPLE
14166 @end example
14168 @node Special blocks in @LaTeX{} export
14169 @subsection Special blocks in @LaTeX{} export
14171 @cindex special blocks, in @LaTeX{} export
14172 @cindex abstract, in @LaTeX{} export
14173 @cindex proof, in @LaTeX{} export
14174 @cindex @samp{ATTR_LATEX}, keyword
14176 For other special blocks in the Org file, the @LaTeX{} export back-end
14177 makes a special environment of the same name.  The back-end also takes
14178 @samp{:options}, if any, and appends as-is to that environment's opening
14179 string.  For example:
14181 @example
14182 #+BEGIN_abstract
14183   We demonstrate how to solve the Syracuse problem.
14184 #+END_abstract
14186 #+ATTR_LATEX: :options [Proof of important theorem]
14187 #+BEGIN_proof
14188   ...
14189   Therefore, any even number greater than 2 is the sum of two primes.
14190 #+END_proof
14191 @end example
14193 @noindent
14194 exports to
14196 @example
14197 \begin@{abstract@}
14198   We demonstrate how to solve the Syracuse problem.
14199 \end@{abstract@}
14201 \begin@{proof@}[Proof of important theorem]
14202   ...
14203   Therefore, any even number greater than 2 is the sum of two primes.
14204 \end@{proof@}
14205 @end example
14207 If you need to insert a specific caption command, use @samp{:caption}
14208 attribute.  It overrides standard @samp{CAPTION} value, if any.  For
14209 example:
14211 @example
14212 #+ATTR_LATEX: :caption \MyCaption@{HeadingA@}
14213 #+BEGIN_proof
14214   ...
14215 #+END_proof
14216 @end example
14218 @node Horizontal rules in @LaTeX{} export
14219 @subsection Horizontal rules in @LaTeX{} export
14221 @cindex horizontal rules, in @LaTeX{} export
14222 @cindex @samp{ATTR_LATEX}, keyword
14224 The @LaTeX{} export back-end converts horizontal rules by the specified
14225 @samp{:width} and @samp{:thickness} attributes.  For example:
14227 @example
14228 #+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt
14229 -----
14230 @end example
14232 @node Markdown Export
14233 @section Markdown Export
14235 @cindex Markdown export
14237 The Markdown export back-end, ``md'', converts an Org file to Markdown
14238 format, as defined at @uref{http://daringfireball.net/projects/markdown/}.
14240 Since it is built on top of the HTML back-end (see @ref{HTML Export}), it
14241 converts every Org construct not defined in Markdown syntax, such as
14242 tables, to HTML.
14244 @anchor{Markdown export commands}
14245 @subheading Markdown export commands
14247 @table @asis
14248 @item @kbd{C-c C-e m m} (@code{org-md-export-to-markdown})
14249 @kindex C-c C-c m m
14250 @findex org-md-export-to-markdown
14251 Export to a text file with Markdown syntax.  For @samp{myfile.org},
14252 Org exports to @samp{myfile.md}, overwritten without warning.
14254 @item @kbd{C-c C-e m M} (@code{org-md-export-as-markdown})
14255 @kindex C-c C-c m M
14256 @findex org-md-export-as-markdown
14257 Export to a temporary buffer.  Does not create a file.
14259 @item @kbd{C-c C-e m o}
14260 @kindex C-c C-e m o
14261 Export as a text file with Markdown syntax, then open it.
14262 @end table
14264 @anchor{Header and sectioning structure (1)}
14265 @subheading Header and sectioning structure
14267 @vindex org-md-headline-style
14268 Based on @code{org-md-headline-style}, Markdown export can generate
14269 headlines of both @emph{atx} and @emph{setext} types.  @emph{atx} limits headline
14270 levels to two whereas @emph{setext} limits headline levels to six.  Beyond
14271 these limits, the export back-end converts headlines to lists.  To set
14272 a limit to a level before the absolute limit (see @ref{Export Settings}).
14274 @node OpenDocument Text Export
14275 @section OpenDocument Text Export
14277 @cindex ODT
14278 @cindex OpenDocument
14279 @cindex export, OpenDocument
14280 @cindex LibreOffice
14282 The ODT export back-end handles creating of OpenDocument Text (ODT)
14283 format.  Documents created by this exporter use the
14284 @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
14285 (OpenDocument) Version 1.2}.} and are compatible
14286 with LibreOffice 3.4.
14288 @menu
14289 * Pre-requisites for ODT export:: Required packages.
14290 * ODT export commands::          Invoking export.
14291 * ODT specific export settings:: Configuration options.
14292 * Extending ODT export::         Producing DOC, PDF files.
14293 * Applying custom styles::       Styling the output.
14294 * Links in ODT export::          Handling and formatting links.
14295 * Tables in ODT export::         Org tables conversions.
14296 * Images in ODT export::         Inserting images.
14297 * Math formatting in ODT export:: Formatting @LaTeX{} fragments.
14298 * Labels and captions in ODT export:: Rendering objects.
14299 * Literal examples in ODT export:: For source code and example blocks.
14300 * Advanced topics in ODT export:: For power users.
14301 @end menu
14303 @node Pre-requisites for ODT export
14304 @subsection Pre-requisites for ODT export
14306 @cindex zip
14308 The ODT export back-end relies on the zip program to create the final
14309 compressed ODT output.  Check if @samp{zip} is locally available and
14310 executable.  Without it, export cannot finish.
14312 @node ODT export commands
14313 @subsection ODT export commands
14315 @table @asis
14316 @item @kbd{C-c C-e o o} (@code{org-export-to-odt})
14317 @kindex C-c C-e o o
14318 @findex org-export-to-odt
14319 Export as OpenDocument Text file.
14321 @cindex @samp{EXPORT_FILE_NAME}, property
14322 @vindex org-odt-preferred-output-format
14324 If @code{org-odt-preferred-output-format} is specified, the ODT export
14325 back-end automatically converts the exported file to that format.
14327 For @samp{myfile.org}, Org exports to @samp{myfile.odt}, overwriting
14328 without warning.  The ODT export back-end exports a region only
14329 if a region was active.
14331 If the selected region is a single tree, the ODT export back-end
14332 makes the tree head the document title.  Incidentally, @kbd{C-c @@} selects the current sub-tree.  If the tree head entry has,
14333 or inherits, an @samp{EXPORT_FILE_NAME} property, the ODT export
14334 back-end uses that for file name.
14336 @item @kbd{C-c C-e o O}
14337 @kindex C-c C-e o O
14338 Export as an OpenDocument Text file and open the resulting file.
14340 @vindex org-export-odt-preferred-output-format
14341 If @code{org-export-odt-preferred-output-format} is specified, open
14342 the converted file instead.  See @ref{Automatically exporting to other formats}.
14343 @end table
14345 @node ODT specific export settings
14346 @subsection ODT specific export settings
14348 The ODT export back-end has several additional keywords for
14349 customizing ODT output.  Setting these keywords works similar to the
14350 general options (see @ref{Export Settings}).
14352 @table @asis
14353 @item @samp{DESCRIPTION}
14354 @cindex @samp{DESCRIPTION}, keyword
14355 This is the document's description, which the ODT export back-end
14356 inserts as document metadata.  For long descriptions, use
14357 multiple lines, prefixed with @samp{DESCRIPTION}.
14359 @item @samp{KEYWORDS}
14360 @cindex @samp{KEYWORDS}, keyword
14361 The keywords for the document.  The ODT export back-end inserts
14362 the description along with author name, keywords, and related
14363 file metadata as metadata in the output file.  Use multiple
14364 @samp{KEYWORDS} if necessary.
14366 @item @samp{ODT_STYLES_FILE}
14367 @cindex @samp{ODT_STYLES_FILE}, keyword
14368 @vindex org-odt-styles-file
14369 The ODT export back-end uses the @code{org-odt-styles-file} by
14370 default.  See @ref{Applying custom styles} for details.
14372 @item @samp{SUBTITLE}
14373 @cindex @samp{SUBTITLE}, keyword
14374 The document subtitle.
14375 @end table
14377 @node Extending ODT export
14378 @subsection Extending ODT export
14380 The ODT export back-end can produce documents in other formats besides
14381 ODT using a specialized ODT converter process.  Its common interface
14382 works with popular converters to produce formats such as @samp{doc}, or
14383 convert a document from one format, say @samp{csv}, to another format, say
14384 @samp{xls}.
14386 @cindex @file{unoconv}
14387 @vindex org-odt-convert-process
14388 Customize @code{org-odt-convert-process} variable to point to @samp{unoconv},
14389 which is the ODT's preferred converter.  Working installations of
14390 LibreOffice would already have @samp{unoconv} installed.  Alternatively,
14391 other converters may be substituted here.  See @ref{Configuring a document converter}.
14393 @anchor{Automatically exporting to other formats}
14394 @subsubheading Automatically exporting to other formats
14396 @vindex org-odt-preferred-output-format
14397 If ODT format is just an intermediate step to get to other formats,
14398 such as @samp{doc}, @samp{docx}, @samp{rtf}, or @samp{pdf}, etc., then extend the ODT
14399 export back-end to directly produce that format.  Specify the final
14400 format in the @code{org-odt-preferred-output-format} variable.  This is one
14401 way to extend (see @ref{ODT export commands}).
14403 @anchor{Converting between document formats}
14404 @subsubheading Converting between document formats
14406 The Org export back-end is made to be inter-operable with a wide range
14407 of text document format converters.  Newer generation converters, such
14408 as LibreOffice and Pandoc, can handle hundreds of formats at once.
14409 Org provides a consistent interaction with whatever converter is
14410 installed.  Here are some generic commands:
14412 @table @asis
14413 @item @kbd{M-x org-odt-convert}
14414 @findex org-odt-convert
14415 Convert an existing document from one format to another.  With
14416 a prefix argument, opens the newly produced file.
14417 @end table
14419 @node Applying custom styles
14420 @subsection Applying custom styles
14422 @cindex styles, custom
14423 @cindex template, custom
14425 The ODT export back-end comes with many OpenDocument styles (see
14426 @ref{Working with OpenDocument style files}).  To expand or further
14427 customize these built-in style sheets, either edit the style sheets
14428 directly or generate them using an application such as LibreOffice.
14429 The example here shows creating a style using LibreOffice.
14431 @anchor{Applying custom styles the easy way}
14432 @subsubheading Applying custom styles: the easy way
14434 @enumerate
14435 @item
14436 Create a sample @samp{example.org} file with settings as shown below,
14437 and export it to ODT format.
14439 @example
14440 #+OPTIONS: H:10 num:t
14441 @end example
14443 @item
14444 Open the above @samp{example.odt} using LibreOffice.  Use the @emph{Stylist}
14445 to locate the target styles, which typically have the ``Org'' prefix.
14446 Open one, modify, and save as either OpenDocument Text (ODT) or
14447 OpenDocument Template (OTT) file.
14449 @item
14450 @vindex org-odt-styles-file
14451 Customize the variable @code{org-odt-styles-file} and point it to the
14452 newly created file.  For additional configuration options, see
14453 @ref{x-overriding-factory-styles, , Overriding factory styles}.
14455 @cindex @samp{ODT_STYLES_FILE}, keyword
14456 To apply an ODT style to a particular file, use the
14457 @samp{ODT_STYLES_FILE} keyword as shown in the example below:
14459 @example
14460 #+ODT_STYLES_FILE: "/path/to/example.ott"
14461 @end example
14463 @noindent
14466 @example
14467 #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
14468 @end example
14469 @end enumerate
14471 @anchor{Using third-party styles and templates}
14472 @subsubheading Using third-party styles and templates
14474 The ODT export back-end relies on many templates and style names.
14475 Using third-party styles and templates can lead to mismatches.
14476 Templates derived from built in ODT templates and styles seem to have
14477 fewer problems.
14479 @node Links in ODT export
14480 @subsection Links in ODT export
14482 @cindex links, in ODT export
14484 ODT exporter creates native cross-references for internal links.  It
14485 creates Internet-style links for all other links.
14487 A link with no description and pointing to a regular, un-itemized,
14488 outline heading is replaced with a cross-reference and section number
14489 of the heading.
14491 A @samp{\ref@{label@}}-style reference to an image, table etc., is replaced
14492 with a cross-reference and sequence number of the labeled entity.  See
14493 @ref{Labels and captions in ODT export}.
14495 @node Tables in ODT export
14496 @subsection Tables in ODT export
14498 @cindex tables, in ODT export
14500 The ODT export back-end handles native Org mode tables (see @ref{Tables})
14501 and simple @samp{table.el} tables.  Complex @samp{table.el} tables having column
14502 or row spans are not supported.  Such tables are stripped from the
14503 exported document.
14505 By default, the ODT export back-end exports a table with top and
14506 bottom frames and with ruled lines separating row and column groups
14507 (see @ref{Column Groups}).  All tables are typeset to occupy the same
14508 width.  The ODT export back-end honors any table alignments and
14509 relative widths for columns (see @ref{Column Width and Alignment}).
14511 Note that the ODT export back-end interprets column widths as weighted
14512 ratios, the default weight being 1.
14514 @cindex @samp{ATTR_ODT}, keyword
14515 Specifying @samp{:rel-width} property on an @samp{ATTR_ODT} line controls the
14516 width of the table.  For example:
14518 @example
14519 #+ATTR_ODT: :rel-width 50
14520 | Area/Month    |   Jan |   Feb |   Mar |   Sum |
14521 |---------------+-------+-------+-------+-------|
14522 | /             |     < |       |       |     < |
14523 | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
14524 | North America |     1 |    21 |   926 |   948 |
14525 | Middle East   |     6 |    75 |   844 |   925 |
14526 | Asia Pacific  |     9 |    27 |   790 |   826 |
14527 |---------------+-------+-------+-------+-------|
14528 | Sum           |    16 |   123 |  2560 |  2699 |
14529 @end example
14531 On export, the above table takes 50% of text width area.  The exporter
14532 sizes the columns in the ratio: 13:5:5:5:6.  The first column is
14533 left-aligned and rest of the columns, right-aligned.  Vertical rules
14534 separate the header and the last column.  Horizontal rules separate
14535 the header and the last row.
14537 For even more customization, create custom table styles and associate
14538 them with a table using the @samp{ATTR_ODT} keyword.  See @ref{Customizing tables in ODT export}.
14540 @node Images in ODT export
14541 @subsection Images in ODT export
14543 @cindex images, embedding in ODT
14544 @cindex embedding images in ODT
14546 @anchor{Embedding images}
14547 @subsubheading Embedding images
14549 The ODT export back-end processes image links in Org files that do not
14550 have descriptions, such as these links @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]},
14551 as direct image insertions in the final output.  Either of these
14552 examples works:
14554 @example
14555 [[file:img.png]]
14556 @end example
14558 @example
14559 [[./img.png]]
14560 @end example
14562 @anchor{Embedding clickable images}
14563 @subsubheading Embedding clickable images
14565 For clickable images, provide a link whose description is another link
14566 to an image file.  For example, to embed an image
14567 @samp{org-mode-unicorn.png} which when clicked jumps to @uref{https://orgmode.org}
14568 website, do the following
14570 @example
14571 [[https://orgmode.org][./org-mode-unicorn.png]]
14572 @end example
14574 @anchor{Sizing and scaling of embedded images}
14575 @subsubheading Sizing and scaling of embedded images
14577 @cindex @samp{ATTR_ODT}, keyword
14579 Control the size and scale of the embedded images with the @samp{ATTR_ODT}
14580 attribute.
14582 @cindex identify, ImageMagick
14583 @vindex org-odt-pixels-per-inch
14584 The ODT export back-end starts with establishing the size of the image
14585 in the final document.  The dimensions of this size are measured in
14586 centimeters.  The back-end then queries the image file for its
14587 dimensions measured in pixels.  For this measurement, the back-end
14588 relies on ImageMagick's identify program or Emacs @code{create-image} and
14589 @code{image-size} API.  ImageMagick is the preferred choice for large file
14590 sizes or frequent batch operations.  The back-end then converts the
14591 pixel dimensions using @code{org-odt-pixels-per-inch} into the familiar 72
14592 dpi or 96 dpi.  The default value for this is in
14593 @code{display-pixels-per-inch}, which can be tweaked for better results
14594 based on the capabilities of the output device.  Here are some common
14595 image scaling operations:
14597 @table @asis
14598 @item Explicitly size the image
14599 To embed @samp{img.png} as a 10 cm x 10 cm image, do the following:
14601 @example
14602 #+ATTR_ODT: :width 10 :height 10
14603 [[./img.png]]
14604 @end example
14606 @item Scale the image
14607 To embed @samp{img.png} at half its size, do the following:
14609 @example
14610 #+ATTR_ODT: :scale 0.5
14611 [[./img.png]]
14612 @end example
14614 @item Scale the image to a specific width
14615 To embed @samp{img.png} with a width of 10 cm while retaining the
14616 original height:width ratio, do the following:
14618 @example
14619 #+ATTR_ODT: :width 10
14620 [[./img.png]]
14621 @end example
14623 @item Scale the image to a specific height
14624 To embed @samp{img.png} with a height of 10 cm while retaining the
14625 original height:width ratio, do the following:
14627 @example
14628 #+ATTR_ODT: :height 10
14629 [[./img.png]]
14630 @end example
14631 @end table
14633 @anchor{Anchoring of images}
14634 @subsubheading Anchoring of images
14636 @cindex @samp{ATTR_ODT}, keyword
14637 The ODT export back-end can anchor images to @samp{"as-char"},
14638 @samp{"paragraph"}, or @samp{"page"}.  Set the preferred anchor using the
14639 @samp{:anchor} property of the @samp{ATTR_ODT} line.
14641 To create an image that is anchored to a page:
14643 @example
14644 #+ATTR_ODT: :anchor "page"
14645 [[./img.png]]
14646 @end example
14648 @node Math formatting in ODT export
14649 @subsection Math formatting in ODT export
14651 The ODT exporter has special support for handling math.
14653 @menu
14654 * @LaTeX{} math snippets::       Embedding in @LaTeX{} format.
14655 * MathML and OpenDocument formula files:: Embedding in native format.
14656 @end menu
14658 @node @LaTeX{} math snippets
14659 @subsubsection @LaTeX{} math snippets
14661 @LaTeX{} math snippets (see @ref{@LaTeX{} fragments}) can be embedded in the ODT
14662 document in one of the following ways:
14664 @table @asis
14665 @item MathML
14666 @cindex MathML
14667 Add this line to the Org file.  This option is activated on
14668 a per-file basis.
14670 @example
14671 #+OPTIONS: tex:t
14672 @end example
14674 With this option, @LaTeX{} fragments are first converted into MathML
14675 fragments using an external @LaTeX{}-to-MathML converter program.
14676 The resulting MathML fragments are then embedded as an
14677 OpenDocument Formula in the exported document.
14679 @vindex org-latex-to-mathml-convert-command
14680 @vindex org-latex-to-mathml-jar-file
14681 You can specify the @LaTeX{}-to-MathML converter by customizing the
14682 variables @code{org-latex-to-mathml-convert-command} and
14683 @code{org-latex-to-mathml-jar-file}.
14685 If you prefer to use MathToWeb@footnote{See @uref{http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl, MathToWeb}.} as your converter, you can
14686 configure the above variables as shown below.
14688 @lisp
14689 (setq org-latex-to-mathml-convert-command
14690       "java -jar %j -unicode -force -df %o %I"
14691       org-latex-to-mathml-jar-file
14692       "/path/to/mathtoweb.jar")
14693 @end lisp
14695 To use @LaTeX{}​ML@footnote{See @uref{http://dlmf.nist.gov/LaTeXML/}.} use
14697 @lisp
14698 (setq org-latex-to-mathml-convert-command
14699       "latexmlmath \"%i\" --presentationmathml=%o")
14700 @end lisp
14702 To quickly verify the reliability of the @LaTeX{}-to-MathML
14703 converter, use the following commands:
14705 @table @asis
14706 @item @kbd{M-x org-export-as-odf}
14707 Convert a @LaTeX{} math snippet to an OpenDocument formula
14708 (@samp{.odf}) file.
14710 @item @kbd{M-x org-export-as-odf-and-open}
14711 Convert a @LaTeX{} math snippet to an OpenDocument formula
14712 (@samp{.odf}) file and open the formula file with the
14713 system-registered application.
14714 @end table
14716 @item PNG images
14717 @cindex dvipng
14718 @cindex dvisvgm
14719 @cindex ImageMagick
14720 Add this line to the Org file.  This option is activated on
14721 a per-file basis.
14723 @example
14724 #+OPTIONS: tex:dvipng
14725 @end example
14727 @example
14728 #+OPTIONS: tex:dvisvgm
14729 @end example
14731 @noindent
14734 @example
14735 #+OPTIONS: tex:imagemagick
14736 @end example
14738 Under this option, @LaTeX{} fragments are processed into PNG or SVG
14739 images and the resulting images are embedded in the exported
14740 document.  This method requires dvipng program, dvisvgm or
14741 ImageMagick programs.
14742 @end table
14744 @node MathML and OpenDocument formula files
14745 @subsubsection MathML and OpenDocument formula files
14747 When embedding @LaTeX{} math snippets in ODT documents is not reliable,
14748 there is one more option to try.  Embed an equation by linking to its
14749 MathML (@samp{.mml}) source or its OpenDocument formula (@samp{.odf}) file as
14750 shown below:
14752 @example
14753 [[./equation.mml]]
14754 @end example
14756 @noindent
14759 @example
14760 [[./equation.odf]]
14761 @end example
14763 @node Labels and captions in ODT export
14764 @subsection Labels and captions in ODT export
14766 ODT format handles labeling and captioning of objects based on their
14767 types.  Inline images, tables, @LaTeX{} fragments, and Math formulas are
14768 numbered and captioned separately.  Each object also gets a unique
14769 sequence number based on its order of first appearance in the Org
14770 file.  Each category has its own sequence.  A caption is just a label
14771 applied to these objects.
14773 @example
14774 #+CAPTION: Bell curve
14775 #+NAME:   fig:SED-HR4049
14776 [[./img/a.png]]
14777 @end example
14779 When rendered, it may show as follows in the exported document:
14781 @example
14782 Figure 2: Bell curve
14783 @end example
14785 @vindex org-odt-category-map-alist
14786 To modify the category component of the caption, customize the option
14787 @code{org-odt-category-map-alist}.  For example, to tag embedded images
14788 with the string ``Illustration'' instead of the default string ``Figure'',
14789 use the following setting:
14791 @lisp
14792 (setq org-odt-category-map-alist
14793       '(("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))
14794 @end lisp
14796 With the above modification, the previous example changes to:
14798 @example
14799 Illustration 2: Bell curve
14800 @end example
14802 @node Literal examples in ODT export
14803 @subsection Literal examples in ODT export
14805 The ODT export back-end supports literal examples (see @ref{Literal Examples}) with full fontification.  Internally, the ODT export
14806 back-end relies on @samp{htmlfontify.el} to generate the style definitions
14807 needed for fancy listings.  The auto-generated styles get @samp{OrgSrc}
14808 prefix and inherit colors from the faces used by Emacs Font Lock
14809 library for that source language.
14811 @vindex org-odt-fontify-srcblocks
14812 For custom fontification styles, customize the
14813 @code{org-odt-create-custom-styles-for-srcblocks} option.
14815 @vindex org-odt-create-custom-styles-for-srcblocks
14816 To turn off fontification of literal examples, customize the
14817 @code{org-odt-fontify-srcblocks} option.
14819 @node Advanced topics in ODT export
14820 @subsection Advanced topics in ODT export
14822 The ODT export back-end has extensive features useful for power users
14823 and frequent uses of ODT formats.
14825 @anchor{Configuring a document converter}
14826 @subsubheading Configuring a document converter
14828 @cindex convert
14829 @cindex doc, docx, rtf
14830 @cindex converter
14832 The ODT export back-end works with popular converters with little or
14833 no extra configuration.  See @ref{Extending ODT export}.  The following is
14834 for unsupported converters or tweaking existing defaults.
14836 @table @asis
14837 @item Register the converter
14838 @vindex org-export-odt-convert-processes
14839 Add the name of the converter to the @code{org-odt-convert-processes}
14840 variable.  Note that it also requires how the converter is
14841 invoked on the command line.  See the variable's docstring for
14842 details.
14844 @item Configure its capabilities
14845 @vindex org-export-odt-convert-capabilities
14846 Specify which formats the converter can handle by customizing the
14847 variable @code{org-odt-convert-capabilities}.  Use the entry for the
14848 default values in this variable for configuring the new
14849 converter.  Also see its docstring for details.
14851 @item Choose the converter
14852 @vindex org-export-odt-convert-process
14853 Select the newly added converter as the preferred one by
14854 customizing the option @code{org-odt-convert-process}.
14855 @end table
14857 @anchor{Working with OpenDocument style files}
14858 @subsubheading Working with OpenDocument style files
14860 @cindex styles, custom
14861 @cindex template, custom
14863 This section explores the internals of the ODT exporter; the means by which
14864 it produces styled documents; the use of automatic and custom OpenDocument
14865 styles.
14867 The ODT exporter relies on two files for generating its output.  These
14868 files are bundled with the distribution under the directory pointed to
14869 by the variable @code{org-odt-styles-dir}.  The two files are:
14871 @table @asis
14872 @item @samp{OrgOdtStyles.xml} @anchor{x-orgodtstyles-xml}
14873 This file contributes to the @samp{styles.xml} file of the final ODT
14874 document.  This file gets modified for the following purposes:
14876 @enumerate
14877 @item
14878 To control outline numbering based on user settings;
14880 @item
14881 To add styles generated by @samp{htmlfontify.el} for fontification of
14882 code blocks.
14883 @end enumerate
14885 @item @samp{OrgOdtContentTemplate.xml} @anchor{x-orgodtcontenttemplate-xml}
14886 This file contributes to the @samp{content.xml} file of the final ODT
14887 document.  The contents of the Org outline are inserted between the
14888 @samp{<office:text>} @dots{} @samp{</office:text>} elements of this file.
14890 Apart from serving as a template file for the final @samp{content.xml},
14891 the file serves the following purposes:
14893 @enumerate
14894 @item
14895 It contains automatic styles for formatting of tables which are
14896 referenced by the exporter;
14898 @item
14899 It contains @samp{<text:sequence-decl>} @dots{} @samp{</text:sequence-decl>}
14900 elements that control numbering of tables, images, equations, and
14901 similar entities.
14902 @end enumerate
14903 @end table
14905 @anchor{x-overriding-factory-styles} The following two variables control
14906 the location from where the ODT exporter picks up the custom styles
14907 and content template files.  Customize these variables to override the
14908 factory styles used by the exporter.
14910 @table @asis
14911 @item @code{org-odt-styles-file}
14912 The ODT export back-end uses the file pointed to by this
14913 variable, such as @samp{styles.xml}, for the final output.  It can
14914 take one of the following values:
14916 @table @asis
14917 @item @samp{FILE.xml}
14918 Use this file instead of the default @samp{styles.xml}
14920 @item @samp{FILE.odt} or @samp{FILE.ott}
14921 Use the @samp{styles.xml} contained in the specified OpenDocument
14922 Text or Template file
14924 @item @samp{FILE.odt} or @samp{FILE.ott} and a subset of included files
14925 Use the @samp{styles.xml} contained in the specified OpenDocument
14926 Text or Template file.  Additionally extract the specified
14927 member files and embed those within the final ODT document.
14929 Use this option if the @samp{styles.xml} file references additional
14930 files like header and footer images.
14932 @item @code{nil}
14933 Use the default @samp{styles.xml}.
14934 @end table
14936 @item @code{org-odt-content-template-file}
14937 Use this variable to specify the blank @samp{content.xml} used in the
14938 final output.
14939 @end table
14941 @anchor{Creating one-off styles}
14942 @subsubheading Creating one-off styles
14944 The ODT export back-end can read embedded raw OpenDocument XML from
14945 the Org file.  Such direct formatting is useful for one-off instances.
14947 @table @asis
14948 @item Embedding ODT tags as part of regular text
14949 Enclose OpenDocument syntax in @samp{@@@@odt:...@@@@} for inline markup.
14950 For example, to highlight a region of text do the following:
14952 @example
14953 @@@@odt:<text:span text:style-name="Highlight">This is highlighted
14954 text</text:span>@@@@.  But this is regular text.
14955 @end example
14957 @strong{Hint:} To see the above example in action, edit the @samp{styles.xml}
14958 (see @ref{x-orgodtstyles-xml, , Factory styles}) and add a custom @emph{Highlight} style as shown
14959 below:
14961 @example
14962 <style:style style:name="Highlight" style:family="text">
14963   <style:text-properties fo:background-color="#ff0000"/>
14964 </style:style>
14965 @end example
14967 @item Embedding a one-line OpenDocument XML
14968 @cindex @samp{ODT}, keyword
14969 The ODT export back-end can read one-liner options with @samp{#+ODT:}
14970 in the Org file.  For example, to force a page break:
14972 @example
14973 #+ODT: <text:p text:style-name="PageBreak"/>
14974 @end example
14976 @strong{Hint:} To see the above example in action, edit your
14977 @samp{styles.xml} (see @ref{x-orgodtstyles-xml, , Factory styles}) and add a custom @samp{PageBreak}
14978 style as shown below.
14980 @example
14981 <style:style style:name="PageBreak" style:family="paragraph"
14982              style:parent-style-name="Text_20_body">
14983   <style:paragraph-properties fo:break-before="page"/>
14984 </style:style>
14985 @end example
14987 @item Embedding a block of OpenDocument XML
14988 The ODT export back-end can also read ODT export blocks for
14989 OpenDocument XML.  Such blocks use the @samp{#+BEGIN_EXPORT odt}
14990 @dots{} @samp{#+END_EXPORT} constructs.
14992 For example, to create a one-off paragraph that uses bold text,
14993 do the following:
14995 @example
14996 #+BEGIN_EXPORT odt
14997   <text:p text:style-name="Text_20_body_20_bold">
14998   This paragraph is specially formatted and uses bold text.
14999   </text:p>
15000 #+END_EXPORT
15001 @end example
15002 @end table
15004 @anchor{Customizing tables in ODT export}
15005 @subsubheading Customizing tables in ODT export
15007 @cindex tables, in ODT export
15008 @cindex @samp{ATTR_ODT}, keyword
15010 Override the default table format by specifying a custom table style
15011 with the @samp{#+ATTR_ODT} line.  For a discussion on default formatting of
15012 tables, see @ref{Tables in ODT export}.
15014 This feature closely mimics the way table templates are defined in the
15015 OpenDocument-v1.2 specification.@footnote{@uref{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html, OpenDocument-v1.2 Specification}}
15017 @vindex org-odt-table-styles
15018 For quick preview of this feature, install the settings below and export the
15019 table that follows:
15021 @lisp
15022 (setq org-export-odt-table-styles
15023       (append org-export-odt-table-styles
15024               '(("TableWithHeaderRowAndColumn" "Custom"
15025                  ((use-first-row-styles . t)
15026                   (use-first-column-styles . t)))
15027                 ("TableWithFirstRowandLastRow" "Custom"
15028                  ((use-first-row-styles . t)
15029                   (use-last-row-styles . t))))))
15030 @end lisp
15032 @example
15033 #+ATTR_ODT: :style TableWithHeaderRowAndColumn
15034 | Name  | Phone | Age |
15035 | Peter |  1234 |  17 |
15036 | Anna  |  4321 |  25 |
15037 @end example
15039 The example above used @samp{Custom} template and installed two table
15040 styles @samp{TableWithHeaderRowAndColumn} and
15041 @samp{TableWithFirstRowandLastRow}.  @strong{Important:} The OpenDocument styles
15042 needed for producing the above template were pre-defined.  They are
15043 available in the section marked @samp{Custom Table Template} in
15044 @samp{OrgOdtContentTemplate.xml} (see @ref{x-orgodtcontenttemplate-xml, , Factory styles}).  For adding new
15045 templates, define new styles there.
15047 To use this feature proceed as follows:
15049 @enumerate
15050 @item
15051 Create a table template@footnote{See the @samp{<table:table-template>} element of the
15052 OpenDocument-v1.2 specification.}.
15054 A table template is set of @samp{table-cell} and @samp{paragraph} styles for
15055 each of the following table cell categories:
15057 @itemize
15058 @item
15059 Body
15060 @item
15061 First column
15062 @item
15063 Last column
15064 @item
15065 First row
15066 @item
15067 Last row
15068 @item
15069 Even row
15070 @item
15071 Odd row
15072 @item
15073 Even column
15074 @item
15075 Odd Column
15076 @end itemize
15078 The names for the above styles must be chosen based on the name of
15079 the table template using a well-defined convention.
15081 The naming convention is better illustrated with an example.  For
15082 a table template with the name @samp{Custom}, the needed style names are
15083 listed in the following table.
15085 @multitable {aaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
15086 @headitem Cell type
15087 @tab Cell style
15088 @tab Paragraph style
15089 @item Body
15090 @tab @samp{CustomTableCell}
15091 @tab @samp{CustomTableParagraph}
15092 @item First column
15093 @tab @samp{CustomFirstColumnTableCell}
15094 @tab @samp{CustomFirstColumnTableParagraph}
15095 @item Last column
15096 @tab @samp{CustomLastColumnTableCell}
15097 @tab @samp{CustomLastColumnTableParagraph}
15098 @item First row
15099 @tab @samp{CustomFirstRowTableCell}
15100 @tab @samp{CustomFirstRowTableParagraph}
15101 @item Last row
15102 @tab @samp{CustomLastRowTableCell}
15103 @tab @samp{CustomLastRowTableParagraph}
15104 @item Even row
15105 @tab @samp{CustomEvenRowTableCell}
15106 @tab @samp{CustomEvenRowTableParagraph}
15107 @item Odd row
15108 @tab @samp{CustomOddRowTableCell}
15109 @tab @samp{CustomOddRowTableParagraph}
15110 @item Even column
15111 @tab @samp{CustomEvenColumnTableCell}
15112 @tab @samp{CustomEvenColumnTableParagraph}
15113 @item Odd column
15114 @tab @samp{CustomOddColumnTableCell}
15115 @tab @samp{CustomOddColumnTableParagraph}
15116 @end multitable
15118 To create a table template with the name @samp{Custom}, define the above
15119 styles in the @samp{<office:automatic-styles>} @dots{}
15120 @samp{</office:automatic-styles>} element of the content template file
15121 (see @ref{x-orgodtcontenttemplate-xml, , Factory styles}).
15123 @item
15124 Define a table style@footnote{See the attributes @samp{table:template-name},
15125 @samp{table:use-first-row-styles}, @samp{table:use-last-row-styles},
15126 @samp{table:use-first-column-styles}, @samp{table:use-last-column-styles},
15127 @samp{table:use-banding-rows-styles}, and @samp{table:use-banding-column-styles}
15128 of the @samp{<table:table>} element in the OpenDocument-v1.2 specification.}.
15130 @vindex org-odt-table-styles
15131 To define a table style, create an entry for the style in the
15132 variable @code{org-odt-table-styles} and specify the following:
15134 @itemize
15135 @item
15136 the name of the table template created in step (1),
15137 @item
15138 the set of cell styles in that template that are to be activated.
15139 @end itemize
15141 For example, the entry below defines two different table styles
15142 @samp{TableWithHeaderRowAndColumn} and @samp{TableWithFirstRowandLastRow}
15143 based on the same template @samp{Custom}.  The styles achieve their
15144 intended effect by selectively activating the individual cell
15145 styles in that template.
15147 @lisp
15148 (setq org-export-odt-table-styles
15149       (append org-export-odt-table-styles
15150               '(("TableWithHeaderRowAndColumn" "Custom"
15151                  ((use-first-row-styles . t)
15152                   (use-first-column-styles . t)))
15153                 ("TableWithFirstRowandLastRow" "Custom"
15154                  ((use-first-row-styles . t)
15155                   (use-last-row-styles . t))))))
15156 @end lisp
15158 @item
15159 Associate a table with the table style.
15161 To do this, specify the table style created in step (2) as part of
15162 the @samp{ATTR_ODT} line as shown below.
15164 @example
15165 #+ATTR_ODT: :style TableWithHeaderRowAndColumn
15166 | Name  | Phone | Age |
15167 | Peter |  1234 |  17 |
15168 | Anna  |  4321 |  25 |
15169 @end example
15170 @end enumerate
15172 @anchor{Validating OpenDocument XML}
15173 @subsubheading Validating OpenDocument XML
15175 Sometimes ODT format files may not open due to @samp{.odt} file corruption.
15176 To verify if such a file is corrupt, validate it against the
15177 OpenDocument Relax NG Compact (RNC) syntax schema.  But first the
15178 @samp{.odt} files have to be decompressed using @samp{zip}.  Note that @samp{.odt}
15179 files are ZIP archives: @ref{File Archives,,,emacs,}.  The contents of
15180 ODT files are in XML.  For general help with validation---and
15181 schema-sensitive editing---of XML files:
15182 @ref{Introduction,,,nxml-mode,}.
15184 @vindex org-export-odt-schema-dir
15185 Customize @code{org-odt-schema-dir} to point to a directory with
15186 OpenDocument RNC files and the needed schema-locating rules.  The ODT
15187 export back-end takes care of updating the
15188 @code{rng-schema-locating-files}.
15190 @node Org Export
15191 @section Org Export
15193 @cindex Org export
15194 @emph{org} export back-end creates a normalized version of the Org document
15195 in current buffer.  The exporter evaluates Babel code (see @ref{Evaluating Code Blocks}) and removes content specific to other back-ends.
15197 @anchor{Org export commands}
15198 @subheading Org export commands
15200 @table @asis
15201 @item @kbd{C-c C-e O o} (@code{org-org-export-to-org})
15202 @kindex C-c C-e O o
15203 @findex org-org-export-to-org
15204 Export as an Org file with a @samp{.org} extension.  For @samp{myfile.org},
15205 Org exports to @samp{myfile.org.org}, overwriting without warning.
15207 @item @kbd{C-c C-e O v} (~~)
15208 @kindex C-c C-e O v
15209 Export to an Org file, then open it.
15210 @end table
15212 @node Texinfo Export
15213 @section Texinfo Export
15215 @menu
15216 * Texinfo export commands::      Invoking commands.
15217 * Texinfo specific export settings:: Setting the environment.
15218 * Texinfo file header::          Generating the header.
15219 * Texinfo title and copyright page:: Creating preamble pages.
15220 * Info directory file::          Installing a manual in Info file hierarchy.
15221 * Headings and sectioning structure:: Building document structure.
15222 * Indices::                      Creating indices.
15223 * Quoting Texinfo code::         Incorporating literal Texinfo code.
15224 * Plain lists in Texinfo export:: List attributes.
15225 * Tables in Texinfo export::     Table attributes.
15226 * Images in Texinfo export::     Image attributes.
15227 * Special blocks in Texinfo export:: Special block attributes.
15228 * A Texinfo example::            Processing Org to Texinfo.
15229 @end menu
15231 @node Texinfo export commands
15232 @subsection Texinfo export commands
15234 @table @asis
15235 @item @kbd{C-c C-e i t} (@code{org-texinfo-export-to-texinfo})
15236 @kindex C-c C-e i t
15237 @findex org-texinfo-export-to-texinfo
15238 Export as a Texinfo file with @samp{.texi} extension.  For
15239 @samp{myfile.org}, Org exports to @samp{myfile.texi}, overwriting without
15240 warning.
15242 @item @kbd{C-c C-e i i} (@code{org-texinfo-export-to-info})
15243 @kindex C-c C-e i i
15244 @findex org-texinfo-export-to-info
15245 @vindex org-texinfo-info-process
15246 Export to Texinfo format first and then process it to make an
15247 Info file.  To generate other formats, such as DocBook, customize
15248 the @code{org-texinfo-info-process} variable.
15249 @end table
15251 @node Texinfo specific export settings
15252 @subsection Texinfo specific export settings
15254 The Texinfo export back-end has several additional keywords for
15255 customizing Texinfo output.  Setting these keywords works similar to
15256 the general options (see @ref{Export Settings}).
15258 @table @asis
15259 @item @samp{SUBTITLE}
15260 @cindex @samp{SUBTITLE}, keyword
15261 The document subtitle.
15263 @item @samp{SUBAUTHOR}
15264 @cindex @samp{SUBAUTHOR}, keyword
15265 Additional authors for the document.
15267 @item @samp{TEXINFO_FILENAME}
15268 @cindex @samp{TEXINFO_FILENAME}, keyword
15269 The Texinfo filename.
15271 @item @samp{TEXINFO_CLASS}
15272 @cindex @samp{TEXINFO_CLASS}, keyword
15273 @vindex org-texinfo-default-class
15274 The default document class (@code{org-texinfo-default-class}), which
15275 must be a member of @code{org-texinfo-classes}.
15277 @item @samp{TEXINFO_HEADER}
15278 @cindex @samp{TEXINFO_HEADER}, keyword
15279 Arbitrary lines inserted at the end of the header.
15281 @item @samp{TEXINFO_POST_HEADER}
15282 @cindex @samp{TEXINFO_POST_HEADER}, keyword
15283 Arbitrary lines inserted after the end of the header.
15285 @item @samp{TEXINFO_DIR_CATEGORY}
15286 @cindex @samp{TEXINFO_DIR_CATEGORY}, keyword
15287 The directory category of the document.
15289 @item @samp{TEXINFO_DIR_TITLE}
15290 @cindex @samp{TEXINFO_DIR_TITLE}, keyword
15291 The directory title of the document.
15293 @item @samp{TEXINFO_DIR_DESC}
15294 @cindex @samp{TEXINFO_DIR_DESC}, keyword
15295 The directory description of the document.
15297 @item @samp{TEXINFO_PRINTED_TITLE}
15298 @cindex @samp{TEXINFO_PRINTED_TITLE}, keyword
15299 The printed title of the document.
15300 @end table
15302 @node Texinfo file header
15303 @subsection Texinfo file header
15305 @cindex @samp{TEXINFO_FILENAME}, keyword
15306 After creating the header for a Texinfo file, the Texinfo back-end
15307 automatically generates a name and destination path for the Info file.
15308 To override this default with a more sensible path and name, specify
15309 the @samp{TEXINFO_FILENAME} keyword.
15311 @vindex org-texinfo-coding-system
15312 @cindex @samp{TEXINFO_HEADER}, keyword
15313 Along with the output's file name, the Texinfo header also contains
15314 language details (see @ref{Export Settings}) and encoding system as set in
15315 the @code{org-texinfo-coding-system} variable.  Insert @samp{TEXINFO_HEADER}
15316 keywords for each additional command in the header, for example:
15318 @example
15319 #+TEXINFO_HEADER: @@synindex
15320 @end example
15322 @cindex @samp{TEXINFO_CLASS}, keyword
15323 @vindex org-texinfo-classes
15324 Instead of repeatedly installing the same set of commands, define
15325 a class in @code{org-texinfo-classes} once, and then activate it in the
15326 document by setting the @samp{TEXINFO_CLASS} keyword to that class.
15328 @node Texinfo title and copyright page
15329 @subsection Texinfo title and copyright page
15331 @cindex @samp{TEXINFO_PRINTED_TITLE}, keyword
15332 The default template for hard copy output has a title page with
15333 @samp{TITLE} and @samp{AUTHOR} keywords (see @ref{Export Settings}).  To replace the
15334 regular title with something different for the printed version, use
15335 the @samp{TEXINFO_PRINTED_TITLE} and @samp{SUBTITLE} keywords.  Both expect raw
15336 Texinfo code for setting their values.
15338 @cindex @samp{SUBAUTHOR}, keyword
15339 If one @samp{AUTHOR} line is not sufficient, add multiple @samp{SUBAUTHOR}
15340 keywords.  They have to be set in raw Texinfo code.
15342 @example
15343 #+AUTHOR: Jane Smith
15344 #+SUBAUTHOR: John Doe
15345 #+TEXINFO_PRINTED_TITLE: This Long Title@@@@inlinefmt@{tex,@@*@} Is Broken in @@TeX@{@}
15346 @end example
15348 @cindex @samp{COPYING}, property
15349 Copying material is defined in a dedicated headline with a non-@code{nil}
15350 @samp{COPYING} property.  The back-end inserts the contents within
15351 a @samp{@@copying} command at the beginning of the document.  The heading
15352 itself does not appear in the structure of the document.
15354 Copyright information is printed on the back of the title page.
15356 @example
15357 * Legalese
15358   :PROPERTIES:
15359   :COPYING: t
15360   :END:
15362   This is a short example of a complete Texinfo file, version 1.0.
15364   Copyright \copy 2016 Free Software Foundation, Inc.
15365 @end example
15367 @node Info directory file
15368 @subsection Info directory file
15370 @cindex @samp{dir} file, in Texinfo export
15371 @cindex Info directory file, in Texinfo export
15372 @cindex @code{install-info}, in Texinfo export
15374 @cindex @samp{TEXINFO_DIR_CATEGORY}, keyword
15375 @cindex @samp{TEXINFO_DIR_TITLE}, keyword
15376 @cindex @samp{TEXINFO_DIR_DESC}, keyword
15377 The end result of the Texinfo export process is the creation of an
15378 Info file.  This Info file's metadata has variables for category,
15379 title, and description: @samp{TEXINFO_DIR_CATEGORY}, @samp{TEXINFO_DIR_TITLE},
15380 and @samp{TEXINFO_DIR_DESC} keywords that establish where in the Info
15381 hierarchy the file fits.
15383 Here is an example that writes to the Info directory file:
15385 @example
15386 #+TEXINFO_DIR_CATEGORY: Emacs
15387 #+TEXINFO_DIR_TITLE: Org Mode: (org)
15388 #+TEXINFO_DIR_DESC: Outline-based notes management and organizer
15389 @end example
15391 @node Headings and sectioning structure
15392 @subsection Headings and sectioning structure
15394 @vindex org-texinfo-classes
15395 @vindex org-texinfo-default-class
15396 @cindex @samp{TEXINFO_CLASS}, keyword
15397 The Texinfo export back-end uses a pre-defined scheme to convert Org
15398 headlines to equivalent Texinfo structuring commands.  A scheme like
15399 this maps top-level headlines to numbered chapters tagged as
15400 @code{@@chapter} and lower-level headlines to unnumbered chapters tagged as
15401 @code{@@unnumbered}.  To override such mappings to introduce @code{@@part} or
15402 other Texinfo structuring commands, define a new class in
15403 @code{org-texinfo-classes}.  Activate the new class with the
15404 @samp{TEXINFO_CLASS} keyword.  When no new class is defined and activated,
15405 the Texinfo export back-end defaults to the
15406 @code{org-texinfo-default-class}.
15408 If an Org headline's level has no associated Texinfo structuring
15409 command, or is below a certain threshold (see @ref{Export Settings}), then
15410 the Texinfo export back-end makes it into a list item.
15412 @cindex @samp{APPENDIX}, property
15413 The Texinfo export back-end makes any headline with a non-@code{nil}
15414 @samp{APPENDIX} property into an appendix.  This happens independent of the
15415 Org headline level or the @samp{TEXINFO_CLASS} keyword.
15417 @cindex @samp{ALT_TITLE}, property
15418 @cindex @samp{DESCRIPTION}, property
15419 The Texinfo export back-end creates a menu entry after the Org
15420 headline for each regular sectioning structure.  To override this with
15421 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
15422 @samp{DESCRIPTION} property.  Here's an example that uses both to override
15423 the default menu entry:
15425 @example
15426 * Controlling Screen Display
15427   :PROPERTIES:
15428   :ALT_TITLE: Display
15429   :DESCRIPTION: Controlling Screen Display
15430   :END:
15431 @end example
15433 @cindex Top node, in Texinfo export
15434 The text before the first headline belongs to the @emph{Top} node, i.e.,
15435 the node in which a reader enters an Info manual.  As such, it is
15436 expected not to appear in printed output generated from the @samp{.texi}
15437 file.  See @ref{The Top Node,,,texinfo,}, for more information.
15439 @node Indices
15440 @subsection Indices
15442 @cindex @samp{CINDEX}, keyword
15443 @cindex concept index, in Texinfo export
15444 @cindex @samp{FINDEX}, keyword
15445 @cindex function index, in Texinfo export
15446 @cindex @samp{KINDEX}, keyword
15447 @cindex keystroke index, in Texinfo export
15448 @cindex @samp{PINDEX}, keyword
15449 @cindex program index, in Texinfo export
15450 @cindex @samp{TINDEX}, keyword
15451 @cindex data type index, in Texinfo export
15452 @cindex @samp{VINDEX}, keyword
15453 @cindex variable index, in Texinfo export
15454 The Texinfo export back-end recognizes these indexing keywords if used
15455 in the Org file: @samp{CINDEX}, @samp{FINDEX}, @samp{KINDEX}, @samp{PINDEX}, @samp{TINDEX} and
15456 @samp{VINDEX}.  Write their value as verbatim Texinfo code; in particular,
15457 @samp{@{}, @samp{@}} and @samp{@@} characters need to be escaped with @samp{@@} if they do not
15458 belong to a Texinfo command.
15460 @example
15461 #+CINDEX: Defining indexing entries
15462 @end example
15464 @cindex @samp{INDEX}, property
15465 For the back-end to generate an index entry for a headline, set the
15466 @samp{INDEX} property to @samp{cp} or @samp{vr}.  These abbreviations come from
15467 Texinfo that stand for concept index and variable index.  The Texinfo
15468 manual has abbreviations for all other kinds of indexes.  The back-end
15469 exports the headline as an unnumbered chapter or section command, and
15470 then inserts the index after its contents.
15472 @example
15473 * Concept Index
15474   :PROPERTIES:
15475   :INDEX: cp
15476   :END:
15477 @end example
15479 @node Quoting Texinfo code
15480 @subsection Quoting Texinfo code
15482 Use any of the following three methods to insert or escape raw Texinfo
15483 code:
15485 @cindex @samp{TEXINFO}, keyword
15486 @cindex @samp{BEGIN_EXPORT texinfo}
15487 @example
15488 Richard @@@@texinfo:@@sc@{@@@@Stallman@@@@texinfo:@}@@@@ commence' GNU.
15490 #+TEXINFO: @@need800
15491 This paragraph is preceded by...
15493 #+BEGIN_EXPORT texinfo
15494   @@auindex Johnson, Mark
15495   @@auindex Lakoff, George
15496 #+END_EXPORT
15497 @end example
15499 @node Plain lists in Texinfo export
15500 @subsection Plain lists in Texinfo export
15502 @cindex @samp{ATTR_TEXINFO}, keyword
15503 @cindex two-column tables, in Texinfo export
15505 @cindex table types, in Texinfo export
15506 The Texinfo export back-end by default converts description lists in
15507 the Org file using the default command @samp{@@table}, which results in
15508 a table with two columns.  To change this behavior, specify
15509 @samp{:table-type} with @samp{ftable} or @samp{vtable} attributes.  For more
15510 information, see @ref{Two-column Tables,,,texinfo,}.
15512 @vindex org-texinfo-table-default-markup
15513 The Texinfo export back-end by default also applies a text highlight
15514 based on the defaults stored in @code{org-texinfo-table-default-markup}.
15515 To override the default highlight command, specify another one with
15516 the @samp{:indic} attribute.
15518 @cindex multiple items in Texinfo lists
15519 Org syntax is limited to one entry per list item.  Nevertheless, the
15520 Texinfo export back-end can split that entry according to any text
15521 provided through the @samp{:sep} attribute.  Each part then becomes a new
15522 entry in the first column of the table.
15524 The following example illustrates all the attributes above:
15526 @example
15527 #+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
15528 - foo, bar :: This is the common text for variables foo and bar.
15529 @end example
15531 @noindent
15532 becomes
15534 @example
15535 @@vtable @@asis
15536 @@item foo
15537 @@itemx bar
15538 This is the common text for variables foo and bar.
15539 @@end table
15540 @end example
15542 @node Tables in Texinfo export
15543 @subsection Tables in Texinfo export
15545 @cindex @samp{ATTR_TEXINFO}, keyword
15546 When exporting tables, the Texinfo export back-end uses the widest
15547 cell width in each column.  To override this and instead specify as
15548 fractions of line length, use the @samp{:columns} attribute.  See example
15549 below.
15551 @example
15552 #+ATTR_TEXINFO: :columns .5 .5
15553 | a cell | another cell |
15554 @end example
15556 @node Images in Texinfo export
15557 @subsection Images in Texinfo export
15559 @cindex @samp{ATTR_TEXINFO}, keyword
15560 Insert a file link to the image in the Org file, and the Texinfo
15561 export back-end inserts the image.  These links must have the usual
15562 supported image extensions and no descriptions.  To scale the image,
15563 use @samp{:width} and @samp{:height} attributes.  For alternate text, use @samp{:alt}
15564 and specify the text using Texinfo code, as shown in the example:
15566 @example
15567 #+ATTR_TEXINFO: :width 1in :alt Alternate @@i@{text@}
15568 [[ridt.pdf]]
15569 @end example
15571 @node Special blocks in Texinfo export
15572 @subsection Special blocks in Texinfo export
15574 @cindex @samp{ATTR_TEXINFO}, keyword
15576 The Texinfo export back-end converts special blocks to commands with
15577 the same name.  It also adds any @samp{:options} attributes to the end of
15578 the command, as shown in this example:
15580 @example
15581 #+ATTR_TEXINFO: :options org-org-export-to-org ...
15582 #+BEGIN_defun
15583   A somewhat obsessive function name.
15584 #+END_defun
15585 @end example
15587 @noindent
15588 becomes
15590 @example
15591 @@defun org-org-export-to-org ...
15592   A somewhat obsessive function name.
15593 @@end defun
15594 @end example
15596 @node A Texinfo example
15597 @subsection A Texinfo example
15599 Here is a more detailed example Org file.  See
15600 @ref{GNU Sample Texts,,,texinfo,} for an equivalent example using
15601 Texinfo code.
15603 @example
15604 #+TITLE: GNU Sample @{@{@{version@}@}@}
15605 #+SUBTITLE: for version @{@{@{version@}@}@}, @{@{@{updated@}@}@}
15606 #+AUTHOR: A.U. Thor
15607 #+EMAIL: bug-sample@@gnu.org
15609 #+OPTIONS: ':t toc:t author:t email:t
15610 #+LANGUAGE: en
15612 #+MACRO: version 2.0
15613 #+MACRO: updated last updated 4 March 2014
15615 #+TEXINFO_FILENAME: sample.info
15616 #+TEXINFO_HEADER: @@syncodeindex pg cp
15618 #+TEXINFO_DIR_CATEGORY: Texinfo documentation system
15619 #+TEXINFO_DIR_TITLE: sample: (sample)
15620 #+TEXINFO_DIR_DESC: Invoking sample
15622 #+TEXINFO_PRINTED_TITLE: GNU Sample
15624 This manual is for GNU Sample (version @{@{@{version@}@}@},
15625 @{@{@{updated@}@}@}).
15627 * Copying
15628   :PROPERTIES:
15629   :COPYING:  t
15630   :END:
15632   This manual is for GNU Sample (version @{@{@{version@}@}@},
15633   @{@{@{updated@}@}@}), which is an example in the Texinfo documentation.
15635   Copyright \copy 2016 Free Software Foundation, Inc.
15637   #+BEGIN_QUOTE
15638   Permission is granted to copy, distribute and/or modify this
15639   document under the terms of the GNU Free Documentation License,
15640   Version 1.3 or any later version published by the Free Software
15641   Foundation; with no Invariant Sections, with no Front-Cover Texts,
15642   and with no Back-Cover Texts.  A copy of the license is included in
15643   the section entitled "GNU Free Documentation License".
15644   #+END_QUOTE
15646 * Invoking sample
15648   #+PINDEX: sample
15649   #+CINDEX: invoking @@command@{sample@}
15651   This is a sample manual.  There is no sample program to invoke, but
15652   if there were, you could see its basic usage and command line
15653   options here.
15655 * GNU Free Documentation License
15656   :PROPERTIES:
15657   :APPENDIX: t
15658   :END:
15660   #+TEXINFO: @@include fdl.texi
15662 * Index
15663   :PROPERTIES:
15664   :INDEX:    cp
15665   :END:
15666 @end example
15668 @node iCalendar Export
15669 @section iCalendar Export
15671 @cindex iCalendar export
15673 A large part of Org mode's interoperability success is its ability to
15674 easily export to or import from external applications.  The iCalendar
15675 export back-end takes calendar data from Org files and exports to the
15676 standard iCalendar format.
15678 @vindex org-icalendar-include-todo
15679 @vindex org-icalendar-use-deadline
15680 @vindex org-icalendar-use-scheduled
15681 The iCalendar export back-end can also incorporate TODO entries based
15682 on the configuration of the @code{org-icalendar-include-todo} variable.
15683 The back-end exports plain timestamps as @samp{VEVENT}, TODO items as
15684 @samp{VTODO}, and also create events from deadlines that are in non-TODO
15685 items.  The back-end uses the deadlines and scheduling dates in Org
15686 TODO items for setting the start and due dates for the iCalendar TODO
15687 entry.  Consult the @code{org-icalendar-use-deadline} and
15688 @code{org-icalendar-use-scheduled} variables for more details.
15690 @vindex org-icalendar-categories
15691 @vindex org-icalendar-alarm-time
15692 For tags on the headline, the iCalendar export back-end makes them
15693 into iCalendar categories.  To tweak the inheritance of tags and TODO
15694 states, configure the variable @code{org-icalendar-categories}.  To assign
15695 clock alarms based on time, configure the @code{org-icalendar-alarm-time}
15696 variable.
15698 @vindex org-icalendar-store-UID
15699 @cindex @samp{ID}, property
15700 The iCalendar format standard requires globally unique identifier---or
15701 UID---for each entry.  The iCalendar export back-end creates UIDs
15702 during export.  To save a copy of the UID in the Org file set the
15703 variable @code{org-icalendar-store-UID}.  The back-end looks for the @samp{ID}
15704 property of the entry for re-using the same UID for subsequent
15705 exports.
15707 Since a single Org entry can result in multiple iCalendar
15708 entries---timestamp, deadline, scheduled item, or TODO item---Org adds
15709 prefixes to the UID, depending on which part of the Org entry
15710 triggered the creation of the iCalendar entry.  Prefixing ensures UIDs
15711 remains unique, yet enable synchronization programs trace the
15712 connections.
15714 @table @asis
15715 @item @kbd{C-c C-e c f} (@code{org-icalendar-export-to-ics})
15716 @kindex C-c C-e c f
15717 @findex org-icalendar-export-to-ics
15718 Create iCalendar entries from the current Org buffer and store
15719 them in the same directory, using a file extension @samp{.ics}.
15721 @item @kbd{C-c C-e c a} (@code{org-icalendar-export-agenda-files})
15722 @kindex C-c C-e c a
15723 @findex org-icalendar-export-agenda-files
15724 Create iCalendar entries from Org files in @code{org-agenda-files} and
15725 store in a separate iCalendar file for each Org file.
15727 @item @kbd{C-c C-e c c} (@code{org-icalendar-combine-agenda-files})
15728 @kindex C-c C-e c c
15729 @findex org-icalendar-combine-agenda-files
15730 @vindex org-icalendar-combined-agenda-file
15731 Create a combined iCalendar file from Org files in
15732 @code{org-agenda-files} and write it to
15733 @code{org-icalendar-combined-agenda-file} file name.
15734 @end table
15736 @cindex @samp{SUMMARY}, property
15737 @cindex @samp{DESCRIPTION}, property
15738 @cindex @samp{LOCATION}, property
15739 @cindex @samp{TIMEZONE}, property
15740 The iCalendar export back-end includes @samp{SUMMARY}, @samp{DESCRIPTION},
15741 @samp{LOCATION} and @samp{TIMEZONE} properties from the Org entries when
15742 exporting.  To force the back-end to inherit the @samp{LOCATION} and
15743 @samp{TIMEZONE} properties, configure the @code{org-use-property-inheritance}
15744 variable.
15746 @vindex org-icalendar-include-body
15747 When Org entries do not have @samp{SUMMARY}, @samp{DESCRIPTION} and @samp{LOCATION}
15748 properties, the iCalendar export back-end derives the summary from the
15749 headline, and derives the description from the body of the Org item.
15750 The @code{org-icalendar-include-body} variable limits the maximum number of
15751 characters of the content are turned into its description.
15753 The @samp{TIMEZONE} property can be used to specify a per-entry time zone,
15754 and is applied to any entry with timestamp information.  Time zones
15755 should be specified as per the IANA time zone database format, e.g.,
15756 @samp{Asia/Almaty}.  Alternately, the property value can be @samp{UTC}, to force
15757 UTC time for this entry only.
15759 Exporting to iCalendar format depends in large part on the
15760 capabilities of the destination application.  Some are more lenient
15761 than others.  Consult the Org mode FAQ for advice on specific
15762 applications.
15764 @node Other Built-in Back-ends
15765 @section Other Built-in Back-ends
15767 Other export back-ends included with Org are:
15769 @itemize
15770 @item
15771 @samp{ox-man.el}: Export to a man page.
15772 @end itemize
15774 To activate such back-ends, either customize @code{org-export-backends} or
15775 load directly with @code{(require 'ox-man)}.  On successful load, the
15776 back-end adds new keys in the export dispatcher (see @ref{The Export Dispatcher}).
15778 Follow the comment section of such files, for example, @samp{ox-man.el},
15779 for usage and configuration details.
15781 @node Advanced Configuration
15782 @section Advanced Configuration
15786 @anchor{Hooks}
15787 @subheading Hooks
15789 @vindex org-export-before-processing-hook
15790 @vindex org-export-before-parsing-hook
15791 The export process executes two hooks before the actual exporting
15792 begins.  The first hook, @code{org-export-before-processing-hook}, runs
15793 before any expansions of macros, Babel code, and include keywords in
15794 the buffer.  The second hook, @code{org-export-before-parsing-hook}, runs
15795 before the buffer is parsed.
15797 Functions added to these hooks are called with a single argument: the
15798 export back-end actually used, as a symbol.  You may use them for
15799 heavy duty structural modifications of the document.  For example, you
15800 can remove every headline in the buffer during export like this:
15802 @lisp
15803 (defun my-headline-removal (backend)
15804   "Remove all headlines in the current buffer.
15805 BACKEND is the export back-end being used, as a symbol."
15806   (org-map-entries
15807    (lambda () (delete-region (point) (line-beginning-position 2)))))
15809 (add-hook 'org-export-before-parsing-hook 'my-headline-removal)
15810 @end lisp
15812 @anchor{Filters}
15813 @subheading Filters
15815 @cindex Filters, exporting
15816 Filters are lists of functions to be applied to certain parts for
15817 a given back-end.  The output from the first function in the filter is
15818 passed on to the next function in the filter.  The final output is the
15819 output from the final function in the filter.
15821 The Org export process has many filter sets applicable to different
15822 types of objects, plain text, parse trees, export options, and final
15823 output formats.  The filters are named after the element type or
15824 object type: @code{org-export-filter-TYPE-functions}, where @var{TYPE}
15825 is the type targeted by the filter.  Valid types are:
15827 @multitable @columnfractions 0.33 0.33 0.33
15828 @item body
15829 @tab bold
15830 @tab babel-call
15831 @item center-block
15832 @tab clock
15833 @tab code
15834 @item diary-sexp
15835 @tab drawer
15836 @tab dynamic-block
15837 @item entity
15838 @tab example-block
15839 @tab export-block
15840 @item export-snippet
15841 @tab final-output
15842 @tab fixed-width
15843 @item footnote-definition
15844 @tab footnote-reference
15845 @tab headline
15846 @item horizontal-rule
15847 @tab inline-babel-call
15848 @tab inline-src-block
15849 @item inlinetask
15850 @tab italic
15851 @tab item
15852 @item keyword
15853 @tab latex-environment
15854 @tab latex-fragment
15855 @item line-break
15856 @tab link
15857 @tab node-property
15858 @item options
15859 @tab paragraph
15860 @tab parse-tree
15861 @item plain-list
15862 @tab plain-text
15863 @tab planning
15864 @item property-drawer
15865 @tab quote-block
15866 @tab radio-target
15867 @item section
15868 @tab special-block
15869 @tab src-block
15870 @item statistics-cookie
15871 @tab strike-through
15872 @tab subscript
15873 @item superscript
15874 @tab table
15875 @tab table-cell
15876 @item table-row
15877 @tab target
15878 @tab timestamp
15879 @item underline
15880 @tab verbatim
15881 @tab verse-block
15882 @end multitable
15884 Here is an example filter that replaces non-breaking spaces @code{ } in the
15885 Org buffer with @samp{~} for the @LaTeX{} back-end.
15887 @lisp
15888 (defun my-latex-filter-nobreaks (text backend info)
15889   "Ensure \" \" are properly handled in LaTeX export."
15890   (when (org-export-derived-backend-p backend 'latex)
15891     (replace-regexp-in-string " " "~" text)))
15893 (add-to-list 'org-export-filter-plain-text-functions
15894              'my-latex-filter-nobreaks)
15895 @end lisp
15897 A filter requires three arguments: the code to be transformed, the
15898 name of the back-end, and some optional information about the export
15899 process.  The third argument can be safely ignored.  Note the use of
15900 @code{org-export-derived-backend-p} predicate that tests for @emph{latex}
15901 back-end or any other back-end, such as @emph{beamer}, derived from
15902 @emph{latex}.
15904 @anchor{Defining filters for individual files}
15905 @subheading Defining filters for individual files
15907 The Org export can filter not just for back-ends, but also for
15908 specific files through the @samp{BIND} keyword.  Here is an example with
15909 two filters; one removes brackets from time stamps, and the other
15910 removes strike-through text.  The filter functions are defined in
15911 a code block in the same Org file, which is a handy location for
15912 debugging.
15914 @example
15915 #+BIND: org-export-filter-timestamp-functions (tmp-f-timestamp)
15916 #+BIND: org-export-filter-strike-through-functions (tmp-f-strike-through)
15917 #+BEGIN_SRC emacs-lisp :exports results :results none
15918   (defun tmp-f-timestamp (s backend info)
15919     (replace-regexp-in-string "&[lg]t;\\|[][]" "" s))
15920   (defun tmp-f-strike-through (s backend info) "")
15921 #+END_SRC
15922 @end example
15924 @anchor{Extending an existing back-end}
15925 @subheading Extending an existing back-end
15927 Some parts of the conversion process can be extended for certain
15928 elements so as to introduce a new or revised translation.  That is how
15929 the HTML export back-end was extended to handle Markdown format.  The
15930 extensions work seamlessly so any aspect of filtering not done by the
15931 extended back-end is handled by the original back-end.  Of all the
15932 export customization in Org, extending is very powerful as it operates
15933 at the parser level.
15935 For this example, make the @emph{ascii} back-end display the language used
15936 in a source code block.  Also make it display only when some attribute
15937 is non-@code{nil}, like the following:
15939 @example
15940 #+ATTR_ASCII: :language t
15941 @end example
15943 Then extend ASCII back-end with a custom ``my-ascii'' back-end.
15945 @lisp
15946 (defun my-ascii-src-block (src-block contents info)
15947   "Transcode a SRC-BLOCK element from Org to ASCII.
15948 CONTENTS is nil.  INFO is a plist used as a communication
15949 channel."
15950   (if (not (org-export-read-attribute :attr_ascii src-block :language))
15951       (org-export-with-backend 'ascii src-block contents info)
15952     (concat
15953      (format ",--[ %s ]--\n%s`----"
15954              (org-element-property :language src-block)
15955              (replace-regexp-in-string
15956               "^" "| "
15957               (org-element-normalize-string
15958                (org-export-format-code-default src-block info)))))))
15960 (org-export-define-derived-backend 'my-ascii 'ascii
15961   :translate-alist '((src-block . my-ascii-src-block)))
15962 @end lisp
15964 The @code{my-ascii-src-block} function looks at the attribute above the
15965 current element.  If not true, hands over to @emph{ascii} back-end.  If
15966 true, which it is in this example, it creates a box around the code
15967 and leaves room for the inserting a string for language.  The last
15968 form creates the new back-end that springs to action only when
15969 translating @code{src-block} type elements.
15971 To use the newly defined back-end, evaluate the following from an Org
15972 buffer:
15974 @lisp
15975 (org-export-to-buffer 'my-ascii "*Org MY-ASCII Export*")
15976 @end lisp
15978 Further steps to consider would be an interactive function,
15979 self-installing an item in the export dispatcher menu, and other
15980 user-friendly improvements.
15982 @node Export in Foreign Buffers
15983 @section Export in Foreign Buffers
15985 The export back-ends in Org often include commands to convert selected
15986 regions.  A convenient feature of this in-place conversion is that the
15987 exported output replaces the original source.  Here are such
15988 functions:
15990 @table @asis
15991 @item @code{org-html-convert-region-to-html}
15992 @findex org-html-convert-region-to-html
15993 Convert the selected region into HTML.
15995 @item @code{org-latex-convert-region-to-latex}
15996 @findex org-latex-convert-region-to-latex
15997 Convert the selected region into @LaTeX{}.
15999 @item @code{org-texinfo-convert-region-to-texinfo}
16000 @findex org-texinfo-convert-region-to-texinfo
16001 Convert the selected region into Texinfo.
16003 @item @code{org-md-convert-region-to-md}
16004 @findex org-md-convert-region-to-md
16005 Convert the selected region into Markdown.
16006 @end table
16008 In-place conversions are particularly handy for quick conversion of
16009 tables and lists in foreign buffers.  For example, turn on the minor
16010 mode @kbd{M-x orgstruct-mode} in an HTML buffer, then use the
16011 convenient Org keyboard commands to create a list, select it, and
16012 covert it to HTML with @kbd{M-x org-html-convert-region-to-html}.
16014 @node Publishing
16015 @chapter Publishing
16017 @cindex publishing
16019 Org includes a publishing management system that allows you to
16020 configure automatic HTML conversion of @emph{projects} composed of
16021 interlinked Org files.  You can also configure Org to automatically
16022 upload your exported HTML pages and related attachments, such as
16023 images and source code files, to a web server.
16025 You can also use Org to convert files into PDF, or even combine HTML
16026 and PDF conversion so that files are available in both formats on the
16027 server.
16029 Publishing has been contributed to Org by David O'Toole.
16031 @menu
16032 * Configuration::                Defining projects.
16033 * Uploading Files::              How to get files up on the server.
16034 * Sample Configuration::         Example projects.
16035 * Triggering Publication::       Publication commands.
16036 @end menu
16038 @node Configuration
16039 @section Configuration
16041 Publishing needs significant configuration to specify files,
16042 destination and many other properties of a project.
16044 @menu
16045 * Project alist::                The central configuration variable.
16046 * Sources and destinations::     From here to there.
16047 * Selecting files::              What files are part of the project?
16048 * Publishing action::            Setting the function doing the publishing.
16049 * Publishing options::           Tweaking HTML/@LaTeX{} export.
16050 * Publishing links::             Which links keep working after publishing?
16051 * Site map::                     Generating a list of all pages.
16052 * Generating an index::          An index that reaches across pages.
16053 @end menu
16055 @node Project alist
16056 @subsection The variable @code{org-publish-project-alist}
16058 @cindex projects, for publishing
16060 @vindex org-publish-project-alist
16061 Publishing is configured almost entirely through setting the value of
16062 one variable, called @code{org-publish-project-alist}.  Each element of the
16063 list configures one project, and may be in one of the two following
16064 forms:
16066 @lisp
16067 ("project-name" :property value :property value ...)
16068 @end lisp
16070 @noindent
16071 i.e., a well-formed property list with alternating keys and values,
16074 @lisp
16075 ("project-name" :components ("project-name" "project-name" ...))
16076 @end lisp
16078 In both cases, projects are configured by specifying property values.
16079 A project defines the set of files that are to be published, as well
16080 as the publishing configuration to use when publishing those files.
16081 When a project takes the second form listed above, the individual
16082 members of the @code{:components} property are taken to be sub-projects,
16083 which group together files requiring different publishing options.
16084 When you publish such a ``meta-project'', all the components are also
16085 published, in the sequence given.
16087 @node Sources and destinations
16088 @subsection Sources and destinations for files
16090 @cindex directories, for publishing
16092 Most properties are optional, but some should always be set.  In
16093 particular, Org needs to know where to look for source files, and
16094 where to put published files.
16096 @table @asis
16097 @item @code{:base-directory}
16098 Directory containing publishing source files.
16100 @item @code{:publishing-directory}
16101 Directory where output files are published.  You can directly
16102 publish to a webserver using a file name syntax appropriate for
16103 the Emacs tramp package.  Or you can publish to a local directory
16104 and use external tools to upload your website (see @ref{Uploading Files}).
16106 @item @code{:preparation-function}
16107 Function or list of functions to be called before starting the
16108 publishing process, for example, to run @samp{make} for updating files
16109 to be published.  Each preparation function is called with
16110 a single argument, the project property list.
16112 @item @code{:completion-function}
16113 Function or list of functions called after finishing the
16114 publishing process, for example, to change permissions of the
16115 resulting files.  Each completion function is called with
16116 a single argument, the project property list.
16117 @end table
16119 @node Selecting files
16120 @subsection Selecting files
16122 @cindex files, selecting for publishing
16124 By default, all files with extension @samp{.org} in the base directory are
16125 considered part of the project.  This can be modified by setting the
16126 following properties
16128 @table @asis
16129 @item @code{:base-extension}
16130 Extension---without the dot---of source files.  This actually
16131 is a regular expression.  Set this to the symbol @code{any} if you
16132 want to get all files in @code{:base-directory}, even without
16133 extension.
16135 @item @code{:exclude}
16136 Regular expression to match file names that should not be published,
16137 even though they have been selected on the basis of their extension.
16139 @item @code{:include}
16140 List of files to be included regardless of @code{:base-extension} and
16141 @code{:exclude}.
16143 @item @code{:recursive}
16144 Non-@code{nil} means, check base-directory recursively for files to
16145 publish.
16146 @end table
16148 @node Publishing action
16149 @subsection Publishing action
16151 @cindex action, for publishing
16153 Publishing means that a file is copied to the destination directory
16154 and possibly transformed in the process.  The default transformation
16155 is to export Org files as HTML files, and this is done by the function
16156 @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
16157 @code{org-publish-org-to-pdf}, or as ASCII, Texinfo, etc., using the
16158 corresponding functions.
16160 If you want to publish the Org file as an @samp{.org} file but with
16161 @emph{archived}, @emph{commented}, and @emph{tag-excluded} trees removed, use
16162 @code{org-publish-org-to-org}.  This produces @samp{file.org} and put it in the
16163 publishing directory.  If you want a htmlized version of this file,
16164 set the parameter @code{:htmlized-source} to @code{t}.  It produces
16165 @samp{file.org.html} in the publishing directory@footnote{If the publishing directory is the same as the source
16166 directory, @samp{file.org} is exported as @samp{file.org.org}, so you probably
16167 do not want to do this.}.
16169 Other files like images only need to be copied to the publishing
16170 destination; for this you can use @code{org-publish-attachment}.  For
16171 non-Org files, you always need to specify the publishing function:
16173 @table @asis
16174 @item @code{:publishing-function}
16175 Function executing the publication of a file.  This may also be
16176 a list of functions, which are all called in turn.
16178 @item @code{:plain-source}
16179 Non-@code{nil} means, publish plain source.
16181 @item @code{:htmlized-source}
16182 Non-@code{nil} means, publish htmlized source.
16183 @end table
16185 The function must accept three arguments: a property list containing
16186 at least a @code{:publishing-directory} property, the name of the file to
16187 be published, and the path to the publishing directory of the output
16188 file.  It should take the specified file, make the necessary
16189 transformation, if any, and place the result into the destination
16190 folder.
16192 @node Publishing options
16193 @subsection Options for the exporters
16195 @cindex options, for publishing
16196 @cindex publishing options
16198 The property list can be used to set many export options for the HTML
16199 and @LaTeX{} exporters.  In most cases, these properties correspond to
16200 user variables in Org.  The table below lists these properties along
16201 with the variable they belong to.  See the documentation string for
16202 the respective variable for details.
16204 @vindex org-publish-project-alist
16205 When a property is given a value in @code{org-publish-project-alist}, its
16206 setting overrides the value of the corresponding user variable, if
16207 any, during publishing.  Options set within a file (see @ref{Export Settings}), however, override everything.
16209 @anchor{Generic properties}
16210 @subsubheading Generic properties
16212 @multitable {aaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16213 @item @code{:archived-trees}
16214 @tab @code{org-export-with-archived-trees}
16215 @item @code{:exclude-tags}
16216 @tab @code{org-export-exclude-tags}
16217 @item @code{:headline-levels}
16218 @tab @code{org-export-headline-levels}
16219 @item @code{:language}
16220 @tab @code{org-export-default-language}
16221 @item @code{:preserve-breaks}
16222 @tab @code{org-export-preserve-breaks}
16223 @item @code{:section-numbers}
16224 @tab @code{org-export-with-section-numbers}
16225 @item @code{:select-tags}
16226 @tab @code{org-export-select-tags}
16227 @item @code{:with-author}
16228 @tab @code{org-export-with-author}
16229 @item @code{:with-broken-links}
16230 @tab @code{org-export-with-broken-links}
16231 @item @code{:with-clocks}
16232 @tab @code{org-export-with-clocks}
16233 @item @code{:with-creator}
16234 @tab @code{org-export-with-creator}
16235 @item @code{:with-date}
16236 @tab @code{org-export-with-date}
16237 @item @code{:with-drawers}
16238 @tab @code{org-export-with-drawers}
16239 @item @code{:with-email}
16240 @tab @code{org-export-with-email}
16241 @item @code{:with-emphasize}
16242 @tab @code{org-export-with-emphasize}
16243 @item @code{:with-fixed-width}
16244 @tab @code{org-export-with-fixed-width}
16245 @item @code{:with-footnotes}
16246 @tab @code{org-export-with-footnotes}
16247 @item @code{:with-latex}
16248 @tab @code{org-export-with-latex}
16249 @item @code{:with-planning}
16250 @tab @code{org-export-with-planning}
16251 @item @code{:with-priority}
16252 @tab @code{org-export-with-priority}
16253 @item @code{:with-properties}
16254 @tab @code{org-export-with-properties}
16255 @item @code{:with-special-strings}
16256 @tab @code{org-export-with-special-strings}
16257 @item @code{:with-sub-superscript}
16258 @tab @code{org-export-with-sub-superscripts}
16259 @item @code{:with-tables}
16260 @tab @code{org-export-with-tables}
16261 @item @code{:with-tags}
16262 @tab @code{org-export-with-tags}
16263 @item @code{:with-tasks}
16264 @tab @code{org-export-with-tasks}
16265 @item @code{:with-timestamps}
16266 @tab @code{org-export-with-timestamps}
16267 @item @code{:with-title}
16268 @tab @code{org-export-with-title}
16269 @item @code{:with-toc}
16270 @tab @code{org-export-with-toc}
16271 @item @code{:with-todo-keywords}
16272 @tab @code{org-export-with-todo-keywords}
16273 @end multitable
16275 @anchor{ASCII specific properties}
16276 @subsubheading ASCII specific properties
16278 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16279 @item @code{:ascii-bullets}
16280 @tab @code{org-ascii-bullets}
16281 @item @code{:ascii-caption-above}
16282 @tab @code{org-ascii-caption-above}
16283 @item @code{:ascii-charset}
16284 @tab @code{org-ascii-charset}
16285 @item @code{:ascii-global-margin}
16286 @tab @code{org-ascii-global-margin}
16287 @item @code{:ascii-format-drawer-function}
16288 @tab @code{org-ascii-format-drawer-function}
16289 @item @code{:ascii-format-inlinetask-function}
16290 @tab @code{org-ascii-format-inlinetask-function}
16291 @item @code{:ascii-headline-spacing}
16292 @tab @code{org-ascii-headline-spacing}
16293 @item @code{:ascii-indented-line-width}
16294 @tab @code{org-ascii-indented-line-width}
16295 @item @code{:ascii-inlinetask-width}
16296 @tab @code{org-ascii-inlinetask-width}
16297 @item @code{:ascii-inner-margin}
16298 @tab @code{org-ascii-inner-margin}
16299 @item @code{:ascii-links-to-notes}
16300 @tab @code{org-ascii-links-to-notes}
16301 @item @code{:ascii-list-margin}
16302 @tab @code{org-ascii-list-margin}
16303 @item @code{:ascii-paragraph-spacing}
16304 @tab @code{org-ascii-paragraph-spacing}
16305 @item @code{:ascii-quote-margin}
16306 @tab @code{org-ascii-quote-margin}
16307 @item @code{:ascii-table-keep-all-vertical-lines}
16308 @tab @code{org-ascii-table-keep-all-vertical-lines}
16309 @item @code{:ascii-table-use-ascii-art}
16310 @tab @code{org-ascii-table-use-ascii-art}
16311 @item @code{:ascii-table-widen-columns}
16312 @tab @code{org-ascii-table-widen-columns}
16313 @item @code{:ascii-text-width}
16314 @tab @code{org-ascii-text-width}
16315 @item @code{:ascii-underline}
16316 @tab @code{org-ascii-underline}
16317 @item @code{:ascii-verbatim-format}
16318 @tab @code{org-ascii-verbatim-format}
16319 @end multitable
16321 @anchor{Beamer specific properties}
16322 @subsubheading Beamer specific properties
16324 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16325 @item @code{:beamer-theme}
16326 @tab @code{org-beamer-theme}
16327 @item @code{:beamer-column-view-format}
16328 @tab @code{org-beamer-column-view-format}
16329 @item @code{:beamer-environments-extra}
16330 @tab @code{org-beamer-environments-extra}
16331 @item @code{:beamer-frame-default-options}
16332 @tab @code{org-beamer-frame-default-options}
16333 @item @code{:beamer-outline-frame-options}
16334 @tab @code{org-beamer-outline-frame-options}
16335 @item @code{:beamer-outline-frame-title}
16336 @tab @code{org-beamer-outline-frame-title}
16337 @item @code{:beamer-subtitle-format}
16338 @tab @code{org-beamer-subtitle-format}
16339 @end multitable
16341 @anchor{HTML specific properties}
16342 @subsubheading HTML specific properties
16344 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16345 @item @code{:html-allow-name-attribute-in-anchors}
16346 @tab @code{org-html-allow-name-attribute-in-anchors}
16347 @item @code{:html-checkbox-type}
16348 @tab @code{org-html-checkbox-type}
16349 @item @code{:html-container}
16350 @tab @code{org-html-container-element}
16351 @item @code{:html-divs}
16352 @tab @code{org-html-divs}
16353 @item @code{:html-doctype}
16354 @tab @code{org-html-doctype}
16355 @item @code{:html-extension}
16356 @tab @code{org-html-extension}
16357 @item @code{:html-footnote-format}
16358 @tab @code{org-html-footnote-format}
16359 @item @code{:html-footnote-separator}
16360 @tab @code{org-html-footnote-separator}
16361 @item @code{:html-footnotes-section}
16362 @tab @code{org-html-footnotes-section}
16363 @item @code{:html-format-drawer-function}
16364 @tab @code{org-html-format-drawer-function}
16365 @item @code{:html-format-headline-function}
16366 @tab @code{org-html-format-headline-function}
16367 @item @code{:html-format-inlinetask-function}
16368 @tab @code{org-html-format-inlinetask-function}
16369 @item @code{:html-head-extra}
16370 @tab @code{org-html-head-extra}
16371 @item @code{:html-head-include-default-style}
16372 @tab @code{org-html-head-include-default-style}
16373 @item @code{:html-head-include-scripts}
16374 @tab @code{org-html-head-include-scripts}
16375 @item @code{:html-head}
16376 @tab @code{org-html-head}
16377 @item @code{:html-home/up-format}
16378 @tab @code{org-html-home/up-format}
16379 @item @code{:html-html5-fancy}
16380 @tab @code{org-html-html5-fancy}
16381 @item @code{:html-indent}
16382 @tab @code{org-html-indent}
16383 @item @code{:html-infojs-options}
16384 @tab @code{org-html-infojs-options}
16385 @item @code{:html-infojs-template}
16386 @tab @code{org-html-infojs-template}
16387 @item @code{:html-inline-image-rules}
16388 @tab @code{org-html-inline-image-rules}
16389 @item @code{:html-inline-images}
16390 @tab @code{org-html-inline-images}
16391 @item @code{:html-link-home}
16392 @tab @code{org-html-link-home}
16393 @item @code{:html-link-org-files-as-html}
16394 @tab @code{org-html-link-org-files-as-html}
16395 @item @code{:html-link-up}
16396 @tab @code{org-html-link-up}
16397 @item @code{:html-link-use-abs-url}
16398 @tab @code{org-html-link-use-abs-url}
16399 @item @code{:html-mathjax-options}
16400 @tab @code{org-html-mathjax-options}
16401 @item @code{:html-mathjax-template}
16402 @tab @code{org-html-mathjax-template}
16403 @item @code{:html-metadata-timestamp-format}
16404 @tab @code{org-html-metadata-timestamp-format}
16405 @item @code{:html-postamble-format}
16406 @tab @code{org-html-postamble-format}
16407 @item @code{:html-postamble}
16408 @tab @code{org-html-postamble}
16409 @item @code{:html-preamble-format}
16410 @tab @code{org-html-preamble-format}
16411 @item @code{:html-preamble}
16412 @tab @code{org-html-preamble}
16413 @item @code{:html-table-align-individual-field}
16414 @tab @code{de@{org-html-table-align-individual-fields}
16415 @item @code{:html-table-attributes}
16416 @tab @code{org-html-table-default-attributes}
16417 @item @code{:html-table-caption-above}
16418 @tab @code{org-html-table-caption-above}
16419 @item @code{:html-table-data-tags}
16420 @tab @code{org-html-table-data-tags}
16421 @item @code{:html-table-header-tags}
16422 @tab @code{org-html-table-header-tags}
16423 @item @code{:html-table-row-tags}
16424 @tab @code{org-html-table-row-tags}
16425 @item @code{:html-table-use-header-tags-for-first-column}
16426 @tab @code{org-html-table-use-header-tags-for-first-column}
16427 @item @code{:html-tag-class-prefix}
16428 @tab @code{org-html-tag-class-prefix}
16429 @item @code{:html-text-markup-alist}
16430 @tab @code{org-html-text-markup-alist}
16431 @item @code{:html-todo-kwd-class-prefix}
16432 @tab @code{org-html-todo-kwd-class-prefix}
16433 @item @code{:html-toplevel-hlevel}
16434 @tab @code{org-html-toplevel-hlevel}
16435 @item @code{:html-use-infojs}
16436 @tab @code{org-html-use-infojs}
16437 @item @code{:html-validation-link}
16438 @tab @code{org-html-validation-link}
16439 @item @code{:html-viewport}
16440 @tab @code{org-html-viewport}
16441 @item @code{:html-xml-declaration}
16442 @tab @code{org-html-xml-declaration}
16443 @end multitable
16445 @anchor{@LaTeX{} specific properties}
16446 @subsubheading @LaTeX{} specific properties
16448 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16449 @item @code{:latex-active-timestamp-format}
16450 @tab @code{org-latex-active-timestamp-format}
16451 @item @code{:latex-caption-above}
16452 @tab @code{org-latex-caption-above}
16453 @item @code{:latex-classes}
16454 @tab @code{org-latex-classes}
16455 @item @code{:latex-class}
16456 @tab @code{org-latex-default-class}
16457 @item @code{:latex-compiler}
16458 @tab @code{org-latex-compiler}
16459 @item @code{:latex-default-figure-position}
16460 @tab @code{org-latex-default-figure-position}
16461 @item @code{:latex-default-table-environment}
16462 @tab @code{org-latex-default-table-environment}
16463 @item @code{:latex-default-table-mode}
16464 @tab @code{org-latex-default-table-mode}
16465 @item @code{:latex-diary-timestamp-format}
16466 @tab @code{org-latex-diary-timestamp-format}
16467 @item @code{:latex-footnote-defined-format}
16468 @tab @code{org-latex-footnote-defined-format}
16469 @item @code{:latex-footnote-separator}
16470 @tab @code{org-latex-footnote-separator}
16471 @item @code{:latex-format-drawer-function}
16472 @tab @code{org-latex-format-drawer-function}
16473 @item @code{:latex-format-headline-function}
16474 @tab @code{org-latex-format-headline-function}
16475 @item @code{:latex-format-inlinetask-function}
16476 @tab @code{org-latex-format-inlinetask-function}
16477 @item @code{:latex-hyperref-template}
16478 @tab @code{org-latex-hyperref-template}
16479 @item @code{:latex-image-default-height}
16480 @tab @code{org-latex-image-default-height}
16481 @item @code{:latex-image-default-option}
16482 @tab @code{org-latex-image-default-option}
16483 @item @code{:latex-image-default-width}
16484 @tab @code{org-latex-image-default-width}
16485 @item @code{:latex-images-centered}
16486 @tab @code{org-latex-images-centered}
16487 @item @code{:latex-inactive-timestamp-format}
16488 @tab @code{org-latex-inactive-timestamp-format}
16489 @item @code{:latex-inline-image-rules}
16490 @tab @code{org-latex-inline-image-rules}
16491 @item @code{:latex-link-with-unknown-path-format}
16492 @tab @code{org-latex-link-with-unknown-path-format}
16493 @item @code{:latex-listings-langs}
16494 @tab @code{org-latex-listings-langs}
16495 @item @code{:latex-listings-options}
16496 @tab @code{org-latex-listings-options}
16497 @item @code{:latex-listings}
16498 @tab @code{org-latex-listings}
16499 @item @code{:latex-minted-langs}
16500 @tab @code{org-latex-minted-langs}
16501 @item @code{:latex-minted-options}
16502 @tab @code{org-latex-minted-options}
16503 @item @code{:latex-prefer-user-labels}
16504 @tab @code{org-latex-prefer-user-labels}
16505 @item @code{:latex-subtitle-format}
16506 @tab @code{org-latex-subtitle-format}
16507 @item @code{:latex-subtitle-separate}
16508 @tab @code{org-latex-subtitle-separate}
16509 @item @code{:latex-table-scientific-notation}
16510 @tab @code{org-latex-table-scientific-notation}
16511 @item @code{:latex-tables-booktabs}
16512 @tab @code{org-latex-tables-booktabs}
16513 @item @code{:latex-tables-centered}
16514 @tab @code{org-latex-tables-centered}
16515 @item @code{:latex-text-markup-alist}
16516 @tab @code{org-latex-text-markup-alist}
16517 @item @code{:latex-title-command}
16518 @tab @code{org-latex-title-command}
16519 @item @code{:latex-toc-command}
16520 @tab @code{org-latex-toc-command}
16521 @end multitable
16523 @anchor{Markdown specific properties}
16524 @subsubheading Markdown specific properties
16526 @multitable {aaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaa}
16527 @item @code{:md-footnote-format}
16528 @tab @code{org-md-footnote-format}
16529 @item @code{:md-footnotes-section}
16530 @tab @code{org-md-footnotes-section}
16531 @item @code{:md-headline-style}
16532 @tab @code{org-md-headline-style}
16533 @end multitable
16535 @anchor{ODT specific properties}
16536 @subsubheading ODT specific properties
16538 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16539 @item @code{:odt-content-template-file}
16540 @tab @code{org-odt-content-template-file}
16541 @item @code{:odt-display-outline-level}
16542 @tab @code{org-odt-display-outline-level}
16543 @item @code{:odt-fontify-srcblocks}
16544 @tab @code{org-odt-fontify-srcblocks}
16545 @item @code{:odt-format-drawer-function}
16546 @tab @code{org-odt-format-drawer-function}
16547 @item @code{:odt-format-headline-function}
16548 @tab @code{org-odt-format-headline-function}
16549 @item @code{:odt-format-inlinetask-function}
16550 @tab @code{org-odt-format-inlinetask-function}
16551 @item @code{:odt-inline-formula-rules}
16552 @tab @code{org-odt-inline-formula-rules}
16553 @item @code{:odt-inline-image-rules}
16554 @tab @code{org-odt-inline-image-rules}
16555 @item @code{:odt-pixels-per-inch}
16556 @tab @code{org-odt-pixels-per-inch}
16557 @item @code{:odt-styles-file}
16558 @tab @code{org-odt-styles-file}
16559 @item @code{:odt-table-styles}
16560 @tab @code{org-odt-table-styles}
16561 @item @code{:odt-use-date-fields}
16562 @tab @code{org-odt-use-date-fields}
16563 @end multitable
16565 @anchor{Texinfo specific properties}
16566 @subsubheading Texinfo specific properties
16568 @multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
16569 @item @code{:texinfo-active-timestamp-format}
16570 @tab @code{org-texinfo-active-timestamp-format}
16571 @item @code{:texinfo-classes}
16572 @tab @code{org-texinfo-classes}
16573 @item @code{:texinfo-class}
16574 @tab @code{org-texinfo-default-class}
16575 @item @code{:texinfo-table-default-markup}
16576 @tab @code{org-texinfo-table-default-markup}
16577 @item @code{:texinfo-diary-timestamp-format}
16578 @tab @code{org-texinfo-diary-timestamp-format}
16579 @item @code{:texinfo-filename}
16580 @tab @code{org-texinfo-filename}
16581 @item @code{:texinfo-format-drawer-function}
16582 @tab @code{org-texinfo-format-drawer-function}
16583 @item @code{:texinfo-format-headline-function}
16584 @tab @code{org-texinfo-format-headline-function}
16585 @item @code{:texinfo-format-inlinetask-function}
16586 @tab @code{org-texinfo-format-inlinetask-function}
16587 @item @code{:texinfo-inactive-timestamp-format}
16588 @tab @code{org-texinfo-inactive-timestamp-format}
16589 @item @code{:texinfo-link-with-unknown-path-format}
16590 @tab @code{org-texinfo-link-with-unknown-path-format}
16591 @item @code{:texinfo-node-description-column}
16592 @tab @code{org-texinfo-node-description-column}
16593 @item @code{:texinfo-table-scientific-notation}
16594 @tab @code{org-texinfo-table-scientific-notation}
16595 @item @code{:texinfo-tables-verbatim}
16596 @tab @code{org-texinfo-tables-verbatim}
16597 @item @code{:texinfo-text-markup-alist}
16598 @tab @code{org-texinfo-text-markup-alist}
16599 @end multitable
16601 @node Publishing links
16602 @subsection Publishing links
16604 @cindex links, publishing
16606 To create a link from one Org file to another, you would use something
16607 like @samp{[[file:foo.org][The foo]]} or simply @samp{[[file:foo.org]]} (see @ref{External Links}).  When
16608 published, this link becomes a link to @samp{foo.html}.  You can thus
16609 interlink the pages of your ``Org web'' project and the links will work
16610 as expected when you publish them to HTML.  If you also publish the
16611 Org source file and want to link to it, use an @samp{http} link instead of
16612 a @samp{file:} link, because @samp{file} links are converted to link to the
16613 corresponding @samp{.html} file.
16615 You may also link to related files, such as images.  Provided you are
16616 careful with relative file names, and provided you have also
16617 configured Org to upload the related files, these links will work too.
16618 See @ref{Complex example}, for an example of this
16619 usage.
16621 Eventually, links between published documents can contain some search
16622 options (see @ref{Search Options}), which will be resolved to
16623 the appropriate location in the linked file.  For example, once
16624 published to HTML, the following links all point to a dedicated anchor
16625 in @samp{foo.html}.
16627 @example
16628 [[file:foo.org::*heading]]
16629 [[file:foo.org::#custom-id]]
16630 [[file:foo.org::target]]
16631 @end example
16633 @node Site map
16634 @subsection Generating a sitemap
16636 @cindex sitemap, of published pages
16638 The following properties may be used to control publishing of
16639 a map of files for a given project.
16641 @table @asis
16642 @item @code{:auto-sitemap}
16643 When non-@code{nil}, publish a sitemap during
16644 @code{org-publish-current-project} or @code{org-publish-all}.
16646 @item @code{:sitemap-filename}
16647 Filename for output of sitemap.  Defaults to @samp{sitemap.org}, which
16648 becomes @samp{sitemap.html}.
16650 @item @code{:sitemap-title}
16651 Title of sitemap page.  Defaults to name of file.
16653 @item @code{:sitemap-format-entry}
16654 @findex org-publish-find-date
16655 @findex org-publish-find-property
16656 @findex org-publish-find-title
16657 With this option one can tell how a site-map entry is formatted
16658 in the site-map.  It is a function called with three arguments:
16659 the file or directory name relative to base directory of the
16660 project, the site-map style and the current project.  It is
16661 expected to return a string.  Default value turns file names into
16662 links and use document titles as descriptions.  For specific
16663 formatting needs, one can use @code{org-publish-find-date},
16664 @code{org-publish-find-title} and @code{org-publish-find-property}, to
16665 retrieve additional information about published documents.
16667 @item @code{:sitemap-function}
16668 Plug-in function to use for generation of the sitemap.  It is
16669 called with two arguments: the title of the site-map and
16670 a representation of the files and directories involved in the
16671 project as a nested list, which can further be transformed using
16672 @code{org-list-to-generic}, @code{org-list-to-subtree} and alike.  Default
16673 value generates a plain list of links to all files in the
16674 project.
16676 @item @code{:sitemap-sort-folders}
16677 Where folders should appear in the sitemap.  Set this to @code{first}
16678 (default) or @code{last} to display folders first or last,
16679 respectively.  When set to @code{ignore}, folders are ignored
16680 altogether.  Any other value mixes files and folders.  This
16681 variable has no effect when site-map style is @code{tree}.
16683 @item @code{:sitemap-sort-files}
16684 How the files are sorted in the site map.  Set this to
16685 @code{alphabetically} (default), @code{chronologically} or
16686 @code{anti-chronologically}.  @code{chronologically} sorts the files with
16687 older date first while @code{anti-chronologically} sorts the files
16688 with newer date first.  @code{alphabetically} sorts the files
16689 alphabetically.  The date of a file is retrieved with
16690 @code{org-publish-find-date}.
16692 @item @code{:sitemap-ignore-case}
16693 Should sorting be case-sensitive?  Default @code{nil}.
16695 @item @code{:sitemap-file-entry-format}
16696 With this option one can tell how a sitemap's entry is formatted
16697 in the sitemap.  This is a format string with some escape
16698 sequences: @code{%t} stands for the title of the file, @code{%a} stands for
16699 the author of the file and @code{%d} stands for the date of the file.
16700 The date is retrieved with the @code{org-publish-find-date} function
16701 and formatted with @code{org-publish-sitemap-date-format}.  Default
16702 @code{%t}.
16704 @item @code{:sitemap-date-format}
16705 Format string for the @code{format-time-string} function that tells
16706 how a sitemap entry's date is to be formatted.  This property
16707 bypasses @code{org-publish-sitemap-date-format} which defaults to
16708 @code{%Y-%m-%d}.
16709 @end table
16711 @node Generating an index
16712 @subsection Generating an index
16714 @cindex index, in a publishing project
16716 Org mode can generate an index across the files of a publishing project.
16718 @table @asis
16719 @item @code{:makeindex}
16720 When non-@code{nil}, generate in index in the file @samp{theindex.org} and
16721 publish it as @samp{theindex.html}.
16722 @end table
16724 The file is created when first publishing a project with the
16725 @code{:makeindex} set.  The file only contains a statement @samp{#+INCLUDE:
16726 "theindex.inc"}.  You can then build around this include statement by
16727 adding a title, style information, etc.
16729 @cindex @samp{INDEX}, keyword
16730 Index entries are specified with @samp{INDEX} keyword.  An entry that
16731 contains an exclamation mark creates a sub item.
16733 @example
16734 *** Curriculum Vitae
16735 #+INDEX: CV
16736 #+INDEX: Application!CV
16737 @end example
16739 @node Uploading Files
16740 @section Uploading Files
16742 @cindex rsync
16743 @cindex unison
16745 For those people already utilizing third party sync tools such as
16746 Rsync or Unison, it might be preferable not to use the built-in remote
16747 publishing facilities of Org mode which rely heavily on Tramp.  Tramp,
16748 while very useful and powerful, tends not to be so efficient for
16749 multiple file transfer and has been known to cause problems under
16750 heavy usage.
16752 Specialized synchronization utilities offer several advantages.  In
16753 addition to timestamp comparison, they also do content and
16754 permissions/attribute checks.  For this reason you might prefer to
16755 publish your web to a local directory---possibly even @emph{in place} with
16756 your Org files---and then use Unison or Rsync to do the
16757 synchronization with the remote host.
16759 Since Unison, for example, can be configured as to which files to
16760 transfer to a certain remote destination, it can greatly simplify the
16761 project publishing definition.  Simply keep all files in the correct
16762 location, process your Org files with @code{org-publish} and let the
16763 synchronization tool do the rest.  You do not need, in this scenario,
16764 to include attachments such as JPG, CSS or PNG files in the project
16765 definition since the third-party tool syncs them.
16767 Publishing to a local directory is also much faster than to a remote
16768 one, so that you can afford more easily to republish entire projects.
16769 If you set @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the
16770 main benefit of re-including any changed external files such as source
16771 example files you might include with @samp{INCLUDE} keyword.  The timestamp
16772 mechanism in Org is not smart enough to detect if included files have
16773 been modified.
16775 @node Sample Configuration
16776 @section Sample Configuration
16778 Below we provide two example configurations.  The first one is
16779 a simple project publishing only a set of Org files.  The second
16780 example is more complex, with a multi-component project.
16782 @menu
16783 * Simple example::               One-component publishing.
16784 * Complex example::              A multi-component publishing example.
16785 @end menu
16787 @node Simple example
16788 @subsection Example: simple publishing configuration
16790 This example publishes a set of Org files to the @samp{public_html}
16791 directory on the local machine.
16793 @lisp
16794 (setq org-publish-project-alist
16795       '(("org"
16796          :base-directory "~/org/"
16797          :publishing-directory "~/public_html"
16798          :section-numbers nil
16799          :table-of-contents nil
16800          :style "<link rel=\"stylesheet\"
16801                 href=\"../other/mystyle.css\"
16802                 type=\"text/css\"/>")))
16803 @end lisp
16805 @node Complex example
16806 @subsection Example: complex publishing configuration
16808 This more complicated example publishes an entire website, including
16809 Org files converted to HTML, image files, Emacs Lisp source code, and
16810 style sheets.  The publishing directory is remote and private files
16811 are excluded.
16813 To ensure that links are preserved, care should be taken to replicate
16814 your directory structure on the web server, and to use relative file
16815 paths.  For example, if your Org files are kept in @samp{~/org/} and your
16816 publishable images in @samp{~/images/}, you would link to an image with
16818 @example
16819 file:../images/myimage.png
16820 @end example
16822 On the web server, the relative path to the image should be the same.
16823 You can accomplish this by setting up an @samp{images/} folder in the right
16824 place on the web server, and publishing images to it.
16826 @lisp
16827 (setq org-publish-project-alist
16828       '(("orgfiles"
16829          :base-directory "~/org/"
16830          :base-extension "org"
16831          :publishing-directory "/ssh:user@@host:~/html/notebook/"
16832          :publishing-function org-html-publish-to-html
16833          :exclude "PrivatePage.org" ;; regexp
16834          :headline-levels 3
16835          :section-numbers nil
16836          :with-toc nil
16837          :html-head "<link rel=\"stylesheet\"
16838                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
16839          :html-preamble t)
16841         ("images"
16842          :base-directory "~/images/"
16843          :base-extension "jpg\\|gif\\|png"
16844          :publishing-directory "/ssh:user@@host:~/html/images/"
16845          :publishing-function org-publish-attachment)
16847         ("other"
16848          :base-directory "~/other/"
16849          :base-extension "css\\|el"
16850          :publishing-directory "/ssh:user@@host:~/html/other/"
16851          :publishing-function org-publish-attachment)
16852         ("website" :components ("orgfiles" "images" "other"))))
16853 @end lisp
16855 @node Triggering Publication
16856 @section Triggering Publication
16858 Once properly configured, Org can publish with the following commands:
16860 @table @asis
16861 @item @kbd{C-c C-e X} (@code{org-publish})
16862 @kindex C-c C-e X
16863 @findex org-publish
16864 Prompt for a specific project and publish all files that belong
16865 to it.
16867 @item @kbd{C-c C-e P} (@code{org-publish-current-project})
16868 @kindex C-c C-e P
16869 @findex org-publish-current-project
16870 Publish the project containing the current file.
16872 @item @kbd{C-c C-e F} (@code{org-publish-current-file})
16873 @kindex C-c C-e F
16874 @findex org-publish-current-file
16875 Publish only the current file.
16877 @item @kbd{C-c C-e E} (@code{org-publish-all})
16878 @kindex C-c C-e E
16879 @findex org-publish-all
16880 Publish every project.
16881 @end table
16883 @vindex org-publish-use-timestamps-flag
16884 Org uses timestamps to track when a file has changed.  The above
16885 functions normally only publish changed files.  You can override this
16886 and force publishing of all files by giving a prefix argument to any
16887 of the commands above, or by customizing the variable
16888 @code{org-publish-use-timestamps-flag}.  This may be necessary in
16889 particular if files include other files via @samp{SETUPFILE} or @samp{INCLUDE}
16890 keywords.
16892 @node Working with Source Code
16893 @chapter Working with Source Code
16895 @cindex source code, working with
16897 Source code here refers to any plain text collection of computer
16898 instructions, possibly with comments, written using a human-readable
16899 programming language.  Org can manage source code in an Org document
16900 when the source code is identified with begin and end markers.
16901 Working with source code begins with identifying source code blocks.
16902 A source code block can be placed almost anywhere in an Org document;
16903 it is not restricted to the preamble or the end of the document.
16904 However, Org cannot manage a source code block if it is placed inside
16905 an Org comment or within a fixed width section.
16907 Here is an example source code block in the Emacs Lisp language:
16909 @example
16910 #+BEGIN_SRC emacs-lisp
16911   (defun org-xor (a b)
16912      "Exclusive or."
16913      (if a (not b) b))
16914 #+END_SRC
16915 @end example
16917 Org can manage the source code in the block delimited by @samp{#+BEGIN_SRC}
16918 @dots{} @samp{#+END_SRC} in several ways that can simplify housekeeping tasks
16919 essential to modern source code maintenance.  Org can edit, format,
16920 extract, export, and publish source code blocks.  Org can also compile
16921 and execute a source code block, then capture the results.  The Org
16922 mode literature sometimes refers to source code blocks as @emph{live code}
16923 blocks because they can alter the content of the Org document or the
16924 material that it exports.  Users can control how live they want each
16925 source code block by tweaking the header arguments (see @ref{Using Header Arguments}) for compiling, execution, extraction, and
16926 exporting.
16928 Source code blocks are one of many Org block types, which also include
16929 @samp{quote}, @samp{export}, @samp{verse}, @samp{latex}, @samp{example}, and @samp{verbatim}.  This
16930 section pertains to blocks between @samp{#+BEGIN_SRC} and @samp{#+END_SRC}.
16932 For editing and formatting a source code block, Org uses an
16933 appropriate Emacs major mode that includes features specifically
16934 designed for source code in that language.
16936 Org can extract one or more source code blocks and write them to one
16937 or more source files---a process known as @emph{tangling} in literate
16938 programming terminology.
16940 For exporting and publishing, Org's back-ends can format a source code
16941 block appropriately, often with native syntax highlighting.
16943 For executing and compiling a source code block, the user can
16944 configure Org to select the appropriate compiler.  Org provides
16945 facilities to collect the result of the execution or compiler output,
16946 insert it into the Org document, and/or export it.  In addition to
16947 text results, Org can insert links to other data types, including
16948 audio, video, and graphics.  Org can also link a compiler error
16949 message to the appropriate line in the source code block.
16951 An important feature of Org's management of source code blocks is the
16952 ability to pass variables, functions, and results to one another using
16953 a common syntax for source code blocks in any language.  Although most
16954 literate programming facilities are restricted to one language or
16955 another, Org's language-agnostic approach lets the literate programmer
16956 match each programming task with the appropriate computer language and
16957 to mix them all together in a single Org document.  This
16958 interoperability among languages explains why Org's source code
16959 management facility was named @emph{Org Babel} by its originators, Eric
16960 Schulte and Dan Davison.
16962 Org mode fulfills the promise of easy verification and maintenance of
16963 publishing reproducible research by keeping text, data, code,
16964 configuration settings of the execution environment, the results of
16965 the execution, and associated narratives, claims, references, and
16966 internal and external links in a single Org document.
16968 Details of Org's facilities for working with source code are described
16969 in the following sections.
16971 @menu
16972 * Structure of Code Blocks::     Code block syntax described.
16973 * Using Header Arguments::       Different ways to set header arguments.
16974 * Environment of a Code Block::  Arguments, sessions, working directory...
16975 * Evaluating Code Blocks::       Place results of evaluation in the Org buffer.
16976 * Results of Evaluation::        Choosing a results type, post-processing...
16977 * Exporting Code Blocks::        Export contents and/or results.
16978 * Extracting Source Code::       Create pure source code files.
16979 * Languages::                    List of supported code block languages.
16980 * Editing Source Code::          Language major-mode editing.
16981 * Noweb Reference Syntax::       Literate programming in Org mode.
16982 * Library of Babel::             Use and contribute to a library of useful code blocks.
16983 * Key bindings and Useful Functions:: Work quickly with code blocks.
16984 * Batch Execution::              Call functions from the command line.
16985 @end menu
16987 @node Structure of Code Blocks
16988 @section Structure of Code Blocks
16990 @cindex code block, structure
16991 @cindex source code, block structure
16992 @cindex @samp{NAME} keyword, in source blocks
16993 @cindex @samp{BEGIN_SRC}
16995 Org offers two ways to structure source code in Org documents: in
16996 a source code block, and directly inline.  Both specifications are
16997 shown below.
16999 A source code block conforms to this structure:
17001 @example
17002 #+NAME: <name>
17003 #+BEGIN_SRC <language> <switches> <header arguments>
17004   <body>
17005 #+END_SRC
17006 @end example
17008 Do not be put-off by having to remember the source block syntax.  Org
17009 mode offers a command for wrapping existing text in a block (see
17010 @ref{Structure Templates}).  Org also works with other completion systems
17011 in Emacs, some of which predate Org and have custom domain-specific
17012 languages for defining templates.  Regular use of templates reduces
17013 errors, increases accuracy, and maintains consistency.
17015 @cindex source code, inline
17016 An inline code block conforms to this structure:
17018 @example
17019 src_<language>@{<body>@}
17020 @end example
17022 @noindent
17025 @example
17026 src_<language>[<header arguments>]@{<body>@}
17027 @end example
17029 @table @asis
17030 @item @samp{#+NAME: <name>}
17031 Optional.  Names the source block so it can be called, like
17032 a function, from other source blocks or inline code to evaluate
17033 or to capture the results.  Code from other blocks, other files,
17034 and from table formulas (see @ref{The spreadsheet}) can use the name
17035 to reference a source block.  This naming serves the same purpose
17036 as naming Org tables.  Org mode requires unique names.  For
17037 duplicate names, Org mode's behavior is undefined.
17039 @item @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}
17040 Mandatory.  They mark the start and end of a block that Org
17041 requires.  The @samp{#+BEGIN_SRC} line takes additional arguments, as
17042 described next.
17044 @item @samp{<language>}
17045 @cindex language, in code blocks
17046 Mandatory.  It is the identifier of the source code language in
17047 the block.  See @ref{Languages}, for identifiers of supported
17048 languages.
17050 @item @samp{<switches>}
17051 @cindex switches, in code blocks
17052 Optional.  Switches provide finer control of the code execution,
17053 export, and format (see the discussion of switches in @ref{Literal Examples}).
17055 @item @samp{<header arguments>}
17056 @cindex header arguments, in code blocks
17057 Optional.  Heading arguments control many aspects of evaluation,
17058 export and tangling of code blocks (see @ref{Using Header Arguments}).
17059 Using Org's properties feature, header arguments can be
17060 selectively applied to the entire buffer or specific sub-trees of
17061 the Org document.
17063 @item @samp{<body>}
17064 Source code in the dialect of the specified language identifier.
17065 @end table
17067 @node Using Header Arguments
17068 @section Using Header Arguments
17070 Org comes with many header arguments common to all languages.  New
17071 header arguments are added for specific languages as they become
17072 available for use in source code blocks.  A header argument is
17073 specified with an initial colon followed by the argument's name in
17074 lowercase.
17076 Since header arguments can be set in several ways, Org prioritizes
17077 them in case of overlaps or conflicts by giving local settings
17078 a higher priority.  Header values in function calls, for example,
17079 override header values from global defaults.
17081 @anchor{System-wide header arguments}
17082 @subheading System-wide header arguments
17084 @vindex org-babel-default-header-args
17086 @vindex org-babel-default-header-args
17087 System-wide values of header arguments can be specified by customizing
17088 the @code{org-babel-default-header-args} variable, which defaults to the
17089 following values:
17091 @example
17092 :session    => "none"
17093 :results    => "replace"
17094 :exports    => "code"
17095 :cache      => "no"
17096 :noweb      => "no"
17097 @end example
17099 The example below sets @samp{:noweb} header arguments to @samp{yes}, which makes
17100 Org expand @samp{:noweb} references by default.
17102 @lisp
17103 (setq org-babel-default-header-args
17104       (cons '(:noweb . "yes")
17105             (assq-delete-all :noweb org-babel-default-header-args)))
17106 @end lisp
17108 @cindex language specific default header arguments
17109 @cindex default header arguments per language
17110 Each language can have separate default header arguments by
17111 customizing the variable @code{org-babel-default-header-args:<LANG>}, where
17112 @var{<LANG>} is the name of the language.  For details, see the
17113 language-specific online documentation at
17114 @uref{https://orgmode.org/worg/org-contrib/babel/}.
17116 @anchor{Header arguments in Org mode properties}
17117 @subheading Header arguments in Org mode properties
17119 For header arguments applicable to the buffer, use @samp{PROPERTY} keyword
17120 anywhere in the Org file (see @ref{Property Syntax}).
17122 The following example makes all the R code blocks execute in the same
17123 session.  Setting @samp{:results} to @samp{silent} ignores the results of
17124 executions for all blocks, not just R code blocks; no results inserted
17125 for any block.
17127 @example
17128 #+PROPERTY: header-args:R  :session *R*
17129 #+PROPERTY: header-args    :results silent
17130 @end example
17132 @vindex org-use-property-inheritance
17133 Header arguments set through Org's property drawers (see @ref{Property Syntax}) apply at the sub-tree level on down.  Since these property
17134 drawers can appear anywhere in the file hierarchy, Org uses outermost
17135 call or source block to resolve the values.  Org ignores
17136 @code{org-use-property-inheritance} setting.
17138 In this example, @samp{:cache} defaults to @samp{yes} for all code blocks in the
17139 sub-tree.
17141 @example
17142 * sample header
17143   :PROPERTIES:
17144   :header-args:    :cache yes
17145   :END:
17146 @end example
17148 @kindex C-c C-x p
17149 @findex org-set-property
17150 Properties defined through @code{org-set-property} function, bound to
17151 @kbd{C-c C-x p}, apply to all active languages.  They override
17152 properties set in @code{org-babel-default-header-args}.
17154 @cindex language specific header arguments properties
17155 @cindex header arguments per language
17156 Language-specific header arguments are also read from properties
17157 @samp{header-args:<LANG>} where @var{<LANG>} is the language
17158 identifier.  For example,
17160 @example
17161 * Heading
17162   :PROPERTIES:
17163   :header-args:clojure:    :session *clojure-1*
17164   :header-args:R:          :session *R*
17165   :END:
17166 ** Subheading
17167   :PROPERTIES:
17168   :header-args:clojure:    :session *clojure-2*
17169   :END:
17170 @end example
17172 @noindent
17173 would force separate sessions for Clojure blocks in @samp{Heading} and
17174 @samp{Subheading}, but use the same session for all R blocks.  Blocks in
17175 @samp{Subheading} inherit settings from @samp{Heading}.
17177 @anchor{Code block specific header arguments}
17178 @subheading Code block specific header arguments
17180 Header arguments are most commonly set at the source code block level,
17181 on the @samp{#+BEGIN_SRC} line.  Arguments set at this level take
17182 precedence over those set in the @code{org-babel-default-header-args}
17183 variable, and also those set as header properties.
17185 In the following example, setting @samp{:results} to @samp{silent} makes it
17186 ignore results of the code execution.  Setting @samp{:exports} to @samp{code}
17187 exports only the body of the code block to HTML or @LaTeX{}.
17189 @example
17190 #+NAME: factorial
17191 #+BEGIN_SRC haskell :results silent :exports code :var n=0
17192   fac 0 = 1
17193   fac n = n * fac (n-1)
17194 #+END_SRC
17195 @end example
17197 The same header arguments in an inline code block:
17199 @example
17200 src_haskell[:exports both]@{fac 5@}
17201 @end example
17203 @cindex @samp{HEADER}, keyword
17204 Code block header arguments can span multiple lines using @samp{#+HEADER:}
17205 on each line.  Note that Org currently accepts the plural spelling of
17206 @samp{#+HEADER:} only as a convenience for backward-compatibility.  It may
17207 be removed at some point.
17209 Multi-line header arguments on an unnamed code block:
17211 @example
17212 #+HEADER: :var data1=1
17213 #+BEGIN_SRC emacs-lisp :var data2=2
17214    (message "data1:%S, data2:%S" data1 data2)
17215 #+END_SRC
17217 #+RESULTS:
17218 : data1:1, data2:2
17219 @end example
17221 Multi-line header arguments on a named code block:
17223 @example
17224 #+NAME: named-block
17225 #+HEADER: :var data=2
17226 #+BEGIN_SRC emacs-lisp
17227   (message "data:%S" data)
17228 #+END_SRC
17230 #+RESULTS: named-block
17231   : data:2
17232 @end example
17234 @anchor{Header arguments in function calls}
17235 @subheading Header arguments in function calls
17237 Header arguments in function calls are the most specific and override
17238 all other settings in case of an overlap.  They get the highest
17239 priority.  Two @samp{#+CALL:} examples are shown below.  For the complete
17240 syntax of @samp{CALL} keyword, see @ref{Evaluating Code Blocks}.
17242 In this example, @samp{:exports results} header argument is applied to the
17243 evaluation of the @samp{#+CALL:} line.
17245 @example
17246 #+CALL: factorial(n=5) :exports results
17247 @end example
17249 In this example, @samp{:session special} header argument is applied to the
17250 evaluation of @samp{factorial} code block.
17252 @example
17253 #+CALL: factorial[:session special](n=5)
17254 @end example
17256 @node Environment of a Code Block
17257 @section Environment of a Code Block
17261 @anchor{Passing arguments}
17262 @subheading Passing arguments
17264 @cindex passing arguments to code blocks
17265 @cindex arguments, in code blocks
17266 @cindex @samp{var}, header argument
17267 Use @samp{var} for passing arguments to source code blocks.  The specifics
17268 of variables in code blocks vary by the source language and are
17269 covered in the language-specific documentation.  The syntax for @samp{var},
17270 however, is the same for all languages.  This includes declaring
17271 a variable, and assigning a default value.
17273 The following syntax is used to pass arguments to code blocks using
17274 the @samp{var} header argument.
17276 @example
17277 :var NAME=ASSIGN
17278 @end example
17280 @noindent
17281 @var{NAME} is the name of the variable bound in the code block
17282 body.  @var{ASSIGN} is a literal value, such as a string,
17283 a number, a reference to a table, a list, a literal example, another
17284 code block---with or without arguments---or the results of evaluating
17285 a code block.
17287 Here are examples of passing values by reference:
17289 @table @asis
17290 @item table
17291 A table named with a @samp{NAME} keyword.
17293 @example
17294 #+NAME: example-table
17295 | 1 |
17296 | 2 |
17297 | 3 |
17298 | 4 |
17300 #+NAME: table-length
17301 #+BEGIN_SRC emacs-lisp :var table=example-table
17302   (length table)
17303 #+END_SRC
17305 #+RESULTS: table-length
17306 : 4
17307 @end example
17309 When passing a table, you can treat specially the row, or the
17310 column, containing labels for the columns, or the rows, in the
17311 table.
17313 @cindex @samp{colnames}, header argument
17314 The @samp{colnames} header argument accepts @samp{yes}, @samp{no}, or @samp{nil}
17315 values.  The default value is @samp{nil}: if an input table has column
17316 names---because the second row is a horizontal rule---then Org
17317 removes the column names, processes the table, puts back the
17318 column names, and then writes the table to the results block.
17319 Using @samp{yes}, Org does the same to the first row, even if the
17320 initial table does not contain any horizontal rule.  When set to
17321 @samp{no}, Org does not pre-process column names at all.
17323 @example
17324 #+NAME: less-cols
17325 | a |
17326 |---|
17327 | b |
17328 | c |
17330 #+BEGIN_SRC python :var tab=less-cols :colnames nil
17331   return [[val + '*' for val in row] for row in tab]
17332 #+END_SRC
17334 #+RESULTS:
17335 | a  |
17336 |----|
17337 | b* |
17338 | c* |
17339 @end example
17341 @cindex @samp{rownames}, header argument
17342 Similarly, the @samp{rownames} header argument can take two values:
17343 @samp{yes} or @samp{no}.  When set to @samp{yes}, Org removes the first column,
17344 processes the table, puts back the first column, and then writes
17345 the table to the results block.  The default is @samp{no}, which means
17346 Org does not pre-process the first column.  Note that Emacs Lisp
17347 code blocks ignore @samp{rownames} header argument because of the ease
17348 of table-handling in Emacs.
17350 @example
17351 #+NAME: with-rownames
17352 | one | 1 | 2 | 3 | 4 |  5 |
17353 | two | 6 | 7 | 8 | 9 | 10 |
17355 #+BEGIN_SRC python :var tab=with-rownames :rownames yes
17356   return [[val + 10 for val in row] for row in tab]
17357 #+END_SRC
17359 #+RESULTS:
17360 | one | 11 | 12 | 13 | 14 | 15 |
17361 | two | 16 | 17 | 18 | 19 | 20 |
17362 @end example
17364 @item list
17365 A simple named list.
17367 @example
17368 #+NAME: example-list
17369 - simple
17370   - not
17371   - nested
17372 - list
17374 #+BEGIN_SRC emacs-lisp :var x=example-list
17375   (print x)
17376 #+END_SRC
17378 #+RESULTS:
17379 | simple | list |
17380 @end example
17382 Note that only the top level list items are passed along.  Nested
17383 list items are ignored.
17385 @item code block without arguments
17386 A code block name, as assigned by @samp{NAME} keyword from the example
17387 above, optionally followed by parentheses.
17389 @example
17390 #+BEGIN_SRC emacs-lisp :var length=table-length()
17391   (* 2 length)
17392 #+END_SRC
17394 #+RESULTS:
17395 : 8
17396 @end example
17398 @item code block with arguments
17399 A code block name, as assigned by @samp{NAME} keyword, followed by
17400 parentheses and optional arguments passed within the parentheses.
17402 @example
17403 #+NAME: double
17404 #+BEGIN_SRC emacs-lisp :var input=8
17405   (* 2 input)
17406 #+END_SRC
17408 #+RESULTS: double
17409 : 16
17411 #+NAME: squared
17412 #+BEGIN_SRC emacs-lisp :var input=double(input=1)
17413   (* input input)
17414 #+END_SRC
17416 #+RESULTS: squared
17417 : 4
17418 @end example
17420 @item literal example
17421 A literal example block named with a @samp{NAME} keyword.
17423 @example
17424 #+NAME: literal-example
17425 #+BEGIN_EXAMPLE
17426   A literal example
17427   on two lines
17428 #+END_EXAMPLE
17430 #+NAME: read-literal-example
17431 #+BEGIN_SRC emacs-lisp :var x=literal-example
17432   (concatenate #'string x " for you.")
17433 #+END_SRC
17435 #+RESULTS: read-literal-example
17436 : A literal example
17437 : on two lines for you.
17438 @end example
17439 @end table
17441 Indexing variable values enables referencing portions of a variable.
17442 Indexes are 0 based with negative values counting backwards from the
17443 end.  If an index is separated by commas then each subsequent section
17444 indexes as the next dimension.  Note that this indexing occurs
17445 @emph{before} other table-related header arguments are applied, such as
17446 @samp{hlines}, @samp{colnames} and @samp{rownames}.  The following example assigns
17447 the last cell of the first row the table @samp{example-table} to the
17448 variable @samp{data}:
17450 @example
17451 #+NAME: example-table
17452 | 1 | a |
17453 | 2 | b |
17454 | 3 | c |
17455 | 4 | d |
17457 #+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
17458   data
17459 #+END_SRC
17461 #+RESULTS:
17462 : a
17463 @end example
17465 Two integers separated by a colon reference a range of variable
17466 values.  In that case the entire inclusive range is referenced.  For
17467 example the following assigns the middle three rows of @samp{example-table}
17468 to @samp{data}.
17470 @example
17471 #+NAME: example-table
17472 | 1 | a |
17473 | 2 | b |
17474 | 3 | c |
17475 | 4 | d |
17476 | 5 | 3 |
17478 #+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
17479   data
17480 #+END_SRC
17482 #+RESULTS:
17483 | 2 | b |
17484 | 3 | c |
17485 | 4 | d |
17486 @end example
17488 To pick the entire range, use an empty index, or the single character
17489 @samp{*}.  @samp{0:-1} does the same thing.  Example below shows how to
17490 reference the first column only.
17492 @example
17493 #+NAME: example-table
17494 | 1 | a |
17495 | 2 | b |
17496 | 3 | c |
17497 | 4 | d |
17499 #+BEGIN_SRC emacs-lisp :var data=example-table[,0]
17500   data
17501 #+END_SRC
17503 #+RESULTS:
17504 | 1 | 2 | 3 | 4 |
17505 @end example
17507 Index referencing can be used for tables and code blocks.  Index
17508 referencing can handle any number of dimensions.  Commas delimit
17509 multiple dimensions, as shown below.
17511 @example
17512 #+NAME: 3D
17513 #+BEGIN_SRC emacs-lisp
17514   '(((1  2  3)  (4  5  6)  (7  8  9))
17515     ((10 11 12) (13 14 15) (16 17 18))
17516     ((19 20 21) (22 23 24) (25 26 27)))
17517 #+END_SRC
17519 #+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
17520   data
17521 #+END_SRC
17523 #+RESULTS:
17524 | 11 | 14 | 17 |
17525 @end example
17527 Note that row names and column names are not removed prior to variable
17528 indexing.  You need to take them into account, even when @samp{colnames} or
17529 @samp{rownames} header arguments remove them.
17531 Emacs lisp code can also set the values for variables.  To
17532 differentiate a value from Lisp code, Org interprets any value
17533 starting with @samp{(}, @samp{[}, @samp{'} or @samp{`} as Emacs Lisp code.  The result of
17534 evaluating that code is then assigned to the value of that variable.
17535 The following example shows how to reliably query and pass the file
17536 name of the Org mode buffer to a code block using headers.  We need
17537 reliability here because the file's name could change once the code in
17538 the block starts executing.
17540 @example
17541 #+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
17542   wc -w $filename
17543 #+END_SRC
17544 @end example
17546 Note that values read from tables and lists are not mistakenly
17547 evaluated as Emacs Lisp code, as illustrated in the following example.
17549 @example
17550 #+NAME: table
17551 | (a b c) |
17553 #+HEADER: :var data=table[0,0]
17554 #+BEGIN_SRC perl
17555   $data
17556 #+END_SRC
17558 #+RESULTS:
17559 : (a b c)
17560 @end example
17562 @anchor{Using sessions}
17563 @subheading Using sessions
17565 @cindex using sessions in code blocks
17566 @cindex @samp{session}, header argument
17567 Two code blocks can share the same environment.  The @samp{session} header
17568 argument is for running multiple source code blocks under one session.
17569 Org runs code blocks with the same session name in the same
17570 interpreter process.
17572 @table @asis
17573 @item @samp{none}
17574 Default.  Each code block gets a new interpreter process to
17575 execute.  The process terminates once the block is evaluated.
17577 @item @var{STRING}
17578 Any string besides @samp{none} turns that string into the name of that
17579 session.  For example, @samp{:session STRING} names it @samp{STRING}.  If
17580 @samp{session} has no value, then the session name is derived from the
17581 source language identifier.  Subsequent blocks with the same
17582 source code language use the same session.  Depending on the
17583 language, state variables, code from other blocks, and the
17584 overall interpreted environment may be shared.  Some interpreted
17585 languages support concurrent sessions when subsequent source code
17586 language blocks change session names.
17587 @end table
17589 Only languages that provide interactive evaluation can have session
17590 support.  Not all languages provide this support, such as C and ditaa.
17591 Even languages, such as Python and Haskell, that do support
17592 interactive evaluation impose limitations on allowable language
17593 constructs that can run interactively.  Org inherits those limitations
17594 for those code blocks running in a session.
17596 @anchor{Choosing a working directory}
17597 @subheading Choosing a working directory
17599 @cindex working directory, in a code block
17600 @cindex @samp{dir}, header argument
17601 The @samp{dir} header argument specifies the default directory during code
17602 block execution.  If it is absent, then the directory associated with
17603 the current buffer is used.  In other words, supplying @samp{:dir PATH}
17604 temporarily has the same effect as changing the current directory with
17605 @kbd{M-x cd PATH}, and then not setting @samp{dir}.  Under the
17606 surface, @samp{dir} simply sets the value of the Emacs variable
17607 @code{default-directory}.
17609 For example, to save the plot file in the @samp{Work/} folder of the home
17610 directory---notice tilde is expanded:
17612 @example
17613 #+BEGIN_SRC R :file myplot.png :dir ~/Work
17614   matplot(matrix(rnorm(100), 10), type="l")
17615 #+END_SRC
17616 @end example
17618 To evaluate the code block on a remote machine, supply a remote
17619 directory name using Tramp syntax.  For example:
17621 @example
17622 #+BEGIN_SRC R :file plot.png :dir /scp:dand@@yakuba.princeton.edu:
17623   plot(1:10, main=system("hostname", intern=TRUE))
17624 #+END_SRC
17625 @end example
17627 Org first captures the text results as usual for insertion in the Org
17628 file.  Then Org also inserts a link to the remote file, thanks to
17629 Emacs Tramp.  Org constructs the remote path to the file name from
17630 @samp{dir} and @code{default-directory}, as illustrated here:
17632 @example
17633 [[file:/scp:dand@@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
17634 @end example
17636 When @samp{dir} is used with @samp{session}, Org sets the starting directory for
17637 a new session.  But Org does not alter the directory of an already
17638 existing session.
17640 Do not use @samp{dir} with @samp{:exports results} or with @samp{:exports both} to
17641 avoid Org inserting incorrect links to remote files.  That is because
17642 Org does not expand @code{default directory} to avoid some underlying
17643 portability issues.
17645 @anchor{Inserting headers and footers}
17646 @subheading Inserting headers and footers
17648 @cindex headers, in code blocks
17649 @cindex footers, in code blocks
17650 @cindex @samp{prologue}, header argument
17651 The @samp{prologue} header argument is for appending to the top of the code
17652 block for execution, like a reset instruction.  For example, you may
17653 use @samp{:prologue "reset"} in a Gnuplot code block or, for every such
17654 block:
17656 @lisp
17657 (add-to-list 'org-babel-default-header-args:gnuplot
17658              '((:prologue . "reset")))
17660 @end lisp
17662 @cindex @samp{epilogue}, header argument
17663 Likewise, the value of the @samp{epilogue} header argument is for appending
17664 to the end of the code block for execution.
17666 @node Evaluating Code Blocks
17667 @section Evaluating Code Blocks
17669 @cindex code block, evaluating
17670 @cindex source code, evaluating
17671 @cindex @samp{RESULTS}, keyword
17673 A note about security: With code evaluation comes the risk of harm.
17674 Org safeguards by prompting for user's permission before executing any
17675 code in the source block.  To customize this safeguard, or disable it,
17676 see @ref{Code Evaluation Security}.
17678 @anchor{How to evaluate source code}
17679 @subheading How to evaluate source code
17681 Org captures the results of the code block evaluation and inserts them
17682 in the Org file, right after the code block.  The insertion point is
17683 after a newline and the @samp{RESULTS} keyword.  Org creates the @samp{RESULTS}
17684 keyword if one is not already there.
17686 By default, Org enables only Emacs Lisp code blocks for execution.
17687 See @ref{Languages} to enable other languages.
17689 @kindex C-c C-c
17690 @kindex C-c C-v e
17691 @findex org-babel-execute-src-block
17692 Org provides many ways to execute code blocks.  @kbd{C-c C-c} or
17693 @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
17694 to remove code evaluation from the @kbd{C-c C-c} key binding.} calls the
17695 @code{org-babel-execute-src-block} function, which executes the code in the
17696 block, collects the results, and inserts them in the buffer.
17698 @cindex @samp{CALL}, keyword
17699 @vindex org-babel-inline-result-wrap
17700 By calling a named code block@footnote{Actually, the constructs @samp{call_<name>()} and @samp{src_<lang>@{@}}
17701 are not evaluated when they appear in a keyword line---i.e. lines
17702 starting with @samp{#+KEYWORD:}, see @ref{In-buffer Settings}.} from an Org mode buffer or
17703 a table.  Org can call the named code blocks from the current Org mode
17704 buffer or from the ``Library of Babel'' (see @ref{Library of Babel}).
17706 The syntax for @samp{CALL} keyword is:
17708 @example
17709 #+CALL: <name>(<arguments>)
17710 #+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
17711 @end example
17713 The syntax for inline named code blocks is:
17715 @example
17716 ... call_<name>(<arguments>) ...
17717 ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
17718 @end example
17720 When inline syntax is used, the result is wrapped based on the
17721 variable @code{org-babel-inline-result-wrap}, which by default is set to
17722 @code{"=%s="} to produce verbatim text suitable for markup.
17724 @table @asis
17725 @item @samp{<name>}
17726 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
17727 located in another file, start @samp{<name>} with the file name
17728 followed by a colon. For example, in order to execute a block
17729 named @samp{clear-data} in @samp{file.org}, you can write the following:
17731 @example
17732 #+CALL: file.org:clear-data()
17733 @end example
17735 @item @samp{<arguments>}
17736 Org passes arguments to the code block using standard function
17737 call syntax.  For example, a @samp{#+CALL:} line that passes @samp{4} to
17738 a code block named @samp{double}, which declares the header argument
17739 @samp{:var n=2}, would be written as:
17741 @example
17742 #+CALL: double(n=4)
17743 @end example
17745 @noindent
17746 Note how this function call syntax is different from the header
17747 argument syntax.
17749 @item @samp{<inside header arguments>}
17750 Org passes inside header arguments to the named code block using
17751 the header argument syntax.  Inside header arguments apply to
17752 code block evaluation.  For example, @samp{[:results output]} collects
17753 results printed to stdout during code execution of that block.
17754 Note how this header argument syntax is different from the
17755 function call syntax.
17757 @item @samp{<end header arguments>}
17758 End header arguments affect the results returned by the code
17759 block.  For example, @samp{:results html} wraps the results in
17760 a @samp{#+BEGIN_EXPORT html} block before inserting the results in the
17761 Org buffer.
17762 @end table
17764 @anchor{Limit code block evaluation}
17765 @subheading Limit code block evaluation
17767 @cindex @samp{eval}, header argument
17768 @cindex control code block evaluation
17769 The @samp{eval} header argument can limit evaluation of specific code
17770 blocks and @samp{CALL} keyword.  It is useful for protection against
17771 evaluating untrusted code blocks by prompting for a confirmation.
17773 @table @asis
17774 @item @samp{never} or @samp{no}
17775 Org never evaluates the source code.
17777 @item @samp{query}
17778 Org prompts the user for permission to evaluate the source code.
17780 @item @samp{never-export} or @samp{no-export}
17781 Org does not evaluate the source code when exporting, yet the
17782 user can evaluate it interactively.
17784 @item @samp{query-export}
17785 Org prompts the user for permission to evaluate the source code
17786 during export.
17787 @end table
17789 If @samp{eval} header argument is not set, then Org determines whether to
17790 evaluate the source code from the @code{org-confirm-babel-evaluate}
17791 variable (see @ref{Code Evaluation Security}).
17793 @anchor{Cache results of evaluation}
17794 @subheading Cache results of evaluation
17796 @cindex @samp{cache}, header argument
17797 @cindex cache results of code evaluation
17798 The @samp{cache} header argument is for caching results of evaluating code
17799 blocks.  Caching results can avoid re-evaluating a code block that
17800 have not changed since the previous run.  To benefit from the cache
17801 and avoid redundant evaluations, the source block must have a result
17802 already present in the buffer, and neither the header
17803 arguments---including the value of @samp{var} references---nor the text of
17804 the block itself has changed since the result was last computed.  This
17805 feature greatly helps avoid long-running calculations.  For some edge
17806 cases, however, the cached results may not be reliable.
17808 The caching feature is best for when code blocks are pure functions,
17809 that is functions that return the same value for the same input
17810 arguments (see @ref{Environment of a Code Block}), and that do not have
17811 side effects, and do not rely on external variables other than the
17812 input arguments.  Functions that depend on a timer, file system
17813 objects, and random number generators are clearly unsuitable for
17814 caching.
17816 A note of warning: when @samp{cache} is used in a session, caching may
17817 cause unexpected results.
17819 When the caching mechanism tests for any source code changes, it does
17820 not expand Noweb style references (see @ref{Noweb Reference Syntax}).  For
17821 reasons why, see @uref{http://thread.gmane.org/gmane.emacs.orgmode/79046}.
17823 The @samp{cache} header argument can have one of two values: @samp{yes} or @samp{no}.
17825 @table @asis
17826 @item @samp{no}
17827 Default.  No caching of results; code block evaluated every
17828 time.
17830 @item @samp{yes}
17831 Whether to run the code or return the cached results is
17832 determined by comparing the SHA1 hash value of the combined code
17833 block and arguments passed to it.  This hash value is packed on
17834 the @samp{#+RESULTS:} line from previous evaluation.  When hash values
17835 match, Org does not evaluate the code block.  When hash values
17836 mismatch, Org evaluates the code block, inserts the results,
17837 recalculates the hash value, and updates @samp{#+RESULTS:} line.
17838 @end table
17840 In this example, both functions are cached.  But @samp{caller} runs only if
17841 the result from @samp{random} has changed since the last run.
17843 @example
17844 #+NAME: random
17845 #+BEGIN_SRC R :cache yes
17846   runif(1)
17847 #+END_SRC
17849 #+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
17850 0.4659510825295
17852 #+NAME: caller
17853 #+BEGIN_SRC emacs-lisp :var x=random :cache yes
17854   x
17855 #+END_SRC
17857 #+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
17858 0.254227238707244
17859 @end example
17861 @node Results of Evaluation
17862 @section Results of Evaluation
17864 @cindex code block, results of evaluation
17865 @cindex source code, results of evaluation
17867 @cindex @samp{results}, header argument
17868 How Org handles results of a code block execution depends on many
17869 header arguments working together.  The primary determinant, however,
17870 is the @samp{results} header argument.  It accepts four classes of options.
17871 Each code block can take only one option per class:
17873 @table @asis
17874 @item collection
17875 For how the results should be collected from the code block;
17877 @item type
17878 For which type of result the code block will return; affects how
17879 Org processes and inserts results in the Org buffer;
17881 @item format
17882 For the result; affects how Org processes and inserts results in
17883 the Org buffer;
17885 @item handling
17886 For processing results after evaluation of the code block;
17887 @end table
17889 @anchor{Collection}
17890 @subheading Collection
17892 Collection options specify the results.  Choose one of the options;
17893 they are mutually exclusive.
17895 @table @asis
17896 @item @samp{value}
17897 Default.  Functional mode.  Org gets the value by wrapping the
17898 code in a function definition in the language of the source
17899 block.  That is why when using @samp{:results value}, code should
17900 execute like a function and return a value.  For languages like
17901 Python, an explicit @code{return} statement is mandatory when using
17902 @samp{:results value}.  Result is the value returned by the last
17903 statement in the code block.
17905 When evaluating the code block in a session (see @ref{Environment of a Code Block}), Org passes the code to an interpreter running as
17906 an interactive Emacs inferior process. Org gets the value from
17907 the source code interpreter's last statement output.  Org has to
17908 use language-specific methods to obtain the value.  For example,
17909 from the variable @code{_} in Python and Ruby, and the value of
17910 @code{.Last.value} in R.
17912 @item @samp{output}
17913 Scripting mode.  Org passes the code to an external process
17914 running the interpreter.  Org returns the contents of the
17915 standard output stream as text results.
17917 When using a session, Org passes the code to the interpreter
17918 running as an interactive Emacs inferior process.  Org
17919 concatenates any text output from the interpreter and returns the
17920 collection as a result.
17922 Note that this collection is not the same as that would be
17923 collected from stdout of a non-interactive interpreter running as
17924 an external process.  Compare for example these two blocks:
17926 @example
17927 #+BEGIN_SRC python :results output
17928   print "hello"
17929   2
17930   print "bye"
17931 #+END_SRC
17933 #+RESULTS:
17934 : hello
17935 : bye
17936 @end example
17938 In the above non-session mode, the ``2'' is not printed; so it does
17939 not appear in results.
17941 @example
17942 #+BEGIN_SRC python :results output :session
17943   print "hello"
17944   2
17945   print "bye"
17946 #+END_SRC
17948 #+RESULTS:
17949 : hello
17950 : 2
17951 : bye
17952 @end example
17954 In the above session, the interactive interpreter receives and
17955 prints ``2''.  Results show that.
17956 @end table
17958 @anchor{Type}
17959 @subheading Type
17961 Type tells what result types to expect from the execution of the code
17962 block.  Choose one of the options; they are mutually exclusive.  The
17963 default behavior is to automatically determine the result type.
17965 @table @asis
17966 @item @samp{table}
17967 @itemx @samp{vector}
17968 Interpret the results as an Org table.  If the result is a single
17969 value, create a table with one row and one column.  Usage
17970 example: @samp{:results value table}.
17972 @cindex @samp{hlines}, header argument
17973 In-between each table row or below the table headings, sometimes
17974 results have horizontal lines, which are also known as ``hlines''.
17975 The @samp{hlines} argument with the default @samp{no} value strips such
17976 lines from the input table.  For most code, this is desirable, or
17977 else those @samp{hline} symbols raise unbound variable errors.
17978 A @samp{yes} accepts such lines, as demonstrated in the following
17979 example.
17981 @example
17982 #+NAME: many-cols
17983 | a | b | c |
17984 |---+---+---|
17985 | d | e | f |
17986 |---+---+---|
17987 | g | h | i |
17989 #+NAME: no-hline
17990 #+BEGIN_SRC python :var tab=many-cols :hlines no
17991   return tab
17992 #+END_SRC
17994 #+RESULTS: no-hline
17995 | a | b | c |
17996 | d | e | f |
17997 | g | h | i |
17999 #+NAME: hlines
18000 #+BEGIN_SRC python :var tab=many-cols :hlines yes
18001   return tab
18002 #+END_SRC
18004 #+RESULTS: hlines
18005 | a | b | c |
18006 |---+---+---|
18007 | d | e | f |
18008 |---+---+---|
18009 | g | h | i |
18010 @end example
18012 @item @samp{list}
18013 Interpret the results as an Org list.  If the result is a single
18014 value, create a list of one element.
18016 @item @samp{scalar}
18017 @itemx @samp{verbatim}
18018 Interpret literally and insert as quoted text.  Do not create
18019 a table.  Usage example: @samp{:results value verbatim}.
18021 @item @samp{file}
18022 Interpret as a filename.  Save the results of execution of the
18023 code block to that file, then insert a link to it.  You can
18024 control both the filename and the description associated to the
18025 link.
18027 @cindex @samp{file}, header argument
18028 @cindex @samp{output-dir}, header argument
18029 Org first tries to generate the filename from the value of the
18030 @samp{file} header argument and the directory specified using the
18031 @samp{output-dir} header arguments.  If @samp{output-dir} is not specified,
18032 Org assumes it is the current directory.
18034 @example
18035 #+BEGIN_SRC asymptote :results value file :file circle.pdf :output-dir img/
18036   size(2cm);
18037   draw(unitcircle);
18038 #+END_SRC
18039 @end example
18041 @cindex @samp{file-ext}, header argument
18042 If @samp{file} is missing, Org generates the base name of the output
18043 file from the name of the code block, and its extension from the
18044 @samp{file-ext} header argument.  In that case, both the name and the
18045 extension are mandatory.
18047 @example
18048 #+name: circle
18049 #+BEGIN_SRC asymptote :results value file :file-ext pdf
18050   size(2cm);
18051   draw(unitcircle);
18052 #+END_SRC
18053 @end example
18055 @cindex @samp{file-desc}, header argument
18056 The @samp{file-desc} header argument defines the description (see
18057 @ref{Link Format}) for the link.  If @samp{file-desc} has no value, Org
18058 uses the generated file name for both the ``link'' and
18059 ``description'' parts of the link.
18060 @end table
18062 @anchor{Format}
18063 @subheading Format
18065 Format pertains to the type of the result returned by the code block.
18066 Choose one of the options; they are mutually exclusive.  The default
18067 follows from the type specified above.
18069 @table @asis
18070 @item @samp{code}
18071 Result enclosed in a code block.  Useful for parsing.  Usage
18072 example: @samp{:results value code}.
18074 @item @samp{drawer}
18075 Result wrapped in a @samp{RESULTS} drawer.  Useful for containing
18076 @samp{raw} or @samp{org} results for later scripting and automated
18077 processing.  Usage example: @samp{:results value drawer}.
18079 @item @samp{html}
18080 Results enclosed in a @samp{BEGIN_EXPORT html} block.  Usage example:
18081 @samp{:results value html}.
18083 @item @samp{latex}
18084 Results enclosed in a @samp{BEGIN_EXPORT latex} block.  Usage example:
18085 @samp{:results value latex}.
18087 @item @samp{link}
18088 @itemx @samp{graphics}
18089 Result is a link to the file specified in @samp{:file} header
18090 argument.  However, unlike plain @samp{:file}, nothing is written to
18091 the disk.  The block is used for its side-effects only, as in the
18092 following example:
18094 @example
18095 #+begin_src shell :results link :file "download.tar.gz"
18096 wget -c "http://example.com/download.tar.gz"
18097 #+end_src
18098 @end example
18100 @item @samp{org}
18101 Results enclosed in a @samp{BEGIN_SRC org} block.  For comma-escape,
18102 either @kbd{@key{TAB}} in the block, or export the file.  Usage
18103 example: @samp{:results value org}.
18105 @item @samp{pp}
18106 Result converted to pretty-print source code.  Enclosed in a code
18107 block.  Languages supported: Emacs Lisp, Python, and Ruby.  Usage
18108 example: @samp{:results value pp}.
18110 @item @samp{raw}
18111 Interpreted as raw Org mode.  Inserted directly into the buffer.
18112 Aligned if it is a table.  Usage example: @samp{:results value raw}.
18113 @end table
18115 @anchor{Handling}
18116 @subheading Handling
18118 Handling options after collecting the results.
18120 @table @asis
18121 @item @samp{silent}
18122 Do not insert results in the Org mode buffer, but echo them in
18123 the minibuffer.  Usage example: @samp{:results output silent}.
18125 @item @samp{replace}
18126 Default.  Insert results in the Org buffer.  Remove previous
18127 results.  Usage example: @samp{:results output replace}.
18129 @item @samp{append}
18130 Append results to the Org buffer.  Latest results are at the
18131 bottom.  Does not remove previous results.  Usage example:
18132 @samp{:results output append}.
18134 @item @samp{prepend}
18135 Prepend results to the Org buffer.  Latest results are at the
18136 top.  Does not remove previous results.  Usage example: @samp{:results
18137      output prepend}.
18138 @end table
18140 @anchor{Post-processing}
18141 @subheading Post-processing
18143 @cindex @samp{post}, header argument
18144 @cindex @samp{*this*}, in @samp{post} header argument
18145 The @samp{post} header argument is for post-processing results from block
18146 evaluation.  When @samp{post} has any value, Org binds the results to
18147 @code{*this*} variable for easy passing to @samp{var} header argument
18148 specifications (see @ref{Environment of a Code Block}).  That makes results
18149 available to other code blocks, or even for direct Emacs Lisp code
18150 execution.
18152 The following two examples illustrate @samp{post} header argument in
18153 action.  The first one shows how to attach an @samp{ATTR_LATEX} keyword
18154 using @samp{post}.
18156 @example
18157 #+NAME: attr_wrap
18158 #+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output
18159   echo "#+ATTR_LATEX: :width $width"
18160   echo "$data"
18161 #+END_SRC
18163 #+HEADER: :file /tmp/it.png
18164 #+BEGIN_SRC dot :post attr_wrap(width="5cm", data=*this*) :results drawer
18165   digraph@{
18166           a -> b;
18167           b -> c;
18168           c -> a;
18169   @}
18170 #+end_src
18172 #+RESULTS:
18173 :RESULTS:
18174 #+ATTR_LATEX :width 5cm
18175 [[file:/tmp/it.png]]
18176 :END:
18177 @end example
18179 The second example shows use of @samp{colnames} header argument in @samp{post}
18180 to pass data between code blocks.
18182 @example
18183 #+NAME: round-tbl
18184 #+BEGIN_SRC emacs-lisp :var tbl="" fmt="%.3f"
18185   (mapcar (lambda (row)
18186             (mapcar (lambda (cell)
18187                       (if (numberp cell)
18188                           (format fmt cell)
18189                         cell))
18190                     row))
18191           tbl)
18192 #+end_src
18194 #+BEGIN_SRC R :colnames yes :post round-tbl[:colnames yes](*this*)
18195   set.seed(42)
18196   data.frame(foo=rnorm(1))
18197 #+END_SRC
18199 #+RESULTS:
18200 |   foo |
18201 |-------|
18202 | 1.371 |
18203 @end example
18205 @node Exporting Code Blocks
18206 @section Exporting Code Blocks
18208 @cindex code block, exporting
18209 @cindex source code, exporting
18211 It is possible to export the @emph{code} of code blocks, the @emph{results} of
18212 code block evaluation, @emph{both} the code and the results of code block
18213 evaluation, or @emph{none}.  Org defaults to exporting @emph{code} for most
18214 languages.  For some languages, such as ditaa, Org defaults to
18215 @emph{results}.  To export just the body of code blocks, see @ref{Literal Examples}.  To selectively export sub-trees of an Org document, see
18216 @ref{Exporting}.
18218 @cindex @samp{export}, header argument
18219 The @samp{exports} header argument is to specify if that part of the Org
18220 file is exported to, say, HTML or @LaTeX{} formats.
18222 @table @asis
18223 @item @samp{code}
18224 The default.  The body of code is included into the exported
18225 file.  Example: @samp{:exports code}.
18227 @item @samp{results}
18228 The results of evaluation of the code is included in the exported
18229 file.  Example: @samp{:exports results}.
18231 @item @samp{both}
18232 Both the code and results of evaluation are included in the
18233 exported file.  Example: @samp{:exports both}.
18235 @item @samp{none}
18236 Neither the code nor the results of evaluation is included in the
18237 exported file.  Whether the code is evaluated at all depends on
18238 other options.  Example: @samp{:exports none}.
18239 @end table
18241 @vindex org-export-use-babel
18242 To stop Org from evaluating code blocks to speed exports, use the
18243 header argument @samp{:eval never-export} (see @ref{Evaluating Code Blocks}).
18244 To stop Org from evaluating code blocks for greater security, set the
18245 @code{org-export-use-babel} variable to @code{nil}, but understand that header
18246 arguments will have no effect.
18248 Turning off evaluation comes in handy when batch processing.  For
18249 example, markup languages for wikis, which have a high risk of
18250 untrusted code.  Stopping code block evaluation also stops evaluation
18251 of all header arguments of the code block.  This may not be desirable
18252 in some circumstances.  So during export, to allow evaluation of just
18253 the header arguments but not any code evaluation in the source block,
18254 set @samp{:eval never-export} (see @ref{Evaluating Code Blocks}).
18256 Org never evaluates code blocks in commented sub-trees when exporting
18257 (see @ref{Comment Lines}).  On the other hand, Org does evaluate code
18258 blocks in sub-trees excluded from export (see @ref{Export Settings}).
18260 @node Extracting Source Code
18261 @section Extracting Source Code
18263 @cindex tangling
18264 @cindex source code, extracting
18265 @cindex code block, extracting source code
18267 Extracting source code from code blocks is a basic task in literate
18268 programming.  Org has features to make this easy.  In literate
18269 programming parlance, documents on creation are @emph{woven} with code and
18270 documentation, and on export, the code is tangled for execution by
18271 a computer.  Org facilitates weaving and tangling for producing,
18272 maintaining, sharing, and exporting literate programming documents.
18273 Org provides extensive customization options for extracting source
18274 code.
18276 When Org tangles code blocks, it expands, merges, and transforms them.
18277 Then Org recomposes them into one or more separate files, as
18278 configured through the options.  During this tangling process, Org
18279 expands variables in the source code, and resolves any Noweb style
18280 references (see @ref{Noweb Reference Syntax}).
18282 @anchor{Header arguments}
18283 @subheading Header arguments
18285 @cindex @samp{tangle}, header argument
18286 The @samp{tangle} header argument specifies if the code block is exported
18287 to source file(s).
18289 @table @asis
18290 @item @samp{yes}
18291 Export the code block to source file.  The file name for the
18292 source file is derived from the name of the Org file, and the
18293 file extension is derived from the source code language
18294 identifier.  Example: @samp{:tangle yes}.
18296 @item @samp{no}
18297 The default.  Do not extract the code in a source code file.
18298 Example: @samp{:tangle no}.
18300 @item @var{FILENAME}
18301 Export the code block to source file whose file name is derived
18302 from any string passed to the @samp{tangle} header argument.  Org
18303 derives the file name as being relative to the directory of the
18304 Org file's location.  Example: @samp{:tangle FILENAME}.
18305 @end table
18307 @cindex @samp{mkdirp}, header argument
18308 The @samp{mkdirp} header argument creates parent directories for tangled
18309 files if the directory does not exist.  @samp{yes} enables directory
18310 creation and @samp{no} inhibits directory creation.
18312 @cindex @samp{comments}, header argument
18313 The @samp{comments} header argument controls inserting comments into
18314 tangled files.  These are above and beyond whatever comments may
18315 already exist in the code block.
18317 @table @asis
18318 @item @samp{no}
18319 The default.  Do not insert any extra comments during tangling.
18321 @item @samp{link}
18322 Wrap the code block in comments.  Include links pointing back to
18323 the place in the Org file from where the code was tangled.
18325 @item @samp{yes}
18326 Kept for backward compatibility; same as @samp{link}.
18328 @item @samp{org}
18329 Nearest headline text from Org file is inserted as comment.  The
18330 exact text that is inserted is picked from the leading context of
18331 the source block.
18333 @item @samp{both}
18334 Includes both @samp{link} and @samp{org} options.
18336 @item @samp{noweb}
18337 Includes @samp{link} option, expands Noweb references (see @ref{Noweb Reference Syntax}), and wraps them in link comments inside the
18338 body of the code block.
18339 @end table
18341 @cindex @samp{padline}, header argument
18342 The @samp{padline} header argument controls insertion of newlines to pad
18343 source code in the tangled file.
18345 @table @asis
18346 @item @samp{yes}
18347 Default.  Insert a newline before and after each code block in
18348 the tangled file.
18350 @item @samp{no}
18351 Do not insert newlines to pad the tangled code blocks.
18352 @end table
18354 @cindex @samp{shebang}, header argument
18355 The @samp{shebang} header argument can turn results into executable script
18356 files.  By setting it to a string value---for example, @samp{:shebang
18357 "#!/bin/bash"}---Org inserts that string as the first line of the
18358 tangled file that the code block is extracted to.  Org then turns on
18359 the tangled file's executable permission.
18361 @cindex @samp{no-expand}, header argument
18362 By default Org expands code blocks during tangling.  The @samp{no-expand}
18363 header argument turns off such expansions.  Note that one side-effect
18364 of expansion by @code{org-babel-expand-src-block} also assigns values (see
18365 @ref{Environment of a Code Block}) to variables.  Expansions also replace
18366 Noweb references with their targets (see @ref{Noweb Reference Syntax}).
18367 Some of these expansions may cause premature assignment, hence this
18368 option.  This option makes a difference only for tangling.  It has no
18369 effect when exporting since code blocks for execution have to be
18370 expanded anyway.
18372 @anchor{Functions}
18373 @subheading Functions
18375 @table @asis
18376 @item @code{org-babel-tangle}
18377 @findex org-babel-tangle
18378 @kindex C-c C-v t
18379 Tangle the current file.  Bound to @kbd{C-c C-v t}.
18381 With prefix argument only tangle the current code block.
18383 @item @code{org-babel-tangle-file}
18384 @findex org-babel-tangle-file
18385 @kindex C-c C-v f
18386 Choose a file to tangle.  Bound to @kbd{C-c C-v f}.
18387 @end table
18389 @anchor{Hooks (1)}
18390 @subheading Hooks
18392 @table @asis
18393 @item @code{org-babel-post-tangle-hook}
18394 @vindex org-babel-post-tangle-hook
18395 This hook is run from within code files tangled by
18396 @code{org-babel-tangle}, making it suitable for post-processing,
18397 compilation, and evaluation of code in the tangled files.
18398 @end table
18400 @anchor{Jumping between code and Org}
18401 @subheading Jumping between code and Org
18403 @findex org-babel-tangle-jump-to-org
18404 Debuggers normally link errors and messages back to the source code.
18405 But for tangled files, we want to link back to the Org file, not to
18406 the tangled source file.  To make this extra jump, Org uses
18407 @code{org-babel-tangle-jump-to-org} function with two additional source
18408 code block header arguments:
18410 @enumerate
18411 @item
18412 Set @samp{padline} to true---this is the default setting.
18413 @item
18414 Set @samp{comments} to @samp{link}, which makes Org insert links to the Org
18415 file.
18416 @end enumerate
18418 @node Languages
18419 @section Languages
18421 @cindex babel, languages
18422 @cindex source code, languages
18423 @cindex code block, languages
18425 Code blocks in the following languages are supported.
18427 @multitable {aaaaaaaaaa} {aaaaaaaaaaaa} {aaaaaaaaaaaaaa} {aaaaaaaaaaaa}
18428 @headitem Language
18429 @tab Identifier
18430 @tab Language
18431 @tab Identifier
18432 @item Asymptote
18433 @tab @samp{asymptote}
18434 @tab Lua
18435 @tab @samp{lua}
18436 @item Awk
18437 @tab @samp{awk}
18438 @tab MATLAB
18439 @tab @samp{matlab}
18440 @item C
18441 @tab @samp{C}
18442 @tab Mscgen
18443 @tab @samp{mscgen}
18444 @item C++
18445 @tab @samp{C++}
18446 @tab Objective Caml
18447 @tab @samp{ocaml}
18448 @item Clojure
18449 @tab @samp{clojure}
18450 @tab Octave
18451 @tab @samp{octave}
18452 @item CSS
18453 @tab @samp{css}
18454 @tab Org mode
18455 @tab @samp{org}
18456 @item D
18457 @tab @samp{d}
18458 @tab Oz
18459 @tab @samp{oz}
18460 @item ditaa
18461 @tab @samp{ditaa}
18462 @tab Perl
18463 @tab @samp{perl}
18464 @item Emacs Calc
18465 @tab @samp{calc}
18466 @tab Plantuml
18467 @tab @samp{plantuml}
18468 @item Emacs Lisp
18469 @tab @samp{emacs-lisp}
18470 @tab Processing.js
18471 @tab @samp{processing}
18472 @item Fortran
18473 @tab @samp{fortran}
18474 @tab Python
18475 @tab @samp{python}
18476 @item Gnuplot
18477 @tab @samp{gnuplot}
18478 @tab R
18479 @tab @samp{R}
18480 @item GNU Screen
18481 @tab @samp{screen}
18482 @tab Ruby
18483 @tab @samp{ruby}
18484 @item Graphviz
18485 @tab @samp{dot}
18486 @tab Sass
18487 @tab @samp{sass}
18488 @item Haskell
18489 @tab @samp{haskell}
18490 @tab Scheme
18491 @tab @samp{scheme}
18492 @item Java
18493 @tab @samp{java}
18494 @tab Sed
18495 @tab @samp{sed}
18496 @item Javascript
18497 @tab @samp{js}
18498 @tab shell
18499 @tab @samp{sh}
18500 @item @LaTeX{}
18501 @tab @samp{latex}
18502 @tab SQL
18503 @tab @samp{sql}
18504 @item Ledger
18505 @tab @samp{ledger}
18506 @tab SQLite
18507 @tab @samp{sqlite}
18508 @item Lilypond
18509 @tab @samp{lilypond}
18510 @tab Vala
18511 @tab @samp{vala}
18512 @item Lisp
18513 @tab @samp{lisp}
18514 @tab 
18515 @tab 
18516 @end multitable
18518 Additional documentation for some languages is at
18519 @uref{https://orgmode.org/worg/org-contrib/babel/languages.html}.
18521 @vindex org-babel-load-languages
18522 By default, only Emacs Lisp is enabled for evaluation.  To enable or
18523 disable other languages, customize the @code{org-babel-load-languages}
18524 variable either through the Emacs customization interface, or by
18525 adding code to the init file as shown next.
18527 In this example, evaluation is disabled for Emacs Lisp, and enabled
18528 for R.
18530 @lisp
18531 (org-babel-do-load-languages
18532  'org-babel-load-languages
18533  '((emacs-lisp . nil)
18534    (R . t)))
18535 @end lisp
18537 Note that this is not the only way to enable a language.  Org also
18538 enables languages when loaded with @code{require} statement.  For example,
18539 the following enables execution of Clojure code blocks:
18541 @lisp
18542 (require 'ob-clojure)
18543 @end lisp
18545 @node Editing Source Code
18546 @section Editing Source Code
18548 @cindex code block, editing
18549 @cindex source code, editing
18551 @kindex C-c '
18552 Use @kbd{C-c '} to edit the current code block.  It opens a new
18553 major-mode edit buffer containing the body of the source code block,
18554 ready for any edits.  Use @kbd{C-c '} again to close the buffer
18555 and return to the Org buffer.
18557 @kindex C-x C-s
18558 @vindex org-edit-src-auto-save-idle-delay
18559 @cindex auto-save, in code block editing
18560 @kbd{C-x C-s} saves the buffer and updates the contents of the
18561 Org buffer.  Set @code{org-edit-src-auto-save-idle-delay} to save the base
18562 buffer after a certain idle delay time.  Set
18563 @code{org-edit-src-turn-on-auto-save} to auto-save this buffer into
18564 a separate file using Auto-save mode.
18566 While editing the source code in the major mode, the Org Src minor
18567 mode remains active.  It provides these customization variables as
18568 described below.  For even more variables, look in the customization
18569 group @code{org-edit-structure}.
18571 @table @asis
18572 @item @code{org-src-lang-modes}
18573 @vindex org-src-lang-modes
18574 If an Emacs major-mode named @code{<LANG>-mode} exists, where
18575 @var{<LANG>} is the language identifier from code block's
18576 header line, then the edit buffer uses that major mode.  Use this
18577 variable to arbitrarily map language identifiers to major modes.
18579 @item @code{org-src-window-setup}
18580 @vindex org-src-window-setup
18581 For specifying Emacs window arrangement when the new edit buffer
18582 is created.
18584 @item @code{org-src-preserve-indentation}
18585 @cindex indentation, in code blocks
18586 @vindex org-src-preserve-indentation
18587 Default is @code{nil}.  Source code is indented.  This indentation
18588 applies during export or tangling, and depending on the context,
18589 may alter leading spaces and tabs.  When non-@code{nil}, source code
18590 is aligned with the leftmost column.  No lines are modified
18591 during export or tangling, which is very useful for white-space
18592 sensitive languages, such as Python.
18594 @item @code{org-src-ask-before-returning-to-edit-buffer}
18595 @vindex org-src-ask-before-returning-to-edit-buffer
18596 When @code{nil}, Org returns to the edit buffer without further
18597 prompts.  The default prompts for a confirmation.
18598 @end table
18600 @vindex org-src-fontify-natively
18601 @vindex org-src-block-faces
18602 Set @code{org-src-fontify-natively} to non-@code{nil} to turn on native code
18603 fontification in the @emph{Org} buffer.  Fontification of code blocks can
18604 give visual separation of text and code on the display page.  To
18605 further customize the appearance of @code{org-block} for specific
18606 languages, customize @code{org-src-block-faces}.  The following example
18607 shades the background of regular blocks, and colors source blocks only
18608 for Python and Emacs Lisp languages.
18610 @lisp
18611 (require 'color)
18612 (set-face-attribute 'org-block nil :background
18613                     (color-darken-name
18614                      (face-attribute 'default :background) 3))
18616 (setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF"))
18617                             ("python" (:background "#E5FFB8"))))
18618 @end lisp
18620 @node Noweb Reference Syntax
18621 @section Noweb Reference Syntax
18623 @cindex code block, Noweb reference
18624 @cindex syntax, Noweb
18625 @cindex source code, Noweb reference
18627 Org supports named blocks in Noweb@footnote{For Noweb literate programming details, see
18628 @uref{http://www.cs.tufts.edu/~nr/noweb/}.} style syntax:
18630 @example
18631 <<CODE-BLOCK-ID>>
18632 @end example
18634 Org can replace the construct with the source code, or the results of
18635 evaluation, of the code block identified as @var{CODE-BLOCK-ID}.
18637 @cindex @samp{noweb}, header argument
18638 The @samp{noweb} header argument controls expansion of Noweb syntax
18639 references.  Expansions occur when source code blocks are evaluated,
18640 tangled, or exported.
18642 @table @asis
18643 @item @samp{no}
18644 Default.  No expansion of Noweb syntax references in the body of
18645 the code when evaluating, tangling, or exporting.
18647 @item @samp{yes}
18648 Expansion of Noweb syntax references in the body of the code
18649 block when evaluating, tangling, or exporting.
18651 @item @samp{tangle}
18652 Expansion of Noweb syntax references in the body of the code
18653 block when tangling.  No expansion when evaluating or exporting.
18655 @item @samp{no-export}
18656 Expansion of Noweb syntax references in the body of the code
18657 block when evaluating or tangling.  No expansion when exporting.
18659 @item @samp{strip-export}
18660 Expansion of Noweb syntax references in the body of the code
18661 block when expanding prior to evaluating or tangling.  Removes
18662 Noweb syntax references when exporting.
18664 @item @samp{eval}
18665 Expansion of Noweb syntax references in the body of the code
18666 block only before evaluating.
18667 @end table
18669 In the following example,
18671 @example
18672 #+NAME: initialization
18673 #+BEGIN_SRC emacs-lisp
18674   (setq sentence "Never a foot too far, even.")
18675 #+END_SRC
18677 #+BEGIN_SRC emacs-lisp :noweb yes
18678   <<initialization>>
18679   (reverse sentence)
18680 #+END_SRC
18681 @end example
18683 @noindent
18684 the second code block is expanded as
18686 @example
18687 #+BEGIN_SRC emacs-lisp :noweb yes
18688   (setq sentence "Never a foot too far, even.")
18689   (reverse sentence)
18690 #+END_SRC
18691 @end example
18693 Noweb insertions honor prefix characters that appear before the Noweb
18694 syntax reference.  This behavior is illustrated in the following
18695 example.  Because the @samp{<<example>>} Noweb reference appears behind the
18696 SQL comment syntax, each line of the expanded Noweb reference is
18697 commented.  With:
18699 @example
18700 #+NAME: example
18701 #+BEGIN_SRC text
18702   this is the
18703   multi-line body of example
18704 #+END_SRC
18705 @end example
18707 @noindent
18708 this code block:
18710 @example
18711 #+BEGIN_SRC sql :noweb yes
18712  ---<<example>>
18713 #+END_SRC
18714 @end example
18716 @noindent
18717 expands to:
18719 @example
18720 #+BEGIN_SRC sql :noweb yes
18721  ---this is the
18722  ---multi-line body of example
18723 #+END_SRC
18724 @end example
18726 Since this change does not affect Noweb replacement text without
18727 newlines in them, inline Noweb references are acceptable.
18729 This feature can also be used for management of indentation in
18730 exported code snippets.  With:
18732 @example
18733 #+NAME: if-true
18734 #+BEGIN_SRC python :exports none
18735   print('do things when true')
18736 #+end_src
18738 #+name: if-false
18739 #+begin_src python :exports none
18740   print('do things when false')
18741 #+end_src
18742 @end example
18744 @noindent
18745 this code block:
18747 @example
18748 #+begin_src python :noweb yes :results output
18749   if true:
18750       <<if-true>>
18751   else:
18752       <<if-false>>
18753 #+end_src
18754 @end example
18756 @noindent
18757 expands to:
18759 @example
18760 if true:
18761     print('do things when true')
18762 else:
18763     print('do things when false')
18764 @end example
18766 @cindex @samp{noweb-ref}, header argument
18767 When expanding Noweb style references, Org concatenates code blocks by
18768 matching the reference name to either the code block name or, if none
18769 is found, to the @samp{noweb-ref} header argument.
18771 For simple concatenation, set this @samp{noweb-ref} header argument at the
18772 sub-tree or file level.  In the example Org file shown next, the body
18773 of the source code in each block is extracted for concatenation to
18774 a pure code file when tangled.
18776 @example
18777 #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
18778   <<fullest-disk>>
18779 #+END_SRC
18780 * the mount point of the fullest disk
18781   :PROPERTIES:
18782   :header-args: :noweb-ref fullest-disk
18783   :END:
18785 ** query all mounted disks
18786 #+BEGIN_SRC sh
18787   df \
18788 #+END_SRC
18790 ** strip the header row
18791 #+BEGIN_SRC sh
18792   |sed '1d' \
18793 #+END_SRC
18795 ** output mount point of fullest disk
18796 #+BEGIN_SRC sh
18797   |awk '@{if (u < +$5) @{u = +$5; m = $6@}@} END @{print m@}'
18798 #+END_SRC
18799 @end example
18801 @cindex @samp{noweb-sep}, header argument
18802 By default a newline separates each noweb reference concatenation.  To
18803 change this newline separator, edit the @samp{noweb-sep} header argument.
18805 Eventually, Org can include the results of a code block rather than
18806 its body.  To that effect, append parentheses, possibly including
18807 arguments, to the code block name, as shown below.
18809 @example
18810 <<code-block-name(optional arguments)>>
18811 @end example
18813 Note that when using the above approach to a code block's results, the
18814 code block name set by @samp{NAME} keyword is required; the reference set
18815 by @samp{noweb-ref} does not work in that case.
18817 Here is an example that demonstrates how the exported content changes
18818 when Noweb style references are used with parentheses versus without.
18819 With:
18821 @example
18822 #+NAME: some-code
18823 #+BEGIN_SRC python :var num=0 :results output :exports none
18824   print(num*10)
18825 #+END_SRC
18826 @end example
18828 @noindent
18829 this code block:
18831 @example
18832 #+BEGIN_SRC text :noweb yes
18833   <<some-code>>
18834 #+END_SRC
18835 @end example
18837 @noindent
18838 expands to:
18840 @example
18841 print(num*10)
18842 @end example
18844 Below, a similar Noweb style reference is used, but with parentheses,
18845 while setting a variable @samp{num} to 10:
18847 @example
18848 #+BEGIN_SRC text :noweb yes
18849   <<some-code(num=10)>>
18850 #+END_SRC
18851 @end example
18853 @noindent
18854 Note that now the expansion contains the results of the code block
18855 @samp{some-code}, not the code block itself:
18857 @example
18859 @end example
18861 @node Library of Babel
18862 @section Library of Babel
18864 @cindex babel, library of
18865 @cindex source code, library
18866 @cindex code block, library
18868 The ``Library of Babel'' is a collection of code blocks.  Like
18869 a function library, these code blocks can be called from other Org
18870 files.  A collection of useful code blocks is available on @uref{https://orgmode.org/worg/library-of-babel.html, Worg}.  For
18871 remote code block evaluation syntax, see @ref{Evaluating Code Blocks}.
18873 @kindex C-c C-v i
18874 @findex org-babel-lob-ingest
18875 For any user to add code to the library, first save the code in
18876 regular code blocks of an Org file, and then load the Org file with
18877 @code{org-babel-lob-ingest}, which is bound to @kbd{C-c C-v i}.
18879 @node Key bindings and Useful Functions
18880 @section Key bindings and Useful Functions
18882 @cindex code block, key bindings
18884 Many common Org mode key sequences are re-bound depending on
18885 the context.
18887 Active key bindings in code blocks:
18889 @kindex C-c C-c
18890 @findex org-babel-execute-src-block
18891 @kindex C-c C-o
18892 @findex org-babel-open-src-block-result
18893 @kindex M-UP
18894 @findex org-babel-load-in-session
18895 @kindex M-DOWN
18896 @findex org-babel-pop-to-session
18897 @multitable @columnfractions 0.2 0.55
18898 @headitem Key binding
18899 @tab Function
18900 @item @kbd{C-c C-c}
18901 @tab @code{org-babel-execute-src-block}
18902 @item @kbd{C-c C-o}
18903 @tab @code{org-babel-open-src-block-result}
18904 @item @kbd{M-@key{UP}}
18905 @tab @code{org-babel-load-in-session}
18906 @item @kbd{M-@key{DOWN}}
18907 @tab @code{org-babel-pop-to-session}
18908 @end multitable
18910 Active key bindings in Org mode buffer:
18912 @kindex C-c C-v p
18913 @kindex C-c C-v C-p
18914 @kindex C-c C-v n
18915 @kindex C-c C-v C-n
18916 @kindex C-c C-v e
18917 @kindex C-c C-v C-e
18918 @kindex C-c C-v o
18919 @kindex C-c C-v C-o
18920 @kindex C-c C-v v
18921 @kindex C-c C-v C-v
18922 @kindex C-c C-v u
18923 @kindex C-c C-v C-u
18924 @kindex C-c C-v g
18925 @kindex C-c C-v C-g
18926 @kindex C-c C-v r
18927 @kindex C-c C-v C-r
18928 @kindex C-c C-v b
18929 @kindex C-c C-v C-b
18930 @kindex C-c C-v s
18931 @kindex C-c C-v C-s
18932 @kindex C-c C-v d
18933 @kindex C-c C-v C-d
18934 @kindex C-c C-v t
18935 @kindex C-c C-v C-t
18936 @kindex C-c C-v f
18937 @kindex C-c C-v C-f
18938 @kindex C-c C-v c
18939 @kindex C-c C-v C-c
18940 @kindex C-c C-v j
18941 @kindex C-c C-v C-j
18942 @kindex C-c C-v l
18943 @kindex C-c C-v C-l
18944 @kindex C-c C-v i
18945 @kindex C-c C-v C-i
18946 @kindex C-c C-v I
18947 @kindex C-c C-v C-I
18948 @kindex C-c C-v z
18949 @kindex C-c C-v C-z
18950 @kindex C-c C-v a
18951 @kindex C-c C-v C-a
18952 @kindex C-c C-v h
18953 @kindex C-c C-v C-h
18954 @kindex C-c C-v x
18955 @kindex C-c C-v C-x
18956 @findex org-babel-previous-src-block
18957 @findex org-babel-next-src-block
18958 @findex org-babel-execute-maybe
18959 @findex org-babel-open-src-block-result
18960 @findex org-babel-expand-src-block
18961 @findex org-babel-goto-src-block-head
18962 @findex org-babel-goto-named-src-block
18963 @findex org-babel-goto-named-result
18964 @findex org-babel-execute-buffer
18965 @findex org-babel-execute-subtree
18966 @findex org-babel-demarcate-block
18967 @findex org-babel-tangle
18968 @findex org-babel-tangle-file
18969 @findex org-babel-check-src-block
18970 @findex org-babel-insert-header-arg
18971 @findex org-babel-load-in-session
18972 @findex org-babel-lob-ingest
18973 @findex org-babel-view-src-block-info
18974 @findex org-babel-switch-to-session-with-code
18975 @findex org-babel-sha1-hash
18976 @findex org-babel-describe-bindings
18977 @findex org-babel-do-key-sequence-in-edit-buffer
18978 @multitable @columnfractions 0.45 0.55
18979 @headitem Key binding
18980 @tab Function
18981 @item @kbd{C-c C-v p} or @kbd{C-c C-v C-p}
18982 @tab @code{org-babel-previous-src-block}
18983 @item @kbd{C-c C-v n} or @kbd{C-c C-v C-n}
18984 @tab @code{org-babel-next-src-block}
18985 @item @kbd{C-c C-v e} or @kbd{C-c C-v C-e}
18986 @tab @code{org-babel-execute-maybe}
18987 @item @kbd{C-c C-v o} or @kbd{C-c C-v C-o}
18988 @tab @code{org-babel-open-src-block-result}
18989 @item @kbd{C-c C-v v} or @kbd{C-c C-v C-v}
18990 @tab @code{org-babel-expand-src-block}
18991 @item @kbd{C-c C-v u} or @kbd{C-c C-v C-u}
18992 @tab @code{org-babel-goto-src-block-head}
18993 @item @kbd{C-c C-v g} or @kbd{C-c C-v C-g}
18994 @tab @code{org-babel-goto-named-src-block}
18995 @item @kbd{C-c C-v r} or @kbd{C-c C-v C-r}
18996 @tab @code{org-babel-goto-named-result}
18997 @item @kbd{C-c C-v b} or @kbd{C-c C-v C-b}
18998 @tab @code{org-babel-execute-buffer}
18999 @item @kbd{C-c C-v s} or @kbd{C-c C-v C-s}
19000 @tab @code{org-babel-execute-subtree}
19001 @item @kbd{C-c C-v d} or @kbd{C-c C-v C-d}
19002 @tab @code{org-babel-demarcate-block}
19003 @item @kbd{C-c C-v t} or @kbd{C-c C-v C-t}
19004 @tab @code{org-babel-tangle}
19005 @item @kbd{C-c C-v f} or @kbd{C-c C-v C-f}
19006 @tab @code{org-babel-tangle-file}
19007 @item @kbd{C-c C-v c} or @kbd{C-c C-v C-c}
19008 @tab @code{org-babel-check-src-block}
19009 @item @kbd{C-c C-v j} or @kbd{C-c C-v C-j}
19010 @tab @code{org-babel-insert-header-arg}
19011 @item @kbd{C-c C-v l} or @kbd{C-c C-v C-l}
19012 @tab @code{org-babel-load-in-session}
19013 @item @kbd{C-c C-v i} or @kbd{C-c C-v C-i}
19014 @tab @code{org-babel-lob-ingest}
19015 @item @kbd{C-c C-v I} or @kbd{C-c C-v C-I}
19016 @tab @code{org-babel-view-src-block-info}
19017 @item @kbd{C-c C-v z} or @kbd{C-c C-v C-z}
19018 @tab @code{org-babel-switch-to-session-with-code}
19019 @item @kbd{C-c C-v a} or @kbd{C-c C-v C-a}
19020 @tab @code{org-babel-sha1-hash}
19021 @item @kbd{C-c C-v h} or @kbd{C-c C-v C-h}
19022 @tab @code{org-babel-describe-bindings}
19023 @item @kbd{C-c C-v x} or @kbd{C-c C-v C-x}
19024 @tab @code{org-babel-do-key-sequence-in-edit-buffer}
19025 @end multitable
19027 @node Batch Execution
19028 @section Batch Execution
19030 @cindex code block, batch execution
19031 @cindex source code, batch execution
19033 Org mode features, including working with source code facilities can
19034 be invoked from the command line.  This enables building shell scripts
19035 for batch processing, running automated system tasks, and expanding
19036 Org mode's usefulness.
19038 The sample script shows batch processing of multiple files using
19039 @code{org-babel-tangle}.
19041 @example
19042 #!/bin/sh
19043 # Tangle files with Org mode
19045 emacs -Q --batch --eval "
19046     (progn
19047       (require 'ob-tangle)
19048       (dolist (file command-line-args-left)
19049         (with-current-buffer (find-file-noselect file)
19050           (org-babel-tangle))))
19051   " "$@@"
19052 @end example
19054 @node Miscellaneous
19055 @chapter Miscellaneous
19057 @menu
19058 * Completion::                   M-@key{TAB} guesses completions.
19059 * Structure Templates::          Quick insertion of structural elements.
19060 * Speed Keys::                   Electric commands at the beginning of a headline.
19061 * Code Evaluation Security::     Org files evaluate in-line code.
19062 * Customization::                Adapting Org to your taste.
19063 * In-buffer Settings::           Overview of keywords.
19064 * The Very Busy @kbd{C-c C-c} Key:: When in doubt, press @kbd{C-c C-c}.
19065 * Clean View::                   Getting rid of leading stars in the outline.
19066 * TTY Keys::                     Using Org on a tty.
19067 * Interaction::                  With other Emacs packages.
19068 * Org Crypt::                    Encrypting Org files.
19069 @end menu
19071 @node Completion
19072 @section Completion
19074 @cindex completion, of @TeX{} symbols
19075 @cindex completion, of TODO keywords
19076 @cindex completion, of dictionary words
19077 @cindex completion, of option keywords
19078 @cindex completion, of tags
19079 @cindex completion, of property keys
19080 @cindex completion, of link abbreviations
19081 @cindex @TeX{} symbol completion
19082 @cindex TODO keywords completion
19083 @cindex dictionary word completion
19084 @cindex option keyword completion
19085 @cindex tag completion
19086 @cindex link abbreviations, completion of
19088 Org has in-buffer completions.  Unlike minibuffer completions, which
19089 are useful for quick command interactions, Org's in-buffer completions
19090 are more suitable for content creation in Org documents.  Type one or
19091 more letters and invoke the hot key to complete the text in-place.
19092 Depending on the context and the keys, Org offers different types of
19093 completions.  No minibuffer is involved.  Such mode-specific hot keys
19094 have become an integral part of Emacs and Org provides several
19095 shortcuts.
19097 @table @asis
19098 @item @kbd{M-@key{TAB}}
19099 @kindex M-TAB
19101 Complete word at point.
19103 @itemize
19104 @item
19105 At the beginning of a headline, complete TODO keywords.
19107 @item
19108 After @samp{\}, complete @TeX{} symbols supported by the exporter.
19110 @item
19111 After @samp{*}, complete headlines in the current buffer so that
19112 they can be used in search links like:
19114 @example
19115 [[*find this headline]]
19116 @end example
19118 @item
19119 After @samp{:} in a headline, complete tags.  Org deduces the list
19120 of tags from the @samp{TAGS} in-buffer option (see @ref{Setting Tags}),
19121 the variable @code{org-tag-alist}, or from all tags used in the
19122 current buffer.
19124 @item
19125 After @samp{:} and not in a headline, complete property keys.  The
19126 list of keys is constructed dynamically from all keys used in
19127 the current buffer.
19129 @item
19130 After @samp{[}, complete link abbreviations (see @ref{Link Abbreviations}).
19132 @item
19133 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
19134 file-specific @samp{OPTIONS}.  After option keyword is complete,
19135 pressing @kbd{M-@key{TAB}} again inserts example settings for
19136 this keyword.
19138 @item
19139 After @samp{STARTUP} keyword, complete startup items.
19141 @item
19142 When point is anywhere else, complete dictionary words using
19143 Ispell.
19144 @end itemize
19145 @end table
19147 @node Structure Templates
19148 @section Structure Templates
19150 @cindex template insertion
19151 @cindex insertion, of templates
19153 With just a few keystrokes, it is possible to insert empty structural
19154 blocks, such as @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}, or to wrap existing
19155 text in such a block.
19157 @table @asis
19158 @item @kbd{C-c C-,} (@code{org-insert-structure-template})
19159 @findex org-insert-structure-template
19160 @kindex C-c C-,
19161 Prompt for a type of block structure, and insert the block at
19162 point.  If the region is active, it is wrapped in the block.
19163 First prompts the user for keys, which are used to look up
19164 a structure type from the variable below.  If the key is
19165 @kbd{@key{TAB}}, @kbd{@key{RET}}, or @kbd{@key{SPC}}, the user is
19166 prompted to enter a block type.
19167 @end table
19169 @vindex org-structure-template-alist
19170 Available structure types are defined in
19171 @code{org-structure-template-alist}, see the docstring for adding or
19172 changing values.
19174 @cindex Tempo
19175 @cindex template expansion
19176 @cindex insertion, of templates
19177 @vindex org-tempo-keywords-alist
19178 Org Tempo expands snippets to structures defined in
19179 @code{org-structure-template-alist} and @code{org-tempo-keywords-alist}.  For
19180 example, @kbd{< s @key{TAB}} creates a code block.  Enable it by
19181 customizing @code{org-modules} or add @code{(require 'org-tempo)} to your Emacs
19182 init file@footnote{For more information, please refer to the commentary section
19183 in @samp{org-tempo.el}.}.
19186 @multitable @columnfractions 0.1 0.9
19187 @item @kbd{a}
19188 @tab @samp{#+BEGIN_EXPORT ascii} @dots{} @samp{#+END_EXPORT}
19189 @item @kbd{c}
19190 @tab @samp{#+BEGIN_CENTER} @dots{} @samp{#+END_CENTER}
19191 @item @kbd{C}
19192 @tab @samp{#+BEGIN_COMMENT} @dots{} @samp{#+END_COMMENT}
19193 @item @kbd{e}
19194 @tab @samp{#+BEGIN_EXAMPLE} @dots{} @samp{#+END_EXAMPLE}
19195 @item @kbd{h}
19196 @tab @samp{#+BEGIN_EXPORT html} @dots{} @samp{#+END_EXPORT}
19197 @item @kbd{l}
19198 @tab @samp{#+BEGIN_EXPORT latex} @dots{} @samp{#+END_EXPORT}
19199 @item @kbd{q}
19200 @tab @samp{#+BEGIN_QUOTE} @dots{} @samp{#+END_QUOTE}
19201 @item @kbd{s}
19202 @tab @samp{#+BEGIN_SRC} @dots{} @samp{#+END_SRC}
19203 @item @kbd{v}
19204 @tab @samp{#+BEGIN_VERSE} @dots{} @samp{#+END_VERSE}
19205 @end multitable
19207 @node Speed Keys
19208 @section Speed Keys
19210 @cindex speed keys
19212 Single keystrokes can execute custom commands in an Org file when the
19213 cursor is on a headline.  Without the extra burden of a meta or
19214 modifier key, Speed Keys can speed navigation or execute custom
19215 commands.  Besides faster navigation, Speed Keys may come in handy on
19216 small mobile devices that do not have full keyboards.  Speed Keys may
19217 also work on TTY devices known for their problems when entering Emacs
19218 key chords.
19220 @vindex org-use-speed-commands
19221 By default, Org has Speed Keys disabled.  To activate Speed Keys, set
19222 the variable @code{org-use-speed-commands} to a non-@code{nil} value.  To
19223 trigger a Speed Key, the cursor must be at the beginning of an Org
19224 headline, before any of the stars.
19226 @vindex org-speed-commands-user
19227 @findex org-speed-command-help
19228 Org comes with a pre-defined list of Speed Keys.  To add or modify
19229 Speed Keys, customize the variable, @code{org-speed-commands-user}.  For
19230 more details, see the variable's docstring.  With Speed Keys
19231 activated, @kbd{M-x org-speed-command-help}, or @kbd{?} when
19232 cursor is at the beginning of an Org headline, shows currently active
19233 Speed Keys, including the user-defined ones.
19235 @node Code Evaluation Security
19236 @section Code Evaluation and Security Issues
19238 Unlike plain text, running code comes with risk.  Each @samp{src} code
19239 block, in terms of risk, is equivalent to an executable file.  Org
19240 therefore puts a few confirmation prompts by default.  This is to
19241 alert the casual user from accidentally running untrusted code.
19243 For users who do not run code blocks or write code regularly, Org's
19244 default settings should suffice.  However, some users may want to
19245 tweak the prompts for fewer interruptions.  To weigh the risks of
19246 automatic execution of code blocks, here are some details about code
19247 evaluation.
19249 Org evaluates code in the following circumstances:
19251 @table @asis
19252 @item @emph{Source code blocks}
19253 Org evaluates @samp{src} code blocks in an Org file during export.
19254 Org also evaluates a @samp{src} code block with the @kbd{C-c C-c}
19255 key chord.  Users exporting or running code blocks must load
19256 files only from trusted sources.  Be wary of customizing
19257 variables that remove or alter default security measures.
19259 @defopt org-confirm-babel-evaluate
19260 When @code{t}, Org prompts the user for confirmation before executing
19261 each code block.  When @code{nil}, Org executes code blocks without
19262 prompting the user for confirmation.  When this option is set to
19263 a custom function, Org invokes the function with these two
19264 arguments: the source code language and the body of the code
19265 block.  The custom function must return either a @code{t} or @code{nil},
19266 which determines if the user is prompted.  Each source code
19267 language can be handled separately through this function
19268 argument.
19269 @end defopt
19271 For example, here is how to execute ditaa code blocks without
19272 prompting:
19274 @lisp
19275 (defun my-org-confirm-babel-evaluate (lang body)
19276   (not (string= lang "ditaa")))  ;don't ask for ditaa
19277 (setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
19278 @end lisp
19280 @item @emph{Following @samp{shell} and @samp{elisp} links}
19281 Org has two link types that can directly evaluate code (see
19282 @ref{External Links}).  Because such code is not visible, these links
19283 have a potential risk.  Org therefore prompts the user when it
19284 encounters such links.  The customization variables are:
19286 @defopt org-confirm-shell-link-function
19287 Function that prompts the user before executing a shell link.
19288 @end defopt
19290 @defopt org-confirm-elisp-link-function
19291 Function that prompts the user before executing an Emacs Lisp link.
19292 @end defopt
19294 @item @emph{Formulas in tables}
19295 Formulas in tables (see @ref{The spreadsheet}) are code that is
19296 evaluated either by the Calc interpreter, or by the Emacs Lisp
19297 interpreter.
19298 @end table
19300 @node Customization
19301 @section Customization
19303 @cindex customization
19304 @cindex options, for customization
19305 @cindex variables, for customization
19307 Org has more than 500 variables for customization.  They can be
19308 accessed through the usual @kbd{M-x org-customize} command.  Or
19309 through the Org menu: Org @arrow{} Customization @arrow{} Browse Org Group.
19311 Org also has per-file settings for some variables (see @ref{In-buffer Settings}).
19313 @node In-buffer Settings
19314 @section Summary of In-Buffer Settings
19316 @cindex in-buffer settings
19317 @cindex special keywords
19319 In-buffer settings start with @samp{#+}, followed by a keyword, a colon,
19320 and then a word for each setting.  Org accepts multiple settings on
19321 the same line.  Org also accepts multiple lines for a keyword.  This
19322 manual describes these settings throughout.  A summary follows here.
19324 @cindex refresh set-up
19325 @kbd{C-c C-c} activates any changes to the in-buffer settings.
19326 Closing and reopening the Org file in Emacs also activates the
19327 changes.
19329 @table @asis
19330 @item @samp{#+ARCHIVE: %s_done}
19331 @cindex @samp{ARCHIVE}, keyword
19332 @vindex org-archive-location
19333 Sets the archive location of the agenda file.  The corresponding
19334 variable is @code{org-archive-location}.
19336 @item @samp{#+CATEGORY}
19337 @cindex @samp{CATEGORY}, keyword
19338 Sets the category of the agenda file, which applies to the entire
19339 document.
19341 @item @samp{#+COLUMNS: %25ITEM ...}
19342 @cindex @samp{COLUMNS}, property
19343 Set the default format for columns view.  This format applies
19344 when columns view is invoked in locations where no @samp{COLUMNS}
19345 property applies.
19347 @item @samp{#+CONSTANTS: name1=value1 ...}
19348 @cindex @samp{CONSTANTS}, keyword
19349 @vindex org-table-formula-constants
19350 @vindex org-table-formula
19351 Set file-local values for constants that table formulas can use.
19352 This line sets the local variable
19353 @code{org-table-formula-constants-local}.  The global version of this
19354 variable is @code{org-table-formula-constants}.
19356 @item @samp{#+FILETAGS: :tag1:tag2:tag3:}
19357 @cindex @samp{FILETAGS}, keyword
19358 Set tags that all entries in the file inherit from, including the
19359 top-level entries.
19361 @item @samp{#+LINK: linkword replace}
19362 @cindex @samp{LINK}, keyword
19363 @vindex org-link-abbrev-alist
19364 Each line specifies one abbreviation for one link.  Use multiple
19365 @samp{LINK} keywords for more, see @ref{Link Abbreviations}.  The
19366 corresponding variable is @code{org-link-abbrev-alist}.
19368 @item @samp{#+PRIORITIES: highest lowest default}
19369 @cindex @samp{PRIORITIES}, keyword
19370 @vindex org-highest-priority
19371 @vindex org-lowest-priority
19372 @vindex org-default-priority
19373 This line sets the limits and the default for the priorities.
19374 All three must be either letters A--Z or numbers 0--9.  The
19375 highest priority must have a lower ASCII number than the lowest
19376 priority.
19378 @item @samp{#+PROPERTY: Property_Name Value}
19379 @cindex @samp{PROPERTY}, keyword
19380 This line sets a default inheritance value for entries in the
19381 current buffer, most useful for specifying the allowed values of
19382 a property.
19384 @item @samp{#+SETUPFILE: file}
19385 @cindex @samp{SETUPFILE}, keyword
19386 The setup file or a URL pointing to such file is for additional
19387 in-buffer settings.  Org loads this file and parses it for any
19388 settings in it only when Org opens the main file.  If URL is
19389 specified, the contents are downloaded and stored in a temporary
19390 file cache.  @kbd{C-c C-c} on the settings line parses and
19391 loads the file, and also resets the temporary file cache.  Org
19392 also parses and loads the document during normal exporting
19393 process.  Org parses the contents of this document as if it was
19394 included in the buffer.  It can be another Org file.  To visit
19395 the file---not a URL---use @kbd{C-c '} while the cursor is
19396 on the line with the file name.
19398 @item @samp{#+STARTUP:}
19399 @cindex @samp{STARTUP}, keyword
19400 Startup options Org uses when first visiting a file.
19402 @vindex org-startup-folded
19403 The first set of options deals with the initial visibility of the
19404 outline tree.  The corresponding variable for global default
19405 settings is @code{org-startup-folded} with a default value of @code{t},
19406 which is the same as @code{overview}.
19408 @table @asis
19409 @item @samp{overview}
19410 Top-level headlines only.
19412 @item @samp{content}
19413 All headlines.
19415 @item @samp{showall}
19416 No folding on any entry.
19418 @item @samp{showeverything}
19419 Show even drawer contents.
19420 @end table
19422 @vindex org-startup-indented
19423 Dynamic virtual indentation is controlled by the variable
19424 @code{org-startup-indented}.@footnote{Note that @code{org-indent-mode} also sets the @code{wrap-prefix}
19425 property, such that @code{visual-line-mode} (or purely setting @code{word-wrap})
19426 wraps long lines (including headlines) correctly indented.}
19428 @table @asis
19429 @item @samp{indent}
19430 Start with @code{org-indent-mode} turned on.
19432 @item @samp{noindent}
19433 Start with @code{org-indent-mode} turned off.
19434 @end table
19436 @vindex org-startup-align-all-tables
19437 Aligns tables consistently upon visiting a file.  The corresponding
19438 variable is @code{org-startup-align-all-tables} with @code{nil} as default
19439 value.
19441 @table @asis
19442 @item @samp{align}
19443 Align all tables.
19445 @item @samp{noalign}
19446 Do not align tables on startup.
19447 @end table
19449 @vindex org-startup-shrink-all-tables
19450 Shrink table columns with a width cookie.  The corresponding
19451 variable is @code{org-startup-shrink-all-tables} with @code{nil} as default
19452 value.
19454 @vindex org-startup-with-inline-images
19455 When visiting a file, inline images can be automatically displayed.
19456 The corresponding variable is @code{org-startup-with-inline-images},
19457 with a default value @code{nil} to avoid delays when visiting a file.
19459 @table @asis
19460 @item @samp{inlineimages}
19461 Show inline images.
19463 @item @samp{noinlineimages}
19464 Do not show inline images on startup.
19465 @end table
19467 @vindex org-log-done
19468 @vindex org-log-note-clock-out
19469 @vindex org-log-repeat
19470 Logging the closing and reopening of TODO items and clock
19471 intervals can be configured using these options (see variables
19472 @code{org-log-done}, @code{org-log-note-clock-out}, and @code{org-log-repeat}).
19474 @table @asis
19475 @item @samp{logdone}
19476 Record a timestamp when an item is marked DONE.
19478 @item @samp{lognotedone}
19479 Record timestamp and a note when DONE.
19481 @item @samp{nologdone}
19482 Do not record when items are marked DONE.
19484 @item @samp{logrepeat}
19485 Record a time when reinstating a repeating item.
19487 @item @samp{lognoterepeat}
19488 Record a note when reinstating a repeating item.
19490 @item @samp{nologrepeat}
19491 Do not record when reinstating repeating item.
19493 @item @samp{lognoteclock-out}
19494 Record a note when clocking out.
19496 @item @samp{nolognoteclock-out}
19497 Do not record a note when clocking out.
19499 @item @samp{logreschedule}
19500 Record a timestamp when scheduling time changes.
19502 @item @samp{lognotereschedule}
19503 Record a note when scheduling time changes.
19505 @item @samp{nologreschedule}
19506 Do not record when a scheduling date changes.
19508 @item @samp{logredeadline}
19509 Record a timestamp when deadline changes.
19511 @item @samp{lognoteredeadline}
19512 Record a note when deadline changes.
19514 @item @samp{nologredeadline}
19515 Do not record when a deadline date changes.
19517 @item @samp{logrefile}
19518 Record a timestamp when refiling.
19520 @item @samp{lognoterefile}
19521 Record a note when refiling.
19523 @item @samp{nologrefile}
19524 Do not record when refiling.
19525 @end table
19527 @vindex org-hide-leading-stars
19528 @vindex org-odd-levels-only
19529 Here are the options for hiding leading stars in outline headings,
19530 and for indenting outlines.  The corresponding variables are
19531 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with
19532 a default setting @code{nil} (meaning @samp{showstars} and @samp{oddeven}).
19534 @table @asis
19535 @item @samp{hidestars}
19536 Make all but one of the stars starting a headline invisible.
19538 @item @samp{showstars}
19539 Show all stars starting a headline.
19541 @item @samp{indent}
19542 Virtual indentation according to outline level.
19544 @item @samp{noindent}
19545 No virtual indentation according to outline level.
19547 @item @samp{odd}
19548 Allow only odd outline levels (1, 3, @dots{}).
19550 @item @samp{oddeven}
19551 Allow all outline levels.
19552 @end table
19554 @vindex org-put-time-stamp-overlays
19555 @vindex org-time-stamp-overlay-formats
19556 To turn on custom format overlays over timestamps (variables
19557 @code{org-put-time-stamp-overlays} and @code{org-time-stamp-overlay-formats}),
19558 use:
19560 @table @asis
19561 @item @samp{customtime}
19562 Overlay custom time format.
19563 @end table
19565 @vindex constants-unit-system
19566 The following options influence the table spreadsheet (variable
19567 @code{constants-unit-system}).
19569 @table @asis
19570 @item @samp{constcgs}
19571 @samp{constants.el} should use the c-g-s unit system.
19573 @item @samp{constSI}
19574 @samp{constants.el} should use the SI unit system.
19575 @end table
19577 @vindex org-footnote-define-inline
19578 @vindex org-footnote-auto-label
19579 @vindex org-footnote-auto-adjust
19580 To influence footnote settings, use the following keywords.  The
19581 corresponding variables are @code{org-footnote-define-inline},
19582 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
19584 @table @asis
19585 @item @samp{fninline}
19586 Define footnotes inline.
19588 @item @samp{fnnoinline}
19589 Define footnotes in separate section.
19591 @item @samp{fnlocal}
19592 Define footnotes near first reference, but not inline.
19594 @item @samp{fnprompt}
19595 Prompt for footnote labels.
19597 @item @samp{fnauto}
19598 Create @samp{[fn:1]}-like labels automatically (default).
19600 @item @samp{fnconfirm}
19601 Offer automatic label for editing or confirmation.
19603 @item @samp{fnadjust}
19604 Automatically renumber and sort footnotes.
19606 @item @samp{nofnadjust}
19607 Do not renumber and sort automatically.
19608 @end table
19610 @vindex org-hide-block-startup
19611 To hide blocks on startup, use these keywords.  The corresponding
19612 variable is @code{org-hide-block-startup}.
19614 @table @asis
19615 @item @samp{hideblocks}
19616 Hide all begin/end blocks on startup.
19618 @item @samp{nohideblocks}
19619 Do not hide blocks on startup.
19620 @end table
19622 @vindex org-pretty-entities
19623 The display of entities as UTF-8 characters is governed by the
19624 variable @code{org-pretty-entities} and the keywords
19626 @table @asis
19627 @item @samp{entitiespretty}
19628 Show entities as UTF-8 characters where possible.
19630 @item @samp{entitiesplain}
19631 Leave entities plain.
19632 @end table
19634 @item @samp{#+TAGS: TAG1(c1) TAG2(c2)}
19635 @cindex @samp{TAGS}, keyword
19636 @vindex org-tag-alist
19637 These lines (several such lines are allowed) specify the valid
19638 tags in this file, and (potentially) the corresponding @emph{fast tag
19639 selection} keys.  The corresponding variable is @code{org-tag-alist}.
19641 @item @samp{#+TODO:}
19642 @itemx @samp{#+SEQ_TODO:}
19643 @itemx @samp{#+TYP_TODO:}
19644 @cindex @samp{SEQ_TODO}, keyword
19645 @cindex @samp{TODO}, keyword
19646 @cindex @samp{TYP_TODO}, keyword
19647 @vindex org-todo-keywords
19648 These lines set the TODO keywords and their interpretation in the
19649 current file.  The corresponding variable is @code{org-todo-keywords}.
19650 @end table
19652 @node The Very Busy @kbd{C-c C-c} Key
19653 @section The Very Busy @kbd{C-c C-c} Key
19655 @kindex C-c C-c
19656 @cindex @kbd{C-c C-c}, overview
19658 The @kbd{C-c C-c} key in Org serves many purposes depending on
19659 the context.  It is probably the most over-worked, multi-purpose key
19660 combination in Org.  Its uses are well documented throughout this
19661 manual, but here is a consolidated list for easy reference.
19663 @itemize
19664 @item
19665 If any highlights shown in the buffer from the creation of a sparse
19666 tree, or from clock display, remove such highlights.
19668 @item
19669 If the cursor is in one of the special @samp{KEYWORD} lines, scan the
19670 buffer for these lines and update the information.  Also reset the
19671 Org file cache used to temporary store the contents of URLs used as
19672 values for keywords like @samp{SETUPFILE}.
19674 @item
19675 If the cursor is inside a table, realign the table.  The table
19676 realigns even if automatic table editor is turned off.
19678 @item
19679 If the cursor is on a @samp{TBLFM} keyword, re-apply the formulas to the
19680 entire table.
19682 @item
19683 If the current buffer is a capture buffer, close the note and file
19684 it.  With a prefix argument, also jump to the target location after
19685 saving the note.
19687 @item
19688 If the cursor is on a @samp{<<<target>>>}, update radio targets and
19689 corresponding links in this buffer.
19691 @item
19692 If the cursor is on a property line or at the start or end of
19693 a property drawer, offer property commands.
19695 @item
19696 If the cursor is at a footnote reference, go to the corresponding
19697 definition, and @emph{vice versa}.
19699 @item
19700 If the cursor is on a statistics cookie, update it.
19702 @item
19703 If the cursor is in a plain list item with a checkbox, toggle the
19704 status of the checkbox.
19706 @item
19707 If the cursor is on a numbered item in a plain list, renumber the
19708 ordered list.
19710 @item
19711 If the cursor is on the @samp{#+BEGIN} line of a dynamic block, the block
19712 is updated.
19714 @item
19715 If the cursor is at a timestamp, fix the day name in the timestamp.
19716 @end itemize
19718 @node Clean View
19719 @section A Cleaner Outline View
19721 @cindex hiding leading stars
19722 @cindex dynamic indentation
19723 @cindex odd-levels-only outlines
19724 @cindex clean outline view
19726 Org's default outline with stars and no indents can become too
19727 cluttered for short documents.  For @emph{book-like} long documents, the
19728 effect is not as noticeable.  Org provides an alternate stars and
19729 indentation scheme, as shown on the right in the following table.  It
19730 uses only one star and indents text to line with the heading:
19732 @example
19733 * Top level headline             |    * Top level headline
19734 ** Second level                  |      * Second level
19735 *** Third level                  |        * Third level
19736     some text                    |          some text
19737 *** Third level                  |        * Third level
19738     more text                    |          more text
19739 * Another top level headline     |    * Another top level headline
19740 @end example
19742 @noindent
19743 @cindex Indent mode
19744 @findex org-indent-mode
19745 To turn this mode on, use the minor mode, @code{org-indent-mode}.  Text
19746 lines that are not headlines are prefixed with spaces to vertically
19747 align with the headline text@footnote{The @code{org-indent-mode} also sets the @code{wrap-prefix} correctly
19748 for indenting and wrapping long lines of headlines or text.  This
19749 minor mode handles @code{visual-line-mode} and directly applied settings
19750 through @code{word-wrap}.}.
19752 @vindex org-indent-indentation-per-level
19753 To make more horizontal space, the headlines are shifted by two stars.
19754 This can be configured by the @code{org-indent-indentation-per-level}
19755 variable.  Only one star on each headline is visible, the rest are
19756 masked with the same font color as the background.
19758 Note that turning on @code{org-indent-mode} sets @code{org-hide-leading-stars}
19759 to @code{t} and @code{org-adapt-indentation} to @code{nil}.
19761 @vindex org-startup-indented
19762 To globally turn on @code{org-indent-mode} for all files, customize the
19763 variable @code{org-startup-indented}.
19765 To turn on indenting for individual files, use @samp{STARTUP} keyword as
19766 follows:
19768 @example
19769 #+STARTUP: indent
19770 @end example
19772 Indent on startup makes Org use hard spaces to align text with
19773 headings as shown in examples below.
19775 @table @asis
19776 @item @emph{Indentation of text below headlines}
19777 Indent text to align with the headline.
19779 @example
19780 *** Third level
19781     more text, now indented
19782 @end example
19784 @vindex org-adapt-indentation
19785 Org supports this with paragraph filling, line wrapping, and
19786 structure editing, preserving or adapting the indentation as
19787 appropriate@footnote{Also see the variable @code{org-adapt-indentation}.}.
19789 @item @emph{Hiding leading stars}
19790 @vindex org-hide-leading-stars
19791 Org can make leading stars invisible.  For global preference,
19792 configure the variable @code{org-hide-leading-stars}.  For per-file
19793 preference, use these file @samp{STARTUP} options:
19795 @example
19796 #+STARTUP: hidestars
19797 #+STARTUP: showstars
19798 @end example
19800 With stars hidden, the tree is shown as:
19802 @example
19803 * Top level headline
19804  * Second level
19805   * Third level
19806   ...
19807 @end example
19809 @noindent
19810 @vindex org-hide, face
19811 Because Org makes the font color the same as the background color
19812 to hide to stars, sometimes @code{org-hide} face may need tweaking to
19813 get the effect right.  For some black and white combinations,
19814 @code{grey90} on a white background might mask the stars better.
19816 @item @emph{Odd levels}
19817 @vindex org-odd-levels-only
19818 Using stars for only odd levels, 1, 3, 5, @dots{}, can also clean up
19819 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
19820 on.}.
19821 For Org to properly handle this cleaner structure during edits
19822 and exports, configure the variable @code{org-odd-levels-only}.  To
19823 set this per-file, use either one of the following lines:
19825 @example
19826 #+STARTUP: odd
19827 #+STARTUP: oddeven
19828 @end example
19830 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}.
19831 @end table
19833 @node TTY Keys
19834 @section Using Org on a TTY
19836 @cindex tty key bindings
19838 Org provides alternative key bindings for TTY and modern mobile
19839 devices that cannot handle cursor keys and complex modifier key
19840 chords.  Some of these workarounds may be more cumbersome than
19841 necessary.  Users should look into customizing these further based on
19842 their usage needs.  For example, the normal @kbd{S-<cursor>} for
19843 editing timestamp might be better with @kbd{C-c .} chord.
19845 @multitable @columnfractions 0.2 0.28 0.15 0.21
19846 @headitem Default
19847 @tab Alternative 1
19848 @tab Speed key
19849 @tab Alternative 2
19850 @item @kbd{S-@key{TAB}}
19851 @tab @kbd{C-u @key{TAB}}
19852 @tab @kbd{C}
19853 @tab 
19854 @item @kbd{M-@key{LEFT}}
19855 @tab @kbd{C-c C-x l}
19856 @tab @kbd{l}
19857 @tab @kbd{Esc @key{LEFT}}
19858 @item @kbd{M-S-@key{LEFT}}
19859 @tab @kbd{C-c C-x L}
19860 @tab @kbd{L}
19861 @tab 
19862 @item @kbd{M-@key{RIGHT}}
19863 @tab @kbd{C-c C-x r}
19864 @tab @kbd{r}
19865 @tab @kbd{Esc @key{RIGHT}}
19866 @item @kbd{M-S-@key{RIGHT}}
19867 @tab @kbd{C-c C-x R}
19868 @tab @kbd{R}
19869 @tab 
19870 @item @kbd{M-@key{UP}}
19871 @tab @kbd{C-c C-x u}
19872 @tab 
19873 @tab @kbd{Esc @key{UP}}
19874 @item @kbd{M-S-@key{UP}}
19875 @tab @kbd{C-c C-x U}
19876 @tab @kbd{U}
19877 @tab 
19878 @item @kbd{M-@key{DOWN}}
19879 @tab @kbd{C-c C-x d}
19880 @tab 
19881 @tab @kbd{Esc @key{DOWN}}
19882 @item @kbd{M-S-@key{DOWN}}
19883 @tab @kbd{C-c C-x D}
19884 @tab @kbd{D}
19885 @tab 
19886 @item @kbd{S-@key{RET}}
19887 @tab @kbd{C-c C-x c}
19888 @tab 
19889 @tab 
19890 @item @kbd{M-@key{RET}}
19891 @tab @kbd{C-c C-x m}
19892 @tab 
19893 @tab @kbd{Esc @key{RET}}
19894 @item @kbd{M-S-@key{RET}}
19895 @tab @kbd{C-c C-x M}
19896 @tab 
19897 @tab 
19898 @item @kbd{S-@key{LEFT}}
19899 @tab @kbd{C-c @key{LEFT}}
19900 @tab 
19901 @tab 
19902 @item @kbd{S-@key{RIGHT}}
19903 @tab @kbd{C-c @key{RIGHT}}
19904 @tab 
19905 @tab 
19906 @item @kbd{S-@key{UP}}
19907 @tab @kbd{C-c @key{UP}}
19908 @tab 
19909 @tab 
19910 @item @kbd{S-@key{DOWN}}
19911 @tab @kbd{C-c @key{DOWN}}
19912 @tab 
19913 @tab 
19914 @item @kbd{C-S-@key{LEFT}}
19915 @tab @kbd{C-c C-x @key{LEFT}}
19916 @tab 
19917 @tab 
19918 @item @kbd{C-S-@key{RIGHT}}
19919 @tab @kbd{C-c C-x @key{RIGHT}}
19920 @tab 
19921 @tab 
19922 @end multitable
19924 @node Interaction
19925 @section Interaction with Other Packages
19927 @cindex packages, interaction with other
19929 Org's compatibility and the level of interaction with other Emacs
19930 packages are documented here.
19932 @menu
19933 * Cooperation::                  Packages Org cooperates with.
19934 * Conflicts::                    Packages that lead to conflicts.
19935 @end menu
19937 @node Cooperation
19938 @subsection Packages that Org cooperates with
19940 @table @asis
19941 @item @samp{calc.el} by Dave Gillespie
19942 @cindex @file{calc.el}
19944 Org uses the Calc package for implementing spreadsheet
19945 functionality in its tables (see @ref{The spreadsheet}).  Org also
19946 uses Calc for embedded calculations.  See @ref{Embedded Mode,GNU Emacs Calc Manual,,calc,}.
19948 @item @samp{constants.el} by Carsten Dominik
19949 @cindex @file{constants.el}
19950 @vindex org-table-formula-constants
19952 Org can use names for constants in formulas in tables.  Org can
19953 also use calculation suffixes for units, such as @samp{M} for @samp{Mega}.
19954 For a standard collection of such constants, install the
19955 @samp{constants} package.  Install version 2.0 of this package,
19956 available at @uref{http://www.astro.uva.nl/~dominik/Tools}.  Org checks
19957 if the function @code{constants-get} has been autoloaded.
19958 Installation instructions are in the file @samp{constants.el}.
19960 @item @samp{cdlatex.el} by Carsten Dominik
19961 @cindex @file{cdlatex.el}
19963 Org mode can make use of the CD@LaTeX{} package to efficiently enter
19964 @LaTeX{} fragments into Org files.  See @ref{CD@LaTeX{} mode}.
19966 @item @samp{imenu.el} by Ake Stenhoff and Lars Lindberg
19967 @cindex @file{imenu.el}
19969 Imenu creates dynamic menus based on an index of items in a file.
19970 Org mode supports Imenu menus.  Enable it with a mode hook as
19971 follows:
19973 @lisp
19974 (add-hook 'org-mode-hook
19975           (lambda () (imenu-add-to-menubar "Imenu")))
19976 @end lisp
19978 @vindex org-imenu-depth
19979 By default the index is two levels deep---you can modify the
19980 depth using the option @code{org-imenu-depth}.
19982 @item @samp{speedbar.el} by Eric M. Ludlam
19983 @cindex @file{speedbar.el}
19985 Speedbar package creates a special Emacs frame for displaying
19986 files and index items in files.  Org mode supports Speedbar;
19987 users can drill into Org files directly from the Speedbar.  The
19988 @kbd{<} in the Speedbar frame tweaks the agenda commands to
19989 that file or to a subtree.
19991 @item @samp{table.el} by Takaaki Ota
19992 @cindex table editor, @file{table.el}
19993 @cindex @file{table.el}
19995 Complex ASCII tables with automatic line wrapping, column- and
19996 row-spanning, and alignment can be created using the Emacs table
19997 package by Takaaki Ota.  Org mode recognizes such tables and
19998 exports them properly.  @kbd{C-c '} to edit these tables in
19999 a special buffer, much like Org's code blocks.  Because of
20000 interference with other Org mode functionality, Takaaki Ota
20001 tables cannot be edited directly in the Org buffer.
20003 @table @asis
20004 @item @kbd{C-c '} (@code{org-edit-special})
20005 @kindex C-c '
20006 @findex org-edit-special
20007 Edit a @samp{table.el} table.  Works when the cursor is in
20008 a @samp{table.el} table.
20010 @item @kbd{C-c ~​} (@code{org-table-create-with-table.el})
20011 @kindex C-c ~
20012 @findex org-table-create-with-table.el
20013 Insert a @samp{table.el} table.  If there is already a table at
20014 point, this command converts it between the @samp{table.el}
20015 format and the Org mode format.  See the documentation
20016 string of the command @code{org-convert-table} for the
20017 restrictions under which this is possible.
20018 @end table
20019 @end table
20021 @node Conflicts
20022 @subsection Packages that conflict with Org mode
20024 @cindex shift-selection-mode
20025 @vindex org-support-shift-select
20026 In Emacs, @code{shift-selection-mode} combines cursor motions with shift
20027 key to enlarge regions.  Emacs sets this mode by default.  This
20028 conflicts with Org's use of @kbd{S-<cursor>} commands to change
20029 timestamps, TODO keywords, priorities, and item bullet types, etc.
20030 Since @kbd{S-<cursor>} commands outside of specific contexts do
20031 not do anything, Org offers the variable @code{org-support-shift-select}
20032 for customization.  Org mode accommodates shift selection by (i)
20033 making it available outside of the special contexts where special
20034 commands apply, and (ii) extending an existing active region even if
20035 the cursor moves across a special context.
20037 @table @asis
20038 @item @samp{cua.el} by Kim. F. Storm
20039 @cindex @file{cua.el}
20040 @vindex org-replace-disputed-keys
20041 Org key bindings conflict with @kbd{S-<cursor>} keys used by
20042 CUA mode.  For Org to relinquish these bindings to CUA mode,
20043 configure the variable @code{org-replace-disputed-keys}.  When set,
20044 Org moves the following key bindings in Org files, and in the
20045 agenda buffer---but not during date selection.
20047 @multitable @columnfractions 0.4 0.4
20048 @item @kbd{S-@key{UP}}      @result{}  @kbd{M-p}
20049 @tab @kbd{S-@key{DOWN}}     @result{}  @kbd{M-n}
20050 @item @kbd{S-@key{LEFT}}    @result{}  @kbd{M--}
20051 @tab @kbd{S-@key{RIGHT}}    @result{}  @kbd{M-+}
20052 @item @kbd{C-S-@key{LEFT}}  @result{}  @kbd{M-S--}
20053 @tab @kbd{C-S-@key{RIGHT}}  @result{}  @kbd{M-S-+}
20054 @end multitable
20056 @vindex org-disputed-keys
20057 Yes, these are unfortunately more difficult to remember.  If you
20058 want to have other replacement keys, look at the variable
20059 @code{org-disputed-keys}.
20061 @item @samp{ecomplete.el} by Lars Magne Ingebrigtsen
20062 @cindex @file{ecomplete.el}
20063 Ecomplete provides ``electric'' address completion in address
20064 header lines in message buffers.  Sadly Orgtbl mode cuts
20065 Ecomplete's power supply: no completion happens when Orgtbl mode
20066 is enabled in message buffers while entering text in address
20067 header lines.  If one wants to use ecomplete one should @emph{not}
20068 follow the advice to automagically turn on Orgtbl mode in message
20069 buffers (see @ref{Orgtbl Mode}), but instead---after
20070 filling in the message headers---turn on Orgtbl mode manually
20071 when needed in the messages body.
20073 @item @samp{filladapt.el} by Kyle Jones
20074 @cindex @file{filladapt.el}
20075 Org mode tries to do the right thing when filling paragraphs,
20076 list items and other elements.  Many users reported problems
20077 using both @samp{filladapt.el} and Org mode, so a safe thing to do is
20078 to disable filladapt like this:
20080 @lisp
20081 (add-hook 'org-mode-hook 'turn-off-filladapt-mode)
20082 @end lisp
20084 @item @samp{viper.el} by Michael Kifer
20085 @cindex @file{viper.el}
20086 @kindex C-c /
20088 Viper uses @kbd{C-c /} and therefore makes this key not
20089 access the corresponding Org mode command @code{org-sparse-tree}.  You
20090 need to find another key for this command, or override the key in
20091 @code{viper-vi-global-user-map} with
20093 @lisp
20094 (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
20095 @end lisp
20097 @item @samp{windmove.el} by Hovav Shacham
20098 @cindex @file{windmove.el}
20100 This package also uses the @kbd{S-<cursor>} keys, so
20101 everything written in the paragraph above about CUA mode also
20102 applies here.  If you want to make the windmove function active
20103 in locations where Org mode does not have special functionality
20104 on @kbd{S-<cursor>}, add this to your configuration:
20106 @lisp
20107 ;; Make windmove work in Org mode:
20108 (add-hook 'org-shiftup-final-hook 'windmove-up)
20109 (add-hook 'org-shiftleft-final-hook 'windmove-left)
20110 (add-hook 'org-shiftdown-final-hook 'windmove-down)
20111 (add-hook 'org-shiftright-final-hook 'windmove-right)
20112 @end lisp
20114 @item @samp{yasnippet.el}
20115 @cindex @file{yasnippet.el}
20116 The way Org mode binds the @kbd{@key{TAB}} key (binding to @code{[tab]}
20117 instead of @code{"\t"}) overrules YASnippet's access to this key.  The
20118 following code fixed this problem:
20120 @lisp
20121 (add-hook 'org-mode-hook
20122           (lambda ()
20123             (setq-local yas/trigger-key [tab])
20124             (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
20125 @end lisp
20127 The latest version of YASnippet does not play well with Org mode.
20128 If the above code does not fix the conflict, start by defining
20129 the following function:
20131 @lisp
20132 (defun yas/org-very-safe-expand ()
20133   (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
20134 @end lisp
20136 Then, tell Org mode to use that function:
20138 @lisp
20139 (add-hook 'org-mode-hook
20140           (lambda ()
20141             (make-variable-buffer-local 'yas/trigger-key)
20142             (setq yas/trigger-key [tab])
20143             (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
20144             (define-key yas/keymap [tab] 'yas/next-field)))
20145 @end lisp
20146 @end table
20148 @node Org Crypt
20149 @section Org Crypt
20151 Org Crypt encrypts the text of an entry, but not the headline, or
20152 properties.  Behind the scene, it uses the Emacs EasyPG library to
20153 encrypt and decrypt files.
20155 @vindex org-crypt-tag-matcher
20156 Any text below a headline that has a @samp{crypt} tag is automatically
20157 encrypted when the file is saved.  To use a different tag, customize
20158 the @code{org-crypt-tag-matcher} setting.
20160 Here is a suggestion for Org Crypt settings in Emacs init file:
20162 @lisp
20163 (require 'org-crypt)
20164 (org-crypt-use-before-save-magic)
20165 (setq org-tags-exclude-from-inheritance '("crypt"))
20167 (setq org-crypt-key nil)
20168 ;; GPG key to use for encryption
20169 ;; Either the Key ID or set to nil to use symmetric encryption.
20171 (setq auto-save-default nil)
20172 ;; Auto-saving does not cooperate with org-crypt.el: so you need to
20173 ;; turn it off if you plan to use org-crypt.el quite often.  Otherwise,
20174 ;; you'll get an (annoying) message each time you start Org.
20176 ;; To turn it off only locally, you can insert this:
20178 ;; # -*- buffer-auto-save-file-name: nil; -*-
20179 @end lisp
20181 Excluding the @samp{crypt} tag from inheritance prevents already encrypted
20182 text from being encrypted again.
20184 @node Hacking
20185 @appendix Hacking
20187 @cindex hacking
20189 This appendix describes some ways a user can extend the functionality
20190 of Org.
20192 @menu
20193 * Hooks: Hooks (2).              How to reach into Org's internals.
20194 * Add-on Packages::              Available extensions.
20195 * Adding Hyperlink Types::       New custom link types.
20196 * Adding Export Back-ends::      How to write new export back-ends.
20197 * Tables in Arbitrary Syntax::   Orgtbl for LaTeX and other programs.
20198 * Dynamic Blocks::               Automatically filled blocks.
20199 * Special Agenda Views::         Customized views.
20200 * Speeding Up Your Agendas::     Tips on how to speed up your agendas.
20201 * Extracting Agenda Information:: Post-processing agenda information.
20202 * Using the Property API::       Writing programs that use entry properties.
20203 * Using the Mapping API::        Mapping over all or selected entries.
20204 @end menu
20206 @node Hooks (2)
20207 @appendixsec Hooks
20209 @cindex hooks
20211 Org has a large number of hook variables for adding functionality.
20212 This appendix illustrates using a few.  A complete list of hooks with
20213 documentation is maintained by the Worg project at
20214 @uref{https://orgmode.org/worg/doc.html#hooks}.
20216 @node Add-on Packages
20217 @appendixsec Add-on Packages
20219 @cindex add-on packages
20221 Various authors wrote a large number of add-on packages for Org.
20223 These packages are not part of Emacs, but they are distributed as
20224 contributed packages with the separate release available at
20225 @uref{https://orgmode.org}.  See the @samp{contrib/README} file in the source code
20226 directory for a list of contributed files.  Worg page with more
20227 information is at: @uref{https://orgmode.org/worg/org-contrib/}.
20229 @node Adding Hyperlink Types
20230 @appendixsec Adding Hyperlink Types
20232 @cindex hyperlinks, adding new types
20234 Org has many built-in hyperlink types (see @ref{Hyperlinks}), and an
20235 interface for adding new link types.  The following example shows the
20236 process of adding Org links to Unix man pages, which look like this
20238 @example
20239 [[man:printf][The printf manual]]
20240 @end example
20242 @noindent
20243 The following @samp{org-man.el} file implements it
20245 @lisp
20246 ;;; org-man.el - Support for links to man pages in Org mode
20247 (require 'org)
20249 (org-link-set-parameters "man"
20250                          :follow org-man-command
20251                          :export #'org-man-export
20252                          :store #'org-man-store-link)
20254 (defcustom org-man-command 'man
20255   "The Emacs command to be used to display a man page."
20256   :group 'org-link
20257   :type '(choice (const man) (const woman)))
20259 (defun org-man-store-link ()
20260   "Store a link to a man page."
20261   (when (memq major-mode '(Man-mode woman-mode))
20262     ;; This is a man page, we do make this link.
20263     (let* ((page (org-man-get-page-name))
20264            (link (concat "man:" page))
20265            (description (format "Man page for %s" page)))
20266       (org-store-link-props
20267        :type "man"
20268        :link link
20269        :description description))))
20271 (defun org-man-get-page-name ()
20272   "Extract the page name from the buffer name."
20273   ;; This works for both `Man-mode' and `woman-mode'.
20274   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
20275       (match-string 1 (buffer-name))
20276     (error "Cannot create link to this man page")))
20278 (defun org-man-export (link description format)
20279   "Export a man page link from Org files."
20280   (let ((path (format "http://man.he.net/?topic=%s&section=all" link))
20281         (desc (or description link)))
20282     (pcase format
20283       (`html (format "<a target=\"_blank\" href=\"%s\">%s</a>" path desc))
20284       (`latex (format "\\href@{%s@}@{%s@}" path desc))
20285       (`texinfo (format "@@uref@{%s,%s@}" path desc))
20286       (`ascii (format "%s (%s)" desc path))
20287       (t path))))
20289 (provide 'org-man)
20290 ;;; org-man.el ends here
20291 @end lisp
20293 @noindent
20294 To activate links to man pages in Org, enter this in the Emacs init
20295 file:
20297 @lisp
20298 (require 'org-man)
20299 @end lisp
20301 @noindent
20302 A review of @samp{org-man.el}:
20304 @enumerate
20305 @item
20306 First, @code{(require 'org)} ensures @samp{org.el} is loaded.
20308 @item
20309 @findex org-link-set-parameters
20310 @vindex org-link-parameters
20311 Then @code{org-link-set-parameters} defines a new link type with @samp{man}
20312 prefix and associates functions for following, exporting and
20313 storing such links.  See the variable @code{org-link-parameters} for
20314 a complete list of possible associations.
20316 @item
20317 The rest of the file implements necessary variables and functions.
20319 For example, @code{org-man-store-link} is responsible for storing a link
20320 when @code{org-store-link} (see @ref{Handling Links}) is called from a buffer
20321 displaying a man page.  It first checks if the @code{major-mode} is
20322 appropriate.  If check fails, the function returns @code{nil}, which
20323 means it isn't responsible for creating a link to the current
20324 buffer.  Otherwise the function makes a link string by combining
20325 the @samp{man:} prefix with the man topic.  It also provides a default
20326 description.  The function @code{org-insert-link} can insert it back
20327 into an Org buffer later on.
20328 @end enumerate
20330 @node Adding Export Back-ends
20331 @appendixsec Adding Export Back-ends
20333 @cindex Export, writing back-ends
20335 Org's export engine makes it easy for writing new back-ends.  The
20336 framework on which the engine was built makes it easy to derive new
20337 back-ends from existing ones.
20339 @findex org-export-define-backend
20340 @findex org-export-define-derived-backend
20341 The two main entry points to the export engine are:
20342 @code{org-export-define-backend} and @code{org-export-define-derived-backend}.
20343 To grok these functions, see @samp{ox-latex.el} for an example of defining
20344 a new back-end from scratch, and @samp{ox-beamer.el} for an example of
20345 deriving from an existing engine.
20347 For creating a new back-end from scratch, first set its name as
20348 a symbol in an alist consisting of elements and export functions.  To
20349 make the back-end visible to the export dispatcher, set @code{:menu-entry}
20350 keyword.  For export options specific to this back-end, set the
20351 @code{:options-alist}.
20353 For creating a new back-end from an existing one, set
20354 @code{:translate-alist} to an alist of export functions.  This alist
20355 replaces the parent back-end functions.
20357 For complete documentation, see @uref{https://orgmode.org/worg/dev/org-export-reference.html, the Org Export Reference on Worg}.
20359 @node Tables in Arbitrary Syntax
20360 @appendixsec Tables in Arbitrary Syntax
20362 @cindex tables, in other modes
20363 @cindex lists, in other modes
20364 @cindex Orgtbl mode
20366 Due to Org's success in handling tables with Orgtbl, a frequently
20367 requested feature is the use of Org's table functions in other modes,
20368 e.g., @LaTeX{}.  This would be hard to do in a general way without
20369 complicated customization nightmares.  Moreover, that would take Org
20370 away from its simplicity roots that Orgtbl has proven.  There is,
20371 however, an alternate approach to accomplishing the same.
20373 This approach involves implementing a custom @emph{translate} function that
20374 operates on a native Org @emph{source table} to produce a table in another
20375 format.  This strategy would keep the excellently working Orgtbl
20376 simple and isolate complications, if any, confined to the translate
20377 function.  To add more alien table formats, we just add more translate
20378 functions.  Also the burden of developing custom translate functions
20379 for new table formats is in the hands of those who know those formats
20380 best.
20382 @menu
20383 * Radio tables::                 Sending and receiving radio tables.
20384 * A @LaTeX{} example::           Step by step, almost a tutorial.
20385 * Translator functions::         Copy and modify.
20386 @end menu
20388 @node Radio tables
20389 @appendixsubsec Radio tables
20391 @cindex radio tables
20393 Radio tables are target locations for translated tables that are not near
20394 their source.  Org finds the target location and inserts the translated
20395 table.
20397 The key to finding the target location is the magic words @samp{BEGIN/END
20398 RECEIVE ORGTBL}.  They have to appear as comments in the current mode.
20399 If the mode is C, then:
20401 @example
20402 /* BEGIN RECEIVE ORGTBL table_name */
20403 /* END RECEIVE ORGTBL table_name */
20404 @end example
20406 @noindent
20407 At the location of source, Org needs a special line to direct Orgtbl
20408 to translate and to find the target for inserting the translated
20409 table.  For example:
20411 @cindex @samp{ORGTBL}, keyword
20412 @example
20413 #+ORGTBL: SEND table_name translation_function arguments ...
20414 @end example
20416 @noindent
20417 @samp{table_name} is the table's reference name, which is also used in the
20418 receiver lines, and the @samp{translation_function} is the Lisp function
20419 that translates.  This line, in addition, may also contain alternating
20420 key and value arguments at the end.  The translation function gets
20421 these values as a property list.  A few standard parameters are
20422 already recognized and acted upon before the translation function is
20423 called:
20425 @table @asis
20426 @item @samp{:skip N}
20427 Skip the first N lines of the table.  Hlines do count; include
20428 them if they are to be skipped.
20430 @item @samp{:skipcols (n1 n2 ...)}
20431 List of columns to be skipped.  First Org automatically discards
20432 columns with calculation marks and then sends the table to the
20433 translator function, which then skips columns as specified in
20434 @samp{skipcols}.
20435 @end table
20437 @noindent
20438 To keep the source table intact in the buffer without being disturbed
20439 when the source file is compiled or otherwise being worked on, use one
20440 of these strategies:
20442 @itemize
20443 @item
20444 Place the table in a block comment.  For example, in C mode you
20445 could wrap the table between @samp{/*} and @samp{*/} lines.
20447 @item
20448 Put the table after an ``end'' statement.  For example @code{\bye} in @TeX{}
20449 and @code{\end@{document@}} in @LaTeX{}.
20451 @item
20452 Comment and un-comment each line of the table during edits.  The
20453 @kbd{M-x orgtbl-toggle-comment} command makes toggling easy.
20454 @end itemize
20456 @node A @LaTeX{} example
20457 @appendixsubsec A @LaTeX{} example of radio tables
20459 @cindex @LaTeX{}, and Orgtbl mode
20461 To wrap a source table in @LaTeX{}, use the @samp{comment} environment
20462 provided by @samp{comment.sty}@footnote{@uref{https://ctan.org/tex-archive/macros/latex/contrib/comment?lang=en}}.  To activate it, put
20463 @code{\usepackage@{comment@}} in the document header.  Orgtbl mode inserts
20464 a radio table skeleton@footnote{Because @samp{LEVEL=2} has 3 stars, @samp{LEVEL=3} has 4 stars, and so
20465 on.} with the command @kbd{M-x orgtbl-insert-radio-table}, which prompts for a table name.  For
20466 example, if @samp{salesfigures} is the name, the template inserts:
20468 @example
20469 % BEGIN RECEIVE ORGTBL salesfigures
20470 % END RECEIVE ORGTBL salesfigures
20471 \begin@{comment@}
20472 #+ORGTBL: SEND salesfigures orgtbl-to-latex
20473 | | |
20474 \end@{comment@}
20475 @end example
20477 @vindex LaTeX-verbatim-environments
20478 @noindent
20479 The line @samp{#+ORGTBL: SEND} tells Orgtbl mode to use the function
20480 @code{orgtbl-to-latex} to convert the table to @LaTeX{} format, then insert
20481 the table at the target (receive) location named @samp{salesfigures}.  Now
20482 the table is ready for data entry.  It can even use spreadsheet
20483 features@footnote{If the @samp{TBLFM} keyword contains an odd number of dollar
20484 characters, this may cause problems with Font Lock in @LaTeX{} mode.  As
20485 shown in the example you can fix this by adding an extra line inside
20486 the @samp{comment} environment that is used to balance the dollar
20487 expressions.  If you are using AUC@TeX{} with the font-latex library,
20488 a much better solution is to add the @samp{comment} environment to the
20489 variable @code{LaTeX-verbatim-environments}.}:
20491 @example
20492 % BEGIN RECEIVE ORGTBL salesfigures
20493 % END RECEIVE ORGTBL salesfigures
20494 \begin@{comment@}
20495 #+ORGTBL: SEND salesfigures orgtbl-to-latex
20496 | Month | Days | Nr sold | per day |
20497 |-------+------+---------+---------|
20498 | Jan   |   23 |      55 |     2.4 |
20499 | Feb   |   21 |      16 |     0.8 |
20500 | March |   22 |     278 |    12.6 |
20501 #+TBLFM: $4=$3/$2;%.1f
20502 % $ (optional extra dollar to keep Font Lock happy, see footnote)
20503 \end@{comment@}
20504 @end example
20506 @noindent
20507 After editing, @kbd{C-c C-c} inserts the translated table at the
20508 target location, between the two marker lines.
20510 For hand-made custom tables, note that the translator needs to skip
20511 the first two lines of the source table.  Also the command has to
20512 @emph{splice} out the target table without the header and footer.
20514 @example
20515 \begin@{tabular@}@{lrrr@}
20516 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
20517 % BEGIN RECEIVE ORGTBL salesfigures
20518 % END RECEIVE ORGTBL salesfigures
20519 \end@{tabular@}
20521 \begin@{comment@}
20522 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
20523 | Month | Days | Nr sold | per day |
20524 |-------+------+---------+---------|
20525 | Jan   |   23 |      55 |     2.4 |
20526 | Feb   |   21 |      16 |     0.8 |
20527 | March |   22 |     278 |    12.6 |
20528 #+TBLFM: $4=$3/$2;%.1f
20529 \end@{comment@}
20530 @end example
20532 The @LaTeX{} translator function @code{orgtbl-to-latex} is already part of
20533 Orgtbl mode and uses a @samp{tabular} environment to typeset the table and
20534 marks horizontal lines with @code{\hline}.  For additional parameters to
20535 control output, see @ref{Translator functions}:
20537 @table @asis
20538 @item @code{:splice nil/t}
20539 When non-@code{nil}, return only table body lines; not wrapped in
20540 tabular environment.  Default is @code{nil}.
20542 @item @code{:fmt FMT}
20543 Format to warp each field.  It should contain @samp{%s} for the
20544 original field value.  For example, to wrap each field value in
20545 dollar symbol, you could use @samp{:fmt "$%s$"}.  Format can also wrap
20546 a property list with column numbers and formats, for example
20547 @samp{:fmt (2 "$%s$" 4 "%s\\%%")}.  In place of a string, a function
20548 of one argument can be used; the function must return a formatted
20549 string.
20551 @item @code{:efmt EFMT}
20552 Format numbers as exponentials.  The spec should have @samp{%s} twice
20553 for inserting mantissa and exponent, for example
20554 @samp{"%s\\times10^@{%s@}"}.  This may also be a property list with
20555 column numbers and formats, for example @samp{:efmt (2
20556      "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
20557 @var{EFMT} has been applied to a value, @var{FMT}---see
20558 above---is also be applied.  Functions with two arguments can be
20559 supplied instead of strings.  By default, no special formatting
20560 is applied.
20561 @end table
20563 @node Translator functions
20564 @appendixsubsec Translator functions
20566 @cindex HTML, and Orgtbl mode
20567 @cindex translator function
20569 @findex orgtbl-to-csv
20570 @findex orgtbl-to-tsv
20571 @findex orgtbl-to-latex
20572 @findex orgtbl-to-html
20573 @findex orgtbl-to-texinfo
20574 @findex orgtbl-to-unicode
20575 @findex orgtbl-to-orgtbl
20576 @findex orgtbl-to-generic
20577 Orgtbl mode has built-in translator functions: @code{orgtbl-to-csv}
20578 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values),
20579 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, @code{orgtbl-to-texinfo},
20580 @code{orgtbl-to-unicode} and @code{orgtbl-to-orgtbl}.  They use the generic
20581 translator, @code{orgtbl-to-generic}, which delegates translations to
20582 various export back-ends.
20584 Properties passed to the function through the @samp{ORGTBL SEND} line take
20585 precedence over properties defined inside the function.  For example,
20586 this overrides the default @LaTeX{} line endings, @code{\\}, with @code{\\[2mm]}:
20588 @example
20589 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
20590 @end example
20592 For a new language translator, define a converter function.  It can be
20593 a generic function, such as shown in this example.  It marks
20594 a beginning and ending of a table with @samp{!BTBL!} and @samp{!ETBL!};
20595 a beginning and ending of lines with @samp{!BL!} and @samp{!EL!}; and uses a TAB
20596 for a field separator:
20598 @lisp
20599 (defun orgtbl-to-language (table params)
20600   "Convert the orgtbl-mode TABLE to language."
20601   (orgtbl-to-generic
20602    table
20603    (org-combine-plists
20604     '(:tstart "!BTBL!" :tend "!ETBL!" :lstart "!BL!" :lend "!EL!" :sep "\t")
20605     params)))
20606 @end lisp
20608 @noindent
20609 The documentation for the @code{orgtbl-to-generic} function shows
20610 a complete list of parameters, each of which can be passed through to
20611 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function using
20612 that generic function.
20614 For complicated translations the generic translator function could be
20615 replaced by a custom translator function.  Such a custom function must
20616 take two arguments and return a single string containing the formatted
20617 table.  The first argument is the table whose lines are a list of
20618 fields or the symbol @code{hline}.  The second argument is the property
20619 list consisting of parameters specified in the @samp{#+ORGTBL: SEND} line.
20620 Please share your translator functions by posting them to the Org
20621 users mailing list, at @email{emacs-orgmode@@gnu.org}.
20623 @node Dynamic Blocks
20624 @appendixsec Dynamic Blocks
20626 @cindex dynamic blocks
20628 Org supports @emph{dynamic blocks} in Org documents.  They are inserted
20629 with begin and end markers like any other code block, but the contents
20630 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
20631 @ref{Clocking Work Time}).
20633 Dynamic blocks can have names and function parameters.  The syntax is
20634 similar to source code block specifications:
20636 @example
20637 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
20638   ...
20639 #+END:
20640 @end example
20642 These commands update dynamic blocks:
20644 @table @asis
20645 @item @kbd{C-c C-x C-u} (@code{org-dblock-update})
20646 @kindex C-c C-x C-u
20647 @findex org-dblock-update
20648 Update dynamic block at point.
20650 @item @kbd{C-u C-c C-x C-u}
20651 @kindex C-u C-c C-x C-u
20652 Update all dynamic blocks in the current file.
20653 @end table
20655 Before updating a dynamic block, Org removes content between the
20656 @samp{BEGIN} and @samp{END} markers.  Org then reads the parameters on the
20657 @samp{BEGIN} line for passing to the writer function.  If the function
20658 expects to access the removed content, then Org expects an extra
20659 parameter, @samp{:content}, on the @samp{BEGIN} line.
20661 The syntax for naming a writer function with a dynamic block labelled
20662 @samp{myblock} is: @code{org-dblock-write:myblock}.  Parameters come from the
20663 @samp{BEGIN} line.
20665 The following is an example of a dynamic block and a block writer function
20666 that updates the time when the function was last run:
20668 @example
20669 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
20670   ...
20671 #+END:
20672 @end example
20674 @noindent
20675 The dynamic block's writer function:
20677 @lisp
20678 (defun org-dblock-write:block-update-time (params)
20679   (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
20680     (insert "Last block update at: "
20681             (format-time-string fmt))))
20682 @end lisp
20684 To keep dynamic blocks up-to-date in an Org file, use the function,
20685 @code{org-update-all-dblocks} in hook, such as @code{before-save-hook}.  The
20686 @code{org-update-all-dblocks} function does not run if the file is not in
20687 Org mode.
20689 @findex org-narrow-to-block
20690 Dynamic blocks, like any other block, can be narrowed with
20691 @code{org-narrow-to-block}.
20693 @node Special Agenda Views
20694 @appendixsec Special Agenda Views
20696 @cindex agenda views, user-defined
20698 @vindex org-agenda-skip-function
20699 @vindex org-agenda-skip-function-global
20700 Org provides a special hook to further limit items in agenda views:
20701 @code{agenda}, @code{agenda*}@footnote{The @code{agenda*} view is the same as @code{agenda} except that it
20702 only considers @emph{appointments}, i.e., scheduled and deadline items that
20703 have a time specification @samp{[h]h:mm} in their time-stamps.}, @code{todo}, @code{alltodo}, @code{tags}, @code{tags-todo},
20704 @code{tags-tree}.  Specify a custom function that tests inclusion of every
20705 matched item in the view.  This function can also skip as much as is
20706 needed.
20708 For a global condition applicable to agenda views, use the
20709 @code{org-agenda-skip-function-global} variable.  Org uses a global
20710 condition with @code{org-agenda-skip-function} for custom searching.
20712 This example defines a function for a custom view showing TODO items
20713 with @samp{waiting} status.  Manually this is a multi-step search process,
20714 but with a custom view, this can be automated as follows:
20716 The custom function searches the subtree for the @samp{waiting} tag and
20717 returns @code{nil} on match.  Otherwise it gives the location from where
20718 the search continues.
20720 @lisp
20721 (defun my-skip-unless-waiting ()
20722   "Skip trees that are not waiting"
20723   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
20724     (if (re-search-forward ":waiting:" subtree-end t)
20725         nil          ; tag found, do not skip
20726       subtree-end))) ; tag not found, continue after end of subtree
20727 @end lisp
20729 To use this custom function in a custom agenda command:
20731 @lisp
20732 (org-add-agenda-custom-command
20733  '("b" todo "PROJECT"
20734    ((org-agenda-skip-function 'my-skip-unless-waiting)
20735     (org-agenda-overriding-header "Projects waiting for something: "))))
20736 @end lisp
20738 @vindex org-agenda-overriding-header
20739 Note that this also binds @code{org-agenda-overriding-header} to a more
20740 meaningful string suitable for the agenda view.
20742 @vindex org-odd-levels-only
20743 @vindex org-agenda-skip-function
20744 Search for entries with a limit set on levels for the custom search.
20745 This is a general approach to creating custom searches in Org.  To
20746 include all levels, use @samp{LEVEL>0}@footnote{Note that, for @code{org-odd-levels-only}, a level number
20747 corresponds to order in the hierarchy, not to the number of stars.}.  Then to selectively pick
20748 the matched entries, use @code{org-agenda-skip-function}, which also
20749 accepts Lisp forms, such as @code{org-agenda-skip-entry-if} and
20750 @code{org-agenda-skip-subtree-if}.  For example:
20752 @table @asis
20753 @item @code{(org-agenda-skip-entry-if 'scheduled)}
20754 Skip current entry if it has been scheduled.
20756 @item @code{(org-agenda-skip-entry-if 'notscheduled)}
20757 Skip current entry if it has not been scheduled.
20759 @item @code{(org-agenda-skip-entry-if 'deadline)}
20760 Skip current entry if it has a deadline.
20762 @item @code{(org-agenda-skip-entry-if 'scheduled 'deadline)}
20763 Skip current entry if it has a deadline, or if it is scheduled.
20765 @item @code{(org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))}
20766 Skip current entry if the TODO keyword is TODO or WAITING.
20768 @item @code{(org-agenda-skip-entry-if 'todo 'done)}
20769 Skip current entry if the TODO keyword marks a DONE state.
20771 @item @code{(org-agenda-skip-entry-if 'timestamp)}
20772 Skip current entry if it has any timestamp, may also be deadline
20773 or scheduled.
20775 @item @code{(org-agenda-skip-entry-if 'regexp "regular expression")}
20776 Skip current entry if the regular expression matches in the
20777 entry.
20779 @item @code{(org-agenda-skip-entry-if 'notregexp "regular expression")}
20780 Skip current entry unless the regular expression matches.
20782 @item @code{(org-agenda-skip-subtree-if 'regexp "regular expression")}
20783 Same as above, but check and skip the entire subtree.
20784 @end table
20786 The following is an example of a search for @samp{waiting} without the
20787 special function:
20789 @lisp
20790 (org-add-agenda-custom-command
20791  '("b" todo "PROJECT"
20792    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
20793                                 'regexp ":waiting:"))
20794     (org-agenda-overriding-header "Projects waiting for something: "))))
20795 @end lisp
20797 @node Speeding Up Your Agendas
20798 @appendixsec Speeding Up Your Agendas
20800 @cindex agenda views, optimization
20802 Some agenda commands slow down when the Org files grow in size or
20803 number.  Here are tips to speed up:
20805 @itemize
20806 @item
20807 Reduce the number of Org agenda files to avoid slowdowns due to hard drive
20808 accesses.
20810 @item
20811 Reduce the number of DONE and archived headlines so agenda
20812 operations that skip over these can finish faster.
20814 @item
20815 Do not dim blocked tasks:
20816 @vindex org-agenda-dim-blocked-tasks
20818 @lisp
20819 (setq org-agenda-dim-blocked-tasks nil)
20820 @end lisp
20822 @item
20823 Stop preparing agenda buffers on startup:
20824 @vindex org-startup-folded
20825 @vindex org-agenda-inhibit-startup
20827 @lisp
20828 (setq org-agenda-inhibit-startup nil)
20829 @end lisp
20831 @item
20832 Disable tag inheritance for agendas:
20833 @vindex org-agenda-show-inherited-tags
20834 @vindex org-agenda-use-tag-inheritance
20836 @lisp
20837 (setq org-agenda-use-tag-inheritance nil)
20838 @end lisp
20839 @end itemize
20841 These options can be applied to selected agenda views.  For more
20842 details about generation of agenda views, see the docstrings for the
20843 relevant variables, and this @uref{https://orgmode.org/worg/agenda-optimization.html, dedicated Worg page} for agenda
20844 optimization.
20846 @node Extracting Agenda Information
20847 @appendixsec Extracting Agenda Information
20849 @cindex agenda, pipe
20850 @cindex scripts, for agenda processing
20852 Org provides commands to access agendas through Emacs batch mode.
20853 Through this command-line interface, agendas are automated for further
20854 processing or printing.
20856 @vindex org-agenda-custom-commands
20857 @findex org-batch-agenda
20858 @code{org-batch-agenda} creates an agenda view in ASCII and outputs to
20859 standard output.  This command takes one string parameter.  When
20860 string consists of a single character, Org uses it as a key to
20861 @code{org-agenda-custom-commands}.  These are the same ones available
20862 through the agenda dispatcher (see @ref{Agenda Dispatcher}).
20864 This example command line directly prints the TODO list to the printer:
20866 @example
20867 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
20868 @end example
20870 When the string parameter length is two or more characters, Org
20871 matches it with tags/TODO strings.  For example, this example command
20872 line prints items tagged with @samp{shop}, but excludes items tagged with
20873 @samp{NewYork}:
20875 @example
20876 emacs -batch -l ~/.emacs                                      \
20877       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
20878 @end example
20880 @noindent
20881 An example showing on-the-fly parameter modifications:
20883 @example
20884 emacs -batch -l ~/.emacs                                      \
20885    -eval '(org-batch-agenda "a"                               \
20886            org-agenda-span (quote month)                      \
20887            org-agenda-include-diary nil                       \
20888            org-agenda-files (quote ("~/org/project.org")))'   \
20889    | lpr
20890 @end example
20892 @noindent
20893 which produces an agenda for the next 30 days from just the
20894 @samp{~/org/projects.org} file.
20896 @findex org-batch-agenda-csv
20897 For structured processing of agenda output, use @code{org-batch-agenda-csv}
20898 with the following fields:
20900 @table @asis
20901 @item category
20902 The category of the item
20903 @item head
20904 The headline, without TODO keyword, TAGS and PRIORITY
20905 @item type
20906 The type of the agenda entry, can be
20908 @multitable {aaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
20909 @item @code{todo}
20910 @tab selected in TODO match
20911 @item @code{tagsmatch}
20912 @tab selected in tags match
20913 @item @code{diary}
20914 @tab imported from diary
20915 @item @code{deadline}
20916 @tab a deadline
20917 @item @code{scheduled}
20918 @tab scheduled
20919 @item @code{timestamp}
20920 @tab appointment, selected by timestamp
20921 @item @code{closed}
20922 @tab entry was closed on date
20923 @item @code{upcoming-deadline}
20924 @tab warning about nearing deadline
20925 @item @code{past-scheduled}
20926 @tab forwarded scheduled item
20927 @item @code{block}
20928 @tab entry has date block including date
20929 @end multitable
20931 @item todo
20932 The TODO keyword, if any
20933 @item tags
20934 All tags including inherited ones, separated by colons
20935 @item date
20936 The relevant date, like @samp{2007-2-14}
20937 @item time
20938 The time, like @samp{15:00-16:50}
20939 @item extra
20940 String with extra planning info
20941 @item priority-l
20942 The priority letter if any was given
20943 @item priority-n
20944 The computed numerical priority
20945 @end table
20947 @noindent
20948 If the selection of the agenda item was based on a timestamp,
20949 including those items with @samp{DEADLINE} and @samp{SCHEDULED} keywords, then
20950 Org includes date and time in the output.
20952 If the selection of the agenda item was based on a timestamp  (or
20953 deadline/scheduled), then Org includes date and time in the output.
20955 Here is an example of a post-processing script in Perl.  It takes the
20956 CSV output from Emacs and prints with a checkbox:
20958 @example
20959 #!/usr/bin/perl
20961 # define the Emacs command to run
20962 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
20964 # run it and capture the output
20965 $agenda = qx@{$cmd 2>/dev/null@};
20967 # loop over all lines
20968 foreach $line (split(/\n/,$agenda)) @{
20969     # get the individual values
20970     ($category,$head,$type,$todo,$tags,$date,$time,$extra,
20971      $priority_l,$priority_n) = split(/,/,$line);
20972     # process and print
20973     print "[ ] $head\n";
20975 @end example
20977 @node Using the Property API
20978 @appendixsec Using the Property API
20980 @cindex API, for properties
20981 @cindex properties, API
20983 Here is a description of the functions that can be used to work with
20984 properties.
20986 @defun org-entry-properties &optional pom which
20987 Get all properties of the entry at point-or-marker @var{POM}.
20988 This includes the TODO keyword, the tags, time strings for deadline,
20989 scheduled, and clocking, and any additional properties defined in the
20990 entry.  The return value is an alist.  Keys may occur multiple times
20991 if the property key was used several times.  @var{POM} may also
20992 be @code{nil}, in which case the current entry is used.  If
20993 @var{WHICH} is @code{nil} or @code{all}, get all properties.  If
20994 @var{WHICH} is @code{special} or @code{standard}, only get that subclass.
20995 @end defun
20997 @vindex org-use-property-inheritance
20998 @findex org-insert-property-drawer
20999 @defun org-entry-get pom property &optional inherit
21000 Get value of @var{PROPERTY} for entry at point-or-marker
21001 @var{POM}.  By default, this only looks at properties defined
21002 locally in the entry.  If @var{INHERIT} is non-@code{nil} and the
21003 entry does not have the property, then also check higher levels of the
21004 hierarchy.  If @var{INHERIT} is the symbol @code{selective}, use
21005 inheritance if and only if the setting of
21006 @code{org-use-property-inheritance} selects @var{PROPERTY} for
21007 inheritance.
21008 @end defun
21010 @defun org-entry-delete pom property
21011 Delete the property @var{PROPERTY} from entry at point-or-marker
21012 @var{POM}.
21013 @end defun
21015 @defun org-entry-put pom property value
21016 Set @var{PROPERTY} to @var{VALUES} for entry at
21017 point-or-marker POM.
21018 @end defun
21020 @defun org-buffer-property-keys &optional include-specials
21021 Get all property keys in the current buffer.
21022 @end defun
21024 @defun org-insert-property-drawer
21025 Insert a property drawer for the current entry.  Also
21026 @end defun
21028 @defun org-entry-put-multivalued-property pom property &rest values
21029 Set @var{PROPERTY} at point-or-marker @var{POM} to
21030 @var{VALUES}.  @var{VALUES} should be a list of strings.
21031 They are concatenated, with spaces as separators.
21032 @end defun
21034 @defun org-entry-get-multivalued-property pom property
21035 Treat the value of the property @var{PROPERTY} as
21036 a whitespace-separated list of values and return the values as a list
21037 of strings.
21038 @end defun
21040 @defun org-entry-add-to-multivalued-property pom property value
21041 Treat the value of the property @var{PROPERTY} as
21042 a whitespace-separated list of values and make sure that
21043 @var{VALUE} is in this list.
21044 @end defun
21046 @defun org-entry-remove-from-multivalued-property pom property value
21047 Treat the value of the property @var{PROPERTY} as
21048 a whitespace-separated list of values and make sure that
21049 @var{VALUE} is @emph{not} in this list.
21050 @end defun
21052 @defun org-entry-member-in-multivalued-property pom property value
21053 Treat the value of the property @var{PROPERTY} as
21054 a whitespace-separated list of values and check if @var{VALUE} is
21055 in this list.
21056 @end defun
21058 @defopt org-property-allowed-value-functions
21059 Hook for functions supplying allowed values for a specific property.
21060 The functions must take a single argument, the name of the property,
21061 and return a flat list of allowed values.  If @samp{:ETC} is one of the
21062 values, use the values as completion help, but allow also other values
21063 to be entered.  The functions must return @code{nil} if they are not
21064 responsible for this property.
21065 @end defopt
21067 @node Using the Mapping API
21068 @appendixsec Using the Mapping API
21070 @cindex API, for mapping
21071 @cindex mapping entries, API
21073 Org has sophisticated mapping capabilities to find all entries
21074 satisfying certain criteria.  Internally, this functionality is used
21075 to produce agenda views, but there is also an API that can be used to
21076 execute arbitrary functions for each or selected entries.  The main
21077 entry point for this API is:
21079 @defun org-map-entries func &optional match scope &rest skip
21080 Call @{@{@{(var(FUNC))@}@}@} at each headline selected by @var{MATCH}
21081 in @var{SCOPE}.
21083 @var{FUNC} is a function or a Lisp form.  With the cursor
21084 positioned at the beginning of the headline, call the function without
21085 arguments.  Org returns an alist of return values of calls to the
21086 function.
21088 To avoid preserving point, Org wraps the call to @var{FUNC} in
21089 save-excursion form.  After evaluation, Org moves the cursor to the
21090 end of the line that was just processed.  Search continues from that
21091 point forward.  This may not always work as expected under some
21092 conditions, such as if the current sub-tree was removed by a previous
21093 archiving operation.  In such rare circumstances, Org skips the next
21094 entry entirely when it should not.  To stop Org from such skips, make
21095 @var{FUNC} set the variable @code{org-map-continue-from} to a specific
21096 buffer position.
21098 @var{MATCH} is a tags/property/TODO match.  Org iterates only
21099 matched headlines.  Org iterates over all headlines when
21100 @var{MATCH} is @code{nil} or @code{t}.
21102 @var{SCOPE} determines the scope of this command.  It can be any
21105 @table @asis
21106 @item @code{nil}
21107 The current buffer, respecting the restriction, if any.
21109 @item @code{tree}
21110 The subtree started with the entry at point.
21112 @item @code{region}
21113 The entries within the active region, if any.
21115 @item @code{file}
21116 The current buffer, without restriction.
21118 @item @code{file-with-archives}
21119 The current buffer, and any archives associated with it.
21121 @item @code{agenda}
21122 All agenda files.
21124 @item @code{agenda-with-archives}
21125 All agenda files with any archive files associated with them.
21127 @item @code{(file1 file2 ...)}
21128 If this is a list, all files in the list are scanned.
21129 @end table
21131 @noindent
21132 The remaining arguments are treated as settings for the scanner's
21133 skipping facilities.  Valid arguments are:
21135 @table @asis
21136 @item @code{archive}
21137 Skip trees with the archive tag.
21139 @item @code{comment}
21140 Skip trees with the COMMENT keyword.
21142 @item function or Lisp form
21143 @vindex org-agenda-skip-function
21144 Used as value for @code{org-agenda-skip-function}, so whenever the
21145 function returns @code{t}, @var{FUNC} is called for that entry
21146 and search continues from the point where the function leaves it.
21147 @end table
21148 @end defun
21150 The mapping routine can call any arbitrary function, even functions
21151 that change meta data or query the property API (see @ref{Using the Property API}).  Here are some handy functions:
21153 @defun org-todo &optional arg
21154 Change the TODO state of the entry.  See the docstring of the
21155 functions for the many possible values for the argument
21156 @var{ARG}.
21157 @end defun
21159 @defun org-priority &optional action
21160 Change the priority of the entry.  See the docstring of this function
21161 for the possible values for @var{ACTION}.
21162 @end defun
21164 @defun org-toggle-tag tag &optional onoff
21165 Toggle the tag @var{TAG} in the current entry.  Setting
21166 @var{ONOFF} to either @code{on} or @code{off} does not toggle tag, but
21167 ensure that it is either on or off.
21168 @end defun
21170 @defun org-promote
21171 Promote the current entry.
21172 @end defun
21174 @defun org-demote
21175 Demote the current entry.
21176 @end defun
21178 This example turns all entries tagged with @samp{TOMORROW} into TODO
21179 entries with keyword @samp{UPCOMING}.  Org ignores entries in comment trees
21180 and archive trees.
21182 @lisp
21183 (org-map-entries '(org-todo "UPCOMING")
21184                  "+TOMORROW" 'file 'archive 'comment)
21185 @end lisp
21187 The following example counts the number of entries with TODO keyword
21188 @samp{WAITING}, in all agenda files.
21190 @lisp
21191 (length (org-map-entries t "/+WAITING" 'agenda))
21192 @end lisp
21194 @node MobileOrg
21195 @appendix MobileOrg
21197 @cindex iPhone
21198 @cindex smartphone
21199 @cindex android
21200 @cindex MobileOrg
21202 MobileOrg is a companion mobile app that runs on iOS and Android
21203 devices.  MobileOrg enables offline-views and capture support for an
21204 Org mode system that is rooted on a ``real'' computer.  MobileOrg can
21205 record changes to existing entries.
21207 The @uref{https://github.com/MobileOrg/, iOS implementation} for the @emph{iPhone/iPod Touch/iPad} series of
21208 devices, was started by Richard Moreland and is now in the hands of
21209 Sean Escriva.  Android users should check out @uref{http://wiki.github.com/matburt/mobileorg-android/, MobileOrg Android} by
21210 Matt Jones.  Though the two implementations are not identical, they
21211 offer similar features.
21213 This appendix describes Org's support for agenda view formats
21214 compatible with MobileOrg.  It also describes synchronizing changes,
21215 such as to notes, between MobileOrg and the computer.
21217 To change tags and TODO states in MobileOrg, first customize the
21218 variables @code{org-todo-keywords} and @code{org-tag-alist}.  These should cover
21219 all the important tags and TODO keywords, even if Org files use only
21220 some of them.  Though MobileOrg has in-buffer settings, it understands
21221 TODO states @emph{sets} (see @ref{Per-file keywords}) and
21222 @emph{mutually exclusive} tags (see @ref{Setting Tags}) only for those set in
21223 these variables.
21225 @menu
21226 * Setting Up the Staging Area::  For the mobile device.
21227 * Pushing to MobileOrg::         Uploading Org files and agendas.
21228 * Pulling from MobileOrg::       Integrating captured and flagged items.
21229 @end menu
21231 @node Setting Up the Staging Area
21232 @appendixsec Setting Up the Staging Area
21234 MobileOrg needs access to a file directory on a server to interact
21235 with Emacs.  With a public server, consider encrypting the files.
21236 MobileOrg version 1.5 supports encryption for the iPhone.  Org also
21237 requires @samp{openssl} installed on the local computer.  To turn on
21238 encryption, set the same password in MobileOrg and in Emacs.  Set the
21239 password in the variable @code{org-mobile-use-encryption}@footnote{If Emacs is configured for safe storing of passwords, then
21240 configure the variable, @code{org-mobile-encryption-password}; please read
21241 the docstring of that variable.}.  Note
21242 that even after MobileOrg encrypts the file contents, the file name
21243 remains visible on the file systems of the local computer, the server,
21244 and the mobile device.
21246 For a server to host files, consider options like @uref{http://dropbox.com, Dropbox.com}
21247 account@footnote{An alternative is to use a WebDAV server.  MobileOrg
21248 documentation has details of WebDAV server configuration.  Additional
21249 help is at this @uref{https://orgmode.org/worg/org-faq.html#mobileorg_webdav, FAQ entry}.}.  On first connection, MobileOrg creates a directory
21250 @samp{MobileOrg} on Dropbox.  Pass its location to Emacs through an
21251 initialisation file variable as follows:
21253 @lisp
21254 (setq org-mobile-directory "~/Dropbox/MobileOrg")
21255 @end lisp
21257 Org copies files to the above directory for MobileOrg.  Org also uses
21258 the same directory for sharing notes between Org and MobileOrg.
21260 @node Pushing to MobileOrg
21261 @appendixsec Pushing to MobileOrg
21263 @vindex org-mobile-files
21264 @vindex org-directory
21265 Org pushes files listed in @code{org-mobile-files} to
21266 @code{org-mobile-directory}.  Files include agenda files (as listed in
21267 @code{org-agenda-files}).  Customize @code{org-mobile-files} to add other files.
21268 File names are staged with paths relative to @code{org-directory}, so all
21269 files should be inside this directory@footnote{Symbolic links in @code{org-directory} need to have the same name
21270 as their targets.}.
21272 Push creates a special Org file @samp{agendas.org} with custom agenda views
21273 defined by the user@footnote{While creating the agendas, Org mode forces ID properties on
21274 all referenced entries, so that these entries can be uniquely
21275 identified if MobileOrg flags them for further action.  To avoid
21276 setting properties configure the variable
21277 @code{org-mobile-force-id-on-agenda-items} to @code{nil}.  Org mode then relies
21278 on outline paths, assuming they are unique.}.
21280 Finally, Org writes the file @samp{index.org}, containing links to other
21281 files.  MobileOrg reads this file first from the server to determine
21282 what other files to download for agendas.  For faster downloads,
21283 MobileOrg only reads files whose checksums@footnote{Checksums are stored automatically in the file
21284 @samp{checksums.dat}.} have changed.
21286 @node Pulling from MobileOrg
21287 @appendixsec Pulling from MobileOrg
21289 When MobileOrg synchronizes with the server, it pulls the Org files
21290 for viewing.  It then appends to the file @samp{mobileorg.org} on the
21291 server the captured entries, pointers to flagged and changed entries.
21292 Org integrates its data in an inbox file format.
21294 @enumerate
21295 @item
21296 @vindex org-mobile-inbox-for-pull
21297 Org moves all entries found in @samp{mobileorg.org}@footnote{The file will be empty after this operation.} and appends
21298 them to the file pointed to by the variable
21299 @code{org-mobile-inbox-for-pull}.  Each captured entry and each editing
21300 event is a top-level entry in the inbox file.
21302 @item
21303 After moving the entries, Org attempts changes to MobileOrg.  Some
21304 changes are applied directly and without user interaction.
21305 Examples include changes to tags, TODO state, headline and body
21306 text.  Entries for further action are tagged as @samp{FLAGGED}.  Org
21307 marks entries with problems with an error message in the inbox.
21308 They have to be resolved manually.
21310 @item
21311 Org generates an agenda view for flagged entries for user
21312 intervention to clean up.  For notes stored in flagged entries,
21313 MobileOrg displays them in the echo area when the cursor is on the
21314 corresponding agenda item.
21316 @table @asis
21317 @item @kbd{?}
21318 @kindex ?
21320 Pressing @kbd{?} displays the entire flagged note in
21321 another window.  Org also pushes it to the kill ring.  To
21322 store flagged note as a normal note, use @kbd{? z C-y C-c C-c}.  Pressing@kbd{?} twice does these things: first
21323 it removes the @samp{FLAGGED} tag; second, it removes the flagged
21324 note from the property drawer; third, it signals that manual
21325 editing of the flagged entry is now finished.
21326 @end table
21327 @end enumerate
21329 @kindex ? @r{(Agenda dispatcher)}
21330 From the agenda dispatcher, @kbd{?} returns to the view to finish
21331 processing flagged entries.  Note that these entries may not be the
21332 most recent since MobileOrg searches files that were last pulled.  To
21333 get an updated agenda view with changes since the last pull, pull
21334 again.
21336 @node History and Acknowledgments
21337 @appendix History and Acknowledgments
21341 @anchor{From Carsten}
21342 @appendixsec From Carsten
21344 Org was born in 2003, out of frustration over the user interface of
21345 the Emacs Outline mode.  I was trying to organize my notes and
21346 projects, and using Emacs seemed to be the natural way to go.
21347 However, having to remember eleven different commands with two or
21348 three keys per command, only to hide and show parts of the outline
21349 tree, that seemed entirely unacceptable to me.  Also, when using
21350 outlines to take notes, I constantly wanted to restructure the tree,
21351 organizing it parallel to my thoughts and plans.  @emph{Visibility cycling}
21352 and @emph{structure editing} were originally implemented in the package
21353 @samp{outline-magic.el}, but quickly moved to the more general @samp{org.el}.
21354 As this environment became comfortable for project planning, the next
21355 step was adding @emph{TODO entries}, basic @emph{timestamps}, and @emph{table
21356 support}.  These areas highlighted the two main goals that Org still
21357 has today: to be a new, outline-based, plain text mode with innovative
21358 and intuitive editing features, and to incorporate project planning
21359 functionality directly into a notes file.
21361 Since the first release, literally thousands of emails to me or to the
21362 @email{emacs-orgmode@@gnu.org, mailing list} have provided a constant stream of bug reports, feedback,
21363 new ideas, and sometimes patches and add-on code.  Many thanks to
21364 everyone who has helped to improve this package.  I am trying to keep
21365 here a list of the people who had significant influence in shaping one
21366 or more aspects of Org.  The list may not be complete, if I have
21367 forgotten someone, please accept my apologies and let me know.
21369 Before I get to this list, a few special mentions are in order:
21371 @table @asis
21372 @item Bastien Guerry
21373 Bastien has written a large number of extensions to Org (most of
21374 them integrated into the core by now), including the @LaTeX{}
21375 exporter and the plain list parser.  His support during the early
21376 days was central to the success of this project.  Bastien also
21377 invented Worg, helped establishing the Web presence of Org, and
21378 sponsored hosting costs for the orgmode.org website.  Bastien
21379 stepped in as maintainer of Org between 2011 and 2013, at a time
21380 when I desperately needed a break.
21382 @item Eric Schulte and Dan Davison
21383 Eric and Dan are jointly responsible for the Org Babel system,
21384 which turns Org into a multi-language environment for evaluating
21385 code and doing literate programming and reproducible research.
21386 This has become one of Org's killer features that define what Org
21387 is today.
21389 @item John Wiegley
21390 John has contributed a number of great ideas and patches directly
21391 to Org, including the attachment system (@samp{org-attach.el}),
21392 integration with Apple Mail (@samp{org-mac-message.el}), hierarchical
21393 dependencies of TODO items, habit tracking (@samp{org-habits.el}), and
21394 encryption (@samp{org-crypt.el}).  Also, the capture system is really
21395 an extended copy of his great @samp{remember.el}.
21397 @item Sebastian Rose
21398 Without Sebastian, the HTML/XHTML publishing of Org would be the
21399 pitiful work of an ignorant amateur.  Sebastian has pushed this
21400 part of Org onto a much higher level.  He also wrote
21401 @samp{org-info.js}, a Java script for displaying webpages derived from
21402 Org using an Info-like or a folding interface with single-key
21403 navigation.
21404 @end table
21406 @noindent
21407 See below for the full list of contributions! Again, please let me
21408 know what I am missing here!
21410 @anchor{From Bastien}
21411 @appendixsec From Bastien
21413 I (Bastien) have been maintaining Org between 2011 and 2013.  This
21414 appendix would not be complete without adding a few more
21415 acknowledgments and thanks.
21417 I am first grateful to Carsten for his trust while handing me over the
21418 maintainership of Org.  His unremitting support is what really helped
21419 me getting more confident over time, with both the community and the
21420 code.
21422 When I took over maintainership, I knew I would have to make Org more
21423 collaborative than ever, as I would have to rely on people that are
21424 more knowledgeable than I am on many parts of the code.  Here is
21425 a list of the persons I could rely on, they should really be
21426 considered co-maintainers, either of the code or the community:
21428 @table @asis
21429 @item Eric Schulte
21430 Eric is maintaining the Babel parts of Org.  His reactivity here
21431 kept me away from worrying about possible bugs here and let me
21432 focus on other parts.
21434 @item Nicolas Goaziou
21435 Nicolas is maintaining the consistency of the deepest parts of
21436 Org.  His work on @samp{org-element.el} and @samp{ox.el} has been
21437 outstanding, and it opened the doors for many new ideas and
21438 features.  He rewrote many of the old exporters to use the new
21439 export engine, and helped with documenting this major change.
21440 More importantly (if that's possible), he has been more than
21441 reliable during all the work done for Org 8.0, and always very
21442 reactive on the mailing list.
21444 @item Achim Gratz
21445 Achim rewrote the building process of Org, turning some @emph{ad hoc}
21446 tools into a flexible and conceptually clean process.  He
21447 patiently coped with the many hiccups that such a change can
21448 create for users.
21450 @item Nick Dokos
21451 The Org mode mailing list would not be such a nice place without
21452 Nick, who patiently helped users so many times.  It is impossible
21453 to overestimate such a great help, and the list would not be so
21454 active without him.
21455 @end table
21457 I received support from so many users that it is clearly impossible to
21458 be fair when shortlisting a few of them, but Org's history would not
21459 be complete if the ones above were not mentioned in this manual.
21461 @anchor{List of Contributions}
21462 @appendixsec List of Contributions
21464 @itemize
21465 @item
21466 Russel Adams came up with the idea for drawers.
21468 @item
21469 Thomas Baumann wrote @samp{org-bbdb.el} and @samp{org-mhe.el}.
21471 @item
21472 Christophe Bataillon created the great unicorn logo that we use on
21473 the Org mode website.
21475 @item
21476 Alex Bochannek provided a patch for rounding timestamps.
21478 @item
21479 Jan Böcker wrote @samp{org-docview.el}.
21481 @item
21482 Brad Bozarth showed how to pull RSS feed data into Org files.
21484 @item
21485 Tom Breton wrote @samp{org-choose.el}.
21487 @item
21488 Charles Cave's suggestion sparked the implementation of templates
21489 for Remember, which are now templates for capture.
21491 @item
21492 Pavel Chalmoviansky influenced the agenda treatment of items with
21493 specified time.
21495 @item
21496 Gregory Chernov patched support for Lisp forms into table
21497 calculations and improved XEmacs compatibility, in particular by
21498 porting @samp{nouline.el} to XEmacs.
21500 @item
21501 Sacha Chua suggested copying some linking code from Planner.
21503 @item
21504 Baoqiu Cui contributed the DocBook exporter.
21506 @item
21507 Eddward DeVilla proposed and tested checkbox statistics.  He also
21508 came up with the idea of properties, and that there should be an API
21509 for them.
21511 @item
21512 Nick Dokos tracked down several nasty bugs.
21514 @item
21515 Kees Dullemond used to edit projects lists directly in HTML and so
21516 inspired some of the early development, including HTML export.  He
21517 also asked for a way to narrow wide table columns.
21519 @item
21520 Thomas S. Dye contributed documentation on Worg and helped
21521 integrating the Org Babel documentation into the manual.
21523 @item
21524 Christian Egli converted the documentation into Texinfo format,
21525 inspired the agenda, patched CSS formatting into the HTML exporter,
21526 and wrote @samp{org-taskjuggler.el}.
21528 @item
21529 David Emery provided a patch for custom CSS support in exported HTML
21530 agendas.
21532 @item
21533 Nic Ferrier contributed mailcap and XOXO support.
21535 @item
21536 Miguel A.  Figueroa-Villanueva implemented hierarchical checkboxes.
21538 @item
21539 John Foerch figured out how to make incremental search show context
21540 around a match in a hidden outline tree.
21542 @item
21543 Raimar Finken wrote @samp{org-git-line.el}.
21545 @item
21546 Mikael Fornius works as a mailing list moderator.
21548 @item
21549 Austin Frank works as a mailing list moderator.
21551 @item
21552 Eric Fraga drove the development of Beamer export with ideas and
21553 testing.
21555 @item
21556 Barry Gidden did proofreading the manual in preparation for the book
21557 publication through Network Theory Ltd.
21559 @item
21560 Niels Giesen had the idea to automatically archive DONE trees.
21562 @item
21563 Nicolas Goaziou rewrote much of the plain list code.
21565 @item
21566 Kai Grossjohann pointed out key-binding conflicts with other
21567 packages.
21569 @item
21570 Brian Gough of Network Theory Ltd publishes the Org mode manual as
21571 a book.
21573 @item
21574 Bernt Hansen has driven much of the support for auto-repeating
21575 tasks, task state change logging, and the clocktable.  His clear
21576 explanations have been critical when we started to adopt the Git
21577 version control system.
21579 @item
21580 Manuel Hermenegildo has contributed various ideas, small fixes and
21581 patches.
21583 @item
21584 Phil Jackson wrote @samp{org-irc.el}.
21586 @item
21587 Scott Jaderholm proposed footnotes, control over whitespace between
21588 folded entries, and column view for properties.
21590 @item
21591 Matt Jones wrote MobileOrg Android.
21593 @item
21594 Tokuya Kameshima wrote @samp{org-wl.el} and @samp{org-mew.el}.
21596 @item
21597 Shidai Liu (``Leo'') asked for embedded @LaTeX{} and tested it.  He also
21598 provided frequent feedback and some patches.
21600 @item
21601 Matt Lundin has proposed last-row references for table formulas and
21602 named invisible anchors.  He has also worked a lot on the FAQ.
21604 @item
21605 David Maus wrote @samp{org-atom.el}, maintains the issues file for Org,
21606 and is a prolific contributor on the mailing list with competent
21607 replies, small fixes and patches.
21609 @item
21610 Jason F. McBrayer suggested agenda export to CSV format.
21612 @item
21613 Max Mikhanosha came up with the idea of refiling.
21615 @item
21616 Dmitri Minaev sent a patch to set priority limits on a per-file
21617 basis.
21619 @item
21620 Stefan Monnier provided a patch to keep the Emacs Lisp compiler
21621 happy.
21623 @item
21624 Richard Moreland wrote MobileOrg for the iPhone.
21626 @item
21627 Rick Moynihan proposed allowing multiple TODO sequences in a file
21628 and being able to quickly restrict the agenda to a subtree.
21630 @item
21631 Todd Neal provided patches for links to Info files and Elisp forms.
21633 @item
21634 Greg Newman refreshed the unicorn logo into its current form.
21636 @item
21637 Tim O'Callaghan suggested in-file links, search options for general
21638 file links, and tags.
21640 @item
21641 Osamu Okano wrote @samp{orgcard2ref.pl}, a Perl program to create a text
21642 version of the reference card.
21644 @item
21645 Takeshi Okano translated the manual and David O'Toole's tutorial
21646 into Japanese.
21648 @item
21649 Oliver Oppitz suggested multi-state TODO items.
21651 @item
21652 Scott Otterson sparked the introduction of descriptive text for
21653 links, among other things.
21655 @item
21656 Pete Phillips helped during the development of the TAGS feature,
21657 and provided frequent feedback.
21659 @item
21660 Martin Pohlack provided the code snippet to bundle character
21661 insertion into bundles of 20 for undo.
21663 @item
21664 T.V. Raman reported bugs and suggested improvements.
21666 @item
21667 Matthias Rempe (Oelde) provided ideas, Windows support, and quality
21668 control.
21670 @item
21671 Paul Rivier provided the basic implementation of named footnotes.
21672 He also acted as mailing list moderator for some time.
21674 @item
21675 Kevin Rogers contributed code to access VM files on remote hosts.
21677 @item
21678 Frank Ruell solved the mystery of the @samp{keymapp nil} bug, a conflict
21679 with @samp{allout.el}.
21681 @item
21682 Jason Riedy generalized the send-receive mechanism for Orgtbl
21683 tables with extensive patches.
21685 @item
21686 Philip Rooke created the Org reference card, provided lots of
21687 feedback, developed and applied standards to the Org documentation.
21689 @item
21690 Christian Schlauer proposed angular brackets around links, among
21691 other things.
21693 @item
21694 Paul Sexton wrote @samp{org-ctags.el}.
21696 @item
21697 Tom Shannon's @samp{organizer-mode.el} inspired linking to VM/BBDB/Gnus.
21699 @item
21700 Ilya Shlyakhter proposed the Archive Sibling, line numbering in
21701 literal examples, and remote highlighting for referenced code lines.
21703 @item
21704 Stathis Sideris wrote the @samp{ditaa.jar} ASCII to PNG converter that is
21705 now packaged into Org's @samp{contrib/} directory.
21707 @item
21708 Daniel Sinder came up with the idea of internal archiving by locking
21709 subtrees.
21711 @item
21712 Dale Smith proposed link abbreviations.
21714 @item
21715 James TD Smith has contributed a large number of patches for
21716 useful tweaks and features.
21718 @item
21719 Adam Spiers asked for global linking commands, inspired the link
21720 extension system, added support for Mairix, and proposed the mapping
21721 API.
21723 @item
21724 Ulf Stegemann created the table to translate special symbols to
21725 HTML, @LaTeX{}, UTF-8, Latin-1 and ASCII.
21727 @item
21728 Andy Stewart contributed code to @samp{org-w3m.el}, to copy
21729 HTML content with links transformation to Org syntax.
21731 @item
21732 David O'Toole wrote @samp{org-publish.el} and drafted the
21733 manual chapter about publishing.
21735 @item
21736 Jambunathan K. contributed the ODT exporter.
21738 @item
21739 Sebastien Vauban reported many issues with @LaTeX{} and Beamer export
21740 and enabled source code highlighting in Gnus.
21742 @item
21743 Stefan Vollmar organized a video-recorded talk at the
21744 Max-Planck-Institute for Neurology.  He also inspired the creation
21745 of a concept index for HTML export.
21747 @item
21748 Jürgen Vollmer contributed code generating the table of contents in
21749 HTML output.
21751 @item
21752 Samuel Wales has provided important feedback and bug reports.
21754 @item
21755 Chris Wallace provided a patch implementing the @samp{QUOTE} block.
21757 @item
21758 David Wainberg suggested archiving, and improvements to the
21759 linking system.
21761 @item
21762 Carsten Wimmer suggested some changes and helped fix a bug in
21763 linking to Gnus.
21765 @item
21766 Roland Winkler requested additional key bindings to make Org work on
21767 a TTY.
21769 @item
21770 Piotr Zielinski wrote @samp{org-mouse.el}, proposed agenda
21771 blocks and contributed various ideas and code snippets.
21773 @item
21774 Marco Wahl wrote @samp{org-eww.el}.
21775 @end itemize
21777 @node GNU Free Documentation License
21778 @appendix GNU Free Documentation License
21780 @include doclicense.texi
21782 @node Main Index
21783 @chapter Main Index
21785 @printindex cp
21787 @node Key Index
21788 @chapter Key Index
21790 @printindex ky
21792 @node Command and Function Index
21793 @chapter Command and Function Index
21795 @printindex fn
21797 @node Variable Index
21798 @chapter Variable Index
21800 This is not a complete index of variables and faces, only the ones
21801 that are mentioned in the manual.  For a more complete list, use
21802 @kbd{M-x org-customize} and then click yourself through the tree.
21804 @printindex vr
21806 @bye