Allow headings inside tables without splicing them.
[org-mode/org-tableheadings.git] / doc / org-manual.org
blobc519d310b72ac4c95ec07a17992b23cdab105210
1 #+title: The Org Manual
2 #+subtitle:  Release {{{version}}}
3 #+author:    The Org Mode Developers
4 #+date:      {{{modification-time}}}
5 #+language:  en
8 #+texinfo: @insertcopying
10 * Introduction
11 :PROPERTIES:
12 :DESCRIPTION: Getting started.
13 :END:
14 #+cindex: introduction
16 ** Summary
17 :PROPERTIES:
18 :DESCRIPTION: Brief summary of what Org does.
19 :END:
20 #+cindex: summary
22 Org is a mode for keeping notes, maintaining TODO lists, and project
23 planning with a fast and effective plain-text markup language.  It
24 also is an authoring system with unique support for literate
25 programming and reproducible research.
27 Org is implemented on top of Outline mode, which makes it possible to
28 keep the content of large files well structured.  Visibility cycling
29 and structure editing help to work with the tree.  Tables are easily
30 created with a built-in table editor.  Plain text URL-like links
31 connect to websites, emails, Usenet messages, BBDB entries, and any
32 files related to the projects.
34 Org develops organizational tasks around notes files that contain
35 lists or information about projects as plain text.  Project planning
36 and task management make use of metadata which is part of an outline
37 node.  Based on this data, specific entries can be extracted in
38 queries and create dynamic /agenda views/ that also integrate the
39 Emacs calendar and diary.  Org can be used to implement many different
40 project planning schemes, such as David Allen's GTD system.
42 Org files can serve as a single source authoring system with export to
43 many different formats such as HTML, LaTeX, Open Document, and
44 Markdown.  New export backends can be derived from existing ones, or
45 defined from scratch.
47 Org files can include source code blocks, which makes Org uniquely
48 suited for authoring technical documents with code examples. Org
49 source code blocks are fully functional; they can be evaluated in
50 place and their results can be captured in the file.  This makes it
51 possible to create a single file reproducible research compendium.
53 Org keeps simple things simple.  When first fired up, it should feel
54 like a straightforward, easy to use outliner.  Complexity is not
55 imposed, but a large amount of functionality is available when needed.
56 Org is a toolbox.  Many users actually run only a---very
57 personal---fraction of Org's capabilities, and know that there is more
58 whenever they need it.
60 All of this is achieved with strictly plain text files, the most
61 portable and future-proof file format.  Org runs in Emacs.  Emacs is
62 one of the most widely ported programs, so that Org mode is available
63 on every major platform.
65 #+cindex: FAQ
66 There is a website for Org which provides links to the newest version
67 of Org, as well as additional information, frequently asked questions
68 (FAQ), links to tutorials, etc.  This page is located at
69 [[https://orgmode.org]].
71 #+cindex: print edition
72 An earlier version (7.3) of this manual is available as a [[http://www.network-theory.co.uk/org/manual/][paperback
73 book from Network Theory Ltd.]].
75 ** Installation
76 :PROPERTIES:
77 :DESCRIPTION: Installing Org.
78 :END:
79 #+cindex: installation
81 Org is included in all recent distributions of GNU Emacs, so you
82 probably do not need to install it.  Most users will simply activate
83 Org and begin exploring its many features.
85 If, for one reason or another, you want to install Org on top of this
86 pre-packaged version, there are three ways to do it:
88 - by using the Emacs package system;
89 - by downloading Org as an archive; or
90 - by using Org's git repository.
92 We *strongly recommend* sticking to a single installation method.
94 *** Using Emacs packaging system
95 :PROPERTIES:
96 :UNNUMBERED: notoc
97 :END:
99 Recent Emacs distributions include a packaging system which lets you
100 install Elisp libraries.  You can install Org with {{{kbd(M-x
101 package-install RET org)}}}.
103 #+attr_texinfo: :tag Important
104 #+begin_quote
105 You need to do this in a session where no =.org= file has been
106 visited, i.e., where no Org built-in function have been loaded.
107 Otherwise autoload Org functions will mess up the installation.
108 #+end_quote
110 If you want to use Org's package repository, check out the [[https://orgmode.org/elpa.html][Org ELPA
111 page]].
113 *** Downloading Org as an archive
114 :PROPERTIES:
115 :UNNUMBERED: notoc
116 :END:
118 You can download Org latest release from [[https://orgmode.org/][Org's website]].  In this case,
119 make sure you set the load-path correctly in your Emacs init file:
121 #+begin_src emacs-lisp
122 (add-to-list 'load-path "~/path/to/orgdir/lisp")
123 #+end_src
125 The downloaded archive contains contributed libraries that are not
126 included in Emacs.  If you want to use them, add the =contrib/=
127 directory to your load-path:
129 #+begin_src emacs-lisp
130 (add-to-list 'load-path "~/path/to/orgdir/contrib/lisp" t)
131 #+end_src
133 Optionally, you can compile the files and/or install them in your
134 system.  Run =make help= to list compilation and installation options.
136 *** Using Org's git repository
137 :PROPERTIES:
138 :UNNUMBERED: notoc
139 :END:
141 You can clone Org's repository and install Org like this:
143 #+begin_example
144 $ cd ~/src/
145 $ git clone git@code.orgmode.org:bzg/org-mode.git
146 $ cd org-mode/
147 $ make autoloads
148 #+end_example
150 Note that in this case, =make autoloads= is mandatory: it defines
151 Org's version in =org-version.el= and Org's autoloads in
152 =org-loaddefs.el=.
154 Remember to add the correct load-path as described in the method
155 above.
157 You can also compile with =make=, generate the documentation with
158 =make doc=, create a local configuration with =make config= and
159 install Org with =make install=.  Please run =make help= to get the
160 list of compilation/installation options.
162 For more detailed explanations on Org's build system, please check the
163 Org Build System page on [[https://orgmode.org/worg/dev/org-build-system.html][Worg]].
165 ** Activation
166 :PROPERTIES:
167 :DESCRIPTION: How to activate Org for certain buffers.
168 :END:
169 #+cindex: activation
170 #+cindex: autoload
171 #+cindex: ELPA
172 #+cindex: global key bindings
173 #+cindex: key bindings, global
175 Org mode buffers need Font Lock to be turned on: this is the default
176 in Emacs[fn:1].
178 There are compatibility issues between Org mode and some other Elisp
179 packages (see [[*Packages that conflict with Org mode]]).  Please take the
180 time to check the list.
182 #+findex: org-agenda
183 #+findex: org-capture
184 #+findex: org-store-link
185 For a better experience, the three Org commands ~org-store-link~,
186 ~org-capture~ and ~org-agenda~ ought to be accessible anywhere in
187 Emacs, not just in Org buffers.  To that effect, you need to bind them
188 to globally available keys, like the ones reserved for users (see
189 [[info:elisp::Key Binding Conventions]]).  Here are suggested bindings,
190 please modify the keys to your own liking.
192 #+begin_src emacs-lisp
193 (global-set-key (kbd "C-c l") 'org-store-link)
194 (global-set-key (kbd "C-c a") 'org-agenda)
195 (global-set-key (kbd "C-c c") 'org-capture)
196 #+end_src
198 #+cindex: Org mode, turning on
199 Files with the =.org= extension use Org mode by default.  To turn on
200 Org mode in a file that does not have the extension =.org=, make the
201 first line of a file look like this:
203 : MY PROJECTS    -*- mode: org; -*-
205 #+vindex: org-insert-mode-line-in-empty-file
206 #+texinfo: @noindent
207 which selects Org mode for this buffer no matter what the file's name
208 is.  See also the variable ~org-insert-mode-line-in-empty-file~.
210 Many commands in Org work on the region if the region is /active/.  To
211 make use of this, you need to have ~transient-mark-mode~ turned on,
212 which is the default.  If you do not like ~transient-mark-mode~, you
213 can create an active region by using the mouse to select a region, or
214 pressing {{{kbd(C-SPC)}}} twice before moving point.
216 ** Feedback
217 :PROPERTIES:
218 :DESCRIPTION: Bug reports, ideas, patches, etc.
219 :END:
220 #+cindex: feedback
221 #+cindex: bug reports
222 #+cindex: reporting a bug
223 #+cindex: maintainer
224 #+cindex: author
226 If you find problems with Org, or if you have questions, remarks, or
227 ideas about it, please send an email to the Org mailing list
228 [[mailto:emacs-orgmode@gnu.org]].  You can subscribe to the list [[https://lists.gnu.org/mailman/listinfo/emacs-orgmode][from this
229 web page]].  If you are not a member of the mailing list, your mail will
230 be passed to the list after a moderator has approved it[fn:2].
232 #+findex: org-version
233 #+findex: org-submit-bug-report
234 For bug reports, please first try to reproduce the bug with the latest
235 version of Org available---if you are running an outdated version, it
236 is quite possible that the bug has been fixed already.  If the bug
237 persists, prepare a report and provide as much information as
238 possible, including the version information of Emacs ({{{kbd(M-x
239 emacs-version)}}}) and Org ({{{kbd(M-x org-version)}}}), as well as
240 the Org related setup in the Emacs init file.  The easiest way to do
241 this is to use the command
243 : M-x org-submit-bug-report <RET>
245 #+texinfo: @noindent
246 which puts all this information into an Emacs mail buffer so that you
247 only need to add your description.  If you are not sending the Email
248 from within Emacs, please copy and paste the content into your Email
249 program.
251 Sometimes you might face a problem due to an error in your Emacs or
252 Org mode setup.  Before reporting a bug, it is very helpful to start
253 Emacs with minimal customizations and reproduce the problem.  Doing so
254 often helps you determine if the problem is with your customization or
255 with Org mode itself.  You can start a typical minimal session with
256 a command like the example below.
258 : $ emacs -Q -l /path/to/minimal-org.el
260 However if you are using Org mode as distributed with Emacs, a minimal
261 setup is not necessary.  In that case it is sufficient to start Emacs
262 as =emacs -Q=.  The =minimal-org.el= setup file can have contents as
263 shown below.
265 #+begin_src emacs-lisp
266 ;;; Minimal setup to load latest `org-mode'.
268 ;; Activate debugging.
269 (setq debug-on-error t
270       debug-on-signal nil
271       debug-on-quit nil)
273 ;; Add latest Org mode to load path.
274 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
275 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t))
276 #+end_src
278 If an error occurs, a "backtrace" can be very useful---see below on
279 how to create one.  Often a small example file helps, along with clear
280 information about:
282 1. What exactly did you do?
283 2. What did you expect to happen?
284 3. What happened instead?
286 Thank you for helping to improve this program.
288 *** How to create a useful backtrace
289 :PROPERTIES:
290 :UNNUMBERED: notoc
291 :END:
293 #+cindex: backtrace of an error
294 If working with Org produces an error with a message you do not
295 understand, you may have hit a bug.  The best way to report this is by
296 providing, in addition to what was mentioned above, a backtrace.  This
297 is information from the built-in debugger about where and how the
298 error occurred.  Here is how to produce a useful backtrace:
300 1. Reload uncompiled versions of all Org mode Lisp files.  The
301    backtrace contains much more information if it is produced with
302    uncompiled code.  To do this, use
304    : C-u M-x org-reload <RET>
306    #+texinfo: @noindent
307    or, from the menu: Org \rarr Refresh/Reload \rarr Reload Org uncompiled.
309 2. Then, activate the debugger:
311    : M-x toggle-debug-or-error <RET>
313    #+texinfo: @noindent
314    or, from the menu: Options \rarr Enter Debugger on Error.
316 3. Do whatever you have to do to hit the error.  Do not forget to
317    document the steps you take.
319 4. When you hit the error, a =*Backtrace*= buffer appears on the
320    screen.  Save this buffer to a file---for example using {{{kbd(C-x
321    C-w)}}}---and attach it to your bug report.
323 ** Typesetting Conventions Used in this Manual
324 :PROPERTIES:
325 :DESCRIPTION: Typesetting conventions used in this manual.
326 :ALT_TITLE: Conventions
327 :END:
329 *** TODO keywords, tags, properties, etc.
330 :PROPERTIES:
331 :UNNUMBERED: notoc
332 :END:
334 Org uses various syntactical elements: TODO keywords, tags, property
335 names, keywords, blocks, etc.  In this manual we use the following
336 conventions:
338 #+attr_texinfo: :sep ,
339 - =TODO=, =WAITING= ::
341   TODO keywords are written with all capitals, even if they are
342   user-defined.
344 - =boss=, =ARCHIVE= ::
346   Tags are case-sensitive.  User-defined tags are written in
347   lowercase; built-in tags with special meaning are written as they
348   should appear in the document, usually with all capitals.
350 - =Release=, =PRIORITY= ::
352   User-defined properties are capitalized; built-in properties with
353   special meaning are written with all capitals.
355 - =TITLE=, =BEGIN= ... =END= ::
357   Keywords and blocks are written in uppercase to enhance their
358   readability, but you can use lowercase in your Org files.
360 *** Key bindings and commands
361 :PROPERTIES:
362 :UNNUMBERED: notoc
363 :END:
365 The manual lists both the keys and the corresponding commands for
366 accessing a functionality.  Org mode often uses the same key for
367 different functions, depending on context.  The command that is bound
368 to such keys has a generic name, like ~org-metaright~.  In the manual
369 we will, wherever possible, give the function that is internally
370 called by the generic command.  For example, in the chapter on
371 document structure, {{{kbd(M-RIGHT)}}} will be listed to call
372 ~org-do-demote~, while in the chapter on tables, it will be listed to
373 call ~org-table-move-column-right~.
375 * Document Structure
376 :PROPERTIES:
377 :DESCRIPTION: A tree works like your brain.
378 :END:
380 #+cindex: document structure
381 #+cindex: structure of document
382 Org is an outliner.  Outlines allow a document to be organized in
383 a hierarchical structure, which, least for me, is the best
384 representation of notes and thoughts.  An overview of this structure
385 is achieved by folding, i.e., hiding large parts of the document to
386 show only the general document structure and the parts currently being
387 worked on.  Org greatly simplifies the use of outlines by compressing
388 the entire show and hide functionalities into a single command,
389 ~org-cycle~, which is bound to the {{{kbd(TAB)}}} key.
391 ** Headlines
392 :PROPERTIES:
393 :DESCRIPTION: How to typeset Org tree headlines.
394 :END:
395 #+cindex: headlines
396 #+cindex: outline tree
397 #+vindex: org-special-ctrl-a/e
398 #+vindex: org-special-ctrl-k
399 #+vindex: org-ctrl-k-protect-subtree
401 Headlines define the structure of an outline tree.  The headlines in
402 Org start with one or more stars, on the left margin[fn:3].  For
403 example:
405 #+begin_example
406 ,* Top level headline
407 ,** Second level
408 ,*** Third level
409     some text
410 ,*** Third level
411     more text
412 ,* Another top level headline
413 #+end_example
415 #+vindex: org-footnote-section
416 The name defined in ~org-footnote-section~ is reserved.  Do not use it
417 as a title for your own headings.
419 Some people find the many stars too noisy and would prefer an outline
420 that has whitespace followed by a single star as headline starters.
421 See [[*A Cleaner Outline View]].
423 Headline are not numbered.  However, you may want to dynamically
424 number some, or all, of them.  See [[*Dynamic Headline Numbering]].
426 #+vindex: org-cycle-separator-lines
427 An empty line after the end of a subtree is considered part of it and
428 is hidden when the subtree is folded.  However, if you leave at least
429 two empty lines, one empty line remains visible after folding the
430 subtree, in order to structure the collapsed view.  See the variable
431 ~org-cycle-separator-lines~ to modify this behavior.
433 ** Visibility Cycling
434 :PROPERTIES:
435 :DESCRIPTION: Show and hide, much simplified.
436 :END:
437 #+cindex: cycling, visibility
438 #+cindex: visibility cycling
439 #+cindex: trees, visibility
440 #+cindex: show hidden text
441 #+cindex: hide text
443 *** Global and local cycling
444 :PROPERTIES:
445 :DESCRIPTION: Cycling through various visibility states.
446 :END:
447 #+cindex: subtree visibility states
448 #+cindex: subtree cycling
449 #+cindex: folded, subtree visibility state
450 #+cindex: children, subtree visibility state
451 #+cindex: subtree, subtree visibility state
453 Outlines make it possible to hide parts of the text in the buffer.
454 Org uses just two commands, bound to {{{kbd(TAB)}}} and
455 {{{kbd(S-TAB)}}} to change the visibility in the buffer.
457 #+attr_texinfo: :sep ,
458 - {{{kbd(TAB)}}} (~org-cycle~) ::
460   #+kindex: TAB
461   #+findex: org-cycle
462   /Subtree cycling/: Rotate current subtree among the states
464   #+begin_example
465   ,-> FOLDED -> CHILDREN -> SUBTREE --.
466   '-----------------------------------'
467   #+end_example
469   #+vindex: org-cycle-emulate-tab
470   Point must be on a headline for this to work[fn:4].
472 - {{{kbd(S-TAB)}}} (~org-global-cycle~), {{{kbd(C-u TAB)}}} ::
474   #+cindex: global visibility states
475   #+cindex: global cycling
476   #+cindex: overview, global visibility state
477   #+cindex: contents, global visibility state
478   #+cindex: show all, global visibility state
479   #+kindex: C-u TAB
480   #+kindex: S-TAB
481   #+findex: org-global-cycle
482   /Global cycling/: Rotate the entire buffer among the states
484   #+begin_example
485   ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
486   '--------------------------------------'
487   #+end_example
489   When {{{kbd(S-TAB)}}} is called with a numeric prefix argument N,
490   the CONTENTS view up to headlines of level N are shown.  Note that
491   inside tables (see [[*Tables]]), {{{kbd(S-TAB)}}} jumps to the previous
492   field instead.
494   #+vindex: org-cycle-global-at-bob
495   You can run global cycling using {{{kbd(TAB)}}} only if point is at
496   the very beginning of the buffer, but not on a headline, and
497   ~org-cycle-global-at-bob~ is set to a non-~nil~ value.
499 - {{{kbd(C-u C-u TAB)}}} (~org-set-startup-visibility~) ::
501   #+cindex: startup visibility
502   #+kindex: C-u C-u TAB
503   #+findex: org-set-startup-visibility
504   Switch back to the startup visibility of the buffer (see [[*Initial
505   visibility]]).
507 - {{{kbd(C-u C-u C-u TAB)}}} (~outline-show-all~) ::
509   #+cindex: show all, command
510   #+kindex: C-u C-u C-u TAB
511   #+findex: outline-show-all
512   Show all, including drawers.
514 - {{{kbd(C-c C-r)}}} (~org-reveal~) ::
516   #+cindex: revealing context
517   #+kindex: C-c C-r
518   #+findex: org-reveal
519   Reveal context around point, showing the current entry, the
520   following heading and the hierarchy above.  Useful for working near
521   a location that has been exposed by a sparse tree command (see
522   [[*Sparse Trees]]) or an agenda command (see [[*Commands in the Agenda
523   Buffer]]).  With a prefix argument show, on each level, all sibling
524   headings.  With a double prefix argument, also show the entire
525   subtree of the parent.
527 - {{{kbd(C-c C-k)}}} (~outline-show-branches~) ::
529   #+cindex: show branches, command
530   #+kindex: C-c C-k
531   #+findex: outline-show-branches
532   Expose all the headings of the subtree, CONTENTS view for just one
533   subtree.
535 - {{{kbd(C-c TAB)}}} (~outline-show-children~) ::
537   #+cindex: show children, command
538   #+kindex: C-c TAB
539   #+findex: outline-show-children
540   Expose all direct children of the subtree.  With a numeric prefix
541   argument N, expose all children down to level N.
543 - {{{kbd(C-c C-x b)}}} (~org-tree-to-indirect-buffer~) ::
545   #+kindex: C-c C-x b
546   #+findex: org-tree-to-indirect-buffer
547   Show the current subtree in an indirect buffer[fn:5].  With
548   a numeric prefix argument, N, go up to level N and then take that
549   tree.  If N is negative then go up that many levels.  With
550   a {{{kbd(C-u)}}} prefix, do not remove the previously used indirect
551   buffer.
553 - {{{kbd(C-c C-x v)}}} (~org-copy-visible~) ::
555   #+kindex: C-c C-x v
556   #+findex: org-copy-visible
557   Copy the /visible/ text in the region into the kill ring.
559 *** Initial visibility
560 :PROPERTIES:
561 :DESCRIPTION: Setting the initial visibility state.
562 :END:
564 #+vindex: org-startup-folded
565 When Emacs first visits an Org file, the global state is set to
566 OVERVIEW, i.e., only the top level headlines are visible[fn:6].  This
567 can be configured through the variable ~org-startup-folded~, or on
568 a per-file basis by adding one of the following lines anywhere in the
569 buffer:
571 #+cindex: @samp{STARTUP}, keyword
572 #+begin_example
573 ,#+STARTUP: overview
574 ,#+STARTUP: content
575 ,#+STARTUP: showall
576 ,#+STARTUP: showeverything
577 #+end_example
579 #+cindex: @samp{VISIBILITY}, property
580 Furthermore, any entries with a =VISIBILITY= property (see [[*Properties
581 and Columns]]) get their visibility adapted accordingly.  Allowed values
582 for this property are =folded=, =children=, =content=, and =all=.
584 - {{{kbd(C-u C-u TAB)}}} (~org-set-startup-visibility~) ::
586   #+kindex: C-u C-u TAB
587   #+findex: org-set-startup-visibility
588   Switch back to the startup visibility of the buffer, i.e., whatever
589   is requested by startup options and =VISIBILITY= properties in
590   individual entries.
592 *** Catching invisible edits
593 :PROPERTIES:
594 :DESCRIPTION: Preventing mistakes when editing invisible parts.
595 :END:
596 #+cindex: edits, catching invisible
598 #+vindex: org-catch-invisible-edits
599 Sometimes you may inadvertently edit an invisible part of the buffer
600 and be confused on what has been edited and how to undo the mistake.
601 Setting ~org-catch-invisible-edits~ to non-~nil~ helps preventing
602 this.  See the docstring of this option on how Org should catch
603 invisible edits and process them.
605 ** Motion
606 :PROPERTIES:
607 :DESCRIPTION: Jumping to other headlines.
608 :END:
609 #+cindex: motion, between headlines
610 #+cindex: jumping, to headlines
611 #+cindex: headline navigation
613 The following commands jump to other headlines in the buffer.
615 - {{{kbd(C-c C-n)}}} (~org-next-visible-heading~) ::
617   #+kindex: C-c C-n
618   #+findex: org-next-visible-heading
619   Next heading.
621 - {{{kbd(C-c C-p)}}} (~org-previous-visible-heading~) ::
623   #+kindex: C-c C-p
624   #+findex: org-previous-visible-heading
625   Previous heading.
627 - {{{kbd(C-c C-f)}}} (~org-forward-heading-same-level~) ::
629   #+kindex: C-c C-f
630   #+findex: org-forward-heading-same-level
631   Next heading same level.
633 - {{{kbd(C-c C-b)}}} (~org-backward-heading-same-level~) ::
635   #+kindex: C-c C-b
636   #+findex: org-backward-heading-same-level
637   Previous heading same level.
639 - {{{kbd(C-c C-u)}}} (~outline-up-heading~) ::
641   #+kindex: C-c C-u
642   #+findex: outline-up-heading
643   Backward to higher level heading.
645 - {{{kbd(C-c C-j)}}} (~org-goto~) ::
647   #+kindex: C-c C-j
648   #+findex: org-goto
649   #+vindex: org-goto-auto-isearch
650   Jump to a different place without changing the current outline
651   visibility.  Shows the document structure in a temporary buffer,
652   where you can use the following keys to find your destination:
654   #+attr_texinfo: :columns 0.3 0.7
655   | {{{kbd(TAB)}}}                  | Cycle visibility.               |
656   | {{{kbd(DOWN)}}} / {{{kbd(UP)}}} | Next/previous visible headline. |
657   | {{{kbd(RET)}}}                  | Select this location.           |
658   | {{{kbd(/)}}}                    | Do a Sparse-tree search         |
660   #+texinfo: @noindent
661   The following keys work if you turn off ~org-goto-auto-isearch~
663   #+attr_texinfo: :columns 0.3 0.7
664   | {{{kbd(n)}}} / {{{kbd(p)}}}   | Next/previous visible headline.    |
665   | {{{kbd(f)}}} / {{{kbd(b)}}}   | Next/previous headline same level. |
666   | {{{kbd(u)}}}                  | One level up.                      |
667   | {{{kbd(0)}}} ... {{{kbd(9)}}} | Digit argument.                    |
668   | {{{kbd(q)}}}                  | Quit.                              |
670   #+vindex: org-goto-interface
671   #+texinfo: @noindent
672   See also the variable ~org-goto-interface~.
674 ** Structure Editing
675 :PROPERTIES:
676 :DESCRIPTION: Changing sequence and level of headlines.
677 :END:
678 #+cindex: structure editing
679 #+cindex: headline, promotion and demotion
680 #+cindex: promotion, of subtrees
681 #+cindex: demotion, of subtrees
682 #+cindex: subtree, cut and paste
683 #+cindex: pasting, of subtrees
684 #+cindex: cutting, of subtrees
685 #+cindex: copying, of subtrees
686 #+cindex: sorting, of subtrees
687 #+cindex: subtrees, cut and paste
689 - {{{kbd(M-RET)}}} (~org-meta-return~) ::
691   #+kindex: M-RET
692   #+findex: org-meta-return
693   #+vindex: org-M-RET-may-split-line
694   Insert a new heading, item or row.
696   If the command is used at the /beginning/ of a line, and if there is
697   a heading or a plain list item (see [[*Plain Lists]]) at point, the new
698   heading/item is created /before/ the current line.  When used at the
699   beginning of a regular line of text, turn that line into a heading.
701   When this command is used in the middle of a line, the line is split
702   and the rest of the line becomes the new item or headline.  If you
703   do not want the line to be split, customize
704   ~org-M-RET-may-split-line~.
706   Calling the command with a {{{kbd(C-u)}}} prefix unconditionally
707   inserts a new heading at the end of the current subtree, thus
708   preserving its contents.  With a double {{{kbd(C-u C-u)}}} prefix,
709   the new heading is created at the end of the parent subtree instead.
711 - {{{kbd(C-RET)}}} (~org-insert-heading-respect-content~) ::
713   #+kindex: C-RET
714   #+findex: org-insert-heading-respect-content
715   Insert a new heading at the end of the current subtree.
717 - {{{kbd(M-S-RET)}}} (~org-insert-todo-heading~) ::
719   #+kindex: M-S-RET
720   #+findex: org-insert-todo-heading
721   #+vindex: org-treat-insert-todo-heading-as-state-change
722   Insert new TODO entry with same level as current heading.  See also
723   the variable ~org-treat-insert-todo-heading-as-state-change~.
725 - {{{kbd(C-S-RET)}}} (~org-insert-todo-heading-respect-content~) ::
727   #+kindex: C-S-RET
728   #+findex: org-insert-todo-heading-respect-content
729   Insert new TODO entry with same level as current heading.  Like
730   {{{kbd(C-RET)}}}, the new headline is inserted after the current
731   subtree.
733 - {{{kbd(TAB)}}} (~org-cycle~) ::
735   #+kindex: TAB
736   #+findex: org-cycle
737   In a new entry with no text yet, the first {{{kbd(TAB)}}} demotes
738   the entry to become a child of the previous one.  The next
739   {{{kbd(TAB)}}} makes it a parent, and so on, all the way to top
740   level.  Yet another {{{kbd(TAB)}}}, and you are back to the initial
741   level.
743 - {{{kbd(M-LEFT)}}} (~org-do-promote~) ::
745   #+kindex: M-LEFT
746   #+findex: org-do-promote
747   Promote current heading by one level.
749 - {{{kbd(M-RIGHT)}}} (~org-do-demote~) ::
751   #+kindex: M-RIGHT
752   #+findex: org-do-demote
753   Demote current heading by one level.
755 - {{{kbd(M-S-LEFT)}}} (~org-promote-subtree~) ::
757   #+kindex: M-S-LEFT
758   #+findex: org-promote-subtree
759   Promote the current subtree by one level.
761 - {{{kbd(M-S-RIGHT)}}} (~org-demote-subtree~) ::
763   #+kindex: M-S-RIGHT
764   #+findex: org-demote-subtree
765   Demote the current subtree by one level.
767 - {{{kbd(M-UP)}}} (~org-move-subtree-up~) ::
769   #+kindex: M-UP
770   #+findex: org-move-subtree-up
771   Move subtree up, i.e., swap with previous subtree of same level.
773 - {{{kbd(M-DOWN)}}} (~org-move-subtree-down~) ::
775   #+kindex: M-DOWN
776   #+findex: org-move-subtree-down
777   Move subtree down, i.e., swap with next subtree of same level.
779 - {{{kbd(C-c @)}}} (~org-mark-subtree~) ::
781   #+kindex: C-c @@
782   #+findex: org-mark-subtree
783   Mark the subtree at point.  Hitting repeatedly marks subsequent
784   subtrees of the same level as the marked subtree.
786 - {{{kbd(C-c C-x C-w)}}} (~org-cut-subtree~) ::
788   #+kindex: C-c C-x C-w
789   #+findex: org-cut-subtree
790   Kill subtree, i.e., remove it from buffer but save in kill ring.
791   With a numeric prefix argument N, kill N sequential subtrees.
793 - {{{kbd(C-c C-x M-w)}}} (~org-copy-subtree~) ::
795   #+kindex: C-c C-x M-w
796   #+findex: org-copy-subtree
797   Copy subtree to kill ring.  With a numeric prefix argument N, copy
798   the N sequential subtrees.
800 - {{{kbd(C-c C-x C-y)}}} (~org-paste-subtree~) ::
802   #+kindex: C-c C-x C-y
803   #+findex: org-paste-subtree
804   Yank subtree from kill ring.  This does modify the level of the
805   subtree to make sure the tree fits in nicely at the yank position.
806   The yank level can also be specified with a numeric prefix argument,
807   or by yanking after a headline marker like =****=.
809 - {{{kbd(C-y)}}} (~org-yank~) ::
811   #+kindex: C-y
812   #+findex: org-yank
813   #+vindex: org-yank-adjusted-subtrees
814   #+vindex: org-yank-folded-subtrees
815   Depending on the variables ~org-yank-adjusted-subtrees~ and
816   ~org-yank-folded-subtrees~, Org's internal ~yank~ command pastes
817   subtrees folded and in a clever way, using the same command as
818   {{{kbd(C-c C-x C-y)}}}.  With the default settings, no level
819   adjustment takes place, but the yanked tree is folded unless doing
820   so would swallow text previously visible.  Any prefix argument to
821   this command forces a normal ~yank~ to be executed, with the prefix
822   passed along.  A good way to force a normal yank is {{{kbd(C-u
823   C-y)}}}.  If you use ~yank-pop~ after a yank, it yanks previous kill
824   items plainly, without adjustment and folding.
826 - {{{kbd(C-c C-x c)}}} (~org-clone-subtree-with-time-shift~) ::
828   #+kindex: C-c C-x c
829   #+findex: org-clone-subtree-with-time-shift
830   Clone a subtree by making a number of sibling copies of it.  You are
831   prompted for the number of copies to make, and you can also specify
832   if any timestamps in the entry should be shifted.  This can be
833   useful, for example, to create a number of tasks related to a series
834   of lectures to prepare.  For more details, see the docstring of the
835   command ~org-clone-subtree-with-time-shift~.
837 - {{{kbd(C-c C-w)}}} (~org-refile~) ::
839   #+kindex: C-c C-w
840   #+findex: org-refile
841   Refile entry or region to a different location.  See [[*Refile and
842   Copy]].
844 - {{{kbd(C-c ^)}}} (~org-sort~) ::
846   #+kindex: C-c ^
847   #+findex: org-sort
848   Sort same-level entries.  When there is an active region, all
849   entries in the region are sorted.  Otherwise the children of the
850   current headline are sorted.  The command prompts for the sorting
851   method, which can be alphabetically, numerically, by time---first
852   timestamp with active preferred, creation time, scheduled time,
853   deadline time---by priority, by TODO keyword---in the sequence the
854   keywords have been defined in the setup---or by the value of
855   a property.  Reverse sorting is possible as well.  You can also
856   supply your own function to extract the sorting key.  With
857   a {{{kbd(C-u)}}} prefix, sorting is case-sensitive.
859 - {{{kbd(C-x n s)}}} (~org-narrow-to-subtree~) ::
861   #+kindex: C-x n s
862   #+findex: org-narrow-to-subtree
863   Narrow buffer to current subtree.
865 - {{{kbd(C-x n b)}}} (~org-narrow-to-block~) ::
867   #+kindex: C-x n b
868   #+findex: org-narrow-to-block
869   Narrow buffer to current block.
871 - {{{kbd(C-x n w)}}} (~widen~) ::
873   #+kindex: C-x n w
874   #+findex: widen
875   Widen buffer to remove narrowing.
877 - {{{kbd(C-c *)}}} (~org-toggle-heading~) ::
879   #+kindex: C-c *
880   #+findex: org-toggle-heading
881   Turn a normal line or plain list item into a headline---so that it
882   becomes a subheading at its location.  Also turn a headline into
883   a normal line by removing the stars.  If there is an active region,
884   turn all lines in the region into headlines.  If the first line in
885   the region was an item, turn only the item lines into headlines.
886   Finally, if the first line is a headline, remove the stars from all
887   headlines in the region.
889 #+cindex: region, active
890 #+cindex: active region
891 #+cindex: transient mark mode
892 When there is an active region---i.e., when Transient Mark mode is
893 active---promotion and demotion work on all headlines in the region.
894 To select a region of headlines, it is best to place both point and
895 mark at the beginning of a line, mark at the beginning of the first
896 headline, and point at the line just after the last headline to
897 change.  Note that when point is inside a table (see [[*Tables]]), the
898 Meta-Cursor keys have different functionality.
900 ** Sparse Trees
901 :PROPERTIES:
902 :DESCRIPTION: Matches embedded in context.
903 :END:
904 #+cindex: sparse trees
905 #+cindex: trees, sparse
906 #+cindex: folding, sparse trees
907 #+cindex: occur, command
909 #+vindex: org-show-context-detail
910 An important feature of Org mode is the ability to construct /sparse
911 trees/ for selected information in an outline tree, so that the entire
912 document is folded as much as possible, but the selected information
913 is made visible along with the headline structure above it[fn:7].
914 Just try it out and you will see immediately how it works.
916 Org mode contains several commands creating such trees, all these
917 commands can be accessed through a dispatcher:
919 - {{{kbd(C-c /)}}} (~org-sparse-tree~) ::
921   #+kindex: C-c /
922   #+findex: org-sparse-tree
923   This prompts for an extra key to select a sparse-tree creating
924   command.
926 - {{{kbd(C-c / r)}}} or {{{kbd(C-c / /)}}} (~org-occur~) ::
928   #+kindex: C-c / r
929   #+kindex: C-c / /
930   #+findex: org-occur
931   #+vindex: org-remove-highlights-with-change
932   Prompts for a regexp and shows a sparse tree with all matches.  If
933   the match is in a headline, the headline is made visible.  If the
934   match is in the body of an entry, headline and body are made
935   visible.  In order to provide minimal context, also the full
936   hierarchy of headlines above the match is shown, as well as the
937   headline following the match.  Each match is also highlighted; the
938   highlights disappear when the buffer is changed by an editing
939   command, or by pressing {{{kbd(C-c C-c)}}}[fn:8].  When called with
940   a {{{kbd(C-u)}}} prefix argument, previous highlights are kept, so
941   several calls to this command can be stacked.
943 - {{{kbd(M-g n)}}} or {{{kbd(M-g M-n)}}} (~next-error~) ::
945   #+kindex: M-g n
946   #+kindex: M-g M-n
947   #+findex: next-error
948   Jump to the next sparse tree match in this buffer.
950 - {{{kbd(M-g p)}}} or {{{kbd(M-g M-p)}}} (~previous-error~) ::
952   #+kindex: M-g p
953   #+kindex: M-g M-p
954   #+findex: previous-error
955   Jump to the previous sparse tree match in this buffer.
957 #+vindex: org-agenda-custom-commands
958 For frequently used sparse trees of specific search strings, you can
959 use the variable ~org-agenda-custom-commands~ to define fast keyboard
960 access to specific sparse trees.  These commands will then be
961 accessible through the agenda dispatcher (see [[*The Agenda Dispatcher]]).
962 For example:
964 #+begin_src emacs-lisp
965 (setq org-agenda-custom-commands
966       '(("f" occur-tree "FIXME")))
967 #+end_src
969 #+texinfo: @noindent
970 defines the key {{{kbd(f)}}} as a shortcut for creating a sparse tree
971 matching the string =FIXME=.
973 The other sparse tree commands select headings based on TODO keywords,
974 tags, or properties and are discussed later in this manual.
976 #+kindex: C-c C-e v
977 #+cindex: printing sparse trees
978 #+cindex: visible text, printing
979 To print a sparse tree, you can use the Emacs command
980 ~ps-print-buffer-with-faces~ which does not print invisible parts of
981 the document.  Or you can use the command {{{kbd(C-c C-e v)}}} to
982 export only the visible part of the document and print the resulting
983 file.
985 ** Plain Lists
986 :PROPERTIES:
987 :DESCRIPTION: Additional structure within an entry.
988 :END:
989 #+cindex: plain lists
990 #+cindex: lists, plain
991 #+cindex: lists, ordered
992 #+cindex: ordered lists
994 Within an entry of the outline tree, hand-formatted lists can provide
995 additional structure.  They also provide a way to create lists of
996 checkboxes (see [[*Checkboxes]]).  Org supports editing such lists, and
997 every exporter (see [[*Exporting]]) can parse and format them.
999 Org knows ordered lists, unordered lists, and description lists.
1001 #+attr_texinfo: :indic @bullet
1002 - /Unordered/ list items start with =-=, =+=, or =*=[fn:9] as bullets.
1005   #+vindex: org-plain-list-ordered-item-terminator
1006   #+vindex: org-alphabetical-lists
1007   /Ordered/ list items start with a numeral followed by either
1008   a period or a right parenthesis[fn:10], such as =1.= or =1)=[fn:11]
1009   If you want a list to start with a different value---e.g.,
1010   20---start the text of the item with =[@20]=[fn:12].  Those
1011   constructs can be used in any item of the list in order to enforce
1012   a particular numbering.
1014 - /Description/ list items are unordered list items, and contain the
1015   separator =::= to distinguish the description /term/ from the
1016   description.
1018 Items belonging to the same list must have the same indentation on the
1019 first line.  In particular, if an ordered list reaches number =10.=,
1020 then the 2-digit numbers must be written left-aligned with the other
1021 numbers in the list.  An item ends before the next line that is less
1022 or equally indented than its bullet/number.
1024 A list ends whenever every item has ended, which means before any line
1025 less or equally indented than items at top level.  It also ends before
1026 two blank lines.  In that case, all items are closed.  Here is an
1027 example:
1029 #+begin_example
1030 ,* Lord of the Rings
1031 My favorite scenes are (in this order)
1032 1. The attack of the Rohirrim
1033 2. Eowyn's fight with the witch king
1034    + this was already my favorite scene in the book
1035    + I really like Miranda Otto.
1036 3. Peter Jackson being shot by Legolas
1037    - on DVD only
1038    He makes a really funny face when it happens.
1039 But in the end, no individual scenes matter but the film as a whole.
1040 Important actors in this film are:
1041 - Elijah Wood :: He plays Frodo
1042 - Sean Astin :: He plays Sam, Frodo's friend. I still remember him
1043      very well from his role as Mikey Walsh in /The Goonies/.
1044 #+end_example
1046 Org supports these lists by tuning filling and wrapping commands to
1047 deal with them correctly, and by exporting them properly (see
1048 [[*Exporting]]).  Since indentation is what governs the structure of these
1049 lists, many structural constructs like =#+BEGIN_= blocks can be
1050 indented to signal that they belong to a particular item.
1052 #+vindex: org-list-demote-modify-bullet
1053 #+vindex: org-list-indent-offset
1054 If you find that using a different bullet for a sub-list---than that
1055 used for the current list-level---improves readability, customize the
1056 variable ~org-list-demote-modify-bullet~.  To get a greater difference
1057 of indentation between items and theirs sub-items, customize
1058 ~org-list-indent-offset~.
1060 #+vindex: org-list-automatic-rules
1061 The following commands act on items when point is in the first line of
1062 an item---the line with the bullet or number.  Some of them imply the
1063 application of automatic rules to keep list structure intact.  If some
1064 of these actions get in your way, configure ~org-list-automatic-rules~
1065 to disable them individually.
1067 #+attr_texinfo: :sep ,
1068 - {{{kbd(TAB)}}} (~org-cycle~) ::
1070   #+cindex: cycling, in plain lists
1071   #+kindex: TAB
1072   #+findex: org-cycle
1073   #+vindex: org-cycle-include-plain-lists
1074   Items can be folded just like headline levels.  Normally this works
1075   only if point is on a plain list item.  For more details, see the
1076   variable ~org-cycle-include-plain-lists~.  If this variable is set
1077   to ~integrate~, plain list items are treated like low-level
1078   headlines.  The level of an item is then given by the indentation of
1079   the bullet/number.  Items are always subordinate to real headlines,
1080   however; the hierarchies remain completely separated.  In a new item
1081   with no text yet, the first {{{kbd(TAB)}}} demotes the item to
1082   become a child of the previous one.  Subsequent {{{kbd(TAB)}}}s move
1083   the item to meaningful levels in the list and eventually get it back
1084   to its initial position.
1086 - {{{kbd(M-RET)}}} (~org-insert-heading~) ::
1088   #+kindex: M-RET
1089   #+findex: org-insert-heading
1090   #+vindex: org-M-RET-may-split-line
1091   Insert new item at current level.  With a prefix argument, force
1092   a new heading (see [[*Structure Editing]]).  If this command is used in
1093   the middle of an item, that item is /split/ in two, and the second
1094   part becomes the new item[fn:13].  If this command is executed
1095   /before item's body/, the new item is created /before/ the current
1096   one.
1098 - {{{kbd(M-S-RET)}}} ::
1100   #+kindex: M-S-RET
1101   Insert a new item with a checkbox (see [[*Checkboxes]]).
1103 - {{{kbd(S-UP)}}}, {{{kbd(S-DOWN)}}} ::
1105   #+kindex: S-UP
1106   #+kindex: S-DOWN
1107   #+cindex: shift-selection-mode
1108   #+vindex: org-support-shift-select
1109   #+vindex: org-list-use-circular-motion
1110   Jump to the previous/next item in the current list, but only if
1111   ~org-support-shift-select~ is off[fn:14].  If not, you can still use
1112   paragraph jumping commands like {{{kbd(C-UP)}}} and
1113   {{{kbd(C-DOWN)}}} to quite similar effect.
1115 - {{{kbd(M-UP)}}}, {{{kbd(M-DOWN)}}} ::
1117   #+kindex: M-UP
1118   #+kindex: M-DOWN
1119   Move the item including subitems up/down[fn:15], i.e., swap with
1120   previous/next item of same indentation.  If the list is ordered,
1121   renumbering is automatic.
1123 - {{{kbd(M-LEFT)}}}, {{{kbd(M-RIGHT)}}} ::
1125   #+kindex: M-LEFT
1126   #+kindex: M-RIGHT
1127   Decrease/increase the indentation of an item, leaving children
1128   alone.
1130 - {{{kbd(M-S-LEFT)}}}, {{{kbd(M-S-RIGHT)}}} ::
1132   #+kindex: M-S-LEFT
1133   #+kindex: M-S-RIGHT
1134   Decrease/increase the indentation of the item, including subitems.
1135   Initially, the item tree is selected based on current indentation.
1136   When these commands are executed several times in direct succession,
1137   the initially selected region is used, even if the new indentation
1138   would imply a different hierarchy.  To use the new hierarchy, break
1139   the command chain by moving point.
1141   As a special case, using this command on the very first item of
1142   a list moves the whole list.  This behavior can be disabled by
1143   configuring ~org-list-automatic-rules~.  The global indentation of
1144   a list has no influence on the text /after/ the list.
1146 - {{{kbd(C-c C-c)}}} ::
1148   #+kindex: C-c C-c
1149   If there is a checkbox (see [[*Checkboxes]]) in the item line, toggle
1150   the state of the checkbox.  In any case, verify bullets and
1151   indentation consistency in the whole list.
1153 - {{{kbd(C-c -)}}} ::
1155   #+kindex: C-c -
1156   #+vindex: org-plain-list-ordered-item-terminator
1157   Cycle the entire list level through the different itemize/enumerate
1158   bullets (=-=, =+=, =*=, =1.=, =1)=) or a subset of them, depending
1159   on ~org-plain-list-ordered-item-terminator~, the type of list, and
1160   its indentation.  With a numeric prefix argument N, select the Nth
1161   bullet from this list.  If there is an active region when calling
1162   this, selected text is changed into an item.  With a prefix
1163   argument, all lines are converted to list items.  If the first line
1164   already was a list item, any item marker is removed from the list.
1165   Finally, even without an active region, a normal line is converted
1166   into a list item.
1168 - {{{kbd(C-c *)}}} ::
1170   #+kindex: C-c *
1171   Turn a plain list item into a headline---so that it becomes
1172   a subheading at its location.  See [[*Structure Editing]], for
1173   a detailed explanation.
1175 - {{{kbd(C-c C-*)}}} ::
1177   #+kindex: C-c C-*
1178   Turn the whole plain list into a subtree of the current heading.
1179   Checkboxes (see [[*Checkboxes]]) become =TODO=, respectively =DONE=,
1180   keywords when unchecked, respectively checked.
1182 - {{{kbd(S-LEFT)}}}, {{{kbd(S-RIGHT)}}} ::
1184   #+vindex: org-support-shift-select
1185   #+kindex: S-LEFT
1186   #+kindex: S-RIGHT
1187   This command also cycles bullet styles when point is in on the
1188   bullet or anywhere in an item line, details depending on
1189   ~org-support-shift-select~.
1191 - {{{kbd(C-c ^)}}} ::
1193   #+kindex: C-c ^
1194   #+cindex: sorting, of plain list
1195   Sort the plain list.  Prompt for the sorting method: numerically,
1196   alphabetically, by time, or by custom function.
1198 ** Drawers
1199 :PROPERTIES:
1200 :DESCRIPTION: Tucking stuff away.
1201 :END:
1202 #+cindex: drawers
1203 #+cindex: visibility cycling, drawers
1205 Sometimes you want to keep information associated with an entry, but
1206 you normally do not want to see it.  For this, Org mode has /drawers/.
1207 They can contain anything but a headline and another drawer.  Drawers
1208 look like this:
1210 #+begin_example
1211 ,** This is a headline
1212 Still outside the drawer
1213 :DRAWERNAME:
1214 This is inside the drawer.
1215 :END:
1216 After the drawer.
1217 #+end_example
1219 #+kindex: C-c C-x d
1220 #+findex: org-insert-drawer
1221 You can interactively insert a drawer at point by calling
1222 ~org-insert-drawer~, which is bound to {{{kbd(C-c C-x d)}}}.  With an
1223 active region, this command puts the region inside the drawer.  With
1224 a prefix argument, this command calls ~org-insert-property-drawer~,
1225 which creates a =PROPERTIES= drawer right below the current headline.
1226 Org mode uses this special drawer for storing properties (see
1227 [[*Properties and Columns]]).  You cannot use it for anything else.
1229 Completion over drawer keywords is also possible using
1230 {{{kbd(M-TAB)}}}[fn:16].
1232 Visibility cycling (see [[*Visibility Cycling]]) on the headline hides and
1233 shows the entry, but keep the drawer collapsed to a single line.  In
1234 order to look inside the drawer, you need to move point to the drawer
1235 line and press {{{kbd(TAB)}}} there.
1237 You can also arrange for state change notes (see [[Tracking TODO state
1238 changes]]) and clock times (see [[*Clocking Work Time]]) to be stored in
1239 a =LOGBOOK= drawer.  If you want to store a quick note there, in
1240 a similar way to state changes, use
1242 - {{{kbd(C-c C-z)}}} ::
1244   #+kindex: C-c C-z
1245   Add a time-stamped note to the =LOGBOOK= drawer.
1247 ** Blocks
1248 :PROPERTIES:
1249 :DESCRIPTION: Folding blocks.
1250 :END:
1251 #+vindex: org-hide-block-startup
1252 #+cindex: blocks, folding
1254 Org mode uses =#+BEGIN= ... =#+END= blocks for various purposes from
1255 including source code examples (see [[*Literal Examples]]) to capturing
1256 time logging information (see [[*Clocking Work Time]]).  These blocks can
1257 be folded and unfolded by pressing {{{kbd(TAB)}}} in the =#+BEGIN=
1258 line.  You can also get all blocks folded at startup by configuring
1259 the variable ~org-hide-block-startup~ or on a per-file basis by using
1261 #+cindex: STARTUP, keyword
1262 #+begin_example
1263 ,#+STARTUP: hideblocks
1264 ,#+STARTUP: nohideblocks
1265 #+end_example
1267 * Tables
1268 :PROPERTIES:
1269 :DESCRIPTION: Pure magic for quick formatting.
1270 :END:
1271 #+cindex: tables
1272 #+cindex: editing tables
1274 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1275 calculations are supported using the Emacs Calc package (see [[info:calc][GNU Emacs
1276 Calculator Manual]]).
1278 ** Built-in Table Editor
1279 :PROPERTIES:
1280 :DESCRIPTION: Simple tables.
1281 :END:
1282 #+cindex: table editor, built-in
1284 #+cindex: header lines, in tables
1285 #+cindex: horizontal rule, in tables
1286 #+cindex: row separator, in tables
1287 #+cindex: table syntax
1288 Org makes it easy to format tables in plain ASCII.  Any line with =|=
1289 as the first non-whitespace character is considered part of a table.
1290 =|= is also the column separator[fn:17].  Moreover, a line starting
1291 with =|-= is a horizontal rule.  It separates rows explicitely.  Rows
1292 before the first horizontal rule are header lines. A table might look
1293 like this:
1295 #+begin_example
1296 | Name  | Phone | Age |
1297 |-------+-------+-----|
1298 | Peter |  1234 |  17 |
1299 | Anna  |  4321 |  25 |
1300 #+end_example
1302 A table is re-aligned automatically each time you press
1303 {{{kbd(TAB)}}}, {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} inside the table.
1304 {{{kbd(TAB)}}} also moves to the next field---{{{kbd(RET)}}} to the
1305 next row---and creates new table rows at the end of the table or
1306 before horizontal lines.  The indentation of the table is set by the
1307 first line.  Horizontal rules are automatically expanded on every
1308 re-align to span the whole table width.  So, to create the above
1309 table, you would only type
1311 #+begin_example
1312 |Name|Phone|Age|
1314 #+end_example
1316 #+texinfo: @noindent
1317 and then press {{{kbd(TAB)}}} to align the table and start filling in
1318 fields.  Even faster would be to type =|Name|Phone|Age= followed by
1319 {{{kbd(C-c RET)}}}.
1321 When typing text into a field, Org treats {{{kbd(DEL)}}},
1322 {{{kbd(Backspace)}}}, and all character keys in a special way, so that
1323 inserting and deleting avoids shifting other fields.  Also, when
1324 typing /immediately/ after point was moved into a new field with
1325 {{{kbd(TAB)}}}, {{{kbd(S-TAB)}}} or {{{kbd(RET)}}}, the field is
1326 automatically made blank.  If this behavior is too unpredictable for
1327 you, configure the option ~org-table-auto-blank-field~.
1329 *** Creation and conversion
1330 :PROPERTIES:
1331 :UNNUMBERED: notoc
1332 :END:
1334 - {{{kbd(C-c |)}}} (~org-table-create-or-convert-from-region~) ::
1336   #+kindex: C-c |
1337   #+findex: org-table-create-or-convert-from-region
1338   Convert the active region to table.  If every line contains at least
1339   one {{{kbd(TAB)}}} character, the function assumes that the material
1340   is tab separated.  If every line contains a comma, comma-separated
1341   values (CSV) are assumed.  If not, lines are split at whitespace
1342   into fields.  You can use a prefix argument to force a specific
1343   separator: {{{kbd(C-u)}}} forces CSV, {{{kbd(C-u C-u)}}} forces
1344   {{{kbd(TAB)}}}, {{{kbd(C-u C-u C-u)}}} prompts for a regular
1345   expression to match the separator, and a numeric argument
1346   N indicates that at least N consecutive spaces, or alternatively
1347   a {{{kbd(TAB)}}} will be the separator.
1349   If there is no active region, this command creates an empty Org
1350   table.  But it is easier just to start typing, like {{{kbd(|
1351   N a m e | P h o n e | A g e RET | - TAB)}}}.
1353 *** Re-aligning and field motion
1354 :PROPERTIES:
1355 :UNNUMBERED: notoc
1356 :END:
1358 - {{{kbd(C-c C-c)}}} (~org-table-align~) ::
1360   #+kindex: C-c C-c
1361   #+findex: org-table-align
1362   Re-align the table without moving point.
1364 - {{{kbd(TAB)}}} (~org-table-next-field~) ::
1366   #+kindex: TAB
1367   #+findex: org-table-next-field
1368   Re-align the table, move to the next field.  Creates a new row if
1369   necessary.
1371 - {{{kbd(C-c SPC)}}} (~org-table-blank-field~) ::
1373   #+kindex: C-c SPC
1374   #+findex: org-table-blank-field
1375   Blank the field at point.
1377 - {{{kbd(S-TAB)}}} (~org-table-previous-field~) ::
1379   #+kindex: S-TAB
1380   #+findex: org-table-previous-field
1381   Re-align, move to previous field.
1383 - {{{kbd(RET)}}} (~org-table-next-row~) ::
1385   #+kindex: RET
1386   #+findex: org-table-next-row
1387   Re-align the table and move down to next row.  Creates a new row if
1388   necessary.  At the beginning or end of a line, {{{kbd(RET)}}} still
1389   inserts a new line, so it can be used to split a table.
1391 - {{{kbd(M-a)}}} (~org-table-beginning-of-field~) ::
1393   #+kindex: M-a
1394   #+findex: org-table-beginning-of-field
1395   Move to beginning of the current table field, or on to the previous
1396   field.
1398 - {{{kbd(M-e)}}} (~org-table-end-of-field~) ::
1400   #+kindex: M-e
1401   #+findex: org-table-end-of-field
1402   Move to end of the current table field, or on to the next field.
1404 *** Column and row editing
1405 :PROPERTIES:
1406 :UNNUMBERED: notoc
1407 :END:
1409 - {{{kbd(M-LEFT)}}} (~org-table-move-column-left~) ::
1411   #+kindex: M-LEFT
1412   #+findex: org-table-move-column-left
1413   Move the current column left.
1415 - {{{kbd(M-RIGHT)}}} (~org-table-move-column-right~) ::
1417   #+kindex: M-RIGHT
1418   #+findex: org-table-move-column-right
1419   Move the current column right.
1421 - {{{kbd(M-S-LEFT)}}} (~org-table-delete-column~) ::
1423   #+kindex: M-S-LEFT
1424   #+findex: org-table-delete-column
1425   Kill the current column.
1427 - {{{kbd(M-S-RIGHT)}}} (~org-table-insert-column~) ::
1429   #+kindex: M-S-RIGHT
1430   #+findex: org-table-insert-column
1431   Insert a new column to the left of point position.
1433 - {{{kbd(M-UP)}}} (~org-table-move-row-up~) ::
1435   #+kindex: M-UP
1436   #+findex: org-table-move-row-up
1437   Move the current row up.
1439 - {{{kbd(M-DOWN)}}} (~org-table-move-row-down~) ::
1441   #+kindex: M-DOWN
1442   #+findex: org-table-move-row-down
1443   Move the current row down.
1445 - {{{kbd(M-S-UP)}}} (~org-table-kill-row~) ::
1447   #+kindex: M-S-UP
1448   #+findex: org-table-kill-row
1449   Kill the current row or horizontal line.
1451 - {{{kbd(S-UP)}}} (~org-table-move-cell-up~) ::
1453   #+kindex: S-UP
1454   #+findex: org-table-move-cell-up
1455   Move cell up by swapping with adjacent cell.
1457 - {{{kbd(S-DOWN)}}} (~org-table-move-cell-down~) ::
1459   #+kindex: S-DOWN
1460   #+findex: org-table-move-cell-down
1461   Move cell down by swapping with adjacent cell.
1463 - {{{kbd(S-LEFT)}}} (~org-table-move-cell-left~) ::
1465   #+kindex: S-LEFT
1466   #+findex: org-table-move-cell-left
1467   Move cell left by swapping with adjacent cell.
1469 - {{{kbd(S-RIGHT)}}} (~org-table-move-cell-right~) ::
1471   #+kindex: S-RIGHT
1472   #+findex: org-table-move-cell-right
1473   Move cell right by swapping with adjacent cell.
1475 - {{{kbd(M-S-DOWN)}}} (~org-table-insert-row~) ::
1477   #+kindex: M-S-DOWN
1478   #+findex: org-table-insert-row
1479   Insert a new row above the current row.  With a prefix argument, the
1480   line is created below the current one.
1482 - {{{kbd(C-c -)}}} (~org-table-insert-hline~) ::
1484   #+kindex: C-c -
1485   #+findex: org-table-insert-hline
1486   Insert a horizontal line below current row.  With a prefix argument,
1487   the line is created above the current line.
1489 - {{{kbd(C-c RET)}}} (~org-table-hline-and-move~) ::
1491   #+kindex: C-c RET
1492   #+findex: org-table-hline-and-move
1493   Insert a horizontal line below current row, and move point into the
1494   row below that line.
1496 - {{{kbd(C-c ^)}}} (~org-table-sort-lines~) ::
1498   #+kindex: C-c ^
1499   #+findex: org-table-sort-lines
1500   Sort the table lines in the region.  The position of point indicates
1501   the column to be used for sorting, and the range of lines is the
1502   range between the nearest horizontal separator lines, or the entire
1503   table.  If point is before the first column, you are prompted for
1504   the sorting column.  If there is an active region, the mark
1505   specifies the first line and the sorting column, while point should
1506   be in the last line to be included into the sorting.  The command
1507   prompts for the sorting type, alphabetically, numerically, or by
1508   time.  You can sort in normal or reverse order.  You can also supply
1509   your own key extraction and comparison functions.  When called with
1510   a prefix argument, alphabetic sorting is case-sensitive.
1512 *** Regions
1513 :PROPERTIES:
1514 :UNNUMBERED: notoc
1515 :END:
1517 - {{{kbd(C-c C-x M-w)}}} (~org-table-copy-region~) ::
1519   #+kindex: C-c C-x M-w
1520   #+findex: org-table-copy-region
1521   Copy a rectangular region from a table to a special clipboard.
1522   Point and mark determine edge fields of the rectangle.  If there is
1523   no active region, copy just the current field.  The process ignores
1524   horizontal separator lines.
1526 - {{{kbd(C-c C-x C-w)}}} (~org-table-cut-region~) ::
1528   #+kindex: C-c C-x C-w
1529   #+findex: org-table-cut-region
1530   Copy a rectangular region from a table to a special clipboard, and
1531   blank all fields in the rectangle.  So this is the "cut" operation.
1533 - {{{kbd(C-c C-x C-y)}}} (~org-table-paste-rectangle~) ::
1535   #+kindex: C-c C-x C-y
1536   #+findex: org-table-paste-rectangle
1537   Paste a rectangular region into a table.  The upper left corner ends
1538   up in the current field.  All involved fields are overwritten.  If
1539   the rectangle does not fit into the present table, the table is
1540   enlarged as needed.  The process ignores horizontal separator lines.
1542 - {{{kbd(M-RET)}}} (~org-table-wrap-region~) ::
1544   #+kindex: M-RET
1545   #+findex: org-table-wrap-region
1546   Split the current field at point position and move the rest to the
1547   line below.  If there is an active region, and both point and mark
1548   are in the same column, the text in the column is wrapped to minimum
1549   width for the given number of lines.  A numeric prefix argument may
1550   be used to change the number of desired lines.  If there is no
1551   region, but you specify a prefix argument, the current field is made
1552   blank, and the content is appended to the field above.
1554 *** Calculations
1555 :PROPERTIES:
1556 :UNNUMBERED: notoc
1557 :END:
1559 #+cindex: formula, in tables
1560 #+cindex: calculations, in tables
1562 - {{{kbd(C-c +)}}} (~org-table-sum~) ::
1564   #+kindex: C-c +
1565   #+findex: org-table-sum
1566   Sum the numbers in the current column, or in the rectangle defined
1567   by the active region.  The result is shown in the echo area and can
1568   be inserted with {{{kbd(C-y)}}}.
1570 - {{{kbd(S-RET)}}} (~org-table-copy-down~) ::
1572   #+kindex: S-RET
1573   #+findex: org-table-copy-down
1574   #+vindex: org-table-copy-increment
1575   When current field is empty, copy from first non-empty field above.
1576   When not empty, copy current field down to next row and move point
1577   along with it.  Depending on the variable
1578   ~org-table-copy-increment~, integer field values can be incremented
1579   during copy.  Integers that are too large are not incremented,
1580   however.  Also, a ~0~ prefix argument temporarily disables the
1581   increment.  This key is also used by shift-selection and related
1582   modes (see [[*Packages that conflict with Org mode]]).
1584 *** Miscellaneous
1585 :PROPERTIES:
1586 :UNNUMBERED: notoc
1587 :END:
1589 - {{{kbd(C-c `)}}} (~org-table-edit-field~) ::
1591   #+kindex: C-c `
1592   #+findex: org-table-edit-field
1593   Edit the current field in a separate window.  This is useful for
1594   fields that are not fully visible (see [[*Column Width and Alignment]]).
1595   When called with a {{{kbd(C-u)}}} prefix, just make the full field
1596   visible, so that it can be edited in place.  When called with two
1597   {{{kbd(C-u)}}} prefixes, make the editor window follow point through
1598   the table and always show the current field.  The follow mode exits
1599   automatically when point leaves the table, or when you repeat this
1600   command with {{{kbd(C-u C-u C-c `)}}}.
1602 - {{{kbd(M-x org-table-import)}}} ::
1604   #+findex: org-table-import
1605   Import a file as a table.  The table should be TAB or whitespace
1606   separated.  Use, for example, to import a spreadsheet table or data
1607   from a database, because these programs generally can write
1608   TAB-separated text files.  This command works by inserting the file
1609   into the buffer and then converting the region to a table.  Any
1610   prefix argument is passed on to the converter, which uses it to
1611   determine the separator.
1613 - {{{kbd(C-c |)}}} (~org-table-create-or-convert-from-region~) ::
1615   #+kindex: C-c |
1616   #+findex: org-table-create-or-convert-from-region
1617   Tables can also be imported by pasting tabular text into the Org
1618   buffer, selecting the pasted text with {{{kbd(C-x C-x)}}} and then
1619   using the {{{kbd(C-c |)}}} command (see [[*Creation and conversion]]).
1621 - {{{kbd(M-x org-table-export)}}} ::
1623   #+findex: org-table-export
1624   #+vindex: org-table-export-default-format
1625   Export the table, by default as a TAB-separated file.  Use for data
1626   exchange with, for example, spreadsheet or database programs.  The
1627   format used to export the file can be configured in the variable
1628   ~org-table-export-default-format~.  You may also use properties
1629   =TABLE_EXPORT_FILE= and =TABLE_EXPORT_FORMAT= to specify the file
1630   name and the format for table export in a subtree.  Org supports
1631   quite general formats for exported tables.  The exporter format is
1632   the same as the format used by Orgtbl radio tables, see [[*Translator
1633   functions]], for a detailed description.
1635 ** Column Width and Alignment
1636 :PROPERTIES:
1637 :DESCRIPTION: Overrule the automatic settings.
1638 :END:
1639 #+cindex: narrow columns in tables
1640 #+cindex: alignment in tables
1642 The width of columns is automatically determined by the table editor.
1643 The alignment of a column is determined automatically from the
1644 fraction of number-like versus non-number fields in the column.
1646 #+vindex: org-table-automatic-realign
1647 Editing a field may modify alignment of the table.  Moving
1648 a contiguous row or column---i.e., using {{{kbd(TAB)}}} or
1649 {{{kbd(RET)}}}---automatically re-aligns it.  If you want to disable
1650 this behavior, set ~org-table-automatic-realign~ to ~nil~.  In any
1651 case, you can always align manually a table:
1653 - {{{kbd(C-c C-c)}}} (~org-table-align~) ::
1655   #+kindex: C-c C-c
1656   #+findex: org-table-align
1657   Align the current table.
1659 #+vindex: org-startup-align-all-tables
1660 Setting the option ~org-startup-align-all-tables~ re-aligns all tables
1661 in a file upon visiting it.  You can also set this option on
1662 a per-file basis with:
1664 #+begin_example
1665 ,#+STARTUP: align
1666 ,#+STARTUP: noalign
1667 #+end_example
1669 Sometimes a single field or a few fields need to carry more text,
1670 leading to inconveniently wide columns.  Maybe you want to hide away
1671 several columns or display them with a fixed width, regardless of
1672 content, as shown in the following example.
1674 #+begin_example
1675 |---+---------------------+--------|           |---+-------…|…|
1676 |   | <6>                 |        |           |   | <6>   â€¦|…|
1677 | 1 | one                 | some   |   ----\   | 1 | one   â€¦|…|
1678 | 2 | two                 | boring |   ----/   | 2 | two   â€¦|…|
1679 | 3 | This is a long text | column |           | 3 | This i…|…|
1680 |---+---------------------+--------|           |---+-------…|…|
1681 #+end_example
1683 To set the width of a column, one field anywhere in the column may
1684 contain just the string =<N>= where {{{var(N)}}} specifies the width
1685 as a number of characters.  You control displayed width of columns
1686 with the following tools:
1688 - {{{kbd(C-c TAB)}}} (~org-table-toggle-column-width~) ::
1690   #+kindex: C-c TAB
1691   #+findex: org-table-toggle-column-width
1692   Shrink or expand current column.
1694   If a width cookie specifies a width W for the column, shrinking it
1695   displays the first W visible characters only.  Otherwise, the column
1696   is shrunk to a single character.
1698   When called before the first column or after the last one, ask for
1699   a list of column ranges to operate on.
1701 - {{{kbd(C-u C-c TAB)}}} (~org-table-shrink~) ::
1703   #+kindex: C-u C-c TAB
1704   #+findex: org-table-shrink
1705   Shrink all columns with a column width.  Expand the others.
1707 - {{{kbd(C-u C-u C-c TAB)}}} (~org-table-expand~) ::
1709   #+kindex: C-u C-u C-c TAB
1710   #+findex: org-table-expand
1711   Expand all columns.
1713 To see the full text of a shrunk field, hold the mouse over it:
1714 a tool-tip window then shows the full contents of the field.
1715 Alternatively, {{{kbd(C-h .)}}} (~display-local-help~) reveals them,
1716 too.  For convenience, any change near the shrunk part of a column
1717 expands it.
1719 #+vindex: org-startup-shrink-all-tables
1720 Setting the option ~org-startup-shrink-all-tables~ shrinks all columns
1721 containing a width cookie in a file the moment it is visited.  You can
1722 also set this option on a per-file basis with:
1724 : #+STARTUP: shrink
1726 If you would like to overrule the automatic alignment of number-rich
1727 columns to the right and of string-rich columns to the left, you can
1728 use =<r>=, =<c>= or =<l>= in a similar fashion.  You may also combine
1729 alignment and field width like this: =<r10>=.
1731 Lines which only contain these formatting cookies are removed
1732 automatically upon exporting the document.
1734 ** Column Groups
1735 :PROPERTIES:
1736 :DESCRIPTION: Grouping to trigger vertical lines.
1737 :END:
1738 #+cindex: grouping columns in tables
1740 When Org exports tables, it does so by default without vertical lines
1741 because that is visually more satisfying in general.  Occasionally
1742 however, vertical lines can be useful to structure a table into groups
1743 of columns, much like horizontal lines can do for groups of rows.  In
1744 order to specify column groups, you can use a special row where the
1745 first field contains only =/=.  The further fields can either contain
1746 =<= to indicate that this column should start a group, =>= to indicate
1747 the end of a column, or =<>= (no space between =<= and =>=) to make
1748 a column a group of its own.  Upon export, boundaries between column
1749 groups are marked with vertical lines.  Here is an example:
1751 #+begin_example
1752 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1753 |---+-----+-----+-----+---------+------------|
1754 | / |  <  |     |  >  |       < |          > |
1755 | 1 |  1  |  1  |  1  |       1 |          1 |
1756 | 2 |  4  |  8  | 16  |  1.4142 |     1.1892 |
1757 | 3 |  9  | 27  | 81  |  1.7321 |     1.3161 |
1758 |---+-----+-----+-----+---------+------------|
1759 ,#+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
1760 #+end_example
1762 It is also sufficient to just insert the column group starters after
1763 every vertical line you would like to have:
1765 #+begin_example
1766 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1767 |---+-----+-----+-----+---------+------------|
1768 | / | <   |     |     | <       |            |
1769 #+end_example
1771 ** The Orgtbl Minor Mode
1772 :PROPERTIES:
1773 :DESCRIPTION: The table editor as minor mode.
1774 :ALT_TITLE: Orgtbl Mode
1775 :END:
1776 #+cindex: Orgtbl mode
1777 #+cindex: minor mode for tables
1779 #+findex: orgtbl-mode
1780 If you like the intuitive way the Org table editor works, you might
1781 also want to use it in other modes like Text mode or Mail mode.  The
1782 minor mode Orgtbl mode makes this possible.  You can always toggle the
1783 mode with {{{kbd(M-x orgtbl-mode)}}}.  To turn it on by default, for
1784 example in Message mode, use
1786 #+begin_src emacs-lisp
1787 (add-hook 'message-mode-hook 'turn-on-orgtbl)
1788 #+end_src
1790 Furthermore, with some special setup, it is possible to maintain
1791 tables in arbitrary syntax with Orgtbl mode.  For example, it is
1792 possible to construct LaTeX tables with the underlying ease and power
1793 of Orgtbl mode, including spreadsheet capabilities.  For details, see
1794 [[*Tables in Arbitrary Syntax]].
1796 ** The Spreadsheet
1797 :PROPERTIES:
1798 :DESCRIPTION: The table editor has spreadsheet capabilities.
1799 :END:
1800 #+cindex: calculations, in tables
1801 #+cindex: spreadsheet capabilities
1802 #+cindex: Calc package
1804 The table editor makes use of the Emacs Calc package to implement
1805 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms
1806 to derive fields from other fields.  While fully featured, Org's
1807 implementation is not identical to other spreadsheets.  For example,
1808 Org knows the concept of a /column formula/ that will be applied to
1809 all non-header fields in a column without having to copy the formula
1810 to each relevant field.  There is also a formula debugger, and a
1811 formula editor with features for highlighting fields in the table
1812 corresponding to the references at point in the formula, moving these
1813 references by arrow keys.
1815 *** References
1816 :PROPERTIES:
1817 :DESCRIPTION: How to refer to another field or range.
1818 :END:
1819 #+cindex: references
1821 To compute fields in the table from other fields, formulas must
1822 reference other fields or ranges.  In Org, fields can be referenced by
1823 name, by absolute coordinates, and by relative coordinates.  To find
1824 out what the coordinates of a field are, press {{{kbd(C-c ?)}}} in
1825 that field, or press {{{kbd(C-c })}}} to toggle the display of a grid.
1827 **** Field references
1828 :PROPERTIES:
1829 :UNNUMBERED: notoc
1830 :END:
1832 #+cindex: field references
1833 #+cindex: references, to fields
1834 Formulas can reference the value of another field in two ways.  Like
1835 in any other spreadsheet, you may reference fields with
1836 a letter/number combination like =B3=, meaning the second field in the
1837 third row.  However, Org prefers to use another, more general
1838 representation that looks like this:[fn:18]
1840 : @ROW$COLUMN
1842 Column specifications can be absolute like =$1=, =$2=, ..., =$N=, or
1843 relative to the current column, i.e., the column of the field which is
1844 being computed, like =$+1= or =$-2=.  =$<= and =$>= are immutable
1845 references to the first and last column, respectively, and you can use
1846 =$>>>= to indicate the third column from the right.
1848 The row specification only counts data lines and ignores horizontal
1849 separator lines, or "hlines".  Like with columns, you can use absolute
1850 row numbers =@1=, =@2=, ..., =@N=, and row numbers relative to the
1851 current row like =@+3= or =@-1=.  =@<= and =@>= are immutable
1852 references the first and last row in the table, respectively.  You may
1853 also specify the row relative to one of the hlines: =@I= refers to the
1854 first hline, =@II= to the second, etc.  =@-I= refers to the first such
1855 line above the current line, =@+I= to the first such line below the
1856 current line.  You can also write =@III+2= which is the second data
1857 line after the third hline in the table.
1859 =@0= and =$0= refer to the current row and column, respectively, i.e.,
1860 to the row/column for the field being computed.  Also, if you omit
1861 either the column or the row part of the reference, the current
1862 row/column is implied.
1864 Org's references with /unsigned/ numbers are fixed references in the
1865 sense that if you use the same reference in the formula for two
1866 different fields, the same field is referenced each time.  Org's
1867 references with /signed/ numbers are floating references because the
1868 same reference operator can reference different fields depending on
1869 the field being calculated by the formula.
1871 Here are a few examples:
1873 #+attr_texinfo: :columns 0.2 0.8
1874 | =@2$3=   | 2nd row, 3rd column (same as =C2=)                 |
1875 | =$5=     | column 5 in the current row (same as =E&=)         |
1876 | =@2=     | current column, row 2                              |
1877 | =@-1$-3= | field one row up, three columns to the left        |
1878 | =@-I$2=  | field just under hline above current row, column 2 |
1879 | =@>$5=   | field in the last row, in column 5                 |
1881 **** Range references
1882 :PROPERTIES:
1883 :UNNUMBERED: notoc
1884 :END:
1886 #+cindex: range references
1887 #+cindex: references, to ranges
1888 You may reference a rectangular range of fields by specifying two
1889 field references connected by two dots =..=.  If both fields are in
1890 the current row, you may simply use =$2..$7=, but if at least one
1891 field is in a different row, you need to use the general =@ROW$COLUMN=
1892 format at least for the first field, i.e., the reference must start
1893 with =@= in order to be interpreted correctly.  Examples:
1895 #+attr_texinfo: :columns 0.2 0.8
1896 | =$1..$3=      | first three fields in the current row                          |
1897 | =$P..$Q=      | range, using column names (see [[*Advanced features]])             |
1898 | =$<<<..$>>=   | start in third column, continue to the last but one            |
1899 | =@2$1..@4$3=  | six fields between these two fields (same as =A2..C4=)         |
1900 | =@-1$-2..@-1= | 3 fields in the row above, starting from 2 columns on the left |
1901 | =@I..II=      | between first and second hline, short for =@I..@II=            |
1903 #+texinfo: @noindent
1904 Range references return a vector of values that can be fed into Calc
1905 vector functions.  Empty fields in ranges are normally suppressed, so
1906 that the vector contains only the non-empty fields.  For other options
1907 with the mode switches =E=, =N= and examples, see [[*Formula syntax for
1908 Calc]].
1910 **** Field coordinates in formulas
1911 :PROPERTIES:
1912 :UNNUMBERED: notoc
1913 :END:
1915 #+cindex: field coordinates
1916 #+cindex: coordinates, of field
1917 #+cindex: row, of field coordinates
1918 #+cindex: column, of field coordinates
1919 #+vindex: org-table-current-column
1920 #+vindex: org-table-current-dline
1921 One of the very first actions during evaluation of Calc formulas and
1922 Lisp formulas is to substitute =@#= and =$#= in the formula with the
1923 row or column number of the field where the current result will go to.
1924 The traditional Lisp formula equivalents are ~org-table-current-dline~
1925 and ~org-table-current-column~.  Examples:
1927 - =if(@# % 2, $#, string(""))= ::
1929   Insert column number on odd rows, set field to empty on even rows.
1931 - =$2 = '(identity remote(FOO, @@#$1))= ::
1933   Copy text or values of each row of column 1 of the table named
1934   {{{var(FOO)}}} into column 2 of the current table.
1936 - =@3 = 2 * remote(FOO, @@1$$#)= ::
1938   Insert the doubled value of each column of row 1 of the table
1939   named {{{var(FOO)}}} into row 3 of the current table.
1941 #+texinfo: @noindent
1942 For the second and third examples, table {{{var(FOO)}}} must have at
1943 least as many rows or columns as the current table.  Note that this is
1944 inefficient[fn:19] for large number of rows.
1946 **** Named references
1947 :PROPERTIES:
1948 :UNNUMBERED: notoc
1949 :END:
1950 #+cindex: named references
1951 #+cindex: references, named
1952 #+cindex: name, of column or field
1953 #+cindex: constants, in calculations
1954 #+cindex: @samp{CONSTANTS}, keyword
1955 #+vindex: org-table-formula-constants
1957 =$name= is interpreted as the name of a column, parameter or constant.
1958 Constants are defined globally through the variable
1959 ~org-table-formula-constants~, and locally---for the file---through
1960 a line like this example:
1962 : #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
1964 #+vindex: constants-unit-system
1965 #+pindex: constants.el
1966 Also, properties (see [[*Properties and Columns]]) can be used as
1967 constants in table formulas: for a property =Xyz= use the name
1968 =$PROP_Xyz=, and the property will be searched in the current outline
1969 entry and in the hierarchy above it.  If you have the =constants.el=
1970 package, it will also be used to resolve constants, including natural
1971 constants like =$h= for Planck's constant, and units like =$km= for
1972 kilometers[fn:20].  Column names and parameters can be specified in
1973 special table lines.  These are described below, see [[*Advanced
1974 features]].  All names must start with a letter, and further consist
1975 of letters and numbers.
1977 **** Remote references
1978 :PROPERTIES:
1979 :UNNUMBERED: notoc
1980 :END:
1982 #+cindex: remote references
1983 #+cindex: references, remote
1984 #+cindex: references, to a different table
1985 #+cindex: name, of column or field
1986 #+cindex: @samp{NAME}, keyword
1987 You may also reference constants, fields and ranges from a different
1988 table, either in the current file or even in a different file.  The
1989 syntax is
1991 : remote(NAME,REF)
1993 #+texinfo: @noindent
1994 where {{{var(NAME)}}} can be the name of a table in the current file
1995 as set by a =#+NAME:= line before the table.  It can also be the ID of
1996 an entry, even in a different file, and the reference then refers to
1997 the first table in that entry.  {{{var(REF)}}} is an absolute field or
1998 range reference as described above for example =@3$3= or =$somename=,
1999 valid in the referenced table.
2001 #+cindex: table indirection
2002 When {{{var(NAME)}}} has the format =@ROW$COLUMN=, it is substituted
2003 with the name or ID found in this field of the current table.  For
2004 example =remote($1, @@>$2)= \Rightarrow =remote(year_2013, @@>$1)=.  The format
2005 =B3= is not supported because it can not be distinguished from a plain
2006 table name or ID.
2008 *** Formula syntax for Calc
2009 :PROPERTIES:
2010 :DESCRIPTION: Using Calc to compute stuff.
2011 :END:
2012 #+cindex: formula syntax, Calc
2013 #+cindex: syntax, of formulas
2015 A formula can be any algebraic expression understood by the Emacs Calc
2016 package.  Note that Calc has the non-standard convention that =/= has
2017 lower precedence than =*=, so that =a/b*c= is interpreted as
2018 =(a/(b*c))=.  Before evaluation by ~calc-eval~ (see [[info:calc#Calling Calc from Your Programs][Calling Calc from
2019 Your Lisp Programs]]), variable substitution takes place according to
2020 the rules described above.
2022 #+cindex: vectors, in table calculations
2023 The range vectors can be directly fed into the Calc vector functions
2024 like ~vmean~ and ~vsum~.
2026 #+cindex: format specifier, in spreadsheet
2027 #+cindex: mode, for Calc
2028 #+vindex: org-calc-default-modes
2029 A formula can contain an optional mode string after a semicolon.  This
2030 string consists of flags to influence Calc and other modes during
2031 execution.  By default, Org uses the standard Calc modes (precision
2032 12, angular units degrees, fraction and symbolic modes off).  The
2033 display format, however, has been changed to =(float 8)= to keep
2034 tables compact.  The default settings can be configured using the
2035 variable ~org-calc-default-modes~.
2037 - =p20= ::
2039   Set the internal Calc calculation precision to 20 digits.
2041 - =n3=, =s3=, =e2=, =f4= ::
2043   Normal, scientific, engineering or fixed format of the result of
2044   Calc passed back to Org.  Calc formatting is unlimited in precision
2045   as long as the Calc calculation precision is greater.
2047 - =D=, =R= ::
2049   Degree and radian angle modes of Calc.
2051 - =F=, =S= ::
2053   Fraction and symbolic modes of Calc.
2055 - =T=, =t=, =U= ::
2057   Duration computations in Calc or Lisp, [[*Durations and time values]].
2059 - =E= ::
2061   If and how to consider empty fields.  Without =E= empty fields in
2062   range references are suppressed so that the Calc vector or Lisp list
2063   contains only the non-empty fields.  With =E= the empty fields are
2064   kept.  For empty fields in ranges or empty field references the
2065   value =nan= (not a number) is used in Calc formulas and the empty
2066   string is used for Lisp formulas.  Add =N= to use 0 instead for both
2067   formula types.  For the value of a field the mode =N= has higher
2068   precedence than =E=.
2070 - =N= ::
2072   Interpret all fields as numbers, use 0 for non-numbers.  See the
2073   next section to see how this is essential for computations with Lisp
2074   formulas.  In Calc formulas it is used only occasionally because
2075   there number strings are already interpreted as numbers without =N=.
2077 - =L= ::
2079   Literal, for Lisp formulas only.  See the next section.
2081 Unless you use large integer numbers or high-precision calculation and
2082 display for floating point numbers you may alternatively provide
2083 a ~printf~ format specifier to reformat the Calc result after it has
2084 been passed back to Org instead of letting Calc already do the
2085 formatting[fn:21].  A few examples:
2087 | =$1+$2=            | Sum of first and second field                    |
2088 | =$1+$2;%.2f=       | Same, format result to two decimals              |
2089 | =exp($2)+exp($1)=  | Math functions can be used                       |
2090 | =$0;%.1f=          | Reformat current cell to 1 decimal               |
2091 | =($3-32)*5/9=      | Degrees F \to C conversion                         |
2092 | =$c/$1/$cm=        | Hz \to cm conversion, using =constants.el=         |
2093 | =tan($1);Dp3s1=    | Compute in degrees, precision 3, display SCI 1   |
2094 | =sin($1);Dp3%.1e=  | Same, but use ~printf~ specifier for display     |
2095 | =vmean($2..$7)=    | Compute column range mean, using vector function |
2096 | =vmean($2..$7);EN= | Same, but treat empty fields as 0                |
2097 | =taylor($3,x=7,2)= | Taylor series of $3, at x=7, second degree       |
2099 Calc also contains a complete set of logical operations (see [[info:calc#Logical Operations][Logical
2100 Operations]]).  For example
2102 - =if($1 < 20, teen, string(""))= ::
2104   ="teen"= if age =$1= is less than 20, else the Org table result
2105   field is set to empty with the empty string.
2107 - =if("$1" =​= "nan" || "$2" =​= "nan", string(""), $1 + $2); E f-1= ::
2109   Sum of the first two columns.  When at least one of the input fields
2110   is empty the Org table result field is set to empty.  =E= is
2111   required to not convert empty fields to 0.  =f-1= is an optional
2112   Calc format string similar to =%.1f= but leaves empty results empty.
2114 - =if(typeof(vmean($1..$7)) =​= 12, string(""), vmean($1..$7); E= ::
2116   Mean value of a range unless there is any empty field.  Every field
2117   in the range that is empty is replaced by =nan= which lets =vmean=
2118   result in =nan=.  Then =typeof == 12= detects the =nan= from ~vmean~
2119   and the Org table result field is set to empty.  Use this when the
2120   sample set is expected to never have missing values.
2122 - =if("$1..$7" =​= "[]", string(""), vmean($1..$7))= ::
2124   Mean value of a range with empty fields skipped.  Every field in the
2125   range that is empty is skipped.  When all fields in the range are
2126   empty the mean value is not defined and the Org table result field
2127   is set to empty.  Use this when the sample set can have a variable
2128   size.
2130 - =vmean($1..$7); EN= ::
2132   To complete the example before: Mean value of a range with empty
2133   fields counting as samples with value 0.  Use this only when
2134   incomplete sample sets should be padded with 0 to the full size.
2136 You can add your own Calc functions defined in Emacs Lisp with
2137 ~defmath~ and use them in formula syntax for Calc.
2139 *** Emacs Lisp forms as formulas
2140 :PROPERTIES:
2141 :DESCRIPTION: Writing formulas in Emacs Lisp.
2142 :ALT_TITLE: Formula syntax for Lisp
2143 :END:
2144 #+cindex: Lisp forms, as table formulas
2146 It is also possible to write a formula in Emacs Lisp.  This can be
2147 useful for string manipulation and control structures, if Calc's
2148 functionality is not enough.
2150 If a formula starts with a single-quote followed by an opening
2151 parenthesis, then it is evaluated as a Lisp form.  The evaluation
2152 should return either a string or a number.  Just as with Calc
2153 formulas, you can specify modes and a ~printf~ format after
2154 a semicolon.
2156 With Emacs Lisp forms, you need to be conscious about the way field
2157 references are interpolated into the form.  By default, a reference is
2158 interpolated as a Lisp string (in double-quotes) containing the field.
2159 If you provide the =N= mode switch, all referenced elements are
2160 numbers---non-number fields will be zero---and interpolated as Lisp
2161 numbers, without quotes.  If you provide the =L= flag, all fields are
2162 interpolated literally, without quotes.  For example, if you want a
2163 reference to be interpreted as a string by the Lisp form, enclose the
2164 reference operator itself in double-quotes, like ="$3"=.  Ranges are
2165 inserted as space-separated fields, so you can embed them in list or
2166 vector syntax.
2168 Here are a few examples---note how the =N= mode is used when we do
2169 computations in Lisp:
2171 - ='(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))= ::
2173   Swap the first two characters of the content of column 1.
2175 - ='(+ $1 $2);N= ::
2177   Add columns 1 and 2, equivalent to Calc's =$1+$2=.
2179 - ='(apply '+ '($1..$4));N= ::
2181   Compute the sum of columns 1 to 4, like Calc's =vsum($1..$4)=.
2183 *** Durations and time values
2184 :PROPERTIES:
2185 :DESCRIPTION: How to compute durations and time values.
2186 :END:
2187 #+cindex: duration, computing
2188 #+cindex: time, computing
2189 #+vindex: org-table-duration-custom-format
2191 If you want to compute time values use the =T=, =t=, or =U= flag,
2192 either in Calc formulas or Elisp formulas:
2194 #+begin_example
2195 |  Task 1 |   Task 2 |    Total |
2196 |---------+----------+----------|
2197 |    2:12 |     1:47 | 03:59:00 |
2198 |    2:12 |     1:47 |    03:59 |
2199 | 3:02:20 | -2:07:00 |     0.92 |
2200 ,#+TBLFM: @2$3=$1+$2;T::@3$3=$1+$2;U::@4$3=$1+$2;t
2201 #+end_example
2203 Input duration values must be of the form =HH:MM[:SS]=, where seconds
2204 are optional.  With the =T= flag, computed durations are displayed as
2205 =HH:MM:SS= (see the first formula above).  With the =U= flag, seconds
2206 are omitted so that the result is only =HH:MM= (see second formula
2207 above).  Zero-padding of the hours field depends upon the value of the
2208 variable ~org-table-duration-hour-zero-padding~.
2210 With the =t= flag, computed durations are displayed according to the
2211 value of the option ~org-table-duration-custom-format~, which defaults
2212 to ~hours~ and displays the result as a fraction of hours (see the
2213 third formula in the example above).
2215 Negative duration values can be manipulated as well, and integers are
2216 considered as seconds in addition and subtraction.
2218 *** Field and range formulas
2219 :PROPERTIES:
2220 :DESCRIPTION: Formula for specific (ranges of) fields.
2221 :END:
2222 #+cindex: field formula
2223 #+cindex: range formula
2224 #+cindex: formula, for individual table field
2225 #+cindex: formula, for range of fields
2227 To assign a formula to a particular field, type it directly into the
2228 field, preceded by =:==, for example =vsum(@II..III)=.  When you press
2229 {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} with point
2230 still in the field, the formula is stored as the formula for this
2231 field, evaluated, and the current field is replaced with the result.
2233 #+cindex: @samp{TBLFM}, keyword
2234 Formulas are stored in a special =TBLFM= keyword located directly
2235 below the table.  If you type the equation in the fourth field of the
2236 third data line in the table, the formula looks like =@3$4=$1+$2=.
2237 When inserting/deleting/swapping column and rows with the appropriate
2238 commands, /absolute references/ (but not relative ones) in stored
2239 formulas are modified in order to still reference the same field.  To
2240 avoid this from happening, in particular in range references, anchor
2241 ranges at the table borders (using =@<=, =@>=, =$<=, =$>=), or at
2242 hlines using the =@I= notation.  Automatic adaptation of field
2243 references does not happen if you edit the table structure with normal
2244 editing commands---you must fix the formulas yourself.
2246 Instead of typing an equation into the field, you may also use the
2247 following command
2249 - {{{kbd(C-u C-c =)}}} (~org-table-eval-formula~) ::
2251   #+kindex: C-u C-c =
2252   #+findex: org-table-eval-formula
2253   Install a new formula for the current field.  The command prompts
2254   for a formula with default taken from the =TBLFM= keyword,
2255   applies it to the current field, and stores it.
2257 The left-hand side of a formula can also be a special expression in
2258 order to assign the formula to a number of different fields.  There is
2259 no keyboard shortcut to enter such range formulas.  To add them, use
2260 the formula editor (see [[*Editing and debugging formulas]]) or edit
2261 the =TBLFM= keyword directly.
2263 - =$2== ::
2265   Column formula, valid for the entire column.  This is so common that
2266   Org treats these formulas in a special way, see [[*Column formulas]].
2268 - =@3== ::
2270   Row formula, applies to all fields in the specified row.  =@>==
2271   means the last row.
2273 - =@1$2..@4$3== ::
2275   Range formula, applies to all fields in the given rectangular range.
2276   This can also be used to assign a formula to some but not all fields
2277   in a row.
2279 - =$NAME== ::
2281   Named field, see [[*Advanced features]].
2283 *** Column formulas
2284 :PROPERTIES:
2285 :DESCRIPTION: Formulas valid for an entire column.
2286 :END:
2287 #+cindex: column formula
2288 #+cindex: formula, for table column
2290 When you assign a formula to a simple column reference like =$3==, the
2291 same formula is used in all fields of that column, with the following
2292 very convenient exceptions: (i) If the table contains horizontal
2293 separator hlines with rows above and below, everything before the
2294 first such hline is considered part of the table /header/ and is not
2295 modified by column formulas.  Therefore a header is mandatory when you
2296 use column formulas and want to add hlines to group rows, like for
2297 example to separate a total row at the bottom from the summand rows
2298 above.  (ii) Fields that already get a value from a field/range
2299 formula are left alone by column formulas.  These conditions make
2300 column formulas very easy to use.
2302 To assign a formula to a column, type it directly into any field in
2303 the column, preceded by an equal sign, like ==$1+$2=.  When you press
2304 {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} with point
2305 still in the field, the formula is stored as the formula for the
2306 current column, evaluated and the current field replaced with the
2307 result.  If the field contains only ===, the previously stored formula
2308 for this column is used.  For each column, Org only remembers the most
2309 recently used formula.  In the =TBLFM= keyword, column formulas look
2310 like =$4=$1+$2=.  The left-hand side of a column formula can not be
2311 the name of column, it must be the numeric column reference or =$>=.
2313 Instead of typing an equation into the field, you may also use the
2314 following command:
2316 - {{{kbd(C-c =)}}} (~org-table-eval-formula~) ::
2318   #+kindex: C-c =
2319   #+findex: org-table-eval-formula
2320   Install a new formula for the current column and replace current
2321   field with the result of the formula.  The command prompts for
2322   a formula, with default taken from the =TBLFM= keyword, applies it
2323   to the current field and stores it.  With a numeric prefix argument,
2324   e.g., {{{kbd(C-5 C-c =)}}}, the command applies it to that many
2325   consecutive fields in the current column.
2327 *** Lookup functions
2328 :PROPERTIES:
2329 :DESCRIPTION: Lookup functions for searching tables.
2330 :END:
2331 #+cindex: lookup functions in tables
2332 #+cindex: table lookup functions
2334 Org has three predefined Emacs Lisp functions for lookups in tables.
2336 - =(org-lookup-first VAL S-LIST R-LIST &optional PREDICATE)= ::
2338   #+findex: org-lookup-first
2339   Searches for the first element {{{var(S)}}} in list
2340   {{{var(S-LIST)}}} for which
2341   #+begin_src emacs-lisp
2342   (PREDICATE VAL S)
2343   #+end_src
2344   is non-~nil~; returns the value from the corresponding position in
2345   list {{{var(R-LIST)}}}.  The default {{{var(PREDICATE)}}} is
2346   ~equal~.  Note that the parameters {{{var(VAL)}}} and {{{var(S)}}}
2347   are passed to {{{var(PREDICATE)}}} in the same order as the
2348   corresponding parameters are in the call to ~org-lookup-first~,
2349   where {{{var(VAL)}}} precedes {{{var(S-LIST)}}}.  If
2350   {{{var(R-LIST)}}} is ~nil~, the matching element {{{var(S)}}} of
2351   {{{var(S-LIST)}}} is returned.
2353 - =(org-lookup-last VAL S-LIST R-LIST &optional PREDICATE)= ::
2355   #+findex: org-lookup-last
2356   Similar to ~org-lookup-first~ above, but searches for the /last/
2357   element for which {{{var(PREDICATE)}}} is non-~nil~.
2359 - =(org-lookup-all VAL S-LIST R-LIST &optional PREDICATE)= ::
2361   #+findex: org-lookup-all
2362   Similar to ~org-lookup-first~, but searches for /all/ elements for
2363   which {{{var(PREDICATE)}}} is non-~nil~, and returns /all/
2364   corresponding values.  This function can not be used by itself in
2365   a formula, because it returns a list of values.  However, powerful
2366   lookups can be built when this function is combined with other Emacs
2367   Lisp functions.
2369 If the ranges used in these functions contain empty fields, the =E=
2370 mode for the formula should usually be specified: otherwise empty
2371 fields are not included in {{{var(S-LIST)}}} and/or {{{var(R-LIST)}}}
2372 which can, for example, result in an incorrect mapping from an element
2373 of {{{var(S-LIST)}}} to the corresponding element of
2374 {{{var(R-LIST)}}}.
2376 These three functions can be used to implement associative arrays,
2377 count matching cells, rank results, group data, etc.  For practical
2378 examples see [[https://orgmode.org/worg/org-tutorials/org-lookups.html][this tutorial on Worg]].
2380 *** Editing and debugging formulas
2381 :PROPERTIES:
2382 :DESCRIPTION: Fixing formulas.
2383 :END:
2384 #+cindex: formula editing
2385 #+cindex: editing, of table formulas
2387 #+vindex: org-table-use-standard-references
2388 You can edit individual formulas in the minibuffer or directly in the
2389 field.  Org can also prepare a special buffer with all active formulas
2390 of a table.  When offering a formula for editing, Org converts
2391 references to the standard format (like =B3= or =D&=) if possible.  If
2392 you prefer to only work with the internal format (like =@3$2= or
2393 =$4=), configure the variable ~org-table-use-standard-references~.
2395 - {{{kbd(C-c =)}}} or {{{kbd(C-u C-c =)}}} (~org-table-eval-formula~) ::
2397   #+kindex: C-c =
2398   #+kindex: C-u C-c =
2399   #+findex: org-table-eval-formula
2400   Edit the formula associated with the current column/field in the
2401   minibuffer.  See [[*Column formulas]], and [[*Field and range formulas]].
2403 - {{{kbd(C-u C-u C-c =)}}} (~org-table-eval-formula~) ::
2405   #+kindex: C-u C-u C-c =
2406   #+findex: org-table-eval-formula
2407   Re-insert the active formula (either a field formula, or a column
2408   formula) into the current field, so that you can edit it directly in
2409   the field.  The advantage over editing in the minibuffer is that you
2410   can use the command {{{kbd(C-c ?)}}}.
2412 - {{{kbd(C-c ?)}}} (~org-table-field-info~) ::
2414   #+kindex: C-c ?
2415   #+findex: org-table-field-info
2416   While editing a formula in a table field, highlight the field(s)
2417   referenced by the reference at point position in the formula.
2419 - {{{kbd(C-c })}}} (~org-table-toggle-coordinate-overlays~) ::
2421   #+kindex: C-c @}
2422   #+findex: org-table-toggle-coordinate-overlays
2423   Toggle the display of row and column numbers for a table, using
2424   overlays.  These are updated each time the table is aligned; you can
2425   force it with {{{kbd(C-c C-c)}}}.
2427 - {{{kbd(C-c {)}}} (~org-table-toggle-formula-debugger~) ::
2429   #+kindex: C-c @{
2430   #+findex: org-table-toggle-formula-debugger
2431   Toggle the formula debugger on and off.  See below.
2433 - {{{kbd(C-c ')}}} (~org-table-edit-formulas~) ::
2435   #+kindex: C-c '
2436   #+findex: org-table-edit-formulas
2437   Edit all formulas for the current table in a special buffer, where
2438   the formulas are displayed one per line.  If the current field has
2439   an active formula, point in the formula editor marks it.  While
2440   inside the special buffer, Org automatically highlights any field or
2441   range reference at point position.  You may edit, remove and add
2442   formulas, and use the following commands:
2444   - {{{kbd(C-c C-c)}}} or {{{kbd(C-x C-s)}}} (~org-table-fedit-finish~) ::
2446     #+kindex: C-x C-s
2447     #+kindex: C-c C-c
2448     #+findex: org-table-fedit-finish
2449     Exit the formula editor and store the modified formulas.  With
2450     {{{kbd(C-u)}}} prefix, also apply the new formulas to the
2451     entire table.
2453   - {{{kbd(C-c C-q)}}} (~org-table-fedit-abort~) ::
2455     #+kindex: C-c C-q
2456     #+findex: org-table-fedit-abort
2457     Exit the formula editor without installing changes.
2459   - {{{kbd(C-c C-r)}}} (~org-table-fedit-toggle-ref-type~) ::
2461     #+kindex: C-c C-r
2462     #+findex: org-table-fedit-toggle-ref-type
2463     Toggle all references in the formula editor between standard (like
2464     =B3=) and internal (like =@3$2=).
2466   - {{{kbd(TAB)}}} (~org-table-fedit-lisp-indent~) ::
2468     #+kindex: TAB
2469     #+findex: org-table-fedit-lisp-indent
2470     Pretty-print or indent Lisp formula at point.  When in a line
2471     containing a Lisp formula, format the formula according to Emacs
2472     Lisp rules.  Another {{{kbd(TAB)}}} collapses the formula back
2473     again.  In the open formula, {{{kbd(TAB)}}} re-indents just like
2474     in Emacs Lisp mode.
2476   - {{{kbd(M-TAB)}}} (~lisp-complete-symbol~) ::
2478     #+kindex: M-TAB
2479     #+findex: lisp-complete-symbol
2480     Complete Lisp symbols, just like in Emacs Lisp mode.
2482   - {{{kbd(S-UP)}}}, {{{kbd(S-DOWN)}}}, {{{kbd(S-LEFT)}}}, {{{kbd(S-RIGHT)}}} ::
2484     #+kindex: S-UP
2485     #+kindex: S-DOWN
2486     #+kindex: S-LEFT
2487     #+kindex: S-RIGHT
2488     #+findex: org-table-fedit-ref-up
2489     #+findex: org-table-fedit-ref-down
2490     #+findex: org-table-fedit-ref-left
2491     #+findex: org-table-fedit-ref-right
2492     Shift the reference at point.  For example, if the reference is
2493     =B3= and you press {{{kbd(S-RIGHT)}}}, it becomes =C3=.  This also
2494     works for relative references and for hline references.
2496   - {{{kbd(M-S-UP)}}} (~org-table-fedit-line-up~) ::
2498     #+kindex: M-S-UP
2499     #+findex: org-table-fedit-line-up
2500     Move the test line for column formulas up in the Org buffer.
2502   - {{{kbd(M-S-DOWN)}}} (~org-table-fedit-line-down~) ::
2504     #+kindex: M-S-DOWN
2505     #+findex: org-table-fedit-line-down
2506     Move the test line for column formulas down in the Org buffer.
2508   - {{{kbd(M-UP)}}} (~org-table-fedit-scroll-up~) ::
2510     #+kindex: M-UP
2511     #+findex: org-table-fedit-scroll-up
2512     Scroll up the window displaying the table.
2514   - {{{kbd(M-DOWN)}}} (~org-table-fedit-scroll-down~) ::
2516     #+kindex: M-DOWN
2517     #+findex: org-table-fedit-scroll-down
2518     Scroll down the window displaying the table.
2520   - {{{kbd(C-c })}}} ::
2522     #+kindex: C-c @}
2523     #+findex: org-table-toggle-coordinate-overlays
2524     Turn the coordinate grid in the table on and off.
2526 Making a table field blank does not remove the formula associated with
2527 the field, because that is stored in a different line---the =TBLFM=
2528 keyword line.  During the next recalculation, the field will be filled
2529 again.  To remove a formula from a field, you have to give an empty
2530 reply when prompted for the formula, or to edit the =TBLFM= keyword.
2532 #+kindex: C-c C-c
2533 You may edit the =TBLFM= keyword directly and re-apply the changed
2534 equations with {{{kbd(C-c C-c)}}} in that line or with the normal
2535 recalculation commands in the table.
2537 **** Using multiple =TBLFM= lines
2538 :PROPERTIES:
2539 :UNNUMBERED: notoc
2540 :END:
2541 #+cindex: multiple formula lines
2542 #+cindex: @samp{TBLFM} keywords, multiple
2543 #+cindex: @samp{TBLFM}, switching
2545 #+kindex: C-c C-c
2546 You may apply the formula temporarily.  This is useful when you want
2547 to switch the formula applied to the table.  Place multiple =TBLFM=
2548 keywords right after the table, and then press {{{kbd(C-c C-c)}}} on
2549 the formula to apply.  Here is an example:
2551 #+begin_example
2552 | x | y |
2553 |---+---|
2554 | 1 |   |
2555 | 2 |   |
2556 ,#+TBLFM: $2=$1*1
2557 ,#+TBLFM: $2=$1*2
2558 #+end_example
2560 #+texinfo: @noindent
2561 Pressing {{{kbd(C-c C-c)}}} in the line of =#+TBLFM: $2=$1*2= yields:
2563 #+begin_example
2564 | x | y |
2565 |---+---|
2566 | 1 | 2 |
2567 | 2 | 4 |
2568 ,#+TBLFM: $2=$1*1
2569 ,#+TBLFM: $2=$1*2
2570 #+end_example
2572 #+texinfo: @noindent
2573 If you recalculate this table, with {{{kbd(C-u C-c *)}}}, for example,
2574 you get the following result from applying only the first =TBLFM=
2575 keyword.
2577 #+begin_example
2578 | x | y |
2579 |---+---|
2580 | 1 | 1 |
2581 | 2 | 2 |
2582 ,#+TBLFM: $2=$1*1
2583 ,#+TBLFM: $2=$1*2
2584 #+end_example
2586 **** Debugging formulas
2587 :PROPERTIES:
2588 :UNNUMBERED: notoc
2589 :END:
2590 #+cindex: formula debugging
2591 #+cindex: debugging, of table formulas
2593 When the evaluation of a formula leads to an error, the field content
2594 becomes the string =#ERROR=.  If you would like to see what is going
2595 on during variable substitution and calculation in order to find
2596 a bug, turn on formula debugging in the Tbl menu and repeat the
2597 calculation, for example by pressing {{{kbd(C-u C-u C-c = RET)}}} in
2598 a field.  Detailed information are displayed.
2600 *** Updating the table
2601 :PROPERTIES:
2602 :DESCRIPTION: Recomputing all dependent fields.
2603 :END:
2604 #+cindex: recomputing table fields
2605 #+cindex: updating, table
2607 Recalculation of a table is normally not automatic, but needs to be
2608 triggered by a command.  To make recalculation at least
2609 semi-automatic, see [[*Advanced features]].
2611 In order to recalculate a line of a table or the entire table, use the
2612 following commands:
2614 - {{{kbd(C-c *)}}} (~org-table-recalculate~) ::
2616   #+kindex: C-c *
2617   #+findex: org-table-recalculate
2618   Recalculate the current row by first applying the stored column
2619   formulas from left to right, and all field/range formulas in the
2620   current row.
2622 - {{{kbd(C-u C-c *)}}} or {{{kbd(C-u C-c C-c)}}} ::
2624   #+kindex: C-u C-c *
2625   #+kindex: C-u C-c C-c
2626   Recompute the entire table, line by line.  Any lines before the
2627   first hline are left alone, assuming that these are part of the
2628   table header.
2630 - {{{kbd(C-u C-u C-c *)}}} or {{{kbd(C-u C-u C-c C-c)}}} (~org-table-iterate~) ::
2632   #+kindex: C-u C-u C-c *
2633   #+kindex: C-u C-u C-c C-c
2634   #+findex: org-table-iterate
2635   Iterate the table by recomputing it until no further changes occur.
2636   This may be necessary if some computed fields use the value of other
2637   fields that are computed /later/ in the calculation sequence.
2639 - {{{kbd(M-x org-table-recalculate-buffer-tables)}}} ::
2641   #+findex: org-table-recalculate-buffer-tables
2642   Recompute all tables in the current buffer.
2644 - {{{kbd(M-x org-table-iterate-buffer-tables)}}} ::
2646   #+findex: org-table-iterate-buffer-tables
2647   Iterate all tables in the current buffer, in order to converge
2648   table-to-table dependencies.
2650 *** Advanced features
2651 :PROPERTIES:
2652 :DESCRIPTION: Field and column names, automatic recalculation...
2653 :END:
2655 If you want the recalculation of fields to happen automatically, or if
2656 you want to be able to assign /names/[fn:22] to fields and columns,
2657 you need to reserve the first column of the table for special marking
2658 characters.
2660 - {{{kbd(C-#)}}} (~org-table-rotate-recalc-marks~) ::
2662   #+kindex: C-#
2663   #+findex: org-table-rotate-recalc-marks
2664   Rotate the calculation mark in first column through the states =#=,
2665   =*=, =!=, =$=.  When there is an active region, change all marks in
2666   the region.
2668 Here is an example of a table that collects exam results of students
2669 and makes use of these features:
2671 #+begin_example
2672 |---+---------+--------+--------+--------+-------+------|
2673 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2674 |---+---------+--------+--------+--------+-------+------|
2675 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2676 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2677 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2678 |---+---------+--------+--------+--------+-------+------|
2679 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2680 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2681 |---+---------+--------+--------+--------+-------+------|
2682 |   | Average |        |        |        |  25.0 |      |
2683 | ^ |         |        |        |        |    at |      |
2684 | $ | max=50  |        |        |        |       |      |
2685 |---+---------+--------+--------+--------+-------+------|
2686 ,#+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@-II..@-I);%.1f
2687 #+end_example
2689 #+attr_texinfo: :tag Important
2690 #+begin_quote
2691 Please note that for these special tables, recalculating the table
2692 with {{{kbd(C-u C-c *)}}} only affects rows that are marked =#= or
2693 =*=, and fields that have a formula assigned to the field itself.  The
2694 column formulas are not applied in rows with empty first field.
2695 #+end_quote
2697 #+cindex: marking characters, tables
2698 The marking characters have the following meaning:
2700 - =!= ::
2702   The fields in this line define names for the columns, so that you
2703   may refer to a column as =$Tot= instead of =$6=.
2705 - =^= ::
2707   This row defines names for the fields /above/ the row.  With such
2708   a definition, any formula in the table may use =$m1= to refer to the
2709   value =10=.  Also, if you assign a formula to a names field, it is
2710   stored as =$name = ...=.
2712 - =_= ::
2714   Similar to =^=, but defines names for the fields in the row /below/.
2716 - =$= ::
2718   Fields in this row can define /parameters/ for formulas.  For
2719   example, if a field in a =$= row contains =max=50=, then formulas in
2720   this table can refer to the value 50 using =$max=.  Parameters work
2721   exactly like constants, only that they can be defined on a per-table
2722   basis.
2724 - =#= ::
2726   Fields in this row are automatically recalculated when pressing
2727   {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(S-TAB)}}} in this row.
2728   Also, this row is selected for a global recalculation with
2729   {{{kbd(C-u C-c *)}}}.  Unmarked lines are left alone by this
2730   command.
2732 - =*= ::
2734   Selects this line for global recalculation with {{{kbd(C-u C-c
2735   *)}}}, but not for automatic recalculation.  Use this when automatic
2736   recalculation slows down editing too much.
2738 - =/= ::
2740   Do not export this line.  Useful for lines that contain the
2741   narrowing =<N>= markers or column group markers.
2743 Finally, just to whet your appetite for what can be done with the
2744 fantastic Calc package, here is a table that computes the Taylor
2745 series of degree n at location x for a couple of functions.
2747 #+begin_example
2748 |---+-------------+---+-----+--------------------------------------|
2749 |   | Func        | n | x   | Result                               |
2750 |---+-------------+---+-----+--------------------------------------|
2751 | # | exp(x)      | 1 | x   | 1 + x                                |
2752 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2753 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2754 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2755 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2756 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2757 |---+-------------+---+-----+--------------------------------------|
2758 ,#+TBLFM: $5=taylor($2,$4,$3);n3
2759 #+end_example
2761 ** Org Plot
2762 :PROPERTIES:
2763 :DESCRIPTION: Plotting from Org tables.
2764 :END:
2765 #+cindex: graph, in tables
2766 #+cindex: plot tables using Gnuplot
2768 Org Plot can produce graphs of information stored in Org tables,
2769 either graphically or in ASCII art.
2771 *** Graphical plots using Gnuplot
2772 :PROPERTIES:
2773 :UNNUMBERED: notoc
2774 :END:
2776 #+cindex: @samp{PLOT}, keyword
2777 Org Plot can produce 2D and 3D graphs of information stored in Org
2778 tables using [[http://www.gnuplot.info/][Gnuplot]] and [[http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html][Gnuplot mode]].  To see this in action, ensure
2779 that you have both Gnuplot and Gnuplot mode installed on your system,
2780 then call {{{kbd(C-c \quot g)}}} or {{{kbd(M-x org-plot/gnuplot)}}} on the
2781 following table.
2783 #+begin_example
2784 ,#+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2785 | Sede      | Max cites | H-index |
2786 |-----------+-----------+---------|
2787 | Chile     |    257.72 |   21.39 |
2788 | Leeds     |    165.77 |   19.68 |
2789 | Sao Paolo |     71.00 |   11.50 |
2790 | Stockholm |    134.19 |   14.33 |
2791 | Morelia   |    257.56 |   17.67 |
2792 #+end_example
2794 Notice that Org Plot is smart enough to apply the table's headers as
2795 labels.  Further control over the labels, type, content, and
2796 appearance of plots can be exercised through the =PLOT= keyword
2797 preceding a table.  See below for a complete list of Org Plot options.
2798 For more information and examples see the [[https://orgmode.org/worg/org-tutorials/org-plot.html][Org Plot tutorial]].
2800 **** Plot options
2801 :PROPERTIES:
2802 :UNNUMBERED: notoc
2803 :END:
2805 - =set= ::
2807   Specify any Gnuplot option to be set when graphing.
2809 - =title= ::
2811   Specify the title of the plot.
2813 - =ind= ::
2815   Specify which column of the table to use as the =x= axis.
2817 - =deps= ::
2819   Specify the columns to graph as a Lisp style list, surrounded by
2820   parentheses and separated by spaces for example =dep:(3 4)= to graph
2821   the third and fourth columns.  Defaults to graphing all other
2822   columns aside from the =ind= column.
2824 - =type= ::
2826   Specify whether the plot is =2d=, =3d=, or =grid=.
2828 - =with= ::
2830   Specify a =with= option to be inserted for every column being
2831   plotted, e.g., =lines=, =points=, =boxes=, =impulses=.  Defaults to
2832   =lines=.
2834 - =file= ::
2836   If you want to plot to a file, specify
2837   ="path/to/desired/output-file"=.
2839 - =labels= ::
2841   List of labels to be used for the =deps=.  Defaults to the column
2842   headers if they exist.
2844 - =line= ::
2846   Specify an entire line to be inserted in the Gnuplot script.
2848 - =map= ::
2850   When plotting =3d= or =grid= types, set this to =t= to graph a flat
2851   mapping rather than a =3d= slope.
2853 - =timefmt= ::
2855   Specify format of Org mode timestamps as they will be parsed by
2856   Gnuplot.  Defaults to =%Y-%m-%d-%H:%M:%S=.
2858 - =script= ::
2860   If you want total control, you can specify a script file---place the
2861   file name between double-quotes---which will be used to plot.
2862   Before plotting, every instance of =$datafile= in the specified
2863   script will be replaced with the path to the generated data file.
2864   Note: even if you set this option, you may still want to specify the
2865   plot type, as that can impact the content of the data file.
2867 *** ASCII bar plots
2868 :PROPERTIES:
2869 :UNNUMBERED: notoc
2870 :END:
2872 While point is on a column, typing {{{kbd(C-c " a)}}} or {{{kbd(M-x
2873 orgtbl-ascii-plot)}}} create a new column containing an ASCII-art bars
2874 plot.  The plot is implemented through a regular column formula.  When
2875 the source column changes, the bar plot may be updated by refreshing
2876 the table, for example typing {{{kbd(C-u C-c *)}}}.
2878 #+begin_example
2879 | Sede          | Max cites |              |
2880 |---------------+-----------+--------------|
2881 | Chile         |    257.72 | WWWWWWWWWWWW |
2882 | Leeds         |    165.77 | WWWWWWWh     |
2883 | Sao Paolo     |     71.00 | WWW;         |
2884 | Stockholm     |    134.19 | WWWWWW:      |
2885 | Morelia       |    257.56 | WWWWWWWWWWWH |
2886 | Rochefourchat |      0.00 |              |
2887 ,#+TBLFM: $3='(orgtbl-ascii-draw $2 0.0 257.72 12)
2888 #+end_example
2890 The formula is an Elisp call.
2892 #+attr_texinfo: :options orgtbl-ascii-draw value min max &optional width
2893 #+begin_defun
2894 Draw an ASCII bar in a table.
2896 {{{var(VALUE)}}} is the value to plot.
2898 {{{var(MIN)}}} is the value displayed as an empty bar.  {{{var(MAX)}}}
2899 is the value filling all the {{{var(WIDTH)}}}.  Sources values outside
2900 this range are displayed as =too small= or =too large=.
2902 {{{var(WIDTH)}}} is the number of characters of the bar plot.  It
2903 defaults to =12=.
2904 #+end_defun
2906 * Hyperlinks
2907 :PROPERTIES:
2908 :DESCRIPTION: Notes in context.
2909 :END:
2910 #+cindex: hyperlinks
2912 Like HTML, Org provides support for links inside a file, external
2913 links to other files, Usenet articles, emails, and much more.
2915 ** Link Format
2916 :PROPERTIES:
2917 :DESCRIPTION: How links in Org are formatted.
2918 :END:
2919 #+cindex: link format
2920 #+cindex: format, of links
2922 #+cindex: angle bracket links
2923 #+cindex: plain links
2924 Org recognizes plain URIs, possibly wrapped within angle
2925 brackets[fn:23], and activate them as clickable links.
2927 #+cindex: bracket links
2928 The general link format, however, looks like this:
2930 : [[LINK][DESCRIPTION]]
2932 #+texinfo: @noindent
2933 or alternatively
2935 : [[LINK]]
2937 #+cindex: escape syntax, for links
2938 #+cindex: backslashes, in links
2939 Some =\= and =]= characters in the {{{var(LINK)}}} part need to be
2940 "escaped", i.e., preceded by another =\= character.  More
2941 specifically, the following character categories, and only them, must
2942 be escaped, in order:
2944 1. all consecutive =\= characters at the end of the link,
2945 2. any =]= character at the very end of the link,
2946 3. all consecutive =\= characters preceding =][= or =]]= patterns,
2947 4. any =]= character followed by either =[= or =]=.
2949 #+findex: org-link-escape
2950 Org takes for granted that such links are correctly escaped.
2951 Functions inserting links (see [[*Handling Links]]) take care of this.
2952 You only need to bother about those rules when inserting directly, or
2953 yanking, a URI within square brackets.  When in doubt, you may use the
2954 function ~org-link-escape~, which turns a link string into its
2955 properly escaped form.
2957 Once a link in the buffer is complete, with all brackets present, Org
2958 changes the display so that =DESCRIPTION= is displayed instead of
2959 =[[LINK][DESCRIPTION]]= and =LINK= is displayed instead of =[[LINK]]=.
2960 Links are highlighted in the ~org-link~ face, which, by default, is an
2961 underlined face.
2963 You can directly edit the visible part of a link.  This can be either
2964 the {{{var(LINK)}}} part, if there is no description, or the
2965 {{{var(DESCRIPTION)}}} part otherwise.  To also edit the invisible
2966 {{{var(LINK)}}} part, use {{{kbd(C-c C-l)}}} with point on the link
2967 (see [[*Handling Links]]).
2969 If you place point at the beginning or just behind the end of the
2970 displayed text and press {{{kbd(BS)}}}, you remove
2971 the---invisible---bracket at that location[fn:24].  This makes the link
2972 incomplete and the internals are again displayed as plain text.
2973 Inserting the missing bracket hides the link internals again.  To show
2974 the internal structure of all links, use the menu: Org \rarr Hyperlinks \rarr
2975 Literal links.
2977 ** Internal Links
2978 :PROPERTIES:
2979 :DESCRIPTION: Links to other places in the current file.
2980 :END:
2981 #+cindex: internal links
2982 #+cindex: links, internal
2983 #+cindex: targets, for links
2985 #+cindex: @samp{CUSTOM_ID}, property
2986 If the link does not look like a URL, it is considered to be internal
2987 in the current file.  The most important case is a link like
2988 =[[#my-custom-id]]= which links to the entry with the =CUSTOM_ID= property
2989 =my-custom-id=.  You are responsible yourself to make sure these
2990 custom IDs are unique in a file.
2992 Links such as =[[My Target]]= or =[[My Target][Find my target]]= lead to a text search in
2993 the current file.
2995 The link can be followed with {{{kbd(C-c C-o)}}} when point is on
2996 the link, or with a mouse click (see [[*Handling Links]]).  Links to
2997 custom IDs point to the corresponding headline.  The preferred match
2998 for a text link is a /dedicated target/: the same string in double
2999 angular brackets, like =<<My Target>>=.
3001 #+cindex: @samp{NAME}, keyword
3002 If no dedicated target exists, the link tries to match the exact name
3003 of an element within the buffer.  Naming is done with the =NAME=
3004 keyword, which has to be put in the line before the element it refers
3005 to, as in the following example
3007 #+begin_example
3008 ,#+NAME: My Target
3009 | a  | table      |
3010 |----+------------|
3011 | of | four cells |
3012 #+end_example
3014 If none of the above succeeds, Org searches for a headline that is
3015 exactly the link text but may also include a TODO keyword and
3016 tags[fn:25].
3018 During export, internal links are used to mark objects and assign them
3019 a number.  Marked objects are then referenced by links pointing to
3020 them.  In particular, links without a description appear as the number
3021 assigned to the marked object[fn:26].  In the following excerpt from
3022 an Org buffer
3024 #+begin_example
3025 1. one item
3026 2. <<target>>another item
3027 Here we refer to item [[target]].
3028 #+end_example
3030 #+texinfo: @noindent
3031 The last sentence will appear as =Here we refer to item 2= when
3032 exported.
3034 In non-Org files, the search looks for the words in the link text.  In
3035 the above example the search would be for =target=.
3037 Following a link pushes a mark onto Org's own mark ring.  You can
3038 return to the previous position with {{{kbd(C-c &)}}}.  Using this
3039 command several times in direct succession goes back to positions
3040 recorded earlier.
3042 ** Radio Targets
3043 :PROPERTIES:
3044 :DESCRIPTION: Make targets trigger links in plain text.
3045 :END:
3046 #+cindex: radio targets
3047 #+cindex: targets, radio
3048 #+cindex: links, radio targets
3050 Org can automatically turn any occurrences of certain target names in
3051 normal text into a link.  So without explicitly creating a link, the
3052 text connects to the target radioing its position.  Radio targets are
3053 enclosed by triple angular brackets.  For example, a target =<<<My
3054 Target>>>= causes each occurrence of =my target= in normal text to
3055 become activated as a link.  The Org file is scanned automatically for
3056 radio targets only when the file is first loaded into Emacs.  To
3057 update the target list during editing, press {{{kbd(C-c C-c)}}} with
3058 point on or at a target.
3060 ** External Links
3061 :PROPERTIES:
3062 :DESCRIPTION: URL-like links to the world.
3063 :END:
3064 #+cindex: links, external
3065 #+cindex: external links
3066 #+cindex: Gnus links
3067 #+cindex: BBDB links
3068 #+cindex: irc links
3069 #+cindex: URL links
3070 #+cindex: file links
3071 #+cindex: Rmail links
3072 #+cindex: MH-E links
3073 #+cindex: Usenet links
3074 #+cindex: shell links
3075 #+cindex: Info links
3076 #+cindex: Elisp links
3078 Org supports links to files, websites, Usenet and email messages, BBDB
3079 database entries and links to both IRC conversations and their logs.
3080 External links are URL-like locators.  They start with a short
3081 identifying string followed by a colon.  There can be no space after
3082 the colon.  The following list shows examples for each link type.
3084 | =http://www.astro.uva.nl/=dominik=        | on the web                     |
3085 | =doi:10.1000/182=                         | DOI for an electronic resource |
3086 | =file:/home/dominik/images/jupiter.jpg=   | file, absolute path            |
3087 | =/home/dominik/images/jupiter.jpg=        | same as above                  |
3088 | =file:papers/last.pdf=                    | file, relative path            |
3089 | =./papers/last.pdf=                       | same as above                  |
3090 | =file:/ssh:me@some.where:papers/last.pdf= | file, path on remote machine   |
3091 | =/ssh:me@some.where:papers/last.pdf=      | same as above                  |
3092 | =file:sometextfile::NNN=                  | file, jump to line number      |
3093 | =file:projects.org=                       | another Org file               |
3094 | =file:projects.org::some words=           | text search in Org file[fn:27] |
3095 | =file:projects.org::*task title=          | heading search in Org file     |
3096 | =file+sys:/path/to/file=                  | open via OS, like double-click |
3097 | =file+emacs:/path/to/file=                | force opening by Emacs         |
3098 | =docview:papers/last.pdf::NNN=            | open in doc-view mode at page  |
3099 | =id:B7423F4D-2E8A-471B-8810-C40F074717E9= | link to heading by ID          |
3100 | =news:comp.emacs=                         | Usenet link                    |
3101 | =mailto:adent@galaxy.net=                 | mail link                      |
3102 | =mhe:folder=                              | MH-E folder link               |
3103 | =mhe:folder#id=                           | MH-E message link              |
3104 | =rmail:folder=                            | Rmail folder link              |
3105 | =rmail:folder#id=                         | Rmail message link             |
3106 | =gnus:group=                              | Gnus group link                |
3107 | =gnus:group#id=                           | Gnus article link              |
3108 | =bbdb:R.*Stallman=                        | BBDB link (with regexp)        |
3109 | =irc:/irc.com/#emacs/bob=                 | IRC link                       |
3110 | =info:org#External links=                 | Info node link                 |
3111 | =shell:ls *.org=                          | shell command                  |
3112 | =elisp:org-agenda=                        | interactive Elisp command      |
3113 | =elisp:(find-file "Elisp.org")=           | Elisp form to evaluate         |
3115 #+cindex: VM links
3116 #+cindex: Wanderlust links
3117 On top of these built-in link types, additional ones are available
3118 through the =contrib/= directory (see [[*Installation]]).  For example,
3119 these links to VM or Wanderlust messages are available when you load
3120 the corresponding libraries from the =contrib/= directory:
3122 | =vm:folder=                            | VM folder link          |
3123 | =vm:folder#id=                         | VM message link         |
3124 | =vm://myself@some.where.org/folder#id= | VM on remote machine    |
3125 | =vm-imap:account:folder=               | VM IMAP folder link     |
3126 | =vm-imap:account:folder#id=            | VM IMAP message link    |
3127 | =wl:folder=                            | Wanderlust folder link  |
3128 | =wl:folder#id=                         | Wanderlust message link |
3130 For information on customizing Org to add new link types, see [[*Adding
3131 Hyperlink Types]].
3133 A link should be enclosed in double brackets and may contain
3134 descriptive text to be displayed instead of the URL (see [[*Link
3135 Format]]), for example:
3137 : [[http://www.gnu.org/software/emacs/][GNU Emacs]]
3139 If the description is a file name or URL that points to an image, HTML
3140 export (see [[*HTML Export]]) inlines the image as a clickable button.  If
3141 there is no description at all and the link points to an image, that
3142 image is inlined into the exported HTML file.
3144 #+cindex: square brackets, around links
3145 #+cindex: angular brackets, around links
3146 #+cindex: plain text external links
3147 Org also recognizes external links amid normal text and activates them
3148 as links.  If spaces must be part of the link (for example in
3149 =bbdb:R.*Stallman=), or if you need to remove ambiguities about the
3150 end of the link, enclose the link in square or angular brackets.
3152 ** Handling Links
3153 :PROPERTIES:
3154 :DESCRIPTION: Creating, inserting and following.
3155 :END:
3156 #+cindex: links, handling
3158 Org provides methods to create a link in the correct syntax, to insert
3159 it into an Org file, and to follow the link.
3161 #+findex: org-store-link
3162 #+cindex: storing links
3163 The main function is ~org-store-link~, called with {{{kbd(M-x
3164 org-store-link)}}}.  Because of its importance, we suggest to bind it
3165 to a widely available key (see [[*Activation]]).  It stores a link to the
3166 current location.  The link is stored for later insertion into an Org
3167 buffer---see below.  The kind of link that is created depends on the
3168 current buffer:
3170 - /Org mode buffers/ ::
3172   For Org files, if there is a =<<target>>= at point, the link points
3173   to the target.  Otherwise it points to the current headline, which
3174   is also the description[fn:28].
3176   #+vindex: org-id-link-to-org-use-id
3177   #+cindex: @samp{CUSTOM_ID}, property
3178   #+cindex: @samp{ID}, property
3179   If the headline has a =CUSTOM_ID= property, store a link to this
3180   custom ID.  In addition or alternatively, depending on the value of
3181   ~org-id-link-to-org-use-id~, create and/or use a globally unique
3182   =ID= property for the link[fn:29].  So using this command in Org
3183   buffers potentially creates two links: a human-readable link from
3184   the custom ID, and one that is globally unique and works even if the
3185   entry is moved from file to file.  Later, when inserting the link,
3186   you need to decide which one to use.
3188 - /Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus/ ::
3190   #+vindex: org-link-email-description-format
3191   Pretty much all Emacs mail clients are supported.  The link points
3192   to the current article, or, in some Gnus buffers, to the group.  The
3193   description is constructed according to the variable
3194   ~org-link-email-description-format~.  By default, it refers to the
3195   addressee and the subject.
3197 - /Web browsers: W3, W3M and EWW/ ::
3199   Here the link is the current URL, with the page title as the
3200   description.
3202 - /Contacts: BBDB/ ::
3204   Links created in a BBDB buffer point to the current entry.
3206 - /Chat: IRC/ ::
3208   #+vindex: org-irc-links-to-logs
3209   For IRC links, if the variable ~org-irc-link-to-logs~ is non-~nil~,
3210   create a =file= style link to the relevant point in the logs for the
3211   current conversation.  Otherwise store an =irc= style link to the
3212   user/channel/server under the point.
3214 - /Other files/ ::
3216   For any other file, the link points to the file, with a search
3217   string (see [[*Search Options in File Links]]) pointing to the contents
3218   of the current line.  If there is an active region, the selected
3219   words form the basis of the search string. You can write custom Lisp
3220   functions to select the search string and perform the search for
3221   particular file types (see [[*Custom Searches]]).
3223   You can also define dedicated links to other files.  See [[*Adding
3224   Hyperlink Types]].
3226 - /Agenda view/ ::
3228   When point is in an agenda view, the created link points to the
3229   entry referenced by the current line.
3231 From an Org buffer, the following commands create, navigate or, more
3232 generally, act on links.
3234 #+attr_texinfo: :sep ,
3235 - {{{kbd(C-c C-l)}}} (~org-insert-link~) ::
3237   #+kindex: C-c C-l
3238   #+findex: org-insert-link
3239   #+cindex: link completion
3240   #+cindex: completion, of links
3241   #+cindex: inserting links
3242   #+vindex: org-link-keep-stored-after-insertion
3243   Insert a link[fn:30].  This prompts for a link to be inserted into
3244   the buffer.  You can just type a link, using text for an internal
3245   link, or one of the link type prefixes mentioned in the examples
3246   above.  The link is inserted into the buffer, along with
3247   a descriptive text[fn:31].  If some text was selected at this time,
3248   it becomes the default description.
3250   - /Inserting stored links/ ::
3252     All links stored during the current session are part of the
3253     history for this prompt, so you can access them with {{{kbd(UP)}}}
3254     and {{{kbd(DOWN)}}} (or {{{kbd(M-p)}}}, {{{kbd(M-n)}}}).
3256   - /Completion support/ ::
3258     Completion with {{{kbd(TAB)}}} helps you to insert valid link
3259     prefixes like =http= or =ftp=, including the prefixes defined
3260     through link abbreviations (see [[*Link Abbreviations]]).  If you
3261     press {{{kbd(RET)}}} after inserting only the prefix, Org offers
3262     specific completion support for some link types[fn:32].  For
3263     example, if you type {{{kbd(f i l e RET)}}}---alternative access:
3264     {{{kbd(C-u C-c C-l)}}}, see below---Org offers file name
3265     completion, and after {{{kbd(b b d b RET)}}} you can complete
3266     contact names.
3268 - {{{kbd(C-u C-c C-l)}}} ::
3270   #+cindex: file name completion
3271   #+cindex: completion, of file names
3272   #+kindex: C-u C-c C-l
3273   When {{{kbd(C-c C-l)}}} is called with a {{{kbd(C-u)}}} prefix
3274   argument, insert a link to a file.  You may use file name completion
3275   to select the name of the file.  The path to the file is inserted
3276   relative to the directory of the current Org file, if the linked
3277   file is in the current directory or in a sub-directory of it, or if
3278   the path is written relative to the current directory using =../=.
3279   Otherwise an absolute path is used, if possible with =~/= for your
3280   home directory.  You can force an absolute path with two
3281   {{{kbd(C-u)}}} prefixes.
3283 - {{{kbd(C-c C-l)}}} (with point on existing link) ::
3285   #+cindex: following links
3286   When point is on an existing link, {{{kbd(C-c C-l)}}} allows you to
3287   edit the link and description parts of the link.
3289 - {{{kbd(C-c C-o)}}} (~org-open-at-point~) ::
3291   #+kindex: C-c C-o
3292   #+findex: org-open-at-point
3293   #+vindex: org-file-apps
3294   Open link at point.  This launches a web browser for URL (using
3295   ~browse-url-at-point~), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
3296   the corresponding links, and execute the command in a shell link.
3297   When point is on an internal link, this command runs the
3298   corresponding search.  When point is on the tags part of a headline,
3299   it creates the corresponding tags view (see [[*Matching tags and
3300   properties]]).  If point is on a timestamp, it compiles the agenda for
3301   that date.  Furthermore, it visits text and remote files in =file=
3302   links with Emacs and select a suitable application for local
3303   non-text files.  Classification of files is based on file extension
3304   only.  See option ~org-file-apps~.  If you want to override the
3305   default application and visit the file with Emacs, use
3306   a {{{kbd(C-u)}}} prefix.  If you want to avoid opening in Emacs, use
3307   a {{{kbd(C-u C-u)}}} prefix.
3309   #+vindex: org-link-frame-setup
3310   If point is on a headline, but not on a link, offer all links in the
3311   headline and entry text.  If you want to setup the frame
3312   configuration for following links, customize ~org-link-frame-setup~.
3314 - {{{kbd(RET)}}} ::
3316   #+vindex: org-return-follows-link
3317   #+kindex: RET
3318   When ~org-return-follows-link~ is set, {{{kbd(RET)}}} also follows
3319   the link at point.
3321 - {{{kbd(mouse-2)}}} or {{{kbd(mouse-1)}}} ::
3323   #+kindex: mouse-2
3324   #+kindex: mouse-1
3325   On links, {{{kbd(mouse-1)}}} and {{{kbd(mouse-2)}}} opens the link
3326   just as {{{kbd(C-c C-o)}}} does.
3328 - {{{kbd(mouse-3)}}} ::
3330   #+vindex: org-link-use-indirect-buffer-for-internals
3331   #+kindex: mouse-3
3332   Like {{{kbd(mouse-2)}}}, but force file links to be opened with
3333   Emacs, and internal links to be displayed in another window[fn:33].
3335 - {{{kbd(C-c %)}}} (~org-mark-ring-push~) ::
3337   #+kindex: C-c %
3338   #+findex: org-mark-ring-push
3339   #+cindex: mark ring
3340   Push the current position onto the Org mark ring, to be able to
3341   return easily.  Commands following an internal link do this
3342   automatically.
3344 - {{{kbd(C-c &)}}} (~org-mark-ring-goto~) ::
3346   #+kindex: C-c &
3347   #+findex: org-mark-ring-goto
3348   #+cindex: links, returning to
3349   Jump back to a recorded position.  A position is recorded by the
3350   commands following internal links, and by {{{kbd(C-c %)}}}.  Using
3351   this command several times in direct succession moves through a ring
3352   of previously recorded positions.
3354 - {{{kbd(C-c C-x C-n)}}} (~org-next-link~), {{{kbd(C-c C-x C-p)}}} (~org-previous-link~) ::
3356   #+kindex: C-c C-x C-p
3357   #+findex: org-previous-link
3358   #+kindex: C-c C-x C-n
3359   #+findex: org-next-link
3360   #+cindex: links, finding next/previous
3361   Move forward/backward to the next link in the buffer.  At the limit
3362   of the buffer, the search fails once, and then wraps around.  The
3363   key bindings for this are really too long; you might want to bind
3364   this also to {{{kbd(M-n)}}} and {{{kbd(M-p)}}}.
3366   #+begin_src emacs-lisp
3367   (add-hook 'org-load-hook
3368             (lambda ()
3369               (define-key org-mode-map "\M-n" 'org-next-link)
3370               (define-key org-mode-map "\M-p" 'org-previous-link)))
3371   #+end_src
3373 ** Using Links Outside Org
3374 :PROPERTIES:
3375 :DESCRIPTION: Linking from my C source code?
3376 :END:
3378 #+findex: org-insert-link-global
3379 #+findex: org-open-at-point-global
3380 You can insert and follow links that have Org syntax not only in Org,
3381 but in any Emacs buffer.  For this, Org provides two functions:
3382 ~org-insert-link-global~ and ~org-open-at-point-global~.
3384 You might want to bind them to globally available keys.  See
3385 [[*Activation]] for some advice.
3387 ** Link Abbreviations
3388 :PROPERTIES:
3389 :DESCRIPTION: Shortcuts for writing complex links.
3390 :END:
3391 #+cindex: link abbreviations
3392 #+cindex: abbreviation, links
3394 Long URL can be cumbersome to type, and often many similar links are
3395 needed in a document.  For this you can use link abbreviations.  An
3396 abbreviated link looks like this
3398 : [[linkword:tag][description]]
3400 #+texinfo: @noindent
3401 #+vindex: org-link-abbrev-alist
3402 where the tag is optional.  The /linkword/ must be a word, starting
3403 with a letter, followed by letters, numbers, =-=, and =_=.
3404 Abbreviations are resolved according to the information in the
3405 variable ~org-link-abbrev-alist~ that relates the linkwords to
3406 replacement text.  Here is an example:
3408 #+begin_src emacs-lisp
3409 (setq org-link-abbrev-alist
3410       '(("bugzilla"  . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3411         ("url-to-ja" . "http://translate.google.fr/translate?sl=en&tl=ja&u=%h")
3412         ("google"    . "http://www.google.com/search?q=")
3413         ("gmap"      . "http://maps.google.com/maps?q=%s")
3414         ("omap"      . "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")
3415         ("ads"       . "https://ui.adsabs.harvard.edu/search/q=%20author%3A\"%s\"")))
3416 #+end_src
3418 If the replacement text contains the string =%s=, it is replaced with
3419 the tag.  Using =%h= instead of =%s= percent-encodes the tag (see the
3420 example above, where we need to encode the URL parameter).  Using
3421 =%(my-function)= passes the tag to a custom Lisp function, and replace
3422 it by the resulting string.
3424 If the replacement text do not contain any specifier, it is simply
3425 appended to the string in order to create the link.
3427 Instead of a string, you may also specify a Lisp function to create
3428 the link.  Such a function will be called with the tag as the only
3429 argument.
3431 With the above setting, you could link to a specific bug with
3432 =[[bugzilla:129]]=, search the web for =OrgMode= with =[[google:OrgMode]]=,
3433 show the map location of the Free Software Foundation =[[gmap:51
3434 Franklin Street, Boston]]= or of Carsten office =[[omap:Science Park 904,
3435 Amsterdam, The Netherlands]]= and find out what the Org author is doing
3436 besides Emacs hacking with =[[ads:Dominik,C]]=.
3438 If you need special abbreviations just for a single Org buffer, you
3439 can define them in the file with
3441 #+cindex: @samp{LINK}, keyword
3442 #+begin_example
3443 ,#+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3444 ,#+LINK: google    http://www.google.com/search?q=%s
3445 #+end_example
3447 In-buffer completion (see [[*Completion]]) can be used after =[= to
3448 complete link abbreviations.  You may also define a Lisp function that
3449 implements special (e.g., completion) support for inserting such a
3450 link with {{{kbd(C-c C-l)}}}.  Such a function should not accept any
3451 arguments, and should return the full link with a prefix.  You can set
3452 the link completion function like this:
3454 #+begin_src emacs-lisp
3455 (org-link-set-parameter "type" :complete #'some-completion-function)
3456 #+end_src
3458 ** Search Options in File Links
3459 :PROPERTIES:
3460 :DESCRIPTION: Linking to a specific location.
3461 :ALT_TITLE: Search Options
3462 :END:
3463 #+cindex: search option in file links
3464 #+cindex: file links, searching
3466 File links can contain additional information to make Emacs jump to
3467 a particular location in the file when following a link.  This can be
3468 a line number or a search option after a double colon[fn:34].  For
3469 example, when the command ~org-store-link~ creates a link (see
3470 [[*Handling Links]]) to a file, it encodes the words in the current line
3471 as a search string that can be used to find this line back later when
3472 following the link with {{{kbd(C-c C-o)}}}.
3474 Here is the syntax of the different ways to attach a search to a file
3475 link, together with explanations for each:
3477 #+begin_example
3478 [[file:~/code/main.c::255]]
3479 [[file:~/xx.org::My Target]]
3480 [[file:~/xx.org::*My Target]]
3481 [[file:~/xx.org::#my-custom-id]]
3482 [[file:~/xx.org::/regexp/]]
3483 #+end_example
3485 - =255= ::
3487   Jump to line 255.
3489 - =My Target= ::
3491   Search for a link target =<<My Target>>=, or do a text search for
3492   =my target=, similar to the search in internal links, see [[*Internal
3493   Links]].  In HTML export (see [[*HTML Export]]), such a file link becomes
3494   a HTML reference to the corresponding named anchor in the linked
3495   file.
3497 - =*My Target= ::
3499   In an Org file, restrict search to headlines.
3501 - =#my-custom-id= ::
3503   Link to a heading with a =CUSTOM_ID= property
3505 - =/REGEXP/= ::
3507   Do a regular expression search for {{{var(REGEXP)}}}.  This uses the
3508   Emacs command ~occur~ to list all matches in a separate window.  If
3509   the target file is in Org mode, ~org-occur~ is used to create
3510   a sparse tree with the matches.
3512 As a degenerate case, a file link with an empty file name can be used
3513 to search the current file.  For example, =[[file:::find me]]= does
3514 a search for =find me= in the current file, just as =[[find me]]=
3515 would.
3517 ** Custom Searches
3518 :PROPERTIES:
3519 :DESCRIPTION: When the default search is not enough.
3520 :END:
3521 #+cindex: custom search strings
3522 #+cindex: search strings, custom
3524 The default mechanism for creating search strings and for doing the
3525 actual search related to a file link may not work correctly in all
3526 cases.  For example, BibTeX database files have many entries like
3527 ~year="1993"~ which would not result in good search strings, because
3528 the only unique identification for a BibTeX entry is the citation key.
3530 #+vindex: org-create-file-search-functions
3531 #+vindex: org-execute-file-search-functions
3532 If you come across such a problem, you can write custom functions to
3533 set the right search string for a particular file type, and to do the
3534 search for the string in the file.  Using ~add-hook~, these functions
3535 need to be added to the hook variables
3536 ~org-create-file-search-functions~ and
3537 ~org-execute-file-search-functions~.  See the docstring for these
3538 variables for more information.  Org actually uses this mechanism for
3539 BibTeX database files, and you can use the corresponding code as an
3540 implementation example.  See the file =ol-bibtex.el=.
3542 * TODO Items
3543 :PROPERTIES:
3544 :DESCRIPTION: Every tree branch can be a TODO item.
3545 :END:
3546 #+cindex: TODO items
3548 Org mode does not maintain TODO lists as separate documents[fn:35].
3549 Instead, TODO items are an integral part of the notes file, because
3550 TODO items usually come up while taking notes!  With Org mode, simply
3551 mark any entry in a tree as being a TODO item.  In this way,
3552 information is not duplicated, and the entire context from which the
3553 TODO item emerged is always present.
3555 Of course, this technique for managing TODO items scatters them
3556 throughout your notes file.  Org mode compensates for this by
3557 providing methods to give you an overview of all the things that you
3558 have to do.
3560 ** Basic TODO Functionality
3561 :PROPERTIES:
3562 :DESCRIPTION: Marking and displaying TODO entries.
3563 :ALT_TITLE: TODO Basics
3564 :END:
3566 Any headline becomes a TODO item when it starts with the word =TODO=,
3567 for example:
3569 : *** TODO Write letter to Sam Fortune
3571 The most important commands to work with TODO entries are:
3573 - {{{kbd(C-c C-t)}}} (~org-todo~) ::
3575   #+kindex: C-c C-t
3576   #+cindex: cycling, of TODO states
3577   Rotate the TODO state of the current item among
3579   #+begin_example
3580   ,-> (unmarked) -> TODO -> DONE --.
3581   '--------------------------------'
3582   #+end_example
3584   If TODO keywords have fast access keys (see [[*Fast access to TODO
3585   states]]), prompt for a TODO keyword through the fast selection
3586   interface; this is the default behavior when
3587   ~org-use-fast-todo-selection~ is non-~nil~.
3589   The same rotation can also be done "remotely" from the agenda buffer
3590   with the {{{kbd(t)}}} command key (see [[*Commands in the Agenda
3591   Buffer]]).
3593 - {{{kbd(C-u C-c C-t)}}} ::
3595   #+kindex: C-u C-c C-t
3596   When TODO keywords have no selection keys, select a specific keyword
3597   using completion; otherwise force cycling through TODO states with
3598   no prompt.  When ~org-use-fast-todo-selection~ is set to ~prefix~,
3599   use the fast selection interface.
3601 - {{{kbd(S-RIGHT)}}} {{{kbd(S-LEFT)}}} ::
3603   #+kindex: S-RIGHT
3604   #+kindex: S-LEFT
3605   #+vindex: org-treat-S-cursor-todo-selection-as-state-change
3606   Select the following/preceding TODO state, similar to cycling.
3607   Useful mostly if more than two TODO states are possible (see
3608   [[*Extended Use of TODO Keywords]]).  See also [[*Packages that conflict
3609   with Org mode]], for a discussion of the interaction with
3610   ~shift-selection-mode~.  See also the variable
3611   ~org-treat-S-cursor-todo-selection-as-state-change~.
3613 - {{{kbd(C-c / t)}}} (~org-show-todo-tree~) ::
3615   #+kindex: C-c / t
3616   #+cindex: sparse tree, for TODO
3617   #+vindex: org-todo-keywords
3618   #+findex: org-show-todo-tree
3619   View TODO items in a /sparse tree/ (see [[*Sparse Trees]]).  Folds the
3620   entire buffer, but shows all TODO items---with not-DONE state---and
3621   the headings hierarchy above them.  With a prefix argument, or by
3622   using {{{kbd(C-c / T)}}}, search for a specific TODO.  You are
3623   prompted for the keyword, and you can also give a list of keywords
3624   like =KWD1|KWD2|...= to list entries that match any one of these
3625   keywords.  With a numeric prefix argument N, show the tree for the
3626   Nth keyword in the variable ~org-todo-keywords~.  With two prefix
3627   arguments, find all TODO states, both un-done and done.
3629 - {{{kbd(M-x org-agenda t)}}} (~org-todo-list~) ::
3631   #+kindex: t @r{(Agenda dispatcher)}
3632   Show the global TODO list.  Collects the TODO items (with not-DONE
3633   states) from all agenda files (see [[*Agenda Views]]) into a single
3634   buffer.  The new buffer is in Org Agenda mode, which provides
3635   commands to examine and manipulate the TODO entries from the new
3636   buffer (see [[*Commands in the Agenda Buffer]]).  See [[*The global TODO
3637   list]], for more information.
3639 - {{{kbd(S-M-RET)}}} (~org-insert-todo-heading~) ::
3641   #+kindex: S-M-RET
3642   #+findex: org-insert-todo-heading
3643   Insert a new TODO entry below the current one.
3645 #+vindex: org-todo-state-tags-triggers
3646 Changing a TODO state can also trigger tag changes.  See the docstring
3647 of the option ~org-todo-state-tags-triggers~ for details.
3649 ** Extended Use of TODO Keywords
3650 :PROPERTIES:
3651 :DESCRIPTION: Workflow and assignments.
3652 :ALT_TITLE: TODO Extensions
3653 :END:
3654 #+cindex: extended TODO keywords
3656 #+vindex: org-todo-keywords
3657 By default, marked TODO entries have one of only two states: TODO and
3658 DONE.  Org mode allows you to classify TODO items in more complex ways
3659 with /TODO keywords/ (stored in ~org-todo-keywords~).  With special
3660 setup, the TODO keyword system can work differently in different
3661 files.
3663 Note that /tags/ are another way to classify headlines in general and
3664 TODO items in particular (see [[*Tags]]).
3666 *** TODO keywords as workflow states
3667 :PROPERTIES:
3668 :DESCRIPTION: From TODO to DONE in steps.
3669 :ALT_TITLE: Workflow states
3670 :END:
3671 #+cindex: TODO workflow
3672 #+cindex: workflow states as TODO keywords
3674 You can use TODO keywords to indicate different /sequential/ states in
3675 the process of working on an item, for example[fn:36]:
3677 #+begin_src emacs-lisp
3678 (setq org-todo-keywords
3679       '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3680 #+end_src
3682 The vertical bar separates the TODO keywords (states that /need
3683 action/) from the DONE states (which need /no further action/).  If
3684 you do not provide the separator bar, the last state is used as the
3685 DONE state.
3687 #+cindex: completion, of TODO keywords
3688 With this setup, the command {{{kbd(C-c C-t)}}} cycles an entry from
3689 =TODO= to =FEEDBACK=, then to =VERIFY=, and finally to =DONE= and
3690 =DELEGATED=.  You may also use a numeric prefix argument to quickly
3691 select a specific state.  For example {{{kbd(C-3 C-c C-t)}}} changes
3692 the state immediately to =VERIFY=.  Or you can use {{{kbd(S-LEFT)}}}
3693 to go backward through the sequence.  If you define many keywords, you
3694 can use in-buffer completion (see [[*Completion]]) or even a special
3695 one-key selection scheme (see [[*Fast access to TODO states]]) to insert
3696 these words into the buffer.  Changing a TODO state can be logged with
3697 a timestamp, see [[*Tracking TODO state changes]], for more information.
3699 *** TODO keywords as types
3700 :PROPERTIES:
3701 :DESCRIPTION: I do this, Fred does the rest.
3702 :ALT_TITLE: TODO types
3703 :END:
3704 #+cindex: TODO types
3705 #+cindex: names as TODO keywords
3706 #+cindex: types as TODO keywords
3708 The second possibility is to use TODO keywords to indicate different
3709 /types/ of action items.  For example, you might want to indicate that
3710 items are for "work" or "home".  Or, when you work with several people
3711 on a single project, you might want to assign action items directly to
3712 persons, by using their names as TODO keywords.  This would be set up
3713 like this:
3715 #+begin_src emacs-lisp
3716 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3717 #+end_src
3719 In this case, different keywords do not indicate a sequence, but
3720 rather different types.  So the normal work flow would be to assign
3721 a task to a person, and later to mark it DONE.  Org mode supports this
3722 style by adapting the workings of the command {{{kbd(C-c
3723 C-t)}}}[fn:37].  When used several times in succession, it still
3724 cycles through all names, in order to first select the right type for
3725 a task.  But when you return to the item after some time and execute
3726 {{{kbd(C-c C-t)}}} again, it will switch from any name directly to
3727 =DONE=.  Use prefix arguments or completion to quickly select
3728 a specific name.  You can also review the items of a specific TODO
3729 type in a sparse tree by using a numeric prefix to {{{kbd(C-c / t)}}}.
3730 For example, to see all things Lucy has to do, you would use
3731 {{{kbd(C-3 C-c / t)}}}.  To collect Lucy's items from all agenda files
3732 into a single buffer, you would use the numeric prefix argument as
3733 well when creating the global TODO list: {{{kbd(C-3 M-x org-agenda
3734 t)}}}.
3736 *** Multiple keyword sets in one file
3737 :PROPERTIES:
3738 :DESCRIPTION: Mixing it all, still finding your way.
3739 :ALT_TITLE: Multiple sets in one file
3740 :END:
3741 #+cindex: TODO keyword sets
3743 Sometimes you may want to use different sets of TODO keywords in
3744 parallel.  For example, you may want to have the basic TODO/DONE, but
3745 also a workflow for bug fixing, and a separate state indicating that
3746 an item has been canceled---so it is not DONE, but also does not
3747 require action.  Your setup would then look like this:
3749 #+begin_src emacs-lisp
3750 (setq org-todo-keywords
3751       '((sequence "TODO" "|" "DONE")
3752         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3753         (sequence "|" "CANCELED")))
3754 #+end_src
3756 The keywords should all be different, this helps Org mode keep track
3757 of which subsequence should be used for a given entry.  In this setup,
3758 {{{kbd(C-c C-t)}}} only operates within a sub-sequence, so it switches
3759 from =DONE= to (nothing) to =TODO=, and from =FIXED= to (nothing) to
3760 =REPORT=.  Therefore you need a mechanism to initially select the
3761 correct sequence.  In addition to typing a keyword or using completion
3762 (see [[*Completion]]), you may also apply the following commands:
3764 #+attr_texinfo: :sep ,
3765 - {{{kbd(C-u C-u C-c C-t)}}}, {{{kbd(C-S-RIGHT)}}}, {{{kbd(C-S-LEFT)}}} ::
3767   #+kindex: C-S-RIGHT
3768   #+kindex: C-S-LEFT
3769   #+kindex: C-u C-u C-c C-t
3770   These keys jump from one TODO sub-sequence to the next.  In the
3771   above example, {{{kbd(C-u C-u C-c C-t)}}} or {{{kbd(C-S-RIGHT)}}}
3772   would jump from =TODO= or =DONE= to =REPORT=, and any of the words
3773   in the second row to =CANCELED=.  Note that the {{{kbd(C-S-)}}} key
3774   binding conflict with ~shift-selection-mode~ (see [[*Packages that
3775   conflict with Org mode]]).
3777 - {{{kbd(S-RIGHT)}}}, {{{kbd(S-LEFT)}}} ::
3779   #+kindex: S-RIGHT
3780   #+kindex: S-LEFT
3781   {{{kbd(S-LEFT)}}} and {{{kbd(S-RIGHT)}}} walk through /all/ keywords
3782   from all sub-sequences, so for example {{{kbd(S-RIGHT)}}} would
3783   switch from =DONE= to =REPORT= in the example above.  For
3784   a discussion of the interaction with ~shift-selection-mode~, see
3785   [[*Packages that conflict with Org mode]].
3787 *** Fast access to TODO states
3788 :PROPERTIES:
3789 :DESCRIPTION: Single letter selection of state.
3790 :END:
3792 If you would like to quickly change an entry to an arbitrary TODO
3793 state instead of cycling through the states, you can set up keys for
3794 single-letter access to the states.  This is done by adding the
3795 selection character after each keyword, in parentheses[fn:38].  For
3796 example:
3798 #+begin_src emacs-lisp
3799 (setq org-todo-keywords
3800       '((sequence "TODO(t)" "|" "DONE(d)")
3801         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3802         (sequence "|" "CANCELED(c)")))
3803 #+end_src
3805 #+vindex: org-fast-tag-selection-include-todo
3806 If you then press {{{kbd(C-c C-t)}}} followed by the selection key,
3807 the entry is switched to this state.  {{{kbd(SPC)}}} can be used to
3808 remove any TODO keyword from an entry[fn:39].
3810 *** Setting up keywords for individual files
3811 :PROPERTIES:
3812 :DESCRIPTION: Different files, different requirements.
3813 :ALT_TITLE: Per-file keywords
3814 :END:
3815 #+cindex: keyword options
3816 #+cindex: per-file keywords
3817 #+cindex: @samp{TODO}, keyword
3818 #+cindex: @samp{TYP_TODO}, keyword
3819 #+cindex: @samp{SEQ_TODO}, keyword
3821 It can be very useful to use different aspects of the TODO mechanism
3822 in different files.  For file-local settings, you need to add special
3823 lines to the file which set the keywords and interpretation for that
3824 file only.  For example, to set one of the two examples discussed
3825 above, you need one of the following lines, starting in column zero
3826 anywhere in the file:
3828 : #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3830 You may also write =#+SEQ_TODO= to be explicit about the
3831 interpretation, but it means the same as =#+TODO=, or
3833 : #+TYP_TODO: Fred Sara Lucy Mike | DONE
3835 A setup for using several sets in parallel would be:
3837 #+begin_example
3838 ,#+TODO: TODO | DONE
3839 ,#+TODO: REPORT BUG KNOWNCAUSE | FIXED
3840 ,#+TODO: | CANCELED
3841 #+end_example
3843 #+cindex: completion, of option keywords
3844 #+kindex: M-TAB
3845 To make sure you are using the correct keyword, type =#+= into the
3846 buffer and then use {{{kbd(M-TAB)}}} to complete it (see [[*Completion]]).
3848 #+cindex: DONE, final TODO keyword
3849 Remember that the keywords after the vertical bar---or the last
3850 keyword if no bar is there---must always mean that the item is DONE,
3851 although you may use a different word.  After changing one of these
3852 lines, use {{{kbd(C-c C-c)}}} with point still in the line to make the
3853 changes known to Org mode[fn:40].
3855 *** Faces for TODO keywords
3856 :PROPERTIES:
3857 :DESCRIPTION: Highlighting states.
3858 :END:
3859 #+cindex: faces, for TODO keywords
3861 #+vindex: org-todo, face
3862 #+vindex: org-done, face
3863 #+vindex: org-todo-keyword-faces
3864 Org mode highlights TODO keywords with special faces: ~org-todo~ for
3865 keywords indicating that an item still has to be acted upon, and
3866 ~org-done~ for keywords indicating that an item is finished.  If you
3867 are using more than two different states, you might want to use
3868 special faces for some of them.  This can be done using the variable
3869 ~org-todo-keyword-faces~.  For example:
3871 #+begin_src emacs-lisp
3872 (setq org-todo-keyword-faces
3873       '(("TODO" . org-warning) ("STARTED" . "yellow")
3874         ("CANCELED" . (:foreground "blue" :weight bold))))
3875 #+end_src
3877 #+vindex: org-faces-easy-properties
3878 While using a list with face properties as shown for =CANCELED=
3879 /should/ work, this does not always seem to be the case.  If
3880 necessary, define a special face and use that.  A string is
3881 interpreted as a color.  The variable ~org-faces-easy-properties~
3882 determines if that color is interpreted as a foreground or
3883 a background color.
3885 *** TODO dependencies
3886 :PROPERTIES:
3887 :DESCRIPTION: When one task needs to wait for others.
3888 :END:
3889 #+cindex: TODO dependencies
3890 #+cindex: dependencies, of TODO states
3892 #+vindex: org-enforce-todo-dependencies
3893 #+cindex: @samp{ORDERED}, property
3894 The structure of Org files---hierarchy and lists---makes it easy to
3895 define TODO dependencies.  Usually, a parent TODO task should not be
3896 marked as done until all TODO subtasks, or children tasks, are marked
3897 as done.  Sometimes there is a logical sequence to (sub)tasks, so that
3898 one subtask cannot be acted upon before all siblings above it have
3899 been marked as done.  If you customize the variable
3900 ~org-enforce-todo-dependencies~, Org blocks entries from changing
3901 state to DONE while they have TODO children that are not DONE.
3902 Furthermore, if an entry has a property =ORDERED=, each of its TODO
3903 children is blocked until all earlier siblings are marked as done.
3904 Here is an example:
3906 #+begin_example
3907 ,* TODO Blocked until (two) is done
3908 ,** DONE one
3909 ,** TODO two
3911 ,* Parent
3912 :PROPERTIES:
3913 :ORDERED:  t
3914 :END:
3915 ,** TODO a
3916 ,** TODO b, needs to wait for (a)
3917 ,** TODO c, needs to wait for (a) and (b)
3918 #+end_example
3920 #+cindex: TODO dependencies, @samp{NOBLOCKING}
3921 #+cindex: @samp{NOBLOCKING}, property
3922 You can ensure an entry is never blocked by using the =NOBLOCKING=
3923 property (see [[*Properties and Columns]]):
3925 #+begin_example
3926 ,* This entry is never blocked
3927 :PROPERTIES:
3928 :NOBLOCKING: t
3929 :END:
3930 #+end_example
3932 - {{{kbd(C-c C-x o)}}} (~org-toggle-ordered-property~) ::
3934   #+kindex: C-c C-x o
3935   #+findex: org-toggle-ordered-property
3936   #+vindex: org-track-ordered-property-with-tag
3937   Toggle the =ORDERED= property of the current entry.  A property is
3938   used for this behavior because this should be local to the current
3939   entry, not inherited from entries above like a tag (see [[*Tags]]).
3940   However, if you would like to /track/ the value of this property
3941   with a tag for better visibility, customize the variable
3942   ~org-track-ordered-property-with-tag~.
3944 - {{{kbd(C-u C-u C-u C-c C-t)}}} ::
3946   #+kindex: C-u C-u C-u C-c C-t
3947   Change TODO state, regardless of any state blocking.
3949 #+vindex: org-agenda-dim-blocked-tasks
3950 If you set the variable ~org-agenda-dim-blocked-tasks~, TODO entries
3951 that cannot be marked as done because of unmarked children are shown
3952 in a dimmed font or even made invisible in agenda views (see [[*Agenda
3953 Views]]).
3955 #+cindex: checkboxes and TODO dependencies
3956 #+vindex: org-enforce-todo-dependencies
3957 You can also block changes of TODO states by using checkboxes (see
3958 [[*Checkboxes]]).  If you set the variable
3959 ~org-enforce-todo-checkbox-dependencies~, an entry that has unchecked
3960 checkboxes is blocked from switching to DONE.
3962 If you need more complex dependency structures, for example
3963 dependencies between entries in different trees or files, check out
3964 the contributed module =org-depend.el=.
3966 ** Progress Logging
3967 :PROPERTIES:
3968 :DESCRIPTION: Dates and notes for progress.
3969 :END:
3970 #+cindex: progress logging
3971 #+cindex: logging, of progress
3973 Org mode can automatically record a timestamp and optionally a note
3974 when you mark a TODO item as DONE, or even each time you change the
3975 state of a TODO item.  This system is highly configurable, settings
3976 can be on a per-keyword basis and can be localized to a file or even a
3977 subtree.  For information on how to clock working time for a task, see
3978 [[*Clocking Work Time]].
3980 *** Closing items
3981 :PROPERTIES:
3982 :DESCRIPTION: When was this entry marked as done?
3983 :END:
3985 The most basic logging is to keep track of /when/ a certain TODO item
3986 was marked as done.  This can be achieved with[fn:41]
3988 #+begin_src emacs-lisp
3989 (setq org-log-done 'time)
3990 #+end_src
3992 #+vindex: org-closed-keep-when-no-todo
3993 #+texinfo: @noindent
3994 Then each time you turn an entry from a TODO (not-done) state into any
3995 of the DONE states, a line =CLOSED: [timestamp]= is inserted just
3996 after the headline.  If you turn the entry back into a TODO item
3997 through further state cycling, that line is removed again.  If you
3998 turn the entry back to a non-TODO state (by pressing {{{kbd(C-c C-t
3999 SPC)}}} for example), that line is also removed, unless you set
4000 ~org-closed-keep-when-no-todo~ to non-~nil~.  If you want to record
4001 a note along with the timestamp, use[fn:42]
4003 #+begin_src emacs-lisp
4004 (setq org-log-done 'note)
4005 #+end_src
4007 #+texinfo: @noindent
4008 You are then be prompted for a note, and that note is stored below the
4009 entry with a =Closing Note= heading.
4011 *** Tracking TODO state changes
4012 :PROPERTIES:
4013 :DESCRIPTION: When did the status change?
4014 :END:
4015 #+cindex: drawer, for state change recording
4017 #+vindex: org-log-states-order-reversed
4018 #+vindex: org-log-into-drawer
4019 #+cindex: @samp{LOG_INTO_DRAWER}, property
4020 When TODO keywords are used as workflow states (see [[*TODO keywords as workflow states][*Workflow states]]),
4021 you might want to keep track of when a state change occurred and maybe
4022 take a note about this change.  You can either record just a
4023 timestamp, or a time-stamped note.  These records are inserted after
4024 the headline as an itemized list, newest first[fn:43].  When taking a
4025 lot of notes, you might want to get the notes out of the way into a
4026 drawer (see [[*Drawers]]).  Customize the variable ~org-log-into-drawer~
4027 to get this behavior---the recommended drawer for this is called
4028 =LOGBOOK=[fn:44].  You can also overrule the setting of this variable
4029 for a subtree by setting a =LOG_INTO_DRAWER= property.
4031 Since it is normally too much to record a note for every state, Org
4032 mode expects configuration on a per-keyword basis for this.  This is
4033 achieved by adding special markers =!= (for a timestamp) or =@= (for
4034 a note with timestamp) in parentheses after each keyword.  For
4035 example, with the setting
4037 #+begin_src emacs-lisp
4038 (setq org-todo-keywords
4039       '((sequence "TODO(t)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)")))
4040 #+end_src
4042 #+texinfo: @noindent
4043 to record a timestamp without a note for TODO keywords configured with
4044 =@=, just type {{{kbd(C-c C-c)}}} to enter a blank note when prompted.
4046 #+vindex: org-log-done
4047 You not only define global TODO keywords and fast access keys, but
4048 also request that a time is recorded when the entry is set to =DONE=,
4049 and that a note is recorded when switching to =WAIT= or
4050 =CANCELED=[fn:45].  The setting for =WAIT= is even more special: the
4051 =!= after the slash means that in addition to the note taken when
4052 entering the state, a timestamp should be recorded when /leaving/ the
4053 =WAIT= state, if and only if the /target/ state does not configure
4054 logging for entering it.  So it has no effect when switching from
4055 =WAIT= to =DONE=, because =DONE= is configured to record a timestamp
4056 only.  But when switching from =WAIT= back to =TODO=, the =/!= in the
4057 =WAIT= setting now triggers a timestamp even though =TODO= has no
4058 logging configured.
4060 You can use the exact same syntax for setting logging preferences local
4061 to a buffer:
4063 : #+TODO: TODO(t) WAIT(w@/!) | DONE(d!) CANCELED(c@)
4065 #+cindex: @samp{LOGGING}, property
4066 In order to define logging settings that are local to a subtree or
4067 a single item, define a =LOGGING= property in this entry.  Any
4068 non-empty =LOGGING= property resets all logging settings to ~nil~.
4069 You may then turn on logging for this specific tree using =STARTUP=
4070 keywords like =lognotedone= or =logrepeat=, as well as adding state
4071 specific settings like =TODO(!)=.  For example:
4073 #+begin_example
4074 ,* TODO Log each state with only a time
4075   :PROPERTIES:
4076   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
4077   :END:
4078 ,* TODO Only log when switching to WAIT, and when repeating
4079   :PROPERTIES:
4080   :LOGGING: WAIT(@) logrepeat
4081   :END:
4082 ,* TODO No logging at all
4083   :PROPERTIES:
4084   :LOGGING: nil
4085   :END:
4086 #+end_example
4088 *** Tracking your habits
4089 :PROPERTIES:
4090 :DESCRIPTION: How consistent have you been?
4091 :END:
4092 #+cindex: habits
4093 #+cindex: @samp{STYLE}, property
4095 Org has the ability to track the consistency of a special category of
4096 TODO, called "habits."  To use habits, you have to enable the ~habits~
4097 module by customizing the variable ~org-modules~.
4099 A habit has the following properties:
4101 1. The habit is a TODO item, with a TODO keyword representing an open
4102    state.
4104 2. The property =STYLE= is set to the value =habit= (see [[*Properties
4105    and Columns]]).
4107 3. The TODO has a scheduled date, usually with a =.+= style repeat
4108    interval.  A =++= style may be appropriate for habits with time
4109    constraints, e.g., must be done on weekends, or a =+= style for an
4110    unusual habit that can have a backlog, e.g., weekly reports.
4112 4. The TODO may also have minimum and maximum ranges specified by
4113    using the syntax =.+2d/3d=, which says that you want to do the task
4114    at least every three days, but at most every two days.
4116 5. State logging for the DONE state is enabled (see [[*Tracking TODO
4117    state changes]]), in order for historical data to be represented in
4118    the consistency graph.  If it is not enabled it is not an error,
4119    but the consistency graphs are largely meaningless.
4121 To give you an idea of what the above rules look like in action, here's an
4122 actual habit with some history:
4124 #+begin_example
4125 ,** TODO Shave
4126    SCHEDULED: <2009-10-17 Sat .+2d/4d>
4127    :PROPERTIES:
4128    :STYLE:    habit
4129    :LAST_REPEAT: [2009-10-19 Mon 00:36]
4130    :END:
4131    - State "DONE"       from "TODO"       [2009-10-15 Thu]
4132    - State "DONE"       from "TODO"       [2009-10-12 Mon]
4133    - State "DONE"       from "TODO"       [2009-10-10 Sat]
4134    - State "DONE"       from "TODO"       [2009-10-04 Sun]
4135    - State "DONE"       from "TODO"       [2009-10-02 Fri]
4136    - State "DONE"       from "TODO"       [2009-09-29 Tue]
4137    - State "DONE"       from "TODO"       [2009-09-25 Fri]
4138    - State "DONE"       from "TODO"       [2009-09-19 Sat]
4139    - State "DONE"       from "TODO"       [2009-09-16 Wed]
4140    - State "DONE"       from "TODO"       [2009-09-12 Sat]
4141 #+end_example
4143 What this habit says is: I want to shave at most every 2 days---given
4144 by the =SCHEDULED= date and repeat interval---and at least every
4145 4 days.  If today is the 15th, then the habit first appears in the
4146 agenda (see [[*Agenda Views]]) on Oct 17, after the minimum of 2 days has
4147 elapsed, and will appear overdue on Oct 19, after four days have
4148 elapsed.
4150 What's really useful about habits is that they are displayed along
4151 with a consistency graph, to show how consistent you've been at
4152 getting that task done in the past.  This graph shows every day that
4153 the task was done over the past three weeks, with colors for each day.
4154 The colors used are:
4156 - Blue :: If the task was not to be done yet on that day.
4157 - Green :: If the task could have been done on that day.
4158 - Yellow :: If the task was going to be overdue the next day.
4159 - Red :: If the task was overdue on that day.
4161 In addition to coloring each day, the day is also marked with an
4162 asterisk if the task was actually done that day, and an exclamation
4163 mark to show where the current day falls in the graph.
4165 There are several configuration variables that can be used to change
4166 the way habits are displayed in the agenda.
4168 - ~org-habit-graph-column~ ::
4170   #+vindex: org-habit-graph-column
4171   The buffer column at which the consistency graph should be drawn.
4172   This overwrites any text in that column, so it is a good idea to
4173   keep your habits' titles brief and to the point.
4175 - ~org-habit-preceding-days~ ::
4177   #+vindex: org-habit-preceding-days
4178   The amount of history, in days before today, to appear in
4179   consistency graphs.
4181 - ~org-habit-following-days~ ::
4183   #+vindex: org-habit-following-days
4184   The number of days after today that appear in consistency graphs.
4186 - ~org-habit-show-habits-only-for-today~ ::
4188   #+vindex: org-habit-show-habits-only-for-today
4189   If non-~nil~, only show habits in today's agenda view.  The default
4190   value is ~t~.  Pressing {{{kbd(C-u K)}}} in the agenda toggles this
4191   variable.
4193 Lastly, pressing {{{kbd(K)}}} in the agenda buffer causes habits to
4194 temporarily be disabled and do not appear at all.  Press {{{kbd(K)}}}
4195 again to bring them back.  They are also subject to tag filtering, if
4196 you have habits which should only be done in certain contexts, for
4197 example.
4199 ** Priorities
4200 :PROPERTIES:
4201 :DESCRIPTION: Some things are more important than others.
4202 :END:
4203 #+cindex: priorities
4204 #+cindex: priority cookie
4206 If you use Org mode extensively, you may end up with enough TODO items
4207 that it starts to make sense to prioritize them.  Prioritizing can be
4208 done by placing a /priority cookie/ into the headline of a TODO item,
4209 like this
4211 : *** TODO [#A] Write letter to Sam Fortune
4213 #+vindex: org-priority-faces
4214 By default, Org mode supports three priorities: =A=, =B=, and =C=.
4215 =A= is the highest priority.  An entry without a cookie is treated as
4216 equivalent if it had priority =B=.  Priorities make a difference only
4217 for sorting in the agenda (see [[*Weekly/daily agenda]]); outside the
4218 agenda, they have no inherent meaning to Org mode.  The cookies are
4219 displayed with the face defined by the variable ~org-priority-faces~,
4220 which can be customized.
4222 Priorities can be attached to any outline node; they do not need to be
4223 TODO items.
4225 #+attr_texinfo: :sep ;
4226 - {{{kbd(C-c \,)}}} (~org-priority~) ::
4228   #+kindex: C-c ,
4229   #+findex: org-priority
4230   Set the priority of the current headline.  The command prompts for
4231   a priority character =A=, =B= or =C=.  When you press {{{kbd(SPC)}}}
4232   instead, the priority cookie, if one is set, is removed from the
4233   headline.  The priorities can also be changed "remotely" from the
4234   agenda buffer with the {{{kbd(\,)}}} command (see [[*Commands in the
4235   Agenda Buffer]]).
4237 - {{{kbd(S-UP)}}} (~org-priority-up~); {{{kbd(S-DOWN)}}} (~org-priority-down~) ::
4239   #+kindex: S-UP
4240   #+kindex: S-DOWN
4241   #+findex: org-priority-up
4242   #+findex: org-priority-down
4243   #+vindex: org-priority-start-cycle-with-default
4244   Increase/decrease the priority of the current headline[fn:46].  Note
4245   that these keys are also used to modify timestamps (see [[*Creating
4246   Timestamps]]).  See also [[*Packages that conflict with Org mode]], for
4247   a discussion of the interaction with ~shift-selection-mode~.
4249 #+vindex: org-highest-priority
4250 #+vindex: org-lowest-priority
4251 #+vindex: org-default-priority
4252 You can change the range of allowed priorities by setting the
4253 variables ~org-highest-priority~, ~org-lowest-priority~, and
4254 ~org-default-priority~.  For an individual buffer, you may set these
4255 values (highest, lowest, default) like this (please make sure that the
4256 highest priority is earlier in the alphabet than the lowest priority):
4258 #+cindex: @samp{PRIORITIES}, keyword
4259 : #+PRIORITIES: A C B
4261 ** Breaking Down Tasks into Subtasks
4262 :PROPERTIES:
4263 :DESCRIPTION: Splitting a task into manageable pieces.
4264 :ALT_TITLE: Breaking Down Tasks
4265 :END:
4266 #+cindex: tasks, breaking down
4267 #+cindex: statistics, for TODO items
4269 #+vindex: org-agenda-todo-list-sublevels
4270 It is often advisable to break down large tasks into smaller,
4271 manageable subtasks.  You can do this by creating an outline tree
4272 below a TODO item, with detailed subtasks on the tree[fn:47].  To keep
4273 an overview of the fraction of subtasks that have already been marked
4274 as done, insert either =[/]= or =[%]= anywhere in the headline.  These
4275 cookies are updated each time the TODO status of a child changes, or
4276 when pressing {{{kbd(C-c C-c)}}} on the cookie.  For example:
4278 #+begin_example
4279 ,* Organize Party [33%]
4280 ,** TODO Call people [1/2]
4281 ,*** TODO Peter
4282 ,*** DONE Sarah
4283 ,** TODO Buy food
4284 ,** DONE Talk to neighbor
4285 #+end_example
4287 #+cindex: @samp{COOKIE_DATA}, property
4288 If a heading has both checkboxes and TODO children below it, the
4289 meaning of the statistics cookie become ambiguous.  Set the property
4290 =COOKIE_DATA= to either =checkbox= or =todo= to resolve this issue.
4292 #+vindex: org-hierarchical-todo-statistics
4293 If you would like to have the statistics cookie count any TODO entries
4294 in the subtree (not just direct children), configure the variable
4295 ~org-hierarchical-todo-statistics~.  To do this for a single subtree,
4296 include the word =recursive= into the value of the =COOKIE_DATA=
4297 property.
4299 #+begin_example org
4300 ,* Parent capturing statistics [2/20]
4301   :PROPERTIES:
4302   :COOKIE_DATA: todo recursive
4303   :END:
4304 #+end_example
4306 If you would like a TODO entry to automatically change to DONE when
4307 all children are done, you can use the following setup:
4309 #+begin_src emacs-lisp
4310 (defun org-summary-todo (n-done n-not-done)
4311   "Switch entry to DONE when all subentries are done, to TODO otherwise."
4312   (let (org-log-done org-log-states)   ; turn off logging
4313     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
4315 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
4316 #+end_src
4318 Another possibility is the use of checkboxes to identify (a hierarchy
4319 of) a large number of subtasks (see [[*Checkboxes]]).
4321 ** Checkboxes
4322 :PROPERTIES:
4323 :DESCRIPTION: Tick-off lists.
4324 :END:
4325 #+cindex: checkboxes
4327 #+vindex: org-list-automatic-rules
4328 Every item in a plain list[fn:48] (see [[*Plain Lists]]) can be made into
4329 a checkbox by starting it with the string =[ ]=.  This feature is
4330 similar to TODO items (see [[*TODO Items]]), but is more lightweight.
4331 Checkboxes are not included into the global TODO list, so they are
4332 often great to split a task into a number of simple steps.  Or you can
4333 use them in a shopping list.
4335 Here is an example of a checkbox list.
4337 #+begin_example
4338 ,* TODO Organize party [2/4]
4339   - [-] call people [1/3]
4340     - [ ] Peter
4341     - [X] Sarah
4342     - [ ] Sam
4343   - [X] order food
4344   - [ ] think about what music to play
4345   - [X] talk to the neighbors
4346 #+end_example
4348 Checkboxes work hierarchically, so if a checkbox item has children
4349 that are checkboxes, toggling one of the children checkboxes makes the
4350 parent checkbox reflect if none, some, or all of the children are
4351 checked.
4353 #+cindex: statistics, for checkboxes
4354 #+cindex: checkbox statistics
4355 #+cindex: @samp{COOKIE_DATA}, property
4356 #+vindex: org-hierarchical-checkbox-statistics
4357 The =[2/4]= and =[1/3]= in the first and second line are cookies
4358 indicating how many checkboxes present in this entry have been checked
4359 off, and the total number of checkboxes present.  This can give you an
4360 idea on how many checkboxes remain, even without opening a folded
4361 entry.  The cookies can be placed into a headline or into (the first
4362 line of) a plain list item.  Each cookie covers checkboxes of direct
4363 children structurally below the headline/item on which the cookie
4364 appears[fn:49].  You have to insert the cookie yourself by typing
4365 either =[/]= or =[%]=.  With =[/]= you get an =n out of m= result, as
4366 in the examples above.  With =[%]= you get information about the
4367 percentage of checkboxes checked (in the above example, this would be
4368 =[50%]= and =[33%]=, respectively).  In a headline, a cookie can count
4369 either checkboxes below the heading or TODO states of children, and it
4370 displays whatever was changed last.  Set the property =COOKIE_DATA= to
4371 either =checkbox= or =todo= to resolve this issue.
4373 #+cindex: blocking, of checkboxes
4374 #+cindex: checkbox blocking
4375 #+cindex: @samp{ORDERED}, property
4376 If the current outline node has an =ORDERED= property, checkboxes must
4377 be checked off in sequence, and an error is thrown if you try to check
4378 off a box while there are unchecked boxes above it.
4380 The following commands work with checkboxes:
4382 - {{{kbd(C-c C-c)}}} (~org-toggle-checkbox~) ::
4384   #+kindex: C-c C-c
4385   #+findex: org-toggle-checkbox
4386   Toggle checkbox status or---with prefix argument---checkbox presence
4387   at point.  With a single prefix argument, add an empty checkbox or
4388   remove the current one[fn:50].  With a double prefix argument, set
4389   it to =[-]=, which is considered to be an intermediate state.
4391 - {{{kbd(C-c C-x C-b)}}} (~org-toggle-checkbox~) ::
4393   #+kindex: C-c C-x C-b
4394   Toggle checkbox status or---with prefix argument---checkbox presence
4395   at point.  With double prefix argument, set it to =[-]=, which is
4396   considered to be an intermediate state.
4398   - If there is an active region, toggle the first checkbox in the
4399     region and set all remaining boxes to the same status as the
4400     first.  With a prefix argument, add or remove the checkbox for all
4401     items in the region.
4403   - If point is in a headline, toggle checkboxes in the region between
4404     this headline and the next---so /not/ the entire subtree.
4406   - If there is no active region, just toggle the checkbox at point.
4408 - {{{kbd(M-S-RET)}}} (~org-insert-todo-heading~) ::
4410   #+kindex: M-S-RET
4411   #+findex: org-insert-todo-heading
4412   Insert a new item with a checkbox.  This works only if point is
4413   already in a plain list item (see [[*Plain Lists]]).
4415 - {{{kbd(C-c C-x o)}}} (~org-toggle-ordered-property~) ::
4417   #+kindex: C-c C-x o
4418   #+findex: org-toggle-ordered-property
4419   #+vindex: org-track-ordered-property-with-tag
4420   Toggle the =ORDERED= property of the entry, to toggle if checkboxes
4421   must be checked off in sequence.  A property is used for this
4422   behavior because this should be local to the current entry, not
4423   inherited like a tag.  However, if you would like to /track/ the
4424   value of this property with a tag for better visibility, customize
4425   ~org-track-ordered-property-with-tag~.
4427 - {{{kbd(C-c #)}}} (~org-update-statistics-cookies~) ::
4429   #+kindex: C-c #
4430   #+findex: org-update-statistics-cookies
4431   Update the statistics cookie in the current outline entry.  When
4432   called with a {{{kbd(C-u)}}} prefix, update the entire file.
4433   Checkbox statistic cookies are updated automatically if you toggle
4434   checkboxes with {{{kbd(C-c C-c)}}} and make new ones with
4435   {{{kbd(M-S-RET)}}}.  TODO statistics cookies update when changing
4436   TODO states.  If you delete boxes/entries or add/change them by
4437   hand, use this command to get things back into sync.
4439 * Tags
4440 :PROPERTIES:
4441 :DESCRIPTION: Tagging headlines and matching sets of tags.
4442 :END:
4443 #+cindex: tags
4444 #+cindex: headline tagging
4445 #+cindex: matching, tags
4446 #+cindex: sparse tree, tag based
4448 An excellent way to implement labels and contexts for
4449 cross-correlating information is to assign /tags/ to headlines.  Org
4450 mode has extensive support for tags.
4452 #+vindex: org-tag-faces
4453 Every headline can contain a list of tags; they occur at the end of
4454 the headline.  Tags are normal words containing letters, numbers, =_=,
4455 and =@=.  Tags must be preceded and followed by a single colon, e.g.,
4456 =:work:=.  Several tags can be specified, as in =:work:urgent:=.  Tags
4457 by default are in bold face with the same color as the headline.  You
4458 may specify special faces for specific tags using the variable
4459 ~org-tag-faces~, in much the same way as you can for TODO keywords
4460 (see [[*Faces for TODO keywords]]).
4462 ** Tag Inheritance
4463 :PROPERTIES:
4464 :DESCRIPTION: Tags use the tree structure of an outline.
4465 :END:
4466 #+cindex: tag inheritance
4467 #+cindex: inheritance, of tags
4468 #+cindex: sublevels, inclusion into tags match
4470 /Tags/ make use of the hierarchical structure of outline trees.  If
4471 a heading has a certain tag, all subheadings inherit the tag as well.
4472 For example, in the list
4474 #+begin_example
4475 ,* Meeting with the French group      :work:
4476 ,** Summary by Frank                  :boss:notes:
4477 ,*** TODO Prepare slides for him      :action:
4478 #+end_example
4480 #+texinfo: @noindent
4481 the final heading has the tags =work=, =boss=, =notes=, and =action=
4482 even though the final heading is not explicitly marked with those
4483 tags.  You can also set tags that all entries in a file should inherit
4484 just as if these tags were defined in a hypothetical level zero that
4485 surrounds the entire file.  Use a line like this[fn:51]
4487 #+cindex: @samp{FILETAGS}, keyword
4488 : #+FILETAGS: :Peter:Boss:Secret:
4490 #+vindex: org-use-tag-inheritance
4491 #+vindex: org-tags-exclude-from-inheritance
4492 To limit tag inheritance to specific tags, or to turn it off entirely,
4493 use the variables ~org-use-tag-inheritance~ and
4494 ~org-tags-exclude-from-inheritance~.
4496 #+vindex: org-tags-match-list-sublevels
4497 When a headline matches during a tags search while tag inheritance is
4498 turned on, all the sublevels in the same tree---for a simple match
4499 form---match as well[fn:52].  The list of matches may then become
4500 very long.  If you only want to see the first tags match in a subtree,
4501 configure the variable ~org-tags-match-list-sublevels~ (not
4502 recommended).
4504 #+vindex: org-agenda-use-tag-inheritance
4505 Tag inheritance is relevant when the agenda search tries to match
4506 a tag, either in the ~tags~ or ~tags-todo~ agenda types.  In other
4507 agenda types, ~org-use-tag-inheritance~ has no effect.  Still, you may
4508 want to have your tags correctly set in the agenda, so that tag
4509 filtering works fine, with inherited tags.  Set
4510 ~org-agenda-use-tag-inheritance~ to control this: the default value
4511 includes all agenda types, but setting this to ~nil~ can really speed
4512 up agenda generation.
4514 ** Setting Tags
4515 :PROPERTIES:
4516 :DESCRIPTION: How to assign tags to a headline.
4517 :END:
4518 #+cindex: setting tags
4519 #+cindex: tags, setting
4521 #+kindex: M-TAB
4522 Tags can simply be typed into the buffer at the end of a headline.
4523 After a colon, {{{kbd(M-TAB)}}} offers completion on tags.  There is
4524 also a special command for inserting tags:
4526 - {{{kbd(C-c C-q)}}} (~org-set-tags-command~) ::
4528   #+kindex: C-c C-q
4529   #+findex: org-set-tags-command
4530   #+cindex: completion, of tags
4531   #+vindex: org-tags-column
4532   Enter new tags for the current headline.  Org mode either offers
4533   completion or a special single-key interface for setting tags, see
4534   below.  After pressing {{{kbd(RET)}}}, the tags are inserted and
4535   aligned to ~org-tags-column~.  When called with a {{{kbd(C-u)}}}
4536   prefix, all tags in the current buffer are aligned to that column,
4537   just to make things look nice.  Tags are automatically realigned
4538   after promotion, demotion, and TODO state changes (see [[*Basic TODO
4539   Functionality]]).
4541 - {{{kbd(C-c C-c)}}} (~org-set-tags-command~) ::
4543   #+kindex: C-c C-c
4544   When point is in a headline, this does the same as {{{kbd(C-c
4545   C-q)}}}.
4547 #+vindex: org-complete-tags-always-offer-all-agenda-tags
4548 #+vindex: org-tag-alist
4549 #+cindex: @samp{TAGS}, keyword
4550 Org supports tag insertion based on a /list of tags/.  By default this
4551 list is constructed dynamically, containing all tags currently used in
4552 the buffer[fn:53].  You may also globally specify a hard list of tags
4553 with the variable ~org-tag-alist~.  Finally you can set the default
4554 tags for a given file using the =TAGS= keyword, like
4556 #+begin_example
4557 ,#+TAGS: @work @home @tennisclub
4558 ,#+TAGS: laptop car pc sailboat
4559 #+end_example
4561 If you have globally defined your preferred set of tags using the
4562 variable ~org-tag-alist~, but would like to use a dynamic tag list in
4563 a specific file, add an empty =TAGS= keyword to that file:
4565 : #+TAGS:
4567 #+vindex: org-tag-persistent-alist
4568 If you have a preferred set of tags that you would like to use in
4569 every file, in addition to those defined on a per-file basis by =TAGS=
4570 keyword, then you may specify a list of tags with the variable
4571 ~org-tag-persistent-alist~.  You may turn this off on a per-file basis
4572 by adding a =STARTUP= keyword to that file:
4574 : #+STARTUP: noptag
4576 By default Org mode uses the standard minibuffer completion facilities
4577 for entering tags.  However, it also implements another, quicker, tag
4578 selection method called /fast tag selection/.  This allows you to
4579 select and deselect tags with just a single key press.  For this to
4580 work well you should assign unique letters to most of your commonly
4581 used tags.  You can do this globally by configuring the variable
4582 ~org-tag-alist~ in your Emacs init file.  For example, you may find
4583 the need to tag many items in different files with =@home=.  In this
4584 case you can set something like:
4586 #+begin_src emacs-lisp
4587 (setq org-tag-alist '(("@work" . ?w) ("@home" . ?h) ("laptop" . ?l)))
4588 #+end_src
4590 If the tag is only relevant to the file you are working on, then you
4591 can instead set the =TAGS= keyword as:
4593 : #+TAGS: @work(w)  @home(h)  @tennisclub(t)  laptop(l)  pc(p)
4595 The tags interface shows the available tags in a splash window.  If
4596 you want to start a new line after a specific tag, insert =\n= into
4597 the tag list
4599 : #+TAGS: @work(w) @home(h) @tennisclub(t) \n laptop(l) pc(p)
4601 #+texinfo: @noindent
4602 or write them in two lines:
4604 #+begin_example
4605 ,#+TAGS: @work(w)  @home(h)  @tennisclub(t)
4606 ,#+TAGS: laptop(l)  pc(p)
4607 #+end_example
4609 You can also group together tags that are mutually exclusive by using
4610 braces, as in:
4612 : #+TAGS: { @work(w)  @home(h)  @tennisclub(t) }  laptop(l)  pc(p)
4614 #+texinfo: @noindent
4615 you indicate that at most one of =@work=, =@home=, and =@tennisclub=
4616 should be selected.  Multiple such groups are allowed.
4618 Do not forget to press {{{kbd(C-c C-c)}}} with point in one of these
4619 lines to activate any changes.
4621 To set these mutually exclusive groups in the variable
4622 ~org-tags-alist~, you must use the dummy tags ~:startgroup~ and
4623 ~:endgroup~ instead of the braces.  Similarly, you can use ~:newline~
4624 to indicate a line break.  The previous example would be set globally
4625 by the following configuration:
4627 #+begin_src emacs-lisp
4628 (setq org-tag-alist '((:startgroup . nil)
4629                       ("@work" . ?w) ("@home" . ?h)
4630                       ("@tennisclub" . ?t)
4631                       (:endgroup . nil)
4632                       ("laptop" . ?l) ("pc" . ?p)))
4633 #+end_src
4635 If at least one tag has a selection key then pressing {{{kbd(C-c
4636 C-c)}}} automatically presents you with a special interface, listing
4637 inherited tags, the tags of the current headline, and a list of all
4638 valid tags with corresponding keys[fn:54].
4640 Pressing keys assigned to tags adds or removes them from the list of
4641 tags in the current line.  Selecting a tag in a group of mutually
4642 exclusive tags turns off any other tag from that group.
4644 In this interface, you can also use the following special keys:
4646 - {{{kbd(TAB)}}} ::
4648   #+kindex: TAB
4649   Enter a tag in the minibuffer, even if the tag is not in the
4650   predefined list.  You can complete on all tags present in the
4651   buffer.  You can also add several tags: just separate them with
4652   a comma.
4654 - {{{kbd(SPC)}}} ::
4656   #+kindex: SPC
4657   Clear all tags for this line.
4659 - {{{kbd(RET)}}} ::
4661   #+kindex: RET
4662   Accept the modified set.
4664 - {{{kbd(C-g)}}} ::
4666   #+kindex: C-g
4667   Abort without installing changes.
4669 - {{{kbd(q)}}} ::
4671   #+kindex: q
4672   If {{{kbd(q)}}} is not assigned to a tag, it aborts like
4673   {{{kbd(C-g)}}}.
4675 - {{{kbd(!)}}} ::
4677   #+kindex: !
4678   Turn off groups of mutually exclusive tags.  Use this to (as an
4679   exception) assign several tags from such a group.
4681 - {{{kbd(C-c)}}} ::
4683   #+kindex: C-c C-c
4684   Toggle auto-exit after the next change (see below).  If you are
4685   using expert mode, the first {{{kbd(C-c)}}} displays the selection
4686   window.
4688 This method lets you assign tags to a headline with very few keys.
4689 With the above setup, you could clear the current tags and set
4690 =@home=, =laptop= and =pc= tags with just the following keys:
4691 {{{kbd(C-c C-c SPC h l p RET)}}}.  Switching from =@home= to =@work=
4692 would be done with {{{kbd(C-c C-c w RET)}}} or alternatively with
4693 {{{kbd(C-c C-c C-c w)}}}.  Adding the non-predefined tag =sarah= could
4694 be done with {{{kbd(C-c C-c TAB s a r a h RET)}}}.
4696 #+vindex: org-fast-tag-selection-single-key
4697 If you find that most of the time you need only a single key press to
4698 modify your list of tags, set the variable
4699 ~org-fast-tag-selection-single-key~.  Then you no longer have to press
4700 {{{kbd(RET)}}} to exit fast tag selection---it exits after the first
4701 change.  If you then occasionally need more keys, press {{{kbd(C-c)}}}
4702 to turn off auto-exit for the current tag selection process (in
4703 effect: start selection with {{{kbd(C-c C-c C-c)}}} instead of
4704 {{{kbd(C-c C-c)}}}).  If you set the variable to the value ~expert~,
4705 the special window is not even shown for single-key tag selection, it
4706 comes up only when you press an extra {{{kbd(C-c)}}}.
4708 ** Tag Hierarchy
4709 :PROPERTIES:
4710 :DESCRIPTION: Create a hierarchy of tags.
4711 :END:
4712 #+cindex: group tags
4713 #+cindex: tags, groups
4714 #+cindex: tags hierarchy
4716 Tags can be defined in hierarchies.  A tag can be defined as a /group
4717 tag/ for a set of other tags.  The group tag can be seen as the
4718 "broader term" for its set of tags.  Defining multiple group tags and
4719 nesting them creates a tag hierarchy.
4721 One use-case is to create a taxonomy of terms (tags) that can be used
4722 to classify nodes in a document or set of documents.
4724 When you search for a group tag, it return matches for all members in
4725 the group and its subgroups.  In an agenda view, filtering by a group
4726 tag displays or hide headlines tagged with at least one of the members
4727 of the group or any of its subgroups.  This makes tag searches and
4728 filters even more flexible.
4730 You can set group tags by using brackets and inserting a colon between
4731 the group tag and its related tags---beware that all whitespaces are
4732 mandatory so that Org can parse this line correctly:
4734 : #+TAGS: [ GTD : Control Persp ]
4736 In this example, =GTD= is the group tag and it is related to two other
4737 tags: =Control=, =Persp=.  Defining =Control= and =Persp= as group
4738 tags creates a hierarchy of tags:
4740 #+begin_example
4741 ,#+TAGS: [ Control : Context Task ]
4742 ,#+TAGS: [ Persp : Vision Goal AOF Project ]
4743 #+end_example
4745 That can conceptually be seen as a hierarchy of tags:
4747 - =GTD=
4748   - =Persp=
4749     - =Vision=
4750     - =Goal=
4751     - =AOF=
4752     - =Project=
4753   - =Control=
4754     - =Context=
4755     - =Task=
4757 You can use the ~:startgrouptag~, ~:grouptags~ and ~:endgrouptag~
4758 keyword directly when setting ~org-tag-alist~ directly:
4760 #+begin_src emacs-lisp
4761 (setq org-tag-alist '((:startgrouptag)
4762                       ("GTD")
4763                       (:grouptags)
4764                       ("Control")
4765                       ("Persp")
4766                       (:endgrouptag)
4767                       (:startgrouptag)
4768                       ("Control")
4769                       (:grouptags)
4770                       ("Context")
4771                       ("Task")
4772                       (:endgrouptag)))
4773 #+end_src
4775 The tags in a group can be mutually exclusive if using the same group
4776 syntax as is used for grouping mutually exclusive tags together; using
4777 curly brackets.
4779 : #+TAGS: { Context : @Home @Work @Call }
4781 When setting ~org-tag-alist~ you can use ~:startgroup~ and ~:endgroup~
4782 instead of ~:startgrouptag~ and ~:endgrouptag~ to make the tags
4783 mutually exclusive.
4785 Furthermore, the members of a group tag can also be regular
4786 expressions, creating the possibility of a more dynamic and rule-based
4787 tag structure.  The regular expressions in the group must be specified
4788 within curly brackets.  Here is an expanded example:
4790 #+begin_example
4791 ,#+TAGS: [ Vision : {V@.+} ]
4792 ,#+TAGS: [ Goal : {G@.+} ]
4793 ,#+TAGS: [ AOF : {AOF@.+} ]
4794 ,#+TAGS: [ Project : {P@.+} ]
4795 #+end_example
4797 Searching for the tag =Project= now lists all tags also including
4798 regular expression matches for =P@.+=, and similarly for tag searches
4799 on =Vision=, =Goal= and =AOF=.  For example, this would work well for
4800 a project tagged with a common project-identifier, e.g.,
4801 =P@2014_OrgTags=.
4803 #+kindex: C-c C-x q
4804 #+findex: org-toggle-tags-groups
4805 #+vindex: org-group-tags
4806 If you want to ignore group tags temporarily, toggle group tags
4807 support with ~org-toggle-tags-groups~, bound to {{{kbd(C-c C-x q)}}}.
4808 If you want to disable tag groups completely, set ~org-group-tags~ to
4809 ~nil~.
4811 ** Tag Searches
4812 :PROPERTIES:
4813 :DESCRIPTION: Searching for combinations of tags.
4814 :END:
4815 #+cindex: tag searches
4816 #+cindex: searching for tags
4818 Once a system of tags has been set up, it can be used to collect
4819 related information into special lists.
4821 - {{{kbd(C-c / m)}}} or {{{kbd(C-c \)}}} (~org-match-sparse-tree~) ::
4823   #+kindex: C-c / m
4824   #+kindex: C-c \
4825   #+findex: org-match-sparse-tree
4826   Create a sparse tree with all headlines matching a tags search.
4827   With a {{{kbd(C-u)}}} prefix argument, ignore headlines that are not
4828   a TODO line.
4830 - {{{kbd(M-x org-agenda m)}}} (~org-tags-view~) ::
4832   #+kindex: m @r{(Agenda dispatcher)}
4833   #+findex: org-tags-view
4834   Create a global list of tag matches from all agenda files.  See
4835   [[*Matching tags and properties]].
4837 - {{{kbd(M-x org-agenda M)}}} (~org-tags-view~) ::
4839   #+kindex: M @r{(Agenda dispatcher)}
4840   #+vindex: org-tags-match-list-sublevels
4841   Create a global list of tag matches from all agenda files, but check
4842   only TODO items and force checking subitems (see the option
4843   ~org-tags-match-list-sublevels~).
4845 These commands all prompt for a match string which allows basic
4846 Boolean logic like =+boss+urgent-project1=, to find entries with tags
4847 =boss= and =urgent=, but not =project1=, or =Kathy|Sally= to find
4848 entries which are tagged, like =Kathy= or =Sally=.  The full syntax of
4849 the search string is rich and allows also matching against TODO
4850 keywords, entry levels and properties.  For a complete description
4851 with many examples, see [[*Matching tags and properties]].
4853 * Properties and Columns
4854 :PROPERTIES:
4855 :DESCRIPTION: Storing information about an entry.
4856 :END:
4857 #+cindex: properties
4859 A property is a key-value pair associated with an entry.  Properties
4860 can be set so they are associated with a single entry, with every
4861 entry in a tree, or with every entry in an Org file.
4863 There are two main applications for properties in Org mode.  First,
4864 properties are like tags, but with a value.  Imagine maintaining
4865 a file where you document bugs and plan releases for a piece of
4866 software.  Instead of using tags like =release_1=, =release_2=, you
4867 can use a property, say =Release=, that in different subtrees has
4868 different values, such as =1.0= or =2.0=.  Second, you can use
4869 properties to implement (very basic) database capabilities in an Org
4870 buffer.  Imagine keeping track of your music CDs, where properties
4871 could be things such as the album, artist, date of release, number of
4872 tracks, and so on.
4874 Properties can be conveniently edited and viewed in column view (see
4875 [[*Column View]]).
4877 ** Property Syntax
4878 :PROPERTIES:
4879 :DESCRIPTION: How properties are spelled out.
4880 :END:
4881 #+cindex: property syntax
4882 #+cindex: drawer, for properties
4884 Properties are key--value pairs.  When they are associated with
4885 a single entry or with a tree they need to be inserted into a special
4886 drawer (see [[*Drawers]]) with the name =PROPERTIES=, which has to be
4887 located right below a headline, and its planning line (see [[*Deadlines
4888 and Scheduling]]) when applicable.  Each property is specified on
4889 a single line, with the key---surrounded by colons---first, and the
4890 value after it.  Keys are case-insensitive.  Here is an example:
4892 #+begin_example
4893 ,* CD collection
4894 ,** Classic
4895 ,*** Goldberg Variations
4896     :PROPERTIES:
4897     :Title:     Goldberg Variations
4898     :Composer:  J.S. Bach
4899     :Artist:    Glenn Gould
4900     :Publisher: Deutsche Grammophon
4901     :NDisks:    1
4902     :END:
4903 #+end_example
4905 Depending on the value of ~org-use-property-inheritance~, a property
4906 set this way is associated either with a single entry, or with the
4907 sub-tree defined by the entry, see [[*Property Inheritance]].
4909 You may define the allowed values for a particular property =Xyz= by
4910 setting a property =Xyz_ALL=.  This special property is /inherited/,
4911 so if you set it in a level 1 entry, it applies to the entire tree.
4912 When allowed values are defined, setting the corresponding property
4913 becomes easier and is less prone to typing errors.  For the example
4914 with the CD collection, we can pre-define publishers and the number of
4915 disks in a box like this:
4917 #+begin_example
4918 ,* CD collection
4919   :PROPERTIES:
4920   :NDisks_ALL:  1 2 3 4
4921   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
4922   :END:
4923 #+end_example
4925 If you want to set properties that can be inherited by any entry in
4926 a file, use a line like:
4928 #+cindex: @samp{_ALL} suffix, in properties
4929 #+cindex: @samp{PROPERTY}, keyword
4930 : #+PROPERTY: NDisks_ALL 1 2 3 4
4932 #+cindex: @samp{+} suffix, in properties
4933 If you want to add to the value of an existing property, append a =+=
4934 to the property name.  The following results in the property =var=
4935 having the value =foo=1 bar=2=.
4937 #+begin_example
4938 ,#+PROPERTY: var  foo=1
4939 ,#+PROPERTY: var+ bar=2
4940 #+end_example
4942 It is also possible to add to the values of inherited properties.  The
4943 following results in the =Genres= property having the value =Classic
4944 Baroque= under the =Goldberg Variations= subtree.
4946 #+begin_example
4947 ,* CD collection
4948 ,** Classic
4949     :PROPERTIES:
4950     :Genres: Classic
4951     :END:
4952 ,*** Goldberg Variations
4953     :PROPERTIES:
4954     :Title:     Goldberg Variations
4955     :Composer:  J.S. Bach
4956     :Artist:    Glenn Gould
4957     :Publisher: Deutsche Grammophon
4958     :NDisks:    1
4959     :Genres+:   Baroque
4960     :END:
4961 #+end_example
4963 Note that a property can only have one entry per drawer.
4965 #+vindex: org-global-properties
4966 Property values set with the global variable ~org-global-properties~
4967 can be inherited by all entries in all Org files.
4969 The following commands help to work with properties:
4971 #+attr_texinfo: :sep ,
4972 - {{{kbd(M-TAB)}}} (~pcomplete~) ::
4974   #+kindex: M-TAB
4975   #+findex: pcomplete
4976   After an initial colon in a line, complete property keys.  All keys
4977   used in the current file are offered as possible completions.
4979 - {{{kbd(C-c C-x p)}}} (~org-set-property~) ::
4981   #+kindex: C-c C-x p
4982   #+findex: org-set-property
4983   Set a property.  This prompts for a property name and a value.  If
4984   necessary, the property drawer is created as well.
4986 - {{{kbd(C-u M-x org-insert-drawer)}}} ::
4988   #+findex: org-insert-drawer
4989   Insert a property drawer into the current entry.  The drawer is
4990   inserted early in the entry, but after the lines with planning
4991   information like deadlines.
4993 - {{{kbd(C-c C-c)}}} (~org-property-action~) ::
4995   #+kindex: C-c C-c
4996   #+findex: org-property-action
4997   With point in a property drawer, this executes property commands.
4999 - {{{kbd(C-c C-c s)}}} (~org-set-property~) ::
5001   #+kindex: C-c C-c s
5002   #+findex: org-set-property
5003   Set a property in the current entry.  Both the property and the
5004   value can be inserted using completion.
5006 - {{{kbd(S-RIGHT)}}} (~org-property-next-allowed-values~),  {{{kbd(S-LEFT)}}} (~org-property-previous-allowed-value~) ::
5008   #+kindex: S-RIGHT
5009   #+kindex: S-LEFT
5010   Switch property at point to the next/previous allowed value.
5012 - {{{kbd(C-c C-c d)}}} (~org-delete-property~) ::
5014   #+kindex: C-c C-c d
5015   #+findex: org-delete-property
5016   Remove a property from the current entry.
5018 - {{{kbd(C-c C-c D)}}} (~org-delete-property-globally~) ::
5020   #+kindex: C-c C-c D
5021   #+findex: org-delete-property-globally
5022   Globally remove a property, from all entries in the current file.
5024 - {{{kbd(C-c C-c c)}}} (~org-compute-property-at-point~) ::
5026   #+kindex: C-c C-c c
5027   #+findex: org-compute-property-at-point
5028   Compute the property at point, using the operator and scope from the
5029   nearest column format definition.
5031 ** Special Properties
5032 :PROPERTIES:
5033 :DESCRIPTION: Access to other Org mode features.
5034 :END:
5035 #+cindex: properties, special
5037 Special properties provide an alternative access method to Org mode
5038 features, like the TODO state or the priority of an entry, discussed
5039 in the previous chapters.  This interface exists so that you can
5040 include these states in a column view (see [[*Column View]]), or to use
5041 them in queries.  The following property names are special and should
5042 not be used as keys in the properties drawer:
5044 #+cindex: @samp{ALLTAGS}, special property
5045 #+cindex: @samp{BLOCKED}, special property
5046 #+cindex: @samp{CLOCKSUM}, special property
5047 #+cindex: @samp{CLOCKSUM_T}, special property
5048 #+cindex: @samp{CLOSED}, special property
5049 #+cindex: @samp{DEADLINE}, special property
5050 #+cindex: @samp{FILE}, special property
5051 #+cindex: @samp{ITEM}, special property
5052 #+cindex: @samp{PRIORITY}, special property
5053 #+cindex: @samp{SCHEDULED}, special property
5054 #+cindex: @samp{TAGS}, special property
5055 #+cindex: @samp{TIMESTAMP}, special property
5056 #+cindex: @samp{TIMESTAMP_IA}, special property
5057 #+cindex: @samp{TODO}, special property
5058 | =ALLTAGS=      | All tags, including inherited ones.                            |
5059 | =BLOCKED=      | ~t~ if task is currently blocked by children or siblings.      |
5060 | =CATEGORY=     | The category of an entry.                                      |
5061 | =CLOCKSUM=     | The sum of CLOCK intervals in the subtree.  ~org-clock-sum~    |
5062 |                | must be run first to compute the values in the current buffer. |
5063 | =CLOCKSUM_T=   | The sum of CLOCK intervals in the subtree for today.           |
5064 |                | ~org-clock-sum-today~ must be run first to compute the         |
5065 |                | values in the current buffer.                                  |
5066 | =CLOSED=       | When was this entry closed?                                    |
5067 | =DEADLINE=     | The deadline time string, without the angular brackets.        |
5068 | =FILE=         | The filename the entry is located in.                          |
5069 | =ITEM=         | The headline of the entry.                                     |
5070 | =PRIORITY=     | The priority of the entry, a string with a single letter.      |
5071 | =SCHEDULED=    | The scheduling timestamp, without the angular brackets.        |
5072 | =TAGS=         | The tags defined directly in the headline.                     |
5073 | =TIMESTAMP=    | The first keyword-less timestamp in the entry.                 |
5074 | =TIMESTAMP_IA= | The first inactive timestamp in the entry.                     |
5075 | =TODO=         | The TODO keyword of the entry.                                 |
5077 ** Property Searches
5078 :PROPERTIES:
5079 :DESCRIPTION: Matching property values.
5080 :END:
5081 #+cindex: properties, searching
5082 #+cindex: searching, of properties
5084 To create sparse trees and special lists with selection based on
5085 properties, the same commands are used as for tag searches (see [[*Tag
5086 Searches]]).
5088 - {{{kbd(C-c / m)}}} or {{{kbd(C-c \)}}} (~org-match-sparse-tree~) ::
5090   #+kindex: C-c / m
5091   #+kindex: C-c \
5092   #+findex: org-match-sparse-tree
5093   Create a sparse tree with all matching entries.  With
5094   a {{{kbd(C-u)}}} prefix argument, ignore headlines that are not
5095   a TODO line.
5097 - {{{kbd(M-x org-agenda m)}}}, ~org-tags-view~ ::
5099   #+kindex: m @r{(Agenda dispatcher)}
5100   #+findex: org-tags-view
5101   Create a global list of tag/property matches from all agenda files.
5103 - {{{kbd(M-x org-agenda M)}}} (~org-tags-view~) ::
5105   #+kindex: M @r{(Agenda dispatcher)}
5106   #+vindex: org-tags-match-list-sublevels
5107   Create a global list of tag matches from all agenda files, but check
5108   only TODO items and force checking of subitems (see the option
5109   ~org-tags-match-list-sublevels~).
5111 The syntax for the search string is described in [[*Matching tags and
5112 properties]].
5114 There is also a special command for creating sparse trees based on a
5115 single property:
5117 - {{{kbd(C-c / p)}}} ::
5119   #+kindex: C-c / p
5120   Create a sparse tree based on the value of a property.  This first
5121   prompts for the name of a property, and then for a value.  A sparse
5122   tree is created with all entries that define this property with the
5123   given value.  If you enclose the value in curly braces, it is
5124   interpreted as a regular expression and matched against the property
5125   values.
5127 ** Property Inheritance
5128 :PROPERTIES:
5129 :DESCRIPTION: Passing values down a tree.
5130 :END:
5131 #+cindex: properties, inheritance
5132 #+cindex: inheritance, of properties
5134 #+vindex: org-use-property-inheritance
5135 The outline structure of Org documents lends itself to an inheritance
5136 model of properties: if the parent in a tree has a certain property,
5137 the children can inherit this property.  Org mode does not turn this
5138 on by default, because it can slow down property searches
5139 significantly and is often not needed.  However, if you find
5140 inheritance useful, you can turn it on by setting the variable
5141 ~org-use-property-inheritance~.  It may be set to ~t~ to make all
5142 properties inherited from the parent, to a list of properties that
5143 should be inherited, or to a regular expression that matches inherited
5144 properties.  If a property has the value ~nil~, this is interpreted as
5145 an explicit un-define of the property, so that inheritance search
5146 stops at this value and returns ~nil~.
5148 Org mode has a few properties for which inheritance is hard-coded, at
5149 least for the special applications for which they are used:
5151 - ~COLUMNS~ ::
5153   #+cindex: @samp{COLUMNS}, property
5154   The =COLUMNS= property defines the format of column view (see
5155   [[*Column View]]).  It is inherited in the sense that the level where
5156   a =COLUMNS= property is defined is used as the starting point for
5157   a column view table, independently of the location in the subtree
5158   from where columns view is turned on.
5160 - ~CATEGORY~ ::
5162   #+cindex: @samp{CATEGORY}, property
5163   For agenda view, a category set through a =CATEGORY= property
5164   applies to the entire subtree.
5166 - ~ARCHIVE~ ::
5168   #+cindex: @samp{ARCHIVE}, property
5169   For archiving, the =ARCHIVE= property may define the archive
5170   location for the entire subtree (see [[*Moving a tree to an archive
5171   file]]).
5173 - ~LOGGING~ ::
5175   #+cindex: @samp{LOGGING}, property
5176   The =LOGGING= property may define logging settings for an entry or
5177   a subtree (see [[*Tracking TODO state changes]]).
5179 ** Column View
5180 :PROPERTIES:
5181 :DESCRIPTION: Tabular viewing and editing.
5182 :END:
5184 A great way to view and edit properties in an outline tree is /column
5185 view/.  In column view, each outline node is turned into a table row.
5186 Columns in this table provide access to properties of the entries.
5187 Org mode implements columns by overlaying a tabular structure over the
5188 headline of each item.  While the headlines have been turned into
5189 a table row, you can still change the visibility of the outline tree.
5190 For example, you get a compact table by switching to "contents"
5191 view---{{{kbd(S-TAB)}}} {{{kbd(S-TAB)}}}, or simply {{{kbd(c)}}}
5192 while column view is active---but you can still open, read, and edit
5193 the entry below each headline.  Or, you can switch to column view
5194 after executing a sparse tree command and in this way get a table only
5195 for the selected items.  Column view also works in agenda buffers (see
5196 [[*Agenda Views]]) where queries have collected selected items, possibly
5197 from a number of files.
5199 *** Defining columns
5200 :PROPERTIES:
5201 :DESCRIPTION: The COLUMNS format property.
5202 :END:
5203 #+cindex: column view, for properties
5204 #+cindex: properties, column view
5206 Setting up a column view first requires defining the columns.  This is
5207 done by defining a column format line.
5209 **** Scope of column definitions
5210 :PROPERTIES:
5211 :DESCRIPTION: Where defined, where valid?
5212 :END:
5214 To define a column format for an entire file, use a line like:
5216 #+cindex: @samp{COLUMNS}, keyword
5217 : #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5219 To specify a format that only applies to a specific tree, add
5220 a =COLUMNS= property to the top node of that tree, for example:
5222 #+begin_example
5223 ,** Top node for columns view
5224    :PROPERTIES:
5225    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5226    :END:
5227 #+end_example
5229 If a =COLUMNS= property is present in an entry, it defines columns for
5230 the entry itself, and for the entire subtree below it.  Since the
5231 column definition is part of the hierarchical structure of the
5232 document, you can define columns on level 1 that are general enough
5233 for all sublevels, and more specific columns further down, when you
5234 edit a deeper part of the tree.
5236 **** Column attributes
5237 :PROPERTIES:
5238 :DESCRIPTION: Appearance and content of a column.
5239 :END:
5241 A column definition sets the attributes of a column.  The general
5242 definition looks like this:
5244 : %[WIDTH]PROPERTY[(TITLE)][{SUMMARY-TYPE}]
5246 #+texinfo: @noindent
5247 Except for the percent sign and the property name, all items are
5248 optional.  The individual parts have the following meaning:
5250 - {{{var(WIDTH)}}} ::
5252   An integer specifying the width of the column in characters.  If
5253   omitted, the width is determined automatically.
5255 - {{{var(PROPERTY)}}} ::
5257   The property that should be edited in this column.  Special
5258   properties representing meta data are allowed here as well (see
5259   [[*Special Properties]]).
5261 - {{{var(TITLE)}}} ::
5263   The header text for the column.  If omitted, the property name is
5264   used.
5266 - {{{var(SUMMARY-TYPE)}}} ::
5268   The summary type.  If specified, the column values for parent nodes
5269   are computed from the children[fn:55].
5271   Supported summary types are:
5273   | =+=      | Sum numbers in this column.                           |
5274   | =+;%.1f= | Like =+=, but format result with =%.1f=.              |
5275   | =$=      | Currency, short for =+;%.2f=.                         |
5276   | =min=    | Smallest number in column.                            |
5277   | =max=    | Largest number.                                       |
5278   | =mean=   | Arithmetic mean of numbers.                           |
5279   | =X=      | Checkbox status, =[X]= if all children are =[X]=.     |
5280   | =X/=     | Checkbox status, =[n/m]=.                             |
5281   | =X%=     | Checkbox status, =[n%]=.                              |
5282   | =:=      | Sum times, HH:MM, plain numbers are minutes.          |
5283   | =:min=   | Smallest time value in column.                        |
5284   | =:max=   | Largest time value.                                   |
5285   | =:mean=  | Arithmetic mean of time values.                       |
5286   | =@min=   | Minimum age[fn:56] (in days/hours/mins/seconds).      |
5287   | =@max=   | Maximum age (in days/hours/mins/seconds).             |
5288   | =@mean=  | Arithmetic mean of ages (in days/hours/mins/seconds). |
5289   | =est+=   | Add low-high estimates.                               |
5291   #+vindex: org-columns-summary-types
5292   You can also define custom summary types by setting
5293   ~org-columns-summary-types~.
5295 The =est+= summary type requires further explanation.  It is used for
5296 combining estimates, expressed as low-high ranges.  For example,
5297 instead of estimating a particular task will take 5 days, you might
5298 estimate it as 5--6 days if you're fairly confident you know how much
5299 work is required, or 1--10 days if you do not really know what needs
5300 to be done.  Both ranges average at 5.5 days, but the first represents
5301 a more predictable delivery.
5303 When combining a set of such estimates, simply adding the lows and
5304 highs produces an unrealistically wide result.  Instead, =est+= adds
5305 the statistical mean and variance of the subtasks, generating a final
5306 estimate from the sum.  For example, suppose you had ten tasks, each
5307 of which was estimated at 0.5 to 2 days of work.  Straight addition
5308 produces an estimate of 5 to 20 days, representing what to expect if
5309 everything goes either extremely well or extremely poorly.  In
5310 contrast, =est+= estimates the full job more realistically, at 10--15
5311 days.
5313 Here is an example for a complete columns definition, along with
5314 allowed values[fn:57].
5316 #+begin_example
5317 :COLUMNS:  %25ITEM %9Approved(Approved?){X} %Owner %11Status \
5318                    %10Time_Estimate{:} %CLOCKSUM %CLOCKSUM_T
5319 :Owner_ALL:    Tammy Mark Karl Lisa Don
5320 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
5321 :Approved_ALL: "[ ]" "[X]"
5322 #+end_example
5324 #+texinfo: @noindent
5325 The first column, =%25ITEM=, means the first 25 characters of the item
5326 itself, i.e., of the headline.  You probably always should start the
5327 column definition with the =ITEM= specifier.  The other specifiers
5328 create columns =Owner= with a list of names as allowed values, for
5329 =Status= with four different possible values, and for a checkbox field
5330 =Approved=.  When no width is given after the =%= character, the
5331 column is exactly as wide as it needs to be in order to fully display
5332 all values.  The =Approved= column does have a modified title
5333 (=Approved?=, with a question mark).  Summaries are created for the
5334 =Time_Estimate= column by adding time duration expressions like HH:MM,
5335 and for the =Approved= column, by providing an =[X]= status if all
5336 children have been checked.  The =CLOCKSUM= and =CLOCKSUM_T= columns
5337 are special, they lists the sums of CLOCK intervals in the subtree,
5338 either for all clocks or just for today.
5340 *** Using column view
5341 :PROPERTIES:
5342 :DESCRIPTION: How to create and use column view.
5343 :END:
5345 **** Turning column view on or off
5346 :PROPERTIES:
5347 :UNNUMBERED: notoc
5348 :END:
5350 - {{{kbd(C-c C-x C-c)}}} (~org-columns~) ::
5352   #+kindex: C-c C-x C-c
5353   #+vindex: org-columns
5354   #+vindex: org-columns-default-format
5355   Turn on column view.  If point is before the first headline in the
5356   file, column view is turned on for the entire file, using the
5357   =#+COLUMNS= definition.  If point is somewhere inside the outline,
5358   this command searches the hierarchy, up from point, for a =COLUMNS=
5359   property that defines a format.  When one is found, the column view
5360   table is established for the tree starting at the entry that
5361   contains the =COLUMNS= property.  If no such property is found, the
5362   format is taken from the =#+COLUMNS= line or from the variable
5363   ~org-columns-default-format~, and column view is established for the
5364   current entry and its subtree.
5366 - {{{kbd(r)}}} or {{{kbd(g)}}} (~org-columns-redo~) ::
5368   #+kindex: r
5369   #+kindex: g
5370   #+findex: org-columns-redo
5371   Recreate the column view, to include recent changes made in the
5372   buffer.
5374 - {{{kbd(q)}}} (~org-columns-quit~) ::
5376   #+kindex: q
5377   #+findex: org-columns-quit
5378   Exit column view.
5380 **** Editing values
5381 :PROPERTIES:
5382 :UNNUMBERED: notoc
5383 :END:
5385 #+attr_texinfo: :sep and
5386 - {{{kbd(LEFT)}}}, {{{kbd(RIGHT)}}}, {{{kbd(UP)}}}, {{{kbd(DOWN)}}} ::
5388   Move through the column view from field to field.
5390 - {{{kbd(1..9\,0)}}} ::
5392   #+kindex: 1..9,0
5393   Directly select the Nth allowed value, {{{kbd(0)}}} selects the
5394   10th value.
5396 - {{{kbd(n)}}} or {{{kbd(S-RIGHT)}}} (~org-columns-next-allowed-value~) and {{{kbd(p)}}} or {{{kbd(S-LEFT)}}} (~org-columns-previous-allowed-value~) ::
5398   #+kindex: n
5399   #+kindex: S-RIGHT
5400   #+kindex: p
5401   #+kindex: S-LEFT
5402   #+findex: org-columns-next-allowed-value
5403   #+findex: org-columns-previous-allowed-value
5404   Switch to the next/previous allowed value of the field.  For this,
5405   you have to have specified allowed values for a property.
5407 - {{{kbd(e)}}} (~org-columns-edit-value~) ::
5409   #+kindex: e
5410   #+findex: org-columns-edit-value
5411   Edit the property at point.  For the special properties, this
5412   invokes the same interface that you normally use to change that
5413   property.  For example, the tag completion or fast selection
5414   interface pops up when editing a =TAGS= property.
5416 - {{{kbd(C-c C-c)}}} (~org-columns-set-tags-or-toggle~) ::
5418   #+kindex: C-c C-c
5419   #+findex: org-columns-set-tags-or-toggle
5420   When there is a checkbox at point, toggle it.
5422 - {{{kbd(v)}}} (~org-columns-show-value~) ::
5424   #+kindex: v
5425   #+findex: org-columns-show-value
5426   View the full value of this property.  This is useful if the width
5427   of the column is smaller than that of the value.
5429 - {{{kbd(a)}}} (~org-columns-edit-allowed~) ::
5431   #+kindex: a
5432   #+findex: org-columns-edit-allowed
5433   Edit the list of allowed values for this property.  If the list is
5434   found in the hierarchy, the modified values is stored there.  If no
5435   list is found, the new value is stored in the first entry that is
5436   part of the current column view.
5438 **** Modifying column view on-the-fly
5439 :PROPERTIES:
5440 :UNNUMBERED: notoc
5441 :END:
5443 #+attr_texinfo: :sep and
5444 - {{{kbd(<)}}} (~org-columns-narrow~) and {{{kbd(>)}}} (~org-columns-widen~) ::
5446   #+kindex: <
5447   #+kindex: >
5448   #+findex: org-columns-narrow
5449   #+findex: org-columns-widen
5450   Make the column narrower/wider by one character.
5452 - {{{kbd(S-M-RIGHT)}}} (~org-columns-new~) ::
5454   #+kindex: S-M-RIGHT
5455   #+findex: org-columns-new
5456   Insert a new column, to the left of the current column.
5458 - {{{kbd(S-M-LEFT)}}} (~org-columns-delete~) ::
5460   #+kindex: S-M-LEFT
5461   #+findex: org-columns-delete
5462   Delete the current column.
5464 *** Capturing column view
5465 :PROPERTIES:
5466 :DESCRIPTION: A dynamic block for column view.
5467 :END:
5469 Since column view is just an overlay over a buffer, it cannot be
5470 exported or printed directly.  If you want to capture a column view,
5471 use a =columnview= dynamic block (see [[*Dynamic Blocks]]).  The frame of
5472 this block looks like this:
5474 #+cindex: @samp{BEGIN columnview}
5475 #+begin_example
5476 ,* The column view
5477 ,#+BEGIN: columnview :hlines 1 :id "label"
5479 ,#+END:
5480 #+end_example
5482 This dynamic block has the following parameters:
5484 - =:id= ::
5486   This is the most important parameter.  Column view is a feature that
5487   is often localized to a certain (sub)tree, and the capture block
5488   might be at a different location in the file.  To identify the tree
5489   whose view to capture, you can use four values:
5491   - =local= ::
5493     Use the tree in which the capture block is located.
5495   - =global= ::
5497     Make a global view, including all headings in the file.
5499   - =file:FILENAME= ::
5501     Run column view at the top of the {{{var(FILENAME)}}} file.
5503   - =LABEL= ::
5505     #+cindex: @samp{ID}, property
5506     Call column view in the tree that has an =ID= property with the
5507     value {{{var(LABEL)}}}.  You can use {{{kbd(M-x org-id-copy)}}} to
5508     create a globally unique ID for the current entry and copy it to
5509     the kill-ring.
5511 - =:hlines= ::
5513   When ~t~, insert an hline after every line.  When a number N, insert
5514   an hline before each headline with level ~<= N~.
5516 - =:vlines= ::
5518   When non-~nil~, force column groups to get vertical lines.
5520 - =:maxlevel= ::
5522   When set to a number, do not capture entries below this level.
5524 - =:skip-empty-rows= ::
5526   When non-~nil~, skip rows where the only non-empty specifier of
5527   the column view is =ITEM=.
5529 - =:exclude-tags= ::
5531   List of tags to exclude from column view table: entries with these
5532   tags will be excluded from the column view.
5534 - =:indent= ::
5536   When non-~nil~, indent each =ITEM= field according to its level.
5538 - =:format= ::
5540   Specify a column attribute (see [[*Column attributes]]) for the dynamic
5541   block.
5543 The following commands insert or update the dynamic block:
5545 - {{{kbd(C-c C-x i)}}} (~org-insert-columns-dblock~) ::
5547   #+kindex: C-c C-x i
5548   #+findex: org-insert-columns-dblock
5549   Insert a dynamic block capturing a column view.  Prompt for the
5550   scope or ID of the view.
5552 - {{{kbd(C-c C-c)}}} {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
5554   #+kindex: C-c C-c
5555   #+kindex: C-c C-x C-u
5556   #+findex: org-dblock-update
5557   Update dynamic block at point.  point needs to be in the =#+BEGIN=
5558   line of the dynamic block.
5560 - {{{kbd(C-u C-c C-x C-u)}}} (~org-update-all-dblocks~) ::
5562   #+kindex: C-u C-c C-x C-u
5563   Update all dynamic blocks (see [[*Dynamic Blocks]]).  This is useful if
5564   you have several clock table blocks, column-capturing blocks or
5565   other dynamic blocks in a buffer.
5567 You can add formulas to the column view table and you may add plotting
5568 instructions in front of the table---these survive an update of the
5569 block.  If there is a =TBLFM= keyword after the table, the table is
5570 recalculated automatically after an update.
5572 An alternative way to capture and process property values into a table
5573 is provided by Eric Schulte's =org-collector.el=, which is
5574 a contributed package[fn:58].  It provides a general API to collect
5575 properties from entries in a certain scope, and arbitrary Lisp
5576 expressions to process these values before inserting them into a table
5577 or a dynamic block.
5579 * Dates and Times
5580 :PROPERTIES:
5581 :DESCRIPTION: Making items useful for planning.
5582 :END:
5583 #+cindex: dates
5584 #+cindex: times
5585 #+cindex: timestamp
5586 #+cindex: date stamp
5588 To assist project planning, TODO items can be labeled with a date
5589 and/or a time.  The specially formatted string carrying the date and
5590 time information is called a /timestamp/ in Org mode.  This may be
5591 a little confusing because timestamp is often used as indicating when
5592 something was created or last changed.  However, in Org mode this term
5593 is used in a much wider sense.
5595 ** Timestamps
5596 :PROPERTIES:
5597 :DESCRIPTION: Assigning a time to a tree entry.
5598 :END:
5599 #+cindex: timestamps
5600 #+cindex: ranges, time
5601 #+cindex: date stamps
5602 #+cindex: deadlines
5603 #+cindex: scheduling
5605 A timestamp is a specification of a date (possibly with a time or
5606 a range of times) in a special format, either =<2003-09-16 Tue>= or
5607 =<2003-09-16 Tue 09:39>= or =<2003-09-16 Tue 12:00-12:30>=[fn:59].
5608 A timestamp can appear anywhere in the headline or body of an Org tree
5609 entry.  Its presence causes entries to be shown on specific dates in
5610 the agenda (see [[*Weekly/daily agenda]]).  We distinguish:
5612 - Plain timestamp; Event; Appointment ::
5614   #+cindex: timestamp
5615   #+cindex: appointment
5616   A simple timestamp just assigns a date/time to an item.  This is
5617   just like writing down an appointment or event in a paper agenda.
5618   In the agenda display, the headline of an entry associated with
5619   a plain timestamp is shown exactly on that date.
5621   #+begin_example
5622   ,* Meet Peter at the movies
5623     <2006-11-01 Wed 19:15>
5624   ,* Discussion on climate change
5625     <2006-11-02 Thu 20:00-22:00>
5626   #+end_example
5628 - Timestamp with repeater interval ::
5630   #+cindex: timestamp, with repeater interval
5631   A timestamp may contain a /repeater interval/, indicating that it
5632   applies not only on the given date, but again and again after
5633   a certain interval of N days (d), weeks (w), months (m), or years
5634   (y).  The following shows up in the agenda every Wednesday:
5636   #+begin_example
5637   ,* Pick up Sam at school
5638     <2007-05-16 Wed 12:30 +1w>
5639   #+end_example
5641 - Diary-style expression entries ::
5643   #+cindex: diary style timestamps
5644   #+cindex: sexp timestamps
5645   For more complex date specifications, Org mode supports using the
5646   special expression diary entries implemented in the Emacs Calendar
5647   package[fn:60].  For example, with optional time:
5649   #+begin_example
5650   ,* 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
5651     <%%(diary-float t 4 2)>
5652   #+end_example
5654 - Time/Date range ::
5656   #+cindex: timerange
5657   #+cindex: date range
5658   Two timestamps connected by =--= denote a range.  The headline is
5659   shown on the first and last day of the range, and on any dates that
5660   are displayed and fall in the range.  Here is an example:
5662   #+begin_example
5663   ,** Meeting in Amsterdam
5664      <2004-08-23 Mon>--<2004-08-26 Thu>
5665   #+end_example
5667 - Inactive timestamp ::
5669   #+cindex: timestamp, inactive
5670   #+cindex: inactive timestamp
5671   Just like a plain timestamp, but with square brackets instead of
5672   angular ones.  These timestamps are inactive in the sense that they
5673   do /not/ trigger an entry to show up in the agenda.
5675   #+begin_example
5676   ,* Gillian comes late for the fifth time
5677     [2006-11-01 Wed]
5678   #+end_example
5680 ** Creating Timestamps
5681 :PROPERTIES:
5682 :DESCRIPTION: Commands to insert timestamps.
5683 :END:
5685 For Org mode to recognize timestamps, they need to be in the specific
5686 format.  All commands listed below produce timestamps in the correct
5687 format.
5689 #+attr_texinfo: :sep ,
5690 - {{{kbd(C-c .)}}} (~org-time-stamp~) ::
5692   #+kindex: C-c .
5693   #+findex: org-time-stamp
5694   Prompt for a date and insert a corresponding timestamp.  When point
5695   is at an existing timestamp in the buffer, the command is used to
5696   modify this timestamp instead of inserting a new one.  When this
5697   command is used twice in succession, a time range is inserted.
5699   #+kindex: C-u C-c .
5700   #+vindex: org-time-stamp-rounding-minutes
5701   When called with a prefix argument, use the alternative format which
5702   contains date and time.  The default time can be rounded to
5703   multiples of 5 minutes.  See the option
5704   ~org-time-stamp-rounding-minutes~.
5706   #+kindex: C-u C-u C-c .
5707   With two prefix arguments, insert an active timestamp with the
5708   current time without prompting.
5710 - {{{kbd(C-c !)}}} (~org-time-stamp-inactive~) ::
5712   #+kindex: C-c !
5713   #+kindex: C-u C-c !
5714   #+kindex: C-u C-u C-c !
5715   #+findex: org-time-stamp-inactive
5716   Like {{{kbd(C-c .)}}}, but insert an inactive timestamp that does
5717   not cause an agenda entry.
5719 - {{{kbd(C-c C-c)}}} ::
5721   #+kindex: C-c C-c
5722   Normalize timestamp, insert or fix day name if missing or wrong.
5724 - {{{kbd(C-c <)}}} (~org-date-from-calendar~) ::
5726   #+kindex: C-c <
5727   #+findex: org-date-from-calendar
5728   Insert a timestamp corresponding to point date in the calendar.
5730 - {{{kbd(C-c >)}}} (~org-goto-calendar~) ::
5732   #+kindex: C-c >
5733   #+findex: org-goto-calendar
5734   Access the Emacs calendar for the current date.  If there is
5735   a timestamp in the current line, go to the corresponding date
5736   instead.
5738 - {{{kbd(C-c C-o)}}} (~org-open-at-point~) ::
5740   #+kindex: C-c C-o
5741   #+findex: org-open-at-point
5742   Access the agenda for the date given by the timestamp or -range at
5743   point (see [[*Weekly/daily agenda]]).
5745 - {{{kbd(S-LEFT)}}} (~org-timestamp-down-day~), {{{kbd(S-RIGHT)}}} (~org-timestamp-up-day~) ::
5747   #+kindex: S-LEFT
5748   #+kindex: S-RIGHT
5749   #+findex: org-timestamp-down-day
5750   #+findex: org-timestamp-up-day
5751   Change date at point by one day.  These key bindings conflict with
5752   shift-selection and related modes (see [[*Packages that conflict with
5753   Org mode]]).
5755 - {{{kbd(S-UP)}}} (~org-timestamp-up~), {{{kbd(S-DOWN)}}} (~org-timestamp-down~) ::
5757   #+kindex: S-UP
5758   #+kindex: S-DOWN
5759   On the beginning or enclosing bracket of a timestamp, change its
5760   type.  Within a timestamp, change the item under point.  Point can
5761   be on a year, month, day, hour or minute.  When the timestamp
5762   contains a time range like =15:30-16:30=, modifying the first time
5763   also shifts the second, shifting the time block with constant
5764   length.  To change the length, modify the second time.  Note that if
5765   point is in a headline and not at a timestamp, these same keys
5766   modify the priority of an item (see [[*Priorities]]).  The key bindings
5767   also conflict with shift-selection and related modes (see [[*Packages
5768   that conflict with Org mode]]).
5770 - {{{kbd(C-c C-y)}}} (~org-evaluate-time-range~) ::
5772   #+kindex: C-c C-y
5773   #+findex: org-evaluate-time-range
5774   #+cindex: evaluate time range
5775   Evaluate a time range by computing the difference between start and
5776   end.  With a prefix argument, insert result after the time range (in
5777   a table: into the following column).
5779 *** The date/time prompt
5780 :PROPERTIES:
5781 :DESCRIPTION: How Org mode helps you enter dates and times.
5782 :END:
5783 #+cindex: date, reading in minibuffer
5784 #+cindex: time, reading in minibuffer
5786 #+vindex: org-read-date-prefer-future
5787 When Org mode prompts for a date/time, the default is shown in default
5788 date/time format, and the prompt therefore seems to ask for a specific
5789 format.  But it in fact accepts date/time information in a variety of
5790 formats.  Generally, the information should start at the beginning of
5791 the string.  Org mode finds whatever information is in there and
5792 derives anything you have not specified from the /default date and
5793 time/.  The default is usually the current date and time, but when
5794 modifying an existing timestamp, or when entering the second stamp of
5795 a range, it is taken from the stamp in the buffer.  When filling in
5796 information, Org mode assumes that most of the time you want to enter
5797 a date in the future: if you omit the month/year and the given
5798 day/month is /before/ today, it assumes that you mean a future
5799 date[fn:61].  If the date has been automatically shifted into the
5800 future, the time prompt shows this with =(=>F)=.
5802 For example, let's assume that today is *June 13, 2006*.  Here is how
5803 various inputs are interpreted, the items filled in by Org mode are in
5804 *bold*.
5806 | =3-2-5=        | \rArr{} 2003-02-05                              |
5807 | =2/5/3=        | \rArr{} 2003-02-05                              |
5808 | =14=           | \rArr{} *2006*-*06*-14                          |
5809 | =12=           | \rArr{} *2006*-*07*-12                          |
5810 | =2/5=          | \rArr{} *2007*-02-05                            |
5811 | =Fri=          | \rArr{} nearest Friday (default date or later)  |
5812 | =sep 15=       | \rArr{} *2006*-09-15                            |
5813 | =feb 15=       | \rArr{} *2007*-02-15                            |
5814 | =sep 12 9=     | \rArr{} 2009-09-12                              |
5815 | =12:45=        | \rArr{} *2006*-*06*-*13* 12:45                  |
5816 | =22 sept 0:34= | \rArr{} *2006*-09-22 0:34                       |
5817 | =w4=           | \rArr{} ISO week for of the current year *2006* |
5818 | =2012 w4 fri=  | \rArr{} Friday of ISO week 4 in 2012            |
5819 | =2012-w04-5=   | \rArr{} Same as above                           |
5821 Furthermore you can specify a relative date by giving, as the /first/
5822 thing in the input: a plus/minus sign, a number and a letter---=d=,
5823 =w=, =m= or =y=---to indicate change in days, weeks, months, or
5824 years.  With a single plus or minus, the date is always relative to
5825 today.  With a double plus or minus, it is relative to the default
5826 date.  If instead of a single letter, you use the abbreviation of day
5827 name, the date is the Nth such day, e.g.:
5829 | =+0=    | \rArr{} today                       |
5830 | =.=     | \rArr{} today                       |
5831 | =+4d=   | \rArr{} four days from today        |
5832 | =+4=    | \rArr{} same as +4d                 |
5833 | =+2w=   | \rArr{} two weeks from today        |
5834 | =++5=   | \rArr{} five days from default date |
5835 | =+2tue= | \rArr{} second Tuesday from now     |
5837 #+vindex: parse-time-months
5838 #+vindex: parse-time-weekdays
5839 The function understands English month and weekday abbreviations.  If
5840 you want to use un-abbreviated names and/or other languages, configure
5841 the variables ~parse-time-months~ and ~parse-time-weekdays~.
5843 #+vindex: org-read-date-force-compatible-dates
5844 Not all dates can be represented in a given Emacs implementation.  By
5845 default Org mode forces dates into the compatibility range 1970--2037
5846 which works on all Emacs implementations.  If you want to use dates
5847 outside of this range, read the docstring of the variable
5848 ~org-read-date-force-compatible-dates~.
5850 You can specify a time range by giving start and end times or by
5851 giving a start time and a duration (in HH:MM format).  Use one or two
5852 dash(es) as the separator in the former case and use =+= as the
5853 separator in the latter case, e.g.:
5855 | =11am-1:15pm=  | \rArr{} 11:00-13:15   |
5856 | =11am--1:15pm= | \rArr{} same as above |
5857 | =11am+2:15=    | \rArr{} same as above |
5859 #+cindex: calendar, for selecting date
5860 #+vindex: org-popup-calendar-for-date-prompt
5861 Parallel to the minibuffer prompt, a calendar is popped up[fn:62].
5862 When you exit the date prompt, either by clicking on a date in the
5863 calendar, or by pressing {{{kbd(RET)}}}, the date selected in the
5864 calendar is combined with the information entered at the prompt.  You
5865 can control the calendar fully from the minibuffer:
5867 #+kindex: <
5868 #+kindex: >
5869 #+kindex: M-v
5870 #+kindex: C-v
5871 #+kindex: mouse-1
5872 #+kindex: S-RIGHT
5873 #+kindex: S-LEFT
5874 #+kindex: S-DOWN
5875 #+kindex: S-UP
5876 #+kindex: M-S-RIGHT
5877 #+kindex: M-S-LEFT
5878 #+kindex: RET
5879 #+attr_texinfo: :columns 0.25 0.55
5880 | {{{kbd(RET)}}}       | Choose date at point in calendar.      |
5881 | {{{kbd(mouse-1)}}}   | Select date by clicking on it.         |
5882 | {{{kbd(S-RIGHT)}}}   | One day forward.                       |
5883 | {{{kbd(S-LEFT)}}}    | One day backward.                      |
5884 | {{{kbd(S-DOWN)}}}    | One week forward.                      |
5885 | {{{kbd(S-UP)}}}      | One week backward.                     |
5886 | {{{kbd(M-S-RIGHT)}}} | One month forward.                     |
5887 | {{{kbd(M-S-LEFT)}}}  | One month backward.                    |
5888 | {{{kbd(>)}}}         | Scroll calendar forward by one month.  |
5889 | {{{kbd(<)}}}         | Scroll calendar backward by one month. |
5890 | {{{kbd(M-v)}}}       | Scroll calendar forward by 3 months.   |
5891 | {{{kbd(C-v)}}}       | Scroll calendar backward by 3 months.  |
5893 #+vindex: org-read-date-display-live
5894 The actions of the date/time prompt may seem complex, but I assure you
5895 they will grow on you, and you will start getting annoyed by pretty
5896 much any other way of entering a date/time out there.  To help you
5897 understand what is going on, the current interpretation of your input
5898 is displayed live in the minibuffer[fn:63].
5900 *** Custom time format
5901 :PROPERTIES:
5902 :DESCRIPTION: Making dates look different.
5903 :END:
5904 #+cindex: custom date/time format
5905 #+cindex: time format, custom
5906 #+cindex: date format, custom
5908 #+vindex: org-display-custom-times
5909 #+vindex: org-time-stamp-custom-formats
5910 Org mode uses the standard ISO notation for dates and times as it is
5911 defined in ISO 8601.  If you cannot get used to this and require
5912 another representation of date and time to keep you happy, you can get
5913 it by customizing the variables ~org-display-custom-times~ and
5914 ~org-time-stamp-custom-formats~.
5916 - {{{kbd(C-c C-x C-t)}}} (~org-toggle-time-stamp-overlays~) ::
5918   #+kindex: C-c C-x C-t
5919   #+findex: org-toggle-time-stamp-overlays
5920   Toggle the display of custom formats for dates and times.
5922 Org mode needs the default format for scanning, so the custom
5923 date/time format does not /replace/ the default format.  Instead, it
5924 is put /over/ the default format using text properties.  This has the
5925 following consequences:
5927 - You cannot place point onto a timestamp anymore, only before or
5928   after.
5930 - The {{{kbd(S-UP)}}} and {{{kbd(S-DOWN)}}} keys can no longer be used
5931   to adjust each component of a timestamp.  If point is at the
5932   beginning of the stamp, {{{kbd(S-UP)}}} and {{{kbd(S-DOWN)}}} change
5933   the stamp by one day, just like {{{kbd(S-LEFT)}}}
5934   {{{kbd(S-RIGHT)}}}.  At the end of the stamp, change the time by one
5935   minute.
5937 - If the timestamp contains a range of clock times or a repeater,
5938   these are not overlaid, but remain in the buffer as they were.
5940 - When you delete a timestamp character-by-character, it only
5941   disappears from the buffer after /all/ (invisible) characters
5942   belonging to the ISO timestamp have been removed.
5944 - If the custom timestamp format is longer than the default and you
5945   are using dates in tables, table alignment will be messed up.  If
5946   the custom format is shorter, things do work as expected.
5948 ** Deadlines and Scheduling
5949 :PROPERTIES:
5950 :DESCRIPTION: Planning your work.
5951 :END:
5953 A timestamp may be preceded by special keywords to facilitate
5954 planning.  Both the timestamp and the keyword have to be positioned
5955 immediately after the task they refer to.
5957 - =DEADLINE= ::
5959   #+cindex: @samp{DEADLINE} marker
5960   Meaning: the task---most likely a TODO item, though not
5961   necessarily---is supposed to be finished on that date.
5963   #+vindex: org-deadline-warning-days
5964   On the deadline date, the task is listed in the agenda.  In
5965   addition, the agenda for /today/ carries a warning about the
5966   approaching or missed deadline, starting ~org-deadline-warning-days~
5967   before the due date, and continuing until the entry is marked as
5968   done.  An example:
5970   #+begin_example
5971   ,*** TODO write article about the Earth for the Guide
5972       DEADLINE: <2004-02-29 Sun>
5973       The editor in charge is [[bbdb:Ford Prefect]]
5974   #+end_example
5976   #+vindex: org-agenda-skip-deadline-prewarning-if-scheduled
5977   You can specify a different lead time for warnings for a specific
5978   deadlines using the following syntax.  Here is an example with
5979   a warning period of 5 days =DEADLINE: <2004-02-29 Sun -5d>=.  This
5980   warning is deactivated if the task gets scheduled and you set
5981   ~org-agenda-skip-deadline-prewarning-if-scheduled~ to ~t~.
5983 - =SCHEDULED= ::
5985   #+cindex: @samp{SCHEDULED} marker
5986   Meaning: you are planning to start working on that task on the given
5987   date.
5989   #+vindex: org-agenda-skip-scheduled-if-done
5990   The headline is listed under the given date[fn:64].  In addition,
5991   a reminder that the scheduled date has passed is present in the
5992   compilation for /today/, until the entry is marked as done, i.e.,
5993   the task is automatically forwarded until completed.
5995   #+begin_example
5996   ,*** TODO Call Trillian for a date on New Years Eve.
5997       SCHEDULED: <2004-12-25 Sat>
5998   #+end_example
6000   #+vindex: org-scheduled-delay-days
6001   #+vindex: org-agenda-skip-scheduled-delay-if-deadline
6002   If you want to /delay/ the display of this task in the agenda, use
6003   =SCHEDULED: <2004-12-25 Sat -2d>=: the task is still scheduled on
6004   the 25th but will appear two days later.  In case the task contains
6005   a repeater, the delay is considered to affect all occurrences; if
6006   you want the delay to only affect the first scheduled occurrence of
6007   the task, use =--2d= instead.  See ~org-scheduled-delay-days~ and
6008   ~org-agenda-skip-scheduled-delay-if-deadline~ for details on how to
6009   control this globally or per agenda.
6011   #+attr_texinfo: :tag Important
6012   #+begin_quote
6013   Scheduling an item in Org mode should /not/ be understood in the
6014   same way that we understand /scheduling a meeting/.  Setting a date
6015   for a meeting is just a simple appointment, you should mark this
6016   entry with a simple plain timestamp, to get this item shown on the
6017   date where it applies.  This is a frequent misunderstanding by Org
6018   users.  In Org mode, /scheduling/ means setting a date when you want
6019   to start working on an action item.
6020   #+end_quote
6022 You may use timestamps with repeaters in scheduling and deadline
6023 entries.  Org mode issues early and late warnings based on the
6024 assumption that the timestamp represents the /nearest instance/ of the
6025 repeater.  However, the use of diary expression entries like
6027 : <%%(diary-float t 42)>
6029 #+texinfo: @noindent
6030 in scheduling and deadline timestamps is limited.  Org mode does not
6031 know enough about the internals of each function to issue early and
6032 late warnings.  However, it shows the item on each day where the
6033 expression entry matches.
6035 *** Inserting deadlines or schedules
6036 :PROPERTIES:
6037 :DESCRIPTION: Planning items.
6038 :ALT_TITLE: Inserting deadline/schedule
6039 :END:
6041 The following commands allow you to quickly insert a deadline or to
6042 schedule an item:[fn:65]
6044 - {{{kbd(C-c C-d)}}} (~org-deadline~) ::
6046   #+kindex: C-c C-d
6047   #+findex: org-deadline
6048   #+vindex: org-log-redeadline
6049   Insert =DEADLINE= keyword along with a stamp.  The insertion happens
6050   in the line directly following the headline.  Remove any =CLOSED=
6051   timestamp .  When called with a prefix argument, also remove any
6052   existing deadline from the entry.  Depending on the variable
6053   ~org-log-redeadline~, take a note when changing an existing
6054   deadline[fn:66].
6056 - {{{kbd(C-c C-s)}}} (~org-schedule~) ::
6058   #+kindex: C-c C-s
6059   #+findex: org-schedule
6060   #+vindex: org-log-reschedule
6061   Insert =SCHEDULED= keyword along with a stamp.  The insertion
6062   happens in the line directly following the headline.  Remove any
6063   =CLOSED= timestamp.  When called with a prefix argument, also remove
6064   the scheduling date from the entry.  Depending on the variable
6065   ~org-log-reschedule~, take a note when changing an existing
6066   scheduling time[fn:67].
6068 - {{{kbd(C-c / d)}}} (~org-check-deadlines~) ::
6070   #+kindex: C-c / d
6071   #+findex: org-check-deadlines
6072   #+cindex: sparse tree, for deadlines
6073   #+vindex: org-deadline-warning-days
6074   Create a sparse tree with all deadlines that are either past-due, or
6075   which will become due within ~org-deadline-warning-days~.  With
6076   {{{kbd(C-u)}}} prefix, show all deadlines in the file.  With
6077   a numeric prefix, check that many days.  For example, {{{kbd(C-1 C-c
6078   / d)}}} shows all deadlines due tomorrow.
6080 - {{{kbd(C-c / b)}}} (~org-check-before-date~) ::
6082   #+kindex: C-c / b
6083   #+findex: org-check-before-date
6084   Sparse tree for deadlines and scheduled items before a given date.
6086 - {{{kbd(C-c / a)}}} (~org-check-after-date~) ::
6088   #+kindex: C-c / a
6089   #+findex: org-check-after-date
6090   Sparse tree for deadlines and scheduled items after a given date.
6092 Note that ~org-schedule~ and ~org-deadline~ supports setting the date
6093 by indicating a relative time e.g., =+1d= sets the date to the next
6094 day after today, and =--1w= sets the date to the previous week before
6095 any current timestamp.
6097 *** Repeated tasks
6098 :PROPERTIES:
6099 :DESCRIPTION: Items that show up again and again.
6100 :END:
6101 #+cindex: tasks, repeated
6102 #+cindex: repeated tasks
6104 Some tasks need to be repeated again and again.  Org mode helps to
6105 organize such tasks using a so-called repeater in a =DEADLINE=,
6106 =SCHEDULED=, or plain timestamps[fn:68].  In the following example:
6108 #+begin_example
6109 ,** TODO Pay the rent
6110    DEADLINE: <2005-10-01 Sat +1m>
6111 #+end_example
6113 #+texinfo: @noindent
6114 the =+1m= is a repeater; the intended interpretation is that the task
6115 has a deadline on =<2005-10-01>= and repeats itself every (one) month
6116 starting from that time.  You can use yearly, monthly, weekly, daily
6117 and hourly repeat cookies by using the =y=, =w=, =m=, =d= and =h=
6118 letters.  If you need both a repeater and a special warning period in
6119 a deadline entry, the repeater should come first and the warning
6120 period last
6122 : DEADLINE: <2005-10-01 Sat +1m -3d>
6124 #+vindex: org-todo-repeat-to-state
6125 Deadlines and scheduled items produce entries in the agenda when they
6126 are over-due, so it is important to be able to mark such an entry as
6127 done once you have done so.  When you mark a =DEADLINE= or
6128 a =SCHEDULED= with the TODO keyword =DONE=, it no longer produces
6129 entries in the agenda.  The problem with this is, however, is that
6130 then also the /next/ instance of the repeated entry will not be
6131 active.  Org mode deals with this in the following way: when you try
6132 to mark such an entry as done, using {{{kbd(C-c C-t)}}}, it shifts the
6133 base date of the repeating timestamp by the repeater interval, and
6134 immediately sets the entry state back to TODO[fn:69].  In the example
6135 above, setting the state to =DONE= would actually switch the date like
6136 this:
6138 #+begin_example
6139 ,** TODO Pay the rent
6140    DEADLINE: <2005-11-01 Tue +1m>
6141 #+end_example
6143 To mark a task with a repeater as DONE, use {{{kbd(C-- 1 C-c C-t)}}},
6144 i.e., ~org-todo~ with a numeric prefix argument of =-1=.
6146 #+vindex: org-log-repeat
6147 A timestamp[fn:70] is added under the deadline, to keep a record that
6148 you actually acted on the previous instance of this deadline.
6150 As a consequence of shifting the base date, this entry is no longer
6151 visible in the agenda when checking past dates, but all future
6152 instances will be visible.
6154 With the =+1m= cookie, the date shift is always exactly one month.  So
6155 if you have not paid the rent for three months, marking this entry
6156 DONE still keeps it as an overdue deadline.  Depending on the task,
6157 this may not be the best way to handle it.  For example, if you forgot
6158 to call your father for 3 weeks, it does not make sense to call him
6159 3 times in a single day to make up for it.  Finally, there are tasks
6160 like changing batteries which should always repeat a certain time
6161 /after/ the last time you did it.  For these tasks, Org mode has
6162 special repeaters =++= and =.+=.  For example:
6164 #+begin_example
6165 ,** TODO Call Father
6166    DEADLINE: <2008-02-10 Sun ++1w>
6167    Marking this DONE shifts the date by at least one week, but also
6168    by as many weeks as it takes to get this date into the future.
6169    However, it stays on a Sunday, even if you called and marked it
6170    done on Saturday.
6172 ,** TODO Empty kitchen trash
6173    DEADLINE: <2008-02-08 Fri 20:00 ++1d>
6174    Marking this DONE shifts the date by at least one day, and also
6175    by as many days as it takes to get the timestamp into the future.
6176    Since there is a time in the timestamp, the next deadline in the
6177    future will be on today's date if you complete the task before
6178    20:00.
6180 ,** TODO Check the batteries in the smoke detectors
6181    DEADLINE: <2005-11-01 Tue .+1m>
6182    Marking this DONE will shift the date to one month after today.
6183 #+end_example
6185 #+vindex: org-agenda-skip-scheduled-if-deadline-is-shown
6186 You may have both scheduling and deadline information for a specific
6187 task.  If the repeater is set for the scheduling information only, you
6188 probably want the repeater to be ignored after the deadline.  If so,
6189 set the variable ~org-agenda-skip-scheduled-if-deadline-is-shown~ to
6190 ~repeated-after-deadline~.  However, any scheduling information
6191 without a repeater is no longer relevant once the task is done, and
6192 thus, removed upon repeating the task.  If you want both scheduling
6193 and deadline information to repeat after the same interval, set the
6194 same repeater for both timestamps.
6196 An alternative to using a repeater is to create a number of copies of
6197 a task subtree, with dates shifted in each copy.  The command
6198 {{{kbd(C-c C-x c)}}} was created for this purpose; it is described in
6199 [[*Structure Editing]].
6201 ** Clocking Work Time
6202 :PROPERTIES:
6203 :DESCRIPTION: Tracking how long you spend on a task.
6204 :END:
6205 #+cindex: clocking time
6206 #+cindex: time clocking
6208 Org mode allows you to clock the time you spend on specific tasks in
6209 a project.  When you start working on an item, you can start the
6210 clock.  When you stop working on that task, or when you mark the task
6211 done, the clock is stopped and the corresponding time interval is
6212 recorded.  It also computes the total time spent on each
6213 subtree[fn:71] of a project.  And it remembers a history or tasks
6214 recently clocked, to that you can jump quickly between a number of
6215 tasks absorbing your time.
6217 To save the clock history across Emacs sessions, use:
6219 #+begin_src emacs-lisp
6220 (setq org-clock-persist 'history)
6221 (org-clock-persistence-insinuate)
6222 #+end_src
6224 #+vindex: org-clock-persist
6225 When you clock into a new task after resuming Emacs, the incomplete
6226 clock[fn:72] is retrieved (see [[*Resolving idle time]]) and you are
6227 prompted about what to do with it.
6229 *** Clocking commands
6230 :PROPERTIES:
6231 :DESCRIPTION: Starting and stopping a clock.
6232 :END:
6234 #+attr_texinfo: :sep ,
6235 - {{{kbd(C-c C-x C-i)}}} (~org-clock-in~) ::
6237   #+kindex: C-c C-x C-i
6238   #+findex: org-clock-in
6239   #+vindex: org-clock-into-drawer
6240   #+vindex: org-clock-continuously
6241   #+cindex: @samp{LOG_INTO_DRAWER}, property
6242   Start the clock on the current item (clock-in).  This inserts the
6243   =CLOCK= keyword together with a timestamp.  If this is not the first
6244   clocking of this item, the multiple =CLOCK= lines are wrapped into
6245   a =LOGBOOK= drawer (see also the variable ~org-clock-into-drawer~).
6246   You can also overrule the setting of this variable for a subtree by
6247   setting a =CLOCK_INTO_DRAWER= or =LOG_INTO_DRAWER= property.  When
6248   called with a {{{kbd(C-u)}}} prefix argument, select the task from
6249   a list of recently clocked tasks.  With two {{{kbd(C-u C-u)}}}
6250   prefixes, clock into the task at point and mark it as the default
6251   task; the default task is always be available with letter
6252   {{{kbd(d)}}} when selecting a clocking task.  With three {{{kbd(C-u
6253   C-u C-u)}}} prefixes, force continuous clocking by starting the
6254   clock when the last clock stopped.
6256   #+cindex: @samp{CLOCK_MODELINE_TOTAL}, property
6257   #+cindex: @samp{LAST_REPEAT}, property
6258   #+vindex: org-clock-mode-line-total
6259   #+vindex: org-clock-in-prepare-hook
6260   While the clock is running, Org shows the current clocking time in
6261   the mode line, along with the title of the task.  The clock time
6262   shown is all time ever clocked for this task and its children.  If
6263   the task has an effort estimate (see [[*Effort Estimates]]), the mode
6264   line displays the current clocking time against it[fn:73].  If the
6265   task is a repeating one (see [[*Repeated tasks]]), show only the time
6266   since the last reset of the task[fn:74].  You can exercise more
6267   control over show time with the =CLOCK_MODELINE_TOTAL= property.  It
6268   may have the values =current= to show only the current clocking
6269   instance, =today= to show all time clocked on this tasks today---see
6270   also the variable ~org-extend-today-until~, ~all~ to include all
6271   time, or ~auto~ which is the default[fn:75].  Clicking with
6272   {{{kbd(mouse-1)}}} onto the mode line entry pops up a menu with
6273   clocking options.
6275 - {{{kbd(C-c C-x C-o)}}} (~org-clock-out~) ::
6277   #+kindex: C-c C-x C-o
6278   #+findex: org-clock-out
6279   #+vindex: org-log-note-clock-out
6280   Stop the clock (clock-out).  This inserts another timestamp at the
6281   same location where the clock was last started.  It also directly
6282   computes the resulting time in inserts it after the time range as
6283   ==>HH:MM=.  See the variable ~org-log-note-clock-out~ for the
6284   possibility to record an additional note together with the clock-out
6285   timestamp[fn:76].
6287 - {{{kbd(C-c C-x C-x)}}} (~org-clock-in-last~) ::
6289   #+kindex: C-c C-x C-x
6290   #+findex: org-clock-in-last
6291   #+vindex: org-clock-continuously
6292   Re-clock the last clocked task.  With one {{{kbd(C-u)}}} prefix
6293   argument, select the task from the clock history.  With two
6294   {{{kbd(C-u)}}} prefixes, force continuous clocking by starting the
6295   clock when the last clock stopped.
6297 - {{{kbd(C-c C-x C-e)}}} (~org-clock-modify-effort-estimate~) ::
6299   #+kindex: C-c C-x C-e
6300   #+findex: org-clock-modify-effort-estimate
6301   Update the effort estimate for the current clock task.
6303 - {{{kbd(C-c C-c)}}} or {{{kbd(C-c C-y)}}} (~org-evaluate-time-range~) ::
6305   #+kindex: C-c C-c
6306   #+kindex: C-c C-y
6307   #+findex: org-evaluate-time-range
6308   Recompute the time interval after changing one of the timestamps.
6309   This is only necessary if you edit the timestamps directly.  If you
6310   change them with {{{kbd(S-<cursor>)}}} keys, the update is
6311   automatic.
6313 - {{{kbd(C-S-UP)}}} (~org-clock-timestamps-up~), {{{kbd(C-S-DOWN)}}} (~org-clock-timestamps-down~) ::
6315   #+kindex: C-S-UP
6316   #+findex: org-clock-timestamps-up
6317   #+kindex: C-S-DOWN
6318   #+findex: org-clock-timestamps-down
6319   On CLOCK log lines, increase/decrease both timestamps so that the
6320   clock duration keeps the same value.
6322 - {{{kbd(S-M-UP)}}} (~org-timestamp-up~), {{{kbd(S-M-DOWN)}}} (~org-timestamp-down~) ::
6324   #+kindex: S-M-UP
6325   #+findex: org-clock-timestamp-up
6326   #+kindex: S-M-DOWN
6327   #+findex: org-clock-timestamp-down
6328   On =CLOCK= log lines, increase/decrease the timestamp at point and
6329   the one of the previous, or the next, clock timestamp by the same
6330   duration.  For example, if you hit {{{kbd(S-M-UP)}}} to increase
6331   a clocked-out timestamp by five minutes, then the clocked-in
6332   timestamp of the next clock is increased by five minutes.
6334 - {{{kbd(C-c C-t)}}} (~org-todo~) ::
6336   #+kindex: C-c C-t
6337   #+findex: org-todo
6338   Changing the TODO state of an item to DONE automatically stops the
6339   clock if it is running in this same item.
6341 - {{{kbd(C-c C-x C-q)}}} (~org-clock-cancel~) ::
6343   #+kindex: C-c C-x C-q
6344   #+findex: org-clock-cancel
6345   Cancel the current clock.  This is useful if a clock was started by
6346   mistake, or if you ended up working on something else.
6348 - {{{kbd(C-c C-x C-j)}}} (~org-clock-goto~) ::
6350   #+kindex: C-c C-x C-j
6351   #+findex: or-clock-goto
6352   Jump to the headline of the currently clocked in task.  With
6353   a {{{kbd(C-u)}}} prefix argument, select the target task from a list
6354   of recently clocked tasks.
6356 - {{{kbd(C-c C-x C-d)}}} (~org-clock-display~) ::
6358   #+kindex: C-c C-x C-d
6359   #+findex: org-clock-display
6360   #+vindex: org-remove-highlights-with-change
6361   Display time summaries for each subtree in the current buffer.  This
6362   puts overlays at the end of each headline, showing the total time
6363   recorded under that heading, including the time of any subheadings.
6364   You can use visibility cycling to study the tree, but the overlays
6365   disappear when you change the buffer (see variable
6366   ~org-remove-highlights-with-change~) or press {{{kbd(C-c C-c)}}}.
6368 The {{{kbd(l)}}} key may be used in the agenda (see [[*Weekly/daily
6369 agenda]]) to show which tasks have been worked on or closed during
6370 a day.
6372 *Important:* note that both ~org-clock-out~ and ~org-clock-in-last~
6373 can have a global keybinding and do not modify the window disposition.
6375 *** The clock table
6376 :PROPERTIES:
6377 :DESCRIPTION: Detailed reports.
6378 :END:
6379 #+cindex: clocktable, dynamic block
6380 #+cindex: report, of clocked time
6382 Org mode can produce quite complex reports based on the time clocking
6383 information.  Such a report is called a /clock table/, because it is
6384 formatted as one or several Org tables.
6386 You can insert, or update, a clock table through Org dynamic blocks
6387 insert command (see [[*Dynamic Blocks]]), by pressing {{{kbd(C-c C-x
6388 x c l o c k t a b l e RET)}}}.  When called with a prefix argument,
6389 jump to the first clock table in the current document and update it.
6390 The clock table includes archived trees.
6392 #+attr_texinfo: :sep ,
6393 - {{{kbd(C-c C-c)}}} or {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
6395   #+kindex: C-c C-c
6396   #+kindex: C-c C-x C-u
6397   #+findex: org-dblock-update
6398   Update dynamic block at point.  Point needs to be in the =BEGIN=
6399   line of the dynamic block.
6401 - {{{kbd(C-u C-c C-x C-u)}}} ::
6403   #+kindex: C-u C-c C-x C-u
6404   Update all dynamic blocks (see [[*Dynamic Blocks]]).  This is useful if
6405   you have several clock table blocks in a buffer.
6407 - {{{kbd(S-LEFT)}}}, {{{kbd(S-RIGHT)}}} (~org-clocktable-try-shift~) ::
6409   #+kindex: S-LEFT
6410   #+kindex: S-RIGHT
6411   #+findex: org-clocktable-try-shift
6412   Shift the current =:block= interval and update the table.  Point
6413   needs to be in the =#+BEGIN: clocktable= line for this command.  If
6414   =:block= is =today=, it is shifted to =today-1=, etc.
6416 Here is an example of the frame for a clock table as it is inserted
6417 into the buffer with the {{{kbd(C-c C-x C-r)}}} command:
6419 #+cindex: @samp{BEGIN clocktable}
6420 #+begin_example
6421 ,#+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
6422 ,#+END: clocktable
6423 #+end_example
6425 #+vindex: org-clocktable-defaults
6426 The =#+BEGIN= line and specify a number of options to define the
6427 scope, structure, and formatting of the report.  Defaults for all
6428 these options can be configured in the variable
6429 ~org-clocktable-defaults~.
6431 First there are options that determine which clock entries are to
6432 be selected:
6434 - =:maxlevel= ::
6436   Maximum level depth to which times are listed in the table.  Clocks
6437   at deeper levels are summed into the upper level.
6439 - =:scope= ::
6441   The scope to consider.  This can be any of the following:
6443   | =nil=                  | the current buffer or narrowed region                               |
6444   | =file=                 | the full current buffer                                             |
6445   | =subtree=              | the subtree where the clocktable is located                         |
6446   | =treeN=                | the surrounding level N tree, for example =tree3=                   |
6447   | =tree=                 | the surrounding level 1 tree                                        |
6448   | =agenda=               | all agenda files                                                    |
6449   | =("file" ...)=         | scan these files                                                    |
6450   | =FUNCTION=             | scan files returned by calling {{{var(FUNCTION)}}} with no argument |
6451   | =file-with-archives=   | current file and its archives                                       |
6452   | =agenda-with-archives= | all agenda files, including archives                                |
6454 - =:block= ::
6456   The time block to consider.  This block is specified either
6457   absolutely, or relative to the current time and may be any of these
6458   formats:
6460   | =2007-12-31=                            | New year eve 2007     |
6461   | =2007-12=                               | December 2007         |
6462   | =2007-W50=                              | ISO-week 50 in 2007   |
6463   | =2007-Q2=                               | 2nd quarter in 2007   |
6464   | =2007=                                  | the year 2007         |
6465   | =today=, =yesterday=, =today-N=         | a relative day        |
6466   | =thisweek=, =lastweek=, =thisweek-N=    | a relative week       |
6467   | =thismonth=, =lastmonth=, =thismonth-N= | a relative month      |
6468   | =thisyear=, =lastyear=, =thisyear-N=    | a relative year       |
6469   | =untilnow=[fn:77]                       | all clocked time ever |
6471   #+vindex: org-clock-display-default-range
6472   When this option is not set, Org falls back to the value in
6473   ~org-clock-display-default-range~, which defaults to the current
6474   year.
6476   Use {{{kbd(S-LEFT)}}} or {{{kbd(S-RIGHT)}}} to shift the time
6477   interval.
6479 - =:tstart= ::
6481   A time string specifying when to start considering times.  Relative
6482   times like ="<-2w>"= can also be used.  See [[*Matching tags and
6483   properties]] for relative time syntax.
6485 - =:tend= ::
6487   A time string specifying when to stop considering times.  Relative
6488   times like ="<now>"= can also be used.  See [[*Matching tags and
6489   properties]] for relative time syntax.
6491 - =:wstart= ::
6493   The starting day of the week.  The default is 1 for Monday.
6495 - =:mstart= ::
6497   The starting day of the month.  The default is 1 for the first.
6499 - =:step= ::
6501   Set to =day=, =week=, =month= or =year= to split the table into
6502   chunks.  To use this, either =:block=, or =:tstart= and =:tend= are
6503   required.
6505 - =:stepskip0= ::
6507   When non-~nil~, do not show steps that have zero time.
6509 - =:fileskip0= ::
6511   When non-~nil~, do not show table sections from files which did not
6512   contribute.
6514 - =:match= ::
6516   A tags match to select entries that should contribute.  See
6517   [[*Matching tags and properties]] for the match syntax.
6519 #+findex: org-clocktable-write-default
6520 Then there are options that determine the formatting of the table.
6521 There options are interpreted by the function
6522 ~org-clocktable-write-default~, but you can specify your own function
6523 using the =:formatter= parameter.
6525 - =:emphasize= ::
6527   When non-~nil~, emphasize level one and level two items.
6529 - =:lang= ::
6531   Language[fn:78] to use for descriptive cells like "Task".
6533 - =:link= ::
6535   Link the item headlines in the table to their origins.
6537 - =:narrow= ::
6539   An integer to limit the width of the headline column in the Org
6540   table.  If you write it like =50!=, then the headline is also
6541   shortened in export.
6543 - =:indent= ::
6545   Indent each headline field according to its level.
6547 - =:tcolumns= ::
6549   Number of columns to be used for times.  If this is smaller than
6550   =:maxlevel=, lower levels are lumped into one column.
6552 - =:level= ::
6554   Should a level number column be included?
6556 - =:sort= ::
6558   A cons cell containing the column to sort and a sorting type.  E.g.,
6559   =:sort (1 . ?a)= sorts the first column alphabetically.
6561 - =:compact= ::
6563   Abbreviation for =:level nil :indent t :narrow 40! :tcolumns 1=.
6564   All are overwritten except if there is an explicit =:narrow=.
6566 - =:timestamp= ::
6568   A timestamp for the entry, when available.  Look for =SCHEDULED=,
6569   =DEADLINE=, =TIMESTAMP= and =TIMESTAMP_IA= special properties (see
6570   [[*Special Properties]]), in this order.
6572 - =:tags= ::
6574   When this flag is non-~nil~, show the headline's tags.
6576 - =:properties= ::
6578   List of properties shown in the table.  Each property gets its own
6579   column.
6581 - =:inherit-props= ::
6583   When this flag is non-~nil~, the values for =:properties= are
6584   inherited.
6586 - =:formula= ::
6588   Content of a =TBLFM= keyword to be added and evaluated.  As
6589   a special case, =:formula %= adds a column with % time.  If you do
6590   not specify a formula here, any existing formula below the clock
6591   table survives updates and is evaluated.
6593 - =:formatter= ::
6595   A function to format clock data and insert it into the buffer.
6597 To get a clock summary of the current level 1 tree, for the current
6598 day, you could write:
6600 #+begin_example
6601 ,#+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
6602 ,#+END: clocktable
6603 #+end_example
6605 #+texinfo: @noindent
6606 To use a specific time range you could write[fn:79]
6608 #+begin_example
6609 ,#+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
6610                     :tend "<2006-08-10 Thu 12:00>"
6611 ,#+END: clocktable
6612 #+end_example
6614 #+texinfo: @noindent
6615 A range starting a week ago and ending right now could be written as
6617 #+begin_example
6618 ,#+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
6619 ,#+END: clocktable
6620 #+end_example
6622 #+texinfo: @noindent
6623 A summary of the current subtree with % times would be
6625 #+begin_example
6626 ,#+BEGIN: clocktable :scope subtree :link t :formula %
6627 ,#+END: clocktable
6628 #+end_example
6630 #+texinfo: @noindent
6631 A horizontally compact representation of everything clocked during
6632 last week would be
6634 #+begin_example
6635 ,#+BEGIN: clocktable :scope agenda :block lastweek :compact t
6636 ,#+END: clocktable
6637 #+end_example
6639 *** Resolving idle time and continuous clocking
6640 :PROPERTIES:
6641 :DESCRIPTION: Resolving time when you've been idle.
6642 :ALT_TITLE: Resolving idle time
6643 :END:
6645 **** Resolving idle time
6646 :PROPERTIES:
6647 :UNNUMBERED: notoc
6648 :END:
6650 #+cindex: resolve idle time
6651 #+cindex: idle, resolve, dangling
6653 If you clock in on a work item, and then walk away from your
6654 computer---perhaps to take a phone call---you often need to
6655 "resolve" the time you were away by either subtracting it from the
6656 current clock, or applying it to another one.
6658 #+vindex: org-clock-idle-time
6659 #+vindex: org-clock-x11idle-program-name
6660 By customizing the variable ~org-clock-idle-time~ to some integer,
6661 such as 10 or 15, Emacs can alert you when you get back to your
6662 computer after being idle for that many minutes[fn:80], and ask what
6663 you want to do with the idle time.  There will be a question waiting
6664 for you when you get back, indicating how much idle time has passed
6665 constantly updated with the current amount, as well as a set of
6666 choices to correct the discrepancy:
6668 - {{{kbd(k)}}} ::
6670   #+kindex: k
6671   To keep some or all of the minutes and stay clocked in, press
6672   {{{kbd(k)}}}.  Org asks how many of the minutes to keep.  Press
6673   {{{kbd(RET)}}} to keep them all, effectively changing nothing, or
6674   enter a number to keep that many minutes.
6676 - {{{kbd(K)}}} ::
6678   #+kindex: K
6679   If you use the shift key and press {{{kbd(K)}}}, it keeps however
6680   many minutes you request and then immediately clock out of that
6681   task.  If you keep all of the minutes, this is the same as just
6682   clocking out of the current task.
6684 - {{{kbd(s)}}} ::
6686   #+kindex: s
6687   To keep none of the minutes, use {{{kbd(s)}}} to subtract all the
6688   away time from the clock, and then check back in from the moment you
6689   returned.
6691 - {{{kbd(S)}}} ::
6693   #+kindex: S
6694   To keep none of the minutes and just clock out at the start of the
6695   away time, use the shift key and press {{{kbd(S)}}}.  Remember that
6696   using shift always leave you clocked out, no matter which option you
6697   choose.
6699 - {{{kbd(C)}}} ::
6701   #+kindex: C
6702   To cancel the clock altogether, use {{{kbd(C)}}}.  Note that if
6703   instead of canceling you subtract the away time, and the resulting
6704   clock amount is less than a minute, the clock is still canceled
6705   rather than cluttering up the log with an empty entry.
6707 What if you subtracted those away minutes from the current clock, and
6708 now want to apply them to a new clock?  Simply clock in to any task
6709 immediately after the subtraction.  Org will notice that you have
6710 subtracted time "on the books", so to speak, and will ask if you want
6711 to apply those minutes to the next task you clock in on.
6713 There is one other instance when this clock resolution magic occurs.
6714 Say you were clocked in and hacking away, and suddenly your cat chased
6715 a mouse who scared a hamster that crashed into your UPS's power
6716 button!  You suddenly lose all your buffers, but thanks to auto-save
6717 you still have your recent Org mode changes, including your last clock
6720 If you restart Emacs and clock into any task, Org will notice that you
6721 have a dangling clock which was never clocked out from your last
6722 session.  Using that clock's starting time as the beginning of the
6723 unaccounted-for period, Org will ask how you want to resolve that
6724 time.  The logic and behavior is identical to dealing with away time
6725 due to idleness; it is just happening due to a recovery event rather
6726 than a set amount of idle time.
6728 You can also check all the files visited by your Org agenda for
6729 dangling clocks at any time using {{{kbd(M-x org-resolve-clocks
6730 RET)}}} (or {{{kbd(C-c C-x C-z)}}}).
6732 **** Continuous clocking
6733 :PROPERTIES:
6734 :UNNUMBERED: notoc
6735 :END:
6736 #+cindex: continuous clocking
6738 #+vindex: org-clock-continuously
6739 You may want to start clocking from the time when you clocked out the
6740 previous task.  To enable this systematically, set
6741 ~org-clock-continuously~ to non-~nil~.  Each time you clock in, Org
6742 retrieves the clock-out time of the last clocked entry for this
6743 session, and start the new clock from there.
6745 If you only want this from time to time, use three universal prefix
6746 arguments with ~org-clock-in~ and two {{{kbd(C-u C-u)}}} with
6747 ~org-clock-in-last~.
6749 ** Effort Estimates
6750 :PROPERTIES:
6751 :DESCRIPTION: Planning work effort in advance.
6752 :END:
6753 #+cindex: effort estimates
6754 #+cindex: @samp{EFFORT}, property
6755 #+vindex: org-effort-property
6757 If you want to plan your work in a very detailed way, or if you need
6758 to produce offers with quotations of the estimated work effort, you
6759 may want to assign effort estimates to entries.  If you are also
6760 clocking your work, you may later want to compare the planned effort
6761 with the actual working time, a great way to improve planning
6762 estimates.  Effort estimates are stored in a special property
6763 =EFFORT=.  You can set the effort for an entry with the following
6764 commands:
6766 - {{{kbd(C-c C-x e)}}}  (~org-set-effort~) ::
6768   #+kindex: C-c C-x e
6769   #+findex: org-set-effort
6770   Set the effort estimate for the current entry.  With a prefix
6771   argument, set it to the next allowed value---see below.  This
6772   command is also accessible from the agenda with the {{{kbd(e)}}}
6773   key.
6775 - {{{kbd(C-c C-x C-e)}}} (~org-clock-modify-effort-estimate~) ::
6777   #+kindex: C-c C-x C-e
6778   #+findex: org-clock-modify-effort-estimate
6779   Modify the effort estimate of the item currently being clocked.
6781 Clearly the best way to work with effort estimates is through column
6782 view (see [[*Column View]]).  You should start by setting up discrete
6783 values for effort estimates, and a =COLUMNS= format that displays
6784 these values together with clock sums---if you want to clock your
6785 time.  For a specific buffer you can use:
6787 #+begin_example
6788 ,#+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
6789 ,#+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort){:} %CLOCKSUM
6790 #+end_example
6792 #+texinfo: @noindent
6793 #+vindex: org-global-properties
6794 #+vindex: org-columns-default-format
6795 or, even better, you can set up these values globally by customizing
6796 the variables ~org-global-properties~ and
6797 ~org-columns-default-format~.  In particular if you want to use this
6798 setup also in the agenda, a global setup may be advised.
6800 The way to assign estimates to individual items is then to switch to
6801 column mode, and to use {{{kbd(S-RIGHT)}}} and {{{kbd(S-LEFT)}}} to
6802 change the value.  The values you enter are immediately summed up in
6803 the hierarchy.  In the column next to it, any clocked time is
6804 displayed.
6806 #+vindex: org-agenda-columns-add-appointments-to-effort-sum
6807 If you switch to column view in the daily/weekly agenda, the effort
6808 column summarizes the estimated work effort for each day[fn:81], and
6809 you can use this to find space in your schedule.  To get an overview
6810 of the entire part of the day that is committed, you can set the
6811 option ~org-agenda-columns-add-appointments-to-effort-sum~.  The
6812 appointments on a day that take place over a specified time interval
6813 are then also added to the load estimate of the day.
6815 Effort estimates can be used in secondary agenda filtering that is
6816 triggered with the {{{kbd(/)}}} key in the agenda (see [[*Commands in
6817 the Agenda Buffer]]).  If you have these estimates defined consistently,
6818 two or three key presses narrow down the list to stuff that fits into
6819 an available time slot.
6821 ** Taking Notes with a Relative Timer
6822 :PROPERTIES:
6823 :DESCRIPTION: Notes with a running timer.
6824 :ALT_TITLE: Timers
6825 :END:
6826 #+cindex: relative timer
6827 #+cindex: countdown timer
6829 Org provides two types of timers.  There is a relative timer that
6830 counts up, which can be useful when taking notes during, for example,
6831 a meeting or a video viewing.  There is also a countdown timer.
6833 The relative and countdown are started with separate commands.
6835 - {{{kbd(C-c C-x 0)}}} (~org-timer-start~) ::
6837   #+kindex: C-c C-x 0
6838   #+findex: org-timer-start
6839   Start or reset the relative timer.  By default, the timer is set
6840   to 0.  When called with a {{{kbd(C-u)}}} prefix, prompt the user for
6841   a starting offset.  If there is a timer string at point, this is
6842   taken as the default, providing a convenient way to restart taking
6843   notes after a break in the process.  When called with a double
6844   prefix argument {{{kbd(C-u C-u)}}}, change all timer strings in the
6845   active region by a certain amount.  This can be used to fix timer
6846   strings if the timer was not started at exactly the right moment.
6848 - {{{kbd(C-c C-x ;)}}} (~org-timer-set-timer~) ::
6850   #+kindex: C-c C-x ;
6851   #+findex: org-timer-set-timer
6852   #+vindex: org-timer-default-timer
6853   Start a countdown timer.  The user is prompted for a duration.
6854   ~org-timer-default-timer~ sets the default countdown value.  Giving
6855   a numeric prefix argument overrides this default value.  This
6856   command is available as {{{kbd(;)}}} in agenda buffers.
6858 Once started, relative and countdown timers are controlled with the
6859 same commands.
6861 - {{{kbd(C-c C-x .)}}} (~org-timer~) ::
6863   #+kindex: C-c C-x .
6864   #+findex: org-timer
6865   Insert a relative time into the buffer.  The first time you use
6866   this, the timer starts.  Using a prefix argument restarts it.
6868 - {{{kbd(C-c C-x -)}}} (~org-timer-item~) ::
6870   #+kindex: C-c C-x -
6871   #+findex: org-timer-item
6872   Insert a description list item with the current relative time.  With
6873   a prefix argument, first reset the timer to 0.
6875 - {{{kbd(M-RET)}}} (~org-insert-heading~) ::
6877   #+kindex: M-RET
6878   #+findex: org-insert-heading
6879   Once the timer list is started, you can also use {{{kbd(M-RET)}}} to
6880   insert new timer items.
6882 - {{{kbd(C-c C-x \,)}}} (~org-timer-pause-or-continue~) ::
6884   #+kindex: C-c C-x ,
6885   #+findex: org-timer-pause-or-continue
6886   Pause the timer, or continue it if it is already paused.
6888 - {{{kbd(C-c C-x _)}}} (~org-timer-stop~) ::
6890   #+kindex: C-c C-x _
6891   #+findex: org-timer-stop
6892   Stop the timer.  After this, you can only start a new timer, not
6893   continue the old one.  This command also removes the timer from the
6894   mode line.
6896 * Capture, Refile, Archive
6897 :PROPERTIES:
6898 :DESCRIPTION: The ins and outs for projects.
6899 :END:
6900 #+cindex: capture
6902 An important part of any organization system is the ability to quickly
6903 capture new ideas and tasks, and to associate reference material with
6904 them.  Org does this using a process called /capture/.  It also can
6905 store files related to a task (/attachments/) in a special directory.
6906 Once in the system, tasks and projects need to be moved around.
6907 Moving completed project trees to an archive file keeps the system
6908 compact and fast.
6910 ** Capture
6911 :PROPERTIES:
6912 :DESCRIPTION: Capturing new stuff.
6913 :END:
6914 #+cindex: capture
6916 Capture lets you quickly store notes with little interruption of your
6917 work flow.  Org's method for capturing new items is heavily inspired
6918 by John Wiegley's excellent Remember package.
6920 *** Setting up capture
6921 :PROPERTIES:
6922 :DESCRIPTION: Where notes will be stored.
6923 :END:
6925 The following customization sets a default target file for notes.
6927 #+vindex: org-default-notes-file
6928 #+begin_src emacs-lisp
6929 (setq org-default-notes-file (concat org-directory "/notes.org"))
6930 #+end_src
6932 You may also define a global key for capturing new material (see
6933 [[*Activation]]).
6935 *** Using capture
6936 :PROPERTIES:
6937 :DESCRIPTION: Commands to invoke and terminate capture.
6938 :END:
6940 - {{{kbd(M-x org-capture)}}} (~org-capture~) ::
6942   #+findex: org-capture
6943   #+cindex: date tree
6944   Display the capture templates menu.  If you have templates defined
6945   (see [[*Capture templates]]), it offers these templates for selection or
6946   use a new Org outline node as the default template.  It inserts the
6947   template into the target file and switch to an indirect buffer
6948   narrowed to this new node.  You may then insert the information you
6949   want.
6951 - {{{kbd(C-c C-c)}}} (~org-capture-finalize~) ::
6953   #+kindex: C-c C-c @r{(Capture buffer)}
6954   #+findex: org-capture-finalize
6955   Once you have finished entering information into the capture buffer,
6956   {{{kbd(C-c C-c)}}} returns you to the window configuration before
6957   the capture process, so that you can resume your work without
6958   further distraction.  When called with a prefix argument, finalize
6959   and then jump to the captured item.
6961 - {{{kbd(C-c C-w)}}} (~org-capture-refile~) ::
6963   #+kindex: C-c C-w @r{(Capture buffer)}
6964   #+findex: org-capture-refile
6965   Finalize the capture process by refiling the note to a different
6966   place (see [[*Refile and Copy]]).  Please realize that this is a normal
6967   refiling command that will be executed---so point position at the
6968   moment you run this command is important.  If you have inserted
6969   a tree with a parent and children, first move point back to the
6970   parent.  Any prefix argument given to this command is passed on to
6971   the ~org-refile~ command.
6973 - {{{kbd(C-c C-k)}}} (~org-capture-kill~) ::
6975   #+kindex: C-c C-k @r{(Capture buffer)}
6976   #+findex: org-capture-kill
6977   Abort the capture process and return to the previous state.
6979 #+kindex: k c @r{(Agenda)}
6980 You can also call ~org-capture~ in a special way from the agenda,
6981 using the {{{kbd(k c)}}} key combination.  With this access, any
6982 timestamps inserted by the selected capture template defaults to the
6983 date at point in the agenda, rather than to the current date.
6985 To find the locations of the last stored capture, use ~org-capture~
6986 with prefix commands:
6988 - {{{kbd(C-u M-x org-capture)}}} ::
6990   Visit the target location of a capture template.  You get to select
6991   the template in the usual way.
6993 - {{{kbd(C-u C-u M-x org-capture)}}} ::
6995   Visit the last stored capture item in its buffer.
6997 #+vindex: org-capture-bookmark
6998 #+vindex: org-capture-last-stored
6999 You can also jump to the bookmark ~org-capture-last-stored~, which is
7000 automatically created unless you set ~org-capture-bookmark~ to ~nil~.
7002 To insert the capture at point in an Org buffer, call ~org-capture~
7003 with a {{{kbd(C-0)}}} prefix argument.
7005 *** Capture templates
7006 :PROPERTIES:
7007 :DESCRIPTION: Define the outline of different note types.
7008 :END:
7009 #+cindex: templates, for Capture
7011 You can use templates for different types of capture items, and for
7012 different target locations.  The easiest way to create such templates
7013 is through the customize interface.
7015 - {{{kbd(C)}}} ::
7017   #+kindex: C @r{(Capture menu}
7018   #+vindex: org-capture-templates
7019   Customize the variable ~org-capture-templates~.
7021 Before we give the formal description of template definitions, let's
7022 look at an example.  Say you would like to use one template to create
7023 general TODO entries, and you want to put these entries under the
7024 heading =Tasks= in your file =~/org/gtd.org=.  Also, a date tree in
7025 the file =journal.org= should capture journal entries.  A possible
7026 configuration would look like:
7028 #+begin_src emacs-lisp
7029 (setq org-capture-templates
7030       '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
7031          "* TODO %?\n  %i\n  %a")
7032         ("j" "Journal" entry (file+datetree "~/org/journal.org")
7033          "* %?\nEntered on %U\n  %i\n  %a")))
7034 #+end_src
7036 If you then press {{{kbd(t)}}} from the capture menu, Org will prepare
7037 the template for you like this:
7039 #+begin_example
7040 ,* TODO
7041   [[file:LINK TO WHERE YOU INITIATED CAPTURE]]
7042 #+end_example
7044 #+texinfo: @noindent
7045 During expansion of the template, =%a= has been replaced by a link to
7046 the location from where you called the capture command.  This can be
7047 extremely useful for deriving tasks from emails, for example.  You
7048 fill in the task definition, press {{{kbd(C-c C-c)}}} and Org returns
7049 you to the same place where you started the capture process.
7051 To define special keys to capture to a particular template without
7052 going through the interactive template selection, you can create your
7053 key binding like this:
7055 #+begin_src emacs-lisp
7056 (define-key global-map "\C-cx"
7057   (lambda () (interactive) (org-capture nil "x")))
7058 #+end_src
7060 **** Template elements
7061 :PROPERTIES:
7062 :DESCRIPTION: What is needed for a complete template entry.
7063 :END:
7065 Now lets look at the elements of a template definition.  Each entry in
7066 ~org-capture-templates~ is a list with the following items:
7068 - keys ::
7070   The keys that selects the template, as a string, characters only,
7071   for example ="a"=, for a template to be selected with a single key,
7072   or ="bt"= for selection with two keys.  When using several keys,
7073   keys using the same prefix key must be sequential in the list and
7074   preceded by a 2-element entry explaining the prefix key, for
7075   example:
7077   #+begin_src emacs-lisp
7078   ("b" "Templates for marking stuff to buy")
7079   #+end_src
7081   If you do not define a template for the {{{kbd(C)}}} key, this key
7082   opens the Customize buffer for this complex variable.
7084 - description ::
7086   A short string describing the template, shown during selection.
7088 - type ::
7090   The type of entry, a symbol.  Valid values are:
7092   - ~entry~ ::
7094     An Org mode node, with a headline.  Will be filed as the child of
7095     the target entry or as a top-level entry.  The target file should
7096     be an Org file.
7098   - ~item~ ::
7100     A plain list item, placed in the first plain list at the target
7101     location.  Again the target file should be an Org file.
7103   - ~checkitem~ ::
7105     A checkbox item.  This only differs from the plain list item by
7106     the default template.
7108   - ~table-line~ ::
7110     A new line in the first table at the target location.  Where
7111     exactly the line will be inserted depends on the properties
7112     ~:prepend~ and ~:table-line-pos~ (see below).
7114   - ~plain~ ::
7116     Text to be inserted as it is.
7118 - target ::
7120   #+vindex: org-default-notes-file
7121   #+vindex: org-directory
7122   Specification of where the captured item should be placed.  In Org
7123   files, targets usually define a node.  Entries will become children
7124   of this node.  Other types will be added to the table or list in the
7125   body of this node.  Most target specifications contain a file name.
7126   If that file name is the empty string, it defaults to
7127   ~org-default-notes-file~.  A file can also be given as a variable or
7128   as a function called with no argument.  When an absolute path is not
7129   specified for a target, it is taken as relative to ~org-directory~.
7131   Valid values are:
7133   - =(file "path/to/file")= ::
7135     Text will be placed at the beginning or end of that file.
7137   - =(id "id of existing org entry")= ::
7139     Filing as child of this entry, or in the body of the entry.
7141   - =(file+headline "filename" "node headline")= ::
7143     Fast configuration if the target heading is unique in the file.
7145   - =(file+olp "filename" "Level 1 heading" "Level 2" ...)= ::
7147     For non-unique headings, the full path is safer.
7149   - =(file+regexp "filename" "regexp to find location")= ::
7151     Use a regular expression to position point.
7153   - =(file+olp+datetree "filename" [ "Level 1 heading" ...])= ::
7155     This target[fn:82] creates a heading in a date tree[fn:83] for
7156     today's date.  If the optional outline path is given, the tree
7157     will be built under the node it is pointing to, instead of at top
7158     level.  Check out the ~:time-prompt~ and ~:tree-type~ properties
7159     below for additional options.
7161   - =(file+function "filename" function-finding-location)= ::
7163     A function to find the right location in the file.
7165   - =(clock)= ::
7167     File to the entry that is currently being clocked.
7169   - =(function function-finding-location)= ::
7171     Most general way: write your own function which both visits the
7172     file and moves point to the right location.
7174 - template ::
7176   The template for creating the capture item.  If you leave this
7177   empty, an appropriate default template will be used.  Otherwise this
7178   is a string with escape codes, which will be replaced depending on
7179   time and context of the capture call.  The string with escapes may
7180   be loaded from a template file, using the special syntax =(file
7181   "template filename")=.  See below for more details.
7183 - properties ::
7185   The rest of the entry is a property list of additional options.
7186   Recognized properties are:
7188   - ~:prepend~ ::
7190     Normally new captured information will be appended at the target
7191     location (last child, last table line, last list item, ...).
7192     Setting this property changes that.
7194   - ~:immediate-finish~ ::
7196     When set, do not offer to edit the information, just file it away
7197     immediately.  This makes sense if the template only needs
7198     information that can be added automatically.
7200   - ~:empty-lines~ ::
7202     Set this to the number of lines to insert before and after the new
7203     item.  Default 0, and the only other common value is 1.
7205   - ~:clock-in~ ::
7207     Start the clock in this item.
7209   - ~:clock-keep~ ::
7211     Keep the clock running when filing the captured entry.
7213   - ~:clock-resume~ ::
7215     If starting the capture interrupted a clock, restart that clock
7216     when finished with the capture.  Note that ~:clock-keep~ has
7217     precedence over ~:clock-resume~.  When setting both to non-~nil~,
7218     the current clock will run and the previous one will not be
7219     resumed.
7221   - ~:time-prompt~ ::
7223     Prompt for a date/time to be used for date/week trees and when
7224     filling the template.  Without this property, capture uses the
7225     current date and time.  Even if this property has not been set,
7226     you can force the same behavior by calling ~org-capture~ with
7227     a {{{kbd(C-1)}}} prefix argument.
7229   - ~:tree-type~ ::
7231     When ~week~, make a week tree instead of the month tree, i.e.,
7232     place the headings for each day under a heading with the current
7233     ISO week.
7235   - ~:unnarrowed~ ::
7237     Do not narrow the target buffer, simply show the full buffer.
7238     Default is to narrow it so that you only see the new material.
7240   - ~:table-line-pos~ ::
7242     Specification of the location in the table where the new line
7243     should be inserted.  It should be a string like =II-3= meaning
7244     that the new line should become the third line before the second
7245     horizontal separator line.
7247   - ~:kill-buffer~ ::
7249     If the target file was not yet visited when capture was invoked,
7250     kill the buffer again after capture is completed.
7252   - ~:no-save~ ::
7254     Do not save the target file after finishing the capture.
7256 **** Template expansion
7257 :PROPERTIES:
7258 :DESCRIPTION: Filling in information about time and context.
7259 :END:
7261 In the template itself, special "%-escapes"[fn:84] allow dynamic
7262 insertion of content.  The templates are expanded in the order given
7263 here:
7265 - =%[FILE]= ::
7267   Insert the contents of the file given by {{{var(FILE)}}}.
7269 - =%(EXP)= ::
7271   Evaluate Elisp expression {{{var(EXP)}}} and replace it with the
7272   result.  The {{{var(EXP)}}} form must return a string.  Only
7273   placeholders pre-existing within the template, or introduced with
7274   =%[file]=, are expanded this way.  Since this happens after
7275   expanding non-interactive "%-escapes", those can be used to fill the
7276   expression.
7278 - =%<FORMAT>= ::
7280   The result of format-time-string on the {{{var(FORMAT)}}}
7281   specification.
7283 - =%t= ::
7285   Timestamp, date only.
7287 - =%T= ::
7289   Timestamp, with date and time.
7291 - =%u=, =%U= ::
7293   Like =%t=, =%T= above, but inactive timestamps.
7295 - =%i= ::
7297   Initial content, the region when capture is called while the region
7298   is active.  If there is text before =%i= on the same line, such as
7299   indentation, and =%i= is not inside a =%(exp)= form, that prefix is
7300   added before every line in the inserted text.
7302 - =%a= ::
7304   Annotation, normally the link created with ~org-store-link~.
7306 - =%A= ::
7308   Like =%a=, but prompt for the description part.
7310 - =%l= ::
7312   Like =%a=, but only insert the literal link.
7314 - =%c= ::
7316   Current kill ring head.
7318 - =%x= ::
7320   Content of the X clipboard.
7322 - =%k= ::
7324   Title of the currently clocked task.
7326 - =%K= ::
7328   Link to the currently clocked task.
7330 - =%n= ::
7332   User name (taken from ~user-full-name~).
7334 - =%f= ::
7336   File visited by current buffer when org-capture was called.
7338 - =%F= ::
7340   Full path of the file or directory visited by current buffer.
7342 - =%:keyword= ::
7344   Specific information for certain link types, see below.
7346 - =%^g= ::
7348   Prompt for tags, with completion on tags in target file.
7350 - =%^G= ::
7352   Prompt for tags, with completion all tags in all agenda files.
7354 - =%^t= ::
7356   Like =%t=, but prompt for date.  Similarly =%^T=, =%^u=, =%^U=.  You
7357   may define a prompt like =%^{Birthday}t=.
7359 - =%^C= ::
7361   Interactive selection of which kill or clip to use.
7363 - =%^L= ::
7365   Like =%^C=, but insert as link.
7367 - =%^{PROP}p= ::
7369   Prompt the user for a value for property {{{var(PROP)}}}.
7371 - =%^{PROMPT}= ::
7373   Prompt the user for a string and replace this sequence with it.  You
7374   may specify a default value and a completion table with
7375   =%^{prompt|default|completion2|completion3...}=.  The arrow keys
7376   access a prompt-specific history.
7378 - =%\N= ::
7380   Insert the text entered at the {{{var(N)}}}th =%^{PROMPT}=, where
7381   {{{var(N)}}} is a number, starting from 1.
7383 - =%?= ::
7385   After completing the template, position point here.
7387 #+vindex: org-store-link-props
7388 For specific link types, the following keywords are defined[fn:85]:
7390 #+vindex: org-link-from-user-regexp
7391 | Link type    | Available keywords                                       |
7392 |--------------+----------------------------------------------------------|
7393 | bbdb         | =%:name=, =%:company=                                    |
7394 | irc          | =%:server=, =%:port=, =%:nick=                           |
7395 | mh, rmail    | =%:type=, =%:subject=, =%:message-id=                    |
7396 |              | =%:from=, =%:fromname=, =%:fromaddress=                  |
7397 |              | =%:to=, =%:toname=, =%:toaddress=                        |
7398 |              | =%:date= (message date header field)                     |
7399 |              | =%:date-timestamp= (date as active timestamp)            |
7400 |              | =%:date-timestamp-inactive= (date as inactive timestamp) |
7401 |              | =%:fromto= (either "to NAME" or "from NAME")[fn:86]      |
7402 | gnus         | =%:group=, for messages also all email fields            |
7403 | w3, w3m      | =%:url=                                                  |
7404 | info         | =%:file=, =%:node=                                       |
7405 | calendar     | =%:date=                                                 |
7406 | org-protocol | =%:link=, =%:description=, =%:annotation=                |
7408 **** Templates in contexts
7409 :PROPERTIES:
7410 :DESCRIPTION: Only show a template in a specific context.
7411 :END:
7413 #+vindex: org-capture-templates-contexts
7414 To control whether a capture template should be accessible from
7415 a specific context, you can customize
7416 ~org-capture-templates-contexts~.  Let's say, for example, that you
7417 have a capture template "p" for storing Gnus emails containing
7418 patches.  Then you would configure this option like this:
7420 #+begin_src emacs-lisp
7421 (setq org-capture-templates-contexts
7422       '(("p" (in-mode . "message-mode"))))
7423 #+end_src
7425 You can also tell that the command key {{{kbd(p)}}} should refer to
7426 another template.  In that case, add this command key like this:
7428 #+begin_src emacs-lisp
7429 (setq org-capture-templates-contexts
7430       '(("p" "q" (in-mode . "message-mode"))))
7431 #+end_src
7433 See the docstring of the variable for more information.
7435 ** Attachments
7436 :PROPERTIES:
7437 :DESCRIPTION: Add files to tasks.
7438 :END:
7439 #+cindex: attachments
7440 #+vindex: org-attach-directory
7442 It is often useful to associate reference material with an outline
7443 node/task.  Small chunks of plain text can simply be stored in the
7444 subtree of a project.  Hyperlinks (see [[*Hyperlinks]]) can establish
7445 associations with files that live elsewhere on your computer or in the
7446 cloud, like emails or source code files belonging to a project.
7447 Another method is /attachments/, which are files located in
7448 a directory belonging to an outline node.  Org uses directories named
7449 by the unique ID of each entry.  These directories are located in the
7450 =data/= directory which lives in the same directory where your Org
7451 file lives[fn:87].  If you initialize this directory with =git init=,
7452 Org automatically commits changes when it sees them.  The attachment
7453 system has been contributed to Org by John Wiegley.
7455 In cases where it seems better to do so, you can attach a directory of
7456 your choice to an entry.  You can also make children inherit the
7457 attachment directory from a parent, so that an entire subtree uses the
7458 same attached directory.
7460 The following commands deal with attachments:
7462 - {{{kbd(C-c C-a)}}} (~org-attach~) ::
7464   #+kindex: C-c C-a
7465   #+findex: org-attach
7466   The dispatcher for commands related to the attachment system.  After
7467   these keys, a list of commands is displayed and you must press an
7468   additional key to select a command:
7470   - {{{kbd(a)}}} (~org-attach-attach~) ::
7472     #+kindex: C-c C-a a
7473     #+findex: org-attach-attach
7474     #+vindex: org-attach-method
7475     Select a file and move it into the task's attachment directory.
7476     The file is copied, moved, or linked, depending on
7477     ~org-attach-method~.  Note that hard links are not supported on
7478     all systems.
7480   - {{{kbd(c)}}}/{{{kbd(m)}}}/{{{kbd(l)}}} ::
7482     #+kindex: C-c C-a c
7483     #+kindex: C-c C-a m
7484     #+kindex: C-c C-a l
7485     Attach a file using the copy/move/link method.  Note that hard
7486     links are not supported on all systems.
7488   - {{{kbd(b)}}} (~org-attach-buffer~) ::
7490     #+kindex: C-c C-a b
7491     #+findex: org-attach-buffer
7492     Select a buffer and save it as a file in the task's attachment
7493     directory.
7495   - {{{kbd(n)}}} (~org-attach-new~) ::
7497     #+kindex: C-c C-a n
7498     #+findex: org-attach-new
7499     Create a new attachment as an Emacs buffer.
7501   - {{{kbd(z)}}} (~org-attach-sync~) ::
7503     #+kindex: C-c C-a z
7504     #+findex: org-attach-sync
7505     Synchronize the current task with its attachment directory, in
7506     case you added attachments yourself.
7508   - {{{kbd(o)}}} (~org-attach-open~) ::
7510     #+kindex: C-c C-a o
7511     #+findex: org-attach-open
7512     #+vindex: org-file-apps
7513     Open current task's attachment.  If there is more than one, prompt
7514     for a file name first.  Opening follows the rules set by
7515     ~org-file-apps~.  For more details, see the information on
7516     following hyperlinks (see [[*Handling Links]]).
7518   - {{{kbd(O)}}} (~org-attach-open-in-emacs~) ::
7520     #+kindex: C-c C-a O
7521     #+findex: org-attach-open-in-emacs
7522     Also open the attachment, but force opening the file in Emacs.
7524   - {{{kbd(f)}}} (~org-attach-reveal~) ::
7526     #+kindex: C-c C-a f
7527     #+findex: org-attach-reveal
7528     Open the current task's attachment directory.
7530   - {{{kbd(F)}}} (~org-attach-reveal-in-emacs~) ::
7532     #+kindex: C-c C-a F
7533     #+findex: org-attach-reveal-in-emacs
7534     Also open the directory, but force using Dired in Emacs.
7536   - {{{kbd(d)}}} (~org-attach-delete-one~) ::
7538     #+kindex: C-c C-a d
7539     Select and delete a single attachment.
7541   - {{{kbd(D)}}} (~org-attach-delete-all~) ::
7543     #+kindex: C-c C-a D
7544     Delete all of a task's attachments.  A safer way is to open the
7545     directory in Dired and delete from there.
7547   - {{{kbd(s)}}} (~org-attach-set-directory~) ::
7549     #+kindex: C-c C-a s
7550     #+cindex: @samp{ATTACH_DIR}, property
7551     Set a specific directory as the entry's attachment directory.
7552     This works by putting the directory path into the =ATTACH_DIR=
7553     property.
7555   - {{{kbd(i)}}} (~org-attach-set-inherit~) ::
7557     #+kindex: C-c C-a i
7558     #+cindex: @samp{ATTACH_DIR_INHERIT}, property
7559     Set the =ATTACH_DIR_INHERIT= property, so that children use the
7560     same directory for attachments as the parent does.
7562 #+cindex: attach from Dired
7563 #+findex: org-attach-dired-to-subtree
7564 It is possible to attach files to a subtree from a Dired buffer.  To
7565 use this feature, have one window in Dired mode containing the file(s)
7566 to be attached and another window with point in the subtree that shall
7567 get the attachments.  In the Dired window, with point on a file,
7568 {{{kbd(M-x org-attach-dired-to-subtree)}}} attaches the file to the
7569 subtree using the attachment method set by variable
7570 ~org-attach-method~.  When files are marked in the Dired window then
7571 all marked files get attached.
7573 Add the following lines to the Emacs init file to have {{{kbd(C-c C-x
7574 a)}}} attach files in Dired buffers.
7576 #+begin_src emacs-lisp
7577 (add-hook 'dired-mode-hook
7578           (lambda ()
7579             (define-key dired-mode-map
7580               (kbd "C-c C-x a")
7581               #'org-attach-dired-to-subtree)))
7582 #+end_src
7584 The following code shows how to bind the previous command with
7585 a specific attachment method.
7587 #+begin_src emacs-lisp
7588 (add-hook 'dired-mode-hook
7589           (lambda ()
7590             (define-key dired-mode-map (kbd "C-c C-x c")
7591               (lambda ()
7592                 (interactive)
7593                 (let ((org-attach-method 'cp))
7594                   (call-interactively #'org-attach-dired-to-subtree))))))
7595 #+end_src
7597 ** RSS Feeds
7598 :PROPERTIES:
7599 :DESCRIPTION: Getting input from RSS feeds.
7600 :END:
7601 #+cindex: RSS feeds
7602 #+cindex: Atom feeds
7604 Org can add and change entries based on information found in RSS feeds
7605 and Atom feeds.  You could use this to make a task out of each new
7606 podcast in a podcast feed.  Or you could use a phone-based
7607 note-creating service on the web to import tasks into Org.  To access
7608 feeds, configure the variable ~org-feed-alist~.  The docstring of this
7609 variable has detailed information.  With the following
7611 #+begin_src emacs-lisp
7612 (setq org-feed-alist
7613       '(("Slashdot"
7614          "http://rss.slashdot.org/Slashdot/slashdot"
7615          "~/txt/org/feeds.org" "Slashdot Entries")))
7616 #+end_src
7618 #+texinfo: @noindent
7619 new items from the feed provided by =rss.slashdot.org= result in new
7620 entries in the file =~/org/feeds.org= under the heading =Slashdot
7621 Entries=, whenever the following command is used:
7623 - {{{kbd(C-c C-x g)}}} (~org-feed-update-all~) ::
7625   #+kindex: C-c C-x g
7626   Collect items from the feeds configured in ~org-feed-alist~ and act
7627   upon them.
7629 - {{{kbd(C-c C-x G)}}} (~org-feed-goto-inbox~) ::
7631   #+kindex: C-c C-x G
7632   Prompt for a feed name and go to the inbox configured for this feed.
7634 Under the same headline, Org creates a drawer =FEEDSTATUS= in which it
7635 stores information about the status of items in the feed, to avoid
7636 adding the same item several times.
7638 For more information, including how to read atom feeds, see
7639 =org-feed.el= and the docstring of ~org-feed-alist~.
7641 ** Protocols for External Access
7642 :PROPERTIES:
7643 :DESCRIPTION: External access to Emacs and Org.
7644 :ALT_TITLE: Protocols
7645 :END:
7646 #+cindex: protocols, for external access
7648 Org protocol is a means to trigger custom actions in Emacs from
7649 external applications.  Any application that supports calling external
7650 programs with an URL as argument may be used with this functionality.
7651 For example, you can configure bookmarks in your web browser to send
7652 a link to the current page to Org and create a note from it using
7653 capture (see [[*Capture]]).  You can also create a bookmark that tells
7654 Emacs to open the local source file of a remote website you are
7655 browsing.
7657 #+cindex: Org protocol, set-up
7658 #+cindex: Installing Org protocol
7659 In order to use Org protocol from an application, you need to register
7660 =org-protocol://= as a valid scheme-handler.  External calls are
7661 passed to Emacs through the =emacsclient= command, so you also need to
7662 ensure an Emacs server is running.  More precisely, when the
7663 application calls
7665 : emacsclient org-protocol://PROTOCOL?key1=val1&key2=val2
7667 #+texinfo: @noindent
7668 Emacs calls the handler associated to {{{var(PROTOCOL)}}} with
7669 argument =(:key1 val1 :key2 val2)=.
7671 #+cindex: protocol, new protocol
7672 #+cindex: defining new protocols
7673 Org protocol comes with three predefined protocols, detailed in the
7674 following sections.  Configure ~org-protocol-protocol-alist~ to define
7675 your own.
7677 *** ~store-link~ protocol
7678 :PROPERTIES:
7679 :DESCRIPTION: Store a link, push URL to kill-ring.
7680 :END:
7681 #+cindex: store-link protocol
7682 #+cindex: protocol, store-link
7684 Using ~store-link~ handler, you can copy links, insertable through
7685 {{{kbd(M-x org-insert-link)}}} or yanking thereafter.  More precisely,
7686 the command
7688 : emacsclient org-protocol://store-link?url=URL&title=TITLE
7690 #+texinfo: @noindent
7691 stores the following link:
7693 : [[URL][TITLE]]
7695 In addition, {{{var(URL)}}} is pushed on the kill-ring for yanking.
7696 You need to encode {{{var(URL)}}} and {{{var(TITLE)}}} if they contain
7697 slashes, and probably quote those for the shell.
7699 To use this feature from a browser, add a bookmark with an arbitrary
7700 name, e.g., =Org: store-link= and enter this as /Location/:
7702 #+begin_example
7703 javascript:location.href='org-protocol://store-link?url='+
7704       encodeURIComponent(location.href);
7705 #+end_example
7707 *** ~capture~ protocol
7708 :PROPERTIES:
7709 :DESCRIPTION: Fill a buffer with external information.
7710 :END:
7711 #+cindex: capture protocol
7712 #+cindex: protocol, capture
7714 Activating "capture" handler pops up a =Capture= buffer and fills the
7715 capture template associated to the =X= key with them.
7717 : emacsclient org-protocol://capture?template=X?url=URL?title=TITLE?body=BODY
7719 To use this feature, add a bookmark with an arbitrary name, e.g.,
7720 =Org: capture=, and enter this as =Location=:
7722 #+begin_example
7723 javascript:location.href='org-protocol://capture?template=x'+
7724       '&url='+encodeURIComponent(window.location.href)+
7725       '&title='+encodeURIComponent(document.title)+
7726       '&body='+encodeURIComponent(window.getSelection());
7727 #+end_example
7729 #+vindex: org-protocol-default-template-key
7730 The result depends on the capture template used, which is set in the
7731 bookmark itself, as in the example above, or in
7732 ~org-protocol-default-template-key~.
7734 The following template placeholders are available:
7736 #+begin_example
7737 %:link          The URL
7738 %:description   The webpage title
7739 %:annotation    Equivalent to [[%:link][%:description]]
7740 %i              The selected text
7741 #+end_example
7743 *** ~open-source~ protocol
7744 :PROPERTIES:
7745 :DESCRIPTION: Edit published contents.
7746 :END:
7747 #+cindex: open-source protocol
7748 #+cindex: protocol, open-source
7750 The ~open-source~ handler is designed to help with editing local
7751 sources when reading a document.  To that effect, you can use
7752 a bookmark with the following location:
7754 #+begin_example
7755 javascript:location.href='org-protocol://open-source?&url='+
7756       encodeURIComponent(location.href)
7757 #+end_example
7759 #+vindex: org-protocol-project-alist
7760 The variable ~org-protocol-project-alist~ maps URLs to local file
7761 names, by stripping URL parameters from the end and replacing the
7762 ~:base-url~ with ~:working-directory~ and ~:online-suffix~ with
7763 ~:working-suffix~.  For example, assuming you own a local copy of
7764 =https://orgmode.org/worg/= contents at =/home/user/worg=, you can set
7765 ~org-protocol-project-alist~ to the following
7767 #+begin_src emacs-lisp
7768 (setq org-protocol-project-alist
7769       '(("Worg"
7770          :base-url "https://orgmode.org/worg/"
7771          :working-directory "/home/user/worg/"
7772          :online-suffix ".html"
7773          :working-suffix ".org")))
7774 #+end_src
7776 #+texinfo: @noindent
7777 If you are now browsing
7778 =https://orgmode.org/worg/org-contrib/org-protocol.html= and find
7779 a typo or have an idea about how to enhance the documentation, simply
7780 click the bookmark and start editing.
7782 #+cindex: rewritten URL in open-source protocol
7783 #+cindex: protocol, open-source rewritten URL
7784 However, such mapping may not yield the desired results.  Suppose you
7785 maintain an online store located at =http://example.com/=.  The local
7786 sources reside in =/home/user/example/=.  It is common practice to
7787 serve all products in such a store through one file and rewrite URLs
7788 that do not match an existing file on the server.  That way, a request
7789 to =http://example.com/print/posters.html= might be rewritten on the
7790 server to something like
7791 =http://example.com/shop/products.php/posters.html.php=.  The
7792 ~open-source~ handler probably cannot find a file named
7793 =/home/user/example/print/posters.html.php= and fails.
7795 Such an entry in ~org-protocol-project-alist~ may hold an additional
7796 property ~:rewrites~.  This property is a list of cons cells, each of
7797 which maps a regular expression to a path relative to the
7798 ~:working-directory~.
7800 Now map the URL to the path =/home/user/example/products.php= by
7801 adding ~:rewrites~ rules like this:
7803 #+begin_src emacs-lisp
7804 (setq org-protocol-project-alist
7805       '(("example.com"
7806          :base-url "http://example.com/"
7807          :working-directory "/home/user/example/"
7808          :online-suffix ".php"
7809          :working-suffix ".php"
7810          :rewrites (("example.com/print/" . "products.php")
7811                     ("example.com/$" . "index.php")))))
7812 #+end_src
7814 #+texinfo: @noindent
7815 Since =example.com/$= is used as a regular expression, it maps
7816 =http://example.com/=, =https://example.com=,
7817 =http://www.example.com/= and similar to
7818 =/home/user/example/index.php=.
7820 The ~:rewrites~ rules are searched as a last resort if and only if no
7821 existing file name is matched.
7823 #+cindex: protocol, open-source, set-up mapping
7824 #+cindex: mappings in open-source protocol
7825 #+findex: org-protocol-create
7826 #+findex: org-protocol-create-for-org
7827 Two functions can help you filling ~org-protocol-project-alist~ with
7828 valid contents: ~org-protocol-create~ and
7829 ~org-protocol-create-for-org~.  The latter is of use if you're editing
7830 an Org file that is part of a publishing project.
7832 ** Refile and Copy
7833 :PROPERTIES:
7834 :DESCRIPTION: Moving/copying a tree from one place to another.
7835 :END:
7836 #+cindex: refiling notes
7837 #+cindex: copying notes
7839 When reviewing the captured data, you may want to refile or to copy
7840 some of the entries into a different list, for example into a project.
7841 Cutting, finding the right location, and then pasting the note is
7842 cumbersome.  To simplify this process, you can use the following
7843 special command:
7845 - {{{kbd(C-c C-w)}}} (~org-refile~) ::
7847   #+kindex: C-c C-w
7848   #+findex: org-refile
7849   #+vindex: org-reverse-note-order
7850   #+vindex: org-refile-targets
7851   #+vindex: org-refile-use-outline-path
7852   #+vindex: org-outline-path-complete-in-steps
7853   #+vindex: org-refile-allow-creating-parent-nodes
7854   #+vindex: org-log-refile
7855   Refile the entry or region at point.  This command offers possible
7856   locations for refiling the entry and lets you select one with
7857   completion.  The item (or all items in the region) is filed below
7858   the target heading as a subitem.  Depending on
7859   ~org-reverse-note-order~, it is either the first or last subitem.
7861   By default, all level 1 headlines in the current buffer are
7862   considered to be targets, but you can have more complex definitions
7863   across a number of files.  See the variable ~org-refile-targets~ for
7864   details.  If you would like to select a location via
7865   a file-path-like completion along the outline path, see the
7866   variables ~org-refile-use-outline-path~ and
7867   ~org-outline-path-complete-in-steps~.  If you would like to be able
7868   to create new nodes as new parents for refiling on the fly, check
7869   the variable ~org-refile-allow-creating-parent-nodes~.  When the
7870   variable ~org-log-refile~[fn:88] is set, a timestamp or a note is
7871   recorded whenever an entry is refiled.
7873 - {{{kbd(C-u C-c C-w)}}} ::
7875   #+kindex: C-u C-c C-w
7876   Use the refile interface to jump to a heading.
7878 - {{{kbd(C-u C-u C-c C-w)}}} (~org-refile-goto-last-stored~) ::
7880   #+kindex: C-u C-u C-c C-w
7881   #+findex: org-refile-goto-last-stored
7882   Jump to the location where ~org-refile~ last moved a tree to.
7884 - {{{kbd(C-2 C-c C-w)}}} ::
7886   #+kindex: C-2 C-c C-w
7887   Refile as the child of the item currently being clocked.
7889 - {{{kbd(C-3 C-c C-w)}}} ::
7891   #+kindex: C-3 C-c C-w
7892   #+vindex: org-refile-keep
7893   Refile and keep the entry in place.  Also see ~org-refile-keep~ to
7894   make this the default behavior, and beware that this may result in
7895   duplicated =ID= properties.
7897 - {{{kbd(C-0 C-c C-w)}}} or {{{kbd(C-u C-u C-u C-c C-w)}}} (~org-refile-cache-clear~) ::
7899   #+kindex: C-u C-u C-u C-c C-w
7900   #+kindex: C-0 C-c C-w
7901   #+findex: org-refile-cache-clear
7902   #+vindex: org-refile-use-cache
7903   Clear the target cache.  Caching of refile targets can be turned on
7904   by setting ~org-refile-use-cache~.  To make the command see new
7905   possible targets, you have to clear the cache with this command.
7907 - {{{kbd(C-c M-w)}}} (~org-copy~) ::
7909   #+kindex: C-c M-w
7910   #+findex: org-copy
7911   Copying works like refiling, except that the original note is not
7912   deleted.
7914 ** Archiving
7915 :PROPERTIES:
7916 :DESCRIPTION: What to do with finished products.
7917 :END:
7918 #+cindex: archiving
7920 When a project represented by a (sub)tree is finished, you may want to
7921 move the tree out of the way and to stop it from contributing to the
7922 agenda.  Archiving is important to keep your working files compact and
7923 global searches like the construction of agenda views fast.
7925 - {{{kbd(C-c C-x C-a)}}} (~org-archive-subtree-default~) ::
7927   #+kindex: C-c C-x C-a
7928   #+findex: org-archive-subtree-default
7929   #+vindex: org-archive-default-command
7930   Archive the current entry using the command specified in the
7931   variable ~org-archive-default-command~.
7933 *** Moving a tree to an archive file
7934 :PROPERTIES:
7935 :DESCRIPTION: Moving a tree to an archive file.
7936 :ALT_TITLE: Moving subtrees
7937 :END:
7938 #+cindex: external archiving
7940 The most common archiving action is to move a project tree to another
7941 file, the archive file.
7943 - {{{kbd(C-c C-x C-s)}}} or short {{{kbd(C-c $)}}} (~org-archive-subtree~) ::
7945   #+kindex: C-c C-x C-s
7946   #+kindex: C-c $
7947   #+findex: org-archive-subtree
7948   #+vindex: org-archive-location
7949   Archive the subtree starting at point position to the location given
7950   by ~org-archive-location~.
7952 - {{{kbd(C-u C-c C-x C-s)}}} ::
7954   #+kindex: C-u C-c C-x C-s
7955   Check if any direct children of the current headline could be moved
7956   to the archive.  To do this, check each subtree for open TODO
7957   entries.  If none is found, the command offers to move it to the
7958   archive location.  If point is /not/ on a headline when this command
7959   is invoked, check level 1 trees.
7961 - {{{kbd(C-u C-u C-c C-x C-s)}}} ::
7963   #+kindex: C-u C-u C-c C-x C-s
7964   As above, but check subtree for timestamps instead of TODO entries.
7965   The command offers to archive the subtree if it /does/ contain
7966   a timestamp, and that timestamp is in the past.
7968 #+cindex: archive locations
7969 The default archive location is a file in the same directory as the
7970 current file, with the name derived by appending =_archive= to the
7971 current file name.  You can also choose what heading to file archived
7972 items under, with the possibility to add them to a datetree in a file.
7973 For information and examples on how to specify the file and the
7974 heading, see the documentation string of the variable
7975 ~org-archive-location~.
7977 There is also an in-buffer option for setting this variable, for
7978 example:
7980 #+cindex: @samp{ARCHIVE}, keyword
7981 : #+ARCHIVE: %s_done::
7983 #+cindex: ARCHIVE, property
7984 If you would like to have a special archive location for a single
7985 entry or a (sub)tree, give the entry an =ARCHIVE= property with the
7986 location as the value (see [[*Properties and Columns]]).
7988 #+vindex: org-archive-save-context-info
7989 When a subtree is moved, it receives a number of special properties
7990 that record context information like the file from where the entry
7991 came, its outline path the archiving time etc.  Configure the variable
7992 ~org-archive-save-context-info~ to adjust the amount of information
7993 added.
7995 *** Internal archiving
7996 :PROPERTIES:
7997 :DESCRIPTION: Switch off a tree but keep it in the file.
7998 :END:
8000 #+cindex: @samp{ARCHIVE}, tag
8001 If you want to just switch off---for agenda views---certain subtrees
8002 without moving them to a different file, you can use the =ARCHIVE=
8003 tag.
8005 A headline that is marked with the =ARCHIVE= tag (see [[*Tags]]) stays at
8006 its location in the outline tree, but behaves in the following way:
8009   #+vindex: org-cycle-open-archived-trees
8010   It does not open when you attempt to do so with a visibility cycling
8011   command (see [[*Visibility Cycling]]).  You can force cycling archived
8012   subtrees with {{{kbd(C-TAB)}}}, or by setting the option
8013   ~org-cycle-open-archived-trees~.  Also normal outline commands, like
8014   ~outline-show-all~, open archived subtrees.
8017   #+vindex: org-sparse-tree-open-archived-trees
8018   During sparse tree construction (see [[*Sparse Trees]]), matches in
8019   archived subtrees are not exposed, unless you configure the option
8020   ~org-sparse-tree-open-archived-trees~.
8023   #+vindex: org-agenda-skip-archived-trees
8024   During agenda view construction (see [[*Agenda Views]]), the content of
8025   archived trees is ignored unless you configure the option
8026   ~org-agenda-skip-archived-trees~, in which case these trees are
8027   always included.  In the agenda you can press {{{kbd(v a)}}} to get
8028   archives temporarily included.
8031   #+vindex: org-export-with-archived-trees
8032   Archived trees are not exported (see [[*Exporting]]), only the headline
8033   is.  Configure the details using the variable
8034   ~org-export-with-archived-trees~.
8037   #+vindex: org-columns-skip-archived-trees
8038   Archived trees are excluded from column view unless the variable
8039   ~org-columns-skip-archived-trees~ is configured to ~nil~.
8041 The following commands help manage the =ARCHIVE= tag:
8043 - {{{kbd(C-c C-x a)}}} (~org-toggle-archive-tag~) ::
8045   #+kindex: C-c C-x a
8046   #+findex: org-toggle-archive-tag
8047   Toggle the archive tag for the current headline.  When the tag is
8048   set, the headline changes to a shadowed face, and the subtree below
8049   it is hidden.
8051 - {{{kbd(C-u C-c C-x a)}}} ::
8053   #+kindex: C-u C-c C-x a
8054   Check if any direct children of the current headline should be
8055   archived.  To do this, check each subtree for open TODO entries.  If
8056   none is found, the command offers to set the =ARCHIVE= tag for the
8057   child.  If point is /not/ on a headline when this command is
8058   invoked, check the level 1 trees.
8060 - {{{kbd(C-TAB)}}} (~org-force-cycle-archived~) ::
8062   #+kindex: C-TAB
8063   Cycle a tree even if it is tagged with =ARCHIVE=.
8065 - {{{kbd(C-c C-x A)}}} (~org-archive-to-archive-sibling~) ::
8067   #+kindex: C-c C-x A
8068   #+findex: org-archive-to-archive-sibling
8069   Move the current entry to the /Archive Sibling/.  This is a sibling
8070   of the entry with the heading =Archive= and the archive tag.  The
8071   entry becomes a child of that sibling and in this way retains a lot
8072   of its original context, including inherited tags and approximate
8073   position in the outline.
8075 * Agenda Views
8076 :PROPERTIES:
8077 :DESCRIPTION: Collecting information into views.
8078 :END:
8079 #+cindex: agenda views
8081 Due to the way Org works, TODO items, time-stamped items, and tagged
8082 headlines can be scattered throughout a file or even a number of
8083 files.  To get an overview of open action items, or of events that are
8084 important for a particular date, this information must be collected,
8085 sorted and displayed in an organized way.
8087 Org can select items based on various criteria and display them in
8088 a separate buffer.  Six different view types are provided:
8090 - an /agenda/ that is like a calendar and shows information for
8091   specific dates,
8093 - a /TODO list/ that covers all unfinished action items,
8095 - a /match view/, showings headlines based on the tags, properties,
8096   and TODO state associated with them,
8098 - a /text search view/ that shows all entries from multiple files that
8099   contain specified keywords,
8101 - a /stuck projects view/ showing projects that currently do not move
8102   along, and
8104 - /custom views/ that are special searches and combinations of
8105   different views.
8107 The extracted information is displayed in a special /agenda buffer/.
8108 This buffer is read-only, but provides commands to visit the
8109 corresponding locations in the original Org files, and even to edit
8110 these files remotely.
8112 #+vindex: org-agenda-skip-comment-trees
8113 #+vindex: org-agenda-skip-archived-trees
8114 #+cindex: commented entries, in agenda views
8115 #+cindex: archived entries, in agenda views
8116 By default, the report ignores commented (see [[*Comment Lines]]) and
8117 archived (see [[*Internal archiving]]) entries.  You can override this by
8118 setting ~org-agenda-skip-comment-trees~ and
8119 ~org-agenda-skip-archived-trees~ to ~nil~.
8121 #+vindex: org-agenda-window-setup
8122 #+vindex: org-agenda-restore-windows-after-quit
8123 Two variables control how the agenda buffer is displayed and whether
8124 the window configuration is restored when the agenda exits:
8125 ~org-agenda-window-setup~ and ~org-agenda-restore-windows-after-quit~.
8127 ** Agenda Files
8128 :PROPERTIES:
8129 :DESCRIPTION: Files being searched for agenda information.
8130 :END:
8131 #+cindex: agenda files
8132 #+cindex: files for agenda
8134 #+vindex: org-agenda-files
8135 The information to be shown is normally collected from all /agenda
8136 files/, the files listed in the variable ~org-agenda-files~[fn:89].
8137 If a directory is part of this list, all files with the extension
8138 =.org= in this directory are part of the list.
8140 Thus, even if you only work with a single Org file, that file should
8141 be put into the list[fn:90].  You can customize ~org-agenda-files~,
8142 but the easiest way to maintain it is through the following commands
8144 #+attr_texinfo: :sep and
8145 - {{{kbd(C-c [)}}} (~org-agenda-file-to-front~) ::
8147   #+kindex: C-c [
8148   #+findex: org-agenda-file-to-front
8149   #+cindex: files, adding to agenda list
8150   Add current file to the list of agenda files.  The file is added to
8151   the front of the list.  If it was already in the list, it is moved
8152   to the front.  With a prefix argument, file is added/moved to the
8153   end.
8155 - {{{kbd(C-c ])}}} (~org-remove-file~) ::
8157   #+kindex: C-c ]
8158   #+findex: org-remove-file
8159   Remove current file from the list of agenda files.
8161 - {{{kbd(C-')}}} and {{{kbd(C-\,)}}} (~org-cycle-agenda-files~) ::
8163   #+kindex: C-'
8164   #+kindex: C-,
8165   #+findex: org-cycle-agenda-files
8166   #+cindex: cycling, of agenda files
8167   Cycle through agenda file list, visiting one file after the other.
8169 - {{{kbd(M-x org-switchb)}}} ::
8171   #+findex: org-switchb
8172   Command to use an Iswitchb-like interface to switch to and between
8173   Org buffers.
8175 #+texinfo: @noindent
8176 The Org menu contains the current list of files and can be used to
8177 visit any of them.
8179 If you would like to focus the agenda temporarily on a file not in
8180 this list, or on just one file in the list, or even on only a subtree
8181 in a file, then this can be done in different ways.  For a single
8182 agenda command, you may press {{{kbd(<)}}} once or several times in
8183 the dispatcher (see [[*The Agenda Dispatcher]]).  To restrict the agenda
8184 scope for an extended period, use the following commands:
8186 - {{{kbd(C-c C-x <)}}} (~org-agenda-set-restriction-lock~) ::
8188   #+kindex: C-c C-x <
8189   #+findex: org-agenda-set-restriction-lock
8190   Restrict the agenda to the current subtree.  If there already is
8191   a restriction at point, remove it.  When called with a universal
8192   prefix argument or with point before the first headline in a file,
8193   set the agenda scope to the entire file.  This restriction remains
8194   in effect until removed with {{{kbd(C-c C-x >)}}}, or by typing
8195   either {{{kbd(<)}}} or {{{kbd(>)}}} in the agenda dispatcher.  If
8196   there is a window displaying an agenda view, the new restriction
8197   takes effect immediately.
8199 - {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
8201   #+kindex: C-c C-x >
8202   #+findex: org-agenda-remove-restriction-lock
8203   Remove the restriction created by {{{kbd(C-c C-x <)}}}.
8205 When working with Speedbar, you can use the following commands in the
8206 Speedbar frame:
8208 - {{{kbd(<)}}} (~org-speedbar-set-agenda-restriction~) ::
8210   #+findex: org-speedbar-set-agenda-restriction
8211   Restrict the agenda to the item---either an Org file or a subtree in
8212   such a file---at point in the Speedbar frame.  If agenda is already
8213   restricted there, remove the restriction.  If there is a window
8214   displaying an agenda view, the new restriction takes effect
8215   immediately.
8217 - {{{kbd(>)}}} (~org-agenda-remove-restriction-lock~) ::
8219   #+findex: org-agenda-remove-restriction-lock
8220   Remove the restriction.
8222 ** The Agenda Dispatcher
8223 :PROPERTIES:
8224 :DESCRIPTION: Keyboard access to agenda views.
8225 :ALT_TITLE: Agenda Dispatcher
8226 :END:
8227 #+cindex: agenda dispatcher
8228 #+cindex: dispatching agenda commands
8230 The views are created through a dispatcher, accessible with {{{kbd(M-x
8231 org-agenda)}}}, or, better, bound to a global key (see [[*Activation]]).
8232 It displays a menu from which an additional letter is required to
8233 execute a command.  The dispatcher offers the following default
8234 commands:
8236 #+attr_texinfo: :sep ,
8237 - {{{kbd(a)}}} ::
8239   Create the calendar-like agenda (see [[*Weekly/daily agenda]]).
8241 - {{{kbd(t)}}}, {{{kbd(T)}}} ::
8243   Create a list of all TODO items (see [[*The global TODO list]]).
8245 - {{{kbd(m)}}}, {{{kbd(M)}}} ::
8247   Create a list of headlines matching a given expression (see
8248   [[*Matching tags and properties]]).
8250 - {{{kbd(s)}}} ::
8252   #+kindex: s @r{(Agenda dispatcher)}
8253   Create a list of entries selected by a boolean expression of
8254   keywords and/or regular expressions that must or must not occur in
8255   the entry.
8257 - {{{kbd(/)}}} ::
8259   #+kindex: / @r{(Agenda dispatcher)}
8260   #+vindex: org-agenda-text-search-extra-files
8261   Search for a regular expression in all agenda files and additionally
8262   in the files listed in ~org-agenda-text-search-extra-files~.  This
8263   uses the Emacs command ~multi-occur~.  A prefix argument can be used
8264   to specify the number of context lines for each match, default is
8265   1.
8267 - {{{kbd(#)}}}, {{{kbd(!)}}} ::
8269   Create a list of stuck projects (see [[*Stuck projects]]).
8271 - {{{kbd(<)}}} ::
8273   #+kindex: < @r{(Agenda dispatcher)}
8274   Restrict an agenda command to the current buffer[fn:91].  After
8275   pressing {{{kbd(<)}}}, you still need to press the character
8276   selecting the command.
8278 - {{{kbd(< <)}}} ::
8280   #+kindex: < < @r{(Agenda dispatcher)}
8281   If there is an active region, restrict the following agenda command
8282   to the region.  Otherwise, restrict it to the current
8283   subtree[fn:92].  After pressing {{{kbd(< <)}}}, you still need to
8284   press the character selecting the command.
8286 - {{{kbd(*)}}} ::
8288   #+kindex: * @r{(Agenda dispatcher)}
8289   #+vindex: org-agenda-sticky
8290   #+findex: org-toggle-sticky-agenda
8291   Toggle sticky agenda views.  By default, Org maintains only a single
8292   agenda buffer and rebuilds it each time you change the view, to make
8293   sure everything is always up to date.  If you switch between views
8294   often and the build time bothers you, you can turn on sticky agenda
8295   buffers (make this the default by customizing the variable
8296   ~org-agenda-sticky~).  With sticky agendas, the dispatcher only
8297   switches to the selected view, you need to update it by hand with
8298   {{{kbd(r)}}} or {{{kbd(g)}}}.  You can toggle sticky agenda view any
8299   time with ~org-toggle-sticky-agenda~.
8301 You can also define custom commands that are accessible through the
8302 dispatcher, just like the default commands.  This includes the
8303 possibility to create extended agenda buffers that contain several
8304 blocks together, for example the weekly agenda, the global TODO list
8305 and a number of special tags matches.  See [[*Custom Agenda Views]].
8307 ** The Built-in Agenda Views
8308 :PROPERTIES:
8309 :DESCRIPTION: What is available out of the box?
8310 :ALT_TITLE: Built-in Agenda Views
8311 :END:
8313 In this section we describe the built-in views.
8315 *** Weekly/daily agenda
8316 :PROPERTIES:
8317 :DESCRIPTION: The calendar page with current tasks.
8318 :END:
8319 #+cindex: agenda
8320 #+cindex: weekly agenda
8321 #+cindex: daily agenda
8323 The purpose of the weekly/daily /agenda/ is to act like a page of
8324 a paper agenda, showing all the tasks for the current week or day.
8326 - {{{kbd(M-x org-agenda a)}}} (~org-agenda-list~) ::
8328   #+kindex: a @r{(Agenda dispatcher)}
8329   #+findex: org-agenda-list
8330   #+cindex: org-agenda, command
8331   Compile an agenda for the current week from a list of Org files.
8332   The agenda shows the entries for each day.  With a numeric prefix
8333   argument[fn:93]---like {{{kbd(C-u 2 1 M-x org-agenda a)}}}---you may
8334   set the number of days to be displayed.
8336 #+vindex: org-agenda-span
8337 #+vindex: org-agenda-start-day
8338 #+vindex: org-agenda-start-on-weekday
8339 The default number of days displayed in the agenda is set by the
8340 variable ~org-agenda-span~.  This variable can be set to any number of
8341 days you want to see by default in the agenda, or to a span name, such
8342 a ~day~, ~week~, ~month~ or ~year~.  For weekly agendas, the default
8343 is to start on the previous Monday (see
8344 ~org-agenda-start-on-weekday~).  You can also set the start date using
8345 a date shift: =(setq org-agenda-start-day "+10d")= starts the agenda
8346 ten days from today in the future.
8348 Remote editing from the agenda buffer means, for example, that you can
8349 change the dates of deadlines and appointments from the agenda buffer.
8350 The commands available in the Agenda buffer are listed in [[*Commands in
8351 the Agenda Buffer]].
8353 **** Calendar/Diary integration
8354 :PROPERTIES:
8355 :UNNUMBERED: notoc
8356 :END:
8357 #+cindex: calendar integration
8358 #+cindex: diary integration
8360 Emacs contains the calendar and diary by Edward\nbsp{}M.\nbsp{}Reingold.  The
8361 calendar displays a three-month calendar with holidays from different
8362 countries and cultures.  The diary allows you to keep track of
8363 anniversaries, lunar phases, sunrise/set, recurrent appointments
8364 (weekly, monthly) and more.  In this way, it is quite complementary to
8365 Org.  It can be very useful to combine output from Org with the diary.
8367 In order to include entries from the Emacs diary into Org mode's
8368 agenda, you only need to customize the variable
8370 #+begin_src emacs-lisp
8371 (setq org-agenda-include-diary t)
8372 #+end_src
8374 #+texinfo: @noindent
8375 After that, everything happens automatically.  All diary entries
8376 including holidays, anniversaries, etc., are included in the agenda
8377 buffer created by Org mode.  {{{kbd(SPC)}}}, {{{kbd(TAB)}}}, and
8378 {{{kbd(RET)}}} can be used from the agenda buffer to jump to the diary
8379 file in order to edit existing diary entries.  The {{{kbd(i)}}}
8380 command to insert new entries for the current date works in the agenda
8381 buffer, as well as the commands {{{kbd(S)}}}, {{{kbd(M)}}}, and
8382 {{{kbd(C)}}} to display Sunrise/Sunset times, show lunar phases and to
8383 convert to other calendars, respectively.  {{{kbd(c)}}} can be used to
8384 switch back and forth between calendar and agenda.
8386 If you are using the diary only for expression entries and holidays,
8387 it is faster to not use the above setting, but instead to copy or even
8388 move the entries into an Org file.  Org mode evaluates diary-style
8389 expression entries, and does it faster because there is no overhead
8390 for first creating the diary display.  Note that the expression
8391 entries must start at the left margin, no whitespace is allowed before
8392 them, as seen in the following segment of an Org file:[fn:94]
8394 #+begin_example
8395 ,* Holidays
8396   :PROPERTIES:
8397   :CATEGORY: Holiday
8398   :END:
8399 %%(org-calendar-holiday)   ; special function for holiday names
8401 ,* Birthdays
8402   :PROPERTIES:
8403   :CATEGORY: Ann
8404   :END:
8405 %%(org-anniversary 1956  5 14) Arthur Dent is %d years old
8406 %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
8407 #+end_example
8409 **** Anniversaries from BBDB
8410 :PROPERTIES:
8411 :UNNUMBERED: notoc
8412 :END:
8413 #+cindex: BBDB, anniversaries
8414 #+cindex: anniversaries, from BBDB
8416 #+findex: org-bbdb-anniversaries
8417 If you are using the Insidious Big Brother Database to store your
8418 contacts, you very likely prefer to store anniversaries in BBDB rather
8419 than in a separate Org or diary file.  Org supports this and can show
8420 BBDB anniversaries as part of the agenda.  All you need to do is to
8421 add the following to one of your agenda files:
8423 #+begin_example
8424 ,* Anniversaries
8425   :PROPERTIES:
8426   :CATEGORY: Anniv
8427   :END:
8428 %%(org-bbdb-anniversaries)
8429 #+end_example
8431 You can then go ahead and define anniversaries for a BBDB record.
8432 Basically, you need a field named =anniversary= for the BBDB record
8433 which contains the date in the format =YYYY-MM-DD= or =MM-DD=,
8434 followed by a space and the class of the anniversary (=birthday=,
8435 =wedding=, or a format string).  If you omit the class, it defaults to
8436 =birthday=.  Here are a few examples, the header for the file
8437 =ol-bbdb.el= contains more detailed information.
8439 #+begin_example
8440 1973-06-22
8441 06-22
8442 1955-08-02 wedding
8443 2008-04-14 %s released version 6.01 of Org mode, %d years ago
8444 #+end_example
8446 After a change to BBDB, or for the first agenda display during an
8447 Emacs session, the agenda display suffers a short delay as Org updates
8448 its hash with anniversaries.  However, from then on things will be
8449 very fast, much faster in fact than a long list of
8450 =%%(diary-anniversary)= entries in an Org or Diary file.
8452 #+findex: org-bbdb-anniversaries-future
8453 If you would like to see upcoming anniversaries with a bit of
8454 forewarning, you can use the following instead:
8456 #+begin_example
8457 ,* Anniversaries
8458   :PROPERTIES:
8459   :CATEGORY: Anniv
8460   :END:
8461 %%(org-bbdb-anniversaries-future 3)
8462 #+end_example
8464 That will give you three days' warning: on the anniversary date itself
8465 and the two days prior.  The argument is optional: if omitted, it
8466 defaults to 7.
8468 **** Appointment reminders
8469 :PROPERTIES:
8470 :UNNUMBERED: notoc
8471 :END:
8472 #+cindex: @file{appt.el}
8473 #+cindex: appointment reminders
8474 #+cindex: appointment
8475 #+cindex: reminders
8477 #+cindex: APPT_WARNTIME, keyword
8478 Org can interact with Emacs appointments notification facility.  To
8479 add the appointments of your agenda files, use the command
8480 ~org-agenda-to-appt~.  This command lets you filter through the list
8481 of your appointments and add only those belonging to a specific
8482 category or matching a regular expression.  It also reads
8483 a =APPT_WARNTIME= property which overrides the value of
8484 ~appt-message-warning-time~ for this appointment.  See the docstring
8485 for details.
8487 *** The global TODO list
8488 :PROPERTIES:
8489 :DESCRIPTION: All unfinished action items.
8490 :ALT_TITLE: Global TODO list
8491 :END:
8492 #+cindex: global TODO list
8493 #+cindex: TODO list, global
8495 The global TODO list contains all unfinished TODO items formatted and
8496 collected into a single place.
8498 - {{{kbd(M-x org-agenda t)}}} (~org-todo-list~) ::
8500   #+kindex: t @r{(Agenda dispatcher)}
8501   #+findex: org-todo-list
8502   Show the global TODO list.  This collects the TODO items from all
8503   agenda files (see [[*Agenda Views]]) into a single buffer.  By default,
8504   this lists items with a state the is not a DONE state.  The buffer
8505   is in ~agenda-mode~, so there are commands to examine and manipulate
8506   the TODO entries directly from that buffer (see [[*Commands in the
8507   Agenda Buffer]]).
8509 - {{{kbd(M-x org-agenda T)}}} (~org-todo-list~) ::
8511   #+kindex: T @r{(Agenda dispatcher)}
8512   #+findex: org-todo-list
8513   #+cindex: TODO keyword matching
8514   #+vindex: org-todo-keywords
8515   Like the above, but allows selection of a specific TODO keyword.
8516   You can also do this by specifying a prefix argument to
8517   {{{kbd(t)}}}.  You are prompted for a keyword, and you may also
8518   specify several keywords by separating them with =|= as the boolean
8519   OR operator.  With a numeric prefix, the Nth keyword in
8520   ~org-todo-keywords~ is selected.
8522   #+kindex: r
8523   The {{{kbd(r)}}} key in the agenda buffer regenerates it, and you
8524   can give a prefix argument to this command to change the selected
8525   TODO keyword, for example {{{kbd(3 r)}}}.  If you often need
8526   a search for a specific keyword, define a custom command for it (see
8527   [[*The Agenda Dispatcher]]).
8529   Matching specific TODO keywords can also be done as part of a tags
8530   search (see [[*Tag Searches]]).
8532 Remote editing of TODO items means that you can change the state of
8533 a TODO entry with a single key press.  The commands available in the
8534 TODO list are described in [[*Commands in the Agenda Buffer]].
8536 #+cindex: sublevels, inclusion into TODO list
8537 Normally the global TODO list simply shows all headlines with TODO
8538 keywords.  This list can become very long.  There are two ways to keep
8539 it more compact:
8542   #+vindex: org-agenda-todo-ignore-scheduled
8543   #+vindex: org-agenda-todo-ignore-deadlines
8544   #+vindex: org-agenda-todo-ignore-timestamp
8545   #+vindex: org-agenda-todo-ignore-with-date
8546   Some people view a TODO item that has been /scheduled/ for execution
8547   or have a /deadline/ (see [[*Timestamps]]) as no longer /open/.
8548   Configure the variables ~org-agenda-todo-ignore-scheduled~,
8549   ~org-agenda-todo-ignore-deadlines~,
8550   ~org-agenda-todo-ignore-timestamp~ and/or
8551   ~org-agenda-todo-ignore-with-date~ to exclude such items from the
8552   global TODO list.
8555   #+vindex: org-agenda-todo-list-sublevels
8556   TODO items may have sublevels to break up the task into subtasks.
8557   In such cases it may be enough to list only the highest level TODO
8558   headline and omit the sublevels from the global list.  Configure the
8559   variable ~org-agenda-todo-list-sublevels~ to get this behavior.
8561 *** Matching tags and properties
8562 :PROPERTIES:
8563 :DESCRIPTION: Structured information with fine-tuned search.
8564 :END:
8565 #+cindex: matching, of tags
8566 #+cindex: matching, of properties
8567 #+cindex: tags view
8568 #+cindex: match view
8570 If headlines in the agenda files are marked with /tags/ (see [[*Tags]]),
8571 or have properties (see [[*Properties and Columns]]), you can select
8572 headlines based on this metadata and collect them into an agenda
8573 buffer.  The match syntax described here also applies when creating
8574 sparse trees with {{{kbd(C-c / m)}}}.
8576 - {{{kbd(M-x org-agenda m)}}} (~org-tags-view~) ::
8578   #+kindex: m @r{(Agenda dispatcher)}
8579   #+findex: org-tags-view
8580   Produce a list of all headlines that match a given set of tags.  The
8581   command prompts for a selection criterion, which is a boolean logic
8582   expression with tags, like =+work+urgent-withboss= or =work|home=
8583   (see [[*Tags]]).  If you often need a specific search, define a custom
8584   command for it (see [[*The Agenda Dispatcher]]).
8586 - {{{kbd(M-x org-agenda M)}}} (~org-tags-view~) ::
8588   #+kindex: M @r{(Agenda dispatcher)}
8589   #+findex: org-tags-view
8590   #+vindex: org-tags-match-list-sublevels
8591   #+vindex: org-agenda-tags-todo-honor-ignore-options
8592   Like {{{kbd(m)}}}, but only select headlines that are also TODO
8593   items and force checking subitems (see the variable
8594   ~org-tags-match-list-sublevels~).  To exclude scheduled/deadline
8595   items, see the variable ~org-agenda-tags-todo-honor-ignore-options~.
8596   Matching specific TODO keywords together with a tags match is also
8597   possible, see [[*Tag Searches]].
8599 The commands available in the tags list are described in [[*Commands in
8600 the Agenda Buffer]].
8602 #+cindex: boolean logic, for agenda searches
8603 A search string can use Boolean operators =&= for AND and =|= for OR.
8604 =&= binds more strongly than =|=.  Parentheses are currently not
8605 implemented.  Each element in the search is either a tag, a regular
8606 expression matching tags, or an expression like =PROPERTY OPERATOR
8607 VALUE= with a comparison operator, accessing a property value.  Each
8608 element may be preceded by =-= to select against it, and =+= is
8609 syntactic sugar for positive selection.  The AND operator =&= is
8610 optional when =+= or =-= is present.  Here are some examples, using
8611 only tags.
8613 - =+work-boss= ::
8615   Select headlines tagged =work=, but discard those also tagged
8616   =boss=.
8618 - =work|laptop= ::
8620   Selects lines tagged =work= or =laptop=.
8622 - =work|laptop+night= ::
8624   Like before, but require the =laptop= lines to be tagged also
8625   =night=.
8627 #+cindex: regular expressions, with tags search
8628 Instead of a tag, you may also specify a regular expression enclosed
8629 in curly braces.  For example, =work+{^boss.*}= matches headlines that
8630 contain the tag =:work:= and any tag /starting/ with =boss=.
8632 #+cindex: group tags, as regular expressions
8633 Group tags (see [[*Tag Hierarchy]]) are expanded as regular expressions.
8634 E.g., if =work= is a group tag for the group =:work:lab:conf:=, then
8635 searching for =work= also searches for ={\(?:work\|lab\|conf\)}= and
8636 searching for =-work= searches for all headlines but those with one of
8637 the tags in the group (i.e., =-{\(?:work\|lab\|conf\)}=).
8639 #+cindex: TODO keyword matching, with tags search
8640 #+cindex: level, for tags/property match
8641 #+cindex: category, for tags/property match
8642 #+vindex: org-odd-levels-only
8643 You may also test for properties (see [[*Properties and Columns]]) at the
8644 same time as matching tags.  The properties may be real properties, or
8645 special properties that represent other metadata (see [[*Special
8646 Properties]]).  For example, the property =TODO= represents the TODO
8647 keyword of the entry.  Or, the property =LEVEL= represents the level
8648 of an entry.  So searching =+LEVEL=3+boss-TODO​="DONE"= lists all level
8649 three headlines that have the tag =boss= and are /not/ marked with the
8650 TODO keyword =DONE=.  In buffers with ~org-odd-levels-only~ set,
8651 =LEVEL= does not count the number of stars, but =LEVEL=2= corresponds
8652 to 3 stars etc.
8654 Here are more examples:
8656 - =work+TODO​="WAITING"= ::
8658   Select =work=-tagged TODO lines with the specific TODO keyword
8659   =WAITING=.
8661 - =work+TODO​="WAITING"|home+TODO​="WAITING"= ::
8663   Waiting tasks both at work and at home.
8665 When matching properties, a number of different operators can be used
8666 to test the value of a property.  Here is a complex example:
8668 #+begin_example
8669 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2
8670          +With={Sarah|Denny}+SCHEDULED>="<2008-10-11>"
8671 #+end_example
8673 #+texinfo: @noindent
8674 The type of comparison depends on how the comparison value is written:
8676 - If the comparison value is a plain number, a numerical comparison is
8677   done, and the allowed operators are =<=, ===, =>=, =<==, =>==, and
8678   =<>=.
8680 - If the comparison value is enclosed in double-quotes, a string
8681   comparison is done, and the same operators are allowed.
8683 - If the comparison value is enclosed in double-quotes /and/ angular
8684   brackets (like =DEADLINE<​="<2008-12-24 18:30>"=), both values are
8685   assumed to be date/time specifications in the standard Org way, and
8686   the comparison is done accordingly.  Valid values also include
8687   ="<now>"= for now (including time), ="<today>"=, and ="<tomorrow>"=
8688   for these days at 0:00 hours, i.e., without a time specification.
8689   You can also use strings like ="<+5d>"= or ="<-2m>"= with units =d=,
8690   =w=, =m=, and =y= for day, week, month, and year, respectively.
8692 - If the comparison value is enclosed in curly braces, a regexp match
8693   is performed, with === meaning that the regexp matches the property
8694   value, and =<>= meaning that it does not match.
8696 So the search string in the example finds entries tagged =work= but
8697 not =boss=, which also have a priority value =A=, a =Coffee= property
8698 with the value =unlimited=, an =EFFORT= property that is numerically
8699 smaller than 2, a =With= property that is matched by the regular
8700 expression =Sarah|Denny=, and that are scheduled on or after October
8701 11, 2008.
8703 You can configure Org mode to use property inheritance during
8704 a search, but beware that this can slow down searches considerably.
8705 See [[*Property Inheritance]], for details.
8707 For backward compatibility, and also for typing speed, there is also
8708 a different way to test TODO states in a search.  For this, terminate
8709 the tags/property part of the search string (which may include several
8710 terms connected with =|=) with a =/= and then specify a Boolean
8711 expression just for TODO keywords.  The syntax is then similar to that
8712 for tags, but should be applied with care: for example, a positive
8713 selection on several TODO keywords cannot meaningfully be combined
8714 with boolean AND.  However, /negative selection/ combined with AND can
8715 be meaningful.  To make sure that only lines are checked that actually
8716 have any TODO keyword (resulting in a speed-up), use {{{kbd(M-x
8717 org-agenda M)}}}, or equivalently start the TODO part after the slash
8718 with =!=.  Using {{{kbd(M-x org-agenda M)}}} or =/!= does not match
8719 TODO keywords in a DONE state.  Examples:
8721 - =work/WAITING= ::
8723   Same as =work+TODO​="WAITING"=.
8725 - =work/!-WAITING-NEXT= ::
8727   Select =work=-tagged TODO lines that are neither =WAITING= nor
8728   =NEXT=.
8730 - =work/!+WAITING|+NEXT= ::
8732   Select =work=-tagged TODO lines that are either =WAITING= or =NEXT=.
8734 *** Search view
8735 :PROPERTIES:
8736 :DESCRIPTION: Find entries by searching for text.
8737 :END:
8738 #+cindex: search view
8739 #+cindex: text search
8740 #+cindex: searching, for text
8742 This agenda view is a general text search facility for Org mode
8743 entries.  It is particularly useful to find notes.
8745 - {{{kbd(M-x org-agenda s)}}} (~org-search-view~) ::
8747   #+kindex: s @r{(Agenda dispatcher)}
8748   #+findex: org-search-view
8749   This is a special search that lets you select entries by matching
8750   a substring or specific words using a boolean logic.
8752 For example, the search string =computer equipment= matches entries
8753 that contain =computer equipment= as a substring, even if the two
8754 words are separated by more space or a line break.
8756 Search view can also search for specific keywords in the entry, using
8757 Boolean logic.  The search string =+computer
8758 +wifi -ethernet -{8\.11[bg]}= matches note entries that contain the
8759 keywords =computer= and =wifi=, but not the keyword =ethernet=, and
8760 which are also not matched by the regular expression =8\.11[bg]=,
8761 meaning to exclude both =8.11b= and =8.11g=.  The first =+= is
8762 necessary to turn on boolean search, other =+= characters are
8763 optional.  For more details, see the docstring of the command
8764 ~org-search-view~.
8766 You can incrementally adjust a boolean search with the following keys
8768 #+attr_texinfo: :columns 0.1 0.6
8769 | {{{kbd([)}}} | Add a positive search word        |
8770 | {{{kbd(])}}} | Add a negative search word        |
8771 | {{{kbd({)}}} | Add a positive regular expression |
8772 | {{{kbd(})}}} | Add a negative regular expression |
8774 #+vindex: org-agenda-text-search-extra-files
8775 Note that in addition to the agenda files, this command also searches
8776 the files listed in ~org-agenda-text-search-extra-files~.
8778 *** Stuck projects
8779 :PROPERTIES:
8780 :DESCRIPTION: Find projects you need to review.
8781 :END:
8782 #+pindex: GTD, Getting Things Done
8784 If you are following a system like David Allen's GTD to organize your
8785 work, one of the "duties" you have is a regular review to make sure
8786 that all projects move along.  A /stuck/ project is a project that has
8787 no defined next actions, so it never shows up in the TODO lists Org
8788 mode produces.  During the review, you need to identify such projects
8789 and define next actions for them.
8791 - {{{kbd(M-x org-agenda #)}}} (~org-agenda-list-stuck-projects~) ::
8793   #+kindex: # @r{(Agenda dispatcher)}
8794   #+findex: org-agenda-list-stuck-projects
8795   List projects that are stuck.
8797 - {{{kbd(M-x org-agenda !)}}} ::
8799   #+kindex: ! @r{(Agenda dispatcher)}
8800   #+vindex: org-stuck-projects
8801   Customize the variable ~org-stuck-projects~ to define what a stuck
8802   project is and how to find it.
8804 You almost certainly need to configure this view before it works for
8805 you.  The built-in default assumes that all your projects are level-2
8806 headlines, and that a project is not stuck if it has at least one
8807 entry marked with a TODO keyword =TODO= or =NEXT= or =NEXTACTION=.
8809 Let's assume that you, in your own way of using Org mode, identify
8810 projects with a tag =:PROJECT:=, and that you use a TODO keyword
8811 =MAYBE= to indicate a project that should not be considered yet.
8812 Let's further assume that the TODO keyword =DONE= marks finished
8813 projects, and that =NEXT= and =TODO= indicate next actions.  The tag
8814 =:@shop:= indicates shopping and is a next action even without the
8815 NEXT tag.  Finally, if the project contains the special word =IGNORE=
8816 anywhere, it should not be listed either.  In this case you would
8817 start by identifying eligible projects with a tags/TODO match (see
8818 [[*Tag Searches]]) =+PROJECT/-MAYBE-DONE=, and then check for =TODO=,
8819 =NEXT=, =@shop=, and =IGNORE= in the subtree to identify projects that
8820 are not stuck.  The correct customization for this is:
8822 #+begin_src emacs-lisp
8823 (setq org-stuck-projects
8824       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@shop")
8825         "\\<IGNORE\\>"))
8826 #+end_src
8828 Note that if a project is identified as non-stuck, the subtree of this
8829 entry is searched for stuck projects.
8831 ** Presentation and Sorting
8832 :PROPERTIES:
8833 :DESCRIPTION: How agenda items are prepared for display.
8834 :END:
8835 #+cindex: presentation, of agenda items
8837 #+vindex: org-agenda-prefix-format
8838 #+vindex: org-agenda-tags-column
8839 Before displaying items in an agenda view, Org mode visually prepares
8840 the items and sorts them.  Each item occupies a single line.  The line
8841 starts with a /prefix/ that contains the /category/ (see [[*Categories]])
8842 of the item and other important information.  You can customize in
8843 which column tags are displayed through ~org-agenda-tags-column~.  You
8844 can also customize the prefix using the option
8845 ~org-agenda-prefix-format~.  This prefix is followed by a cleaned-up
8846 version of the outline headline associated with the item.
8848 *** Categories
8849 :PROPERTIES:
8850 :DESCRIPTION: Not all tasks are equal.
8851 :END:
8852 #+cindex: category
8853 #+cindex: @samp{CATEGORY}, keyword
8855 The category is a broad label assigned to each agenda item.  By
8856 default, the category is simply derived from the file name, but you
8857 can also specify it with a special line in the buffer, like
8858 this:
8860 : #+CATEGORY: Thesis
8862 #+cindex: @samp{CATEGORY}, property
8863 If you would like to have a special category for a single entry or
8864 a (sub)tree, give the entry a =CATEGORY= property with the special
8865 category you want to apply as the value.
8867 The display in the agenda buffer looks best if the category is not
8868 longer than 10 characters.
8870 #+vindex: org-agenda-category-icon-alist
8871 You can set up icons for category by customizing the
8872 ~org-agenda-category-icon-alist~ variable.
8874 *** Time-of-day specifications
8875 :PROPERTIES:
8876 :DESCRIPTION: How the agenda knows the time.
8877 :END:
8878 #+cindex: time-of-day specification
8880 Org mode checks each agenda item for a time-of-day specification.  The
8881 time can be part of the timestamp that triggered inclusion into the
8882 agenda, for example
8884 : <2005-05-10 Tue 19:00>
8886 #+texinfo: @noindent
8887 Time ranges can be specified with two timestamps:
8889 : <2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>
8891 #+vindex: org-agenda-search-headline-for-time
8892 In the headline of the entry itself, a time(range)---like =12:45= or
8893 a =8:30-1pm=---may also appear as plain text[fn:95].
8895 If the agenda integrates the Emacs diary (see [[*Weekly/daily agenda]]),
8896 time specifications in diary entries are recognized as well.
8898 For agenda display, Org mode extracts the time and displays it in
8899 a standard 24 hour format as part of the prefix.  The example times in
8900 the previous paragraphs would end up in the agenda like this:
8902 #+begin_example
8903  8:30-13:00 Arthur Dent lies in front of the bulldozer
8904 12:45...... Ford Prefect arrives and takes Arthur to the pub
8905 19:00...... The Vogon reads his poem
8906 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
8907 #+end_example
8909 #+cindex: time grid
8910 If the agenda is in single-day mode, or for the display of today, the
8911 timed entries are embedded in a time grid, like
8913 #+begin_example
8914  8:00...... ------------------
8915  8:30-13:00 Arthur Dent lies in front of the bulldozer
8916 10:00...... ------------------
8917 12:00...... ------------------
8918 12:45...... Ford Prefect arrives and takes Arthur to the pub
8919 14:00...... ------------------
8920 16:00...... ------------------
8921 18:00...... ------------------
8922 19:00...... The Vogon reads his poem
8923 20:00...... ------------------
8924 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
8925 #+end_example
8927 #+vindex: org-agenda-use-time-grid
8928 #+vindex: org-agenda-time-grid
8929 The time grid can be turned on and off with the variable
8930 ~org-agenda-use-time-grid~, and can be configured with
8931 ~org-agenda-time-grid~.
8933 *** Sorting of agenda items
8934 :PROPERTIES:
8935 :DESCRIPTION: The order of things.
8936 :END:
8937 #+cindex: sorting, of agenda items
8938 #+cindex: priorities, of agenda items
8940 Before being inserted into a view, the items are sorted.  How this is
8941 done depends on the type of view.
8944   #+vindex: org-agenda-files
8945   For the daily/weekly agenda, the items for each day are sorted.  The
8946   default order is to first collect all items containing an explicit
8947   time-of-day specification.  These entries are shown at the beginning
8948   of the list, as a /schedule/ for the day.  After that, items remain
8949   grouped in categories, in the sequence given by ~org-agenda-files~.
8950   Within each category, items are sorted by priority (see
8951   [[*Priorities]]), which is composed of the base priority (2000 for
8952   priority =A=, 1000 for =B=, and 0 for =C=), plus additional
8953   increments for overdue scheduled or deadline items.
8955 - For the TODO list, items remain in the order of categories, but
8956   within each category, sorting takes place according to priority (see
8957   [[*Priorities]]).  The priority used for sorting derives from the
8958   priority cookie, with additions depending on how close an item is to
8959   its due or scheduled date.
8961 - For tags matches, items are not sorted at all, but just appear in
8962   the sequence in which they are found in the agenda files.
8964 #+vindex: org-agenda-sorting-strategy
8965 Sorting can be customized using the variable
8966 ~org-agenda-sorting-strategy~, and may also include criteria based on
8967 the estimated effort of an entry (see [[*Effort Estimates]]).
8969 *** Filtering/limiting agenda items
8970 :PROPERTIES:
8971 :DESCRIPTION: Dynamically narrow the agenda.
8972 :END:
8974 Agenda built-in or customized commands are statically defined.  Agenda
8975 filters and limits provide two ways of dynamically narrowing down the
8976 list of agenda entries: /filters/ and /limits/.  Filters only act on
8977 the display of the items, while limits take effect before the list of
8978 agenda entries is built.  Filters are more often used interactively,
8979 while limits are mostly useful when defined as local variables within
8980 custom agenda commands.
8982 **** Filtering in the agenda
8983 :PROPERTIES:
8984 :UNNUMBERED: notoc
8985 :END:
8986 #+cindex: agenda filtering
8987 #+cindex: filtering entries, in agenda
8988 #+cindex: tag filtering, in agenda
8989 #+cindex: category filtering, in agenda
8990 #+cindex: top headline filtering, in agenda
8991 #+cindex: effort filtering, in agenda
8992 #+cindex: query editing, in agenda
8994 - {{{kbd(/)}}} (~org-agenda-filter-by-tag~) ::
8996   #+findex: org-agenda-filter-by-tag
8997   #+vindex: org-agenda-tag-filter-preset
8998   Filter the agenda view with respect to a tag and/or effort
8999   estimates.  The difference between this and a custom agenda command
9000   is that filtering is very fast, so that you can switch quickly
9001   between different filters without having to recreate the
9002   agenda.[fn:96]
9004   You are prompted for a tag selection letter; {{{kbd(SPC)}}} means
9005   any tag at all.  Pressing {{{kbd(TAB)}}} at that prompt offers
9006   completion to select a tag, including any tags that do not have
9007   a selection character.  The command then hides all entries that do
9008   not contain or inherit this tag.  When called with prefix argument,
9009   remove the entries that /do/ have the tag.  A second {{{kbd(/)}}} at
9010   the prompt turns off the filter and shows any hidden entries.
9011   Pressing {{{kbd(+)}}} or {{{kbd(-)}}} switches between filtering and
9012   excluding the next tag.
9014   #+vindex: org-agenda-auto-exclude-function
9015   Org also supports automatic, context-aware tag filtering.  If the
9016   variable ~org-agenda-auto-exclude-function~ is set to a user-defined
9017   function, that function can decide which tags should be excluded
9018   from the agenda automatically.  Once this is set, the {{{kbd(/)}}}
9019   command then accepts {{{kbd(RET)}}} as a sub-option key and runs the
9020   auto exclusion logic.  For example, let's say you use a =Net= tag to
9021   identify tasks which need network access, an =Errand= tag for
9022   errands in town, and a =Call= tag for making phone calls.  You could
9023   auto-exclude these tags based on the availability of the Internet,
9024   and outside of business hours, with something like this:
9026   #+begin_src emacs-lisp
9027   (defun org-my-auto-exclude-function (tag)
9028     (and (cond
9029           ((string= tag "Net")
9030            (/= 0 (call-process "/sbin/ping" nil nil nil
9031                                "-c1" "-q" "-t1" "mail.gnu.org")))
9032           ((or (string= tag "Errand") (string= tag "Call"))
9033            (let ((hour (nth 2 (decode-time))))
9034              (or (< hour 8) (> hour 21)))))
9035          (concat "-" tag)))
9037   (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
9038   #+end_src
9040 - {{{kbd(<)}}} (~org-agenda-filter-by-category~) ::
9042   #+findex: org-agenda-filter-by-category
9043   Filter the current agenda view with respect to the category of the
9044   item at point.  Pressing {{{kbd(<)}}} another time removes this
9045   filter.  When called with a prefix argument exclude the category of
9046   the item at point from the agenda.
9048   #+vindex: org-agenda-category-filter-preset
9049   You can add a filter preset in custom agenda commands through the
9050   option ~org-agenda-category-filter-preset~.  See [[*Setting options
9051   for custom commands]].
9053 - {{{kbd(^)}}} (~org-agenda-filter-by-top-headline~) ::
9055   #+findex: org-agenda-filter-by-top-headline
9056   Filter the current agenda view and only display the siblings and the
9057   parent headline of the one at point.
9059 - {{{kbd(=)}}} (~org-agenda-filter-by-regexp~) ::
9061   #+findex: org-agenda-filter-by-regexp
9062   Filter the agenda view by a regular expression: only show agenda
9063   entries matching the regular expression the user entered.  When
9064   called with a prefix argument, it filters /out/ entries matching the
9065   regexp.  Called in a regexp-filtered agenda view, remove the filter,
9066   unless there are two universal prefix arguments, in which case
9067   filters are cumulated.
9069   #+vindex: org-agenda-regexp-filter-preset
9070   You can add a filter preset in custom agenda commands through the
9071   option ~org-agenda-regexp-filter-preset~.  See [[*Setting options
9072   for custom commands]].
9074 - {{{kbd(_)}}} (~org-agenda-filter-by-effort~) ::
9076   #+findex: org-agenda-filter-by-effort
9077   Filter the agenda view with respect to effort estimates.  You first
9078   need to set up allowed efforts globally, for example
9080   #+begin_src emacs-lisp
9081   (setq org-global-properties
9082         '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
9083   #+end_src
9085   #+vindex: org-sort-agenda-noeffort-is-high
9086   You can then filter for an effort by first typing an operator, one
9087   of {{{kbd(<)}}}, {{{kbd(>)}}} and {{{kbd(=)}}}, and then the
9088   one-digit index of an effort estimate in your array of allowed
9089   values, where {{{kbd(0)}}} means the 10th value.  The filter then
9090   restricts to entries with effort smaller-or-equal, equal, or
9091   larger-or-equal than the selected value.  For application of the
9092   operator, entries without a defined effort are treated according to
9093   the value of ~org-sort-agenda-noeffort-is-high~.
9095   When called with a prefix argument, it removes entries matching the
9096   condition.  With two universal prefix arguments, it clears effort
9097   filters, which can be accumulated.
9099   #+vindex: org-agenda-effort-filter-preset
9100   You can add a filter preset in custom agenda commands through the
9101   option ~org-agenda-effort-filter-preset~.  See [[*Setting options for
9102   custom commands]].
9104 - {{{kbd(|)}}} (~org-agenda-filter-remove-all~) ::
9106   Remove all filters in the current agenda view.
9108 **** Setting limits for the agenda
9109 :PROPERTIES:
9110 :UNNUMBERED: notoc
9111 :END:
9112 #+cindex: limits, in agenda
9114 Here is a list of options that you can set, either globally, or
9115 locally in your custom agenda views (see [[*Custom Agenda Views]]).
9117 - ~org-agenda-max-entries~ ::
9119   #+vindex: org-agenda-max-entries
9120   Limit the number of entries.
9122 - ~org-agenda-max-effort~ ::
9124   #+vindex: org-agenda-max-effort
9125   Limit the duration of accumulated efforts (as minutes).
9127 - ~org-agenda-max-todos~ ::
9129   #+vindex: org-agenda-max-todos
9130   Limit the number of entries with TODO keywords.
9132 - ~org-agenda-max-tags~ ::
9134   #+vindex: org-agenda-max-tags
9135   Limit the number of tagged entries.
9137 When set to a positive integer, each option excludes entries from
9138 other categories: for example, =(setq org-agenda-max-effort 100)=
9139 limits the agenda to 100 minutes of effort and exclude any entry that
9140 has no effort property.  If you want to include entries with no effort
9141 property, use a negative value for ~org-agenda-max-effort~.  One
9142 useful setup is to use ~org-agenda-max-entries~ locally in a custom
9143 command.  For example, this custom command displays the next five
9144 entries with a =NEXT= TODO keyword.
9146 #+begin_src emacs-lisp
9147 (setq org-agenda-custom-commands
9148       '(("n" todo "NEXT"
9149          ((org-agenda-max-entries 5)))))
9150 #+end_src
9152 Once you mark one of these five entry as DONE, rebuilding the agenda
9153 will again the next five entries again, including the first entry that
9154 was excluded so far.
9156 You can also dynamically set temporary limits, which are lost when
9157 rebuilding the agenda:
9159 - {{{kbd(~ )}}} (~org-agenda-limit-interactively~) ::
9161   #+findex: org-agenda-limit-interactively
9162   This prompts for the type of limit to apply and its value.
9164 ** Commands in the Agenda Buffer
9165 :PROPERTIES:
9166 :DESCRIPTION: Remote editing of Org trees.
9167 :ALT_TITLE: Agenda Commands
9168 :END:
9169 #+cindex: commands, in agenda buffer
9171 Entries in the agenda buffer are linked back to the Org file or diary
9172 file where they originate.  You are not allowed to edit the agenda
9173 buffer itself, but commands are provided to show and jump to the
9174 original entry location, and to edit the Org files "remotely" from the
9175 agenda buffer.  In this way, all information is stored only once,
9176 removing the risk that your agenda and note files may diverge.
9178 Some commands can be executed with mouse clicks on agenda lines.  For
9179 the other commands, point needs to be in the desired line.
9181 *** Motion
9182 :PROPERTIES:
9183 :UNNUMBERED: notoc
9184 :END:
9185 #+cindex: motion commands in agenda
9187 - {{{kbd(n)}}} (~org-agenda-next-line~) ::
9189   #+kindex: n
9190   #+findex: org-agenda-next-line
9191   Next line (same as {{{kbd(DOWN)}}} and {{{kbd(C-n)}}}).
9193 - {{{kbd(p)}}} (~org-agenda-previous-line~) ::
9195   #+kindex: p
9196   #+findex: org-agenda-previous-line
9197   Previous line (same as {{{kbd(UP)}}} and {{{kbd(C-p)}}}).
9199 *** View/Go to Org file
9200 :PROPERTIES:
9201 :UNNUMBERED: notoc
9202 :END:
9203 #+cindex: view file commands in agenda
9205 - {{{kbd(SPC)}}} or {{{kbd(mouse-3)}}} (~org-agenda-show-and-scroll-up~) ::
9207   #+kindex: SPC
9208   #+kindex: mouse-3
9209   #+findex: org-agenda-show-and-scroll-up
9210   Display the original location of the item in another window.
9211   With a prefix argument, make sure that drawers stay folded.
9213 - {{{kbd(L)}}} (~org-agenda-recenter~) ::
9215   #+findex: org-agenda-recenter
9216   Display original location and recenter that window.
9218 - {{{kbd(TAB)}}} or {{{kbd(mouse-2)}}} (~org-agenda-goto~) ::
9220   #+kindex: TAB
9221   #+kindex: mouse-2
9222   #+findex: org-agenda-goto
9223   Go to the original location of the item in another window.
9225 - {{{kbd(RET)}}} (~org-agenda-switch-to~) ::
9227   #+kindex: RET
9228   #+findex: org-agenda-switch-to
9229   Go to the original location of the item and delete other windows.
9231 - {{{kbd(F)}}} (~org-agenda-follow-mode~) ::
9233   #+kindex: F
9234   #+findex: org-agenda-follow-mode
9235   #+vindex: org-agenda-start-with-follow-mode
9236   Toggle Follow mode.  In Follow mode, as you move point through the
9237   agenda buffer, the other window always shows the corresponding
9238   location in the Org file.  The initial setting for this mode in new
9239   agenda buffers can be set with the variable
9240   ~org-agenda-start-with-follow-mode~.
9242 - {{{kbd(C-c C-x b)}}} (~org-agenda-tree-to-indirect-buffer~) ::
9244   #+kindex: C-c C-x b
9245   #+findex: org-agenda-tree-to-indirect-buffer
9246   Display the entire subtree of the current item in an indirect
9247   buffer.  With a numeric prefix argument N, go up to level N and then
9248   take that tree.  If N is negative, go up that many levels.  With
9249   a {{{kbd(C-u)}}} prefix, do not remove the previously used indirect
9250   buffer.
9252 - {{{kbd(C-c C-o)}}} (~org-agenda-open-link~) ::
9254   #+kindex: C-c C-o
9255   #+findex: org-agenda-open-link
9256   Follow a link in the entry.  This offers a selection of any links in
9257   the text belonging to the referenced Org node.  If there is only one
9258   link, follow it without a selection prompt.
9260 *** Change display
9261 :PROPERTIES:
9262 :UNNUMBERED: notoc
9263 :END:
9264 #+cindex: change agenda display
9265 #+cindex: display changing, in agenda
9267 #+attr_texinfo: :sep ,
9268 - {{{kbd(A)}}} ::
9270   #+kindex: A
9271   Interactively select another agenda view and append it to the
9272   current view.
9274 - {{{kbd(o)}}} ::
9276   #+kindex: o
9277   Delete other windows.
9279 - {{{kbd(v d)}}} or short {{{kbd(d)}}} (~org-agenda-day-view~) ::
9281   #+kindex: v d
9282   #+kindex: d
9283   #+findex: org-agenda-day-view
9284   Switch to day view.  When switching to day view, this setting
9285   becomes the default for subsequent agenda refreshes.  A numeric
9286   prefix argument may be used to jump directly to a specific day of
9287   the year.  For example, {{{kbd(32 d)}}} jumps to February 1st.  When
9288   setting day view, a year may be encoded in the prefix argument as
9289   well.  For example, {{{kbd(200712 d)}}} jumps to January 12, 2007.
9290   If such a year specification has only one or two digits, it is
9291   expanded into one of the 30 next years or the last 69 years.
9293 - {{{kbd(v w)}}} or short {{{kbd(w)}}} (~org-agenda-week-view~) ::
9295   #+kindex: v w
9296   #+kindex: w
9297   #+findex: org-agenda-week-view
9298   Switch to week view.  When switching week view, this setting becomes
9299   the default for subsequent agenda refreshes.  A numeric prefix
9300   argument may be used to jump directly to a specific day of the ISO
9301   week.  For example {{{kbd(9 w)}}} to ISO week number 9.  When
9302   setting week view, a year may be encoded in the prefix argument as
9303   well.  For example, {{{kbd(200712 w)}}} jumps to week 12 in 2007.
9304   If such a year specification has only one or two digits, it is
9305   expanded into one of the 30 next years or the last 69 years.
9307 - {{{kbd(v m)}}} (~org-agenda-month-view~) ::
9309   #+kindex: v m
9310   #+findex: org-agenda-month-view
9311   Switch to month view.  Because month views are slow to create, they
9312   do not become the default for subsequent agenda refreshes.
9313   A numeric prefix argument may be used to jump directly to a specific
9314   day of the month.  When setting month view, a year may be encoded in
9315   the prefix argument as well.  For example, {{{kbd(200712 m)}}} jumps
9316   to December, 2007.  If such a year specification has only one or two
9317   digits, it is expanded into one of the 30 next years or the last 69
9318   years.
9320 - {{{kbd(v y)}}} (~org-agenda-year-view~) ::
9322   #+kindex: v y
9323   #+findex: org-agenda-year-view
9324   Switch to year view.  Because year views are slow to create, they do
9325   not become the default for subsequent agenda refreshes.  A numeric
9326   prefix argument may be used to jump directly to a specific day of
9327   the year.
9329 - {{{kbd(v SPC)}}} (~org-agenda-reset-view~) ::
9331   #+kindex: v SPC
9332   #+findex: org-agenda-reset-view
9333   #+vindex: org-agenda-span
9334   Reset the current view to ~org-agenda-span~.
9336 - {{{kbd(f)}}} (~org-agenda-later~) ::
9338   #+kindex: f
9339   #+findex: org-agenda-later
9340   Go forward in time to display the span following the current one.
9341   For example, if the display covers a week, switch to the following
9342   week.  With a prefix argument, repeat that many times.
9344 - {{{kbd(b)}}} (~org-agenda-earlier~) ::
9346   #+kindex: b
9347   #+findex: org-agenda-earlier
9348   Go backward in time to display earlier dates.
9350 - {{{kbd(.)}}} (~org-agenda-goto-today~) ::
9352   #+kindex: .
9353   #+findex: org-agenda-goto-today
9354   Go to today.
9356 - {{{kbd(j)}}} (~org-agenda-goto-date~) ::
9358   #+kindex: j
9359   #+findex: org-agenda-goto-date
9360   Prompt for a date and go there.
9362 - {{{kbd(J)}}} (~org-agenda-clock-goto~) ::
9364   #+kindex: J
9365   #+findex: org-agenda-clock-goto
9366   Go to the currently clocked-in task /in the agenda buffer/.
9368 - {{{kbd(D)}}} (~org-agenda-toggle-diary~) ::
9370   #+kindex: D
9371   #+findex: org-agenda-toggle-diary
9372   Toggle the inclusion of diary entries.  See [[*Weekly/daily agenda]].
9374 - {{{kbd(v l)}}} or {{{kbd(v L)}}} or short {{{kbd(l)}}} (~org-agenda-log-mode~) ::
9376   #+kindex: v l
9377   #+kindex: l
9378   #+kindex: v L
9379   #+findex: org-agenda-log-mode
9380   #+vindex: org-log-done
9381   #+vindex: org-agenda-log-mode-items
9382   Toggle Logbook mode.  In Logbook mode, entries that were marked as
9383   done while logging was on (see the variable ~org-log-done~) are
9384   shown in the agenda, as are entries that have been clocked on that
9385   day.  You can configure the entry types that should be included in
9386   log mode using the variable ~org-agenda-log-mode-items~.  When
9387   called with a {{{kbd(C-u)}}} prefix argument, show all possible
9388   logbook entries, including state changes.  When called with two
9389   prefix arguments {{{kbd(C-u C-u)}}}, show only logging information,
9390   nothing else.  {{{kbd(v L)}}} is equivalent to {{{kbd(C-u v l)}}}.
9392 - {{{kbd(v [)}}} or short {{{kbd([)}}} (~org-agenda-manipulate-query-add~) ::
9394   #+kindex: v [
9395   #+kindex: [
9396   #+findex: org-agenda-manipulate-query-add
9397   Include inactive timestamps into the current view.  Only for
9398   weekly/daily agenda.
9400 - {{{kbd(v a)}}} (~org-agenda-archives-mode~) ::
9402   #+kindex: v a
9403   #+findex: org-agenda-archives-mode
9404   Toggle Archives mode.  In Archives mode, trees that are archived
9405   (see [[*Internal archiving]]) are also scanned when producing the
9406   agenda.  To exit archives mode, press {{{kbd(v a)}}} again.
9408 - {{{kbd(v A)}}} ::
9410   #+kindex: v A
9411   Toggle Archives mode.  Include all archive files as well.
9413 - {{{kbd(v R)}}} or short {{{kbd(R)}}} (~org-agenda-clockreport-mode~) ::
9415   #+kindex: v R
9416   #+kindex: R
9417   #+findex: org-agenda-clockreport-mode
9418   #+vindex: org-agenda-start-with-clockreport-mode
9419   #+vindex: org-clock-report-include-clocking-task
9420   Toggle Clockreport mode.  In Clockreport mode, the daily/weekly
9421   agenda always shows a table with the clocked times for the time span
9422   and file scope covered by the current agenda view.  The initial
9423   setting for this mode in new agenda buffers can be set with the
9424   variable ~org-agenda-start-with-clockreport-mode~.  By using
9425   a prefix argument when toggling this mode (i.e., {{{kbd(C-u R)}}}),
9426   the clock table does not show contributions from entries that are
9427   hidden by agenda filtering[fn:97].  See also the variable
9428   ~org-clock-report-include-clocking-task~.
9430 - {{{kbd(v c)}}} ::
9432   #+kindex: v c
9433   #+vindex: org-agenda-clock-consistency-checks
9434   Show overlapping clock entries, clocking gaps, and other clocking
9435   problems in the current agenda range.  You can then visit clocking
9436   lines and fix them manually.  See the variable
9437   ~org-agenda-clock-consistency-checks~ for information on how to
9438   customize the definition of what constituted a clocking problem.  To
9439   return to normal agenda display, press {{{kbd(l)}}} to exit Logbook
9440   mode.
9442 - {{{kbd(v E)}}} or short {{{kbd(E)}}} (~org-agenda-entry-text-mode~) ::
9444   #+kindex: v E
9445   #+kindex: E
9446   #+findex: org-agenda-entry-text-mode
9447   #+vindex: org-agenda-start-with-entry-text-mode
9448   #+vindex: org-agenda-entry-text-maxlines
9449   Toggle entry text mode.  In entry text mode, a number of lines from
9450   the Org outline node referenced by an agenda line are displayed
9451   below the line.  The maximum number of lines is given by the
9452   variable ~org-agenda-entry-text-maxlines~.  Calling this command
9453   with a numeric prefix argument temporarily modifies that number to
9454   the prefix value.
9456 - {{{kbd(G)}}} (~org-agenda-toggle-time-grid~) ::
9458   #+kindex: G
9459   #+vindex: org-agenda-use-time-grid
9460   #+vindex: org-agenda-time-grid
9461   Toggle the time grid on and off.  See also the variables
9462   ~org-agenda-use-time-grid~ and ~org-agenda-time-grid~.
9464 - {{{kbd(r)}}} (~org-agenda-redo~), {{{kbd(g)}}} ::
9466   #+kindex: r
9467   #+kindex: g
9468   #+findex: org-agenda-redo
9469   Recreate the agenda buffer, for example to reflect the changes after
9470   modification of the timestamps of items with {{{kbd(S-LEFT)}}} and
9471   {{{kbd(S-RIGHT)}}}.  When the buffer is the global TODO list,
9472   a prefix argument is interpreted to create a selective list for
9473   a specific TODO keyword.
9475 - {{{kbd(C-x C-s)}}} or short {{{kbd(s)}}} (~org-save-all-org-buffers~) ::
9477   #+kindex: C-x C-s
9478   #+findex: org-save-all-org-buffers
9479   #+kindex: s
9480   Save all Org buffers in the current Emacs session, and also the
9481   locations of IDs.
9483 - {{{kbd(C-c C-x C-c)}}} (~org-agenda-columns~) ::
9485   #+kindex: C-c C-x C-c
9486   #+findex: org-agenda-columns
9487   #+vindex: org-columns-default-format
9488   Invoke column view (see [[*Column View]]) in the agenda buffer.  The
9489   column view format is taken from the entry at point, or, if there is
9490   no entry at point, from the first entry in the agenda view.  So
9491   whatever the format for that entry would be in the original buffer
9492   (taken from a property, from a =COLUMNS= keyword, or from the
9493   default variable ~org-columns-default-format~) is used in the
9494   agenda.
9496 - {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
9498   #+kindex: C-c C-x >
9499   #+findex: org-agenda-remove-restriction-lock
9500   Remove the restriction lock on the agenda, if it is currently
9501   restricted to a file or subtree (see [[*Agenda Files]]).
9503 - {{{kbd(M-UP)}}} (~org-agenda-drag-line-backward~) ::
9505   #+kindex: M-UP
9506   #+findex: org-agenda-drag-line-backward
9507   Drag the line at point backward one line.  With a numeric prefix
9508   argument, drag backward by that many lines.
9510   Moving agenda lines does not persist after an agenda refresh and
9511   does not modify the contributing Org files.
9513 - {{{kbd(M-DOWN)}}} (~org-agenda-drag-line-forward~) ::
9515   #+kindex: M-DOWN
9516   #+findex: org-agenda-drag-line-forward
9517   Drag the line at point forward one line.  With a numeric prefix
9518   argument, drag forward by that many lines.
9520 *** Remote editing
9521 :PROPERTIES:
9522 :UNNUMBERED: notoc
9523 :END:
9524 #+cindex: remote editing, from agenda
9526 - {{{kbd(0--9)}}} ::
9528   Digit argument.
9530 - {{{kbd(C-_)}}} (~org-agenda-undo~) ::
9532   #+kindex: C-_
9533   #+findex: org-agenda-undo
9534   #+cindex: undoing remote-editing events
9535   #+cindex: remote editing, undo
9536   Undo a change due to a remote editing command.  The change is undone
9537   both in the agenda buffer and in the remote buffer.
9539 - {{{kbd(t)}}} (~org-agenda-todo~) ::
9541   #+kindex: t
9542   #+findex: org-agenda-todo
9543   Change the TODO state of the item, both in the agenda and in the
9544   original Org file.
9546 - {{{kbd(C-S-RIGHT)}}} (~org-agenda-todo-nextset~) ::
9548   #+kindex: C-S-RIGHT
9549   #+findex: org-agenda-todo-nextset
9550   Switch to the next set of TODO keywords.
9552 - {{{kbd(C-S-LEFT)}}}, ~org-agenda-todo-previousset~ ::
9554   #+kindex: C-S-LEFT
9555   Switch to the previous set of TODO keywords.
9557 - {{{kbd(C-k)}}} (~org-agenda-kill~) ::
9559   #+kindex: C-k
9560   #+findex: org-agenda-kill
9561   #+vindex: org-agenda-confirm-kill
9562   Delete the current agenda item along with the entire subtree
9563   belonging to it in the original Org file.  If the text to be deleted
9564   remotely is longer than one line, the kill needs to be confirmed by
9565   the user.  See variable ~org-agenda-confirm-kill~.
9567 - {{{kbd(C-c C-w)}}} (~org-agenda-refile~) ::
9569   #+kindex: C-c C-w
9570   #+findex: org-agenda-refile
9571   Refile the entry at point.
9573 - {{{kbd(C-c C-x C-a)}}} or short {{{kbd(a)}}} (~org-agenda-archive-default-with-confirmation~) ::
9575   #+kindex: C-c C-x C-a
9576   #+kindex: a
9577   #+findex: org-agenda-archive-default-with-confirmation
9578   #+vindex: org-archive-default-command
9579   Archive the subtree corresponding to the entry at point using the
9580   default archiving command set in ~org-archive-default-command~.
9581   When using the {{{kbd(a)}}} key, confirmation is required.
9583 - {{{kbd(C-c C-x a)}}} (~org-agenda-toggle-archive-tag~) ::
9585   #+kindex: C-c C-x a
9586   #+findex: org-agenda-toggle-archive-tag
9587   Toggle the archive tag (see [[*Internal archiving]]) for the current
9588   headline.
9590 - {{{kbd(C-c C-x A)}}} (~org-agenda-archive-to-archive-sibling~) ::
9592   #+kindex: C-c C-x A
9593   #+findex: org-agenda-archive-to-archive-sibling
9594   Move the subtree corresponding to the current entry to its /archive
9595   sibling/.
9597 - {{{kbd(C-c C-x C-s)}}} or short {{{kbd($)}}} (~org-agenda-archive~) ::
9599   #+kindex: C-c C-x C-s
9600   #+kindex: $
9601   #+findex: org-agenda-archive
9602   Archive the subtree corresponding to the current headline.  This
9603   means the entry is moved to the configured archive location, most
9604   likely a different file.
9606 - {{{kbd(T)}}} (~org-agenda-show-tags~) ::
9608   #+kindex: T
9609   #+findex: org-agenda-show-tags
9610   #+vindex: org-agenda-show-inherited-tags
9611   Show all tags associated with the current item.  This is useful if
9612   you have turned off ~org-agenda-show-inherited-tags~, but still want
9613   to see all tags of a headline occasionally.
9615 - {{{kbd(:)}}} (~org-agenda-set-tags~) ::
9617   #+kindex: :
9618   #+findex: org-agenda-set-tags
9619   Set tags for the current headline.  If there is an active region in
9620   the agenda, change a tag for all headings in the region.
9622 - {{{kbd(\,)}}} (~org-agenda-priority~) ::
9624   #+kindex: ,
9625   #+findex: org-agenda-priority
9626   Set the priority for the current item.  Org mode prompts for the
9627   priority character.  If you reply with {{{kbd(SPC)}}}, the priority
9628   cookie is removed from the entry.
9630 - {{{kbd(P)}}} (~org-agenda-show-priority~) ::
9632   #+kindex: P
9633   #+findex: org-agenda-show-priority
9634   Display weighted priority of current item.
9636 - {{{kbd(+)}}} or {{{kbd(S-UP)}}} (~org-agenda-priority-up~) ::
9638   #+kindex: +
9639   #+kindex: S-UP
9640   #+findex: org-agenda-priority-up
9641   Increase the priority of the current item.  The priority is changed
9642   in the original buffer, but the agenda is not resorted.  Use the
9643   {{{kbd(r)}}} key for this.
9645 - {{{kbd(-)}}} or {{{kbd(S-DOWN)}}} (~org-agenda-priority-down~) ::
9647   #+kindex: -
9648   #+kindex: S-DOWN
9649   #+findex: org-agenda-priority-down
9650   Decrease the priority of the current item.
9652 - {{{kbd(C-c C-z)}}} or short {{{kbd(z)}}} (~org-agenda-add-note~) ::
9654   #+kindex: z
9655   #+kindex: C-c C-z
9656   #+findex: org-agenda-add-note
9657   #+vindex: org-log-into-drawer
9658   Add a note to the entry.  This note is recorded, and then filed to
9659   the same location where state change notes are put.  Depending on
9660   ~org-log-into-drawer~, this may be inside a drawer.
9662 - {{{kbd(C-c C-a)}}} (~org-attach~) ::
9664   #+kindex: C-c C-a
9665   #+findex: org-attach
9666   Dispatcher for all command related to attachments.
9668 - {{{kbd(C-c C-s)}}} (~org-agenda-schedule~) ::
9670   #+kindex: C-c C-s
9671   #+findex: org-agenda-schedule
9672   Schedule this item.  With a prefix argument, remove the
9673   scheduling timestamp
9675 - {{{kbd(C-c C-d)}}} (~org-agenda-deadline~) ::
9677   #+kindex: C-c C-d
9678   #+findex: org-agenda-deadline
9679   Set a deadline for this item.  With a prefix argument, remove the
9680   deadline.
9682 - {{{kbd(S-RIGHT)}}} (~org-agenda-do-date-later~) ::
9684   #+kindex: S-RIGHT
9685   #+findex: org-agenda-do-date-later
9686   Change the timestamp associated with the current line by one day
9687   into the future.  If the date is in the past, the first call to this
9688   command moves it to today.  With a numeric prefix argument, change
9689   it by that many days.  For example, {{{kbd(3 6 5 S-RIGHT)}}} changes
9690   it by a year.  With a {{{kbd(C-u)}}} prefix, change the time by one
9691   hour.  If you immediately repeat the command, it will continue to
9692   change hours even without the prefix argument.  With a double
9693   {{{kbd(C-u C-u)}}} prefix, do the same for changing minutes.  The
9694   stamp is changed in the original Org file, but the change is not
9695   directly reflected in the agenda buffer.  Use {{{kbd(r)}}} or
9696   {{{kbd(g)}}} to update the buffer.
9698 - {{{kbd(S-LEFT)}}} (~org-agenda-do-date-earlier~) ::
9700   #+kindex: S-LEFT
9701   #+findex: org-agenda-do-date-earlier
9702   Change the timestamp associated with the current line by one day
9703   into the past.
9705 - {{{kbd(>)}}} (~org-agenda-date-prompt~) ::
9707   #+kindex: >
9708   #+findex: org-agenda-date-prompt
9709   Change the timestamp associated with the current line.  The key
9710   {{{kbd(>)}}} has been chosen, because it is the same as
9711   {{{kbd(S-.)}}}  on my keyboard.
9713 - {{{kbd(I)}}} (~org-agenda-clock-in~) ::
9715   #+kindex: I
9716   #+findex: org-agenda-clock-in
9717   Start the clock on the current item.  If a clock is running already,
9718   it is stopped first.
9720 - {{{kbd(O)}}} (~org-agenda-clock-out~) ::
9722   #+kindex: O
9723   #+findex: org-agenda-clock-out
9724   Stop the previously started clock.
9726 - {{{kbd(X)}}} (~org-agenda-clock-cancel~) ::
9728   #+kindex: X
9729   #+findex: org-agenda-clock-cancel
9730   Cancel the currently running clock.
9732 - {{{kbd(J)}}} (~org-agenda-clock-goto~) ::
9734   #+kindex: J
9735   #+findex: org-agenda-clock-goto
9736   Jump to the running clock in another window.
9738 - {{{kbd(k)}}} (~org-agenda-capture~) ::
9740   #+kindex: k
9741   #+findex: org-agenda-capture
9742   #+cindex: capturing, from agenda
9743   #+vindex: org-capture-use-agenda-date
9744   Like ~org-capture~, but use the date at point as the default date
9745   for the capture template.  See ~org-capture-use-agenda-date~ to make
9746   this the default behavior of ~org-capture~.
9748 *** Bulk remote editing selected entries
9749 :PROPERTIES:
9750 :UNNUMBERED: notoc
9751 :END:
9752 #+cindex: remote editing, bulk, from agenda
9753 #+vindex: org-agenda-bulk-custom-functions
9755 - {{{kbd(m)}}} (~org-agenda-bulk-mark~) ::
9756   #+kindex: m
9757   #+findex: org-agenda-bulk-mark
9759   Mark the entry at point for bulk action.  If there is an active
9760   region in the agenda, mark the entries in the region.  With numeric
9761   prefix argument, mark that many successive entries.
9763 - {{{kbd(*)}}} (~org-agenda-bulk-mark-all~) ::
9764   #+kindex: *
9765   #+findex: org-agenda-bulk-mark-all
9767   Mark all visible agenda entries for bulk action.
9769 - {{{kbd(u)}}} (~org-agenda-bulk-unmark~) ::
9770   #+kindex: u
9771   #+findex: org-agenda-bulk-unmark
9773   Unmark entry for bulk action.
9775 - {{{kbd(U)}}} (~org-agenda-bulk-remove-all-marks~) ::
9776   #+kindex: U
9777   #+findex: org-agenda-bulk-remove-all-marks
9779   Unmark all marked entries for bulk action.
9781 - {{{kbd(M-m)}}} (~org-agenda-bulk-toggle~) ::
9782   #+kindex: M-m
9783   #+findex: org-agenda-bulk-toggle
9785   Toggle mark of the entry at point for bulk action.
9787 - {{{kbd(M-*)}}} (~org-agenda-bulk-toggle-all~) ::
9788   #+kindex: M-*
9789   #+findex: org-agenda-bulk-toggle-all
9791   Toggle mark of every entry for bulk action.
9793 - {{{kbd(%)}}} (~org-agenda-bulk-mark-regexp~) ::
9794   #+kindex: %
9795   #+findex: org-agenda-bulk-mark-regexp
9797   Mark entries matching a regular expression for bulk action.
9799 - {{{kbd(B)}}} (~org-agenda-bulk-action~) ::
9800   #+kindex: B
9801   #+findex: org-agenda-bulk-action
9802   #+vindex: org-agenda-bulk-persistent-marks
9804   Bulk action: act on all marked entries in the agenda.  This prompts
9805   for another key to select the action to be applied.  The prefix
9806   argument to {{{kbd(B)}}} is passed through to the {{{kbd(s)}}} and
9807   {{{kbd(d)}}} commands, to bulk-remove these special timestamps.  By
9808   default, marks are removed after the bulk.  If you want them to
9809   persist, set ~org-agenda-bulk-persistent-marks~ to ~t~ or hit
9810   {{{kbd(p)}}} at the prompt.
9812   - {{{kbd(*)}}} ::
9814     Toggle persistent marks.
9816   - {{{kbd($)}}} ::
9818     Archive all selected entries.
9820   - {{{kbd(A)}}} ::
9822     Archive entries by moving them to their respective archive
9823     siblings.
9825   - {{{kbd(t)}}} ::
9827     Change TODO state.  This prompts for a single TODO keyword and
9828     changes the state of all selected entries, bypassing blocking and
9829     suppressing logging notes---but not timestamps.
9831   - {{{kbd(+)}}} ::
9833     Add a tag to all selected entries.
9835   - {{{kbd(-)}}} ::
9837     Remove a tag from all selected entries.
9839   - {{{kbd(s)}}} ::
9841     Schedule all items to a new date.  To shift existing schedule
9842     dates by a fixed number of days, use something starting with
9843     double plus at the prompt, for example =++8d= or =++2w=.
9845   - {{{kbd(d)}}} ::
9847     Set deadline to a specific date.
9849   - {{{kbd(r)}}} ::
9851     Prompt for a single refile target and move all entries.  The
9852     entries are no longer in the agenda; refresh ({{{kbd(g)}}}) to
9853     bring them back.
9855   - {{{kbd(S)}}} ::
9857     Reschedule randomly into the coming N days.  N is prompted for.
9858     With a prefix argument ({{{kbd(C-u B S)}}}), scatter only across
9859     weekdays.
9861   - {{{kbd(f)}}} ::
9863     #+vindex: org-agenda-bulk-custom-functions
9864     Apply a function[fn:98] to marked entries.  For example, the
9865     function below sets the =CATEGORY= property of the entries to
9866     =web=.
9868     #+begin_src emacs-lisp
9869     (defun set-category ()
9870       (interactive "P")
9871       (let ((marker (or (org-get-at-bol 'org-hd-marker)
9872                         (org-agenda-error))))
9873         (org-with-point-at marker
9874           (org-back-to-heading t)
9875           (org-set-property "CATEGORY" "web"))))
9876     #+end_src
9878 *** Calendar commands
9879 :PROPERTIES:
9880 :UNNUMBERED: notoc
9881 :END:
9882 #+cindex: calendar commands, from agenda
9884 - {{{kbd(c)}}} (~org-agenda-goto-calendar~) ::
9886   #+kindex: c
9887   #+findex: org-agenda-goto-calendar
9888   Open the Emacs calendar and go to the date at point in the agenda.
9890 - {{{kbd(c)}}} (~org-calendar-goto-agenda~) ::
9892   #+kindex: c
9893   #+findex: org-calendar-goto-agenda
9894   When in the calendar, compute and show the Org agenda for the date
9895   at point.
9897 - {{{kbd(i)}}} (~org-agenda-diary-entry~) ::
9898   #+kindex: i
9899   #+findex: org-agenda-diary-entry
9901   #+cindex: diary entries, creating from agenda
9902   Insert a new entry into the diary, using the date at point and (for
9903   block entries) the date at the mark.  This adds to the Emacs diary
9904   file[fn:99], in a way similar to the {{{kbd(i)}}} command in the
9905   calendar.  The diary file pops up in another window, where you can
9906   add the entry.
9908   #+vindex: org-agenda-diary-file
9909   If you configure ~org-agenda-diary-file~ to point to an Org file,
9910   Org creates entries in that file instead.  Most entries are stored
9911   in a date-based outline tree that will later make it easy to archive
9912   appointments from previous months/years.  The tree is built under an
9913   entry with a =DATE_TREE= property, or else with years as top-level
9914   entries.  Emacs prompts you for the entry text---if you specify it,
9915   the entry is created in ~org-agenda-diary-file~ without further
9916   interaction.  If you directly press {{{kbd(RET)}}} at the prompt
9917   without typing text, the target file is shown in another window for
9918   you to finish the entry there.  See also the {{{kbd(k r)}}} command.
9920 - {{{kbd(M)}}} (~org-agenda-phases-of-moon~) ::
9922   #+kindex: M
9923   #+findex: org-agenda-phases-of-moon
9924   Show the phases of the moon for the three months around current
9925   date.
9927 - {{{kbd(S)}}} (~org-agenda-sunrise-sunset~) ::
9929   #+kindex: S
9930   #+findex: org-agenda-sunrise-sunset
9931   Show sunrise and sunset times.  The geographical location must be
9932   set with calendar variables, see the documentation for the Emacs
9933   calendar.
9935 - {{{kbd(C)}}} (~org-agenda-convert-date~) ::
9937   #+kindex: C
9938   #+findex: org-agenda-convert-date
9939   Convert the date at point into many other cultural and historic
9940   calendars.
9942 - {{{kbd(H)}}} (~org-agenda-holidays~) ::
9944   #+kindex: H
9945   #+findex: org-agenda-holidays
9946   Show holidays for three months around point date.
9948 *** Quit and exit
9949 :PROPERTIES:
9950 :UNNUMBERED: notoc
9951 :END:
9953 - {{{kbd(q)}}} (~org-agenda-quit~) ::
9954   #+kindex: q
9955   #+findex: org-agenda-quit
9957   Quit agenda, remove the agenda buffer.
9959 - {{{kbd(x)}}} (~org-agenda-exit~) ::
9960   #+kindex: x
9961   #+findex: org-agenda-exit
9963   #+cindex: agenda files, removing buffers
9964   Exit agenda, remove the agenda buffer and all buffers loaded by
9965   Emacs for the compilation of the agenda.  Buffers created by the
9966   user to visit Org files are not removed.
9968 ** Custom Agenda Views
9969 :PROPERTIES:
9970 :DESCRIPTION: Defining special searches and views.
9971 :END:
9972 #+cindex: custom agenda views
9973 #+cindex: agenda views, custom
9975 Custom agenda commands serve two purposes: to store and quickly access
9976 frequently used TODO and tags searches, and to create special
9977 composite agenda buffers.  Custom agenda commands are accessible
9978 through the dispatcher (see [[*The Agenda Dispatcher]]), just like the
9979 default commands.
9981 *** Storing searches
9982 :PROPERTIES:
9983 :DESCRIPTION: Type once, use often.
9984 :END:
9986 The first application of custom searches is the definition of keyboard
9987 shortcuts for frequently used searches, either creating an agenda
9988 buffer, or a sparse tree (the latter covering of course only the
9989 current buffer).
9991 #+kindex: C @r{(Agenda dispatcher)}
9992 #+vindex: org-agenda-custom-commands
9993 #+cindex: agenda views, main example
9994 #+cindex: agenda, as an agenda views
9995 #+cindex: agenda*, as an agenda views
9996 #+cindex: tags, as an agenda view
9997 #+cindex: todo, as an agenda view
9998 #+cindex: tags-todo
9999 #+cindex: todo-tree
10000 #+cindex: occur-tree
10001 #+cindex: tags-tree
10002 Custom commands are configured in the variable
10003 ~org-agenda-custom-commands~.  You can customize this variable, for
10004 example by pressing {{{kbd(C)}}} from the agenda dispatcher (see [[*The
10005 Agenda Dispatcher]]).  You can also directly set it with Emacs Lisp in
10006 the Emacs init file.  The following example contains all valid agenda
10007 views:
10009 #+begin_src emacs-lisp
10010 (setq org-agenda-custom-commands
10011       '(("x" agenda)
10012         ("y" agenda*)
10013         ("w" todo "WAITING")
10014         ("W" todo-tree "WAITING")
10015         ("u" tags "+boss-urgent")
10016         ("v" tags-todo "+boss-urgent")
10017         ("U" tags-tree "+boss-urgent")
10018         ("f" occur-tree "\\<FIXME\\>")
10019         ("h" . "HOME+Name tags searches") ;description for "h" prefix
10020         ("hl" tags "+home+Lisa")
10021         ("hp" tags "+home+Peter")
10022         ("hk" tags "+home+Kim")))
10023 #+end_src
10025 The initial string in each entry defines the keys you have to press
10026 after the dispatcher command in order to access the command.  Usually
10027 this is just a single character, but if you have many similar
10028 commands, you can also define two-letter combinations where the first
10029 character is the same in several combinations and serves as a prefix
10030 key[fn:100].  The second parameter is the search type, followed by the
10031 string or regular expression to be used for the matching.  The example
10032 above will therefore define:
10034 - {{{kbd(x)}}} ::
10036   as a global search for agenda entries planned[fn:101] this week/day.
10038 - {{{kbd(y)}}} ::
10040   as the same search, but only for entries with an hour specification
10041   like =[h]h:mm=---think of them as appointments.
10043 - {{{kbd(w)}}} ::
10045   as a global search for TODO entries with =WAITING= as the TODO
10046   keyword.
10048 - {{{kbd(W)}}} ::
10050   as the same search, but only in the current buffer and displaying
10051   the results as a sparse tree.
10053 - {{{kbd(u)}}} ::
10055   as a global tags search for headlines tagged =boss= but not
10056   =urgent=.
10058 - {{{kbd(v)}}} ::
10060   The same search, but limiting it to headlines that are also TODO
10061   items.
10063 - {{{kbd(U)}}} ::
10065   as the same search, but only in the current buffer and displaying
10066   the result as a sparse tree.
10068 - {{{kbd(f)}}} ::
10070   to create a sparse tree (again, current buffer only) with all
10071   entries containing the word =FIXME=.
10073 - {{{kbd(h)}}} ::
10075   as a prefix command for a =HOME= tags search where you have to press
10076   an additional key ({{{kbd(l)}}}, {{{kbd(p)}}} or {{{kbd(k)}}}) to
10077   select a name (Lisa, Peter, or Kim) as additional tag to match.
10079 Note that ~*-tree~ agenda views need to be called from an Org buffer
10080 as they operate on the current buffer only.
10082 *** Block agenda
10083 :PROPERTIES:
10084 :DESCRIPTION: All the stuff you need in a single buffer.
10085 :END:
10086 #+cindex: block agenda
10087 #+cindex: agenda, with block views
10089 Another possibility is the construction of agenda views that comprise
10090 the results of /several/ commands, each of which creates a block in
10091 the agenda buffer.  The available commands include ~agenda~ for the
10092 daily or weekly agenda (as created with {{{kbd(a)}}}) , ~alltodo~ for
10093 the global TODO list (as constructed with {{{kbd(t)}}}), and the
10094 matching commands discussed above: ~todo~, ~tags~, and ~tags-todo~.
10095 Here are two examples:
10097 #+begin_src emacs-lisp
10098 (setq org-agenda-custom-commands
10099       '(("h" "Agenda and Home-related tasks"
10100          ((agenda "")
10101           (tags-todo "home")
10102           (tags "garden")))
10103         ("o" "Agenda and Office-related tasks"
10104          ((agenda "")
10105           (tags-todo "work")
10106           (tags "office")))))
10107 #+end_src
10109 #+texinfo: @noindent
10110 This defines {{{kbd(h)}}} to create a multi-block view for stuff you
10111 need to attend to at home.  The resulting agenda buffer contains your
10112 agenda for the current week, all TODO items that carry the tag =home=,
10113 and also all lines tagged with =garden=.  Finally the command
10114 {{{kbd(o)}}} provides a similar view for office tasks.
10116 *** Setting options for custom commands
10117 :PROPERTIES:
10118 :DESCRIPTION: Changing the rules.
10119 :ALT_TITLE: Setting options
10120 :END:
10121 #+cindex: options, for custom agenda views
10123 #+vindex: org-agenda-custom-commands
10124 Org mode contains a number of variables regulating agenda construction
10125 and display.  The global variables define the behavior for all agenda
10126 commands, including the custom commands.  However, if you want to
10127 change some settings just for a single custom view, you can do so.
10128 Setting options requires inserting a list of variable names and values
10129 at the right spot in ~org-agenda-custom-commands~.  For example:
10131 #+begin_src emacs-lisp
10132 (setq org-agenda-custom-commands
10133       '(("w" todo "WAITING"
10134          ((org-agenda-sorting-strategy '(priority-down))
10135           (org-agenda-prefix-format "  Mixed: ")))
10136         ("U" tags-tree "+boss-urgent"
10137          ((org-show-context-detail 'minimal)))
10138         ("N" search ""
10139          ((org-agenda-files '("~org/notes.org"))
10140           (org-agenda-text-search-extra-files nil)))))
10141 #+end_src
10143 #+texinfo: @noindent
10144 Now the {{{kbd(w)}}} command sorts the collected entries only by
10145 priority, and the prefix format is modified to just say =Mixed:=
10146 instead of giving the category of the entry.  The sparse tags tree of
10147 {{{kbd(U)}}} now turns out ultra-compact, because neither the headline
10148 hierarchy above the match, nor the headline following the match are
10149 shown.  The command {{{kbd(N)}}} does a text search limited to only
10150 a single file.
10152 For command sets creating a block agenda, ~org-agenda-custom-commands~
10153 has two separate spots for setting options.  You can add options that
10154 should be valid for just a single command in the set, and options that
10155 should be valid for all commands in the set.  The former are just
10156 added to the command entry; the latter must come after the list of
10157 command entries.  Going back to the block agenda example (see [[*Block
10158 agenda]]), let's change the sorting strategy for the {{{kbd(h)}}}
10159 commands to ~priority-down~, but let's sort the results for =garden=
10160 tags query in the opposite order, ~priority-up~.  This would look like
10161 this:
10163 #+begin_src emacs-lisp
10164 (setq org-agenda-custom-commands
10165       '(("h" "Agenda and Home-related tasks"
10166          ((agenda)
10167           (tags-todo "home")
10168           (tags "garden"
10169                 ((org-agenda-sorting-strategy '(priority-up)))))
10170          ((org-agenda-sorting-strategy '(priority-down))))
10171         ("o" "Agenda and Office-related tasks"
10172          ((agenda)
10173           (tags-todo "work")
10174           (tags "office")))))
10175 #+end_src
10177 As you see, the values and parentheses setting is a little complex.
10178 When in doubt, use the customize interface to set this variable---it
10179 fully supports its structure.  Just one caveat: when setting options
10180 in this interface, the /values/ are just Lisp expressions.  So if the
10181 value is a string, you need to add the double-quotes around the value
10182 yourself.
10184 #+vindex: org-agenda-custom-commands-contexts
10185 To control whether an agenda command should be accessible from
10186 a specific context, you can customize
10187 ~org-agenda-custom-commands-contexts~.  Let's say for example that you
10188 have an agenda command {{{kbd(o)}}} displaying a view that you only
10189 need when reading emails.  Then you would configure this option like
10190 this:
10192 #+begin_src emacs-lisp
10193 (setq org-agenda-custom-commands-contexts
10194       '(("o" (in-mode . "message-mode"))))
10195 #+end_src
10197 You can also tell that the command key {{{kbd(o)}}} should refer to
10198 another command key {{{kbd(r)}}}.  In that case, add this command key
10199 like this:
10201 #+begin_src emacs-lisp
10202 (setq org-agenda-custom-commands-contexts
10203       '(("o" "r" (in-mode . "message-mode"))))
10204 #+end_src
10206 See the docstring of the variable for more information.
10208 ** Exporting Agenda Views
10209 :PROPERTIES:
10210 :DESCRIPTION: Writing a view to a file.
10211 :END:
10212 #+cindex: agenda views, exporting
10214 If you are away from your computer, it can be very useful to have
10215 a printed version of some agenda views to carry around.  Org mode can
10216 export custom agenda views as plain text, HTML[fn:102], Postscript,
10217 PDF[fn:103], and iCalendar files.  If you want to do this only
10218 occasionally, use the following command:
10220 - {{{kbd(C-x C-w)}}} (~org-agenda-write~) ::
10221   #+kindex: C-x C-w
10222   #+findex: org-agenda-write
10223   #+cindex: exporting agenda views
10224   #+cindex: agenda views, exporting
10226   #+vindex: org-agenda-exporter-settings
10227   Write the agenda view to a file.
10229 If you need to export certain agenda views frequently, you can
10230 associate any custom agenda command with a list of output file
10231 names[fn:104].  Here is an example that first defines custom commands
10232 for the agenda and the global TODO list, together with a number of
10233 files to which to export them.  Then we define two block agenda
10234 commands and specify file names for them as well.  File names can be
10235 relative to the current working directory, or absolute.
10237 #+begin_src emacs-lisp
10238 (setq org-agenda-custom-commands
10239       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
10240         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
10241         ("h" "Agenda and Home-related tasks"
10242          ((agenda "")
10243           (tags-todo "home")
10244           (tags "garden"))
10245          nil
10246          ("~/views/home.html"))
10247         ("o" "Agenda and Office-related tasks"
10248          ((agenda)
10249           (tags-todo "work")
10250           (tags "office"))
10251          nil
10252          ("~/views/office.ps" "~/calendars/office.ics"))))
10253 #+end_src
10255 The extension of the file name determines the type of export.  If it
10256 is =.html=, Org mode uses the htmlize package to convert the buffer to
10257 HTML and save it to this file name.  If the extension is =.ps=,
10258 ~ps-print-buffer-with-faces~ is used to produce Postscript output.  If
10259 the extension is =.ics=, iCalendar export is run export over all files
10260 that were used to construct the agenda, and limit the export to
10261 entries listed in the agenda.  Any other extension produces a plain
10262 ASCII file.
10264 The export files are /not/ created when you use one of those
10265 commands interactively because this might use too much overhead.
10266 Instead, there is a special command to produce /all/ specified
10267 files in one step:
10269 - {{{kbd(e)}}} (~org-store-agenda-views~) ::
10271   #+kindex: e @r{(Agenda dispatcher)}
10272   #+findex: org-store-agenda-views
10273   Export all agenda views that have export file names associated with
10274   them.
10276 You can use the options section of the custom agenda commands to also
10277 set options for the export commands.  For example:
10279 #+begin_src emacs-lisp
10280 (setq org-agenda-custom-commands
10281       '(("X" agenda ""
10282          ((ps-number-of-columns 2)
10283           (ps-landscape-mode t)
10284           (org-agenda-prefix-format " [ ] ")
10285           (org-agenda-with-colors nil)
10286           (org-agenda-remove-tags t))
10287          ("theagenda.ps"))))
10288 #+end_src
10290 #+texinfo: @noindent
10291 #+vindex: org-agenda-exporter-settings
10292 This command sets two options for the Postscript exporter, to make it
10293 print in two columns in landscape format---the resulting page can be
10294 cut in two and then used in a paper agenda.  The remaining settings
10295 modify the agenda prefix to omit category and scheduling information,
10296 and instead include a checkbox to check off items.  We also remove the
10297 tags to make the lines compact, and we do not want to use colors for
10298 the black-and-white printer.  Settings specified in
10299 ~org-agenda-exporter-settings~ also apply, e.g.,
10301 #+begin_src emacs-lisp
10302 (setq org-agenda-exporter-settings
10303       '((ps-number-of-columns 2)
10304         (ps-landscape-mode t)
10305         (org-agenda-add-entry-text-maxlines 5)
10306         (htmlize-output-type 'css)))
10307 #+end_src
10309 #+texinfo: @noindent
10310 but the settings in ~org-agenda-custom-commands~ take precedence.
10312 From the command line you may also use:
10314 #+begin_src shell
10315 emacs -eval (org-batch-store-agenda-views) -kill
10316 #+end_src
10318 #+texinfo: @noindent
10319 or, if you need to modify some parameters[fn:105]
10321 #+begin_src shell
10322 emacs -eval '(org-batch-store-agenda-views                      \
10323               org-agenda-span (quote month)                     \
10324               org-agenda-start-day "2007-11-01"                 \
10325               org-agenda-include-diary nil                      \
10326               org-agenda-files (quote ("~/org/project.org")))'  \
10327       -kill
10328 #+end_src
10330 #+texinfo: @noindent
10331 which creates the agenda views restricted to the file
10332 =~/org/project.org=, without diary entries and with a 30-day extent.
10334 You can also extract agenda information in a way that allows further
10335 processing by other programs.  See [[*Extracting Agenda Information]], for
10336 more information.
10338 ** Using Column View in the Agenda
10339 :PROPERTIES:
10340 :DESCRIPTION: Using column view for collected entries.
10341 :ALT_TITLE: Agenda Column View
10342 :END:
10343 #+cindex: column view, in agenda
10344 #+cindex: agenda, column view
10346 Column view (see [[*Column View]]) is normally used to view and edit
10347 properties embedded in the hierarchical structure of an Org file.  It
10348 can be quite useful to use column view also from the agenda, where
10349 entries are collected by certain criteria.
10351 - {{{kbd(C-c C-x C-c)}}} (~org-agenda-columns~) ::
10352   #+kindex: C-c C-x C-c
10353   #+findex: org-agenda-columns
10355   Turn on column view in the agenda.
10357 To understand how to use this properly, it is important to realize
10358 that the entries in the agenda are no longer in their proper outline
10359 environment.  This causes the following issues:
10362    #+vindex: org-columns-default-format
10363    #+vindex: org-overriding-columns-format
10364    Org needs to make a decision which columns format to use.  Since
10365    the entries in the agenda are collected from different files, and
10366    different files may have different columns formats, this is
10367    a non-trivial problem.  Org first checks if the variable
10368    ~org-overriding-columns-format~ is currently set, and if so, takes
10369    the format from there.  Otherwise it takes the format associated
10370    with the first item in the agenda, or, if that item does not have
10371    a specific format (defined in a property, or in its file), it uses
10372    ~org-columns-default-format~.
10375    #+cindex: @samp{CLOCKSUM}, special property
10376    If any of the columns has a summary type defined (see [[*Column
10377    attributes]]), turning on column view in the agenda visits all
10378    relevant agenda files and make sure that the computations of this
10379    property are up to date.  This is also true for the special
10380    =CLOCKSUM= property.  Org then sums the values displayed in the
10381    agenda.  In the daily/weekly agenda, the sums cover a single day;
10382    in all other views they cover the entire block.
10384    It is important to realize that the agenda may show the same entry
10385    /twice/---for example as scheduled and as a deadline---and it may
10386    show two entries from the same hierarchy (for example a /parent/
10387    and its /child/).  In these cases, the summation in the agenda
10388    leads to incorrect results because some values count double.
10390 3. When the column view in the agenda shows the =CLOCKSUM= property,
10391    that is always the entire clocked time for this item.  So even in
10392    the daily/weekly agenda, the clocksum listed in column view may
10393    originate from times outside the current view.  This has the
10394    advantage that you can compare these values with a column listing
10395    the planned total effort for a task---one of the major
10396    applications for column view in the agenda.  If you want
10397    information about clocked time in the displayed period use clock
10398    table mode (press {{{kbd(R)}}} in the agenda).
10401    #+cindex: @samp{CLOCKSUM_T}, special property
10402    When the column view in the agenda shows the =CLOCKSUM_T= property,
10403    that is always today's clocked time for this item.  So even in the
10404    weekly agenda, the clocksum listed in column view only originates
10405    from today.  This lets you compare the time you spent on a task for
10406    today, with the time already spent---via =CLOCKSUM=---and with
10407    the planned total effort for it.
10409 * Markup for Rich Contents
10410 :PROPERTIES:
10411 :DESCRIPTION: Compose beautiful documents.
10412 :END:
10414 Org is primarily about organizing and searching through your
10415 plain-text notes.  However, it also provides a lightweight yet robust
10416 markup language for rich text formatting and more.  For instance, you
10417 may want to center or emphasize text.  Or you may need to insert
10418 a formula or image in your writing.  Org offers syntax for all of this
10419 and more.  Used in conjunction with the export framework (see
10420 [[*Exporting]]), you can author beautiful documents in Org---like the fine
10421 manual you are currently reading.
10423 ** Paragraphs
10424 :PROPERTIES:
10425 :DESCRIPTION: The basic unit of text.
10426 :END:
10428 #+cindex: paragraphs, markup rules
10429 Paragraphs are separated by at least one empty line.  If you need to
10430 enforce a line break within a paragraph, use =\\= at the end of
10431 a line.
10433 #+cindex: line breaks, markup rules
10434 To preserve the line breaks, indentation and blank lines in a region,
10435 but otherwise use normal formatting, you can use this construct, which
10436 can also be used to format poetry.
10438 #+cindex: @samp{BEGIN_VERSE}
10439 #+cindex: verse blocks
10440 #+begin_example
10441 ,#+BEGIN_VERSE
10442  Great clouds overhead
10443  Tiny black birds rise and fall
10444  Snow covers Emacs
10446     ---AlexSchroeder
10447 ,#+END_VERSE
10448 #+end_example
10450 When quoting a passage from another document, it is customary to
10451 format this as a paragraph that is indented on both the left and the
10452 right margin.  You can include quotations in Org documents like this:
10454 #+cindex: @samp{BEGIN_QUOTE}
10455 #+cindex: quote blocks
10456 #+begin_example
10457 ,#+BEGIN_QUOTE
10458 Everything should be made as simple as possible,
10459 but not any simpler ---Albert Einstein
10460 ,#+END_QUOTE
10461 #+end_example
10463 If you would like to center some text, do it like this:
10465 #+cindex: @samp{BEGIN_CENTER}
10466 #+cindex: center blocks
10467 #+begin_example
10468 ,#+BEGIN_CENTER
10469 Everything should be made as simple as possible, \\
10470 but not any simpler
10471 ,#+END_CENTER
10472 #+end_example
10474 ** Emphasis and Monospace
10475 :PROPERTIES:
10476 :DESCRIPTION: Bold, italic, etc.
10477 :END:
10478 #+cindex: underlined text, markup rules
10479 #+cindex: bold text, markup rules
10480 #+cindex: italic text, markup rules
10481 #+cindex: verbatim text, markup rules
10482 #+cindex: code text, markup rules
10483 #+cindex: strike-through text, markup rules
10485 You can make words =*bold*=, =/italic/=, =_underlined_=, ==verbatim==
10486 and =~code~=, and, if you must, =+strike-through+=.  Text in the code
10487 and verbatim string is not processed for Org specific syntax; it is
10488 exported verbatim.
10490 #+vindex: org-fontify-emphasized-text
10491 To turn off fontification for marked up text, you can set
10492 ~org-fontify-emphasized-text~ to ~nil~.  To narrow down the list of
10493 available markup syntax, you can customize ~org-emphasis-alist~.
10495 ** Subscripts and Superscripts
10496 :PROPERTIES:
10497 :DESCRIPTION: Simple syntax for raising/lowering text.
10498 :END:
10499 #+cindex: subscript
10500 #+cindex: superscript
10502 =^= and =_= are used to indicate super- and subscripts.  To increase
10503 the readability of ASCII text, it is not necessary, but OK, to
10504 surround multi-character sub- and superscripts with curly braces.  For
10505 example
10507 #+begin_example
10508 The radius of the sun is R_sun = 6.96 x 10^8 m.  On the other hand,
10509 the radius of Alpha Centauri is R_{Alpha Centauri} = 1.28 x R_{sun}.
10510 #+end_example
10512 #+vindex: org-use-sub-superscripts
10513 If you write a text where the underscore is often used in a different
10514 context, Org's convention to always interpret these as subscripts can
10515 get in your way.  Configure the variable ~org-use-sub-superscripts~ to
10516 change this convention.  For example, when setting this variable to
10517 ~{}~, =a_b= is not interpreted as a subscript, but =a_{b}= is.
10519 - {{{kbd(C-c C-x \)}}} (~org-toggle-pretty-entities~) ::
10521   #+kindex: C-c C-x \
10522   #+findex: org-toggle-pretty-entities
10523   This command formats sub- and superscripts in a WYSIWYM way.
10525 ** Special Symbols
10526 :PROPERTIES:
10527 :DESCRIPTION: Greek letters and other symbols.
10528 :END:
10529 #+cindex: math symbols
10530 #+cindex: special symbols
10531 #+cindex: entities
10533 You can use LaTeX-like syntax to insert special symbols---named
10534 entities---like =\alpha= to indicate the Greek letter, or =\to= to indicate
10535 an arrow.  Completion for these symbols is available, just type =\=
10536 and maybe a few letters, and press {{{kbd(M-TAB)}}} to see possible
10537 completions.  If you need such a symbol inside a word, terminate it
10538 with a pair of curly brackets.  For example
10540 #+begin_example
10541 Pro tip: Given a circle \Gamma of diameter d, the length of its
10542 circumference is \pi{}d.
10543 #+end_example
10545 #+findex: org-entities-help
10546 #+vindex: org-entities-user
10547 A large number of entities is provided, with names taken from both
10548 HTML and LaTeX; you can comfortably browse the complete list from
10549 a dedicated buffer using the command ~org-entities-help~.  It is also
10550 possible to provide your own special symbols in the variable
10551 ~org-entities-user~.
10553 During export, these symbols are transformed into the native format of
10554 the exporter back-end.  Strings like =\alpha= are exported as =&alpha;= in
10555 the HTML output, and as =\(\alpha\)= in the LaTeX output.  Similarly, =\nbsp=
10556 becomes =&nbsp;= in HTML and =~= in LaTeX.
10558 #+cindex: special symbols, in-buffer display
10559 If you would like to see entities displayed as UTF-8 characters, use
10560 the following command[fn:106]:
10562 - {{{kbd(C-c C-x \)}}} (~org-toggle-pretty-entities~) ::
10563   #+kindex: C-c C-x \
10564   #+findex: org-toggle-pretty-entities
10566   Toggle display of entities as UTF-8 characters.  This does not
10567   change the buffer content which remains plain ASCII, but it overlays
10568   the UTF-8 character for display purposes only.
10570 #+cindex: shy hyphen, special symbol
10571 #+cindex: dash, special symbol
10572 #+cindex: ellipsis, special symbol
10573 In addition to regular entities defined above, Org exports in
10574 a special way[fn:107] the following commonly used character
10575 combinations: =\-= is treated as a shy hyphen, =--= and =---= are
10576 converted into dashes, and =...= becomes a compact set of dots.
10578 ** Embedded LaTeX
10579 :PROPERTIES:
10580 :DESCRIPTION: LaTeX can be freely used inside Org documents.
10581 :END:
10582 #+cindex: @TeX{} interpretation
10583 #+cindex: @LaTeX{} interpretation
10585 Plain ASCII is normally sufficient for almost all note taking.
10586 Exceptions include scientific notes, which often require mathematical
10587 symbols and the occasional formula.  LaTeX[fn:108] is widely used to
10588 typeset scientific documents.  Org mode supports embedding LaTeX code
10589 into its files, because many academics are used to writing and reading
10590 LaTeX source code, and because it can be readily processed to produce
10591 pretty output for a number of export back-ends.
10593 *** LaTeX fragments
10594 :PROPERTIES:
10595 :DESCRIPTION: Complex formulas made easy.
10596 :END:
10597 #+cindex: @LaTeX{} fragments
10599 #+vindex: org-format-latex-header
10600 Org mode can contain LaTeX math fragments, and it supports ways to
10601 process these for several export back-ends.  When exporting to LaTeX,
10602 the code is left as it is.  When exporting to HTML, Org can use either
10603 [[http://www.mathjax.org][MathJax]] (see [[*Math formatting in HTML export]]) or transcode the math
10604 into images (see [[*Previewing LaTeX fragments]]).
10606 LaTeX fragments do not need any special marking at all.  The following
10607 snippets are identified as LaTeX source code:
10609 - Environments of any kind[fn:109].  The only requirement is that the
10610   =\begin= statement appears on a new line, preceded by only
10611   whitespace.
10613 - Text within the usual LaTeX math delimiters.  To avoid conflicts
10614   with currency specifications, single =$= characters are only
10615   recognized as math delimiters if the enclosed text contains at most
10616   two line breaks, is directly attached to the =$= characters with no
10617   whitespace in between, and if the closing =$= is followed by
10618   whitespace, punctuation or a dash.  For the other delimiters, there
10619   is no such restriction, so when in doubt, use =\(...\)= as inline
10620   math delimiters.
10622 #+texinfo: @noindent
10623 For example:
10625 #+begin_example
10626 \begin{equation}                        % arbitrary environments,
10627 x=\sqrt{b}                              % even tables, figures
10628 \end{equation}                          % etc
10630 If $a^2=b$ and \( b=2 \), then the solution must be
10631 either $$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \].
10632 #+end_example
10634 #+vindex: org-export-with-latex
10635 LaTeX processing can be configured with the variable
10636 ~org-export-with-latex~.  The default setting is ~t~ which means
10637 MathJax for HTML, and no processing for ASCII and LaTeX back-ends.
10638 You can also set this variable on a per-file basis using one of these
10639 lines:
10641 | =#+OPTIONS: tex:t=        | Do the right thing automatically (MathJax) |
10642 | =#+OPTIONS: tex:nil=      | Do not process LaTeX fragments at all      |
10643 | =#+OPTIONS: tex:verbatim= | Verbatim export, for jsMath or so          |
10645 *** Previewing LaTeX fragments
10646 :PROPERTIES:
10647 :DESCRIPTION: What will this snippet look like?
10648 :END:
10649 #+cindex: @LaTeX{} fragments, preview
10651 #+vindex: org-preview-latex-default-process
10652 If you have a working LaTeX installation and =dvipng=, =dvisvgm= or
10653 =convert= installed[fn:110], LaTeX fragments can be processed to
10654 produce images of the typeset expressions to be used for inclusion
10655 while exporting to HTML (see [[*LaTeX fragments]]), or for inline
10656 previewing within Org mode.
10658 #+vindex: org-format-latex-options
10659 #+vindex: org-format-latex-header
10660 You can customize the variables ~org-format-latex-options~ and
10661 ~org-format-latex-header~ to influence some aspects of the preview.
10662 In particular, the ~:scale~ (and for HTML export, ~:html-scale~)
10663 property of the former can be used to adjust the size of the preview
10664 images.
10666 - {{{kbd(C-c C-x C-l)}}} (~org-latex-preview~) ::
10667   #+kindex: C-c C-x C-l
10668   #+findex: org-latex-preview
10670   Produce a preview image of the LaTeX fragment at point and overlay
10671   it over the source code.  If there is no fragment at point, process
10672   all fragments in the current entry---between two headlines.
10674   When called with a single prefix argument, clear all images in the
10675   current entry.  Two prefix arguments produce a preview image for all
10676   fragments in the buffer, while three of them clear all the images in
10677   that buffer.
10679 #+vindex: org-startup-with-latex-preview
10680 You can turn on the previewing of all LaTeX fragments in a file with
10682 : #+STARTUP: latexpreview
10684 To disable it, simply use
10686 : #+STARTUP: nolatexpreview
10688 *** Using CDLaTeX to enter math
10689 :PROPERTIES:
10690 :DESCRIPTION: Speed up entering of formulas.
10691 :ALT_TITLE: CDLaTeX mode
10692 :END:
10693 #+cindex: CD@LaTeX{}
10695 CDLaTeX mode is a minor mode that is normally used in combination with
10696 a major LaTeX mode like AUCTeX in order to speed-up insertion of
10697 environments and math templates.  Inside Org mode, you can make use of
10698 some of the features of CDLaTeX mode.  You need to install
10699 =cdlatex.el= and =texmathp.el= (the latter comes also with AUCTeX)
10700 from [[http://www.astro.uva.nl/~dominik/Tools/cdlatex]].  Do not use
10701 CDLaTeX mode itself under Org mode, but use the light version
10702 ~org-cdlatex-mode~ that comes as part of Org mode.  Turn it on for the
10703 current buffer with {{{kbd(M-x org-cdlatex-mode)}}}, or for all Org
10704 files with
10706 #+begin_src emacs-lisp
10707 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
10708 #+end_src
10710 When this mode is enabled, the following features are present (for
10711 more details see the documentation of CDLaTeX mode):
10713 #+attr_texinfo: :sep ,
10714 - {{{kbd(C-c {)}}} ::
10715   #+kindex: C-c @{
10717   Insert an environment template.
10719 - {{{kbd(TAB)}}} ::
10720   #+kindex: TAB
10722   The {{{kbd(TAB)}}} key expands the template if point is inside
10723   a LaTeX fragment[fn:111].  For example, {{{kbd(TAB)}}} expands =fr=
10724   to =\frac{}{}= and position point correctly inside the first brace.
10725   Another {{{kbd(TAB)}}} gets you into the second brace.
10727   Even outside fragments, {{{kbd(TAB)}}} expands environment
10728   abbreviations at the beginning of a line.  For example, if you write
10729   =equ= at the beginning of a line and press {{{kbd(TAB)}}}, this
10730   abbreviation is expanded to an =equation= environment.  To get
10731   a list of all abbreviations, type {{{kbd(M-x
10732   cdlatex-command-help)}}}.
10734 - {{{kbd(^)}}}, {{{kbd(_)}}} ::
10735   #+kindex: _
10736   #+kindex: ^
10737   #+vindex: cdlatex-simplify-sub-super-scripts
10739   Pressing {{{kbd(_)}}} and {{{kbd(^)}}} inside a LaTeX fragment
10740   inserts these characters together with a pair of braces.  If you use
10741   {{{kbd(TAB)}}} to move out of the braces, and if the braces surround
10742   only a single character or macro, they are removed again (depending
10743   on the variable ~cdlatex-simplify-sub-super-scripts~).
10745 - {{{kbd(`)}}} ::
10746   #+kindex: `
10748   Pressing the backquote followed by a character inserts math macros,
10749   also outside LaTeX fragments.  If you wait more than 1.5 seconds
10750   after the backquote, a help window pops up.
10752 - {{{kbd(')}}} ::
10753   #+kindex: '
10755   Pressing the single-quote followed by another character modifies the
10756   symbol before point with an accent or a font.  If you wait more than
10757   1.5 seconds after the single-quote, a help window pops up.
10758   Character modification works only inside LaTeX fragments; outside
10759   the quote is normal.
10761 ** Literal Examples
10762 :PROPERTIES:
10763 :DESCRIPTION: Source code examples with special formatting.
10764 :END:
10765 #+cindex: literal examples, markup rules
10766 #+cindex: code line references, markup rules
10768 You can include literal examples that should not be subjected to
10769 markup.  Such examples are typeset in monospace, so this is well
10770 suited for source code and similar examples.
10772 #+cindex: @samp{BEGIN_EXAMPLE}
10773 #+cindex: example block
10774 #+begin_example
10775 ,#+BEGIN_EXAMPLE
10776   Some example from a text file.
10777 ,#+END_EXAMPLE
10778 #+end_example
10780 Note that such blocks may be /indented/ in order to align nicely with
10781 indented text and in particular with plain list structure (see
10782 [[*Plain Lists]]).  For simplicity when using small examples, you can
10783 also start the example lines with a colon followed by a space.  There
10784 may also be additional whitespace before the colon:
10786 #+begin_example
10787 Here is an example
10788    : Some example from a text file.
10789 #+end_example
10791 #+cindex: formatting source code, markup rules
10792 #+vindex: org-latex-listings
10793 If the example is source code from a programming language, or any
10794 other text that can be marked up by Font Lock in Emacs, you can ask
10795 for the example to look like the fontified Emacs buffer[fn:112].  This
10796 is done with the code block, where you also need to specify the name
10797 of the major mode that should be used to fontify the example[fn:113],
10798 see [[*Structure Templates]] for shortcuts to easily insert code blocks.
10800 #+cindex: @samp{BEGIN_SRC}
10801 #+cindex: source block
10802 #+begin_example
10803 ,#+BEGIN_SRC emacs-lisp
10804   (defun org-xor (a b)
10805     "Exclusive or."
10806     (if a (not b) b))
10807  ,#+END_SRC
10808 #+end_example
10810 Both in =example= and in =src= snippets, you can add a =-n= switch to
10811 the end of the =#+BEGIN= line, to get the lines of the example
10812 numbered.  The =-n= takes an optional numeric argument specifying the
10813 starting line number of the block.  If you use a =+n= switch, the
10814 numbering from the previous numbered snippet is continued in the
10815 current one.  The =+n= switch can also take a numeric argument.  This
10816 adds the value of the argument to the last line of the previous block
10817 to determine the starting line number.
10819 #+begin_example
10820 ,#+BEGIN_SRC emacs-lisp -n 20
10821   ;; This exports with line number 20.
10822   (message "This is line 21")
10823 ,#+END_SRC
10825 ,#+BEGIN_SRC emacs-lisp +n 10
10826   ;; This is listed as line 31.
10827   (message "This is line 32")
10828 ,#+END_SRC
10829 #+end_example
10831 In literal examples, Org interprets strings like =(ref:name)= as
10832 labels, and use them as targets for special hyperlinks like
10833 =[[(name)]]=---i.e., the reference name enclosed in single parenthesis.
10834 In HTML, hovering the mouse over such a link remote-highlights the
10835 corresponding code line, which is kind of cool.
10837 You can also add a =-r= switch which /removes/ the labels from the
10838 source code[fn:114].  With the =-n= switch, links to these references
10839 are labeled by the line numbers from the code listing.  Otherwise
10840 links use the labels with no parentheses.  Here is an example:
10842 #+begin_example -l "(dumb-reference:%s)"
10843 ,#+BEGIN_SRC emacs-lisp -n -r
10844   (save-excursion                 (ref:sc)
10845      (goto-char (point-min))      (ref:jump)
10846 ,#+END_SRC
10847 In line [[(sc)]] we remember the current position. [[(jump)][Line (jump)]]
10848 jumps to point-min.
10849 #+end_example
10851 #+cindex: indentation, in source blocks
10852 Finally, you can use =-i= to preserve the indentation of a specific
10853 code block (see [[*Editing Source Code]]).
10855 #+vindex: org-coderef-label-format
10856 If the syntax for the label format conflicts with the language syntax,
10857 use a =-l= switch to change the format, for example
10859 : #+BEGIN_SRC pascal -n -r -l "((%s))"
10861 #+texinfo: @noindent
10862 See also the variable ~org-coderef-label-format~.
10864 HTML export also allows examples to be published as text areas (see
10865 [[*Text areas in HTML export]]).
10867 Because the =#+BEGIN= ... =#+END= patterns need to be added so often,
10868 a shortcut is provided (see [[*Structure Templates]]).
10870 - {{{kbd(C-c ')}}} (~org-edit-special~) ::
10872   #+kindex: C-c '
10873   #+findex: org-edit-special
10874   Edit the source code example at point in its native mode.  This
10875   works by switching to a temporary buffer with the source code.  You
10876   need to exit by pressing {{{kbd(C-c ')}}} again[fn:115].  The edited
10877   version then replaces the old version in the Org buffer.
10878   Fixed-width regions---where each line starts with a colon followed
10879   by a space---are edited using ~artist-mode~[fn:116] to allow
10880   creating ASCII drawings easily.  Using this command in an empty line
10881   creates a new fixed-width region.
10883 #+cindex: storing link, in a source code buffer
10884 Calling ~org-store-link~ (see [[*Handling Links]]) while editing a source
10885 code example in a temporary buffer created with {{{kbd(C-c ')}}}
10886 prompts for a label.  Make sure that it is unique in the current
10887 buffer, and insert it with the proper formatting like =(ref:label)= at
10888 the end of the current line.  Then the label is stored as a link
10889 =(label)=, for retrieval with {{{kbd(C-c C-l)}}}.
10891 ** Images
10892 :PROPERTIES:
10893 :DESCRIPTION: Display an image.
10894 :END:
10896 #+cindex: inlining images
10897 #+cindex: images, markup rules
10898 An image is a link to an image file[fn:117] that does not have
10899 a description part, for example
10901 : ./img/cat.jpg
10903 If you wish to define a caption for the image (see [[*Captions]]) and
10904 maybe a label for internal cross references (see [[*Internal Links]]),
10905 make sure that the link is on a line by itself and precede it with
10906 =CAPTION= and =NAME= keywords as follows:
10908 #+begin_example
10909 ,#+CAPTION: This is the caption for the next figure link (or table)
10910 ,#+NAME:   fig:SED-HR4049
10911 [[./img/a.jpg]]
10912 #+end_example
10914 Such images can be displayed within the buffer with the following
10915 command:
10917 - {{{kbd(C-c C-x C-v)}}} (~org-toggle-inline-images~) ::
10919   #+kindex: C-c C-x C-v
10920   #+findex: org-toggle-inline-images
10921   #+vindex: org-startup-with-inline-images
10922   Toggle the inline display of linked images.  When called with
10923   a prefix argument, also display images that do have a link
10924   description.  You can ask for inline images to be displayed at
10925   startup by configuring the variable
10926   ~org-startup-with-inline-images~[fn:118].
10928 ** Captions
10929 :PROPERTIES:
10930 :DESCRIPTION: Describe tables, images...
10931 :END:
10932 #+cindex: captions, markup rules
10933 #+cindex: @samp{CAPTION}, keyword
10935 You can assign a caption to a specific part of a document by inserting
10936 a =CAPTION= keyword immediately before it:
10938 #+begin_example
10939 ,#+CAPTION: This is the caption for the next table (or link)
10940 | ... | ... |
10941 |-----+-----|
10942 #+end_example
10944 Optionally, the caption can take the form:
10946 : #+CAPTION[Short caption]: Longer caption.
10948 Even though images and tables are prominent examples of captioned
10949 structures, the same caption mechanism can apply to many
10950 others---e.g., LaTeX equations, source code blocks.  Depending on the
10951 export back-end, those may or may not be handled.
10953 ** Horizontal Rules
10954 :PROPERTIES:
10955 :DESCRIPTION: Make a line.
10956 :END:
10958 #+cindex: horizontal rules, markup rules
10959 A line consisting of only dashes, and at least 5 of them, is exported
10960 as a horizontal line.
10962 ** Creating Footnotes
10963 :PROPERTIES:
10964 :DESCRIPTION: Edit and read footnotes.
10965 :END:
10966 #+cindex: footnotes
10968 A footnote is started by a footnote marker in square brackets in
10969 column 0, no indentation allowed.  It ends at the next footnote
10970 definition, headline, or after two consecutive empty lines.  The
10971 footnote reference is simply the marker in square brackets, inside
10972 text.  Markers always start with =fn:=.  For example:
10974 #+begin_example
10975 The Org homepage[fn:1] now looks a lot better than it used to.
10977 [fn:1] The link is: https://orgmode.org
10978 #+end_example
10980 Org mode extends the number-based syntax to /named/ footnotes and
10981 optional inline definition.  Here are the valid references:
10983 - =[fn:NAME]= ::
10985   A named footnote reference, where {{{var(NAME)}}} is a unique
10986   label word, or, for simplicity of automatic creation, a number.
10988 - =[fn:: This is the inline definition of this footnote]= ::
10990   An anonymous footnote where the definition is given directly at the
10991   reference point.
10993 - =[fn:NAME: a definition]= ::
10995   An inline definition of a footnote, which also specifies a name for
10996   the note.  Since Org allows multiple references to the same note,
10997   you can then use =[fn:NAME]= to create additional references.
10999 #+vindex: org-footnote-auto-label
11000 Footnote labels can be created automatically, or you can create names
11001 yourself.  This is handled by the variable ~org-footnote-auto-label~
11002 and its corresponding =STARTUP= keywords.  See the docstring of that
11003 variable for details.
11005 The following command handles footnotes:
11007 - {{{kbd(C-c C-x f)}}} ::
11009   The footnote action command.
11011   #+kindex: C-c C-x f
11012   When point is on a footnote reference, jump to the definition.  When
11013   it is at a definition, jump to the---first---reference.
11015   #+vindex: org-footnote-define-inline
11016   #+vindex: org-footnote-section
11017   Otherwise, create a new footnote.  Depending on the variable
11018   ~org-footnote-define-inline~[fn:119], the definition is placed right
11019   into the text as part of the reference, or separately into the
11020   location determined by the variable ~org-footnote-section~.
11022   When this command is called with a prefix argument, a menu of
11023   additional options is offered:
11025   #+attr_texinfo: :columns 0.1 0.9
11026   | {{{kbd(s)}}} | Sort the footnote definitions by reference sequence.               |
11027   | {{{kbd(r)}}} | Renumber the simple =fn:N= footnotes.                              |
11028   | {{{kbd(S)}}} | Short for first {{{kbd(r)}}}, then {{{kbd(s)}}} action.            |
11029   | {{{kbd(n)}}} | Rename all footnotes into a =fn:1= ... =fn:n= sequence.            |
11030   | {{{kbd(d)}}} | Delete the footnote at point, including definition and references. |
11032   #+vindex: org-footnote-auto-adjust
11033   Depending on the variable ~org-footnote-auto-adjust~[fn:120],
11034   renumbering and sorting footnotes can be automatic after each
11035   insertion or deletion.
11037 - {{{kbd(C-c C-c)}}} ::
11039   #+kindex: C-c C-c
11040   If point is on a footnote reference, jump to the definition.  If it
11041   is at the definition, jump back to the reference.  When called at
11042   a footnote location with a prefix argument, offer the same menu as
11043   {{{kbd(C-c C-x f)}}}.
11045 - {{{kbd(C-c C-o)}}} or {{{kbd(mouse-1/2)}}} ::
11047   #+kindex: C-c C-o
11048   #+kindex: mouse-1
11049   #+kindex: mouse-2
11050   Footnote labels are also links to the corresponding definition or
11051   reference, and you can use the usual commands to follow these links.
11053 * Exporting
11054 :PROPERTIES:
11055 :DESCRIPTION: Sharing and publishing notes.
11056 :END:
11057 #+cindex: exporting
11059 At some point you might want to print your notes, publish them on the
11060 web, or share them with people not using Org.  Org can convert and
11061 export documents to a variety of other formats while retaining as much
11062 structure (see [[*Document Structure]]) and markup (see [[*Markup for Rich
11063 Contents]]) as possible.
11065 #+cindex: export back-end
11066 The libraries responsible for translating Org files to other formats
11067 are called /back-ends/.  Org ships with support for the following
11068 back-ends:
11070 - /ascii/ (ASCII format)
11071 - /beamer/ (LaTeX Beamer format)
11072 - /html/ (HTML format)
11073 - /icalendar/ (iCalendar format)
11074 - /latex/ (LaTeX format)
11075 - /md/ (Markdown format)
11076 - /odt/ (OpenDocument Text format)
11077 - /org/ (Org format)
11078 - /texinfo/ (Texinfo format)
11079 - /man/ (Man page format)
11081 Users can install libraries for additional formats from the Emacs
11082 packaging system. For easy discovery, these packages have a common
11083 naming scheme: ~ox-NAME~, where {{{var(NAME)}}} is a format.  For
11084 example, ~ox-koma-letter~ for /koma-letter/ back-end.  More libraries
11085 can be found in the =contrib/= directory (see [[*Installation]]).
11087 #+vindex: org-export-backends
11088 Org only loads back-ends for the following formats by default: ASCII,
11089 HTML, iCalendar, LaTeX, and ODT.  Additional back-ends can be loaded
11090 in either of two ways: by configuring the ~org-export-backends~
11091 variable, or by requiring libraries in the Emacs init file.  For
11092 example, to load the Markdown back-end, add this to your Emacs config:
11094 #+begin_src emacs-lisp
11095 (require 'ox-md)
11096 #+end_src
11098 ** The Export Dispatcher
11099 :PROPERTIES:
11100 :DESCRIPTION: The main interface.
11101 :END:
11102 #+cindex: dispatcher, for export commands
11103 #+cindex: export, dispatcher
11105 The export dispatcher is the main interface for Org's exports.
11106 A hierarchical menu presents the currently configured export formats.
11107 Options are shown as easy toggle switches on the same screen.
11109 #+vindex: org-export-dispatch-use-expert-ui
11110 Org also has a minimal prompt interface for the export dispatcher.
11111 When the variable ~org-export-dispatch-use-expert-ui~ is set to
11112 a non-~nil~ value, Org prompts in the minibuffer.  To switch back to
11113 the hierarchical menu, press {{{kbd(?)}}}.
11115 - {{{kbd(C-c C-e)}}} (~org-export~) ::
11116   #+kindex: C-c C-e
11117   #+findex: org-export
11119   Invokes the export dispatcher interface.  The options show default
11120   settings.  The {{{kbd(C-u)}}} prefix argument preserves options from
11121   the previous export, including any sub-tree selections.
11123 Org exports the entire buffer by default.  If the Org buffer has an
11124 active region, then Org exports just that region.
11126 Within the dispatcher interface, the following key combinations can
11127 further alter what is exported, and how.
11129 - {{{kbd(C-a)}}} ::
11130   #+kindex: C-c C-e C-a
11132   Toggle asynchronous export.  Asynchronous export uses an external
11133   Emacs process with a specially configured initialization file to
11134   complete the exporting process in the background, without tying-up
11135   Emacs.  This is particularly useful when exporting long documents.
11137   Output from an asynchronous export is saved on the /export stack/.
11138   To view this stack, call the export dispatcher with a double
11139   {{{kbd(C-u)}}} prefix argument.  If already in the export dispatcher
11140   menu, {{{kbd(&)}}} displays the stack.
11142   #+vindex: org-export-in-background
11143   You can make asynchronous export the default by setting
11144   ~org-export-in-background~.
11146   #+vindex: org-export-async-init-file
11147   You can set the initialization file used by the background process
11148   by setting ~org-export-async-init-file~.
11150 - {{{kbd(C-b)}}} ::
11151   #+kindex: C-c C-e C-b
11153   Toggle body-only export.  Useful for excluding headers and footers
11154   in the export.  Affects only those back-end formats that have
11155   sections like =<head>...</head>= in HTML.
11157 - {{{kbd(C-s)}}} ::
11158   #+kindex: C-c C-e C-s
11160   Toggle sub-tree export.  When turned on, Org exports only the
11161   sub-tree starting from point position at the time the export
11162   dispatcher was invoked.  Org uses the top heading of this sub-tree
11163   as the document's title.  If point is not on a heading, Org uses the
11164   nearest enclosing header.  If point is in the document preamble, Org
11165   signals an error and aborts export.
11167   #+vindex: org-export-initial-scope
11168   To make sub-tree export the default, customize the variable
11169   ~org-export-initial-scope~.
11171 - {{{kbd(C-v)}}} ::
11172   #+kindex: C-c C-e C-v
11174   Toggle visible-only export.  This is useful for exporting only
11175   certain parts of an Org document by adjusting the visibility of
11176   particular headings.
11178 ** Export Settings
11179 :PROPERTIES:
11180 :DESCRIPTION: Common export settings.
11181 :END:
11182 #+cindex: options, for export
11183 #+cindex: Export, settings
11185 #+cindex: @samp{OPTIONS}, keyword
11186 Export options can be set: globally with variables; for an individual
11187 file by making variables buffer-local with in-buffer settings (see
11188 [[*Summary of In-Buffer Settings]]); by setting individual keywords or
11189 specifying them in compact form with the =OPTIONS= keyword; or for
11190 a tree by setting properties (see [[*Properties and Columns]]).  Options
11191 set at a specific level override options set at a more general level.
11193 #+cindex: @samp{SETUPFILE}, keyword
11194 In-buffer settings may appear anywhere in the file, either directly or
11195 indirectly through a file included using =#+SETUPFILE: filename or
11196 URL= syntax.  Option keyword sets tailored to a particular back-end
11197 can be inserted from the export dispatcher (see [[*The Export
11198 Dispatcher]]) using the =Insert template= command by pressing
11199 {{{kbd(#)}}}.  To insert keywords individually, a good way to make
11200 sure the keyword is correct is to type =#+= and then to use
11201 {{{kbd(M-TAB)}}}[fn:16] for completion.
11203 The export keywords available for every back-end, and their equivalent
11204 global variables, include:
11206 - =AUTHOR= ::
11208   #+cindex: @samp{AUTHOR}, keyword
11209   #+vindex: user-full-name
11210   The document author (~user-full-name~).
11212 - =CREATOR= ::
11214   #+cindex: @samp{CREATOR}, keyword
11215   #+vindex: org-expot-creator-string
11216   Entity responsible for output generation
11217   (~org-export-creator-string~).
11219 - =DATE= ::
11221   #+cindex: @samp{DATE}, keyword
11222   #+vindex: org-export-date-timestamp-format
11223   A date or a time-stamp[fn:121].
11225 - =EMAIL= ::
11227   #+cindex: @samp{EMAIL}, keyword
11228   #+vindex: user-mail-address
11229   The email address (~user-mail-address~).
11231 - =LANGUAGE= ::
11233   #+cindex: @samp{LANGUAGE}, keyword
11234   #+vindex: org-export-default-language
11235   Language to use for translating certain strings
11236   (~org-export-default-language~).  With =#+LANGUAGE: fr=, for
11237   example, Org translates =Table of contents= to the French =Table des
11238   matières=[fn:122].
11240 - =SELECT_TAGS= ::
11242   #+cindex: @samp{SELECT_TAGS}, keyword
11243   #+vindex: org-export-select-tags
11244   The default value is =("export")=.  When a tree is tagged with
11245   =export= (~org-export-select-tags~), Org selects that tree and its
11246   sub-trees for export.  Org excludes trees with =noexport= tags, see
11247   below.  When selectively exporting files with =export= tags set, Org
11248   does not export any text that appears before the first headline.
11250 - =EXCLUDE_TAGS= ::
11252   #+cindex: @samp{EXCLUDE_TAGS}, keyword
11253   #+vindex: org-export-exclude-tags
11254   The default value is =("noexport")=.  When a tree is tagged with
11255   =noexport= (~org-export-exclude-tags~), Org excludes that tree and
11256   its sub-trees from export.  Entries tagged with =noexport= are
11257   unconditionally excluded from the export, even if they have an
11258   =export= tag.  Even if a sub-tree is not exported, Org executes any
11259   code blocks contained there.
11261 - =TITLE= ::
11263   #+cindex: @samp{TITLE}, keyword
11264   #+cindex: document title
11265   Org displays this title.  For long titles, use multiple =#+TITLE=
11266   lines.
11268 - =EXPORT_FILE_NAME= ::
11270   #+cindex: @samp{EXPORT_FILE_NAME}, keyword
11271   The name of the output file to be generated.  Otherwise, Org
11272   generates the file name based on the buffer name and the extension
11273   based on the back-end format.
11275 The =OPTIONS= keyword is a compact form.  To configure multiple
11276 options, use several =OPTIONS= lines.  =OPTIONS= recognizes the
11277 following arguments.
11279 - ~'~ ::
11281   #+vindex: org-export-with-smart-quotes
11282   Toggle smart quotes (~org-export-with-smart-quotes~).  Depending on
11283   the language used, when activated, Org treats pairs of double quotes
11284   as primary quotes, pairs of single quotes as secondary quotes, and
11285   single quote marks as apostrophes.
11287 - ~*~ ::
11289   #+vindex: org-export-with-emphasize
11290   Toggle emphasized text (~org-export-with-emphasize~).
11292 - ~-~ ::
11294   #+vindex: org-export-with-special-strings
11295   Toggle conversion of special strings
11296   (~org-export-with-special-strings~).
11298 - ~:~ ::
11300   #+vindex: org-export-with-fixed-width
11301   Toggle fixed-width sections (~org-export-with-fixed-width~).
11303 - ~<~ ::
11305   #+vindex: org-export-with-timestamps
11306   Toggle inclusion of time/date active/inactive stamps
11307   (~org-export-with-timestamps~).
11309 - ~\n~ ::
11311   #+vindex: org-export-preserve-breaks
11312   Toggles whether to preserve line breaks
11313   (~org-export-preserve-breaks~).
11315 - ~^~ ::
11317   #+vindex: org-export-with-sub-superscripts
11318   Toggle TeX-like syntax for sub- and superscripts.  If you write
11319   =^:{}=, =a_{b}= is interpreted, but the simple =a_b= is left as it
11320   is (~org-export-with-sub-superscripts~).
11322 - ~arch~ ::
11324   #+vindex: org-export-with-archived-trees
11325   Configure how archived trees are exported.  When set to ~headline~,
11326   the export process skips the contents and processes only the
11327   headlines (~org-export-with-archived-trees~).
11329 - ~author~ ::
11331   #+vindex: org-export-with-author
11332   Toggle inclusion of author name into exported file
11333   (~org-export-with-author~).
11335 - ~broken-links~ ::
11337   #+vindex: org-export-with-broken-links
11338   Toggles if Org should continue exporting upon finding a broken
11339   internal link.  When set to ~mark~, Org clearly marks the problem
11340   link in the output (~org-export-with-broken-links~).
11342 - ~c~ ::
11344   #+vindex: org-export-with-clocks
11345   Toggle inclusion of =CLOCK= keywords (~org-export-with-clocks~).
11347 - ~creator~ ::
11349   #+vindex: org-export-with-creator
11350   Toggle inclusion of creator information in the exported file
11351   (~org-export-with-creator~).
11353 - ~d~ ::
11355   #+vindex: org-export-with-drawers
11356   Toggles inclusion of drawers, or list of drawers to include, or list
11357   of drawers to exclude (~org-export-with-drawers~).
11359 - ~date~ ::
11361   #+vindex: org-export-with-date
11362   Toggle inclusion of a date into exported file
11363   (~org-export-with-date~).
11365 - ~e~ ::
11367   #+vindex: org-export-with-entities
11368   Toggle inclusion of entities (~org-export-with-entities~).
11370 - ~email~ ::
11372   #+vindex: org-export-with-email
11373   Toggle inclusion of the author's e-mail into exported file
11374   (~org-export-with-email~).
11376 - ~f~ ::
11378   #+vindex: org-export-with-footnotes
11379   Toggle the inclusion of footnotes (~org-export-with-footnotes~).
11381 - ~H~ ::
11383   #+vindex: org-export-headline-levels
11384   Set the number of headline levels for export
11385   (~org-export-headline-levels~).  Below that level, headlines are
11386   treated differently.  In most back-ends, they become list items.
11388 - ~inline~ ::
11390   #+vindex: org-export-with-inlinetasks
11391   Toggle inclusion of inlinetasks (~org-export-with-inlinetasks~).
11393 - ~num~ ::
11395   #+vindex: org-export-with-section-numbers
11396   #+cindex: @samp{UNNUMBERED}, property
11397   Toggle section-numbers (~org-export-with-section-numbers~).  When
11398   set to number N, Org numbers only those headlines at level N or
11399   above.  Set =UNNUMBERED= property to non-~nil~ to disable numbering
11400   of heading and subheadings entirely.  Moreover, when the value is
11401   =notoc= the headline, and all its children, do not appear in the
11402   table of contents either (see [[*Table of Contents]]).
11404 - ~p~ ::
11406   #+vindex: org-export-with-planning
11407   Toggle export of planning information (~org-export-with-planning~).
11408   "Planning information" comes from lines located right after the
11409   headline and contain any combination of these cookies: =SCHEDULED=,
11410   =DEADLINE=, or =CLOSED=.
11412 - ~pri~ ::
11414   #+vindex: org-export-with-priority
11415   Toggle inclusion of priority cookies
11416   (~org-export-with-priority~).
11418 - ~prop~ ::
11420   #+vindex: org-export-with-properties
11421   Toggle inclusion of property drawers, or list the properties to
11422   include (~org-export-with-properties~).
11424 - ~stat~ ::
11426   #+vindex: org-export-with-statistics-cookies
11427   Toggle inclusion of statistics cookies
11428   (~org-export-with-statistics-cookies~).
11430 - ~tags~ ::
11432   #+vindex: org-export-with-tags
11433   Toggle inclusion of tags, may also be ~not-in-toc~
11434   (~org-export-with-tags~).
11436 - ~tasks~ ::
11438   #+vindex: org-export-with-tasks
11439   Toggle inclusion of tasks (TODO items); or ~nil~ to remove all
11440   tasks; or ~todo~ to remove done tasks; or list the keywords to keep
11441   (~org-export-with-tasks~).
11443 - ~tex~ ::
11445   #+vindex: org-export-with-latex
11446   ~nil~ does not export; ~t~ exports; ~verbatim~ keeps everything in
11447   verbatim (~org-export-with-latex~).
11449 - ~timestamp~ ::
11451   #+vindex: org-export-time-stamp-file
11452   Toggle inclusion of the creation time in the exported file
11453   (~org-export-time-stamp-file~).
11455 - ~title~ ::
11457   #+vindex: org-export-with-title
11458   Toggle inclusion of title (~org-export-with-title~).
11460 - ~toc~ ::
11462   #+vindex: org-export-with-toc
11463   Toggle inclusion of the table of contents, or set the level limit
11464   (~org-export-with-toc~).
11466 - ~todo~ ::
11468   #+vindex: org-export-with-todo-keywords
11469   Toggle inclusion of TODO keywords into exported text
11470   (~org-export-with-todo-keywords~).
11472 - ~|~ ::
11474   #+vindex: org-export-with-tables
11475   Toggle inclusion of tables (~org-export-with-tables~).
11477 When exporting sub-trees, special node properties can override the
11478 above keywords.  These properties have an =EXPORT_= prefix.  For
11479 example, =DATE= becomes, =EXPORT_DATE= when used for a specific
11480 sub-tree.  Except for =SETUPFILE=, all other keywords listed above
11481 have an =EXPORT_= equivalent.
11483 #+cindex: @samp{BIND}, keyword
11484 #+vindex: org-export-allow-bind-keywords
11485 If ~org-export-allow-bind-keywords~ is non-~nil~, Emacs variables can
11486 become buffer-local during export by using the =BIND= keyword.  Its
11487 syntax is =#+BIND: variable value=.  This is particularly useful for
11488 in-buffer settings that cannot be changed using keywords.
11490 ** Table of Contents
11491 :PROPERTIES:
11492 :DESCRIPTION: The if and where of the table of contents.
11493 :END:
11494 #+cindex: table of contents
11495 #+cindex: list of tables
11496 #+cindex: list of listings
11498 #+cindex: @samp{toc}, in @samp{OPTIONS} keyword
11499 #+vindex: org-export-with-toc
11500 The table of contents includes all headlines in the document.  Its
11501 depth is therefore the same as the headline levels in the file.  If
11502 you need to use a different depth, or turn it off entirely, set the
11503 ~org-export-with-toc~ variable accordingly.  You can achieve the same
11504 on a per file basis, using the following =toc= item in =OPTIONS=
11505 keyword:
11507 #+begin_example
11508 ,#+OPTIONS: toc:2          (only include two levels in TOC)
11509 ,#+OPTIONS: toc:nil        (no default TOC at all)
11510 #+end_example
11512 #+cindex: excluding entries from table of contents
11513 #+cindex: table of contents, exclude entries
11514 Org includes both numbered and unnumbered headlines in the table of
11515 contents[fn:123].  If you need to exclude an unnumbered headline,
11516 along with all its children, set the =UNNUMBERED= property to =notoc=
11517 value.
11519 #+begin_example
11520 ,* Subtree not numbered, not in table of contents either
11521   :PROPERTIES:
11522   :UNNUMBERED: notoc
11523   :END:
11524 #+end_example
11526 #+cindex: @samp{TOC}, keyword
11527 Org normally inserts the table of contents directly before the first
11528 headline of the file.  To move the table of contents to a different
11529 location, first turn off the default with ~org-export-with-toc~
11530 variable or with =#+OPTIONS: toc:nil=.  Then insert =#+TOC: headlines
11531 N= at the desired location(s).
11533 #+begin_example
11534 ,#+OPTIONS: toc:nil
11536 ,#+TOC: headlines 2
11537 #+end_example
11539 To adjust the table of contents depth for a specific section of the
11540 Org document, append an additional =local= parameter.  This parameter
11541 becomes a relative depth for the current level.  The following example
11542 inserts a local table of contents, with direct children only.
11544 #+begin_example
11545 ,* Section
11546 ,#+TOC: headlines 1 local
11547 #+end_example
11549 Note that for this feature to work properly in LaTeX export, the Org
11550 file requires the inclusion of the titletoc package.  Because of
11551 compatibility issues, titletoc has to be loaded /before/ hyperref.
11552 Customize the ~org-latex-default-packages-alist~ variable.
11554 Use the =TOC= keyword to generate list of tables---respectively, all
11555 listings---with captions.
11557 #+begin_example
11558 ,#+TOC: listings
11559 ,#+TOC: tables
11560 #+end_example
11562 #+cindex: @samp{ALT_TITLE}, property
11563 Normally Org uses the headline for its entry in the table of contents.
11564 But with =ALT_TITLE= property, a different entry can be specified for
11565 the table of contents.
11567 ** Include Files
11568 :PROPERTIES:
11569 :DESCRIPTION: Include additional files into a document.
11570 :END:
11571 #+cindex: include files, during export
11572 #+cindex: export, include files
11573 #+cindex: @samp{INCLUDE}, keyword
11575 During export, you can include the content of another file.  For
11576 example, to include your =.emacs= file, you could use:
11578 : #+INCLUDE: "~/.emacs" src emacs-lisp
11580 #+texinfo: @noindent
11581 The first parameter is the file name to include.  The optional second
11582 parameter specifies the block type: =example=, =export= or =src=.  The
11583 optional third parameter specifies the source code language to use for
11584 formatting the contents.  This is relevant to both =export= and =src=
11585 block types.
11587 If an included file is specified as having a markup language, Org
11588 neither checks for valid syntax nor changes the contents in any way.
11589 For example and source blocks, Org code-escapes the contents before
11590 inclusion.
11592 #+cindex: @samp{minlevel}, include
11593 If an included file is not specified as having any markup language,
11594 Org assumes it be in Org format and proceeds as usual with a few
11595 exceptions.  Org makes the footnote labels (see [[*Creating Footnotes]])
11596 in the included file local to that file.  The contents of the included
11597 file belong to the same structure---headline, item---containing the
11598 =INCLUDE= keyword.  In particular, headlines within the file become
11599 children of the current section.  That behavior can be changed by
11600 providing an additional keyword parameter, =:minlevel=.  It shifts the
11601 headlines in the included file to become the lowest level.  For
11602 example, this syntax makes the included file a sibling of the current
11603 top-level headline:
11605 : #+INCLUDE: "~/my-book/chapter2.org" :minlevel 1
11607 #+cindex: @samp{lines}, include
11608 Inclusion of only portions of files are specified using ranges
11609 parameter with =:lines= keyword.  The line at the upper end of the
11610 range will not be included.  The start and/or the end of the range may
11611 be omitted to use the obvious defaults.
11613 | =#+INCLUDE: "~/.emacs" :lines "5-10"= | Include lines 5 to 10, 10 excluded |
11614 | =#+INCLUDE: "~/.emacs" :lines "-10"=  | Include lines 1 to 10, 10 excluded |
11615 | =#+INCLUDE: "~/.emacs" :lines "10-"=  | Include lines from 10 to EOF       |
11617 Inclusions may specify a file-link to extract an object matched by
11618 ~org-link-search~[fn:124] (see [[*Search Options in File Links]]).  The
11619 ranges for =:lines= keyword are relative to the requested element.
11620 Therefore,
11622 : #+INCLUDE: "./paper.org::*conclusion" :lines 1-20
11624 #+texinfo: @noindent
11625 includes the first 20 lines of the headline named =conclusion=.
11627 #+cindex: @samp{only-contents}, include
11628 To extract only the contents of the matched object, set
11629 =:only-contents= property to non-~nil~.  This omits any planning lines
11630 or property drawers.  For example, to include the body of the heading
11631 with the custom ID =theory=, you can use
11633 : #+INCLUDE: "./paper.org::#theory" :only-contents t
11635 The following command allows navigating to the included document:
11637 - {{{kbd(C-c ')}}} (~org-edit~special~) ::
11638   #+kindex: C-c '
11639   #+findex: org-edit-special
11641   Visit the included file at point.
11643 ** Macro Replacement
11644 :PROPERTIES:
11645 :DESCRIPTION: Use macros to create templates.
11646 :END:
11647 #+cindex: macro replacement, during export
11648 #+cindex: @samp{MACRO}, keyword
11650 #+vindex: org-export-global-macros
11651 Macros replace text snippets during export.  Macros are defined
11652 globally in ~org-export-global-macros~, or document-wise with the
11653 following syntax:
11655 : #+MACRO: name   replacement text; $1, $2 are arguments
11657 #+texinfo: @noindent
11658 which can be referenced using ={{{name(arg1, arg2)}}}=[fn:125].  For
11659 example
11661 #+begin_example
11662 ,#+MACRO: poem Rose is $1, violet's $2. Life's ordered: Org assists you.
11663 {{{poem(red,blue)}}}
11664 #+end_example
11666 #+texinfo: @noindent
11667 becomes
11669 : Rose is red, violet's blue. Life's ordered: Org assists you.
11671 As a special case, Org parses any replacement text starting with
11672 =(eval= as an Emacs Lisp expression and evaluates it accordingly.
11673 Within such templates, arguments become strings.  Thus, the following
11674 macro
11676 : #+MACRO: gnustamp (eval (concat "GNU/" (capitalize $1)))
11678 #+texinfo: @noindent
11679 turns ={{{gnustamp(linux)}}}= into =GNU/Linux= during export.
11681 Org recognizes macro references in following Org markup areas:
11682 paragraphs, headlines, verse blocks, tables cells and lists.  Org also
11683 recognizes macro references in keywords, such as =CAPTION=, =TITLE=,
11684 =AUTHOR=, =DATE=, and for some back-end specific export options.
11686 Org comes with following pre-defined macros:
11688 #+attr_texinfo: :sep ;
11689 - ={{{keyword(NAME)}}}=; ={{{title}}}=; ={{{author}}}=; ={{{email}}}= ::
11691   #+cindex: @samp{keyword}, macro
11692   #+cindex: @samp{title}, macro
11693   #+cindex: @samp{author}, macro
11694   #+cindex: @samp{email}, macro
11695   The =keyword= macro collects all values from {{{var(NAME)}}}
11696   keywords throughout the buffer, separated with white space.
11697   =title=, =author= and =email= macros are shortcuts for,
11698   respectively, ={{{keyword(TITLE)}}}=, ={{{keyword(AUTHOR)}}}= and
11699   ={{{keyword(EMAIL)}}}=.
11701 - ={{{date}}}=; ={{{date(FORMAT)}}}= ::
11703   #+cindex: @samp{date}, macro
11704   This macro refers to the =DATE= keyword.  {{{var(FORMAT)}}} is an
11705   optional argument to the =date= macro that is used only if =DATE= is
11706   a single timestamp.  {{{var(FORMAT)}}} should be a format string
11707   understood by ~format-time-string~.
11709 - ={{{time(FORMAT)}}}=; ={{{modification-time(FORMAT, VC)}}}= ::
11711   #+cindex: @samp{time}, macro
11712   #+cindex: @samp{modification-time}, macro
11713   These macros refer to the document's date and time of export and
11714   date and time of modification.  {{{var(FORMAT)}}} is a string
11715   understood by ~format-time-string~.  If the second argument to the
11716   ~modification-time~ macro is non-~nil~, Org uses =vc.el= to retrieve
11717   the document's modification time from the version control system.
11718   Otherwise Org reads the file attributes.
11720 - ={{{input-file}}}= ::
11722   #+cindex: @samp{input-file}, macro
11723   This macro refers to the filename of the exported file.
11725 - ={{{property(PROPERTY-NAME)}}}=; ={{{property(PROPERTY-NAME, SEARCH OPTION)}}}= ::
11727   #+cindex: @samp{property}, macro
11728   This macro returns the value of property {{{var(PROPERTY-NAME)}}} in
11729   the current entry.  If {{{var(SEARCH-OPTION)}}} (see [[*Search
11730   Options in File Links]]) refers to a remote entry, use it instead.
11732 - ={{{n}}}=; ={{{n(NAME)}}}=; ={{{n(NAME, ACTION)}}}= ::
11734   #+cindex: @samp{n}, macro
11735   #+cindex: counter, macro
11736   This macro implements custom counters by returning the number of
11737   times the macro has been expanded so far while exporting the buffer.
11738   You can create more than one counter using different {{{var(NAME)}}}
11739   values.  If {{{var(ACTION)}}} is =-=, previous value of the counter
11740   is held, i.e., the specified counter is not incremented.  If the
11741   value is a number, the specified counter is set to that value.  If
11742   it is any other non-empty string, the specified counter is reset
11743   to 1.  You may leave {{{var(NAME)}}} empty to reset the default
11744   counter.
11746 #+cindex: @samp{results}, macro
11747 Moreover, inline source blocks (see [[*Structure of Code Blocks]]) use the
11748 special =results= macro to mark their output.  As such, you are
11749 advised against re-defining it, unless you know what you are doing.
11751 #+vindex: org-hide-macro-markers
11752 The surrounding brackets can be made invisible by setting
11753 ~org-hide-macro-markers~ to a non-~nil~ value.
11755 Org expands macros at the very beginning of the export process.
11757 ** Comment Lines
11758 :PROPERTIES:
11759 :DESCRIPTION: What will not be exported.
11760 :END:
11761 #+cindex: exporting, not
11763 #+cindex: comment lines
11764 Lines starting with zero or more whitespace characters followed by one
11765 =#= and a whitespace are treated as comments and, as such, are not
11766 exported.
11768 #+cindex: @samp{BEGIN_COMMENT}
11769 #+cindex: comment block
11770 Likewise, regions surrounded by =#+BEGIN_COMMENT= ... =#+END_COMMENT=
11771 are not exported.
11773 #+cindex: comment trees
11774 Finally, a =COMMENT= keyword at the beginning of an entry, but after
11775 any other keyword or priority cookie, comments out the entire subtree.
11776 In this case, the subtree is not exported and no code block within it
11777 is executed either[fn:126].  The command below helps changing the
11778 comment status of a headline.
11780 - {{{kbd(C-c ;)}}} (~org-toggle-comment~) ::
11781   #+kindex: C-c ;
11782   #+findex: org-toggle-comment
11784   Toggle the =COMMENT= keyword at the beginning of an entry.
11786 ** ASCII/Latin-1/UTF-8 export
11787 :PROPERTIES:
11788 :DESCRIPTION: Exporting to flat files with encoding.
11789 :END:
11790 #+cindex: ASCII export
11791 #+cindex: Latin-1 export
11792 #+cindex: UTF-8 export
11794 ASCII export produces an output file containing only plain ASCII
11795 characters.  This is the simplest and most direct text output.  It
11796 does not contain any Org markup.  Latin-1 and UTF-8 export use
11797 additional characters and symbols available in these encoding
11798 standards.  All three of these export formats offer the most basic of
11799 text output for maximum portability.
11801 #+vindex: org-ascii-text-width
11802 On export, Org fills and justifies text according to the text width
11803 set in ~org-ascii-text-width~.
11805 #+vindex: org-ascii-links-to-notes
11806 Org exports links using a footnote-like style where the descriptive
11807 part is in the text and the link is in a note before the next heading.
11808 See the variable ~org-ascii-links-to-notes~ for details.
11810 *** ASCII export commands
11811 :PROPERTIES:
11812 :UNNUMBERED: notoc
11813 :END:
11815 #+attr_texinfo: :sep ,
11816 - {{{kbd(C-c C-e t a)}}} (~org-ascii-export-to-ascii~), {{{kbd(C-c C-e t l)}}}, {{{kbd(C-c C-e t u)}}} ::
11817   #+kindex: C-c C-e t a
11818   #+kindex: C-c C-e t l
11819   #+kindex: C-c C-e t u
11820   #+findex: org-ascii-export-to-ascii
11822   Export as an ASCII file with a =.txt= extension.  For =myfile.org=,
11823   Org exports to =myfile.txt=, overwriting without warning.  For
11824   =myfile.txt=, Org exports to =myfile.txt.txt= in order to prevent
11825   data loss.
11827 - {{{kbd(C-c C-e t A)}}} (~org-ascii-export-to-ascii~), {{{kbd(C-c C-e t L)}}}, {{{kbd(C-c C-e t U)}}} ::
11828   #+kindex: C-c C-e t A
11829   #+kindex: C-c C-e t L
11830   #+kindex: C-c C-e t U
11831   #+findex: org-ascii-export-as-ascii
11833   Export to a temporary buffer.  Does not create a file.
11835 *** ASCII specific export settings
11836 :PROPERTIES:
11837 :UNNUMBERED: notoc
11838 :END:
11840 The ASCII export back-end has one extra keyword for customizing ASCII
11841 output.  Setting this keyword works similar to the general options
11842 (see [[*Export Settings]]).
11844 - =SUBTITLE= ::
11846   #+cindex: @samp{SUBTITLE}, keyword
11847   The document subtitle.  For long subtitles, use multiple
11848   =#+SUBTITLE= lines in the Org file.  Org prints them on one
11849   continuous line, wrapping into multiple lines if necessary.
11851 *** Header and sectioning structure
11852 :PROPERTIES:
11853 :UNNUMBERED: notoc
11854 :END:
11856 Org converts the first three outline levels into headlines for ASCII
11857 export.  The remaining levels are turned into lists.  To change this
11858 cut-off point where levels become lists, see [[*Export Settings]].
11860 *** Quoting ASCII text
11861 :PROPERTIES:
11862 :UNNUMBERED: notoc
11863 :END:
11865 To insert text within the Org file by the ASCII back-end, use one the
11866 following constructs, inline, keyword, or export block:
11868 #+cindex: @samp{ASCII}, keyword
11869 #+cindex: @samp{BEGIN_EXPORT ascii}
11870 #+begin_example
11871 Inline text @@ascii:and additional text@@ within a paragraph.
11873 ,#+ASCII: Some text
11875 ,#+BEGIN_EXPORT ascii
11876 Org exports text in this block only when using ASCII back-end.
11877 ,#+END_EXPORT
11878 #+end_example
11880 *** ASCII specific attributes
11881 :PROPERTIES:
11882 :UNNUMBERED: notoc
11883 :END:
11884 #+cindex: @samp{ATTR_ASCII}, keyword
11885 #+cindex: horizontal rules, in ASCII export
11887 ASCII back-end recognizes only one attribute, =:width=, which
11888 specifies the width of a horizontal rule in number of characters.  The
11889 keyword and syntax for specifying widths is:
11891 #+begin_example
11892 ,#+ATTR_ASCII: :width 10
11893 -----
11894 #+end_example
11896 *** ASCII special blocks
11897 :PROPERTIES:
11898 :UNNUMBERED: notoc
11899 :END:
11900 #+cindex: special blocks, in ASCII export
11901 #+cindex: @samp{BEGIN_JUSTIFYLEFT}
11902 #+cindex: @samp{BEGIN_JUSTIFYRIGHT}
11904 Besides =#+BEGIN_CENTER= blocks (see [[*Paragraphs]]), ASCII back-end has
11905 these two left and right justification blocks:
11907 #+begin_example
11908 ,#+BEGIN_JUSTIFYLEFT
11909 It's just a jump to the left...
11910 ,#+END_JUSTIFYLEFT
11912 ,#+BEGIN_JUSTIFYRIGHT
11913 ...and then a step to the right.
11914 ,#+END_JUSTIFYRIGHT
11915 #+end_example
11917 ** Beamer Export
11918 :PROPERTIES:
11919 :DESCRIPTION: Producing presentations and slides.
11920 :END:
11921 #+cindex: Beamer export
11923 Org uses Beamer export to convert an Org file tree structure into
11924 high-quality interactive slides for presentations.  Beamer is a LaTeX
11925 document class for creating presentations in PDF, HTML, and other
11926 popular display formats.
11928 *** Beamer export commands
11929 :PROPERTIES:
11930 :DESCRIPTION: For creating Beamer documents.
11931 :END:
11933 - {{{kbd(C-c C-e l b)}}} (~org-beamer-export-to-latex~) ::
11934   #+kindex: C-c C-e l b
11935   #+findex: org-beamer-export-to-latex
11937   Export as LaTeX file with a =.tex= extension.  For =myfile.org=, Org
11938   exports to =myfile.tex=, overwriting without warning.
11940 - {{{kbd(C-c C-e l B)}}} (~org-beamer-export-as-latex~) ::
11941   #+kindex: C-c C-e l B
11942   #+findex: org-beamer-export-as-latex
11944   Export to a temporary buffer.  Does not create a file.
11946 - {{{kbd(C-c C-e l P)}}} (~org-beamer-export-to-pdf~) ::
11947   #+kindex: C-c C-e l P
11948   #+findex: org-beamer-export-to-pdf
11950   Export as LaTeX file and then convert it to PDF format.
11952 - {{{kbd(C-c C-e l O)}}} ::
11953   #+kindex: C-c C-e l O
11955   Export as LaTeX file, convert it to PDF format, and then open the
11956   PDF file.
11958 *** Beamer specific export settings
11959 :PROPERTIES:
11960 :DESCRIPTION: For customizing Beamer export.
11961 :END:
11963 Beamer export back-end has several additional keywords for customizing
11964 Beamer output.  These keywords work similar to the general options
11965 settings (see [[*Export Settings]]).
11967 - =BEAMER_THEME= ::
11969   #+cindex: @samp{BEAMER_THEME}, keyword
11970   #+vindex: org-beamer-theme
11971   The Beamer layout theme (~org-beamer-theme~).  Use square brackets
11972   for options.  For example:
11974   : #+BEAMER_THEME: Rochester [height=20pt]
11976 - =BEAMER_FONT_THEME= ::
11978   #+cindex: @samp{BEAMER_FONT_THEME}, keyword
11979   The Beamer font theme.
11981 - =BEAMER_INNER_THEME= ::
11983   #+cindex: @samp{BEAMER_INNER_THEME}, keyword
11984   The Beamer inner theme.
11986 - =BEAMER_OUTER_THEME= ::
11988   #+cindex: @samp{BEAMER_OUTER_THEME}, keyword
11989   The Beamer outer theme.
11991 - =BEAMER_HEADER= ::
11993   #+cindex: @samp{BEAMER_HEADER}, keyword
11994   Arbitrary lines inserted in the preamble, just before the =hyperref=
11995   settings.
11997 - =DESCRIPTION= ::
11999   #+cindex: @samp{DESCRIPTION}, keyword
12000   The document description.  For long descriptions, use multiple
12001   =DESCRIPTION= keywords.  By default, =hyperref= inserts
12002   =DESCRIPTION= as metadata.  Use ~org-latex-hyperref-template~ to
12003   configure document metadata.  Use ~org-latex-title-command~ to
12004   configure typesetting of description as part of front matter.
12006 - =KEYWORDS= ::
12008   #+cindex: @samp{KEYWORDS}, keyword
12009   The keywords for defining the contents of the document.  Use
12010   multiple =KEYWORDS= lines if necessary.  By default, =hyperref=
12011   inserts =KEYWORDS= as metadata.  Use ~org-latex-hyperref-template~
12012   to configure document metadata.  Use ~org-latex-title-command~ to
12013   configure typesetting of keywords as part of front matter.
12015 - =SUBTITLE= ::
12017   #+cindex: @samp{SUBTITLE}, keyword
12018   Document's subtitle.  For typesetting, use
12019   ~org-beamer-subtitle-format~ string.  Use
12020   ~org-latex-hyperref-template~ to configure document metadata.  Use
12021   ~org-latex-title-command~ to configure typesetting of subtitle as
12022   part of front matter.
12024 *** Frames and Blocks in Beamer
12025 :PROPERTIES:
12026 :DESCRIPTION: For composing Beamer slides.
12027 :END:
12029 Org transforms heading levels into Beamer's sectioning elements,
12030 frames and blocks.  Any Org tree with a not-too-deep-level nesting
12031 should in principle be exportable as a Beamer presentation.
12034   #+vindex: org-beamer-frame-level
12035   Org headlines become Beamer frames when the heading level in Org is
12036   equal to ~org-beamer-frame-level~ or =H= value in a =OPTIONS= line
12037   (see [[*Export Settings]]).
12039   #+cindex: @samp{BEAMER_ENV}, property
12040   Org overrides headlines to frames conversion for the current tree of
12041   an Org file if it encounters the =BEAMER_ENV= property set to
12042   =frame= or =fullframe=.  Org ignores whatever
12043   ~org-beamer-frame-level~ happens to be for that headline level in
12044   the Org tree.  In Beamer terminology, a full frame is a frame
12045   without its title.
12047 - Org exports a Beamer frame's objects as block environments.  Org can
12048   enforce wrapping in special block types when =BEAMER_ENV= property
12049   is set[fn:127].  For valid values see
12050   ~org-beamer-environments-default~.  To add more values, see
12051   ~org-beamer-environments-extra~.
12052   #+vindex: org-beamer-environments-default
12053   #+vindex: org-beamer-environments-extra
12056   #+cindex: @samp{BEAMER_REF}, property
12057   If =BEAMER_ENV= is set to =appendix=, Org exports the entry as an
12058   appendix.  When set to =note=, Org exports the entry as a note
12059   within the frame or between frames, depending on the entry's heading
12060   level.  When set to =noteNH=, Org exports the entry as a note
12061   without its title.  When set to =againframe=, Org exports the entry
12062   with =\againframe= command, which makes setting the =BEAMER_REF=
12063   property mandatory because =\againframe= needs frame to resume.
12065   When =ignoreheading= is set, Org export ignores the entry's headline
12066   but not its content.  This is useful for inserting content between
12067   frames.  It is also useful for properly closing a =column=
12068   environment.  @end itemize
12070   #+cindex: @samp{BEAMER_ACT}, property
12071   #+cindex: @samp{BEAMER_OPT}, property
12072   When =BEAMER_ACT= is set for a headline, Org export translates that
12073   headline as an overlay or action specification.  When enclosed in
12074   square brackets, Org export makes the overlay specification
12075   a default.  Use =BEAMER_OPT= to set any options applicable to the
12076   current Beamer frame or block.  The Beamer export back-end wraps
12077   with appropriate angular or square brackets.  It also adds the
12078   =fragile= option for any code that may require a verbatim block.
12080   #+cindex: @samp{BEAMER_COL}, property
12081   To create a column on the Beamer slide, use the =BEAMER_COL=
12082   property for its headline in the Org file.  Set the value of
12083   =BEAMER_COL= to a decimal number representing the fraction of the
12084   total text width.  Beamer export uses this value to set the column's
12085   width and fills the column with the contents of the Org entry.  If
12086   the Org entry has no specific environment defined, Beamer export
12087   ignores the heading.  If the Org entry has a defined environment,
12088   Beamer export uses the heading as title.  Behind the scenes, Beamer
12089   export automatically handles LaTeX column separations for contiguous
12090   headlines.  To manually adjust them for any unique configurations
12091   needs, use the =BEAMER_ENV= property.
12093 *** Beamer specific syntax
12094 :PROPERTIES:
12095 :DESCRIPTION: For using in Org documents.
12096 :END:
12098 Since Org's Beamer export back-end is an extension of the LaTeX
12099 back-end, it recognizes other LaTeX specific syntax---for example,
12100 =#+LATEX:= or =#+ATTR_LATEX:=.  See [[*LaTeX Export]], for details.
12102 Beamer export wraps the table of contents generated with =toc:t=
12103 =OPTION= keyword in a =frame= environment.  Beamer export does not
12104 wrap the table of contents generated with =TOC= keyword (see [[*Table of
12105 Contents]]).  Use square brackets for specifying options.
12107 : #+TOC: headlines [currentsection]
12109 Insert Beamer-specific code using the following constructs:
12111 #+cindex: @samp{BEAMER}, keyword
12112 #+cindex: @samp{BEGIN_EXPORT beamer}
12113 #+begin_example
12114 ,#+BEAMER: \pause
12116 ,#+BEGIN_EXPORT beamer
12117   Only Beamer export back-end exports this.
12118 ,#+END_BEAMER
12120 Text @@beamer:some code@@ within a paragraph.
12121 #+end_example
12123 Inline constructs, such as the last one above, are useful for adding
12124 overlay specifications to objects with ~bold~, ~item~, ~link~,
12125 ~radio-target~ and ~target~ types.  Enclose the value in angular
12126 brackets and place the specification at the beginning of the object as
12127 shown in this example:
12129 :  A *@@beamer:<2->@@useful* feature
12131 #+cindex: @samp{ATTR_BEAMER}, keyword
12132 Beamer export recognizes the =ATTR_BEAMER= keyword with the following
12133 attributes from Beamer configurations: =:environment= for changing
12134 local Beamer environment, =:overlay= for specifying Beamer overlays in
12135 angular or square brackets, and =:options= for inserting optional
12136 arguments.
12138 #+begin_example
12139 ,#+ATTR_BEAMER: :environment nonindentlist
12140 - item 1, not indented
12141 - item 2, not indented
12142 - item 3, not indented
12143 #+end_example
12145 #+begin_example
12146 ,#+ATTR_BEAMER: :overlay <+->
12147 - item 1
12148 - item 2
12149 #+end_example
12151 #+begin_example
12152 ,#+ATTR_BEAMER: :options [Lagrange]
12153 Let $G$ be a finite group, and let $H$ be
12154 a subgroup of $G$.  Then the order of $H$ divides the order of $G$.
12155 #+end_example
12157 *** Editing support
12158 :PROPERTIES:
12159 :DESCRIPTION: Editing support.
12160 :END:
12162 The ~org-beamer-mode~ is a special minor mode for faster editing of
12163 Beamer documents.
12165 : #+STARTUP: beamer
12167 - {{{kbd(C-c C-b)}}} (~org-beamer-select-environment~) ::
12168   #+kindex: C-c C-b
12169   #+findex: org-beamer-select-environment
12171   The ~org-beamer-mode~ provides this key for quicker selections in
12172   Beamer normal environments, and for selecting the =BEAMER_COL=
12173   property.
12175 *** A Beamer example
12176 :PROPERTIES:
12177 :DESCRIPTION: A complete presentation.
12178 :END:
12180 Here is an example of an Org document ready for Beamer export.
12182 #+begin_example
12183 ,#+TITLE: Example Presentation
12184 ,#+AUTHOR: Carsten Dominik
12185 ,#+OPTIONS: H:2 toc:t num:t
12186 ,#+LATEX_CLASS: beamer
12187 ,#+LATEX_CLASS_OPTIONS: [presentation]
12188 ,#+BEAMER_THEME: Madrid
12189 ,#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col)
12191 ,* This is the first structural section
12193 ,** Frame 1
12194 ,*** Thanks to Eric Fraga                                           :B_block:
12195     :PROPERTIES:
12196     :BEAMER_COL: 0.48
12197     :BEAMER_ENV: block
12198     :END:
12199     for the first viable Beamer setup in Org
12200 ,*** Thanks to everyone else                                        :B_block:
12201     :PROPERTIES:
12202     :BEAMER_COL: 0.48
12203     :BEAMER_ACT: <2->
12204     :BEAMER_ENV: block
12205     :END:
12206     for contributing to the discussion
12207 ,**** This will be formatted as a beamer note                       :B_note:
12208      :PROPERTIES:
12209      :BEAMER_env: note
12210      :END:
12211 ,** Frame 2 (where we will not use columns)
12212 ,*** Request
12213     Please test this stuff!
12214 #+end_example
12216 ** HTML Export
12217 :PROPERTIES:
12218 :DESCRIPTION: Exporting to HTML.
12219 :END:
12220 #+cindex: HTML export
12222 Org mode contains an HTML exporter with extensive HTML formatting
12223 compatible with XHTML 1.0 strict standard.
12225 *** HTML export commands
12226 :PROPERTIES:
12227 :DESCRIPTION: Invoking HTML export.
12228 :END:
12230 - {{{kbd(C-c C-e h h)}}} (~org-html-export-to-html~) ::
12231   #+kindex: C-c C-e h h
12232   #+kindex: C-c C-e h o
12233   #+findex: org-html-export-to-html
12235   Export as HTML file with a =.html= extension.  For =myfile.org=, Org
12236   exports to =myfile.html=, overwriting without warning.  {{{kbd{C-c
12237   C-e h o)}}} exports to HTML and opens it in a web browser.
12239 - {{{kbd(C-c C-e h H)}}} (~org-html-export-as-html~) ::
12240   #+kindex: C-c C-e h H
12241   #+findex: org-html-export-as-html
12243   Exports to a temporary buffer.  Does not create a file.
12245 *** HTML specific export settings
12246 :PROPERTIES:
12247 :DESCRIPTION: Settings for HTML export.
12248 :END:
12250 HTML export has a number of keywords, similar to the general options
12251 settings described in [[*Export Settings]].
12253 - =DESCRIPTION= ::
12255   #+cindex: @samp{DESCRIPTION}, keyword
12256   This is the document's description, which the HTML exporter inserts
12257   it as a HTML meta tag in the HTML file.  For long descriptions, use
12258   multiple =DESCRIPTION= lines.  The exporter takes care of wrapping
12259   the lines properly.
12261 - =HTML_DOCTYPE= ::
12263   #+cindex: @samp{HTML_DOCTYPE}, keyword
12264   #+vindex: org-html-doctype
12265   Specify the document type, for example: HTML5 (~org-html-doctype~).
12267 - =HTML_CONTAINER= ::
12269   #+cindex: @samp{HTML_CONTAINER}, keyword
12270   #+vindex: org-html-container-element
12271   Specify the HTML container, such as =div=, for wrapping sections and
12272   elements (~org-html-container-element~).
12274 - =HTML_LINK_HOME= ::
12276   #+cindex: @samp{HTML_LINK_HOME}, keyword
12277   #+vindex: org-html-link-home
12278   The URL for home link (~org-html-link-home~).
12280 - =HTML_LINK_UP= ::
12282   #+cindex: @samp{HTML_LINK_UP}, keyword
12283   #+vindex: org-html-link-up
12284   The URL for the up link of exported HTML pages (~org-html-link-up~).
12286 - =HTML_MATHJAX= ::
12288   #+cindex: @samp{HTML_MATHJAX}, keyword
12289   #+vindex: org-html-mathjax-options
12290   Options for MathJax (~org-html-mathjax-options~).  MathJax is used
12291   to typeset LaTeX math in HTML documents.  See [[*Math formatting in
12292   HTML export]], for an example.
12294 - =HTML_HEAD= ::
12296   #+cindex: @samp{HTML_HEAD}, keyword
12297   #+vindex: org-html-head
12298   Arbitrary lines for appending to the HTML document's head
12299   (~org-html-head~).
12301 - =HTML_HEAD_EXTRA= ::
12303   #+cindex: @samp{HTML_HEAD_EXTRA}, keyword
12304   #+vindex: org-html-head-extra
12305   More arbitrary lines for appending to the HTML document's head
12306   (~org-html-head-extra~).
12308 - =KEYWORDS= ::
12310   #+cindex: @samp{KEYWORDS}, keyword
12311   Keywords to describe the document's content.  HTML exporter inserts
12312   these keywords as HTML meta tags.  For long keywords, use multiple
12313   =KEYWORDS= lines.
12315 - =LATEX_HEADER= ::
12317   #+cindex: @samp{LATEX_HEADER}, keyword
12318   Arbitrary lines for appending to the preamble; HTML exporter appends
12319   when transcoding LaTeX fragments to images (see [[*Math formatting in
12320   HTML export]]).
12322 - =SUBTITLE= ::
12324   #+cindex: @samp{SUBTITLE}, keyword
12325   The document's subtitle.  HTML exporter formats subtitle if document
12326   type is =HTML5= and the CSS has a =subtitle= class.
12328 Some of these keywords are explained in more detail in the following
12329 sections of the manual.
12331 *** HTML doctypes
12332 :PROPERTIES:
12333 :DESCRIPTION: Exporting various (X)HTML flavors.
12334 :END:
12336 Org can export to various (X)HTML flavors.
12338 #+vindex: org-html-doctype
12339 #+vindex: org-html-doctype-alist
12340 Set the ~org-html-doctype~ variable for different (X)HTML variants.
12341 Depending on the variant, the HTML exporter adjusts the syntax of HTML
12342 conversion accordingly.  Org includes the following ready-made
12343 variants:
12345 - ~"html4-strict"~
12346 - ~"html4-transitional"~
12347 - ~"html4-frameset"~
12348 - ~"xhtml-strict"~
12349 - ~"xhtml-transitional"~
12350 - ~"xhtml-frameset"~
12351 - ~"xhtml-11"~
12352 - ~"html5"~
12353 - ~"xhtml5"~
12355 #+texinfo: @noindent
12356 See the variable ~org-html-doctype-alist~ for details.  The default is
12357 ~"xhtml-strict"~.
12359 #+vindex: org-html-html5-fancy
12360 #+cindex: @samp{HTML5}, export new elements
12361 Org's HTML exporter does not by default enable new block elements
12362 introduced with the HTML5 standard.  To enable them, set
12363 ~org-html-html5-fancy~ to non-~nil~.  Or use an =OPTIONS= line in the
12364 file to set =html5-fancy=.
12366 HTML5 documents can now have arbitrary =#+BEGIN= ... =#+END= blocks.
12367 For example:
12369 #+begin_example
12370 ,#+BEGIN_aside
12371   Lorem ipsum
12372 ,#+END_aside
12373 #+end_example
12375 #+texinfo: @noindent
12376 exports to:
12378 #+begin_src html
12379 <aside>
12380   <p>Lorem ipsum</p>
12381 </aside>
12382 #+end_src
12384 #+texinfo: @noindent
12385 while this:
12387 #+begin_example
12388 ,#+ATTR_HTML: :controls controls :width 350
12389 ,#+BEGIN_video
12390 ,#+HTML: <source src="movie.mp4" type="video/mp4">
12391 ,#+HTML: <source src="movie.ogg" type="video/ogg">
12392 Your browser does not support the video tag.
12393 ,#+END_video
12394 #+end_example
12396 #+texinfo: @noindent
12397 exports to:
12399 #+begin_src html
12400 <video controls="controls" width="350">
12401   <source src="movie.mp4" type="video/mp4">
12402     <source src="movie.ogg" type="video/ogg">
12403       <p>Your browser does not support the video tag.</p>
12404 </video>
12405 #+end_src
12407 #+vindex: org-html-html5-elements
12408 When special blocks do not have a corresponding HTML5 element, the
12409 HTML exporter reverts to standard translation (see
12410 ~org-html-html5-elements~).  For example, =#+BEGIN_lederhosen= exports
12411 to ~<div class="lederhosen">~.
12413 Special blocks cannot have headlines.  For the HTML exporter to wrap
12414 the headline and its contents in ~<section>~ or ~<article>~ tags, set
12415 the =HTML_CONTAINER= property for the headline.
12417 *** HTML preamble and postamble
12418 :PROPERTIES:
12419 :DESCRIPTION: Inserting preamble and postamble.
12420 :END:
12421 #+vindex: org-html-preamble
12422 #+vindex: org-html-postamble
12423 #+vindex: org-html-preamble-format
12424 #+vindex: org-html-postamble-format
12425 #+vindex: org-html-validation-link
12426 #+vindex: org-export-creator-string
12427 #+vindex: org-export-time-stamp-file
12429 The HTML exporter has delineations for preamble and postamble.  The
12430 default value for ~org-html-preamble~ is ~t~, which makes the HTML
12431 exporter insert the preamble.  See the variable
12432 ~org-html-preamble-format~ for the format string.
12434 Set ~org-html-preamble~ to a string to override the default format
12435 string.  If the string is a function, the HTML exporter expects the
12436 function to return a string upon execution.  The HTML exporter inserts
12437 this string in the preamble.  The HTML exporter does not insert
12438 a preamble if ~org-html-preamble~ is set ~nil~.
12440 The default value for ~org-html-postamble~ is ~auto~, which makes the
12441 HTML exporter build a postamble from looking up author's name, email
12442 address, creator's name, and date.  Set ~org-html-postamble~ to ~t~ to
12443 insert the postamble in the format specified in the
12444 ~org-html-postamble-format~ variable.  The HTML exporter does not
12445 insert a postamble if ~org-html-postamble~ is set to ~nil~.
12447 *** Quoting HTML tags
12448 :PROPERTIES:
12449 :DESCRIPTION: Using direct HTML in Org files.
12450 :END:
12452 The HTML export back-end transforms =<= and =>= to =&lt;= and =&gt;=.
12453 To include raw HTML code in the Org file so the HTML export back-end
12454 can insert that HTML code in the output, use this inline syntax:
12455 =@@html:...@@=.  For example:
12457 : @@html:<b>@@bold text@@html:</b>@@
12459 #+cindex: @samp{HTML}, keyword
12460 #+cindex: @samp{BEGIN_EXPORT html}
12461 For larger raw HTML code blocks, use these HTML export code blocks:
12463 #+begin_example
12464 ,#+HTML: Literal HTML code for export
12466 ,#+BEGIN_EXPORT html
12467   All lines between these markers are exported literally
12468 ,#+END_EXPORT
12469 #+end_example
12471 *** Headlines in HTML export
12472 :PROPERTIES:
12473 :DESCRIPTION: Formatting headlines.
12474 :END:
12475 #+cindex: headlines, in HTML export
12477 Headlines are exported to =<h1>=, =<h2>=, etc.  Each headline gets the
12478 =id= attribute from =CUSTOM_ID= property, or a unique generated value,
12479 see [[*Internal Links]].
12481 #+vindex: org-html-self-link-headlines
12482 When ~org-html-self-link-headlines~ is set to a non-~nil~ value, the
12483 text of the headlines is also wrapped in =<a>= tags.  These tags have
12484 a =href= attribute making the headlines link to themselves.
12486 *** Links in HTML export
12487 :PROPERTIES:
12488 :DESCRIPTION: Inserting and formatting links.
12489 :END:
12490 #+cindex: links, in HTML export
12491 #+cindex: internal links, in HTML export
12492 #+cindex: external links, in HTML export
12494 The HTML export back-end transforms Org's internal links (see
12495 [[*Internal Links]]) to equivalent HTML links in the output.  The back-end
12496 similarly handles Org's automatic links created by radio targets (see
12497 [[*Radio Targets]]) similarly.  For Org links to external files, the
12498 back-end transforms the links to /relative/ paths.
12500 #+vindex: org-html-link-org-files-as-html
12501 For Org links to other =.org= files, the back-end automatically
12502 changes the file extension to =.html= and makes file paths relative.
12503 If the =.org= files have an equivalent =.html= version at the same
12504 location, then the converted links should work without any further
12505 manual intervention.  However, to disable this automatic path
12506 translation, set ~org-html-link-org-files-as-html~ to ~nil~.  When
12507 disabled, the HTML export back-end substitutes the ID-based links in
12508 the HTML output.  For more about linking files when publishing to
12509 a directory, see [[*Publishing links]].
12511 Org files can also have special directives to the HTML export
12512 back-end.  For example, by using =#+ATTR_HTML= lines to specify new
12513 format attributes to ~<a>~ or ~<img>~ tags.  This example shows
12514 changing the link's title and style:
12516 #+cindex: @samp{ATTR_HTML}, keyword
12517 #+begin_example
12518 ,#+ATTR_HTML: :title The Org mode homepage :style color:red;
12519 [[https://orgmode.org]]
12520 #+end_example
12522 *** Tables in HTML export
12523 :PROPERTIES:
12524 :DESCRIPTION: How to modify the formatting of tables.
12525 :END:
12526 #+cindex: tables, in HTML
12527 #+vindex: org-export-html-table-tag
12529 The HTML export back-end uses ~org-html-table-default-attributes~ when
12530 exporting Org tables to HTML.  By default, the exporter does not draw
12531 frames and cell borders.  To change for this for a table, use the
12532 following lines before the table in the Org file:
12534 #+cindex: @samp{CAPTION}, keyword
12535 #+cindex: @samp{ATTR_HTML}, keyword
12536 #+begin_example
12537 ,#+CAPTION: This is a table with lines around and between cells
12538 ,#+ATTR_HTML: border="2" rules="all" frame="border"
12539 #+end_example
12541 The HTML export back-end preserves column groupings in Org tables (see
12542 [[*Column Groups]]) when exporting to HTML.
12544 Additional options for customizing tables for HTML export.
12546 - ~org-html-table-align-individual-fields~ ::
12548   #+vindex: org-html-table-align-individual-fields
12549   Non-~nil~ attaches style attributes for alignment to each table
12550   field.
12552 - ~org-html-table-caption-above~ ::
12554   #+vindex: org-html-table-caption-above
12555   Non-~nil~ places caption string at the beginning of the table.
12557 - ~org-html-table-data-tags~ ::
12559   #+vindex: org-html-table-data-tags
12560   Opening and ending tags for table data fields.
12562 - ~org-html-table-default-attributes~ ::
12564   #+vindex: org-html-table-default-attributes
12565   Default attributes and values for table tags.
12567 - ~org-html-table-header-tags~ ::
12569   #+vindex: org-html-table-header-tags
12570   Opening and ending tags for table's header fields.
12572 - ~org-html-table-row-tags~ ::
12574   #+vindex: org-html-table-row-tags
12575   Opening and ending tags for table rows.
12577 - ~org-html-table-use-header-tags-for-first-column~ ::
12579   #+vindex: org-html-table-use-header-tags-for-first-column
12580   Non-~nil~ formats column one in tables with header tags.
12582 *** Images in HTML export
12583 :PROPERTIES:
12584 :DESCRIPTION: How to insert figures into HTML output.
12585 :END:
12586 #+cindex: images, inline in HTML
12587 #+cindex: inlining images in HTML
12589 The HTML export back-end has features to convert Org image links to
12590 HTML inline images and HTML clickable image links.
12592 #+vindex: org-html-inline-images
12593 When the link in the Org file has no description, the HTML export
12594 back-end by default in-lines that image.  For example:
12595 =[[file:myimg.jpg]]= is in-lined, while =[[file:myimg.jpg][the image]]= links to the text,
12596 =the image=.  For more details, see the variable
12597 ~org-html-inline-images~.
12599 On the other hand, if the description part of the Org link is itself
12600 another link, such as =file:= or =http:= URL pointing to an image, the
12601 HTML export back-end in-lines this image and links to the main image.
12602 This Org syntax enables the back-end to link low-resolution thumbnail
12603 to the high-resolution version of the image, as shown in this example:
12605 : [[file:highres.jpg][file:thumb.jpg]]
12607 To change attributes of in-lined images, use =#+ATTR_HTML= lines in
12608 the Org file.  This example shows realignment to right, and adds ~alt~
12609 and ~title~ attributes in support of text viewers and modern web
12610 accessibility standards.
12612 #+cindex: @samp{CAPTION}, keyword
12613 #+cindex: @samp{ATTR_HTML}, keyword
12614 #+begin_example
12615 ,#+CAPTION: A black cat stalking a spider
12616 ,#+ATTR_HTML: :alt cat/spider image :title Action! :align right
12617 [[./img/a.jpg]]
12618 #+end_example
12620 The HTML export back-end copies the =http= links from the Org file
12621 as-is.
12623 *** Math formatting in HTML export
12624 :PROPERTIES:
12625 :DESCRIPTION: Beautiful math also on the web.
12626 :END:
12627 #+cindex: MathJax
12628 #+cindex: dvipng
12629 #+cindex: dvisvgm
12630 #+cindex: ImageMagick
12632 #+vindex: org-html-mathjax-options~
12633 LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
12634 different ways on HTML pages.  The default is to use the [[http://www.mathjax.org][MathJax]],
12635 which should work out of the box with Org[fn:128][fn:129].  Some MathJax
12636 display options can be configured via ~org-html-mathjax-options~, or
12637 in the buffer.  For example, with the following settings,
12639 #+begin_example
12640 ,#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
12641 ,#+HTML_MATHJAX: cancel.js noErrors.js
12642 #+end_example
12644 #+texinfo: @noindent
12645 equation labels are displayed on the left margin and equations are
12646 five em from the left margin.  In addition, it loads the two MathJax
12647 extensions =cancel.js= and =noErrors.js=[fn:130].
12649 #+vindex: org-html-mathjax-template
12650 See the docstring of ~org-html-mathjax-options~ for all supported
12651 variables.  The MathJax template can be configure via
12652 ~org-html-mathjax-template~.
12654 If you prefer, you can also request that LaTeX fragments are processed
12655 into small images that will be inserted into the browser page.  Before
12656 the availability of MathJax, this was the default method for Org
12657 files.  This method requires that the dvipng program, dvisvgm or
12658 ImageMagick suite is available on your system.  You can still get this
12659 processing with
12661 : #+OPTIONS: tex:dvipng
12663 : #+OPTIONS: tex:dvisvgm
12665 #+texinfo: @noindent
12668 : #+OPTIONS: tex:imagemagick
12670 *** Text areas in HTML export
12671 :PROPERTIES:
12672 :DESCRIPTION: An alternate way to show an example.
12673 :END:
12675 #+cindex: text areas, in HTML
12676 Before Org mode's Babel, one popular approach to publishing code in
12677 HTML was by using =:textarea=.  The advantage of this approach was
12678 that copying and pasting was built into browsers with simple
12679 JavaScript commands.  Even editing before pasting was made simple.
12681 The HTML export back-end can create such text areas.  It requires an
12682 =#+ATTR_HTML= line as shown in the example below with the =:textarea=
12683 option.  This must be followed by either an example or a source code
12684 block.  Other Org block types do not honor the =:textarea= option.
12686 By default, the HTML export back-end creates a text area 80 characters
12687 wide and height just enough to fit the content.  Override these
12688 defaults with =:width= and =:height= options on the =#+ATTR_HTML=
12689 line.
12691 #+begin_example
12692 ,#+ATTR_HTML: :textarea t :width 40
12693 ,#+BEGIN_EXAMPLE
12694   (defun org-xor (a b)
12695      "Exclusive or."
12696      (if a (not b) b))
12697 ,#+END_EXAMPLE
12698 #+end_example
12700 *** CSS support
12701 :PROPERTIES:
12702 :DESCRIPTION: Changing the appearance of the output.
12703 :END:
12704 #+cindex: CSS, for HTML export
12705 #+cindex: HTML export, CSS
12707 #+vindex: org-export-html-todo-kwd-class-prefix
12708 #+vindex: org-export-html-tag-class-prefix
12709 You can modify the CSS style definitions for the exported file.  The
12710 HTML exporter assigns the following special CSS classes[fn:131] to
12711 appropriate parts of the document---your style specifications may
12712 change these, in addition to any of the standard classes like for
12713 headlines, tables, etc.
12715 | ~p.author~           | author information, including email                    |
12716 | ~p.date~             | publishing date                                        |
12717 | ~p.creator~          | creator info, about org mode version                   |
12718 | ~.title~             | document title                                         |
12719 | ~.subtitle~          | document subtitle                                      |
12720 | ~.todo~              | TODO keywords, all not-done states                     |
12721 | ~.done~              | the DONE keywords, all states that count as done       |
12722 | ~.WAITING~           | each TODO keyword also uses a class named after itself |
12723 | ~.timestamp~         | timestamp                                              |
12724 | ~.timestamp-kwd~     | keyword associated with a timestamp, like =SCHEDULED=  |
12725 | ~.timestamp-wrapper~ | span around keyword plus timestamp                     |
12726 | ~.tag~               | tag in a headline                                      |
12727 | ~._HOME~             | each tag uses itself as a class, "@" replaced by "_"   |
12728 | ~.target~            | target for links                                       |
12729 | ~.linenr~            | the line number in a code example                      |
12730 | ~.code-highlighted~  | for highlighting referenced code lines                 |
12731 | ~div.outline-N~      | div for outline level N (headline plus text)           |
12732 | ~div.outline-text-N~ | extra div for text at outline level N                  |
12733 | ~.section-number-N~  | section number in headlines, different for each level  |
12734 | ~.figure-number~     | label like "Figure 1:"                                 |
12735 | ~.table-number~      | label like "Table 1:"                                  |
12736 | ~.listing-number~    | label like "Listing 1:"                                |
12737 | ~div.figure~         | how to format an in-lined image                        |
12738 | ~pre.src~            | formatted source code                                  |
12739 | ~pre.example~        | normal example                                         |
12740 | ~p.verse~            | verse paragraph                                        |
12741 | ~div.footnotes~      | footnote section headline                              |
12742 | ~p.footnote~         | footnote definition paragraph, containing a footnote   |
12743 | ~.footref~           | a footnote reference number (always a <sup>)           |
12744 | ~.footnum~           | footnote number in footnote definition (always <sup>)  |
12745 | ~.org-svg~           | default class for a linked =.svg= image                |
12747 #+vindex: org-html-style-default
12748 #+vindex: org-html-head
12749 #+vindex: org-html-head-extra
12750 #+cindex: @samp{HTML_INCLUDE_STYLE}, keyword
12751 The HTML export back-end includes a compact default style in each
12752 exported HTML file.  To override the default style with another style,
12753 use these keywords in the Org file.  They will replace the global
12754 defaults the HTML exporter uses.
12756 #+cindex: @samp{HTML_HEAD}, keyword
12757 #+cindex: @samp{HTML_HEAD_EXTRA}, keyword
12758 #+begin_example
12759 ,#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
12760 ,#+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
12761 #+end_example
12763 #+vindex: org-html-head-include-default-style
12764 To just turn off the default style, customize
12765 ~org-html-head-include-default-style~ variable, or use this option
12766 line in the Org file.
12768 #+cindex: @samp{html-style}, @samp{OPTIONS} item
12769 : #+OPTIONS: html-style:nil
12771 For longer style definitions, either use several =HTML_HEAD= and
12772 =HTML_HEAD_EXTRA= keywords, or use ~<style> ... </style>~ blocks
12773 around them.  Both of these approaches can avoid referring to an
12774 external file.
12776 #+cindex: @samp{HTML_CONTAINER_CLASS}, property
12777 #+cindex: @samp{HTML_HEADLINE_CLASS}, property
12778 In order to add styles to a sub-tree, use the =HTML_CONTAINER_CLASS=
12779 property to assign a class to the tree.  In order to specify CSS
12780 styles for a particular headline, you can use the ID specified in
12781 a =CUSTOM_ID= property.  You can also assign a specific class to
12782 a headline with the =HTML_HEADLINE_CLASS= property.
12784 Never change the ~org-html-style-default~ constant.  Instead use other
12785 simpler ways of customizing as described above.
12787 *** JavaScript supported display of web pages
12788 :PROPERTIES:
12789 :DESCRIPTION: Info and folding in a web browser.
12790 :ALT_TITLE: JavaScript support
12791 :END:
12793 Sebastian Rose has written a JavaScript program especially designed to
12794 enhance the web viewing experience of HTML files created with Org.
12795 This program enhances large files in two different ways of viewing.
12796 One is an /Info/-like mode where each section is displayed separately
12797 and navigation can be done with the {{{kbd(n)}}} and {{{kbd(p)}}}
12798 keys, and some other keys as well, press {{{kbd(?)}}} for an overview
12799 of the available keys.  The second one has a /folding/ view, much like
12800 Org provides inside Emacs.  The script is available at
12801 https://orgmode.org/org-info.js and the documentation at
12802 https://orgmode.org/worg/code/org-info-js/.  The script is hosted on
12803 https://orgmode.org, but for reliability, prefer installing it on your
12804 own web server.
12806 To use this program, just add this line to the Org file:
12808 #+cindex: @samp{INFOJS_OPT}, keyword
12809 : #+INFOJS_OPT: view:info toc:nil
12811 #+texinfo: @noindent
12812 The HTML header now has the code needed to automatically invoke the
12813 script.  For setting options, use the syntax from the above line for
12814 options described below:
12816 - =path:= ::
12818   The path to the script.  The default is to grab the script from
12819   [[https://orgmode.org/org-info.js]], but you might want to have a local
12820   copy and use a path like =../scripts/org-info.js=.
12822 - =view:= ::
12824   Initial view when the website is first shown.  Possible values are:
12826   | =info=     | Info-like interface with one section per page          |
12827   | =overview= | Folding interface, initially showing only top-level    |
12828   | =content=  | Folding interface, starting with all headlines visible |
12829   | =showall=  | Folding interface, all headlines and text visible      |
12831 - =sdepth:= ::
12833   Maximum headline level still considered as an independent section
12834   for info and folding modes.  The default is taken from
12835   ~org-export-headline-levels~, i.e., the =H= switch in =OPTIONS=.  If
12836   this is smaller than in ~org-export-headline-levels~, each
12837   info/folding section can still contain child headlines.
12839 - =toc:= ::
12841   Should the table of contents /initially/ be visible?  Even when
12842   =nil=, you can always get to the "toc" with {{{kbd(i)}}}.
12844 - =tdepth:= ::
12846   The depth of the table of contents.  The defaults are taken from the
12847   variables ~org-export-headline-levels~ and ~org-export-with-toc~.
12849 - =ftoc:= ::
12851   Does the CSS of the page specify a fixed position for the "toc"?  If
12852   yes, the toc is displayed as a section.
12854 - =ltoc:= ::
12856   Should there be short contents (children) in each section?  Make
12857   this =above= if the section should be above initial text.
12859 - =mouse:= ::
12861   Headings are highlighted when the mouse is over them.  Should be
12862   =underline= (default) or a background color like =#cccccc=.
12864 - =buttons:= ::
12866   Should view-toggle buttons be everywhere?  When =nil= (the default),
12867   only one such button is present.
12869 #+vindex: org-infojs-options
12870 #+vindex: org-export-html-use-infojs
12871 You can choose default values for these options by customizing the
12872 variable ~org-infojs-options~.  If you always want to apply the script
12873 to your pages, configure the variable ~org-export-html-use-infojs~.
12875 ** LaTeX Export
12876 :PROPERTIES:
12877 :DESCRIPTION: Exporting to @LaTeX{} and processing to PDF.
12878 :END:
12879 #+cindex: @LaTeX{} export
12880 #+cindex: PDF export
12882 The LaTeX export back-end can handle complex documents, incorporate
12883 standard or custom LaTeX document classes, generate documents using
12884 alternate LaTeX engines, and produce fully linked PDF files with
12885 indexes, bibliographies, and tables of contents, destined for
12886 interactive online viewing or high-quality print publication.
12888 While the details are covered in-depth in this section, here are some
12889 quick references to variables for the impatient: for engines, see
12890 ~org-latex-compiler~; for build sequences, see
12891 ~org-latex-pdf-process~; for packages, see
12892 ~org-latex-default-packages-alist~ and ~org-latex-packages-alist~.
12894 An important note about the LaTeX export back-end: it is sensitive to
12895 blank lines in the Org document.  That's because LaTeX itself depends
12896 on blank lines to tell apart syntactical elements, such as paragraphs.
12898 *** LaTeX/PDF export commands
12899 :PROPERTIES:
12900 :DESCRIPTION: For producing @LaTeX{} and PDF documents.
12901 :END:
12903 - {{{kbd(C-c C-e l l)}}} (~org-latex-export-to-latex~) ::
12905   #+kindex: C-c C-e l l
12906   #+findex: org-latex-export-to-latex~
12907   Export to a LaTeX file with a =.tex= extension.  For =myfile.org=,
12908   Org exports to =myfile.tex=, overwriting without warning.
12910 - {{{kbd(C-c C-e l L)}}} (~org-latex-export-as-latex~) ::
12912   #+kindex: C-c C-e l L
12913   #+findex: org-latex-export-as-latex
12914   Export to a temporary buffer.  Do not create a file.
12916 - {{{kbd(C-c C-e l p)}}} (~org-latex-export-to-pdf~) ::
12918   #+kindex: C-c C-e l p
12919   #+findex: org-latex-export-to-pdf
12920   Export as LaTeX file and convert it to PDF file.
12922 - {{{kbd(C-c C-e l o)}}} ::
12924   #+kindex: C-c C-e l o
12925   Export as LaTeX file and convert it to PDF, then open the PDF using
12926   the default viewer.
12928 - {{{kbd(M-x org-export-region-as-latex)}}} ::
12930   Convert the region to LaTeX under the assumption that it was in Org
12931   mode syntax before.  This is a global command that can be invoked in
12932   any buffer.
12934 #+vindex: org-latex-compiler
12935 #+vindex: org-latex-bibtex-compiler
12936 #+vindex: org-latex-default-packages-alist
12937 #+cindex: pdflatex
12938 #+cindex: xelatex
12939 #+cindex: lualatex
12940 #+cindex: @samp{LATEX_COMPILER}, keyword
12941 The LaTeX export back-end can use any of these LaTeX engines:
12942 =pdflatex=, =xelatex=, and =lualatex=.  These engines compile LaTeX
12943 files with different compilers, packages, and output options.  The
12944 LaTeX export back-end finds the compiler version to use from
12945 ~org-latex-compiler~ variable or the =#+LATEX_COMPILER= keyword in the
12946 Org file.  See the docstring for the
12947 ~org-latex-default-packages-alist~ for loading packages with certain
12948 compilers.  Also see ~org-latex-bibtex-compiler~ to set the
12949 bibliography compiler[fn:132].
12951 *** LaTeX specific export settings
12952 :PROPERTIES:
12953 :DESCRIPTION: Unique to this @LaTeX{} back-end.
12954 :END:
12956 The LaTeX export back-end has several additional keywords for
12957 customizing LaTeX output.  Setting these keywords works similar to the
12958 general options (see [[*Export Settings]]).
12960 #+attr_texinfo: :sep ,
12961 - =DESCRIPTION= ::
12962   #+cindex: @samp{DESCRIPTION}, keyword
12963   #+vindex: org-latex-hyperref-template
12964   #+vindex: org-latex-title-command
12965   The document's description.  The description along with author name,
12966   keywords, and related file metadata are inserted in the output file
12967   by the hyperref package.  See ~org-latex-hyperref-template~ for
12968   customizing metadata items.  See ~org-latex-title-command~ for
12969   typesetting description into the document's front matter.  Use
12970   multiple =DESCRIPTION= keywords for long descriptions.
12972 - =LANGUAGE= ::
12973   #+cindex: @samp{LANGUAGE}, keyword
12974   #+vindex: org-latex-package-alist
12975   In order to be effective, the =babel= or =polyglossia=
12976   packages---according to the LaTeX compiler used---must be loaded
12977   with the appropriate language as argument.  This can be accomplished
12978   by modifying the =org-latex-package-alist= variable, e.g., with the
12979   following snippet:
12981   #+begin_src emacs-lisp
12982   (add-to-list org-latex-package-alist
12983                '("AUTO" "babel" t ("pdflatex")))
12984   (add-to-list org-latex-package-alist
12985                '("AUTO" "polyglossia" t ("xelatex" "lualatex")))
12986   #+end_src
12988 - =LATEX_CLASS= ::
12990   #+cindex: @samp{LATEX_CLASS}, keyword
12991   #+vindex: org-latex-default-class
12992   #+vindex: org-latex-classes
12993   This is LaTeX document class, such as /article/, /report/, /book/,
12994   and so on, which contain predefined preamble and headline level
12995   mapping that the LaTeX export back-end needs.  The back-end reads
12996   the default class name from the ~org-latex-default-class~ variable.
12997   Org has /article/ as the default class.  A valid default class must
12998   be an element of ~org-latex-classes~.
13000 - =LATEX_CLASS_OPTIONS= ::
13002   #+cindex: @samp{LATEX_CLASS_OPTIONS}, keyword
13003   Options the LaTeX export back-end uses when calling the LaTeX
13004   document class.
13006 - =LATEX_COMPILER= ::
13008   #+cindex: @samp{LATEX_COMPILER}, keyword
13009   #+vindex: org-latex-compiler
13010   The compiler, such as =pdflatex=, =xelatex=, =lualatex=, for
13011   producing the PDF.  See ~org-latex-compiler~.
13013 - =LATEX_HEADER=, =LATEX_HEADER_EXTRA= ::
13015   #+cindex: @samp{LATEX_HEADER}, keyword
13016   #+cindex: @samp{LATEX_HEADER_EXTRA}, keyword
13017   #+vindex: org-latex-classes
13018   Arbitrary lines to add to the document's preamble, before the
13019   hyperref settings.  See ~org-latex-classes~ for adjusting the
13020   structure and order of the LaTeX headers.
13022 - =KEYWORDS= ::
13024   #+cindex: @samp{KEYWORDS}, keyword
13025   #+vindex: org-latex-hyperref-template
13026   #+vindex: org-latex-title-command
13027   The keywords for the document.  The description along with author
13028   name, keywords, and related file metadata are inserted in the output
13029   file by the hyperref package.  See ~org-latex-hyperref-template~ for
13030   customizing metadata items.  See ~org-latex-title-command~ for
13031   typesetting description into the document's front matter.  Use
13032   multiple =KEYWORDS= lines if necessary.
13034 - =SUBTITLE= ::
13036   #+cindex: @samp{SUBTITLE}, keyword
13037   #+vindex: org-latex-subtitle-separate
13038   #+vindex: org-latex-subtitle-format
13039   The document's subtitle.  It is typeset as per
13040   ~org-latex-subtitle-format~.  If ~org-latex-subtitle-separate~ is
13041   non-~nil~, it is typed as part of the ~\title~ macro.  See
13042   ~org-latex-hyperref-template~ for customizing metadata items.  See
13043   ~org-latex-title-command~ for typesetting description into the
13044   document's front matter.
13046 The following sections have further details.
13048 *** LaTeX header and sectioning structure
13049 :PROPERTIES:
13050 :DESCRIPTION: Setting up the export file structure.
13051 :ALT_TITLE: LaTeX header and sectioning
13052 :END:
13053 #+cindex: @LaTeX{} class
13054 #+cindex: @LaTeX{} sectioning structure
13055 #+cindex: @LaTeX{} header
13056 #+cindex: header, for @LaTeX{} files
13057 #+cindex: sectioning structure, for @LaTeX{} export
13059 The LaTeX export back-end converts the first three of Org's outline
13060 levels into LaTeX headlines.  The remaining Org levels are exported as
13061 lists.  To change this globally for the cut-off point between levels
13062 and lists, (see [[*Export Settings]]).
13064 By default, the LaTeX export back-end uses the /article/ class.
13066 #+vindex: org-latex-default-class
13067 #+vindex: org-latex-classes
13068 #+vindex: org-latex-default-packages-alist
13069 #+vindex: org-latex-packages-alist
13070 To change the default class globally, edit ~org-latex-default-class~.
13071 To change the default class locally in an Org file, add option lines
13072 =#+LATEX_CLASS: myclass=.  To change the default class for just a part
13073 of the Org file, set a sub-tree property, =EXPORT_LATEX_CLASS=.  The
13074 class name entered here must be valid member of ~org-latex-classes~.
13075 This variable defines a header template for each class into which the
13076 exporter splices the values of ~org-latex-default-packages-alist~ and
13077 ~org-latex-packages-alist~.  Use the same three variables to define
13078 custom sectioning or custom classes.
13080 #+cindex: @samp{LATEX_CLASS}, keyword
13081 #+cindex: @samp{LATEX_CLASS_OPTIONS}, keyword
13082 #+cindex: @samp{EXPORT_LATEX_CLASS}, property
13083 #+cindex: @samp{EXPORT_LATEX_CLASS_OPTIONS}, property
13084 The LaTeX export back-end sends the =LATEX_CLASS_OPTIONS= keyword and
13085 =EXPORT_LATEX_CLASS_OPTIONS= property as options to the LaTeX
13086 ~\documentclass~ macro.  The options and the syntax for specifying
13087 them, including enclosing them in square brackets, follow LaTeX
13088 conventions.
13090 : #+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside,twocolumn]
13092 #+cindex: @samp{LATEX_HEADER}, keyword
13093 #+cindex: @samp{LATEX_HEADER_EXTRA}, keyword
13094 The LaTeX export back-end appends values from =LATEX_HEADER= and
13095 =LATEX_HEADER_EXTRA= keywords to the LaTeX header.  The docstring for
13096 ~org-latex-classes~ explains in more detail.  Also note that LaTeX
13097 export back-end does not append =LATEX_HEADER_EXTRA= to the header
13098 when previewing LaTeX snippets (see [[*Previewing LaTeX fragments]]).
13100 A sample Org file with the above headers:
13102 #+begin_example
13103 ,#+LATEX_CLASS: article
13104 ,#+LATEX_CLASS_OPTIONS: [a4paper]
13105 ,#+LATEX_HEADER: \usepackage{xyz}
13107 ,* Headline 1
13108   some text
13109 ,* Headline 2
13110   some more text
13111 #+end_example
13113 *** Quoting LaTeX code
13114 :PROPERTIES:
13115 :DESCRIPTION: Incorporating literal @LaTeX{} code.
13116 :END:
13118 The LaTeX export back-end can insert any arbitrary LaTeX code, see
13119 [[*Embedded LaTeX]].  There are three ways to embed such code in the Org
13120 file and they all use different quoting syntax.
13122 #+cindex: inline, in @LaTeX{} export
13123 Inserting in-line quoted with @ symbols:
13125 : Code embedded in-line @@latex:any arbitrary LaTeX code@@ in a paragraph.
13127 #+cindex: @samp{LATEX}, keyword
13128 Inserting as one or more keyword lines in the Org file:
13130 : #+LATEX: any arbitrary LaTeX code
13132 #+cindex: @samp{BEGIN_EXPORT latex}
13133 Inserting as an export block in the Org file, where the back-end
13134 exports any code between begin and end markers:
13136 #+begin_example
13137 ,#+BEGIN_EXPORT latex
13138   any arbitrary LaTeX code
13139 ,#+END_EXPORT
13140 #+end_example
13142 *** Tables in LaTeX export
13143 :PROPERTIES:
13144 :DESCRIPTION: Options for exporting tables to @LaTeX{}.
13145 :END:
13146 #+cindex: tables, in @LaTeX{} export
13148 The LaTeX export back-end can pass several LaTeX attributes for table
13149 contents and layout.  Besides specifying a label (see [[*Internal Links]])
13150 and a caption (see [[*Captions]]), the other valid LaTeX attributes
13151 include:
13153 #+attr_texinfo: :sep ,
13154 - =:mode= ::
13156   #+vindex: org-latex-default-table-mode
13157   The LaTeX export back-end wraps the table differently depending on
13158   the mode for accurate rendering of math symbols.  Mode is either
13159   =table=, =math=, =inline-math= or =verbatim=.
13161   For =math= or =inline-math= mode, LaTeX export back-end wraps the
13162   table in a math environment, but every cell in it is exported as-is.
13163   The LaTeX export back-end determines the default mode from
13164   ~org-latex-default-table-mode~.  The LaTeX export back-end merges
13165   contiguous tables in the same mode into a single environment.
13167 - =:environment= ::
13169   #+vindex: org-latex-default-table-environment
13170   Set the default LaTeX table environment for the LaTeX export
13171   back-end to use when exporting Org tables.  Common LaTeX table
13172   environments are provided by these packages: tabularx, longtable,
13173   array, tabu, and bmatrix.  For packages, such as tabularx and tabu,
13174   or any newer replacements, include them in the
13175   ~org-latex-packages-alist~ variable so the LaTeX export back-end can
13176   insert the appropriate load package headers in the converted LaTeX
13177   file.  Look in the docstring for the ~org-latex-packages-alist~
13178   variable for configuring these packages for LaTeX snippet previews,
13179   if any.
13181 - =:caption= ::
13183   Use =CAPTION= keyword to set a simple caption for a table (see
13184   [[*Captions]]).  For custom captions, use =:caption= attribute, which
13185   accepts raw LaTeX code.  =:caption= value overrides =CAPTION= value.
13187 - =:float=, =:placement= ::
13189   The table environments by default are not floats in LaTeX.  To make
13190   them floating objects use =:float= with one of the following
13191   options: =sideways=, =multicolumn=, =t=, and =nil=.
13193   LaTeX floats can also have additional layout =:placement=
13194   attributes.  These are the usual =[h t b p ! H]= permissions
13195   specified in square brackets.  Note that for =:float sideways=
13196   tables, the LaTeX export back-end ignores =:placement= attributes.
13198 - =:align=, =:font=, =:width= ::
13200   The LaTeX export back-end uses these attributes for regular tables
13201   to set their alignments, fonts, and widths.
13203 - =:spread= ::
13205   When =:spread= is non-~nil~, the LaTeX export back-end spreads or
13206   shrinks the table by the =:width= for tabu and longtabu
13207   environments.  =:spread= has no effect if =:width= is not set.
13209 - =:booktabs=, =:center=, =:rmlines= ::
13211   #+vindex: org-latex-tables-booktabs
13212   #+vindex: org-latex-tables-centered
13213   All three commands are toggles.  =:booktabs= brings in modern
13214   typesetting enhancements to regular tables.  The booktabs package
13215   has to be loaded through ~org-latex-packages-alist~.  =:center= is
13216   for centering the table.  =:rmlines= removes all but the very first
13217   horizontal line made of ASCII characters from "table.el" tables
13218   only.
13220 - =:math-prefix=, =:math-suffix=, =:math-arguments= ::
13222   The LaTeX export back-end inserts =:math-prefix= string value in
13223   a math environment before the table.  The LaTeX export back-end
13224   inserts =:math-suffix= string value in a math environment after the
13225   table.  The LaTeX export back-end inserts =:math-arguments= string
13226   value between the macro name and the table's contents.
13227   =:math-arguments= comes in use for matrix macros that require more
13228   than one argument, such as =qbordermatrix=.
13230 LaTeX table attributes help formatting tables for a wide range of
13231 situations, such as matrix product or spanning multiple pages:
13233 #+begin_example
13234 ,#+ATTR_LATEX: :environment longtable :align l|lp{3cm}r|l
13235 | ... | ... |
13236 | ... | ... |
13238 ,#+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
13239 | a | b |
13240 | c | d |
13241 ,#+ATTR_LATEX: :mode math :environment bmatrix
13242 | 1 | 2 |
13243 | 3 | 4 |
13244 #+end_example
13246 Set the caption with the LaTeX command
13247 =\bicaption{HeadingA}{HeadingB}=:
13249 #+begin_example
13250 ,#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
13251 | ... | ... |
13252 | ... | ... |
13253 #+end_example
13255 *** Images in LaTeX export
13256 :PROPERTIES:
13257 :DESCRIPTION: How to insert figures into @LaTeX{} output.
13258 :END:
13259 #+cindex: images, inline in LaTeX
13260 #+cindex: inlining images in LaTeX
13261 #+cindex: @samp{ATTR_LATEX}, keyword
13263 The LaTeX export back-end processes image links in Org files that do
13264 not have descriptions, such as these links =[[file:img.jpg]]= or
13265 =[[./img.jpg]]=, as direct image insertions in the final PDF output.  In
13266 the PDF, they are no longer links but actual images embedded on the
13267 page.  The LaTeX export back-end uses =\includegraphics= macro to
13268 insert the image.  But for TikZ (http://sourceforge.net/projects/pgf/)
13269 images, the back-end uses an ~\input~ macro wrapped within
13270 a ~tikzpicture~ environment.
13272 For specifying image =:width=, =:height=, =:scale= and other =:options=,
13273 use this syntax:
13275 #+begin_example
13276 ,#+ATTR_LATEX: :width 5cm :options angle=90
13277 [[./img/sed-hr4049.pdf]]
13278 #+end_example
13280 A =:scale= attribute overrides both =:width= and =:height= attributes.
13282 For custom commands for captions, use the =:caption= attribute.  It
13283 overrides the default =#+CAPTION= value:
13285 #+begin_example
13286 ,#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
13287 [[./img/sed-hr4049.pdf]]
13288 #+end_example
13290 When captions follow the method as described in [[*Captions]], the LaTeX
13291 export back-end wraps the picture in a floating =figure= environment.
13292 To float an image without specifying a caption, set the =:float=
13293 attribute to one of the following:
13295 - =t= ::
13297   For a standard =figure= environment; used by default whenever an
13298   image has a caption.
13300 - =multicolumn= ::
13302   To span the image across multiple columns of a page; the back-end
13303   wraps the image in a =figure*= environment.
13305 - =wrap= ::
13307   For text to flow around the image on the right; the figure occupies
13308   the left half of the page.
13310 - =sideways= ::
13312   For a new page with the image sideways, rotated ninety degrees, in
13313   a =sidewaysfigure= environment; overrides =:placement= setting.
13315 - =nil= ::
13317   To avoid a =:float= even if using a caption.
13319 Use the =placement= attribute to modify a floating environment's
13320 placement.
13322 #+begin_example
13323 ,#+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement {r}{0.4\textwidth}
13324 [[./img/hst.png]]
13325 #+end_example
13327 #+vindex: org-latex-images-centered
13328 #+cindex: center image in LaTeX export
13329 #+cindex: image, centering in LaTeX export
13330 The LaTeX export back-end centers all images by default.  Setting
13331 =:center= to =nil= disables centering.  To disable centering globally,
13332 set ~org-latex-images-centered~ to =t=.
13334 Set the =:comment-include= attribute to non-~nil~ value for the LaTeX
13335 export back-end to comment out the =\includegraphics= macro.
13337 *** Plain lists in LaTeX export
13338 :PROPERTIES:
13339 :DESCRIPTION: Attributes specific to lists.
13340 :END:
13342 #+cindex: plain lists, in @LaTeX{} export
13343 #+cindex: @samp{ATTR_LATEX}, keyword
13344 The LaTeX export back-end accepts the =environment= and =options=
13345 attributes for plain lists.  Both attributes work together for
13346 customizing lists, as shown in the examples:
13348 #+begin_example
13349 ,#+LATEX_HEADER: \usepackage[inline]{enumitem}
13350 Some ways to say "Hello":
13351 ,#+ATTR_LATEX: :environment itemize*
13352 ,#+ATTR_LATEX: :options [label={}, itemjoin={,}, itemjoin*={, and}]
13353 - Hola
13354 - Bonjour
13355 - Guten Tag.
13356 #+end_example
13358 Since LaTeX supports only four levels of nesting for lists, use an
13359 external package, such as =enumitem= in LaTeX, for levels deeper than
13360 four:
13362 #+begin_example
13363 ,#+LATEX_HEADER: \usepackage{enumitem}
13364 ,#+LATEX_HEADER: \renewlist{itemize}{itemize}{9}
13365 ,#+LATEX_HEADER: \setlist[itemize]{label=$\circ$}
13366 - One
13367   - Two
13368     - Three
13369       - Four
13370         - Five
13371 #+end_example
13373 *** Source blocks in LaTeX export
13374 :PROPERTIES:
13375 :DESCRIPTION: Attributes specific to source code blocks.
13376 :END:
13377 #+cindex: source blocks, in @LaTeX{} export
13378 #+cindex: @samp{ATTR_LATEX}, keyword
13380 The LaTeX export back-end can make source code blocks into floating
13381 objects through the attributes =:float= and =:options=.  For =:float=:
13383 - =t= ::
13385   Makes a source block float; by default floats any source block with
13386   a caption.
13388 - =multicolumn= ::
13390   Spans the source block across multiple columns of a page.
13392 - =nil= ::
13394   Avoids a =:float= even if using a caption; useful for source code
13395   blocks that may not fit on a page.
13397 #+begin_example
13398 ,#+ATTR_LATEX: :float nil
13399 ,#+BEGIN_SRC emacs-lisp
13400   Lisp code that may not fit in a single page.
13401 ,#+END_SRC
13402 #+end_example
13404 #+vindex: org-latex-listings-options
13405 #+vindex: org-latex-minted-options
13406 The LaTeX export back-end passes string values in =:options= to LaTeX
13407 packages for customization of that specific source block.  In the
13408 example below, the =:options= are set for Minted.  Minted is a source
13409 code highlighting LaTeX package with many configurable options.
13411 #+begin_example
13412 ,#+ATTR_LATEX: :options commentstyle=\bfseries
13413 ,#+BEGIN_SRC emacs-lisp
13414   (defun Fib (n)
13415     (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
13416 ,#+END_SRC
13417 #+end_example
13419 To apply similar configuration options for all source blocks in
13420 a file, use the ~org-latex-listings-options~ and
13421 ~org-latex-minted-options~ variables.
13423 *** Example blocks in LaTeX export
13424 :PROPERTIES:
13425 :DESCRIPTION: Attributes specific to example blocks.
13426 :END:
13427 #+cindex: example blocks, in @LaTeX{} export
13428 #+cindex: verbatim blocks, in @LaTeX{} export
13429 #+cindex: @samp{ATTR_LATEX}, keyword
13431 The LaTeX export back-end wraps the contents of example blocks in
13432 a =verbatim= environment.  To change this behavior to use another
13433 environment globally, specify an appropriate export filter (see
13434 [[*Advanced Export Configuration]]).  To change this behavior to use
13435 another environment for each block, use the =:environment= parameter
13436 to specify a custom environment.
13438 #+begin_example
13439 ,#+ATTR_LATEX: :environment myverbatim
13440 ,#+BEGIN_EXAMPLE
13441   This sentence is false.
13442 ,#+END_EXAMPLE
13443 #+end_example
13445 *** Special blocks in LaTeX export
13446 :PROPERTIES:
13447 :DESCRIPTION: Attributes specific to special blocks.
13448 :END:
13450 #+cindex: special blocks, in @LaTeX{} export
13451 #+cindex: abstract, in @LaTeX{} export
13452 #+cindex: proof, in @LaTeX{} export
13453 #+cindex: @samp{ATTR_LATEX}, keyword
13455 For other special blocks in the Org file, the LaTeX export back-end
13456 makes a special environment of the same name.  The back-end also takes
13457 =:options=, if any, and appends as-is to that environment's opening
13458 string.  For example:
13460 #+begin_example
13461 ,#+BEGIN_abstract
13462   We demonstrate how to solve the Syracuse problem.
13463 ,#+END_abstract
13465 ,#+ATTR_LATEX: :options [Proof of important theorem]
13466 ,#+BEGIN_proof
13467   ...
13468   Therefore, any even number greater than 2 is the sum of two primes.
13469 ,#+END_proof
13470 #+end_example
13472 #+texinfo: @noindent
13473 exports to
13475 #+begin_example
13476 \begin{abstract}
13477   We demonstrate how to solve the Syracuse problem.
13478 \end{abstract}
13480 \begin{proof}[Proof of important theorem]
13481   ...
13482   Therefore, any even number greater than 2 is the sum of two primes.
13483 \end{proof}
13484 #+end_example
13486 If you need to insert a specific caption command, use =:caption=
13487 attribute.  It overrides standard =CAPTION= value, if any.  For
13488 example:
13490 #+begin_example
13491 ,#+ATTR_LATEX: :caption \MyCaption{HeadingA}
13492 ,#+BEGIN_proof
13493   ...
13494 ,#+END_proof
13495 #+end_example
13497 *** Horizontal rules in LaTeX export
13498 :PROPERTIES:
13499 :DESCRIPTION: Attributes specific to horizontal rules.
13500 :END:
13501 #+cindex: horizontal rules, in @LaTeX{} export
13502 #+cindex: @samp{ATTR_LATEX}, keyword
13504 The LaTeX export back-end converts horizontal rules by the specified
13505 =:width= and =:thickness= attributes.  For example:
13507 #+begin_example
13508 ,#+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt
13509 -----
13510 #+end_example
13512 ** Markdown Export
13513 :PROPERTIES:
13514 :DESCRIPTION: Exporting to Markdown.
13515 :END:
13516 #+cindex: Markdown export
13518 The Markdown export back-end, "md", converts an Org file to Markdown
13519 format, as defined at http://daringfireball.net/projects/markdown/.
13521 Since it is built on top of the HTML back-end (see [[*HTML Export]]), it
13522 converts every Org construct not defined in Markdown syntax, such as
13523 tables, to HTML.
13525 *** Markdown export commands
13526 :PROPERTIES:
13527 :UNNUMBERED: notoc
13528 :END:
13530 - {{{kbd(C-c C-e m m)}}} (~org-md-export-to-markdown~) ::
13532   #+kindex: C-c C-c m m
13533   #+findex: org-md-export-to-markdown
13534   Export to a text file with Markdown syntax.  For =myfile.org=, Org
13535   exports to =myfile.md=, overwritten without warning.
13537 - {{{kbd(C-c C-e m M)}}} (~org-md-export-as-markdown~) ::
13539   #+kindex: C-c C-c m M
13540   #+findex: org-md-export-as-markdown
13541   Export to a temporary buffer.  Does not create a file.
13543 - {{{kbd(C-c C-e m o)}}} ::
13545   #+kindex: C-c C-e m o
13546   Export as a text file with Markdown syntax, then open it.
13548 *** Header and sectioning structure
13549 :PROPERTIES:
13550 :UNNUMBERED: notoc
13551 :END:
13553 #+vindex: org-md-headline-style
13554 Based on ~org-md-headline-style~, Markdown export can generate
13555 headlines of both /atx/ and /setext/ types.  /atx/ limits headline
13556 levels to two whereas /setext/ limits headline levels to six.  Beyond
13557 these limits, the export back-end converts headlines to lists.  To set
13558 a limit to a level before the absolute limit (see [[*Export Settings]]).
13560 ** OpenDocument Text Export
13561 :PROPERTIES:
13562 :DESCRIPTION: Exporting to OpenDocument Text.
13563 :END:
13564 #+cindex: ODT
13565 #+cindex: OpenDocument
13566 #+cindex: export, OpenDocument
13567 #+cindex: LibreOffice
13569 The ODT export back-end handles creating of OpenDocument Text (ODT)
13570 format.  Documents created by this exporter use the
13571 {{{cite(OpenDocument-v1.2 specification)}}}[fn:133] and are compatible
13572 with LibreOffice 3.4.
13574 *** Pre-requisites for ODT export
13575 :PROPERTIES:
13576 :DESCRIPTION: Required packages.
13577 :END:
13578 #+cindex: zip
13580 The ODT export back-end relies on the zip program to create the final
13581 compressed ODT output.  Check if =zip= is locally available and
13582 executable.  Without it, export cannot finish.
13584 *** ODT export commands
13585 :PROPERTIES:
13586 :DESCRIPTION: Invoking export.
13587 :END:
13589 - {{{kbd(C-c C-e o o)}}} (~org-export-to-odt~) ::
13591   #+kindex: C-c C-e o o
13592   #+findex: org-export-to-odt
13593   Export as OpenDocument Text file.
13595   #+cindex: @samp{EXPORT_FILE_NAME}, property
13596   #+vindex: org-odt-preferred-output-format
13598   If ~org-odt-preferred-output-format~ is specified, the ODT export
13599   back-end automatically converts the exported file to that format.
13601   For =myfile.org=, Org exports to =myfile.odt=, overwriting without
13602   warning.  The ODT export back-end exports a region only if a region
13603   was active.
13605   If the selected region is a single tree, the ODT export back-end
13606   makes the tree head the document title.  Incidentally, {{{kbd(C-c
13607   @)}}} selects the current sub-tree.  If the tree head entry has, or
13608   inherits, an =EXPORT_FILE_NAME= property, the ODT export back-end
13609   uses that for file name.
13611 - {{{kbd(C-c C-e o O)}}} ::
13613   #+kindex: C-c C-e o O
13614   Export as an OpenDocument Text file and open the resulting file.
13616   #+vindex: org-export-odt-preferred-output-format
13617   If ~org-export-odt-preferred-output-format~ is specified, open the
13618   converted file instead.  See [[*Automatically exporting to other
13619   formats]].
13621 *** ODT specific export settings
13622 :PROPERTIES:
13623 :DESCRIPTION: Configuration options.
13624 :END:
13626 The ODT export back-end has several additional keywords for
13627 customizing ODT output.  Setting these keywords works similar to the
13628 general options (see [[*Export Settings]]).
13630 - =DESCRIPTION= ::
13632   #+cindex: @samp{DESCRIPTION}, keyword
13633   This is the document's description, which the ODT export back-end
13634   inserts as document metadata.  For long descriptions, use multiple
13635   lines, prefixed with =DESCRIPTION=.
13637 - =KEYWORDS= ::
13639   #+cindex: @samp{KEYWORDS}, keyword
13640   The keywords for the document.  The ODT export back-end inserts the
13641   description along with author name, keywords, and related file
13642   metadata as metadata in the output file.  Use multiple =KEYWORDS= if
13643   necessary.
13645 - =ODT_STYLES_FILE= ::
13647   #+cindex: @samp{ODT_STYLES_FILE}, keyword
13648   #+vindex: org-odt-styles-file
13649   The ODT export back-end uses the ~org-odt-styles-file~ by default.
13650   See [[*Applying custom styles]] for details.
13652 - =SUBTITLE= ::
13654   #+cindex: @samp{SUBTITLE}, keyword
13655   The document subtitle.
13657 *** Extending ODT export
13658 :PROPERTIES:
13659 :DESCRIPTION: Producing DOC, PDF files.
13660 :END:
13662 The ODT export back-end can produce documents in other formats besides
13663 ODT using a specialized ODT converter process.  Its common interface
13664 works with popular converters to produce formats such as =doc=, or
13665 convert a document from one format, say =csv=, to another format, say
13666 =xls=.
13668 #+cindex: @file{unoconv}
13669 #+vindex: org-odt-convert-process
13670 Customize ~org-odt-convert-process~ variable to point to =unoconv=,
13671 which is the ODT's preferred converter.  Working installations of
13672 LibreOffice would already have =unoconv= installed.  Alternatively,
13673 other converters may be substituted here.  See [[*Configuring
13674 a document converter]].
13676 **** Automatically exporting to other formats
13677 :PROPERTIES:
13678 :UNNUMBERED: notoc
13679 :END:
13681 #+vindex: org-odt-preferred-output-format
13682 If ODT format is just an intermediate step to get to other formats,
13683 such as =doc=, =docx=, =rtf=, or =pdf=, etc., then extend the ODT
13684 export back-end to directly produce that format.  Specify the final
13685 format in the ~org-odt-preferred-output-format~ variable.  This is one
13686 way to extend (see [[*ODT export commands]]).
13688 **** Converting between document formats
13689 :PROPERTIES:
13690 :UNNUMBERED: notoc
13691 :END:
13693 The Org export back-end is made to be inter-operable with a wide range
13694 of text document format converters.  Newer generation converters, such
13695 as LibreOffice and Pandoc, can handle hundreds of formats at once.
13696 Org provides a consistent interaction with whatever converter is
13697 installed.  Here are some generic commands:
13699 - {{{kbd(M-x org-odt-convert)}}} ::
13701   #+findex: org-odt-convert
13702   Convert an existing document from one format to another.  With
13703   a prefix argument, opens the newly produced file.
13705 *** Applying custom styles
13706 :PROPERTIES:
13707 :DESCRIPTION: Styling the output.
13708 :END:
13709 #+cindex: styles, custom
13710 #+cindex: template, custom
13712 The ODT export back-end comes with many OpenDocument styles (see
13713 [[*Working with OpenDocument style files]]).  To expand or further
13714 customize these built-in style sheets, either edit the style sheets
13715 directly or generate them using an application such as LibreOffice.
13716 The example here shows creating a style using LibreOffice.
13718 **** Applying custom styles: the easy way
13719 :PROPERTIES:
13720 :UNNUMBERED: notoc
13721 :END:
13723 1. Create a sample =example.org= file with settings as shown below,
13724    and export it to ODT format.
13726    : #+OPTIONS: H:10 num:t
13728 2. Open the above =example.odt= using LibreOffice.  Use the /Stylist/
13729    to locate the target styles, which typically have the "Org" prefix.
13730    Open one, modify, and save as either OpenDocument Text (ODT) or
13731    OpenDocument Template (OTT) file.
13734    #+vindex: org-odt-styles-file
13735    Customize the variable ~org-odt-styles-file~ and point it to the
13736    newly created file.  For additional configuration options, see
13737    [[x-overriding-factory-styles][Overriding factory styles]].
13739    #+cindex: @samp{ODT_STYLES_FILE}, keyword
13740    To apply an ODT style to a particular file, use the
13741    =ODT_STYLES_FILE= keyword as shown in the example below:
13743    : #+ODT_STYLES_FILE: "/path/to/example.ott"
13745    #+texinfo: @noindent
13746    or
13748    : #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
13750 **** Using third-party styles and templates
13751 :PROPERTIES:
13752 :UNNUMBERED: notoc
13753 :END:
13755 The ODT export back-end relies on many templates and style names.
13756 Using third-party styles and templates can lead to mismatches.
13757 Templates derived from built in ODT templates and styles seem to have
13758 fewer problems.
13760 *** Links in ODT export
13761 :PROPERTIES:
13762 :DESCRIPTION: Handling and formatting links.
13763 :END:
13764 #+cindex: links, in ODT export
13766 ODT exporter creates native cross-references for internal links.  It
13767 creates Internet-style links for all other links.
13769 A link with no description and pointing to a regular, un-itemized,
13770 outline heading is replaced with a cross-reference and section number
13771 of the heading.
13773 A =\ref{label}=-style reference to an image, table etc., is replaced
13774 with a cross-reference and sequence number of the labeled entity.  See
13775 [[*Labels and captions in ODT export]].
13777 *** Tables in ODT export
13778 :PROPERTIES:
13779 :DESCRIPTION: Org tables conversions.
13780 :END:
13782 #+cindex: tables, in ODT export
13784 The ODT export back-end handles native Org mode tables (see [[*Tables]])
13785 and simple =table.el= tables.  Complex =table.el= tables having column
13786 or row spans are not supported.  Such tables are stripped from the
13787 exported document.
13789 By default, the ODT export back-end exports a table with top and
13790 bottom frames and with ruled lines separating row and column groups
13791 (see [[*Column Groups]]).  All tables are typeset to occupy the same
13792 width.  The ODT export back-end honors any table alignments and
13793 relative widths for columns (see [[*Column Width and Alignment]]).
13795 Note that the ODT export back-end interprets column widths as weighted
13796 ratios, the default weight being 1.
13798 #+cindex: @samp{ATTR_ODT}, keyword
13799 Specifying =:rel-width= property on an =ATTR_ODT= line controls the
13800 width of the table.  For example:
13802 #+begin_example
13803 ,#+ATTR_ODT: :rel-width 50
13804 | Area/Month    |   Jan |   Feb |   Mar |   Sum |
13805 |---------------+-------+-------+-------+-------|
13806 | /             |     < |       |       |     < |
13807 | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
13808 | North America |     1 |    21 |   926 |   948 |
13809 | Middle East   |     6 |    75 |   844 |   925 |
13810 | Asia Pacific  |     9 |    27 |   790 |   826 |
13811 |---------------+-------+-------+-------+-------|
13812 | Sum           |    16 |   123 |  2560 |  2699 |
13813 #+end_example
13815 On export, the above table takes 50% of text width area.  The exporter
13816 sizes the columns in the ratio: 13:5:5:5:6.  The first column is
13817 left-aligned and rest of the columns, right-aligned.  Vertical rules
13818 separate the header and the last column.  Horizontal rules separate
13819 the header and the last row.
13821 For even more customization, create custom table styles and associate
13822 them with a table using the =ATTR_ODT= keyword.  See [[*Customizing
13823 tables in ODT export]].
13825 *** Images in ODT export
13826 :PROPERTIES:
13827 :DESCRIPTION: Inserting images.
13828 :END:
13829 #+cindex: images, embedding in ODT
13830 #+cindex: embedding images in ODT
13832 **** Embedding images
13833 :PROPERTIES:
13834 :UNNUMBERED: notoc
13835 :END:
13837 The ODT export back-end processes image links in Org files that do not
13838 have descriptions, such as these links =[[file:img.jpg]]= or =[[./img.jpg]]=,
13839 as direct image insertions in the final output.  Either of these
13840 examples works:
13842 : [[file:img.png]]
13844 : [[./img.png]]
13846 **** Embedding clickable images
13847 :PROPERTIES:
13848 :UNNUMBERED: notoc
13849 :END:
13851 For clickable images, provide a link whose description is another link
13852 to an image file.  For example, to embed an image
13853 =org-mode-unicorn.png= which when clicked jumps to https://orgmode.org
13854 website, do the following
13856 : [[https://orgmode.org][./org-mode-unicorn.png]]
13858 **** Sizing and scaling of embedded images
13859 :PROPERTIES:
13860 :UNNUMBERED: notoc
13861 :END:
13863 #+cindex: @samp{ATTR_ODT}, keyword
13865 Control the size and scale of the embedded images with the =ATTR_ODT=
13866 attribute.
13868 #+cindex: identify, ImageMagick
13869 #+vindex: org-odt-pixels-per-inch
13870 The ODT export back-end starts with establishing the size of the image
13871 in the final document.  The dimensions of this size are measured in
13872 centimeters.  The back-end then queries the image file for its
13873 dimensions measured in pixels.  For this measurement, the back-end
13874 relies on ImageMagick's identify program or Emacs ~create-image~ and
13875 ~image-size~ API.  ImageMagick is the preferred choice for large file
13876 sizes or frequent batch operations.  The back-end then converts the
13877 pixel dimensions using ~org-odt-pixels-per-inch~ into the familiar 72
13878 dpi or 96 dpi.  The default value for this is in
13879 ~display-pixels-per-inch~, which can be tweaked for better results
13880 based on the capabilities of the output device.  Here are some common
13881 image scaling operations:
13883 - Explicitly size the image ::
13885   To embed =img.png= as a 10 cm x 10 cm image, do the following:
13887   #+begin_example
13888   ,#+ATTR_ODT: :width 10 :height 10
13889   [[./img.png]]
13890   #+end_example
13892 - Scale the image ::
13894   To embed =img.png= at half its size, do the following:
13896   #+begin_example
13897   ,#+ATTR_ODT: :scale 0.5
13898   [[./img.png]]
13899   #+end_example
13901 - Scale the image to a specific width ::
13903   To embed =img.png= with a width of 10 cm while retaining the
13904   original height:width ratio, do the following:
13906   #+begin_example
13907   ,#+ATTR_ODT: :width 10
13908   [[./img.png]]
13909   #+end_example
13911 - Scale the image to a specific height ::
13913   To embed =img.png= with a height of 10 cm while retaining the
13914   original height:width ratio, do the following:
13916   #+begin_example
13917   ,#+ATTR_ODT: :height 10
13918   [[./img.png]]
13919   #+end_example
13921 **** Anchoring of images
13922 :PROPERTIES:
13923 :UNNUMBERED: notoc
13924 :END:
13926 #+cindex: @samp{ATTR_ODT}, keyword
13927 The ODT export back-end can anchor images to =as-char=, =paragraph=,
13928 or =page=.  Set the preferred anchor using the =:anchor= property of
13929 the =ATTR_ODT= line.
13931 To create an image that is anchored to a page:
13933 #+begin_example
13934 ,#+ATTR_ODT: :anchor page
13935 [[./img.png]]
13936 #+end_example
13938 *** Math formatting in ODT export
13939 :PROPERTIES:
13940 :DESCRIPTION: Formatting @LaTeX{} fragments.
13941 :END:
13943 The ODT exporter has special support for handling math.
13945 **** LaTeX math snippets
13946 :PROPERTIES:
13947 :DESCRIPTION: Embedding in @LaTeX{} format.
13948 :END:
13950 LaTeX math snippets (see [[*LaTeX fragments]]) can be embedded in the ODT
13951 document in one of the following ways:
13953 - MathML ::
13955   #+cindex: MathML
13956   Add this line to the Org file.  This option is activated on
13957   a per-file basis.
13959   : #+OPTIONS: tex:t
13961   With this option, LaTeX fragments are first converted into MathML
13962   fragments using an external LaTeX-to-MathML converter program.  The
13963   resulting MathML fragments are then embedded as an OpenDocument
13964   Formula in the exported document.
13966   #+vindex: org-latex-to-mathml-convert-command
13967   #+vindex: org-latex-to-mathml-jar-file
13968   You can specify the LaTeX-to-MathML converter by customizing the
13969   variables ~org-latex-to-mathml-convert-command~ and
13970   ~org-latex-to-mathml-jar-file~.
13972   If you prefer to use MathToWeb[fn:134] as your converter, you can
13973   configure the above variables as shown below.
13975   #+begin_src emacs-lisp
13976   (setq org-latex-to-mathml-convert-command
13977         "java -jar %j -unicode -force -df %o %I"
13978         org-latex-to-mathml-jar-file
13979         "/path/to/mathtoweb.jar")
13980   #+end_src
13982   #+texinfo: @noindent
13983   or, to use LaTeX​ML[fn:135] instead,
13985   #+begin_src emacs-lisp
13986   (setq org-latex-to-mathml-convert-command
13987         "latexmlmath \"%i\" --presentationmathml=%o")
13988   #+end_src
13990   To quickly verify the reliability of the LaTeX-to-MathML
13991   converter, use the following commands:
13993   - {{{kbd(M-x org-export-as-odf)}}} ::
13995     Convert a LaTeX math snippet to an OpenDocument formula (=.odf=)
13996     file.
13998   - {{{kbd(M-x org-export-as-odf-and-open)}}} ::
14000     Convert a LaTeX math snippet to an OpenDocument formula (=.odf=)
14001     file and open the formula file with the system-registered
14002     application.
14004 - PNG images ::
14006   #+cindex: dvipng
14007   #+cindex: dvisvgm
14008   #+cindex: ImageMagick
14009   Add this line to the Org file.  This option is activated on
14010   a per-file basis.
14012   : #+OPTIONS: tex:dvipng
14014   : #+OPTIONS: tex:dvisvgm
14016   #+texinfo: @noindent
14017   or
14019   : #+OPTIONS: tex:imagemagick
14021   Under this option, LaTeX fragments are processed into PNG or SVG
14022   images and the resulting images are embedded in the exported
14023   document.  This method requires dvipng program, dvisvgm or
14024   ImageMagick programs.
14026 **** MathML and OpenDocument formula files
14027 :PROPERTIES:
14028 :DESCRIPTION: Embedding in native format.
14029 :END:
14031 When embedding LaTeX math snippets in ODT documents is not reliable,
14032 there is one more option to try.  Embed an equation by linking to its
14033 MathML (=.mml=) source or its OpenDocument formula (=.odf=) file as
14034 shown below:
14036 : [[./equation.mml]]
14038 #+texinfo: @noindent
14041 : [[./equation.odf]]
14043 *** Labels and captions in ODT export
14044 :PROPERTIES:
14045 :DESCRIPTION: Rendering objects.
14046 :END:
14048 ODT format handles labeling and captioning of objects based on their
14049 types.  Inline images, tables, LaTeX fragments, and Math formulas are
14050 numbered and captioned separately.  Each object also gets a unique
14051 sequence number based on its order of first appearance in the Org
14052 file.  Each category has its own sequence.  A caption is just a label
14053 applied to these objects.
14055 #+begin_example
14056 ,#+CAPTION: Bell curve
14057 ,#+NAME:   fig:SED-HR4049
14058 [[./img/a.png]]
14059 #+end_example
14061 When rendered, it may show as follows in the exported document:
14063 : Figure 2: Bell curve
14065 #+vindex: org-odt-category-map-alist
14066 To modify the category component of the caption, customize the option
14067 ~org-odt-category-map-alist~.  For example, to tag embedded images
14068 with the string "Illustration" instead of the default string "Figure",
14069 use the following setting:
14071 #+begin_src emacs-lisp
14072 (setq org-odt-category-map-alist
14073       '(("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))
14074 #+end_src
14076 With the above modification, the previous example changes to:
14078 : Illustration 2: Bell curve
14080 *** Literal examples in ODT export
14081 :PROPERTIES:
14082 :DESCRIPTION: For source code and example blocks.
14083 :END:
14085 The ODT export back-end supports literal examples (see [[*Literal
14086 Examples]]) with full fontification.  Internally, the ODT export
14087 back-end relies on =htmlfontify.el= to generate the style definitions
14088 needed for fancy listings.  The auto-generated styles get =OrgSrc=
14089 prefix and inherit colors from the faces used by Emacs Font Lock
14090 library for that source language.
14092 #+vindex: org-odt-fontify-srcblocks
14093 For custom fontification styles, customize the
14094 ~org-odt-create-custom-styles-for-srcblocks~ option.
14096 #+vindex: org-odt-create-custom-styles-for-srcblocks
14097 To turn off fontification of literal examples, customize the
14098 ~org-odt-fontify-srcblocks~ option.
14100 *** Advanced topics in ODT export
14101 :PROPERTIES:
14102 :DESCRIPTION: For power users.
14103 :END:
14105 The ODT export back-end has extensive features useful for power users
14106 and frequent uses of ODT formats.
14108 **** Configuring a document converter
14109 :PROPERTIES:
14110 :DESCRIPTION: Registering a document converter.
14111 :UNNUMBERED: notoc
14112 :END:
14113 #+cindex: convert
14114 #+cindex: doc, docx, rtf
14115 #+cindex: converter
14117 The ODT export back-end works with popular converters with little or
14118 no extra configuration.  See [[*Extending ODT export]].  The following is
14119 for unsupported converters or tweaking existing defaults.
14121 - Register the converter ::
14123   #+vindex: org-export-odt-convert-processes
14124   Add the name of the converter to the ~org-odt-convert-processes~
14125   variable.  Note that it also requires how the converter is invoked
14126   on the command line.  See the variable's docstring for details.
14128 - Configure its capabilities ::
14130   #+vindex: org-export-odt-convert-capabilities
14131   Specify which formats the converter can handle by customizing the
14132   variable ~org-odt-convert-capabilities~.  Use the entry for the
14133   default values in this variable for configuring the new converter.
14134   Also see its docstring for details.
14136 - Choose the converter ::
14138   #+vindex: org-export-odt-convert-process
14139   Select the newly added converter as the preferred one by customizing
14140   the option ~org-odt-convert-process~.
14142 **** Working with OpenDocument style files
14143 :PROPERTIES:
14144 :DESCRIPTION: Exploring internals.
14145 :UNNUMBERED: notoc
14146 :END:
14147 #+cindex: styles, custom
14148 #+cindex: template, custom
14150 This section explores the internals of the ODT exporter; the means by which
14151 it produces styled documents; the use of automatic and custom OpenDocument
14152 styles.
14154 The ODT exporter relies on two files for generating its output.  These
14155 files are bundled with the distribution under the directory pointed to
14156 by the variable ~org-odt-styles-dir~.  The two files are:
14158 - =OrgOdtStyles.xml= <<x-orgodtstyles-xml>> ::
14160   This file contributes to the =styles.xml= file of the final ODT
14161   document.  This file gets modified for the following purposes:
14163   1. To control outline numbering based on user settings;
14165   2. To add styles generated by =htmlfontify.el= for fontification of
14166      code blocks.
14168 - =OrgOdtContentTemplate.xml= <<x-orgodtcontenttemplate-xml>> ::
14170   This file contributes to the =content.xml= file of the final ODT
14171   document.  The contents of the Org outline are inserted between the
14172   =<office:text>= ... =</office:text>= elements of this file.
14174   Apart from serving as a template file for the final =content.xml=,
14175   the file serves the following purposes:
14177   1. It contains automatic styles for formatting of tables which are
14178      referenced by the exporter;
14180   2. It contains =<text:sequence-decl>= ... =</text:sequence-decl>=
14181      elements that control numbering of tables, images, equations, and
14182      similar entities.
14184 <<x-overriding-factory-styles>> The following two variables control
14185 the location from where the ODT exporter picks up the custom styles
14186 and content template files.  Customize these variables to override the
14187 factory styles used by the exporter.
14189 - ~org-odt-styles-file~ ::
14191   The ODT export back-end uses the file pointed to by this variable,
14192   such as =styles.xml=, for the final output.  It can take one of the
14193   following values:
14195   - =FILE.xml= ::
14197     Use this file instead of the default =styles.xml=
14199   - =FILE.odt= or =FILE.ott= ::
14201     Use the =styles.xml= contained in the specified OpenDocument
14202     Text or Template file
14204   - =FILE.odt= or =FILE.ott= and a subset of included files ::
14206     Use the =styles.xml= contained in the specified OpenDocument Text
14207     or Template file.  Additionally extract the specified member files
14208     and embed those within the final ODT document.
14210     Use this option if the =styles.xml= file references additional
14211     files like header and footer images.
14213   - ~nil~ ::
14215     Use the default =styles.xml=.
14217 - ~org-odt-content-template-file~ ::
14219   Use this variable to specify the blank =content.xml= used in the
14220   final output.
14222 **** Creating one-off styles
14223 :PROPERTIES:
14224 :DESCRIPTION: Customizing styles, highlighting...
14225 :UNNUMBERED: notoc
14226 :END:
14228 The ODT export back-end can read embedded raw OpenDocument XML from
14229 the Org file.  Such direct formatting is useful for one-off instances.
14231 - Embedding ODT tags as part of regular text ::
14233   Enclose OpenDocument syntax in =@@odt:...@@= for inline markup.  For
14234   example, to highlight a region of text do the following:
14236   #+begin_example
14237   @@odt:<text:span text:style-name="Highlight">This is highlighted
14238   text</text:span>@@.  But this is regular text.
14239   #+end_example
14241   *Hint:* To see the above example in action, edit the =styles.xml=
14242   (see [[x-orgodtstyles-xml][Factory styles]]) and add a custom /Highlight/ style as shown
14243   below:
14245   #+begin_example
14246   <style:style style:name="Highlight" style:family="text">
14247     <style:text-properties fo:background-color="#ff0000"/>
14248   </style:style>
14249   #+end_example
14251 - Embedding a one-line OpenDocument XML ::
14253   #+cindex: @samp{ODT}, keyword
14254   The ODT export back-end can read one-liner options with =#+ODT:= in
14255   the Org file.  For example, to force a page break:
14257   #+begin_example
14258   ,#+ODT: <text:p text:style-name="PageBreak"/>
14259   #+end_example
14261   *Hint:* To see the above example in action, edit your
14262   =styles.xml= (see [[x-orgodtstyles-xml][Factory styles]]) and add a custom =PageBreak=
14263   style as shown below.
14265   #+begin_example
14266   <style:style style:name="PageBreak" style:family="paragraph"
14267                style:parent-style-name="Text_20_body">
14268     <style:paragraph-properties fo:break-before="page"/>
14269   </style:style>
14270   #+end_example
14272 - Embedding a block of OpenDocument XML ::
14274   The ODT export back-end can also read ODT export blocks for
14275   OpenDocument XML.  Such blocks use the =#+BEGIN_EXPORT odt=
14276   ... =#+END_EXPORT= constructs.
14278   For example, to create a one-off paragraph that uses bold text, do
14279   the following:
14281   #+begin_example
14282   ,#+BEGIN_EXPORT odt
14283     <text:p text:style-name="Text_20_body_20_bold">
14284     This paragraph is specially formatted and uses bold text.
14285     </text:p>
14286   ,#+END_EXPORT
14287   #+end_example
14289 **** Customizing tables in ODT export
14290 :PROPERTIES:
14291 :DESCRIPTION: Defining table templates.
14292 :UNNUMBERED: notoc
14293 :END:
14294 #+cindex: tables, in ODT export
14295 #+cindex: @samp{ATTR_ODT}, keyword
14297 Override the default table format by specifying a custom table style
14298 with the =#+ATTR_ODT= line.  For a discussion on default formatting of
14299 tables, see [[*Tables in ODT export]].
14301 This feature closely mimics the way table templates are defined in the
14302 OpenDocument-v1.2 specification[fn:136].
14304 #+vindex: org-odt-table-styles
14305 For quick preview of this feature, install the settings below and export the
14306 table that follows:
14308 #+begin_src emacs-lisp
14309 (setq org-export-odt-table-styles
14310       (append org-export-odt-table-styles
14311               '(("TableWithHeaderRowAndColumn" "Custom"
14312                  ((use-first-row-styles . t)
14313                   (use-first-column-styles . t)))
14314                 ("TableWithFirstRowandLastRow" "Custom"
14315                  ((use-first-row-styles . t)
14316                   (use-last-row-styles . t))))))
14317 #+end_src
14319 #+begin_example
14320 ,#+ATTR_ODT: :style TableWithHeaderRowAndColumn
14321 | Name  | Phone | Age |
14322 | Peter |  1234 |  17 |
14323 | Anna  |  4321 |  25 |
14324 #+end_example
14326 The example above used =Custom= template and installed two table
14327 styles =TableWithHeaderRowAndColumn= and
14328 =TableWithFirstRowandLastRow=.  *Important:* The OpenDocument styles
14329 needed for producing the above template were pre-defined.  They are
14330 available in the section marked =Custom Table Template= in
14331 =OrgOdtContentTemplate.xml= (see [[x-orgodtcontenttemplate-xml][Factory styles]]).  For adding new
14332 templates, define new styles there.
14334 To use this feature proceed as follows:
14336 1. Create a table template[fn:137].
14338    A table template is set of =table-cell= and =paragraph= styles for
14339    each of the following table cell categories:
14341    - Body
14342    - First column
14343    - Last column
14344    - First row
14345    - Last row
14346    - Even row
14347    - Odd row
14348    - Even column
14349    - Odd Column
14351    The names for the above styles must be chosen based on the name of
14352    the table template using a well-defined convention.
14354    The naming convention is better illustrated with an example.  For
14355    a table template with the name =Custom=, the needed style names are
14356    listed in the following table.
14358    | Cell type    | Cell style                   | Paragraph style                   |
14359    |--------------+------------------------------+-----------------------------------|
14360    | Body         | =CustomTableCell=            | =CustomTableParagraph=            |
14361    | First column | =CustomFirstColumnTableCell= | =CustomFirstColumnTableParagraph= |
14362    | Last column  | =CustomLastColumnTableCell=  | =CustomLastColumnTableParagraph=  |
14363    | First row    | =CustomFirstRowTableCell=    | =CustomFirstRowTableParagraph=    |
14364    | Last row     | =CustomLastRowTableCell=     | =CustomLastRowTableParagraph=     |
14365    | Even row     | =CustomEvenRowTableCell=     | =CustomEvenRowTableParagraph=     |
14366    | Odd row      | =CustomOddRowTableCell=      | =CustomOddRowTableParagraph=      |
14367    | Even column  | =CustomEvenColumnTableCell=  | =CustomEvenColumnTableParagraph=  |
14368    | Odd column   | =CustomOddColumnTableCell=   | =CustomOddColumnTableParagraph=   |
14370    To create a table template with the name =Custom=, define the above
14371    styles in the =<office:automatic-styles>= ...
14372    =</office:automatic-styles>= element of the content template file
14373    (see [[x-orgodtcontenttemplate-xml][Factory styles]]).
14375 2. Define a table style[fn:138].
14377    #+vindex: org-odt-table-styles
14378    To define a table style, create an entry for the style in the
14379    variable ~org-odt-table-styles~ and specify the following:
14381    - the name of the table template created in step (1),
14382    - the set of cell styles in that template that are to be activated.
14384    For example, the entry below defines two different table styles
14385    =TableWithHeaderRowAndColumn= and =TableWithFirstRowandLastRow=
14386    based on the same template =Custom=.  The styles achieve their
14387    intended effect by selectively activating the individual cell
14388    styles in that template.
14390    #+begin_src emacs-lisp
14391    (setq org-export-odt-table-styles
14392          (append org-export-odt-table-styles
14393                  '(("TableWithHeaderRowAndColumn" "Custom"
14394                     ((use-first-row-styles . t)
14395                      (use-first-column-styles . t)))
14396                    ("TableWithFirstRowandLastRow" "Custom"
14397                     ((use-first-row-styles . t)
14398                      (use-last-row-styles . t))))))
14399    #+end_src
14401 3. Associate a table with the table style.
14403    To do this, specify the table style created in step (2) as part of
14404    the =ATTR_ODT= line as shown below.
14406    #+begin_example
14407    ,#+ATTR_ODT: :style TableWithHeaderRowAndColumn
14408    | Name  | Phone | Age |
14409    | Peter |  1234 |  17 |
14410    | Anna  |  4321 |  25 |
14411    #+end_example
14413 **** Validating OpenDocument XML
14414 :PROPERTIES:
14415 :DESCRIPTION: Debugging corrupted OpenDocument files.
14416 :UNNUMBERED: notoc
14417 :END:
14419 Sometimes ODT format files may not open due to =.odt= file corruption.
14420 To verify if such a file is corrupt, validate it against the
14421 OpenDocument Relax NG Compact (RNC) syntax schema.  But first the
14422 =.odt= files have to be decompressed using =zip=.  Note that =.odt=
14423 files are ZIP archives: [[info:emacs::File Archives]].  The contents of
14424 ODT files are in XML.  For general help with validation---and
14425 schema-sensitive editing---of XML files: [[info:nxml-mode::Introduction]].
14427 #+vindex: org-export-odt-schema-dir
14428 Customize ~org-odt-schema-dir~ to point to a directory with
14429 OpenDocument RNC files and the needed schema-locating rules.  The ODT
14430 export back-end takes care of updating the
14431 ~rng-schema-locating-files~.
14433 ** Org Export
14434 :PROPERTIES:
14435 :DESCRIPTION: Exporting to Org.
14436 :END:
14438 #+cindex: Org export
14439 /org/ export back-end creates a normalized version of the Org document
14440 in current buffer.  The exporter evaluates Babel code (see [[*Evaluating
14441 Code Blocks]]) and removes content specific to other back-ends.
14443 *** Org export commands
14444 :PROPERTIES:
14445 :UNNUMBERED: notoc
14446 :END:
14448 - {{{kbd(C-c C-e O o)}}} (~org-org-export-to-org~) ::
14450   #+kindex: C-c C-e O o
14451   #+findex: org-org-export-to-org
14452   Export as an Org file with a =.org= extension.  For =myfile.org=,
14453   Org exports to =myfile.org.org=, overwriting without warning.
14455 - {{{kbd(C-c C-e O v)}}} (~~) ::
14457   #+kindex: C-c C-e O v
14458   Export to an Org file, then open it.
14460 ** Texinfo Export
14461 :PROPERTIES:
14462 :DESCRIPTION: Exporting to Texinfo.
14463 :END:
14465 *** Texinfo export commands
14466 :PROPERTIES:
14467 :DESCRIPTION: Invoking commands.
14468 :END:
14470 - {{{kbd(C-c C-e i t)}}} (~org-texinfo-export-to-texinfo~) ::
14472   #+kindex: C-c C-e i t
14473   #+findex: org-texinfo-export-to-texinfo
14474   Export as a Texinfo file with =.texi= extension.  For =myfile.org=,
14475   Org exports to =myfile.texi=, overwriting without warning.
14477 - {{{kbd(C-c C-e i i)}}} (~org-texinfo-export-to-info~) ::
14479   #+kindex: C-c C-e i i
14480   #+findex: org-texinfo-export-to-info
14481   #+vindex: org-texinfo-info-process
14482   Export to Texinfo format first and then process it to make an Info
14483   file.  To generate other formats, such as DocBook, customize the
14484   ~org-texinfo-info-process~ variable.
14486 *** Texinfo specific export settings
14487 :PROPERTIES:
14488 :DESCRIPTION: Setting the environment.
14489 :END:
14491 The Texinfo export back-end has several additional keywords for
14492 customizing Texinfo output.  Setting these keywords works similar to
14493 the general options (see [[*Export Settings]]).
14495 - =SUBTITLE= ::
14497   #+cindex: @samp{SUBTITLE}, keyword
14498   The document subtitle.
14500 - =SUBAUTHOR= ::
14502   #+cindex: @samp{SUBAUTHOR}, keyword
14503   Additional authors for the document.
14505 - =TEXINFO_FILENAME= ::
14507   #+cindex: @samp{TEXINFO_FILENAME}, keyword
14508   The Texinfo filename.
14510 - =TEXINFO_CLASS= ::
14512   #+cindex: @samp{TEXINFO_CLASS}, keyword
14513   #+vindex: org-texinfo-default-class
14514   The default document class (~org-texinfo-default-class~), which must
14515   be a member of ~org-texinfo-classes~.
14517 - =TEXINFO_HEADER= ::
14519   #+cindex: @samp{TEXINFO_HEADER}, keyword
14520   Arbitrary lines inserted at the end of the header.
14522 - =TEXINFO_POST_HEADER= ::
14524   #+cindex: @samp{TEXINFO_POST_HEADER}, keyword
14525   Arbitrary lines inserted after the end of the header.
14527 - =TEXINFO_DIR_CATEGORY= ::
14529   #+cindex: @samp{TEXINFO_DIR_CATEGORY}, keyword
14530   The directory category of the document.
14532 - =TEXINFO_DIR_TITLE= ::
14534   #+cindex: @samp{TEXINFO_DIR_TITLE}, keyword
14535   The directory title of the document.
14537 - =TEXINFO_DIR_DESC= ::
14539   #+cindex: @samp{TEXINFO_DIR_DESC}, keyword
14540   The directory description of the document.
14542 - =TEXINFO_PRINTED_TITLE= ::
14544   #+cindex: @samp{TEXINFO_PRINTED_TITLE}, keyword
14545   The printed title of the document.
14547 *** Texinfo file header
14548 :PROPERTIES:
14549 :DESCRIPTION: Generating the header.
14550 :END:
14552 #+cindex: @samp{TEXINFO_FILENAME}, keyword
14553 After creating the header for a Texinfo file, the Texinfo back-end
14554 automatically generates a name and destination path for the Info file.
14555 To override this default with a more sensible path and name, specify
14556 the =TEXINFO_FILENAME= keyword.
14558 #+vindex: org-texinfo-coding-system
14559 #+cindex: @samp{TEXINFO_HEADER}, keyword
14560 Along with the output's file name, the Texinfo header also contains
14561 language details (see [[*Export Settings]]) and encoding system as set in
14562 the ~org-texinfo-coding-system~ variable.  Insert =TEXINFO_HEADER=
14563 keywords for each additional command in the header, for example:
14565 : #+TEXINFO_HEADER: @synindex
14567 #+cindex: @samp{TEXINFO_CLASS}, keyword
14568 #+vindex: org-texinfo-classes
14569 Instead of repeatedly installing the same set of commands, define
14570 a class in ~org-texinfo-classes~ once, and then activate it in the
14571 document by setting the =TEXINFO_CLASS= keyword to that class.
14573 *** Texinfo title and copyright page
14574 :PROPERTIES:
14575 :DESCRIPTION: Creating preamble pages.
14576 :END:
14578 #+cindex: @samp{TEXINFO_PRINTED_TITLE}, keyword
14579 The default template for hard copy output has a title page with
14580 =TITLE= and =AUTHOR= keywords (see [[*Export Settings]]).  To replace the
14581 regular title with something different for the printed version, use
14582 the =TEXINFO_PRINTED_TITLE= and =SUBTITLE= keywords.  Both expect raw
14583 Texinfo code for setting their values.
14585 #+cindex: @samp{SUBAUTHOR}, keyword
14586 If one =AUTHOR= line is not sufficient, add multiple =SUBAUTHOR=
14587 keywords.  They have to be set in raw Texinfo code.
14589 #+begin_example
14590 ,#+AUTHOR: Jane Smith
14591 ,#+SUBAUTHOR: John Doe
14592 ,#+TEXINFO_PRINTED_TITLE: This Long Title@@inlinefmt{tex,@*} Is Broken in @TeX{}
14593 #+end_example
14595 #+cindex: @samp{COPYING}, property
14596 Copying material is defined in a dedicated headline with a non-~nil~
14597 =COPYING= property.  The back-end inserts the contents within
14598 a =@copying= command at the beginning of the document.  The heading
14599 itself does not appear in the structure of the document.
14601 Copyright information is printed on the back of the title page.
14603 #+begin_example
14604 ,* Legalese
14605   :PROPERTIES:
14606   :COPYING: t
14607   :END:
14609   This is a short example of a complete Texinfo file, version 1.0.
14611   Copyright \copy 2016 Free Software Foundation, Inc.
14612 #+end_example
14614 *** Info directory file
14615 :PROPERTIES:
14616 :DESCRIPTION: Installing a manual in Info file hierarchy.
14617 :END:
14619 #+cindex: @samp{dir} file, in Texinfo export
14620 #+cindex: Info directory file, in Texinfo export
14621 #+cindex: @code{install-info}, in Texinfo export
14623 #+cindex: @samp{TEXINFO_DIR_CATEGORY}, keyword
14624 #+cindex: @samp{TEXINFO_DIR_TITLE}, keyword
14625 #+cindex: @samp{TEXINFO_DIR_DESC}, keyword
14626 The end result of the Texinfo export process is the creation of an
14627 Info file.  This Info file's metadata has variables for category,
14628 title, and description: =TEXINFO_DIR_CATEGORY=, =TEXINFO_DIR_TITLE=,
14629 and =TEXINFO_DIR_DESC= keywords that establish where in the Info
14630 hierarchy the file fits.
14632 Here is an example that writes to the Info directory file:
14634 #+begin_example
14635 ,#+TEXINFO_DIR_CATEGORY: Emacs
14636 ,#+TEXINFO_DIR_TITLE: Org Mode: (org)
14637 ,#+TEXINFO_DIR_DESC: Outline-based notes management and organizer
14638 #+end_example
14640 *** Headings and sectioning structure
14641 :PROPERTIES:
14642 :DESCRIPTION: Building document structure.
14643 :END:
14645 #+vindex: org-texinfo-classes
14646 #+vindex: org-texinfo-default-class
14647 #+cindex: @samp{TEXINFO_CLASS}, keyword
14648 The Texinfo export back-end uses a pre-defined scheme to convert Org
14649 headlines to equivalent Texinfo structuring commands.  A scheme like
14650 this maps top-level headlines to numbered chapters tagged as
14651 ~@chapter~ and lower-level headlines to unnumbered chapters tagged as
14652 ~@unnumbered~.  To override such mappings to introduce ~@part~ or
14653 other Texinfo structuring commands, define a new class in
14654 ~org-texinfo-classes~.  Activate the new class with the
14655 =TEXINFO_CLASS= keyword.  When no new class is defined and activated,
14656 the Texinfo export back-end defaults to the
14657 ~org-texinfo-default-class~.
14659 If an Org headline's level has no associated Texinfo structuring
14660 command, or is below a certain threshold (see [[*Export Settings]]), then
14661 the Texinfo export back-end makes it into a list item.
14663 #+cindex: @samp{APPENDIX}, property
14664 The Texinfo export back-end makes any headline with a non-~nil~
14665 =APPENDIX= property into an appendix.  This happens independent of the
14666 Org headline level or the =TEXINFO_CLASS= keyword.
14668 #+cindex: @samp{ALT_TITLE}, property
14669 #+cindex: @samp{DESCRIPTION}, property
14670 The Texinfo export back-end creates a menu entry after the Org
14671 headline for each regular sectioning structure.  To override this with
14672 a shorter menu entry, use the =ALT_TITLE= property (see [[*Table of
14673 Contents]]).  Texinfo menu entries also have an option for a longer
14674 =DESCRIPTION= property.  Here's an example that uses both to override
14675 the default menu entry:
14677 #+begin_example
14678 ,* Controlling Screen Display
14679   :PROPERTIES:
14680   :ALT_TITLE: Display
14681   :DESCRIPTION: Controlling Screen Display
14682   :END:
14683 #+end_example
14685 #+cindex: Top node, in Texinfo export
14686 The text before the first headline belongs to the /Top/ node, i.e.,
14687 the node in which a reader enters an Info manual.  As such, it is
14688 expected not to appear in printed output generated from the =.texi=
14689 file.  See [[info:texinfo::The Top Node]], for more information.
14691 *** Indices
14692 :PROPERTIES:
14693 :DESCRIPTION: Creating indices.
14694 :END:
14696 #+cindex: @samp{CINDEX}, keyword
14697 #+cindex: concept index, in Texinfo export
14698 #+cindex: @samp{FINDEX}, keyword
14699 #+cindex: function index, in Texinfo export
14700 #+cindex: @samp{KINDEX}, keyword
14701 #+cindex: keystroke index, in Texinfo export
14702 #+cindex: @samp{PINDEX}, keyword
14703 #+cindex: program index, in Texinfo export
14704 #+cindex: @samp{TINDEX}, keyword
14705 #+cindex: data type index, in Texinfo export
14706 #+cindex: @samp{VINDEX}, keyword
14707 #+cindex: variable index, in Texinfo export
14708 The Texinfo export back-end recognizes these indexing keywords if used
14709 in the Org file: =CINDEX=, =FINDEX=, =KINDEX=, =PINDEX=, =TINDEX= and
14710 =VINDEX=.  Write their value as verbatim Texinfo code; in particular,
14711 ={=, =}= and =@= characters need to be escaped with =@= if they do not
14712 belong to a Texinfo command.
14714 : #+CINDEX: Defining indexing entries
14716 #+cindex: @samp{INDEX}, property
14717 For the back-end to generate an index entry for a headline, set the
14718 =INDEX= property to =cp= or =vr=.  These abbreviations come from
14719 Texinfo that stand for concept index and variable index.  The Texinfo
14720 manual has abbreviations for all other kinds of indexes.  The back-end
14721 exports the headline as an unnumbered chapter or section command, and
14722 then inserts the index after its contents.
14724 #+begin_example
14725 ,* Concept Index
14726   :PROPERTIES:
14727   :INDEX: cp
14728   :END:
14729 #+end_example
14731 *** Quoting Texinfo code
14732 :PROPERTIES:
14733 :DESCRIPTION: Incorporating literal Texinfo code.
14734 :END:
14736 Use any of the following three methods to insert or escape raw Texinfo
14737 code:
14739 #+cindex: @samp{TEXINFO}, keyword
14740 #+cindex: @samp{BEGIN_EXPORT texinfo}
14741 #+begin_example
14742 Richard @@texinfo:@sc{@@Stallman@@texinfo:}@@ commence' GNU.
14744 ,#+TEXINFO: @need800
14745 This paragraph is preceded by...
14747 ,#+BEGIN_EXPORT texinfo
14748   @auindex Johnson, Mark
14749   @auindex Lakoff, George
14750 ,#+END_EXPORT
14751 #+end_example
14753 *** Plain lists in Texinfo export
14754 :PROPERTIES:
14755 :DESCRIPTION: List attributes.
14756 :END:
14758 #+cindex: @samp{ATTR_TEXINFO}, keyword
14759 #+cindex: two-column tables, in Texinfo export
14760 #+cindex: table-type, Texinfo attribute
14761 The Texinfo export back-end by default converts description lists in
14762 the Org file using the default command =@table=, which results in
14763 a table with two columns.  To change this behavior, set =:table-type=
14764 attribute to either =ftable= or =vtable= value.  For more information,
14765 see [[info:texinfo::Two-column Tables]].
14767 #+vindex: org-texinfo-table-default-markup
14768 #+cindex: indic, Texinfo attribute
14769 The Texinfo export back-end by default also applies a text highlight
14770 based on the defaults stored in ~org-texinfo-table-default-markup~.
14771 To override the default highlight command, specify another one with
14772 the =:indic= attribute.
14774 #+cindex: multiple items in Texinfo lists
14775 #+cindex: sep, Texinfo attribute
14776 Org syntax is limited to one entry per list item.  Nevertheless, the
14777 Texinfo export back-end can split that entry according to any text
14778 provided through the =:sep= attribute.  Each part then becomes a new
14779 entry in the first column of the table.
14781 The following example illustrates all the attributes above:
14783 #+begin_example
14784 ,#+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
14785 - foo, bar :: This is the common text for variables foo and bar.
14786 #+end_example
14788 #+texinfo: @noindent
14789 becomes
14791 #+begin_example
14792 @vtable @asis
14793 @item foo
14794 @itemx bar
14795 This is the common text for variables foo and bar.
14796 @end table
14797 #+end_example
14799 #+cindex: lettered lists, in Texinfo export
14800 #+cindex: enum, Texinfo attribute
14801 Ordered lists are numbered when exported to Texinfo format.  Such
14802 numbering obeys any counter (see [[*Plain Lists]]) in the first item of
14803 the list.  The =:enum= attribute also let you start the list at
14804 a specific number, or switch to a lettered list, as illustrated here
14806 #+begin_example
14807 #+ATTR_TEXINFO: :enum A
14808 1. Alpha
14809 2. Bravo
14810 3. Charlie
14811 #+end_example
14813 *** Tables in Texinfo export
14814 :PROPERTIES:
14815 :DESCRIPTION: Table attributes.
14816 :END:
14818 #+cindex: @samp{ATTR_TEXINFO}, keyword
14819 When exporting tables, the Texinfo export back-end uses the widest
14820 cell width in each column.  To override this and instead specify as
14821 fractions of line length, use the =:columns= attribute.  See example
14822 below.
14824 #+begin_example
14825 ,#+ATTR_TEXINFO: :columns .5 .5
14826 | a cell | another cell |
14827 #+end_example
14829 *** Images in Texinfo export
14830 :PROPERTIES:
14831 :DESCRIPTION: Image attributes.
14832 :END:
14834 #+cindex: @samp{ATTR_TEXINFO}, keyword
14835 Insert a file link to the image in the Org file, and the Texinfo
14836 export back-end inserts the image.  These links must have the usual
14837 supported image extensions and no descriptions.  To scale the image,
14838 use =:width= and =:height= attributes.  For alternate text, use =:alt=
14839 and specify the text using Texinfo code, as shown in the example:
14841 #+begin_example
14842 ,#+ATTR_TEXINFO: :width 1in :alt Alternate @i{text}
14843 [[ridt.pdf]]
14844 #+end_example
14846 *** Quotations in Texinfo export
14847 :PROPERTIES:
14848 :DESCRIPTION: Quote block attributes.
14849 :END:
14851 #+cindex: @samp{ATTR_TEXINFO}, keyword
14852 You can write the text of a quotation within a quote block (see
14853 [[*Paragraphs]]).  You may also emphasize some text at the beginning of
14854 the quotation with the =:tag= attribute.
14856 #+begin_example
14857 ,#+ATTR_TEXINFO: :tag Warning
14858 ,#+BEGIN_QUOTE
14859 Striking your thumb with a hammer may cause severe pain and discomfort.
14860 ,#+END_QUOTE
14861 #+end_example
14863 To specify the author of the quotation, use the =:author= attribute.
14865 #+begin_example
14866 ,#+ATTR_TEXINFO: :author King Arthur
14867 ,#+BEGIN_QUOTE
14868 The Lady of the Lake, her arm clad in the purest shimmering samite,
14869 held aloft Excalibur from the bosom of the water, signifying by divine
14870 providence that I, Arthur, was to carry Excalibur. That is why I am
14871 your king.
14872 ,#+END_QUOTE
14873 #+end_example
14875 *** Special blocks in Texinfo export
14876 :PROPERTIES:
14877 :DESCRIPTION: Special block attributes.
14878 :END:
14880 #+cindex: @samp{ATTR_TEXINFO}, keyword
14882 The Texinfo export back-end converts special blocks to commands with
14883 the same name.  It also adds any =:options= attributes to the end of
14884 the command, as shown in this example:
14886 #+begin_example
14887 ,#+ATTR_TEXINFO: :options org-org-export-to-org ...
14888 ,#+BEGIN_defun
14889   A somewhat obsessive function name.
14890 ,#+END_defun
14891 #+end_example
14893 #+texinfo: @noindent
14894 becomes
14896 #+begin_example
14897 @defun org-org-export-to-org ...
14898   A somewhat obsessive function name.
14899 @end defun
14900 #+end_example
14902 *** A Texinfo example
14903 :PROPERTIES:
14904 :DESCRIPTION: Processing Org to Texinfo.
14905 :END:
14907 Here is a more detailed example Org file.  See
14908 [[info:texinfo::GNU Sample Texts]] for an equivalent example using
14909 Texinfo code.
14911 #+begin_example
14912 ,#+TITLE: GNU Sample {{{version}}}
14913 ,#+SUBTITLE: for version {{{version}}}, {{{updated}}}
14914 ,#+AUTHOR: A.U. Thor
14915 ,#+EMAIL: bug-sample@gnu.org
14917 ,#+OPTIONS: ':t toc:t author:t email:t
14918 ,#+LANGUAGE: en
14920 ,#+MACRO: version 2.0
14921 ,#+MACRO: updated last updated 4 March 2014
14923 ,#+TEXINFO_FILENAME: sample.info
14924 ,#+TEXINFO_HEADER: @syncodeindex pg cp
14926 ,#+TEXINFO_DIR_CATEGORY: Texinfo documentation system
14927 ,#+TEXINFO_DIR_TITLE: sample: (sample)
14928 ,#+TEXINFO_DIR_DESC: Invoking sample
14930 ,#+TEXINFO_PRINTED_TITLE: GNU Sample
14932 This manual is for GNU Sample (version {{{version}}},
14933 {{{updated}}}).
14935 ,* Copying
14936   :PROPERTIES:
14937   :COPYING:  t
14938   :END:
14940   This manual is for GNU Sample (version {{{version}}},
14941   {{{updated}}}), which is an example in the Texinfo documentation.
14943   Copyright \copy 2016 Free Software Foundation, Inc.
14945   ,#+BEGIN_QUOTE
14946   Permission is granted to copy, distribute and/or modify this
14947   document under the terms of the GNU Free Documentation License,
14948   Version 1.3 or any later version published by the Free Software
14949   Foundation; with no Invariant Sections, with no Front-Cover Texts,
14950   and with no Back-Cover Texts.  A copy of the license is included in
14951   the section entitled "GNU Free Documentation License".
14952   ,#+END_QUOTE
14954 ,* Invoking sample
14956   ,#+PINDEX: sample
14957   ,#+CINDEX: invoking @command{sample}
14959   This is a sample manual.  There is no sample program to invoke, but
14960   if there were, you could see its basic usage and command line
14961   options here.
14963 ,* GNU Free Documentation License
14964   :PROPERTIES:
14965   :APPENDIX: t
14966   :END:
14968   ,#+INCLUDE: fdl.org
14970 ,* Index
14971   :PROPERTIES:
14972   :INDEX:    cp
14973   :END:
14974 #+end_example
14976 ** iCalendar Export
14977 :PROPERTIES:
14978 :DESCRIPTION: Exporting to iCalendar.
14979 :END:
14980 #+cindex: iCalendar export
14982 A large part of Org mode's interoperability success is its ability to
14983 easily export to or import from external applications.  The iCalendar
14984 export back-end takes calendar data from Org files and exports to the
14985 standard iCalendar format.
14987 #+vindex: org-icalendar-include-todo
14988 #+vindex: org-icalendar-use-deadline
14989 #+vindex: org-icalendar-use-scheduled
14990 The iCalendar export back-end can also incorporate TODO entries based
14991 on the configuration of the ~org-icalendar-include-todo~ variable.
14992 The back-end exports plain timestamps as =VEVENT=, TODO items as
14993 =VTODO=, and also create events from deadlines that are in non-TODO
14994 items.  The back-end uses the deadlines and scheduling dates in Org
14995 TODO items for setting the start and due dates for the iCalendar TODO
14996 entry.  Consult the ~org-icalendar-use-deadline~ and
14997 ~org-icalendar-use-scheduled~ variables for more details.
14999 #+vindex: org-icalendar-categories
15000 #+vindex: org-icalendar-alarm-time
15001 For tags on the headline, the iCalendar export back-end makes them
15002 into iCalendar categories.  To tweak the inheritance of tags and TODO
15003 states, configure the variable ~org-icalendar-categories~.  To assign
15004 clock alarms based on time, configure the ~org-icalendar-alarm-time~
15005 variable.
15007 #+vindex: org-icalendar-store-UID
15008 #+cindex: @samp{ID}, property
15009 The iCalendar format standard requires globally unique identifier---or
15010 UID---for each entry.  The iCalendar export back-end creates UIDs
15011 during export.  To save a copy of the UID in the Org file set the
15012 variable ~org-icalendar-store-UID~.  The back-end looks for the =ID=
15013 property of the entry for re-using the same UID for subsequent
15014 exports.
15016 Since a single Org entry can result in multiple iCalendar
15017 entries---timestamp, deadline, scheduled item, or TODO item---Org adds
15018 prefixes to the UID, depending on which part of the Org entry
15019 triggered the creation of the iCalendar entry.  Prefixing ensures UIDs
15020 remains unique, yet enable synchronization programs trace the
15021 connections.
15023 - {{{kbd(C-c C-e c f)}}} (~org-icalendar-export-to-ics~) ::
15025   #+kindex: C-c C-e c f
15026   #+findex: org-icalendar-export-to-ics
15027   Create iCalendar entries from the current Org buffer and store them
15028   in the same directory, using a file extension =.ics=.
15030 - {{{kbd(C-c C-e c a)}}} (~org-icalendar-export-agenda-files~) ::
15032   #+kindex: C-c C-e c a
15033   #+findex: org-icalendar-export-agenda-files
15034   Create iCalendar entries from Org files in ~org-agenda-files~ and
15035   store in a separate iCalendar file for each Org file.
15037 - {{{kbd(C-c C-e c c)}}} (~org-icalendar-combine-agenda-files~) ::
15039   #+kindex: C-c C-e c c
15040   #+findex: org-icalendar-combine-agenda-files
15041   #+vindex: org-icalendar-combined-agenda-file
15042   Create a combined iCalendar file from Org files in
15043   ~org-agenda-files~ and write it to
15044   ~org-icalendar-combined-agenda-file~ file name.
15046 #+cindex: @samp{SUMMARY}, property
15047 #+cindex: @samp{DESCRIPTION}, property
15048 #+cindex: @samp{LOCATION}, property
15049 #+cindex: @samp{TIMEZONE}, property
15050 #+cindex: @samp{CLASS}, property
15051 The iCalendar export back-end includes =SUMMARY=, =DESCRIPTION=,
15052 =LOCATION=, =TIMEZONE= and =CLASS= properties from the Org entries
15053 when exporting.  To force the back-end to inherit the =LOCATION=,
15054 =TIMEZONE= and =CLASS= properties, configure the
15055 ~org-use-property-inheritance~ variable.
15057 #+vindex: org-icalendar-include-body
15058 When Org entries do not have =SUMMARY=, =DESCRIPTION=, =LOCATION= and
15059 =CLASS= properties, the iCalendar export back-end derives the summary
15060 from the headline, and derives the description from the body of the
15061 Org item.  The ~org-icalendar-include-body~ variable limits the
15062 maximum number of characters of the content are turned into its
15063 description.
15065 The =TIMEZONE= property can be used to specify a per-entry time zone,
15066 and is applied to any entry with timestamp information.  Time zones
15067 should be specified as per the IANA time zone database format, e.g.,
15068 =Asia/Almaty=.  Alternately, the property value can be =UTC=, to force
15069 UTC time for this entry only.
15071 The =CLASS= property can be used to specify a per-entry visibility
15072 class or access restrictions, and is applied to any entry with class
15073 information.  The iCalendar standard defines three visibility classes:
15074 - =PUBLIC= :: The entry is publicly visible (this is the default).
15075 - =CONFIDENTIAL= :: Only a limited group of clients get access to the
15076   event.
15077 - =PRIVATE= :: The entry can be retrieved only by its owner.
15078 The server should treat unknown class properties the same as
15079 =PRIVATE=.
15081 Exporting to iCalendar format depends in large part on the
15082 capabilities of the destination application.  Some are more lenient
15083 than others.  Consult the Org mode FAQ for advice on specific
15084 applications.
15086 ** Other Built-in Back-ends
15087 :PROPERTIES:
15088 :DESCRIPTION: Exporting to a man page.
15089 :END:
15091 Other export back-ends included with Org are:
15093 - =ox-man.el=: Export to a man page.
15095 To activate such back-ends, either customize ~org-export-backends~ or
15096 load directly with =(require 'ox-man)=.  On successful load, the
15097 back-end adds new keys in the export dispatcher (see [[*The Export
15098 Dispatcher]]).
15100 Follow the comment section of such files, for example, =ox-man.el=,
15101 for usage and configuration details.
15103 ** Advanced Export Configuration
15104 :PROPERTIES:
15105 :DESCRIPTION: Fine-tuning the export output.
15106 :END:
15108 *** Hooks
15109 :PROPERTIES:
15110 :UNNUMBERED: notoc
15111 :END:
15113 #+vindex: org-export-before-processing-hook
15114 #+vindex: org-export-before-parsing-hook
15115 The export process executes two hooks before the actual exporting
15116 begins.  The first hook, ~org-export-before-processing-hook~, runs
15117 before any expansions of macros, Babel code, and include keywords in
15118 the buffer.  The second hook, ~org-export-before-parsing-hook~, runs
15119 before the buffer is parsed.
15121 Functions added to these hooks are called with a single argument: the
15122 export back-end actually used, as a symbol.  You may use them for
15123 heavy duty structural modifications of the document.  For example, you
15124 can remove every headline in the buffer during export like this:
15126 #+begin_src emacs-lisp
15127 (defun my-headline-removal (backend)
15128   "Remove all headlines in the current buffer.
15129 BACKEND is the export back-end being used, as a symbol."
15130   (org-map-entries
15131    (lambda () (delete-region (point) (line-beginning-position 2)))))
15133 (add-hook 'org-export-before-parsing-hook 'my-headline-removal)
15134 #+end_src
15136 *** Filters
15137 :PROPERTIES:
15138 :UNNUMBERED: notoc
15139 :END:
15141 #+cindex: Filters, exporting
15142 Filters are lists of functions to be applied to certain parts for
15143 a given back-end.  The output from the first function in the filter is
15144 passed on to the next function in the filter.  The final output is the
15145 output from the final function in the filter.
15147 The Org export process has many filter sets applicable to different
15148 types of objects, plain text, parse trees, export options, and final
15149 output formats.  The filters are named after the element type or
15150 object type: ~org-export-filter-TYPE-functions~, where {{{var(TYPE)}}}
15151 is the type targeted by the filter.  Valid types are:
15153 #+attr_texinfo: :columns 0.33 0.33 0.33
15154 | body                | bold               | babel-call       |
15155 | center-block        | clock              | code             |
15156 | diary-sexp          | drawer             | dynamic-block    |
15157 | entity              | example-block      | export-block     |
15158 | export-snippet      | final-output       | fixed-width      |
15159 | footnote-definition | footnote-reference | headline         |
15160 | horizontal-rule     | inline-babel-call  | inline-src-block |
15161 | inlinetask          | italic             | item             |
15162 | keyword             | latex-environment  | latex-fragment   |
15163 | line-break          | link               | node-property    |
15164 | options             | paragraph          | parse-tree       |
15165 | plain-list          | plain-text         | planning         |
15166 | property-drawer     | quote-block        | radio-target     |
15167 | section             | special-block      | src-block        |
15168 | statistics-cookie   | strike-through     | subscript        |
15169 | superscript         | table              | table-cell       |
15170 | table-row           | target             | timestamp        |
15171 | underline           | verbatim           | verse-block      |
15173 Here is an example filter that replaces non-breaking spaces ~ ~ in the
15174 Org buffer with =~= for the LaTeX back-end.
15176 #+begin_src emacs-lisp
15177 (defun my-latex-filter-nobreaks (text backend info)
15178   "Ensure \" \" are properly handled in LaTeX export."
15179   (when (org-export-derived-backend-p backend 'latex)
15180     (replace-regexp-in-string " " "~" text)))
15182 (add-to-list 'org-export-filter-plain-text-functions
15183              'my-latex-filter-nobreaks)
15184 #+end_src
15186 A filter requires three arguments: the code to be transformed, the
15187 name of the back-end, and some optional information about the export
15188 process.  The third argument can be safely ignored.  Note the use of
15189 ~org-export-derived-backend-p~ predicate that tests for /latex/
15190 back-end or any other back-end, such as /beamer/, derived from
15191 /latex/.
15193 *** Defining filters for individual files
15194 :PROPERTIES:
15195 :UNNUMBERED: notoc
15196 :END:
15198 The Org export can filter not just for back-ends, but also for
15199 specific files through the =BIND= keyword.  Here is an example with
15200 two filters; one removes brackets from time stamps, and the other
15201 removes strike-through text.  The filter functions are defined in
15202 a code block in the same Org file, which is a handy location for
15203 debugging.
15205 #+begin_example
15206 ,#+BIND: org-export-filter-timestamp-functions (tmp-f-timestamp)
15207 ,#+BIND: org-export-filter-strike-through-functions (tmp-f-strike-through)
15208 ,#+BEGIN_SRC emacs-lisp :exports results :results none
15209   (defun tmp-f-timestamp (s backend info)
15210     (replace-regexp-in-string "&[lg]t;\\|[][]" "" s))
15211   (defun tmp-f-strike-through (s backend info) "")
15212 ,#+END_SRC
15213 #+end_example
15215 *** Extending an existing back-end
15216 :PROPERTIES:
15217 :UNNUMBERED: notoc
15218 :END:
15220 Some parts of the conversion process can be extended for certain
15221 elements so as to introduce a new or revised translation.  That is how
15222 the HTML export back-end was extended to handle Markdown format.  The
15223 extensions work seamlessly so any aspect of filtering not done by the
15224 extended back-end is handled by the original back-end.  Of all the
15225 export customization in Org, extending is very powerful as it operates
15226 at the parser level.
15228 For this example, make the /ascii/ back-end display the language used
15229 in a source code block.  Also make it display only when some attribute
15230 is non-~nil~, like the following:
15232 : #+ATTR_ASCII: :language t
15234 Then extend ASCII back-end with a custom "my-ascii" back-end.
15236 #+begin_src emacs-lisp
15237 (defun my-ascii-src-block (src-block contents info)
15238   "Transcode a SRC-BLOCK element from Org to ASCII.
15239 CONTENTS is nil.  INFO is a plist used as a communication
15240 channel."
15241   (if (not (org-export-read-attribute :attr_ascii src-block :language))
15242       (org-export-with-backend 'ascii src-block contents info)
15243     (concat
15244      (format ",--[ %s ]--\n%s`----"
15245              (org-element-property :language src-block)
15246              (replace-regexp-in-string
15247               "^" "| "
15248               (org-element-normalize-string
15249                (org-export-format-code-default src-block info)))))))
15251 (org-export-define-derived-backend 'my-ascii 'ascii
15252   :translate-alist '((src-block . my-ascii-src-block)))
15253 #+end_src
15255 The ~my-ascii-src-block~ function looks at the attribute above the
15256 current element.  If not true, hands over to /ascii/ back-end.  If
15257 true, which it is in this example, it creates a box around the code
15258 and leaves room for the inserting a string for language.  The last
15259 form creates the new back-end that springs to action only when
15260 translating ~src-block~ type elements.
15262 To use the newly defined back-end, evaluate the following from an Org
15263 buffer:
15265 #+begin_src emacs-lisp
15266 (org-export-to-buffer 'my-ascii "*Org MY-ASCII Export*")
15267 #+end_src
15269 Further steps to consider would be an interactive function,
15270 self-installing an item in the export dispatcher menu, and other
15271 user-friendly improvements.
15273 ** Export in Foreign Buffers
15274 :PROPERTIES:
15275 :DESCRIPTION: Author tables and lists in Org syntax.
15276 :END:
15278 The export back-ends in Org often include commands to convert selected
15279 regions.  A convenient feature of this in-place conversion is that the
15280 exported output replaces the original source.  Here are such
15281 functions:
15283 - ~org-ascii-convert-region-to-ascii~ ::
15285   #+findex: org-ascii-convert-region-to-ascii
15286   Convert the selected region into ASCII.
15288 - ~org-ascii-convert-region-to-utf8~ ::
15290   #+findex: org-ascii-convert-region-to-utf8
15291   Convert the selected region into UTF-8.
15293 - ~org-html-convert-region-to-html~ ::
15295   #+findex: org-html-convert-region-to-html
15296   Convert the selected region into HTML.
15298 - ~org-latex-convert-region-to-latex~ ::
15300   #+findex: org-latex-convert-region-to-latex
15301   Convert the selected region into LaTeX.
15303 - ~org-texinfo-convert-region-to-texinfo~ ::
15305   #+findex: org-texinfo-convert-region-to-texinfo
15306   Convert the selected region into Texinfo.
15308 - ~org-md-convert-region-to-md~ ::
15310   #+findex: org-md-convert-region-to-md
15311   Convert the selected region into Markdown.
15313 In-place conversions are particularly handy for quick conversion of
15314 tables and lists in foreign buffers.  For example, in an HTML buffer,
15315 write a list in Org syntax, select it, and convert it to HTML with
15316 {{{kbd(M-x org-html-convert-region-to-html)}}}.
15318 * Publishing
15319 :PROPERTIES:
15320 :DESCRIPTION: Create a web site of linked Org files.
15321 :END:
15322 #+cindex: publishing
15324 Org includes a publishing management system that allows you to
15325 configure automatic HTML conversion of /projects/ composed of
15326 interlinked Org files.  You can also configure Org to automatically
15327 upload your exported HTML pages and related attachments, such as
15328 images and source code files, to a web server.
15330 You can also use Org to convert files into PDF, or even combine HTML
15331 and PDF conversion so that files are available in both formats on the
15332 server.
15334 Publishing has been contributed to Org by David O'Toole.
15336 ** Configuration
15337 :PROPERTIES:
15338 :DESCRIPTION: Defining projects.
15339 :END:
15340 Publishing needs significant configuration to specify files,
15341 destination and many other properties of a project.
15343 *** The variable ~org-publish-project-alist~
15344 :PROPERTIES:
15345 :DESCRIPTION: The central configuration variable.
15346 :ALT_TITLE: Project alist
15347 :END:
15348 #+cindex: projects, for publishing
15350 #+vindex: org-publish-project-alist
15351 Publishing is configured almost entirely through setting the value of
15352 one variable, called ~org-publish-project-alist~.  Each element of the
15353 list configures one project, and may be in one of the two following
15354 forms:
15356 #+begin_src emacs-lisp
15357 ("project-name" :property value :property value ...)
15358 #+end_src
15360 #+texinfo: @noindent
15361 i.e., a well-formed property list with alternating keys and values,
15364 #+begin_src emacs-lisp
15365 ("project-name" :components ("project-name" "project-name" ...))
15366 #+end_src
15368 In both cases, projects are configured by specifying property values.
15369 A project defines the set of files that are to be published, as well
15370 as the publishing configuration to use when publishing those files.
15371 When a project takes the second form listed above, the individual
15372 members of the ~:components~ property are taken to be sub-projects,
15373 which group together files requiring different publishing options.
15374 When you publish such a "meta-project", all the components are also
15375 published, in the sequence given.
15377 *** Sources and destinations for files
15378 :PROPERTIES:
15379 :DESCRIPTION: From here to there.
15380 :ALT_TITLE: Sources and destinations
15381 :END:
15382 #+cindex: directories, for publishing
15384 Most properties are optional, but some should always be set.  In
15385 particular, Org needs to know where to look for source files, and
15386 where to put published files.
15388 - ~:base-directory~ ::
15390   Directory containing publishing source files.
15392 - ~:publishing-directory~ ::
15394   Directory where output files are published.  You can directly
15395   publish to a webserver using a file name syntax appropriate for the
15396   Emacs tramp package.  Or you can publish to a local directory and
15397   use external tools to upload your website (see [[*Uploading Files]]).
15399 - ~:preparation-function~ ::
15401   Function or list of functions to be called before starting the
15402   publishing process, for example, to run =make= for updating files to
15403   be published.  Each preparation function is called with a single
15404   argument, the project property list.
15406 - ~:completion-function~ ::
15408   Function or list of functions called after finishing the publishing
15409   process, for example, to change permissions of the resulting files.
15410   Each completion function is called with a single argument, the
15411   project property list.
15413 *** Selecting files
15414 :PROPERTIES:
15415 :DESCRIPTION: What files are part of the project?
15416 :END:
15417 #+cindex: files, selecting for publishing
15419 By default, all files with extension =.org= in the base directory are
15420 considered part of the project.  This can be modified by setting the
15421 following properties
15423 - ~:base-extension~ ::
15425   Extension---without the dot---of source files.  This actually is
15426   a regular expression.  Set this to the symbol ~any~ if you want to
15427   get all files in ~:base-directory~, even without extension.
15429 - ~:exclude~ ::
15431   Regular expression to match file names that should not be published,
15432   even though they have been selected on the basis of their extension.
15434 - ~:include~ ::
15436   List of files to be included regardless of ~:base-extension~ and
15437   ~:exclude~.
15439 - ~:recursive~ ::
15441   Non-~nil~ means, check base-directory recursively for files to
15442   publish.
15444 *** Publishing action
15445 :PROPERTIES:
15446 :DESCRIPTION: Setting the function doing the publishing.
15447 :END:
15448 #+cindex: action, for publishing
15450 Publishing means that a file is copied to the destination directory
15451 and possibly transformed in the process.  The default transformation
15452 is to export Org files as HTML files, and this is done by the function
15453 ~org-publish-org-to-html~ which calls the HTML exporter (see [[*HTML
15454 Export]]).  But you can also publish your content as PDF files using
15455 ~org-publish-org-to-pdf~, or as ASCII, Texinfo, etc., using the
15456 corresponding functions.
15458 If you want to publish the Org file as an =.org= file but with
15459 /archived/, /commented/, and /tag-excluded/ trees removed, use
15460 ~org-publish-org-to-org~.  This produces =file.org= and put it in the
15461 publishing directory.  If you want a htmlized version of this file,
15462 set the parameter ~:htmlized-source~ to ~t~.  It produces
15463 =file.org.html= in the publishing directory[fn:139].
15465 Other files like images only need to be copied to the publishing
15466 destination; for this you can use ~org-publish-attachment~.  For
15467 non-Org files, you always need to specify the publishing function:
15469 - ~:publishing-function~ ::
15471   Function executing the publication of a file.  This may also be
15472   a list of functions, which are all called in turn.
15474 - ~:htmlized-source~ ::
15476   Non-~nil~ means, publish htmlized source.
15478 The function must accept three arguments: a property list containing
15479 at least a ~:publishing-directory~ property, the name of the file to
15480 be published, and the path to the publishing directory of the output
15481 file.  It should take the specified file, make the necessary
15482 transformation, if any, and place the result into the destination
15483 folder.
15485 *** Options for the exporters
15486 :PROPERTIES:
15487 :DESCRIPTION: Tweaking HTML/@LaTeX{} export.
15488 :ALT_TITLE: Publishing options
15489 :END:
15490 #+cindex: options, for publishing
15491 #+cindex: publishing options
15493 The property list can be used to set many export options for the HTML
15494 and LaTeX exporters.  In most cases, these properties correspond to
15495 user variables in Org.  The table below lists these properties along
15496 with the variable they belong to.  See the documentation string for
15497 the respective variable for details.
15499 #+vindex: org-publish-project-alist
15500 When a property is given a value in ~org-publish-project-alist~, its
15501 setting overrides the value of the corresponding user variable, if
15502 any, during publishing.  Options set within a file (see [[*Export
15503 Settings]]), however, override everything.
15505 **** Generic properties
15506 :PROPERTIES:
15507 :UNNUMBERED: notoc
15508 :END:
15510 | ~:archived-trees~       | ~org-export-with-archived-trees~   |
15511 | ~:exclude-tags~         | ~org-export-exclude-tags~          |
15512 | ~:headline-levels~      | ~org-export-headline-levels~       |
15513 | ~:language~             | ~org-export-default-language~      |
15514 | ~:preserve-breaks~      | ~org-export-preserve-breaks~       |
15515 | ~:section-numbers~      | ~org-export-with-section-numbers~  |
15516 | ~:select-tags~          | ~org-export-select-tags~           |
15517 | ~:with-author~          | ~org-export-with-author~           |
15518 | ~:with-broken-links~    | ~org-export-with-broken-links~     |
15519 | ~:with-clocks~          | ~org-export-with-clocks~           |
15520 | ~:with-creator~         | ~org-export-with-creator~          |
15521 | ~:with-date~            | ~org-export-with-date~             |
15522 | ~:with-drawers~         | ~org-export-with-drawers~          |
15523 | ~:with-email~           | ~org-export-with-email~            |
15524 | ~:with-emphasize~       | ~org-export-with-emphasize~        |
15525 | ~:with-fixed-width~     | ~org-export-with-fixed-width~      |
15526 | ~:with-footnotes~       | ~org-export-with-footnotes~        |
15527 | ~:with-latex~           | ~org-export-with-latex~            |
15528 | ~:with-planning~        | ~org-export-with-planning~         |
15529 | ~:with-priority~        | ~org-export-with-priority~         |
15530 | ~:with-properties~      | ~org-export-with-properties~       |
15531 | ~:with-special-strings~ | ~org-export-with-special-strings~  |
15532 | ~:with-sub-superscript~ | ~org-export-with-sub-superscripts~ |
15533 | ~:with-tables~          | ~org-export-with-tables~           |
15534 | ~:with-tags~            | ~org-export-with-tags~             |
15535 | ~:with-tasks~           | ~org-export-with-tasks~            |
15536 | ~:with-timestamps~      | ~org-export-with-timestamps~       |
15537 | ~:with-title~           | ~org-export-with-title~            |
15538 | ~:with-toc~             | ~org-export-with-toc~              |
15539 | ~:with-todo-keywords~   | ~org-export-with-todo-keywords~    |
15541 **** ASCII specific properties
15542 :PROPERTIES:
15543 :UNNUMBERED: notoc
15544 :END:
15546 | ~:ascii-bullets~                       | ~org-ascii-bullets~                       |
15547 | ~:ascii-caption-above~                 | ~org-ascii-caption-above~                 |
15548 | ~:ascii-charset~                       | ~org-ascii-charset~                       |
15549 | ~:ascii-global-margin~                 | ~org-ascii-global-margin~                 |
15550 | ~:ascii-format-drawer-function~        | ~org-ascii-format-drawer-function~        |
15551 | ~:ascii-format-inlinetask-function~    | ~org-ascii-format-inlinetask-function~    |
15552 | ~:ascii-headline-spacing~              | ~org-ascii-headline-spacing~              |
15553 | ~:ascii-indented-line-width~           | ~org-ascii-indented-line-width~           |
15554 | ~:ascii-inlinetask-width~              | ~org-ascii-inlinetask-width~              |
15555 | ~:ascii-inner-margin~                  | ~org-ascii-inner-margin~                  |
15556 | ~:ascii-links-to-notes~                | ~org-ascii-links-to-notes~                |
15557 | ~:ascii-list-margin~                   | ~org-ascii-list-margin~                   |
15558 | ~:ascii-paragraph-spacing~             | ~org-ascii-paragraph-spacing~             |
15559 | ~:ascii-quote-margin~                  | ~org-ascii-quote-margin~                  |
15560 | ~:ascii-table-keep-all-vertical-lines~ | ~org-ascii-table-keep-all-vertical-lines~ |
15561 | ~:ascii-table-use-ascii-art~           | ~org-ascii-table-use-ascii-art~           |
15562 | ~:ascii-table-widen-columns~           | ~org-ascii-table-widen-columns~           |
15563 | ~:ascii-text-width~                    | ~org-ascii-text-width~                    |
15564 | ~:ascii-underline~                     | ~org-ascii-underline~                     |
15565 | ~:ascii-verbatim-format~               | ~org-ascii-verbatim-format~               |
15567 **** Beamer specific properties
15568 :PROPERTIES:
15569 :UNNUMBERED: notoc
15570 :END:
15572 | ~:beamer-theme~                 | ~org-beamer-theme~                 |
15573 | ~:beamer-column-view-format~    | ~org-beamer-column-view-format~    |
15574 | ~:beamer-environments-extra~    | ~org-beamer-environments-extra~    |
15575 | ~:beamer-frame-default-options~ | ~org-beamer-frame-default-options~ |
15576 | ~:beamer-outline-frame-options~ | ~org-beamer-outline-frame-options~ |
15577 | ~:beamer-outline-frame-title~   | ~org-beamer-outline-frame-title~   |
15578 | ~:beamer-subtitle-format~       | ~org-beamer-subtitle-format~       |
15580 **** HTML specific properties
15581 :PROPERTIES:
15582 :UNNUMBERED: notoc
15583 :END:
15585 | ~:html-allow-name-attribute-in-anchors~        | ~org-html-allow-name-attribute-in-anchors~        |
15586 | ~:html-checkbox-type~                          | ~org-html-checkbox-type~                          |
15587 | ~:html-container~                              | ~org-html-container-element~                      |
15588 | ~:html-divs~                                   | ~org-html-divs~                                   |
15589 | ~:html-doctype~                                | ~org-html-doctype~                                |
15590 | ~:html-extension~                              | ~org-html-extension~                              |
15591 | ~:html-footnote-format~                        | ~org-html-footnote-format~                        |
15592 | ~:html-footnote-separator~                     | ~org-html-footnote-separator~                     |
15593 | ~:html-footnotes-section~                      | ~org-html-footnotes-section~                      |
15594 | ~:html-format-drawer-function~                 | ~org-html-format-drawer-function~                 |
15595 | ~:html-format-headline-function~               | ~org-html-format-headline-function~               |
15596 | ~:html-format-inlinetask-function~             | ~org-html-format-inlinetask-function~             |
15597 | ~:html-head-extra~                             | ~org-html-head-extra~                             |
15598 | ~:html-head-include-default-style~             | ~org-html-head-include-default-style~             |
15599 | ~:html-head-include-scripts~                   | ~org-html-head-include-scripts~                   |
15600 | ~:html-head~                                   | ~org-html-head~                                   |
15601 | ~:html-home/up-format~                         | ~org-html-home/up-format~                         |
15602 | ~:html-html5-fancy~                            | ~org-html-html5-fancy~                            |
15603 | ~:html-indent~                                 | ~org-html-indent~                                 |
15604 | ~:html-infojs-options~                         | ~org-html-infojs-options~                         |
15605 | ~:html-infojs-template~                        | ~org-html-infojs-template~                        |
15606 | ~:html-inline-image-rules~                     | ~org-html-inline-image-rules~                     |
15607 | ~:html-inline-images~                          | ~org-html-inline-images~                          |
15608 | ~:html-link-home~                              | ~org-html-link-home~                              |
15609 | ~:html-link-org-files-as-html~                 | ~org-html-link-org-files-as-html~                 |
15610 | ~:html-link-up~                                | ~org-html-link-up~                                |
15611 | ~:html-link-use-abs-url~                       | ~org-html-link-use-abs-url~                       |
15612 | ~:html-mathjax-options~                        | ~org-html-mathjax-options~                        |
15613 | ~:html-mathjax-template~                       | ~org-html-mathjax-template~                       |
15614 | ~:html-metadata-timestamp-format~              | ~org-html-metadata-timestamp-format~              |
15615 | ~:html-postamble-format~                       | ~org-html-postamble-format~                       |
15616 | ~:html-postamble~                              | ~org-html-postamble~                              |
15617 | ~:html-preamble-format~                        | ~org-html-preamble-format~                        |
15618 | ~:html-preamble~                               | ~org-html-preamble~                               |
15619 | ~:html-self-link-headlines~                    | ~org-html-self-link-headlines~                    |
15620 | ~:html-table-align-individual-field~           | ~de{org-html-table-align-individual-fields~       |
15621 | ~:html-table-attributes~                       | ~org-html-table-default-attributes~               |
15622 | ~:html-table-caption-above~                    | ~org-html-table-caption-above~                    |
15623 | ~:html-table-data-tags~                        | ~org-html-table-data-tags~                        |
15624 | ~:html-table-header-tags~                      | ~org-html-table-header-tags~                      |
15625 | ~:html-table-row-tags~                         | ~org-html-table-row-tags~                         |
15626 | ~:html-table-use-header-tags-for-first-column~ | ~org-html-table-use-header-tags-for-first-column~ |
15627 | ~:html-tag-class-prefix~                       | ~org-html-tag-class-prefix~                       |
15628 | ~:html-text-markup-alist~                      | ~org-html-text-markup-alist~                      |
15629 | ~:html-todo-kwd-class-prefix~                  | ~org-html-todo-kwd-class-prefix~                  |
15630 | ~:html-toplevel-hlevel~                        | ~org-html-toplevel-hlevel~                        |
15631 | ~:html-use-infojs~                             | ~org-html-use-infojs~                             |
15632 | ~:html-validation-link~                        | ~org-html-validation-link~                        |
15633 | ~:html-viewport~                               | ~org-html-viewport~                               |
15634 | ~:html-xml-declaration~                        | ~org-html-xml-declaration~                        |
15636 **** LaTeX specific properties
15637 :PROPERTIES:
15638 :UNNUMBERED: notoc
15639 :END:
15641 | ~:latex-active-timestamp-format~       | ~org-latex-active-timestamp-format~       |
15642 | ~:latex-caption-above~                 | ~org-latex-caption-above~                 |
15643 | ~:latex-classes~                       | ~org-latex-classes~                       |
15644 | ~:latex-class~                         | ~org-latex-default-class~                 |
15645 | ~:latex-compiler~                      | ~org-latex-compiler~                      |
15646 | ~:latex-default-figure-position~       | ~org-latex-default-figure-position~       |
15647 | ~:latex-default-table-environment~     | ~org-latex-default-table-environment~     |
15648 | ~:latex-default-table-mode~            | ~org-latex-default-table-mode~            |
15649 | ~:latex-diary-timestamp-format~        | ~org-latex-diary-timestamp-format~        |
15650 | ~:latex-footnote-defined-format~       | ~org-latex-footnote-defined-format~       |
15651 | ~:latex-footnote-separator~            | ~org-latex-footnote-separator~            |
15652 | ~:latex-format-drawer-function~        | ~org-latex-format-drawer-function~        |
15653 | ~:latex-format-headline-function~      | ~org-latex-format-headline-function~      |
15654 | ~:latex-format-inlinetask-function~    | ~org-latex-format-inlinetask-function~    |
15655 | ~:latex-hyperref-template~             | ~org-latex-hyperref-template~             |
15656 | ~:latex-image-default-height~          | ~org-latex-image-default-height~          |
15657 | ~:latex-image-default-option~          | ~org-latex-image-default-option~          |
15658 | ~:latex-image-default-width~           | ~org-latex-image-default-width~           |
15659 | ~:latex-images-centered~               | ~org-latex-images-centered~               |
15660 | ~:latex-inactive-timestamp-format~     | ~org-latex-inactive-timestamp-format~     |
15661 | ~:latex-inline-image-rules~            | ~org-latex-inline-image-rules~            |
15662 | ~:latex-link-with-unknown-path-format~ | ~org-latex-link-with-unknown-path-format~ |
15663 | ~:latex-listings-langs~                | ~org-latex-listings-langs~                |
15664 | ~:latex-listings-options~              | ~org-latex-listings-options~              |
15665 | ~:latex-listings~                      | ~org-latex-listings~                      |
15666 | ~:latex-minted-langs~                  | ~org-latex-minted-langs~                  |
15667 | ~:latex-minted-options~                | ~org-latex-minted-options~                |
15668 | ~:latex-prefer-user-labels~            | ~org-latex-prefer-user-labels~            |
15669 | ~:latex-subtitle-format~               | ~org-latex-subtitle-format~               |
15670 | ~:latex-subtitle-separate~             | ~org-latex-subtitle-separate~             |
15671 | ~:latex-table-scientific-notation~     | ~org-latex-table-scientific-notation~     |
15672 | ~:latex-tables-booktabs~               | ~org-latex-tables-booktabs~               |
15673 | ~:latex-tables-centered~               | ~org-latex-tables-centered~               |
15674 | ~:latex-text-markup-alist~             | ~org-latex-text-markup-alist~             |
15675 | ~:latex-title-command~                 | ~org-latex-title-command~                 |
15676 | ~:latex-toc-command~                   | ~org-latex-toc-command~                   |
15678 **** Markdown specific properties
15679 :PROPERTIES:
15680 :UNNUMBERED: notoc
15681 :END:
15683 | ~:md-footnote-format~   | ~org-md-footnote-format~   |
15684 | ~:md-footnotes-section~ | ~org-md-footnotes-section~ |
15685 | ~:md-headline-style~    | ~org-md-headline-style~    |
15687 **** ODT specific properties
15688 :PROPERTIES:
15689 :UNNUMBERED: notoc
15690 :END:
15692 | ~:odt-content-template-file~      | ~org-odt-content-template-file~      |
15693 | ~:odt-display-outline-level~      | ~org-odt-display-outline-level~      |
15694 | ~:odt-fontify-srcblocks~          | ~org-odt-fontify-srcblocks~          |
15695 | ~:odt-format-drawer-function~     | ~org-odt-format-drawer-function~     |
15696 | ~:odt-format-headline-function~   | ~org-odt-format-headline-function~   |
15697 | ~:odt-format-inlinetask-function~ | ~org-odt-format-inlinetask-function~ |
15698 | ~:odt-inline-formula-rules~       | ~org-odt-inline-formula-rules~       |
15699 | ~:odt-inline-image-rules~         | ~org-odt-inline-image-rules~         |
15700 | ~:odt-pixels-per-inch~            | ~org-odt-pixels-per-inch~            |
15701 | ~:odt-styles-file~                | ~org-odt-styles-file~                |
15702 | ~:odt-table-styles~               | ~org-odt-table-styles~               |
15703 | ~:odt-use-date-fields~            | ~org-odt-use-date-fields~            |
15705 **** Texinfo specific properties
15706 :PROPERTIES:
15707 :UNNUMBERED: notoc
15708 :END:
15710 | ~:texinfo-active-timestamp-format~       | ~org-texinfo-active-timestamp-format~       |
15711 | ~:texinfo-classes~                       | ~org-texinfo-classes~                       |
15712 | ~:texinfo-class~                         | ~org-texinfo-default-class~                 |
15713 | ~:texinfo-table-default-markup~          | ~org-texinfo-table-default-markup~          |
15714 | ~:texinfo-diary-timestamp-format~        | ~org-texinfo-diary-timestamp-format~        |
15715 | ~:texinfo-filename~                      | ~org-texinfo-filename~                      |
15716 | ~:texinfo-format-drawer-function~        | ~org-texinfo-format-drawer-function~        |
15717 | ~:texinfo-format-headline-function~      | ~org-texinfo-format-headline-function~      |
15718 | ~:texinfo-format-inlinetask-function~    | ~org-texinfo-format-inlinetask-function~    |
15719 | ~:texinfo-inactive-timestamp-format~     | ~org-texinfo-inactive-timestamp-format~     |
15720 | ~:texinfo-link-with-unknown-path-format~ | ~org-texinfo-link-with-unknown-path-format~ |
15721 | ~:texinfo-node-description-column~       | ~org-texinfo-node-description-column~       |
15722 | ~:texinfo-table-scientific-notation~     | ~org-texinfo-table-scientific-notation~     |
15723 | ~:texinfo-tables-verbatim~               | ~org-texinfo-tables-verbatim~               |
15724 | ~:texinfo-text-markup-alist~             | ~org-texinfo-text-markup-alist~             |
15726 *** Publishing links
15727 :PROPERTIES:
15728 :DESCRIPTION: Which links keep working after publishing?
15729 :END:
15730 #+cindex: links, publishing
15732 To create a link from one Org file to another, you would use something
15733 like =[[file:foo.org][The foo]]= or simply =[[file:foo.org]]= (see [[*External Links]]).  When
15734 published, this link becomes a link to =foo.html=.  You can thus
15735 interlink the pages of your "Org web" project and the links will work
15736 as expected when you publish them to HTML.  If you also publish the
15737 Org source file and want to link to it, use an =http= link instead of
15738 a =file:= link, because =file= links are converted to link to the
15739 corresponding =.html= file.
15741 You may also link to related files, such as images.  Provided you are
15742 careful with relative file names, and provided you have also
15743 configured Org to upload the related files, these links will work too.
15744 See [[*Example: complex publishing configuration]], for an example of this
15745 usage.
15747 Eventually, links between published documents can contain some search
15748 options (see [[*Search Options in File Links]]), which will be resolved to
15749 the appropriate location in the linked file.  For example, once
15750 published to HTML, the following links all point to a dedicated anchor
15751 in =foo.html=.
15753 #+begin_example
15754 [[file:foo.org::*heading]]
15755 [[file:foo.org::#custom-id]]
15756 [[file:foo.org::target]]
15757 #+end_example
15759 *** Generating a sitemap
15760 :PROPERTIES:
15761 :DESCRIPTION: Generating a list of all pages.
15762 :ALT_TITLE: Site map
15763 :END:
15764 #+cindex: sitemap, of published pages
15766 The following properties may be used to control publishing of
15767 a map of files for a given project.
15769 - ~:auto-sitemap~ ::
15771   When non-~nil~, publish a sitemap during
15772   ~org-publish-current-project~ or ~org-publish-all~.
15774 - ~:sitemap-filename~ ::
15776   Filename for output of sitemap.  Defaults to =sitemap.org=, which
15777   becomes =sitemap.html=.
15779 - ~:sitemap-title~ ::
15781   Title of sitemap page.  Defaults to name of file.
15783 - ~:sitemap-format-entry~ ::
15785   #+findex: org-publish-find-date
15786   #+findex: org-publish-find-property
15787   #+findex: org-publish-find-title
15788   With this option one can tell how a site-map entry is formatted in
15789   the site-map.  It is a function called with three arguments: the
15790   file or directory name relative to base directory of the project,
15791   the site-map style and the current project.  It is expected to
15792   return a string.  Default value turns file names into links and use
15793   document titles as descriptions.  For specific formatting needs, one
15794   can use ~org-publish-find-date~, ~org-publish-find-title~ and
15795   ~org-publish-find-property~, to retrieve additional information
15796   about published documents.
15798 - ~:sitemap-function~ ::
15800   Plug-in function to use for generation of the sitemap.  It is called
15801   with two arguments: the title of the site-map and a representation
15802   of the files and directories involved in the project as a nested
15803   list, which can further be transformed using ~org-list-to-generic~,
15804   ~org-list-to-subtree~ and alike.  Default value generates a plain
15805   list of links to all files in the project.
15807 - ~:sitemap-sort-folders~ ::
15809   Where folders should appear in the sitemap.  Set this to ~first~
15810   (default) or ~last~ to display folders first or last, respectively.
15811   When set to ~ignore~, folders are ignored altogether.  Any other
15812   value mixes files and folders.  This variable has no effect when
15813   site-map style is ~tree~.
15815 - ~:sitemap-sort-files~ ::
15817   How the files are sorted in the site map.  Set this to
15818   ~alphabetically~ (default), ~chronologically~ or
15819   ~anti-chronologically~.  ~chronologically~ sorts the files with
15820   older date first while ~anti-chronologically~ sorts the files with
15821   newer date first.  ~alphabetically~ sorts the files alphabetically.
15822   The date of a file is retrieved with ~org-publish-find-date~.
15824 - ~:sitemap-ignore-case~ ::
15826   Should sorting be case-sensitive?  Default ~nil~.
15828 - ~:sitemap-file-entry-format~ ::
15830   With this option one can tell how a sitemap's entry is formatted in
15831   the sitemap.  This is a format string with some escape sequences:
15832   ~%t~ stands for the title of the file, ~%a~ stands for the author of
15833   the file and ~%d~ stands for the date of the file.  The date is
15834   retrieved with the ~org-publish-find-date~ function and formatted
15835   with ~org-publish-sitemap-date-format~.  Default ~%t~.
15837 - ~:sitemap-date-format~ ::
15839   Format string for the ~format-time-string~ function that tells how
15840   a sitemap entry's date is to be formatted.  This property bypasses
15841   ~org-publish-sitemap-date-format~ which defaults to ~%Y-%m-%d~.
15843 *** Generating an index
15844 :PROPERTIES:
15845 :DESCRIPTION: An index that reaches across pages.
15846 :END:
15847 #+cindex: index, in a publishing project
15849 Org mode can generate an index across the files of a publishing project.
15851 - ~:makeindex~ ::
15853   When non-~nil~, generate in index in the file =theindex.org= and
15854   publish it as =theindex.html=.
15856 The file is created when first publishing a project with the
15857 ~:makeindex~ set.  The file only contains a statement =#+INCLUDE:
15858 "theindex.inc"=.  You can then build around this include statement by
15859 adding a title, style information, etc.
15861 #+cindex: @samp{INDEX}, keyword
15862 Index entries are specified with =INDEX= keyword.  An entry that
15863 contains an exclamation mark creates a sub item.
15865 #+begin_example
15866 ,*** Curriculum Vitae
15867 ,#+INDEX: CV
15868 ,#+INDEX: Application!CV
15869 #+end_example
15871 ** Uploading Files
15872 :PROPERTIES:
15873 :DESCRIPTION: How to get files up on the server.
15874 :END:
15875 #+cindex: rsync
15876 #+cindex: unison
15878 For those people already utilizing third party sync tools such as
15879 Rsync or Unison, it might be preferable not to use the built-in remote
15880 publishing facilities of Org mode which rely heavily on Tramp.  Tramp,
15881 while very useful and powerful, tends not to be so efficient for
15882 multiple file transfer and has been known to cause problems under
15883 heavy usage.
15885 Specialized synchronization utilities offer several advantages.  In
15886 addition to timestamp comparison, they also do content and
15887 permissions/attribute checks.  For this reason you might prefer to
15888 publish your web to a local directory---possibly even /in place/ with
15889 your Org files---and then use Unison or Rsync to do the
15890 synchronization with the remote host.
15892 Since Unison, for example, can be configured as to which files to
15893 transfer to a certain remote destination, it can greatly simplify the
15894 project publishing definition.  Simply keep all files in the correct
15895 location, process your Org files with ~org-publish~ and let the
15896 synchronization tool do the rest.  You do not need, in this scenario,
15897 to include attachments such as JPG, CSS or PNG files in the project
15898 definition since the third-party tool syncs them.
15900 Publishing to a local directory is also much faster than to a remote
15901 one, so that you can afford more easily to republish entire projects.
15902 If you set ~org-publish-use-timestamps-flag~ to ~nil~, you gain the
15903 main benefit of re-including any changed external files such as source
15904 example files you might include with =INCLUDE= keyword.  The timestamp
15905 mechanism in Org is not smart enough to detect if included files have
15906 been modified.
15908 ** Sample Configuration
15909 :PROPERTIES:
15910 :DESCRIPTION: Example projects.
15911 :END:
15913 Below we provide two example configurations.  The first one is
15914 a simple project publishing only a set of Org files.  The second
15915 example is more complex, with a multi-component project.
15917 *** Example: simple publishing configuration
15918 :PROPERTIES:
15919 :DESCRIPTION: One-component publishing.
15920 :ALT_TITLE: Simple example
15921 :END:
15923 This example publishes a set of Org files to the =public_html=
15924 directory on the local machine.
15926 #+begin_src emacs-lisp
15927 (setq org-publish-project-alist
15928       '(("org"
15929          :base-directory "~/org/"
15930          :publishing-directory "~/public_html"
15931          :section-numbers nil
15932          :table-of-contents nil
15933          :style "<link rel=\"stylesheet\"
15934                 href=\"../other/mystyle.css\"
15935                 type=\"text/css\"/>")))
15936 #+end_src
15938 *** Example: complex publishing configuration
15939 :PROPERTIES:
15940 :DESCRIPTION: A multi-component publishing example.
15941 :ALT_TITLE: Complex example
15942 :END:
15944 This more complicated example publishes an entire website, including
15945 Org files converted to HTML, image files, Emacs Lisp source code, and
15946 style sheets.  The publishing directory is remote and private files
15947 are excluded.
15949 To ensure that links are preserved, care should be taken to replicate
15950 your directory structure on the web server, and to use relative file
15951 paths.  For example, if your Org files are kept in =~/org/= and your
15952 publishable images in =~/images/=, you would link to an image with
15954 : file:../images/myimage.png
15956 On the web server, the relative path to the image should be the same.
15957 You can accomplish this by setting up an =images/= folder in the right
15958 place on the web server, and publishing images to it.
15960 #+begin_src emacs-lisp
15961 (setq org-publish-project-alist
15962       '(("orgfiles"
15963          :base-directory "~/org/"
15964          :base-extension "org"
15965          :publishing-directory "/ssh:user@host:~/html/notebook/"
15966          :publishing-function org-html-publish-to-html
15967          :exclude "PrivatePage.org" ;; regexp
15968          :headline-levels 3
15969          :section-numbers nil
15970          :with-toc nil
15971          :html-head "<link rel=\"stylesheet\"
15972                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
15973          :html-preamble t)
15975         ("images"
15976          :base-directory "~/images/"
15977          :base-extension "jpg\\|gif\\|png"
15978          :publishing-directory "/ssh:user@host:~/html/images/"
15979          :publishing-function org-publish-attachment)
15981         ("other"
15982          :base-directory "~/other/"
15983          :base-extension "css\\|el"
15984          :publishing-directory "/ssh:user@host:~/html/other/"
15985          :publishing-function org-publish-attachment)
15986         ("website" :components ("orgfiles" "images" "other"))))
15987 #+end_src
15989 ** Triggering Publication
15990 :PROPERTIES:
15991 :DESCRIPTION: Publication commands.
15992 :END:
15994 Once properly configured, Org can publish with the following commands:
15996 - {{{kbd(C-c C-e P x)}}} (~org-publish~) ::
15998   #+kindex: C-c C-e P x
15999   #+findex: org-publish
16000   Prompt for a specific project and publish all files that belong to
16001   it.
16003 - {{{kbd(C-c C-e P p)}}} (~org-publish-current-project~) ::
16005   #+kindex: C-c C-e P p
16006   #+findex: org-publish-current-project
16007   Publish the project containing the current file.
16009 - {{{kbd(C-c C-e P f)}}} (~org-publish-current-file~) ::
16011   #+kindex: C-c C-e P f
16012   #+findex: org-publish-current-file
16013   Publish only the current file.
16015 - {{{kbd(C-c C-e P a)}}} (~org-publish-all~) ::
16017   #+kindex: C-c C-e P a
16018   #+findex: org-publish-all
16019   Publish every project.
16021 #+vindex: org-publish-use-timestamps-flag
16022 Org uses timestamps to track when a file has changed.  The above
16023 functions normally only publish changed files.  You can override this
16024 and force publishing of all files by giving a prefix argument to any
16025 of the commands above, or by customizing the variable
16026 ~org-publish-use-timestamps-flag~.  This may be necessary in
16027 particular if files include other files via =SETUPFILE= or =INCLUDE=
16028 keywords.
16030 * Working with Source Code
16031 :PROPERTIES:
16032 :DESCRIPTION: Export, evaluate, and tangle code blocks.
16033 :END:
16034 #+cindex: source code, working with
16036 Source code here refers to any plain text collection of computer
16037 instructions, possibly with comments, written using a human-readable
16038 programming language.  Org can manage source code in an Org document
16039 when the source code is identified with begin and end markers.
16040 Working with source code begins with identifying source code blocks.
16041 A source code block can be placed almost anywhere in an Org document;
16042 it is not restricted to the preamble or the end of the document.
16043 However, Org cannot manage a source code block if it is placed inside
16044 an Org comment or within a fixed width section.
16046 Here is an example source code block in the Emacs Lisp language:
16048 #+begin_example
16049 ,#+BEGIN_SRC emacs-lisp
16050   (defun org-xor (a b)
16051      "Exclusive or."
16052      (if a (not b) b))
16053 ,#+END_SRC
16054 #+end_example
16056 Org can manage the source code in the block delimited by =#+BEGIN_SRC=
16057 ... =#+END_SRC= in several ways that can simplify housekeeping tasks
16058 essential to modern source code maintenance.  Org can edit, format,
16059 extract, export, and publish source code blocks.  Org can also compile
16060 and execute a source code block, then capture the results.  The Org
16061 mode literature sometimes refers to source code blocks as /live code/
16062 blocks because they can alter the content of the Org document or the
16063 material that it exports.  Users can control how live they want each
16064 source code block by tweaking the header arguments (see [[*Using
16065 Header Arguments]]) for compiling, execution, extraction, and
16066 exporting.
16068 Source code blocks are one of many Org block types, which also include
16069 "center", "comment", "dynamic", "example", "export", "quote",
16070 "special", and "verse".  This section pertains to blocks between
16071 =#+BEGIN_SRC= and =#+END_SRC=.
16073 For editing and formatting a source code block, Org uses an
16074 appropriate Emacs major mode that includes features specifically
16075 designed for source code in that language.
16077 Org can extract one or more source code blocks and write them to one
16078 or more source files---a process known as /tangling/ in literate
16079 programming terminology.
16081 For exporting and publishing, Org's back-ends can format a source code
16082 block appropriately, often with native syntax highlighting.
16084 For executing and compiling a source code block, the user can
16085 configure Org to select the appropriate compiler.  Org provides
16086 facilities to collect the result of the execution or compiler output,
16087 insert it into the Org document, and/or export it.  In addition to
16088 text results, Org can insert links to other data types, including
16089 audio, video, and graphics.  Org can also link a compiler error
16090 message to the appropriate line in the source code block.
16092 An important feature of Org's management of source code blocks is the
16093 ability to pass variables, functions, and results to one another using
16094 a common syntax for source code blocks in any language.  Although most
16095 literate programming facilities are restricted to one language or
16096 another, Org's language-agnostic approach lets the literate programmer
16097 match each programming task with the appropriate computer language and
16098 to mix them all together in a single Org document.  This
16099 interoperability among languages explains why Org's source code
16100 management facility was named /Org Babel/ by its originators, Eric
16101 Schulte and Dan Davison.
16103 Org mode fulfills the promise of easy verification and maintenance of
16104 publishing reproducible research by keeping text, data, code,
16105 configuration settings of the execution environment, the results of
16106 the execution, and associated narratives, claims, references, and
16107 internal and external links in a single Org document.
16109 Details of Org's facilities for working with source code are described
16110 in the following sections.
16112 ** Structure of Code Blocks
16113 :PROPERTIES:
16114 :DESCRIPTION: Code block syntax described.
16115 :END:
16116 #+cindex: code block, structure
16117 #+cindex: source code, block structure
16118 #+cindex: @samp{NAME} keyword, in source blocks
16119 #+cindex: @samp{BEGIN_SRC}
16121 Org offers two ways to structure source code in Org documents: in
16122 a source code block, and directly inline.  Both specifications are
16123 shown below.
16125 A source code block conforms to this structure:
16127 #+begin_example
16128 ,#+NAME: <name>
16129 ,#+BEGIN_SRC <language> <switches> <header arguments>
16130   <body>
16131 ,#+END_SRC
16132 #+end_example
16134 Do not be put-off by having to remember the source block syntax.  Org
16135 mode offers a command for wrapping existing text in a block (see
16136 [[*Structure Templates]]).  Org also works with other completion systems
16137 in Emacs, some of which predate Org and have custom domain-specific
16138 languages for defining templates.  Regular use of templates reduces
16139 errors, increases accuracy, and maintains consistency.
16141 #+cindex: source code, inline
16142 An inline code block conforms to this structure:
16144 : src_<language>{<body>}
16146 #+texinfo: @noindent
16149 : src_<language>[<header arguments>]{<body>}
16151 - =#+NAME: <name>= ::
16153   Optional.  Names the source block so it can be called, like
16154   a function, from other source blocks or inline code to evaluate or
16155   to capture the results.  Code from other blocks, other files, and
16156   from table formulas (see [[*The Spreadsheet]]) can use the name to
16157   reference a source block.  This naming serves the same purpose as
16158   naming Org tables.  Org mode requires unique names.  For duplicate
16159   names, Org mode's behavior is undefined.
16161 - =#+BEGIN_SRC= ... =#+END_SRC= ::
16163   Mandatory.  They mark the start and end of a block that Org
16164   requires.  The =#+BEGIN_SRC= line takes additional arguments, as
16165   described next.
16167 - =<language>= ::
16169   #+cindex: language, in code blocks
16170   Mandatory.  It is the identifier of the source code language in the
16171   block.  See [[*Languages]], for identifiers of supported languages.
16173 - =<switches>= ::
16175   #+cindex: switches, in code blocks
16176   Optional.  Switches provide finer control of the code execution,
16177   export, and format (see the discussion of switches in [[*Literal
16178   Examples]]).
16180 - =<header arguments>= ::
16182   #+cindex: header arguments, in code blocks
16183   Optional.  Heading arguments control many aspects of evaluation,
16184   export and tangling of code blocks (see [[*Using Header Arguments]]).
16185   Using Org's properties feature, header arguments can be selectively
16186   applied to the entire buffer or specific sub-trees of the Org
16187   document.
16189 - =<body>= ::
16191   Source code in the dialect of the specified language identifier.
16193 ** Using Header Arguments
16194 :PROPERTIES:
16195 :DESCRIPTION: Different ways to set header arguments.
16196 :END:
16198 Org comes with many header arguments common to all languages.  New
16199 header arguments are added for specific languages as they become
16200 available for use in source code blocks.  A header argument is
16201 specified with an initial colon followed by the argument's name in
16202 lowercase.
16204 Since header arguments can be set in several ways, Org prioritizes
16205 them in case of overlaps or conflicts by giving local settings
16206 a higher priority.  Header values in function calls, for example,
16207 override header values from global defaults.
16209 *** System-wide header arguments
16210 :PROPERTIES:
16211 :UNNUMBERED: notoc
16212 :END:
16213 #+vindex: org-babel-default-header-args
16215 #+vindex: org-babel-default-header-args
16216 System-wide values of header arguments can be specified by customizing
16217 the ~org-babel-default-header-args~ variable, which defaults to the
16218 following values:
16220 #+begin_example
16221 :session    => "none"
16222 :results    => "replace"
16223 :exports    => "code"
16224 :cache      => "no"
16225 :noweb      => "no"
16226 #+end_example
16228 The example below sets =:noweb= header arguments to =yes=, which makes
16229 Org expand =:noweb= references by default.
16231 #+begin_src emacs-lisp
16232 (setq org-babel-default-header-args
16233       (cons '(:noweb . "yes")
16234             (assq-delete-all :noweb org-babel-default-header-args)))
16235 #+end_src
16237 #+cindex: language specific default header arguments
16238 #+cindex: default header arguments per language
16239 Each language can have separate default header arguments by
16240 customizing the variable ~org-babel-default-header-args:<LANG>~, where
16241 {{{var(<LANG>)}}} is the name of the language.  For details, see the
16242 language-specific online documentation at
16243 https://orgmode.org/worg/org-contrib/babel/.
16245 *** Header arguments in Org mode properties
16246 :PROPERTIES:
16247 :UNNUMBERED: notoc
16248 :END:
16250 For header arguments applicable to the buffer, use =PROPERTY= keyword
16251 anywhere in the Org file (see [[*Property Syntax]]).
16253 The following example makes all the R code blocks execute in the same
16254 session.  Setting =:results= to =silent= ignores the results of
16255 executions for all blocks, not just R code blocks; no results inserted
16256 for any block.
16258 #+begin_example
16259 ,#+PROPERTY: header-args:R  :session *R*
16260 ,#+PROPERTY: header-args    :results silent
16261 #+end_example
16263 #+vindex: org-use-property-inheritance
16264 Header arguments set through Org's property drawers (see [[*Property
16265 Syntax]]) apply at the sub-tree level on down.  Since these property
16266 drawers can appear anywhere in the file hierarchy, Org uses outermost
16267 call or source block to resolve the values.  Org ignores
16268 ~org-use-property-inheritance~ setting.
16270 In this example, =:cache= defaults to =yes= for all code blocks in the
16271 sub-tree.
16273 #+begin_example
16274 ,* sample header
16275   :PROPERTIES:
16276   :header-args:    :cache yes
16277   :END:
16278 #+end_example
16280 #+kindex: C-c C-x p
16281 #+findex: org-set-property
16282 Properties defined through ~org-set-property~ function, bound to
16283 {{{kbd(C-c C-x p)}}}, apply to all active languages.  They override
16284 properties set in ~org-babel-default-header-args~.
16286 #+cindex: language specific header arguments properties
16287 #+cindex: header arguments per language
16288 Language-specific header arguments are also read from properties
16289 =header-args:<LANG>= where {{{var(<LANG>)}}} is the language
16290 identifier.  For example,
16292 #+begin_example
16293 ,* Heading
16294   :PROPERTIES:
16295   :header-args:clojure:    :session *clojure-1*
16296   :header-args:R:          :session *R*
16297   :END:
16298 ,** Subheading
16299   :PROPERTIES:
16300   :header-args:clojure:    :session *clojure-2*
16301   :END:
16302 #+end_example
16304 #+texinfo: @noindent
16305 would force separate sessions for Clojure blocks in =Heading= and
16306 =Subheading=, but use the same session for all R blocks.  Blocks in
16307 =Subheading= inherit settings from =Heading=.
16309 *** Code block specific header arguments
16310 :PROPERTIES:
16311 :UNNUMBERED: notoc
16312 :END:
16314 Header arguments are most commonly set at the source code block level,
16315 on the =#+BEGIN_SRC= line.  Arguments set at this level take
16316 precedence over those set in the ~org-babel-default-header-args~
16317 variable, and also those set as header properties.
16319 In the following example, setting =:results= to =silent= makes it
16320 ignore results of the code execution.  Setting =:exports= to =code=
16321 exports only the body of the code block to HTML or LaTeX.
16323 #+begin_example
16324 ,#+NAME: factorial
16325 ,#+BEGIN_SRC haskell :results silent :exports code :var n=0
16326   fac 0 = 1
16327   fac n = n * fac (n-1)
16328 ,#+END_SRC
16329 #+end_example
16331 The same header arguments in an inline code block:
16333 : src_haskell[:exports both]{fac 5}
16335 #+cindex: @samp{HEADER}, keyword
16336 Code block header arguments can span multiple lines using =#+HEADER:=
16337 on each line.  Note that Org currently accepts the plural spelling of
16338 =#+HEADER:= only as a convenience for backward-compatibility.  It may
16339 be removed at some point.
16341 Multi-line header arguments on an unnamed code block:
16343 #+begin_example
16344 ,#+HEADER: :var data1=1
16345 ,#+BEGIN_SRC emacs-lisp :var data2=2
16346    (message "data1:%S, data2:%S" data1 data2)
16347 ,#+END_SRC
16349 ,#+RESULTS:
16350 : data1:1, data2:2
16351 #+end_example
16353 Multi-line header arguments on a named code block:
16355 #+begin_example
16356 ,#+NAME: named-block
16357 ,#+HEADER: :var data=2
16358 ,#+BEGIN_SRC emacs-lisp
16359   (message "data:%S" data)
16360 ,#+END_SRC
16362 ,#+RESULTS: named-block
16363   : data:2
16364 #+end_example
16366 *** Header arguments in function calls
16367 :PROPERTIES:
16368 :UNNUMBERED: notoc
16369 :END:
16371 Header arguments in function calls are the most specific and override
16372 all other settings in case of an overlap.  They get the highest
16373 priority.  Two =#+CALL:= examples are shown below.  For the complete
16374 syntax of =CALL= keyword, see [[*Evaluating Code Blocks]].
16376 In this example, =:exports results= header argument is applied to the
16377 evaluation of the =#+CALL:= line.
16379 : #+CALL: factorial(n=5) :exports results
16381 In this example, =:session special= header argument is applied to the
16382 evaluation of =factorial= code block.
16384 : #+CALL: factorial[:session special](n=5)
16386 ** Environment of a Code Block
16387 :PROPERTIES:
16388 :DESCRIPTION: Arguments, sessions, working directory...
16389 :END:
16391 *** Passing arguments
16392 :PROPERTIES:
16393 :UNNUMBERED: notoc
16394 :END:
16396 #+cindex: passing arguments to code blocks
16397 #+cindex: arguments, in code blocks
16398 #+cindex: @samp{var}, header argument
16399 Use =var= for passing arguments to source code blocks.  The specifics
16400 of variables in code blocks vary by the source language and are
16401 covered in the language-specific documentation.  The syntax for =var=,
16402 however, is the same for all languages.  This includes declaring
16403 a variable, and assigning a default value.
16405 The following syntax is used to pass arguments to code blocks using
16406 the =var= header argument.
16408 : :var NAME=ASSIGN
16410 #+texinfo: @noindent
16411 {{{var(NAME)}}} is the name of the variable bound in the code block
16412 body.  {{{var(ASSIGN)}}} is a literal value, such as a string,
16413 a number, a reference to a table, a list, a literal example, another
16414 code block---with or without arguments---or the results of evaluating
16415 a code block.
16417 Here are examples of passing values by reference:
16419 - table ::
16421   A table named with a =NAME= keyword.
16423   #+begin_example
16424   ,#+NAME: example-table
16425   | 1 |
16426   | 2 |
16427   | 3 |
16428   | 4 |
16430   ,#+NAME: table-length
16431   ,#+BEGIN_SRC emacs-lisp :var table=example-table
16432     (length table)
16433   ,#+END_SRC
16435   ,#+RESULTS: table-length
16436   : 4
16437   #+end_example
16439   When passing a table, you can treat specially the row, or the
16440   column, containing labels for the columns, or the rows, in the
16441   table.
16443   #+cindex: @samp{colnames}, header argument
16444   The =colnames= header argument accepts =yes=, =no=, or =nil= values.
16445   The default value is =nil=: if an input table has column
16446   names---because the second row is a horizontal rule---then Org
16447   removes the column names, processes the table, puts back the column
16448   names, and then writes the table to the results block.  Using =yes=,
16449   Org does the same to the first row, even if the initial table does
16450   not contain any horizontal rule.  When set to =no=, Org does not
16451   pre-process column names at all.
16453   #+begin_example
16454   ,#+NAME: less-cols
16455   | a |
16456   |---|
16457   | b |
16458   | c |
16460   ,#+BEGIN_SRC python :var tab=less-cols :colnames nil
16461     return [[val + '*' for val in row] for row in tab]
16462   ,#+END_SRC
16464   ,#+RESULTS:
16465   | a  |
16466   |----|
16467   | b* |
16468   | c* |
16469   #+end_example
16471   #+cindex: @samp{rownames}, header argument
16472   Similarly, the =rownames= header argument can take two values: =yes=
16473   or =no=.  When set to =yes=, Org removes the first column, processes
16474   the table, puts back the first column, and then writes the table to
16475   the results block.  The default is =no=, which means Org does not
16476   pre-process the first column.  Note that Emacs Lisp code blocks
16477   ignore =rownames= header argument because of the ease of
16478   table-handling in Emacs.
16480   #+begin_example
16481   ,#+NAME: with-rownames
16482   | one | 1 | 2 | 3 | 4 |  5 |
16483   | two | 6 | 7 | 8 | 9 | 10 |
16485   ,#+BEGIN_SRC python :var tab=with-rownames :rownames yes
16486     return [[val + 10 for val in row] for row in tab]
16487   ,#+END_SRC
16489   ,#+RESULTS:
16490   | one | 11 | 12 | 13 | 14 | 15 |
16491   | two | 16 | 17 | 18 | 19 | 20 |
16492   #+end_example
16494 - list ::
16496   A simple named list.
16498   #+begin_example
16499   ,#+NAME: example-list
16500   - simple
16501     - not
16502     - nested
16503   - list
16505   ,#+BEGIN_SRC emacs-lisp :var x=example-list
16506     (print x)
16507   ,#+END_SRC
16509   ,#+RESULTS:
16510   | simple | list |
16511   #+end_example
16513   Note that only the top level list items are passed along.  Nested
16514   list items are ignored.
16516 - code block without arguments ::
16518   A code block name, as assigned by =NAME= keyword from the example
16519   above, optionally followed by parentheses.
16521   #+begin_example
16522   ,#+BEGIN_SRC emacs-lisp :var length=table-length()
16523     (* 2 length)
16524   ,#+END_SRC
16526   ,#+RESULTS:
16527   : 8
16528   #+end_example
16530 - code block with arguments ::
16532   A code block name, as assigned by =NAME= keyword, followed by
16533   parentheses and optional arguments passed within the parentheses.
16535   #+begin_example
16536   ,#+NAME: double
16537   ,#+BEGIN_SRC emacs-lisp :var input=8
16538     (* 2 input)
16539   ,#+END_SRC
16541   ,#+RESULTS: double
16542   : 16
16544   ,#+NAME: squared
16545   ,#+BEGIN_SRC emacs-lisp :var input=double(input=1)
16546     (* input input)
16547   ,#+END_SRC
16549   ,#+RESULTS: squared
16550   : 4
16551   #+end_example
16553 - literal example ::
16555   A literal example block named with a =NAME= keyword.
16557   #+begin_example
16558   ,#+NAME: literal-example
16559   ,#+BEGIN_EXAMPLE
16560     A literal example
16561     on two lines
16562   ,#+END_EXAMPLE
16564   ,#+NAME: read-literal-example
16565   ,#+BEGIN_SRC emacs-lisp :var x=literal-example
16566     (concatenate #'string x " for you.")
16567   ,#+END_SRC
16569   ,#+RESULTS: read-literal-example
16570   : A literal example
16571   : on two lines for you.
16572   #+end_example
16574 Indexing variable values enables referencing portions of a variable.
16575 Indexes are 0 based with negative values counting backwards from the
16576 end.  If an index is separated by commas then each subsequent section
16577 indexes as the next dimension.  Note that this indexing occurs
16578 /before/ other table-related header arguments are applied, such as
16579 =hlines=, =colnames= and =rownames=.  The following example assigns
16580 the last cell of the first row the table =example-table= to the
16581 variable =data=:
16583 #+begin_example
16584 ,#+NAME: example-table
16585 | 1 | a |
16586 | 2 | b |
16587 | 3 | c |
16588 | 4 | d |
16590 ,#+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
16591   data
16592 ,#+END_SRC
16594 ,#+RESULTS:
16595 : a
16596 #+end_example
16598 Two integers separated by a colon reference a range of variable
16599 values.  In that case the entire inclusive range is referenced.  For
16600 example the following assigns the middle three rows of =example-table=
16601 to =data=.
16603 #+begin_example
16604 ,#+NAME: example-table
16605 | 1 | a |
16606 | 2 | b |
16607 | 3 | c |
16608 | 4 | d |
16609 | 5 | 3 |
16611 ,#+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
16612   data
16613 ,#+END_SRC
16615 ,#+RESULTS:
16616 | 2 | b |
16617 | 3 | c |
16618 | 4 | d |
16619 #+end_example
16621 To pick the entire range, use an empty index, or the single character
16622 =*=.  =0:-1= does the same thing.  Example below shows how to
16623 reference the first column only.
16625 #+begin_example
16626 ,#+NAME: example-table
16627 | 1 | a |
16628 | 2 | b |
16629 | 3 | c |
16630 | 4 | d |
16632 ,#+BEGIN_SRC emacs-lisp :var data=example-table[,0]
16633   data
16634 ,#+END_SRC
16636 ,#+RESULTS:
16637 | 1 | 2 | 3 | 4 |
16638 #+end_example
16640 Index referencing can be used for tables and code blocks.  Index
16641 referencing can handle any number of dimensions.  Commas delimit
16642 multiple dimensions, as shown below.
16644 #+begin_example
16645 ,#+NAME: 3D
16646 ,#+BEGIN_SRC emacs-lisp
16647   '(((1  2  3)  (4  5  6)  (7  8  9))
16648     ((10 11 12) (13 14 15) (16 17 18))
16649     ((19 20 21) (22 23 24) (25 26 27)))
16650 ,#+END_SRC
16652 ,#+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
16653   data
16654 ,#+END_SRC
16656 ,#+RESULTS:
16657 | 11 | 14 | 17 |
16658 #+end_example
16660 Note that row names and column names are not removed prior to variable
16661 indexing.  You need to take them into account, even when =colnames= or
16662 =rownames= header arguments remove them.
16664 Emacs lisp code can also set the values for variables.  To
16665 differentiate a value from Lisp code, Org interprets any value
16666 starting with =(=, =[=, ='= or =`= as Emacs Lisp code.  The result of
16667 evaluating that code is then assigned to the value of that variable.
16668 The following example shows how to reliably query and pass the file
16669 name of the Org mode buffer to a code block using headers.  We need
16670 reliability here because the file's name could change once the code in
16671 the block starts executing.
16673 #+begin_example
16674 ,#+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
16675   wc -w $filename
16676 ,#+END_SRC
16677 #+end_example
16679 Note that values read from tables and lists are not mistakenly
16680 evaluated as Emacs Lisp code, as illustrated in the following example.
16682 #+begin_example
16683 ,#+NAME: table
16684 | (a b c) |
16686 ,#+HEADER: :var data=table[0,0]
16687 ,#+BEGIN_SRC perl
16688   $data
16689 ,#+END_SRC
16691 ,#+RESULTS:
16692 : (a b c)
16693 #+end_example
16695 *** Using sessions
16696 :PROPERTIES:
16697 :UNNUMBERED: notoc
16698 :END:
16700 #+cindex: using sessions in code blocks
16701 #+cindex: @samp{session}, header argument
16702 Two code blocks can share the same environment.  The =session= header
16703 argument is for running multiple source code blocks under one session.
16704 Org runs code blocks with the same session name in the same
16705 interpreter process.
16707 - =none= ::
16709   Default.  Each code block gets a new interpreter process to execute.
16710   The process terminates once the block is evaluated.
16712 - {{{var(STRING)}}} ::
16714   Any string besides =none= turns that string into the name of that
16715   session.  For example, =:session STRING= names it =STRING=.  If
16716   =session= has no value, then the session name is derived from the
16717   source language identifier.  Subsequent blocks with the same source
16718   code language use the same session.  Depending on the language,
16719   state variables, code from other blocks, and the overall interpreted
16720   environment may be shared.  Some interpreted languages support
16721   concurrent sessions when subsequent source code language blocks
16722   change session names.
16724 Only languages that provide interactive evaluation can have session
16725 support.  Not all languages provide this support, such as C and ditaa.
16726 Even languages, such as Python and Haskell, that do support
16727 interactive evaluation impose limitations on allowable language
16728 constructs that can run interactively.  Org inherits those limitations
16729 for those code blocks running in a session.
16731 *** Choosing a working directory
16732 :PROPERTIES:
16733 :UNNUMBERED: notoc
16734 :END:
16736 #+cindex: working directory, in a code block
16737 #+cindex: @samp{dir}, header argument
16738 #+cindex: @samp{mkdirp}, header argument
16739 The =dir= header argument specifies the default directory during code
16740 block execution.  If it is absent, then the directory associated with
16741 the current buffer is used.  In other words, supplying =:dir
16742 DIRECTORY= temporarily has the same effect as changing the current
16743 directory with {{{kbd(M-x cd RET DIRECTORY)}}}, and then not setting
16744 =dir=.  Under the surface, =dir= simply sets the value of the Emacs
16745 variable ~default-directory~.  Setting =mkdirp= header argument to
16746 a non-~nil~ value creates the directory, if necessary.
16748 For example, to save the plot file in the =Work/= folder of the home
16749 directory---notice tilde is expanded:
16751 #+begin_example
16752 ,#+BEGIN_SRC R :file myplot.png :dir ~/Work
16753   matplot(matrix(rnorm(100), 10), type="l")
16754 ,#+END_SRC
16755 #+end_example
16757 To evaluate the code block on a remote machine, supply a remote
16758 directory name using Tramp syntax.  For example:
16760 #+begin_example
16761 ,#+BEGIN_SRC R :file plot.png :dir /scp:dand@yakuba.princeton.edu:
16762   plot(1:10, main=system("hostname", intern=TRUE))
16763 ,#+END_SRC
16764 #+end_example
16766 Org first captures the text results as usual for insertion in the Org
16767 file.  Then Org also inserts a link to the remote file, thanks to
16768 Emacs Tramp.  Org constructs the remote path to the file name from
16769 =dir= and ~default-directory~, as illustrated here:
16771 : [[file:/scp:dand@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
16773 When =dir= is used with =session=, Org sets the starting directory for
16774 a new session.  But Org does not alter the directory of an already
16775 existing session.
16777 Do not use =dir= with =:exports results= or with =:exports both= to
16778 avoid Org inserting incorrect links to remote files.  That is because
16779 Org does not expand ~default directory~ to avoid some underlying
16780 portability issues.
16782 *** Inserting headers and footers
16783 :PROPERTIES:
16784 :UNNUMBERED: notoc
16785 :END:
16787 #+cindex: headers, in code blocks
16788 #+cindex: footers, in code blocks
16789 #+cindex: @samp{prologue}, header argument
16790 The =prologue= header argument is for appending to the top of the code
16791 block for execution, like a reset instruction.  For example, you may
16792 use =:prologue "reset"= in a Gnuplot code block or, for every such
16793 block:
16795 #+begin_src emacs-lisp
16796 (add-to-list 'org-babel-default-header-args:gnuplot
16797              '((:prologue . "reset")))
16799 #+end_src
16801 #+cindex: @samp{epilogue}, header argument
16802 Likewise, the value of the =epilogue= header argument is for appending
16803 to the end of the code block for execution.
16805 ** Evaluating Code Blocks
16806 :PROPERTIES:
16807 :DESCRIPTION: Place results of evaluation in the Org buffer.
16808 :END:
16809 #+cindex: code block, evaluating
16810 #+cindex: source code, evaluating
16811 #+cindex: @samp{RESULTS}, keyword
16813 A note about security: With code evaluation comes the risk of harm.
16814 Org safeguards by prompting for user's permission before executing any
16815 code in the source block.  To customize this safeguard, or disable it,
16816 see [[*Code Evaluation and Security Issues]].
16818 *** How to evaluate source code
16819 :PROPERTIES:
16820 :UNNUMBERED: notoc
16821 :END:
16823 Org captures the results of the code block evaluation and inserts them
16824 in the Org file, right after the code block.  The insertion point is
16825 after a newline and the =RESULTS= keyword.  Org creates the =RESULTS=
16826 keyword if one is not already there.
16828 By default, Org enables only Emacs Lisp code blocks for execution.
16829 See [[*Languages]] to enable other languages.
16831 #+kindex: C-c C-c
16832 #+kindex: C-c C-v e
16833 #+findex: org-babel-execute-src-block
16834 Org provides many ways to execute code blocks.  {{{kbd(C-c C-c)}}} or
16835 {{{kbd(C-c C-v e)}}} with the point on a code block[fn:140] calls the
16836 ~org-babel-execute-src-block~ function, which executes the code in the
16837 block, collects the results, and inserts them in the buffer.
16839 #+cindex: @samp{CALL}, keyword
16840 #+vindex: org-babel-inline-result-wrap
16841 By calling a named code block[fn:141] from an Org mode buffer or
16842 a table.  Org can call the named code blocks from the current Org mode
16843 buffer or from the "Library of Babel" (see [[*Library of Babel]]).
16845 The syntax for =CALL= keyword is:
16847 #+begin_example
16848 ,#+CALL: <name>(<arguments>)
16849 ,#+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
16850 #+end_example
16852 The syntax for inline named code blocks is:
16854 #+begin_example
16855 ... call_<name>(<arguments>) ...
16856 ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
16857 #+end_example
16859 When inline syntax is used, the result is wrapped based on the
16860 variable ~org-babel-inline-result-wrap~, which by default is set to
16861 ~"=%s="~ to produce verbatim text suitable for markup.
16863 - =<name>= ::
16865   This is the name of the code block (see [[*Structure of Code Blocks]])
16866   to be evaluated in the current document.  If the block is located in
16867   another file, start =<name>= with the file name followed by
16868   a colon. For example, in order to execute a block named =clear-data=
16869   in =file.org=, you can write the following:
16871   : #+CALL: file.org:clear-data()
16873 - =<arguments>= ::
16875   Org passes arguments to the code block using standard function call
16876   syntax.  For example, a =#+CALL:= line that passes =4= to a code
16877   block named =double=, which declares the header argument =:var n=2=,
16878   would be written as:
16880   : #+CALL: double(n=4)
16882   #+texinfo: @noindent
16883   Note how this function call syntax is different from the header
16884   argument syntax.
16886 - =<inside header arguments>= ::
16888   Org passes inside header arguments to the named code block using the
16889   header argument syntax.  Inside header arguments apply to code block
16890   evaluation.  For example, =[:results output]= collects results
16891   printed to stdout during code execution of that block.  Note how
16892   this header argument syntax is different from the function call
16893   syntax.
16895 - =<end header arguments>= ::
16897   End header arguments affect the results returned by the code block.
16898   For example, =:results html= wraps the results in a =#+BEGIN_EXPORT
16899   html= block before inserting the results in the Org buffer.
16901 *** Limit code block evaluation
16902 :PROPERTIES:
16903 :UNNUMBERED: notoc
16904 :END:
16906 #+cindex: @samp{eval}, header argument
16907 #+cindex: control code block evaluation
16908 The =eval= header argument can limit evaluation of specific code
16909 blocks and =CALL= keyword.  It is useful for protection against
16910 evaluating untrusted code blocks by prompting for a confirmation.
16912 - =never= or =no= ::
16914   Org never evaluates the source code.
16916 - =query= ::
16918   Org prompts the user for permission to evaluate the source code.
16920 - =never-export= or =no-export= ::
16922   Org does not evaluate the source code when exporting, yet the user
16923   can evaluate it interactively.
16925 - =query-export= ::
16927   Org prompts the user for permission to evaluate the source code
16928   during export.
16930 If =eval= header argument is not set, then Org determines whether to
16931 evaluate the source code from the ~org-confirm-babel-evaluate~
16932 variable (see [[*Code Evaluation and Security Issues]]).
16934 *** Cache results of evaluation
16935 :PROPERTIES:
16936 :UNNUMBERED: notoc
16937 :END:
16939 #+cindex: @samp{cache}, header argument
16940 #+cindex: cache results of code evaluation
16941 The =cache= header argument is for caching results of evaluating code
16942 blocks.  Caching results can avoid re-evaluating a code block that
16943 have not changed since the previous run.  To benefit from the cache
16944 and avoid redundant evaluations, the source block must have a result
16945 already present in the buffer, and neither the header
16946 arguments---including the value of =var= references---nor the text of
16947 the block itself has changed since the result was last computed.  This
16948 feature greatly helps avoid long-running calculations.  For some edge
16949 cases, however, the cached results may not be reliable.
16951 The caching feature is best for when code blocks are pure functions,
16952 that is functions that return the same value for the same input
16953 arguments (see [[*Environment of a Code Block]]), and that do not have
16954 side effects, and do not rely on external variables other than the
16955 input arguments.  Functions that depend on a timer, file system
16956 objects, and random number generators are clearly unsuitable for
16957 caching.
16959 A note of warning: when =cache= is used in a session, caching may
16960 cause unexpected results.
16962 When the caching mechanism tests for any source code changes, it does
16963 not expand Noweb style references (see [[*Noweb Reference Syntax]]).  For
16964 reasons why, see http://thread.gmane.org/gmane.emacs.orgmode/79046.
16966 The =cache= header argument can have one of two values: =yes= or =no=.
16968 - =no= ::
16970   Default.  No caching of results; code block evaluated every time.
16972 - =yes= ::
16974   Whether to run the code or return the cached results is determined
16975   by comparing the SHA1 hash value of the combined code block and
16976   arguments passed to it.  This hash value is packed on the
16977   =#+RESULTS:= line from previous evaluation.  When hash values match,
16978   Org does not evaluate the code block.  When hash values mismatch,
16979   Org evaluates the code block, inserts the results, recalculates the
16980   hash value, and updates =#+RESULTS:= line.
16982 In this example, both functions are cached.  But =caller= runs only if
16983 the result from =random= has changed since the last run.
16985 #+begin_example
16986 ,#+NAME: random
16987 ,#+BEGIN_SRC R :cache yes
16988   runif(1)
16989 ,#+END_SRC
16991 ,#+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
16992 0.4659510825295
16994 ,#+NAME: caller
16995 ,#+BEGIN_SRC emacs-lisp :var x=random :cache yes
16996   x
16997 ,#+END_SRC
16999 ,#+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
17000 0.254227238707244
17001 #+end_example
17003 ** Results of Evaluation
17004 :PROPERTIES:
17005 :DESCRIPTION: Choosing a results type, post-processing...
17006 :END:
17007 #+cindex: code block, results of evaluation
17008 #+cindex: source code, results of evaluation
17010 #+cindex: @samp{results}, header argument
17011 How Org handles results of a code block execution depends on many
17012 header arguments working together.  The primary determinant, however,
17013 is the =results= header argument.  It accepts four classes of options.
17014 Each code block can take only one option per class:
17016 - Collection ::
17018   For how the results should be collected from the code block;
17020 - Type ::
17022   For which type of result the code block will return; affects how Org
17023   processes and inserts results in the Org buffer;
17025 - Format ::
17027   For the result; affects how Org processes results;
17029 - Handling ::
17031   For inserting results once they are properly formatted.
17033 *** Collection
17034 :PROPERTIES:
17035 :UNNUMBERED: notoc
17036 :END:
17038 Collection options specify the results.  Choose one of the options;
17039 they are mutually exclusive.
17041 - =value= ::
17043   Default.  Functional mode.  Org gets the value by wrapping the code
17044   in a function definition in the language of the source block.  That
17045   is why when using =:results value=, code should execute like
17046   a function and return a value.  For languages like Python, an
17047   explicit ~return~ statement is mandatory when using =:results
17048   value=.  Result is the value returned by the last statement in the
17049   code block.
17051   When evaluating the code block in a session (see [[*Environment of
17052   a Code Block]]), Org passes the code to an interpreter running as an
17053   interactive Emacs inferior process. Org gets the value from the
17054   source code interpreter's last statement output.  Org has to use
17055   language-specific methods to obtain the value.  For example, from
17056   the variable ~_~ in Python and Ruby, and the value of ~.Last.value~
17057   in R.
17059 - =output= ::
17061   Scripting mode.  Org passes the code to an external process running
17062   the interpreter.  Org returns the contents of the standard output
17063   stream as text results.
17065   When using a session, Org passes the code to the interpreter running
17066   as an interactive Emacs inferior process.  Org concatenates any text
17067   output from the interpreter and returns the collection as a result.
17069   Note that this collection is not the same as that would be collected
17070   from stdout of a non-interactive interpreter running as an external
17071   process.  Compare for example these two blocks:
17073   #+begin_example
17074   ,#+BEGIN_SRC python :results output
17075     print "hello"
17076     2
17077     print "bye"
17078   ,#+END_SRC
17080   ,#+RESULTS:
17081   : hello
17082   : bye
17083   #+end_example
17085   In the above non-session mode, the "2" is not printed; so it does
17086   not appear in results.
17088   #+begin_example
17089   ,#+BEGIN_SRC python :results output :session
17090     print "hello"
17091     2
17092     print "bye"
17093   ,#+END_SRC
17095   ,#+RESULTS:
17096   : hello
17097   : 2
17098   : bye
17099   #+end_example
17101   In the above session, the interactive interpreter receives and
17102   prints "2".  Results show that.
17104 *** Type
17105 :PROPERTIES:
17106 :UNNUMBERED: notoc
17107 :END:
17109 Type tells what result types to expect from the execution of the code
17110 block.  Choose one of the options; they are mutually exclusive.  The
17111 default behavior is to automatically determine the result type.
17113 #+attr_texinfo: :sep ,
17114 - =table=, =vector= ::
17116   Interpret the results as an Org table.  If the result is a single
17117   value, create a table with one row and one column.  Usage example:
17118   =:results value table=.
17120   #+cindex: @samp{hlines}, header argument
17121   In-between each table row or below the table headings, sometimes
17122   results have horizontal lines, which are also known as "hlines".
17123   The =hlines= argument with the default =no= value strips such lines
17124   from the input table.  For most code, this is desirable, or else
17125   those =hline= symbols raise unbound variable errors.  A =yes=
17126   accepts such lines, as demonstrated in the following example.
17128   #+begin_example
17129   ,#+NAME: many-cols
17130   | a | b | c |
17131   |---+---+---|
17132   | d | e | f |
17133   |---+---+---|
17134   | g | h | i |
17136   ,#+NAME: no-hline
17137   ,#+BEGIN_SRC python :var tab=many-cols :hlines no
17138     return tab
17139   ,#+END_SRC
17141   ,#+RESULTS: no-hline
17142   | a | b | c |
17143   | d | e | f |
17144   | g | h | i |
17146   ,#+NAME: hlines
17147   ,#+BEGIN_SRC python :var tab=many-cols :hlines yes
17148     return tab
17149   ,#+END_SRC
17151   ,#+RESULTS: hlines
17152   | a | b | c |
17153   |---+---+---|
17154   | d | e | f |
17155   |---+---+---|
17156   | g | h | i |
17157   #+end_example
17159 - =list= ::
17161   Interpret the results as an Org list.  If the result is a single
17162   value, create a list of one element.
17164 - =scalar=, =verbatim= ::
17166   Interpret literally and insert as quoted text.  Do not create
17167   a table.  Usage example: =:results value verbatim=.
17169 - =file= ::
17171   Interpret as a filename.  Save the results of execution of the code
17172   block to that file, then insert a link to it.  You can control both
17173   the filename and the description associated to the link.
17175   #+cindex: @samp{file}, header argument
17176   #+cindex: @samp{output-dir}, header argument
17177   Org first tries to generate the filename from the value of the
17178   =file= header argument and the directory specified using the
17179   =output-dir= header arguments.  If =output-dir= is not specified,
17180   Org assumes it is the current directory.
17182   #+begin_example
17183   ,#+BEGIN_SRC asymptote :results value file :file circle.pdf :output-dir img/
17184     size(2cm);
17185     draw(unitcircle);
17186   ,#+END_SRC
17187   #+end_example
17189   #+cindex: @samp{file-ext}, header argument
17190   If =file= is missing, Org generates the base name of the output
17191   file from the name of the code block, and its extension from the
17192   =file-ext= header argument.  In that case, both the name and the
17193   extension are mandatory[fn:142].
17195   #+begin_example
17196   ,#+name: circle
17197   ,#+BEGIN_SRC asymptote :results value file :file-ext pdf
17198     size(2cm);
17199     draw(unitcircle);
17200   ,#+END_SRC
17201   #+end_example
17203   #+cindex: @samp{file-desc}, header argument
17204   The =file-desc= header argument defines the description (see
17205   [[*Link Format]]) for the link.  If =file-desc= has no value, Org
17206   uses the generated file name for both the "link" and
17207   "description" parts of the link.
17209   #+cindex: @samp{sep}, header argument
17210   By default, Org assumes that a table written to a file has
17211   TAB-delimited output.  You can choose a different separator with
17212   the =sep= header argument.
17214 *** Format
17215 :PROPERTIES:
17216 :UNNUMBERED: notoc
17217 :END:
17219 Format pertains to the type of the result returned by the code block.
17220 Choose one of the options; they are mutually exclusive.  The default
17221 follows from the type specified above.
17223 #+attr_texinfo: :sep ,
17224 - =code= ::
17226   Result enclosed in a code block.  Useful for parsing.  Usage
17227   example: =:results value code=.
17229 - =drawer= ::
17231   Result wrapped in a =RESULTS= drawer.  Useful for containing =raw=
17232   or =org= results for later scripting and automated processing.
17233   Usage example: =:results value drawer=.
17235 - =html= ::
17237   Results enclosed in a =BEGIN_EXPORT html= block.  Usage example:
17238   =:results value html=.
17240 - =latex= ::
17242   Results enclosed in a =BEGIN_EXPORT latex= block.  Usage example:
17243   =:results value latex=.
17245 - =link=, =graphics= ::
17247   Result is a link to the file specified in =:file= header argument.
17248   However, unlike plain =:file=, nothing is written to the disk.  The
17249   block is used for its side-effects only, as in the following
17250   example:
17252   #+begin_example
17253   ,#+begin_src shell :results link :file "download.tar.gz"
17254   wget -c "http://example.com/download.tar.gz"
17255   ,#+end_src
17256   #+end_example
17258 - =org= ::
17260   Results enclosed in a =BEGIN_SRC org= block.  For comma-escape,
17261   either {{{kbd(TAB)}}} in the block, or export the file.  Usage
17262   example: =:results value org=.
17264 - =pp= ::
17266   Result converted to pretty-print source code.  Enclosed in a code
17267   block.  Languages supported: Emacs Lisp, Python, and Ruby.  Usage
17268   example: =:results value pp=.
17270 - =raw= ::
17272   Interpreted as raw Org mode.  Inserted directly into the buffer.
17273   Aligned if it is a table.  Usage example: =:results value raw=.
17275 #+cindex: @samp{wrap}, header argument
17276 The =wrap= header argument unconditionnally marks the results block by
17277 appending strings to =#+BEGIN_= and =#+END_=.  If no string is
17278 specified, Org wraps the results in a =#+BEGIN_results=
17279 ... =#+END_results= block.  It takes precedent over the =results=
17280 value listed above.  E.g.,
17282 #+begin_example
17283 ,#+BEGIN_SRC emacs-lisp :results html :wrap EXPORT markdown
17284 "<blink>Welcome back to the 90's</blink>"
17285 ,#+END_SRC
17287 ,#+RESULTS:
17288 ,#+BEGIN_EXPORT markdown
17289 <blink>Welcome back to the 90's</blink>
17290 ,#+END_EXPORT
17291 #+end_example
17293 *** Handling
17294 :PROPERTIES:
17295 :UNNUMBERED: notoc
17296 :END:
17298 Handling options after collecting the results.
17300 - =silent= ::
17302   Do not insert results in the Org mode buffer, but echo them in the
17303   minibuffer.  Usage example: =:results output silent=.
17305 - =replace= ::
17307   Default.  Insert results in the Org buffer.  Remove previous
17308   results.  Usage example: =:results output replace=.
17310 - =append= ::
17312   Append results to the Org buffer.  Latest results are at the bottom.
17313   Does not remove previous results.  Usage example: =:results output
17314   append=.
17316 - =prepend= ::
17318   Prepend results to the Org buffer.  Latest results are at the top.
17319   Does not remove previous results.  Usage example: =:results output
17320   prepend=.
17322 *** Post-processing
17323 :PROPERTIES:
17324 :UNNUMBERED: notoc
17325 :END:
17327 #+cindex: @samp{post}, header argument
17328 #+cindex: @samp{*this*}, in @samp{post} header argument
17329 The =post= header argument is for post-processing results from block
17330 evaluation.  When =post= has any value, Org binds the results to
17331 ~*this*~ variable for easy passing to =var= header argument
17332 specifications (see [[*Environment of a Code Block]]).  That makes results
17333 available to other code blocks, or even for direct Emacs Lisp code
17334 execution.
17336 The following two examples illustrate =post= header argument in
17337 action.  The first one shows how to attach an =ATTR_LATEX= keyword
17338 using =post=.
17340 #+begin_example
17341 ,#+NAME: attr_wrap
17342 ,#+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output
17343   echo "#+ATTR_LATEX: :width $width"
17344   echo "$data"
17345 ,#+END_SRC
17347 ,#+HEADER: :file /tmp/it.png
17348 ,#+BEGIN_SRC dot :post attr_wrap(width="5cm", data=*this*) :results drawer
17349   digraph{
17350           a -> b;
17351           b -> c;
17352           c -> a;
17353   }
17354 ,#+end_src
17356 ,#+RESULTS:
17357 :RESULTS:
17358 ,#+ATTR_LATEX :width 5cm
17359 [[file:/tmp/it.png]]
17360 :END:
17361 #+end_example
17363 The second example shows use of =colnames= header argument in =post=
17364 to pass data between code blocks.
17366 #+begin_example
17367 ,#+NAME: round-tbl
17368 ,#+BEGIN_SRC emacs-lisp :var tbl="" fmt="%.3f"
17369   (mapcar (lambda (row)
17370             (mapcar (lambda (cell)
17371                       (if (numberp cell)
17372                           (format fmt cell)
17373                         cell))
17374                     row))
17375           tbl)
17376 ,#+end_src
17378 ,#+BEGIN_SRC R :colnames yes :post round-tbl[:colnames yes](*this*)
17379   set.seed(42)
17380   data.frame(foo=rnorm(1))
17381 ,#+END_SRC
17383 ,#+RESULTS:
17384 |   foo |
17385 |-------|
17386 | 1.371 |
17387 #+end_example
17389 ** Exporting Code Blocks
17390 :PROPERTIES:
17391 :DESCRIPTION: Export contents and/or results.
17392 :END:
17393 #+cindex: code block, exporting
17394 #+cindex: source code, exporting
17396 It is possible to export the /code/ of code blocks, the /results/ of
17397 code block evaluation, /both/ the code and the results of code block
17398 evaluation, or /none/.  Org defaults to exporting /code/ for most
17399 languages.  For some languages, such as ditaa, Org defaults to
17400 /results/.  To export just the body of code blocks, see [[*Literal
17401 Examples]].  To selectively export sub-trees of an Org document, see
17402 [[*Exporting]].
17404 #+cindex: @samp{exports}, header argument
17405 The =exports= header argument is to specify if that part of the Org
17406 file is exported to, say, HTML or LaTeX formats.
17408 - =code= ::
17410   The default.  The body of code is included into the exported file.
17411   Example: =:exports code=.
17413 - =results= ::
17415   The results of evaluation of the code is included in the exported
17416   file.  Example: =:exports results=.
17418 - =both= ::
17420   Both the code and results of evaluation are included in the exported
17421   file.  Example: =:exports both=.
17423 - =none= ::
17425   Neither the code nor the results of evaluation is included in the
17426   exported file.  Whether the code is evaluated at all depends on
17427   other options.  Example: =:exports none=.
17429 #+vindex: org-export-use-babel
17430 To stop Org from evaluating code blocks to speed exports, use the
17431 header argument =:eval never-export= (see [[*Evaluating Code Blocks]]).
17432 To stop Org from evaluating code blocks for greater security, set the
17433 ~org-export-use-babel~ variable to ~nil~, but understand that header
17434 arguments will have no effect.
17436 Turning off evaluation comes in handy when batch processing.  For
17437 example, markup languages for wikis, which have a high risk of
17438 untrusted code.  Stopping code block evaluation also stops evaluation
17439 of all header arguments of the code block.  This may not be desirable
17440 in some circumstances.  So during export, to allow evaluation of just
17441 the header arguments but not any code evaluation in the source block,
17442 set =:eval never-export= (see [[*Evaluating Code Blocks]]).
17444 Org never evaluates code blocks in commented sub-trees when exporting
17445 (see [[*Comment Lines]]).  On the other hand, Org does evaluate code
17446 blocks in sub-trees excluded from export (see [[*Export Settings]]).
17448 ** Extracting Source Code
17449 :PROPERTIES:
17450 :DESCRIPTION: Create pure source code files.
17451 :END:
17452 #+cindex: tangling
17453 #+cindex: source code, extracting
17454 #+cindex: code block, extracting source code
17456 Extracting source code from code blocks is a basic task in literate
17457 programming.  Org has features to make this easy.  In literate
17458 programming parlance, documents on creation are /woven/ with code and
17459 documentation, and on export, the code is tangled for execution by
17460 a computer.  Org facilitates weaving and tangling for producing,
17461 maintaining, sharing, and exporting literate programming documents.
17462 Org provides extensive customization options for extracting source
17463 code.
17465 When Org tangles code blocks, it expands, merges, and transforms them.
17466 Then Org recomposes them into one or more separate files, as
17467 configured through the options.  During this tangling process, Org
17468 expands variables in the source code, and resolves any Noweb style
17469 references (see [[*Noweb Reference Syntax]]).
17471 *** Header arguments
17472 :PROPERTIES:
17473 :UNNUMBERED: notoc
17474 :END:
17476 #+cindex: @samp{tangle}, header argument
17477 The =tangle= header argument specifies if the code block is exported
17478 to source file(s).
17480 - =yes= ::
17482   Export the code block to source file.  The file name for the source
17483   file is derived from the name of the Org file, and the file
17484   extension is derived from the source code language identifier.
17485   Example: =:tangle yes=.
17487 - =no= ::
17489   The default.  Do not extract the code in a source code file.
17490   Example: =:tangle no=.
17492 - {{{var(FILENAME)}}} ::
17494   Export the code block to source file whose file name is derived from
17495   any string passed to the =tangle= header argument.  Org derives the
17496   file name as being relative to the directory of the Org file's
17497   location.  Example: =:tangle FILENAME=.
17499 #+cindex: @samp{mkdirp}, header argument
17500 The =mkdirp= header argument creates parent directories for tangled
17501 files if the directory does not exist.  A =yes= value enables
17502 directory creation whereas =no= inhibits it.
17504 #+cindex: @samp{comments}, header argument
17505 The =comments= header argument controls inserting comments into
17506 tangled files.  These are above and beyond whatever comments may
17507 already exist in the code block.
17509 - =no= ::
17511   The default.  Do not insert any extra comments during tangling.
17513 - =link= ::
17515   Wrap the code block in comments.  Include links pointing back to the
17516   place in the Org file from where the code was tangled.
17518 - =yes= ::
17520   Kept for backward compatibility; same as =link=.
17522 - =org= ::
17524   Nearest headline text from Org file is inserted as comment.  The
17525   exact text that is inserted is picked from the leading context of
17526   the source block.
17528 - =both= ::
17530   Includes both =link= and =org= options.
17532 - =noweb= ::
17534   Includes =link= option, expands Noweb references (see [[*Noweb
17535   Reference Syntax]]), and wraps them in link comments inside the body
17536   of the code block.
17538 #+cindex: @samp{padline}, header argument
17539 The =padline= header argument controls insertion of newlines to pad
17540 source code in the tangled file.
17542 - =yes= ::
17544   Default.  Insert a newline before and after each code block in the
17545   tangled file.
17547 - =no= ::
17549   Do not insert newlines to pad the tangled code blocks.
17551 #+cindex: @samp{shebang}, header argument
17552 The =shebang= header argument can turn results into executable script
17553 files.  By setting it to a string value---for example, =:shebang
17554 "#!/bin/bash"=---Org inserts that string as the first line of the
17555 tangled file that the code block is extracted to.  Org then turns on
17556 the tangled file's executable permission.
17558 #+cindex: @samp{tangle-mode}, header argument
17559 The =tangle-mode= header argument specifies what permissions to set
17560 for tangled files by ~set-file-modes~.  For example, to make
17561 a read-only tangled file, use =:tangle-mode (identity #o444)=.  To
17562 make it executable, use =:tangle-mode (identity #o755)=.  It also
17563 overrides executable permission granted by =shebang=.  When multiple
17564 source code blocks tangle to a single file with different and
17565 conflicting =tangle-mode= header arguments, Org's behavior is
17566 undefined.
17568 #+cindex: @samp{no-expand}, header argument
17569 By default Org expands code blocks during tangling.  The =no-expand=
17570 header argument turns off such expansions.  Note that one side-effect
17571 of expansion by ~org-babel-expand-src-block~ also assigns values (see
17572 [[*Environment of a Code Block]]) to variables.  Expansions also replace
17573 Noweb references with their targets (see [[*Noweb Reference Syntax]]).
17574 Some of these expansions may cause premature assignment, hence this
17575 option.  This option makes a difference only for tangling.  It has no
17576 effect when exporting since code blocks for execution have to be
17577 expanded anyway.
17579 *** Functions
17580 :PROPERTIES:
17581 :UNNUMBERED: notoc
17582 :END:
17584 - ~org-babel-tangle~ ::
17586   #+findex: org-babel-tangle
17587   #+kindex: C-c C-v t
17588   Tangle the current file.  Bound to {{{kbd(C-c C-v t)}}}.
17590   With prefix argument only tangle the current code block.
17592 - ~org-babel-tangle-file~ ::
17594   #+findex: org-babel-tangle-file
17595   #+kindex: C-c C-v f
17596   Choose a file to tangle.  Bound to {{{kbd(C-c C-v f)}}}.
17598 *** Hooks
17599 :PROPERTIES:
17600 :UNNUMBERED: notoc
17601 :END:
17603 - ~org-babel-post-tangle-hook~ ::
17605   #+vindex: org-babel-post-tangle-hook
17606   This hook is run from within code files tangled by
17607   ~org-babel-tangle~, making it suitable for post-processing,
17608   compilation, and evaluation of code in the tangled files.
17610 *** Jumping between code and Org
17611 :PROPERTIES:
17612 :UNNUMBERED: notoc
17613 :END:
17615 #+findex: org-babel-tangle-jump-to-org
17616 Debuggers normally link errors and messages back to the source code.
17617 But for tangled files, we want to link back to the Org file, not to
17618 the tangled source file.  To make this extra jump, Org uses
17619 ~org-babel-tangle-jump-to-org~ function with two additional source
17620 code block header arguments:
17622 1. Set =padline= to true---this is the default setting.
17623 2. Set =comments= to =link=, which makes Org insert links to the Org
17624    file.
17626 ** Languages
17627 :PROPERTIES:
17628 :DESCRIPTION: List of supported code block languages.
17629 :END:
17630 #+cindex: babel, languages
17631 #+cindex: source code, languages
17632 #+cindex: code block, languages
17634 Code blocks in the following languages are supported.
17636 #+attr_texinfo: :columns 0.20 0.35 0.20 0.20
17637 | Language   | Identifier    | Language       | Identifier   |
17638 |------------+---------------+----------------+--------------|
17639 | Asymptote  | =asymptote=   | Lisp           | =lisp=       |
17640 | Awk        | =awk=         | Lua            | =lua=        |
17641 | C          | =C=           | MATLAB         | =matlab=     |
17642 | C++        | =C++=[fn:143] | Mscgen         | =mscgen=     |
17643 | Clojure    | =clojure=     | Objective Caml | =ocaml=      |
17644 | CSS        | =css=         | Octave         | =octave=     |
17645 | D          | =D=[fn:144]   | Org mode       | =org=        |
17646 | ditaa      | =ditaa=       | Oz             | =oz=         |
17647 | Emacs Calc | =calc=        | Perl           | =perl=       |
17648 | Emacs Lisp | =emacs-lisp=  | Plantuml       | =plantuml=   |
17649 | Eshell     | =eshell=      | Processing.js  | =processing= |
17650 | Fortran    | =fortran=     | Python         | =python=     |
17651 | Gnuplot    | =gnuplot=     | R              | =R=          |
17652 | GNU Screen | =screen=      | Ruby           | =ruby=       |
17653 | Graphviz   | =dot=         | Sass           | =sass=       |
17654 | Haskell    | =haskell=     | Scheme         | =scheme=     |
17655 | Java       | =java=        | Sed            | =sed=        |
17656 | Javascript | =js=          | shell          | =sh=         |
17657 | LaTeX      | =latex=       | SQL            | =sql=        |
17658 | Ledger     | =ledger=      | SQLite         | =sqlite=     |
17659 | Lilypond   | =lilypond=    | Vala           | =vala=       |
17661 Additional documentation for some languages is at
17662 https://orgmode.org/worg/org-contrib/babel/languages.html.
17664 #+vindex: org-babel-load-languages
17665 By default, only Emacs Lisp is enabled for evaluation.  To enable or
17666 disable other languages, customize the ~org-babel-load-languages~
17667 variable either through the Emacs customization interface, or by
17668 adding code to the init file as shown next.
17670 In this example, evaluation is disabled for Emacs Lisp, and enabled
17671 for R.
17673 #+begin_src emacs-lisp
17674 (org-babel-do-load-languages
17675  'org-babel-load-languages
17676  '((emacs-lisp . nil)
17677    (R . t)))
17678 #+end_src
17680 Note that this is not the only way to enable a language.  Org also
17681 enables languages when loaded with ~require~ statement.  For example,
17682 the following enables execution of Clojure code blocks:
17684 #+begin_src emacs-lisp
17685 (require 'ob-clojure)
17686 #+end_src
17688 ** Editing Source Code
17689 :PROPERTIES:
17690 :DESCRIPTION: Language major-mode editing.
17691 :END:
17692 #+cindex: code block, editing
17693 #+cindex: source code, editing
17695 #+kindex: C-c '
17696 Use {{{kbd(C-c ')}}} to edit the current code block.  It opens a new
17697 major mode edit buffer containing the body of the source code block,
17698 ready for any edits.  Use {{{kbd(C-c ')}}} again to close the buffer
17699 and return to the Org buffer.
17701 #+kindex: C-x C-s
17702 #+vindex: org-edit-src-auto-save-idle-delay
17703 #+cindex: auto-save, in code block editing
17704 {{{kbd(C-x C-s)}}} saves the buffer and updates the contents of the
17705 Org buffer.  Set ~org-edit-src-auto-save-idle-delay~ to save the base
17706 buffer after a certain idle delay time.  Set
17707 ~org-edit-src-turn-on-auto-save~ to auto-save this buffer into
17708 a separate file using Auto-save mode.
17710 While editing the source code in the major mode, the Org Src minor
17711 mode remains active.  It provides these customization variables as
17712 described below.  For even more variables, look in the customization
17713 group ~org-edit-structure~.
17715 - ~org-src-lang-modes~ ::
17717   #+vindex: org-src-lang-modes
17718   If an Emacs major-mode named ~<LANG>-mode~ exists, where
17719   {{{var(<LANG>)}}} is the language identifier from code block's
17720   header line, then the edit buffer uses that major mode.  Use this
17721   variable to arbitrarily map language identifiers to major modes.
17723 - ~org-src-window-setup~ ::
17725   #+vindex: org-src-window-setup
17726   For specifying Emacs window arrangement when the new edit buffer is
17727   created.
17729 - ~org-src-preserve-indentation~ ::
17731   #+cindex: indentation, in code blocks
17732   #+vindex: org-src-preserve-indentation
17733   Default is ~nil~.  Source code is indented.  This indentation
17734   applies during export or tangling, and depending on the context, may
17735   alter leading spaces and tabs.  When non-~nil~, source code is
17736   aligned with the leftmost column.  No lines are modified during
17737   export or tangling, which is very useful for white-space sensitive
17738   languages, such as Python.
17740 - ~org-src-ask-before-returning-to-edit-buffer~ ::
17742   #+vindex: org-src-ask-before-returning-to-edit-buffer
17743   When ~nil~, Org returns to the edit buffer without further prompts.
17744   The default prompts for a confirmation.
17746 #+vindex: org-src-fontify-natively
17747 #+vindex: org-src-block-faces
17748 Set ~org-src-fontify-natively~ to non-~nil~ to turn on native code
17749 fontification in the /Org/ buffer.  Fontification of code blocks can
17750 give visual separation of text and code on the display page.  To
17751 further customize the appearance of ~org-block~ for specific
17752 languages, customize ~org-src-block-faces~.  The following example
17753 shades the background of regular blocks, and colors source blocks only
17754 for Python and Emacs Lisp languages.
17756 #+begin_src emacs-lisp
17757 (require 'color)
17758 (set-face-attribute 'org-block nil :background
17759                     (color-darken-name
17760                      (face-attribute 'default :background) 3))
17762 (setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF"))
17763                             ("python" (:background "#E5FFB8"))))
17764 #+end_src
17766 ** Noweb Reference Syntax
17767 :PROPERTIES:
17768 :DESCRIPTION: Literate programming in Org mode.
17769 :END:
17770 #+cindex: code block, Noweb reference
17771 #+cindex: syntax, Noweb
17772 #+cindex: source code, Noweb reference
17774 Org supports named blocks in Noweb[fn:145] style syntax:
17776 : <<CODE-BLOCK-ID>>
17778 Org can replace the construct with the source code, or the results of
17779 evaluation, of the code block identified as {{{var(CODE-BLOCK-ID)}}}.
17781 #+cindex: @samp{noweb}, header argument
17782 The =noweb= header argument controls expansion of Noweb syntax
17783 references.  Expansions occur when source code blocks are evaluated,
17784 tangled, or exported.
17786 - =no= ::
17788   Default.  No expansion of Noweb syntax references in the body of the
17789   code when evaluating, tangling, or exporting.
17791 - =yes= ::
17793   Expansion of Noweb syntax references in the body of the code block
17794   when evaluating, tangling, or exporting.
17796 - =tangle= ::
17798   Expansion of Noweb syntax references in the body of the code block
17799   when tangling.  No expansion when evaluating or exporting.
17801 - =no-export= ::
17803   Expansion of Noweb syntax references in the body of the code block
17804   when evaluating or tangling.  No expansion when exporting.
17806 - =strip-export= ::
17808   Expansion of Noweb syntax references in the body of the code block
17809   when expanding prior to evaluating or tangling.  Removes Noweb
17810   syntax references when exporting.
17812 - =eval= ::
17814   Expansion of Noweb syntax references in the body of the code block
17815   only before evaluating.
17817 In the following example,
17819 #+begin_example
17820 ,#+NAME: initialization
17821 ,#+BEGIN_SRC emacs-lisp
17822   (setq sentence "Never a foot too far, even.")
17823 ,#+END_SRC
17825 ,#+BEGIN_SRC emacs-lisp :noweb yes
17826   <<initialization>>
17827   (reverse sentence)
17828 ,#+END_SRC
17829 #+end_example
17831 #+texinfo: @noindent
17832 the second code block is expanded as
17834 #+begin_example
17835 ,#+BEGIN_SRC emacs-lisp :noweb yes
17836   (setq sentence "Never a foot too far, even.")
17837   (reverse sentence)
17838 ,#+END_SRC
17839 #+end_example
17841 Noweb insertions honor prefix characters that appear before the Noweb
17842 syntax reference.  This behavior is illustrated in the following
17843 example.  Because the =<<example>>= Noweb reference appears behind the
17844 SQL comment syntax, each line of the expanded Noweb reference is
17845 commented.  With:
17847 #+begin_example
17848 ,#+NAME: example
17849 ,#+BEGIN_SRC text
17850   this is the
17851   multi-line body of example
17852 ,#+END_SRC
17853 #+end_example
17855 #+texinfo: @noindent
17856 this code block:
17858 #+begin_example
17859 ,#+BEGIN_SRC sql :noweb yes
17860  ---<<example>>
17861 ,#+END_SRC
17862 #+end_example
17864 #+texinfo: @noindent
17865 expands to:
17867 #+begin_example
17868 ,#+BEGIN_SRC sql :noweb yes
17869  ---this is the
17870  ---multi-line body of example
17871 ,#+END_SRC
17872 #+end_example
17874 Since this change does not affect Noweb replacement text without
17875 newlines in them, inline Noweb references are acceptable.
17877 This feature can also be used for management of indentation in
17878 exported code snippets.  With:
17880 #+begin_example
17881 ,#+NAME: if-true
17882 ,#+BEGIN_SRC python :exports none
17883   print('do things when true')
17884 ,#+end_src
17886 ,#+name: if-false
17887 ,#+begin_src python :exports none
17888   print('do things when false')
17889 ,#+end_src
17890 #+end_example
17892 #+texinfo: @noindent
17893 this code block:
17895 #+begin_example
17896 ,#+begin_src python :noweb yes :results output
17897   if true:
17898       <<if-true>>
17899   else:
17900       <<if-false>>
17901 ,#+end_src
17902 #+end_example
17904 #+texinfo: @noindent
17905 expands to:
17907 #+begin_example
17908 if true:
17909     print('do things when true')
17910 else:
17911     print('do things when false')
17912 #+end_example
17914 #+cindex: @samp{noweb-ref}, header argument
17915 When expanding Noweb style references, Org concatenates code blocks by
17916 matching the reference name to either the code block name or, if none
17917 is found, to the =noweb-ref= header argument.
17919 For simple concatenation, set this =noweb-ref= header argument at the
17920 sub-tree or file level.  In the example Org file shown next, the body
17921 of the source code in each block is extracted for concatenation to
17922 a pure code file when tangled.
17924 #+begin_example
17925 ,#+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
17926   <<fullest-disk>>
17927 ,#+END_SRC
17928 ,* the mount point of the fullest disk
17929   :PROPERTIES:
17930   :header-args: :noweb-ref fullest-disk
17931   :END:
17933 ,** query all mounted disks
17934 ,#+BEGIN_SRC sh
17935   df \
17936 ,#+END_SRC
17938 ,** strip the header row
17939 ,#+BEGIN_SRC sh
17940   |sed '1d' \
17941 ,#+END_SRC
17943 ,** output mount point of fullest disk
17944 ,#+BEGIN_SRC sh
17945   |awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}'
17946 ,#+END_SRC
17947 #+end_example
17949 #+cindex: @samp{noweb-sep}, header argument
17950 By default a newline separates each noweb reference concatenation.  To
17951 change this newline separator, edit the =noweb-sep= header argument.
17953 Eventually, Org can include the results of a code block rather than
17954 its body.  To that effect, append parentheses, possibly including
17955 arguments, to the code block name, as shown below.
17957 : <<code-block-name(optional arguments)>>
17959 Note that when using the above approach to a code block's results, the
17960 code block name set by =NAME= keyword is required; the reference set
17961 by =noweb-ref= does not work in that case.
17963 Here is an example that demonstrates how the exported content changes
17964 when Noweb style references are used with parentheses versus without.
17965 With:
17967 #+begin_example
17968 ,#+NAME: some-code
17969 ,#+BEGIN_SRC python :var num=0 :results output :exports none
17970   print(num*10)
17971 ,#+END_SRC
17972 #+end_example
17974 #+texinfo: @noindent
17975 this code block:
17977 #+begin_example
17978 ,#+BEGIN_SRC text :noweb yes
17979   <<some-code>>
17980 ,#+END_SRC
17981 #+end_example
17983 #+texinfo: @noindent
17984 expands to:
17986 : print(num*10)
17988 Below, a similar Noweb style reference is used, but with parentheses,
17989 while setting a variable =num= to 10:
17991 #+begin_example
17992 ,#+BEGIN_SRC text :noweb yes
17993   <<some-code(num=10)>>
17994 ,#+END_SRC
17995 #+end_example
17997 #+texinfo: @noindent
17998 Note that now the expansion contains the results of the code block
17999 =some-code=, not the code block itself:
18001 : 100
18003 ** Library of Babel
18004 :PROPERTIES:
18005 :DESCRIPTION: Use and contribute to a library of useful code blocks.
18006 :END:
18007 #+cindex: babel, library of
18008 #+cindex: source code, library
18009 #+cindex: code block, library
18011 The "Library of Babel" is a collection of code blocks.  Like
18012 a function library, these code blocks can be called from other Org
18013 files.  A collection of useful code blocks is available on [[https://orgmode.org/worg/library-of-babel.html][Worg]].  For
18014 remote code block evaluation syntax, see [[*Evaluating Code Blocks]].
18016 #+kindex: C-c C-v i
18017 #+findex: org-babel-lob-ingest
18018 For any user to add code to the library, first save the code in
18019 regular code blocks of an Org file, and then load the Org file with
18020 ~org-babel-lob-ingest~, which is bound to {{{kbd(C-c C-v i)}}}.
18022 ** Key bindings and Useful Functions
18023 :PROPERTIES:
18024 :DESCRIPTION: Work quickly with code blocks.
18025 :END:
18026 #+cindex: code block, key bindings
18028 Many common Org mode key sequences are re-bound depending on
18029 the context.
18031 Active key bindings in code blocks:
18033 #+kindex: C-c C-c
18034 #+findex: org-babel-execute-src-block
18035 #+kindex: C-c C-o
18036 #+findex: org-babel-open-src-block-result
18037 #+kindex: M-UP
18038 #+findex: org-babel-load-in-session
18039 #+kindex: M-DOWN
18040 #+findex: org-babel-pop-to-session
18041 #+attr_texinfo: :columns 0.2 0.55
18042 | Key binding        | Function                          |
18043 |--------------------+-----------------------------------|
18044 | {{{kbd(C-c C-c)}}} | ~org-babel-execute-src-block~     |
18045 | {{{kbd(C-c C-o)}}} | ~org-babel-open-src-block-result~ |
18046 | {{{kbd(M-UP)}}}    | ~org-babel-load-in-session~       |
18047 | {{{kbd(M-DOWN)}}}  | ~org-babel-pop-to-session~        |
18049 Active key bindings in Org mode buffer:
18051 #+kindex: C-c C-v p
18052 #+kindex: C-c C-v C-p
18053 #+kindex: C-c C-v n
18054 #+kindex: C-c C-v C-n
18055 #+kindex: C-c C-v e
18056 #+kindex: C-c C-v C-e
18057 #+kindex: C-c C-v o
18058 #+kindex: C-c C-v C-o
18059 #+kindex: C-c C-v v
18060 #+kindex: C-c C-v C-v
18061 #+kindex: C-c C-v u
18062 #+kindex: C-c C-v C-u
18063 #+kindex: C-c C-v g
18064 #+kindex: C-c C-v C-g
18065 #+kindex: C-c C-v r
18066 #+kindex: C-c C-v C-r
18067 #+kindex: C-c C-v b
18068 #+kindex: C-c C-v C-b
18069 #+kindex: C-c C-v s
18070 #+kindex: C-c C-v C-s
18071 #+kindex: C-c C-v d
18072 #+kindex: C-c C-v C-d
18073 #+kindex: C-c C-v t
18074 #+kindex: C-c C-v C-t
18075 #+kindex: C-c C-v f
18076 #+kindex: C-c C-v C-f
18077 #+kindex: C-c C-v c
18078 #+kindex: C-c C-v C-c
18079 #+kindex: C-c C-v j
18080 #+kindex: C-c C-v C-j
18081 #+kindex: C-c C-v l
18082 #+kindex: C-c C-v C-l
18083 #+kindex: C-c C-v i
18084 #+kindex: C-c C-v C-i
18085 #+kindex: C-c C-v I
18086 #+kindex: C-c C-v C-I
18087 #+kindex: C-c C-v z
18088 #+kindex: C-c C-v C-z
18089 #+kindex: C-c C-v a
18090 #+kindex: C-c C-v C-a
18091 #+kindex: C-c C-v h
18092 #+kindex: C-c C-v C-h
18093 #+kindex: C-c C-v x
18094 #+kindex: C-c C-v C-x
18095 #+findex: org-babel-previous-src-block
18096 #+findex: org-babel-next-src-block
18097 #+findex: org-babel-execute-maybe
18098 #+findex: org-babel-open-src-block-result
18099 #+findex: org-babel-expand-src-block
18100 #+findex: org-babel-goto-src-block-head
18101 #+findex: org-babel-goto-named-src-block
18102 #+findex: org-babel-goto-named-result
18103 #+findex: org-babel-execute-buffer
18104 #+findex: org-babel-execute-subtree
18105 #+findex: org-babel-demarcate-block
18106 #+findex: org-babel-tangle
18107 #+findex: org-babel-tangle-file
18108 #+findex: org-babel-check-src-block
18109 #+findex: org-babel-insert-header-arg
18110 #+findex: org-babel-load-in-session
18111 #+findex: org-babel-lob-ingest
18112 #+findex: org-babel-view-src-block-info
18113 #+findex: org-babel-switch-to-session-with-code
18114 #+findex: org-babel-sha1-hash
18115 #+findex: org-babel-describe-bindings
18116 #+findex: org-babel-do-key-sequence-in-edit-buffer
18117 #+attr_texinfo: :columns 0.45 0.55
18118 | Key binding                                    | Function                                   |
18119 |------------------------------------------------+--------------------------------------------|
18120 | {{{kbd(C-c C-v p)}}} or {{{kbd(C-c C-v C-p)}}} | ~org-babel-previous-src-block~             |
18121 | {{{kbd(C-c C-v n)}}} or {{{kbd(C-c C-v C-n)}}} | ~org-babel-next-src-block~                 |
18122 | {{{kbd(C-c C-v e)}}} or {{{kbd(C-c C-v C-e)}}} | ~org-babel-execute-maybe~                  |
18123 | {{{kbd(C-c C-v o)}}} or {{{kbd(C-c C-v C-o)}}} | ~org-babel-open-src-block-result~          |
18124 | {{{kbd(C-c C-v v)}}} or {{{kbd(C-c C-v C-v)}}} | ~org-babel-expand-src-block~               |
18125 | {{{kbd(C-c C-v u)}}} or {{{kbd(C-c C-v C-u)}}} | ~org-babel-goto-src-block-head~            |
18126 | {{{kbd(C-c C-v g)}}} or {{{kbd(C-c C-v C-g)}}} | ~org-babel-goto-named-src-block~           |
18127 | {{{kbd(C-c C-v r)}}} or {{{kbd(C-c C-v C-r)}}} | ~org-babel-goto-named-result~              |
18128 | {{{kbd(C-c C-v b)}}} or {{{kbd(C-c C-v C-b)}}} | ~org-babel-execute-buffer~                 |
18129 | {{{kbd(C-c C-v s)}}} or {{{kbd(C-c C-v C-s)}}} | ~org-babel-execute-subtree~                |
18130 | {{{kbd(C-c C-v d)}}} or {{{kbd(C-c C-v C-d)}}} | ~org-babel-demarcate-block~                |
18131 | {{{kbd(C-c C-v t)}}} or {{{kbd(C-c C-v C-t)}}} | ~org-babel-tangle~                         |
18132 | {{{kbd(C-c C-v f)}}} or {{{kbd(C-c C-v C-f)}}} | ~org-babel-tangle-file~                    |
18133 | {{{kbd(C-c C-v c)}}} or {{{kbd(C-c C-v C-c)}}} | ~org-babel-check-src-block~                |
18134 | {{{kbd(C-c C-v j)}}} or {{{kbd(C-c C-v C-j)}}} | ~org-babel-insert-header-arg~              |
18135 | {{{kbd(C-c C-v l)}}} or {{{kbd(C-c C-v C-l)}}} | ~org-babel-load-in-session~                |
18136 | {{{kbd(C-c C-v i)}}} or {{{kbd(C-c C-v C-i)}}} | ~org-babel-lob-ingest~                     |
18137 | {{{kbd(C-c C-v I)}}} or {{{kbd(C-c C-v C-I)}}} | ~org-babel-view-src-block-info~            |
18138 | {{{kbd(C-c C-v z)}}} or {{{kbd(C-c C-v C-z)}}} | ~org-babel-switch-to-session-with-code~    |
18139 | {{{kbd(C-c C-v a)}}} or {{{kbd(C-c C-v C-a)}}} | ~org-babel-sha1-hash~                      |
18140 | {{{kbd(C-c C-v h)}}} or {{{kbd(C-c C-v C-h)}}} | ~org-babel-describe-bindings~              |
18141 | {{{kbd(C-c C-v x)}}} or {{{kbd(C-c C-v C-x)}}} | ~org-babel-do-key-sequence-in-edit-buffer~ |
18143 ** Batch Execution
18144 :PROPERTIES:
18145 :DESCRIPTION: Call functions from the command line.
18146 :END:
18147 #+cindex: code block, batch execution
18148 #+cindex: source code, batch execution
18150 Org mode features, including working with source code facilities can
18151 be invoked from the command line.  This enables building shell scripts
18152 for batch processing, running automated system tasks, and expanding
18153 Org mode's usefulness.
18155 The sample script shows batch processing of multiple files using
18156 ~org-babel-tangle~.
18158 #+begin_example
18159 #!/bin/sh
18160 # Tangle files with Org mode
18162 emacs -Q --batch --eval "
18163     (progn
18164       (require 'ob-tangle)
18165       (dolist (file command-line-args-left)
18166         (with-current-buffer (find-file-noselect file)
18167           (org-babel-tangle))))
18168   " "$@"
18169 #+end_example
18171 * Miscellaneous
18172 :PROPERTIES:
18173 :DESCRIPTION: All the rest which did not fit elsewhere.
18174 :END:
18176 ** Completion
18177 :PROPERTIES:
18178 :DESCRIPTION: @kbd{M-@key{TAB}} guesses completions.
18179 :END:
18180 #+cindex: completion, of @TeX{} symbols
18181 #+cindex: completion, of TODO keywords
18182 #+cindex: completion, of dictionary words
18183 #+cindex: completion, of option keywords
18184 #+cindex: completion, of tags
18185 #+cindex: completion, of property keys
18186 #+cindex: completion, of link abbreviations
18187 #+cindex: @TeX{} symbol completion
18188 #+cindex: TODO keywords completion
18189 #+cindex: dictionary word completion
18190 #+cindex: option keyword completion
18191 #+cindex: tag completion
18192 #+cindex: link abbreviations, completion of
18194 Org has in-buffer completions.  Unlike minibuffer completions, which
18195 are useful for quick command interactions, Org's in-buffer completions
18196 are more suitable for content creation in Org documents.  Type one or
18197 more letters and invoke the hot key to complete the text in-place.
18198 Depending on the context and the keys, Org offers different types of
18199 completions.  No minibuffer is involved.  Such mode-specific hot keys
18200 have become an integral part of Emacs and Org provides several
18201 shortcuts.
18203 - {{{kbd(M-TAB)}}} ::
18204   #+kindex: M-TAB
18206   Complete word at point.
18208   - At the beginning of a headline, complete TODO keywords.
18210   - After =\=, complete TeX symbols supported by the exporter.
18212   - After =*=, complete headlines in the current buffer so that they
18213     can be used in search links like:
18215     : [[*find this headline]]
18217   - After =:= in a headline, complete tags.  Org deduces the list of
18218     tags from the =TAGS= in-buffer option (see [[*Setting Tags]]), the
18219     variable ~org-tag-alist~, or from all tags used in the current
18220     buffer.
18222   - After =:= and not in a headline, complete property keys.  The list
18223     of keys is constructed dynamically from all keys used in the
18224     current buffer.
18226   - After =[=, complete link abbreviations (see [[*Link Abbreviations]]).
18228   - After =#+=, complete the special keywords like =TYP_TODO= or
18229     file-specific =OPTIONS=.  After option keyword is complete,
18230     pressing {{{kbd(M-TAB)}}} again inserts example settings for this
18231     keyword.
18233   - After =STARTUP= keyword, complete startup items.
18235   - When point is anywhere else, complete dictionary words using
18236     Ispell.
18238 ** Structure Templates
18239 :PROPERTIES:
18240 :DESCRIPTION: Quick insertion of structural elements.
18241 :END:
18242 #+cindex: template insertion
18243 #+cindex: insertion, of templates
18245 With just a few keystrokes, it is possible to insert empty structural
18246 blocks, such as =#+BEGIN_SRC= ... =#+END_SRC=, or to wrap existing
18247 text in such a block.
18249 - {{{kbd(C-c C-\,)}}} (~org-insert-structure-template~) ::
18251   #+findex: org-insert-structure-template
18252   #+kindex: C-c C-,
18253   Prompt for a type of block structure, and insert the block at point.
18254   If the region is active, it is wrapped in the block.  First prompts
18255   the user for keys, which are used to look up a structure type from
18256   the variable below.  If the key is {{{kbd(TAB)}}}, {{{kbd(RET)}}},
18257   or {{{kbd(SPC)}}}, the user is prompted to enter a block type.
18259 #+vindex: org-structure-template-alist
18260 Available structure types are defined in
18261 ~org-structure-template-alist~, see the docstring for adding or
18262 changing values.
18264 #+cindex: Tempo
18265 #+cindex: template expansion
18266 #+cindex: insertion, of templates
18267 #+vindex: org-tempo-keywords-alist
18268 Org Tempo expands snippets to structures defined in
18269 ~org-structure-template-alist~ and ~org-tempo-keywords-alist~.  For
18270 example, {{{kbd(< s TAB)}}} creates a code block.  Enable it by
18271 customizing ~org-modules~ or add =(require 'org-tempo)= to your Emacs
18272 init file[fn:146].
18274 #+attr_texinfo: :columns 0.1 0.9
18275 | {{{kbd(a)}}} | =#+BEGIN_EXPORT ascii= ... =#+END_EXPORT= |
18276 | {{{kbd(c)}}} | =#+BEGIN_CENTER= ... =#+END_CENTER=       |
18277 | {{{kbd(C)}}} | =#+BEGIN_COMMENT= ... =#+END_COMMENT=     |
18278 | {{{kbd(e)}}} | =#+BEGIN_EXAMPLE= ... =#+END_EXAMPLE=     |
18279 | {{{kbd(E)}}} | =#+BEGIN_EXPORT= ... =#+END_EXPORT= |
18280 | {{{kbd(h)}}} | =#+BEGIN_EXPORT html= ... =#+END_EXPORT=  |
18281 | {{{kbd(l)}}} | =#+BEGIN_EXPORT latex= ... =#+END_EXPORT= |
18282 | {{{kbd(q)}}} | =#+BEGIN_QUOTE= ... =#+END_QUOTE=         |
18283 | {{{kbd(s)}}} | =#+BEGIN_SRC= ... =#+END_SRC=             |
18284 | {{{kbd(v)}}} | =#+BEGIN_VERSE= ... =#+END_VERSE=         |
18286 ** Escape Character
18288 #+cindex: escape character
18289 #+cindex: zero width space
18290 You may sometimes want to write text that looks like Org syntax, but
18291 should really read as plain text.  Org may use a specific escape
18292 character in some situations, e.g., a backslash in macros (see [[*Macro
18293 Replacement]]).  In the general case, however, we suggest to use the
18294 zero width space.  You can get it with one of the following:
18296 : C-x 8 <RET> zero width space <RET>
18297 : C-x 8 <RET> 200B <RET>
18299 For example, in order to write =[[1,2]]= as-is in your document, you can
18300 write this, where =X= denotes the zero width space character:
18302 : [[X1,2]]
18304 ** Speed Keys
18305 :PROPERTIES:
18306 :DESCRIPTION: Electric commands at the beginning of a headline.
18307 :END:
18308 #+cindex: speed keys
18310 Single keystrokes can execute custom commands in an Org file when
18311 point is on a headline.  Without the extra burden of a meta or
18312 modifier key, Speed Keys can speed navigation or execute custom
18313 commands.  Besides faster navigation, Speed Keys may come in handy on
18314 small mobile devices that do not have full keyboards.  Speed Keys may
18315 also work on TTY devices known for their problems when entering Emacs
18316 key chords.
18318 #+vindex: org-use-speed-commands
18319 By default, Org has Speed Keys disabled.  To activate Speed Keys, set
18320 the variable ~org-use-speed-commands~ to a non-~nil~ value.  To
18321 trigger a Speed Key, point must be at the beginning of an Org
18322 headline, before any of the stars.
18324 #+vindex: org-speed-commands-user
18325 #+findex: org-speed-command-help
18326 Org comes with a pre-defined list of Speed Keys.  To add or modify
18327 Speed Keys, customize the variable, ~org-speed-commands-user~.  For
18328 more details, see the variable's docstring.  With Speed Keys
18329 activated, {{{kbd(M-x org-speed-command-help)}}}, or {{{kbd(?)}}} when
18330 point is at the beginning of an Org headline, shows currently active
18331 Speed Keys, including the user-defined ones.
18333 ** Code Evaluation and Security Issues
18334 :PROPERTIES:
18335 :DESCRIPTION: Org files evaluate in-line code.
18336 :ALT_TITLE: Code Evaluation Security
18337 :END:
18339 Unlike plain text, running code comes with risk.  Each source code
18340 block, in terms of risk, is equivalent to an executable file.  Org
18341 therefore puts a few confirmation prompts by default.  This is to
18342 alert the casual user from accidentally running untrusted code.
18344 For users who do not run code blocks or write code regularly, Org's
18345 default settings should suffice.  However, some users may want to
18346 tweak the prompts for fewer interruptions.  To weigh the risks of
18347 automatic execution of code blocks, here are some details about code
18348 evaluation.
18350 Org evaluates code in the following circumstances:
18352 - /Source code blocks/ ::
18354   Org evaluates source code blocks in an Org file during export.  Org
18355   also evaluates a source code block with the {{{kbd(C-c C-c)}}} key
18356   chord.  Users exporting or running code blocks must load files only
18357   from trusted sources.  Be wary of customizing variables that remove
18358   or alter default security measures.
18360   #+attr_texinfo: :options org-confirm-babel-evaluate
18361   #+begin_defopt
18362   When ~t~, Org prompts the user for confirmation before executing
18363   each code block.  When ~nil~, Org executes code blocks without
18364   prompting the user for confirmation.  When this option is set to
18365   a custom function, Org invokes the function with these two
18366   arguments: the source code language and the body of the code block.
18367   The custom function must return either a ~t~ or ~nil~, which
18368   determines if the user is prompted.  Each source code language can
18369   be handled separately through this function argument.
18370   #+end_defopt
18372   For example, here is how to execute ditaa code blocks without
18373   prompting:
18375   #+begin_src emacs-lisp
18376   (defun my-org-confirm-babel-evaluate (lang body)
18377     (not (string= lang "ditaa")))  ;don't ask for ditaa
18378   (setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
18379   #+end_src
18381 - /Following =shell= and =elisp= links/ ::
18383   Org has two link types that can directly evaluate code (see
18384   [[*External Links]]).  Because such code is not visible, these links
18385   have a potential risk.  Org therefore prompts the user when it
18386   encounters such links.  The customization variables are:
18388   #+attr_texinfo: :options org-link-shell-confirm-function
18389   #+begin_defopt
18390   Function that prompts the user before executing a shell link.
18391   #+end_defopt
18393   #+attr_texinfo: :options org-link-elisp-confirm-function
18394   #+begin_defopt
18395   Function that prompts the user before executing an Emacs Lisp link.
18396   #+end_defopt
18398 - /Formulas in tables/ ::
18400   Formulas in tables (see [[*The Spreadsheet]]) are code that is evaluated
18401   either by the Calc interpreter, or by the Emacs Lisp interpreter.
18403 ** Customization
18404 :PROPERTIES:
18405 :DESCRIPTION: Adapting Org to your taste.
18406 :END:
18407 #+cindex: customization
18408 #+cindex: options, for customization
18409 #+cindex: variables, for customization
18411 Org has more than 500 variables for customization.  They can be
18412 accessed through the usual {{{kbd(M-x org-customize)}}} command.  Or
18413 through the Org menu: Org \rarr Customization \rarr Browse Org Group.
18415 Org also has per-file settings for some variables (see [[*Summary of
18416 In-Buffer Settings]]).
18418 ** Summary of In-Buffer Settings
18419 :PROPERTIES:
18420 :DESCRIPTION: Overview of keywords.
18421 :ALT_TITLE: In-buffer Settings
18422 :END:
18423 #+cindex: in-buffer settings
18424 #+cindex: special keywords
18426 In-buffer settings start with =#+=, followed by a keyword, a colon,
18427 and then a word for each setting.  Org accepts multiple settings on
18428 the same line.  Org also accepts multiple lines for a keyword.  This
18429 manual describes these settings throughout.  A summary follows here.
18431 #+cindex: refresh set-up
18432 {{{kbd(C-c C-c)}}} activates any changes to the in-buffer settings.
18433 Closing and reopening the Org file in Emacs also activates the
18434 changes.
18436 #+attr_texinfo: :sep ,
18437 - =#+ARCHIVE: %s_done= ::
18439   #+cindex: @samp{ARCHIVE}, keyword
18440   #+vindex: org-archive-location
18441   Sets the archive location of the agenda file.  The corresponding
18442   variable is ~org-archive-location~.
18444 - =#+CATEGORY= ::
18446   #+cindex: @samp{CATEGORY}, keyword
18447   Sets the category of the agenda file, which applies to the entire
18448   document.
18450 - =#+COLUMNS: %25ITEM ...= ::
18452   #+cindex: @samp{COLUMNS}, property
18453   Set the default format for columns view.  This format applies when
18454   columns view is invoked in locations where no =COLUMNS= property
18455   applies.
18457 - =#+CONSTANTS: name1=value1 ...= ::
18459   #+cindex: @samp{CONSTANTS}, keyword
18460   #+vindex: org-table-formula-constants
18461   #+vindex: org-table-formula
18462   Set file-local values for constants that table formulas can use.
18463   This line sets the local variable
18464   ~org-table-formula-constants-local~.  The global version of this
18465   variable is ~org-table-formula-constants~.
18467 - =#+FILETAGS: :tag1:tag2:tag3:= ::
18469   #+cindex: @samp{FILETAGS}, keyword
18470   Set tags that all entries in the file inherit from, including the
18471   top-level entries.
18473 - =#+LINK: linkword replace= ::
18475   #+cindex: @samp{LINK}, keyword
18476   #+vindex: org-link-abbrev-alist
18477   Each line specifies one abbreviation for one link.  Use multiple
18478   =LINK= keywords for more, see [[*Link Abbreviations]].  The
18479   corresponding variable is ~org-link-abbrev-alist~.
18481 - =#+PRIORITIES: highest lowest default= ::
18483   #+cindex: @samp{PRIORITIES}, keyword
18484   #+vindex: org-highest-priority
18485   #+vindex: org-lowest-priority
18486   #+vindex: org-default-priority
18487   This line sets the limits and the default for the priorities.  All
18488   three must be either letters A--Z or numbers 0--9.  The highest
18489   priority must have a lower ASCII number than the lowest priority.
18491 - =#+PROPERTY: Property_Name Value= ::
18493   #+cindex: @samp{PROPERTY}, keyword
18494   This line sets a default inheritance value for entries in the
18495   current buffer, most useful for specifying the allowed values of
18496   a property.
18498 - =#+SETUPFILE: file= ::
18500   #+cindex: @samp{SETUPFILE}, keyword
18501   The setup file or a URL pointing to such file is for additional
18502   in-buffer settings.  Org loads this file and parses it for any
18503   settings in it only when Org opens the main file.  If URL is
18504   specified, the contents are downloaded and stored in a temporary
18505   file cache.  {{{kbd(C-c C-c)}}} on the settings line parses and
18506   loads the file, and also resets the temporary file cache.  Org also
18507   parses and loads the document during normal exporting process.  Org
18508   parses the contents of this document as if it was included in the
18509   buffer.  It can be another Org file.  To visit the file---not
18510   a URL---use {{{kbd(C-c ')}}} while point is on the line with the
18511   file name.
18513 - =#+STARTUP:= ::
18515   #+cindex: @samp{STARTUP}, keyword
18516   Startup options Org uses when first visiting a file.
18518   #+vindex: org-startup-folded
18519   The first set of options deals with the initial visibility of the
18520   outline tree.  The corresponding variable for global default
18521   settings is ~org-startup-folded~ with a default value of ~t~, which
18522   is the same as ~overview~.
18524   - =overview= ::
18526     Top-level headlines only.
18528   - =content= ::
18530     All headlines.
18532   - =showall= ::
18534     No folding on any entry.
18536   - =showeverything= ::
18538     Show even drawer contents.
18540     #+vindex: org-startup-indented
18541     Dynamic virtual indentation is controlled by the variable
18542     ~org-startup-indented~[fn:147].
18544     - =indent= ::
18546       Start with ~org-indent-mode~ turned on.
18548     - =noindent= ::
18550       Start with ~org-indent-mode~ turned off.
18552       #+vindex: org-startup-align-all-tables
18553       Aligns tables consistently upon visiting a file.  The
18554       corresponding variable is ~org-startup-align-all-tables~ with
18555       ~nil~ as default value.
18557       - =align= ::
18559         Align all tables.
18561       - =noalign= ::
18563         Do not align tables on startup.
18565       #+vindex: org-startup-shrink-all-tables
18566       Shrink table columns with a width cookie.  The corresponding
18567       variable is ~org-startup-shrink-all-tables~ with ~nil~ as
18568       default value.
18570       #+vindex: org-startup-with-inline-images
18571       When visiting a file, inline images can be automatically
18572       displayed.  The corresponding variable is
18573       ~org-startup-with-inline-images~, with a default value ~nil~ to
18574       avoid delays when visiting a file.
18576       - =inlineimages= ::
18578         Show inline images.
18580       - =noinlineimages= ::
18582         Do not show inline images on startup.
18584       #+vindex: org-log-done
18585       #+vindex: org-log-note-clock-out
18586       #+vindex: org-log-repeat
18587       Logging the closing and reopening of TODO items and clock
18588       intervals can be configured using these options (see variables
18589       ~org-log-done~, ~org-log-note-clock-out~, and ~org-log-repeat~).
18591       - =logdone= ::
18593         Record a timestamp when an item is marked as done.
18595       - =lognotedone= ::
18597         Record timestamp and a note when DONE.
18599       - =nologdone= ::
18601         Do not record when items are marked as done.
18603       - =logrepeat= ::
18605         Record a time when reinstating a repeating item.
18607       - =lognoterepeat= ::
18609         Record a note when reinstating a repeating item.
18611       - =nologrepeat= ::
18613         Do not record when reinstating repeating item.
18615       - =lognoteclock-out= ::
18617         Record a note when clocking out.
18619       - =nolognoteclock-out= ::
18621         Do not record a note when clocking out.
18623       - =logreschedule= ::
18625         Record a timestamp when scheduling time changes.
18627       - =lognotereschedule= ::
18629         Record a note when scheduling time changes.
18631       - =nologreschedule= ::
18633         Do not record when a scheduling date changes.
18635       - =logredeadline= ::
18637         Record a timestamp when deadline changes.
18639       - =lognoteredeadline= ::
18641         Record a note when deadline changes.
18643       - =nologredeadline= ::
18645         Do not record when a deadline date changes.
18647       - =logrefile= ::
18649         Record a timestamp when refiling.
18651       - =lognoterefile= ::
18653         Record a note when refiling.
18655       - =nologrefile= ::
18657         Do not record when refiling.
18659       #+vindex: org-hide-leading-stars
18660       #+vindex: org-odd-levels-only
18661       Here are the options for hiding leading stars in outline
18662       headings, and for indenting outlines.  The corresponding
18663       variables are ~org-hide-leading-stars~ and
18664       ~org-odd-levels-only~, both with a default setting ~nil~
18665       (meaning =showstars= and =oddeven=).
18667       - =hidestars= ::
18669         Make all but one of the stars starting a headline invisible.
18671       - =showstars= ::
18673         Show all stars starting a headline.
18675       - =indent= ::
18677         Virtual indentation according to outline level.
18679       - =noindent= ::
18681         No virtual indentation according to outline level.
18683       - =odd= ::
18685         Allow only odd outline levels (1, 3, ...).
18687       - =oddeven= ::
18689         Allow all outline levels.
18691       #+vindex: org-put-time-stamp-overlays
18692       #+vindex: org-time-stamp-overlay-formats
18693       To turn on custom format overlays over timestamps (variables
18694       ~org-put-time-stamp-overlays~ and
18695       ~org-time-stamp-overlay-formats~), use:
18697       - =customtime= ::
18699         Overlay custom time format.
18701       #+vindex: constants-unit-system
18702       The following options influence the table spreadsheet (variable
18703       ~constants-unit-system~).
18705       - =constcgs= ::
18707         =constants.el= should use the c-g-s unit system.
18709       - =constSI= ::
18711         =constants.el= should use the SI unit system.
18713       #+vindex: org-footnote-define-inline
18714       #+vindex: org-footnote-auto-label
18715       #+vindex: org-footnote-auto-adjust
18716       To influence footnote settings, use the following keywords.  The
18717       corresponding variables are ~org-footnote-define-inline~,
18718       ~org-footnote-auto-label~, and ~org-footnote-auto-adjust~.
18720       - =fninline= ::
18722         Define footnotes inline.
18724       - =fnnoinline= ::
18726         Define footnotes in separate section.
18728       - =fnlocal= ::
18730         Define footnotes near first reference, but not inline.
18732       - =fnprompt= ::
18734         Prompt for footnote labels.
18736       - =fnauto= ::
18738         Create =[fn:1]=-like labels automatically (default).
18740       - =fnconfirm= ::
18742         Offer automatic label for editing or confirmation.
18744       - =fnadjust= ::
18746         Automatically renumber and sort footnotes.
18748       - =nofnadjust= ::
18750         Do not renumber and sort automatically.
18752       #+vindex: org-hide-block-startup
18753       To hide blocks on startup, use these keywords.  The
18754       corresponding variable is ~org-hide-block-startup~.
18756       - =hideblocks= ::
18758         Hide all begin/end blocks on startup.
18760       - =nohideblocks= ::
18762         Do not hide blocks on startup.
18764       #+vindex: org-pretty-entities
18765       The display of entities as UTF-8 characters is governed by the
18766       variable ~org-pretty-entities~ and the keywords
18768       - =entitiespretty= ::
18770         Show entities as UTF-8 characters where possible.
18772       - =entitiesplain= ::
18774         Leave entities plain.
18776 - =#+TAGS: TAG1(c1) TAG2(c2)= ::
18778   #+cindex: @samp{TAGS}, keyword
18779   #+vindex: org-tag-alist
18780   These lines (several such lines are allowed) specify the valid tags
18781   in this file, and (potentially) the corresponding /fast tag
18782   selection/ keys.  The corresponding variable is ~org-tag-alist~.
18784 - =#+TODO:=, =#+SEQ_TODO:=, =#+TYP_TODO:= ::
18786   #+cindex: @samp{SEQ_TODO}, keyword
18787   #+cindex: @samp{TODO}, keyword
18788   #+cindex: @samp{TYP_TODO}, keyword
18789   #+vindex: org-todo-keywords
18790   These lines set the TODO keywords and their interpretation in the
18791   current file.  The corresponding variable is ~org-todo-keywords~.
18793 ** The Very Busy {{{kbd(C-c C-c)}}} Key
18794 :PROPERTIES:
18795 :DESCRIPTION: When in doubt, press @kbd{C-c C-c}.
18796 :END:
18797 #+kindex: C-c C-c
18798 #+cindex: @kbd{C-c C-c}, overview
18800 The {{{kbd(C-c C-c)}}} key in Org serves many purposes depending on
18801 the context.  It is probably the most over-worked, multi-purpose key
18802 combination in Org.  Its uses are well documented throughout this
18803 manual, but here is a consolidated list for easy reference.
18805 - If any highlights shown in the buffer from the creation of a sparse
18806   tree, or from clock display, remove such highlights.
18808 - If point is in one of the special =KEYWORD= lines, scan the buffer
18809   for these lines and update the information.  Also reset the Org file
18810   cache used to temporary store the contents of URLs used as values
18811   for keywords like =SETUPFILE=.
18813 - If point is inside a table, realign the table.  The table realigns
18814   even if automatic table editor is turned off.
18816 - If point is on a =TBLFM= keyword, re-apply the formulas to the
18817   entire table.
18819 - If the current buffer is a capture buffer, close the note and file
18820   it.  With a prefix argument, also jump to the target location after
18821   saving the note.
18823 - If point is on a =<<<target>>>=, update radio targets and
18824   corresponding links in this buffer.
18826 - If point is on a property line or at the start or end of a property
18827   drawer, offer property commands.
18829 - If point is at a footnote reference, go to the corresponding
18830   definition, and /vice versa/.
18832 - If point is on a statistics cookie, update it.
18834 - If point is in a plain list item with a checkbox, toggle the status
18835   of the checkbox.
18837 - If point is on a numbered item in a plain list, renumber the ordered
18838   list.
18840 - If point is on the =#+BEGIN= line of a dynamic block, the block is
18841   updated.
18843 - If point is at a timestamp, fix the day name in the timestamp.
18845 ** A Cleaner Outline View
18846 :PROPERTIES:
18847 :DESCRIPTION: Getting rid of leading stars in the outline.
18848 :ALT_TITLE: Clean View
18849 :END:
18850 #+cindex: hiding leading stars
18851 #+cindex: dynamic indentation
18852 #+cindex: odd-levels-only outlines
18853 #+cindex: clean outline view
18855 Org's default outline with stars and no indents can become too
18856 cluttered for short documents.  For /book-like/ long documents, the
18857 effect is not as noticeable.  Org provides an alternate stars and
18858 indentation scheme, as shown on the right in the following table.  It
18859 uses only one star and indents text to line with the heading:
18861 #+begin_example
18862 ,* Top level headline             |    * Top level headline
18863 ,** Second level                  |      * Second level
18864 ,*** Third level                  |        * Third level
18865     some text                    |          some text
18866 ,*** Third level                  |        * Third level
18867     more text                    |          more text
18868 ,* Another top level headline     |    * Another top level headline
18869 #+end_example
18871 #+cindex: Indent mode
18872 #+findex: org-indent-mode
18873 To turn this mode on, use the minor mode, ~org-indent-mode~.  Text
18874 lines that are not headlines are prefixed with spaces to vertically
18875 align with the headline text[fn:148].
18877 #+vindex: org-indent-indentation-per-level
18878 To make more horizontal space, the headlines are shifted by two stars.
18879 This can be configured by the ~org-indent-indentation-per-level~
18880 variable.  Only one star on each headline is visible, the rest are
18881 masked with the same font color as the background.
18883 Note that turning on ~org-indent-mode~ sets ~org-hide-leading-stars~
18884 to ~t~ and ~org-adapt-indentation~ to ~nil~.
18886 #+vindex: org-startup-indented
18887 To globally turn on ~org-indent-mode~ for all files, customize the
18888 variable ~org-startup-indented~.
18890 To turn on indenting for individual files, use =STARTUP= keyword as
18891 follows:
18893 : #+STARTUP: indent
18895 Indent on startup makes Org use hard spaces to align text with
18896 headings as shown in examples below.
18898 - /Indentation of text below headlines/ ::
18900   Indent text to align with the headline.
18902   #+begin_example
18903   ,*** Third level
18904       more text, now indented
18905   #+end_example
18907   #+vindex: org-adapt-indentation
18908   Org supports this with paragraph filling, line wrapping, and
18909   structure editing, preserving or adapting the indentation as
18910   appropriate[fn:149].
18912 - /Hiding leading stars/ ::
18914   #+vindex: org-hide-leading-stars
18915   Org can make leading stars invisible.  For global preference,
18916   configure the variable ~org-hide-leading-stars~.  For per-file
18917   preference, use these file =STARTUP= options:
18919   #+begin_example
18920   ,#+STARTUP: hidestars
18921   ,#+STARTUP: showstars
18922   #+end_example
18924   With stars hidden, the tree is shown as:
18926   #+begin_example
18927   ,* Top level headline
18928    ,* Second level
18929     ,* Third level
18930     ...
18931   #+end_example
18933   #+vindex: org-hide, face
18934   Because Org makes the font color the same as the background color
18935   to hide to stars, sometimes ~org-hide~ face may need tweaking to
18936   get the effect right.  For some black and white combinations,
18937   ~grey90~ on a white background might mask the stars better.
18939 - /Odd levels/ ::
18941   #+vindex: org-odd-levels-only
18942   Using stars for only odd levels, 1, 3, 5, ..., can also clean up the
18943   clutter.  This removes two stars from each level[fn:150].  For Org
18944   to properly handle this cleaner structure during edits and exports,
18945   configure the variable ~org-odd-levels-only~.  To set this per-file,
18946   use either one of the following lines:
18948   #+begin_example
18949   ,#+STARTUP: odd
18950   ,#+STARTUP: oddeven
18951   #+end_example
18953   To switch between single and double stars layouts, use {{{kbd(M-x
18954   org-convert-to-odd-levels)}}} and {{{kbd(M-x
18955   org-convert-to-oddeven-levels)}}}.
18957 ** Dynamic Headline Numbering
18958 :PROPERTIES:
18959 :DESCRIPTION: Display and update outline numbering.
18960 :END:
18962 #+cindex: Org Num mode
18963 #+cindex: number headlines
18964 The Org Num minor mode, toggled with {{{kbd(M-x org-num-mode)}}},
18965 displays on top of headlines.  It also updates numbering automatically
18966 upon changes to the structure of the document.
18968 #+vindex: org-num-max-level
18969 #+vindex: org-num-skip-tags
18970 #+vindex: org-num-skip-commented
18971 #+vindex: org-num-skip-unnumbered
18972 By default, all headlines are numbered.  You can limit numbering to
18973 specific headlines according to their level, tags, =COMMENT= keyword,
18974 or =UNNUMBERED= property.  Set ~org-num-max-level~,
18975 ~org-num-skip-tags~, ~org-num-skip-commented~,
18976 ~org-num-skip-unnumbered~, or ~org-num-skip-footnotes~ accordingly.
18978 #+vindex: org-num-skip-footnotes
18979 If ~org-num-skip-footnotes~ is non-~nil~, footnotes sections (see
18980 [[*Creating Footnotes]]) are not numbered either.
18982 #+vindex: org-num-face
18983 #+vindex: org-num-format-function
18984 You can control how the numbering is displayed by setting
18985 ~org-num-face~ and ~org-num-format-function~.
18987 ** Using Org on a TTY
18988 :PROPERTIES:
18989 :DESCRIPTION: Using Org on a tty.
18990 :ALT_TITLE: TTY Keys
18991 :END:
18992 #+cindex: tty key bindings
18994 Org provides alternative key bindings for TTY and modern mobile
18995 devices that cannot perform movement commands on point and key
18996 bindings with modifier keys.  Some of these workarounds may be more
18997 cumbersome than necessary.  Users should look into customizing these
18998 further based on their usage needs.  For example, the normal
18999 {{{kbd(S-<cursor>)}}} for editing timestamp might be better with
19000 {{{kbd(C-c .)}}} chord.
19002 #+attr_texinfo: :columns 0.2 0.28 0.15 0.21
19003 | Default              | Alternative 1            | Speed key    | Alternative 2        |
19004 |----------------------+--------------------------+--------------+----------------------|
19005 | {{{kbd(S-TAB)}}}     | {{{kbd(C-u TAB)}}}       | {{{kbd(C)}}} |                      |
19006 | {{{kbd(M-LEFT)}}}    | {{{kbd(C-c C-x l)}}}     | {{{kbd(l)}}} | {{{kbd(Esc LEFT)}}}  |
19007 | {{{kbd(M-S-LEFT)}}}  | {{{kbd(C-c C-x L)}}}     | {{{kbd(L)}}} |                      |
19008 | {{{kbd(M-RIGHT)}}}   | {{{kbd(C-c C-x r)}}}     | {{{kbd(r)}}} | {{{kbd(Esc RIGHT)}}} |
19009 | {{{kbd(M-S-RIGHT)}}} | {{{kbd(C-c C-x R)}}}     | {{{kbd(R)}}} |                      |
19010 | {{{kbd(M-UP)}}}      | {{{kbd(C-c C-x u)}}}     |              | {{{kbd(Esc UP)}}}    |
19011 | {{{kbd(M-S-UP)}}}    | {{{kbd(C-c C-x U)}}}     | {{{kbd(U)}}} |                      |
19012 | {{{kbd(M-DOWN)}}}    | {{{kbd(C-c C-x d)}}}     |              | {{{kbd(Esc DOWN)}}}  |
19013 | {{{kbd(M-S-DOWN)}}}  | {{{kbd(C-c C-x D)}}}     | {{{kbd(D)}}} |                      |
19014 | {{{kbd(S-RET)}}}     | {{{kbd(C-c C-x c)}}}     |              |                      |
19015 | {{{kbd(M-RET)}}}     | {{{kbd(C-c C-x m)}}}     |              | {{{kbd(Esc RET)}}}   |
19016 | {{{kbd(M-S-RET)}}}   | {{{kbd(C-c C-x M)}}}     |              |                      |
19017 | {{{kbd(S-LEFT)}}}    | {{{kbd(C-c LEFT)}}}      |              |                      |
19018 | {{{kbd(S-RIGHT)}}}   | {{{kbd(C-c RIGHT)}}}     |              |                      |
19019 | {{{kbd(S-UP)}}}      | {{{kbd(C-c UP)}}}        |              |                      |
19020 | {{{kbd(S-DOWN)}}}    | {{{kbd(C-c DOWN)}}}      |              |                      |
19021 | {{{kbd(C-S-LEFT)}}}  | {{{kbd(C-c C-x LEFT)}}}  |              |                      |
19022 | {{{kbd(C-S-RIGHT)}}} | {{{kbd(C-c C-x RIGHT)}}} |              |                      |
19024 ** Context Dependent Documentation
19025 :PROPERTIES:
19026 :DESCRIPTION: Read documentation about current syntax.
19027 :ALT_TITLE: Documentation Access
19028 :END:
19029 #+cindex: documentation
19030 #+cindex: Info
19032 #+findex: org-info-find-node
19033 #+kindex: C-c C-x I
19034 {{{kbd(C-c C-x I)}}} in an Org file tries to open a suitable section
19035 of the Org manual depending on the syntax at point.  For example,
19036 using it on a headline displays "Document Structure" section.
19038 {{{kbd(q)}}} closes the Info window.
19040 ** Interaction with Other Packages
19041 :PROPERTIES:
19042 :DESCRIPTION: With other Emacs packages.
19043 :ALT_TITLE: Interaction
19044 :END:
19045 #+cindex: packages, interaction with other
19047 Org's compatibility and the level of interaction with other Emacs
19048 packages are documented here.
19050 *** Packages that Org cooperates with
19051 :PROPERTIES:
19052 :DESCRIPTION: Packages Org cooperates with.
19053 :ALT_TITLE: Cooperation
19054 :END:
19056 - =calc.el= by Dave Gillespie ::
19057   #+cindex: @file{calc.el}
19059   Org uses the Calc package for implementing spreadsheet functionality
19060   in its tables (see [[*The Spreadsheet]]).  Org also uses Calc for
19061   embedded calculations.  See [[info:calc::Embedded Mode][GNU Emacs Calc Manual]].
19063 - =constants.el= by Carsten Dominik ::
19064   #+cindex: @file{constants.el}
19065   #+vindex: org-table-formula-constants
19067   Org can use names for constants in formulas in tables.  Org can also
19068   use calculation suffixes for units, such as =M= for =Mega=.  For
19069   a standard collection of such constants, install the =constants=
19070   package.  Install version 2.0 of this package, available at
19071   [[http://www.astro.uva.nl/~dominik/Tools]].  Org checks if the function
19072   ~constants-get~ has been autoloaded.  Installation instructions are
19073   in the file =constants.el=.
19075 - =cdlatex.el= by Carsten Dominik ::
19076   #+cindex: @file{cdlatex.el}
19078   Org mode can make use of the CDLaTeX package to efficiently enter
19079   LaTeX fragments into Org files.  See [[*Using CDLaTeX to enter math]].
19081 - =imenu.el= by Ake Stenhoff and Lars Lindberg ::
19082   #+cindex: @file{imenu.el}
19084   Imenu creates dynamic menus based on an index of items in a file.
19085   Org mode supports Imenu menus.  Enable it with a mode hook as
19086   follows:
19088   #+begin_src emacs-lisp
19089   (add-hook 'org-mode-hook
19090             (lambda () (imenu-add-to-menubar "Imenu")))
19091   #+end_src
19093   #+vindex: org-imenu-depth
19094   By default the index is two levels deep---you can modify the
19095   depth using the option ~org-imenu-depth~.
19097 - =speedbar.el= by Eric\nbsp{}M.\nbsp{}Ludlam ::
19098   #+cindex: @file{speedbar.el}
19100   Speedbar package creates a special Emacs frame for displaying files
19101   and index items in files.  Org mode supports Speedbar; users can
19102   drill into Org files directly from the Speedbar.  The {{{kbd(<)}}}
19103   in the Speedbar frame tweaks the agenda commands to that file or to
19104   a subtree.
19106 - =table.el= by Takaaki Ota ::
19107   #+cindex: table editor, @file{table.el}
19108   #+cindex: @file{table.el}
19110   Complex ASCII tables with automatic line wrapping, column- and
19111   row-spanning, and alignment can be created using the Emacs table
19112   package by Takaaki Ota.  Org mode recognizes such tables and exports
19113   them properly.  {{{kbd(C-c ')}}} to edit these tables in a special
19114   buffer, much like Org's code blocks.  Because of interference with
19115   other Org mode functionality, Takaaki Ota tables cannot be edited
19116   directly in the Org buffer.
19118   - {{{kbd(C-c ')}}} (~org-edit-special~) ::
19120     #+kindex: C-c '
19121     #+findex: org-edit-special
19122     Edit a =table.el= table.  Works when point is in a =table.el=
19123     table.
19125   - {{{kbd(C-c ~​)}}} (~org-table-create-with-table.el~) ::
19127     #+kindex: C-c ~
19128     #+findex: org-table-create-with-table.el
19129     Insert a =table.el= table.  If there is already a table at point,
19130     this command converts it between the =table.el= format and the Org
19131     mode format.  See the documentation string of the command
19132     ~org-convert-table~ for the restrictions under which this is
19133     possible.
19135 *** Packages that conflict with Org mode
19136 :PROPERTIES:
19137 :DESCRIPTION: Packages that lead to conflicts.
19138 :ALT_TITLE: Conflicts
19139 :END:
19141 #+cindex: shift-selection-mode
19142 #+vindex: org-support-shift-select
19143 In Emacs, ~shift-selection-mode~ combines motions of point with shift
19144 key to enlarge regions.  Emacs sets this mode by default.  This
19145 conflicts with Org's use of {{{kbd(S-<cursor>)}}} commands to change
19146 timestamps, TODO keywords, priorities, and item bullet types, etc.
19147 Since {{{kbd(S-<cursor>)}}} commands outside of specific contexts do
19148 not do anything, Org offers the variable ~org-support-shift-select~
19149 for customization.  Org mode accommodates shift selection by (i)
19150 making it available outside of the special contexts where special
19151 commands apply, and (ii) extending an existing active region even if
19152 point moves across a special context.
19154 - =cua.el= by Kim\nbsp{}F.\nbsp{}Storm ::
19156   #+cindex: @file{cua.el}
19157   #+vindex: org-replace-disputed-keys
19158   Org key bindings conflict with {{{kbd(S-<cursor>)}}} keys used by
19159   CUA mode.  For Org to relinquish these bindings to CUA mode,
19160   configure the variable ~org-replace-disputed-keys~.  When set, Org
19161   moves the following key bindings in Org files, and in the agenda
19162   buffer---but not during date selection.
19164   #+attr_texinfo: :columns 0.4 0.4
19165   | {{{kbd(S-UP)}}}      \rArr{}  {{{kbd(M-p)}}}   | {{{kbd(S-DOWN)}}}     \rArr{}  {{{kbd(M-n)}}}   |
19166   | {{{kbd(S-LEFT)}}}    \rArr{}  {{{kbd(M--)}}}   | {{{kbd(S-RIGHT)}}}    \rArr{}  {{{kbd(M-+)}}}   |
19167   | {{{kbd(C-S-LEFT)}}}  \rArr{}  {{{kbd(M-S--)}}} | {{{kbd(C-S-RIGHT)}}}  \rArr{}  {{{kbd(M-S-+)}}} |
19169   #+vindex: org-disputed-keys
19170   Yes, these are unfortunately more difficult to remember.  If you
19171   want to have other replacement keys, look at the variable
19172   ~org-disputed-keys~.
19174 - =ecomplete.el= by Lars Magne Ingebrigtsen ::
19176   #+cindex: @file{ecomplete.el}
19177   Ecomplete provides "electric" address completion in address header
19178   lines in message buffers.  Sadly Orgtbl mode cuts Ecomplete's power
19179   supply: no completion happens when Orgtbl mode is enabled in message
19180   buffers while entering text in address header lines.  If one wants
19181   to use ecomplete one should /not/ follow the advice to automagically
19182   turn on Orgtbl mode in message buffers (see [[*The Orgtbl Minor Mode]]),
19183   but instead---after filling in the message headers---turn on Orgtbl
19184   mode manually when needed in the messages body.
19186 - =filladapt.el= by Kyle Jones ::
19188   #+cindex: @file{filladapt.el}
19189   Org mode tries to do the right thing when filling paragraphs, list
19190   items and other elements.  Many users reported problems using both
19191   =filladapt.el= and Org mode, so a safe thing to do is to disable
19192   filladapt like this:
19194   #+begin_src emacs-lisp
19195   (add-hook 'org-mode-hook 'turn-off-filladapt-mode)
19196   #+end_src
19198 - =viper.el= by Michael Kifer ::
19199   #+cindex: @file{viper.el}
19200   #+kindex: C-c /
19202   Viper uses {{{kbd(C-c /)}}} and therefore makes this key not access
19203   the corresponding Org mode command ~org-sparse-tree~.  You need to
19204   find another key for this command, or override the key in
19205   ~viper-vi-global-user-map~ with
19207   #+begin_src emacs-lisp
19208   (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
19209   #+end_src
19211 - =windmove.el= by Hovav Shacham ::
19212   #+cindex: @file{windmove.el}
19214   This package also uses the {{{kbd(S-<cursor>)}}} keys, so everything
19215   written in the paragraph above about CUA mode also applies here.  If
19216   you want to make the windmove function active in locations where Org
19217   mode does not have special functionality on {{{kbd(S-<cursor>)}}},
19218   add this to your configuration:
19220   #+begin_src emacs-lisp
19221   ;; Make windmove work in Org mode:
19222   (add-hook 'org-shiftup-final-hook 'windmove-up)
19223   (add-hook 'org-shiftleft-final-hook 'windmove-left)
19224   (add-hook 'org-shiftdown-final-hook 'windmove-down)
19225   (add-hook 'org-shiftright-final-hook 'windmove-right)
19226   #+end_src
19228 - =yasnippet.el= ::
19230   #+cindex: @file{yasnippet.el}
19231   The way Org mode binds the {{{kbd(TAB)}}} key (binding to ~[tab]~
19232   instead of ~"\t"~) overrules YASnippet's access to this key.  The
19233   following code fixed this problem:
19235   #+begin_src emacs-lisp
19236   (add-hook 'org-mode-hook
19237             (lambda ()
19238               (setq-local yas/trigger-key [tab])
19239               (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
19240   #+end_src
19242   The latest version of YASnippet does not play well with Org mode.
19243   If the above code does not fix the conflict, start by defining
19244   the following function:
19246   #+begin_src emacs-lisp
19247   (defun yas/org-very-safe-expand ()
19248     (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
19249   #+end_src
19251   Then, tell Org mode to use that function:
19253   #+begin_src emacs-lisp
19254   (add-hook 'org-mode-hook
19255             (lambda ()
19256               (make-variable-buffer-local 'yas/trigger-key)
19257               (setq yas/trigger-key [tab])
19258               (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
19259               (define-key yas/keymap [tab] 'yas/next-field)))
19260   #+end_src
19262 ** Org Crypt
19263 :PROPERTIES:
19264 :DESCRIPTION: Encrypting Org files.
19265 :END:
19267 Org Crypt encrypts the text of an entry, but not the headline, or
19268 properties.  Behind the scene, it uses the Emacs EasyPG library to
19269 encrypt and decrypt files.
19271 #+vindex: org-crypt-tag-matcher
19272 Any text below a headline that has a =crypt= tag is automatically
19273 encrypted when the file is saved.  To use a different tag, customize
19274 the ~org-crypt-tag-matcher~ setting.
19276 Here is a suggestion for Org Crypt settings in Emacs init file:
19278 #+begin_src emacs-lisp
19279 (require 'org-crypt)
19280 (org-crypt-use-before-save-magic)
19281 (setq org-tags-exclude-from-inheritance '("crypt"))
19283 (setq org-crypt-key nil)
19284 ;; GPG key to use for encryption
19285 ;; Either the Key ID or set to nil to use symmetric encryption.
19287 (setq auto-save-default nil)
19288 ;; Auto-saving does not cooperate with org-crypt.el: so you need to
19289 ;; turn it off if you plan to use org-crypt.el quite often.  Otherwise,
19290 ;; you'll get an (annoying) message each time you start Org.
19292 ;; To turn it off only locally, you can insert this:
19294 ;; # -*- buffer-auto-save-file-name: nil; -*-
19295 #+end_src
19297 It's possible to use different keys for different headings by
19298 specifying the respective key as property =CRYPTKEY=, e.g.:
19300 #+begin_example
19301 ,* Totally secret :crypt:
19302   :PROPERTIES:
19303   :CRYPTKEY: 0x0123456789012345678901234567890123456789
19304   :END:
19305 #+end_example
19307 Excluding the =crypt= tag from inheritance prevents already encrypted
19308 text from being encrypted again.
19310 ** Org Mobile
19311 :PROPERTIES:
19312 :DESCRIPTION: Viewing and capture on a mobile device.
19313 :END:
19314 #+cindex: smartphone
19316 Org Mobile is a protocol for synchronizing Org files between Emacs and
19317 other applications, e.g., on mobile devices.  It enables offline-views
19318 and capture support for an Org mode system that is rooted on a "real"
19319 computer.  The external application can also record changes to
19320 existing entries.
19322 This appendix describes Org's support for agenda view formats
19323 compatible with Org Mobile.  It also describes synchronizing changes,
19324 such as to notes, between the mobile application and the computer.
19326 To change tags and TODO states in the mobile application, first
19327 customize the variables ~org-todo-keywords~ and ~org-tag-alist~.
19328 These should cover all the important tags and TODO keywords, even if
19329 Org files use only some of them.  Though the mobile application is
19330 expected to support in-buffer settings, it is required to understand
19331 TODO states /sets/ (see [[*Setting up keywords for individual files]]) and
19332 /mutually exclusive/ tags (see [[*Setting Tags]]) only for those set in
19333 these variables.
19335 *** Setting up the staging area
19336 :PROPERTIES:
19337 :DESCRIPTION: For the mobile device.
19338 :END:
19340 #+vindex: org-mobile-directory
19341 The mobile application needs access to a file directory on
19342 a server[fn:151] to interact with Emacs.  Pass its location through
19343 the ~org-mobile-directory~ variable.  If you can mount that directory
19344 locally just set the variable to point to that directory:
19346 #+begin_src emacs-lisp
19347 (setq org-mobile-directory "~/orgmobile/")
19348 #+end_src
19350 Alternatively, by using TRAMP (see [[info:tramp][TRAMP User Manual]]),
19351 ~org-mobile-directory~ may point to a remote directory accessible
19352 through, for example, SSH, SCP, or DAVS:
19354 #+begin_src emacs-lisp
19355 (setq org-mobile-directory "/davs:user@remote.host:/org/webdav/")
19356 #+end_src
19358 #+vindex: org-mobile-encryption
19359 With a public server, consider encrypting the files.  Org also
19360 requires OpenSSL installed on the local computer.  To turn on
19361 encryption, set the same password in the mobile application and in
19362 Emacs.  Set the password in the variable
19363 ~org-mobile-use-encryption~[fn:152].  Note that even after the mobile
19364 application encrypts the file contents, the file name remains visible
19365 on the file systems of the local computer, the server, and the mobile
19366 device.
19368 *** Pushing to the mobile application
19369 :PROPERTIES:
19370 :DESCRIPTION: Uploading Org files and agendas.
19371 :END:
19373 #+findex: org-mobile-push
19374 #+vindex: org-mobile-files
19375 The command ~org-mobile-push~ copies files listed in
19376 ~org-mobile-files~ into the staging area.  Files include agenda files
19377 (as listed in ~org-agenda-files~).  Customize ~org-mobile-files~ to
19378 add other files.  File names are staged with paths relative to
19379 ~org-directory~, so all files should be inside this directory[fn:153].
19381 Push creates a special Org file =agendas.org= with custom agenda views
19382 defined by the user[fn:154].
19384 Finally, Org writes the file =index.org=, containing links to other
19385 files.  The mobile application reads this file first from the server
19386 to determine what other files to download for agendas.  For faster
19387 downloads, it is expected to only read files whose checksums[fn:155]
19388 have changed.
19390 *** Pulling from the mobile application
19391 :PROPERTIES:
19392 :DESCRIPTION: Integrating captured and flagged items.
19393 :END:
19395 #+findex: org-mobile-pull
19396 The command ~org-mobile-pull~ synchronizes changes with the server.
19397 More specifically, it first pulls the Org files for viewing.  It then
19398 appends captured entries and pointers to flagged or changed entries to
19399 the file =mobileorg.org= on the server.  Org ultimately integrates its
19400 data in an inbox file format, through the following steps:
19403    #+vindex: org-mobile-inbox-for-pull
19404    Org moves all entries found in =mobileorg.org=[fn:156] and appends
19405    them to the file pointed to by the variable
19406    ~org-mobile-inbox-for-pull~.  It should reside neither in the
19407    staging area nor on the server.  Each captured entry and each
19408    editing event is a top-level entry in the inbox file.
19411    #+cindex: @samp{FLAGGED}, tag
19412    After moving the entries, Org processes changes to the shared
19413    files.  Some of them are applied directly and without user
19414    interaction.  Examples include changes to tags, TODO state,
19415    headline and body text.  Entries requiring further action are
19416    tagged as =FLAGGED=.  Org marks entries with problems with an error
19417    message in the inbox.  They have to be resolved manually.
19419 3. Org generates an agenda view for flagged entries for user
19420    intervention to clean up.  For notes stored in flagged entries, Org
19421    displays them in the echo area when point is on the corresponding
19422    agenda item.
19424    - {{{kbd(?)}}} ::
19426      Pressing {{{kbd(?)}}} displays the entire flagged note in another
19427      window.  Org also pushes it to the kill ring.  To store flagged
19428      note as a normal note, use {{{kbd(? z C-y C-c C-c)}}}.  Pressing
19429      {{{kbd(?)}}} twice does these things: first it removes the
19430      =FLAGGED= tag; second, it removes the flagged note from the
19431      property drawer; third, it signals that manual editing of the
19432      flagged entry is now finished.
19434 #+kindex: ? @r{(Agenda dispatcher)}
19435 From the agenda dispatcher, {{{kbd(?)}}} returns to the view to finish
19436 processing flagged entries.  Note that these entries may not be the
19437 most recent since the mobile application searches files that were last
19438 pulled.  To get an updated agenda view with changes since the last
19439 pull, pull again.
19441 ** Org Syntax
19442 :PROPERTIES:
19443 :DESCRIPTION: Formal description of Org's syntax.
19444 :END:
19446 A reference document providing a formal description of Org's syntax is
19447 available as [[https://orgmode.org/worg/dev/org-syntax.html][a draft on Worg]], written and maintained by Nicolas
19448 Goaziou.  It defines Org's core internal concepts such as "headlines",
19449 "sections", "affiliated keywords", "(greater) elements" and "objects".
19450 Each part of an Org document belongs to one of the previous
19451 categories.
19453 To explore the abstract structure of an Org buffer, run this in
19454 a buffer:
19456 : M-: (org-element-parse-buffer) <RET>
19458 #+texinfo: @noindent
19459 It outputs a list containing the buffer's content represented as an
19460 abstract structure.  The export engine relies on the information
19461 stored in this list.  Most interactive commands---e.g., for structure
19462 editing---also rely on the syntactic meaning of the surrounding
19463 context.
19465 #+cindex: syntax checker
19466 #+cindex: linter
19467 #+findex: org-lint
19468 You can probe the syntax of your documents with the command
19470 : M-x org-lint <RET>
19472 #+texinfo: @noindent
19473 It runs a number of checks to find common mistakes.  It then displays
19474 their location in a dedicated buffer, along with a description and
19475 a "trust level", since false-positive are possible.  From there, you
19476 can operate on the reports with the following keys:
19478 #+attr_texinfo: :columns 0.22 0.78
19479 | {{{kbd(C-j)}}}, {{{kbd(TAB)}}} | Display the offending line                  |
19480 | {{{kbd(RET)}}}                 | Move point to the offending line            |
19481 | {{{kbd(g)}}}                   | Check the document again                    |
19482 | {{{kbd(h)}}}                   | Hide all reports from the same checker      |
19483 | {{{kbd(i)}}}                   | Also remove them from all subsequent checks |
19484 | {{{kbd(S)}}}                   | Sort reports by the column at point         |
19486 * Hacking
19487 :PROPERTIES:
19488 :DESCRIPTION: How to hack your way around.
19489 :APPENDIX: t
19490 :END:
19491 #+cindex: hacking
19493 This appendix describes some ways a user can extend the functionality
19494 of Org.
19496 ** Hooks
19497 :PROPERTIES:
19498 :DESCRIPTION: How to reach into Org's internals.
19499 :END:
19500 #+cindex: hooks
19502 Org has a large number of hook variables for adding functionality.
19503 This appendix illustrates using a few.  A complete list of hooks with
19504 documentation is maintained by the Worg project at
19505 https://orgmode.org/worg/doc.html#hooks.
19507 ** Add-on Packages
19508 :PROPERTIES:
19509 :DESCRIPTION: Available extensions.
19510 :END:
19511 #+cindex: add-on packages
19513 Various authors wrote a large number of add-on packages for Org.
19515 These packages are not part of Emacs, but they are distributed as
19516 contributed packages with the separate release available at
19517 https://orgmode.org.  See the =contrib/README= file in the source code
19518 directory for a list of contributed files.  Worg page with more
19519 information is at: https://orgmode.org/worg/org-contrib/.
19521 ** Adding Hyperlink Types
19522 :PROPERTIES:
19523 :DESCRIPTION: New custom link types.
19524 :END:
19525 #+cindex: hyperlinks, adding new types
19527 Org has many built-in hyperlink types (see [[*Hyperlinks]]), and an
19528 interface for adding new link types.  The following example shows the
19529 process of adding Org links to Unix man pages, which look like this
19531 : [[man:printf][The printf manual]]
19533 #+texinfo: @noindent
19534 The following =org-man.el= file implements it
19536 #+begin_src emacs-lisp
19537 ;;; org-man.el - Support for links to man pages in Org mode
19538 (require 'org)
19540 (org-link-set-parameters "man"
19541                          :follow org-man-command
19542                          :export #'org-man-export
19543                          :store #'org-man-store-link)
19545 (defcustom org-man-command 'man
19546   "The Emacs command to be used to display a man page."
19547   :group 'org-link
19548   :type '(choice (const man) (const woman)))
19550 (defun org-man-store-link ()
19551   "Store a link to a man page."
19552   (when (memq major-mode '(Man-mode woman-mode))
19553     ;; This is a man page, we do make this link.
19554     (let* ((page (org-man-get-page-name))
19555            (link (concat "man:" page))
19556            (description (format "Man page for %s" page)))
19557       (org-store-link-props
19558        :type "man"
19559        :link link
19560        :description description))))
19562 (defun org-man-get-page-name ()
19563   "Extract the page name from the buffer name."
19564   ;; This works for both `Man-mode' and `woman-mode'.
19565   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
19566       (match-string 1 (buffer-name))
19567     (error "Cannot create link to this man page")))
19569 (defun org-man-export (link description format)
19570   "Export a man page link from Org files."
19571   (let ((path (format "http://man.he.net/?topic=%s&section=all" link))
19572         (desc (or description link)))
19573     (pcase format
19574       (`html (format "<a target=\"_blank\" href=\"%s\">%s</a>" path desc))
19575       (`latex (format "\\href{%s}{%s}" path desc))
19576       (`texinfo (format "@uref{%s,%s}" path desc))
19577       (`ascii (format "%s (%s)" desc path))
19578       (t path))))
19580 (provide 'org-man)
19581 ;;; org-man.el ends here
19582 #+end_src
19584 #+texinfo: @noindent
19585 To activate links to man pages in Org, enter this in the Emacs init
19586 file:
19588 #+begin_src emacs-lisp
19589 (require 'org-man)
19590 #+end_src
19592 #+texinfo: @noindent
19593 A review of =org-man.el=:
19595 1. First, =(require 'org)= ensures =org.el= is loaded.
19599    #+findex: org-link-set-parameters
19600    #+vindex: org-link-parameters
19601    Then ~org-link-set-parameters~ defines a new link type with =man=
19602    prefix and associates functions for following, exporting and
19603    storing such links.  See the variable ~org-link-parameters~ for
19604    a complete list of possible associations.
19606 3. The rest of the file implements necessary variables and functions.
19608    For example, ~org-man-store-link~ is responsible for storing a link
19609    when ~org-store-link~ (see [[*Handling Links]]) is called from a buffer
19610    displaying a man page.  It first checks if the ~major-mode~ is
19611    appropriate.  If check fails, the function returns ~nil~, which
19612    means it isn't responsible for creating a link to the current
19613    buffer.  Otherwise the function makes a link string by combining
19614    the =man:= prefix with the man topic.  It also provides a default
19615    description.  The function ~org-insert-link~ can insert it back
19616    into an Org buffer later on.
19618 ** Adding Export Back-ends
19619 :PROPERTIES:
19620 :DESCRIPTION: How to write new export back-ends.
19621 :END:
19622 #+cindex: Export, writing back-ends
19624 Org's export engine makes it easy for writing new back-ends.  The
19625 framework on which the engine was built makes it easy to derive new
19626 back-ends from existing ones.
19628 #+findex: org-export-define-backend
19629 #+findex: org-export-define-derived-backend
19630 The two main entry points to the export engine are:
19631 ~org-export-define-backend~ and ~org-export-define-derived-backend~.
19632 To grok these functions, see =ox-latex.el= for an example of defining
19633 a new back-end from scratch, and =ox-beamer.el= for an example of
19634 deriving from an existing engine.
19636 For creating a new back-end from scratch, first set its name as
19637 a symbol in an alist consisting of elements and export functions.  To
19638 make the back-end visible to the export dispatcher, set ~:menu-entry~
19639 keyword.  For export options specific to this back-end, set the
19640 ~:options-alist~.
19642 For creating a new back-end from an existing one, set
19643 ~:translate-alist~ to an alist of export functions.  This alist
19644 replaces the parent back-end functions.
19646 For complete documentation, see [[https://orgmode.org/worg/dev/org-export-reference.html][the Org Export Reference on Worg]].
19648 ** Tables in Arbitrary Syntax
19649 :PROPERTIES:
19650 :DESCRIPTION: Orgtbl for LaTeX and other programs.
19651 :END:
19652 #+cindex: tables, in other modes
19653 #+cindex: lists, in other modes
19654 #+cindex: Orgtbl mode
19656 Due to Org's success in handling tables with Orgtbl, a frequently
19657 requested feature is the use of Org's table functions in other modes,
19658 e.g., LaTeX.  This would be hard to do in a general way without
19659 complicated customization nightmares.  Moreover, that would take Org
19660 away from its simplicity roots that Orgtbl has proven.  There is,
19661 however, an alternate approach to accomplishing the same.
19663 This approach involves implementing a custom /translate/ function that
19664 operates on a native Org /source table/ to produce a table in another
19665 format.  This strategy would keep the excellently working Orgtbl
19666 simple and isolate complications, if any, confined to the translate
19667 function.  To add more alien table formats, we just add more translate
19668 functions.  Also the burden of developing custom translate functions
19669 for new table formats is in the hands of those who know those formats
19670 best.
19672 *** Radio tables
19673 :PROPERTIES:
19674 :DESCRIPTION: Sending and receiving radio tables.
19675 :END:
19676 #+cindex: radio tables
19678 Radio tables are target locations for translated tables that are not near
19679 their source.  Org finds the target location and inserts the translated
19680 table.
19682 The key to finding the target location is the magic words =BEGIN/END
19683 RECEIVE ORGTBL=.  They have to appear as comments in the current mode.
19684 If the mode is C, then:
19686 #+begin_example
19687 /* BEGIN RECEIVE ORGTBL table_name */
19688 /* END RECEIVE ORGTBL table_name */
19689 #+end_example
19691 At the location of source, Org needs a special line to direct Orgtbl
19692 to translate and to find the target for inserting the translated
19693 table.  For example:
19695 #+cindex: @samp{ORGTBL}, keyword
19696 : #+ORGTBL: SEND table_name translation_function arguments ...
19698 #+texinfo: @noindent
19699 =table_name= is the table's reference name, which is also used in the
19700 receiver lines, and the =translation_function= is the Lisp function
19701 that translates.  This line, in addition, may also contain alternating
19702 key and value arguments at the end.  The translation function gets
19703 these values as a property list.  A few standard parameters are
19704 already recognized and acted upon before the translation function is
19705 called:
19707 - =:skip N= ::
19709   Skip the first N lines of the table.  Hlines do count; include them
19710   if they are to be skipped.
19712 - =:skipcols (n1 n2 ...)= ::
19714   List of columns to be skipped.  First Org automatically discards
19715   columns with calculation marks and then sends the table to the
19716   translator function, which then skips columns as specified in
19717   =skipcols=.
19719 To keep the source table intact in the buffer without being disturbed
19720 when the source file is compiled or otherwise being worked on, use one
19721 of these strategies:
19723 - Place the table in a block comment.  For example, in C mode you
19724   could wrap the table between =/*= and =*/= lines.
19726 - Put the table after an "end" statement.  For example ~\bye~ in TeX
19727   and ~\end{document}~ in LaTeX.
19729 - Comment and un-comment each line of the table during edits.  The
19730   {{{kbd(M-x orgtbl-toggle-comment)}}} command makes toggling easy.
19732 *** A LaTeX example of radio tables
19733 :PROPERTIES:
19734 :DESCRIPTION: Step by step, almost a tutorial.
19735 :ALT_TITLE: A LaTeX example
19736 :END:
19737 #+cindex: @LaTeX{}, and Orgtbl mode
19739 To wrap a source table in LaTeX, use the =comment= environment
19740 provided by =comment.sty=[fn:157].  To activate it, put
19741 ~\usepackage{comment}~ in the document header.  Orgtbl mode inserts
19742 a radio table skeleton[fn:158] with the command {{{kbd(M-x
19743 orgtbl-insert-radio-table)}}}, which prompts for a table name.  For
19744 example, if =salesfigures= is the name, the template inserts:
19746 #+begin_example
19747 % BEGIN RECEIVE ORGTBL salesfigures
19748 % END RECEIVE ORGTBL salesfigures
19749 \begin{comment}
19750 ,#+ORGTBL: SEND salesfigures orgtbl-to-latex
19751 | | |
19752 \end{comment}
19753 #+end_example
19755 #+vindex: LaTeX-verbatim-environments
19756 #+texinfo: @noindent
19757 The line =#+ORGTBL: SEND= tells Orgtbl mode to use the function
19758 ~orgtbl-to-latex~ to convert the table to LaTeX format, then insert
19759 the table at the target (receive) location named =salesfigures=.  Now
19760 the table is ready for data entry.  It can even use spreadsheet
19761 features[fn:159]:
19763 #+begin_example
19764 % BEGIN RECEIVE ORGTBL salesfigures
19765 % END RECEIVE ORGTBL salesfigures
19766 \begin{comment}
19767 ,#+ORGTBL: SEND salesfigures orgtbl-to-latex
19768 | Month | Days | Nr sold | per day |
19769 |-------+------+---------+---------|
19770 | Jan   |   23 |      55 |     2.4 |
19771 | Feb   |   21 |      16 |     0.8 |
19772 | March |   22 |     278 |    12.6 |
19773 ,#+TBLFM: $4=$3/$2;%.1f
19774 % $ (optional extra dollar to keep Font Lock happy, see footnote)
19775 \end{comment}
19776 #+end_example
19778 After editing, {{{kbd(C-c C-c)}}} inserts the translated table at the
19779 target location, between the two marker lines.
19781 For hand-made custom tables, note that the translator needs to skip
19782 the first two lines of the source table.  Also the command has to
19783 /splice/ out the target table without the header and footer.
19785 #+begin_example
19786 \begin{tabular}{lrrr}
19787 Month & \multicolumn{1}{c}{Days} & Nr.\ sold & per day\\
19788 % BEGIN RECEIVE ORGTBL salesfigures
19789 % END RECEIVE ORGTBL salesfigures
19790 \end{tabular}
19792 \begin{comment}
19793 ,#+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
19794 | Month | Days | Nr sold | per day |
19795 |-------+------+---------+---------|
19796 | Jan   |   23 |      55 |     2.4 |
19797 | Feb   |   21 |      16 |     0.8 |
19798 | March |   22 |     278 |    12.6 |
19799 ,#+TBLFM: $4=$3/$2;%.1f
19800 \end{comment}
19801 #+end_example
19803 The LaTeX translator function ~orgtbl-to-latex~ is already part of
19804 Orgtbl mode and uses a =tabular= environment to typeset the table and
19805 marks horizontal lines with ~\hline~.  For additional parameters to
19806 control output, see [[*Translator functions]]:
19808 - =:splice BOOLEAN= ::
19810   When {{{var(BOOLEAN}}} is non-~nil~, return only table body lines;
19811   i.e., not wrapped in =tabular= environment.  Default is ~nil~.
19813 - =:fmt FMT= ::
19815   Format string to warp each field.  It should contain =%s= for the
19816   original field value.  For example, to wrap each field value in
19817   dollar symbol, you could use =:fmt "$%s$"=.  Format can also wrap
19818   a property list with column numbers and formats, for example =:fmt
19819   (2 "$%s$" 4 "%s\\%%")=.  In place of a string, a function of one
19820   argument can be used; the function must return a formatted string.
19822 - =:efmt EFMT= ::
19824   Format numbers as exponentials.  The spec should have =%s= twice for
19825   inserting mantissa and exponent, for example ="%s\\times10^{%s}"=.  This
19826   may also be a property list with column numbers and formats, for
19827   example =:efmt (2 "$%s\\times10^{%s}$" 4 "$%s\\cdot10^{%s}$")=.  After
19828   {{{var(EFMT)}}} has been applied to a value, {{{var(FMT)}}}---see
19829   above---is also applied.  Functions with two arguments can be
19830   supplied instead of strings.  By default, no special formatting is
19831   applied.
19833 *** Translator functions
19834 :PROPERTIES:
19835 :DESCRIPTION: Copy and modify.
19836 :END:
19837 #+cindex: HTML, and Orgtbl mode
19838 #+cindex: translator function
19840 #+findex: orgtbl-to-csv
19841 #+findex: orgtbl-to-tsv
19842 #+findex: orgtbl-to-latex
19843 #+findex: orgtbl-to-html
19844 #+findex: orgtbl-to-texinfo
19845 #+findex: orgtbl-to-unicode
19846 #+findex: orgtbl-to-orgtbl
19847 #+findex: orgtbl-to-generic
19848 Orgtbl mode has built-in translator functions: ~orgtbl-to-csv~
19849 (comma-separated values), ~orgtbl-to-tsv~ (TAB-separated values),
19850 ~orgtbl-to-latex~, ~orgtbl-to-html~, ~orgtbl-to-texinfo~,
19851 ~orgtbl-to-unicode~ and ~orgtbl-to-orgtbl~.  They use the generic
19852 translator, ~orgtbl-to-generic~, which delegates translations to
19853 various export back-ends.
19855 Properties passed to the function through the =ORGTBL SEND= line take
19856 precedence over properties defined inside the function.  For example,
19857 this overrides the default LaTeX line endings, ~\\~, with ~\\[2mm]~:
19859 : #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
19861 For a new language translator, define a converter function.  It can be
19862 a generic function, such as shown in this example.  It marks
19863 a beginning and ending of a table with =!BTBL!= and =!ETBL!=;
19864 a beginning and ending of lines with =!BL!= and =!EL!=; and uses a TAB
19865 for a field separator:
19867 #+begin_src emacs-lisp
19868 (defun orgtbl-to-language (table params)
19869   "Convert the orgtbl-mode TABLE to language."
19870   (orgtbl-to-generic
19871    table
19872    (org-combine-plists
19873     '(:tstart "!BTBL!" :tend "!ETBL!" :lstart "!BL!" :lend "!EL!" :sep "\t")
19874     params)))
19875 #+end_src
19877 #+texinfo: @noindent
19878 The documentation for the ~orgtbl-to-generic~ function shows
19879 a complete list of parameters, each of which can be passed through to
19880 ~orgtbl-to-latex~, ~orgtbl-to-texinfo~, and any other function using
19881 that generic function.
19883 For complicated translations the generic translator function could be
19884 replaced by a custom translator function.  Such a custom function must
19885 take two arguments and return a single string containing the formatted
19886 table.  The first argument is the table whose lines are a list of
19887 fields or the symbol ~hline~.  The second argument is the property
19888 list consisting of parameters specified in the =#+ORGTBL: SEND= line.
19889 Please share your translator functions by posting them to the Org
19890 users mailing list, at mailto:emacs-orgmode@gnu.org.
19892 ** Dynamic Blocks
19893 :PROPERTIES:
19894 :DESCRIPTION: Automatically filled blocks.
19895 :END:
19896 #+cindex: dynamic blocks
19898 Org supports /dynamic blocks/ in Org documents.  They are inserted
19899 with begin and end markers like any other code block, but the contents
19900 are updated automatically by a user function.
19902 #+kindex: C-c C-x x
19903 #+findex: org-dynamic-block-insert-dblock
19904 You can insert a dynamic block with ~org-dynamic-block-insert-dblock~,
19905 which is bound to {{{kbd(C-c C-x x)}}} by default.  For example,
19906 {{{kbd(C-c C-x x c l o c k t a b l e RET)}}} inserts a table that
19907 updates the work time (see [[*Clocking Work Time]]).
19909 Dynamic blocks can have names and function parameters.  The syntax is
19910 similar to source code block specifications:
19912 #+begin_example
19913 ,#+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
19914   ...
19915 ,#+END:
19916 #+end_example
19918 These commands update dynamic blocks:
19920 - {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
19922   #+kindex: C-c C-x C-u
19923   #+findex: org-dblock-update
19924   Update dynamic block at point.
19926 - {{{kbd(C-u C-c C-x C-u)}}} ::
19928   #+kindex: C-u C-c C-x C-u
19929   Update all dynamic blocks in the current file.
19931 Before updating a dynamic block, Org removes content between the
19932 =BEGIN= and =END= markers.  Org then reads the parameters on the
19933 =BEGIN= line for passing to the writer function.  If the function
19934 expects to access the removed content, then Org expects an extra
19935 parameter, =:content=, on the =BEGIN= line.
19937 The syntax for naming a writer function with a dynamic block labelled
19938 =myblock= is: ~org-dblock-write:myblock~.  Parameters come from the
19939 =BEGIN= line.
19941 The following is an example of a dynamic block and a block writer function
19942 that updates the time when the function was last run:
19944 #+begin_example
19945 ,#+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
19946   ...
19947 ,#+END:
19948 #+end_example
19950 #+texinfo: @noindent
19951 The dynamic block's writer function:
19953 #+begin_src emacs-lisp
19954 (defun org-dblock-write:block-update-time (params)
19955   (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
19956     (insert "Last block update at: "
19957             (format-time-string fmt))))
19958 #+end_src
19960 To keep dynamic blocks up-to-date in an Org file, use the function,
19961 ~org-update-all-dblocks~ in hook, such as ~before-save-hook~.  The
19962 ~org-update-all-dblocks~ function does not run if the file is not in
19963 Org mode.
19965 #+findex: org-narrow-to-block
19966 Dynamic blocks, like any other block, can be narrowed with
19967 ~org-narrow-to-block~.
19969 ** Special Agenda Views
19970 :PROPERTIES:
19971 :DESCRIPTION: Customized views.
19972 :END:
19973 #+cindex: agenda views, user-defined
19975 #+vindex: org-agenda-skip-function
19976 #+vindex: org-agenda-skip-function-global
19977 Org provides a special hook to further limit items in agenda views:
19978 ~agenda~, ~agenda*~[fn:160], ~todo~, ~alltodo~, ~tags~, ~tags-todo~,
19979 ~tags-tree~.  Specify a custom function that tests inclusion of every
19980 matched item in the view.  This function can also skip as much as is
19981 needed.
19983 For a global condition applicable to agenda views, use the
19984 ~org-agenda-skip-function-global~ variable.  Org uses a global
19985 condition with ~org-agenda-skip-function~ for custom searching.
19987 This example defines a function for a custom view showing TODO items
19988 with =waiting= status.  Manually this is a multi-step search process,
19989 but with a custom view, this can be automated as follows:
19991 The custom function searches the subtree for the =waiting= tag and
19992 returns ~nil~ on match.  Otherwise it gives the location from where
19993 the search continues.
19995 #+begin_src emacs-lisp
19996 (defun my-skip-unless-waiting ()
19997   "Skip trees that are not waiting"
19998   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
19999     (if (re-search-forward ":waiting:" subtree-end t)
20000         nil          ; tag found, do not skip
20001       subtree-end))) ; tag not found, continue after end of subtree
20002 #+end_src
20004 To use this custom function in a custom agenda command:
20006 #+begin_src emacs-lisp
20007 (org-add-agenda-custom-command
20008  '("b" todo "PROJECT"
20009    ((org-agenda-skip-function 'my-skip-unless-waiting)
20010     (org-agenda-overriding-header "Projects waiting for something: "))))
20011 #+end_src
20013 #+vindex: org-agenda-overriding-header
20014 Note that this also binds ~org-agenda-overriding-header~ to a more
20015 meaningful string suitable for the agenda view.
20017 #+vindex: org-odd-levels-only
20018 #+vindex: org-agenda-skip-function
20019 Search for entries with a limit set on levels for the custom search.
20020 This is a general approach to creating custom searches in Org.  To
20021 include all levels, use =LEVEL>0=[fn:161].  Then to selectively pick
20022 the matched entries, use ~org-agenda-skip-function~, which also
20023 accepts Lisp forms, such as ~org-agenda-skip-entry-if~ and
20024 ~org-agenda-skip-subtree-if~.  For example:
20026 - =(org-agenda-skip-entry-if 'scheduled)= ::
20028   Skip current entry if it has been scheduled.
20030 - =(org-agenda-skip-entry-if 'notscheduled)= ::
20032   Skip current entry if it has not been scheduled.
20034 - =(org-agenda-skip-entry-if 'deadline)= ::
20036   Skip current entry if it has a deadline.
20038 - =(org-agenda-skip-entry-if 'scheduled 'deadline)= ::
20040   Skip current entry if it has a deadline, or if it is scheduled.
20042 - =(org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))= ::
20044   Skip current entry if the TODO keyword is TODO or WAITING.
20046 - =(org-agenda-skip-entry-if 'todo 'done)= ::
20048   Skip current entry if the TODO keyword marks a DONE state.
20050 - =(org-agenda-skip-entry-if 'timestamp)= ::
20052   Skip current entry if it has any timestamp, may also be deadline or
20053   scheduled.
20055 - =(org-agenda-skip-entry-if 'regexp "regular expression")= ::
20057   Skip current entry if the regular expression matches in the entry.
20059 - =(org-agenda-skip-entry-if 'notregexp "regular expression")= ::
20061   Skip current entry unless the regular expression matches.
20063 - =(org-agenda-skip-subtree-if 'regexp "regular expression")= ::
20065   Same as above, but check and skip the entire subtree.
20067 The following is an example of a search for =waiting= without the
20068 special function:
20070 #+begin_src emacs-lisp
20071 (org-add-agenda-custom-command
20072  '("b" todo "PROJECT"
20073    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
20074                                 'regexp ":waiting:"))
20075     (org-agenda-overriding-header "Projects waiting for something: "))))
20076 #+end_src
20078 ** Speeding Up Your Agendas
20079 :PROPERTIES:
20080 :DESCRIPTION: Tips on how to speed up your agendas.
20081 :END:
20082 #+cindex: agenda views, optimization
20084 Some agenda commands slow down when the Org files grow in size or
20085 number.  Here are tips to speed up:
20087 - Reduce the number of Org agenda files to avoid slowdowns due to hard drive
20088   accesses.
20090 - Reduce the number of DONE and archived headlines so agenda
20091   operations that skip over these can finish faster.
20093 - Do not dim blocked tasks:
20094   #+vindex: org-agenda-dim-blocked-tasks
20096   #+begin_src emacs-lisp
20097   (setq org-agenda-dim-blocked-tasks nil)
20098   #+end_src
20100 - Stop preparing agenda buffers on startup:
20101   #+vindex: org-startup-folded
20102   #+vindex: org-agenda-inhibit-startup
20104   #+begin_src emacs-lisp
20105   (setq org-agenda-inhibit-startup t)
20106   #+end_src
20108 - Disable tag inheritance for agendas:
20109   #+vindex: org-agenda-show-inherited-tags
20110   #+vindex: org-agenda-use-tag-inheritance
20112   #+begin_src emacs-lisp
20113   (setq org-agenda-use-tag-inheritance nil)
20114   #+end_src
20116 These options can be applied to selected agenda views.  For more
20117 details about generation of agenda views, see the docstrings for the
20118 relevant variables, and this [[https://orgmode.org/worg/agenda-optimization.html][dedicated Worg page]] for agenda
20119 optimization.
20121 ** Extracting Agenda Information
20122 :PROPERTIES:
20123 :DESCRIPTION: Post-processing agenda information.
20124 :END:
20125 #+cindex: agenda, pipe
20126 #+cindex: scripts, for agenda processing
20128 Org provides commands to access agendas through Emacs batch mode.
20129 Through this command-line interface, agendas are automated for further
20130 processing or printing.
20132 #+vindex: org-agenda-custom-commands
20133 #+findex: org-batch-agenda
20134 ~org-batch-agenda~ creates an agenda view in ASCII and outputs to
20135 standard output.  This command takes one string parameter.  When
20136 string consists of a single character, Org uses it as a key to
20137 ~org-agenda-custom-commands~.  These are the same ones available
20138 through the agenda dispatcher (see [[*The Agenda Dispatcher]]).
20140 This example command line directly prints the TODO list to the printer:
20142 : emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
20144 When the string parameter length is two or more characters, Org
20145 matches it with tags/TODO strings.  For example, this example command
20146 line prints items tagged with =shop=, but excludes items tagged with
20147 =NewYork=:
20149 #+begin_example
20150 emacs -batch -l ~/.emacs                                      \
20151       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
20152 #+end_example
20154 #+texinfo: @noindent
20155 An example showing on-the-fly parameter modifications:
20157 #+begin_example
20158 emacs -batch -l ~/.emacs                                      \
20159    -eval '(org-batch-agenda "a"                               \
20160            org-agenda-span (quote month)                      \
20161            org-agenda-include-diary nil                       \
20162            org-agenda-files (quote ("~/org/project.org")))'   \
20163    | lpr
20164 #+end_example
20166 #+texinfo: @noindent
20167 which produces an agenda for the next 30 days from just the
20168 =~/org/projects.org= file.
20170 #+findex: org-batch-agenda-csv
20171 For structured processing of agenda output, use ~org-batch-agenda-csv~
20172 with the following fields:
20174 - category :: The category of the item
20175 - head :: The headline, without TODO keyword, TAGS and PRIORITY
20176 - type :: The type of the agenda entry, can be
20178   | ~todo~              | selected in TODO match              |
20179   | ~tagsmatch~         | selected in tags match              |
20180   | ~diary~             | imported from diary                 |
20181   | ~deadline~          | a deadline                          |
20182   | ~scheduled~         | scheduled                           |
20183   | ~timestamp~         | appointment, selected by timestamp  |
20184   | ~closed~            | entry was closed on date            |
20185   | ~upcoming-deadline~ | warning about nearing deadline      |
20186   | ~past-scheduled~    | forwarded scheduled item            |
20187   | ~block~             | entry has date block including date |
20189 - todo :: The TODO keyword, if any
20190 - tags :: All tags including inherited ones, separated by colons
20191 - date :: The relevant date, like =2007-2-14=
20192 - time :: The time, like =15:00-16:50=
20193 - extra :: String with extra planning info
20194 - priority-l :: The priority letter if any was given
20195 - priority-n :: The computed numerical priority
20197 If the selection of the agenda item was based on a timestamp,
20198 including those items with =DEADLINE= and =SCHEDULED= keywords, then
20199 Org includes date and time in the output.
20201 If the selection of the agenda item was based on a timestamp  (or
20202 deadline/scheduled), then Org includes date and time in the output.
20204 Here is an example of a post-processing script in Perl.  It takes the
20205 CSV output from Emacs and prints with a checkbox:
20207 #+begin_src perl
20208 #!/usr/bin/perl
20210 # define the Emacs command to run
20211 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
20213 # run it and capture the output
20214 $agenda = qx{$cmd 2>/dev/null};
20216 # loop over all lines
20217 foreach $line (split(/\n/,$agenda)) {
20218     # get the individual values
20219     ($category,$head,$type,$todo,$tags,$date,$time,$extra,
20220      $priority_l,$priority_n) = split(/,/,$line);
20221     # process and print
20222     print "[ ] $head\n";
20224 #+end_src
20226 ** Using the Property API
20227 :PROPERTIES:
20228 :DESCRIPTION: Writing programs that use entry properties.
20229 :END:
20230 #+cindex: API, for properties
20231 #+cindex: properties, API
20233 Here is a description of the functions that can be used to work with
20234 properties.
20236 #+attr_texinfo: :options org-entry-properties &optional pom which
20237 #+begin_defun
20238 Get all properties of the entry at point-or-marker {{{var(POM)}}}.
20239 This includes the TODO keyword, the tags, time strings for deadline,
20240 scheduled, and clocking, and any additional properties defined in the
20241 entry.  The return value is an alist.  Keys may occur multiple times
20242 if the property key was used several times.  {{{var(POM)}}} may also
20243 be ~nil~, in which case the current entry is used.  If
20244 {{{var(WHICH)}}} is ~nil~ or ~all~, get all properties.  If
20245 {{{var(WHICH)}}} is ~special~ or ~standard~, only get that subclass.
20246 #+end_defun
20248 #+vindex: org-use-property-inheritance
20249 #+findex: org-insert-property-drawer
20250 #+attr_texinfo: :options org-entry-get pom property &optional inherit
20251 #+begin_defun
20252 Get value of {{{var(PROPERTY)}}} for entry at point-or-marker
20253 {{{var(POM)}}}.  By default, this only looks at properties defined
20254 locally in the entry.  If {{{var(INHERIT)}}} is non-~nil~ and the
20255 entry does not have the property, then also check higher levels of the
20256 hierarchy.  If {{{var(INHERIT)}}} is the symbol ~selective~, use
20257 inheritance if and only if the setting of
20258 ~org-use-property-inheritance~ selects {{{var(PROPERTY)}}} for
20259 inheritance.
20260 #+end_defun
20262 #+attr_texinfo: :options org-entry-delete pom property
20263 #+begin_defun
20264 Delete the property {{{var(PROPERTY)}}} from entry at point-or-marker
20265 {{{var(POM)}}}.
20266 #+end_defun
20268 #+attr_texinfo: :options org-entry-put pom property value
20269 #+begin_defun
20270 Set {{{var(PROPERTY)}}} to {{{var(VALUES)}}} for entry at
20271 point-or-marker POM.
20272 #+end_defun
20274 #+attr_texinfo: :options org-buffer-property-keys &optional include-specials
20275 #+begin_defun
20276 Get all property keys in the current buffer.
20277 #+end_defun
20279 #+attr_texinfo: :options org-insert-property-drawer
20280 #+begin_defun
20281 Insert a property drawer for the current entry.  Also
20282 #+end_defun
20284 #+attr_texinfo: :options org-entry-put-multivalued-property pom property &rest values
20285 #+begin_defun
20286 Set {{{var(PROPERTY)}}} at point-or-marker {{{var(POM)}}} to
20287 {{{var(VALUES)}}}.  {{{var(VALUES)}}} should be a list of strings.
20288 They are concatenated, with spaces as separators.
20289 #+end_defun
20291 #+attr_texinfo: :options org-entry-get-multivalued-property pom property
20292 #+begin_defun
20293 Treat the value of the property {{{var(PROPERTY)}}} as
20294 a whitespace-separated list of values and return the values as a list
20295 of strings.
20296 #+end_defun
20298 #+attr_texinfo: :options org-entry-add-to-multivalued-property pom property value
20299 #+begin_defun
20300 Treat the value of the property {{{var(PROPERTY)}}} as
20301 a whitespace-separated list of values and make sure that
20302 {{{var(VALUE)}}} is in this list.
20303 #+end_defun
20305 #+attr_texinfo: :options org-entry-remove-from-multivalued-property pom property value
20306 #+begin_defun
20307 Treat the value of the property {{{var(PROPERTY)}}} as
20308 a whitespace-separated list of values and make sure that
20309 {{{var(VALUE)}}} is /not/ in this list.
20310 #+end_defun
20312 #+attr_texinfo: :options org-entry-member-in-multivalued-property pom property value
20313 #+begin_defun
20314 Treat the value of the property {{{var(PROPERTY)}}} as
20315 a whitespace-separated list of values and check if {{{var(VALUE)}}} is
20316 in this list.
20317 #+end_defun
20319 #+attr_texinfo: :options org-property-allowed-value-functions
20320 #+begin_defopt
20321 Hook for functions supplying allowed values for a specific property.
20322 The functions must take a single argument, the name of the property,
20323 and return a flat list of allowed values.  If =:ETC= is one of the
20324 values, use the values as completion help, but allow also other values
20325 to be entered.  The functions must return ~nil~ if they are not
20326 responsible for this property.
20327 #+end_defopt
20329 ** Using the Mapping API
20330 :PROPERTIES:
20331 :DESCRIPTION: Mapping over all or selected entries.
20332 :END:
20333 #+cindex: API, for mapping
20334 #+cindex: mapping entries, API
20336 Org has sophisticated mapping capabilities to find all entries
20337 satisfying certain criteria.  Internally, this functionality is used
20338 to produce agenda views, but there is also an API that can be used to
20339 execute arbitrary functions for each or selected entries.  The main
20340 entry point for this API is:
20342 #+attr_texinfo: :options org-map-entries func &optional match scope &rest skip
20343 #+begin_defun
20344 Call {{{var(FUNC)}}} at each headline selected by {{{var(MATCH)}}} in
20345 {{{var(SCOPE)}}}.
20347 {{{var(FUNC)}}} is a function or a Lisp form.  With point positioned
20348 at the beginning of the headline, call the function without arguments.
20349 Org returns an alist of return values of calls to the function.
20351 To avoid preserving point, Org wraps the call to {{{var(FUNC)}}} in
20352 ~save-excursion~ form.  After evaluation, Org moves point to the end
20353 of the line that was just processed.  Search continues from that point
20354 forward.  This may not always work as expected under some conditions,
20355 such as if the current sub-tree was removed by a previous archiving
20356 operation.  In such rare circumstances, Org skips the next entry
20357 entirely when it should not.  To stop Org from such skips, make
20358 {{{var(FUNC)}}} set the variable ~org-map-continue-from~ to a specific
20359 buffer position.
20361 {{{var(MATCH)}}} is a tags/property/TODO match.  Org iterates only
20362 matched headlines.  Org iterates over all headlines when
20363 {{{var(MATCH)}}} is ~nil~ or ~t~.
20365 {{{var(SCOPE)}}} determines the scope of this command.  It can be any
20368 - ~nil~ ::
20370   The current buffer, respecting the restriction, if any.
20372 - ~tree~ ::
20374   The subtree started with the entry at point.
20376 - ~region~ ::
20378   The entries within the active region, if any.
20380 - ~file~ ::
20382   The current buffer, without restriction.
20384 - ~file-with-archives~ ::
20386   The current buffer, and any archives associated with it.
20388 - ~agenda~ ::
20390   All agenda files.
20392 - ~agenda-with-archives~ ::
20394   All agenda files with any archive files associated with them.
20396 - list of filenames ::
20398   If this is a list, all files in the list are scanned.
20400 #+texinfo: @noindent
20401 The remaining arguments are treated as settings for the scanner's
20402 skipping facilities.  Valid arguments are:
20404 - ~archive~ ::
20406   Skip trees with the =ARCHIVE= tag.
20408 - ~comment~ ::
20410   Skip trees with the COMMENT keyword.
20412 - function or Lisp form ::
20414   #+vindex: org-agenda-skip-function
20415   Used as value for ~org-agenda-skip-function~, so whenever the
20416   function returns ~t~, {{{var(FUNC)}}} is called for that entry and
20417   search continues from the point where the function leaves it.
20418 #+end_defun
20420 The mapping routine can call any arbitrary function, even functions
20421 that change meta data or query the property API (see [[*Using the
20422 Property API]]).  Here are some handy functions:
20424 #+attr_texinfo: :options org-todo &optional arg
20425 #+begin_defun
20426 Change the TODO state of the entry.  See the docstring of the
20427 functions for the many possible values for the argument
20428 {{{var(ARG)}}}.
20429 #+end_defun
20431 #+attr_texinfo: :options org-priority &optional action
20432 #+begin_defun
20433 Change the priority of the entry.  See the docstring of this function
20434 for the possible values for {{{var(ACTION)}}}.
20435 #+end_defun
20437 #+attr_texinfo: :options org-toggle-tag tag &optional onoff
20438 #+begin_defun
20439 Toggle the tag {{{var(TAG)}}} in the current entry.  Setting
20440 {{{var(ONOFF)}}} to either ~on~ or ~off~ does not toggle tag, but
20441 ensure that it is either on or off.
20442 #+end_defun
20444 #+attr_texinfo: :options org-promote
20445 #+begin_defun
20446 Promote the current entry.
20447 #+end_defun
20449 #+attr_texinfo: :options org-demote
20450 #+begin_defun
20451 Demote the current entry.
20452 #+end_defun
20454 This example turns all entries tagged with =TOMORROW= into TODO
20455 entries with keyword =UPCOMING=.  Org ignores entries in comment trees
20456 and archive trees.
20458 #+begin_src emacs-lisp
20459 (org-map-entries '(org-todo "UPCOMING")
20460                  "+TOMORROW" 'file 'archive 'comment)
20461 #+end_src
20463 The following example counts the number of entries with TODO keyword
20464 =WAITING=, in all agenda files.
20466 #+begin_src emacs-lisp
20467 (length (org-map-entries t "/+WAITING" 'agenda))
20468 #+end_src
20470 * History and Acknowledgments
20471 :PROPERTIES:
20472 :DESCRIPTION: How Org came into being.
20473 :APPENDIX: t
20474 :END:
20476 ** From Carsten
20477 :PROPERTIES:
20478 :UNNUMBERED: notoc
20479 :END:
20481 Org was born in 2003, out of frustration over the user interface of
20482 the Emacs Outline mode.  I was trying to organize my notes and
20483 projects, and using Emacs seemed to be the natural way to go.
20484 However, having to remember eleven different commands with two or
20485 three keys per command, only to hide and show parts of the outline
20486 tree, that seemed entirely unacceptable to me.  Also, when using
20487 outlines to take notes, I constantly wanted to restructure the tree,
20488 organizing it parallel to my thoughts and plans.  /Visibility cycling/
20489 and /structure editing/ were originally implemented in the package
20490 =outline-magic.el=, but quickly moved to the more general =org.el=.
20491 As this environment became comfortable for project planning, the next
20492 step was adding /TODO entries/, basic /timestamps/, and /table
20493 support/.  These areas highlighted the two main goals that Org still
20494 has today: to be a new, outline-based, plain text mode with innovative
20495 and intuitive editing features, and to incorporate project planning
20496 functionality directly into a notes file.
20498 Since the first release, literally thousands of emails to me or to the
20499 [[mailto:emacs-orgmode@gnu.org][mailing list]] have provided a constant stream of bug reports, feedback,
20500 new ideas, and sometimes patches and add-on code.  Many thanks to
20501 everyone who has helped to improve this package.  I am trying to keep
20502 here a list of the people who had significant influence in shaping one
20503 or more aspects of Org.  The list may not be complete, if I have
20504 forgotten someone, please accept my apologies and let me know.
20506 Before I get to this list, a few special mentions are in order:
20508 - Bastien Guerry ::
20510   Bastien has written a large number of extensions to Org (most of
20511   them integrated into the core by now), including the LaTeX exporter
20512   and the plain list parser.  His support during the early days was
20513   central to the success of this project.  Bastien also invented Worg,
20514   helped establishing the Web presence of Org, and sponsored hosting
20515   costs for the orgmode.org website.  Bastien stepped in as maintainer
20516   of Org between 2011 and 2013, at a time when I desperately needed
20517   a break.
20519 - Eric Schulte and Dan Davison ::
20521   Eric and Dan are jointly responsible for the Org Babel system, which
20522   turns Org into a multi-language environment for evaluating code and
20523   doing literate programming and reproducible research.  This has
20524   become one of Org's killer features that define what Org is today.
20526 - John Wiegley ::
20528   John has contributed a number of great ideas and patches directly to
20529   Org, including the attachment system (=org-attach.el=), integration
20530   with Apple Mail (=org-mac-message.el=), hierarchical dependencies of
20531   TODO items, habit tracking (=org-habits.el=), and encryption
20532   (=org-crypt.el=).  Also, the capture system is really an extended
20533   copy of his great =remember.el=.
20535 - Sebastian Rose ::
20537   Without Sebastian, the HTML/XHTML publishing of Org would be the
20538   pitiful work of an ignorant amateur.  Sebastian has pushed this part
20539   of Org onto a much higher level.  He also wrote =org-info.js=,
20540   a Java script for displaying webpages derived from Org using an
20541   Info-like or a folding interface with single-key navigation.
20543 See below for the full list of contributions! Again, please let me
20544 know what I am missing here!
20546 ** From Bastien
20547 :PROPERTIES:
20548 :UNNUMBERED: notoc
20549 :END:
20551 I (Bastien) have been maintaining Org between 2011 and 2013.  This
20552 appendix would not be complete without adding a few more
20553 acknowledgments and thanks.
20555 I am first grateful to Carsten for his trust while handing me over the
20556 maintainership of Org.  His unremitting support is what really helped
20557 me getting more confident over time, with both the community and the
20558 code.
20560 When I took over maintainership, I knew I would have to make Org more
20561 collaborative than ever, as I would have to rely on people that are
20562 more knowledgeable than I am on many parts of the code.  Here is
20563 a list of the persons I could rely on, they should really be
20564 considered co-maintainers, either of the code or the community:
20566 - Eric Schulte ::
20568   Eric is maintaining the Babel parts of Org.  His reactivity here
20569   kept me away from worrying about possible bugs here and let me focus
20570   on other parts.
20572 - Nicolas Goaziou ::
20574   Nicolas is maintaining the consistency of the deepest parts of Org.
20575   His work on =org-element.el= and =ox.el= has been outstanding, and
20576   it opened the doors for many new ideas and features.  He rewrote
20577   many of the old exporters to use the new export engine, and helped
20578   with documenting this major change.  More importantly (if that's
20579   possible), he has been more than reliable during all the work done
20580   for Org 8.0, and always very reactive on the mailing list.
20582 - Achim Gratz ::
20584   Achim rewrote the building process of Org, turning some /ad hoc/
20585   tools into a flexible and conceptually clean process.  He patiently
20586   coped with the many hiccups that such a change can create for users.
20588 - Nick Dokos ::
20590   The Org mode mailing list would not be such a nice place without
20591   Nick, who patiently helped users so many times.  It is impossible to
20592   overestimate such a great help, and the list would not be so active
20593   without him.
20595 I received support from so many users that it is clearly impossible to
20596 be fair when shortlisting a few of them, but Org's history would not
20597 be complete if the ones above were not mentioned in this manual.
20599 ** List of Contributions
20600 :PROPERTIES:
20601 :UNNUMBERED: notoc
20602 :END:
20604 - Russel Adams came up with the idea for drawers.
20606 - Thomas Baumann wrote =ol-bbdb.el= and =ol-mhe.el=.
20608 - Christophe Bataillon created the great unicorn logo that we use on
20609   the Org mode website.
20611 - Alex Bochannek provided a patch for rounding timestamps.
20613 - Jan Böcker wrote =ol-docview.el=.
20615 - Brad Bozarth showed how to pull RSS feed data into Org files.
20617 - Tom Breton wrote =org-choose.el=.
20619 - Charles Cave's suggestion sparked the implementation of templates
20620   for Remember, which are now templates for capture.
20622 - Pavel Chalmoviansky influenced the agenda treatment of items with
20623   specified time.
20625 - Gregory Chernov patched support for Lisp forms into table
20626   calculations and improved XEmacs compatibility, in particular by
20627   porting =nouline.el= to XEmacs.
20629 - Sacha Chua suggested copying some linking code from Planner.
20631 - Baoqiu Cui contributed the DocBook exporter.
20633 - Eddward DeVilla proposed and tested checkbox statistics.  He also
20634   came up with the idea of properties, and that there should be an API
20635   for them.
20637 - Nick Dokos tracked down several nasty bugs.
20639 - Kees Dullemond used to edit projects lists directly in HTML and so
20640   inspired some of the early development, including HTML export.  He
20641   also asked for a way to narrow wide table columns.
20643 - Thomas\nbsp{}S.\nbsp{}Dye contributed documentation on Worg and helped
20644   integrating the Org Babel documentation into the manual.
20646 - Christian Egli converted the documentation into Texinfo format,
20647   inspired the agenda, patched CSS formatting into the HTML exporter,
20648   and wrote =org-taskjuggler.el=.
20650 - David Emery provided a patch for custom CSS support in exported HTML
20651   agendas.
20653 - Nic Ferrier contributed mailcap and XOXO support.
20655 - Miguel\nbsp{}A.\nbsp{}Figueroa-Villanueva implemented hierarchical checkboxes.
20657 - John Foerch figured out how to make incremental search show context
20658   around a match in a hidden outline tree.
20660 - Raimar Finken wrote =org-git-line.el=.
20662 - Mikael Fornius works as a mailing list moderator.
20664 - Austin Frank works as a mailing list moderator.
20666 - Eric Fraga drove the development of Beamer export with ideas and
20667   testing.
20669 - Barry Gidden did proofreading the manual in preparation for the book
20670   publication through Network Theory Ltd.
20672 - Niels Giesen had the idea to automatically archive DONE trees.
20674 - Nicolas Goaziou rewrote much of the plain list code.
20676 - Kai Grossjohann pointed out key-binding conflicts with other
20677   packages.
20679 - Brian Gough of Network Theory Ltd publishes the Org mode manual as
20680   a book.
20682 - Bernt Hansen has driven much of the support for auto-repeating
20683   tasks, task state change logging, and the clocktable.  His clear
20684   explanations have been critical when we started to adopt the Git
20685   version control system.
20687 - Manuel Hermenegildo has contributed various ideas, small fixes and
20688   patches.
20690 - Phil Jackson wrote =ol-irc.el=.
20692 - Scott Jaderholm proposed footnotes, control over whitespace between
20693   folded entries, and column view for properties.
20695 - Matt Jones wrote MobileOrg Android.
20697 - Tokuya Kameshima wrote =org-wl.el= and =org-mew.el=.
20699 - Shidai Liu ("Leo") asked for embedded LaTeX and tested it.  He also
20700   provided frequent feedback and some patches.
20702 - Matt Lundin has proposed last-row references for table formulas and
20703   named invisible anchors.  He has also worked a lot on the FAQ.
20705 - David Maus wrote =org-atom.el=, maintains the issues file for Org,
20706   and is a prolific contributor on the mailing list with competent
20707   replies, small fixes and patches.
20709 - Jason\nbsp{}F.\nbsp{}McBrayer suggested agenda export to CSV format.
20711 - Max Mikhanosha came up with the idea of refiling.
20713 - Dmitri Minaev sent a patch to set priority limits on a per-file
20714   basis.
20716 - Stefan Monnier provided a patch to keep the Emacs Lisp compiler
20717   happy.
20719 - Richard Moreland wrote MobileOrg for the iPhone.
20721 - Rick Moynihan proposed allowing multiple TODO sequences in a file
20722   and being able to quickly restrict the agenda to a subtree.
20724 - Todd Neal provided patches for links to Info files and Elisp forms.
20726 - Greg Newman refreshed the unicorn logo into its current form.
20728 - Tim O'Callaghan suggested in-file links, search options for general
20729   file links, and tags.
20731 - Osamu Okano wrote =orgcard2ref.pl=, a Perl program to create a text
20732   version of the reference card.
20734 - Takeshi Okano translated the manual and David O'Toole's tutorial
20735   into Japanese.
20737 - Oliver Oppitz suggested multi-state TODO items.
20739 - Scott Otterson sparked the introduction of descriptive text for
20740   links, among other things.
20742 - Pete Phillips helped during the development of the TAGS feature,
20743   and provided frequent feedback.
20745 - Martin Pohlack provided the code snippet to bundle character
20746   insertion into bundles of 20 for undo.
20748 - T.\nbsp{}V.\nbsp{}Raman reported bugs and suggested improvements.
20750 - Matthias Rempe (Oelde) provided ideas, Windows support, and quality
20751   control.
20753 - Paul Rivier provided the basic implementation of named footnotes.
20754   He also acted as mailing list moderator for some time.
20756 - Kevin Rogers contributed code to access VM files on remote hosts.
20758 - Frank Ruell solved the mystery of the =keymapp nil= bug, a conflict
20759   with =allout.el=.
20761 - Jason Riedy generalized the send-receive mechanism for Orgtbl
20762   tables with extensive patches.
20764 - Philip Rooke created the Org reference card, provided lots of
20765   feedback, developed and applied standards to the Org documentation.
20767 - Christian Schlauer proposed angular brackets around links, among
20768   other things.
20770 - Paul Sexton wrote =org-ctags.el=.
20772 - Tom Shannon's =organizer-mode.el= inspired linking to VM/BBDB/Gnus.
20774 - Ilya Shlyakhter proposed the Archive Sibling, line numbering in
20775   literal examples, and remote highlighting for referenced code lines.
20777 - Stathis Sideris wrote the =ditaa.jar= ASCII to PNG converter that is
20778   now packaged into Org's =contrib/= directory.
20780 - Daniel Sinder came up with the idea of internal archiving by locking
20781   subtrees.
20783 - Dale Smith proposed link abbreviations.
20785 - James TD Smith has contributed a large number of patches for
20786   useful tweaks and features.
20788 - Adam Spiers asked for global linking commands, inspired the link
20789   extension system, added support for Mairix, and proposed the mapping
20790   API.
20792 - Ulf Stegemann created the table to translate special symbols to
20793   HTML, LaTeX, UTF-8, Latin-1 and ASCII.
20795 - Andy Stewart contributed code to =ol-w3m.el=, to copy
20796   HTML content with links transformation to Org syntax.
20798 - David O'Toole wrote =org-publish.el= and drafted the
20799   manual chapter about publishing.
20801 - Jambunathan\nbsp{}K.\nbsp{}contributed the ODT exporter.
20803 - Sebastien Vauban reported many issues with LaTeX and Beamer export
20804   and enabled source code highlighting in Gnus.
20806 - Stefan Vollmar organized a video-recorded talk at the
20807   Max-Planck-Institute for Neurology.  He also inspired the creation
20808   of a concept index for HTML export.
20810 - Jürgen Vollmer contributed code generating the table of contents in
20811   HTML output.
20813 - Samuel Wales has provided important feedback and bug reports.
20815 - Chris Wallace provided a patch implementing the =QUOTE= block.
20817 - David Wainberg suggested archiving, and improvements to the
20818   linking system.
20820 - Carsten Wimmer suggested some changes and helped fix a bug in
20821   linking to Gnus.
20823 - Roland Winkler requested additional key bindings to make Org work on
20824   a TTY.
20826 - Piotr Zielinski wrote =org-mouse.el=, proposed agenda
20827   blocks and contributed various ideas and code snippets.
20829 - Marco Wahl wrote =ol-eww.el=.
20831 * GNU Free Documentation License
20832 :PROPERTIES:
20833 :APPENDIX: t
20834 :DESCRIPTION: The license for this documentation.
20835 :END:
20837 #+include: fdl.org
20839 * Main Index
20840 :PROPERTIES:
20841 :INDEX:    cp
20842 :DESCRIPTION: An index of Org's concepts and features.
20843 :END:
20845 * Key Index
20846 :PROPERTIES:
20847 :DESCRIPTION: Key bindings and where they are described.
20848 :INDEX:    ky
20849 :END:
20851 * Command and Function Index
20852 :PROPERTIES:
20853 :DESCRIPTION: Command names and some internal functions.
20854 :INDEX:    fn
20855 :END:
20857 * Variable Index
20858 :PROPERTIES:
20859 :DESCRIPTION: Variables mentioned in the manual.
20860 :INDEX:    vr
20861 :END:
20863 This is not a complete index of variables and faces, only the ones
20864 that are mentioned in the manual.  For a more complete list, use
20865 {{{kbd(M-x org-customize)}}} and then click yourself through the tree.
20867 * Copying
20868 :PROPERTIES:
20869 :copying:  t
20870 :END:
20872 This manual is for Org version {{{version}}}.
20874 Copyright \copy 2004--2019  Free Software Foundation, Inc.
20876 #+begin_quote
20877 Permission is granted to copy, distribute and/or modify this document
20878 under the terms of the GNU Free Documentation License, Version 1.3 or
20879 any later version published by the Free Software Foundation; with no
20880 Invariant Sections, with the Front-Cover Texts being "A GNU Manual,"
20881 and with the Back-Cover Texts as in (a) below.  A copy of the license
20882 is included in the section entitled "GNU Free Documentation License."
20884 (a) The FSF's Back-Cover Text is: "You have the freedom to copy and
20885 modify this GNU manual."
20886 #+end_quote
20888 * Export Setup                                                          :noexport:
20890 #+setupfile: doc-setup.org
20892 #+export_file_name: org.texi
20894 #+texinfo_dir_category: Emacs
20895 #+texinfo_dir_title: Org Mode: (org)
20896 #+texinfo_dir_desc: Outline-based notes management and organizer
20898 * Footnotes
20900 [fn:1] If you do not use Font Lock globally turn it on in Org buffer
20901 with =(add-hook 'org-mode-hook 'turn-on-font-lock)=.
20903 [fn:2] Please consider subscribing to the mailing list in order to
20904 minimize the work the mailing list moderators have to do.
20906 [fn:3] See the variables ~org-special-ctrl-a/e~, ~org-special-ctrl-k~,
20907 and ~org-ctrl-k-protect-subtree~ to configure special behavior of
20908 {{{kbd(C-a)}}}, {{{kbd(C-e)}}}, and {{{kbd(C-k)}}} in headlines.  Note
20909 also that clocking only works with headings indented less than 30
20910 stars.
20912 [fn:4] See, however, the option ~org-cycle-emulate-tab~.
20914 [fn:5] The indirect buffer contains the entire buffer, but is narrowed
20915 to the current tree.  Editing the indirect buffer also changes the
20916 original buffer, but without affecting visibility in that buffer.  For
20917 more information about indirect buffers, see [[info:emacs#Indirect Buffers][GNU Emacs Manual]].
20919 [fn:6] When ~org-agenda-inhibit-startup~ is non-~nil~, Org does not
20920 honor the default visibility state when first opening a file for the
20921 agenda (see [[*Speeding Up Your Agendas]]).
20923 [fn:7] See also the variable ~org-show-context-detail~ to decide how
20924 much context is shown around each match.
20926 [fn:8] This depends on the option ~org-remove-highlights-with-change~.
20928 [fn:9] When using =*= as a bullet, lines must be indented so that they
20929 are not interpreted as headlines.  Also, when you are hiding leading
20930 stars to get a clean outline view, plain list items starting with
20931 a star may be hard to distinguish from true headlines.  In short: even
20932 though =*= is supported, it may be better to not use it for plain list
20933 items.
20935 [fn:10] You can filter out any of them by configuring
20936 ~org-plain-list-ordered-item-terminator~.
20938 [fn:11] You can also get =a.=, =A.=, =a)= and =A)= by configuring
20939 ~org-list-allow-alphabetical~.  To minimize confusion with normal
20940 text, those are limited to one character only.  Beyond that limit,
20941 bullets automatically become numbers.
20943 [fn:12] If there's a checkbox in the item, the cookie must be put
20944 /before/ the checkbox.  If you have activated alphabetical lists, you
20945 can also use counters like =[@b]=.
20947 [fn:13] If you do not want the item to be split, customize the
20948 variable ~org-M-RET-may-split-line~.
20950 [fn:14] If you want to cycle around items that way, you may customize
20951 ~org-list-use-circular-motion~.
20953 [fn:15] See ~org-list-use-circular-motion~ for a cyclic behavior.
20955 [fn:16] Many desktops intercept {{{kbd(M-TAB)}}} to switch windows.
20956 Use {{{kbd(C-M-i)}}} or {{{kbd(ESC TAB)}}} instead.
20958 [fn:17] To insert a vertical bar into a table field, use =\vert= or,
20959 inside a word =abc\vert{}def=.
20961 [fn:18] Org understands references typed by the user as =B4=, but it
20962 does not use this syntax when offering a formula for editing.  You can
20963 customize this behavior using the variable
20964 ~org-table-use-standard-references~.
20966 [fn:19] The computation time scales as O(N^2) because table
20967 {{{var(FOO)}}} is parsed for each field to be copied.
20969 [fn:20] The file =constants.el= can supply the values of constants in
20970 two different unit systems, =SI= and =cgs=.  Which one is used depends
20971 on the value of the variable ~constants-unit-system~.  You can use the
20972 =STARTUP= options =constSI= and =constcgs= to set this value for the
20973 current buffer.
20975 [fn:21] The printf reformatting is limited in precision because the
20976 value passed to it is converted into an "integer" or "double".  The
20977 "integer" is limited in size by truncating the signed value to 32
20978 bits.  The "double" is limited in precision to 64 bits overall which
20979 leaves approximately 16 significant decimal digits.
20981 [fn:22] Such names must start with an alphabetic character and use
20982 only alphanumeric/underscore characters.
20984 [fn:23] Plain URIs are recognized only for a well-defined set of
20985 schemes.  See [[*External Links]].  Unlike URI syntax, they cannot contain
20986 parenthesis or white spaces, either.  URIs within angle brackets have
20987 no such limitation.
20989 [fn:24] More accurately, the precise behavior depends on how point
20990 arrived there---see [[info:elisp#Invisible Text][Invisible Text]].
20992 [fn:25] To insert a link targeting a headline, in-buffer completion
20993 can be used.  Just type a star followed by a few optional letters into
20994 the buffer and press {{{kbd(M-TAB)}}}.  All headlines in the current
20995 buffer are offered as completions.
20997 [fn:26] When targeting a =NAME= keyword, the =CAPTION= keyword is
20998 mandatory in order to get proper numbering (see [[*Captions]]).
21000 [fn:27] The actual behavior of the search depends on the value of the
21001 variable ~org-link-search-must-match-exact-headline~.  If its value is
21002 ~nil~, then a fuzzy text search is done.  If it is ~t~, then only the
21003 exact headline is matched, ignoring spaces and statistic cookies.  If
21004 the value is ~query-to-create~, then an exact headline is searched; if
21005 it is not found, then the user is queried to create it.
21007 [fn:28] If the headline contains a timestamp, it is removed from the
21008 link, which results in a wrong link---you should avoid putting
21009 a timestamp in the headline.
21011 [fn:29] The Org Id library must first be loaded, either through
21012 ~org-customize~, by enabling ~id~ in ~org-modules~, or by adding
21013 =(require 'org-id)= in your Emacs init file.
21015 [fn:30] Note that you do not have to use this command to insert
21016 a link.  Links in Org are plain text, and you can type or paste them
21017 straight into the buffer.  By using this command, the links are
21018 automatically enclosed in double brackets, and you will be asked for
21019 the optional descriptive text.
21021 [fn:31] After insertion of a stored link, the link will be removed
21022 from the list of stored links.  To keep it in the list for later use,
21023 use a triple {{{kbd(C-u)}}} prefix argument to {{{kbd(C-c C-l)}}}, or
21024 configure the option ~org-link-keep-stored-after-insertion~.
21026 [fn:32] This works if a function has been defined in the ~:complete~
21027 property of a link in ~org-link-parameters~.
21029 [fn:33] See the variable ~org-link-use-indirect-buffer-for-internals~.
21031 [fn:34] For backward compatibility, line numbers can also follow a
21032 single colon.
21034 [fn:35] Of course, you can make a document that contains only long
21035 lists of TODO items, but this is not required.
21037 [fn:36] Changing the variable ~org-todo-keywords~ only becomes
21038 effective after restarting Org mode in a buffer.
21040 [fn:37] This is also true for the {{{kbd(t)}}} command in the agenda
21041 buffer.
21043 [fn:38] All characters are allowed except =@=, =^= and =!=, which have
21044 a special meaning here.
21046 [fn:39] Check also the variable ~org-fast-tag-selection-include-todo~,
21047 it allows you to change the TODO state through the tags interface (see
21048 [[*Setting Tags]]), in case you like to mingle the two concepts.  Note
21049 that this means you need to come up with unique keys across both sets
21050 of keywords.
21052 [fn:40] Org mode parses these lines only when Org mode is activated
21053 after visiting a file.  {{{kbd(C-c C-c)}}} with point in a line
21054 starting with =#+= is simply restarting Org mode for the current
21055 buffer.
21057 [fn:41] The corresponding in-buffer setting is: =#+STARTUP: logdone=.
21059 [fn:42] The corresponding in-buffer setting is: =#+STARTUP:
21060 lognotedone=.
21062 [fn:43] See the variable ~org-log-states-order-reversed~.
21064 [fn:44] Note that the =LOGBOOK= drawer is unfolded when pressing
21065 {{{kbd(SPC)}}} in the agenda to show an entry---use {{{kbd(C-u
21066 SPC)}}} to keep it folded here.
21068 [fn:45] It is possible that Org mode records two timestamps when you
21069 are using both ~org-log-done~ and state change logging.  However, it
21070 never prompts for two notes: if you have configured both, the state
21071 change recording note takes precedence and cancel the closing note.
21073 [fn:46] See also the option ~org-priority-start-cycle-with-default~.
21075 [fn:47] To keep subtasks out of the global TODO list, see the option
21076 ~org-agenda-todo-list-sublevels~.
21078 [fn:48] With the exception of description lists.  But you can allow it
21079 by modifying ~org-list-automatic-rules~ accordingly.
21081 [fn:49] Set the variable ~org-hierarchical-checkbox-statistics~ if you
21082 want such cookies to count all checkboxes below the cookie, not just
21083 those belonging to direct children.
21085 [fn:50] {{{kbd(C-u C-c C-c)}}} on the /first/ item of a list with no
21086 checkbox adds checkboxes to the rest of the list.
21088 [fn:51] As with all these in-buffer settings, pressing {{{kbd(C-c
21089 C-c)}}} activates any changes in the line.
21091 [fn:52] This is only true if the search does not involve more complex
21092 tests including properties (see [[*Property Searches]]).
21094 [fn:53] To extend this default list to all tags used in all agenda
21095 files (see [[*Agenda Views]]), customize the variable
21096 ~org-complete-tags-always-offer-all-agenda-tags~.
21098 [fn:54] Keys are automatically assigned to tags that have no
21099 configured keys.
21101 [fn:55] If more than one summary type applies to the same property,
21102 the parent values are computed according to the first of them.
21104 [fn:56] An age can be defined as a duration, using units defined in
21105 ~org-duration-units~, e.g., =3d 1h=.  If any value in the column is as
21106 such, the summary is also expressed as a duration.
21108 [fn:57] Please note that the =COLUMNS= definition must be on a single
21109 line; it is wrapped here only because of formatting constraints.
21111 [fn:58] Contributed packages are not part of Emacs, but are
21112 distributed with the main distribution of Org---visit
21113 [[https://orgmode.org]].
21115 [fn:59] The Org date format is inspired by the standard ISO 8601
21116 date/time format.  To use an alternative format, see [[*Custom time
21117 format]].  The day name is optional when you type the date yourself.
21118 However, any date inserted or modified by Org adds that day name, for
21119 reading convenience.
21121 [fn:60] When working with the standard diary expression functions, you
21122 need to be very careful with the order of the arguments.  That order
21123 depends evilly on the variable ~calendar-date-style~.  For example, to
21124 specify a date December 12, 2005, the call might look like
21125 =(diary-date 12 1 2005)= or =(diary-date 1 12 2005)= or =(diary-date
21126 2005 12 1)=, depending on the settings.  This has been the source of
21127 much confusion.  Org mode users can resort to special versions of
21128 these functions like ~org-date~ or ~org-anniversary~.  These work just
21129 like the corresponding ~diary-~ functions, but with stable ISO order
21130 of arguments (year, month, day) wherever applicable, independent of
21131 the value of ~calendar-date-style~.
21133 [fn:61] See the variable ~org-read-date-prefer-future~.  You may set
21134 that variable to the symbol ~time~ to even make a time before now
21135 shift the date to tomorrow.
21137 [fn:62] If you do not need/want the calendar, configure the variable
21138 ~org-popup-calendar-for-date-prompt~.
21140 [fn:63] If you find this distracting, turn off the display with
21141 ~org-read-date-display-live~.
21143 [fn:64] It will still be listed on that date after it has been marked
21144 as done.  If you do not like this, set the variable
21145 ~org-agenda-skip-scheduled-if-done~.
21147 [fn:65] The =SCHEDULED= and =DEADLINE= dates are inserted on the line
21148 right below the headline.  Do not put any text between this line and
21149 the headline.
21151 [fn:66] Note the corresponding =STARTUP= options =logredeadline=,
21152 =lognoteredeadline=, and =nologredeadline=.
21154 [fn:67] Note the corresponding =STARTUP= options =logreschedule=,
21155 =lognotereschedule=, and =nologreschedule=.
21157 [fn:68] Org does not repeat inactive timestamps, however.  See
21158 [[*Timestamps]].
21160 [fn:69] In fact, the target state is taken from, in this sequence, the
21161 =REPEAT_TO_STATE= property, the variable ~org-todo-repeat-to-state~ if
21162 it is a string, the previous TODO state if ~org-todo-repeat-to-state~
21163 is ~t~, or the first state of the TODO state sequence.
21165 [fn:70] You can change this using the option ~org-log-repeat~, or the
21166 =STARTUP= options =logrepeat=, =lognoterepeat=, and =nologrepeat=.
21167 With =lognoterepeat=, you will also be prompted for a note.
21169 [fn:71] Clocking only works if all headings are indented with less
21170 than 30 stars.  This is a hard-coded limitation of ~lmax~ in
21171 ~org-clock-sum~.
21173 [fn:72] To resume the clock under the assumption that you have worked
21174 on this task while outside Emacs, use =(setq org-clock-persist t)=.
21176 [fn:73] To add an effort estimate "on the fly", hook a function doing
21177 this to ~org-clock-in-prepare-hook~.
21179 [fn:74] The last reset of the task is recorded by the =LAST_REPEAT=
21180 property.
21182 [fn:75] See also the variable ~org-clock-mode-line-total~.
21184 [fn:76] The corresponding in-buffer setting is: =#+STARTUP:
21185 lognoteclock-out=.
21187 [fn:77] When using ~:step~, ~untilnow~ starts from the beginning of
21188 2003, not the beginning of time.
21190 [fn:78] Language terms can be set through the variable
21191 ~org-clock-clocktable-language-setup~.
21193 [fn:79] Note that all parameters must be specified in a single
21194 line---the line is broken here only to fit it into the manual.
21196 [fn:80] On computers using macOS, idleness is based on actual user
21197 idleness, not just Emacs' idle time.  For X11, you can install
21198 a utility program =x11idle.c=, available in the =contrib/scripts/=
21199 directory of the Org Git distribution, or install the xprintidle
21200 package and set it to the variable ~org-clock-x11idle-program-name~ if
21201 you are running Debian, to get the same general treatment of idleness.
21202 On other systems, idle time refers to Emacs idle time only.
21204 [fn:81] Please note the pitfalls of summing hierarchical data in
21205 a flat list (see [[*Using Column View in the Agenda]]).
21207 [fn:82] Org used to offer four different targets for date/week tree
21208 capture.  Now, Org automatically translates these to use
21209 ~file+olp+datetree~, applying the ~:time-prompt~ and ~:tree-type~
21210 properties.  Please rewrite your date/week-tree targets using
21211 ~file+olp+datetree~ since the older targets are now deprecated.
21213 [fn:83] A date tree is an outline structure with years on the highest
21214 level, months or ISO weeks as sublevels and then dates on the lowest
21215 level.  Tags are allowed in the tree structure.
21217 [fn:84] If you need one of these sequences literally, escape the =%=
21218 with a backslash.
21220 [fn:85] If you define your own link types (see [[*Adding Hyperlink
21221 Types]]), any property you store with ~org-store-link-props~ can be
21222 accessed in capture templates in a similar way.
21224 [fn:86] This is always the other, not the user.  See the variable
21225 ~org-link-from-user-regexp~.
21227 [fn:87] If you move entries or Org files from one directory to
21228 another, you may want to configure ~org-attach-directory~ to contain
21229 an absolute path.
21231 [fn:88] Note the corresponding =STARTUP= options =logrefile=,
21232 =lognoterefile=, and =nologrefile=.
21234 [fn:89] If the value of that variable is not a list, but a single file
21235 name, then the list of agenda files in maintained in that external
21236 file.
21238 [fn:90] When using the dispatcher, pressing {{{kbd(<)}}} before
21239 selecting a command actually limits the command to the current file,
21240 and ignores ~org-agenda-files~ until the next dispatcher command.
21242 [fn:91] For backward compatibility, you can also press {{{kbd(1)}}} to
21243 restrict to the current buffer.
21245 [fn:92] For backward compatibility, you can also press {{{kbd(0)}}} to
21246 restrict to the current region/subtree.
21248 [fn:93] For backward compatibility, the universal prefix argument
21249 {{{kbd(C-u)}}} causes all TODO entries to be listed before the agenda.
21250 This feature is deprecated, use the dedicated TODO list, or a block
21251 agenda instead (see [[*Block agenda]]).
21253 [fn:94] The variable ~org-anniversary~ used in the example is just
21254 like ~diary-anniversary~, but the argument order is always according
21255 to ISO and therefore independent of the value of
21256 ~calendar-date-style~.
21258 [fn:95] You can, however, disable this by setting
21259 ~org-agenda-search-headline-for-time~ variable to a ~nil~ value.
21261 [fn:96] Custom commands can preset a filter by binding the variable
21262 ~org-agenda-tag-filter-preset~ as an option.  This filter is then
21263 applied to the view and persists as a basic filter through refreshes
21264 and more secondary filtering.  The filter is a global property of the
21265 entire agenda view---in a block agenda, you should only set this in
21266 the global options section, not in the section of an individual block.
21268 [fn:97] Only tags filtering is respected here, effort filtering is
21269 ignored.
21271 [fn:98] You can also create persistent custom functions through
21272 ~org-agenda-bulk-custom-functions~.
21274 [fn:99] This file is parsed for the agenda when
21275 ~org-agenda-include-diary~ is set.
21277 [fn:100] You can provide a description for a prefix key by inserting
21278 a cons cell with the prefix and the description.
21280 [fn:101] /Planned/ means here that these entries have some planning
21281 information attached to them, like a time-stamp, a scheduled or
21282 a deadline string.  See ~org-agenda-entry-types~ on how to set what
21283 planning information is taken into account.
21285 [fn:102] For HTML you need to install Hrvoje Niksic's =htmlize.el=
21286 from [[https://github.com/hniksic/emacs-htmlize][Hrvoje Niksic's repository]].
21288 [fn:103] To create PDF output, the Ghostscript ps2pdf utility must be
21289 installed on the system.  Selecting a PDF file also creates the
21290 postscript file.
21292 [fn:104] If you want to store standard views like the weekly agenda or
21293 the global TODO list as well, you need to define custom commands for
21294 them in order to be able to specify file names.
21296 [fn:105] Quoting depends on the system you use, please check the FAQ
21297 for examples.
21299 [fn:106] You can turn this on by default by setting the variable
21300 ~org-pretty-entities~, or on a per-file base with the =STARTUP= option
21301 =entitiespretty=.
21303 [fn:107] This behavior can be disabled with =-= export setting (see
21304 [[*Export Settings]]).
21306 [fn:108] LaTeX is a macro system based on Donald\nbsp{}E.\nbsp{}Knuth's TeX
21307 system.  Many of the features described here as "LaTeX" are really
21308 from TeX, but for simplicity I am blurring this distinction.
21310 [fn:109] When MathJax is used, only the environments recognized by
21311 MathJax are processed.  When dvipng, dvisvgm, or ImageMagick suite is
21312 used to create images, any LaTeX environment is handled.
21314 [fn:110] These are respectively available at
21315 [[http://sourceforge.net/projects/dvipng/]], [[http://dvisvgm.bplaced.net/]]
21316 and from the ImageMagick suite.  Choose the converter by setting the
21317 variable ~org-preview-latex-default-process~ accordingly.
21319 [fn:111] Org mode has a method to test if point is inside such
21320 a fragment, see the documentation of the function
21321 ~org-inside-LaTeX-fragment-p~.
21323 [fn:112] This works automatically for the HTML backend (it requires
21324 version 1.34 of the =htmlize.el= package, which you need to install).
21325 Fontified code chunks in LaTeX can be achieved using either the
21326 [[https://www.ctan.org/pkg/listings][listings]] package or the [[https://www.ctan.org/pkg/minted][minted]] package.  Refer to
21327 ~org-export-latex-listings~ for details.
21329 [fn:113] Source code in code blocks may also be evaluated either
21330 interactively or on export.  See [[*Working with Source Code]] for more
21331 information on evaluating code blocks.
21333 [fn:114] Adding =-k= to =-n -r= /keeps/ the labels in the source code
21334 while using line numbers for the links, which might be useful to
21335 explain those in an Org mode example code.
21337 [fn:115] Upon exit, lines starting with =*=, =,*=, =#+= and =,#+= get
21338 a comma prepended, to keep them from being interpreted by Org as
21339 outline nodes or special syntax.  These commas are stripped when
21340 editing with {{{kbd(C-c ')}}}, and also before export.
21342 [fn:116] You may select a different-mode with the variable
21343 ~org-edit-fixed-width-region-mode~.
21345 [fn:117] What Emacs considers to be an image depends on
21346 ~image-file-name-extensions~ and ~image-file-name-regexps~.
21348 [fn:118] The variable ~org-startup-with-inline-images~ can be set
21349 within a buffer with the =STARTUP= options =inlineimages= and
21350 =noinlineimages=.
21352 [fn:119] The corresponding in-buffer setting is: =#+STARTUP: fninline=
21353 or =#+STARTUP: nofninline=.
21355 [fn:120] The corresponding in-buffer options are =#+STARTUP: fnadjust=
21356 and =#+STARTUP: nofnadjust=.
21358 [fn:121] The variable ~org-export-date-timestamp-format~ defines how
21359 this timestamp are exported.
21361 [fn:122] For export to LaTeX format---or LaTeX-related formats such as
21362 Beamer---, the =org-latex-package-alist= variable needs further
21363 configuration. See [[LaTeX specific export settings]].
21365 [fn:123] At the moment, some export back-ends do not obey this
21366 specification.  For example, LaTeX export excludes every unnumbered
21367 headline from the table of contents.
21369 [fn:124] Note that ~org-link-search-must-match-exact-headline~ is
21370 locally bound to non-~nil~.  Therefore, ~org-link-search~ only matches
21371 headlines and named elements.
21373 [fn:125] Since commas separate the arguments, commas within arguments
21374 have to be escaped with the backslash character.  So only those
21375 backslash characters before a comma need escaping with another
21376 backslash character.
21378 [fn:126] For a less drastic behavior, consider using a select tag (see
21379 [[*Export Settings]]) instead.
21381 [fn:127] If =BEAMER_ENV= is set, Org export adds =B_environment= tag
21382 to make it visible.  The tag serves as a visual aid and has no
21383 semantic relevance.
21385 [fn:128] By default Org loads MathJax from [[https://cdnjs.com][cdnjs.com]] as recommended by
21386 [[http://www.mathjax.org][MathJax]].
21388 [fn:129] Please note that exported formulas are part of an HTML
21389 document, and that signs such as =<=, =>=, or =&= have special
21390 meanings.  See [[http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents][MathJax TeX and LaTeX support]].
21392 [fn:130] See [[http://docs.mathjax.org/en/latest/tex.html#tex-extensions][TeX and LaTeX extensions]] in the [[http://docs.mathjax.org][MathJax manual]] to learn
21393 about extensions.
21395 [fn:131] If the classes on TODO keywords and tags lead to conflicts,
21396 use the variables ~org-html-todo-kwd-class-prefix~ and
21397 ~org-html-tag-class-prefix~ to make them unique.
21399 [fn:132] This does not allow setting different bibliography compilers
21400 for different files.  However, "smart" LaTeX compilation systems, such
21401 as latexmk, can select the correct bibliography compiler.
21403 [fn:133] See [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][Open Document Format for Office Applications
21404 (OpenDocument) Version 1.2]].
21406 [fn:134] See [[http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl][MathToWeb]].
21408 [fn:135] See [[http://dlmf.nist.gov/LaTeXML/]].
21410 [fn:136] [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][OpenDocument-v1.2 Specification]]
21412 [fn:137] See the =<table:table-template>= element of the
21413 OpenDocument-v1.2 specification.
21415 [fn:138] See the attributes =table:template-name=,
21416 =table:use-first-row-styles=, =table:use-last-row-styles=,
21417 =table:use-first-column-styles=, =table:use-last-column-styles=,
21418 =table:use-banding-rows-styles=, and =table:use-banding-column-styles=
21419 of the =<table:table>= element in the OpenDocument-v1.2 specification.
21421 [fn:139] If the publishing directory is the same as the source
21422 directory, =file.org= is exported as =file.org.org=, so you probably
21423 do not want to do this.
21425 [fn:140] The option ~org-babel-no-eval-on-ctrl-c-ctrl-c~ can be used
21426 to remove code evaluation from the {{{kbd(C-c C-c)}}} key binding.
21428 [fn:141] Actually, the constructs =call_<name>()= and =src_<lang>{}=
21429 are not evaluated when they appear in a keyword (see [[*Summary of
21430 In-Buffer Settings]]).
21432 [fn:142] Due to the way this header argument is implemented, it
21433 implies ":results file".  Therefore if it is set for multiple blocks
21434 at once (by a subtree or buffer property for example), all blocks are
21435 forced to produce file results.  This is seldom desired behavior, so
21436 it is recommended to set this header only on a per-block basis.  It is
21437 possible that this aspect of the implementation might change in the
21438 future.
21440 [fn:143] C++ language is handled in =ob-C.el=.  Even though the
21441 identifier for such source blocks is =C++=, you activate it by loading
21442 the C language.
21444 [fn:144] D language is handled in =ob-C.el=.  Even though the
21445 identifier for such source blocks is =D=, you activate it by loading
21446 the C language.
21448 [fn:145] For Noweb literate programming details, see
21449 http://www.cs.tufts.edu/~nr/noweb/.
21451 [fn:146] For more information, please refer to the commentary section
21452 in =org-tempo.el=.
21454 [fn:147] Note that ~org-indent-mode~ also sets the ~wrap-prefix~
21455 property, such that ~visual-line-mode~ (or purely setting ~word-wrap~)
21456 wraps long lines (including headlines) correctly indented.
21458 [fn:148] The ~org-indent-mode~ also sets the ~wrap-prefix~ correctly
21459 for indenting and wrapping long lines of headlines or text.  This
21460 minor mode handles ~visual-line-mode~ and directly applied settings
21461 through ~word-wrap~.
21463 [fn:149] Also see the variable ~org-adapt-indentation~.
21465 [fn:150] Because =LEVEL=2= has 3 stars, =LEVEL=3= has 5 stars, and so
21468 [fn:151] For a server to host files, consider using a WebDAV server,
21469 such as [[https://nextcloud.com][Nextcloud]].  Additional help is at this [[https://orgmode.org/worg/org-faq.html#mobileorg_webdav][FAQ entry]].
21471 [fn:152] If Emacs is configured for safe storing of passwords, then
21472 configure the variable ~org-mobile-encryption-password~; please read
21473 the docstring of that variable.
21475 [fn:153] Symbolic links in ~org-directory~ need to have the same name
21476 as their targets.
21478 [fn:154] While creating the agendas, Org mode forces =ID= properties
21479 on all referenced entries, so that these entries can be uniquely
21480 identified if Org Mobile flags them for further action.  To avoid
21481 setting properties configure the variable
21482 ~org-mobile-force-id-on-agenda-items~ to ~nil~.  Org mode then relies
21483 on outline paths, assuming they are unique.
21485 [fn:155] Checksums are stored automatically in the file
21486 =checksums.dat=.
21488 [fn:156] The file will be empty after this operation.
21490 [fn:157] https://www.ctan.org/pkg/comment
21492 [fn:158] By default this works only for LaTeX, HTML, and Texinfo.
21493 Configure the variable ~orgtbl-radio-table-templates~ to install
21494 templates for other modes.
21496 [fn:159] If the =TBLFM= keyword contains an odd number of dollar
21497 characters, this may cause problems with Font Lock in LaTeX mode.  As
21498 shown in the example you can fix this by adding an extra line inside
21499 the =comment= environment that is used to balance the dollar
21500 expressions.  If you are using AUCTeX with the font-latex library,
21501 a much better solution is to add the =comment= environment to the
21502 variable ~LaTeX-verbatim-environments~.
21504 [fn:160] The ~agenda*~ view is the same as ~agenda~ except that it
21505 only considers /appointments/, i.e., scheduled and deadline items that
21506 have a time specification =[h]h:mm= in their time-stamps.
21508 [fn:161] Note that, for ~org-odd-levels-only~, a level number
21509 corresponds to order in the hierarchy, not to the number of stars.