Merge branch 'agenda-subtree-kill-with-subtree-feedback'
[org-mode/org-tableheadings.git] / doc / org-manual.org
blob5af9d66321355e4aaec1cc10a5acefdbfefcbe36
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)}}} (~outline-next-visible-heading~) ::
617   #+kindex: C-c C-n
618   #+findex: outline-next-visible-heading
619   Next heading.
621 - {{{kbd(C-c C-p)}}} (~outline-previous-visible-heading~) ::
623   #+kindex: C-c C-p
624   #+findex: outline-previous-visible-heading
625   Previous heading.
627 - {{{kbd(C-c C-f)}}} (~org-forward-same-level~) ::
629   #+kindex: C-c C-f
630   #+findex: org-forward-same-level
631   Next heading same level.
633 - {{{kbd(C-c C-b)}}} (~org-backward-same-level~) ::
635   #+kindex: C-c C-b
636   #+findex: org-backward-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-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-link-to-org-use-id~, create and/or use a globally unique =ID=
3182   property for the link[fn:29].  So using this command in Org buffers
3183   potentially creates two links: a human-readable link from the custom
3184   ID, and one that is globally unique and works even if the entry is
3185   moved from file to file.  Later, when inserting the link, you need
3186   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"       . "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?author=%s&db_key=AST")))
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 C-x C-k)}}} (~org-mark-entry-for-agenda-action~) ::
6070   #+kindex: C-c C-x C-k
6071   #+kindex: k a
6072   #+kindex: k s
6073   #+findex: org-mark-entry-for-agenda-action
6074   Mark the current entry for agenda action.  After you have marked the
6075   entry like this, you can open the agenda or the calendar to find an
6076   appropriate date.  With point on the selected date, press {{{kbd(k
6077   s)}}} or {{{kbd(k d)}}} to schedule the marked item.
6079 - {{{kbd(C-c / d)}}} (~org-check-deadlines~) ::
6081   #+kindex: C-c / d
6082   #+findex: org-check-deadlines
6083   #+cindex: sparse tree, for deadlines
6084   #+vindex: org-deadline-warning-days
6085   Create a sparse tree with all deadlines that are either past-due, or
6086   which will become due within ~org-deadline-warning-days~.  With
6087   {{{kbd(C-u)}}} prefix, show all deadlines in the file.  With
6088   a numeric prefix, check that many days.  For example, {{{kbd(C-1 C-c
6089   / d)}}} shows all deadlines due tomorrow.
6091 - {{{kbd(C-c / b)}}} (~org-check-before-date~) ::
6093   #+kindex: C-c / b
6094   #+findex: org-check-before-date
6095   Sparse tree for deadlines and scheduled items before a given date.
6097 - {{{kbd(C-c / a)}}} (~org-check-after-date~) ::
6099   #+kindex: C-c / a
6100   #+findex: org-check-after-date
6101   Sparse tree for deadlines and scheduled items after a given date.
6103 Note that ~org-schedule~ and ~org-deadline~ supports setting the date
6104 by indicating a relative time e.g., =+1d= sets the date to the next
6105 day after today, and =--1w= sets the date to the previous week before
6106 any current timestamp.
6108 *** Repeated tasks
6109 :PROPERTIES:
6110 :DESCRIPTION: Items that show up again and again.
6111 :END:
6112 #+cindex: tasks, repeated
6113 #+cindex: repeated tasks
6115 Some tasks need to be repeated again and again.  Org mode helps to
6116 organize such tasks using a so-called repeater in a =DEADLINE=,
6117 =SCHEDULED=, or plain timestamps[fn:68].  In the following example:
6119 #+begin_example
6120 ,** TODO Pay the rent
6121    DEADLINE: <2005-10-01 Sat +1m>
6122 #+end_example
6124 #+texinfo: @noindent
6125 the =+1m= is a repeater; the intended interpretation is that the task
6126 has a deadline on =<2005-10-01>= and repeats itself every (one) month
6127 starting from that time.  You can use yearly, monthly, weekly, daily
6128 and hourly repeat cookies by using the =y=, =w=, =m=, =d= and =h=
6129 letters.  If you need both a repeater and a special warning period in
6130 a deadline entry, the repeater should come first and the warning
6131 period last
6133 : DEADLINE: <2005-10-01 Sat +1m -3d>
6135 #+vindex: org-todo-repeat-to-state
6136 Deadlines and scheduled items produce entries in the agenda when they
6137 are over-due, so it is important to be able to mark such an entry as
6138 done once you have done so.  When you mark a =DEADLINE= or
6139 a =SCHEDULED= with the TODO keyword =DONE=, it no longer produces
6140 entries in the agenda.  The problem with this is, however, is that
6141 then also the /next/ instance of the repeated entry will not be
6142 active.  Org mode deals with this in the following way: when you try
6143 to mark such an entry as done, using {{{kbd(C-c C-t)}}}, it shifts the
6144 base date of the repeating timestamp by the repeater interval, and
6145 immediately sets the entry state back to TODO[fn:69].  In the example
6146 above, setting the state to =DONE= would actually switch the date like
6147 this:
6149 #+begin_example
6150 ,** TODO Pay the rent
6151    DEADLINE: <2005-11-01 Tue +1m>
6152 #+end_example
6154 To mark a task with a repeater as DONE, use {{{kbd(C-- 1 C-c C-t)}}},
6155 i.e., ~org-todo~ with a numeric prefix argument of =-1=.
6157 #+vindex: org-log-repeat
6158 A timestamp[fn:70] is added under the deadline, to keep a record that
6159 you actually acted on the previous instance of this deadline.
6161 As a consequence of shifting the base date, this entry is no longer
6162 visible in the agenda when checking past dates, but all future
6163 instances will be visible.
6165 With the =+1m= cookie, the date shift is always exactly one month.  So
6166 if you have not paid the rent for three months, marking this entry
6167 DONE still keeps it as an overdue deadline.  Depending on the task,
6168 this may not be the best way to handle it.  For example, if you forgot
6169 to call your father for 3 weeks, it does not make sense to call him
6170 3 times in a single day to make up for it.  Finally, there are tasks
6171 like changing batteries which should always repeat a certain time
6172 /after/ the last time you did it.  For these tasks, Org mode has
6173 special repeaters =++= and =.+=.  For example:
6175 #+begin_example
6176 ,** TODO Call Father
6177    DEADLINE: <2008-02-10 Sun ++1w>
6178    Marking this DONE shifts the date by at least one week, but also
6179    by as many weeks as it takes to get this date into the future.
6180    However, it stays on a Sunday, even if you called and marked it
6181    done on Saturday.
6183 ,** TODO Empty kitchen trash
6184    DEADLINE: <2008-02-08 Fri 20:00 ++1d>
6185    Marking this DONE shifts the date by at least one day, and also
6186    by as many days as it takes to get the timestamp into the future.
6187    Since there is a time in the timestamp, the next deadline in the
6188    future will be on today's date if you complete the task before
6189    20:00.
6191 ,** TODO Check the batteries in the smoke detectors
6192    DEADLINE: <2005-11-01 Tue .+1m>
6193    Marking this DONE will shift the date to one month after today.
6194 #+end_example
6196 #+vindex: org-agenda-skip-scheduled-if-deadline-is-shown
6197 You may have both scheduling and deadline information for a specific
6198 task.  If the repeater is set for the scheduling information only, you
6199 probably want the repeater to be ignored after the deadline.  If so,
6200 set the variable ~org-agenda-skip-scheduled-if-deadline-is-shown~ to
6201 ~repeated-after-deadline~.  However, any scheduling information
6202 without a repeater is no longer relevant once the task is done, and
6203 thus, removed upon repeating the task.  If you want both scheduling
6204 and deadline information to repeat after the same interval, set the
6205 same repeater for both timestamps.
6207 An alternative to using a repeater is to create a number of copies of
6208 a task subtree, with dates shifted in each copy.  The command
6209 {{{kbd(C-c C-x c)}}} was created for this purpose; it is described in
6210 [[*Structure Editing]].
6212 ** Clocking Work Time
6213 :PROPERTIES:
6214 :DESCRIPTION: Tracking how long you spend on a task.
6215 :END:
6216 #+cindex: clocking time
6217 #+cindex: time clocking
6219 Org mode allows you to clock the time you spend on specific tasks in
6220 a project.  When you start working on an item, you can start the
6221 clock.  When you stop working on that task, or when you mark the task
6222 done, the clock is stopped and the corresponding time interval is
6223 recorded.  It also computes the total time spent on each
6224 subtree[fn:71] of a project.  And it remembers a history or tasks
6225 recently clocked, to that you can jump quickly between a number of
6226 tasks absorbing your time.
6228 To save the clock history across Emacs sessions, use:
6230 #+begin_src emacs-lisp
6231 (setq org-clock-persist 'history)
6232 (org-clock-persistence-insinuate)
6233 #+end_src
6235 #+vindex: org-clock-persist
6236 When you clock into a new task after resuming Emacs, the incomplete
6237 clock[fn:72] is retrieved (see [[*Resolving idle time]]) and you are
6238 prompted about what to do with it.
6240 *** Clocking commands
6241 :PROPERTIES:
6242 :DESCRIPTION: Starting and stopping a clock.
6243 :END:
6245 #+attr_texinfo: :sep ,
6246 - {{{kbd(C-c C-x C-i)}}} (~org-clock-in~) ::
6248   #+kindex: C-c C-x C-i
6249   #+findex: org-clock-in
6250   #+vindex: org-clock-into-drawer
6251   #+vindex: org-clock-continuously
6252   #+cindex: @samp{LOG_INTO_DRAWER}, property
6253   Start the clock on the current item (clock-in).  This inserts the
6254   =CLOCK= keyword together with a timestamp.  If this is not the first
6255   clocking of this item, the multiple =CLOCK= lines are wrapped into
6256   a =LOGBOOK= drawer (see also the variable ~org-clock-into-drawer~).
6257   You can also overrule the setting of this variable for a subtree by
6258   setting a =CLOCK_INTO_DRAWER= or =LOG_INTO_DRAWER= property.  When
6259   called with a {{{kbd(C-u)}}} prefix argument, select the task from
6260   a list of recently clocked tasks.  With two {{{kbd(C-u C-u)}}}
6261   prefixes, clock into the task at point and mark it as the default
6262   task; the default task is always be available with letter
6263   {{{kbd(d)}}} when selecting a clocking task.  With three {{{kbd(C-u
6264   C-u C-u)}}} prefixes, force continuous clocking by starting the
6265   clock when the last clock stopped.
6267   #+cindex: @samp{CLOCK_MODELINE_TOTAL}, property
6268   #+cindex: @samp{LAST_REPEAT}, property
6269   #+vindex: org-clock-mode-line-total
6270   #+vindex: org-clock-in-prepare-hook
6271   While the clock is running, Org shows the current clocking time in
6272   the mode line, along with the title of the task.  The clock time
6273   shown is all time ever clocked for this task and its children.  If
6274   the task has an effort estimate (see [[*Effort Estimates]]), the mode
6275   line displays the current clocking time against it[fn:73].  If the
6276   task is a repeating one (see [[*Repeated tasks]]), show only the time
6277   since the last reset of the task[fn:74].  You can exercise more
6278   control over show time with the =CLOCK_MODELINE_TOTAL= property.  It
6279   may have the values =current= to show only the current clocking
6280   instance, =today= to show all time clocked on this tasks today---see
6281   also the variable ~org-extend-today-until~, ~all~ to include all
6282   time, or ~auto~ which is the default[fn:75].  Clicking with
6283   {{{kbd(mouse-1)}}} onto the mode line entry pops up a menu with
6284   clocking options.
6286 - {{{kbd(C-c C-x C-o)}}} (~org-clock-out~) ::
6288   #+kindex: C-c C-x C-o
6289   #+findex: org-clock-out
6290   #+vindex: org-log-note-clock-out
6291   Stop the clock (clock-out).  This inserts another timestamp at the
6292   same location where the clock was last started.  It also directly
6293   computes the resulting time in inserts it after the time range as
6294   ==>HH:MM=.  See the variable ~org-log-note-clock-out~ for the
6295   possibility to record an additional note together with the clock-out
6296   timestamp[fn:76].
6298 - {{{kbd(C-c C-x C-x)}}} (~org-clock-in-last~) ::
6300   #+kindex: C-c C-x C-x
6301   #+findex: org-clock-in-last
6302   #+vindex: org-clock-continuously
6303   Re-clock the last clocked task.  With one {{{kbd(C-u)}}} prefix
6304   argument, select the task from the clock history.  With two
6305   {{{kbd(C-u)}}} prefixes, force continuous clocking by starting the
6306   clock when the last clock stopped.
6308 - {{{kbd(C-c C-x C-e)}}} (~org-clock-modify-effort-estimate~) ::
6310   #+kindex: C-c C-x C-e
6311   #+findex: org-clock-modify-effort-estimate
6312   Update the effort estimate for the current clock task.
6314 - {{{kbd(C-c C-c)}}} or {{{kbd(C-c C-y)}}} (~org-evaluate-time-range~) ::
6316   #+kindex: C-c C-c
6317   #+kindex: C-c C-y
6318   #+findex: org-evaluate-time-range
6319   Recompute the time interval after changing one of the timestamps.
6320   This is only necessary if you edit the timestamps directly.  If you
6321   change them with {{{kbd(S-<cursor>)}}} keys, the update is
6322   automatic.
6324 - {{{kbd(C-S-UP)}}} (~org-clock-timestamps-up~), {{{kbd(C-S-DOWN)}}} (~org-clock-timestamps-down~) ::
6326   #+kindex: C-S-UP
6327   #+findex: org-clock-timestamps-up
6328   #+kindex: C-S-DOWN
6329   #+findex: org-clock-timestamps-down
6330   On CLOCK log lines, increase/decrease both timestamps so that the
6331   clock duration keeps the same value.
6333 - {{{kbd(S-M-UP)}}} (~org-timestamp-up~), {{{kbd(S-M-DOWN)}}} (~org-timestamp-down~) ::
6335   #+kindex: S-M-UP
6336   #+findex: org-clock-timestamp-up
6337   #+kindex: S-M-DOWN
6338   #+findex: org-clock-timestamp-down
6339   On =CLOCK= log lines, increase/decrease the timestamp at point and
6340   the one of the previous, or the next, clock timestamp by the same
6341   duration.  For example, if you hit {{{kbd(S-M-UP)}}} to increase
6342   a clocked-out timestamp by five minutes, then the clocked-in
6343   timestamp of the next clock is increased by five minutes.
6345 - {{{kbd(C-c C-t)}}} (~org-todo~) ::
6347   #+kindex: C-c C-t
6348   #+findex: org-todo
6349   Changing the TODO state of an item to DONE automatically stops the
6350   clock if it is running in this same item.
6352 - {{{kbd(C-c C-x C-q)}}} (~org-clock-cancel~) ::
6354   #+kindex: C-c C-x C-q
6355   #+findex: org-clock-cancel
6356   Cancel the current clock.  This is useful if a clock was started by
6357   mistake, or if you ended up working on something else.
6359 - {{{kbd(C-c C-x C-j)}}} (~org-clock-goto~) ::
6361   #+kindex: C-c C-x C-j
6362   #+findex: or-clock-goto
6363   Jump to the headline of the currently clocked in task.  With
6364   a {{{kbd(C-u)}}} prefix argument, select the target task from a list
6365   of recently clocked tasks.
6367 - {{{kbd(C-c C-x C-d)}}} (~org-clock-display~) ::
6369   #+kindex: C-c C-x C-d
6370   #+findex: org-clock-display
6371   #+vindex: org-remove-highlights-with-change
6372   Display time summaries for each subtree in the current buffer.  This
6373   puts overlays at the end of each headline, showing the total time
6374   recorded under that heading, including the time of any subheadings.
6375   You can use visibility cycling to study the tree, but the overlays
6376   disappear when you change the buffer (see variable
6377   ~org-remove-highlights-with-change~) or press {{{kbd(C-c C-c)}}}.
6379 The {{{kbd(l)}}} key may be used in the agenda (see [[*Weekly/daily
6380 agenda]]) to show which tasks have been worked on or closed during
6381 a day.
6383 *Important:* note that both ~org-clock-out~ and ~org-clock-in-last~
6384 can have a global keybinding and do not modify the window disposition.
6386 *** The clock table
6387 :PROPERTIES:
6388 :DESCRIPTION: Detailed reports.
6389 :END:
6390 #+cindex: clocktable, dynamic block
6391 #+cindex: report, of clocked time
6393 Org mode can produce quite complex reports based on the time clocking
6394 information.  Such a report is called a /clock table/, because it is
6395 formatted as one or several Org tables.
6397 You can insert, or update, a clock table through Org dynamic blocks
6398 insert command (see [[*Dynamic Blocks]]), by pressing {{{kbd(C-c C-x
6399 x c l o c k t a b l e RET)}}}.  When called with a prefix argument,
6400 jump to the first clock table in the current document and update it.
6401 The clock table includes archived trees.
6403 #+attr_texinfo: :sep ,
6404 - {{{kbd(C-c C-c)}}} or {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
6406   #+kindex: C-c C-c
6407   #+kindex: C-c C-x C-u
6408   #+findex: org-dblock-update
6409   Update dynamic block at point.  Point needs to be in the =BEGIN=
6410   line of the dynamic block.
6412 - {{{kbd(C-u C-c C-x C-u)}}} ::
6414   #+kindex: C-u C-c C-x C-u
6415   Update all dynamic blocks (see [[*Dynamic Blocks]]).  This is useful if
6416   you have several clock table blocks in a buffer.
6418 - {{{kbd(S-LEFT)}}}, {{{kbd(S-RIGHT)}}} (~org-clocktable-try-shift~) ::
6420   #+kindex: S-LEFT
6421   #+kindex: S-RIGHT
6422   #+findex: org-clocktable-try-shift
6423   Shift the current =:block= interval and update the table.  Point
6424   needs to be in the =#+BEGIN: clocktable= line for this command.  If
6425   =:block= is =today=, it is shifted to =today-1=, etc.
6427 Here is an example of the frame for a clock table as it is inserted
6428 into the buffer with the {{{kbd(C-c C-x C-r)}}} command:
6430 #+cindex: @samp{BEGIN clocktable}
6431 #+begin_example
6432 ,#+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
6433 ,#+END: clocktable
6434 #+end_example
6436 #+vindex: org-clocktable-defaults
6437 The =#+BEGIN= line and specify a number of options to define the
6438 scope, structure, and formatting of the report.  Defaults for all
6439 these options can be configured in the variable
6440 ~org-clocktable-defaults~.
6442 First there are options that determine which clock entries are to
6443 be selected:
6445 - =:maxlevel= ::
6447   Maximum level depth to which times are listed in the table.  Clocks
6448   at deeper levels are summed into the upper level.
6450 - =:scope= ::
6452   The scope to consider.  This can be any of the following:
6454   | =nil=                  | the current buffer or narrowed region                               |
6455   | =file=                 | the full current buffer                                             |
6456   | =subtree=              | the subtree where the clocktable is located                         |
6457   | =treeN=                | the surrounding level N tree, for example =tree3=                   |
6458   | =tree=                 | the surrounding level 1 tree                                        |
6459   | =agenda=               | all agenda files                                                    |
6460   | =("file" ...)=         | scan these files                                                    |
6461   | =FUNCTION=             | scan files returned by calling {{{var(FUNCTION)}}} with no argument |
6462   | =file-with-archives=   | current file and its archives                                       |
6463   | =agenda-with-archives= | all agenda files, including archives                                |
6465 - =:block= ::
6467   The time block to consider.  This block is specified either
6468   absolutely, or relative to the current time and may be any of these
6469   formats:
6471   | =2007-12-31=                            | New year eve 2007     |
6472   | =2007-12=                               | December 2007         |
6473   | =2007-W50=                              | ISO-week 50 in 2007   |
6474   | =2007-Q2=                               | 2nd quarter in 2007   |
6475   | =2007=                                  | the year 2007         |
6476   | =today=, =yesterday=, =today-N=         | a relative day        |
6477   | =thisweek=, =lastweek=, =thisweek-N=    | a relative week       |
6478   | =thismonth=, =lastmonth=, =thismonth-N= | a relative month      |
6479   | =thisyear=, =lastyear=, =thisyear-N=    | a relative year       |
6480   | =untilnow=[fn:77]                       | all clocked time ever |
6482   #+vindex: org-clock-display-default-range
6483   When this option is not set, Org falls back to the value in
6484   ~org-clock-display-default-range~, which defaults to the current
6485   year.
6487   Use {{{kbd(S-LEFT)}}} or {{{kbd(S-RIGHT)}}} to shift the time
6488   interval.
6490 - =:tstart= ::
6492   A time string specifying when to start considering times.  Relative
6493   times like ="<-2w>"= can also be used.  See [[*Matching tags and
6494   properties]] for relative time syntax.
6496 - =:tend= ::
6498   A time string specifying when to stop considering times.  Relative
6499   times like ="<now>"= can also be used.  See [[*Matching tags and
6500   properties]] for relative time syntax.
6502 - =:wstart= ::
6504   The starting day of the week.  The default is 1 for Monday.
6506 - =:mstart= ::
6508   The starting day of the month.  The default is 1 for the first.
6510 - =:step= ::
6512   Set to =day=, =week=, =month= or =year= to split the table into
6513   chunks.  To use this, either =:block=, or =:tstart= and =:tend= are
6514   required.
6516 - =:stepskip0= ::
6518   When non-~nil~, do not show steps that have zero time.
6520 - =:fileskip0= ::
6522   When non-~nil~, do not show table sections from files which did not
6523   contribute.
6525 - =:match= ::
6527   A tags match to select entries that should contribute.  See
6528   [[*Matching tags and properties]] for the match syntax.
6530 #+findex: org-clocktable-write-default
6531 Then there are options that determine the formatting of the table.
6532 There options are interpreted by the function
6533 ~org-clocktable-write-default~, but you can specify your own function
6534 using the =:formatter= parameter.
6536 - =:emphasize= ::
6538   When non-~nil~, emphasize level one and level two items.
6540 - =:lang= ::
6542   Language[fn:78] to use for descriptive cells like "Task".
6544 - =:link= ::
6546   Link the item headlines in the table to their origins.
6548 - =:narrow= ::
6550   An integer to limit the width of the headline column in the Org
6551   table.  If you write it like =50!=, then the headline is also
6552   shortened in export.
6554 - =:indent= ::
6556   Indent each headline field according to its level.
6558 - =:tcolumns= ::
6560   Number of columns to be used for times.  If this is smaller than
6561   =:maxlevel=, lower levels are lumped into one column.
6563 - =:level= ::
6565   Should a level number column be included?
6567 - =:sort= ::
6569   A cons cell containing the column to sort and a sorting type.  E.g.,
6570   =:sort (1 . ?a)= sorts the first column alphabetically.
6572 - =:compact= ::
6574   Abbreviation for =:level nil :indent t :narrow 40! :tcolumns 1=.
6575   All are overwritten except if there is an explicit =:narrow=.
6577 - =:timestamp= ::
6579   A timestamp for the entry, when available.  Look for =SCHEDULED=,
6580   =DEADLINE=, =TIMESTAMP= and =TIMESTAMP_IA= special properties (see
6581   [[*Special Properties]]), in this order.
6583 - =:tags= ::
6585   When this flag is non-~nil~, show the headline's tags.
6587 - =:properties= ::
6589   List of properties shown in the table.  Each property gets its own
6590   column.
6592 - =:inherit-props= ::
6594   When this flag is non-~nil~, the values for =:properties= are
6595   inherited.
6597 - =:formula= ::
6599   Content of a =TBLFM= keyword to be added and evaluated.  As
6600   a special case, =:formula %= adds a column with % time.  If you do
6601   not specify a formula here, any existing formula below the clock
6602   table survives updates and is evaluated.
6604 - =:formatter= ::
6606   A function to format clock data and insert it into the buffer.
6608 To get a clock summary of the current level 1 tree, for the current
6609 day, you could write:
6611 #+begin_example
6612 ,#+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
6613 ,#+END: clocktable
6614 #+end_example
6616 #+texinfo: @noindent
6617 To use a specific time range you could write[fn:79]
6619 #+begin_example
6620 ,#+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
6621                     :tend "<2006-08-10 Thu 12:00>"
6622 ,#+END: clocktable
6623 #+end_example
6625 #+texinfo: @noindent
6626 A range starting a week ago and ending right now could be written as
6628 #+begin_example
6629 ,#+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
6630 ,#+END: clocktable
6631 #+end_example
6633 #+texinfo: @noindent
6634 A summary of the current subtree with % times would be
6636 #+begin_example
6637 ,#+BEGIN: clocktable :scope subtree :link t :formula %
6638 ,#+END: clocktable
6639 #+end_example
6641 #+texinfo: @noindent
6642 A horizontally compact representation of everything clocked during
6643 last week would be
6645 #+begin_example
6646 ,#+BEGIN: clocktable :scope agenda :block lastweek :compact t
6647 ,#+END: clocktable
6648 #+end_example
6650 *** Resolving idle time and continuous clocking
6651 :PROPERTIES:
6652 :DESCRIPTION: Resolving time when you've been idle.
6653 :ALT_TITLE: Resolving idle time
6654 :END:
6656 **** Resolving idle time
6657 :PROPERTIES:
6658 :UNNUMBERED: notoc
6659 :END:
6661 #+cindex: resolve idle time
6662 #+cindex: idle, resolve, dangling
6664 If you clock in on a work item, and then walk away from your
6665 computer---perhaps to take a phone call---you often need to
6666 "resolve" the time you were away by either subtracting it from the
6667 current clock, or applying it to another one.
6669 #+vindex: org-clock-idle-time
6670 #+vindex: org-clock-x11idle-program-name
6671 By customizing the variable ~org-clock-idle-time~ to some integer,
6672 such as 10 or 15, Emacs can alert you when you get back to your
6673 computer after being idle for that many minutes[fn:80], and ask what
6674 you want to do with the idle time.  There will be a question waiting
6675 for you when you get back, indicating how much idle time has passed
6676 constantly updated with the current amount, as well as a set of
6677 choices to correct the discrepancy:
6679 - {{{kbd(k)}}} ::
6681   #+kindex: k
6682   To keep some or all of the minutes and stay clocked in, press
6683   {{{kbd(k)}}}.  Org asks how many of the minutes to keep.  Press
6684   {{{kbd(RET)}}} to keep them all, effectively changing nothing, or
6685   enter a number to keep that many minutes.
6687 - {{{kbd(K)}}} ::
6689   #+kindex: K
6690   If you use the shift key and press {{{kbd(K)}}}, it keeps however
6691   many minutes you request and then immediately clock out of that
6692   task.  If you keep all of the minutes, this is the same as just
6693   clocking out of the current task.
6695 - {{{kbd(s)}}} ::
6697   #+kindex: s
6698   To keep none of the minutes, use {{{kbd(s)}}} to subtract all the
6699   away time from the clock, and then check back in from the moment you
6700   returned.
6702 - {{{kbd(S)}}} ::
6704   #+kindex: S
6705   To keep none of the minutes and just clock out at the start of the
6706   away time, use the shift key and press {{{kbd(S)}}}.  Remember that
6707   using shift always leave you clocked out, no matter which option you
6708   choose.
6710 - {{{kbd(C)}}} ::
6712   #+kindex: C
6713   To cancel the clock altogether, use {{{kbd(C)}}}.  Note that if
6714   instead of canceling you subtract the away time, and the resulting
6715   clock amount is less than a minute, the clock is still canceled
6716   rather than cluttering up the log with an empty entry.
6718 What if you subtracted those away minutes from the current clock, and
6719 now want to apply them to a new clock?  Simply clock in to any task
6720 immediately after the subtraction.  Org will notice that you have
6721 subtracted time "on the books", so to speak, and will ask if you want
6722 to apply those minutes to the next task you clock in on.
6724 There is one other instance when this clock resolution magic occurs.
6725 Say you were clocked in and hacking away, and suddenly your cat chased
6726 a mouse who scared a hamster that crashed into your UPS's power
6727 button!  You suddenly lose all your buffers, but thanks to auto-save
6728 you still have your recent Org mode changes, including your last clock
6731 If you restart Emacs and clock into any task, Org will notice that you
6732 have a dangling clock which was never clocked out from your last
6733 session.  Using that clock's starting time as the beginning of the
6734 unaccounted-for period, Org will ask how you want to resolve that
6735 time.  The logic and behavior is identical to dealing with away time
6736 due to idleness; it is just happening due to a recovery event rather
6737 than a set amount of idle time.
6739 You can also check all the files visited by your Org agenda for
6740 dangling clocks at any time using {{{kbd(M-x org-resolve-clocks
6741 RET)}}} (or {{{kbd(C-c C-x C-z)}}}).
6743 **** Continuous clocking
6744 :PROPERTIES:
6745 :UNNUMBERED: notoc
6746 :END:
6747 #+cindex: continuous clocking
6749 #+vindex: org-clock-continuously
6750 You may want to start clocking from the time when you clocked out the
6751 previous task.  To enable this systematically, set
6752 ~org-clock-continuously~ to non-~nil~.  Each time you clock in, Org
6753 retrieves the clock-out time of the last clocked entry for this
6754 session, and start the new clock from there.
6756 If you only want this from time to time, use three universal prefix
6757 arguments with ~org-clock-in~ and two {{{kbd(C-u C-u)}}} with
6758 ~org-clock-in-last~.
6760 ** Effort Estimates
6761 :PROPERTIES:
6762 :DESCRIPTION: Planning work effort in advance.
6763 :END:
6764 #+cindex: effort estimates
6765 #+cindex: @samp{EFFORT}, property
6766 #+vindex: org-effort-property
6768 If you want to plan your work in a very detailed way, or if you need
6769 to produce offers with quotations of the estimated work effort, you
6770 may want to assign effort estimates to entries.  If you are also
6771 clocking your work, you may later want to compare the planned effort
6772 with the actual working time, a great way to improve planning
6773 estimates.  Effort estimates are stored in a special property
6774 =EFFORT=.  You can set the effort for an entry with the following
6775 commands:
6777 - {{{kbd(C-c C-x e)}}}  (~org-set-effort~) ::
6779   #+kindex: C-c C-x e
6780   #+findex: org-set-effort
6781   Set the effort estimate for the current entry.  With a prefix
6782   argument, set it to the next allowed value---see below.  This
6783   command is also accessible from the agenda with the {{{kbd(e)}}}
6784   key.
6786 - {{{kbd(C-c C-x C-e)}}} (~org-clock-modify-effort-estimate~) ::
6788   #+kindex: C-c C-x C-e
6789   #+findex: org-clock-modify-effort-estimate
6790   Modify the effort estimate of the item currently being clocked.
6792 Clearly the best way to work with effort estimates is through column
6793 view (see [[*Column View]]).  You should start by setting up discrete
6794 values for effort estimates, and a =COLUMNS= format that displays
6795 these values together with clock sums---if you want to clock your
6796 time.  For a specific buffer you can use:
6798 #+begin_example
6799 ,#+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
6800 ,#+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort){:} %CLOCKSUM
6801 #+end_example
6803 #+texinfo: @noindent
6804 #+vindex: org-global-properties
6805 #+vindex: org-columns-default-format
6806 or, even better, you can set up these values globally by customizing
6807 the variables ~org-global-properties~ and
6808 ~org-columns-default-format~.  In particular if you want to use this
6809 setup also in the agenda, a global setup may be advised.
6811 The way to assign estimates to individual items is then to switch to
6812 column mode, and to use {{{kbd(S-RIGHT)}}} and {{{kbd(S-LEFT)}}} to
6813 change the value.  The values you enter are immediately summed up in
6814 the hierarchy.  In the column next to it, any clocked time is
6815 displayed.
6817 #+vindex: org-agenda-columns-add-appointments-to-effort-sum
6818 If you switch to column view in the daily/weekly agenda, the effort
6819 column summarizes the estimated work effort for each day[fn:81], and
6820 you can use this to find space in your schedule.  To get an overview
6821 of the entire part of the day that is committed, you can set the
6822 option ~org-agenda-columns-add-appointments-to-effort-sum~.  The
6823 appointments on a day that take place over a specified time interval
6824 are then also added to the load estimate of the day.
6826 Effort estimates can be used in secondary agenda filtering that is
6827 triggered with the {{{kbd(/)}}} key in the agenda (see [[*Commands in
6828 the Agenda Buffer]]).  If you have these estimates defined consistently,
6829 two or three key presses narrow down the list to stuff that fits into
6830 an available time slot.
6832 ** Taking Notes with a Relative Timer
6833 :PROPERTIES:
6834 :DESCRIPTION: Notes with a running timer.
6835 :ALT_TITLE: Timers
6836 :END:
6837 #+cindex: relative timer
6838 #+cindex: countdown timer
6840 Org provides two types of timers.  There is a relative timer that
6841 counts up, which can be useful when taking notes during, for example,
6842 a meeting or a video viewing.  There is also a countdown timer.
6844 The relative and countdown are started with separate commands.
6846 - {{{kbd(C-c C-x 0)}}} (~org-timer-start~) ::
6848   #+kindex: C-c C-x 0
6849   #+findex: org-timer-start
6850   Start or reset the relative timer.  By default, the timer is set
6851   to 0.  When called with a {{{kbd(C-u)}}} prefix, prompt the user for
6852   a starting offset.  If there is a timer string at point, this is
6853   taken as the default, providing a convenient way to restart taking
6854   notes after a break in the process.  When called with a double
6855   prefix argument {{{kbd(C-u C-u)}}}, change all timer strings in the
6856   active region by a certain amount.  This can be used to fix timer
6857   strings if the timer was not started at exactly the right moment.
6859 - {{{kbd(C-c C-x ;)}}} (~org-timer-set-timer~) ::
6861   #+kindex: C-c C-x ;
6862   #+findex: org-timer-set-timer
6863   #+vindex: org-timer-default-timer
6864   Start a countdown timer.  The user is prompted for a duration.
6865   ~org-timer-default-timer~ sets the default countdown value.  Giving
6866   a numeric prefix argument overrides this default value.  This
6867   command is available as {{{kbd(;)}}} in agenda buffers.
6869 Once started, relative and countdown timers are controlled with the
6870 same commands.
6872 - {{{kbd(C-c C-x .)}}} (~org-timer~) ::
6874   #+kindex: C-c C-x .
6875   #+findex: org-timer
6876   Insert a relative time into the buffer.  The first time you use
6877   this, the timer starts.  Using a prefix argument restarts it.
6879 - {{{kbd(C-c C-x -)}}} (~org-timer-item~) ::
6881   #+kindex: C-c C-x -
6882   #+findex: org-timer-item
6883   Insert a description list item with the current relative time.  With
6884   a prefix argument, first reset the timer to 0.
6886 - {{{kbd(M-RET)}}} (~org-insert-heading~) ::
6888   #+kindex: M-RET
6889   #+findex: org-insert-heading
6890   Once the timer list is started, you can also use {{{kbd(M-RET)}}} to
6891   insert new timer items.
6893 - {{{kbd(C-c C-x \,)}}} (~org-timer-pause-or-continue~) ::
6895   #+kindex: C-c C-x ,
6896   #+findex: org-timer-pause-or-continue
6897   Pause the timer, or continue it if it is already paused.
6899 - {{{kbd(C-c C-x _)}}} (~org-timer-stop~) ::
6901   #+kindex: C-c C-x _
6902   #+findex: org-timer-stop
6903   Stop the timer.  After this, you can only start a new timer, not
6904   continue the old one.  This command also removes the timer from the
6905   mode line.
6907 * Capture, Refile, Archive
6908 :PROPERTIES:
6909 :DESCRIPTION: The ins and outs for projects.
6910 :END:
6911 #+cindex: capture
6913 An important part of any organization system is the ability to quickly
6914 capture new ideas and tasks, and to associate reference material with
6915 them.  Org does this using a process called /capture/.  It also can
6916 store files related to a task (/attachments/) in a special directory.
6917 Once in the system, tasks and projects need to be moved around.
6918 Moving completed project trees to an archive file keeps the system
6919 compact and fast.
6921 ** Capture
6922 :PROPERTIES:
6923 :DESCRIPTION: Capturing new stuff.
6924 :END:
6925 #+cindex: capture
6927 Capture lets you quickly store notes with little interruption of your
6928 work flow.  Org's method for capturing new items is heavily inspired
6929 by John Wiegley's excellent Remember package.
6931 *** Setting up capture
6932 :PROPERTIES:
6933 :DESCRIPTION: Where notes will be stored.
6934 :END:
6936 The following customization sets a default target file for notes.
6938 #+vindex: org-default-notes-file
6939 #+begin_src emacs-lisp
6940 (setq org-default-notes-file (concat org-directory "/notes.org"))
6941 #+end_src
6943 You may also define a global key for capturing new material (see
6944 [[*Activation]]).
6946 *** Using capture
6947 :PROPERTIES:
6948 :DESCRIPTION: Commands to invoke and terminate capture.
6949 :END:
6951 - {{{kbd(M-x org-capture)}}} (~org-capture~) ::
6953   #+findex: org-capture
6954   #+cindex: date tree
6955   Display the capture templates menu.  If you have templates defined
6956   (see [[*Capture templates]]), it offers these templates for selection or
6957   use a new Org outline node as the default template.  It inserts the
6958   template into the target file and switch to an indirect buffer
6959   narrowed to this new node.  You may then insert the information you
6960   want.
6962 - {{{kbd(C-c C-c)}}} (~org-capture-finalize~) ::
6964   #+kindex: C-c C-c @r{(Capture buffer)}
6965   #+findex: org-capture-finalize
6966   Once you have finished entering information into the capture buffer,
6967   {{{kbd(C-c C-c)}}} returns you to the window configuration before
6968   the capture process, so that you can resume your work without
6969   further distraction.  When called with a prefix argument, finalize
6970   and then jump to the captured item.
6972 - {{{kbd(C-c C-w)}}} (~org-capture-refile~) ::
6974   #+kindex: C-c C-w @r{(Capture buffer)}
6975   #+findex: org-capture-refile
6976   Finalize the capture process by refiling the note to a different
6977   place (see [[*Refile and Copy]]).  Please realize that this is a normal
6978   refiling command that will be executed---so point position at the
6979   moment you run this command is important.  If you have inserted
6980   a tree with a parent and children, first move point back to the
6981   parent.  Any prefix argument given to this command is passed on to
6982   the ~org-refile~ command.
6984 - {{{kbd(C-c C-k)}}} (~org-capture-kill~) ::
6986   #+kindex: C-c C-k @r{(Capture buffer)}
6987   #+findex: org-capture-kill
6988   Abort the capture process and return to the previous state.
6990 #+kindex: k c @r{(Agenda)}
6991 You can also call ~org-capture~ in a special way from the agenda,
6992 using the {{{kbd(k c)}}} key combination.  With this access, any
6993 timestamps inserted by the selected capture template defaults to the
6994 date at point in the agenda, rather than to the current date.
6996 To find the locations of the last stored capture, use ~org-capture~
6997 with prefix commands:
6999 - {{{kbd(C-u M-x org-capture)}}} ::
7001   Visit the target location of a capture template.  You get to select
7002   the template in the usual way.
7004 - {{{kbd(C-u C-u M-x org-capture)}}} ::
7006   Visit the last stored capture item in its buffer.
7008 #+vindex: org-capture-bookmark
7009 #+vindex: org-capture-last-stored
7010 You can also jump to the bookmark ~org-capture-last-stored~, which is
7011 automatically created unless you set ~org-capture-bookmark~ to ~nil~.
7013 To insert the capture at point in an Org buffer, call ~org-capture~
7014 with a {{{kbd(C-0)}}} prefix argument.
7016 *** Capture templates
7017 :PROPERTIES:
7018 :DESCRIPTION: Define the outline of different note types.
7019 :END:
7020 #+cindex: templates, for Capture
7022 You can use templates for different types of capture items, and for
7023 different target locations.  The easiest way to create such templates
7024 is through the customize interface.
7026 - {{{kbd(C)}}} ::
7028   #+kindex: C @r{(Capture menu}
7029   #+vindex: org-capture-templates
7030   Customize the variable ~org-capture-templates~.
7032 Before we give the formal description of template definitions, let's
7033 look at an example.  Say you would like to use one template to create
7034 general TODO entries, and you want to put these entries under the
7035 heading =Tasks= in your file =~/org/gtd.org=.  Also, a date tree in
7036 the file =journal.org= should capture journal entries.  A possible
7037 configuration would look like:
7039 #+begin_src emacs-lisp
7040 (setq org-capture-templates
7041       '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
7042          "* TODO %?\n  %i\n  %a")
7043         ("j" "Journal" entry (file+datetree "~/org/journal.org")
7044          "* %?\nEntered on %U\n  %i\n  %a")))
7045 #+end_src
7047 If you then press {{{kbd(t)}}} from the capture menu, Org will prepare
7048 the template for you like this:
7050 #+begin_example
7051 ,* TODO
7052   [[file:LINK TO WHERE YOU INITIATED CAPTURE]]
7053 #+end_example
7055 #+texinfo: @noindent
7056 During expansion of the template, =%a= has been replaced by a link to
7057 the location from where you called the capture command.  This can be
7058 extremely useful for deriving tasks from emails, for example.  You
7059 fill in the task definition, press {{{kbd(C-c C-c)}}} and Org returns
7060 you to the same place where you started the capture process.
7062 To define special keys to capture to a particular template without
7063 going through the interactive template selection, you can create your
7064 key binding like this:
7066 #+begin_src emacs-lisp
7067 (define-key global-map "\C-cx"
7068   (lambda () (interactive) (org-capture nil "x")))
7069 #+end_src
7071 **** Template elements
7072 :PROPERTIES:
7073 :DESCRIPTION: What is needed for a complete template entry.
7074 :END:
7076 Now lets look at the elements of a template definition.  Each entry in
7077 ~org-capture-templates~ is a list with the following items:
7079 - keys ::
7081   The keys that selects the template, as a string, characters only,
7082   for example ="a"=, for a template to be selected with a single key,
7083   or ="bt"= for selection with two keys.  When using several keys,
7084   keys using the same prefix key must be sequential in the list and
7085   preceded by a 2-element entry explaining the prefix key, for
7086   example:
7088   #+begin_src emacs-lisp
7089   ("b" "Templates for marking stuff to buy")
7090   #+end_src
7092   If you do not define a template for the {{{kbd(C)}}} key, this key
7093   opens the Customize buffer for this complex variable.
7095 - description ::
7097   A short string describing the template, shown during selection.
7099 - type ::
7101   The type of entry, a symbol.  Valid values are:
7103   - ~entry~ ::
7105     An Org mode node, with a headline.  Will be filed as the child of
7106     the target entry or as a top-level entry.  The target file should
7107     be an Org file.
7109   - ~item~ ::
7111     A plain list item, placed in the first plain list at the target
7112     location.  Again the target file should be an Org file.
7114   - ~checkitem~ ::
7116     A checkbox item.  This only differs from the plain list item by
7117     the default template.
7119   - ~table-line~ ::
7121     A new line in the first table at the target location.  Where
7122     exactly the line will be inserted depends on the properties
7123     ~:prepend~ and ~:table-line-pos~ (see below).
7125   - ~plain~ ::
7127     Text to be inserted as it is.
7129 - target ::
7131   #+vindex: org-default-notes-file
7132   #+vindex: org-directory
7133   Specification of where the captured item should be placed.  In Org
7134   files, targets usually define a node.  Entries will become children
7135   of this node.  Other types will be added to the table or list in the
7136   body of this node.  Most target specifications contain a file name.
7137   If that file name is the empty string, it defaults to
7138   ~org-default-notes-file~.  A file can also be given as a variable or
7139   as a function called with no argument.  When an absolute path is not
7140   specified for a target, it is taken as relative to ~org-directory~.
7142   Valid values are:
7144   - =(file "path/to/file")= ::
7146     Text will be placed at the beginning or end of that file.
7148   - =(id "id of existing org entry")= ::
7150     Filing as child of this entry, or in the body of the entry.
7152   - =(file+headline "filename" "node headline")= ::
7154     Fast configuration if the target heading is unique in the file.
7156   - =(file+olp "filename" "Level 1 heading" "Level 2" ...)= ::
7158     For non-unique headings, the full path is safer.
7160   - =(file+regexp "filename" "regexp to find location")= ::
7162     Use a regular expression to position point.
7164   - =(file+olp+datetree "filename" [ "Level 1 heading" ...])= ::
7166     This target[fn:82] creates a heading in a date tree[fn:83] for
7167     today's date.  If the optional outline path is given, the tree
7168     will be built under the node it is pointing to, instead of at top
7169     level.  Check out the ~:time-prompt~ and ~:tree-type~ properties
7170     below for additional options.
7172   - =(file+function "filename" function-finding-location)= ::
7174     A function to find the right location in the file.
7176   - =(clock)= ::
7178     File to the entry that is currently being clocked.
7180   - =(function function-finding-location)= ::
7182     Most general way: write your own function which both visits the
7183     file and moves point to the right location.
7185 - template ::
7187   The template for creating the capture item.  If you leave this
7188   empty, an appropriate default template will be used.  Otherwise this
7189   is a string with escape codes, which will be replaced depending on
7190   time and context of the capture call.  The string with escapes may
7191   be loaded from a template file, using the special syntax =(file
7192   "template filename")=.  See below for more details.
7194 - properties ::
7196   The rest of the entry is a property list of additional options.
7197   Recognized properties are:
7199   - ~:prepend~ ::
7201     Normally new captured information will be appended at the target
7202     location (last child, last table line, last list item, ...).
7203     Setting this property changes that.
7205   - ~:immediate-finish~ ::
7207     When set, do not offer to edit the information, just file it away
7208     immediately.  This makes sense if the template only needs
7209     information that can be added automatically.
7211   - ~:empty-lines~ ::
7213     Set this to the number of lines to insert before and after the new
7214     item.  Default 0, and the only other common value is 1.
7216   - ~:clock-in~ ::
7218     Start the clock in this item.
7220   - ~:clock-keep~ ::
7222     Keep the clock running when filing the captured entry.
7224   - ~:clock-resume~ ::
7226     If starting the capture interrupted a clock, restart that clock
7227     when finished with the capture.  Note that ~:clock-keep~ has
7228     precedence over ~:clock-resume~.  When setting both to non-~nil~,
7229     the current clock will run and the previous one will not be
7230     resumed.
7232   - ~:time-prompt~ ::
7234     Prompt for a date/time to be used for date/week trees and when
7235     filling the template.  Without this property, capture uses the
7236     current date and time.  Even if this property has not been set,
7237     you can force the same behavior by calling ~org-capture~ with
7238     a {{{kbd(C-1)}}} prefix argument.
7240   - ~:tree-type~ ::
7242     When ~week~, make a week tree instead of the month tree, i.e.,
7243     place the headings for each day under a heading with the current
7244     ISO week.
7246   - ~:unnarrowed~ ::
7248     Do not narrow the target buffer, simply show the full buffer.
7249     Default is to narrow it so that you only see the new material.
7251   - ~:table-line-pos~ ::
7253     Specification of the location in the table where the new line
7254     should be inserted.  It should be a string like =II-3= meaning
7255     that the new line should become the third line before the second
7256     horizontal separator line.
7258   - ~:kill-buffer~ ::
7260     If the target file was not yet visited when capture was invoked,
7261     kill the buffer again after capture is completed.
7263   - ~:no-save~ ::
7265     Do not save the target file after finishing the capture.
7267 **** Template expansion
7268 :PROPERTIES:
7269 :DESCRIPTION: Filling in information about time and context.
7270 :END:
7272 In the template itself, special "%-escapes"[fn:84] allow dynamic
7273 insertion of content.  The templates are expanded in the order given
7274 here:
7276 - =%[FILE]= ::
7278   Insert the contents of the file given by {{{var(FILE)}}}.
7280 - =%(EXP)= ::
7282   Evaluate Elisp expression {{{var(EXP)}}} and replace it with the
7283   result.  The {{{var(EXP)}}} form must return a string.  Only
7284   placeholders pre-existing within the template, or introduced with
7285   =%[file]=, are expanded this way.  Since this happens after
7286   expanding non-interactive "%-escapes", those can be used to fill the
7287   expression.
7289 - =%<FORMAT>= ::
7291   The result of format-time-string on the {{{var(FORMAT)}}}
7292   specification.
7294 - =%t= ::
7296   Timestamp, date only.
7298 - =%T= ::
7300   Timestamp, with date and time.
7302 - =%u=, =%U= ::
7304   Like =%t=, =%T= above, but inactive timestamps.
7306 - =%i= ::
7308   Initial content, the region when capture is called while the region
7309   is active.  If there is text before =%i= on the same line, such as
7310   indentation, and =%i= is not inside a =%(exp)= form, that prefix is
7311   added before every line in the inserted text.
7313 - =%a= ::
7315   Annotation, normally the link created with ~org-store-link~.
7317 - =%A= ::
7319   Like =%a=, but prompt for the description part.
7321 - =%l= ::
7323   Like =%a=, but only insert the literal link.
7325 - =%c= ::
7327   Current kill ring head.
7329 - =%x= ::
7331   Content of the X clipboard.
7333 - =%k= ::
7335   Title of the currently clocked task.
7337 - =%K= ::
7339   Link to the currently clocked task.
7341 - =%n= ::
7343   User name (taken from ~user-full-name~).
7345 - =%f= ::
7347   File visited by current buffer when org-capture was called.
7349 - =%F= ::
7351   Full path of the file or directory visited by current buffer.
7353 - =%:keyword= ::
7355   Specific information for certain link types, see below.
7357 - =%^g= ::
7359   Prompt for tags, with completion on tags in target file.
7361 - =%^G= ::
7363   Prompt for tags, with completion all tags in all agenda files.
7365 - =%^t= ::
7367   Like =%t=, but prompt for date.  Similarly =%^T=, =%^u=, =%^U=.  You
7368   may define a prompt like =%^{Birthday}t=.
7370 - =%^C= ::
7372   Interactive selection of which kill or clip to use.
7374 - =%^L= ::
7376   Like =%^C=, but insert as link.
7378 - =%^{PROP}p= ::
7380   Prompt the user for a value for property {{{var(PROP)}}}.
7382 - =%^{PROMPT}= ::
7384   Prompt the user for a string and replace this sequence with it.  You
7385   may specify a default value and a completion table with
7386   =%^{prompt|default|completion2|completion3...}=.  The arrow keys
7387   access a prompt-specific history.
7389 - =%\N= ::
7391   Insert the text entered at the {{{var(N)}}}th =%^{PROMPT}=, where
7392   {{{var(N)}}} is a number, starting from 1.
7394 - =%?= ::
7396   After completing the template, position point here.
7398 #+vindex: org-store-link-props
7399 For specific link types, the following keywords are defined[fn:85]:
7401 #+vindex: org-link-from-user-regexp
7402 | Link type    | Available keywords                                       |
7403 |--------------+----------------------------------------------------------|
7404 | bbdb         | =%:name=, =%:company=                                    |
7405 | irc          | =%:server=, =%:port=, =%:nick=                           |
7406 | mh, rmail    | =%:type=, =%:subject=, =%:message-id=                    |
7407 |              | =%:from=, =%:fromname=, =%:fromaddress=                  |
7408 |              | =%:to=, =%:toname=, =%:toaddress=                        |
7409 |              | =%:date= (message date header field)                     |
7410 |              | =%:date-timestamp= (date as active timestamp)            |
7411 |              | =%:date-timestamp-inactive= (date as inactive timestamp) |
7412 |              | =%:fromto= (either "to NAME" or "from NAME")[fn:86]      |
7413 | gnus         | =%:group=, for messages also all email fields            |
7414 | w3, w3m      | =%:url=                                                  |
7415 | info         | =%:file=, =%:node=                                       |
7416 | calendar     | =%:date=                                                 |
7417 | org-protocol | =%:link=, =%:description=, =%:annotation=                |
7419 **** Templates in contexts
7420 :PROPERTIES:
7421 :DESCRIPTION: Only show a template in a specific context.
7422 :END:
7424 #+vindex: org-capture-templates-contexts
7425 To control whether a capture template should be accessible from
7426 a specific context, you can customize
7427 ~org-capture-templates-contexts~.  Let's say, for example, that you
7428 have a capture template "p" for storing Gnus emails containing
7429 patches.  Then you would configure this option like this:
7431 #+begin_src emacs-lisp
7432 (setq org-capture-templates-contexts
7433       '(("p" (in-mode . "message-mode"))))
7434 #+end_src
7436 You can also tell that the command key {{{kbd(p)}}} should refer to
7437 another template.  In that case, add this command key like this:
7439 #+begin_src emacs-lisp
7440 (setq org-capture-templates-contexts
7441       '(("p" "q" (in-mode . "message-mode"))))
7442 #+end_src
7444 See the docstring of the variable for more information.
7446 ** Attachments
7447 :PROPERTIES:
7448 :DESCRIPTION: Add files to tasks.
7449 :END:
7450 #+cindex: attachments
7451 #+vindex: org-attach-directory
7453 It is often useful to associate reference material with an outline
7454 node/task.  Small chunks of plain text can simply be stored in the
7455 subtree of a project.  Hyperlinks (see [[*Hyperlinks]]) can establish
7456 associations with files that live elsewhere on your computer or in the
7457 cloud, like emails or source code files belonging to a project.
7458 Another method is /attachments/, which are files located in
7459 a directory belonging to an outline node.  Org uses directories named
7460 by the unique ID of each entry.  These directories are located in the
7461 =data/= directory which lives in the same directory where your Org
7462 file lives[fn:87].  If you initialize this directory with =git init=,
7463 Org automatically commits changes when it sees them.  The attachment
7464 system has been contributed to Org by John Wiegley.
7466 In cases where it seems better to do so, you can attach a directory of
7467 your choice to an entry.  You can also make children inherit the
7468 attachment directory from a parent, so that an entire subtree uses the
7469 same attached directory.
7471 The following commands deal with attachments:
7473 - {{{kbd(C-c C-a)}}} (~org-attach~) ::
7475   #+kindex: C-c C-a
7476   #+findex: org-attach
7477   The dispatcher for commands related to the attachment system.  After
7478   these keys, a list of commands is displayed and you must press an
7479   additional key to select a command:
7481   - {{{kbd(a)}}} (~org-attach-attach~) ::
7483     #+kindex: C-c C-a a
7484     #+findex: org-attach-attach
7485     #+vindex: org-attach-method
7486     Select a file and move it into the task's attachment directory.
7487     The file is copied, moved, or linked, depending on
7488     ~org-attach-method~.  Note that hard links are not supported on
7489     all systems.
7491   - {{{kbd(c)}}}/{{{kbd(m)}}}/{{{kbd(l)}}} ::
7493     #+kindex: C-c C-a c
7494     #+kindex: C-c C-a m
7495     #+kindex: C-c C-a l
7496     Attach a file using the copy/move/link method.  Note that hard
7497     links are not supported on all systems.
7499   - {{{kbd(b)}}} (~org-attach-buffer~) ::
7501     #+kindex: C-c C-a b
7502     #+findex: org-attach-buffer
7503     Select a buffer and save it as a file in the task's attachment
7504     directory.
7506   - {{{kbd(n)}}} (~org-attach-new~) ::
7508     #+kindex: C-c C-a n
7509     #+findex: org-attach-new
7510     Create a new attachment as an Emacs buffer.
7512   - {{{kbd(z)}}} (~org-attach-sync~) ::
7514     #+kindex: C-c C-a z
7515     #+findex: org-attach-sync
7516     Synchronize the current task with its attachment directory, in
7517     case you added attachments yourself.
7519   - {{{kbd(o)}}} (~org-attach-open~) ::
7521     #+kindex: C-c C-a o
7522     #+findex: org-attach-open
7523     #+vindex: org-file-apps
7524     Open current task's attachment.  If there is more than one, prompt
7525     for a file name first.  Opening follows the rules set by
7526     ~org-file-apps~.  For more details, see the information on
7527     following hyperlinks (see [[*Handling Links]]).
7529   - {{{kbd(O)}}} (~org-attach-open-in-emacs~) ::
7531     #+kindex: C-c C-a O
7532     #+findex: org-attach-open-in-emacs
7533     Also open the attachment, but force opening the file in Emacs.
7535   - {{{kbd(f)}}} (~org-attach-reveal~) ::
7537     #+kindex: C-c C-a f
7538     #+findex: org-attach-reveal
7539     Open the current task's attachment directory.
7541   - {{{kbd(F)}}} (~org-attach-reveal-in-emacs~) ::
7543     #+kindex: C-c C-a F
7544     #+findex: org-attach-reveal-in-emacs
7545     Also open the directory, but force using Dired in Emacs.
7547   - {{{kbd(d)}}} (~org-attach-delete-one~) ::
7549     #+kindex: C-c C-a d
7550     Select and delete a single attachment.
7552   - {{{kbd(D)}}} (~org-attach-delete-all~) ::
7554     #+kindex: C-c C-a D
7555     Delete all of a task's attachments.  A safer way is to open the
7556     directory in Dired and delete from there.
7558   - {{{kbd(s)}}} (~org-attach-set-directory~) ::
7560     #+kindex: C-c C-a s
7561     #+cindex: @samp{ATTACH_DIR}, property
7562     Set a specific directory as the entry's attachment directory.
7563     This works by putting the directory path into the =ATTACH_DIR=
7564     property.
7566   - {{{kbd(i)}}} (~org-attach-set-inherit~) ::
7568     #+kindex: C-c C-a i
7569     #+cindex: @samp{ATTACH_DIR_INHERIT}, property
7570     Set the =ATTACH_DIR_INHERIT= property, so that children use the
7571     same directory for attachments as the parent does.
7573 #+cindex: attach from Dired
7574 #+findex: org-attach-dired-to-subtree
7575 It is possible to attach files to a subtree from a Dired buffer.  To
7576 use this feature, have one window in Dired mode containing the file(s)
7577 to be attached and another window with point in the subtree that shall
7578 get the attachments.  In the Dired window, with point on a file,
7579 {{{kbd(M-x org-attach-dired-to-subtree)}}} attaches the file to the
7580 subtree using the attachment method set by variable
7581 ~org-attach-method~.  When files are marked in the Dired window then
7582 all marked files get attached.
7584 Add the following lines to the Emacs init file to have {{{kbd(C-c C-x
7585 a)}}} attach files in Dired buffers.
7587 #+begin_src emacs-lisp
7588 (add-hook 'dired-mode-hook
7589           (lambda ()
7590             (define-key dired-mode-map
7591               (kbd "C-c C-x a")
7592               #'org-attach-dired-to-subtree)))
7593 #+end_src
7595 The following code shows how to bind the previous command with
7596 a specific attachment method.
7598 #+begin_src emacs-lisp
7599 (add-hook 'dired-mode-hook
7600           (lambda ()
7601             (define-key dired-mode-map (kbd "C-c C-x c")
7602               (lambda ()
7603                 (interactive)
7604                 (let ((org-attach-method 'cp))
7605                   (call-interactively #'org-attach-dired-to-subtree))))))
7606 #+end_src
7608 ** RSS Feeds
7609 :PROPERTIES:
7610 :DESCRIPTION: Getting input from RSS feeds.
7611 :END:
7612 #+cindex: RSS feeds
7613 #+cindex: Atom feeds
7615 Org can add and change entries based on information found in RSS feeds
7616 and Atom feeds.  You could use this to make a task out of each new
7617 podcast in a podcast feed.  Or you could use a phone-based
7618 note-creating service on the web to import tasks into Org.  To access
7619 feeds, configure the variable ~org-feed-alist~.  The docstring of this
7620 variable has detailed information.  With the following
7622 #+begin_src emacs-lisp
7623 (setq org-feed-alist
7624       '(("Slashdot"
7625          "http://rss.slashdot.org/Slashdot/slashdot"
7626          "~/txt/org/feeds.org" "Slashdot Entries")))
7627 #+end_src
7629 #+texinfo: @noindent
7630 new items from the feed provided by =rss.slashdot.org= result in new
7631 entries in the file =~/org/feeds.org= under the heading =Slashdot
7632 Entries=, whenever the following command is used:
7634 - {{{kbd(C-c C-x g)}}} (~org-feed-update-all~) ::
7636   #+kindex: C-c C-x g
7637   Collect items from the feeds configured in ~org-feed-alist~ and act
7638   upon them.
7640 - {{{kbd(C-c C-x G)}}} (~org-feed-goto-inbox~) ::
7642   #+kindex: C-c C-x G
7643   Prompt for a feed name and go to the inbox configured for this feed.
7645 Under the same headline, Org creates a drawer =FEEDSTATUS= in which it
7646 stores information about the status of items in the feed, to avoid
7647 adding the same item several times.
7649 For more information, including how to read atom feeds, see
7650 =org-feed.el= and the docstring of ~org-feed-alist~.
7652 ** Protocols for External Access
7653 :PROPERTIES:
7654 :DESCRIPTION: External access to Emacs and Org.
7655 :ALT_TITLE: Protocols
7656 :END:
7657 #+cindex: protocols, for external access
7659 Org protocol is a means to trigger custom actions in Emacs from
7660 external applications.  Any application that supports calling external
7661 programs with an URL as argument may be used with this functionality.
7662 For example, you can configure bookmarks in your web browser to send
7663 a link to the current page to Org and create a note from it using
7664 capture (see [[*Capture]]).  You can also create a bookmark that tells
7665 Emacs to open the local source file of a remote website you are
7666 browsing.
7668 #+cindex: Org protocol, set-up
7669 #+cindex: Installing Org protocol
7670 In order to use Org protocol from an application, you need to register
7671 =org-protocol://= as a valid scheme-handler.  External calls are
7672 passed to Emacs through the =emacsclient= command, so you also need to
7673 ensure an Emacs server is running.  More precisely, when the
7674 application calls
7676 : emacsclient org-protocol://PROTOCOL?key1=val1&key2=val2
7678 #+texinfo: @noindent
7679 Emacs calls the handler associated to {{{var(PROTOCOL)}}} with
7680 argument =(:key1 val1 :key2 val2)=.
7682 #+cindex: protocol, new protocol
7683 #+cindex: defining new protocols
7684 Org protocol comes with three predefined protocols, detailed in the
7685 following sections.  Configure ~org-protocol-protocol-alist~ to define
7686 your own.
7688 *** ~store-link~ protocol
7689 :PROPERTIES:
7690 :DESCRIPTION: Store a link, push URL to kill-ring.
7691 :END:
7692 #+cindex: store-link protocol
7693 #+cindex: protocol, store-link
7695 Using ~store-link~ handler, you can copy links, insertable through
7696 {{{kbd(M-x org-insert-link)}}} or yanking thereafter.  More precisely,
7697 the command
7699 : emacsclient org-protocol://store-link?url=URL&title=TITLE
7701 #+texinfo: @noindent
7702 stores the following link:
7704 : [[URL][TITLE]]
7706 In addition, {{{var(URL)}}} is pushed on the kill-ring for yanking.
7707 You need to encode {{{var(URL)}}} and {{{var(TITLE)}}} if they contain
7708 slashes, and probably quote those for the shell.
7710 To use this feature from a browser, add a bookmark with an arbitrary
7711 name, e.g., =Org: store-link= and enter this as /Location/:
7713 #+begin_example
7714 javascript:location.href='org-protocol://store-link?url='+
7715       encodeURIComponent(location.href);
7716 #+end_example
7718 *** ~capture~ protocol
7719 :PROPERTIES:
7720 :DESCRIPTION: Fill a buffer with external information.
7721 :END:
7722 #+cindex: capture protocol
7723 #+cindex: protocol, capture
7725 Activating "capture" handler pops up a =Capture= buffer and fills the
7726 capture template associated to the =X= key with them.
7728 : emacsclient org-protocol://capture?template=X?url=URL?title=TITLE?body=BODY
7730 To use this feature, add a bookmark with an arbitrary name, e.g.,
7731 =Org: capture=, and enter this as =Location=:
7733 #+begin_example
7734 javascript:location.href='org-protocol://capture?template=x'+
7735       '&url='+encodeURIComponent(window.location.href)+
7736       '&title='+encodeURIComponent(document.title)+
7737       '&body='+encodeURIComponent(window.getSelection());
7738 #+end_example
7740 #+vindex: org-protocol-default-template-key
7741 The result depends on the capture template used, which is set in the
7742 bookmark itself, as in the example above, or in
7743 ~org-protocol-default-template-key~.
7745 The following template placeholders are available:
7747 #+begin_example
7748 %:link          The URL
7749 %:description   The webpage title
7750 %:annotation    Equivalent to [[%:link][%:description]]
7751 %i              The selected text
7752 #+end_example
7754 *** ~open-source~ protocol
7755 :PROPERTIES:
7756 :DESCRIPTION: Edit published contents.
7757 :END:
7758 #+cindex: open-source protocol
7759 #+cindex: protocol, open-source
7761 The ~open-source~ handler is designed to help with editing local
7762 sources when reading a document.  To that effect, you can use
7763 a bookmark with the following location:
7765 #+begin_example
7766 javascript:location.href='org-protocol://open-source?&url='+
7767       encodeURIComponent(location.href)
7768 #+end_example
7770 #+vindex: org-protocol-project-alist
7771 The variable ~org-protocol-project-alist~ maps URLs to local file
7772 names, by stripping URL parameters from the end and replacing the
7773 ~:base-url~ with ~:working-directory~ and ~:online-suffix~ with
7774 ~:working-suffix~.  For example, assuming you own a local copy of
7775 =https://orgmode.org/worg/= contents at =/home/user/worg=, you can set
7776 ~org-protocol-project-alist~ to the following
7778 #+begin_src emacs-lisp
7779 (setq org-protocol-project-alist
7780       '(("Worg"
7781          :base-url "https://orgmode.org/worg/"
7782          :working-directory "/home/user/worg/"
7783          :online-suffix ".html"
7784          :working-suffix ".org")))
7785 #+end_src
7787 #+texinfo: @noindent
7788 If you are now browsing
7789 =https://orgmode.org/worg/org-contrib/org-protocol.html= and find
7790 a typo or have an idea about how to enhance the documentation, simply
7791 click the bookmark and start editing.
7793 #+cindex: rewritten URL in open-source protocol
7794 #+cindex: protocol, open-source rewritten URL
7795 However, such mapping may not yield the desired results.  Suppose you
7796 maintain an online store located at =http://example.com/=.  The local
7797 sources reside in =/home/user/example/=.  It is common practice to
7798 serve all products in such a store through one file and rewrite URLs
7799 that do not match an existing file on the server.  That way, a request
7800 to =http://example.com/print/posters.html= might be rewritten on the
7801 server to something like
7802 =http://example.com/shop/products.php/posters.html.php=.  The
7803 ~open-source~ handler probably cannot find a file named
7804 =/home/user/example/print/posters.html.php= and fails.
7806 Such an entry in ~org-protocol-project-alist~ may hold an additional
7807 property ~:rewrites~.  This property is a list of cons cells, each of
7808 which maps a regular expression to a path relative to the
7809 ~:working-directory~.
7811 Now map the URL to the path =/home/user/example/products.php= by
7812 adding ~:rewrites~ rules like this:
7814 #+begin_src emacs-lisp
7815 (setq org-protocol-project-alist
7816       '(("example.com"
7817          :base-url "http://example.com/"
7818          :working-directory "/home/user/example/"
7819          :online-suffix ".php"
7820          :working-suffix ".php"
7821          :rewrites (("example.com/print/" . "products.php")
7822                     ("example.com/$" . "index.php")))))
7823 #+end_src
7825 #+texinfo: @noindent
7826 Since =example.com/$= is used as a regular expression, it maps
7827 =http://example.com/=, =https://example.com=,
7828 =http://www.example.com/= and similar to
7829 =/home/user/example/index.php=.
7831 The ~:rewrites~ rules are searched as a last resort if and only if no
7832 existing file name is matched.
7834 #+cindex: protocol, open-source, set-up mapping
7835 #+cindex: mappings in open-source protocol
7836 #+findex: org-protocol-create
7837 #+findex: org-protocol-create-for-org
7838 Two functions can help you filling ~org-protocol-project-alist~ with
7839 valid contents: ~org-protocol-create~ and
7840 ~org-protocol-create-for-org~.  The latter is of use if you're editing
7841 an Org file that is part of a publishing project.
7843 ** Refile and Copy
7844 :PROPERTIES:
7845 :DESCRIPTION: Moving/copying a tree from one place to another.
7846 :END:
7847 #+cindex: refiling notes
7848 #+cindex: copying notes
7850 When reviewing the captured data, you may want to refile or to copy
7851 some of the entries into a different list, for example into a project.
7852 Cutting, finding the right location, and then pasting the note is
7853 cumbersome.  To simplify this process, you can use the following
7854 special command:
7856 - {{{kbd(C-c C-w)}}} (~org-refile~) ::
7858   #+kindex: C-c C-w
7859   #+findex: org-refile
7860   #+vindex: org-reverse-note-order
7861   #+vindex: org-refile-targets
7862   #+vindex: org-refile-use-outline-path
7863   #+vindex: org-outline-path-complete-in-steps
7864   #+vindex: org-refile-allow-creating-parent-nodes
7865   #+vindex: org-log-refile
7866   Refile the entry or region at point.  This command offers possible
7867   locations for refiling the entry and lets you select one with
7868   completion.  The item (or all items in the region) is filed below
7869   the target heading as a subitem.  Depending on
7870   ~org-reverse-note-order~, it is either the first or last subitem.
7872   By default, all level 1 headlines in the current buffer are
7873   considered to be targets, but you can have more complex definitions
7874   across a number of files.  See the variable ~org-refile-targets~ for
7875   details.  If you would like to select a location via
7876   a file-path-like completion along the outline path, see the
7877   variables ~org-refile-use-outline-path~ and
7878   ~org-outline-path-complete-in-steps~.  If you would like to be able
7879   to create new nodes as new parents for refiling on the fly, check
7880   the variable ~org-refile-allow-creating-parent-nodes~.  When the
7881   variable ~org-log-refile~[fn:88] is set, a timestamp or a note is
7882   recorded whenever an entry is refiled.
7884 - {{{kbd(C-u C-c C-w)}}} ::
7886   #+kindex: C-u C-c C-w
7887   Use the refile interface to jump to a heading.
7889 - {{{kbd(C-u C-u C-c C-w)}}} (~org-refile-goto-last-stored~) ::
7891   #+kindex: C-u C-u C-c C-w
7892   #+findex: org-refile-goto-last-stored
7893   Jump to the location where ~org-refile~ last moved a tree to.
7895 - {{{kbd(C-2 C-c C-w)}}} ::
7897   #+kindex: C-2 C-c C-w
7898   Refile as the child of the item currently being clocked.
7900 - {{{kbd(C-3 C-c C-w)}}} ::
7902   #+kindex: C-3 C-c C-w
7903   #+vindex: org-refile-keep
7904   Refile and keep the entry in place.  Also see ~org-refile-keep~ to
7905   make this the default behavior, and beware that this may result in
7906   duplicated =ID= properties.
7908 - {{{kbd(C-0 C-c C-w)}}} or {{{kbd(C-u C-u C-u C-c C-w)}}} (~org-refile-cache-clear~) ::
7910   #+kindex: C-u C-u C-u C-c C-w
7911   #+kindex: C-0 C-c C-w
7912   #+findex: org-refile-cache-clear
7913   #+vindex: org-refile-use-cache
7914   Clear the target cache.  Caching of refile targets can be turned on
7915   by setting ~org-refile-use-cache~.  To make the command see new
7916   possible targets, you have to clear the cache with this command.
7918 - {{{kbd(C-c M-w)}}} (~org-copy~) ::
7920   #+kindex: C-c M-w
7921   #+findex: org-copy
7922   Copying works like refiling, except that the original note is not
7923   deleted.
7925 ** Archiving
7926 :PROPERTIES:
7927 :DESCRIPTION: What to do with finished products.
7928 :END:
7929 #+cindex: archiving
7931 When a project represented by a (sub)tree is finished, you may want to
7932 move the tree out of the way and to stop it from contributing to the
7933 agenda.  Archiving is important to keep your working files compact and
7934 global searches like the construction of agenda views fast.
7936 - {{{kbd(C-c C-x C-a)}}} (~org-archive-subtree-default~) ::
7938   #+kindex: C-c C-x C-a
7939   #+findex: org-archive-subtree-default
7940   #+vindex: org-archive-default-command
7941   Archive the current entry using the command specified in the
7942   variable ~org-archive-default-command~.
7944 *** Moving a tree to an archive file
7945 :PROPERTIES:
7946 :DESCRIPTION: Moving a tree to an archive file.
7947 :ALT_TITLE: Moving subtrees
7948 :END:
7949 #+cindex: external archiving
7951 The most common archiving action is to move a project tree to another
7952 file, the archive file.
7954 - {{{kbd(C-c C-x C-s)}}} or short {{{kbd(C-c $)}}} (~org-archive-subtree~) ::
7956   #+kindex: C-c C-x C-s
7957   #+kindex: C-c $
7958   #+findex: org-archive-subtree
7959   #+vindex: org-archive-location
7960   Archive the subtree starting at point position to the location given
7961   by ~org-archive-location~.
7963 - {{{kbd(C-u C-c C-x C-s)}}} ::
7965   #+kindex: C-u C-c C-x C-s
7966   Check if any direct children of the current headline could be moved
7967   to the archive.  To do this, check each subtree for open TODO
7968   entries.  If none is found, the command offers to move it to the
7969   archive location.  If point is /not/ on a headline when this command
7970   is invoked, check level 1 trees.
7972 - {{{kbd(C-u C-u C-c C-x C-s)}}} ::
7974   #+kindex: C-u C-u C-c C-x C-s
7975   As above, but check subtree for timestamps instead of TODO entries.
7976   The command offers to archive the subtree if it /does/ contain
7977   a timestamp, and that timestamp is in the past.
7979 #+cindex: archive locations
7980 The default archive location is a file in the same directory as the
7981 current file, with the name derived by appending =_archive= to the
7982 current file name.  You can also choose what heading to file archived
7983 items under, with the possibility to add them to a datetree in a file.
7984 For information and examples on how to specify the file and the
7985 heading, see the documentation string of the variable
7986 ~org-archive-location~.
7988 There is also an in-buffer option for setting this variable, for
7989 example:
7991 #+cindex: @samp{ARCHIVE}, keyword
7992 : #+ARCHIVE: %s_done::
7994 #+cindex: ARCHIVE, property
7995 If you would like to have a special archive location for a single
7996 entry or a (sub)tree, give the entry an =ARCHIVE= property with the
7997 location as the value (see [[*Properties and Columns]]).
7999 #+vindex: org-archive-save-context-info
8000 When a subtree is moved, it receives a number of special properties
8001 that record context information like the file from where the entry
8002 came, its outline path the archiving time etc.  Configure the variable
8003 ~org-archive-save-context-info~ to adjust the amount of information
8004 added.
8006 *** Internal archiving
8007 :PROPERTIES:
8008 :DESCRIPTION: Switch off a tree but keep it in the file.
8009 :END:
8011 #+cindex: @samp{ARCHIVE}, tag
8012 If you want to just switch off---for agenda views---certain subtrees
8013 without moving them to a different file, you can use the =ARCHIVE=
8014 tag.
8016 A headline that is marked with the =ARCHIVE= tag (see [[*Tags]]) stays at
8017 its location in the outline tree, but behaves in the following way:
8020   #+vindex: org-cycle-open-archived-trees
8021   It does not open when you attempt to do so with a visibility cycling
8022   command (see [[*Visibility Cycling]]).  You can force cycling archived
8023   subtrees with {{{kbd(C-TAB)}}}, or by setting the option
8024   ~org-cycle-open-archived-trees~.  Also normal outline commands, like
8025   ~outline-show-all~, open archived subtrees.
8028   #+vindex: org-sparse-tree-open-archived-trees
8029   During sparse tree construction (see [[*Sparse Trees]]), matches in
8030   archived subtrees are not exposed, unless you configure the option
8031   ~org-sparse-tree-open-archived-trees~.
8034   #+vindex: org-agenda-skip-archived-trees
8035   During agenda view construction (see [[*Agenda Views]]), the content of
8036   archived trees is ignored unless you configure the option
8037   ~org-agenda-skip-archived-trees~, in which case these trees are
8038   always included.  In the agenda you can press {{{kbd(v a)}}} to get
8039   archives temporarily included.
8042   #+vindex: org-export-with-archived-trees
8043   Archived trees are not exported (see [[*Exporting]]), only the headline
8044   is.  Configure the details using the variable
8045   ~org-export-with-archived-trees~.
8048   #+vindex: org-columns-skip-archived-trees
8049   Archived trees are excluded from column view unless the variable
8050   ~org-columns-skip-archived-trees~ is configured to ~nil~.
8052 The following commands help manage the =ARCHIVE= tag:
8054 - {{{kbd(C-c C-x a)}}} (~org-toggle-archive-tag~) ::
8056   #+kindex: C-c C-x a
8057   #+findex: org-toggle-archive-tag
8058   Toggle the archive tag for the current headline.  When the tag is
8059   set, the headline changes to a shadowed face, and the subtree below
8060   it is hidden.
8062 - {{{kbd(C-u C-c C-x a)}}} ::
8064   #+kindex: C-u C-c C-x a
8065   Check if any direct children of the current headline should be
8066   archived.  To do this, check each subtree for open TODO entries.  If
8067   none is found, the command offers to set the =ARCHIVE= tag for the
8068   child.  If point is /not/ on a headline when this command is
8069   invoked, check the level 1 trees.
8071 - {{{kbd(C-TAB)}}} (~org-force-cycle-archived~) ::
8073   #+kindex: C-TAB
8074   Cycle a tree even if it is tagged with =ARCHIVE=.
8076 - {{{kbd(C-c C-x A)}}} (~org-archive-to-archive-sibling~) ::
8078   #+kindex: C-c C-x A
8079   #+findex: org-archive-to-archive-sibling
8080   Move the current entry to the /Archive Sibling/.  This is a sibling
8081   of the entry with the heading =Archive= and the archive tag.  The
8082   entry becomes a child of that sibling and in this way retains a lot
8083   of its original context, including inherited tags and approximate
8084   position in the outline.
8086 * Agenda Views
8087 :PROPERTIES:
8088 :DESCRIPTION: Collecting information into views.
8089 :END:
8090 #+cindex: agenda views
8092 Due to the way Org works, TODO items, time-stamped items, and tagged
8093 headlines can be scattered throughout a file or even a number of
8094 files.  To get an overview of open action items, or of events that are
8095 important for a particular date, this information must be collected,
8096 sorted and displayed in an organized way.
8098 Org can select items based on various criteria and display them in
8099 a separate buffer.  Seven different view types are provided:
8101 - an /agenda/ that is like a calendar and shows information for
8102   specific dates,
8104 - a /TODO list/ that covers all unfinished action items,
8106 - a /match view/, showings headlines based on the tags, properties,
8107   and TODO state associated with them,
8109 - a /text search view/ that shows all entries from multiple files that
8110   contain specified keywords,
8112 - a /stuck projects view/ showing projects that currently do not move
8113   along, and
8115 - /custom views/ that are special searches and combinations of
8116   different views.
8118 The extracted information is displayed in a special /agenda buffer/.
8119 This buffer is read-only, but provides commands to visit the
8120 corresponding locations in the original Org files, and even to edit
8121 these files remotely.
8123 #+vindex: org-agenda-skip-comment-trees
8124 #+vindex: org-agenda-skip-archived-trees
8125 #+cindex: commented entries, in agenda views
8126 #+cindex: archived entries, in agenda views
8127 By default, the report ignores commented (see [[*Comment Lines]]) and
8128 archived (see [[*Internal archiving]]) entries.  You can override this by
8129 setting ~org-agenda-skip-comment-trees~ and
8130 ~org-agenda-skip-archived-trees~ to ~nil~.
8132 #+vindex: org-agenda-window-setup
8133 #+vindex: org-agenda-restore-windows-after-quit
8134 Two variables control how the agenda buffer is displayed and whether
8135 the window configuration is restored when the agenda exits:
8136 ~org-agenda-window-setup~ and ~org-agenda-restore-windows-after-quit~.
8138 ** Agenda Files
8139 :PROPERTIES:
8140 :DESCRIPTION: Files being searched for agenda information.
8141 :END:
8142 #+cindex: agenda files
8143 #+cindex: files for agenda
8145 #+vindex: org-agenda-files
8146 The information to be shown is normally collected from all /agenda
8147 files/, the files listed in the variable ~org-agenda-files~[fn:89].
8148 If a directory is part of this list, all files with the extension
8149 =.org= in this directory are part of the list.
8151 Thus, even if you only work with a single Org file, that file should
8152 be put into the list[fn:90].  You can customize ~org-agenda-files~,
8153 but the easiest way to maintain it is through the following commands
8155 #+attr_texinfo: :sep and
8156 - {{{kbd(C-c [)}}} (~org-agenda-file-to-front~) ::
8158   #+kindex: C-c [
8159   #+findex: org-agenda-file-to-front
8160   #+cindex: files, adding to agenda list
8161   Add current file to the list of agenda files.  The file is added to
8162   the front of the list.  If it was already in the list, it is moved
8163   to the front.  With a prefix argument, file is added/moved to the
8164   end.
8166 - {{{kbd(C-c ])}}} (~org-remove-file~) ::
8168   #+kindex: C-c ]
8169   #+findex: org-remove-file
8170   Remove current file from the list of agenda files.
8172 - {{{kbd(C-')}}} and {{{kbd(C-\,)}}} (~org-cycle-agenda-files~) ::
8174   #+kindex: C-'
8175   #+kindex: C-,
8176   #+findex: org-cycle-agenda-files
8177   #+cindex: cycling, of agenda files
8178   Cycle through agenda file list, visiting one file after the other.
8180 - {{{kbd(M-x org-switchb)}}} ::
8182   #+findex: org-switchb
8183   Command to use an Iswitchb-like interface to switch to and between
8184   Org buffers.
8186 #+texinfo: @noindent
8187 The Org menu contains the current list of files and can be used to
8188 visit any of them.
8190 If you would like to focus the agenda temporarily on a file not in
8191 this list, or on just one file in the list, or even on only a subtree
8192 in a file, then this can be done in different ways.  For a single
8193 agenda command, you may press {{{kbd(<)}}} once or several times in
8194 the dispatcher (see [[*The Agenda Dispatcher]]).  To restrict the agenda
8195 scope for an extended period, use the following commands:
8197 - {{{kbd(C-c C-x <)}}} (~org-agenda-set-restriction-lock~) ::
8199   #+kindex: C-c C-x <
8200   #+findex: org-agenda-set-restriction-lock
8201   Restrict the agenda to the current subtree.  If there already is
8202   a restriction at point, remove it.  When called with a universal
8203   prefix argument or with point before the first headline in a file,
8204   set the agenda scope to the entire file.  This restriction remains
8205   in effect until removed with {{{kbd(C-c C-x >)}}}, or by typing
8206   either {{{kbd(<)}}} or {{{kbd(>)}}} in the agenda dispatcher.  If
8207   there is a window displaying an agenda view, the new restriction
8208   takes effect immediately.
8210 - {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
8212   #+kindex: C-c C-x >
8213   #+findex: org-agenda-remove-restriction-lock
8214   Remove the restriction created by {{{kbd(C-c C-x <)}}}.
8216 When working with Speedbar, you can use the following commands in the
8217 Speedbar frame:
8219 - {{{kbd(<)}}} (~org-speedbar-set-agenda-restriction~) ::
8221   #+findex: org-speedbar-set-agenda-restriction
8222   Restrict the agenda to the item---either an Org file or a subtree in
8223   such a file---at point in the Speedbar frame.  If agenda is already
8224   restricted there, remove the restriction.  If there is a window
8225   displaying an agenda view, the new restriction takes effect
8226   immediately.
8228 - {{{kbd(>)}}} (~org-agenda-remove-restriction-lock~) ::
8230   #+findex: org-agenda-remove-restriction-lock
8231   Remove the restriction.
8233 ** The Agenda Dispatcher
8234 :PROPERTIES:
8235 :DESCRIPTION: Keyboard access to agenda views.
8236 :ALT_TITLE: Agenda Dispatcher
8237 :END:
8238 #+cindex: agenda dispatcher
8239 #+cindex: dispatching agenda commands
8241 The views are created through a dispatcher, accessible with {{{kbd(M-x
8242 org-agenda)}}}, or, better, bound to a global key (see [[*Activation]]).
8243 It displays a menu from which an additional letter is required to
8244 execute a command.  The dispatcher offers the following default
8245 commands:
8247 #+attr_texinfo: :sep ,
8248 - {{{kbd(a)}}} ::
8250   Create the calendar-like agenda (see [[*Weekly/daily agenda]]).
8252 - {{{kbd(t)}}}, {{{kbd(T)}}} ::
8254   Create a list of all TODO items (see [[*The global TODO list]]).
8256 - {{{kbd(m)}}}, {{{kbd(M)}}} ::
8258   Create a list of headlines matching a given expression (see
8259   [[*Matching tags and properties]]).
8261 - {{{kbd(s)}}} ::
8263   #+kindex: s @r{(Agenda dispatcher)}
8264   Create a list of entries selected by a boolean expression of
8265   keywords and/or regular expressions that must or must not occur in
8266   the entry.
8268 - {{{kbd(/)}}} ::
8270   #+kindex: / @r{(Agenda dispatcher)}
8271   #+vindex: org-agenda-text-search-extra-files
8272   Search for a regular expression in all agenda files and additionally
8273   in the files listed in ~org-agenda-text-search-extra-files~.  This
8274   uses the Emacs command ~multi-occur~.  A prefix argument can be used
8275   to specify the number of context lines for each match, default is
8276   1.
8278 - {{{kbd(#)}}}, {{{kbd(!)}}} ::
8280   Create a list of stuck projects (see [[*Stuck projects]]).
8282 - {{{kbd(<)}}} ::
8284   #+kindex: < @r{(Agenda dispatcher)}
8285   Restrict an agenda command to the current buffer[fn:91].  After
8286   pressing {{{kbd(<)}}}, you still need to press the character
8287   selecting the command.
8289 - {{{kbd(< <)}}} ::
8291   #+kindex: < < @r{(Agenda dispatcher)}
8292   If there is an active region, restrict the following agenda command
8293   to the region.  Otherwise, restrict it to the current
8294   subtree[fn:92].  After pressing {{{kbd(< <)}}}, you still need to
8295   press the character selecting the command.
8297 - {{{kbd(*)}}} ::
8299   #+kindex: * @r{(Agenda dispatcher)}
8300   #+vindex: org-agenda-sticky
8301   #+findex: org-toggle-sticky-agenda
8302   Toggle sticky agenda views.  By default, Org maintains only a single
8303   agenda buffer and rebuilds it each time you change the view, to make
8304   sure everything is always up to date.  If you switch between views
8305   often and the build time bothers you, you can turn on sticky agenda
8306   buffers (make this the default by customizing the variable
8307   ~org-agenda-sticky~).  With sticky agendas, the dispatcher only
8308   switches to the selected view, you need to update it by hand with
8309   {{{kbd(r)}}} or {{{kbd(g)}}}.  You can toggle sticky agenda view any
8310   time with ~org-toggle-sticky-agenda~.
8312 You can also define custom commands that are accessible through the
8313 dispatcher, just like the default commands.  This includes the
8314 possibility to create extended agenda buffers that contain several
8315 blocks together, for example the weekly agenda, the global TODO list
8316 and a number of special tags matches.  See [[*Custom Agenda Views]].
8318 ** The Built-in Agenda Views
8319 :PROPERTIES:
8320 :DESCRIPTION: What is available out of the box?
8321 :ALT_TITLE: Built-in Agenda Views
8322 :END:
8324 In this section we describe the built-in views.
8326 *** Weekly/daily agenda
8327 :PROPERTIES:
8328 :DESCRIPTION: The calendar page with current tasks.
8329 :END:
8330 #+cindex: agenda
8331 #+cindex: weekly agenda
8332 #+cindex: daily agenda
8334 The purpose of the weekly/daily /agenda/ is to act like a page of
8335 a paper agenda, showing all the tasks for the current week or day.
8337 - {{{kbd(M-x org-agenda a)}}} (~org-agenda-list~) ::
8339   #+kindex: a @r{(Agenda dispatcher)}
8340   #+findex: org-agenda-list
8341   #+cindex: org-agenda, command
8342   Compile an agenda for the current week from a list of Org files.
8343   The agenda shows the entries for each day.  With a numeric prefix
8344   argument[fn:93]---like {{{kbd(C-u 2 1 M-x org-agenda a)}}}---you may
8345   set the number of days to be displayed.
8347 #+vindex: org-agenda-span
8348 #+vindex: org-agenda-start-day
8349 #+vindex: org-agenda-start-on-weekday
8350 The default number of days displayed in the agenda is set by the
8351 variable ~org-agenda-span~.  This variable can be set to any number of
8352 days you want to see by default in the agenda, or to a span name, such
8353 a ~day~, ~week~, ~month~ or ~year~.  For weekly agendas, the default
8354 is to start on the previous Monday (see
8355 ~org-agenda-start-on-weekday~).  You can also set the start date using
8356 a date shift: =(setq org-agenda-start-day "+10d")= starts the agenda
8357 ten days from today in the future.
8359 Remote editing from the agenda buffer means, for example, that you can
8360 change the dates of deadlines and appointments from the agenda buffer.
8361 The commands available in the Agenda buffer are listed in [[*Commands in
8362 the Agenda Buffer]].
8364 **** Calendar/Diary integration
8365 :PROPERTIES:
8366 :UNNUMBERED: notoc
8367 :END:
8368 #+cindex: calendar integration
8369 #+cindex: diary integration
8371 Emacs contains the calendar and diary by Edward\nbsp{}M.\nbsp{}Reingold.  The
8372 calendar displays a three-month calendar with holidays from different
8373 countries and cultures.  The diary allows you to keep track of
8374 anniversaries, lunar phases, sunrise/set, recurrent appointments
8375 (weekly, monthly) and more.  In this way, it is quite complementary to
8376 Org.  It can be very useful to combine output from Org with the diary.
8378 In order to include entries from the Emacs diary into Org mode's
8379 agenda, you only need to customize the variable
8381 #+begin_src emacs-lisp
8382 (setq org-agenda-include-diary t)
8383 #+end_src
8385 #+texinfo: @noindent
8386 After that, everything happens automatically.  All diary entries
8387 including holidays, anniversaries, etc., are included in the agenda
8388 buffer created by Org mode.  {{{kbd(SPC)}}}, {{{kbd(TAB)}}}, and
8389 {{{kbd(RET)}}} can be used from the agenda buffer to jump to the diary
8390 file in order to edit existing diary entries.  The {{{kbd(i)}}}
8391 command to insert new entries for the current date works in the agenda
8392 buffer, as well as the commands {{{kbd(S)}}}, {{{kbd(M)}}}, and
8393 {{{kbd(C)}}} to display Sunrise/Sunset times, show lunar phases and to
8394 convert to other calendars, respectively.  {{{kbd(c)}}} can be used to
8395 switch back and forth between calendar and agenda.
8397 If you are using the diary only for expression entries and holidays,
8398 it is faster to not use the above setting, but instead to copy or even
8399 move the entries into an Org file.  Org mode evaluates diary-style
8400 expression entries, and does it faster because there is no overhead
8401 for first creating the diary display.  Note that the expression
8402 entries must start at the left margin, no whitespace is allowed before
8403 them, as seen in the following segment of an Org file:[fn:94]
8405 #+begin_example
8406 ,* Holidays
8407   :PROPERTIES:
8408   :CATEGORY: Holiday
8409   :END:
8410 %%(org-calendar-holiday)   ; special function for holiday names
8412 ,* Birthdays
8413   :PROPERTIES:
8414   :CATEGORY: Ann
8415   :END:
8416 %%(org-anniversary 1956  5 14) Arthur Dent is %d years old
8417 %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
8418 #+end_example
8420 **** Anniversaries from BBDB
8421 :PROPERTIES:
8422 :UNNUMBERED: notoc
8423 :END:
8424 #+cindex: BBDB, anniversaries
8425 #+cindex: anniversaries, from BBDB
8427 #+findex: org-bbdb-anniversaries
8428 If you are using the Insidious Big Brother Database to store your
8429 contacts, you very likely prefer to store anniversaries in BBDB rather
8430 than in a separate Org or diary file.  Org supports this and can show
8431 BBDB anniversaries as part of the agenda.  All you need to do is to
8432 add the following to one of your agenda files:
8434 #+begin_example
8435 ,* Anniversaries
8436   :PROPERTIES:
8437   :CATEGORY: Anniv
8438   :END:
8439 %%(org-bbdb-anniversaries)
8440 #+end_example
8442 You can then go ahead and define anniversaries for a BBDB record.
8443 Basically, you need a field named =anniversary= for the BBDB record
8444 which contains the date in the format =YYYY-MM-DD= or =MM-DD=,
8445 followed by a space and the class of the anniversary (=birthday=,
8446 =wedding=, or a format string).  If you omit the class, it defaults to
8447 =birthday=.  Here are a few examples, the header for the file
8448 =ol-bbdb.el= contains more detailed information.
8450 #+begin_example
8451 1973-06-22
8452 06-22
8453 1955-08-02 wedding
8454 2008-04-14 %s released version 6.01 of Org mode, %d years ago
8455 #+end_example
8457 After a change to BBDB, or for the first agenda display during an
8458 Emacs session, the agenda display suffers a short delay as Org updates
8459 its hash with anniversaries.  However, from then on things will be
8460 very fast, much faster in fact than a long list of
8461 =%%(diary-anniversary)= entries in an Org or Diary file.
8463 #+findex: org-bbdb-anniversaries-future
8464 If you would like to see upcoming anniversaries with a bit of
8465 forewarning, you can use the following instead:
8467 #+begin_example
8468 ,* Anniversaries
8469   :PROPERTIES:
8470   :CATEGORY: Anniv
8471   :END:
8472 %%(org-bbdb-anniversaries-future 3)
8473 #+end_example
8475 That will give you three days' warning: on the anniversary date itself
8476 and the two days prior.  The argument is optional: if omitted, it
8477 defaults to 7.
8479 **** Appointment reminders
8480 :PROPERTIES:
8481 :UNNUMBERED: notoc
8482 :END:
8483 #+cindex: @file{appt.el}
8484 #+cindex: appointment reminders
8485 #+cindex: appointment
8486 #+cindex: reminders
8488 #+cindex: APPT_WARNTIME, keyword
8489 Org can interact with Emacs appointments notification facility.  To
8490 add the appointments of your agenda files, use the command
8491 ~org-agenda-to-appt~.  This command lets you filter through the list
8492 of your appointments and add only those belonging to a specific
8493 category or matching a regular expression.  It also reads
8494 a =APPT_WARNTIME= property which overrides the value of
8495 ~appt-message-warning-time~ for this appointment.  See the docstring
8496 for details.
8498 *** The global TODO list
8499 :PROPERTIES:
8500 :DESCRIPTION: All unfinished action items.
8501 :ALT_TITLE: Global TODO list
8502 :END:
8503 #+cindex: global TODO list
8504 #+cindex: TODO list, global
8506 The global TODO list contains all unfinished TODO items formatted and
8507 collected into a single place.
8509 - {{{kbd(M-x org-agenda t)}}} (~org-todo-list~) ::
8511   #+kindex: t @r{(Agenda dispatcher)}
8512   #+findex: org-todo-list
8513   Show the global TODO list.  This collects the TODO items from all
8514   agenda files (see [[*Agenda Views]]) into a single buffer.  By default,
8515   this lists items with a state the is not a DONE state.  The buffer
8516   is in ~agenda-mode~, so there are commands to examine and manipulate
8517   the TODO entries directly from that buffer (see [[*Commands in the
8518   Agenda Buffer]]).
8520 - {{{kbd(M-x org-agenda T)}}} (~org-todo-list~) ::
8522   #+kindex: T @r{(Agenda dispatcher)}
8523   #+findex: org-todo-list
8524   #+cindex: TODO keyword matching
8525   #+vindex: org-todo-keywords
8526   Like the above, but allows selection of a specific TODO keyword.
8527   You can also do this by specifying a prefix argument to
8528   {{{kbd(t)}}}.  You are prompted for a keyword, and you may also
8529   specify several keywords by separating them with =|= as the boolean
8530   OR operator.  With a numeric prefix, the Nth keyword in
8531   ~org-todo-keywords~ is selected.
8533   #+kindex: r
8534   The {{{kbd(r)}}} key in the agenda buffer regenerates it, and you
8535   can give a prefix argument to this command to change the selected
8536   TODO keyword, for example {{{kbd(3 r)}}}.  If you often need
8537   a search for a specific keyword, define a custom command for it (see
8538   [[*The Agenda Dispatcher]]).
8540   Matching specific TODO keywords can also be done as part of a tags
8541   search (see [[*Tag Searches]]).
8543 Remote editing of TODO items means that you can change the state of
8544 a TODO entry with a single key press.  The commands available in the
8545 TODO list are described in [[*Commands in the Agenda Buffer]].
8547 #+cindex: sublevels, inclusion into TODO list
8548 Normally the global TODO list simply shows all headlines with TODO
8549 keywords.  This list can become very long.  There are two ways to keep
8550 it more compact:
8553   #+vindex: org-agenda-todo-ignore-scheduled
8554   #+vindex: org-agenda-todo-ignore-deadlines
8555   #+vindex: org-agenda-todo-ignore-timestamp
8556   #+vindex: org-agenda-todo-ignore-with-date
8557   Some people view a TODO item that has been /scheduled/ for execution
8558   or have a /deadline/ (see [[*Timestamps]]) as no longer /open/.
8559   Configure the variables ~org-agenda-todo-ignore-scheduled~,
8560   ~org-agenda-todo-ignore-deadlines~,
8561   ~org-agenda-todo-ignore-timestamp~ and/or
8562   ~org-agenda-todo-ignore-with-date~ to exclude such items from the
8563   global TODO list.
8566   #+vindex: org-agenda-todo-list-sublevels
8567   TODO items may have sublevels to break up the task into subtasks.
8568   In such cases it may be enough to list only the highest level TODO
8569   headline and omit the sublevels from the global list.  Configure the
8570   variable ~org-agenda-todo-list-sublevels~ to get this behavior.
8572 *** Matching tags and properties
8573 :PROPERTIES:
8574 :DESCRIPTION: Structured information with fine-tuned search.
8575 :END:
8576 #+cindex: matching, of tags
8577 #+cindex: matching, of properties
8578 #+cindex: tags view
8579 #+cindex: match view
8581 If headlines in the agenda files are marked with /tags/ (see [[*Tags]]),
8582 or have properties (see [[*Properties and Columns]]), you can select
8583 headlines based on this metadata and collect them into an agenda
8584 buffer.  The match syntax described here also applies when creating
8585 sparse trees with {{{kbd(C-c / m)}}}.
8587 - {{{kbd(M-x org-agenda m)}}} (~org-tags-view~) ::
8589   #+kindex: m @r{(Agenda dispatcher)}
8590   #+findex: org-tags-view
8591   Produce a list of all headlines that match a given set of tags.  The
8592   command prompts for a selection criterion, which is a boolean logic
8593   expression with tags, like =+work+urgent-withboss= or =work|home=
8594   (see [[*Tags]]).  If you often need a specific search, define a custom
8595   command for it (see [[*The Agenda Dispatcher]]).
8597 - {{{kbd(M-x org-agenda M)}}} (~org-tags-view~) ::
8599   #+kindex: M @r{(Agenda dispatcher)}
8600   #+findex: org-tags-view
8601   #+vindex: org-tags-match-list-sublevels
8602   #+vindex: org-agenda-tags-todo-honor-ignore-options
8603   Like {{{kbd(m)}}}, but only select headlines that are also TODO
8604   items and force checking subitems (see the variable
8605   ~org-tags-match-list-sublevels~).  To exclude scheduled/deadline
8606   items, see the variable ~org-agenda-tags-todo-honor-ignore-options~.
8607   Matching specific TODO keywords together with a tags match is also
8608   possible, see [[*Tag Searches]].
8610 The commands available in the tags list are described in [[*Commands in
8611 the Agenda Buffer]].
8613 #+cindex: boolean logic, for agenda searches
8614 A search string can use Boolean operators =&= for AND and =|= for OR.
8615 =&= binds more strongly than =|=.  Parentheses are currently not
8616 implemented.  Each element in the search is either a tag, a regular
8617 expression matching tags, or an expression like =PROPERTY OPERATOR
8618 VALUE= with a comparison operator, accessing a property value.  Each
8619 element may be preceded by =-= to select against it, and =+= is
8620 syntactic sugar for positive selection.  The AND operator =&= is
8621 optional when =+= or =-= is present.  Here are some examples, using
8622 only tags.
8624 - =+work-boss= ::
8626   Select headlines tagged =work=, but discard those also tagged
8627   =boss=.
8629 - =work|laptop= ::
8631   Selects lines tagged =work= or =laptop=.
8633 - =work|laptop+night= ::
8635   Like before, but require the =laptop= lines to be tagged also
8636   =night=.
8638 #+cindex: regular expressions, with tags search
8639 Instead of a tag, you may also specify a regular expression enclosed
8640 in curly braces.  For example, =work+{^boss.*}= matches headlines that
8641 contain the tag =:work:= and any tag /starting/ with =boss=.
8643 #+cindex: group tags, as regular expressions
8644 Group tags (see [[*Tag Hierarchy]]) are expanded as regular expressions.
8645 E.g., if =work= is a group tag for the group =:work:lab:conf:=, then
8646 searching for =work= also searches for ={\(?:work\|lab\|conf\)}= and
8647 searching for =-work= searches for all headlines but those with one of
8648 the tags in the group (i.e., =-{\(?:work\|lab\|conf\)}=).
8650 #+cindex: TODO keyword matching, with tags search
8651 #+cindex: level, for tags/property match
8652 #+cindex: category, for tags/property match
8653 #+vindex: org-odd-levels-only
8654 You may also test for properties (see [[*Properties and Columns]]) at the
8655 same time as matching tags.  The properties may be real properties, or
8656 special properties that represent other metadata (see [[*Special
8657 Properties]]).  For example, the property =TODO= represents the TODO
8658 keyword of the entry.  Or, the property =LEVEL= represents the level
8659 of an entry.  So searching =+LEVEL=3+boss-TODO​="DONE"= lists all level
8660 three headlines that have the tag =boss= and are /not/ marked with the
8661 TODO keyword =DONE=.  In buffers with ~org-odd-levels-only~ set,
8662 =LEVEL= does not count the number of stars, but =LEVEL=2= corresponds
8663 to 3 stars etc.
8665 Here are more examples:
8667 - =work+TODO​="WAITING"= ::
8669   Select =work=-tagged TODO lines with the specific TODO keyword
8670   =WAITING=.
8672 - =work+TODO​="WAITING"|home+TODO​="WAITING"= ::
8674   Waiting tasks both at work and at home.
8676 When matching properties, a number of different operators can be used
8677 to test the value of a property.  Here is a complex example:
8679 #+begin_example
8680 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2
8681          +With={Sarah|Denny}+SCHEDULED>="<2008-10-11>"
8682 #+end_example
8684 #+texinfo: @noindent
8685 The type of comparison depends on how the comparison value is written:
8687 - If the comparison value is a plain number, a numerical comparison is
8688   done, and the allowed operators are =<=, ===, =>=, =<==, =>==, and
8689   =<>=.
8691 - If the comparison value is enclosed in double-quotes, a string
8692   comparison is done, and the same operators are allowed.
8694 - If the comparison value is enclosed in double-quotes /and/ angular
8695   brackets (like =DEADLINE<​="<2008-12-24 18:30>"=), both values are
8696   assumed to be date/time specifications in the standard Org way, and
8697   the comparison is done accordingly.  Valid values also include
8698   ="<now>"= for now (including time), ="<today>"=, and ="<tomorrow>"=
8699   for these days at 0:00 hours, i.e., without a time specification.
8700   You can also use strings like ="<+5d>"= or ="<-2m>"= with units =d=,
8701   =w=, =m=, and =y= for day, week, month, and year, respectively.
8703 - If the comparison value is enclosed in curly braces, a regexp match
8704   is performed, with === meaning that the regexp matches the property
8705   value, and =<>= meaning that it does not match.
8707 So the search string in the example finds entries tagged =work= but
8708 not =boss=, which also have a priority value =A=, a =Coffee= property
8709 with the value =unlimited=, an =EFFORT= property that is numerically
8710 smaller than 2, a =With= property that is matched by the regular
8711 expression =Sarah|Denny=, and that are scheduled on or after October
8712 11, 2008.
8714 You can configure Org mode to use property inheritance during
8715 a search, but beware that this can slow down searches considerably.
8716 See [[*Property Inheritance]], for details.
8718 For backward compatibility, and also for typing speed, there is also
8719 a different way to test TODO states in a search.  For this, terminate
8720 the tags/property part of the search string (which may include several
8721 terms connected with =|=) with a =/= and then specify a Boolean
8722 expression just for TODO keywords.  The syntax is then similar to that
8723 for tags, but should be applied with care: for example, a positive
8724 selection on several TODO keywords cannot meaningfully be combined
8725 with boolean AND.  However, /negative selection/ combined with AND can
8726 be meaningful.  To make sure that only lines are checked that actually
8727 have any TODO keyword (resulting in a speed-up), use {{{kbd(M-x
8728 org-agenda M)}}}, or equivalently start the TODO part after the slash
8729 with =!=.  Using {{{kbd(M-x org-agenda M)}}} or =/!= does not match
8730 TODO keywords in a DONE state.  Examples:
8732 - =work/WAITING= ::
8734   Same as =work+TODO​="WAITING"=.
8736 - =work/!-WAITING-NEXT= ::
8738   Select =work=-tagged TODO lines that are neither =WAITING= nor
8739   =NEXT=.
8741 - =work/!+WAITING|+NEXT= ::
8743   Select =work=-tagged TODO lines that are either =WAITING= or =NEXT=.
8745 *** Search view
8746 :PROPERTIES:
8747 :DESCRIPTION: Find entries by searching for text.
8748 :END:
8749 #+cindex: search view
8750 #+cindex: text search
8751 #+cindex: searching, for text
8753 This agenda view is a general text search facility for Org mode
8754 entries.  It is particularly useful to find notes.
8756 - {{{kbd(M-x org-agenda s)}}} (~org-search-view~) ::
8758   #+kindex: s @r{(Agenda dispatcher)}
8759   #+findex: org-search-view
8760   This is a special search that lets you select entries by matching
8761   a substring or specific words using a boolean logic.
8763 For example, the search string =computer equipment= matches entries
8764 that contain =computer equipment= as a substring, even if the two
8765 words are separated by more space or a line break.
8767 Search view can also search for specific keywords in the entry, using
8768 Boolean logic.  The search string =+computer
8769 +wifi -ethernet -{8\.11[bg]}= matches note entries that contain the
8770 keywords =computer= and =wifi=, but not the keyword =ethernet=, and
8771 which are also not matched by the regular expression =8\.11[bg]=,
8772 meaning to exclude both =8.11b= and =8.11g=.  The first =+= is
8773 necessary to turn on boolean search, other =+= characters are
8774 optional.  For more details, see the docstring of the command
8775 ~org-search-view~.
8777 You can incrementally adjust a boolean search with the following keys
8779 #+attr_texinfo: :columns 0.1 0.6
8780 | {{{kbd([)}}} | Add a positive search word        |
8781 | {{{kbd(])}}} | Add a negative search word        |
8782 | {{{kbd({)}}} | Add a positive regular expression |
8783 | {{{kbd(})}}} | Add a negative regular expression |
8785 #+vindex: org-agenda-text-search-extra-files
8786 Note that in addition to the agenda files, this command also searches
8787 the files listed in ~org-agenda-text-search-extra-files~.
8789 *** Stuck projects
8790 :PROPERTIES:
8791 :DESCRIPTION: Find projects you need to review.
8792 :END:
8793 #+pindex: GTD, Getting Things Done
8795 If you are following a system like David Allen's GTD to organize your
8796 work, one of the "duties" you have is a regular review to make sure
8797 that all projects move along.  A /stuck/ project is a project that has
8798 no defined next actions, so it never shows up in the TODO lists Org
8799 mode produces.  During the review, you need to identify such projects
8800 and define next actions for them.
8802 - {{{kbd(M-x org-agenda #)}}} (~org-agenda-list-stuck-projects~) ::
8804   #+kindex: # @r{(Agenda dispatcher)}
8805   #+findex: org-agenda-list-stuck-projects
8806   List projects that are stuck.
8808 - {{{kbd(M-x org-agenda !)}}} ::
8810   #+kindex: ! @r{(Agenda dispatcher)}
8811   #+vindex: org-stuck-projects
8812   Customize the variable ~org-stuck-projects~ to define what a stuck
8813   project is and how to find it.
8815 You almost certainly need to configure this view before it works for
8816 you.  The built-in default assumes that all your projects are level-2
8817 headlines, and that a project is not stuck if it has at least one
8818 entry marked with a TODO keyword =TODO= or =NEXT= or =NEXTACTION=.
8820 Let's assume that you, in your own way of using Org mode, identify
8821 projects with a tag =:PROJECT:=, and that you use a TODO keyword
8822 =MAYBE= to indicate a project that should not be considered yet.
8823 Let's further assume that the TODO keyword =DONE= marks finished
8824 projects, and that =NEXT= and =TODO= indicate next actions.  The tag
8825 =:@shop:= indicates shopping and is a next action even without the
8826 NEXT tag.  Finally, if the project contains the special word =IGNORE=
8827 anywhere, it should not be listed either.  In this case you would
8828 start by identifying eligible projects with a tags/TODO match (see
8829 [[*Tag Searches]]) =+PROJECT/-MAYBE-DONE=, and then check for =TODO=,
8830 =NEXT=, =@shop=, and =IGNORE= in the subtree to identify projects that
8831 are not stuck.  The correct customization for this is:
8833 #+begin_src emacs-lisp
8834 (setq org-stuck-projects
8835       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@shop")
8836         "\\<IGNORE\\>"))
8837 #+end_src
8839 Note that if a project is identified as non-stuck, the subtree of this
8840 entry is searched for stuck projects.
8842 ** Presentation and Sorting
8843 :PROPERTIES:
8844 :DESCRIPTION: How agenda items are prepared for display.
8845 :END:
8846 #+cindex: presentation, of agenda items
8848 #+vindex: org-agenda-prefix-format
8849 #+vindex: org-agenda-tags-column
8850 Before displaying items in an agenda view, Org mode visually prepares
8851 the items and sorts them.  Each item occupies a single line.  The line
8852 starts with a /prefix/ that contains the /category/ (see [[*Categories]])
8853 of the item and other important information.  You can customize in
8854 which column tags are displayed through ~org-agenda-tags-column~.  You
8855 can also customize the prefix using the option
8856 ~org-agenda-prefix-format~.  This prefix is followed by a cleaned-up
8857 version of the outline headline associated with the item.
8859 *** Categories
8860 :PROPERTIES:
8861 :DESCRIPTION: Not all tasks are equal.
8862 :END:
8863 #+cindex: category
8864 #+cindex: @samp{CATEGORY}, keyword
8866 The category is a broad label assigned to each agenda item.  By
8867 default, the category is simply derived from the file name, but you
8868 can also specify it with a special line in the buffer, like
8869 this:
8871 : #+CATEGORY: Thesis
8873 #+cindex: @samp{CATEGORY}, property
8874 If you would like to have a special category for a single entry or
8875 a (sub)tree, give the entry a =CATEGORY= property with the special
8876 category you want to apply as the value.
8878 The display in the agenda buffer looks best if the category is not
8879 longer than 10 characters.
8881 #+vindex: org-agenda-category-icon-alist
8882 You can set up icons for category by customizing the
8883 ~org-agenda-category-icon-alist~ variable.
8885 *** Time-of-day specifications
8886 :PROPERTIES:
8887 :DESCRIPTION: How the agenda knows the time.
8888 :END:
8889 #+cindex: time-of-day specification
8891 Org mode checks each agenda item for a time-of-day specification.  The
8892 time can be part of the timestamp that triggered inclusion into the
8893 agenda, for example
8895 : <2005-05-10 Tue 19:00>
8897 #+texinfo: @noindent
8898 Time ranges can be specified with two timestamps:
8900 : <2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>
8902 #+vindex: org-agenda-search-headline-for-time
8903 In the headline of the entry itself, a time(range)---like =12:45= or
8904 a =8:30-1pm=---may also appear as plain text[fn:95].
8906 If the agenda integrates the Emacs diary (see [[*Weekly/daily agenda]]),
8907 time specifications in diary entries are recognized as well.
8909 For agenda display, Org mode extracts the time and displays it in
8910 a standard 24 hour format as part of the prefix.  The example times in
8911 the previous paragraphs would end up in the agenda like this:
8913 #+begin_example
8914  8:30-13:00 Arthur Dent lies in front of the bulldozer
8915 12:45...... Ford Prefect arrives and takes Arthur to the pub
8916 19:00...... The Vogon reads his poem
8917 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
8918 #+end_example
8920 #+cindex: time grid
8921 If the agenda is in single-day mode, or for the display of today, the
8922 timed entries are embedded in a time grid, like
8924 #+begin_example
8925  8:00...... ------------------
8926  8:30-13:00 Arthur Dent lies in front of the bulldozer
8927 10:00...... ------------------
8928 12:00...... ------------------
8929 12:45...... Ford Prefect arrives and takes Arthur to the pub
8930 14:00...... ------------------
8931 16:00...... ------------------
8932 18:00...... ------------------
8933 19:00...... The Vogon reads his poem
8934 20:00...... ------------------
8935 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
8936 #+end_example
8938 #+vindex: org-agenda-use-time-grid
8939 #+vindex: org-agenda-time-grid
8940 The time grid can be turned on and off with the variable
8941 ~org-agenda-use-time-grid~, and can be configured with
8942 ~org-agenda-time-grid~.
8944 *** Sorting of agenda items
8945 :PROPERTIES:
8946 :DESCRIPTION: The order of things.
8947 :END:
8948 #+cindex: sorting, of agenda items
8949 #+cindex: priorities, of agenda items
8951 Before being inserted into a view, the items are sorted.  How this is
8952 done depends on the type of view.
8955   #+vindex: org-agenda-files
8956   For the daily/weekly agenda, the items for each day are sorted.  The
8957   default order is to first collect all items containing an explicit
8958   time-of-day specification.  These entries are shown at the beginning
8959   of the list, as a /schedule/ for the day.  After that, items remain
8960   grouped in categories, in the sequence given by ~org-agenda-files~.
8961   Within each category, items are sorted by priority (see
8962   [[*Priorities]]), which is composed of the base priority (2000 for
8963   priority =A=, 1000 for =B=, and 0 for =C=), plus additional
8964   increments for overdue scheduled or deadline items.
8966 - For the TODO list, items remain in the order of categories, but
8967   within each category, sorting takes place according to priority (see
8968   [[*Priorities]]).  The priority used for sorting derives from the
8969   priority cookie, with additions depending on how close an item is to
8970   its due or scheduled date.
8972 - For tags matches, items are not sorted at all, but just appear in
8973   the sequence in which they are found in the agenda files.
8975 #+vindex: org-agenda-sorting-strategy
8976 Sorting can be customized using the variable
8977 ~org-agenda-sorting-strategy~, and may also include criteria based on
8978 the estimated effort of an entry (see [[*Effort Estimates]]).
8980 *** Filtering/limiting agenda items
8981 :PROPERTIES:
8982 :DESCRIPTION: Dynamically narrow the agenda.
8983 :END:
8985 Agenda built-in or customized commands are statically defined.  Agenda
8986 filters and limits provide two ways of dynamically narrowing down the
8987 list of agenda entries: /filters/ and /limits/.  Filters only act on
8988 the display of the items, while limits take effect before the list of
8989 agenda entries is built.  Filters are more often used interactively,
8990 while limits are mostly useful when defined as local variables within
8991 custom agenda commands.
8993 **** Filtering in the agenda
8994 :PROPERTIES:
8995 :UNNUMBERED: notoc
8996 :END:
8997 #+cindex: agenda filtering
8998 #+cindex: filtering entries, in agenda
8999 #+cindex: tag filtering, in agenda
9000 #+cindex: category filtering, in agenda
9001 #+cindex: top headline filtering, in agenda
9002 #+cindex: effort filtering, in agenda
9003 #+cindex: query editing, in agenda
9005 - {{{kbd(/)}}} (~org-agenda-filter-by-tag~) ::
9007   #+findex: org-agenda-filter-by-tag
9008   #+vindex: org-agenda-tag-filter-preset
9009   Filter the agenda view with respect to a tag and/or effort
9010   estimates.  The difference between this and a custom agenda command
9011   is that filtering is very fast, so that you can switch quickly
9012   between different filters without having to recreate the
9013   agenda.[fn:96]
9015   You are prompted for a tag selection letter; {{{kbd(SPC)}}} means
9016   any tag at all.  Pressing {{{kbd(TAB)}}} at that prompt offers
9017   completion to select a tag, including any tags that do not have
9018   a selection character.  The command then hides all entries that do
9019   not contain or inherit this tag.  When called with prefix argument,
9020   remove the entries that /do/ have the tag.  A second {{{kbd(/)}}} at
9021   the prompt turns off the filter and shows any hidden entries.
9022   Pressing {{{kbd(+)}}} or {{{kbd(-)}}} switches between filtering and
9023   excluding the next tag.
9025   #+vindex: org-agenda-auto-exclude-function
9026   Org also supports automatic, context-aware tag filtering.  If the
9027   variable ~org-agenda-auto-exclude-function~ is set to a user-defined
9028   function, that function can decide which tags should be excluded
9029   from the agenda automatically.  Once this is set, the {{{kbd(/)}}}
9030   command then accepts {{{kbd(RET)}}} as a sub-option key and runs the
9031   auto exclusion logic.  For example, let's say you use a =Net= tag to
9032   identify tasks which need network access, an =Errand= tag for
9033   errands in town, and a =Call= tag for making phone calls.  You could
9034   auto-exclude these tags based on the availability of the Internet,
9035   and outside of business hours, with something like this:
9037   #+begin_src emacs-lisp
9038   (defun org-my-auto-exclude-function (tag)
9039     (and (cond
9040           ((string= tag "Net")
9041            (/= 0 (call-process "/sbin/ping" nil nil nil
9042                                "-c1" "-q" "-t1" "mail.gnu.org")))
9043           ((or (string= tag "Errand") (string= tag "Call"))
9044            (let ((hour (nth 2 (decode-time))))
9045              (or (< hour 8) (> hour 21)))))
9046          (concat "-" tag)))
9048   (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
9049   #+end_src
9051 - {{{kbd(<)}}} (~org-agenda-filter-by-category~) ::
9053   #+findex: org-agenda-filter-by-category
9054   Filter the current agenda view with respect to the category of the
9055   item at point.  Pressing {{{kbd(<)}}} another time removes this
9056   filter.  When called with a prefix argument exclude the category of
9057   the item at point from the agenda.
9059   #+vindex: org-agenda-category-filter-preset
9060   You can add a filter preset in custom agenda commands through the
9061   option ~org-agenda-category-filter-preset~.  See [[*Setting options
9062   for custom commands]].
9064 - {{{kbd(^)}}} (~org-agenda-filter-by-top-headline~) ::
9066   #+findex: org-agenda-filter-by-top-headline
9067   Filter the current agenda view and only display the siblings and the
9068   parent headline of the one at point.
9070 - {{{kbd(=)}}} (~org-agenda-filter-by-regexp~) ::
9072   #+findex: org-agenda-filter-by-regexp
9073   Filter the agenda view by a regular expression: only show agenda
9074   entries matching the regular expression the user entered.  When
9075   called with a prefix argument, it filters /out/ entries matching the
9076   regexp.  Called in a regexp-filtered agenda view, remove the filter,
9077   unless there are two universal prefix arguments, in which case
9078   filters are cumulated.
9080   #+vindex: org-agenda-regexp-filter-preset
9081   You can add a filter preset in custom agenda commands through the
9082   option ~org-agenda-regexp-filter-preset~.  See [[*Setting options
9083   for custom commands]].
9085 - {{{kbd(_)}}} (~org-agenda-filter-by-effort~) ::
9087   #+findex: org-agenda-filter-by-effort
9088   Filter the agenda view with respect to effort estimates.  You first
9089   need to set up allowed efforts globally, for example
9091   #+begin_src emacs-lisp
9092   (setq org-global-properties
9093         '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
9094   #+end_src
9096   #+vindex: org-sort-agenda-noeffort-is-high
9097   You can then filter for an effort by first typing an operator, one
9098   of {{{kbd(<)}}}, {{{kbd(>)}}} and {{{kbd(=)}}}, and then the
9099   one-digit index of an effort estimate in your array of allowed
9100   values, where {{{kbd(0)}}} means the 10th value.  The filter then
9101   restricts to entries with effort smaller-or-equal, equal, or
9102   larger-or-equal than the selected value.  For application of the
9103   operator, entries without a defined effort are treated according to
9104   the value of ~org-sort-agenda-noeffort-is-high~.
9106   When called with a prefix argument, it removes entries matching the
9107   condition.  With two universal prefix arguments, it clears effort
9108   filters, which can be accumulated.
9110   #+vindex: org-agenda-effort-filter-preset
9111   You can add a filter preset in custom agenda commands through the
9112   option ~org-agenda-effort-filter-preset~.  See [[*Setting options for
9113   custom commands]].
9115 - {{{kbd(|)}}} (~org-agenda-filter-remove-all~) ::
9117   Remove all filters in the current agenda view.
9119 **** Setting limits for the agenda
9120 :PROPERTIES:
9121 :UNNUMBERED: notoc
9122 :END:
9123 #+cindex: limits, in agenda
9125 Here is a list of options that you can set, either globally, or
9126 locally in your custom agenda views (see [[*Custom Agenda Views]]).
9128 - ~org-agenda-max-entries~ ::
9130   #+vindex: org-agenda-max-entries
9131   Limit the number of entries.
9133 - ~org-agenda-max-effort~ ::
9135   #+vindex: org-agenda-max-effort
9136   Limit the duration of accumulated efforts (as minutes).
9138 - ~org-agenda-max-todos~ ::
9140   #+vindex: org-agenda-max-todos
9141   Limit the number of entries with TODO keywords.
9143 - ~org-agenda-max-tags~ ::
9145   #+vindex: org-agenda-max-tags
9146   Limit the number of tagged entries.
9148 When set to a positive integer, each option excludes entries from
9149 other categories: for example, =(setq org-agenda-max-effort 100)=
9150 limits the agenda to 100 minutes of effort and exclude any entry that
9151 has no effort property.  If you want to include entries with no effort
9152 property, use a negative value for ~org-agenda-max-effort~.  One
9153 useful setup is to use ~org-agenda-max-entries~ locally in a custom
9154 command.  For example, this custom command displays the next five
9155 entries with a =NEXT= TODO keyword.
9157 #+begin_src emacs-lisp
9158 (setq org-agenda-custom-commands
9159       '(("n" todo "NEXT"
9160          ((org-agenda-max-entries 5)))))
9161 #+end_src
9163 Once you mark one of these five entry as DONE, rebuilding the agenda
9164 will again the next five entries again, including the first entry that
9165 was excluded so far.
9167 You can also dynamically set temporary limits, which are lost when
9168 rebuilding the agenda:
9170 - {{{kbd(~ )}}} (~org-agenda-limit-interactively~) ::
9172   #+findex: org-agenda-limit-interactively
9173   This prompts for the type of limit to apply and its value.
9175 ** Commands in the Agenda Buffer
9176 :PROPERTIES:
9177 :DESCRIPTION: Remote editing of Org trees.
9178 :ALT_TITLE: Agenda Commands
9179 :END:
9180 #+cindex: commands, in agenda buffer
9182 Entries in the agenda buffer are linked back to the Org file or diary
9183 file where they originate.  You are not allowed to edit the agenda
9184 buffer itself, but commands are provided to show and jump to the
9185 original entry location, and to edit the Org files "remotely" from the
9186 agenda buffer.  In this way, all information is stored only once,
9187 removing the risk that your agenda and note files may diverge.
9189 Some commands can be executed with mouse clicks on agenda lines.  For
9190 the other commands, point needs to be in the desired line.
9192 *** Motion
9193 :PROPERTIES:
9194 :UNNUMBERED: notoc
9195 :END:
9196 #+cindex: motion commands in agenda
9198 - {{{kbd(n)}}} (~org-agenda-next-line~) ::
9200   #+kindex: n
9201   #+findex: org-agenda-next-line
9202   Next line (same as {{{kbd(DOWN)}}} and {{{kbd(C-n)}}}).
9204 - {{{kbd(p)}}} (~org-agenda-previous-line~) ::
9206   #+kindex: p
9207   #+findex: org-agenda-previous-line
9208   Previous line (same as {{{kbd(UP)}}} and {{{kbd(C-p)}}}).
9210 *** View/Go to Org file
9211 :PROPERTIES:
9212 :UNNUMBERED: notoc
9213 :END:
9214 #+cindex: view file commands in agenda
9216 - {{{kbd(SPC)}}} or {{{kbd(mouse-3)}}} (~org-agenda-show-and-scroll-up~) ::
9218   #+kindex: SPC
9219   #+kindex: mouse-3
9220   #+findex: org-agenda-show-and-scroll-up
9221   Display the original location of the item in another window.
9222   With a prefix argument, make sure that drawers stay folded.
9224 - {{{kbd(L)}}} (~org-agenda-recenter~) ::
9226   #+findex: org-agenda-recenter
9227   Display original location and recenter that window.
9229 - {{{kbd(TAB)}}} or {{{kbd(mouse-2)}}} (~org-agenda-goto~) ::
9231   #+kindex: TAB
9232   #+kindex: mouse-2
9233   #+findex: org-agenda-goto
9234   Go to the original location of the item in another window.
9236 - {{{kbd(RET)}}} (~org-agenda-switch-to~) ::
9238   #+kindex: RET
9239   #+findex: org-agenda-switch-to
9240   Go to the original location of the item and delete other windows.
9242 - {{{kbd(F)}}} (~org-agenda-follow-mode~) ::
9244   #+kindex: F
9245   #+findex: org-agenda-follow-mode
9246   #+vindex: org-agenda-start-with-follow-mode
9247   Toggle Follow mode.  In Follow mode, as you move point through the
9248   agenda buffer, the other window always shows the corresponding
9249   location in the Org file.  The initial setting for this mode in new
9250   agenda buffers can be set with the variable
9251   ~org-agenda-start-with-follow-mode~.
9253 - {{{kbd(C-c C-x b)}}} (~org-agenda-tree-to-indirect-buffer~) ::
9255   #+kindex: C-c C-x b
9256   #+findex: org-agenda-tree-to-indirect-buffer
9257   Display the entire subtree of the current item in an indirect
9258   buffer.  With a numeric prefix argument N, go up to level N and then
9259   take that tree.  If N is negative, go up that many levels.  With
9260   a {{{kbd(C-u)}}} prefix, do not remove the previously used indirect
9261   buffer.
9263 - {{{kbd(C-c C-o)}}} (~org-agenda-open-link~) ::
9265   #+kindex: C-c C-o
9266   #+findex: org-agenda-open-link
9267   Follow a link in the entry.  This offers a selection of any links in
9268   the text belonging to the referenced Org node.  If there is only one
9269   link, follow it without a selection prompt.
9271 *** Change display
9272 :PROPERTIES:
9273 :UNNUMBERED: notoc
9274 :END:
9275 #+cindex: change agenda display
9276 #+cindex: display changing, in agenda
9278 #+attr_texinfo: :sep ,
9279 - {{{kbd(A)}}} ::
9281   #+kindex: A
9282   Interactively select another agenda view and append it to the
9283   current view.
9285 - {{{kbd(o)}}} ::
9287   #+kindex: o
9288   Delete other windows.
9290 - {{{kbd(v d)}}} or short {{{kbd(d)}}} (~org-agenda-day-view~) ::
9292   #+kindex: v d
9293   #+kindex: d
9294   #+findex: org-agenda-day-view
9295   Switch to day view.  When switching to day view, this setting
9296   becomes the default for subsequent agenda refreshes.  A numeric
9297   prefix argument may be used to jump directly to a specific day of
9298   the year.  For example, {{{kbd(32 d)}}} jumps to February 1st.  When
9299   setting day view, a year may be encoded in the prefix argument as
9300   well.  For example, {{{kbd(200712 d)}}} jumps to January 12, 2007.
9301   If such a year specification has only one or two digits, it is
9302   expanded into one of the 30 next years or the last 69 years.
9304 - {{{kbd(v w)}}} or short {{{kbd(w)}}} (~org-agenda-week-view~) ::
9306   #+kindex: v w
9307   #+kindex: w
9308   #+findex: org-agenda-week-view
9309   Switch to week view.  When switching week view, this setting becomes
9310   the default for subsequent agenda refreshes.  A numeric prefix
9311   argument may be used to jump directly to a specific day of the ISO
9312   week.  For example {{{kbd(9 w)}}} to ISO week number 9.  When
9313   setting week view, a year may be encoded in the prefix argument as
9314   well.  For example, {{{kbd(200712 w)}}} jumps to week 12 in 2007.
9315   If such a year specification has only one or two digits, it is
9316   expanded into one of the 30 next years or the last 69 years.
9318 - {{{kbd(v m)}}} (~org-agenda-month-view~) ::
9320   #+kindex: v m
9321   #+findex: org-agenda-month-view
9322   Switch to month view.  Because month views are slow to create, they
9323   do not become the default for subsequent agenda refreshes.
9324   A numeric prefix argument may be used to jump directly to a specific
9325   day of the month.  When setting month view, a year may be encoded in
9326   the prefix argument as well.  For example, {{{kbd(200712 m)}}} jumps
9327   to December, 2007.  If such a year specification has only one or two
9328   digits, it is expanded into one of the 30 next years or the last 69
9329   years.
9331 - {{{kbd(v y)}}} (~org-agenda-year-view~) ::
9333   #+kindex: v y
9334   #+findex: org-agenda-year-view
9335   Switch to year view.  Because year views are slow to create, they do
9336   not become the default for subsequent agenda refreshes.  A numeric
9337   prefix argument may be used to jump directly to a specific day of
9338   the year.
9340 - {{{kbd(v SPC)}}} (~org-agenda-reset-view~) ::
9342   #+kindex: v SPC
9343   #+findex: org-agenda-reset-view
9344   #+vindex: org-agenda-span
9345   Reset the current view to ~org-agenda-span~.
9347 - {{{kbd(f)}}} (~org-agenda-later~) ::
9349   #+kindex: f
9350   #+findex: org-agenda-later
9351   Go forward in time to display the span following the current one.
9352   For example, if the display covers a week, switch to the following
9353   week.  With a prefix argument, repeat that many times.
9355 - {{{kbd(b)}}} (~org-agenda-earlier~) ::
9357   #+kindex: b
9358   #+findex: org-agenda-earlier
9359   Go backward in time to display earlier dates.
9361 - {{{kbd(.)}}} (~org-agenda-goto-today~) ::
9363   #+kindex: .
9364   #+findex: org-agenda-goto-today
9365   Go to today.
9367 - {{{kbd(j)}}} (~org-agenda-goto-date~) ::
9369   #+kindex: j
9370   #+findex: org-agenda-goto-date
9371   Prompt for a date and go there.
9373 - {{{kbd(J)}}} (~org-agenda-clock-goto~) ::
9375   #+kindex: J
9376   #+findex: org-agenda-clock-goto
9377   Go to the currently clocked-in task /in the agenda buffer/.
9379 - {{{kbd(D)}}} (~org-agenda-toggle-diary~) ::
9381   #+kindex: D
9382   #+findex: org-agenda-toggle-diary
9383   Toggle the inclusion of diary entries.  See [[*Weekly/daily agenda]].
9385 - {{{kbd(v l)}}} or {{{kbd(v L)}}} or short {{{kbd(l)}}} (~org-agenda-log-mode~) ::
9387   #+kindex: v l
9388   #+kindex: l
9389   #+kindex: v L
9390   #+findex: org-agenda-log-mode
9391   #+vindex: org-log-done
9392   #+vindex: org-agenda-log-mode-items
9393   Toggle Logbook mode.  In Logbook mode, entries that were marked as
9394   done while logging was on (see the variable ~org-log-done~) are
9395   shown in the agenda, as are entries that have been clocked on that
9396   day.  You can configure the entry types that should be included in
9397   log mode using the variable ~org-agenda-log-mode-items~.  When
9398   called with a {{{kbd(C-u)}}} prefix argument, show all possible
9399   logbook entries, including state changes.  When called with two
9400   prefix arguments {{{kbd(C-u C-u)}}}, show only logging information,
9401   nothing else.  {{{kbd(v L)}}} is equivalent to {{{kbd(C-u v l)}}}.
9403 - {{{kbd(v [)}}} or short {{{kbd([)}}} (~org-agenda-manipulate-query-add~) ::
9405   #+kindex: v [
9406   #+kindex: [
9407   #+findex: org-agenda-manipulate-query-add
9408   Include inactive timestamps into the current view.  Only for
9409   weekly/daily agenda.
9411 - {{{kbd(v a)}}} (~org-agenda-archives-mode~) ::
9413   #+kindex: v a
9414   #+findex: org-agenda-archives-mode
9415   Toggle Archives mode.  In Archives mode, trees that are archived
9416   (see [[*Internal archiving]]) are also scanned when producing the
9417   agenda.  To exit archives mode, press {{{kbd(v a)}}} again.
9419 - {{{kbd(v A)}}} ::
9421   #+kindex: v A
9422   Toggle Archives mode.  Include all archive files as well.
9424 - {{{kbd(v R)}}} or short {{{kbd(R)}}} (~org-agenda-clockreport-mode~) ::
9426   #+kindex: v R
9427   #+kindex: R
9428   #+findex: org-agenda-clockreport-mode
9429   #+vindex: org-agenda-start-with-clockreport-mode
9430   #+vindex: org-clock-report-include-clocking-task
9431   Toggle Clockreport mode.  In Clockreport mode, the daily/weekly
9432   agenda always shows a table with the clocked times for the time span
9433   and file scope covered by the current agenda view.  The initial
9434   setting for this mode in new agenda buffers can be set with the
9435   variable ~org-agenda-start-with-clockreport-mode~.  By using
9436   a prefix argument when toggling this mode (i.e., {{{kbd(C-u R)}}}),
9437   the clock table does not show contributions from entries that are
9438   hidden by agenda filtering[fn:97].  See also the variable
9439   ~org-clock-report-include-clocking-task~.
9441 - {{{kbd(v c)}}} ::
9443   #+kindex: v c
9444   #+vindex: org-agenda-clock-consistency-checks
9445   Show overlapping clock entries, clocking gaps, and other clocking
9446   problems in the current agenda range.  You can then visit clocking
9447   lines and fix them manually.  See the variable
9448   ~org-agenda-clock-consistency-checks~ for information on how to
9449   customize the definition of what constituted a clocking problem.  To
9450   return to normal agenda display, press {{{kbd(l)}}} to exit Logbook
9451   mode.
9453 - {{{kbd(v E)}}} or short {{{kbd(E)}}} (~org-agenda-entry-text-mode~) ::
9455   #+kindex: v E
9456   #+kindex: E
9457   #+findex: org-agenda-entry-text-mode
9458   #+vindex: org-agenda-start-with-entry-text-mode
9459   #+vindex: org-agenda-entry-text-maxlines
9460   Toggle entry text mode.  In entry text mode, a number of lines from
9461   the Org outline node referenced by an agenda line are displayed
9462   below the line.  The maximum number of lines is given by the
9463   variable ~org-agenda-entry-text-maxlines~.  Calling this command
9464   with a numeric prefix argument temporarily modifies that number to
9465   the prefix value.
9467 - {{{kbd(G)}}} (~org-agenda-toggle-time-grid~) ::
9469   #+kindex: G
9470   #+vindex: org-agenda-use-time-grid
9471   #+vindex: org-agenda-time-grid
9472   Toggle the time grid on and off.  See also the variables
9473   ~org-agenda-use-time-grid~ and ~org-agenda-time-grid~.
9475 - {{{kbd(r)}}} (~org-agenda-redo~), {{{kbd(g)}}} ::
9477   #+kindex: r
9478   #+kindex: g
9479   #+findex: org-agenda-redo
9480   Recreate the agenda buffer, for example to reflect the changes after
9481   modification of the timestamps of items with {{{kbd(S-LEFT)}}} and
9482   {{{kbd(S-RIGHT)}}}.  When the buffer is the global TODO list,
9483   a prefix argument is interpreted to create a selective list for
9484   a specific TODO keyword.
9486 - {{{kbd(C-x C-s)}}} or short {{{kbd(s)}}} (~org-save-all-org-buffers~) ::
9488   #+kindex: C-x C-s
9489   #+findex: org-save-all-org-buffers
9490   #+kindex: s
9491   Save all Org buffers in the current Emacs session, and also the
9492   locations of IDs.
9494 - {{{kbd(C-c C-x C-c)}}} (~org-agenda-columns~) ::
9496   #+kindex: C-c C-x C-c
9497   #+findex: org-agenda-columns
9498   #+vindex: org-columns-default-format
9499   Invoke column view (see [[*Column View]]) in the agenda buffer.  The
9500   column view format is taken from the entry at point, or, if there is
9501   no entry at point, from the first entry in the agenda view.  So
9502   whatever the format for that entry would be in the original buffer
9503   (taken from a property, from a =COLUMNS= keyword, or from the
9504   default variable ~org-columns-default-format~) is used in the
9505   agenda.
9507 - {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
9509   #+kindex: C-c C-x >
9510   #+findex: org-agenda-remove-restriction-lock
9511   Remove the restriction lock on the agenda, if it is currently
9512   restricted to a file or subtree (see [[*Agenda Files]]).
9514 - {{{kbd(M-UP)}}} (~org-agenda-drag-line-backward~) ::
9516   #+kindex: M-UP
9517   #+findex: org-agenda-drag-line-backward
9518   Drag the line at point backward one line.  With a numeric prefix
9519   argument, drag backward by that many lines.
9521   Moving agenda lines does not persist after an agenda refresh and
9522   does not modify the contributing Org files.
9524 - {{{kbd(M-DOWN)}}} (~org-agenda-drag-line-forward~) ::
9526   #+kindex: M-DOWN
9527   #+findex: org-agenda-drag-line-forward
9528   Drag the line at point forward one line.  With a numeric prefix
9529   argument, drag forward by that many lines.
9531 *** Remote editing
9532 :PROPERTIES:
9533 :UNNUMBERED: notoc
9534 :END:
9535 #+cindex: remote editing, from agenda
9537 - {{{kbd(0--9)}}} ::
9539   Digit argument.
9541 - {{{kbd(C-_)}}} (~org-agenda-undo~) ::
9543   #+kindex: C-_
9544   #+findex: org-agenda-undo
9545   #+cindex: undoing remote-editing events
9546   #+cindex: remote editing, undo
9547   Undo a change due to a remote editing command.  The change is undone
9548   both in the agenda buffer and in the remote buffer.
9550 - {{{kbd(t)}}} (~org-agenda-todo~) ::
9552   #+kindex: t
9553   #+findex: org-agenda-todo
9554   Change the TODO state of the item, both in the agenda and in the
9555   original Org file.
9557 - {{{kbd(C-S-RIGHT)}}} (~org-agenda-todo-nextset~) ::
9559   #+kindex: C-S-RIGHT
9560   #+findex: org-agenda-todo-nextset
9561   Switch to the next set of TODO keywords.
9563 - {{{kbd(C-S-LEFT)}}}, ~org-agenda-todo-previousset~ ::
9565   #+kindex: C-S-LEFT
9566   Switch to the previous set of TODO keywords.
9568 - {{{kbd(C-k)}}} (~org-agenda-kill~) ::
9570   #+kindex: C-k
9571   #+findex: org-agenda-kill
9572   #+vindex: org-agenda-confirm-kill
9573   Delete the current agenda item along with the entire subtree
9574   belonging to it in the original Org file.  If the text to be deleted
9575   remotely is longer than one line, the kill needs to be confirmed by
9576   the user.  See variable ~org-agenda-confirm-kill~.
9578 - {{{kbd(C-c C-w)}}} (~org-agenda-refile~) ::
9580   #+kindex: C-c C-w
9581   #+findex: org-agenda-refile
9582   Refile the entry at point.
9584 - {{{kbd(C-c C-x C-a)}}} or short {{{kbd(a)}}} (~org-agenda-archive-default-with-confirmation~) ::
9586   #+kindex: C-c C-x C-a
9587   #+kindex: a
9588   #+findex: org-agenda-archive-default-with-confirmation
9589   #+vindex: org-archive-default-command
9590   Archive the subtree corresponding to the entry at point using the
9591   default archiving command set in ~org-archive-default-command~.
9592   When using the {{{kbd(a)}}} key, confirmation is required.
9594 - {{{kbd(C-c C-x a)}}} (~org-agenda-toggle-archive-tag~) ::
9596   #+kindex: C-c C-x a
9597   #+findex: org-agenda-toggle-archive-tag
9598   Toggle the archive tag (see [[*Internal archiving]]) for the current
9599   headline.
9601 - {{{kbd(C-c C-x A)}}} (~org-agenda-archive-to-archive-sibling~) ::
9603   #+kindex: C-c C-x A
9604   #+findex: org-agenda-archive-to-archive-sibling
9605   Move the subtree corresponding to the current entry to its /archive
9606   sibling/.
9608 - {{{kbd(C-c C-x C-s)}}} or short {{{kbd($)}}} (~org-agenda-archive~) ::
9610   #+kindex: C-c C-x C-s
9611   #+kindex: $
9612   #+findex: org-agenda-archive
9613   Archive the subtree corresponding to the current headline.  This
9614   means the entry is moved to the configured archive location, most
9615   likely a different file.
9617 - {{{kbd(T)}}} (~org-agenda-show-tags~) ::
9619   #+kindex: T
9620   #+findex: org-agenda-show-tags
9621   #+vindex: org-agenda-show-inherited-tags
9622   Show all tags associated with the current item.  This is useful if
9623   you have turned off ~org-agenda-show-inherited-tags~, but still want
9624   to see all tags of a headline occasionally.
9626 - {{{kbd(:)}}} (~org-agenda-set-tags~) ::
9628   #+kindex: :
9629   #+findex: org-agenda-set-tags
9630   Set tags for the current headline.  If there is an active region in
9631   the agenda, change a tag for all headings in the region.
9633 - {{{kbd(\,)}}} (~org-agenda-priority~) ::
9635   #+kindex: ,
9636   #+findex: org-agenda-priority
9637   Set the priority for the current item.  Org mode prompts for the
9638   priority character.  If you reply with {{{kbd(SPC)}}}, the priority
9639   cookie is removed from the entry.
9641 - {{{kbd(P)}}} (~org-agenda-show-priority~) ::
9643   #+kindex: P
9644   #+findex: org-agenda-show-priority
9645   Display weighted priority of current item.
9647 - {{{kbd(+)}}} or {{{kbd(S-UP)}}} (~org-agenda-priority-up~) ::
9649   #+kindex: +
9650   #+kindex: S-UP
9651   #+findex: org-agenda-priority-up
9652   Increase the priority of the current item.  The priority is changed
9653   in the original buffer, but the agenda is not resorted.  Use the
9654   {{{kbd(r)}}} key for this.
9656 - {{{kbd(-)}}} or {{{kbd(S-DOWN)}}} (~org-agenda-priority-down~) ::
9658   #+kindex: -
9659   #+kindex: S-DOWN
9660   #+findex: org-agenda-priority-down
9661   Decrease the priority of the current item.
9663 - {{{kbd(C-c C-z)}}} or short {{{kbd(z)}}} (~org-agenda-add-note~) ::
9665   #+kindex: z
9666   #+kindex: C-c C-z
9667   #+findex: org-agenda-add-note
9668   #+vindex: org-log-into-drawer
9669   Add a note to the entry.  This note is recorded, and then filed to
9670   the same location where state change notes are put.  Depending on
9671   ~org-log-into-drawer~, this may be inside a drawer.
9673 - {{{kbd(C-c C-a)}}} (~org-attach~) ::
9675   #+kindex: C-c C-a
9676   #+findex: org-attach
9677   Dispatcher for all command related to attachments.
9679 - {{{kbd(C-c C-s)}}} (~org-agenda-schedule~) ::
9681   #+kindex: C-c C-s
9682   #+findex: org-agenda-schedule
9683   Schedule this item.  With a prefix argument, remove the
9684   scheduling timestamp
9686 - {{{kbd(C-c C-d)}}} (~org-agenda-deadline~) ::
9688   #+kindex: C-c C-d
9689   #+findex: org-agenda-deadline
9690   Set a deadline for this item.  With a prefix argument, remove the
9691   deadline.
9693 - {{{kbd(S-RIGHT)}}} (~org-agenda-do-date-later~) ::
9695   #+kindex: S-RIGHT
9696   #+findex: org-agenda-do-date-later
9697   Change the timestamp associated with the current line by one day
9698   into the future.  If the date is in the past, the first call to this
9699   command moves it to today.  With a numeric prefix argument, change
9700   it by that many days.  For example, {{{kbd(3 6 5 S-RIGHT)}}} changes
9701   it by a year.  With a {{{kbd(C-u)}}} prefix, change the time by one
9702   hour.  If you immediately repeat the command, it will continue to
9703   change hours even without the prefix argument.  With a double
9704   {{{kbd(C-u C-u)}}} prefix, do the same for changing minutes.  The
9705   stamp is changed in the original Org file, but the change is not
9706   directly reflected in the agenda buffer.  Use {{{kbd(r)}}} or
9707   {{{kbd(g)}}} to update the buffer.
9709 - {{{kbd(S-LEFT)}}} (~org-agenda-do-date-earlier~) ::
9711   #+kindex: S-LEFT
9712   #+findex: org-agenda-do-date-earlier
9713   Change the timestamp associated with the current line by one day
9714   into the past.
9716 - {{{kbd(>)}}} (~org-agenda-date-prompt~) ::
9718   #+kindex: >
9719   #+findex: org-agenda-date-prompt
9720   Change the timestamp associated with the current line.  The key
9721   {{{kbd(>)}}} has been chosen, because it is the same as
9722   {{{kbd(S-.)}}}  on my keyboard.
9724 - {{{kbd(I)}}} (~org-agenda-clock-in~) ::
9726   #+kindex: I
9727   #+findex: org-agenda-clock-in
9728   Start the clock on the current item.  If a clock is running already,
9729   it is stopped first.
9731 - {{{kbd(O)}}} (~org-agenda-clock-out~) ::
9733   #+kindex: O
9734   #+findex: org-agenda-clock-out
9735   Stop the previously started clock.
9737 - {{{kbd(X)}}} (~org-agenda-clock-cancel~) ::
9739   #+kindex: X
9740   #+findex: org-agenda-clock-cancel
9741   Cancel the currently running clock.
9743 - {{{kbd(J)}}} (~org-agenda-clock-goto~) ::
9745   #+kindex: J
9746   #+findex: org-agenda-clock-goto
9747   Jump to the running clock in another window.
9749 - {{{kbd(k)}}} (~org-agenda-capture~) ::
9751   #+kindex: k
9752   #+findex: org-agenda-capture
9753   #+cindex: capturing, from agenda
9754   #+vindex: org-capture-use-agenda-date
9755   Like ~org-capture~, but use the date at point as the default date
9756   for the capture template.  See ~org-capture-use-agenda-date~ to make
9757   this the default behavior of ~org-capture~.
9759 *** Bulk remote editing selected entries
9760 :PROPERTIES:
9761 :UNNUMBERED: notoc
9762 :END:
9763 #+cindex: remote editing, bulk, from agenda
9764 #+vindex: org-agenda-bulk-custom-functions
9766 - {{{kbd(m)}}} (~org-agenda-bulk-mark~) ::
9767   #+kindex: m
9768   #+findex: org-agenda-bulk-mark
9770   Mark the entry at point for bulk action.  If there is an active
9771   region in the agenda, mark the entries in the region.  With numeric
9772   prefix argument, mark that many successive entries.
9774 - {{{kbd(*)}}} (~org-agenda-bulk-mark-all~) ::
9775   #+kindex: *
9776   #+findex: org-agenda-bulk-mark-all
9778   Mark all visible agenda entries for bulk action.
9780 - {{{kbd(u)}}} (~org-agenda-bulk-unmark~) ::
9781   #+kindex: u
9782   #+findex: org-agenda-bulk-unmark
9784   Unmark entry for bulk action.
9786 - {{{kbd(U)}}} (~org-agenda-bulk-remove-all-marks~) ::
9787   #+kindex: U
9788   #+findex: org-agenda-bulk-remove-all-marks
9790   Unmark all marked entries for bulk action.
9792 - {{{kbd(M-m)}}} (~org-agenda-bulk-toggle~) ::
9793   #+kindex: M-m
9794   #+findex: org-agenda-bulk-toggle
9796   Toggle mark of the entry at point for bulk action.
9798 - {{{kbd(M-*)}}} (~org-agenda-bulk-toggle-all~) ::
9799   #+kindex: M-*
9800   #+findex: org-agenda-bulk-toggle-all
9802   Toggle mark of every entry for bulk action.
9804 - {{{kbd(%)}}} (~org-agenda-bulk-mark-regexp~) ::
9805   #+kindex: %
9806   #+findex: org-agenda-bulk-mark-regexp
9808   Mark entries matching a regular expression for bulk action.
9810 - {{{kbd(B)}}} (~org-agenda-bulk-action~) ::
9811   #+kindex: B
9812   #+findex: org-agenda-bulk-action
9813   #+vindex: org-agenda-bulk-persistent-marks
9815   Bulk action: act on all marked entries in the agenda.  This prompts
9816   for another key to select the action to be applied.  The prefix
9817   argument to {{{kbd(B)}}} is passed through to the {{{kbd(s)}}} and
9818   {{{kbd(d)}}} commands, to bulk-remove these special timestamps.  By
9819   default, marks are removed after the bulk.  If you want them to
9820   persist, set ~org-agenda-bulk-persistent-marks~ to ~t~ or hit
9821   {{{kbd(p)}}} at the prompt.
9823   - {{{kbd(*)}}} ::
9825     Toggle persistent marks.
9827   - {{{kbd($)}}} ::
9829     Archive all selected entries.
9831   - {{{kbd(A)}}} ::
9833     Archive entries by moving them to their respective archive
9834     siblings.
9836   - {{{kbd(t)}}} ::
9838     Change TODO state.  This prompts for a single TODO keyword and
9839     changes the state of all selected entries, bypassing blocking and
9840     suppressing logging notes---but not timestamps.
9842   - {{{kbd(+)}}} ::
9844     Add a tag to all selected entries.
9846   - {{{kbd(-)}}} ::
9848     Remove a tag from all selected entries.
9850   - {{{kbd(s)}}} ::
9852     Schedule all items to a new date.  To shift existing schedule
9853     dates by a fixed number of days, use something starting with
9854     double plus at the prompt, for example =++8d= or =++2w=.
9856   - {{{kbd(d)}}} ::
9858     Set deadline to a specific date.
9860   - {{{kbd(r)}}} ::
9862     Prompt for a single refile target and move all entries.  The
9863     entries are no longer in the agenda; refresh ({{{kbd(g)}}}) to
9864     bring them back.
9866   - {{{kbd(S)}}} ::
9868     Reschedule randomly into the coming N days.  N is prompted for.
9869     With a prefix argument ({{{kbd(C-u B S)}}}), scatter only across
9870     weekdays.
9872   - {{{kbd(f)}}} ::
9874     #+vindex: org-agenda-bulk-custom-functions
9875     Apply a function[fn:98] to marked entries.  For example, the
9876     function below sets the =CATEGORY= property of the entries to
9877     =web=.
9879     #+begin_src emacs-lisp
9880     (defun set-category ()
9881       (interactive "P")
9882       (let ((marker (or (org-get-at-bol 'org-hd-marker)
9883                         (org-agenda-error))))
9884         (org-with-point-at marker
9885           (org-back-to-heading t)
9886           (org-set-property "CATEGORY" "web"))))
9887     #+end_src
9889 *** Calendar commands
9890 :PROPERTIES:
9891 :UNNUMBERED: notoc
9892 :END:
9893 #+cindex: calendar commands, from agenda
9895 - {{{kbd(c)}}} (~org-agenda-goto-calendar~) ::
9897   #+kindex: c
9898   #+findex: org-agenda-goto-calendar
9899   Open the Emacs calendar and go to the date at point in the agenda.
9901 - {{{kbd(c)}}} (~org-calendar-goto-agenda~) ::
9903   #+kindex: c
9904   #+findex: org-calendar-goto-agenda
9905   When in the calendar, compute and show the Org agenda for the date
9906   at point.
9908 - {{{kbd(i)}}} (~org-agenda-diary-entry~) ::
9909   #+kindex: i
9910   #+findex: org-agenda-diary-entry
9912   #+cindex: diary entries, creating from agenda
9913   Insert a new entry into the diary, using the date at point and (for
9914   block entries) the date at the mark.  This adds to the Emacs diary
9915   file[fn:99], in a way similar to the {{{kbd(i)}}} command in the
9916   calendar.  The diary file pops up in another window, where you can
9917   add the entry.
9919   #+vindex: org-agenda-diary-file
9920   If you configure ~org-agenda-diary-file~ to point to an Org file,
9921   Org creates entries in that file instead.  Most entries are stored
9922   in a date-based outline tree that will later make it easy to archive
9923   appointments from previous months/years.  The tree is built under an
9924   entry with a =DATE_TREE= property, or else with years as top-level
9925   entries.  Emacs prompts you for the entry text---if you specify it,
9926   the entry is created in ~org-agenda-diary-file~ without further
9927   interaction.  If you directly press {{{kbd(RET)}}} at the prompt
9928   without typing text, the target file is shown in another window for
9929   you to finish the entry there.  See also the {{{kbd(k r)}}} command.
9931 - {{{kbd(M)}}} (~org-agenda-phases-of-moon~) ::
9933   #+kindex: M
9934   #+findex: org-agenda-phases-of-moon
9935   Show the phases of the moon for the three months around current
9936   date.
9938 - {{{kbd(S)}}} (~org-agenda-sunrise-sunset~) ::
9940   #+kindex: S
9941   #+findex: org-agenda-sunrise-sunset
9942   Show sunrise and sunset times.  The geographical location must be
9943   set with calendar variables, see the documentation for the Emacs
9944   calendar.
9946 - {{{kbd(C)}}} (~org-agenda-convert-date~) ::
9948   #+kindex: C
9949   #+findex: org-agenda-convert-date
9950   Convert the date at point into many other cultural and historic
9951   calendars.
9953 - {{{kbd(H)}}} (~org-agenda-holidays~) ::
9955   #+kindex: H
9956   #+findex: org-agenda-holidays
9957   Show holidays for three months around point date.
9959 *** Quit and exit
9960 :PROPERTIES:
9961 :UNNUMBERED: notoc
9962 :END:
9964 - {{{kbd(q)}}} (~org-agenda-quit~) ::
9965   #+kindex: q
9966   #+findex: org-agenda-quit
9968   Quit agenda, remove the agenda buffer.
9970 - {{{kbd(x)}}} (~org-agenda-exit~) ::
9971   #+kindex: x
9972   #+findex: org-agenda-exit
9974   #+cindex: agenda files, removing buffers
9975   Exit agenda, remove the agenda buffer and all buffers loaded by
9976   Emacs for the compilation of the agenda.  Buffers created by the
9977   user to visit Org files are not removed.
9979 ** Custom Agenda Views
9980 :PROPERTIES:
9981 :DESCRIPTION: Defining special searches and views.
9982 :END:
9983 #+cindex: custom agenda views
9984 #+cindex: agenda views, custom
9986 Custom agenda commands serve two purposes: to store and quickly access
9987 frequently used TODO and tags searches, and to create special
9988 composite agenda buffers.  Custom agenda commands are accessible
9989 through the dispatcher (see [[*The Agenda Dispatcher]]), just like the
9990 default commands.
9992 *** Storing searches
9993 :PROPERTIES:
9994 :DESCRIPTION: Type once, use often.
9995 :END:
9997 The first application of custom searches is the definition of keyboard
9998 shortcuts for frequently used searches, either creating an agenda
9999 buffer, or a sparse tree (the latter covering of course only the
10000 current buffer).
10002 #+kindex: C @r{(Agenda dispatcher)}
10003 #+vindex: org-agenda-custom-commands
10004 #+cindex: agenda views, main example
10005 #+cindex: agenda, as an agenda views
10006 #+cindex: agenda*, as an agenda views
10007 #+cindex: tags, as an agenda view
10008 #+cindex: todo, as an agenda view
10009 #+cindex: tags-todo
10010 #+cindex: todo-tree
10011 #+cindex: occur-tree
10012 #+cindex: tags-tree
10013 Custom commands are configured in the variable
10014 ~org-agenda-custom-commands~.  You can customize this variable, for
10015 example by pressing {{{kbd(C)}}} from the agenda dispatcher (see [[*The
10016 Agenda Dispatcher]]).  You can also directly set it with Emacs Lisp in
10017 the Emacs init file.  The following example contains all valid agenda
10018 views:
10020 #+begin_src emacs-lisp
10021 (setq org-agenda-custom-commands
10022       '(("x" agenda)
10023         ("y" agenda*)
10024         ("w" todo "WAITING")
10025         ("W" todo-tree "WAITING")
10026         ("u" tags "+boss-urgent")
10027         ("v" tags-todo "+boss-urgent")
10028         ("U" tags-tree "+boss-urgent")
10029         ("f" occur-tree "\\<FIXME\\>")
10030         ("h" . "HOME+Name tags searches") ;description for "h" prefix
10031         ("hl" tags "+home+Lisa")
10032         ("hp" tags "+home+Peter")
10033         ("hk" tags "+home+Kim")))
10034 #+end_src
10036 The initial string in each entry defines the keys you have to press
10037 after the dispatcher command in order to access the command.  Usually
10038 this is just a single character, but if you have many similar
10039 commands, you can also define two-letter combinations where the first
10040 character is the same in several combinations and serves as a prefix
10041 key[fn:100].  The second parameter is the search type, followed by the
10042 string or regular expression to be used for the matching.  The example
10043 above will therefore define:
10045 - {{{kbd(x)}}} ::
10047   as a global search for agenda entries planned[fn:101] this week/day.
10049 - {{{kbd(y)}}} ::
10051   as the same search, but only for entries with an hour specification
10052   like =[h]h:mm=---think of them as appointments.
10054 - {{{kbd(w)}}} ::
10056   as a global search for TODO entries with =WAITING= as the TODO
10057   keyword.
10059 - {{{kbd(W)}}} ::
10061   as the same search, but only in the current buffer and displaying
10062   the results as a sparse tree.
10064 - {{{kbd(u)}}} ::
10066   as a global tags search for headlines tagged =boss= but not
10067   =urgent=.
10069 - {{{kbd(v)}}} ::
10071   The same search, but limiting it to headlines that are also TODO
10072   items.
10074 - {{{kbd(U)}}} ::
10076   as the same search, but only in the current buffer and displaying
10077   the result as a sparse tree.
10079 - {{{kbd(f)}}} ::
10081   to create a sparse tree (again, current buffer only) with all
10082   entries containing the word =FIXME=.
10084 - {{{kbd(h)}}} ::
10086   as a prefix command for a =HOME= tags search where you have to press
10087   an additional key ({{{kbd(l)}}}, {{{kbd(p)}}} or {{{kbd(k)}}}) to
10088   select a name (Lisa, Peter, or Kim) as additional tag to match.
10090 Note that ~*-tree~ agenda views need to be called from an Org buffer
10091 as they operate on the current buffer only.
10093 *** Block agenda
10094 :PROPERTIES:
10095 :DESCRIPTION: All the stuff you need in a single buffer.
10096 :END:
10097 #+cindex: block agenda
10098 #+cindex: agenda, with block views
10100 Another possibility is the construction of agenda views that comprise
10101 the results of /several/ commands, each of which creates a block in
10102 the agenda buffer.  The available commands include ~agenda~ for the
10103 daily or weekly agenda (as created with {{{kbd(a)}}}) , ~alltodo~ for
10104 the global TODO list (as constructed with {{{kbd(t)}}}), and the
10105 matching commands discussed above: ~todo~, ~tags~, and ~tags-todo~.
10106 Here are two examples:
10108 #+begin_src emacs-lisp
10109 (setq org-agenda-custom-commands
10110       '(("h" "Agenda and Home-related tasks"
10111          ((agenda "")
10112           (tags-todo "home")
10113           (tags "garden")))
10114         ("o" "Agenda and Office-related tasks"
10115          ((agenda "")
10116           (tags-todo "work")
10117           (tags "office")))))
10118 #+end_src
10120 #+texinfo: @noindent
10121 This defines {{{kbd(h)}}} to create a multi-block view for stuff you
10122 need to attend to at home.  The resulting agenda buffer contains your
10123 agenda for the current week, all TODO items that carry the tag =home=,
10124 and also all lines tagged with =garden=.  Finally the command
10125 {{{kbd(o)}}} provides a similar view for office tasks.
10127 *** Setting options for custom commands
10128 :PROPERTIES:
10129 :DESCRIPTION: Changing the rules.
10130 :ALT_TITLE: Setting options
10131 :END:
10132 #+cindex: options, for custom agenda views
10134 #+vindex: org-agenda-custom-commands
10135 Org mode contains a number of variables regulating agenda construction
10136 and display.  The global variables define the behavior for all agenda
10137 commands, including the custom commands.  However, if you want to
10138 change some settings just for a single custom view, you can do so.
10139 Setting options requires inserting a list of variable names and values
10140 at the right spot in ~org-agenda-custom-commands~.  For example:
10142 #+begin_src emacs-lisp
10143 (setq org-agenda-custom-commands
10144       '(("w" todo "WAITING"
10145          ((org-agenda-sorting-strategy '(priority-down))
10146           (org-agenda-prefix-format "  Mixed: ")))
10147         ("U" tags-tree "+boss-urgent"
10148          ((org-show-context-detail 'minimal)))
10149         ("N" search ""
10150          ((org-agenda-files '("~org/notes.org"))
10151           (org-agenda-text-search-extra-files nil)))))
10152 #+end_src
10154 #+texinfo: @noindent
10155 Now the {{{kbd(w)}}} command sorts the collected entries only by
10156 priority, and the prefix format is modified to just say =Mixed:=
10157 instead of giving the category of the entry.  The sparse tags tree of
10158 {{{kbd(U)}}} now turns out ultra-compact, because neither the headline
10159 hierarchy above the match, nor the headline following the match are
10160 shown.  The command {{{kbd(N)}}} does a text search limited to only
10161 a single file.
10163 For command sets creating a block agenda, ~org-agenda-custom-commands~
10164 has two separate spots for setting options.  You can add options that
10165 should be valid for just a single command in the set, and options that
10166 should be valid for all commands in the set.  The former are just
10167 added to the command entry; the latter must come after the list of
10168 command entries.  Going back to the block agenda example (see [[*Block
10169 agenda]]), let's change the sorting strategy for the {{{kbd(h)}}}
10170 commands to ~priority-down~, but let's sort the results for =garden=
10171 tags query in the opposite order, ~priority-up~.  This would look like
10172 this:
10174 #+begin_src emacs-lisp
10175 (setq org-agenda-custom-commands
10176       '(("h" "Agenda and Home-related tasks"
10177          ((agenda)
10178           (tags-todo "home")
10179           (tags "garden"
10180                 ((org-agenda-sorting-strategy '(priority-up)))))
10181          ((org-agenda-sorting-strategy '(priority-down))))
10182         ("o" "Agenda and Office-related tasks"
10183          ((agenda)
10184           (tags-todo "work")
10185           (tags "office")))))
10186 #+end_src
10188 As you see, the values and parentheses setting is a little complex.
10189 When in doubt, use the customize interface to set this variable---it
10190 fully supports its structure.  Just one caveat: when setting options
10191 in this interface, the /values/ are just Lisp expressions.  So if the
10192 value is a string, you need to add the double-quotes around the value
10193 yourself.
10195 #+vindex: org-agenda-custom-commands-contexts
10196 To control whether an agenda command should be accessible from
10197 a specific context, you can customize
10198 ~org-agenda-custom-commands-contexts~.  Let's say for example that you
10199 have an agenda command {{{kbd(o)}}} displaying a view that you only
10200 need when reading emails.  Then you would configure this option like
10201 this:
10203 #+begin_src emacs-lisp
10204 (setq org-agenda-custom-commands-contexts
10205       '(("o" (in-mode . "message-mode"))))
10206 #+end_src
10208 You can also tell that the command key {{{kbd(o)}}} should refer to
10209 another command key {{{kbd(r)}}}.  In that case, add this command key
10210 like this:
10212 #+begin_src emacs-lisp
10213 (setq org-agenda-custom-commands-contexts
10214       '(("o" "r" (in-mode . "message-mode"))))
10215 #+end_src
10217 See the docstring of the variable for more information.
10219 ** Exporting Agenda Views
10220 :PROPERTIES:
10221 :DESCRIPTION: Writing a view to a file.
10222 :END:
10223 #+cindex: agenda views, exporting
10225 If you are away from your computer, it can be very useful to have
10226 a printed version of some agenda views to carry around.  Org mode can
10227 export custom agenda views as plain text, HTML[fn:102], Postscript,
10228 PDF[fn:103], and iCalendar files.  If you want to do this only
10229 occasionally, use the following command:
10231 - {{{kbd(C-x C-w)}}} (~org-agenda-write~) ::
10232   #+kindex: C-x C-w
10233   #+findex: org-agenda-write
10234   #+cindex: exporting agenda views
10235   #+cindex: agenda views, exporting
10237   #+vindex: org-agenda-exporter-settings
10238   Write the agenda view to a file.
10240 If you need to export certain agenda views frequently, you can
10241 associate any custom agenda command with a list of output file
10242 names[fn:104].  Here is an example that first defines custom commands
10243 for the agenda and the global TODO list, together with a number of
10244 files to which to export them.  Then we define two block agenda
10245 commands and specify file names for them as well.  File names can be
10246 relative to the current working directory, or absolute.
10248 #+begin_src emacs-lisp
10249 (setq org-agenda-custom-commands
10250       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
10251         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
10252         ("h" "Agenda and Home-related tasks"
10253          ((agenda "")
10254           (tags-todo "home")
10255           (tags "garden"))
10256          nil
10257          ("~/views/home.html"))
10258         ("o" "Agenda and Office-related tasks"
10259          ((agenda)
10260           (tags-todo "work")
10261           (tags "office"))
10262          nil
10263          ("~/views/office.ps" "~/calendars/office.ics"))))
10264 #+end_src
10266 The extension of the file name determines the type of export.  If it
10267 is =.html=, Org mode uses the htmlize package to convert the buffer to
10268 HTML and save it to this file name.  If the extension is =.ps=,
10269 ~ps-print-buffer-with-faces~ is used to produce Postscript output.  If
10270 the extension is =.ics=, iCalendar export is run export over all files
10271 that were used to construct the agenda, and limit the export to
10272 entries listed in the agenda.  Any other extension produces a plain
10273 ASCII file.
10275 The export files are /not/ created when you use one of those
10276 commands interactively because this might use too much overhead.
10277 Instead, there is a special command to produce /all/ specified
10278 files in one step:
10280 - {{{kbd(e)}}} (~org-store-agenda-views~) ::
10282   #+kindex: e @r{(Agenda dispatcher)}
10283   #+findex: org-store-agenda-views
10284   Export all agenda views that have export file names associated with
10285   them.
10287 You can use the options section of the custom agenda commands to also
10288 set options for the export commands.  For example:
10290 #+begin_src emacs-lisp
10291 (setq org-agenda-custom-commands
10292       '(("X" agenda ""
10293          ((ps-number-of-columns 2)
10294           (ps-landscape-mode t)
10295           (org-agenda-prefix-format " [ ] ")
10296           (org-agenda-with-colors nil)
10297           (org-agenda-remove-tags t))
10298          ("theagenda.ps"))))
10299 #+end_src
10301 #+texinfo: @noindent
10302 #+vindex: org-agenda-exporter-settings
10303 This command sets two options for the Postscript exporter, to make it
10304 print in two columns in landscape format---the resulting page can be
10305 cut in two and then used in a paper agenda.  The remaining settings
10306 modify the agenda prefix to omit category and scheduling information,
10307 and instead include a checkbox to check off items.  We also remove the
10308 tags to make the lines compact, and we do not want to use colors for
10309 the black-and-white printer.  Settings specified in
10310 ~org-agenda-exporter-settings~ also apply, e.g.,
10312 #+begin_src emacs-lisp
10313 (setq org-agenda-exporter-settings
10314       '((ps-number-of-columns 2)
10315         (ps-landscape-mode t)
10316         (org-agenda-add-entry-text-maxlines 5)
10317         (htmlize-output-type 'css)))
10318 #+end_src
10320 #+texinfo: @noindent
10321 but the settings in ~org-agenda-custom-commands~ take precedence.
10323 From the command line you may also use:
10325 #+begin_src shell
10326 emacs -eval (org-batch-store-agenda-views) -kill
10327 #+end_src
10329 #+texinfo: @noindent
10330 or, if you need to modify some parameters[fn:105]
10332 #+begin_src shell
10333 emacs -eval '(org-batch-store-agenda-views                      \
10334               org-agenda-span (quote month)                     \
10335               org-agenda-start-day "2007-11-01"                 \
10336               org-agenda-include-diary nil                      \
10337               org-agenda-files (quote ("~/org/project.org")))'  \
10338       -kill
10339 #+end_src
10341 #+texinfo: @noindent
10342 which creates the agenda views restricted to the file
10343 =~/org/project.org=, without diary entries and with a 30-day extent.
10345 You can also extract agenda information in a way that allows further
10346 processing by other programs.  See [[*Extracting Agenda Information]], for
10347 more information.
10349 ** Using Column View in the Agenda
10350 :PROPERTIES:
10351 :DESCRIPTION: Using column view for collected entries.
10352 :ALT_TITLE: Agenda Column View
10353 :END:
10354 #+cindex: column view, in agenda
10355 #+cindex: agenda, column view
10357 Column view (see [[*Column View]]) is normally used to view and edit
10358 properties embedded in the hierarchical structure of an Org file.  It
10359 can be quite useful to use column view also from the agenda, where
10360 entries are collected by certain criteria.
10362 - {{{kbd(C-c C-x C-c)}}} (~org-agenda-columns~) ::
10363   #+kindex: C-c C-x C-c
10364   #+findex: org-agenda-columns
10366   Turn on column view in the agenda.
10368 To understand how to use this properly, it is important to realize
10369 that the entries in the agenda are no longer in their proper outline
10370 environment.  This causes the following issues:
10373    #+vindex: org-columns-default-format
10374    #+vindex: org-overriding-columns-format
10375    Org needs to make a decision which columns format to use.  Since
10376    the entries in the agenda are collected from different files, and
10377    different files may have different columns formats, this is
10378    a non-trivial problem.  Org first checks if the variable
10379    ~org-overriding-columns-format~ is currently set, and if so, takes
10380    the format from there.  Otherwise it takes the format associated
10381    with the first item in the agenda, or, if that item does not have
10382    a specific format (defined in a property, or in its file), it uses
10383    ~org-columns-default-format~.
10386    #+cindex: @samp{CLOCKSUM}, special property
10387    If any of the columns has a summary type defined (see [[*Column
10388    attributes]]), turning on column view in the agenda visits all
10389    relevant agenda files and make sure that the computations of this
10390    property are up to date.  This is also true for the special
10391    =CLOCKSUM= property.  Org then sums the values displayed in the
10392    agenda.  In the daily/weekly agenda, the sums cover a single day;
10393    in all other views they cover the entire block.
10395    It is important to realize that the agenda may show the same entry
10396    /twice/---for example as scheduled and as a deadline---and it may
10397    show two entries from the same hierarchy (for example a /parent/
10398    and its /child/).  In these cases, the summation in the agenda
10399    leads to incorrect results because some values count double.
10401 3. When the column view in the agenda shows the =CLOCKSUM= property,
10402    that is always the entire clocked time for this item.  So even in
10403    the daily/weekly agenda, the clocksum listed in column view may
10404    originate from times outside the current view.  This has the
10405    advantage that you can compare these values with a column listing
10406    the planned total effort for a task---one of the major
10407    applications for column view in the agenda.  If you want
10408    information about clocked time in the displayed period use clock
10409    table mode (press {{{kbd(R)}}} in the agenda).
10412    #+cindex: @samp{CLOCKSUM_T}, special property
10413    When the column view in the agenda shows the =CLOCKSUM_T= property,
10414    that is always today's clocked time for this item.  So even in the
10415    weekly agenda, the clocksum listed in column view only originates
10416    from today.  This lets you compare the time you spent on a task for
10417    today, with the time already spent---via =CLOCKSUM=---and with
10418    the planned total effort for it.
10420 * Markup for Rich Contents
10421 :PROPERTIES:
10422 :DESCRIPTION: Compose beautiful documents.
10423 :END:
10425 Org is primarily about organizing and searching through your
10426 plain-text notes.  However, it also provides a lightweight yet robust
10427 markup language for rich text formatting and more.  For instance, you
10428 may want to center or emphasize text.  Or you may need to insert
10429 a formula or image in your writing.  Org offers syntax for all of this
10430 and more.  Used in conjunction with the export framework (see
10431 [[*Exporting]]), you can author beautiful documents in Org---like the fine
10432 manual you are currently reading.
10434 ** Paragraphs
10435 :PROPERTIES:
10436 :DESCRIPTION: The basic unit of text.
10437 :END:
10439 #+cindex: paragraphs, markup rules
10440 Paragraphs are separated by at least one empty line.  If you need to
10441 enforce a line break within a paragraph, use =\\= at the end of
10442 a line.
10444 #+cindex: line breaks, markup rules
10445 To preserve the line breaks, indentation and blank lines in a region,
10446 but otherwise use normal formatting, you can use this construct, which
10447 can also be used to format poetry.
10449 #+cindex: @samp{BEGIN_VERSE}
10450 #+cindex: verse blocks
10451 #+begin_example
10452 ,#+BEGIN_VERSE
10453  Great clouds overhead
10454  Tiny black birds rise and fall
10455  Snow covers Emacs
10457     ---AlexSchroeder
10458 ,#+END_VERSE
10459 #+end_example
10461 When quoting a passage from another document, it is customary to
10462 format this as a paragraph that is indented on both the left and the
10463 right margin.  You can include quotations in Org documents like this:
10465 #+cindex: @samp{BEGIN_QUOTE}
10466 #+cindex: quote blocks
10467 #+begin_example
10468 ,#+BEGIN_QUOTE
10469 Everything should be made as simple as possible,
10470 but not any simpler ---Albert Einstein
10471 ,#+END_QUOTE
10472 #+end_example
10474 If you would like to center some text, do it like this:
10476 #+cindex: @samp{BEGIN_CENTER}
10477 #+cindex: center blocks
10478 #+begin_example
10479 ,#+BEGIN_CENTER
10480 Everything should be made as simple as possible, \\
10481 but not any simpler
10482 ,#+END_CENTER
10483 #+end_example
10485 ** Emphasis and Monospace
10486 :PROPERTIES:
10487 :DESCRIPTION: Bold, italic, etc.
10488 :END:
10489 #+cindex: underlined text, markup rules
10490 #+cindex: bold text, markup rules
10491 #+cindex: italic text, markup rules
10492 #+cindex: verbatim text, markup rules
10493 #+cindex: code text, markup rules
10494 #+cindex: strike-through text, markup rules
10496 You can make words =*bold*=, =/italic/=, =_underlined_=, ==verbatim==
10497 and =~code~=, and, if you must, =+strike-through+=.  Text in the code
10498 and verbatim string is not processed for Org specific syntax; it is
10499 exported verbatim.
10501 #+vindex: org-fontify-emphasized-text
10502 To turn off fontification for marked up text, you can set
10503 ~org-fontify-emphasized-text~ to ~nil~.  To narrow down the list of
10504 available markup syntax, you can customize ~org-emphasis-alist~.
10506 ** Subscripts and Superscripts
10507 :PROPERTIES:
10508 :DESCRIPTION: Simple syntax for raising/lowering text.
10509 :END:
10510 #+cindex: subscript
10511 #+cindex: superscript
10513 =^= and =_= are used to indicate super- and subscripts.  To increase
10514 the readability of ASCII text, it is not necessary, but OK, to
10515 surround multi-character sub- and superscripts with curly braces.  For
10516 example
10518 #+begin_example
10519 The radius of the sun is R_sun = 6.96 x 10^8 m.  On the other hand,
10520 the radius of Alpha Centauri is R_{Alpha Centauri} = 1.28 x R_{sun}.
10521 #+end_example
10523 #+vindex: org-use-sub-superscripts
10524 If you write a text where the underscore is often used in a different
10525 context, Org's convention to always interpret these as subscripts can
10526 get in your way.  Configure the variable ~org-use-sub-superscripts~ to
10527 change this convention.  For example, when setting this variable to
10528 ~{}~, =a_b= is not interpreted as a subscript, but =a_{b}= is.
10530 - {{{kbd(C-c C-x \)}}} (~org-toggle-pretty-entities~) ::
10532   #+kindex: C-c C-x \
10533   #+findex: org-toggle-pretty-entities
10534   This command formats sub- and superscripts in a WYSIWYM way.
10536 ** Special Symbols
10537 :PROPERTIES:
10538 :DESCRIPTION: Greek letters and other symbols.
10539 :END:
10540 #+cindex: math symbols
10541 #+cindex: special symbols
10542 #+cindex: entities
10544 You can use LaTeX-like syntax to insert special symbols---named
10545 entities---like =\alpha= to indicate the Greek letter, or =\to= to indicate
10546 an arrow.  Completion for these symbols is available, just type =\=
10547 and maybe a few letters, and press {{{kbd(M-TAB)}}} to see possible
10548 completions.  If you need such a symbol inside a word, terminate it
10549 with a pair of curly brackets.  For example
10551 #+begin_example
10552 Pro tip: Given a circle \Gamma of diameter d, the length of its
10553 circumference is \pi{}d.
10554 #+end_example
10556 #+findex: org-entities-help
10557 #+vindex: org-entities-user
10558 A large number of entities is provided, with names taken from both
10559 HTML and LaTeX; you can comfortably browse the complete list from
10560 a dedicated buffer using the command ~org-entities-help~.  It is also
10561 possible to provide your own special symbols in the variable
10562 ~org-entities-user~.
10564 During export, these symbols are transformed into the native format of
10565 the exporter back-end.  Strings like =\alpha= are exported as =&alpha;= in
10566 the HTML output, and as =\(\alpha\)= in the LaTeX output.  Similarly, =\nbsp=
10567 becomes =&nbsp;= in HTML and =~= in LaTeX.
10569 #+cindex: special symbols, in-buffer display
10570 If you would like to see entities displayed as UTF-8 characters, use
10571 the following command[fn:106]:
10573 - {{{kbd(C-c C-x \)}}} (~org-toggle-pretty-entities~) ::
10574   #+kindex: C-c C-x \
10575   #+findex: org-toggle-pretty-entities
10577   Toggle display of entities as UTF-8 characters.  This does not
10578   change the buffer content which remains plain ASCII, but it overlays
10579   the UTF-8 character for display purposes only.
10581 #+cindex: shy hyphen, special symbol
10582 #+cindex: dash, special symbol
10583 #+cindex: ellipsis, special symbol
10584 In addition to regular entities defined above, Org exports in
10585 a special way[fn:107] the following commonly used character
10586 combinations: =\-= is treated as a shy hyphen, =--= and =---= are
10587 converted into dashes, and =...= becomes a compact set of dots.
10589 ** Embedded LaTeX
10590 :PROPERTIES:
10591 :DESCRIPTION: LaTeX can be freely used inside Org documents.
10592 :END:
10593 #+cindex: @TeX{} interpretation
10594 #+cindex: @LaTeX{} interpretation
10596 Plain ASCII is normally sufficient for almost all note taking.
10597 Exceptions include scientific notes, which often require mathematical
10598 symbols and the occasional formula.  LaTeX[fn:108] is widely used to
10599 typeset scientific documents.  Org mode supports embedding LaTeX code
10600 into its files, because many academics are used to writing and reading
10601 LaTeX source code, and because it can be readily processed to produce
10602 pretty output for a number of export back-ends.
10604 *** LaTeX fragments
10605 :PROPERTIES:
10606 :DESCRIPTION: Complex formulas made easy.
10607 :END:
10608 #+cindex: @LaTeX{} fragments
10610 #+vindex: org-format-latex-header
10611 Org mode can contain LaTeX math fragments, and it supports ways to
10612 process these for several export back-ends.  When exporting to LaTeX,
10613 the code is left as it is.  When exporting to HTML, Org can use either
10614 [[http://www.mathjax.org][MathJax]] (see [[*Math formatting in HTML export]]) or transcode the math
10615 into images (see [[*Previewing LaTeX fragments]]).
10617 LaTeX fragments do not need any special marking at all.  The following
10618 snippets are identified as LaTeX source code:
10620 - Environments of any kind[fn:109].  The only requirement is that the
10621   =\begin= statement appears on a new line, preceded by only
10622   whitespace.
10624 - Text within the usual LaTeX math delimiters.  To avoid conflicts
10625   with currency specifications, single =$= characters are only
10626   recognized as math delimiters if the enclosed text contains at most
10627   two line breaks, is directly attached to the =$= characters with no
10628   whitespace in between, and if the closing =$= is followed by
10629   whitespace, punctuation or a dash.  For the other delimiters, there
10630   is no such restriction, so when in doubt, use =\(...\)= as inline
10631   math delimiters.
10633 #+texinfo: @noindent
10634 For example:
10636 #+begin_example
10637 \begin{equation}                        % arbitrary environments,
10638 x=\sqrt{b}                              % even tables, figures
10639 \end{equation}                          % etc
10641 If $a^2=b$ and \( b=2 \), then the solution must be
10642 either $$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \].
10643 #+end_example
10645 #+vindex: org-export-with-latex
10646 LaTeX processing can be configured with the variable
10647 ~org-export-with-latex~.  The default setting is ~t~ which means
10648 MathJax for HTML, and no processing for ASCII and LaTeX back-ends.
10649 You can also set this variable on a per-file basis using one of these
10650 lines:
10652 | =#+OPTIONS: tex:t=        | Do the right thing automatically (MathJax) |
10653 | =#+OPTIONS: tex:nil=      | Do not process LaTeX fragments at all      |
10654 | =#+OPTIONS: tex:verbatim= | Verbatim export, for jsMath or so          |
10656 *** Previewing LaTeX fragments
10657 :PROPERTIES:
10658 :DESCRIPTION: What will this snippet look like?
10659 :END:
10660 #+cindex: @LaTeX{} fragments, preview
10662 #+vindex: org-preview-latex-default-process
10663 If you have a working LaTeX installation and =dvipng=, =dvisvgm= or
10664 =convert= installed[fn:110], LaTeX fragments can be processed to
10665 produce images of the typeset expressions to be used for inclusion
10666 while exporting to HTML (see [[*LaTeX fragments]]), or for inline
10667 previewing within Org mode.
10669 #+vindex: org-format-latex-options
10670 #+vindex: org-format-latex-header
10671 You can customize the variables ~org-format-latex-options~ and
10672 ~org-format-latex-header~ to influence some aspects of the preview.
10673 In particular, the ~:scale~ (and for HTML export, ~:html-scale~)
10674 property of the former can be used to adjust the size of the preview
10675 images.
10677 - {{{kbd(C-c C-x C-l)}}} (~org-latex-preview~) ::
10678   #+kindex: C-c C-x C-l
10679   #+findex: org-latex-preview
10681   Produce a preview image of the LaTeX fragment at point and overlay
10682   it over the source code.  If there is no fragment at point, process
10683   all fragments in the current entry---between two headlines.
10685   When called with a single prefix argument, clear all images in the
10686   current entry.  Two prefix arguments produce a preview image for all
10687   fragments in the buffer, while three of them clear all the images in
10688   that buffer.
10690 #+vindex: org-startup-with-latex-preview
10691 You can turn on the previewing of all LaTeX fragments in a file with
10693 : #+STARTUP: latexpreview
10695 To disable it, simply use
10697 : #+STARTUP: nolatexpreview
10699 *** Using CDLaTeX to enter math
10700 :PROPERTIES:
10701 :DESCRIPTION: Speed up entering of formulas.
10702 :ALT_TITLE: CDLaTeX mode
10703 :END:
10704 #+cindex: CD@LaTeX{}
10706 CDLaTeX mode is a minor mode that is normally used in combination with
10707 a major LaTeX mode like AUCTeX in order to speed-up insertion of
10708 environments and math templates.  Inside Org mode, you can make use of
10709 some of the features of CDLaTeX mode.  You need to install
10710 =cdlatex.el= and =texmathp.el= (the latter comes also with AUCTeX)
10711 from [[http://www.astro.uva.nl/~dominik/Tools/cdlatex]].  Do not use
10712 CDLaTeX mode itself under Org mode, but use the light version
10713 ~org-cdlatex-mode~ that comes as part of Org mode.  Turn it on for the
10714 current buffer with {{{kbd(M-x org-cdlatex-mode)}}}, or for all Org
10715 files with
10717 #+begin_src emacs-lisp
10718 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
10719 #+end_src
10721 When this mode is enabled, the following features are present (for
10722 more details see the documentation of CDLaTeX mode):
10724 #+attr_texinfo: :sep ,
10725 - {{{kbd(C-c {)}}} ::
10726   #+kindex: C-c @{
10728   Insert an environment template.
10730 - {{{kbd(TAB)}}} ::
10731   #+kindex: TAB
10733   The {{{kbd(TAB)}}} key expands the template if point is inside
10734   a LaTeX fragment[fn:111].  For example, {{{kbd(TAB)}}} expands =fr=
10735   to =\frac{}{}= and position point correctly inside the first brace.
10736   Another {{{kbd(TAB)}}} gets you into the second brace.
10738   Even outside fragments, {{{kbd(TAB)}}} expands environment
10739   abbreviations at the beginning of a line.  For example, if you write
10740   =equ= at the beginning of a line and press {{{kbd(TAB)}}}, this
10741   abbreviation is expanded to an =equation= environment.  To get
10742   a list of all abbreviations, type {{{kbd(M-x
10743   cdlatex-command-help)}}}.
10745 - {{{kbd(^)}}}, {{{kbd(_)}}} ::
10746   #+kindex: _
10747   #+kindex: ^
10748   #+vindex: cdlatex-simplify-sub-super-scripts
10750   Pressing {{{kbd(_)}}} and {{{kbd(^)}}} inside a LaTeX fragment
10751   inserts these characters together with a pair of braces.  If you use
10752   {{{kbd(TAB)}}} to move out of the braces, and if the braces surround
10753   only a single character or macro, they are removed again (depending
10754   on the variable ~cdlatex-simplify-sub-super-scripts~).
10756 - {{{kbd(`)}}} ::
10757   #+kindex: `
10759   Pressing the backquote followed by a character inserts math macros,
10760   also outside LaTeX fragments.  If you wait more than 1.5 seconds
10761   after the backquote, a help window pops up.
10763 - {{{kbd(')}}} ::
10764   #+kindex: '
10766   Pressing the single-quote followed by another character modifies the
10767   symbol before point with an accent or a font.  If you wait more than
10768   1.5 seconds after the single-quote, a help window pops up.
10769   Character modification works only inside LaTeX fragments; outside
10770   the quote is normal.
10772 ** Literal Examples
10773 :PROPERTIES:
10774 :DESCRIPTION: Source code examples with special formatting.
10775 :END:
10776 #+cindex: literal examples, markup rules
10777 #+cindex: code line references, markup rules
10779 You can include literal examples that should not be subjected to
10780 markup.  Such examples are typeset in monospace, so this is well
10781 suited for source code and similar examples.
10783 #+cindex: @samp{BEGIN_EXAMPLE}
10784 #+cindex: example block
10785 #+begin_example
10786 ,#+BEGIN_EXAMPLE
10787   Some example from a text file.
10788 ,#+END_EXAMPLE
10789 #+end_example
10791 Note that such blocks may be /indented/ in order to align nicely with
10792 indented text and in particular with plain list structure (see
10793 [[*Plain Lists]]).  For simplicity when using small examples, you can
10794 also start the example lines with a colon followed by a space.  There
10795 may also be additional whitespace before the colon:
10797 #+begin_example
10798 Here is an example
10799    : Some example from a text file.
10800 #+end_example
10802 #+cindex: formatting source code, markup rules
10803 #+vindex: org-latex-listings
10804 If the example is source code from a programming language, or any
10805 other text that can be marked up by Font Lock in Emacs, you can ask
10806 for the example to look like the fontified Emacs buffer[fn:112].  This
10807 is done with the code block, where you also need to specify the name
10808 of the major mode that should be used to fontify the example[fn:113],
10809 see [[*Structure Templates]] for shortcuts to easily insert code blocks.
10811 #+cindex: @samp{BEGIN_SRC}
10812 #+cindex: source block
10813 #+begin_example
10814 ,#+BEGIN_SRC emacs-lisp
10815   (defun org-xor (a b)
10816     "Exclusive or."
10817     (if a (not b) b))
10818  ,#+END_SRC
10819 #+end_example
10821 Both in =example= and in =src= snippets, you can add a =-n= switch to
10822 the end of the =#+BEGIN= line, to get the lines of the example
10823 numbered.  The =-n= takes an optional numeric argument specifying the
10824 starting line number of the block.  If you use a =+n= switch, the
10825 numbering from the previous numbered snippet is continued in the
10826 current one.  The =+n= switch can also take a numeric argument.  This
10827 adds the value of the argument to the last line of the previous block
10828 to determine the starting line number.
10830 #+begin_example
10831 ,#+BEGIN_SRC emacs-lisp -n 20
10832   ;; This exports with line number 20.
10833   (message "This is line 21")
10834 ,#+END_SRC
10836 ,#+BEGIN_SRC emacs-lisp +n 10
10837   ;; This is listed as line 31.
10838   (message "This is line 32")
10839 ,#+END_SRC
10840 #+end_example
10842 In literal examples, Org interprets strings like =(ref:name)= as
10843 labels, and use them as targets for special hyperlinks like
10844 =[[(name)]]=---i.e., the reference name enclosed in single parenthesis.
10845 In HTML, hovering the mouse over such a link remote-highlights the
10846 corresponding code line, which is kind of cool.
10848 You can also add a =-r= switch which /removes/ the labels from the
10849 source code[fn:114].  With the =-n= switch, links to these references
10850 are labeled by the line numbers from the code listing.  Otherwise
10851 links use the labels with no parentheses.  Here is an example:
10853 #+begin_example -l "(dumb-reference:%s)"
10854 ,#+BEGIN_SRC emacs-lisp -n -r
10855   (save-excursion                 (ref:sc)
10856      (goto-char (point-min))      (ref:jump)
10857 ,#+END_SRC
10858 In line [[(sc)]] we remember the current position. [[(jump)][Line (jump)]]
10859 jumps to point-min.
10860 #+end_example
10862 #+cindex: indentation, in source blocks
10863 Finally, you can use =-i= to preserve the indentation of a specific
10864 code block (see [[*Editing Source Code]]).
10866 #+vindex: org-coderef-label-format
10867 If the syntax for the label format conflicts with the language syntax,
10868 use a =-l= switch to change the format, for example
10870 : #+BEGIN_SRC pascal -n -r -l "((%s))"
10872 #+texinfo: @noindent
10873 See also the variable ~org-coderef-label-format~.
10875 HTML export also allows examples to be published as text areas (see
10876 [[*Text areas in HTML export]]).
10878 Because the =#+BEGIN= ... =#+END= patterns need to be added so often,
10879 a shortcut is provided (see [[*Structure Templates]]).
10881 - {{{kbd(C-c ')}}} (~org-edit-special~) ::
10883   #+kindex: C-c '
10884   #+findex: org-edit-special
10885   Edit the source code example at point in its native mode.  This
10886   works by switching to a temporary buffer with the source code.  You
10887   need to exit by pressing {{{kbd(C-c ')}}} again[fn:115].  The edited
10888   version then replaces the old version in the Org buffer.
10889   Fixed-width regions---where each line starts with a colon followed
10890   by a space---are edited using ~artist-mode~[fn:116] to allow
10891   creating ASCII drawings easily.  Using this command in an empty line
10892   creates a new fixed-width region.
10894 #+cindex: storing link, in a source code buffer
10895 Calling ~org-store-link~ (see [[*Handling Links]]) while editing a source
10896 code example in a temporary buffer created with {{{kbd(C-c ')}}}
10897 prompts for a label.  Make sure that it is unique in the current
10898 buffer, and insert it with the proper formatting like =(ref:label)= at
10899 the end of the current line.  Then the label is stored as a link
10900 =(label)=, for retrieval with {{{kbd(C-c C-l)}}}.
10902 ** Images
10903 :PROPERTIES:
10904 :DESCRIPTION: Display an image.
10905 :END:
10907 #+cindex: inlining images
10908 #+cindex: images, markup rules
10909 An image is a link to an image file[fn:117] that does not have
10910 a description part, for example
10912 : ./img/cat.jpg
10914 If you wish to define a caption for the image (see [[*Captions]]) and
10915 maybe a label for internal cross references (see [[*Internal Links]]),
10916 make sure that the link is on a line by itself and precede it with
10917 =CAPTION= and =NAME= keywords as follows:
10919 #+begin_example
10920 ,#+CAPTION: This is the caption for the next figure link (or table)
10921 ,#+NAME:   fig:SED-HR4049
10922 [[./img/a.jpg]]
10923 #+end_example
10925 Such images can be displayed within the buffer with the following
10926 command:
10928 - {{{kbd(C-c C-x C-v)}}} (~org-toggle-inline-images~) ::
10930   #+kindex: C-c C-x C-v
10931   #+findex: org-toggle-inline-images
10932   #+vindex: org-startup-with-inline-images
10933   Toggle the inline display of linked images.  When called with
10934   a prefix argument, also display images that do have a link
10935   description.  You can ask for inline images to be displayed at
10936   startup by configuring the variable
10937   ~org-startup-with-inline-images~[fn:118].
10939 ** Captions
10940 :PROPERTIES:
10941 :DESCRIPTION: Describe tables, images...
10942 :END:
10943 #+cindex: captions, markup rules
10944 #+cindex: @samp{CAPTION}, keyword
10946 You can assign a caption to a specific part of a document by inserting
10947 a =CAPTION= keyword immediately before it:
10949 #+begin_example
10950 ,#+CAPTION: This is the caption for the next table (or link)
10951 | ... | ... |
10952 |-----+-----|
10953 #+end_example
10955 Optionally, the caption can take the form:
10957 : #+CAPTION[Short caption]: Longer caption.
10959 Even though images and tables are prominent examples of captioned
10960 structures, the same caption mechanism can apply to many
10961 others---e.g., LaTeX equations, source code blocks.  Depending on the
10962 export back-end, those may or may not be handled.
10964 ** Horizontal Rules
10965 :PROPERTIES:
10966 :DESCRIPTION: Make a line.
10967 :END:
10969 #+cindex: horizontal rules, markup rules
10970 A line consisting of only dashes, and at least 5 of them, is exported
10971 as a horizontal line.
10973 ** Creating Footnotes
10974 :PROPERTIES:
10975 :DESCRIPTION: Edit and read footnotes.
10976 :END:
10977 #+cindex: footnotes
10979 A footnote is started by a footnote marker in square brackets in
10980 column 0, no indentation allowed.  It ends at the next footnote
10981 definition, headline, or after two consecutive empty lines.  The
10982 footnote reference is simply the marker in square brackets, inside
10983 text.  Markers always start with =fn:=.  For example:
10985 #+begin_example
10986 The Org homepage[fn:1] now looks a lot better than it used to.
10988 [fn:1] The link is: https://orgmode.org
10989 #+end_example
10991 Org mode extends the number-based syntax to /named/ footnotes and
10992 optional inline definition.  Here are the valid references:
10994 - =[fn:NAME]= ::
10996   A named footnote reference, where {{{var(NAME)}}} is a unique
10997   label word, or, for simplicity of automatic creation, a number.
10999 - =[fn:: This is the inline definition of this footnote]= ::
11001   An anonymous footnote where the definition is given directly at the
11002   reference point.
11004 - =[fn:NAME: a definition]= ::
11006   An inline definition of a footnote, which also specifies a name for
11007   the note.  Since Org allows multiple references to the same note,
11008   you can then use =[fn:NAME]= to create additional references.
11010 #+vindex: org-footnote-auto-label
11011 Footnote labels can be created automatically, or you can create names
11012 yourself.  This is handled by the variable ~org-footnote-auto-label~
11013 and its corresponding =STARTUP= keywords.  See the docstring of that
11014 variable for details.
11016 The following command handles footnotes:
11018 - {{{kbd(C-c C-x f)}}} ::
11020   The footnote action command.
11022   #+kindex: C-c C-x f
11023   When point is on a footnote reference, jump to the definition.  When
11024   it is at a definition, jump to the---first---reference.
11026   #+vindex: org-footnote-define-inline
11027   #+vindex: org-footnote-section
11028   Otherwise, create a new footnote.  Depending on the variable
11029   ~org-footnote-define-inline~[fn:119], the definition is placed right
11030   into the text as part of the reference, or separately into the
11031   location determined by the variable ~org-footnote-section~.
11033   When this command is called with a prefix argument, a menu of
11034   additional options is offered:
11036   #+attr_texinfo: :columns 0.1 0.9
11037   | {{{kbd(s)}}} | Sort the footnote definitions by reference sequence.               |
11038   | {{{kbd(r)}}} | Renumber the simple =fn:N= footnotes.                              |
11039   | {{{kbd(S)}}} | Short for first {{{kbd(r)}}}, then {{{kbd(s)}}} action.            |
11040   | {{{kbd(n)}}} | Rename all footnotes into a =fn:1= ... =fn:n= sequence.            |
11041   | {{{kbd(d)}}} | Delete the footnote at point, including definition and references. |
11043   #+vindex: org-footnote-auto-adjust
11044   Depending on the variable ~org-footnote-auto-adjust~[fn:120],
11045   renumbering and sorting footnotes can be automatic after each
11046   insertion or deletion.
11048 - {{{kbd(C-c C-c)}}} ::
11050   #+kindex: C-c C-c
11051   If point is on a footnote reference, jump to the definition.  If it
11052   is at the definition, jump back to the reference.  When called at
11053   a footnote location with a prefix argument, offer the same menu as
11054   {{{kbd(C-c C-x f)}}}.
11056 - {{{kbd(C-c C-o)}}} or {{{kbd(mouse-1/2)}}} ::
11058   #+kindex: C-c C-o
11059   #+kindex: mouse-1
11060   #+kindex: mouse-2
11061   Footnote labels are also links to the corresponding definition or
11062   reference, and you can use the usual commands to follow these links.
11064 * Exporting
11065 :PROPERTIES:
11066 :DESCRIPTION: Sharing and publishing notes.
11067 :END:
11068 #+cindex: exporting
11070 At some point you might want to print your notes, publish them on the
11071 web, or share them with people not using Org.  Org can convert and
11072 export documents to a variety of other formats while retaining as much
11073 structure (see [[*Document Structure]]) and markup (see [[*Markup for Rich
11074 Contents]]) as possible.
11076 #+cindex: export back-end
11077 The libraries responsible for translating Org files to other formats
11078 are called /back-ends/.  Org ships with support for the following
11079 back-ends:
11081 - /ascii/ (ASCII format)
11082 - /beamer/ (LaTeX Beamer format)
11083 - /html/ (HTML format)
11084 - /icalendar/ (iCalendar format)
11085 - /latex/ (LaTeX format)
11086 - /md/ (Markdown format)
11087 - /odt/ (OpenDocument Text format)
11088 - /org/ (Org format)
11089 - /texinfo/ (Texinfo format)
11090 - /man/ (Man page format)
11092 Users can install libraries for additional formats from the Emacs
11093 packaging system. For easy discovery, these packages have a common
11094 naming scheme: ~ox-NAME~, where {{{var(NAME)}}} is a format.  For
11095 example, ~ox-koma-letter~ for /koma-letter/ back-end.  More libraries
11096 can be found in the =contrib/= directory (see [[*Installation]]).
11098 #+vindex: org-export-backends
11099 Org only loads back-ends for the following formats by default: ASCII,
11100 HTML, iCalendar, LaTeX, and ODT.  Additional back-ends can be loaded
11101 in either of two ways: by configuring the ~org-export-backends~
11102 variable, or by requiring libraries in the Emacs init file.  For
11103 example, to load the Markdown back-end, add this to your Emacs config:
11105 #+begin_src emacs-lisp
11106 (require 'ox-md)
11107 #+end_src
11109 ** The Export Dispatcher
11110 :PROPERTIES:
11111 :DESCRIPTION: The main interface.
11112 :END:
11113 #+cindex: dispatcher, for export commands
11114 #+cindex: export, dispatcher
11116 The export dispatcher is the main interface for Org's exports.
11117 A hierarchical menu presents the currently configured export formats.
11118 Options are shown as easy toggle switches on the same screen.
11120 #+vindex: org-export-dispatch-use-expert-ui
11121 Org also has a minimal prompt interface for the export dispatcher.
11122 When the variable ~org-export-dispatch-use-expert-ui~ is set to
11123 a non-~nil~ value, Org prompts in the minibuffer.  To switch back to
11124 the hierarchical menu, press {{{kbd(?)}}}.
11126 - {{{kbd(C-c C-e)}}} (~org-export~) ::
11127   #+kindex: C-c C-e
11128   #+findex: org-export
11130   Invokes the export dispatcher interface.  The options show default
11131   settings.  The {{{kbd(C-u)}}} prefix argument preserves options from
11132   the previous export, including any sub-tree selections.
11134 Org exports the entire buffer by default.  If the Org buffer has an
11135 active region, then Org exports just that region.
11137 Within the dispatcher interface, the following key combinations can
11138 further alter what is exported, and how.
11140 - {{{kbd(C-a)}}} ::
11141   #+kindex: C-c C-e C-a
11143   Toggle asynchronous export.  Asynchronous export uses an external
11144   Emacs process with a specially configured initialization file to
11145   complete the exporting process in the background, without tying-up
11146   Emacs.  This is particularly useful when exporting long documents.
11148   Output from an asynchronous export is saved on the /export stack/.
11149   To view this stack, call the export dispatcher with a double
11150   {{{kbd(C-u)}}} prefix argument.  If already in the export dispatcher
11151   menu, {{{kbd(&)}}} displays the stack.
11153   #+vindex: org-export-in-background
11154   You can make asynchronous export the default by setting
11155   ~org-export-in-background~.
11157   #+vindex: org-export-async-init-file
11158   You can set the initialization file used by the background process
11159   by setting ~org-export-async-init-file~.
11161 - {{{kbd(C-b)}}} ::
11162   #+kindex: C-c C-e C-b
11164   Toggle body-only export.  Useful for excluding headers and footers
11165   in the export.  Affects only those back-end formats that have
11166   sections like =<head>...</head>= in HTML.
11168 - {{{kbd(C-s)}}} ::
11169   #+kindex: C-c C-e C-s
11171   Toggle sub-tree export.  When turned on, Org exports only the
11172   sub-tree starting from point position at the time the export
11173   dispatcher was invoked.  Org uses the top heading of this sub-tree
11174   as the document's title.  If point is not on a heading, Org uses the
11175   nearest enclosing header.  If point is in the document preamble, Org
11176   signals an error and aborts export.
11178   #+vindex: org-export-initial-scope
11179   To make sub-tree export the default, customize the variable
11180   ~org-export-initial-scope~.
11182 - {{{kbd(C-v)}}} ::
11183   #+kindex: C-c C-e C-v
11185   Toggle visible-only export.  This is useful for exporting only
11186   certain parts of an Org document by adjusting the visibility of
11187   particular headings.
11189 ** Export Settings
11190 :PROPERTIES:
11191 :DESCRIPTION: Common export settings.
11192 :END:
11193 #+cindex: options, for export
11194 #+cindex: Export, settings
11196 #+cindex: @samp{OPTIONS}, keyword
11197 Export options can be set: globally with variables; for an individual
11198 file by making variables buffer-local with in-buffer settings (see
11199 [[*Summary of In-Buffer Settings]]); by setting individual keywords or
11200 specifying them in compact form with the =OPTIONS= keyword; or for
11201 a tree by setting properties (see [[*Properties and Columns]]).  Options
11202 set at a specific level override options set at a more general level.
11204 #+cindex: @samp{SETUPFILE}, keyword
11205 In-buffer settings may appear anywhere in the file, either directly or
11206 indirectly through a file included using =#+SETUPFILE: filename or
11207 URL= syntax.  Option keyword sets tailored to a particular back-end
11208 can be inserted from the export dispatcher (see [[*The Export
11209 Dispatcher]]) using the =Insert template= command by pressing
11210 {{{kbd(#)}}}.  To insert keywords individually, a good way to make
11211 sure the keyword is correct is to type =#+= and then to use
11212 {{{kbd(M-TAB)}}}[fn:16] for completion.
11214 The export keywords available for every back-end, and their equivalent
11215 global variables, include:
11217 - =AUTHOR= ::
11219   #+cindex: @samp{AUTHOR}, keyword
11220   #+vindex: user-full-name
11221   The document author (~user-full-name~).
11223 - =CREATOR= ::
11225   #+cindex: @samp{CREATOR}, keyword
11226   #+vindex: org-expot-creator-string
11227   Entity responsible for output generation
11228   (~org-export-creator-string~).
11230 - =DATE= ::
11232   #+cindex: @samp{DATE}, keyword
11233   #+vindex: org-export-date-timestamp-format
11234   A date or a time-stamp[fn:121].
11236 - =EMAIL= ::
11238   #+cindex: @samp{EMAIL}, keyword
11239   #+vindex: user-mail-address
11240   The email address (~user-mail-address~).
11242 - =LANGUAGE= ::
11244   #+cindex: @samp{LANGUAGE}, keyword
11245   #+vindex: org-export-default-language
11246   Language to use for translating certain strings
11247   (~org-export-default-language~).  With =#+LANGUAGE: fr=, for
11248   example, Org translates =Table of contents= to the French =Table des
11249   matières=[fn:122].
11251 - =SELECT_TAGS= ::
11253   #+cindex: @samp{SELECT_TAGS}, keyword
11254   #+vindex: org-export-select-tags
11255   The default value is =("export")=.  When a tree is tagged with
11256   =export= (~org-export-select-tags~), Org selects that tree and its
11257   sub-trees for export.  Org excludes trees with =noexport= tags, see
11258   below.  When selectively exporting files with =export= tags set, Org
11259   does not export any text that appears before the first headline.
11261 - =EXCLUDE_TAGS= ::
11263   #+cindex: @samp{EXCLUDE_TAGS}, keyword
11264   #+vindex: org-export-exclude-tags
11265   The default value is =("noexport")=.  When a tree is tagged with
11266   =noexport= (~org-export-exclude-tags~), Org excludes that tree and
11267   its sub-trees from export.  Entries tagged with =noexport= are
11268   unconditionally excluded from the export, even if they have an
11269   =export= tag.  Even if a sub-tree is not exported, Org executes any
11270   code blocks contained there.
11272 - =TITLE= ::
11274   #+cindex: @samp{TITLE}, keyword
11275   #+cindex: document title
11276   Org displays this title.  For long titles, use multiple =#+TITLE=
11277   lines.
11279 - =EXPORT_FILE_NAME= ::
11281   #+cindex: @samp{EXPORT_FILE_NAME}, keyword
11282   The name of the output file to be generated.  Otherwise, Org
11283   generates the file name based on the buffer name and the extension
11284   based on the back-end format.
11286 The =OPTIONS= keyword is a compact form.  To configure multiple
11287 options, use several =OPTIONS= lines.  =OPTIONS= recognizes the
11288 following arguments.
11290 - ~'~ ::
11292   #+vindex: org-export-with-smart-quotes
11293   Toggle smart quotes (~org-export-with-smart-quotes~).  Depending on
11294   the language used, when activated, Org treats pairs of double quotes
11295   as primary quotes, pairs of single quotes as secondary quotes, and
11296   single quote marks as apostrophes.
11298 - ~*~ ::
11300   #+vindex: org-export-with-emphasize
11301   Toggle emphasized text (~org-export-with-emphasize~).
11303 - ~-~ ::
11305   #+vindex: org-export-with-special-strings
11306   Toggle conversion of special strings
11307   (~org-export-with-special-strings~).
11309 - ~:~ ::
11311   #+vindex: org-export-with-fixed-width
11312   Toggle fixed-width sections (~org-export-with-fixed-width~).
11314 - ~<~ ::
11316   #+vindex: org-export-with-timestamps
11317   Toggle inclusion of time/date active/inactive stamps
11318   (~org-export-with-timestamps~).
11320 - ~\n~ ::
11322   #+vindex: org-export-preserve-breaks
11323   Toggles whether to preserve line breaks
11324   (~org-export-preserve-breaks~).
11326 - ~^~ ::
11328   #+vindex: org-export-with-sub-superscripts
11329   Toggle TeX-like syntax for sub- and superscripts.  If you write
11330   =^:{}=, =a_{b}= is interpreted, but the simple =a_b= is left as it
11331   is (~org-export-with-sub-superscripts~).
11333 - ~arch~ ::
11335   #+vindex: org-export-with-archived-trees
11336   Configure how archived trees are exported.  When set to ~headline~,
11337   the export process skips the contents and processes only the
11338   headlines (~org-export-with-archived-trees~).
11340 - ~author~ ::
11342   #+vindex: org-export-with-author
11343   Toggle inclusion of author name into exported file
11344   (~org-export-with-author~).
11346 - ~broken-links~ ::
11348   #+vindex: org-export-with-broken-links
11349   Toggles if Org should continue exporting upon finding a broken
11350   internal link.  When set to ~mark~, Org clearly marks the problem
11351   link in the output (~org-export-with-broken-links~).
11353 - ~c~ ::
11355   #+vindex: org-export-with-clocks
11356   Toggle inclusion of =CLOCK= keywords (~org-export-with-clocks~).
11358 - ~creator~ ::
11360   #+vindex: org-export-with-creator
11361   Toggle inclusion of creator information in the exported file
11362   (~org-export-with-creator~).
11364 - ~d~ ::
11366   #+vindex: org-export-with-drawers
11367   Toggles inclusion of drawers, or list of drawers to include, or list
11368   of drawers to exclude (~org-export-with-drawers~).
11370 - ~date~ ::
11372   #+vindex: org-export-with-date
11373   Toggle inclusion of a date into exported file
11374   (~org-export-with-date~).
11376 - ~e~ ::
11378   #+vindex: org-export-with-entities
11379   Toggle inclusion of entities (~org-export-with-entities~).
11381 - ~email~ ::
11383   #+vindex: org-export-with-email
11384   Toggle inclusion of the author's e-mail into exported file
11385   (~org-export-with-email~).
11387 - ~f~ ::
11389   #+vindex: org-export-with-footnotes
11390   Toggle the inclusion of footnotes (~org-export-with-footnotes~).
11392 - ~H~ ::
11394   #+vindex: org-export-headline-levels
11395   Set the number of headline levels for export
11396   (~org-export-headline-levels~).  Below that level, headlines are
11397   treated differently.  In most back-ends, they become list items.
11399 - ~inline~ ::
11401   #+vindex: org-export-with-inlinetasks
11402   Toggle inclusion of inlinetasks (~org-export-with-inlinetasks~).
11404 - ~num~ ::
11406   #+vindex: org-export-with-section-numbers
11407   #+cindex: @samp{UNNUMBERED}, property
11408   Toggle section-numbers (~org-export-with-section-numbers~).  When
11409   set to number N, Org numbers only those headlines at level N or
11410   above.  Set =UNNUMBERED= property to non-~nil~ to disable numbering
11411   of heading and subheadings entirely.  Moreover, when the value is
11412   =notoc= the headline, and all its children, do not appear in the
11413   table of contents either (see [[*Table of Contents]]).
11415 - ~p~ ::
11417   #+vindex: org-export-with-planning
11418   Toggle export of planning information (~org-export-with-planning~).
11419   "Planning information" comes from lines located right after the
11420   headline and contain any combination of these cookies: =SCHEDULED=,
11421   =DEADLINE=, or =CLOSED=.
11423 - ~pri~ ::
11425   #+vindex: org-export-with-priority
11426   Toggle inclusion of priority cookies
11427   (~org-export-with-priority~).
11429 - ~prop~ ::
11431   #+vindex: org-export-with-properties
11432   Toggle inclusion of property drawers, or list the properties to
11433   include (~org-export-with-properties~).
11435 - ~stat~ ::
11437   #+vindex: org-export-with-statistics-cookies
11438   Toggle inclusion of statistics cookies
11439   (~org-export-with-statistics-cookies~).
11441 - ~tags~ ::
11443   #+vindex: org-export-with-tags
11444   Toggle inclusion of tags, may also be ~not-in-toc~
11445   (~org-export-with-tags~).
11447 - ~tasks~ ::
11449   #+vindex: org-export-with-tasks
11450   Toggle inclusion of tasks (TODO items); or ~nil~ to remove all
11451   tasks; or ~todo~ to remove done tasks; or list the keywords to keep
11452   (~org-export-with-tasks~).
11454 - ~tex~ ::
11456   #+vindex: org-export-with-latex
11457   ~nil~ does not export; ~t~ exports; ~verbatim~ keeps everything in
11458   verbatim (~org-export-with-latex~).
11460 - ~timestamp~ ::
11462   #+vindex: org-export-time-stamp-file
11463   Toggle inclusion of the creation time in the exported file
11464   (~org-export-time-stamp-file~).
11466 - ~title~ ::
11468   #+vindex: org-export-with-title
11469   Toggle inclusion of title (~org-export-with-title~).
11471 - ~toc~ ::
11473   #+vindex: org-export-with-toc
11474   Toggle inclusion of the table of contents, or set the level limit
11475   (~org-export-with-toc~).
11477 - ~todo~ ::
11479   #+vindex: org-export-with-todo-keywords
11480   Toggle inclusion of TODO keywords into exported text
11481   (~org-export-with-todo-keywords~).
11483 - ~|~ ::
11485   #+vindex: org-export-with-tables
11486   Toggle inclusion of tables (~org-export-with-tables~).
11488 When exporting sub-trees, special node properties can override the
11489 above keywords.  These properties have an =EXPORT_= prefix.  For
11490 example, =DATE= becomes, =EXPORT_DATE= when used for a specific
11491 sub-tree.  Except for =SETUPFILE=, all other keywords listed above
11492 have an =EXPORT_= equivalent.
11494 #+cindex: @samp{BIND}, keyword
11495 #+vindex: org-export-allow-bind-keywords
11496 If ~org-export-allow-bind-keywords~ is non-~nil~, Emacs variables can
11497 become buffer-local during export by using the =BIND= keyword.  Its
11498 syntax is =#+BIND: variable value=.  This is particularly useful for
11499 in-buffer settings that cannot be changed using keywords.
11501 ** Table of Contents
11502 :PROPERTIES:
11503 :DESCRIPTION: The if and where of the table of contents.
11504 :END:
11505 #+cindex: table of contents
11506 #+cindex: list of tables
11507 #+cindex: list of listings
11509 #+cindex: @samp{toc}, in @samp{OPTIONS} keyword
11510 #+vindex: org-export-with-toc
11511 The table of contents includes all headlines in the document.  Its
11512 depth is therefore the same as the headline levels in the file.  If
11513 you need to use a different depth, or turn it off entirely, set the
11514 ~org-export-with-toc~ variable accordingly.  You can achieve the same
11515 on a per file basis, using the following =toc= item in =OPTIONS=
11516 keyword:
11518 #+begin_example
11519 ,#+OPTIONS: toc:2          (only include two levels in TOC)
11520 ,#+OPTIONS: toc:nil        (no default TOC at all)
11521 #+end_example
11523 #+cindex: excluding entries from table of contents
11524 #+cindex: table of contents, exclude entries
11525 Org includes both numbered and unnumbered headlines in the table of
11526 contents[fn:123].  If you need to exclude an unnumbered headline,
11527 along with all its children, set the =UNNUMBERED= property to =notoc=
11528 value.
11530 #+begin_example
11531 ,* Subtree not numbered, not in table of contents either
11532   :PROPERTIES:
11533   :UNNUMBERED: notoc
11534   :END:
11535 #+end_example
11537 #+cindex: @samp{TOC}, keyword
11538 Org normally inserts the table of contents directly before the first
11539 headline of the file.  To move the table of contents to a different
11540 location, first turn off the default with ~org-export-with-toc~
11541 variable or with =#+OPTIONS: toc:nil=.  Then insert =#+TOC: headlines
11542 N= at the desired location(s).
11544 #+begin_example
11545 ,#+OPTIONS: toc:nil
11547 ,#+TOC: headlines 2
11548 #+end_example
11550 To adjust the table of contents depth for a specific section of the
11551 Org document, append an additional =local= parameter.  This parameter
11552 becomes a relative depth for the current level.  The following example
11553 inserts a local table of contents, with direct children only.
11555 #+begin_example
11556 ,* Section
11557 ,#+TOC: headlines 1 local
11558 #+end_example
11560 Note that for this feature to work properly in LaTeX export, the Org
11561 file requires the inclusion of the titletoc package.  Because of
11562 compatibility issues, titletoc has to be loaded /before/ hyperref.
11563 Customize the ~org-latex-default-packages-alist~ variable.
11565 Use the =TOC= keyword to generate list of tables---respectively, all
11566 listings---with captions.
11568 #+begin_example
11569 ,#+TOC: listings
11570 ,#+TOC: tables
11571 #+end_example
11573 #+cindex: @samp{ALT_TITLE}, property
11574 Normally Org uses the headline for its entry in the table of contents.
11575 But with =ALT_TITLE= property, a different entry can be specified for
11576 the table of contents.
11578 ** Include Files
11579 :PROPERTIES:
11580 :DESCRIPTION: Include additional files into a document.
11581 :END:
11582 #+cindex: include files, during export
11583 #+cindex: export, include files
11584 #+cindex: @samp{INCLUDE}, keyword
11586 During export, you can include the content of another file.  For
11587 example, to include your =.emacs= file, you could use:
11589 : #+INCLUDE: "~/.emacs" src emacs-lisp
11591 #+texinfo: @noindent
11592 The first parameter is the file name to include.  The optional second
11593 parameter specifies the block type: =example=, =export= or =src=.  The
11594 optional third parameter specifies the source code language to use for
11595 formatting the contents.  This is relevant to both =export= and =src=
11596 block types.
11598 If an included file is specified as having a markup language, Org
11599 neither checks for valid syntax nor changes the contents in any way.
11600 For example and source blocks, Org code-escapes the contents before
11601 inclusion.
11603 #+cindex: @samp{minlevel}, include
11604 If an included file is not specified as having any markup language,
11605 Org assumes it be in Org format and proceeds as usual with a few
11606 exceptions.  Org makes the footnote labels (see [[*Creating Footnotes]])
11607 in the included file local to that file.  The contents of the included
11608 file belong to the same structure---headline, item---containing the
11609 =INCLUDE= keyword.  In particular, headlines within the file become
11610 children of the current section.  That behavior can be changed by
11611 providing an additional keyword parameter, =:minlevel=.  It shifts the
11612 headlines in the included file to become the lowest level.  For
11613 example, this syntax makes the included file a sibling of the current
11614 top-level headline:
11616 : #+INCLUDE: "~/my-book/chapter2.org" :minlevel 1
11618 #+cindex: @samp{lines}, include
11619 Inclusion of only portions of files are specified using ranges
11620 parameter with =:lines= keyword.  The line at the upper end of the
11621 range will not be included.  The start and/or the end of the range may
11622 be omitted to use the obvious defaults.
11624 | =#+INCLUDE: "~/.emacs" :lines "5-10"= | Include lines 5 to 10, 10 excluded |
11625 | =#+INCLUDE: "~/.emacs" :lines "-10"=  | Include lines 1 to 10, 10 excluded |
11626 | =#+INCLUDE: "~/.emacs" :lines "10-"=  | Include lines from 10 to EOF       |
11628 Inclusions may specify a file-link to extract an object matched by
11629 ~org-link-search~[fn:124] (see [[*Search Options in File Links]]).  The
11630 ranges for =:lines= keyword are relative to the requested element.
11631 Therefore,
11633 : #+INCLUDE: "./paper.org::*conclusion" :lines 1-20
11635 #+texinfo: @noindent
11636 includes the first 20 lines of the headline named =conclusion=.
11638 #+cindex: @samp{only-contents}, include
11639 To extract only the contents of the matched object, set
11640 =:only-contents= property to non-~nil~.  This omits any planning lines
11641 or property drawers.  For example, to include the body of the heading
11642 with the custom ID =theory=, you can use
11644 : #+INCLUDE: "./paper.org::#theory" :only-contents t
11646 The following command allows navigating to the included document:
11648 - {{{kbd(C-c ')}}} (~org-edit~special~) ::
11649   #+kindex: C-c '
11650   #+findex: org-edit-special
11652   Visit the included file at point.
11654 ** Macro Replacement
11655 :PROPERTIES:
11656 :DESCRIPTION: Use macros to create templates.
11657 :END:
11658 #+cindex: macro replacement, during export
11659 #+cindex: @samp{MACRO}, keyword
11661 #+vindex: org-export-global-macros
11662 Macros replace text snippets during export.  Macros are defined
11663 globally in ~org-export-global-macros~, or document-wise with the
11664 following syntax:
11666 : #+MACRO: name   replacement text; $1, $2 are arguments
11668 #+texinfo: @noindent
11669 which can be referenced using ={{{name(arg1, arg2)}}}=[fn:125].  For
11670 example
11672 #+begin_example
11673 ,#+MACRO: poem Rose is $1, violet's $2. Life's ordered: Org assists you.
11674 {{{poem(red,blue)}}}
11675 #+end_example
11677 #+texinfo: @noindent
11678 becomes
11680 : Rose is red, violet's blue. Life's ordered: Org assists you.
11682 As a special case, Org parses any replacement text starting with
11683 =(eval= as an Emacs Lisp expression and evaluates it accordingly.
11684 Within such templates, arguments become strings.  Thus, the following
11685 macro
11687 : #+MACRO: gnustamp (eval (concat "GNU/" (capitalize $1)))
11689 #+texinfo: @noindent
11690 turns ={{{gnustamp(linux)}}}= into =GNU/Linux= during export.
11692 Org recognizes macro references in following Org markup areas:
11693 paragraphs, headlines, verse blocks, tables cells and lists.  Org also
11694 recognizes macro references in keywords, such as =CAPTION=, =TITLE=,
11695 =AUTHOR=, =DATE=, and for some back-end specific export options.
11697 Org comes with following pre-defined macros:
11699 #+attr_texinfo: :sep ;
11700 - ={{{keyword(NAME)}}}=; ={{{title}}}=; ={{{author}}}=; ={{{email}}}= ::
11702   #+cindex: @samp{keyword}, macro
11703   #+cindex: @samp{title}, macro
11704   #+cindex: @samp{author}, macro
11705   #+cindex: @samp{email}, macro
11706   The =keyword= macro collects all values from {{{var(NAME)}}}
11707   keywords throughout the buffer, separated with white space.
11708   =title=, =author= and =email= macros are shortcuts for,
11709   respectively, ={{{keyword(TITLE)}}}=, ={{{keyword(AUTHOR)}}}= and
11710   ={{{keyword(EMAIL)}}}=.
11712 - ={{{date}}}=; ={{{date(FORMAT)}}}= ::
11714   #+cindex: @samp{date}, macro
11715   This macro refers to the =DATE= keyword.  {{{var(FORMAT)}}} is an
11716   optional argument to the =date= macro that is used only if =DATE= is
11717   a single timestamp.  {{{var(FORMAT)}}} should be a format string
11718   understood by ~format-time-string~.
11720 - ={{{time(FORMAT)}}}=; ={{{modification-time(FORMAT, VC)}}}= ::
11722   #+cindex: @samp{time}, macro
11723   #+cindex: @samp{modification-time}, macro
11724   These macros refer to the document's date and time of export and
11725   date and time of modification.  {{{var(FORMAT)}}} is a string
11726   understood by ~format-time-string~.  If the second argument to the
11727   ~modification-time~ macro is non-~nil~, Org uses =vc.el= to retrieve
11728   the document's modification time from the version control system.
11729   Otherwise Org reads the file attributes.
11731 - ={{{input-file}}}= ::
11733   #+cindex: @samp{input-file}, macro
11734   This macro refers to the filename of the exported file.
11736 - ={{{property(PROPERTY-NAME)}}}=; ={{{property(PROPERTY-NAME, SEARCH OPTION)}}}= ::
11738   #+cindex: @samp{property}, macro
11739   This macro returns the value of property {{{var(PROPERTY-NAME)}}} in
11740   the current entry.  If {{{var(SEARCH-OPTION)}}} (see [[*Search
11741   Options in File Links]]) refers to a remote entry, use it instead.
11743 - ={{{n}}}=; ={{{n(NAME)}}}=; ={{{n(NAME, ACTION)}}}= ::
11745   #+cindex: @samp{n}, macro
11746   #+cindex: counter, macro
11747   This macro implements custom counters by returning the number of
11748   times the macro has been expanded so far while exporting the buffer.
11749   You can create more than one counter using different {{{var(NAME)}}}
11750   values.  If {{{var(ACTION)}}} is =-=, previous value of the counter
11751   is held, i.e., the specified counter is not incremented.  If the
11752   value is a number, the specified counter is set to that value.  If
11753   it is any other non-empty string, the specified counter is reset
11754   to 1.  You may leave {{{var(NAME)}}} empty to reset the default
11755   counter.
11757 #+cindex: @samp{results}, macro
11758 Moreover, inline source blocks (see [[*Structure of Code Blocks]]) use the
11759 special =results= macro to mark their output.  As such, you are
11760 advised against re-defining it, unless you know what you are doing.
11762 #+vindex: org-hide-macro-markers
11763 The surrounding brackets can be made invisible by setting
11764 ~org-hide-macro-markers~ to a non-~nil~ value.
11766 Org expands macros at the very beginning of the export process.
11768 ** Comment Lines
11769 :PROPERTIES:
11770 :DESCRIPTION: What will not be exported.
11771 :END:
11772 #+cindex: exporting, not
11774 #+cindex: comment lines
11775 Lines starting with zero or more whitespace characters followed by one
11776 =#= and a whitespace are treated as comments and, as such, are not
11777 exported.
11779 #+cindex: @samp{BEGIN_COMMENT}
11780 #+cindex: comment block
11781 Likewise, regions surrounded by =#+BEGIN_COMMENT= ... =#+END_COMMENT=
11782 are not exported.
11784 #+cindex: comment trees
11785 Finally, a =COMMENT= keyword at the beginning of an entry, but after
11786 any other keyword or priority cookie, comments out the entire subtree.
11787 In this case, the subtree is not exported and no code block within it
11788 is executed either[fn:126].  The command below helps changing the
11789 comment status of a headline.
11791 - {{{kbd(C-c ;)}}} (~org-toggle-comment~) ::
11792   #+kindex: C-c ;
11793   #+findex: org-toggle-comment
11795   Toggle the =COMMENT= keyword at the beginning of an entry.
11797 ** ASCII/Latin-1/UTF-8 export
11798 :PROPERTIES:
11799 :DESCRIPTION: Exporting to flat files with encoding.
11800 :END:
11801 #+cindex: ASCII export
11802 #+cindex: Latin-1 export
11803 #+cindex: UTF-8 export
11805 ASCII export produces an output file containing only plain ASCII
11806 characters.  This is the simplest and most direct text output.  It
11807 does not contain any Org markup.  Latin-1 and UTF-8 export use
11808 additional characters and symbols available in these encoding
11809 standards.  All three of these export formats offer the most basic of
11810 text output for maximum portability.
11812 #+vindex: org-ascii-text-width
11813 On export, Org fills and justifies text according to the text width
11814 set in ~org-ascii-text-width~.
11816 #+vindex: org-ascii-links-to-notes
11817 Org exports links using a footnote-like style where the descriptive
11818 part is in the text and the link is in a note before the next heading.
11819 See the variable ~org-ascii-links-to-notes~ for details.
11821 *** ASCII export commands
11822 :PROPERTIES:
11823 :UNNUMBERED: notoc
11824 :END:
11826 #+attr_texinfo: :sep ,
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-to-ascii
11833   Export as an ASCII file with a =.txt= extension.  For =myfile.org=,
11834   Org exports to =myfile.txt=, overwriting without warning.  For
11835   =myfile.txt=, Org exports to =myfile.txt.txt= in order to prevent
11836   data loss.
11838 - {{{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)}}} ::
11839   #+kindex: C-c C-e t A
11840   #+kindex: C-c C-e t L
11841   #+kindex: C-c C-e t U
11842   #+findex: org-ascii-export-as-ascii
11844   Export to a temporary buffer.  Does not create a file.
11846 *** ASCII specific export settings
11847 :PROPERTIES:
11848 :UNNUMBERED: notoc
11849 :END:
11851 The ASCII export back-end has one extra keyword for customizing ASCII
11852 output.  Setting this keyword works similar to the general options
11853 (see [[*Export Settings]]).
11855 - =SUBTITLE= ::
11857   #+cindex: @samp{SUBTITLE}, keyword
11858   The document subtitle.  For long subtitles, use multiple
11859   =#+SUBTITLE= lines in the Org file.  Org prints them on one
11860   continuous line, wrapping into multiple lines if necessary.
11862 *** Header and sectioning structure
11863 :PROPERTIES:
11864 :UNNUMBERED: notoc
11865 :END:
11867 Org converts the first three outline levels into headlines for ASCII
11868 export.  The remaining levels are turned into lists.  To change this
11869 cut-off point where levels become lists, see [[*Export Settings]].
11871 *** Quoting ASCII text
11872 :PROPERTIES:
11873 :UNNUMBERED: notoc
11874 :END:
11876 To insert text within the Org file by the ASCII back-end, use one the
11877 following constructs, inline, keyword, or export block:
11879 #+cindex: @samp{ASCII}, keyword
11880 #+cindex: @samp{BEGIN_EXPORT ascii}
11881 #+begin_example
11882 Inline text @@ascii:and additional text@@ within a paragraph.
11884 ,#+ASCII: Some text
11886 ,#+BEGIN_EXPORT ascii
11887 Org exports text in this block only when using ASCII back-end.
11888 ,#+END_EXPORT
11889 #+end_example
11891 *** ASCII specific attributes
11892 :PROPERTIES:
11893 :UNNUMBERED: notoc
11894 :END:
11895 #+cindex: @samp{ATTR_ASCII}, keyword
11896 #+cindex: horizontal rules, in ASCII export
11898 ASCII back-end recognizes only one attribute, =:width=, which
11899 specifies the width of a horizontal rule in number of characters.  The
11900 keyword and syntax for specifying widths is:
11902 #+begin_example
11903 ,#+ATTR_ASCII: :width 10
11904 -----
11905 #+end_example
11907 *** ASCII special blocks
11908 :PROPERTIES:
11909 :UNNUMBERED: notoc
11910 :END:
11911 #+cindex: special blocks, in ASCII export
11912 #+cindex: @samp{BEGIN_JUSTIFYLEFT}
11913 #+cindex: @samp{BEGIN_JUSTIFYRIGHT}
11915 Besides =#+BEGIN_CENTER= blocks (see [[*Paragraphs]]), ASCII back-end has
11916 these two left and right justification blocks:
11918 #+begin_example
11919 ,#+BEGIN_JUSTIFYLEFT
11920 It's just a jump to the left...
11921 ,#+END_JUSTIFYLEFT
11923 ,#+BEGIN_JUSTIFYRIGHT
11924 ...and then a step to the right.
11925 ,#+END_JUSTIFYRIGHT
11926 #+end_example
11928 ** Beamer Export
11929 #+cindex: Beamer export
11931 Org uses Beamer export to convert an Org file tree structure into
11932 high-quality interactive slides for presentations.  Beamer is a LaTeX
11933 document class for creating presentations in PDF, HTML, and other
11934 popular display formats.
11936 *** Beamer export commands
11937 :PROPERTIES:
11938 :DESCRIPTION: For creating Beamer documents.
11939 :END:
11941 - {{{kbd(C-c C-e l b)}}} (~org-beamer-export-to-latex~) ::
11942   #+kindex: C-c C-e l b
11943   #+findex: org-beamer-export-to-latex
11945   Export as LaTeX file with a =.tex= extension.  For =myfile.org=, Org
11946   exports to =myfile.tex=, overwriting without warning.
11948 - {{{kbd(C-c C-e l B)}}} (~org-beamer-export-as-latex~) ::
11949   #+kindex: C-c C-e l B
11950   #+findex: org-beamer-export-as-latex
11952   Export to a temporary buffer.  Does not create a file.
11954 - {{{kbd(C-c C-e l P)}}} (~org-beamer-export-to-pdf~) ::
11955   #+kindex: C-c C-e l P
11956   #+findex: org-beamer-export-to-pdf
11958   Export as LaTeX file and then convert it to PDF format.
11960 - {{{kbd(C-c C-e l O)}}} ::
11961   #+kindex: C-c C-e l O
11963   Export as LaTeX file, convert it to PDF format, and then open the
11964   PDF file.
11966 *** Beamer specific export settings
11967 :PROPERTIES:
11968 :DESCRIPTION: For customizing Beamer export.
11969 :END:
11971 Beamer export back-end has several additional keywords for customizing
11972 Beamer output.  These keywords work similar to the general options
11973 settings (see [[*Export Settings]]).
11975 - =BEAMER_THEME= ::
11977   #+cindex: @samp{BEAMER_THEME}, keyword
11978   #+vindex: org-beamer-theme
11979   The Beamer layout theme (~org-beamer-theme~).  Use square brackets
11980   for options.  For example:
11982   : #+BEAMER_THEME: Rochester [height=20pt]
11984 - =BEAMER_FONT_THEME= ::
11986   #+cindex: @samp{BEAMER_FONT_THEME}, keyword
11987   The Beamer font theme.
11989 - =BEAMER_INNER_THEME= ::
11991   #+cindex: @samp{BEAMER_INNER_THEME}, keyword
11992   The Beamer inner theme.
11994 - =BEAMER_OUTER_THEME= ::
11996   #+cindex: @samp{BEAMER_OUTER_THEME}, keyword
11997   The Beamer outer theme.
11999 - =BEAMER_HEADER= ::
12001   #+cindex: @samp{BEAMER_HEADER}, keyword
12002   Arbitrary lines inserted in the preamble, just before the =hyperref=
12003   settings.
12005 - =DESCRIPTION= ::
12007   #+cindex: @samp{DESCRIPTION}, keyword
12008   The document description.  For long descriptions, use multiple
12009   =DESCRIPTION= keywords.  By default, =hyperref= inserts
12010   =DESCRIPTION= as metadata.  Use ~org-latex-hyperref-template~ to
12011   configure document metadata.  Use ~org-latex-title-command~ to
12012   configure typesetting of description as part of front matter.
12014 - =KEYWORDS= ::
12016   #+cindex: @samp{KEYWORDS}, keyword
12017   The keywords for defining the contents of the document.  Use
12018   multiple =KEYWORDS= lines if necessary.  By default, =hyperref=
12019   inserts =KEYWORDS= as metadata.  Use ~org-latex-hyperref-template~
12020   to configure document metadata.  Use ~org-latex-title-command~ to
12021   configure typesetting of keywords as part of front matter.
12023 - =SUBTITLE= ::
12025   #+cindex: @samp{SUBTITLE}, keyword
12026   Document's subtitle.  For typesetting, use
12027   ~org-beamer-subtitle-format~ string.  Use
12028   ~org-latex-hyperref-template~ to configure document metadata.  Use
12029   ~org-latex-title-command~ to configure typesetting of subtitle as
12030   part of front matter.
12032 *** Frames and Blocks in Beamer
12033 :PROPERTIES:
12034 :DESCRIPTION: For composing Beamer slides.
12035 :END:
12037 Org transforms heading levels into Beamer's sectioning elements,
12038 frames and blocks.  Any Org tree with a not-too-deep-level nesting
12039 should in principle be exportable as a Beamer presentation.
12042   #+vindex: org-beamer-frame-level
12043   Org headlines become Beamer frames when the heading level in Org is
12044   equal to ~org-beamer-frame-level~ or =H= value in a =OPTIONS= line
12045   (see [[*Export Settings]]).
12047   #+cindex: @samp{BEAMER_ENV}, property
12048   Org overrides headlines to frames conversion for the current tree of
12049   an Org file if it encounters the =BEAMER_ENV= property set to
12050   =frame= or =fullframe=.  Org ignores whatever
12051   ~org-beamer-frame-level~ happens to be for that headline level in
12052   the Org tree.  In Beamer terminology, a full frame is a frame
12053   without its title.
12055 - Org exports a Beamer frame's objects as block environments.  Org can
12056   enforce wrapping in special block types when =BEAMER_ENV= property
12057   is set[fn:127].  For valid values see
12058   ~org-beamer-environments-default~.  To add more values, see
12059   ~org-beamer-environments-extra~.
12060   #+vindex: org-beamer-environments-default
12061   #+vindex: org-beamer-environments-extra
12064   #+cindex: @samp{BEAMER_REF}, property
12065   If =BEAMER_ENV= is set to =appendix=, Org exports the entry as an
12066   appendix.  When set to =note=, Org exports the entry as a note
12067   within the frame or between frames, depending on the entry's heading
12068   level.  When set to =noteNH=, Org exports the entry as a note
12069   without its title.  When set to =againframe=, Org exports the entry
12070   with =\againframe= command, which makes setting the =BEAMER_REF=
12071   property mandatory because =\againframe= needs frame to resume.
12073   When =ignoreheading= is set, Org export ignores the entry's headline
12074   but not its content.  This is useful for inserting content between
12075   frames.  It is also useful for properly closing a =column=
12076   environment.  @end itemize
12078   #+cindex: @samp{BEAMER_ACT}, property
12079   #+cindex: @samp{BEAMER_OPT}, property
12080   When =BEAMER_ACT= is set for a headline, Org export translates that
12081   headline as an overlay or action specification.  When enclosed in
12082   square brackets, Org export makes the overlay specification
12083   a default.  Use =BEAMER_OPT= to set any options applicable to the
12084   current Beamer frame or block.  The Beamer export back-end wraps
12085   with appropriate angular or square brackets.  It also adds the
12086   =fragile= option for any code that may require a verbatim block.
12088   #+cindex: @samp{BEAMER_COL}, property
12089   To create a column on the Beamer slide, use the =BEAMER_COL=
12090   property for its headline in the Org file.  Set the value of
12091   =BEAMER_COL= to a decimal number representing the fraction of the
12092   total text width.  Beamer export uses this value to set the column's
12093   width and fills the column with the contents of the Org entry.  If
12094   the Org entry has no specific environment defined, Beamer export
12095   ignores the heading.  If the Org entry has a defined environment,
12096   Beamer export uses the heading as title.  Behind the scenes, Beamer
12097   export automatically handles LaTeX column separations for contiguous
12098   headlines.  To manually adjust them for any unique configurations
12099   needs, use the =BEAMER_ENV= property.
12101 *** Beamer specific syntax
12102 :PROPERTIES:
12103 :DESCRIPTION: For using in Org documents.
12104 :END:
12106 Since Org's Beamer export back-end is an extension of the LaTeX
12107 back-end, it recognizes other LaTeX specific syntax---for example,
12108 =#+LATEX:= or =#+ATTR_LATEX:=.  See [[*LaTeX Export]], for details.
12110 Beamer export wraps the table of contents generated with =toc:t=
12111 =OPTION= keyword in a =frame= environment.  Beamer export does not
12112 wrap the table of contents generated with =TOC= keyword (see [[*Table of
12113 Contents]]).  Use square brackets for specifying options.
12115 : #+TOC: headlines [currentsection]
12117 Insert Beamer-specific code using the following constructs:
12119 #+cindex: @samp{BEAMER}, keyword
12120 #+cindex: @samp{BEGIN_EXPORT beamer}
12121 #+begin_example
12122 ,#+BEAMER: \pause
12124 ,#+BEGIN_EXPORT beamer
12125   Only Beamer export back-end exports this.
12126 ,#+END_BEAMER
12128 Text @@beamer:some code@@ within a paragraph.
12129 #+end_example
12131 Inline constructs, such as the last one above, are useful for adding
12132 overlay specifications to objects with ~bold~, ~item~, ~link~,
12133 ~radio-target~ and ~target~ types.  Enclose the value in angular
12134 brackets and place the specification at the beginning of the object as
12135 shown in this example:
12137 :  A *@@beamer:<2->@@useful* feature
12139 #+cindex: @samp{ATTR_BEAMER}, keyword
12140 Beamer export recognizes the =ATTR_BEAMER= keyword with the following
12141 attributes from Beamer configurations: =:environment= for changing
12142 local Beamer environment, =:overlay= for specifying Beamer overlays in
12143 angular or square brackets, and =:options= for inserting optional
12144 arguments.
12146 #+begin_example
12147 ,#+ATTR_BEAMER: :environment nonindentlist
12148 - item 1, not indented
12149 - item 2, not indented
12150 - item 3, not indented
12151 #+end_example
12153 #+begin_example
12154 ,#+ATTR_BEAMER: :overlay <+->
12155 - item 1
12156 - item 2
12157 #+end_example
12159 #+begin_example
12160 ,#+ATTR_BEAMER: :options [Lagrange]
12161 Let $G$ be a finite group, and let $H$ be
12162 a subgroup of $G$.  Then the order of $H$ divides the order of $G$.
12163 #+end_example
12165 *** Editing support
12166 :PROPERTIES:
12167 :DESCRIPTION: Editing support.
12168 :END:
12170 The ~org-beamer-mode~ is a special minor mode for faster editing of
12171 Beamer documents.
12173 : #+STARTUP: beamer
12175 - {{{kbd(C-c C-b)}}} (~org-beamer-select-environment~) ::
12176   #+kindex: C-c C-b
12177   #+findex: org-beamer-select-environment
12179   The ~org-beamer-mode~ provides this key for quicker selections in
12180   Beamer normal environments, and for selecting the =BEAMER_COL=
12181   property.
12183 *** A Beamer example
12184 :PROPERTIES:
12185 :DESCRIPTION: A complete presentation.
12186 :END:
12188 Here is an example of an Org document ready for Beamer export.
12190 #+begin_example
12191 ,#+TITLE: Example Presentation
12192 ,#+AUTHOR: Carsten Dominik
12193 ,#+OPTIONS: H:2 toc:t num:t
12194 ,#+LATEX_CLASS: beamer
12195 ,#+LATEX_CLASS_OPTIONS: [presentation]
12196 ,#+BEAMER_THEME: Madrid
12197 ,#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col)
12199 ,* This is the first structural section
12201 ,** Frame 1
12202 ,*** Thanks to Eric Fraga                                           :B_block:
12203     :PROPERTIES:
12204     :BEAMER_COL: 0.48
12205     :BEAMER_ENV: block
12206     :END:
12207     for the first viable Beamer setup in Org
12208 ,*** Thanks to everyone else                                        :B_block:
12209     :PROPERTIES:
12210     :BEAMER_COL: 0.48
12211     :BEAMER_ACT: <2->
12212     :BEAMER_ENV: block
12213     :END:
12214     for contributing to the discussion
12215 ,**** This will be formatted as a beamer note                       :B_note:
12216      :PROPERTIES:
12217      :BEAMER_env: note
12218      :END:
12219 ,** Frame 2 (where we will not use columns)
12220 ,*** Request
12221     Please test this stuff!
12222 #+end_example
12224 ** HTML Export
12225 :PROPERTIES:
12226 :DESCRIPTION: Exporting to HTML.
12227 :END:
12228 #+cindex: HTML export
12230 Org mode contains an HTML exporter with extensive HTML formatting
12231 compatible with XHTML 1.0 strict standard.
12233 *** HTML export commands
12234 :PROPERTIES:
12235 :DESCRIPTION: Invoking HTML export.
12236 :END:
12238 - {{{kbd(C-c C-e h h)}}} (~org-html-export-to-html~) ::
12239   #+kindex: C-c C-e h h
12240   #+kindex: C-c C-e h o
12241   #+findex: org-html-export-to-html
12243   Export as HTML file with a =.html= extension.  For =myfile.org=, Org
12244   exports to =myfile.html=, overwriting without warning.  {{{kbd{C-c
12245   C-e h o)}}} exports to HTML and opens it in a web browser.
12247 - {{{kbd(C-c C-e h H)}}} (~org-html-export-as-html~) ::
12248   #+kindex: C-c C-e h H
12249   #+findex: org-html-export-as-html
12251   Exports to a temporary buffer.  Does not create a file.
12253 *** HTML specific export settings
12254 :PROPERTIES:
12255 :DESCRIPTION: Settings for HTML export.
12256 :END:
12258 HTML export has a number of keywords, similar to the general options
12259 settings described in [[*Export Settings]].
12261 - =DESCRIPTION= ::
12263   #+cindex: @samp{DESCRIPTION}, keyword
12264   This is the document's description, which the HTML exporter inserts
12265   it as a HTML meta tag in the HTML file.  For long descriptions, use
12266   multiple =DESCRIPTION= lines.  The exporter takes care of wrapping
12267   the lines properly.
12269 - =HTML_DOCTYPE= ::
12271   #+cindex: @samp{HTML_DOCTYPE}, keyword
12272   #+vindex: org-html-doctype
12273   Specify the document type, for example: HTML5 (~org-html-doctype~).
12275 - =HTML_CONTAINER= ::
12277   #+cindex: @samp{HTML_CONTAINER}, keyword
12278   #+vindex: org-html-container-element
12279   Specify the HTML container, such as =div=, for wrapping sections and
12280   elements (~org-html-container-element~).
12282 - =HTML_LINK_HOME= ::
12284   #+cindex: @samp{HTML_LINK_HOME}, keyword
12285   #+vindex: org-html-link-home
12286   The URL for home link (~org-html-link-home~).
12288 - =HTML_LINK_UP= ::
12290   #+cindex: @samp{HTML_LINK_UP}, keyword
12291   #+vindex: org-html-link-up
12292   The URL for the up link of exported HTML pages (~org-html-link-up~).
12294 - =HTML_MATHJAX= ::
12296   #+cindex: @samp{HTML_MATHJAX}, keyword
12297   #+vindex: org-html-mathjax-options
12298   Options for MathJax (~org-html-mathjax-options~).  MathJax is used
12299   to typeset LaTeX math in HTML documents.  See [[*Math formatting in
12300   HTML export]], for an example.
12302 - =HTML_HEAD= ::
12304   #+cindex: @samp{HTML_HEAD}, keyword
12305   #+vindex: org-html-head
12306   Arbitrary lines for appending to the HTML document's head
12307   (~org-html-head~).
12309 - =HTML_HEAD_EXTRA= ::
12311   #+cindex: @samp{HTML_HEAD_EXTRA}, keyword
12312   #+vindex: org-html-head-extra
12313   More arbitrary lines for appending to the HTML document's head
12314   (~org-html-head-extra~).
12316 - =KEYWORDS= ::
12318   #+cindex: @samp{KEYWORDS}, keyword
12319   Keywords to describe the document's content.  HTML exporter inserts
12320   these keywords as HTML meta tags.  For long keywords, use multiple
12321   =KEYWORDS= lines.
12323 - =LATEX_HEADER= ::
12325   #+cindex: @samp{LATEX_HEADER}, keyword
12326   Arbitrary lines for appending to the preamble; HTML exporter appends
12327   when transcoding LaTeX fragments to images (see [[*Math formatting in
12328   HTML export]]).
12330 - =SUBTITLE= ::
12332   #+cindex: @samp{SUBTITLE}, keyword
12333   The document's subtitle.  HTML exporter formats subtitle if document
12334   type is =HTML5= and the CSS has a =subtitle= class.
12336 Some of these keywords are explained in more detail in the following
12337 sections of the manual.
12339 *** HTML doctypes
12340 :PROPERTIES:
12341 :DESCRIPTION: Exporting various (X)HTML flavors.
12342 :END:
12344 Org can export to various (X)HTML flavors.
12346 #+vindex: org-html-doctype
12347 #+vindex: org-html-doctype-alist
12348 Set the ~org-html-doctype~ variable for different (X)HTML variants.
12349 Depending on the variant, the HTML exporter adjusts the syntax of HTML
12350 conversion accordingly.  Org includes the following ready-made
12351 variants:
12353 - ~"html4-strict"~
12354 - ~"html4-transitional"~
12355 - ~"html4-frameset"~
12356 - ~"xhtml-strict"~
12357 - ~"xhtml-transitional"~
12358 - ~"xhtml-frameset"~
12359 - ~"xhtml-11"~
12360 - ~"html5"~
12361 - ~"xhtml5"~
12363 #+texinfo: @noindent
12364 See the variable ~org-html-doctype-alist~ for details.  The default is
12365 ~"xhtml-strict"~.
12367 #+vindex: org-html-html5-fancy
12368 #+cindex: @samp{HTML5}, export new elements
12369 Org's HTML exporter does not by default enable new block elements
12370 introduced with the HTML5 standard.  To enable them, set
12371 ~org-html-html5-fancy~ to non-~nil~.  Or use an =OPTIONS= line in the
12372 file to set =html5-fancy=.
12374 HTML5 documents can now have arbitrary =#+BEGIN= ... =#+END= blocks.
12375 For example:
12377 #+begin_example
12378 ,#+BEGIN_aside
12379   Lorem ipsum
12380 ,#+END_aside
12381 #+end_example
12383 #+texinfo: @noindent
12384 exports to:
12386 #+begin_src html
12387 <aside>
12388   <p>Lorem ipsum</p>
12389 </aside>
12390 #+end_src
12392 #+texinfo: @noindent
12393 while this:
12395 #+begin_example
12396 ,#+ATTR_HTML: :controls controls :width 350
12397 ,#+BEGIN_video
12398 ,#+HTML: <source src="movie.mp4" type="video/mp4">
12399 ,#+HTML: <source src="movie.ogg" type="video/ogg">
12400 Your browser does not support the video tag.
12401 ,#+END_video
12402 #+end_example
12404 #+texinfo: @noindent
12405 exports to:
12407 #+begin_src html
12408 <video controls="controls" width="350">
12409   <source src="movie.mp4" type="video/mp4">
12410     <source src="movie.ogg" type="video/ogg">
12411       <p>Your browser does not support the video tag.</p>
12412 </video>
12413 #+end_src
12415 #+vindex: org-html-html5-elements
12416 When special blocks do not have a corresponding HTML5 element, the
12417 HTML exporter reverts to standard translation (see
12418 ~org-html-html5-elements~).  For example, =#+BEGIN_lederhosen= exports
12419 to ~<div class="lederhosen">~.
12421 Special blocks cannot have headlines.  For the HTML exporter to wrap
12422 the headline and its contents in ~<section>~ or ~<article>~ tags, set
12423 the =HTML_CONTAINER= property for the headline.
12425 *** HTML preamble and postamble
12426 :PROPERTIES:
12427 :DESCRIPTION: Inserting preamble and postamble.
12428 :END:
12429 #+vindex: org-html-preamble
12430 #+vindex: org-html-postamble
12431 #+vindex: org-html-preamble-format
12432 #+vindex: org-html-postamble-format
12433 #+vindex: org-html-validation-link
12434 #+vindex: org-export-creator-string
12435 #+vindex: org-export-time-stamp-file
12437 The HTML exporter has delineations for preamble and postamble.  The
12438 default value for ~org-html-preamble~ is ~t~, which makes the HTML
12439 exporter insert the preamble.  See the variable
12440 ~org-html-preamble-format~ for the format string.
12442 Set ~org-html-preamble~ to a string to override the default format
12443 string.  If the string is a function, the HTML exporter expects the
12444 function to return a string upon execution.  The HTML exporter inserts
12445 this string in the preamble.  The HTML exporter does not insert
12446 a preamble if ~org-html-preamble~ is set ~nil~.
12448 The default value for ~org-html-postamble~ is ~auto~, which makes the
12449 HTML exporter build a postamble from looking up author's name, email
12450 address, creator's name, and date.  Set ~org-html-postamble~ to ~t~ to
12451 insert the postamble in the format specified in the
12452 ~org-html-postamble-format~ variable.  The HTML exporter does not
12453 insert a postamble if ~org-html-postamble~ is set to ~nil~.
12455 *** Quoting HTML tags
12456 :PROPERTIES:
12457 :DESCRIPTION: Using direct HTML in Org files.
12458 :END:
12460 The HTML export back-end transforms =<= and =>= to =&lt;= and =&gt;=.
12461 To include raw HTML code in the Org file so the HTML export back-end
12462 can insert that HTML code in the output, use this inline syntax:
12463 =@@html:...@@=.  For example:
12465 : @@html:<b>@@bold text@@html:</b>@@
12467 #+cindex: @samp{HTML}, keyword
12468 #+cindex: @samp{BEGIN_EXPORT html}
12469 For larger raw HTML code blocks, use these HTML export code blocks:
12471 #+begin_example
12472 ,#+HTML: Literal HTML code for export
12474 ,#+BEGIN_EXPORT html
12475   All lines between these markers are exported literally
12476 ,#+END_EXPORT
12477 #+end_example
12479 *** Headlines in HTML export
12480 :PROPERTIES:
12481 :DESCRIPTION: Formatting headlines.
12482 :END:
12483 #+cindex: headlines, in HTML export
12485 Headlines are exported to =<h1>=, =<h2>=, etc.  Each headline gets the
12486 =id= attribute from =CUSTOM_ID= property, or a unique generated value,
12487 see [[*Internal Links]].
12489 #+vindex: org-html-self-link-headlines
12490 When ~org-html-self-link-headlines~ is set to a non-~nil~ value, the
12491 text of the headlines is also wrapped in =<a>= tags.  These tags have
12492 a =href= attribute making the headlines link to themselves.
12494 *** Links in HTML export
12495 :PROPERTIES:
12496 :DESCRIPTION: Inserting and formatting links.
12497 :END:
12498 #+cindex: links, in HTML export
12499 #+cindex: internal links, in HTML export
12500 #+cindex: external links, in HTML export
12502 The HTML export back-end transforms Org's internal links (see
12503 [[*Internal Links]]) to equivalent HTML links in the output.  The back-end
12504 similarly handles Org's automatic links created by radio targets (see
12505 [[*Radio Targets]]) similarly.  For Org links to external files, the
12506 back-end transforms the links to /relative/ paths.
12508 #+vindex: org-html-link-org-files-as-html
12509 For Org links to other =.org= files, the back-end automatically
12510 changes the file extension to =.html= and makes file paths relative.
12511 If the =.org= files have an equivalent =.html= version at the same
12512 location, then the converted links should work without any further
12513 manual intervention.  However, to disable this automatic path
12514 translation, set ~org-html-link-org-files-as-html~ to ~nil~.  When
12515 disabled, the HTML export back-end substitutes the ID-based links in
12516 the HTML output.  For more about linking files when publishing to
12517 a directory, see [[*Publishing links]].
12519 Org files can also have special directives to the HTML export
12520 back-end.  For example, by using =#+ATTR_HTML= lines to specify new
12521 format attributes to ~<a>~ or ~<img>~ tags.  This example shows
12522 changing the link's title and style:
12524 #+cindex: @samp{ATTR_HTML}, keyword
12525 #+begin_example
12526 ,#+ATTR_HTML: :title The Org mode homepage :style color:red;
12527 [[https://orgmode.org]]
12528 #+end_example
12530 *** Tables in HTML export
12531 :PROPERTIES:
12532 :DESCRIPTION: How to modify the formatting of tables.
12533 :END:
12534 #+cindex: tables, in HTML
12535 #+vindex: org-export-html-table-tag
12537 The HTML export back-end uses ~org-html-table-default-attributes~ when
12538 exporting Org tables to HTML.  By default, the exporter does not draw
12539 frames and cell borders.  To change for this for a table, use the
12540 following lines before the table in the Org file:
12542 #+cindex: @samp{CAPTION}, keyword
12543 #+cindex: @samp{ATTR_HTML}, keyword
12544 #+begin_example
12545 ,#+CAPTION: This is a table with lines around and between cells
12546 ,#+ATTR_HTML: border="2" rules="all" frame="border"
12547 #+end_example
12549 The HTML export back-end preserves column groupings in Org tables (see
12550 [[*Column Groups]]) when exporting to HTML.
12552 Additional options for customizing tables for HTML export.
12554 - ~org-html-table-align-individual-fields~ ::
12556   #+vindex: org-html-table-align-individual-fields
12557   Non-~nil~ attaches style attributes for alignment to each table
12558   field.
12560 - ~org-html-table-caption-above~ ::
12562   #+vindex: org-html-table-caption-above
12563   Non-~nil~ places caption string at the beginning of the table.
12565 - ~org-html-table-data-tags~ ::
12567   #+vindex: org-html-table-data-tags
12568   Opening and ending tags for table data fields.
12570 - ~org-html-table-default-attributes~ ::
12572   #+vindex: org-html-table-default-attributes
12573   Default attributes and values for table tags.
12575 - ~org-html-table-header-tags~ ::
12577   #+vindex: org-html-table-header-tags
12578   Opening and ending tags for table's header fields.
12580 - ~org-html-table-row-tags~ ::
12582   #+vindex: org-html-table-row-tags
12583   Opening and ending tags for table rows.
12585 - ~org-html-table-use-header-tags-for-first-column~ ::
12587   #+vindex: org-html-table-use-header-tags-for-first-column
12588   Non-~nil~ formats column one in tables with header tags.
12590 *** Images in HTML export
12591 :PROPERTIES:
12592 :DESCRIPTION: How to insert figures into HTML output.
12593 :END:
12594 #+cindex: images, inline in HTML
12595 #+cindex: inlining images in HTML
12597 The HTML export back-end has features to convert Org image links to
12598 HTML inline images and HTML clickable image links.
12600 #+vindex: org-html-inline-images
12601 When the link in the Org file has no description, the HTML export
12602 back-end by default in-lines that image.  For example:
12603 =[[file:myimg.jpg]]= is in-lined, while =[[file:myimg.jpg][the image]]= links to the text,
12604 =the image=.  For more details, see the variable
12605 ~org-html-inline-images~.
12607 On the other hand, if the description part of the Org link is itself
12608 another link, such as =file:= or =http:= URL pointing to an image, the
12609 HTML export back-end in-lines this image and links to the main image.
12610 This Org syntax enables the back-end to link low-resolution thumbnail
12611 to the high-resolution version of the image, as shown in this example:
12613 : [[file:highres.jpg][file:thumb.jpg]]
12615 To change attributes of in-lined images, use =#+ATTR_HTML= lines in
12616 the Org file.  This example shows realignment to right, and adds ~alt~
12617 and ~title~ attributes in support of text viewers and modern web
12618 accessibility standards.
12620 #+cindex: @samp{CAPTION}, keyword
12621 #+cindex: @samp{ATTR_HTML}, keyword
12622 #+begin_example
12623 ,#+CAPTION: A black cat stalking a spider
12624 ,#+ATTR_HTML: :alt cat/spider image :title Action! :align right
12625 [[./img/a.jpg]]
12626 #+end_example
12628 The HTML export back-end copies the =http= links from the Org file
12629 as-is.
12631 *** Math formatting in HTML export
12632 :PROPERTIES:
12633 :DESCRIPTION: Beautiful math also on the web.
12634 :END:
12635 #+cindex: MathJax
12636 #+cindex: dvipng
12637 #+cindex: dvisvgm
12638 #+cindex: ImageMagick
12640 #+vindex: org-html-mathjax-options~
12641 LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
12642 different ways on HTML pages.  The default is to use the [[http://www.mathjax.org][MathJax]],
12643 which should work out of the box with Org[fn:128][fn:129].  Some MathJax
12644 display options can be configured via ~org-html-mathjax-options~, or
12645 in the buffer.  For example, with the following settings,
12647 #+begin_example
12648 ,#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
12649 ,#+HTML_MATHJAX: cancel.js noErrors.js
12650 #+end_example
12652 #+texinfo: @noindent
12653 equation labels are displayed on the left margin and equations are
12654 five em from the left margin.  In addition, it loads the two MathJax
12655 extensions =cancel.js= and =noErrors.js=[fn:130].
12657 #+vindex: org-html-mathjax-template
12658 See the docstring of ~org-html-mathjax-options~ for all supported
12659 variables.  The MathJax template can be configure via
12660 ~org-html-mathjax-template~.
12662 If you prefer, you can also request that LaTeX fragments are processed
12663 into small images that will be inserted into the browser page.  Before
12664 the availability of MathJax, this was the default method for Org
12665 files.  This method requires that the dvipng program, dvisvgm or
12666 ImageMagick suite is available on your system.  You can still get this
12667 processing with
12669 : #+OPTIONS: tex:dvipng
12671 : #+OPTIONS: tex:dvisvgm
12673 #+texinfo: @noindent
12676 : #+OPTIONS: tex:imagemagick
12678 *** Text areas in HTML export
12679 :PROPERTIES:
12680 :DESCRIPTION: An alternate way to show an example.
12681 :END:
12683 #+cindex: text areas, in HTML
12684 Before Org mode's Babel, one popular approach to publishing code in
12685 HTML was by using =:textarea=.  The advantage of this approach was
12686 that copying and pasting was built into browsers with simple
12687 JavaScript commands.  Even editing before pasting was made simple.
12689 The HTML export back-end can create such text areas.  It requires an
12690 =#+ATTR_HTML= line as shown in the example below with the =:textarea=
12691 option.  This must be followed by either an example or a source code
12692 block.  Other Org block types do not honor the =:textarea= option.
12694 By default, the HTML export back-end creates a text area 80 characters
12695 wide and height just enough to fit the content.  Override these
12696 defaults with =:width= and =:height= options on the =#+ATTR_HTML=
12697 line.
12699 #+begin_example
12700 ,#+ATTR_HTML: :textarea t :width 40
12701 ,#+BEGIN_EXAMPLE
12702   (defun org-xor (a b)
12703      "Exclusive or."
12704      (if a (not b) b))
12705 ,#+END_EXAMPLE
12706 #+end_example
12708 *** CSS support
12709 :PROPERTIES:
12710 :DESCRIPTION: Changing the appearance of the output.
12711 :END:
12712 #+cindex: CSS, for HTML export
12713 #+cindex: HTML export, CSS
12715 #+vindex: org-export-html-todo-kwd-class-prefix
12716 #+vindex: org-export-html-tag-class-prefix
12717 You can modify the CSS style definitions for the exported file.  The
12718 HTML exporter assigns the following special CSS classes[fn:131] to
12719 appropriate parts of the document---your style specifications may
12720 change these, in addition to any of the standard classes like for
12721 headlines, tables, etc.
12723 | ~p.author~           | author information, including email                    |
12724 | ~p.date~             | publishing date                                        |
12725 | ~p.creator~          | creator info, about org mode version                   |
12726 | ~.title~             | document title                                         |
12727 | ~.subtitle~          | document subtitle                                      |
12728 | ~.todo~              | TODO keywords, all not-done states                     |
12729 | ~.done~              | the DONE keywords, all states that count as done       |
12730 | ~.WAITING~           | each TODO keyword also uses a class named after itself |
12731 | ~.timestamp~         | timestamp                                              |
12732 | ~.timestamp-kwd~     | keyword associated with a timestamp, like =SCHEDULED=  |
12733 | ~.timestamp-wrapper~ | span around keyword plus timestamp                     |
12734 | ~.tag~               | tag in a headline                                      |
12735 | ~._HOME~             | each tag uses itself as a class, "@" replaced by "_"   |
12736 | ~.target~            | target for links                                       |
12737 | ~.linenr~            | the line number in a code example                      |
12738 | ~.code-highlighted~  | for highlighting referenced code lines                 |
12739 | ~div.outline-N~      | div for outline level N (headline plus text)           |
12740 | ~div.outline-text-N~ | extra div for text at outline level N                  |
12741 | ~.section-number-N~  | section number in headlines, different for each level  |
12742 | ~.figure-number~     | label like "Figure 1:"                                 |
12743 | ~.table-number~      | label like "Table 1:"                                  |
12744 | ~.listing-number~    | label like "Listing 1:"                                |
12745 | ~div.figure~         | how to format an in-lined image                        |
12746 | ~pre.src~            | formatted source code                                  |
12747 | ~pre.example~        | normal example                                         |
12748 | ~p.verse~            | verse paragraph                                        |
12749 | ~div.footnotes~      | footnote section headline                              |
12750 | ~p.footnote~         | footnote definition paragraph, containing a footnote   |
12751 | ~.footref~           | a footnote reference number (always a <sup>)           |
12752 | ~.footnum~           | footnote number in footnote definition (always <sup>)  |
12753 | ~.org-svg~           | default class for a linked =.svg= image                |
12755 #+vindex: org-html-style-default
12756 #+vindex: org-html-head
12757 #+vindex: org-html-head-extra
12758 #+cindex: @samp{HTML_INCLUDE_STYLE}, keyword
12759 The HTML export back-end includes a compact default style in each
12760 exported HTML file.  To override the default style with another style,
12761 use these keywords in the Org file.  They will replace the global
12762 defaults the HTML exporter uses.
12764 #+cindex: @samp{HTML_HEAD}, keyword
12765 #+cindex: @samp{HTML_HEAD_EXTRA}, keyword
12766 #+begin_example
12767 ,#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
12768 ,#+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
12769 #+end_example
12771 #+vindex: org-html-head-include-default-style
12772 To just turn off the default style, customize
12773 ~org-html-head-include-default-style~ variable, or use this option
12774 line in the Org file.
12776 #+cindex: @samp{html-style}, @samp{OPTIONS} item
12777 : #+OPTIONS: html-style:nil
12779 For longer style definitions, either use several =HTML_HEAD= and
12780 =HTML_HEAD_EXTRA= keywords, or use ~<style> ... </style>~ blocks
12781 around them.  Both of these approaches can avoid referring to an
12782 external file.
12784 #+cindex: @samp{HTML_CONTAINER_CLASS}, property
12785 #+cindex: @samp{HTML_HEADLINE_CLASS}, property
12786 In order to add styles to a sub-tree, use the =HTML_CONTAINER_CLASS=
12787 property to assign a class to the tree.  In order to specify CSS
12788 styles for a particular headline, you can use the ID specified in
12789 a =CUSTOM_ID= property.  You can also assign a specific class to
12790 a headline with the =HTML_HEADLINE_CLASS= property.
12792 Never change the ~org-html-style-default~ constant.  Instead use other
12793 simpler ways of customizing as described above.
12795 *** JavaScript supported display of web pages
12796 :PROPERTIES:
12797 :DESCRIPTION: Info and folding in a web browser.
12798 :ALT_TITLE: JavaScript support
12799 :END:
12801 Sebastian Rose has written a JavaScript program especially designed to
12802 enhance the web viewing experience of HTML files created with Org.
12803 This program enhances large files in two different ways of viewing.
12804 One is an /Info/-like mode where each section is displayed separately
12805 and navigation can be done with the {{{kbd(n)}}} and {{{kbd(p)}}}
12806 keys, and some other keys as well, press {{{kbd(?)}}} for an overview
12807 of the available keys.  The second one has a /folding/ view, much like
12808 Org provides inside Emacs.  The script is available at
12809 https://orgmode.org/org-info.js and the documentation at
12810 https://orgmode.org/worg/code/org-info-js/.  The script is hosted on
12811 https://orgmode.org, but for reliability, prefer installing it on your
12812 own web server.
12814 To use this program, just add this line to the Org file:
12816 #+cindex: @samp{INFOJS_OPT}, keyword
12817 : #+INFOJS_OPT: view:info toc:nil
12819 #+texinfo: @noindent
12820 The HTML header now has the code needed to automatically invoke the
12821 script.  For setting options, use the syntax from the above line for
12822 options described below:
12824 - =path:= ::
12826   The path to the script.  The default is to grab the script from
12827   [[https://orgmode.org/org-info.js]], but you might want to have a local
12828   copy and use a path like =../scripts/org-info.js=.
12830 - =view:= ::
12832   Initial view when the website is first shown.  Possible values are:
12834   | =info=     | Info-like interface with one section per page          |
12835   | =overview= | Folding interface, initially showing only top-level    |
12836   | =content=  | Folding interface, starting with all headlines visible |
12837   | =showall=  | Folding interface, all headlines and text visible      |
12839 - =sdepth:= ::
12841   Maximum headline level still considered as an independent section
12842   for info and folding modes.  The default is taken from
12843   ~org-export-headline-levels~, i.e., the =H= switch in =OPTIONS=.  If
12844   this is smaller than in ~org-export-headline-levels~, each
12845   info/folding section can still contain child headlines.
12847 - =toc:= ::
12849   Should the table of contents /initially/ be visible?  Even when
12850   =nil=, you can always get to the "toc" with {{{kbd(i)}}}.
12852 - =tdepth:= ::
12854   The depth of the table of contents.  The defaults are taken from the
12855   variables ~org-export-headline-levels~ and ~org-export-with-toc~.
12857 - =ftoc:= ::
12859   Does the CSS of the page specify a fixed position for the "toc"?  If
12860   yes, the toc is displayed as a section.
12862 - =ltoc:= ::
12864   Should there be short contents (children) in each section?  Make
12865   this =above= if the section should be above initial text.
12867 - =mouse:= ::
12869   Headings are highlighted when the mouse is over them.  Should be
12870   =underline= (default) or a background color like =#cccccc=.
12872 - =buttons:= ::
12874   Should view-toggle buttons be everywhere?  When =nil= (the default),
12875   only one such button is present.
12877 #+vindex: org-infojs-options
12878 #+vindex: org-export-html-use-infojs
12879 You can choose default values for these options by customizing the
12880 variable ~org-infojs-options~.  If you always want to apply the script
12881 to your pages, configure the variable ~org-export-html-use-infojs~.
12883 ** LaTeX Export
12884 :PROPERTIES:
12885 :DESCRIPTION: Exporting to @LaTeX{} and processing to PDF.
12886 :END:
12887 #+cindex: @LaTeX{} export
12888 #+cindex: PDF export
12890 The LaTeX export back-end can handle complex documents, incorporate
12891 standard or custom LaTeX document classes, generate documents using
12892 alternate LaTeX engines, and produce fully linked PDF files with
12893 indexes, bibliographies, and tables of contents, destined for
12894 interactive online viewing or high-quality print publication.
12896 While the details are covered in-depth in this section, here are some
12897 quick references to variables for the impatient: for engines, see
12898 ~org-latex-compiler~; for build sequences, see
12899 ~org-latex-pdf-process~; for packages, see
12900 ~org-latex-default-packages-alist~ and ~org-latex-packages-alist~.
12902 An important note about the LaTeX export back-end: it is sensitive to
12903 blank lines in the Org document.  That's because LaTeX itself depends
12904 on blank lines to tell apart syntactical elements, such as paragraphs.
12906 *** LaTeX/PDF export commands
12907 :PROPERTIES:
12908 :DESCRIPTION: For producing @LaTeX{} and PDF documents.
12909 :END:
12911 - {{{kbd(C-c C-e l l)}}} (~org-latex-export-to-latex~) ::
12913   #+kindex: C-c C-e l l
12914   #+findex: org-latex-export-to-latex~
12915   Export to a LaTeX file with a =.tex= extension.  For =myfile.org=,
12916   Org exports to =myfile.tex=, overwriting without warning.
12918 - {{{kbd(C-c C-e l L)}}} (~org-latex-export-as-latex~) ::
12920   #+kindex: C-c C-e l L
12921   #+findex: org-latex-export-as-latex
12922   Export to a temporary buffer.  Do not create a file.
12924 - {{{kbd(C-c C-e l p)}}} (~org-latex-export-to-pdf~) ::
12926   #+kindex: C-c C-e l p
12927   #+findex: org-latex-export-to-pdf
12928   Export as LaTeX file and convert it to PDF file.
12930 - {{{kbd(C-c C-e l o)}}} ::
12932   #+kindex: C-c C-e l o
12933   Export as LaTeX file and convert it to PDF, then open the PDF using
12934   the default viewer.
12936 - {{{kbd(M-x org-export-region-as-latex)}}} ::
12938   Convert the region to LaTeX under the assumption that it was in Org
12939   mode syntax before.  This is a global command that can be invoked in
12940   any buffer.
12942 #+vindex: org-latex-compiler
12943 #+vindex: org-latex-bibtex-compiler
12944 #+vindex: org-latex-default-packages-alist
12945 #+cindex: pdflatex
12946 #+cindex: xelatex
12947 #+cindex: lualatex
12948 #+cindex: @samp{LATEX_COMPILER}, keyword
12949 The LaTeX export back-end can use any of these LaTeX engines:
12950 =pdflatex=, =xelatex=, and =lualatex=.  These engines compile LaTeX
12951 files with different compilers, packages, and output options.  The
12952 LaTeX export back-end finds the compiler version to use from
12953 ~org-latex-compiler~ variable or the =#+LATEX_COMPILER= keyword in the
12954 Org file.  See the docstring for the
12955 ~org-latex-default-packages-alist~ for loading packages with certain
12956 compilers.  Also see ~org-latex-bibtex-compiler~ to set the
12957 bibliography compiler[fn:132].
12959 *** LaTeX specific export settings
12960 :PROPERTIES:
12961 :DESCRIPTION: Unique to this @LaTeX{} back-end.
12962 :END:
12964 The LaTeX export back-end has several additional keywords for
12965 customizing LaTeX output.  Setting these keywords works similar to the
12966 general options (see [[*Export Settings]]).
12968 #+attr_texinfo: :sep ,
12969 - =DESCRIPTION= ::
12970   #+cindex: @samp{DESCRIPTION}, keyword
12971   #+vindex: org-latex-hyperref-template
12972   #+vindex: org-latex-title-command
12973   The document's description.  The description along with author name,
12974   keywords, and related file metadata are inserted in the output file
12975   by the hyperref package.  See ~org-latex-hyperref-template~ for
12976   customizing metadata items.  See ~org-latex-title-command~ for
12977   typesetting description into the document's front matter.  Use
12978   multiple =DESCRIPTION= keywords for long descriptions.
12980 - =LANGUAGE= ::
12981   #+cindex: @samp{LANGUAGE}, keyword
12982   #+vindex: org-latex-package-alist
12983   In order to be effective, the =babel= or =polyglossia=
12984   packages---according to the LaTeX compiler used---must be loaded
12985   with the appropriate language as argument.  This can be accomplished
12986   by modifying the =org-latex-package-alist= variable, e.g., with the
12987   following snippet:
12989   #+begin_src emacs-lisp
12990   (add-to-list org-latex-package-alist
12991                '("AUTO" "babel" t ("pdflatex")))
12992   (add-to-list org-latex-package-alist
12993                '("AUTO" "polyglossia" t ("xelatex" "lualatex")))
12994   #+end_src
12996 - =LATEX_CLASS= ::
12998   #+cindex: @samp{LATEX_CLASS}, keyword
12999   #+vindex: org-latex-default-class
13000   #+vindex: org-latex-classes
13001   This is LaTeX document class, such as /article/, /report/, /book/,
13002   and so on, which contain predefined preamble and headline level
13003   mapping that the LaTeX export back-end needs.  The back-end reads
13004   the default class name from the ~org-latex-default-class~ variable.
13005   Org has /article/ as the default class.  A valid default class must
13006   be an element of ~org-latex-classes~.
13008 - =LATEX_CLASS_OPTIONS= ::
13010   #+cindex: @samp{LATEX_CLASS_OPTIONS}, keyword
13011   Options the LaTeX export back-end uses when calling the LaTeX
13012   document class.
13014 - =LATEX_COMPILER= ::
13016   #+cindex: @samp{LATEX_COMPILER}, keyword
13017   #+vindex: org-latex-compiler
13018   The compiler, such as =pdflatex=, =xelatex=, =lualatex=, for
13019   producing the PDF.  See ~org-latex-compiler~.
13021 - =LATEX_HEADER=, =LATEX_HEADER_EXTRA= ::
13023   #+cindex: @samp{LATEX_HEADER}, keyword
13024   #+cindex: @samp{LATEX_HEADER_EXTRA}, keyword
13025   #+vindex: org-latex-classes
13026   Arbitrary lines to add to the document's preamble, before the
13027   hyperref settings.  See ~org-latex-classes~ for adjusting the
13028   structure and order of the LaTeX headers.
13030 - =KEYWORDS= ::
13032   #+cindex: @samp{KEYWORDS}, keyword
13033   #+vindex: org-latex-hyperref-template
13034   #+vindex: org-latex-title-command
13035   The keywords for the document.  The description along with author
13036   name, keywords, and related file metadata are inserted in the output
13037   file by the hyperref package.  See ~org-latex-hyperref-template~ for
13038   customizing metadata items.  See ~org-latex-title-command~ for
13039   typesetting description into the document's front matter.  Use
13040   multiple =KEYWORDS= lines if necessary.
13042 - =SUBTITLE= ::
13044   #+cindex: @samp{SUBTITLE}, keyword
13045   #+vindex: org-latex-subtitle-separate
13046   #+vindex: org-latex-subtitle-format
13047   The document's subtitle.  It is typeset as per
13048   ~org-latex-subtitle-format~.  If ~org-latex-subtitle-separate~ is
13049   non-~nil~, it is typed as part of the ~\title~ macro.  See
13050   ~org-latex-hyperref-template~ for customizing metadata items.  See
13051   ~org-latex-title-command~ for typesetting description into the
13052   document's front matter.
13054 The following sections have further details.
13056 *** LaTeX header and sectioning structure
13057 :PROPERTIES:
13058 :DESCRIPTION: Setting up the export file structure.
13059 :ALT_TITLE: LaTeX header and sectioning
13060 :END:
13061 #+cindex: @LaTeX{} class
13062 #+cindex: @LaTeX{} sectioning structure
13063 #+cindex: @LaTeX{} header
13064 #+cindex: header, for @LaTeX{} files
13065 #+cindex: sectioning structure, for @LaTeX{} export
13067 The LaTeX export back-end converts the first three of Org's outline
13068 levels into LaTeX headlines.  The remaining Org levels are exported as
13069 lists.  To change this globally for the cut-off point between levels
13070 and lists, (see [[*Export Settings]]).
13072 By default, the LaTeX export back-end uses the /article/ class.
13074 #+vindex: org-latex-default-class
13075 #+vindex: org-latex-classes
13076 #+vindex: org-latex-default-packages-alist
13077 #+vindex: org-latex-packages-alist
13078 To change the default class globally, edit ~org-latex-default-class~.
13079 To change the default class locally in an Org file, add option lines
13080 =#+LATEX_CLASS: myclass=.  To change the default class for just a part
13081 of the Org file, set a sub-tree property, =EXPORT_LATEX_CLASS=.  The
13082 class name entered here must be valid member of ~org-latex-classes~.
13083 This variable defines a header template for each class into which the
13084 exporter splices the values of ~org-latex-default-packages-alist~ and
13085 ~org-latex-packages-alist~.  Use the same three variables to define
13086 custom sectioning or custom classes.
13088 #+cindex: @samp{LATEX_CLASS}, keyword
13089 #+cindex: @samp{LATEX_CLASS_OPTIONS}, keyword
13090 #+cindex: @samp{EXPORT_LATEX_CLASS}, property
13091 #+cindex: @samp{EXPORT_LATEX_CLASS_OPTIONS}, property
13092 The LaTeX export back-end sends the =LATEX_CLASS_OPTIONS= keyword and
13093 =EXPORT_LATEX_CLASS_OPTIONS= property as options to the LaTeX
13094 ~\documentclass~ macro.  The options and the syntax for specifying
13095 them, including enclosing them in square brackets, follow LaTeX
13096 conventions.
13098 : #+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside,twocolumn]
13100 #+cindex: @samp{LATEX_HEADER}, keyword
13101 #+cindex: @samp{LATEX_HEADER_EXTRA}, keyword
13102 The LaTeX export back-end appends values from =LATEX_HEADER= and
13103 =LATEX_HEADER_EXTRA= keywords to the LaTeX header.  The docstring for
13104 ~org-latex-classes~ explains in more detail.  Also note that LaTeX
13105 export back-end does not append =LATEX_HEADER_EXTRA= to the header
13106 when previewing LaTeX snippets (see [[*Previewing LaTeX fragments]]).
13108 A sample Org file with the above headers:
13110 #+begin_example
13111 ,#+LATEX_CLASS: article
13112 ,#+LATEX_CLASS_OPTIONS: [a4paper]
13113 ,#+LATEX_HEADER: \usepackage{xyz}
13115 ,* Headline 1
13116   some text
13117 ,* Headline 2
13118   some more text
13119 #+end_example
13121 *** Quoting LaTeX code
13122 :PROPERTIES:
13123 :DESCRIPTION: Incorporating literal @LaTeX{} code.
13124 :END:
13126 The LaTeX export back-end can insert any arbitrary LaTeX code, see
13127 [[*Embedded LaTeX]].  There are three ways to embed such code in the Org
13128 file and they all use different quoting syntax.
13130 #+cindex: inline, in @LaTeX{} export
13131 Inserting in-line quoted with @ symbols:
13133 : Code embedded in-line @@latex:any arbitrary LaTeX code@@ in a paragraph.
13135 #+cindex: @samp{LATEX}, keyword
13136 Inserting as one or more keyword lines in the Org file:
13138 : #+LATEX: any arbitrary LaTeX code
13140 #+cindex: @samp{BEGIN_EXPORT latex}
13141 Inserting as an export block in the Org file, where the back-end
13142 exports any code between begin and end markers:
13144 #+begin_example
13145 ,#+BEGIN_EXPORT latex
13146   any arbitrary LaTeX code
13147 ,#+END_EXPORT
13148 #+end_example
13150 *** Tables in LaTeX export
13151 :PROPERTIES:
13152 :DESCRIPTION: Options for exporting tables to @LaTeX{}.
13153 :END:
13154 #+cindex: tables, in @LaTeX{} export
13156 The LaTeX export back-end can pass several LaTeX attributes for table
13157 contents and layout.  Besides specifying a label (see [[*Internal Links]])
13158 and a caption (see [[*Captions]]), the other valid LaTeX attributes
13159 include:
13161 #+attr_texinfo: :sep ,
13162 - =:mode= ::
13164   #+vindex: org-latex-default-table-mode
13165   The LaTeX export back-end wraps the table differently depending on
13166   the mode for accurate rendering of math symbols.  Mode is either
13167   =table=, =math=, =inline-math= or =verbatim=.
13169   For =math= or =inline-math= mode, LaTeX export back-end wraps the
13170   table in a math environment, but every cell in it is exported as-is.
13171   The LaTeX export back-end determines the default mode from
13172   ~org-latex-default-table-mode~.  The LaTeX export back-end merges
13173   contiguous tables in the same mode into a single environment.
13175 - =:environment= ::
13177   #+vindex: org-latex-default-table-environment
13178   Set the default LaTeX table environment for the LaTeX export
13179   back-end to use when exporting Org tables.  Common LaTeX table
13180   environments are provided by these packages: tabularx, longtable,
13181   array, tabu, and bmatrix.  For packages, such as tabularx and tabu,
13182   or any newer replacements, include them in the
13183   ~org-latex-packages-alist~ variable so the LaTeX export back-end can
13184   insert the appropriate load package headers in the converted LaTeX
13185   file.  Look in the docstring for the ~org-latex-packages-alist~
13186   variable for configuring these packages for LaTeX snippet previews,
13187   if any.
13189 - =:caption= ::
13191   Use =CAPTION= keyword to set a simple caption for a table (see
13192   [[*Captions]]).  For custom captions, use =:caption= attribute, which
13193   accepts raw LaTeX code.  =:caption= value overrides =CAPTION= value.
13195 - =:float=, =:placement= ::
13197   The table environments by default are not floats in LaTeX.  To make
13198   them floating objects use =:float= with one of the following
13199   options: =sideways=, =multicolumn=, =t=, and =nil=.
13201   LaTeX floats can also have additional layout =:placement=
13202   attributes.  These are the usual =[h t b p ! H]= permissions
13203   specified in square brackets.  Note that for =:float sideways=
13204   tables, the LaTeX export back-end ignores =:placement= attributes.
13206 - =:align=, =:font=, =:width= ::
13208   The LaTeX export back-end uses these attributes for regular tables
13209   to set their alignments, fonts, and widths.
13211 - =:spread= ::
13213   When =:spread= is non-~nil~, the LaTeX export back-end spreads or
13214   shrinks the table by the =:width= for tabu and longtabu
13215   environments.  =:spread= has no effect if =:width= is not set.
13217 - =:booktabs=, =:center=, =:rmlines= ::
13219   #+vindex: org-latex-tables-booktabs
13220   #+vindex: org-latex-tables-centered
13221   All three commands are toggles.  =:booktabs= brings in modern
13222   typesetting enhancements to regular tables.  The booktabs package
13223   has to be loaded through ~org-latex-packages-alist~.  =:center= is
13224   for centering the table.  =:rmlines= removes all but the very first
13225   horizontal line made of ASCII characters from "table.el" tables
13226   only.
13228 - =:math-prefix=, =:math-suffix=, =:math-arguments= ::
13230   The LaTeX export back-end inserts =:math-prefix= string value in
13231   a math environment before the table.  The LaTeX export back-end
13232   inserts =:math-suffix= string value in a math environment after the
13233   table.  The LaTeX export back-end inserts =:math-arguments= string
13234   value between the macro name and the table's contents.
13235   =:math-arguments= comes in use for matrix macros that require more
13236   than one argument, such as =qbordermatrix=.
13238 LaTeX table attributes help formatting tables for a wide range of
13239 situations, such as matrix product or spanning multiple pages:
13241 #+begin_example
13242 ,#+ATTR_LATEX: :environment longtable :align l|lp{3cm}r|l
13243 | ... | ... |
13244 | ... | ... |
13246 ,#+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
13247 | a | b |
13248 | c | d |
13249 ,#+ATTR_LATEX: :mode math :environment bmatrix
13250 | 1 | 2 |
13251 | 3 | 4 |
13252 #+end_example
13254 Set the caption with the LaTeX command
13255 =\bicaption{HeadingA}{HeadingB}=:
13257 #+begin_example
13258 ,#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
13259 | ... | ... |
13260 | ... | ... |
13261 #+end_example
13263 *** Images in LaTeX export
13264 :PROPERTIES:
13265 :DESCRIPTION: How to insert figures into @LaTeX{} output.
13266 :END:
13267 #+cindex: images, inline in LaTeX
13268 #+cindex: inlining images in LaTeX
13269 #+cindex: @samp{ATTR_LATEX}, keyword
13271 The LaTeX export back-end processes image links in Org files that do
13272 not have descriptions, such as these links =[[file:img.jpg]]= or
13273 =[[./img.jpg]]=, as direct image insertions in the final PDF output.  In
13274 the PDF, they are no longer links but actual images embedded on the
13275 page.  The LaTeX export back-end uses =\includegraphics= macro to
13276 insert the image.  But for TikZ (http://sourceforge.net/projects/pgf/)
13277 images, the back-end uses an ~\input~ macro wrapped within
13278 a ~tikzpicture~ environment.
13280 For specifying image =:width=, =:height=, and other =:options=, use
13281 this syntax:
13283 #+begin_example
13284 ,#+ATTR_LATEX: :width 5cm :options angle=90
13285 [[./img/sed-hr4049.pdf]]
13286 #+end_example
13288 For custom commands for captions, use the =:caption= attribute.  It
13289 overrides the default =#+CAPTION= value:
13291 #+begin_example
13292 ,#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
13293 [[./img/sed-hr4049.pdf]]
13294 #+end_example
13296 When captions follow the method as described in [[*Captions]], the LaTeX
13297 export back-end wraps the picture in a floating =figure= environment.
13298 To float an image without specifying a caption, set the =:float=
13299 attribute to one of the following:
13301 - =t= ::
13303   For a standard =figure= environment; used by default whenever an
13304   image has a caption.
13306 - =multicolumn= ::
13308   To span the image across multiple columns of a page; the back-end
13309   wraps the image in a =figure*= environment.
13311 - =wrap= ::
13313   For text to flow around the image on the right; the figure occupies
13314   the left half of the page.
13316 - =sideways= ::
13318   For a new page with the image sideways, rotated ninety degrees, in
13319   a =sidewaysfigure= environment; overrides =:placement= setting.
13321 - =nil= ::
13323   To avoid a =:float= even if using a caption.
13325 Use the =placement= attribute to modify a floating environment's
13326 placement.
13328 #+begin_example
13329 ,#+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement {r}{0.4\textwidth}
13330 [[./img/hst.png]]
13331 #+end_example
13333 #+vindex: org-latex-images-centered
13334 #+cindex: center image in LaTeX export
13335 #+cindex: image, centering in LaTeX export
13336 The LaTeX export back-end centers all images by default.  Setting
13337 =:center= to =nil= disables centering.  To disable centering globally,
13338 set ~org-latex-images-centered~ to =t=.
13340 Set the =:comment-include= attribute to non-~nil~ value for the LaTeX
13341 export back-end to comment out the =\includegraphics= macro.
13343 *** Plain lists in LaTeX export
13344 :PROPERTIES:
13345 :DESCRIPTION: Attributes specific to lists.
13346 :END:
13348 #+cindex: plain lists, in @LaTeX{} export
13349 #+cindex: @samp{ATTR_LATEX}, keyword
13350 The LaTeX export back-end accepts the =environment= and =options=
13351 attributes for plain lists.  Both attributes work together for
13352 customizing lists, as shown in the examples:
13354 #+begin_example
13355 ,#+LATEX_HEADER: \usepackage[inline]{enumitem}
13356 Some ways to say "Hello":
13357 ,#+ATTR_LATEX: :environment itemize*
13358 ,#+ATTR_LATEX: :options [label={}, itemjoin={,}, itemjoin*={, and}]
13359 - Hola
13360 - Bonjour
13361 - Guten Tag.
13362 #+end_example
13364 Since LaTeX supports only four levels of nesting for lists, use an
13365 external package, such as =enumitem= in LaTeX, for levels deeper than
13366 four:
13368 #+begin_example
13369 ,#+LATEX_HEADER: \usepackage{enumitem}
13370 ,#+LATEX_HEADER: \renewlist{itemize}{itemize}{9}
13371 ,#+LATEX_HEADER: \setlist[itemize]{label=$\circ$}
13372 - One
13373   - Two
13374     - Three
13375       - Four
13376         - Five
13377 #+end_example
13379 *** Source blocks in LaTeX export
13380 :PROPERTIES:
13381 :DESCRIPTION: Attributes specific to source code blocks.
13382 :END:
13383 #+cindex: source blocks, in @LaTeX{} export
13384 #+cindex: @samp{ATTR_LATEX}, keyword
13386 The LaTeX export back-end can make source code blocks into floating
13387 objects through the attributes =:float= and =:options=.  For =:float=:
13389 - =t= ::
13391   Makes a source block float; by default floats any source block with
13392   a caption.
13394 - =multicolumn= ::
13396   Spans the source block across multiple columns of a page.
13398 - =nil= ::
13400   Avoids a =:float= even if using a caption; useful for source code
13401   blocks that may not fit on a page.
13403 #+begin_example
13404 ,#+ATTR_LATEX: :float nil
13405 ,#+BEGIN_SRC emacs-lisp
13406   Lisp code that may not fit in a single page.
13407 ,#+END_SRC
13408 #+end_example
13410 #+vindex: org-latex-listings-options
13411 #+vindex: org-latex-minted-options
13412 The LaTeX export back-end passes string values in =:options= to LaTeX
13413 packages for customization of that specific source block.  In the
13414 example below, the =:options= are set for Minted.  Minted is a source
13415 code highlighting LaTeX package with many configurable options.
13417 #+begin_example
13418 ,#+ATTR_LATEX: :options commentstyle=\bfseries
13419 ,#+BEGIN_SRC emacs-lisp
13420   (defun Fib (n)
13421     (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
13422 ,#+END_SRC
13423 #+end_example
13425 To apply similar configuration options for all source blocks in
13426 a file, use the ~org-latex-listings-options~ and
13427 ~org-latex-minted-options~ variables.
13429 *** Example blocks in LaTeX export
13430 :PROPERTIES:
13431 :DESCRIPTION: Attributes specific to example blocks.
13432 :END:
13433 #+cindex: example blocks, in @LaTeX{} export
13434 #+cindex: verbatim blocks, in @LaTeX{} export
13435 #+cindex: @samp{ATTR_LATEX}, keyword
13437 The LaTeX export back-end wraps the contents of example blocks in
13438 a =verbatim= environment.  To change this behavior to use another
13439 environment globally, specify an appropriate export filter (see
13440 [[*Advanced Export Configuration]]).  To change this behavior to use
13441 another environment for each block, use the =:environment= parameter
13442 to specify a custom environment.
13444 #+begin_example
13445 ,#+ATTR_LATEX: :environment myverbatim
13446 ,#+BEGIN_EXAMPLE
13447   This sentence is false.
13448 ,#+END_EXAMPLE
13449 #+end_example
13451 *** Special blocks in LaTeX export
13452 :PROPERTIES:
13453 :DESCRIPTION: Attributes specific to special blocks.
13454 :END:
13456 #+cindex: special blocks, in @LaTeX{} export
13457 #+cindex: abstract, in @LaTeX{} export
13458 #+cindex: proof, in @LaTeX{} export
13459 #+cindex: @samp{ATTR_LATEX}, keyword
13461 For other special blocks in the Org file, the LaTeX export back-end
13462 makes a special environment of the same name.  The back-end also takes
13463 =:options=, if any, and appends as-is to that environment's opening
13464 string.  For example:
13466 #+begin_example
13467 ,#+BEGIN_abstract
13468   We demonstrate how to solve the Syracuse problem.
13469 ,#+END_abstract
13471 ,#+ATTR_LATEX: :options [Proof of important theorem]
13472 ,#+BEGIN_proof
13473   ...
13474   Therefore, any even number greater than 2 is the sum of two primes.
13475 ,#+END_proof
13476 #+end_example
13478 #+texinfo: @noindent
13479 exports to
13481 #+begin_example
13482 \begin{abstract}
13483   We demonstrate how to solve the Syracuse problem.
13484 \end{abstract}
13486 \begin{proof}[Proof of important theorem]
13487   ...
13488   Therefore, any even number greater than 2 is the sum of two primes.
13489 \end{proof}
13490 #+end_example
13492 If you need to insert a specific caption command, use =:caption=
13493 attribute.  It overrides standard =CAPTION= value, if any.  For
13494 example:
13496 #+begin_example
13497 ,#+ATTR_LATEX: :caption \MyCaption{HeadingA}
13498 ,#+BEGIN_proof
13499   ...
13500 ,#+END_proof
13501 #+end_example
13503 *** Horizontal rules in LaTeX export
13504 :PROPERTIES:
13505 :DESCRIPTION: Attributes specific to horizontal rules.
13506 :END:
13507 #+cindex: horizontal rules, in @LaTeX{} export
13508 #+cindex: @samp{ATTR_LATEX}, keyword
13510 The LaTeX export back-end converts horizontal rules by the specified
13511 =:width= and =:thickness= attributes.  For example:
13513 #+begin_example
13514 ,#+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt
13515 -----
13516 #+end_example
13518 ** Markdown Export
13519 :PROPERTIES:
13520 :DESCRIPTION: Exporting to Markdown.
13521 :END:
13522 #+cindex: Markdown export
13524 The Markdown export back-end, "md", converts an Org file to Markdown
13525 format, as defined at http://daringfireball.net/projects/markdown/.
13527 Since it is built on top of the HTML back-end (see [[*HTML Export]]), it
13528 converts every Org construct not defined in Markdown syntax, such as
13529 tables, to HTML.
13531 *** Markdown export commands
13532 :PROPERTIES:
13533 :UNNUMBERED: notoc
13534 :END:
13536 - {{{kbd(C-c C-e m m)}}} (~org-md-export-to-markdown~) ::
13538   #+kindex: C-c C-c m m
13539   #+findex: org-md-export-to-markdown
13540   Export to a text file with Markdown syntax.  For =myfile.org=, Org
13541   exports to =myfile.md=, overwritten without warning.
13543 - {{{kbd(C-c C-e m M)}}} (~org-md-export-as-markdown~) ::
13545   #+kindex: C-c C-c m M
13546   #+findex: org-md-export-as-markdown
13547   Export to a temporary buffer.  Does not create a file.
13549 - {{{kbd(C-c C-e m o)}}} ::
13551   #+kindex: C-c C-e m o
13552   Export as a text file with Markdown syntax, then open it.
13554 *** Header and sectioning structure
13555 :PROPERTIES:
13556 :UNNUMBERED: notoc
13557 :END:
13559 #+vindex: org-md-headline-style
13560 Based on ~org-md-headline-style~, Markdown export can generate
13561 headlines of both /atx/ and /setext/ types.  /atx/ limits headline
13562 levels to two whereas /setext/ limits headline levels to six.  Beyond
13563 these limits, the export back-end converts headlines to lists.  To set
13564 a limit to a level before the absolute limit (see [[*Export Settings]]).
13566 ** OpenDocument Text Export
13567 :PROPERTIES:
13568 :DESCRIPTION: Exporting to OpenDocument Text.
13569 :END:
13570 #+cindex: ODT
13571 #+cindex: OpenDocument
13572 #+cindex: export, OpenDocument
13573 #+cindex: LibreOffice
13575 The ODT export back-end handles creating of OpenDocument Text (ODT)
13576 format.  Documents created by this exporter use the
13577 {{{cite(OpenDocument-v1.2 specification)}}}[fn:133] and are compatible
13578 with LibreOffice 3.4.
13580 *** Pre-requisites for ODT export
13581 :PROPERTIES:
13582 :DESCRIPTION: Required packages.
13583 :END:
13584 #+cindex: zip
13586 The ODT export back-end relies on the zip program to create the final
13587 compressed ODT output.  Check if =zip= is locally available and
13588 executable.  Without it, export cannot finish.
13590 *** ODT export commands
13591 :PROPERTIES:
13592 :DESCRIPTION: Invoking export.
13593 :END:
13595 - {{{kbd(C-c C-e o o)}}} (~org-export-to-odt~) ::
13597   #+kindex: C-c C-e o o
13598   #+findex: org-export-to-odt
13599   Export as OpenDocument Text file.
13601   #+cindex: @samp{EXPORT_FILE_NAME}, property
13602   #+vindex: org-odt-preferred-output-format
13604   If ~org-odt-preferred-output-format~ is specified, the ODT export
13605   back-end automatically converts the exported file to that format.
13607   For =myfile.org=, Org exports to =myfile.odt=, overwriting without
13608   warning.  The ODT export back-end exports a region only if a region
13609   was active.
13611   If the selected region is a single tree, the ODT export back-end
13612   makes the tree head the document title.  Incidentally, {{{kbd(C-c
13613   @)}}} selects the current sub-tree.  If the tree head entry has, or
13614   inherits, an =EXPORT_FILE_NAME= property, the ODT export back-end
13615   uses that for file name.
13617 - {{{kbd(C-c C-e o O)}}} ::
13619   #+kindex: C-c C-e o O
13620   Export as an OpenDocument Text file and open the resulting file.
13622   #+vindex: org-export-odt-preferred-output-format
13623   If ~org-export-odt-preferred-output-format~ is specified, open the
13624   converted file instead.  See [[*Automatically exporting to other
13625   formats]].
13627 *** ODT specific export settings
13628 :PROPERTIES:
13629 :DESCRIPTION: Configuration options.
13630 :END:
13632 The ODT export back-end has several additional keywords for
13633 customizing ODT output.  Setting these keywords works similar to the
13634 general options (see [[*Export Settings]]).
13636 - =DESCRIPTION= ::
13638   #+cindex: @samp{DESCRIPTION}, keyword
13639   This is the document's description, which the ODT export back-end
13640   inserts as document metadata.  For long descriptions, use multiple
13641   lines, prefixed with =DESCRIPTION=.
13643 - =KEYWORDS= ::
13645   #+cindex: @samp{KEYWORDS}, keyword
13646   The keywords for the document.  The ODT export back-end inserts the
13647   description along with author name, keywords, and related file
13648   metadata as metadata in the output file.  Use multiple =KEYWORDS= if
13649   necessary.
13651 - =ODT_STYLES_FILE= ::
13653   #+cindex: @samp{ODT_STYLES_FILE}, keyword
13654   #+vindex: org-odt-styles-file
13655   The ODT export back-end uses the ~org-odt-styles-file~ by default.
13656   See [[*Applying custom styles]] for details.
13658 - =SUBTITLE= ::
13660   #+cindex: @samp{SUBTITLE}, keyword
13661   The document subtitle.
13663 *** Extending ODT export
13664 :PROPERTIES:
13665 :DESCRIPTION: Producing DOC, PDF files.
13666 :END:
13668 The ODT export back-end can produce documents in other formats besides
13669 ODT using a specialized ODT converter process.  Its common interface
13670 works with popular converters to produce formats such as =doc=, or
13671 convert a document from one format, say =csv=, to another format, say
13672 =xls=.
13674 #+cindex: @file{unoconv}
13675 #+vindex: org-odt-convert-process
13676 Customize ~org-odt-convert-process~ variable to point to =unoconv=,
13677 which is the ODT's preferred converter.  Working installations of
13678 LibreOffice would already have =unoconv= installed.  Alternatively,
13679 other converters may be substituted here.  See [[*Configuring
13680 a document converter]].
13682 **** Automatically exporting to other formats
13683 :PROPERTIES:
13684 :UNNUMBERED: notoc
13685 :END:
13687 #+vindex: org-odt-preferred-output-format
13688 If ODT format is just an intermediate step to get to other formats,
13689 such as =doc=, =docx=, =rtf=, or =pdf=, etc., then extend the ODT
13690 export back-end to directly produce that format.  Specify the final
13691 format in the ~org-odt-preferred-output-format~ variable.  This is one
13692 way to extend (see [[*ODT export commands]]).
13694 **** Converting between document formats
13695 :PROPERTIES:
13696 :UNNUMBERED: notoc
13697 :END:
13699 The Org export back-end is made to be inter-operable with a wide range
13700 of text document format converters.  Newer generation converters, such
13701 as LibreOffice and Pandoc, can handle hundreds of formats at once.
13702 Org provides a consistent interaction with whatever converter is
13703 installed.  Here are some generic commands:
13705 - {{{kbd(M-x org-odt-convert)}}} ::
13707   #+findex: org-odt-convert
13708   Convert an existing document from one format to another.  With
13709   a prefix argument, opens the newly produced file.
13711 *** Applying custom styles
13712 :PROPERTIES:
13713 :DESCRIPTION: Styling the output.
13714 :END:
13715 #+cindex: styles, custom
13716 #+cindex: template, custom
13718 The ODT export back-end comes with many OpenDocument styles (see
13719 [[*Working with OpenDocument style files]]).  To expand or further
13720 customize these built-in style sheets, either edit the style sheets
13721 directly or generate them using an application such as LibreOffice.
13722 The example here shows creating a style using LibreOffice.
13724 **** Applying custom styles: the easy way
13725 :PROPERTIES:
13726 :UNNUMBERED: notoc
13727 :END:
13729 1. Create a sample =example.org= file with settings as shown below,
13730    and export it to ODT format.
13732    : #+OPTIONS: H:10 num:t
13734 2. Open the above =example.odt= using LibreOffice.  Use the /Stylist/
13735    to locate the target styles, which typically have the "Org" prefix.
13736    Open one, modify, and save as either OpenDocument Text (ODT) or
13737    OpenDocument Template (OTT) file.
13740    #+vindex: org-odt-styles-file
13741    Customize the variable ~org-odt-styles-file~ and point it to the
13742    newly created file.  For additional configuration options, see
13743    [[x-overriding-factory-styles][Overriding factory styles]].
13745    #+cindex: @samp{ODT_STYLES_FILE}, keyword
13746    To apply an ODT style to a particular file, use the
13747    =ODT_STYLES_FILE= keyword as shown in the example below:
13749    : #+ODT_STYLES_FILE: "/path/to/example.ott"
13751    #+texinfo: @noindent
13752    or
13754    : #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
13756 **** Using third-party styles and templates
13757 :PROPERTIES:
13758 :UNNUMBERED: notoc
13759 :END:
13761 The ODT export back-end relies on many templates and style names.
13762 Using third-party styles and templates can lead to mismatches.
13763 Templates derived from built in ODT templates and styles seem to have
13764 fewer problems.
13766 *** Links in ODT export
13767 :PROPERTIES:
13768 :DESCRIPTION: Handling and formatting links.
13769 :END:
13770 #+cindex: links, in ODT export
13772 ODT exporter creates native cross-references for internal links.  It
13773 creates Internet-style links for all other links.
13775 A link with no description and pointing to a regular, un-itemized,
13776 outline heading is replaced with a cross-reference and section number
13777 of the heading.
13779 A =\ref{label}=-style reference to an image, table etc., is replaced
13780 with a cross-reference and sequence number of the labeled entity.  See
13781 [[*Labels and captions in ODT export]].
13783 *** Tables in ODT export
13784 :PROPERTIES:
13785 :DESCRIPTION: Org tables conversions.
13786 :END:
13788 #+cindex: tables, in ODT export
13790 The ODT export back-end handles native Org mode tables (see [[*Tables]])
13791 and simple =table.el= tables.  Complex =table.el= tables having column
13792 or row spans are not supported.  Such tables are stripped from the
13793 exported document.
13795 By default, the ODT export back-end exports a table with top and
13796 bottom frames and with ruled lines separating row and column groups
13797 (see [[*Column Groups]]).  All tables are typeset to occupy the same
13798 width.  The ODT export back-end honors any table alignments and
13799 relative widths for columns (see [[*Column Width and Alignment]]).
13801 Note that the ODT export back-end interprets column widths as weighted
13802 ratios, the default weight being 1.
13804 #+cindex: @samp{ATTR_ODT}, keyword
13805 Specifying =:rel-width= property on an =ATTR_ODT= line controls the
13806 width of the table.  For example:
13808 #+begin_example
13809 ,#+ATTR_ODT: :rel-width 50
13810 | Area/Month    |   Jan |   Feb |   Mar |   Sum |
13811 |---------------+-------+-------+-------+-------|
13812 | /             |     < |       |       |     < |
13813 | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
13814 | North America |     1 |    21 |   926 |   948 |
13815 | Middle East   |     6 |    75 |   844 |   925 |
13816 | Asia Pacific  |     9 |    27 |   790 |   826 |
13817 |---------------+-------+-------+-------+-------|
13818 | Sum           |    16 |   123 |  2560 |  2699 |
13819 #+end_example
13821 On export, the above table takes 50% of text width area.  The exporter
13822 sizes the columns in the ratio: 13:5:5:5:6.  The first column is
13823 left-aligned and rest of the columns, right-aligned.  Vertical rules
13824 separate the header and the last column.  Horizontal rules separate
13825 the header and the last row.
13827 For even more customization, create custom table styles and associate
13828 them with a table using the =ATTR_ODT= keyword.  See [[*Customizing
13829 tables in ODT export]].
13831 *** Images in ODT export
13832 :PROPERTIES:
13833 :DESCRIPTION: Inserting images.
13834 :END:
13835 #+cindex: images, embedding in ODT
13836 #+cindex: embedding images in ODT
13838 **** Embedding images
13839 :PROPERTIES:
13840 :UNNUMBERED: notoc
13841 :END:
13843 The ODT export back-end processes image links in Org files that do not
13844 have descriptions, such as these links =[[file:img.jpg]]= or =[[./img.jpg]]=,
13845 as direct image insertions in the final output.  Either of these
13846 examples works:
13848 : [[file:img.png]]
13850 : [[./img.png]]
13852 **** Embedding clickable images
13853 :PROPERTIES:
13854 :UNNUMBERED: notoc
13855 :END:
13857 For clickable images, provide a link whose description is another link
13858 to an image file.  For example, to embed an image
13859 =org-mode-unicorn.png= which when clicked jumps to https://orgmode.org
13860 website, do the following
13862 : [[https://orgmode.org][./org-mode-unicorn.png]]
13864 **** Sizing and scaling of embedded images
13865 :PROPERTIES:
13866 :UNNUMBERED: notoc
13867 :END:
13869 #+cindex: @samp{ATTR_ODT}, keyword
13871 Control the size and scale of the embedded images with the =ATTR_ODT=
13872 attribute.
13874 #+cindex: identify, ImageMagick
13875 #+vindex: org-odt-pixels-per-inch
13876 The ODT export back-end starts with establishing the size of the image
13877 in the final document.  The dimensions of this size are measured in
13878 centimeters.  The back-end then queries the image file for its
13879 dimensions measured in pixels.  For this measurement, the back-end
13880 relies on ImageMagick's identify program or Emacs ~create-image~ and
13881 ~image-size~ API.  ImageMagick is the preferred choice for large file
13882 sizes or frequent batch operations.  The back-end then converts the
13883 pixel dimensions using ~org-odt-pixels-per-inch~ into the familiar 72
13884 dpi or 96 dpi.  The default value for this is in
13885 ~display-pixels-per-inch~, which can be tweaked for better results
13886 based on the capabilities of the output device.  Here are some common
13887 image scaling operations:
13889 - Explicitly size the image ::
13891   To embed =img.png= as a 10 cm x 10 cm image, do the following:
13893   #+begin_example
13894   ,#+ATTR_ODT: :width 10 :height 10
13895   [[./img.png]]
13896   #+end_example
13898 - Scale the image ::
13900   To embed =img.png= at half its size, do the following:
13902   #+begin_example
13903   ,#+ATTR_ODT: :scale 0.5
13904   [[./img.png]]
13905   #+end_example
13907 - Scale the image to a specific width ::
13909   To embed =img.png= with a width of 10 cm while retaining the
13910   original height:width ratio, do the following:
13912   #+begin_example
13913   ,#+ATTR_ODT: :width 10
13914   [[./img.png]]
13915   #+end_example
13917 - Scale the image to a specific height ::
13919   To embed =img.png= with a height of 10 cm while retaining the
13920   original height:width ratio, do the following:
13922   #+begin_example
13923   ,#+ATTR_ODT: :height 10
13924   [[./img.png]]
13925   #+end_example
13927 **** Anchoring of images
13928 :PROPERTIES:
13929 :UNNUMBERED: notoc
13930 :END:
13932 #+cindex: @samp{ATTR_ODT}, keyword
13933 The ODT export back-end can anchor images to =as-char=, =paragraph=,
13934 or =page=.  Set the preferred anchor using the =:anchor= property of
13935 the =ATTR_ODT= line.
13937 To create an image that is anchored to a page:
13939 #+begin_example
13940 ,#+ATTR_ODT: :anchor page
13941 [[./img.png]]
13942 #+end_example
13944 *** Math formatting in ODT export
13945 :PROPERTIES:
13946 :DESCRIPTION: Formatting @LaTeX{} fragments.
13947 :END:
13949 The ODT exporter has special support for handling math.
13951 **** LaTeX math snippets
13952 :PROPERTIES:
13953 :DESCRIPTION: Embedding in @LaTeX{} format.
13954 :END:
13956 LaTeX math snippets (see [[*LaTeX fragments]]) can be embedded in the ODT
13957 document in one of the following ways:
13959 - MathML ::
13961   #+cindex: MathML
13962   Add this line to the Org file.  This option is activated on
13963   a per-file basis.
13965   : #+OPTIONS: tex:t
13967   With this option, LaTeX fragments are first converted into MathML
13968   fragments using an external LaTeX-to-MathML converter program.  The
13969   resulting MathML fragments are then embedded as an OpenDocument
13970   Formula in the exported document.
13972   #+vindex: org-latex-to-mathml-convert-command
13973   #+vindex: org-latex-to-mathml-jar-file
13974   You can specify the LaTeX-to-MathML converter by customizing the
13975   variables ~org-latex-to-mathml-convert-command~ and
13976   ~org-latex-to-mathml-jar-file~.
13978   If you prefer to use MathToWeb[fn:134] as your converter, you can
13979   configure the above variables as shown below.
13981   #+begin_src emacs-lisp
13982   (setq org-latex-to-mathml-convert-command
13983         "java -jar %j -unicode -force -df %o %I"
13984         org-latex-to-mathml-jar-file
13985         "/path/to/mathtoweb.jar")
13986   #+end_src
13988   #+texinfo: @noindent
13989   or, to use LaTeX​ML[fn:135] instead,
13991   #+begin_src emacs-lisp
13992   (setq org-latex-to-mathml-convert-command
13993         "latexmlmath \"%i\" --presentationmathml=%o")
13994   #+end_src
13996   To quickly verify the reliability of the LaTeX-to-MathML
13997   converter, use the following commands:
13999   - {{{kbd(M-x org-export-as-odf)}}} ::
14001     Convert a LaTeX math snippet to an OpenDocument formula (=.odf=)
14002     file.
14004   - {{{kbd(M-x org-export-as-odf-and-open)}}} ::
14006     Convert a LaTeX math snippet to an OpenDocument formula (=.odf=)
14007     file and open the formula file with the system-registered
14008     application.
14010 - PNG images ::
14012   #+cindex: dvipng
14013   #+cindex: dvisvgm
14014   #+cindex: ImageMagick
14015   Add this line to the Org file.  This option is activated on
14016   a per-file basis.
14018   : #+OPTIONS: tex:dvipng
14020   : #+OPTIONS: tex:dvisvgm
14022   #+texinfo: @noindent
14023   or
14025   : #+OPTIONS: tex:imagemagick
14027   Under this option, LaTeX fragments are processed into PNG or SVG
14028   images and the resulting images are embedded in the exported
14029   document.  This method requires dvipng program, dvisvgm or
14030   ImageMagick programs.
14032 **** MathML and OpenDocument formula files
14033 :PROPERTIES:
14034 :DESCRIPTION: Embedding in native format.
14035 :END:
14037 When embedding LaTeX math snippets in ODT documents is not reliable,
14038 there is one more option to try.  Embed an equation by linking to its
14039 MathML (=.mml=) source or its OpenDocument formula (=.odf=) file as
14040 shown below:
14042 : [[./equation.mml]]
14044 #+texinfo: @noindent
14047 : [[./equation.odf]]
14049 *** Labels and captions in ODT export
14050 :PROPERTIES:
14051 :DESCRIPTION: Rendering objects.
14052 :END:
14054 ODT format handles labeling and captioning of objects based on their
14055 types.  Inline images, tables, LaTeX fragments, and Math formulas are
14056 numbered and captioned separately.  Each object also gets a unique
14057 sequence number based on its order of first appearance in the Org
14058 file.  Each category has its own sequence.  A caption is just a label
14059 applied to these objects.
14061 #+begin_example
14062 ,#+CAPTION: Bell curve
14063 ,#+NAME:   fig:SED-HR4049
14064 [[./img/a.png]]
14065 #+end_example
14067 When rendered, it may show as follows in the exported document:
14069 : Figure 2: Bell curve
14071 #+vindex: org-odt-category-map-alist
14072 To modify the category component of the caption, customize the option
14073 ~org-odt-category-map-alist~.  For example, to tag embedded images
14074 with the string "Illustration" instead of the default string "Figure",
14075 use the following setting:
14077 #+begin_src emacs-lisp
14078 (setq org-odt-category-map-alist
14079       '(("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))
14080 #+end_src
14082 With the above modification, the previous example changes to:
14084 : Illustration 2: Bell curve
14086 *** Literal examples in ODT export
14087 :PROPERTIES:
14088 :DESCRIPTION: For source code and example blocks.
14089 :END:
14091 The ODT export back-end supports literal examples (see [[*Literal
14092 Examples]]) with full fontification.  Internally, the ODT export
14093 back-end relies on =htmlfontify.el= to generate the style definitions
14094 needed for fancy listings.  The auto-generated styles get =OrgSrc=
14095 prefix and inherit colors from the faces used by Emacs Font Lock
14096 library for that source language.
14098 #+vindex: org-odt-fontify-srcblocks
14099 For custom fontification styles, customize the
14100 ~org-odt-create-custom-styles-for-srcblocks~ option.
14102 #+vindex: org-odt-create-custom-styles-for-srcblocks
14103 To turn off fontification of literal examples, customize the
14104 ~org-odt-fontify-srcblocks~ option.
14106 *** Advanced topics in ODT export
14107 :PROPERTIES:
14108 :DESCRIPTION: For power users.
14109 :END:
14111 The ODT export back-end has extensive features useful for power users
14112 and frequent uses of ODT formats.
14114 **** Configuring a document converter
14115 :PROPERTIES:
14116 :DESCRIPTION: Registering a document converter.
14117 :UNNUMBERED: notoc
14118 :END:
14119 #+cindex: convert
14120 #+cindex: doc, docx, rtf
14121 #+cindex: converter
14123 The ODT export back-end works with popular converters with little or
14124 no extra configuration.  See [[*Extending ODT export]].  The following is
14125 for unsupported converters or tweaking existing defaults.
14127 - Register the converter ::
14129   #+vindex: org-export-odt-convert-processes
14130   Add the name of the converter to the ~org-odt-convert-processes~
14131   variable.  Note that it also requires how the converter is invoked
14132   on the command line.  See the variable's docstring for details.
14134 - Configure its capabilities ::
14136   #+vindex: org-export-odt-convert-capabilities
14137   Specify which formats the converter can handle by customizing the
14138   variable ~org-odt-convert-capabilities~.  Use the entry for the
14139   default values in this variable for configuring the new converter.
14140   Also see its docstring for details.
14142 - Choose the converter ::
14144   #+vindex: org-export-odt-convert-process
14145   Select the newly added converter as the preferred one by customizing
14146   the option ~org-odt-convert-process~.
14148 **** Working with OpenDocument style files
14149 :PROPERTIES:
14150 :DESCRIPTION: Exploring internals.
14151 :UNNUMBERED: notoc
14152 :END:
14153 #+cindex: styles, custom
14154 #+cindex: template, custom
14156 This section explores the internals of the ODT exporter; the means by which
14157 it produces styled documents; the use of automatic and custom OpenDocument
14158 styles.
14160 The ODT exporter relies on two files for generating its output.  These
14161 files are bundled with the distribution under the directory pointed to
14162 by the variable ~org-odt-styles-dir~.  The two files are:
14164 - =OrgOdtStyles.xml= <<x-orgodtstyles-xml>> ::
14166   This file contributes to the =styles.xml= file of the final ODT
14167   document.  This file gets modified for the following purposes:
14169   1. To control outline numbering based on user settings;
14171   2. To add styles generated by =htmlfontify.el= for fontification of
14172      code blocks.
14174 - =OrgOdtContentTemplate.xml= <<x-orgodtcontenttemplate-xml>> ::
14176   This file contributes to the =content.xml= file of the final ODT
14177   document.  The contents of the Org outline are inserted between the
14178   =<office:text>= ... =</office:text>= elements of this file.
14180   Apart from serving as a template file for the final =content.xml=,
14181   the file serves the following purposes:
14183   1. It contains automatic styles for formatting of tables which are
14184      referenced by the exporter;
14186   2. It contains =<text:sequence-decl>= ... =</text:sequence-decl>=
14187      elements that control numbering of tables, images, equations, and
14188      similar entities.
14190 <<x-overriding-factory-styles>> The following two variables control
14191 the location from where the ODT exporter picks up the custom styles
14192 and content template files.  Customize these variables to override the
14193 factory styles used by the exporter.
14195 - ~org-odt-styles-file~ ::
14197   The ODT export back-end uses the file pointed to by this variable,
14198   such as =styles.xml=, for the final output.  It can take one of the
14199   following values:
14201   - =FILE.xml= ::
14203     Use this file instead of the default =styles.xml=
14205   - =FILE.odt= or =FILE.ott= ::
14207     Use the =styles.xml= contained in the specified OpenDocument
14208     Text or Template file
14210   - =FILE.odt= or =FILE.ott= and a subset of included files ::
14212     Use the =styles.xml= contained in the specified OpenDocument Text
14213     or Template file.  Additionally extract the specified member files
14214     and embed those within the final ODT document.
14216     Use this option if the =styles.xml= file references additional
14217     files like header and footer images.
14219   - ~nil~ ::
14221     Use the default =styles.xml=.
14223 - ~org-odt-content-template-file~ ::
14225   Use this variable to specify the blank =content.xml= used in the
14226   final output.
14228 **** Creating one-off styles
14229 :PROPERTIES:
14230 :DESCRIPTION: Customizing styles, highlighting...
14231 :UNNUMBERED: notoc
14232 :END:
14234 The ODT export back-end can read embedded raw OpenDocument XML from
14235 the Org file.  Such direct formatting is useful for one-off instances.
14237 - Embedding ODT tags as part of regular text ::
14239   Enclose OpenDocument syntax in =@@odt:...@@= for inline markup.  For
14240   example, to highlight a region of text do the following:
14242   #+begin_example
14243   @@odt:<text:span text:style-name="Highlight">This is highlighted
14244   text</text:span>@@.  But this is regular text.
14245   #+end_example
14247   *Hint:* To see the above example in action, edit the =styles.xml=
14248   (see [[x-orgodtstyles-xml][Factory styles]]) and add a custom /Highlight/ style as shown
14249   below:
14251   #+begin_example
14252   <style:style style:name="Highlight" style:family="text">
14253     <style:text-properties fo:background-color="#ff0000"/>
14254   </style:style>
14255   #+end_example
14257 - Embedding a one-line OpenDocument XML ::
14259   #+cindex: @samp{ODT}, keyword
14260   The ODT export back-end can read one-liner options with =#+ODT:= in
14261   the Org file.  For example, to force a page break:
14263   #+begin_example
14264   ,#+ODT: <text:p text:style-name="PageBreak"/>
14265   #+end_example
14267   *Hint:* To see the above example in action, edit your
14268   =styles.xml= (see [[x-orgodtstyles-xml][Factory styles]]) and add a custom =PageBreak=
14269   style as shown below.
14271   #+begin_example
14272   <style:style style:name="PageBreak" style:family="paragraph"
14273                style:parent-style-name="Text_20_body">
14274     <style:paragraph-properties fo:break-before="page"/>
14275   </style:style>
14276   #+end_example
14278 - Embedding a block of OpenDocument XML ::
14280   The ODT export back-end can also read ODT export blocks for
14281   OpenDocument XML.  Such blocks use the =#+BEGIN_EXPORT odt=
14282   ... =#+END_EXPORT= constructs.
14284   For example, to create a one-off paragraph that uses bold text, do
14285   the following:
14287   #+begin_example
14288   ,#+BEGIN_EXPORT odt
14289     <text:p text:style-name="Text_20_body_20_bold">
14290     This paragraph is specially formatted and uses bold text.
14291     </text:p>
14292   ,#+END_EXPORT
14293   #+end_example
14295 **** Customizing tables in ODT export
14296 :PROPERTIES:
14297 :DESCRIPTION: Defining table templates.
14298 :UNNUMBERED: notoc
14299 :END:
14300 #+cindex: tables, in ODT export
14301 #+cindex: @samp{ATTR_ODT}, keyword
14303 Override the default table format by specifying a custom table style
14304 with the =#+ATTR_ODT= line.  For a discussion on default formatting of
14305 tables, see [[*Tables in ODT export]].
14307 This feature closely mimics the way table templates are defined in the
14308 OpenDocument-v1.2 specification[fn:136].
14310 #+vindex: org-odt-table-styles
14311 For quick preview of this feature, install the settings below and export the
14312 table that follows:
14314 #+begin_src emacs-lisp
14315 (setq org-export-odt-table-styles
14316       (append org-export-odt-table-styles
14317               '(("TableWithHeaderRowAndColumn" "Custom"
14318                  ((use-first-row-styles . t)
14319                   (use-first-column-styles . t)))
14320                 ("TableWithFirstRowandLastRow" "Custom"
14321                  ((use-first-row-styles . t)
14322                   (use-last-row-styles . t))))))
14323 #+end_src
14325 #+begin_example
14326 ,#+ATTR_ODT: :style TableWithHeaderRowAndColumn
14327 | Name  | Phone | Age |
14328 | Peter |  1234 |  17 |
14329 | Anna  |  4321 |  25 |
14330 #+end_example
14332 The example above used =Custom= template and installed two table
14333 styles =TableWithHeaderRowAndColumn= and
14334 =TableWithFirstRowandLastRow=.  *Important:* The OpenDocument styles
14335 needed for producing the above template were pre-defined.  They are
14336 available in the section marked =Custom Table Template= in
14337 =OrgOdtContentTemplate.xml= (see [[x-orgodtcontenttemplate-xml][Factory styles]]).  For adding new
14338 templates, define new styles there.
14340 To use this feature proceed as follows:
14342 1. Create a table template[fn:137].
14344    A table template is set of =table-cell= and =paragraph= styles for
14345    each of the following table cell categories:
14347    - Body
14348    - First column
14349    - Last column
14350    - First row
14351    - Last row
14352    - Even row
14353    - Odd row
14354    - Even column
14355    - Odd Column
14357    The names for the above styles must be chosen based on the name of
14358    the table template using a well-defined convention.
14360    The naming convention is better illustrated with an example.  For
14361    a table template with the name =Custom=, the needed style names are
14362    listed in the following table.
14364    | Cell type    | Cell style                   | Paragraph style                   |
14365    |--------------+------------------------------+-----------------------------------|
14366    | Body         | =CustomTableCell=            | =CustomTableParagraph=            |
14367    | First column | =CustomFirstColumnTableCell= | =CustomFirstColumnTableParagraph= |
14368    | Last column  | =CustomLastColumnTableCell=  | =CustomLastColumnTableParagraph=  |
14369    | First row    | =CustomFirstRowTableCell=    | =CustomFirstRowTableParagraph=    |
14370    | Last row     | =CustomLastRowTableCell=     | =CustomLastRowTableParagraph=     |
14371    | Even row     | =CustomEvenRowTableCell=     | =CustomEvenRowTableParagraph=     |
14372    | Odd row      | =CustomOddRowTableCell=      | =CustomOddRowTableParagraph=      |
14373    | Even column  | =CustomEvenColumnTableCell=  | =CustomEvenColumnTableParagraph=  |
14374    | Odd column   | =CustomOddColumnTableCell=   | =CustomOddColumnTableParagraph=   |
14376    To create a table template with the name =Custom=, define the above
14377    styles in the =<office:automatic-styles>= ...
14378    =</office:automatic-styles>= element of the content template file
14379    (see [[x-orgodtcontenttemplate-xml][Factory styles]]).
14381 2. Define a table style[fn:138].
14383    #+vindex: org-odt-table-styles
14384    To define a table style, create an entry for the style in the
14385    variable ~org-odt-table-styles~ and specify the following:
14387    - the name of the table template created in step (1),
14388    - the set of cell styles in that template that are to be activated.
14390    For example, the entry below defines two different table styles
14391    =TableWithHeaderRowAndColumn= and =TableWithFirstRowandLastRow=
14392    based on the same template =Custom=.  The styles achieve their
14393    intended effect by selectively activating the individual cell
14394    styles in that template.
14396    #+begin_src emacs-lisp
14397    (setq org-export-odt-table-styles
14398          (append org-export-odt-table-styles
14399                  '(("TableWithHeaderRowAndColumn" "Custom"
14400                     ((use-first-row-styles . t)
14401                      (use-first-column-styles . t)))
14402                    ("TableWithFirstRowandLastRow" "Custom"
14403                     ((use-first-row-styles . t)
14404                      (use-last-row-styles . t))))))
14405    #+end_src
14407 3. Associate a table with the table style.
14409    To do this, specify the table style created in step (2) as part of
14410    the =ATTR_ODT= line as shown below.
14412    #+begin_example
14413    ,#+ATTR_ODT: :style TableWithHeaderRowAndColumn
14414    | Name  | Phone | Age |
14415    | Peter |  1234 |  17 |
14416    | Anna  |  4321 |  25 |
14417    #+end_example
14419 **** Validating OpenDocument XML
14420 :PROPERTIES:
14421 :DESCRIPTION: Debugging corrupted OpenDocument files.
14422 :UNNUMBERED: notoc
14423 :END:
14425 Sometimes ODT format files may not open due to =.odt= file corruption.
14426 To verify if such a file is corrupt, validate it against the
14427 OpenDocument Relax NG Compact (RNC) syntax schema.  But first the
14428 =.odt= files have to be decompressed using =zip=.  Note that =.odt=
14429 files are ZIP archives: [[info:emacs::File Archives]].  The contents of
14430 ODT files are in XML.  For general help with validation---and
14431 schema-sensitive editing---of XML files: [[info:nxml-mode::Introduction]].
14433 #+vindex: org-export-odt-schema-dir
14434 Customize ~org-odt-schema-dir~ to point to a directory with
14435 OpenDocument RNC files and the needed schema-locating rules.  The ODT
14436 export back-end takes care of updating the
14437 ~rng-schema-locating-files~.
14439 ** Org Export
14440 :PROPERTIES:
14441 :DESCRIPTION: Exporting to Org.
14442 :END:
14444 #+cindex: Org export
14445 /org/ export back-end creates a normalized version of the Org document
14446 in current buffer.  The exporter evaluates Babel code (see [[*Evaluating
14447 Code Blocks]]) and removes content specific to other back-ends.
14449 *** Org export commands
14450 :PROPERTIES:
14451 :UNNUMBERED: notoc
14452 :END:
14454 - {{{kbd(C-c C-e O o)}}} (~org-org-export-to-org~) ::
14456   #+kindex: C-c C-e O o
14457   #+findex: org-org-export-to-org
14458   Export as an Org file with a =.org= extension.  For =myfile.org=,
14459   Org exports to =myfile.org.org=, overwriting without warning.
14461 - {{{kbd(C-c C-e O v)}}} (~~) ::
14463   #+kindex: C-c C-e O v
14464   Export to an Org file, then open it.
14466 ** Texinfo Export
14467 :PROPERTIES:
14468 :DESCRIPTION: Exporting to Texinfo.
14469 :END:
14471 *** Texinfo export commands
14472 :PROPERTIES:
14473 :DESCRIPTION: Invoking commands.
14474 :END:
14476 - {{{kbd(C-c C-e i t)}}} (~org-texinfo-export-to-texinfo~) ::
14478   #+kindex: C-c C-e i t
14479   #+findex: org-texinfo-export-to-texinfo
14480   Export as a Texinfo file with =.texi= extension.  For =myfile.org=,
14481   Org exports to =myfile.texi=, overwriting without warning.
14483 - {{{kbd(C-c C-e i i)}}} (~org-texinfo-export-to-info~) ::
14485   #+kindex: C-c C-e i i
14486   #+findex: org-texinfo-export-to-info
14487   #+vindex: org-texinfo-info-process
14488   Export to Texinfo format first and then process it to make an Info
14489   file.  To generate other formats, such as DocBook, customize the
14490   ~org-texinfo-info-process~ variable.
14492 *** Texinfo specific export settings
14493 :PROPERTIES:
14494 :DESCRIPTION: Setting the environment.
14495 :END:
14497 The Texinfo export back-end has several additional keywords for
14498 customizing Texinfo output.  Setting these keywords works similar to
14499 the general options (see [[*Export Settings]]).
14501 - =SUBTITLE= ::
14503   #+cindex: @samp{SUBTITLE}, keyword
14504   The document subtitle.
14506 - =SUBAUTHOR= ::
14508   #+cindex: @samp{SUBAUTHOR}, keyword
14509   Additional authors for the document.
14511 - =TEXINFO_FILENAME= ::
14513   #+cindex: @samp{TEXINFO_FILENAME}, keyword
14514   The Texinfo filename.
14516 - =TEXINFO_CLASS= ::
14518   #+cindex: @samp{TEXINFO_CLASS}, keyword
14519   #+vindex: org-texinfo-default-class
14520   The default document class (~org-texinfo-default-class~), which must
14521   be a member of ~org-texinfo-classes~.
14523 - =TEXINFO_HEADER= ::
14525   #+cindex: @samp{TEXINFO_HEADER}, keyword
14526   Arbitrary lines inserted at the end of the header.
14528 - =TEXINFO_POST_HEADER= ::
14530   #+cindex: @samp{TEXINFO_POST_HEADER}, keyword
14531   Arbitrary lines inserted after the end of the header.
14533 - =TEXINFO_DIR_CATEGORY= ::
14535   #+cindex: @samp{TEXINFO_DIR_CATEGORY}, keyword
14536   The directory category of the document.
14538 - =TEXINFO_DIR_TITLE= ::
14540   #+cindex: @samp{TEXINFO_DIR_TITLE}, keyword
14541   The directory title of the document.
14543 - =TEXINFO_DIR_DESC= ::
14545   #+cindex: @samp{TEXINFO_DIR_DESC}, keyword
14546   The directory description of the document.
14548 - =TEXINFO_PRINTED_TITLE= ::
14550   #+cindex: @samp{TEXINFO_PRINTED_TITLE}, keyword
14551   The printed title of the document.
14553 *** Texinfo file header
14554 :PROPERTIES:
14555 :DESCRIPTION: Generating the header.
14556 :END:
14558 #+cindex: @samp{TEXINFO_FILENAME}, keyword
14559 After creating the header for a Texinfo file, the Texinfo back-end
14560 automatically generates a name and destination path for the Info file.
14561 To override this default with a more sensible path and name, specify
14562 the =TEXINFO_FILENAME= keyword.
14564 #+vindex: org-texinfo-coding-system
14565 #+cindex: @samp{TEXINFO_HEADER}, keyword
14566 Along with the output's file name, the Texinfo header also contains
14567 language details (see [[*Export Settings]]) and encoding system as set in
14568 the ~org-texinfo-coding-system~ variable.  Insert =TEXINFO_HEADER=
14569 keywords for each additional command in the header, for example:
14571 : #+TEXINFO_HEADER: @synindex
14573 #+cindex: @samp{TEXINFO_CLASS}, keyword
14574 #+vindex: org-texinfo-classes
14575 Instead of repeatedly installing the same set of commands, define
14576 a class in ~org-texinfo-classes~ once, and then activate it in the
14577 document by setting the =TEXINFO_CLASS= keyword to that class.
14579 *** Texinfo title and copyright page
14580 :PROPERTIES:
14581 :DESCRIPTION: Creating preamble pages.
14582 :END:
14584 #+cindex: @samp{TEXINFO_PRINTED_TITLE}, keyword
14585 The default template for hard copy output has a title page with
14586 =TITLE= and =AUTHOR= keywords (see [[*Export Settings]]).  To replace the
14587 regular title with something different for the printed version, use
14588 the =TEXINFO_PRINTED_TITLE= and =SUBTITLE= keywords.  Both expect raw
14589 Texinfo code for setting their values.
14591 #+cindex: @samp{SUBAUTHOR}, keyword
14592 If one =AUTHOR= line is not sufficient, add multiple =SUBAUTHOR=
14593 keywords.  They have to be set in raw Texinfo code.
14595 #+begin_example
14596 ,#+AUTHOR: Jane Smith
14597 ,#+SUBAUTHOR: John Doe
14598 ,#+TEXINFO_PRINTED_TITLE: This Long Title@@inlinefmt{tex,@*} Is Broken in @TeX{}
14599 #+end_example
14601 #+cindex: @samp{COPYING}, property
14602 Copying material is defined in a dedicated headline with a non-~nil~
14603 =COPYING= property.  The back-end inserts the contents within
14604 a =@copying= command at the beginning of the document.  The heading
14605 itself does not appear in the structure of the document.
14607 Copyright information is printed on the back of the title page.
14609 #+begin_example
14610 ,* Legalese
14611   :PROPERTIES:
14612   :COPYING: t
14613   :END:
14615   This is a short example of a complete Texinfo file, version 1.0.
14617   Copyright \copy 2016 Free Software Foundation, Inc.
14618 #+end_example
14620 *** Info directory file
14621 :PROPERTIES:
14622 :DESCRIPTION: Installing a manual in Info file hierarchy.
14623 :END:
14625 #+cindex: @samp{dir} file, in Texinfo export
14626 #+cindex: Info directory file, in Texinfo export
14627 #+cindex: @code{install-info}, in Texinfo export
14629 #+cindex: @samp{TEXINFO_DIR_CATEGORY}, keyword
14630 #+cindex: @samp{TEXINFO_DIR_TITLE}, keyword
14631 #+cindex: @samp{TEXINFO_DIR_DESC}, keyword
14632 The end result of the Texinfo export process is the creation of an
14633 Info file.  This Info file's metadata has variables for category,
14634 title, and description: =TEXINFO_DIR_CATEGORY=, =TEXINFO_DIR_TITLE=,
14635 and =TEXINFO_DIR_DESC= keywords that establish where in the Info
14636 hierarchy the file fits.
14638 Here is an example that writes to the Info directory file:
14640 #+begin_example
14641 ,#+TEXINFO_DIR_CATEGORY: Emacs
14642 ,#+TEXINFO_DIR_TITLE: Org Mode: (org)
14643 ,#+TEXINFO_DIR_DESC: Outline-based notes management and organizer
14644 #+end_example
14646 *** Headings and sectioning structure
14647 :PROPERTIES:
14648 :DESCRIPTION: Building document structure.
14649 :END:
14651 #+vindex: org-texinfo-classes
14652 #+vindex: org-texinfo-default-class
14653 #+cindex: @samp{TEXINFO_CLASS}, keyword
14654 The Texinfo export back-end uses a pre-defined scheme to convert Org
14655 headlines to equivalent Texinfo structuring commands.  A scheme like
14656 this maps top-level headlines to numbered chapters tagged as
14657 ~@chapter~ and lower-level headlines to unnumbered chapters tagged as
14658 ~@unnumbered~.  To override such mappings to introduce ~@part~ or
14659 other Texinfo structuring commands, define a new class in
14660 ~org-texinfo-classes~.  Activate the new class with the
14661 =TEXINFO_CLASS= keyword.  When no new class is defined and activated,
14662 the Texinfo export back-end defaults to the
14663 ~org-texinfo-default-class~.
14665 If an Org headline's level has no associated Texinfo structuring
14666 command, or is below a certain threshold (see [[*Export Settings]]), then
14667 the Texinfo export back-end makes it into a list item.
14669 #+cindex: @samp{APPENDIX}, property
14670 The Texinfo export back-end makes any headline with a non-~nil~
14671 =APPENDIX= property into an appendix.  This happens independent of the
14672 Org headline level or the =TEXINFO_CLASS= keyword.
14674 #+cindex: @samp{ALT_TITLE}, property
14675 #+cindex: @samp{DESCRIPTION}, property
14676 The Texinfo export back-end creates a menu entry after the Org
14677 headline for each regular sectioning structure.  To override this with
14678 a shorter menu entry, use the =ALT_TITLE= property (see [[*Table of
14679 Contents]]).  Texinfo menu entries also have an option for a longer
14680 =DESCRIPTION= property.  Here's an example that uses both to override
14681 the default menu entry:
14683 #+begin_example
14684 ,* Controlling Screen Display
14685   :PROPERTIES:
14686   :ALT_TITLE: Display
14687   :DESCRIPTION: Controlling Screen Display
14688   :END:
14689 #+end_example
14691 #+cindex: Top node, in Texinfo export
14692 The text before the first headline belongs to the /Top/ node, i.e.,
14693 the node in which a reader enters an Info manual.  As such, it is
14694 expected not to appear in printed output generated from the =.texi=
14695 file.  See [[info:texinfo::The Top Node]], for more information.
14697 *** Indices
14698 :PROPERTIES:
14699 :DESCRIPTION: Creating indices.
14700 :END:
14702 #+cindex: @samp{CINDEX}, keyword
14703 #+cindex: concept index, in Texinfo export
14704 #+cindex: @samp{FINDEX}, keyword
14705 #+cindex: function index, in Texinfo export
14706 #+cindex: @samp{KINDEX}, keyword
14707 #+cindex: keystroke index, in Texinfo export
14708 #+cindex: @samp{PINDEX}, keyword
14709 #+cindex: program index, in Texinfo export
14710 #+cindex: @samp{TINDEX}, keyword
14711 #+cindex: data type index, in Texinfo export
14712 #+cindex: @samp{VINDEX}, keyword
14713 #+cindex: variable index, in Texinfo export
14714 The Texinfo export back-end recognizes these indexing keywords if used
14715 in the Org file: =CINDEX=, =FINDEX=, =KINDEX=, =PINDEX=, =TINDEX= and
14716 =VINDEX=.  Write their value as verbatim Texinfo code; in particular,
14717 ={=, =}= and =@= characters need to be escaped with =@= if they do not
14718 belong to a Texinfo command.
14720 : #+CINDEX: Defining indexing entries
14722 #+cindex: @samp{INDEX}, property
14723 For the back-end to generate an index entry for a headline, set the
14724 =INDEX= property to =cp= or =vr=.  These abbreviations come from
14725 Texinfo that stand for concept index and variable index.  The Texinfo
14726 manual has abbreviations for all other kinds of indexes.  The back-end
14727 exports the headline as an unnumbered chapter or section command, and
14728 then inserts the index after its contents.
14730 #+begin_example
14731 ,* Concept Index
14732   :PROPERTIES:
14733   :INDEX: cp
14734   :END:
14735 #+end_example
14737 *** Quoting Texinfo code
14738 :PROPERTIES:
14739 :DESCRIPTION: Incorporating literal Texinfo code.
14740 :END:
14742 Use any of the following three methods to insert or escape raw Texinfo
14743 code:
14745 #+cindex: @samp{TEXINFO}, keyword
14746 #+cindex: @samp{BEGIN_EXPORT texinfo}
14747 #+begin_example
14748 Richard @@texinfo:@sc{@@Stallman@@texinfo:}@@ commence' GNU.
14750 ,#+TEXINFO: @need800
14751 This paragraph is preceded by...
14753 ,#+BEGIN_EXPORT texinfo
14754   @auindex Johnson, Mark
14755   @auindex Lakoff, George
14756 ,#+END_EXPORT
14757 #+end_example
14759 *** Plain lists in Texinfo export
14760 :PROPERTIES:
14761 :DESCRIPTION: List attributes.
14762 :END:
14764 #+cindex: @samp{ATTR_TEXINFO}, keyword
14765 #+cindex: two-column tables, in Texinfo export
14766 #+cindex: table-type, Texinfo attribute
14767 The Texinfo export back-end by default converts description lists in
14768 the Org file using the default command =@table=, which results in
14769 a table with two columns.  To change this behavior, set =:table-type=
14770 attribute to either =ftable= or =vtable= value.  For more information,
14771 see [[info:texinfo::Two-column Tables]].
14773 #+vindex: org-texinfo-table-default-markup
14774 #+cindex: indic, Texinfo attribute
14775 The Texinfo export back-end by default also applies a text highlight
14776 based on the defaults stored in ~org-texinfo-table-default-markup~.
14777 To override the default highlight command, specify another one with
14778 the =:indic= attribute.
14780 #+cindex: multiple items in Texinfo lists
14781 #+cindex: sep, Texinfo attribute
14782 Org syntax is limited to one entry per list item.  Nevertheless, the
14783 Texinfo export back-end can split that entry according to any text
14784 provided through the =:sep= attribute.  Each part then becomes a new
14785 entry in the first column of the table.
14787 The following example illustrates all the attributes above:
14789 #+begin_example
14790 ,#+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
14791 - foo, bar :: This is the common text for variables foo and bar.
14792 #+end_example
14794 #+texinfo: @noindent
14795 becomes
14797 #+begin_example
14798 @vtable @asis
14799 @item foo
14800 @itemx bar
14801 This is the common text for variables foo and bar.
14802 @end table
14803 #+end_example
14805 #+cindex: lettered lists, in Texinfo export
14806 #+cindex: enum, Texinfo attribute
14807 Ordered lists are numbered when exported to Texinfo format.  Such
14808 numbering obeys any counter (see [[*Plain Lists]]) in the first item of
14809 the list.  The =:enum= attribute also let you start the list at
14810 a specific number, or switch to a lettered list, as illustrated here
14812 #+begin_example
14813 #+ATTR_TEXINFO: :enum A
14814 1. Alpha
14815 2. Bravo
14816 3. Charlie
14817 #+end_example
14819 *** Tables in Texinfo export
14820 :PROPERTIES:
14821 :DESCRIPTION: Table attributes.
14822 :END:
14824 #+cindex: @samp{ATTR_TEXINFO}, keyword
14825 When exporting tables, the Texinfo export back-end uses the widest
14826 cell width in each column.  To override this and instead specify as
14827 fractions of line length, use the =:columns= attribute.  See example
14828 below.
14830 #+begin_example
14831 ,#+ATTR_TEXINFO: :columns .5 .5
14832 | a cell | another cell |
14833 #+end_example
14835 *** Images in Texinfo export
14836 :PROPERTIES:
14837 :DESCRIPTION: Image attributes.
14838 :END:
14840 #+cindex: @samp{ATTR_TEXINFO}, keyword
14841 Insert a file link to the image in the Org file, and the Texinfo
14842 export back-end inserts the image.  These links must have the usual
14843 supported image extensions and no descriptions.  To scale the image,
14844 use =:width= and =:height= attributes.  For alternate text, use =:alt=
14845 and specify the text using Texinfo code, as shown in the example:
14847 #+begin_example
14848 ,#+ATTR_TEXINFO: :width 1in :alt Alternate @i{text}
14849 [[ridt.pdf]]
14850 #+end_example
14852 *** Quotations in Texinfo export
14853 :PROPERTIES:
14854 :DESCRIPTION: Quote block attributes.
14855 :END:
14857 #+cindex: @samp{ATTR_TEXINFO}, keyword
14858 You can write the text of a quotation within a quote block (see
14859 [[*Paragraphs]]).  You may also emphasize some text at the beginning of
14860 the quotation with the =:tag= attribute.
14862 #+begin_example
14863 ,#+ATTR_TEXINFO: :tag Warning
14864 ,#+BEGIN_QUOTE
14865 Striking your thumb with a hammer may cause severe pain and discomfort.
14866 ,#+END_QUOTE
14867 #+end_example
14869 To specify the author of the quotation, use the =:author= attribute.
14871 #+begin_example
14872 ,#+ATTR_TEXINFO: :author King Arthur
14873 ,#+BEGIN_QUOTE
14874 The Lady of the Lake, her arm clad in the purest shimmering samite,
14875 held aloft Excalibur from the bosom of the water, signifying by divine
14876 providence that I, Arthur, was to carry Excalibur. That is why I am
14877 your king.
14878 ,#+END_QUOTE
14879 #+end_example
14881 *** Special blocks in Texinfo export
14882 :PROPERTIES:
14883 :DESCRIPTION: Special block attributes.
14884 :END:
14886 #+cindex: @samp{ATTR_TEXINFO}, keyword
14888 The Texinfo export back-end converts special blocks to commands with
14889 the same name.  It also adds any =:options= attributes to the end of
14890 the command, as shown in this example:
14892 #+begin_example
14893 ,#+ATTR_TEXINFO: :options org-org-export-to-org ...
14894 ,#+BEGIN_defun
14895   A somewhat obsessive function name.
14896 ,#+END_defun
14897 #+end_example
14899 #+texinfo: @noindent
14900 becomes
14902 #+begin_example
14903 @defun org-org-export-to-org ...
14904   A somewhat obsessive function name.
14905 @end defun
14906 #+end_example
14908 *** A Texinfo example
14909 :PROPERTIES:
14910 :DESCRIPTION: Processing Org to Texinfo.
14911 :END:
14913 Here is a more detailed example Org file.  See
14914 [[info:texinfo::GNU Sample Texts]] for an equivalent example using
14915 Texinfo code.
14917 #+begin_example
14918 ,#+TITLE: GNU Sample {{{version}}}
14919 ,#+SUBTITLE: for version {{{version}}}, {{{updated}}}
14920 ,#+AUTHOR: A.U. Thor
14921 ,#+EMAIL: bug-sample@gnu.org
14923 ,#+OPTIONS: ':t toc:t author:t email:t
14924 ,#+LANGUAGE: en
14926 ,#+MACRO: version 2.0
14927 ,#+MACRO: updated last updated 4 March 2014
14929 ,#+TEXINFO_FILENAME: sample.info
14930 ,#+TEXINFO_HEADER: @syncodeindex pg cp
14932 ,#+TEXINFO_DIR_CATEGORY: Texinfo documentation system
14933 ,#+TEXINFO_DIR_TITLE: sample: (sample)
14934 ,#+TEXINFO_DIR_DESC: Invoking sample
14936 ,#+TEXINFO_PRINTED_TITLE: GNU Sample
14938 This manual is for GNU Sample (version {{{version}}},
14939 {{{updated}}}).
14941 ,* Copying
14942   :PROPERTIES:
14943   :COPYING:  t
14944   :END:
14946   This manual is for GNU Sample (version {{{version}}},
14947   {{{updated}}}), which is an example in the Texinfo documentation.
14949   Copyright \copy 2016 Free Software Foundation, Inc.
14951   ,#+BEGIN_QUOTE
14952   Permission is granted to copy, distribute and/or modify this
14953   document under the terms of the GNU Free Documentation License,
14954   Version 1.3 or any later version published by the Free Software
14955   Foundation; with no Invariant Sections, with no Front-Cover Texts,
14956   and with no Back-Cover Texts.  A copy of the license is included in
14957   the section entitled "GNU Free Documentation License".
14958   ,#+END_QUOTE
14960 ,* Invoking sample
14962   ,#+PINDEX: sample
14963   ,#+CINDEX: invoking @command{sample}
14965   This is a sample manual.  There is no sample program to invoke, but
14966   if there were, you could see its basic usage and command line
14967   options here.
14969 ,* GNU Free Documentation License
14970   :PROPERTIES:
14971   :APPENDIX: t
14972   :END:
14974   ,#+INCLUDE: fdl.org
14976 ,* Index
14977   :PROPERTIES:
14978   :INDEX:    cp
14979   :END:
14980 #+end_example
14982 ** iCalendar Export
14983 :PROPERTIES:
14984 :DESCRIPTION: Exporting to iCalendar.
14985 :END:
14986 #+cindex: iCalendar export
14988 A large part of Org mode's interoperability success is its ability to
14989 easily export to or import from external applications.  The iCalendar
14990 export back-end takes calendar data from Org files and exports to the
14991 standard iCalendar format.
14993 #+vindex: org-icalendar-include-todo
14994 #+vindex: org-icalendar-use-deadline
14995 #+vindex: org-icalendar-use-scheduled
14996 The iCalendar export back-end can also incorporate TODO entries based
14997 on the configuration of the ~org-icalendar-include-todo~ variable.
14998 The back-end exports plain timestamps as =VEVENT=, TODO items as
14999 =VTODO=, and also create events from deadlines that are in non-TODO
15000 items.  The back-end uses the deadlines and scheduling dates in Org
15001 TODO items for setting the start and due dates for the iCalendar TODO
15002 entry.  Consult the ~org-icalendar-use-deadline~ and
15003 ~org-icalendar-use-scheduled~ variables for more details.
15005 #+vindex: org-icalendar-categories
15006 #+vindex: org-icalendar-alarm-time
15007 For tags on the headline, the iCalendar export back-end makes them
15008 into iCalendar categories.  To tweak the inheritance of tags and TODO
15009 states, configure the variable ~org-icalendar-categories~.  To assign
15010 clock alarms based on time, configure the ~org-icalendar-alarm-time~
15011 variable.
15013 #+vindex: org-icalendar-store-UID
15014 #+cindex: @samp{ID}, property
15015 The iCalendar format standard requires globally unique identifier---or
15016 UID---for each entry.  The iCalendar export back-end creates UIDs
15017 during export.  To save a copy of the UID in the Org file set the
15018 variable ~org-icalendar-store-UID~.  The back-end looks for the =ID=
15019 property of the entry for re-using the same UID for subsequent
15020 exports.
15022 Since a single Org entry can result in multiple iCalendar
15023 entries---timestamp, deadline, scheduled item, or TODO item---Org adds
15024 prefixes to the UID, depending on which part of the Org entry
15025 triggered the creation of the iCalendar entry.  Prefixing ensures UIDs
15026 remains unique, yet enable synchronization programs trace the
15027 connections.
15029 - {{{kbd(C-c C-e c f)}}} (~org-icalendar-export-to-ics~) ::
15031   #+kindex: C-c C-e c f
15032   #+findex: org-icalendar-export-to-ics
15033   Create iCalendar entries from the current Org buffer and store them
15034   in the same directory, using a file extension =.ics=.
15036 - {{{kbd(C-c C-e c a)}}} (~org-icalendar-export-agenda-files~) ::
15038   #+kindex: C-c C-e c a
15039   #+findex: org-icalendar-export-agenda-files
15040   Create iCalendar entries from Org files in ~org-agenda-files~ and
15041   store in a separate iCalendar file for each Org file.
15043 - {{{kbd(C-c C-e c c)}}} (~org-icalendar-combine-agenda-files~) ::
15045   #+kindex: C-c C-e c c
15046   #+findex: org-icalendar-combine-agenda-files
15047   #+vindex: org-icalendar-combined-agenda-file
15048   Create a combined iCalendar file from Org files in
15049   ~org-agenda-files~ and write it to
15050   ~org-icalendar-combined-agenda-file~ file name.
15052 #+cindex: @samp{SUMMARY}, property
15053 #+cindex: @samp{DESCRIPTION}, property
15054 #+cindex: @samp{LOCATION}, property
15055 #+cindex: @samp{TIMEZONE}, property
15056 #+cindex: @samp{CLASS}, property
15057 The iCalendar export back-end includes =SUMMARY=, =DESCRIPTION=,
15058 =LOCATION=, =TIMEZONE= and =CLASS= properties from the Org entries
15059 when exporting.  To force the back-end to inherit the =LOCATION=,
15060 =TIMEZONE= and =CLASS= properties, configure the
15061 ~org-use-property-inheritance~ variable.
15063 #+vindex: org-icalendar-include-body
15064 When Org entries do not have =SUMMARY=, =DESCRIPTION=, =LOCATION= and
15065 =CLASS= properties, the iCalendar export back-end derives the summary
15066 from the headline, and derives the description from the body of the
15067 Org item.  The ~org-icalendar-include-body~ variable limits the
15068 maximum number of characters of the content are turned into its
15069 description.
15071 The =TIMEZONE= property can be used to specify a per-entry time zone,
15072 and is applied to any entry with timestamp information.  Time zones
15073 should be specified as per the IANA time zone database format, e.g.,
15074 =Asia/Almaty=.  Alternately, the property value can be =UTC=, to force
15075 UTC time for this entry only.
15077 The =CLASS= property can be used to specify a per-entry visibility
15078 class or access restrictions, and is applied to any entry with class
15079 information.  The iCalendar standard defines three visibility classes:
15080 - =PUBLIC= :: The entry is publicly visible (this is the default).
15081 - =CONFIDENTIAL= :: Only a limited group of clients get access to the
15082   event.
15083 - =PRIVATE= :: The entry can be retrieved only by its owner.
15084 The server should treat unknown class properties the same as
15085 =PRIVATE=.
15087 Exporting to iCalendar format depends in large part on the
15088 capabilities of the destination application.  Some are more lenient
15089 than others.  Consult the Org mode FAQ for advice on specific
15090 applications.
15092 ** Other Built-in Back-ends
15093 :PROPERTIES:
15094 :DESCRIPTION: Exporting to a man page.
15095 :END:
15097 Other export back-ends included with Org are:
15099 - =ox-man.el=: Export to a man page.
15101 To activate such back-ends, either customize ~org-export-backends~ or
15102 load directly with =(require 'ox-man)=.  On successful load, the
15103 back-end adds new keys in the export dispatcher (see [[*The Export
15104 Dispatcher]]).
15106 Follow the comment section of such files, for example, =ox-man.el=,
15107 for usage and configuration details.
15109 ** Advanced Export Configuration
15110 :PROPERTIES:
15111 :DESCRIPTION: Fine-tuning the export output.
15112 :END:
15114 *** Hooks
15115 :PROPERTIES:
15116 :UNNUMBERED: notoc
15117 :END:
15119 #+vindex: org-export-before-processing-hook
15120 #+vindex: org-export-before-parsing-hook
15121 The export process executes two hooks before the actual exporting
15122 begins.  The first hook, ~org-export-before-processing-hook~, runs
15123 before any expansions of macros, Babel code, and include keywords in
15124 the buffer.  The second hook, ~org-export-before-parsing-hook~, runs
15125 before the buffer is parsed.
15127 Functions added to these hooks are called with a single argument: the
15128 export back-end actually used, as a symbol.  You may use them for
15129 heavy duty structural modifications of the document.  For example, you
15130 can remove every headline in the buffer during export like this:
15132 #+begin_src emacs-lisp
15133 (defun my-headline-removal (backend)
15134   "Remove all headlines in the current buffer.
15135 BACKEND is the export back-end being used, as a symbol."
15136   (org-map-entries
15137    (lambda () (delete-region (point) (line-beginning-position 2)))))
15139 (add-hook 'org-export-before-parsing-hook 'my-headline-removal)
15140 #+end_src
15142 *** Filters
15143 :PROPERTIES:
15144 :UNNUMBERED: notoc
15145 :END:
15147 #+cindex: Filters, exporting
15148 Filters are lists of functions to be applied to certain parts for
15149 a given back-end.  The output from the first function in the filter is
15150 passed on to the next function in the filter.  The final output is the
15151 output from the final function in the filter.
15153 The Org export process has many filter sets applicable to different
15154 types of objects, plain text, parse trees, export options, and final
15155 output formats.  The filters are named after the element type or
15156 object type: ~org-export-filter-TYPE-functions~, where {{{var(TYPE)}}}
15157 is the type targeted by the filter.  Valid types are:
15159 #+attr_texinfo: :columns 0.33 0.33 0.33
15160 | body                | bold               | babel-call       |
15161 | center-block        | clock              | code             |
15162 | diary-sexp          | drawer             | dynamic-block    |
15163 | entity              | example-block      | export-block     |
15164 | export-snippet      | final-output       | fixed-width      |
15165 | footnote-definition | footnote-reference | headline         |
15166 | horizontal-rule     | inline-babel-call  | inline-src-block |
15167 | inlinetask          | italic             | item             |
15168 | keyword             | latex-environment  | latex-fragment   |
15169 | line-break          | link               | node-property    |
15170 | options             | paragraph          | parse-tree       |
15171 | plain-list          | plain-text         | planning         |
15172 | property-drawer     | quote-block        | radio-target     |
15173 | section             | special-block      | src-block        |
15174 | statistics-cookie   | strike-through     | subscript        |
15175 | superscript         | table              | table-cell       |
15176 | table-row           | target             | timestamp        |
15177 | underline           | verbatim           | verse-block      |
15179 Here is an example filter that replaces non-breaking spaces ~ ~ in the
15180 Org buffer with =~= for the LaTeX back-end.
15182 #+begin_src emacs-lisp
15183 (defun my-latex-filter-nobreaks (text backend info)
15184   "Ensure \" \" are properly handled in LaTeX export."
15185   (when (org-export-derived-backend-p backend 'latex)
15186     (replace-regexp-in-string " " "~" text)))
15188 (add-to-list 'org-export-filter-plain-text-functions
15189              'my-latex-filter-nobreaks)
15190 #+end_src
15192 A filter requires three arguments: the code to be transformed, the
15193 name of the back-end, and some optional information about the export
15194 process.  The third argument can be safely ignored.  Note the use of
15195 ~org-export-derived-backend-p~ predicate that tests for /latex/
15196 back-end or any other back-end, such as /beamer/, derived from
15197 /latex/.
15199 *** Defining filters for individual files
15200 :PROPERTIES:
15201 :UNNUMBERED: notoc
15202 :END:
15204 The Org export can filter not just for back-ends, but also for
15205 specific files through the =BIND= keyword.  Here is an example with
15206 two filters; one removes brackets from time stamps, and the other
15207 removes strike-through text.  The filter functions are defined in
15208 a code block in the same Org file, which is a handy location for
15209 debugging.
15211 #+begin_example
15212 ,#+BIND: org-export-filter-timestamp-functions (tmp-f-timestamp)
15213 ,#+BIND: org-export-filter-strike-through-functions (tmp-f-strike-through)
15214 ,#+BEGIN_SRC emacs-lisp :exports results :results none
15215   (defun tmp-f-timestamp (s backend info)
15216     (replace-regexp-in-string "&[lg]t;\\|[][]" "" s))
15217   (defun tmp-f-strike-through (s backend info) "")
15218 ,#+END_SRC
15219 #+end_example
15221 *** Extending an existing back-end
15222 :PROPERTIES:
15223 :UNNUMBERED: notoc
15224 :END:
15226 Some parts of the conversion process can be extended for certain
15227 elements so as to introduce a new or revised translation.  That is how
15228 the HTML export back-end was extended to handle Markdown format.  The
15229 extensions work seamlessly so any aspect of filtering not done by the
15230 extended back-end is handled by the original back-end.  Of all the
15231 export customization in Org, extending is very powerful as it operates
15232 at the parser level.
15234 For this example, make the /ascii/ back-end display the language used
15235 in a source code block.  Also make it display only when some attribute
15236 is non-~nil~, like the following:
15238 : #+ATTR_ASCII: :language t
15240 Then extend ASCII back-end with a custom "my-ascii" back-end.
15242 #+begin_src emacs-lisp
15243 (defun my-ascii-src-block (src-block contents info)
15244   "Transcode a SRC-BLOCK element from Org to ASCII.
15245 CONTENTS is nil.  INFO is a plist used as a communication
15246 channel."
15247   (if (not (org-export-read-attribute :attr_ascii src-block :language))
15248       (org-export-with-backend 'ascii src-block contents info)
15249     (concat
15250      (format ",--[ %s ]--\n%s`----"
15251              (org-element-property :language src-block)
15252              (replace-regexp-in-string
15253               "^" "| "
15254               (org-element-normalize-string
15255                (org-export-format-code-default src-block info)))))))
15257 (org-export-define-derived-backend 'my-ascii 'ascii
15258   :translate-alist '((src-block . my-ascii-src-block)))
15259 #+end_src
15261 The ~my-ascii-src-block~ function looks at the attribute above the
15262 current element.  If not true, hands over to /ascii/ back-end.  If
15263 true, which it is in this example, it creates a box around the code
15264 and leaves room for the inserting a string for language.  The last
15265 form creates the new back-end that springs to action only when
15266 translating ~src-block~ type elements.
15268 To use the newly defined back-end, evaluate the following from an Org
15269 buffer:
15271 #+begin_src emacs-lisp
15272 (org-export-to-buffer 'my-ascii "*Org MY-ASCII Export*")
15273 #+end_src
15275 Further steps to consider would be an interactive function,
15276 self-installing an item in the export dispatcher menu, and other
15277 user-friendly improvements.
15279 ** Export in Foreign Buffers
15280 :PROPERTIES:
15281 :DESCRIPTION: Author tables and lists in Org syntax.
15282 :END:
15284 The export back-ends in Org often include commands to convert selected
15285 regions.  A convenient feature of this in-place conversion is that the
15286 exported output replaces the original source.  Here are such
15287 functions:
15289 - ~org-ascii-convert-region-to-ascii~ ::
15291   #+findex: org-ascii-convert-region-to-ascii
15292   Convert the selected region into ASCII.
15294 - ~org-ascii-convert-region-to-utf8~ ::
15296   #+findex: org-ascii-convert-region-to-utf8
15297   Convert the selected region into UTF-8.
15299 - ~org-html-convert-region-to-html~ ::
15301   #+findex: org-html-convert-region-to-html
15302   Convert the selected region into HTML.
15304 - ~org-latex-convert-region-to-latex~ ::
15306   #+findex: org-latex-convert-region-to-latex
15307   Convert the selected region into LaTeX.
15309 - ~org-texinfo-convert-region-to-texinfo~ ::
15311   #+findex: org-texinfo-convert-region-to-texinfo
15312   Convert the selected region into Texinfo.
15314 - ~org-md-convert-region-to-md~ ::
15316   #+findex: org-md-convert-region-to-md
15317   Convert the selected region into Markdown.
15319 In-place conversions are particularly handy for quick conversion of
15320 tables and lists in foreign buffers.  For example, in an HTML buffer,
15321 write a list in Org syntax, select it, and convert it to HTML with
15322 {{{kbd(M-x org-html-convert-region-to-html)}}}.
15324 * Publishing
15325 :PROPERTIES:
15326 :DESCRIPTION: Create a web site of linked Org files.
15327 :END:
15328 #+cindex: publishing
15330 Org includes a publishing management system that allows you to
15331 configure automatic HTML conversion of /projects/ composed of
15332 interlinked Org files.  You can also configure Org to automatically
15333 upload your exported HTML pages and related attachments, such as
15334 images and source code files, to a web server.
15336 You can also use Org to convert files into PDF, or even combine HTML
15337 and PDF conversion so that files are available in both formats on the
15338 server.
15340 Publishing has been contributed to Org by David O'Toole.
15342 ** Configuration
15343 :PROPERTIES:
15344 :DESCRIPTION: Defining projects.
15345 :END:
15346 Publishing needs significant configuration to specify files,
15347 destination and many other properties of a project.
15349 *** The variable ~org-publish-project-alist~
15350 :PROPERTIES:
15351 :DESCRIPTION: The central configuration variable.
15352 :ALT_TITLE: Project alist
15353 :END:
15354 #+cindex: projects, for publishing
15356 #+vindex: org-publish-project-alist
15357 Publishing is configured almost entirely through setting the value of
15358 one variable, called ~org-publish-project-alist~.  Each element of the
15359 list configures one project, and may be in one of the two following
15360 forms:
15362 #+begin_src emacs-lisp
15363 ("project-name" :property value :property value ...)
15364 #+end_src
15366 #+texinfo: @noindent
15367 i.e., a well-formed property list with alternating keys and values,
15370 #+begin_src emacs-lisp
15371 ("project-name" :components ("project-name" "project-name" ...))
15372 #+end_src
15374 In both cases, projects are configured by specifying property values.
15375 A project defines the set of files that are to be published, as well
15376 as the publishing configuration to use when publishing those files.
15377 When a project takes the second form listed above, the individual
15378 members of the ~:components~ property are taken to be sub-projects,
15379 which group together files requiring different publishing options.
15380 When you publish such a "meta-project", all the components are also
15381 published, in the sequence given.
15383 *** Sources and destinations for files
15384 :PROPERTIES:
15385 :DESCRIPTION: From here to there.
15386 :ALT_TITLE: Sources and destinations
15387 :END:
15388 #+cindex: directories, for publishing
15390 Most properties are optional, but some should always be set.  In
15391 particular, Org needs to know where to look for source files, and
15392 where to put published files.
15394 - ~:base-directory~ ::
15396   Directory containing publishing source files.
15398 - ~:publishing-directory~ ::
15400   Directory where output files are published.  You can directly
15401   publish to a webserver using a file name syntax appropriate for the
15402   Emacs tramp package.  Or you can publish to a local directory and
15403   use external tools to upload your website (see [[*Uploading Files]]).
15405 - ~:preparation-function~ ::
15407   Function or list of functions to be called before starting the
15408   publishing process, for example, to run =make= for updating files to
15409   be published.  Each preparation function is called with a single
15410   argument, the project property list.
15412 - ~:completion-function~ ::
15414   Function or list of functions called after finishing the publishing
15415   process, for example, to change permissions of the resulting files.
15416   Each completion function is called with a single argument, the
15417   project property list.
15419 *** Selecting files
15420 :PROPERTIES:
15421 :DESCRIPTION: What files are part of the project?
15422 :END:
15423 #+cindex: files, selecting for publishing
15425 By default, all files with extension =.org= in the base directory are
15426 considered part of the project.  This can be modified by setting the
15427 following properties
15429 - ~:base-extension~ ::
15431   Extension---without the dot---of source files.  This actually is
15432   a regular expression.  Set this to the symbol ~any~ if you want to
15433   get all files in ~:base-directory~, even without extension.
15435 - ~:exclude~ ::
15437   Regular expression to match file names that should not be published,
15438   even though they have been selected on the basis of their extension.
15440 - ~:include~ ::
15442   List of files to be included regardless of ~:base-extension~ and
15443   ~:exclude~.
15445 - ~:recursive~ ::
15447   Non-~nil~ means, check base-directory recursively for files to
15448   publish.
15450 *** Publishing action
15451 :PROPERTIES:
15452 :DESCRIPTION: Setting the function doing the publishing.
15453 :END:
15454 #+cindex: action, for publishing
15456 Publishing means that a file is copied to the destination directory
15457 and possibly transformed in the process.  The default transformation
15458 is to export Org files as HTML files, and this is done by the function
15459 ~org-publish-org-to-html~ which calls the HTML exporter (see [[*HTML
15460 Export]]).  But you can also publish your content as PDF files using
15461 ~org-publish-org-to-pdf~, or as ASCII, Texinfo, etc., using the
15462 corresponding functions.
15464 If you want to publish the Org file as an =.org= file but with
15465 /archived/, /commented/, and /tag-excluded/ trees removed, use
15466 ~org-publish-org-to-org~.  This produces =file.org= and put it in the
15467 publishing directory.  If you want a htmlized version of this file,
15468 set the parameter ~:htmlized-source~ to ~t~.  It produces
15469 =file.org.html= in the publishing directory[fn:139].
15471 Other files like images only need to be copied to the publishing
15472 destination; for this you can use ~org-publish-attachment~.  For
15473 non-Org files, you always need to specify the publishing function:
15475 - ~:publishing-function~ ::
15477   Function executing the publication of a file.  This may also be
15478   a list of functions, which are all called in turn.
15480 - ~:htmlized-source~ ::
15482   Non-~nil~ means, publish htmlized source.
15484 The function must accept three arguments: a property list containing
15485 at least a ~:publishing-directory~ property, the name of the file to
15486 be published, and the path to the publishing directory of the output
15487 file.  It should take the specified file, make the necessary
15488 transformation, if any, and place the result into the destination
15489 folder.
15491 *** Options for the exporters
15492 :PROPERTIES:
15493 :DESCRIPTION: Tweaking HTML/@LaTeX{} export.
15494 :ALT_TITLE: Publishing options
15495 :END:
15496 #+cindex: options, for publishing
15497 #+cindex: publishing options
15499 The property list can be used to set many export options for the HTML
15500 and LaTeX exporters.  In most cases, these properties correspond to
15501 user variables in Org.  The table below lists these properties along
15502 with the variable they belong to.  See the documentation string for
15503 the respective variable for details.
15505 #+vindex: org-publish-project-alist
15506 When a property is given a value in ~org-publish-project-alist~, its
15507 setting overrides the value of the corresponding user variable, if
15508 any, during publishing.  Options set within a file (see [[*Export
15509 Settings]]), however, override everything.
15511 **** Generic properties
15512 :PROPERTIES:
15513 :UNNUMBERED: notoc
15514 :END:
15516 | ~:archived-trees~       | ~org-export-with-archived-trees~   |
15517 | ~:exclude-tags~         | ~org-export-exclude-tags~          |
15518 | ~:headline-levels~      | ~org-export-headline-levels~       |
15519 | ~:language~             | ~org-export-default-language~      |
15520 | ~:preserve-breaks~      | ~org-export-preserve-breaks~       |
15521 | ~:section-numbers~      | ~org-export-with-section-numbers~  |
15522 | ~:select-tags~          | ~org-export-select-tags~           |
15523 | ~:with-author~          | ~org-export-with-author~           |
15524 | ~:with-broken-links~    | ~org-export-with-broken-links~     |
15525 | ~:with-clocks~          | ~org-export-with-clocks~           |
15526 | ~:with-creator~         | ~org-export-with-creator~          |
15527 | ~:with-date~            | ~org-export-with-date~             |
15528 | ~:with-drawers~         | ~org-export-with-drawers~          |
15529 | ~:with-email~           | ~org-export-with-email~            |
15530 | ~:with-emphasize~       | ~org-export-with-emphasize~        |
15531 | ~:with-fixed-width~     | ~org-export-with-fixed-width~      |
15532 | ~:with-footnotes~       | ~org-export-with-footnotes~        |
15533 | ~:with-latex~           | ~org-export-with-latex~            |
15534 | ~:with-planning~        | ~org-export-with-planning~         |
15535 | ~:with-priority~        | ~org-export-with-priority~         |
15536 | ~:with-properties~      | ~org-export-with-properties~       |
15537 | ~:with-special-strings~ | ~org-export-with-special-strings~  |
15538 | ~:with-sub-superscript~ | ~org-export-with-sub-superscripts~ |
15539 | ~:with-tables~          | ~org-export-with-tables~           |
15540 | ~:with-tags~            | ~org-export-with-tags~             |
15541 | ~:with-tasks~           | ~org-export-with-tasks~            |
15542 | ~:with-timestamps~      | ~org-export-with-timestamps~       |
15543 | ~:with-title~           | ~org-export-with-title~            |
15544 | ~:with-toc~             | ~org-export-with-toc~              |
15545 | ~:with-todo-keywords~   | ~org-export-with-todo-keywords~    |
15547 **** ASCII specific properties
15548 :PROPERTIES:
15549 :UNNUMBERED: notoc
15550 :END:
15552 | ~:ascii-bullets~                       | ~org-ascii-bullets~                       |
15553 | ~:ascii-caption-above~                 | ~org-ascii-caption-above~                 |
15554 | ~:ascii-charset~                       | ~org-ascii-charset~                       |
15555 | ~:ascii-global-margin~                 | ~org-ascii-global-margin~                 |
15556 | ~:ascii-format-drawer-function~        | ~org-ascii-format-drawer-function~        |
15557 | ~:ascii-format-inlinetask-function~    | ~org-ascii-format-inlinetask-function~    |
15558 | ~:ascii-headline-spacing~              | ~org-ascii-headline-spacing~              |
15559 | ~:ascii-indented-line-width~           | ~org-ascii-indented-line-width~           |
15560 | ~:ascii-inlinetask-width~              | ~org-ascii-inlinetask-width~              |
15561 | ~:ascii-inner-margin~                  | ~org-ascii-inner-margin~                  |
15562 | ~:ascii-links-to-notes~                | ~org-ascii-links-to-notes~                |
15563 | ~:ascii-list-margin~                   | ~org-ascii-list-margin~                   |
15564 | ~:ascii-paragraph-spacing~             | ~org-ascii-paragraph-spacing~             |
15565 | ~:ascii-quote-margin~                  | ~org-ascii-quote-margin~                  |
15566 | ~:ascii-table-keep-all-vertical-lines~ | ~org-ascii-table-keep-all-vertical-lines~ |
15567 | ~:ascii-table-use-ascii-art~           | ~org-ascii-table-use-ascii-art~           |
15568 | ~:ascii-table-widen-columns~           | ~org-ascii-table-widen-columns~           |
15569 | ~:ascii-text-width~                    | ~org-ascii-text-width~                    |
15570 | ~:ascii-underline~                     | ~org-ascii-underline~                     |
15571 | ~:ascii-verbatim-format~               | ~org-ascii-verbatim-format~               |
15573 **** Beamer specific properties
15574 :PROPERTIES:
15575 :UNNUMBERED: notoc
15576 :END:
15578 | ~:beamer-theme~                 | ~org-beamer-theme~                 |
15579 | ~:beamer-column-view-format~    | ~org-beamer-column-view-format~    |
15580 | ~:beamer-environments-extra~    | ~org-beamer-environments-extra~    |
15581 | ~:beamer-frame-default-options~ | ~org-beamer-frame-default-options~ |
15582 | ~:beamer-outline-frame-options~ | ~org-beamer-outline-frame-options~ |
15583 | ~:beamer-outline-frame-title~   | ~org-beamer-outline-frame-title~   |
15584 | ~:beamer-subtitle-format~       | ~org-beamer-subtitle-format~       |
15586 **** HTML specific properties
15587 :PROPERTIES:
15588 :UNNUMBERED: notoc
15589 :END:
15591 | ~:html-allow-name-attribute-in-anchors~        | ~org-html-allow-name-attribute-in-anchors~        |
15592 | ~:html-checkbox-type~                          | ~org-html-checkbox-type~                          |
15593 | ~:html-container~                              | ~org-html-container-element~                      |
15594 | ~:html-divs~                                   | ~org-html-divs~                                   |
15595 | ~:html-doctype~                                | ~org-html-doctype~                                |
15596 | ~:html-extension~                              | ~org-html-extension~                              |
15597 | ~:html-footnote-format~                        | ~org-html-footnote-format~                        |
15598 | ~:html-footnote-separator~                     | ~org-html-footnote-separator~                     |
15599 | ~:html-footnotes-section~                      | ~org-html-footnotes-section~                      |
15600 | ~:html-format-drawer-function~                 | ~org-html-format-drawer-function~                 |
15601 | ~:html-format-headline-function~               | ~org-html-format-headline-function~               |
15602 | ~:html-format-inlinetask-function~             | ~org-html-format-inlinetask-function~             |
15603 | ~:html-head-extra~                             | ~org-html-head-extra~                             |
15604 | ~:html-head-include-default-style~             | ~org-html-head-include-default-style~             |
15605 | ~:html-head-include-scripts~                   | ~org-html-head-include-scripts~                   |
15606 | ~:html-head~                                   | ~org-html-head~                                   |
15607 | ~:html-home/up-format~                         | ~org-html-home/up-format~                         |
15608 | ~:html-html5-fancy~                            | ~org-html-html5-fancy~                            |
15609 | ~:html-indent~                                 | ~org-html-indent~                                 |
15610 | ~:html-infojs-options~                         | ~org-html-infojs-options~                         |
15611 | ~:html-infojs-template~                        | ~org-html-infojs-template~                        |
15612 | ~:html-inline-image-rules~                     | ~org-html-inline-image-rules~                     |
15613 | ~:html-inline-images~                          | ~org-html-inline-images~                          |
15614 | ~:html-link-home~                              | ~org-html-link-home~                              |
15615 | ~:html-link-org-files-as-html~                 | ~org-html-link-org-files-as-html~                 |
15616 | ~:html-link-up~                                | ~org-html-link-up~                                |
15617 | ~:html-link-use-abs-url~                       | ~org-html-link-use-abs-url~                       |
15618 | ~:html-mathjax-options~                        | ~org-html-mathjax-options~                        |
15619 | ~:html-mathjax-template~                       | ~org-html-mathjax-template~                       |
15620 | ~:html-metadata-timestamp-format~              | ~org-html-metadata-timestamp-format~              |
15621 | ~:html-postamble-format~                       | ~org-html-postamble-format~                       |
15622 | ~:html-postamble~                              | ~org-html-postamble~                              |
15623 | ~:html-preamble-format~                        | ~org-html-preamble-format~                        |
15624 | ~:html-preamble~                               | ~org-html-preamble~                               |
15625 | ~:html-self-link-headlines~                    | ~org-html-self-link-headlines~                    |
15626 | ~:html-table-align-individual-field~           | ~de{org-html-table-align-individual-fields~       |
15627 | ~:html-table-attributes~                       | ~org-html-table-default-attributes~               |
15628 | ~:html-table-caption-above~                    | ~org-html-table-caption-above~                    |
15629 | ~:html-table-data-tags~                        | ~org-html-table-data-tags~                        |
15630 | ~:html-table-header-tags~                      | ~org-html-table-header-tags~                      |
15631 | ~:html-table-row-tags~                         | ~org-html-table-row-tags~                         |
15632 | ~:html-table-use-header-tags-for-first-column~ | ~org-html-table-use-header-tags-for-first-column~ |
15633 | ~:html-tag-class-prefix~                       | ~org-html-tag-class-prefix~                       |
15634 | ~:html-text-markup-alist~                      | ~org-html-text-markup-alist~                      |
15635 | ~:html-todo-kwd-class-prefix~                  | ~org-html-todo-kwd-class-prefix~                  |
15636 | ~:html-toplevel-hlevel~                        | ~org-html-toplevel-hlevel~                        |
15637 | ~:html-use-infojs~                             | ~org-html-use-infojs~                             |
15638 | ~:html-validation-link~                        | ~org-html-validation-link~                        |
15639 | ~:html-viewport~                               | ~org-html-viewport~                               |
15640 | ~:html-xml-declaration~                        | ~org-html-xml-declaration~                        |
15642 **** LaTeX specific properties
15643 :PROPERTIES:
15644 :UNNUMBERED: notoc
15645 :END:
15647 | ~:latex-active-timestamp-format~       | ~org-latex-active-timestamp-format~       |
15648 | ~:latex-caption-above~                 | ~org-latex-caption-above~                 |
15649 | ~:latex-classes~                       | ~org-latex-classes~                       |
15650 | ~:latex-class~                         | ~org-latex-default-class~                 |
15651 | ~:latex-compiler~                      | ~org-latex-compiler~                      |
15652 | ~:latex-default-figure-position~       | ~org-latex-default-figure-position~       |
15653 | ~:latex-default-table-environment~     | ~org-latex-default-table-environment~     |
15654 | ~:latex-default-table-mode~            | ~org-latex-default-table-mode~            |
15655 | ~:latex-diary-timestamp-format~        | ~org-latex-diary-timestamp-format~        |
15656 | ~:latex-footnote-defined-format~       | ~org-latex-footnote-defined-format~       |
15657 | ~:latex-footnote-separator~            | ~org-latex-footnote-separator~            |
15658 | ~:latex-format-drawer-function~        | ~org-latex-format-drawer-function~        |
15659 | ~:latex-format-headline-function~      | ~org-latex-format-headline-function~      |
15660 | ~:latex-format-inlinetask-function~    | ~org-latex-format-inlinetask-function~    |
15661 | ~:latex-hyperref-template~             | ~org-latex-hyperref-template~             |
15662 | ~:latex-image-default-height~          | ~org-latex-image-default-height~          |
15663 | ~:latex-image-default-option~          | ~org-latex-image-default-option~          |
15664 | ~:latex-image-default-width~           | ~org-latex-image-default-width~           |
15665 | ~:latex-images-centered~               | ~org-latex-images-centered~               |
15666 | ~:latex-inactive-timestamp-format~     | ~org-latex-inactive-timestamp-format~     |
15667 | ~:latex-inline-image-rules~            | ~org-latex-inline-image-rules~            |
15668 | ~:latex-link-with-unknown-path-format~ | ~org-latex-link-with-unknown-path-format~ |
15669 | ~:latex-listings-langs~                | ~org-latex-listings-langs~                |
15670 | ~:latex-listings-options~              | ~org-latex-listings-options~              |
15671 | ~:latex-listings~                      | ~org-latex-listings~                      |
15672 | ~:latex-minted-langs~                  | ~org-latex-minted-langs~                  |
15673 | ~:latex-minted-options~                | ~org-latex-minted-options~                |
15674 | ~:latex-prefer-user-labels~            | ~org-latex-prefer-user-labels~            |
15675 | ~:latex-subtitle-format~               | ~org-latex-subtitle-format~               |
15676 | ~:latex-subtitle-separate~             | ~org-latex-subtitle-separate~             |
15677 | ~:latex-table-scientific-notation~     | ~org-latex-table-scientific-notation~     |
15678 | ~:latex-tables-booktabs~               | ~org-latex-tables-booktabs~               |
15679 | ~:latex-tables-centered~               | ~org-latex-tables-centered~               |
15680 | ~:latex-text-markup-alist~             | ~org-latex-text-markup-alist~             |
15681 | ~:latex-title-command~                 | ~org-latex-title-command~                 |
15682 | ~:latex-toc-command~                   | ~org-latex-toc-command~                   |
15684 **** Markdown specific properties
15685 :PROPERTIES:
15686 :UNNUMBERED: notoc
15687 :END:
15689 | ~:md-footnote-format~   | ~org-md-footnote-format~   |
15690 | ~:md-footnotes-section~ | ~org-md-footnotes-section~ |
15691 | ~:md-headline-style~    | ~org-md-headline-style~    |
15693 **** ODT specific properties
15694 :PROPERTIES:
15695 :UNNUMBERED: notoc
15696 :END:
15698 | ~:odt-content-template-file~      | ~org-odt-content-template-file~      |
15699 | ~:odt-display-outline-level~      | ~org-odt-display-outline-level~      |
15700 | ~:odt-fontify-srcblocks~          | ~org-odt-fontify-srcblocks~          |
15701 | ~:odt-format-drawer-function~     | ~org-odt-format-drawer-function~     |
15702 | ~:odt-format-headline-function~   | ~org-odt-format-headline-function~   |
15703 | ~:odt-format-inlinetask-function~ | ~org-odt-format-inlinetask-function~ |
15704 | ~:odt-inline-formula-rules~       | ~org-odt-inline-formula-rules~       |
15705 | ~:odt-inline-image-rules~         | ~org-odt-inline-image-rules~         |
15706 | ~:odt-pixels-per-inch~            | ~org-odt-pixels-per-inch~            |
15707 | ~:odt-styles-file~                | ~org-odt-styles-file~                |
15708 | ~:odt-table-styles~               | ~org-odt-table-styles~               |
15709 | ~:odt-use-date-fields~            | ~org-odt-use-date-fields~            |
15711 **** Texinfo specific properties
15712 :PROPERTIES:
15713 :UNNUMBERED: notoc
15714 :END:
15716 | ~:texinfo-active-timestamp-format~       | ~org-texinfo-active-timestamp-format~       |
15717 | ~:texinfo-classes~                       | ~org-texinfo-classes~                       |
15718 | ~:texinfo-class~                         | ~org-texinfo-default-class~                 |
15719 | ~:texinfo-table-default-markup~          | ~org-texinfo-table-default-markup~          |
15720 | ~:texinfo-diary-timestamp-format~        | ~org-texinfo-diary-timestamp-format~        |
15721 | ~:texinfo-filename~                      | ~org-texinfo-filename~                      |
15722 | ~:texinfo-format-drawer-function~        | ~org-texinfo-format-drawer-function~        |
15723 | ~:texinfo-format-headline-function~      | ~org-texinfo-format-headline-function~      |
15724 | ~:texinfo-format-inlinetask-function~    | ~org-texinfo-format-inlinetask-function~    |
15725 | ~:texinfo-inactive-timestamp-format~     | ~org-texinfo-inactive-timestamp-format~     |
15726 | ~:texinfo-link-with-unknown-path-format~ | ~org-texinfo-link-with-unknown-path-format~ |
15727 | ~:texinfo-node-description-column~       | ~org-texinfo-node-description-column~       |
15728 | ~:texinfo-table-scientific-notation~     | ~org-texinfo-table-scientific-notation~     |
15729 | ~:texinfo-tables-verbatim~               | ~org-texinfo-tables-verbatim~               |
15730 | ~:texinfo-text-markup-alist~             | ~org-texinfo-text-markup-alist~             |
15732 *** Publishing links
15733 :PROPERTIES:
15734 :DESCRIPTION: Which links keep working after publishing?
15735 :END:
15736 #+cindex: links, publishing
15738 To create a link from one Org file to another, you would use something
15739 like =[[file:foo.org][The foo]]= or simply =[[file:foo.org]]= (see [[*External Links]]).  When
15740 published, this link becomes a link to =foo.html=.  You can thus
15741 interlink the pages of your "Org web" project and the links will work
15742 as expected when you publish them to HTML.  If you also publish the
15743 Org source file and want to link to it, use an =http= link instead of
15744 a =file:= link, because =file= links are converted to link to the
15745 corresponding =.html= file.
15747 You may also link to related files, such as images.  Provided you are
15748 careful with relative file names, and provided you have also
15749 configured Org to upload the related files, these links will work too.
15750 See [[*Example: complex publishing configuration]], for an example of this
15751 usage.
15753 Eventually, links between published documents can contain some search
15754 options (see [[*Search Options in File Links]]), which will be resolved to
15755 the appropriate location in the linked file.  For example, once
15756 published to HTML, the following links all point to a dedicated anchor
15757 in =foo.html=.
15759 #+begin_example
15760 [[file:foo.org::*heading]]
15761 [[file:foo.org::#custom-id]]
15762 [[file:foo.org::target]]
15763 #+end_example
15765 *** Generating a sitemap
15766 :PROPERTIES:
15767 :DESCRIPTION: Generating a list of all pages.
15768 :ALT_TITLE: Site map
15769 :END:
15770 #+cindex: sitemap, of published pages
15772 The following properties may be used to control publishing of
15773 a map of files for a given project.
15775 - ~:auto-sitemap~ ::
15777   When non-~nil~, publish a sitemap during
15778   ~org-publish-current-project~ or ~org-publish-all~.
15780 - ~:sitemap-filename~ ::
15782   Filename for output of sitemap.  Defaults to =sitemap.org=, which
15783   becomes =sitemap.html=.
15785 - ~:sitemap-title~ ::
15787   Title of sitemap page.  Defaults to name of file.
15789 - ~:sitemap-format-entry~ ::
15791   #+findex: org-publish-find-date
15792   #+findex: org-publish-find-property
15793   #+findex: org-publish-find-title
15794   With this option one can tell how a site-map entry is formatted in
15795   the site-map.  It is a function called with three arguments: the
15796   file or directory name relative to base directory of the project,
15797   the site-map style and the current project.  It is expected to
15798   return a string.  Default value turns file names into links and use
15799   document titles as descriptions.  For specific formatting needs, one
15800   can use ~org-publish-find-date~, ~org-publish-find-title~ and
15801   ~org-publish-find-property~, to retrieve additional information
15802   about published documents.
15804 - ~:sitemap-function~ ::
15806   Plug-in function to use for generation of the sitemap.  It is called
15807   with two arguments: the title of the site-map and a representation
15808   of the files and directories involved in the project as a nested
15809   list, which can further be transformed using ~org-list-to-generic~,
15810   ~org-list-to-subtree~ and alike.  Default value generates a plain
15811   list of links to all files in the project.
15813 - ~:sitemap-sort-folders~ ::
15815   Where folders should appear in the sitemap.  Set this to ~first~
15816   (default) or ~last~ to display folders first or last, respectively.
15817   When set to ~ignore~, folders are ignored altogether.  Any other
15818   value mixes files and folders.  This variable has no effect when
15819   site-map style is ~tree~.
15821 - ~:sitemap-sort-files~ ::
15823   How the files are sorted in the site map.  Set this to
15824   ~alphabetically~ (default), ~chronologically~ or
15825   ~anti-chronologically~.  ~chronologically~ sorts the files with
15826   older date first while ~anti-chronologically~ sorts the files with
15827   newer date first.  ~alphabetically~ sorts the files alphabetically.
15828   The date of a file is retrieved with ~org-publish-find-date~.
15830 - ~:sitemap-ignore-case~ ::
15832   Should sorting be case-sensitive?  Default ~nil~.
15834 - ~:sitemap-file-entry-format~ ::
15836   With this option one can tell how a sitemap's entry is formatted in
15837   the sitemap.  This is a format string with some escape sequences:
15838   ~%t~ stands for the title of the file, ~%a~ stands for the author of
15839   the file and ~%d~ stands for the date of the file.  The date is
15840   retrieved with the ~org-publish-find-date~ function and formatted
15841   with ~org-publish-sitemap-date-format~.  Default ~%t~.
15843 - ~:sitemap-date-format~ ::
15845   Format string for the ~format-time-string~ function that tells how
15846   a sitemap entry's date is to be formatted.  This property bypasses
15847   ~org-publish-sitemap-date-format~ which defaults to ~%Y-%m-%d~.
15849 *** Generating an index
15850 :PROPERTIES:
15851 :DESCRIPTION: An index that reaches across pages.
15852 :END:
15853 #+cindex: index, in a publishing project
15855 Org mode can generate an index across the files of a publishing project.
15857 - ~:makeindex~ ::
15859   When non-~nil~, generate in index in the file =theindex.org= and
15860   publish it as =theindex.html=.
15862 The file is created when first publishing a project with the
15863 ~:makeindex~ set.  The file only contains a statement =#+INCLUDE:
15864 "theindex.inc"=.  You can then build around this include statement by
15865 adding a title, style information, etc.
15867 #+cindex: @samp{INDEX}, keyword
15868 Index entries are specified with =INDEX= keyword.  An entry that
15869 contains an exclamation mark creates a sub item.
15871 #+begin_example
15872 ,*** Curriculum Vitae
15873 ,#+INDEX: CV
15874 ,#+INDEX: Application!CV
15875 #+end_example
15877 ** Uploading Files
15878 :PROPERTIES:
15879 :DESCRIPTION: How to get files up on the server.
15880 :END:
15881 #+cindex: rsync
15882 #+cindex: unison
15884 For those people already utilizing third party sync tools such as
15885 Rsync or Unison, it might be preferable not to use the built-in remote
15886 publishing facilities of Org mode which rely heavily on Tramp.  Tramp,
15887 while very useful and powerful, tends not to be so efficient for
15888 multiple file transfer and has been known to cause problems under
15889 heavy usage.
15891 Specialized synchronization utilities offer several advantages.  In
15892 addition to timestamp comparison, they also do content and
15893 permissions/attribute checks.  For this reason you might prefer to
15894 publish your web to a local directory---possibly even /in place/ with
15895 your Org files---and then use Unison or Rsync to do the
15896 synchronization with the remote host.
15898 Since Unison, for example, can be configured as to which files to
15899 transfer to a certain remote destination, it can greatly simplify the
15900 project publishing definition.  Simply keep all files in the correct
15901 location, process your Org files with ~org-publish~ and let the
15902 synchronization tool do the rest.  You do not need, in this scenario,
15903 to include attachments such as JPG, CSS or PNG files in the project
15904 definition since the third-party tool syncs them.
15906 Publishing to a local directory is also much faster than to a remote
15907 one, so that you can afford more easily to republish entire projects.
15908 If you set ~org-publish-use-timestamps-flag~ to ~nil~, you gain the
15909 main benefit of re-including any changed external files such as source
15910 example files you might include with =INCLUDE= keyword.  The timestamp
15911 mechanism in Org is not smart enough to detect if included files have
15912 been modified.
15914 ** Sample Configuration
15915 :PROPERTIES:
15916 :DESCRIPTION: Example projects.
15917 :END:
15919 Below we provide two example configurations.  The first one is
15920 a simple project publishing only a set of Org files.  The second
15921 example is more complex, with a multi-component project.
15923 *** Example: simple publishing configuration
15924 :PROPERTIES:
15925 :DESCRIPTION: One-component publishing.
15926 :ALT_TITLE: Simple example
15927 :END:
15929 This example publishes a set of Org files to the =public_html=
15930 directory on the local machine.
15932 #+begin_src emacs-lisp
15933 (setq org-publish-project-alist
15934       '(("org"
15935          :base-directory "~/org/"
15936          :publishing-directory "~/public_html"
15937          :section-numbers nil
15938          :table-of-contents nil
15939          :style "<link rel=\"stylesheet\"
15940                 href=\"../other/mystyle.css\"
15941                 type=\"text/css\"/>")))
15942 #+end_src
15944 *** Example: complex publishing configuration
15945 :PROPERTIES:
15946 :DESCRIPTION: A multi-component publishing example.
15947 :ALT_TITLE: Complex example
15948 :END:
15950 This more complicated example publishes an entire website, including
15951 Org files converted to HTML, image files, Emacs Lisp source code, and
15952 style sheets.  The publishing directory is remote and private files
15953 are excluded.
15955 To ensure that links are preserved, care should be taken to replicate
15956 your directory structure on the web server, and to use relative file
15957 paths.  For example, if your Org files are kept in =~/org/= and your
15958 publishable images in =~/images/=, you would link to an image with
15960 : file:../images/myimage.png
15962 On the web server, the relative path to the image should be the same.
15963 You can accomplish this by setting up an =images/= folder in the right
15964 place on the web server, and publishing images to it.
15966 #+begin_src emacs-lisp
15967 (setq org-publish-project-alist
15968       '(("orgfiles"
15969          :base-directory "~/org/"
15970          :base-extension "org"
15971          :publishing-directory "/ssh:user@host:~/html/notebook/"
15972          :publishing-function org-html-publish-to-html
15973          :exclude "PrivatePage.org" ;; regexp
15974          :headline-levels 3
15975          :section-numbers nil
15976          :with-toc nil
15977          :html-head "<link rel=\"stylesheet\"
15978                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
15979          :html-preamble t)
15981         ("images"
15982          :base-directory "~/images/"
15983          :base-extension "jpg\\|gif\\|png"
15984          :publishing-directory "/ssh:user@host:~/html/images/"
15985          :publishing-function org-publish-attachment)
15987         ("other"
15988          :base-directory "~/other/"
15989          :base-extension "css\\|el"
15990          :publishing-directory "/ssh:user@host:~/html/other/"
15991          :publishing-function org-publish-attachment)
15992         ("website" :components ("orgfiles" "images" "other"))))
15993 #+end_src
15995 ** Triggering Publication
15996 :PROPERTIES:
15997 :DESCRIPTION: Publication commands.
15998 :END:
16000 Once properly configured, Org can publish with the following commands:
16002 - {{{kbd(C-c C-e P x)}}} (~org-publish~) ::
16004   #+kindex: C-c C-e P x
16005   #+findex: org-publish
16006   Prompt for a specific project and publish all files that belong to
16007   it.
16009 - {{{kbd(C-c C-e P p)}}} (~org-publish-current-project~) ::
16011   #+kindex: C-c C-e P p
16012   #+findex: org-publish-current-project
16013   Publish the project containing the current file.
16015 - {{{kbd(C-c C-e P f)}}} (~org-publish-current-file~) ::
16017   #+kindex: C-c C-e P f
16018   #+findex: org-publish-current-file
16019   Publish only the current file.
16021 - {{{kbd(C-c C-e P a)}}} (~org-publish-all~) ::
16023   #+kindex: C-c C-e P a
16024   #+findex: org-publish-all
16025   Publish every project.
16027 #+vindex: org-publish-use-timestamps-flag
16028 Org uses timestamps to track when a file has changed.  The above
16029 functions normally only publish changed files.  You can override this
16030 and force publishing of all files by giving a prefix argument to any
16031 of the commands above, or by customizing the variable
16032 ~org-publish-use-timestamps-flag~.  This may be necessary in
16033 particular if files include other files via =SETUPFILE= or =INCLUDE=
16034 keywords.
16036 * Working with Source Code
16037 :PROPERTIES:
16038 :DESCRIPTION: Export, evaluate, and tangle code blocks.
16039 :END:
16040 #+cindex: source code, working with
16042 Source code here refers to any plain text collection of computer
16043 instructions, possibly with comments, written using a human-readable
16044 programming language.  Org can manage source code in an Org document
16045 when the source code is identified with begin and end markers.
16046 Working with source code begins with identifying source code blocks.
16047 A source code block can be placed almost anywhere in an Org document;
16048 it is not restricted to the preamble or the end of the document.
16049 However, Org cannot manage a source code block if it is placed inside
16050 an Org comment or within a fixed width section.
16052 Here is an example source code block in the Emacs Lisp language:
16054 #+begin_example
16055 ,#+BEGIN_SRC emacs-lisp
16056   (defun org-xor (a b)
16057      "Exclusive or."
16058      (if a (not b) b))
16059 ,#+END_SRC
16060 #+end_example
16062 Org can manage the source code in the block delimited by =#+BEGIN_SRC=
16063 ... =#+END_SRC= in several ways that can simplify housekeeping tasks
16064 essential to modern source code maintenance.  Org can edit, format,
16065 extract, export, and publish source code blocks.  Org can also compile
16066 and execute a source code block, then capture the results.  The Org
16067 mode literature sometimes refers to source code blocks as /live code/
16068 blocks because they can alter the content of the Org document or the
16069 material that it exports.  Users can control how live they want each
16070 source code block by tweaking the header arguments (see [[*Using
16071 Header Arguments]]) for compiling, execution, extraction, and
16072 exporting.
16074 Source code blocks are one of many Org block types, which also include
16075 "center", "comment", "dynamic", "example", "export", "quote",
16076 "special", and "verse".  This section pertains to blocks between
16077 =#+BEGIN_SRC= and =#+END_SRC=.
16079 For editing and formatting a source code block, Org uses an
16080 appropriate Emacs major mode that includes features specifically
16081 designed for source code in that language.
16083 Org can extract one or more source code blocks and write them to one
16084 or more source files---a process known as /tangling/ in literate
16085 programming terminology.
16087 For exporting and publishing, Org's back-ends can format a source code
16088 block appropriately, often with native syntax highlighting.
16090 For executing and compiling a source code block, the user can
16091 configure Org to select the appropriate compiler.  Org provides
16092 facilities to collect the result of the execution or compiler output,
16093 insert it into the Org document, and/or export it.  In addition to
16094 text results, Org can insert links to other data types, including
16095 audio, video, and graphics.  Org can also link a compiler error
16096 message to the appropriate line in the source code block.
16098 An important feature of Org's management of source code blocks is the
16099 ability to pass variables, functions, and results to one another using
16100 a common syntax for source code blocks in any language.  Although most
16101 literate programming facilities are restricted to one language or
16102 another, Org's language-agnostic approach lets the literate programmer
16103 match each programming task with the appropriate computer language and
16104 to mix them all together in a single Org document.  This
16105 interoperability among languages explains why Org's source code
16106 management facility was named /Org Babel/ by its originators, Eric
16107 Schulte and Dan Davison.
16109 Org mode fulfills the promise of easy verification and maintenance of
16110 publishing reproducible research by keeping text, data, code,
16111 configuration settings of the execution environment, the results of
16112 the execution, and associated narratives, claims, references, and
16113 internal and external links in a single Org document.
16115 Details of Org's facilities for working with source code are described
16116 in the following sections.
16118 ** Structure of Code Blocks
16119 :PROPERTIES:
16120 :DESCRIPTION: Code block syntax described.
16121 :END:
16122 #+cindex: code block, structure
16123 #+cindex: source code, block structure
16124 #+cindex: @samp{NAME} keyword, in source blocks
16125 #+cindex: @samp{BEGIN_SRC}
16127 Org offers two ways to structure source code in Org documents: in
16128 a source code block, and directly inline.  Both specifications are
16129 shown below.
16131 A source code block conforms to this structure:
16133 #+begin_example
16134 ,#+NAME: <name>
16135 ,#+BEGIN_SRC <language> <switches> <header arguments>
16136   <body>
16137 ,#+END_SRC
16138 #+end_example
16140 Do not be put-off by having to remember the source block syntax.  Org
16141 mode offers a command for wrapping existing text in a block (see
16142 [[*Structure Templates]]).  Org also works with other completion systems
16143 in Emacs, some of which predate Org and have custom domain-specific
16144 languages for defining templates.  Regular use of templates reduces
16145 errors, increases accuracy, and maintains consistency.
16147 #+cindex: source code, inline
16148 An inline code block conforms to this structure:
16150 : src_<language>{<body>}
16152 #+texinfo: @noindent
16155 : src_<language>[<header arguments>]{<body>}
16157 - =#+NAME: <name>= ::
16159   Optional.  Names the source block so it can be called, like
16160   a function, from other source blocks or inline code to evaluate or
16161   to capture the results.  Code from other blocks, other files, and
16162   from table formulas (see [[*The Spreadsheet]]) can use the name to
16163   reference a source block.  This naming serves the same purpose as
16164   naming Org tables.  Org mode requires unique names.  For duplicate
16165   names, Org mode's behavior is undefined.
16167 - =#+BEGIN_SRC= ... =#+END_SRC= ::
16169   Mandatory.  They mark the start and end of a block that Org
16170   requires.  The =#+BEGIN_SRC= line takes additional arguments, as
16171   described next.
16173 - =<language>= ::
16175   #+cindex: language, in code blocks
16176   Mandatory.  It is the identifier of the source code language in the
16177   block.  See [[*Languages]], for identifiers of supported languages.
16179 - =<switches>= ::
16181   #+cindex: switches, in code blocks
16182   Optional.  Switches provide finer control of the code execution,
16183   export, and format (see the discussion of switches in [[*Literal
16184   Examples]]).
16186 - =<header arguments>= ::
16188   #+cindex: header arguments, in code blocks
16189   Optional.  Heading arguments control many aspects of evaluation,
16190   export and tangling of code blocks (see [[*Using Header Arguments]]).
16191   Using Org's properties feature, header arguments can be selectively
16192   applied to the entire buffer or specific sub-trees of the Org
16193   document.
16195 - =<body>= ::
16197   Source code in the dialect of the specified language identifier.
16199 ** Using Header Arguments
16200 :PROPERTIES:
16201 :DESCRIPTION: Different ways to set header arguments.
16202 :END:
16204 Org comes with many header arguments common to all languages.  New
16205 header arguments are added for specific languages as they become
16206 available for use in source code blocks.  A header argument is
16207 specified with an initial colon followed by the argument's name in
16208 lowercase.
16210 Since header arguments can be set in several ways, Org prioritizes
16211 them in case of overlaps or conflicts by giving local settings
16212 a higher priority.  Header values in function calls, for example,
16213 override header values from global defaults.
16215 *** System-wide header arguments
16216 :PROPERTIES:
16217 :UNNUMBERED: notoc
16218 :END:
16219 #+vindex: org-babel-default-header-args
16221 #+vindex: org-babel-default-header-args
16222 System-wide values of header arguments can be specified by customizing
16223 the ~org-babel-default-header-args~ variable, which defaults to the
16224 following values:
16226 #+begin_example
16227 :session    => "none"
16228 :results    => "replace"
16229 :exports    => "code"
16230 :cache      => "no"
16231 :noweb      => "no"
16232 #+end_example
16234 The example below sets =:noweb= header arguments to =yes=, which makes
16235 Org expand =:noweb= references by default.
16237 #+begin_src emacs-lisp
16238 (setq org-babel-default-header-args
16239       (cons '(:noweb . "yes")
16240             (assq-delete-all :noweb org-babel-default-header-args)))
16241 #+end_src
16243 #+cindex: language specific default header arguments
16244 #+cindex: default header arguments per language
16245 Each language can have separate default header arguments by
16246 customizing the variable ~org-babel-default-header-args:<LANG>~, where
16247 {{{var(<LANG>)}}} is the name of the language.  For details, see the
16248 language-specific online documentation at
16249 https://orgmode.org/worg/org-contrib/babel/.
16251 *** Header arguments in Org mode properties
16252 :PROPERTIES:
16253 :UNNUMBERED: notoc
16254 :END:
16256 For header arguments applicable to the buffer, use =PROPERTY= keyword
16257 anywhere in the Org file (see [[*Property Syntax]]).
16259 The following example makes all the R code blocks execute in the same
16260 session.  Setting =:results= to =silent= ignores the results of
16261 executions for all blocks, not just R code blocks; no results inserted
16262 for any block.
16264 #+begin_example
16265 ,#+PROPERTY: header-args:R  :session *R*
16266 ,#+PROPERTY: header-args    :results silent
16267 #+end_example
16269 #+vindex: org-use-property-inheritance
16270 Header arguments set through Org's property drawers (see [[*Property
16271 Syntax]]) apply at the sub-tree level on down.  Since these property
16272 drawers can appear anywhere in the file hierarchy, Org uses outermost
16273 call or source block to resolve the values.  Org ignores
16274 ~org-use-property-inheritance~ setting.
16276 In this example, =:cache= defaults to =yes= for all code blocks in the
16277 sub-tree.
16279 #+begin_example
16280 ,* sample header
16281   :PROPERTIES:
16282   :header-args:    :cache yes
16283   :END:
16284 #+end_example
16286 #+kindex: C-c C-x p
16287 #+findex: org-set-property
16288 Properties defined through ~org-set-property~ function, bound to
16289 {{{kbd(C-c C-x p)}}}, apply to all active languages.  They override
16290 properties set in ~org-babel-default-header-args~.
16292 #+cindex: language specific header arguments properties
16293 #+cindex: header arguments per language
16294 Language-specific header arguments are also read from properties
16295 =header-args:<LANG>= where {{{var(<LANG>)}}} is the language
16296 identifier.  For example,
16298 #+begin_example
16299 ,* Heading
16300   :PROPERTIES:
16301   :header-args:clojure:    :session *clojure-1*
16302   :header-args:R:          :session *R*
16303   :END:
16304 ,** Subheading
16305   :PROPERTIES:
16306   :header-args:clojure:    :session *clojure-2*
16307   :END:
16308 #+end_example
16310 #+texinfo: @noindent
16311 would force separate sessions for Clojure blocks in =Heading= and
16312 =Subheading=, but use the same session for all R blocks.  Blocks in
16313 =Subheading= inherit settings from =Heading=.
16315 *** Code block specific header arguments
16316 :PROPERTIES:
16317 :UNNUMBERED: notoc
16318 :END:
16320 Header arguments are most commonly set at the source code block level,
16321 on the =#+BEGIN_SRC= line.  Arguments set at this level take
16322 precedence over those set in the ~org-babel-default-header-args~
16323 variable, and also those set as header properties.
16325 In the following example, setting =:results= to =silent= makes it
16326 ignore results of the code execution.  Setting =:exports= to =code=
16327 exports only the body of the code block to HTML or LaTeX.
16329 #+begin_example
16330 ,#+NAME: factorial
16331 ,#+BEGIN_SRC haskell :results silent :exports code :var n=0
16332   fac 0 = 1
16333   fac n = n * fac (n-1)
16334 ,#+END_SRC
16335 #+end_example
16337 The same header arguments in an inline code block:
16339 : src_haskell[:exports both]{fac 5}
16341 #+cindex: @samp{HEADER}, keyword
16342 Code block header arguments can span multiple lines using =#+HEADER:=
16343 on each line.  Note that Org currently accepts the plural spelling of
16344 =#+HEADER:= only as a convenience for backward-compatibility.  It may
16345 be removed at some point.
16347 Multi-line header arguments on an unnamed code block:
16349 #+begin_example
16350 ,#+HEADER: :var data1=1
16351 ,#+BEGIN_SRC emacs-lisp :var data2=2
16352    (message "data1:%S, data2:%S" data1 data2)
16353 ,#+END_SRC
16355 ,#+RESULTS:
16356 : data1:1, data2:2
16357 #+end_example
16359 Multi-line header arguments on a named code block:
16361 #+begin_example
16362 ,#+NAME: named-block
16363 ,#+HEADER: :var data=2
16364 ,#+BEGIN_SRC emacs-lisp
16365   (message "data:%S" data)
16366 ,#+END_SRC
16368 ,#+RESULTS: named-block
16369   : data:2
16370 #+end_example
16372 *** Header arguments in function calls
16373 :PROPERTIES:
16374 :UNNUMBERED: notoc
16375 :END:
16377 Header arguments in function calls are the most specific and override
16378 all other settings in case of an overlap.  They get the highest
16379 priority.  Two =#+CALL:= examples are shown below.  For the complete
16380 syntax of =CALL= keyword, see [[*Evaluating Code Blocks]].
16382 In this example, =:exports results= header argument is applied to the
16383 evaluation of the =#+CALL:= line.
16385 : #+CALL: factorial(n=5) :exports results
16387 In this example, =:session special= header argument is applied to the
16388 evaluation of =factorial= code block.
16390 : #+CALL: factorial[:session special](n=5)
16392 ** Environment of a Code Block
16393 :PROPERTIES:
16394 :DESCRIPTION: Arguments, sessions, working directory...
16395 :END:
16397 *** Passing arguments
16398 :PROPERTIES:
16399 :UNNUMBERED: notoc
16400 :END:
16402 #+cindex: passing arguments to code blocks
16403 #+cindex: arguments, in code blocks
16404 #+cindex: @samp{var}, header argument
16405 Use =var= for passing arguments to source code blocks.  The specifics
16406 of variables in code blocks vary by the source language and are
16407 covered in the language-specific documentation.  The syntax for =var=,
16408 however, is the same for all languages.  This includes declaring
16409 a variable, and assigning a default value.
16411 The following syntax is used to pass arguments to code blocks using
16412 the =var= header argument.
16414 : :var NAME=ASSIGN
16416 #+texinfo: @noindent
16417 {{{var(NAME)}}} is the name of the variable bound in the code block
16418 body.  {{{var(ASSIGN)}}} is a literal value, such as a string,
16419 a number, a reference to a table, a list, a literal example, another
16420 code block---with or without arguments---or the results of evaluating
16421 a code block.
16423 Here are examples of passing values by reference:
16425 - table ::
16427   A table named with a =NAME= keyword.
16429   #+begin_example
16430   ,#+NAME: example-table
16431   | 1 |
16432   | 2 |
16433   | 3 |
16434   | 4 |
16436   ,#+NAME: table-length
16437   ,#+BEGIN_SRC emacs-lisp :var table=example-table
16438     (length table)
16439   ,#+END_SRC
16441   ,#+RESULTS: table-length
16442   : 4
16443   #+end_example
16445   When passing a table, you can treat specially the row, or the
16446   column, containing labels for the columns, or the rows, in the
16447   table.
16449   #+cindex: @samp{colnames}, header argument
16450   The =colnames= header argument accepts =yes=, =no=, or =nil= values.
16451   The default value is =nil=: if an input table has column
16452   names---because the second row is a horizontal rule---then Org
16453   removes the column names, processes the table, puts back the column
16454   names, and then writes the table to the results block.  Using =yes=,
16455   Org does the same to the first row, even if the initial table does
16456   not contain any horizontal rule.  When set to =no=, Org does not
16457   pre-process column names at all.
16459   #+begin_example
16460   ,#+NAME: less-cols
16461   | a |
16462   |---|
16463   | b |
16464   | c |
16466   ,#+BEGIN_SRC python :var tab=less-cols :colnames nil
16467     return [[val + '*' for val in row] for row in tab]
16468   ,#+END_SRC
16470   ,#+RESULTS:
16471   | a  |
16472   |----|
16473   | b* |
16474   | c* |
16475   #+end_example
16477   #+cindex: @samp{rownames}, header argument
16478   Similarly, the =rownames= header argument can take two values: =yes=
16479   or =no=.  When set to =yes=, Org removes the first column, processes
16480   the table, puts back the first column, and then writes the table to
16481   the results block.  The default is =no=, which means Org does not
16482   pre-process the first column.  Note that Emacs Lisp code blocks
16483   ignore =rownames= header argument because of the ease of
16484   table-handling in Emacs.
16486   #+begin_example
16487   ,#+NAME: with-rownames
16488   | one | 1 | 2 | 3 | 4 |  5 |
16489   | two | 6 | 7 | 8 | 9 | 10 |
16491   ,#+BEGIN_SRC python :var tab=with-rownames :rownames yes
16492     return [[val + 10 for val in row] for row in tab]
16493   ,#+END_SRC
16495   ,#+RESULTS:
16496   | one | 11 | 12 | 13 | 14 | 15 |
16497   | two | 16 | 17 | 18 | 19 | 20 |
16498   #+end_example
16500 - list ::
16502   A simple named list.
16504   #+begin_example
16505   ,#+NAME: example-list
16506   - simple
16507     - not
16508     - nested
16509   - list
16511   ,#+BEGIN_SRC emacs-lisp :var x=example-list
16512     (print x)
16513   ,#+END_SRC
16515   ,#+RESULTS:
16516   | simple | list |
16517   #+end_example
16519   Note that only the top level list items are passed along.  Nested
16520   list items are ignored.
16522 - code block without arguments ::
16524   A code block name, as assigned by =NAME= keyword from the example
16525   above, optionally followed by parentheses.
16527   #+begin_example
16528   ,#+BEGIN_SRC emacs-lisp :var length=table-length()
16529     (* 2 length)
16530   ,#+END_SRC
16532   ,#+RESULTS:
16533   : 8
16534   #+end_example
16536 - code block with arguments ::
16538   A code block name, as assigned by =NAME= keyword, followed by
16539   parentheses and optional arguments passed within the parentheses.
16541   #+begin_example
16542   ,#+NAME: double
16543   ,#+BEGIN_SRC emacs-lisp :var input=8
16544     (* 2 input)
16545   ,#+END_SRC
16547   ,#+RESULTS: double
16548   : 16
16550   ,#+NAME: squared
16551   ,#+BEGIN_SRC emacs-lisp :var input=double(input=1)
16552     (* input input)
16553   ,#+END_SRC
16555   ,#+RESULTS: squared
16556   : 4
16557   #+end_example
16559 - literal example ::
16561   A literal example block named with a =NAME= keyword.
16563   #+begin_example
16564   ,#+NAME: literal-example
16565   ,#+BEGIN_EXAMPLE
16566     A literal example
16567     on two lines
16568   ,#+END_EXAMPLE
16570   ,#+NAME: read-literal-example
16571   ,#+BEGIN_SRC emacs-lisp :var x=literal-example
16572     (concatenate #'string x " for you.")
16573   ,#+END_SRC
16575   ,#+RESULTS: read-literal-example
16576   : A literal example
16577   : on two lines for you.
16578   #+end_example
16580 Indexing variable values enables referencing portions of a variable.
16581 Indexes are 0 based with negative values counting backwards from the
16582 end.  If an index is separated by commas then each subsequent section
16583 indexes as the next dimension.  Note that this indexing occurs
16584 /before/ other table-related header arguments are applied, such as
16585 =hlines=, =colnames= and =rownames=.  The following example assigns
16586 the last cell of the first row the table =example-table= to the
16587 variable =data=:
16589 #+begin_example
16590 ,#+NAME: example-table
16591 | 1 | a |
16592 | 2 | b |
16593 | 3 | c |
16594 | 4 | d |
16596 ,#+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
16597   data
16598 ,#+END_SRC
16600 ,#+RESULTS:
16601 : a
16602 #+end_example
16604 Two integers separated by a colon reference a range of variable
16605 values.  In that case the entire inclusive range is referenced.  For
16606 example the following assigns the middle three rows of =example-table=
16607 to =data=.
16609 #+begin_example
16610 ,#+NAME: example-table
16611 | 1 | a |
16612 | 2 | b |
16613 | 3 | c |
16614 | 4 | d |
16615 | 5 | 3 |
16617 ,#+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
16618   data
16619 ,#+END_SRC
16621 ,#+RESULTS:
16622 | 2 | b |
16623 | 3 | c |
16624 | 4 | d |
16625 #+end_example
16627 To pick the entire range, use an empty index, or the single character
16628 =*=.  =0:-1= does the same thing.  Example below shows how to
16629 reference the first column only.
16631 #+begin_example
16632 ,#+NAME: example-table
16633 | 1 | a |
16634 | 2 | b |
16635 | 3 | c |
16636 | 4 | d |
16638 ,#+BEGIN_SRC emacs-lisp :var data=example-table[,0]
16639   data
16640 ,#+END_SRC
16642 ,#+RESULTS:
16643 | 1 | 2 | 3 | 4 |
16644 #+end_example
16646 Index referencing can be used for tables and code blocks.  Index
16647 referencing can handle any number of dimensions.  Commas delimit
16648 multiple dimensions, as shown below.
16650 #+begin_example
16651 ,#+NAME: 3D
16652 ,#+BEGIN_SRC emacs-lisp
16653   '(((1  2  3)  (4  5  6)  (7  8  9))
16654     ((10 11 12) (13 14 15) (16 17 18))
16655     ((19 20 21) (22 23 24) (25 26 27)))
16656 ,#+END_SRC
16658 ,#+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
16659   data
16660 ,#+END_SRC
16662 ,#+RESULTS:
16663 | 11 | 14 | 17 |
16664 #+end_example
16666 Note that row names and column names are not removed prior to variable
16667 indexing.  You need to take them into account, even when =colnames= or
16668 =rownames= header arguments remove them.
16670 Emacs lisp code can also set the values for variables.  To
16671 differentiate a value from Lisp code, Org interprets any value
16672 starting with =(=, =[=, ='= or =`= as Emacs Lisp code.  The result of
16673 evaluating that code is then assigned to the value of that variable.
16674 The following example shows how to reliably query and pass the file
16675 name of the Org mode buffer to a code block using headers.  We need
16676 reliability here because the file's name could change once the code in
16677 the block starts executing.
16679 #+begin_example
16680 ,#+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
16681   wc -w $filename
16682 ,#+END_SRC
16683 #+end_example
16685 Note that values read from tables and lists are not mistakenly
16686 evaluated as Emacs Lisp code, as illustrated in the following example.
16688 #+begin_example
16689 ,#+NAME: table
16690 | (a b c) |
16692 ,#+HEADER: :var data=table[0,0]
16693 ,#+BEGIN_SRC perl
16694   $data
16695 ,#+END_SRC
16697 ,#+RESULTS:
16698 : (a b c)
16699 #+end_example
16701 *** Using sessions
16702 :PROPERTIES:
16703 :UNNUMBERED: notoc
16704 :END:
16706 #+cindex: using sessions in code blocks
16707 #+cindex: @samp{session}, header argument
16708 Two code blocks can share the same environment.  The =session= header
16709 argument is for running multiple source code blocks under one session.
16710 Org runs code blocks with the same session name in the same
16711 interpreter process.
16713 - =none= ::
16715   Default.  Each code block gets a new interpreter process to execute.
16716   The process terminates once the block is evaluated.
16718 - {{{var(STRING)}}} ::
16720   Any string besides =none= turns that string into the name of that
16721   session.  For example, =:session STRING= names it =STRING=.  If
16722   =session= has no value, then the session name is derived from the
16723   source language identifier.  Subsequent blocks with the same source
16724   code language use the same session.  Depending on the language,
16725   state variables, code from other blocks, and the overall interpreted
16726   environment may be shared.  Some interpreted languages support
16727   concurrent sessions when subsequent source code language blocks
16728   change session names.
16730 Only languages that provide interactive evaluation can have session
16731 support.  Not all languages provide this support, such as C and ditaa.
16732 Even languages, such as Python and Haskell, that do support
16733 interactive evaluation impose limitations on allowable language
16734 constructs that can run interactively.  Org inherits those limitations
16735 for those code blocks running in a session.
16737 *** Choosing a working directory
16738 :PROPERTIES:
16739 :UNNUMBERED: notoc
16740 :END:
16742 #+cindex: working directory, in a code block
16743 #+cindex: @samp{dir}, header argument
16744 #+cindex: @samp{mkdirp}, header argument
16745 The =dir= header argument specifies the default directory during code
16746 block execution.  If it is absent, then the directory associated with
16747 the current buffer is used.  In other words, supplying =:dir
16748 DIRECTORY= temporarily has the same effect as changing the current
16749 directory with {{{kbd(M-x cd RET DIRECTORY)}}}, and then not setting
16750 =dir=.  Under the surface, =dir= simply sets the value of the Emacs
16751 variable ~default-directory~.  Setting =mkdirp= header argument to
16752 a non-~nil~ value creates the directory, if necessary.
16754 For example, to save the plot file in the =Work/= folder of the home
16755 directory---notice tilde is expanded:
16757 #+begin_example
16758 ,#+BEGIN_SRC R :file myplot.png :dir ~/Work
16759   matplot(matrix(rnorm(100), 10), type="l")
16760 ,#+END_SRC
16761 #+end_example
16763 To evaluate the code block on a remote machine, supply a remote
16764 directory name using Tramp syntax.  For example:
16766 #+begin_example
16767 ,#+BEGIN_SRC R :file plot.png :dir /scp:dand@yakuba.princeton.edu:
16768   plot(1:10, main=system("hostname", intern=TRUE))
16769 ,#+END_SRC
16770 #+end_example
16772 Org first captures the text results as usual for insertion in the Org
16773 file.  Then Org also inserts a link to the remote file, thanks to
16774 Emacs Tramp.  Org constructs the remote path to the file name from
16775 =dir= and ~default-directory~, as illustrated here:
16777 : [[file:/scp:dand@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
16779 When =dir= is used with =session=, Org sets the starting directory for
16780 a new session.  But Org does not alter the directory of an already
16781 existing session.
16783 Do not use =dir= with =:exports results= or with =:exports both= to
16784 avoid Org inserting incorrect links to remote files.  That is because
16785 Org does not expand ~default directory~ to avoid some underlying
16786 portability issues.
16788 *** Inserting headers and footers
16789 :PROPERTIES:
16790 :UNNUMBERED: notoc
16791 :END:
16793 #+cindex: headers, in code blocks
16794 #+cindex: footers, in code blocks
16795 #+cindex: @samp{prologue}, header argument
16796 The =prologue= header argument is for appending to the top of the code
16797 block for execution, like a reset instruction.  For example, you may
16798 use =:prologue "reset"= in a Gnuplot code block or, for every such
16799 block:
16801 #+begin_src emacs-lisp
16802 (add-to-list 'org-babel-default-header-args:gnuplot
16803              '((:prologue . "reset")))
16805 #+end_src
16807 #+cindex: @samp{epilogue}, header argument
16808 Likewise, the value of the =epilogue= header argument is for appending
16809 to the end of the code block for execution.
16811 ** Evaluating Code Blocks
16812 :PROPERTIES:
16813 :DESCRIPTION: Place results of evaluation in the Org buffer.
16814 :END:
16815 #+cindex: code block, evaluating
16816 #+cindex: source code, evaluating
16817 #+cindex: @samp{RESULTS}, keyword
16819 A note about security: With code evaluation comes the risk of harm.
16820 Org safeguards by prompting for user's permission before executing any
16821 code in the source block.  To customize this safeguard, or disable it,
16822 see [[*Code Evaluation and Security Issues]].
16824 *** How to evaluate source code
16825 :PROPERTIES:
16826 :UNNUMBERED: notoc
16827 :END:
16829 Org captures the results of the code block evaluation and inserts them
16830 in the Org file, right after the code block.  The insertion point is
16831 after a newline and the =RESULTS= keyword.  Org creates the =RESULTS=
16832 keyword if one is not already there.
16834 By default, Org enables only Emacs Lisp code blocks for execution.
16835 See [[*Languages]] to enable other languages.
16837 #+kindex: C-c C-c
16838 #+kindex: C-c C-v e
16839 #+findex: org-babel-execute-src-block
16840 Org provides many ways to execute code blocks.  {{{kbd(C-c C-c)}}} or
16841 {{{kbd(C-c C-v e)}}} with the point on a code block[fn:140] calls the
16842 ~org-babel-execute-src-block~ function, which executes the code in the
16843 block, collects the results, and inserts them in the buffer.
16845 #+cindex: @samp{CALL}, keyword
16846 #+vindex: org-babel-inline-result-wrap
16847 By calling a named code block[fn:141] from an Org mode buffer or
16848 a table.  Org can call the named code blocks from the current Org mode
16849 buffer or from the "Library of Babel" (see [[*Library of Babel]]).
16851 The syntax for =CALL= keyword is:
16853 #+begin_example
16854 ,#+CALL: <name>(<arguments>)
16855 ,#+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
16856 #+end_example
16858 The syntax for inline named code blocks is:
16860 #+begin_example
16861 ... call_<name>(<arguments>) ...
16862 ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
16863 #+end_example
16865 When inline syntax is used, the result is wrapped based on the
16866 variable ~org-babel-inline-result-wrap~, which by default is set to
16867 ~"=%s="~ to produce verbatim text suitable for markup.
16869 - =<name>= ::
16871   This is the name of the code block (see [[*Structure of Code Blocks]])
16872   to be evaluated in the current document.  If the block is located in
16873   another file, start =<name>= with the file name followed by
16874   a colon. For example, in order to execute a block named =clear-data=
16875   in =file.org=, you can write the following:
16877   : #+CALL: file.org:clear-data()
16879 - =<arguments>= ::
16881   Org passes arguments to the code block using standard function call
16882   syntax.  For example, a =#+CALL:= line that passes =4= to a code
16883   block named =double=, which declares the header argument =:var n=2=,
16884   would be written as:
16886   : #+CALL: double(n=4)
16888   #+texinfo: @noindent
16889   Note how this function call syntax is different from the header
16890   argument syntax.
16892 - =<inside header arguments>= ::
16894   Org passes inside header arguments to the named code block using the
16895   header argument syntax.  Inside header arguments apply to code block
16896   evaluation.  For example, =[:results output]= collects results
16897   printed to stdout during code execution of that block.  Note how
16898   this header argument syntax is different from the function call
16899   syntax.
16901 - =<end header arguments>= ::
16903   End header arguments affect the results returned by the code block.
16904   For example, =:results html= wraps the results in a =#+BEGIN_EXPORT
16905   html= block before inserting the results in the Org buffer.
16907 *** Limit code block evaluation
16908 :PROPERTIES:
16909 :UNNUMBERED: notoc
16910 :END:
16912 #+cindex: @samp{eval}, header argument
16913 #+cindex: control code block evaluation
16914 The =eval= header argument can limit evaluation of specific code
16915 blocks and =CALL= keyword.  It is useful for protection against
16916 evaluating untrusted code blocks by prompting for a confirmation.
16918 - =never= or =no= ::
16920   Org never evaluates the source code.
16922 - =query= ::
16924   Org prompts the user for permission to evaluate the source code.
16926 - =never-export= or =no-export= ::
16928   Org does not evaluate the source code when exporting, yet the user
16929   can evaluate it interactively.
16931 - =query-export= ::
16933   Org prompts the user for permission to evaluate the source code
16934   during export.
16936 If =eval= header argument is not set, then Org determines whether to
16937 evaluate the source code from the ~org-confirm-babel-evaluate~
16938 variable (see [[*Code Evaluation and Security Issues]]).
16940 *** Cache results of evaluation
16941 :PROPERTIES:
16942 :UNNUMBERED: notoc
16943 :END:
16945 #+cindex: @samp{cache}, header argument
16946 #+cindex: cache results of code evaluation
16947 The =cache= header argument is for caching results of evaluating code
16948 blocks.  Caching results can avoid re-evaluating a code block that
16949 have not changed since the previous run.  To benefit from the cache
16950 and avoid redundant evaluations, the source block must have a result
16951 already present in the buffer, and neither the header
16952 arguments---including the value of =var= references---nor the text of
16953 the block itself has changed since the result was last computed.  This
16954 feature greatly helps avoid long-running calculations.  For some edge
16955 cases, however, the cached results may not be reliable.
16957 The caching feature is best for when code blocks are pure functions,
16958 that is functions that return the same value for the same input
16959 arguments (see [[*Environment of a Code Block]]), and that do not have
16960 side effects, and do not rely on external variables other than the
16961 input arguments.  Functions that depend on a timer, file system
16962 objects, and random number generators are clearly unsuitable for
16963 caching.
16965 A note of warning: when =cache= is used in a session, caching may
16966 cause unexpected results.
16968 When the caching mechanism tests for any source code changes, it does
16969 not expand Noweb style references (see [[*Noweb Reference Syntax]]).  For
16970 reasons why, see http://thread.gmane.org/gmane.emacs.orgmode/79046.
16972 The =cache= header argument can have one of two values: =yes= or =no=.
16974 - =no= ::
16976   Default.  No caching of results; code block evaluated every time.
16978 - =yes= ::
16980   Whether to run the code or return the cached results is determined
16981   by comparing the SHA1 hash value of the combined code block and
16982   arguments passed to it.  This hash value is packed on the
16983   =#+RESULTS:= line from previous evaluation.  When hash values match,
16984   Org does not evaluate the code block.  When hash values mismatch,
16985   Org evaluates the code block, inserts the results, recalculates the
16986   hash value, and updates =#+RESULTS:= line.
16988 In this example, both functions are cached.  But =caller= runs only if
16989 the result from =random= has changed since the last run.
16991 #+begin_example
16992 ,#+NAME: random
16993 ,#+BEGIN_SRC R :cache yes
16994   runif(1)
16995 ,#+END_SRC
16997 ,#+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
16998 0.4659510825295
17000 ,#+NAME: caller
17001 ,#+BEGIN_SRC emacs-lisp :var x=random :cache yes
17002   x
17003 ,#+END_SRC
17005 ,#+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
17006 0.254227238707244
17007 #+end_example
17009 ** Results of Evaluation
17010 :PROPERTIES:
17011 :DESCRIPTION: Choosing a results type, post-processing...
17012 :END:
17013 #+cindex: code block, results of evaluation
17014 #+cindex: source code, results of evaluation
17016 #+cindex: @samp{results}, header argument
17017 How Org handles results of a code block execution depends on many
17018 header arguments working together.  The primary determinant, however,
17019 is the =results= header argument.  It accepts four classes of options.
17020 Each code block can take only one option per class:
17022 - Collection ::
17024   For how the results should be collected from the code block;
17026 - Type ::
17028   For which type of result the code block will return; affects how Org
17029   processes and inserts results in the Org buffer;
17031 - Format ::
17033   For the result; affects how Org processes results;
17035 - Handling ::
17037   For inserting results once they are properly formatted.
17039 *** Collection
17040 :PROPERTIES:
17041 :UNNUMBERED: notoc
17042 :END:
17044 Collection options specify the results.  Choose one of the options;
17045 they are mutually exclusive.
17047 - =value= ::
17049   Default.  Functional mode.  Org gets the value by wrapping the code
17050   in a function definition in the language of the source block.  That
17051   is why when using =:results value=, code should execute like
17052   a function and return a value.  For languages like Python, an
17053   explicit ~return~ statement is mandatory when using =:results
17054   value=.  Result is the value returned by the last statement in the
17055   code block.
17057   When evaluating the code block in a session (see [[*Environment of
17058   a Code Block]]), Org passes the code to an interpreter running as an
17059   interactive Emacs inferior process. Org gets the value from the
17060   source code interpreter's last statement output.  Org has to use
17061   language-specific methods to obtain the value.  For example, from
17062   the variable ~_~ in Python and Ruby, and the value of ~.Last.value~
17063   in R.
17065 - =output= ::
17067   Scripting mode.  Org passes the code to an external process running
17068   the interpreter.  Org returns the contents of the standard output
17069   stream as text results.
17071   When using a session, Org passes the code to the interpreter running
17072   as an interactive Emacs inferior process.  Org concatenates any text
17073   output from the interpreter and returns the collection as a result.
17075   Note that this collection is not the same as that would be collected
17076   from stdout of a non-interactive interpreter running as an external
17077   process.  Compare for example these two blocks:
17079   #+begin_example
17080   ,#+BEGIN_SRC python :results output
17081     print "hello"
17082     2
17083     print "bye"
17084   ,#+END_SRC
17086   ,#+RESULTS:
17087   : hello
17088   : bye
17089   #+end_example
17091   In the above non-session mode, the "2" is not printed; so it does
17092   not appear in results.
17094   #+begin_example
17095   ,#+BEGIN_SRC python :results output :session
17096     print "hello"
17097     2
17098     print "bye"
17099   ,#+END_SRC
17101   ,#+RESULTS:
17102   : hello
17103   : 2
17104   : bye
17105   #+end_example
17107   In the above session, the interactive interpreter receives and
17108   prints "2".  Results show that.
17110 *** Type
17111 :PROPERTIES:
17112 :UNNUMBERED: notoc
17113 :END:
17115 Type tells what result types to expect from the execution of the code
17116 block.  Choose one of the options; they are mutually exclusive.  The
17117 default behavior is to automatically determine the result type.
17119 #+attr_texinfo: :sep ,
17120 - =table=, =vector= ::
17122   Interpret the results as an Org table.  If the result is a single
17123   value, create a table with one row and one column.  Usage example:
17124   =:results value table=.
17126   #+cindex: @samp{hlines}, header argument
17127   In-between each table row or below the table headings, sometimes
17128   results have horizontal lines, which are also known as "hlines".
17129   The =hlines= argument with the default =no= value strips such lines
17130   from the input table.  For most code, this is desirable, or else
17131   those =hline= symbols raise unbound variable errors.  A =yes=
17132   accepts such lines, as demonstrated in the following example.
17134   #+begin_example
17135   ,#+NAME: many-cols
17136   | a | b | c |
17137   |---+---+---|
17138   | d | e | f |
17139   |---+---+---|
17140   | g | h | i |
17142   ,#+NAME: no-hline
17143   ,#+BEGIN_SRC python :var tab=many-cols :hlines no
17144     return tab
17145   ,#+END_SRC
17147   ,#+RESULTS: no-hline
17148   | a | b | c |
17149   | d | e | f |
17150   | g | h | i |
17152   ,#+NAME: hlines
17153   ,#+BEGIN_SRC python :var tab=many-cols :hlines yes
17154     return tab
17155   ,#+END_SRC
17157   ,#+RESULTS: hlines
17158   | a | b | c |
17159   |---+---+---|
17160   | d | e | f |
17161   |---+---+---|
17162   | g | h | i |
17163   #+end_example
17165 - =list= ::
17167   Interpret the results as an Org list.  If the result is a single
17168   value, create a list of one element.
17170 - =scalar=, =verbatim= ::
17172   Interpret literally and insert as quoted text.  Do not create
17173   a table.  Usage example: =:results value verbatim=.
17175 - =file= ::
17177   Interpret as a filename.  Save the results of execution of the code
17178   block to that file, then insert a link to it.  You can control both
17179   the filename and the description associated to the link.
17181   #+cindex: @samp{file}, header argument
17182   #+cindex: @samp{output-dir}, header argument
17183   Org first tries to generate the filename from the value of the
17184   =file= header argument and the directory specified using the
17185   =output-dir= header arguments.  If =output-dir= is not specified,
17186   Org assumes it is the current directory.
17188   #+begin_example
17189   ,#+BEGIN_SRC asymptote :results value file :file circle.pdf :output-dir img/
17190     size(2cm);
17191     draw(unitcircle);
17192   ,#+END_SRC
17193   #+end_example
17195   #+cindex: @samp{file-ext}, header argument
17196   If =file= is missing, Org generates the base name of the output
17197   file from the name of the code block, and its extension from the
17198   =file-ext= header argument.  In that case, both the name and the
17199   extension are mandatory[fn:142].
17201   #+begin_example
17202   ,#+name: circle
17203   ,#+BEGIN_SRC asymptote :results value file :file-ext pdf
17204     size(2cm);
17205     draw(unitcircle);
17206   ,#+END_SRC
17207   #+end_example
17209   #+cindex: @samp{file-desc}, header argument
17210   The =file-desc= header argument defines the description (see
17211   [[*Link Format]]) for the link.  If =file-desc= has no value, Org
17212   uses the generated file name for both the "link" and
17213   "description" parts of the link.
17215   #+cindex: @samp{sep}, header argument
17216   By default, Org assumes that a table written to a file has
17217   TAB-delimited output.  You can choose a different separator with
17218   the =sep= header argument.
17220 *** Format
17221 :PROPERTIES:
17222 :UNNUMBERED: notoc
17223 :END:
17225 Format pertains to the type of the result returned by the code block.
17226 Choose one of the options; they are mutually exclusive.  The default
17227 follows from the type specified above.
17229 #+attr_texinfo: :sep ,
17230 - =code= ::
17232   Result enclosed in a code block.  Useful for parsing.  Usage
17233   example: =:results value code=.
17235 - =drawer= ::
17237   Result wrapped in a =RESULTS= drawer.  Useful for containing =raw=
17238   or =org= results for later scripting and automated processing.
17239   Usage example: =:results value drawer=.
17241 - =html= ::
17243   Results enclosed in a =BEGIN_EXPORT html= block.  Usage example:
17244   =:results value html=.
17246 - =latex= ::
17248   Results enclosed in a =BEGIN_EXPORT latex= block.  Usage example:
17249   =:results value latex=.
17251 - =link=, =graphics= ::
17253   Result is a link to the file specified in =:file= header argument.
17254   However, unlike plain =:file=, nothing is written to the disk.  The
17255   block is used for its side-effects only, as in the following
17256   example:
17258   #+begin_example
17259   ,#+begin_src shell :results link :file "download.tar.gz"
17260   wget -c "http://example.com/download.tar.gz"
17261   ,#+end_src
17262   #+end_example
17264 - =org= ::
17266   Results enclosed in a =BEGIN_SRC org= block.  For comma-escape,
17267   either {{{kbd(TAB)}}} in the block, or export the file.  Usage
17268   example: =:results value org=.
17270 - =pp= ::
17272   Result converted to pretty-print source code.  Enclosed in a code
17273   block.  Languages supported: Emacs Lisp, Python, and Ruby.  Usage
17274   example: =:results value pp=.
17276 - =raw= ::
17278   Interpreted as raw Org mode.  Inserted directly into the buffer.
17279   Aligned if it is a table.  Usage example: =:results value raw=.
17281 #+cindex: @samp{wrap}, header argument
17282 The =wrap= header argument unconditionnally marks the results block by
17283 appending strings to =#+BEGIN_= and =#+END_=.  If no string is
17284 specified, Org wraps the results in a =#+BEGIN_results=
17285 ... =#+END_results= block.  It takes precedent over the =results=
17286 value listed above.  E.g.,
17288 #+begin_example
17289 ,#+BEGIN_SRC emacs-lisp :results html :wrap EXPORT markdown
17290 "<blink>Welcome back to the 90's</blink>"
17291 ,#+END_SRC
17293 ,#+RESULTS:
17294 ,#+BEGIN_EXPORT markdown
17295 <blink>Welcome back to the 90's</blink>
17296 ,#+END_EXPORT
17297 #+end_example
17299 *** Handling
17300 :PROPERTIES:
17301 :UNNUMBERED: notoc
17302 :END:
17304 Handling options after collecting the results.
17306 - =silent= ::
17308   Do not insert results in the Org mode buffer, but echo them in the
17309   minibuffer.  Usage example: =:results output silent=.
17311 - =replace= ::
17313   Default.  Insert results in the Org buffer.  Remove previous
17314   results.  Usage example: =:results output replace=.
17316 - =append= ::
17318   Append results to the Org buffer.  Latest results are at the bottom.
17319   Does not remove previous results.  Usage example: =:results output
17320   append=.
17322 - =prepend= ::
17324   Prepend results to the Org buffer.  Latest results are at the top.
17325   Does not remove previous results.  Usage example: =:results output
17326   prepend=.
17328 *** Post-processing
17329 :PROPERTIES:
17330 :UNNUMBERED: notoc
17331 :END:
17333 #+cindex: @samp{post}, header argument
17334 #+cindex: @samp{*this*}, in @samp{post} header argument
17335 The =post= header argument is for post-processing results from block
17336 evaluation.  When =post= has any value, Org binds the results to
17337 ~*this*~ variable for easy passing to =var= header argument
17338 specifications (see [[*Environment of a Code Block]]).  That makes results
17339 available to other code blocks, or even for direct Emacs Lisp code
17340 execution.
17342 The following two examples illustrate =post= header argument in
17343 action.  The first one shows how to attach an =ATTR_LATEX= keyword
17344 using =post=.
17346 #+begin_example
17347 ,#+NAME: attr_wrap
17348 ,#+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output
17349   echo "#+ATTR_LATEX: :width $width"
17350   echo "$data"
17351 ,#+END_SRC
17353 ,#+HEADER: :file /tmp/it.png
17354 ,#+BEGIN_SRC dot :post attr_wrap(width="5cm", data=*this*) :results drawer
17355   digraph{
17356           a -> b;
17357           b -> c;
17358           c -> a;
17359   }
17360 ,#+end_src
17362 ,#+RESULTS:
17363 :RESULTS:
17364 ,#+ATTR_LATEX :width 5cm
17365 [[file:/tmp/it.png]]
17366 :END:
17367 #+end_example
17369 The second example shows use of =colnames= header argument in =post=
17370 to pass data between code blocks.
17372 #+begin_example
17373 ,#+NAME: round-tbl
17374 ,#+BEGIN_SRC emacs-lisp :var tbl="" fmt="%.3f"
17375   (mapcar (lambda (row)
17376             (mapcar (lambda (cell)
17377                       (if (numberp cell)
17378                           (format fmt cell)
17379                         cell))
17380                     row))
17381           tbl)
17382 ,#+end_src
17384 ,#+BEGIN_SRC R :colnames yes :post round-tbl[:colnames yes](*this*)
17385   set.seed(42)
17386   data.frame(foo=rnorm(1))
17387 ,#+END_SRC
17389 ,#+RESULTS:
17390 |   foo |
17391 |-------|
17392 | 1.371 |
17393 #+end_example
17395 ** Exporting Code Blocks
17396 :PROPERTIES:
17397 :DESCRIPTION: Export contents and/or results.
17398 :END:
17399 #+cindex: code block, exporting
17400 #+cindex: source code, exporting
17402 It is possible to export the /code/ of code blocks, the /results/ of
17403 code block evaluation, /both/ the code and the results of code block
17404 evaluation, or /none/.  Org defaults to exporting /code/ for most
17405 languages.  For some languages, such as ditaa, Org defaults to
17406 /results/.  To export just the body of code blocks, see [[*Literal
17407 Examples]].  To selectively export sub-trees of an Org document, see
17408 [[*Exporting]].
17410 #+cindex: @samp{exports}, header argument
17411 The =exports= header argument is to specify if that part of the Org
17412 file is exported to, say, HTML or LaTeX formats.
17414 - =code= ::
17416   The default.  The body of code is included into the exported file.
17417   Example: =:exports code=.
17419 - =results= ::
17421   The results of evaluation of the code is included in the exported
17422   file.  Example: =:exports results=.
17424 - =both= ::
17426   Both the code and results of evaluation are included in the exported
17427   file.  Example: =:exports both=.
17429 - =none= ::
17431   Neither the code nor the results of evaluation is included in the
17432   exported file.  Whether the code is evaluated at all depends on
17433   other options.  Example: =:exports none=.
17435 #+vindex: org-export-use-babel
17436 To stop Org from evaluating code blocks to speed exports, use the
17437 header argument =:eval never-export= (see [[*Evaluating Code Blocks]]).
17438 To stop Org from evaluating code blocks for greater security, set the
17439 ~org-export-use-babel~ variable to ~nil~, but understand that header
17440 arguments will have no effect.
17442 Turning off evaluation comes in handy when batch processing.  For
17443 example, markup languages for wikis, which have a high risk of
17444 untrusted code.  Stopping code block evaluation also stops evaluation
17445 of all header arguments of the code block.  This may not be desirable
17446 in some circumstances.  So during export, to allow evaluation of just
17447 the header arguments but not any code evaluation in the source block,
17448 set =:eval never-export= (see [[*Evaluating Code Blocks]]).
17450 Org never evaluates code blocks in commented sub-trees when exporting
17451 (see [[*Comment Lines]]).  On the other hand, Org does evaluate code
17452 blocks in sub-trees excluded from export (see [[*Export Settings]]).
17454 ** Extracting Source Code
17455 :PROPERTIES:
17456 :DESCRIPTION: Create pure source code files.
17457 :END:
17458 #+cindex: tangling
17459 #+cindex: source code, extracting
17460 #+cindex: code block, extracting source code
17462 Extracting source code from code blocks is a basic task in literate
17463 programming.  Org has features to make this easy.  In literate
17464 programming parlance, documents on creation are /woven/ with code and
17465 documentation, and on export, the code is tangled for execution by
17466 a computer.  Org facilitates weaving and tangling for producing,
17467 maintaining, sharing, and exporting literate programming documents.
17468 Org provides extensive customization options for extracting source
17469 code.
17471 When Org tangles code blocks, it expands, merges, and transforms them.
17472 Then Org recomposes them into one or more separate files, as
17473 configured through the options.  During this tangling process, Org
17474 expands variables in the source code, and resolves any Noweb style
17475 references (see [[*Noweb Reference Syntax]]).
17477 *** Header arguments
17478 :PROPERTIES:
17479 :UNNUMBERED: notoc
17480 :END:
17482 #+cindex: @samp{tangle}, header argument
17483 The =tangle= header argument specifies if the code block is exported
17484 to source file(s).
17486 - =yes= ::
17488   Export the code block to source file.  The file name for the source
17489   file is derived from the name of the Org file, and the file
17490   extension is derived from the source code language identifier.
17491   Example: =:tangle yes=.
17493 - =no= ::
17495   The default.  Do not extract the code in a source code file.
17496   Example: =:tangle no=.
17498 - {{{var(FILENAME)}}} ::
17500   Export the code block to source file whose file name is derived from
17501   any string passed to the =tangle= header argument.  Org derives the
17502   file name as being relative to the directory of the Org file's
17503   location.  Example: =:tangle FILENAME=.
17505 #+cindex: @samp{mkdirp}, header argument
17506 The =mkdirp= header argument creates parent directories for tangled
17507 files if the directory does not exist.  A =yes= value enables
17508 directory creation whereas =no= inhibits it.
17510 #+cindex: @samp{comments}, header argument
17511 The =comments= header argument controls inserting comments into
17512 tangled files.  These are above and beyond whatever comments may
17513 already exist in the code block.
17515 - =no= ::
17517   The default.  Do not insert any extra comments during tangling.
17519 - =link= ::
17521   Wrap the code block in comments.  Include links pointing back to the
17522   place in the Org file from where the code was tangled.
17524 - =yes= ::
17526   Kept for backward compatibility; same as =link=.
17528 - =org= ::
17530   Nearest headline text from Org file is inserted as comment.  The
17531   exact text that is inserted is picked from the leading context of
17532   the source block.
17534 - =both= ::
17536   Includes both =link= and =org= options.
17538 - =noweb= ::
17540   Includes =link= option, expands Noweb references (see [[*Noweb
17541   Reference Syntax]]), and wraps them in link comments inside the body
17542   of the code block.
17544 #+cindex: @samp{padline}, header argument
17545 The =padline= header argument controls insertion of newlines to pad
17546 source code in the tangled file.
17548 - =yes= ::
17550   Default.  Insert a newline before and after each code block in the
17551   tangled file.
17553 - =no= ::
17555   Do not insert newlines to pad the tangled code blocks.
17557 #+cindex: @samp{shebang}, header argument
17558 The =shebang= header argument can turn results into executable script
17559 files.  By setting it to a string value---for example, =:shebang
17560 "#!/bin/bash"=---Org inserts that string as the first line of the
17561 tangled file that the code block is extracted to.  Org then turns on
17562 the tangled file's executable permission.
17564 #+cindex: @samp{tangle-mode}, header argument
17565 The =tangle-mode= header argument specifies what permissions to set
17566 for tangled files by ~set-file-modes~.  For example, to make
17567 a read-only tangled file, use =:tangle-mode (identity #o444)=.  To
17568 make it executable, use =:tangle-mode (identity #o755)=.  It also
17569 overrides executable permission granted by =shebang=.  When multiple
17570 source code blocks tangle to a single file with different and
17571 conflicting =tangle-mode= header arguments, Org's behavior is
17572 undefined.
17574 #+cindex: @samp{no-expand}, header argument
17575 By default Org expands code blocks during tangling.  The =no-expand=
17576 header argument turns off such expansions.  Note that one side-effect
17577 of expansion by ~org-babel-expand-src-block~ also assigns values (see
17578 [[*Environment of a Code Block]]) to variables.  Expansions also replace
17579 Noweb references with their targets (see [[*Noweb Reference Syntax]]).
17580 Some of these expansions may cause premature assignment, hence this
17581 option.  This option makes a difference only for tangling.  It has no
17582 effect when exporting since code blocks for execution have to be
17583 expanded anyway.
17585 *** Functions
17586 :PROPERTIES:
17587 :UNNUMBERED: notoc
17588 :END:
17590 - ~org-babel-tangle~ ::
17592   #+findex: org-babel-tangle
17593   #+kindex: C-c C-v t
17594   Tangle the current file.  Bound to {{{kbd(C-c C-v t)}}}.
17596   With prefix argument only tangle the current code block.
17598 - ~org-babel-tangle-file~ ::
17600   #+findex: org-babel-tangle-file
17601   #+kindex: C-c C-v f
17602   Choose a file to tangle.  Bound to {{{kbd(C-c C-v f)}}}.
17604 *** Hooks
17605 :PROPERTIES:
17606 :UNNUMBERED: notoc
17607 :END:
17609 - ~org-babel-post-tangle-hook~ ::
17611   #+vindex: org-babel-post-tangle-hook
17612   This hook is run from within code files tangled by
17613   ~org-babel-tangle~, making it suitable for post-processing,
17614   compilation, and evaluation of code in the tangled files.
17616 *** Jumping between code and Org
17617 :PROPERTIES:
17618 :UNNUMBERED: notoc
17619 :END:
17621 #+findex: org-babel-tangle-jump-to-org
17622 Debuggers normally link errors and messages back to the source code.
17623 But for tangled files, we want to link back to the Org file, not to
17624 the tangled source file.  To make this extra jump, Org uses
17625 ~org-babel-tangle-jump-to-org~ function with two additional source
17626 code block header arguments:
17628 1. Set =padline= to true---this is the default setting.
17629 2. Set =comments= to =link=, which makes Org insert links to the Org
17630    file.
17632 ** Languages
17633 :PROPERTIES:
17634 :DESCRIPTION: List of supported code block languages.
17635 :END:
17636 #+cindex: babel, languages
17637 #+cindex: source code, languages
17638 #+cindex: code block, languages
17640 Code blocks in the following languages are supported.
17642 #+attr_texinfo: :columns 0.20 0.35 0.20 0.20
17643 | Language   | Identifier    | Language       | Identifier   |
17644 |------------+---------------+----------------+--------------|
17645 | Asymptote  | =asymptote=   | Lisp           | =lisp=       |
17646 | Awk        | =awk=         | Lua            | =lua=        |
17647 | C          | =C=           | MATLAB         | =matlab=     |
17648 | C++        | =C++=[fn:143] | Mscgen         | =mscgen=     |
17649 | Clojure    | =clojure=     | Objective Caml | =ocaml=      |
17650 | CSS        | =css=         | Octave         | =octave=     |
17651 | D          | =D=[fn:144]   | Org mode       | =org=        |
17652 | ditaa      | =ditaa=       | Oz             | =oz=         |
17653 | Emacs Calc | =calc=        | Perl           | =perl=       |
17654 | Emacs Lisp | =emacs-lisp=  | Plantuml       | =plantuml=   |
17655 | Eshell     | =eshell=      | Processing.js  | =processing= |
17656 | Fortran    | =fortran=     | Python         | =python=     |
17657 | Gnuplot    | =gnuplot=     | R              | =R=          |
17658 | GNU Screen | =screen=      | Ruby           | =ruby=       |
17659 | Graphviz   | =dot=         | Sass           | =sass=       |
17660 | Haskell    | =haskell=     | Scheme         | =scheme=     |
17661 | Java       | =java=        | Sed            | =sed=        |
17662 | Javascript | =js=          | shell          | =sh=         |
17663 | LaTeX      | =latex=       | SQL            | =sql=        |
17664 | Ledger     | =ledger=      | SQLite         | =sqlite=     |
17665 | Lilypond   | =lilypond=    | Vala           | =vala=       |
17667 Additional documentation for some languages is at
17668 https://orgmode.org/worg/org-contrib/babel/languages.html.
17670 #+vindex: org-babel-load-languages
17671 By default, only Emacs Lisp is enabled for evaluation.  To enable or
17672 disable other languages, customize the ~org-babel-load-languages~
17673 variable either through the Emacs customization interface, or by
17674 adding code to the init file as shown next.
17676 In this example, evaluation is disabled for Emacs Lisp, and enabled
17677 for R.
17679 #+begin_src emacs-lisp
17680 (org-babel-do-load-languages
17681  'org-babel-load-languages
17682  '((emacs-lisp . nil)
17683    (R . t)))
17684 #+end_src
17686 Note that this is not the only way to enable a language.  Org also
17687 enables languages when loaded with ~require~ statement.  For example,
17688 the following enables execution of Clojure code blocks:
17690 #+begin_src emacs-lisp
17691 (require 'ob-clojure)
17692 #+end_src
17694 ** Editing Source Code
17695 :PROPERTIES:
17696 :DESCRIPTION: Language major-mode editing.
17697 :END:
17698 #+cindex: code block, editing
17699 #+cindex: source code, editing
17701 #+kindex: C-c '
17702 Use {{{kbd(C-c ')}}} to edit the current code block.  It opens a new
17703 major mode edit buffer containing the body of the source code block,
17704 ready for any edits.  Use {{{kbd(C-c ')}}} again to close the buffer
17705 and return to the Org buffer.
17707 #+kindex: C-x C-s
17708 #+vindex: org-edit-src-auto-save-idle-delay
17709 #+cindex: auto-save, in code block editing
17710 {{{kbd(C-x C-s)}}} saves the buffer and updates the contents of the
17711 Org buffer.  Set ~org-edit-src-auto-save-idle-delay~ to save the base
17712 buffer after a certain idle delay time.  Set
17713 ~org-edit-src-turn-on-auto-save~ to auto-save this buffer into
17714 a separate file using Auto-save mode.
17716 While editing the source code in the major mode, the Org Src minor
17717 mode remains active.  It provides these customization variables as
17718 described below.  For even more variables, look in the customization
17719 group ~org-edit-structure~.
17721 - ~org-src-lang-modes~ ::
17723   #+vindex: org-src-lang-modes
17724   If an Emacs major-mode named ~<LANG>-mode~ exists, where
17725   {{{var(<LANG>)}}} is the language identifier from code block's
17726   header line, then the edit buffer uses that major mode.  Use this
17727   variable to arbitrarily map language identifiers to major modes.
17729 - ~org-src-window-setup~ ::
17731   #+vindex: org-src-window-setup
17732   For specifying Emacs window arrangement when the new edit buffer is
17733   created.
17735 - ~org-src-preserve-indentation~ ::
17737   #+cindex: indentation, in code blocks
17738   #+vindex: org-src-preserve-indentation
17739   Default is ~nil~.  Source code is indented.  This indentation
17740   applies during export or tangling, and depending on the context, may
17741   alter leading spaces and tabs.  When non-~nil~, source code is
17742   aligned with the leftmost column.  No lines are modified during
17743   export or tangling, which is very useful for white-space sensitive
17744   languages, such as Python.
17746 - ~org-src-ask-before-returning-to-edit-buffer~ ::
17748   #+vindex: org-src-ask-before-returning-to-edit-buffer
17749   When ~nil~, Org returns to the edit buffer without further prompts.
17750   The default prompts for a confirmation.
17752 #+vindex: org-src-fontify-natively
17753 #+vindex: org-src-block-faces
17754 Set ~org-src-fontify-natively~ to non-~nil~ to turn on native code
17755 fontification in the /Org/ buffer.  Fontification of code blocks can
17756 give visual separation of text and code on the display page.  To
17757 further customize the appearance of ~org-block~ for specific
17758 languages, customize ~org-src-block-faces~.  The following example
17759 shades the background of regular blocks, and colors source blocks only
17760 for Python and Emacs Lisp languages.
17762 #+begin_src emacs-lisp
17763 (require 'color)
17764 (set-face-attribute 'org-block nil :background
17765                     (color-darken-name
17766                      (face-attribute 'default :background) 3))
17768 (setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF"))
17769                             ("python" (:background "#E5FFB8"))))
17770 #+end_src
17772 ** Noweb Reference Syntax
17773 :PROPERTIES:
17774 :DESCRIPTION: Literate programming in Org mode.
17775 :END:
17776 #+cindex: code block, Noweb reference
17777 #+cindex: syntax, Noweb
17778 #+cindex: source code, Noweb reference
17780 Org supports named blocks in Noweb[fn:145] style syntax:
17782 : <<CODE-BLOCK-ID>>
17784 Org can replace the construct with the source code, or the results of
17785 evaluation, of the code block identified as {{{var(CODE-BLOCK-ID)}}}.
17787 #+cindex: @samp{noweb}, header argument
17788 The =noweb= header argument controls expansion of Noweb syntax
17789 references.  Expansions occur when source code blocks are evaluated,
17790 tangled, or exported.
17792 - =no= ::
17794   Default.  No expansion of Noweb syntax references in the body of the
17795   code when evaluating, tangling, or exporting.
17797 - =yes= ::
17799   Expansion of Noweb syntax references in the body of the code block
17800   when evaluating, tangling, or exporting.
17802 - =tangle= ::
17804   Expansion of Noweb syntax references in the body of the code block
17805   when tangling.  No expansion when evaluating or exporting.
17807 - =no-export= ::
17809   Expansion of Noweb syntax references in the body of the code block
17810   when evaluating or tangling.  No expansion when exporting.
17812 - =strip-export= ::
17814   Expansion of Noweb syntax references in the body of the code block
17815   when expanding prior to evaluating or tangling.  Removes Noweb
17816   syntax references when exporting.
17818 - =eval= ::
17820   Expansion of Noweb syntax references in the body of the code block
17821   only before evaluating.
17823 In the following example,
17825 #+begin_example
17826 ,#+NAME: initialization
17827 ,#+BEGIN_SRC emacs-lisp
17828   (setq sentence "Never a foot too far, even.")
17829 ,#+END_SRC
17831 ,#+BEGIN_SRC emacs-lisp :noweb yes
17832   <<initialization>>
17833   (reverse sentence)
17834 ,#+END_SRC
17835 #+end_example
17837 #+texinfo: @noindent
17838 the second code block is expanded as
17840 #+begin_example
17841 ,#+BEGIN_SRC emacs-lisp :noweb yes
17842   (setq sentence "Never a foot too far, even.")
17843   (reverse sentence)
17844 ,#+END_SRC
17845 #+end_example
17847 Noweb insertions honor prefix characters that appear before the Noweb
17848 syntax reference.  This behavior is illustrated in the following
17849 example.  Because the =<<example>>= Noweb reference appears behind the
17850 SQL comment syntax, each line of the expanded Noweb reference is
17851 commented.  With:
17853 #+begin_example
17854 ,#+NAME: example
17855 ,#+BEGIN_SRC text
17856   this is the
17857   multi-line body of example
17858 ,#+END_SRC
17859 #+end_example
17861 #+texinfo: @noindent
17862 this code block:
17864 #+begin_example
17865 ,#+BEGIN_SRC sql :noweb yes
17866  ---<<example>>
17867 ,#+END_SRC
17868 #+end_example
17870 #+texinfo: @noindent
17871 expands to:
17873 #+begin_example
17874 ,#+BEGIN_SRC sql :noweb yes
17875  ---this is the
17876  ---multi-line body of example
17877 ,#+END_SRC
17878 #+end_example
17880 Since this change does not affect Noweb replacement text without
17881 newlines in them, inline Noweb references are acceptable.
17883 This feature can also be used for management of indentation in
17884 exported code snippets.  With:
17886 #+begin_example
17887 ,#+NAME: if-true
17888 ,#+BEGIN_SRC python :exports none
17889   print('do things when true')
17890 ,#+end_src
17892 ,#+name: if-false
17893 ,#+begin_src python :exports none
17894   print('do things when false')
17895 ,#+end_src
17896 #+end_example
17898 #+texinfo: @noindent
17899 this code block:
17901 #+begin_example
17902 ,#+begin_src python :noweb yes :results output
17903   if true:
17904       <<if-true>>
17905   else:
17906       <<if-false>>
17907 ,#+end_src
17908 #+end_example
17910 #+texinfo: @noindent
17911 expands to:
17913 #+begin_example
17914 if true:
17915     print('do things when true')
17916 else:
17917     print('do things when false')
17918 #+end_example
17920 #+cindex: @samp{noweb-ref}, header argument
17921 When expanding Noweb style references, Org concatenates code blocks by
17922 matching the reference name to either the code block name or, if none
17923 is found, to the =noweb-ref= header argument.
17925 For simple concatenation, set this =noweb-ref= header argument at the
17926 sub-tree or file level.  In the example Org file shown next, the body
17927 of the source code in each block is extracted for concatenation to
17928 a pure code file when tangled.
17930 #+begin_example
17931 ,#+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
17932   <<fullest-disk>>
17933 ,#+END_SRC
17934 ,* the mount point of the fullest disk
17935   :PROPERTIES:
17936   :header-args: :noweb-ref fullest-disk
17937   :END:
17939 ,** query all mounted disks
17940 ,#+BEGIN_SRC sh
17941   df \
17942 ,#+END_SRC
17944 ,** strip the header row
17945 ,#+BEGIN_SRC sh
17946   |sed '1d' \
17947 ,#+END_SRC
17949 ,** output mount point of fullest disk
17950 ,#+BEGIN_SRC sh
17951   |awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}'
17952 ,#+END_SRC
17953 #+end_example
17955 #+cindex: @samp{noweb-sep}, header argument
17956 By default a newline separates each noweb reference concatenation.  To
17957 change this newline separator, edit the =noweb-sep= header argument.
17959 Eventually, Org can include the results of a code block rather than
17960 its body.  To that effect, append parentheses, possibly including
17961 arguments, to the code block name, as shown below.
17963 : <<code-block-name(optional arguments)>>
17965 Note that when using the above approach to a code block's results, the
17966 code block name set by =NAME= keyword is required; the reference set
17967 by =noweb-ref= does not work in that case.
17969 Here is an example that demonstrates how the exported content changes
17970 when Noweb style references are used with parentheses versus without.
17971 With:
17973 #+begin_example
17974 ,#+NAME: some-code
17975 ,#+BEGIN_SRC python :var num=0 :results output :exports none
17976   print(num*10)
17977 ,#+END_SRC
17978 #+end_example
17980 #+texinfo: @noindent
17981 this code block:
17983 #+begin_example
17984 ,#+BEGIN_SRC text :noweb yes
17985   <<some-code>>
17986 ,#+END_SRC
17987 #+end_example
17989 #+texinfo: @noindent
17990 expands to:
17992 : print(num*10)
17994 Below, a similar Noweb style reference is used, but with parentheses,
17995 while setting a variable =num= to 10:
17997 #+begin_example
17998 ,#+BEGIN_SRC text :noweb yes
17999   <<some-code(num=10)>>
18000 ,#+END_SRC
18001 #+end_example
18003 #+texinfo: @noindent
18004 Note that now the expansion contains the results of the code block
18005 =some-code=, not the code block itself:
18007 : 100
18009 ** Library of Babel
18010 :PROPERTIES:
18011 :DESCRIPTION: Use and contribute to a library of useful code blocks.
18012 :END:
18013 #+cindex: babel, library of
18014 #+cindex: source code, library
18015 #+cindex: code block, library
18017 The "Library of Babel" is a collection of code blocks.  Like
18018 a function library, these code blocks can be called from other Org
18019 files.  A collection of useful code blocks is available on [[https://orgmode.org/worg/library-of-babel.html][Worg]].  For
18020 remote code block evaluation syntax, see [[*Evaluating Code Blocks]].
18022 #+kindex: C-c C-v i
18023 #+findex: org-babel-lob-ingest
18024 For any user to add code to the library, first save the code in
18025 regular code blocks of an Org file, and then load the Org file with
18026 ~org-babel-lob-ingest~, which is bound to {{{kbd(C-c C-v i)}}}.
18028 ** Key bindings and Useful Functions
18029 :PROPERTIES:
18030 :DESCRIPTION: Work quickly with code blocks.
18031 :END:
18032 #+cindex: code block, key bindings
18034 Many common Org mode key sequences are re-bound depending on
18035 the context.
18037 Active key bindings in code blocks:
18039 #+kindex: C-c C-c
18040 #+findex: org-babel-execute-src-block
18041 #+kindex: C-c C-o
18042 #+findex: org-babel-open-src-block-result
18043 #+kindex: M-UP
18044 #+findex: org-babel-load-in-session
18045 #+kindex: M-DOWN
18046 #+findex: org-babel-pop-to-session
18047 #+attr_texinfo: :columns 0.2 0.55
18048 | Key binding        | Function                          |
18049 |--------------------+-----------------------------------|
18050 | {{{kbd(C-c C-c)}}} | ~org-babel-execute-src-block~     |
18051 | {{{kbd(C-c C-o)}}} | ~org-babel-open-src-block-result~ |
18052 | {{{kbd(M-UP)}}}    | ~org-babel-load-in-session~       |
18053 | {{{kbd(M-DOWN)}}}  | ~org-babel-pop-to-session~        |
18055 Active key bindings in Org mode buffer:
18057 #+kindex: C-c C-v p
18058 #+kindex: C-c C-v C-p
18059 #+kindex: C-c C-v n
18060 #+kindex: C-c C-v C-n
18061 #+kindex: C-c C-v e
18062 #+kindex: C-c C-v C-e
18063 #+kindex: C-c C-v o
18064 #+kindex: C-c C-v C-o
18065 #+kindex: C-c C-v v
18066 #+kindex: C-c C-v C-v
18067 #+kindex: C-c C-v u
18068 #+kindex: C-c C-v C-u
18069 #+kindex: C-c C-v g
18070 #+kindex: C-c C-v C-g
18071 #+kindex: C-c C-v r
18072 #+kindex: C-c C-v C-r
18073 #+kindex: C-c C-v b
18074 #+kindex: C-c C-v C-b
18075 #+kindex: C-c C-v s
18076 #+kindex: C-c C-v C-s
18077 #+kindex: C-c C-v d
18078 #+kindex: C-c C-v C-d
18079 #+kindex: C-c C-v t
18080 #+kindex: C-c C-v C-t
18081 #+kindex: C-c C-v f
18082 #+kindex: C-c C-v C-f
18083 #+kindex: C-c C-v c
18084 #+kindex: C-c C-v C-c
18085 #+kindex: C-c C-v j
18086 #+kindex: C-c C-v C-j
18087 #+kindex: C-c C-v l
18088 #+kindex: C-c C-v C-l
18089 #+kindex: C-c C-v i
18090 #+kindex: C-c C-v C-i
18091 #+kindex: C-c C-v I
18092 #+kindex: C-c C-v C-I
18093 #+kindex: C-c C-v z
18094 #+kindex: C-c C-v C-z
18095 #+kindex: C-c C-v a
18096 #+kindex: C-c C-v C-a
18097 #+kindex: C-c C-v h
18098 #+kindex: C-c C-v C-h
18099 #+kindex: C-c C-v x
18100 #+kindex: C-c C-v C-x
18101 #+findex: org-babel-previous-src-block
18102 #+findex: org-babel-next-src-block
18103 #+findex: org-babel-execute-maybe
18104 #+findex: org-babel-open-src-block-result
18105 #+findex: org-babel-expand-src-block
18106 #+findex: org-babel-goto-src-block-head
18107 #+findex: org-babel-goto-named-src-block
18108 #+findex: org-babel-goto-named-result
18109 #+findex: org-babel-execute-buffer
18110 #+findex: org-babel-execute-subtree
18111 #+findex: org-babel-demarcate-block
18112 #+findex: org-babel-tangle
18113 #+findex: org-babel-tangle-file
18114 #+findex: org-babel-check-src-block
18115 #+findex: org-babel-insert-header-arg
18116 #+findex: org-babel-load-in-session
18117 #+findex: org-babel-lob-ingest
18118 #+findex: org-babel-view-src-block-info
18119 #+findex: org-babel-switch-to-session-with-code
18120 #+findex: org-babel-sha1-hash
18121 #+findex: org-babel-describe-bindings
18122 #+findex: org-babel-do-key-sequence-in-edit-buffer
18123 #+attr_texinfo: :columns 0.45 0.55
18124 | Key binding                                    | Function                                   |
18125 |------------------------------------------------+--------------------------------------------|
18126 | {{{kbd(C-c C-v p)}}} or {{{kbd(C-c C-v C-p)}}} | ~org-babel-previous-src-block~             |
18127 | {{{kbd(C-c C-v n)}}} or {{{kbd(C-c C-v C-n)}}} | ~org-babel-next-src-block~                 |
18128 | {{{kbd(C-c C-v e)}}} or {{{kbd(C-c C-v C-e)}}} | ~org-babel-execute-maybe~                  |
18129 | {{{kbd(C-c C-v o)}}} or {{{kbd(C-c C-v C-o)}}} | ~org-babel-open-src-block-result~          |
18130 | {{{kbd(C-c C-v v)}}} or {{{kbd(C-c C-v C-v)}}} | ~org-babel-expand-src-block~               |
18131 | {{{kbd(C-c C-v u)}}} or {{{kbd(C-c C-v C-u)}}} | ~org-babel-goto-src-block-head~            |
18132 | {{{kbd(C-c C-v g)}}} or {{{kbd(C-c C-v C-g)}}} | ~org-babel-goto-named-src-block~           |
18133 | {{{kbd(C-c C-v r)}}} or {{{kbd(C-c C-v C-r)}}} | ~org-babel-goto-named-result~              |
18134 | {{{kbd(C-c C-v b)}}} or {{{kbd(C-c C-v C-b)}}} | ~org-babel-execute-buffer~                 |
18135 | {{{kbd(C-c C-v s)}}} or {{{kbd(C-c C-v C-s)}}} | ~org-babel-execute-subtree~                |
18136 | {{{kbd(C-c C-v d)}}} or {{{kbd(C-c C-v C-d)}}} | ~org-babel-demarcate-block~                |
18137 | {{{kbd(C-c C-v t)}}} or {{{kbd(C-c C-v C-t)}}} | ~org-babel-tangle~                         |
18138 | {{{kbd(C-c C-v f)}}} or {{{kbd(C-c C-v C-f)}}} | ~org-babel-tangle-file~                    |
18139 | {{{kbd(C-c C-v c)}}} or {{{kbd(C-c C-v C-c)}}} | ~org-babel-check-src-block~                |
18140 | {{{kbd(C-c C-v j)}}} or {{{kbd(C-c C-v C-j)}}} | ~org-babel-insert-header-arg~              |
18141 | {{{kbd(C-c C-v l)}}} or {{{kbd(C-c C-v C-l)}}} | ~org-babel-load-in-session~                |
18142 | {{{kbd(C-c C-v i)}}} or {{{kbd(C-c C-v C-i)}}} | ~org-babel-lob-ingest~                     |
18143 | {{{kbd(C-c C-v I)}}} or {{{kbd(C-c C-v C-I)}}} | ~org-babel-view-src-block-info~            |
18144 | {{{kbd(C-c C-v z)}}} or {{{kbd(C-c C-v C-z)}}} | ~org-babel-switch-to-session-with-code~    |
18145 | {{{kbd(C-c C-v a)}}} or {{{kbd(C-c C-v C-a)}}} | ~org-babel-sha1-hash~                      |
18146 | {{{kbd(C-c C-v h)}}} or {{{kbd(C-c C-v C-h)}}} | ~org-babel-describe-bindings~              |
18147 | {{{kbd(C-c C-v x)}}} or {{{kbd(C-c C-v C-x)}}} | ~org-babel-do-key-sequence-in-edit-buffer~ |
18149 ** Batch Execution
18150 :PROPERTIES:
18151 :DESCRIPTION: Call functions from the command line.
18152 :END:
18153 #+cindex: code block, batch execution
18154 #+cindex: source code, batch execution
18156 Org mode features, including working with source code facilities can
18157 be invoked from the command line.  This enables building shell scripts
18158 for batch processing, running automated system tasks, and expanding
18159 Org mode's usefulness.
18161 The sample script shows batch processing of multiple files using
18162 ~org-babel-tangle~.
18164 #+begin_example
18165 #!/bin/sh
18166 # Tangle files with Org mode
18168 emacs -Q --batch --eval "
18169     (progn
18170       (require 'ob-tangle)
18171       (dolist (file command-line-args-left)
18172         (with-current-buffer (find-file-noselect file)
18173           (org-babel-tangle))))
18174   " "$@"
18175 #+end_example
18177 * Miscellaneous
18178 :PROPERTIES:
18179 :DESCRIPTION: All the rest which did not fit elsewhere.
18180 :END:
18182 ** Completion
18183 :PROPERTIES:
18184 :DESCRIPTION: @kbd{M-@key{TAB}} guesses completions.
18185 :END:
18186 #+cindex: completion, of @TeX{} symbols
18187 #+cindex: completion, of TODO keywords
18188 #+cindex: completion, of dictionary words
18189 #+cindex: completion, of option keywords
18190 #+cindex: completion, of tags
18191 #+cindex: completion, of property keys
18192 #+cindex: completion, of link abbreviations
18193 #+cindex: @TeX{} symbol completion
18194 #+cindex: TODO keywords completion
18195 #+cindex: dictionary word completion
18196 #+cindex: option keyword completion
18197 #+cindex: tag completion
18198 #+cindex: link abbreviations, completion of
18200 Org has in-buffer completions.  Unlike minibuffer completions, which
18201 are useful for quick command interactions, Org's in-buffer completions
18202 are more suitable for content creation in Org documents.  Type one or
18203 more letters and invoke the hot key to complete the text in-place.
18204 Depending on the context and the keys, Org offers different types of
18205 completions.  No minibuffer is involved.  Such mode-specific hot keys
18206 have become an integral part of Emacs and Org provides several
18207 shortcuts.
18209 - {{{kbd(M-TAB)}}} ::
18210   #+kindex: M-TAB
18212   Complete word at point.
18214   - At the beginning of a headline, complete TODO keywords.
18216   - After =\=, complete TeX symbols supported by the exporter.
18218   - After =*=, complete headlines in the current buffer so that they
18219     can be used in search links like:
18221     : [[*find this headline]]
18223   - After =:= in a headline, complete tags.  Org deduces the list of
18224     tags from the =TAGS= in-buffer option (see [[*Setting Tags]]), the
18225     variable ~org-tag-alist~, or from all tags used in the current
18226     buffer.
18228   - After =:= and not in a headline, complete property keys.  The list
18229     of keys is constructed dynamically from all keys used in the
18230     current buffer.
18232   - After =[=, complete link abbreviations (see [[*Link Abbreviations]]).
18234   - After =#+=, complete the special keywords like =TYP_TODO= or
18235     file-specific =OPTIONS=.  After option keyword is complete,
18236     pressing {{{kbd(M-TAB)}}} again inserts example settings for this
18237     keyword.
18239   - After =STARTUP= keyword, complete startup items.
18241   - When point is anywhere else, complete dictionary words using
18242     Ispell.
18244 ** Structure Templates
18245 :PROPERTIES:
18246 :DESCRIPTION: Quick insertion of structural elements.
18247 :END:
18248 #+cindex: template insertion
18249 #+cindex: insertion, of templates
18251 With just a few keystrokes, it is possible to insert empty structural
18252 blocks, such as =#+BEGIN_SRC= ... =#+END_SRC=, or to wrap existing
18253 text in such a block.
18255 - {{{kbd(C-c C-\,)}}} (~org-insert-structure-template~) ::
18257   #+findex: org-insert-structure-template
18258   #+kindex: C-c C-,
18259   Prompt for a type of block structure, and insert the block at point.
18260   If the region is active, it is wrapped in the block.  First prompts
18261   the user for keys, which are used to look up a structure type from
18262   the variable below.  If the key is {{{kbd(TAB)}}}, {{{kbd(RET)}}},
18263   or {{{kbd(SPC)}}}, the user is prompted to enter a block type.
18265 #+vindex: org-structure-template-alist
18266 Available structure types are defined in
18267 ~org-structure-template-alist~, see the docstring for adding or
18268 changing values.
18270 #+cindex: Tempo
18271 #+cindex: template expansion
18272 #+cindex: insertion, of templates
18273 #+vindex: org-tempo-keywords-alist
18274 Org Tempo expands snippets to structures defined in
18275 ~org-structure-template-alist~ and ~org-tempo-keywords-alist~.  For
18276 example, {{{kbd(< s TAB)}}} creates a code block.  Enable it by
18277 customizing ~org-modules~ or add =(require 'org-tempo)= to your Emacs
18278 init file[fn:146].
18280 #+attr_texinfo: :columns 0.1 0.9
18281 | {{{kbd(a)}}} | =#+BEGIN_EXPORT ascii= ... =#+END_EXPORT= |
18282 | {{{kbd(c)}}} | =#+BEGIN_CENTER= ... =#+END_CENTER=       |
18283 | {{{kbd(C)}}} | =#+BEGIN_COMMENT= ... =#+END_COMMENT=     |
18284 | {{{kbd(e)}}} | =#+BEGIN_EXAMPLE= ... =#+END_EXAMPLE=     |
18285 | {{{kbd(E)}}} | =#+BEGIN_EXPORT= ... =#+END_EXPORT= |
18286 | {{{kbd(h)}}} | =#+BEGIN_EXPORT html= ... =#+END_EXPORT=  |
18287 | {{{kbd(l)}}} | =#+BEGIN_EXPORT latex= ... =#+END_EXPORT= |
18288 | {{{kbd(q)}}} | =#+BEGIN_QUOTE= ... =#+END_QUOTE=         |
18289 | {{{kbd(s)}}} | =#+BEGIN_SRC= ... =#+END_SRC=             |
18290 | {{{kbd(v)}}} | =#+BEGIN_VERSE= ... =#+END_VERSE=         |
18292 ** Escape Character
18294 #+cindex: escape character
18295 #+cindex: zero width space
18296 You may sometimes want to write text that looks like Org syntax, but
18297 should really read as plain text.  Org may use a specific escape
18298 character in some situations, e.g., a backslash in macros (see [[*Macro
18299 Replacement]]).  In the general case, however, we suggest to use the
18300 zero width space.  You can get it with one of the following:
18302 : C-x 8 <RET> zero width space <RET>
18303 : C-x 8 <RET> 200B <RET>
18305 For example, in order to write =[[1,2]]= as-is in your document, you can
18306 write this, where =X= denotes the zero width space character:
18308 : [[X1,2]]
18310 ** Speed Keys
18311 :PROPERTIES:
18312 :DESCRIPTION: Electric commands at the beginning of a headline.
18313 :END:
18314 #+cindex: speed keys
18316 Single keystrokes can execute custom commands in an Org file when
18317 point is on a headline.  Without the extra burden of a meta or
18318 modifier key, Speed Keys can speed navigation or execute custom
18319 commands.  Besides faster navigation, Speed Keys may come in handy on
18320 small mobile devices that do not have full keyboards.  Speed Keys may
18321 also work on TTY devices known for their problems when entering Emacs
18322 key chords.
18324 #+vindex: org-use-speed-commands
18325 By default, Org has Speed Keys disabled.  To activate Speed Keys, set
18326 the variable ~org-use-speed-commands~ to a non-~nil~ value.  To
18327 trigger a Speed Key, point must be at the beginning of an Org
18328 headline, before any of the stars.
18330 #+vindex: org-speed-commands-user
18331 #+findex: org-speed-command-help
18332 Org comes with a pre-defined list of Speed Keys.  To add or modify
18333 Speed Keys, customize the variable, ~org-speed-commands-user~.  For
18334 more details, see the variable's docstring.  With Speed Keys
18335 activated, {{{kbd(M-x org-speed-command-help)}}}, or {{{kbd(?)}}} when
18336 point is at the beginning of an Org headline, shows currently active
18337 Speed Keys, including the user-defined ones.
18339 ** Code Evaluation and Security Issues
18340 :PROPERTIES:
18341 :DESCRIPTION: Org files evaluate in-line code.
18342 :ALT_TITLE: Code Evaluation Security
18343 :END:
18345 Unlike plain text, running code comes with risk.  Each source code
18346 block, in terms of risk, is equivalent to an executable file.  Org
18347 therefore puts a few confirmation prompts by default.  This is to
18348 alert the casual user from accidentally running untrusted code.
18350 For users who do not run code blocks or write code regularly, Org's
18351 default settings should suffice.  However, some users may want to
18352 tweak the prompts for fewer interruptions.  To weigh the risks of
18353 automatic execution of code blocks, here are some details about code
18354 evaluation.
18356 Org evaluates code in the following circumstances:
18358 - /Source code blocks/ ::
18360   Org evaluates source code blocks in an Org file during export.  Org
18361   also evaluates a source code block with the {{{kbd(C-c C-c)}}} key
18362   chord.  Users exporting or running code blocks must load files only
18363   from trusted sources.  Be wary of customizing variables that remove
18364   or alter default security measures.
18366   #+attr_texinfo: :options org-confirm-babel-evaluate
18367   #+begin_defopt
18368   When ~t~, Org prompts the user for confirmation before executing
18369   each code block.  When ~nil~, Org executes code blocks without
18370   prompting the user for confirmation.  When this option is set to
18371   a custom function, Org invokes the function with these two
18372   arguments: the source code language and the body of the code block.
18373   The custom function must return either a ~t~ or ~nil~, which
18374   determines if the user is prompted.  Each source code language can
18375   be handled separately through this function argument.
18376   #+end_defopt
18378   For example, here is how to execute ditaa code blocks without
18379   prompting:
18381   #+begin_src emacs-lisp
18382   (defun my-org-confirm-babel-evaluate (lang body)
18383     (not (string= lang "ditaa")))  ;don't ask for ditaa
18384   (setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
18385   #+end_src
18387 - /Following =shell= and =elisp= links/ ::
18389   Org has two link types that can directly evaluate code (see
18390   [[*External Links]]).  Because such code is not visible, these links
18391   have a potential risk.  Org therefore prompts the user when it
18392   encounters such links.  The customization variables are:
18394   #+attr_texinfo: :options org-link-shell-confirm-function
18395   #+begin_defopt
18396   Function that prompts the user before executing a shell link.
18397   #+end_defopt
18399   #+attr_texinfo: :options org-link-elisp-confirm-function
18400   #+begin_defopt
18401   Function that prompts the user before executing an Emacs Lisp link.
18402   #+end_defopt
18404 - /Formulas in tables/ ::
18406   Formulas in tables (see [[*The Spreadsheet]]) are code that is evaluated
18407   either by the Calc interpreter, or by the Emacs Lisp interpreter.
18409 ** Customization
18410 :PROPERTIES:
18411 :DESCRIPTION: Adapting Org to your taste.
18412 :END:
18413 #+cindex: customization
18414 #+cindex: options, for customization
18415 #+cindex: variables, for customization
18417 Org has more than 500 variables for customization.  They can be
18418 accessed through the usual {{{kbd(M-x org-customize)}}} command.  Or
18419 through the Org menu: Org \rarr Customization \rarr Browse Org Group.
18421 Org also has per-file settings for some variables (see [[*Summary of
18422 In-Buffer Settings]]).
18424 ** Summary of In-Buffer Settings
18425 :PROPERTIES:
18426 :DESCRIPTION: Overview of keywords.
18427 :ALT_TITLE: In-buffer Settings
18428 :END:
18429 #+cindex: in-buffer settings
18430 #+cindex: special keywords
18432 In-buffer settings start with =#+=, followed by a keyword, a colon,
18433 and then a word for each setting.  Org accepts multiple settings on
18434 the same line.  Org also accepts multiple lines for a keyword.  This
18435 manual describes these settings throughout.  A summary follows here.
18437 #+cindex: refresh set-up
18438 {{{kbd(C-c C-c)}}} activates any changes to the in-buffer settings.
18439 Closing and reopening the Org file in Emacs also activates the
18440 changes.
18442 #+attr_texinfo: :sep ,
18443 - =#+ARCHIVE: %s_done= ::
18445   #+cindex: @samp{ARCHIVE}, keyword
18446   #+vindex: org-archive-location
18447   Sets the archive location of the agenda file.  The corresponding
18448   variable is ~org-archive-location~.
18450 - =#+CATEGORY= ::
18452   #+cindex: @samp{CATEGORY}, keyword
18453   Sets the category of the agenda file, which applies to the entire
18454   document.
18456 - =#+COLUMNS: %25ITEM ...= ::
18458   #+cindex: @samp{COLUMNS}, property
18459   Set the default format for columns view.  This format applies when
18460   columns view is invoked in locations where no =COLUMNS= property
18461   applies.
18463 - =#+CONSTANTS: name1=value1 ...= ::
18465   #+cindex: @samp{CONSTANTS}, keyword
18466   #+vindex: org-table-formula-constants
18467   #+vindex: org-table-formula
18468   Set file-local values for constants that table formulas can use.
18469   This line sets the local variable
18470   ~org-table-formula-constants-local~.  The global version of this
18471   variable is ~org-table-formula-constants~.
18473 - =#+FILETAGS: :tag1:tag2:tag3:= ::
18475   #+cindex: @samp{FILETAGS}, keyword
18476   Set tags that all entries in the file inherit from, including the
18477   top-level entries.
18479 - =#+LINK: linkword replace= ::
18481   #+cindex: @samp{LINK}, keyword
18482   #+vindex: org-link-abbrev-alist
18483   Each line specifies one abbreviation for one link.  Use multiple
18484   =LINK= keywords for more, see [[*Link Abbreviations]].  The
18485   corresponding variable is ~org-link-abbrev-alist~.
18487 - =#+PRIORITIES: highest lowest default= ::
18489   #+cindex: @samp{PRIORITIES}, keyword
18490   #+vindex: org-highest-priority
18491   #+vindex: org-lowest-priority
18492   #+vindex: org-default-priority
18493   This line sets the limits and the default for the priorities.  All
18494   three must be either letters A--Z or numbers 0--9.  The highest
18495   priority must have a lower ASCII number than the lowest priority.
18497 - =#+PROPERTY: Property_Name Value= ::
18499   #+cindex: @samp{PROPERTY}, keyword
18500   This line sets a default inheritance value for entries in the
18501   current buffer, most useful for specifying the allowed values of
18502   a property.
18504 - =#+SETUPFILE: file= ::
18506   #+cindex: @samp{SETUPFILE}, keyword
18507   The setup file or a URL pointing to such file is for additional
18508   in-buffer settings.  Org loads this file and parses it for any
18509   settings in it only when Org opens the main file.  If URL is
18510   specified, the contents are downloaded and stored in a temporary
18511   file cache.  {{{kbd(C-c C-c)}}} on the settings line parses and
18512   loads the file, and also resets the temporary file cache.  Org also
18513   parses and loads the document during normal exporting process.  Org
18514   parses the contents of this document as if it was included in the
18515   buffer.  It can be another Org file.  To visit the file---not
18516   a URL---use {{{kbd(C-c ')}}} while point is on the line with the
18517   file name.
18519 - =#+STARTUP:= ::
18521   #+cindex: @samp{STARTUP}, keyword
18522   Startup options Org uses when first visiting a file.
18524   #+vindex: org-startup-folded
18525   The first set of options deals with the initial visibility of the
18526   outline tree.  The corresponding variable for global default
18527   settings is ~org-startup-folded~ with a default value of ~t~, which
18528   is the same as ~overview~.
18530   - =overview= ::
18532     Top-level headlines only.
18534   - =content= ::
18536     All headlines.
18538   - =showall= ::
18540     No folding on any entry.
18542   - =showeverything= ::
18544     Show even drawer contents.
18546     #+vindex: org-startup-indented
18547     Dynamic virtual indentation is controlled by the variable
18548     ~org-startup-indented~[fn:147].
18550     - =indent= ::
18552       Start with ~org-indent-mode~ turned on.
18554     - =noindent= ::
18556       Start with ~org-indent-mode~ turned off.
18558       #+vindex: org-startup-align-all-tables
18559       Aligns tables consistently upon visiting a file.  The
18560       corresponding variable is ~org-startup-align-all-tables~ with
18561       ~nil~ as default value.
18563       - =align= ::
18565         Align all tables.
18567       - =noalign= ::
18569         Do not align tables on startup.
18571       #+vindex: org-startup-shrink-all-tables
18572       Shrink table columns with a width cookie.  The corresponding
18573       variable is ~org-startup-shrink-all-tables~ with ~nil~ as
18574       default value.
18576       #+vindex: org-startup-with-inline-images
18577       When visiting a file, inline images can be automatically
18578       displayed.  The corresponding variable is
18579       ~org-startup-with-inline-images~, with a default value ~nil~ to
18580       avoid delays when visiting a file.
18582       - =inlineimages= ::
18584         Show inline images.
18586       - =noinlineimages= ::
18588         Do not show inline images on startup.
18590       #+vindex: org-log-done
18591       #+vindex: org-log-note-clock-out
18592       #+vindex: org-log-repeat
18593       Logging the closing and reopening of TODO items and clock
18594       intervals can be configured using these options (see variables
18595       ~org-log-done~, ~org-log-note-clock-out~, and ~org-log-repeat~).
18597       - =logdone= ::
18599         Record a timestamp when an item is marked as done.
18601       - =lognotedone= ::
18603         Record timestamp and a note when DONE.
18605       - =nologdone= ::
18607         Do not record when items are marked as done.
18609       - =logrepeat= ::
18611         Record a time when reinstating a repeating item.
18613       - =lognoterepeat= ::
18615         Record a note when reinstating a repeating item.
18617       - =nologrepeat= ::
18619         Do not record when reinstating repeating item.
18621       - =lognoteclock-out= ::
18623         Record a note when clocking out.
18625       - =nolognoteclock-out= ::
18627         Do not record a note when clocking out.
18629       - =logreschedule= ::
18631         Record a timestamp when scheduling time changes.
18633       - =lognotereschedule= ::
18635         Record a note when scheduling time changes.
18637       - =nologreschedule= ::
18639         Do not record when a scheduling date changes.
18641       - =logredeadline= ::
18643         Record a timestamp when deadline changes.
18645       - =lognoteredeadline= ::
18647         Record a note when deadline changes.
18649       - =nologredeadline= ::
18651         Do not record when a deadline date changes.
18653       - =logrefile= ::
18655         Record a timestamp when refiling.
18657       - =lognoterefile= ::
18659         Record a note when refiling.
18661       - =nologrefile= ::
18663         Do not record when refiling.
18665       #+vindex: org-hide-leading-stars
18666       #+vindex: org-odd-levels-only
18667       Here are the options for hiding leading stars in outline
18668       headings, and for indenting outlines.  The corresponding
18669       variables are ~org-hide-leading-stars~ and
18670       ~org-odd-levels-only~, both with a default setting ~nil~
18671       (meaning =showstars= and =oddeven=).
18673       - =hidestars= ::
18675         Make all but one of the stars starting a headline invisible.
18677       - =showstars= ::
18679         Show all stars starting a headline.
18681       - =indent= ::
18683         Virtual indentation according to outline level.
18685       - =noindent= ::
18687         No virtual indentation according to outline level.
18689       - =odd= ::
18691         Allow only odd outline levels (1, 3, ...).
18693       - =oddeven= ::
18695         Allow all outline levels.
18697       #+vindex: org-put-time-stamp-overlays
18698       #+vindex: org-time-stamp-overlay-formats
18699       To turn on custom format overlays over timestamps (variables
18700       ~org-put-time-stamp-overlays~ and
18701       ~org-time-stamp-overlay-formats~), use:
18703       - =customtime= ::
18705         Overlay custom time format.
18707       #+vindex: constants-unit-system
18708       The following options influence the table spreadsheet (variable
18709       ~constants-unit-system~).
18711       - =constcgs= ::
18713         =constants.el= should use the c-g-s unit system.
18715       - =constSI= ::
18717         =constants.el= should use the SI unit system.
18719       #+vindex: org-footnote-define-inline
18720       #+vindex: org-footnote-auto-label
18721       #+vindex: org-footnote-auto-adjust
18722       To influence footnote settings, use the following keywords.  The
18723       corresponding variables are ~org-footnote-define-inline~,
18724       ~org-footnote-auto-label~, and ~org-footnote-auto-adjust~.
18726       - =fninline= ::
18728         Define footnotes inline.
18730       - =fnnoinline= ::
18732         Define footnotes in separate section.
18734       - =fnlocal= ::
18736         Define footnotes near first reference, but not inline.
18738       - =fnprompt= ::
18740         Prompt for footnote labels.
18742       - =fnauto= ::
18744         Create =[fn:1]=-like labels automatically (default).
18746       - =fnconfirm= ::
18748         Offer automatic label for editing or confirmation.
18750       - =fnadjust= ::
18752         Automatically renumber and sort footnotes.
18754       - =nofnadjust= ::
18756         Do not renumber and sort automatically.
18758       #+vindex: org-hide-block-startup
18759       To hide blocks on startup, use these keywords.  The
18760       corresponding variable is ~org-hide-block-startup~.
18762       - =hideblocks= ::
18764         Hide all begin/end blocks on startup.
18766       - =nohideblocks= ::
18768         Do not hide blocks on startup.
18770       #+vindex: org-pretty-entities
18771       The display of entities as UTF-8 characters is governed by the
18772       variable ~org-pretty-entities~ and the keywords
18774       - =entitiespretty= ::
18776         Show entities as UTF-8 characters where possible.
18778       - =entitiesplain= ::
18780         Leave entities plain.
18782 - =#+TAGS: TAG1(c1) TAG2(c2)= ::
18784   #+cindex: @samp{TAGS}, keyword
18785   #+vindex: org-tag-alist
18786   These lines (several such lines are allowed) specify the valid tags
18787   in this file, and (potentially) the corresponding /fast tag
18788   selection/ keys.  The corresponding variable is ~org-tag-alist~.
18790 - =#+TODO:=, =#+SEQ_TODO:=, =#+TYP_TODO:= ::
18792   #+cindex: @samp{SEQ_TODO}, keyword
18793   #+cindex: @samp{TODO}, keyword
18794   #+cindex: @samp{TYP_TODO}, keyword
18795   #+vindex: org-todo-keywords
18796   These lines set the TODO keywords and their interpretation in the
18797   current file.  The corresponding variable is ~org-todo-keywords~.
18799 ** The Very Busy {{{kbd(C-c C-c)}}} Key
18800 :PROPERTIES:
18801 :DESCRIPTION: When in doubt, press @kbd{C-c C-c}.
18802 :END:
18803 #+kindex: C-c C-c
18804 #+cindex: @kbd{C-c C-c}, overview
18806 The {{{kbd(C-c C-c)}}} key in Org serves many purposes depending on
18807 the context.  It is probably the most over-worked, multi-purpose key
18808 combination in Org.  Its uses are well documented throughout this
18809 manual, but here is a consolidated list for easy reference.
18811 - If any highlights shown in the buffer from the creation of a sparse
18812   tree, or from clock display, remove such highlights.
18814 - If point is in one of the special =KEYWORD= lines, scan the buffer
18815   for these lines and update the information.  Also reset the Org file
18816   cache used to temporary store the contents of URLs used as values
18817   for keywords like =SETUPFILE=.
18819 - If point is inside a table, realign the table.  The table realigns
18820   even if automatic table editor is turned off.
18822 - If point is on a =TBLFM= keyword, re-apply the formulas to the
18823   entire table.
18825 - If the current buffer is a capture buffer, close the note and file
18826   it.  With a prefix argument, also jump to the target location after
18827   saving the note.
18829 - If point is on a =<<<target>>>=, update radio targets and
18830   corresponding links in this buffer.
18832 - If point is on a property line or at the start or end of a property
18833   drawer, offer property commands.
18835 - If point is at a footnote reference, go to the corresponding
18836   definition, and /vice versa/.
18838 - If point is on a statistics cookie, update it.
18840 - If point is in a plain list item with a checkbox, toggle the status
18841   of the checkbox.
18843 - If point is on a numbered item in a plain list, renumber the ordered
18844   list.
18846 - If point is on the =#+BEGIN= line of a dynamic block, the block is
18847   updated.
18849 - If point is at a timestamp, fix the day name in the timestamp.
18851 ** A Cleaner Outline View
18852 :PROPERTIES:
18853 :DESCRIPTION: Getting rid of leading stars in the outline.
18854 :ALT_TITLE: Clean View
18855 :END:
18856 #+cindex: hiding leading stars
18857 #+cindex: dynamic indentation
18858 #+cindex: odd-levels-only outlines
18859 #+cindex: clean outline view
18861 Org's default outline with stars and no indents can become too
18862 cluttered for short documents.  For /book-like/ long documents, the
18863 effect is not as noticeable.  Org provides an alternate stars and
18864 indentation scheme, as shown on the right in the following table.  It
18865 uses only one star and indents text to line with the heading:
18867 #+begin_example
18868 ,* Top level headline             |    * Top level headline
18869 ,** Second level                  |      * Second level
18870 ,*** Third level                  |        * Third level
18871     some text                    |          some text
18872 ,*** Third level                  |        * Third level
18873     more text                    |          more text
18874 ,* Another top level headline     |    * Another top level headline
18875 #+end_example
18877 #+cindex: Indent mode
18878 #+findex: org-indent-mode
18879 To turn this mode on, use the minor mode, ~org-indent-mode~.  Text
18880 lines that are not headlines are prefixed with spaces to vertically
18881 align with the headline text[fn:148].
18883 #+vindex: org-indent-indentation-per-level
18884 To make more horizontal space, the headlines are shifted by two stars.
18885 This can be configured by the ~org-indent-indentation-per-level~
18886 variable.  Only one star on each headline is visible, the rest are
18887 masked with the same font color as the background.
18889 Note that turning on ~org-indent-mode~ sets ~org-hide-leading-stars~
18890 to ~t~ and ~org-adapt-indentation~ to ~nil~.
18892 #+vindex: org-startup-indented
18893 To globally turn on ~org-indent-mode~ for all files, customize the
18894 variable ~org-startup-indented~.
18896 To turn on indenting for individual files, use =STARTUP= keyword as
18897 follows:
18899 : #+STARTUP: indent
18901 Indent on startup makes Org use hard spaces to align text with
18902 headings as shown in examples below.
18904 - /Indentation of text below headlines/ ::
18906   Indent text to align with the headline.
18908   #+begin_example
18909   ,*** Third level
18910       more text, now indented
18911   #+end_example
18913   #+vindex: org-adapt-indentation
18914   Org supports this with paragraph filling, line wrapping, and
18915   structure editing, preserving or adapting the indentation as
18916   appropriate[fn:149].
18918 - /Hiding leading stars/ ::
18920   #+vindex: org-hide-leading-stars
18921   Org can make leading stars invisible.  For global preference,
18922   configure the variable ~org-hide-leading-stars~.  For per-file
18923   preference, use these file =STARTUP= options:
18925   #+begin_example
18926   ,#+STARTUP: hidestars
18927   ,#+STARTUP: showstars
18928   #+end_example
18930   With stars hidden, the tree is shown as:
18932   #+begin_example
18933   ,* Top level headline
18934    ,* Second level
18935     ,* Third level
18936     ...
18937   #+end_example
18939   #+vindex: org-hide, face
18940   Because Org makes the font color the same as the background color
18941   to hide to stars, sometimes ~org-hide~ face may need tweaking to
18942   get the effect right.  For some black and white combinations,
18943   ~grey90~ on a white background might mask the stars better.
18945 - /Odd levels/ ::
18947   #+vindex: org-odd-levels-only
18948   Using stars for only odd levels, 1, 3, 5, ..., can also clean up the
18949   clutter.  This removes two stars from each level[fn:150].  For Org
18950   to properly handle this cleaner structure during edits and exports,
18951   configure the variable ~org-odd-levels-only~.  To set this per-file,
18952   use either one of the following lines:
18954   #+begin_example
18955   ,#+STARTUP: odd
18956   ,#+STARTUP: oddeven
18957   #+end_example
18959   To switch between single and double stars layouts, use {{{kbd(M-x
18960   org-convert-to-odd-levels)}}} and {{{kbd(M-x
18961   org-convert-to-oddeven-levels)}}}.
18963 ** Dynamic Headline Numbering
18964 :PROPERTIES:
18965 :DESCRIPTION: Display and update outline numbering.
18966 :END:
18968 #+cindex: Org Num mode
18969 #+cindex: number headlines
18970 The Org Num minor mode, toggled with {{{kbd(M-x org-num-mode)}}},
18971 displays on top of headlines.  It also updates numbering automatically
18972 upon changes to the structure of the document.
18974 #+vindex: org-num-max-level
18975 #+vindex: org-num-skip-tags
18976 #+vindex: org-num-skip-commented
18977 #+vindex: org-num-skip-unnumbered
18978 By default, all headlines are numbered.  You can limit numbering to
18979 specific headlines according to their level, tags, =COMMENT= keyword,
18980 or =UNNUMBERED= property.  Set ~org-num-max-level~,
18981 ~org-num-skip-tags~, ~org-num-skip-commented~,
18982 ~org-num-skip-unnumbered~, or ~org-num-skip-footnotes~ accordingly.
18984 #+vindex: org-num-skip-footnotes
18985 If ~org-num-skip-footnotes~ is non-~nil~, footnotes sections (see
18986 [[*Creating Footnotes]]) are not numbered either.
18988 #+vindex: org-num-face
18989 #+vindex: org-num-format-function
18990 You can control how the numbering is displayed by setting
18991 ~org-num-face~ and ~org-num-format-function~.
18993 ** Using Org on a TTY
18994 :PROPERTIES:
18995 :DESCRIPTION: Using Org on a tty.
18996 :ALT_TITLE: TTY Keys
18997 :END:
18998 #+cindex: tty key bindings
19000 Org provides alternative key bindings for TTY and modern mobile
19001 devices that cannot perform movement commands on point and key
19002 bindings with modifier keys.  Some of these workarounds may be more
19003 cumbersome than necessary.  Users should look into customizing these
19004 further based on their usage needs.  For example, the normal
19005 {{{kbd(S-<cursor>)}}} for editing timestamp might be better with
19006 {{{kbd(C-c .)}}} chord.
19008 #+attr_texinfo: :columns 0.2 0.28 0.15 0.21
19009 | Default              | Alternative 1            | Speed key    | Alternative 2        |
19010 |----------------------+--------------------------+--------------+----------------------|
19011 | {{{kbd(S-TAB)}}}     | {{{kbd(C-u TAB)}}}       | {{{kbd(C)}}} |                      |
19012 | {{{kbd(M-LEFT)}}}    | {{{kbd(C-c C-x l)}}}     | {{{kbd(l)}}} | {{{kbd(Esc LEFT)}}}  |
19013 | {{{kbd(M-S-LEFT)}}}  | {{{kbd(C-c C-x L)}}}     | {{{kbd(L)}}} |                      |
19014 | {{{kbd(M-RIGHT)}}}   | {{{kbd(C-c C-x r)}}}     | {{{kbd(r)}}} | {{{kbd(Esc RIGHT)}}} |
19015 | {{{kbd(M-S-RIGHT)}}} | {{{kbd(C-c C-x R)}}}     | {{{kbd(R)}}} |                      |
19016 | {{{kbd(M-UP)}}}      | {{{kbd(C-c C-x u)}}}     |              | {{{kbd(Esc UP)}}}    |
19017 | {{{kbd(M-S-UP)}}}    | {{{kbd(C-c C-x U)}}}     | {{{kbd(U)}}} |                      |
19018 | {{{kbd(M-DOWN)}}}    | {{{kbd(C-c C-x d)}}}     |              | {{{kbd(Esc DOWN)}}}  |
19019 | {{{kbd(M-S-DOWN)}}}  | {{{kbd(C-c C-x D)}}}     | {{{kbd(D)}}} |                      |
19020 | {{{kbd(S-RET)}}}     | {{{kbd(C-c C-x c)}}}     |              |                      |
19021 | {{{kbd(M-RET)}}}     | {{{kbd(C-c C-x m)}}}     |              | {{{kbd(Esc RET)}}}   |
19022 | {{{kbd(M-S-RET)}}}   | {{{kbd(C-c C-x M)}}}     |              |                      |
19023 | {{{kbd(S-LEFT)}}}    | {{{kbd(C-c LEFT)}}}      |              |                      |
19024 | {{{kbd(S-RIGHT)}}}   | {{{kbd(C-c RIGHT)}}}     |              |                      |
19025 | {{{kbd(S-UP)}}}      | {{{kbd(C-c UP)}}}        |              |                      |
19026 | {{{kbd(S-DOWN)}}}    | {{{kbd(C-c DOWN)}}}      |              |                      |
19027 | {{{kbd(C-S-LEFT)}}}  | {{{kbd(C-c C-x LEFT)}}}  |              |                      |
19028 | {{{kbd(C-S-RIGHT)}}} | {{{kbd(C-c C-x RIGHT)}}} |              |                      |
19030 ** Context Dependent Documentation
19031 :PROPERTIES:
19032 :DESCRIPTION: Read documentation about current syntax.
19033 :ALT_TITLE: Documentation Access
19034 :END:
19035 #+cindex: documentation
19036 #+cindex: Info
19038 #+findex: org-info-find-node
19039 #+kindex: C-c C-x I
19040 {{{kbd(C-c C-x I)}}} in an Org file tries to open a suitable section
19041 of the Org manual depending on the syntax at point.  For example,
19042 using it on a headline displays "Document Structure" section.
19044 {{{kbd(q)}}} closes the Info window.
19046 ** Interaction with Other Packages
19047 :PROPERTIES:
19048 :DESCRIPTION: With other Emacs packages.
19049 :ALT_TITLE: Interaction
19050 :END:
19051 #+cindex: packages, interaction with other
19053 Org's compatibility and the level of interaction with other Emacs
19054 packages are documented here.
19056 *** Packages that Org cooperates with
19057 :PROPERTIES:
19058 :DESCRIPTION: Packages Org cooperates with.
19059 :ALT_TITLE: Cooperation
19060 :END:
19062 - =calc.el= by Dave Gillespie ::
19063   #+cindex: @file{calc.el}
19065   Org uses the Calc package for implementing spreadsheet functionality
19066   in its tables (see [[*The Spreadsheet]]).  Org also uses Calc for
19067   embedded calculations.  See [[info:calc::Embedded Mode][GNU Emacs Calc Manual]].
19069 - =constants.el= by Carsten Dominik ::
19070   #+cindex: @file{constants.el}
19071   #+vindex: org-table-formula-constants
19073   Org can use names for constants in formulas in tables.  Org can also
19074   use calculation suffixes for units, such as =M= for =Mega=.  For
19075   a standard collection of such constants, install the =constants=
19076   package.  Install version 2.0 of this package, available at
19077   [[http://www.astro.uva.nl/~dominik/Tools]].  Org checks if the function
19078   ~constants-get~ has been autoloaded.  Installation instructions are
19079   in the file =constants.el=.
19081 - =cdlatex.el= by Carsten Dominik ::
19082   #+cindex: @file{cdlatex.el}
19084   Org mode can make use of the CDLaTeX package to efficiently enter
19085   LaTeX fragments into Org files.  See [[*Using CDLaTeX to enter math]].
19087 - =imenu.el= by Ake Stenhoff and Lars Lindberg ::
19088   #+cindex: @file{imenu.el}
19090   Imenu creates dynamic menus based on an index of items in a file.
19091   Org mode supports Imenu menus.  Enable it with a mode hook as
19092   follows:
19094   #+begin_src emacs-lisp
19095   (add-hook 'org-mode-hook
19096             (lambda () (imenu-add-to-menubar "Imenu")))
19097   #+end_src
19099   #+vindex: org-imenu-depth
19100   By default the index is two levels deep---you can modify the
19101   depth using the option ~org-imenu-depth~.
19103 - =speedbar.el= by Eric\nbsp{}M.\nbsp{}Ludlam ::
19104   #+cindex: @file{speedbar.el}
19106   Speedbar package creates a special Emacs frame for displaying files
19107   and index items in files.  Org mode supports Speedbar; users can
19108   drill into Org files directly from the Speedbar.  The {{{kbd(<)}}}
19109   in the Speedbar frame tweaks the agenda commands to that file or to
19110   a subtree.
19112 - =table.el= by Takaaki Ota ::
19113   #+cindex: table editor, @file{table.el}
19114   #+cindex: @file{table.el}
19116   Complex ASCII tables with automatic line wrapping, column- and
19117   row-spanning, and alignment can be created using the Emacs table
19118   package by Takaaki Ota.  Org mode recognizes such tables and exports
19119   them properly.  {{{kbd(C-c ')}}} to edit these tables in a special
19120   buffer, much like Org's code blocks.  Because of interference with
19121   other Org mode functionality, Takaaki Ota tables cannot be edited
19122   directly in the Org buffer.
19124   - {{{kbd(C-c ')}}} (~org-edit-special~) ::
19126     #+kindex: C-c '
19127     #+findex: org-edit-special
19128     Edit a =table.el= table.  Works when point is in a =table.el=
19129     table.
19131   - {{{kbd(C-c ~​)}}} (~org-table-create-with-table.el~) ::
19133     #+kindex: C-c ~
19134     #+findex: org-table-create-with-table.el
19135     Insert a =table.el= table.  If there is already a table at point,
19136     this command converts it between the =table.el= format and the Org
19137     mode format.  See the documentation string of the command
19138     ~org-convert-table~ for the restrictions under which this is
19139     possible.
19141 *** Packages that conflict with Org mode
19142 :PROPERTIES:
19143 :DESCRIPTION: Packages that lead to conflicts.
19144 :ALT_TITLE: Conflicts
19145 :END:
19147 #+cindex: shift-selection-mode
19148 #+vindex: org-support-shift-select
19149 In Emacs, ~shift-selection-mode~ combines motions of point with shift
19150 key to enlarge regions.  Emacs sets this mode by default.  This
19151 conflicts with Org's use of {{{kbd(S-<cursor>)}}} commands to change
19152 timestamps, TODO keywords, priorities, and item bullet types, etc.
19153 Since {{{kbd(S-<cursor>)}}} commands outside of specific contexts do
19154 not do anything, Org offers the variable ~org-support-shift-select~
19155 for customization.  Org mode accommodates shift selection by (i)
19156 making it available outside of the special contexts where special
19157 commands apply, and (ii) extending an existing active region even if
19158 point moves across a special context.
19160 - =cua.el= by Kim\nbsp{}F.\nbsp{}Storm ::
19162   #+cindex: @file{cua.el}
19163   #+vindex: org-replace-disputed-keys
19164   Org key bindings conflict with {{{kbd(S-<cursor>)}}} keys used by
19165   CUA mode.  For Org to relinquish these bindings to CUA mode,
19166   configure the variable ~org-replace-disputed-keys~.  When set, Org
19167   moves the following key bindings in Org files, and in the agenda
19168   buffer---but not during date selection.
19170   #+attr_texinfo: :columns 0.4 0.4
19171   | {{{kbd(S-UP)}}}      \rArr{}  {{{kbd(M-p)}}}   | {{{kbd(S-DOWN)}}}     \rArr{}  {{{kbd(M-n)}}}   |
19172   | {{{kbd(S-LEFT)}}}    \rArr{}  {{{kbd(M--)}}}   | {{{kbd(S-RIGHT)}}}    \rArr{}  {{{kbd(M-+)}}}   |
19173   | {{{kbd(C-S-LEFT)}}}  \rArr{}  {{{kbd(M-S--)}}} | {{{kbd(C-S-RIGHT)}}}  \rArr{}  {{{kbd(M-S-+)}}} |
19175   #+vindex: org-disputed-keys
19176   Yes, these are unfortunately more difficult to remember.  If you
19177   want to have other replacement keys, look at the variable
19178   ~org-disputed-keys~.
19180 - =ecomplete.el= by Lars Magne Ingebrigtsen ::
19182   #+cindex: @file{ecomplete.el}
19183   Ecomplete provides "electric" address completion in address header
19184   lines in message buffers.  Sadly Orgtbl mode cuts Ecomplete's power
19185   supply: no completion happens when Orgtbl mode is enabled in message
19186   buffers while entering text in address header lines.  If one wants
19187   to use ecomplete one should /not/ follow the advice to automagically
19188   turn on Orgtbl mode in message buffers (see [[*The Orgtbl Minor Mode]]),
19189   but instead---after filling in the message headers---turn on Orgtbl
19190   mode manually when needed in the messages body.
19192 - =filladapt.el= by Kyle Jones ::
19194   #+cindex: @file{filladapt.el}
19195   Org mode tries to do the right thing when filling paragraphs, list
19196   items and other elements.  Many users reported problems using both
19197   =filladapt.el= and Org mode, so a safe thing to do is to disable
19198   filladapt like this:
19200   #+begin_src emacs-lisp
19201   (add-hook 'org-mode-hook 'turn-off-filladapt-mode)
19202   #+end_src
19204 - =viper.el= by Michael Kifer ::
19205   #+cindex: @file{viper.el}
19206   #+kindex: C-c /
19208   Viper uses {{{kbd(C-c /)}}} and therefore makes this key not access
19209   the corresponding Org mode command ~org-sparse-tree~.  You need to
19210   find another key for this command, or override the key in
19211   ~viper-vi-global-user-map~ with
19213   #+begin_src emacs-lisp
19214   (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
19215   #+end_src
19217 - =windmove.el= by Hovav Shacham ::
19218   #+cindex: @file{windmove.el}
19220   This package also uses the {{{kbd(S-<cursor>)}}} keys, so everything
19221   written in the paragraph above about CUA mode also applies here.  If
19222   you want to make the windmove function active in locations where Org
19223   mode does not have special functionality on {{{kbd(S-<cursor>)}}},
19224   add this to your configuration:
19226   #+begin_src emacs-lisp
19227   ;; Make windmove work in Org mode:
19228   (add-hook 'org-shiftup-final-hook 'windmove-up)
19229   (add-hook 'org-shiftleft-final-hook 'windmove-left)
19230   (add-hook 'org-shiftdown-final-hook 'windmove-down)
19231   (add-hook 'org-shiftright-final-hook 'windmove-right)
19232   #+end_src
19234 - =yasnippet.el= ::
19236   #+cindex: @file{yasnippet.el}
19237   The way Org mode binds the {{{kbd(TAB)}}} key (binding to ~[tab]~
19238   instead of ~"\t"~) overrules YASnippet's access to this key.  The
19239   following code fixed this problem:
19241   #+begin_src emacs-lisp
19242   (add-hook 'org-mode-hook
19243             (lambda ()
19244               (setq-local yas/trigger-key [tab])
19245               (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
19246   #+end_src
19248   The latest version of YASnippet does not play well with Org mode.
19249   If the above code does not fix the conflict, start by defining
19250   the following function:
19252   #+begin_src emacs-lisp
19253   (defun yas/org-very-safe-expand ()
19254     (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
19255   #+end_src
19257   Then, tell Org mode to use that function:
19259   #+begin_src emacs-lisp
19260   (add-hook 'org-mode-hook
19261             (lambda ()
19262               (make-variable-buffer-local 'yas/trigger-key)
19263               (setq yas/trigger-key [tab])
19264               (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
19265               (define-key yas/keymap [tab] 'yas/next-field)))
19266   #+end_src
19268 ** Org Crypt
19269 :PROPERTIES:
19270 :DESCRIPTION: Encrypting Org files.
19271 :END:
19273 Org Crypt encrypts the text of an entry, but not the headline, or
19274 properties.  Behind the scene, it uses the Emacs EasyPG library to
19275 encrypt and decrypt files.
19277 #+vindex: org-crypt-tag-matcher
19278 Any text below a headline that has a =crypt= tag is automatically
19279 encrypted when the file is saved.  To use a different tag, customize
19280 the ~org-crypt-tag-matcher~ setting.
19282 Here is a suggestion for Org Crypt settings in Emacs init file:
19284 #+begin_src emacs-lisp
19285 (require 'org-crypt)
19286 (org-crypt-use-before-save-magic)
19287 (setq org-tags-exclude-from-inheritance '("crypt"))
19289 (setq org-crypt-key nil)
19290 ;; GPG key to use for encryption
19291 ;; Either the Key ID or set to nil to use symmetric encryption.
19293 (setq auto-save-default nil)
19294 ;; Auto-saving does not cooperate with org-crypt.el: so you need to
19295 ;; turn it off if you plan to use org-crypt.el quite often.  Otherwise,
19296 ;; you'll get an (annoying) message each time you start Org.
19298 ;; To turn it off only locally, you can insert this:
19300 ;; # -*- buffer-auto-save-file-name: nil; -*-
19301 #+end_src
19303 It's possible to use different keys for different headings by
19304 specifying the respective key as property =CRYPTKEY=, e.g.:
19306 #+begin_example
19307 ,* Totally secret :crypt:
19308   :PROPERTIES:
19309   :CRYPTKEY: 0x0123456789012345678901234567890123456789
19310   :END:
19311 #+end_example
19313 Excluding the =crypt= tag from inheritance prevents already encrypted
19314 text from being encrypted again.
19316 ** Org Mobile
19317 :PROPERTIES:
19318 :DESCRIPTION: Viewing and capture on a mobile device.
19319 :END:
19320 #+cindex: smartphone
19322 Org Mobile is a protocol for synchronizing Org files between Emacs and
19323 other applications, e.g., on mobile devices.  It enables offline-views
19324 and capture support for an Org mode system that is rooted on a "real"
19325 computer.  The external application can also record changes to
19326 existing entries.
19328 This appendix describes Org's support for agenda view formats
19329 compatible with Org Mobile.  It also describes synchronizing changes,
19330 such as to notes, between the mobile application and the computer.
19332 To change tags and TODO states in the mobile application, first
19333 customize the variables ~org-todo-keywords~ and ~org-tag-alist~.
19334 These should cover all the important tags and TODO keywords, even if
19335 Org files use only some of them.  Though the mobile application is
19336 expected to support in-buffer settings, it is required to understand
19337 TODO states /sets/ (see [[*Setting up keywords for individual files]]) and
19338 /mutually exclusive/ tags (see [[*Setting Tags]]) only for those set in
19339 these variables.
19341 *** Setting up the staging area
19342 :PROPERTIES:
19343 :DESCRIPTION: For the mobile device.
19344 :END:
19346 #+vindex: org-mobile-directory
19347 The mobile application needs access to a file directory on
19348 a server[fn:151] to interact with Emacs.  Pass its location through
19349 the ~org-mobile-directory~ variable.  If you can mount that directory
19350 locally just set the variable to point to that directory:
19352 #+begin_src emacs-lisp
19353 (setq org-mobile-directory "~/orgmobile/")
19354 #+end_src
19356 Alternatively, by using TRAMP (see [[info:tramp][TRAMP User Manual]]),
19357 ~org-mobile-directory~ may point to a remote directory accessible
19358 through, for example, SSH, SCP, or DAVS:
19360 #+begin_src emacs-lisp
19361 (setq org-mobile-directory "/davs:user@remote.host:/org/webdav/")
19362 #+end_src
19364 #+vindex: org-mobile-encryption
19365 With a public server, consider encrypting the files.  Org also
19366 requires OpenSSL installed on the local computer.  To turn on
19367 encryption, set the same password in the mobile application and in
19368 Emacs.  Set the password in the variable
19369 ~org-mobile-use-encryption~[fn:152].  Note that even after the mobile
19370 application encrypts the file contents, the file name remains visible
19371 on the file systems of the local computer, the server, and the mobile
19372 device.
19374 *** Pushing to the mobile application
19375 :PROPERTIES:
19376 :DESCRIPTION: Uploading Org files and agendas.
19377 :END:
19379 #+findex: org-mobile-push
19380 #+vindex: org-mobile-files
19381 The command ~org-mobile-push~ copies files listed in
19382 ~org-mobile-files~ into the staging area.  Files include agenda files
19383 (as listed in ~org-agenda-files~).  Customize ~org-mobile-files~ to
19384 add other files.  File names are staged with paths relative to
19385 ~org-directory~, so all files should be inside this directory[fn:153].
19387 Push creates a special Org file =agendas.org= with custom agenda views
19388 defined by the user[fn:154].
19390 Finally, Org writes the file =index.org=, containing links to other
19391 files.  The mobile application reads this file first from the server
19392 to determine what other files to download for agendas.  For faster
19393 downloads, it is expected to only read files whose checksums[fn:155]
19394 have changed.
19396 *** Pulling from the mobile application
19397 :PROPERTIES:
19398 :DESCRIPTION: Integrating captured and flagged items.
19399 :END:
19401 #+findex: org-mobile-pull
19402 The command ~org-mobile-pull~ synchronizes changes with the server.
19403 More specifically, it first pulls the Org files for viewing.  It then
19404 appends captured entries and pointers to flagged or changed entries to
19405 the file =mobileorg.org= on the server.  Org ultimately integrates its
19406 data in an inbox file format, through the following steps:
19409    #+vindex: org-mobile-inbox-for-pull
19410    Org moves all entries found in =mobileorg.org=[fn:156] and appends
19411    them to the file pointed to by the variable
19412    ~org-mobile-inbox-for-pull~.  It should reside neither in the
19413    staging area nor on the server.  Each captured entry and each
19414    editing event is a top-level entry in the inbox file.
19417    #+cindex: @samp{FLAGGED}, tag
19418    After moving the entries, Org processes changes to the shared
19419    files.  Some of them are applied directly and without user
19420    interaction.  Examples include changes to tags, TODO state,
19421    headline and body text.  Entries requiring further action are
19422    tagged as =FLAGGED=.  Org marks entries with problems with an error
19423    message in the inbox.  They have to be resolved manually.
19425 3. Org generates an agenda view for flagged entries for user
19426    intervention to clean up.  For notes stored in flagged entries, Org
19427    displays them in the echo area when point is on the corresponding
19428    agenda item.
19430    - {{{kbd(?)}}} ::
19432      Pressing {{{kbd(?)}}} displays the entire flagged note in another
19433      window.  Org also pushes it to the kill ring.  To store flagged
19434      note as a normal note, use {{{kbd(? z C-y C-c C-c)}}}.  Pressing
19435      {{{kbd(?)}}} twice does these things: first it removes the
19436      =FLAGGED= tag; second, it removes the flagged note from the
19437      property drawer; third, it signals that manual editing of the
19438      flagged entry is now finished.
19440 #+kindex: ? @r{(Agenda dispatcher)}
19441 From the agenda dispatcher, {{{kbd(?)}}} returns to the view to finish
19442 processing flagged entries.  Note that these entries may not be the
19443 most recent since the mobile application searches files that were last
19444 pulled.  To get an updated agenda view with changes since the last
19445 pull, pull again.
19447 ** Org Syntax
19448 :PROPERTIES:
19449 :DESCRIPTION: Formal description of Org's syntax.
19450 :END:
19452 A reference document providing a formal description of Org's syntax is
19453 available as [[https://orgmode.org/worg/dev/org-syntax.html][a draft on Worg]], written and maintained by Nicolas
19454 Goaziou.  It defines Org's core internal concepts such as "headlines",
19455 "sections", "affiliated keywords", "(greater) elements" and "objects".
19456 Each part of an Org document belongs to one of the previous
19457 categories.
19459 To explore the abstract structure of an Org buffer, run this in
19460 a buffer:
19462 : M-: (org-element-parse-buffer) <RET>
19464 #+texinfo: @noindent
19465 It outputs a list containing the buffer's content represented as an
19466 abstract structure.  The export engine relies on the information
19467 stored in this list.  Most interactive commands---e.g., for structure
19468 editing---also rely on the syntactic meaning of the surrounding
19469 context.
19471 #+cindex: syntax checker
19472 #+cindex: linter
19473 #+findex: org-lint
19474 You can probe the syntax of your documents with the command
19476 : M-x org-lint <RET>
19478 #+texinfo: @noindent
19479 It runs a number of checks to find common mistakes.  It then displays
19480 their location in a dedicated buffer, along with a description and
19481 a "trust level", since false-positive are possible.  From there, you
19482 can operate on the reports with the following keys:
19484 #+attr_texinfo: :columns 0.22 0.78
19485 | {{{kbd(C-j)}}}, {{{kbd(TAB)}}} | Display the offending line                  |
19486 | {{{kbd(RET)}}}                 | Move point to the offending line            |
19487 | {{{kbd(g)}}}                   | Check the document again                    |
19488 | {{{kbd(h)}}}                   | Hide all reports from the same checker      |
19489 | {{{kbd(i)}}}                   | Also remove them from all subsequent checks |
19490 | {{{kbd(S)}}}                   | Sort reports by the column at point         |
19492 * Hacking
19493 :PROPERTIES:
19494 :DESCRIPTION: How to hack your way around.
19495 :APPENDIX: t
19496 :END:
19497 #+cindex: hacking
19499 This appendix describes some ways a user can extend the functionality
19500 of Org.
19502 ** Hooks
19503 :PROPERTIES:
19504 :DESCRIPTION: How to reach into Org's internals.
19505 :END:
19506 #+cindex: hooks
19508 Org has a large number of hook variables for adding functionality.
19509 This appendix illustrates using a few.  A complete list of hooks with
19510 documentation is maintained by the Worg project at
19511 https://orgmode.org/worg/doc.html#hooks.
19513 ** Add-on Packages
19514 :PROPERTIES:
19515 :DESCRIPTION: Available extensions.
19516 :END:
19517 #+cindex: add-on packages
19519 Various authors wrote a large number of add-on packages for Org.
19521 These packages are not part of Emacs, but they are distributed as
19522 contributed packages with the separate release available at
19523 https://orgmode.org.  See the =contrib/README= file in the source code
19524 directory for a list of contributed files.  Worg page with more
19525 information is at: https://orgmode.org/worg/org-contrib/.
19527 ** Adding Hyperlink Types
19528 :PROPERTIES:
19529 :DESCRIPTION: New custom link types.
19530 :END:
19531 #+cindex: hyperlinks, adding new types
19533 Org has many built-in hyperlink types (see [[*Hyperlinks]]), and an
19534 interface for adding new link types.  The following example shows the
19535 process of adding Org links to Unix man pages, which look like this
19537 : [[man:printf][The printf manual]]
19539 #+texinfo: @noindent
19540 The following =org-man.el= file implements it
19542 #+begin_src emacs-lisp
19543 ;;; org-man.el - Support for links to man pages in Org mode
19544 (require 'org)
19546 (org-link-set-parameters "man"
19547                          :follow org-man-command
19548                          :export #'org-man-export
19549                          :store #'org-man-store-link)
19551 (defcustom org-man-command 'man
19552   "The Emacs command to be used to display a man page."
19553   :group 'org-link
19554   :type '(choice (const man) (const woman)))
19556 (defun org-man-store-link ()
19557   "Store a link to a man page."
19558   (when (memq major-mode '(Man-mode woman-mode))
19559     ;; This is a man page, we do make this link.
19560     (let* ((page (org-man-get-page-name))
19561            (link (concat "man:" page))
19562            (description (format "Man page for %s" page)))
19563       (org-store-link-props
19564        :type "man"
19565        :link link
19566        :description description))))
19568 (defun org-man-get-page-name ()
19569   "Extract the page name from the buffer name."
19570   ;; This works for both `Man-mode' and `woman-mode'.
19571   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
19572       (match-string 1 (buffer-name))
19573     (error "Cannot create link to this man page")))
19575 (defun org-man-export (link description format)
19576   "Export a man page link from Org files."
19577   (let ((path (format "http://man.he.net/?topic=%s&section=all" link))
19578         (desc (or description link)))
19579     (pcase format
19580       (`html (format "<a target=\"_blank\" href=\"%s\">%s</a>" path desc))
19581       (`latex (format "\\href{%s}{%s}" path desc))
19582       (`texinfo (format "@uref{%s,%s}" path desc))
19583       (`ascii (format "%s (%s)" desc path))
19584       (t path))))
19586 (provide 'org-man)
19587 ;;; org-man.el ends here
19588 #+end_src
19590 #+texinfo: @noindent
19591 To activate links to man pages in Org, enter this in the Emacs init
19592 file:
19594 #+begin_src emacs-lisp
19595 (require 'org-man)
19596 #+end_src
19598 #+texinfo: @noindent
19599 A review of =org-man.el=:
19601 1. First, =(require 'org)= ensures =org.el= is loaded.
19605    #+findex: org-link-set-parameters
19606    #+vindex: org-link-parameters
19607    Then ~org-link-set-parameters~ defines a new link type with =man=
19608    prefix and associates functions for following, exporting and
19609    storing such links.  See the variable ~org-link-parameters~ for
19610    a complete list of possible associations.
19612 3. The rest of the file implements necessary variables and functions.
19614    For example, ~org-man-store-link~ is responsible for storing a link
19615    when ~org-store-link~ (see [[*Handling Links]]) is called from a buffer
19616    displaying a man page.  It first checks if the ~major-mode~ is
19617    appropriate.  If check fails, the function returns ~nil~, which
19618    means it isn't responsible for creating a link to the current
19619    buffer.  Otherwise the function makes a link string by combining
19620    the =man:= prefix with the man topic.  It also provides a default
19621    description.  The function ~org-insert-link~ can insert it back
19622    into an Org buffer later on.
19624 ** Adding Export Back-ends
19625 :PROPERTIES:
19626 :DESCRIPTION: How to write new export back-ends.
19627 :END:
19628 #+cindex: Export, writing back-ends
19630 Org's export engine makes it easy for writing new back-ends.  The
19631 framework on which the engine was built makes it easy to derive new
19632 back-ends from existing ones.
19634 #+findex: org-export-define-backend
19635 #+findex: org-export-define-derived-backend
19636 The two main entry points to the export engine are:
19637 ~org-export-define-backend~ and ~org-export-define-derived-backend~.
19638 To grok these functions, see =ox-latex.el= for an example of defining
19639 a new back-end from scratch, and =ox-beamer.el= for an example of
19640 deriving from an existing engine.
19642 For creating a new back-end from scratch, first set its name as
19643 a symbol in an alist consisting of elements and export functions.  To
19644 make the back-end visible to the export dispatcher, set ~:menu-entry~
19645 keyword.  For export options specific to this back-end, set the
19646 ~:options-alist~.
19648 For creating a new back-end from an existing one, set
19649 ~:translate-alist~ to an alist of export functions.  This alist
19650 replaces the parent back-end functions.
19652 For complete documentation, see [[https://orgmode.org/worg/dev/org-export-reference.html][the Org Export Reference on Worg]].
19654 ** Tables in Arbitrary Syntax
19655 :PROPERTIES:
19656 :DESCRIPTION: Orgtbl for LaTeX and other programs.
19657 :END:
19658 #+cindex: tables, in other modes
19659 #+cindex: lists, in other modes
19660 #+cindex: Orgtbl mode
19662 Due to Org's success in handling tables with Orgtbl, a frequently
19663 requested feature is the use of Org's table functions in other modes,
19664 e.g., LaTeX.  This would be hard to do in a general way without
19665 complicated customization nightmares.  Moreover, that would take Org
19666 away from its simplicity roots that Orgtbl has proven.  There is,
19667 however, an alternate approach to accomplishing the same.
19669 This approach involves implementing a custom /translate/ function that
19670 operates on a native Org /source table/ to produce a table in another
19671 format.  This strategy would keep the excellently working Orgtbl
19672 simple and isolate complications, if any, confined to the translate
19673 function.  To add more alien table formats, we just add more translate
19674 functions.  Also the burden of developing custom translate functions
19675 for new table formats is in the hands of those who know those formats
19676 best.
19678 *** Radio tables
19679 :PROPERTIES:
19680 :DESCRIPTION: Sending and receiving radio tables.
19681 :END:
19682 #+cindex: radio tables
19684 Radio tables are target locations for translated tables that are not near
19685 their source.  Org finds the target location and inserts the translated
19686 table.
19688 The key to finding the target location is the magic words =BEGIN/END
19689 RECEIVE ORGTBL=.  They have to appear as comments in the current mode.
19690 If the mode is C, then:
19692 #+begin_example
19693 /* BEGIN RECEIVE ORGTBL table_name */
19694 /* END RECEIVE ORGTBL table_name */
19695 #+end_example
19697 At the location of source, Org needs a special line to direct Orgtbl
19698 to translate and to find the target for inserting the translated
19699 table.  For example:
19701 #+cindex: @samp{ORGTBL}, keyword
19702 : #+ORGTBL: SEND table_name translation_function arguments ...
19704 #+texinfo: @noindent
19705 =table_name= is the table's reference name, which is also used in the
19706 receiver lines, and the =translation_function= is the Lisp function
19707 that translates.  This line, in addition, may also contain alternating
19708 key and value arguments at the end.  The translation function gets
19709 these values as a property list.  A few standard parameters are
19710 already recognized and acted upon before the translation function is
19711 called:
19713 - =:skip N= ::
19715   Skip the first N lines of the table.  Hlines do count; include them
19716   if they are to be skipped.
19718 - =:skipcols (n1 n2 ...)= ::
19720   List of columns to be skipped.  First Org automatically discards
19721   columns with calculation marks and then sends the table to the
19722   translator function, which then skips columns as specified in
19723   =skipcols=.
19725 To keep the source table intact in the buffer without being disturbed
19726 when the source file is compiled or otherwise being worked on, use one
19727 of these strategies:
19729 - Place the table in a block comment.  For example, in C mode you
19730   could wrap the table between =/*= and =*/= lines.
19732 - Put the table after an "end" statement.  For example ~\bye~ in TeX
19733   and ~\end{document}~ in LaTeX.
19735 - Comment and un-comment each line of the table during edits.  The
19736   {{{kbd(M-x orgtbl-toggle-comment)}}} command makes toggling easy.
19738 *** A LaTeX example of radio tables
19739 :PROPERTIES:
19740 :DESCRIPTION: Step by step, almost a tutorial.
19741 :ALT_TITLE: A LaTeX example
19742 :END:
19743 #+cindex: @LaTeX{}, and Orgtbl mode
19745 To wrap a source table in LaTeX, use the =comment= environment
19746 provided by =comment.sty=[fn:157].  To activate it, put
19747 ~\usepackage{comment}~ in the document header.  Orgtbl mode inserts
19748 a radio table skeleton[fn:158] with the command {{{kbd(M-x
19749 orgtbl-insert-radio-table)}}}, which prompts for a table name.  For
19750 example, if =salesfigures= is the name, the template inserts:
19752 #+begin_example
19753 % BEGIN RECEIVE ORGTBL salesfigures
19754 % END RECEIVE ORGTBL salesfigures
19755 \begin{comment}
19756 ,#+ORGTBL: SEND salesfigures orgtbl-to-latex
19757 | | |
19758 \end{comment}
19759 #+end_example
19761 #+vindex: LaTeX-verbatim-environments
19762 #+texinfo: @noindent
19763 The line =#+ORGTBL: SEND= tells Orgtbl mode to use the function
19764 ~orgtbl-to-latex~ to convert the table to LaTeX format, then insert
19765 the table at the target (receive) location named =salesfigures=.  Now
19766 the table is ready for data entry.  It can even use spreadsheet
19767 features[fn:159]:
19769 #+begin_example
19770 % BEGIN RECEIVE ORGTBL salesfigures
19771 % END RECEIVE ORGTBL salesfigures
19772 \begin{comment}
19773 ,#+ORGTBL: SEND salesfigures orgtbl-to-latex
19774 | Month | Days | Nr sold | per day |
19775 |-------+------+---------+---------|
19776 | Jan   |   23 |      55 |     2.4 |
19777 | Feb   |   21 |      16 |     0.8 |
19778 | March |   22 |     278 |    12.6 |
19779 ,#+TBLFM: $4=$3/$2;%.1f
19780 % $ (optional extra dollar to keep Font Lock happy, see footnote)
19781 \end{comment}
19782 #+end_example
19784 After editing, {{{kbd(C-c C-c)}}} inserts the translated table at the
19785 target location, between the two marker lines.
19787 For hand-made custom tables, note that the translator needs to skip
19788 the first two lines of the source table.  Also the command has to
19789 /splice/ out the target table without the header and footer.
19791 #+begin_example
19792 \begin{tabular}{lrrr}
19793 Month & \multicolumn{1}{c}{Days} & Nr.\ sold & per day\\
19794 % BEGIN RECEIVE ORGTBL salesfigures
19795 % END RECEIVE ORGTBL salesfigures
19796 \end{tabular}
19798 \begin{comment}
19799 ,#+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
19800 | Month | Days | Nr sold | per day |
19801 |-------+------+---------+---------|
19802 | Jan   |   23 |      55 |     2.4 |
19803 | Feb   |   21 |      16 |     0.8 |
19804 | March |   22 |     278 |    12.6 |
19805 ,#+TBLFM: $4=$3/$2;%.1f
19806 \end{comment}
19807 #+end_example
19809 The LaTeX translator function ~orgtbl-to-latex~ is already part of
19810 Orgtbl mode and uses a =tabular= environment to typeset the table and
19811 marks horizontal lines with ~\hline~.  For additional parameters to
19812 control output, see [[*Translator functions]]:
19814 - =:splice BOOLEAN= ::
19816   When {{{var(BOOLEAN}}} is non-~nil~, return only table body lines;
19817   i.e., not wrapped in =tabular= environment.  Default is ~nil~.
19819 - =:fmt FMT= ::
19821   Format string to warp each field.  It should contain =%s= for the
19822   original field value.  For example, to wrap each field value in
19823   dollar symbol, you could use =:fmt "$%s$"=.  Format can also wrap
19824   a property list with column numbers and formats, for example =:fmt
19825   (2 "$%s$" 4 "%s\\%%")=.  In place of a string, a function of one
19826   argument can be used; the function must return a formatted string.
19828 - =:efmt EFMT= ::
19830   Format numbers as exponentials.  The spec should have =%s= twice for
19831   inserting mantissa and exponent, for example ="%s\\times10^{%s}"=.  This
19832   may also be a property list with column numbers and formats, for
19833   example =:efmt (2 "$%s\\times10^{%s}$" 4 "$%s\\cdot10^{%s}$")=.  After
19834   {{{var(EFMT)}}} has been applied to a value, {{{var(FMT)}}}---see
19835   above---is also applied.  Functions with two arguments can be
19836   supplied instead of strings.  By default, no special formatting is
19837   applied.
19839 *** Translator functions
19840 :PROPERTIES:
19841 :DESCRIPTION: Copy and modify.
19842 :END:
19843 #+cindex: HTML, and Orgtbl mode
19844 #+cindex: translator function
19846 #+findex: orgtbl-to-csv
19847 #+findex: orgtbl-to-tsv
19848 #+findex: orgtbl-to-latex
19849 #+findex: orgtbl-to-html
19850 #+findex: orgtbl-to-texinfo
19851 #+findex: orgtbl-to-unicode
19852 #+findex: orgtbl-to-orgtbl
19853 #+findex: orgtbl-to-generic
19854 Orgtbl mode has built-in translator functions: ~orgtbl-to-csv~
19855 (comma-separated values), ~orgtbl-to-tsv~ (TAB-separated values),
19856 ~orgtbl-to-latex~, ~orgtbl-to-html~, ~orgtbl-to-texinfo~,
19857 ~orgtbl-to-unicode~ and ~orgtbl-to-orgtbl~.  They use the generic
19858 translator, ~orgtbl-to-generic~, which delegates translations to
19859 various export back-ends.
19861 Properties passed to the function through the =ORGTBL SEND= line take
19862 precedence over properties defined inside the function.  For example,
19863 this overrides the default LaTeX line endings, ~\\~, with ~\\[2mm]~:
19865 : #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
19867 For a new language translator, define a converter function.  It can be
19868 a generic function, such as shown in this example.  It marks
19869 a beginning and ending of a table with =!BTBL!= and =!ETBL!=;
19870 a beginning and ending of lines with =!BL!= and =!EL!=; and uses a TAB
19871 for a field separator:
19873 #+begin_src emacs-lisp
19874 (defun orgtbl-to-language (table params)
19875   "Convert the orgtbl-mode TABLE to language."
19876   (orgtbl-to-generic
19877    table
19878    (org-combine-plists
19879     '(:tstart "!BTBL!" :tend "!ETBL!" :lstart "!BL!" :lend "!EL!" :sep "\t")
19880     params)))
19881 #+end_src
19883 #+texinfo: @noindent
19884 The documentation for the ~orgtbl-to-generic~ function shows
19885 a complete list of parameters, each of which can be passed through to
19886 ~orgtbl-to-latex~, ~orgtbl-to-texinfo~, and any other function using
19887 that generic function.
19889 For complicated translations the generic translator function could be
19890 replaced by a custom translator function.  Such a custom function must
19891 take two arguments and return a single string containing the formatted
19892 table.  The first argument is the table whose lines are a list of
19893 fields or the symbol ~hline~.  The second argument is the property
19894 list consisting of parameters specified in the =#+ORGTBL: SEND= line.
19895 Please share your translator functions by posting them to the Org
19896 users mailing list, at mailto:emacs-orgmode@gnu.org.
19898 ** Dynamic Blocks
19899 :PROPERTIES:
19900 :DESCRIPTION: Automatically filled blocks.
19901 :END:
19902 #+cindex: dynamic blocks
19904 Org supports /dynamic blocks/ in Org documents.  They are inserted
19905 with begin and end markers like any other code block, but the contents
19906 are updated automatically by a user function.
19908 #+kindex: C-c C-x x
19909 #+findex: org-dynamic-block-insert-dblock
19910 You can insert a dynamic block with ~org-dynamic-block-insert-dblock~,
19911 which is bound to {{{kbd(C-c C-x x)}}} by default.  For example,
19912 {{{kbd(C-c C-x x c l o c k t a b l e RET)}}} inserts a table that
19913 updates the work time (see [[*Clocking Work Time]]).
19915 Dynamic blocks can have names and function parameters.  The syntax is
19916 similar to source code block specifications:
19918 #+begin_example
19919 ,#+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
19920   ...
19921 ,#+END:
19922 #+end_example
19924 These commands update dynamic blocks:
19926 - {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
19928   #+kindex: C-c C-x C-u
19929   #+findex: org-dblock-update
19930   Update dynamic block at point.
19932 - {{{kbd(C-u C-c C-x C-u)}}} ::
19934   #+kindex: C-u C-c C-x C-u
19935   Update all dynamic blocks in the current file.
19937 Before updating a dynamic block, Org removes content between the
19938 =BEGIN= and =END= markers.  Org then reads the parameters on the
19939 =BEGIN= line for passing to the writer function.  If the function
19940 expects to access the removed content, then Org expects an extra
19941 parameter, =:content=, on the =BEGIN= line.
19943 The syntax for naming a writer function with a dynamic block labelled
19944 =myblock= is: ~org-dblock-write:myblock~.  Parameters come from the
19945 =BEGIN= line.
19947 The following is an example of a dynamic block and a block writer function
19948 that updates the time when the function was last run:
19950 #+begin_example
19951 ,#+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
19952   ...
19953 ,#+END:
19954 #+end_example
19956 #+texinfo: @noindent
19957 The dynamic block's writer function:
19959 #+begin_src emacs-lisp
19960 (defun org-dblock-write:block-update-time (params)
19961   (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
19962     (insert "Last block update at: "
19963             (format-time-string fmt))))
19964 #+end_src
19966 To keep dynamic blocks up-to-date in an Org file, use the function,
19967 ~org-update-all-dblocks~ in hook, such as ~before-save-hook~.  The
19968 ~org-update-all-dblocks~ function does not run if the file is not in
19969 Org mode.
19971 #+findex: org-narrow-to-block
19972 Dynamic blocks, like any other block, can be narrowed with
19973 ~org-narrow-to-block~.
19975 ** Special Agenda Views
19976 :PROPERTIES:
19977 :DESCRIPTION: Customized views.
19978 :END:
19979 #+cindex: agenda views, user-defined
19981 #+vindex: org-agenda-skip-function
19982 #+vindex: org-agenda-skip-function-global
19983 Org provides a special hook to further limit items in agenda views:
19984 ~agenda~, ~agenda*~[fn:160], ~todo~, ~alltodo~, ~tags~, ~tags-todo~,
19985 ~tags-tree~.  Specify a custom function that tests inclusion of every
19986 matched item in the view.  This function can also skip as much as is
19987 needed.
19989 For a global condition applicable to agenda views, use the
19990 ~org-agenda-skip-function-global~ variable.  Org uses a global
19991 condition with ~org-agenda-skip-function~ for custom searching.
19993 This example defines a function for a custom view showing TODO items
19994 with =waiting= status.  Manually this is a multi-step search process,
19995 but with a custom view, this can be automated as follows:
19997 The custom function searches the subtree for the =waiting= tag and
19998 returns ~nil~ on match.  Otherwise it gives the location from where
19999 the search continues.
20001 #+begin_src emacs-lisp
20002 (defun my-skip-unless-waiting ()
20003   "Skip trees that are not waiting"
20004   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
20005     (if (re-search-forward ":waiting:" subtree-end t)
20006         nil          ; tag found, do not skip
20007       subtree-end))) ; tag not found, continue after end of subtree
20008 #+end_src
20010 To use this custom function in a custom agenda command:
20012 #+begin_src emacs-lisp
20013 (org-add-agenda-custom-command
20014  '("b" todo "PROJECT"
20015    ((org-agenda-skip-function 'my-skip-unless-waiting)
20016     (org-agenda-overriding-header "Projects waiting for something: "))))
20017 #+end_src
20019 #+vindex: org-agenda-overriding-header
20020 Note that this also binds ~org-agenda-overriding-header~ to a more
20021 meaningful string suitable for the agenda view.
20023 #+vindex: org-odd-levels-only
20024 #+vindex: org-agenda-skip-function
20025 Search for entries with a limit set on levels for the custom search.
20026 This is a general approach to creating custom searches in Org.  To
20027 include all levels, use =LEVEL>0=[fn:161].  Then to selectively pick
20028 the matched entries, use ~org-agenda-skip-function~, which also
20029 accepts Lisp forms, such as ~org-agenda-skip-entry-if~ and
20030 ~org-agenda-skip-subtree-if~.  For example:
20032 - =(org-agenda-skip-entry-if 'scheduled)= ::
20034   Skip current entry if it has been scheduled.
20036 - =(org-agenda-skip-entry-if 'notscheduled)= ::
20038   Skip current entry if it has not been scheduled.
20040 - =(org-agenda-skip-entry-if 'deadline)= ::
20042   Skip current entry if it has a deadline.
20044 - =(org-agenda-skip-entry-if 'scheduled 'deadline)= ::
20046   Skip current entry if it has a deadline, or if it is scheduled.
20048 - =(org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))= ::
20050   Skip current entry if the TODO keyword is TODO or WAITING.
20052 - =(org-agenda-skip-entry-if 'todo 'done)= ::
20054   Skip current entry if the TODO keyword marks a DONE state.
20056 - =(org-agenda-skip-entry-if 'timestamp)= ::
20058   Skip current entry if it has any timestamp, may also be deadline or
20059   scheduled.
20061 - =(org-agenda-skip-entry-if 'regexp "regular expression")= ::
20063   Skip current entry if the regular expression matches in the entry.
20065 - =(org-agenda-skip-entry-if 'notregexp "regular expression")= ::
20067   Skip current entry unless the regular expression matches.
20069 - =(org-agenda-skip-subtree-if 'regexp "regular expression")= ::
20071   Same as above, but check and skip the entire subtree.
20073 The following is an example of a search for =waiting= without the
20074 special function:
20076 #+begin_src emacs-lisp
20077 (org-add-agenda-custom-command
20078  '("b" todo "PROJECT"
20079    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
20080                                 'regexp ":waiting:"))
20081     (org-agenda-overriding-header "Projects waiting for something: "))))
20082 #+end_src
20084 ** Speeding Up Your Agendas
20085 :PROPERTIES:
20086 :DESCRIPTION: Tips on how to speed up your agendas.
20087 :END:
20088 #+cindex: agenda views, optimization
20090 Some agenda commands slow down when the Org files grow in size or
20091 number.  Here are tips to speed up:
20093 - Reduce the number of Org agenda files to avoid slowdowns due to hard drive
20094   accesses.
20096 - Reduce the number of DONE and archived headlines so agenda
20097   operations that skip over these can finish faster.
20099 - Do not dim blocked tasks:
20100   #+vindex: org-agenda-dim-blocked-tasks
20102   #+begin_src emacs-lisp
20103   (setq org-agenda-dim-blocked-tasks nil)
20104   #+end_src
20106 - Stop preparing agenda buffers on startup:
20107   #+vindex: org-startup-folded
20108   #+vindex: org-agenda-inhibit-startup
20110   #+begin_src emacs-lisp
20111   (setq org-agenda-inhibit-startup t)
20112   #+end_src
20114 - Disable tag inheritance for agendas:
20115   #+vindex: org-agenda-show-inherited-tags
20116   #+vindex: org-agenda-use-tag-inheritance
20118   #+begin_src emacs-lisp
20119   (setq org-agenda-use-tag-inheritance nil)
20120   #+end_src
20122 These options can be applied to selected agenda views.  For more
20123 details about generation of agenda views, see the docstrings for the
20124 relevant variables, and this [[https://orgmode.org/worg/agenda-optimization.html][dedicated Worg page]] for agenda
20125 optimization.
20127 ** Extracting Agenda Information
20128 :PROPERTIES:
20129 :DESCRIPTION: Post-processing agenda information.
20130 :END:
20131 #+cindex: agenda, pipe
20132 #+cindex: scripts, for agenda processing
20134 Org provides commands to access agendas through Emacs batch mode.
20135 Through this command-line interface, agendas are automated for further
20136 processing or printing.
20138 #+vindex: org-agenda-custom-commands
20139 #+findex: org-batch-agenda
20140 ~org-batch-agenda~ creates an agenda view in ASCII and outputs to
20141 standard output.  This command takes one string parameter.  When
20142 string consists of a single character, Org uses it as a key to
20143 ~org-agenda-custom-commands~.  These are the same ones available
20144 through the agenda dispatcher (see [[*The Agenda Dispatcher]]).
20146 This example command line directly prints the TODO list to the printer:
20148 : emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
20150 When the string parameter length is two or more characters, Org
20151 matches it with tags/TODO strings.  For example, this example command
20152 line prints items tagged with =shop=, but excludes items tagged with
20153 =NewYork=:
20155 #+begin_example
20156 emacs -batch -l ~/.emacs                                      \
20157       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
20158 #+end_example
20160 #+texinfo: @noindent
20161 An example showing on-the-fly parameter modifications:
20163 #+begin_example
20164 emacs -batch -l ~/.emacs                                      \
20165    -eval '(org-batch-agenda "a"                               \
20166            org-agenda-span (quote month)                      \
20167            org-agenda-include-diary nil                       \
20168            org-agenda-files (quote ("~/org/project.org")))'   \
20169    | lpr
20170 #+end_example
20172 #+texinfo: @noindent
20173 which produces an agenda for the next 30 days from just the
20174 =~/org/projects.org= file.
20176 #+findex: org-batch-agenda-csv
20177 For structured processing of agenda output, use ~org-batch-agenda-csv~
20178 with the following fields:
20180 - category :: The category of the item
20181 - head :: The headline, without TODO keyword, TAGS and PRIORITY
20182 - type :: The type of the agenda entry, can be
20184   | ~todo~              | selected in TODO match              |
20185   | ~tagsmatch~         | selected in tags match              |
20186   | ~diary~             | imported from diary                 |
20187   | ~deadline~          | a deadline                          |
20188   | ~scheduled~         | scheduled                           |
20189   | ~timestamp~         | appointment, selected by timestamp  |
20190   | ~closed~            | entry was closed on date            |
20191   | ~upcoming-deadline~ | warning about nearing deadline      |
20192   | ~past-scheduled~    | forwarded scheduled item            |
20193   | ~block~             | entry has date block including date |
20195 - todo :: The TODO keyword, if any
20196 - tags :: All tags including inherited ones, separated by colons
20197 - date :: The relevant date, like =2007-2-14=
20198 - time :: The time, like =15:00-16:50=
20199 - extra :: String with extra planning info
20200 - priority-l :: The priority letter if any was given
20201 - priority-n :: The computed numerical priority
20203 If the selection of the agenda item was based on a timestamp,
20204 including those items with =DEADLINE= and =SCHEDULED= keywords, then
20205 Org includes date and time in the output.
20207 If the selection of the agenda item was based on a timestamp  (or
20208 deadline/scheduled), then Org includes date and time in the output.
20210 Here is an example of a post-processing script in Perl.  It takes the
20211 CSV output from Emacs and prints with a checkbox:
20213 #+begin_src perl
20214 #!/usr/bin/perl
20216 # define the Emacs command to run
20217 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
20219 # run it and capture the output
20220 $agenda = qx{$cmd 2>/dev/null};
20222 # loop over all lines
20223 foreach $line (split(/\n/,$agenda)) {
20224     # get the individual values
20225     ($category,$head,$type,$todo,$tags,$date,$time,$extra,
20226      $priority_l,$priority_n) = split(/,/,$line);
20227     # process and print
20228     print "[ ] $head\n";
20230 #+end_src
20232 ** Using the Property API
20233 :PROPERTIES:
20234 :DESCRIPTION: Writing programs that use entry properties.
20235 :END:
20236 #+cindex: API, for properties
20237 #+cindex: properties, API
20239 Here is a description of the functions that can be used to work with
20240 properties.
20242 #+attr_texinfo: :options org-entry-properties &optional pom which
20243 #+begin_defun
20244 Get all properties of the entry at point-or-marker {{{var(POM)}}}.
20245 This includes the TODO keyword, the tags, time strings for deadline,
20246 scheduled, and clocking, and any additional properties defined in the
20247 entry.  The return value is an alist.  Keys may occur multiple times
20248 if the property key was used several times.  {{{var(POM)}}} may also
20249 be ~nil~, in which case the current entry is used.  If
20250 {{{var(WHICH)}}} is ~nil~ or ~all~, get all properties.  If
20251 {{{var(WHICH)}}} is ~special~ or ~standard~, only get that subclass.
20252 #+end_defun
20254 #+vindex: org-use-property-inheritance
20255 #+findex: org-insert-property-drawer
20256 #+attr_texinfo: :options org-entry-get pom property &optional inherit
20257 #+begin_defun
20258 Get value of {{{var(PROPERTY)}}} for entry at point-or-marker
20259 {{{var(POM)}}}.  By default, this only looks at properties defined
20260 locally in the entry.  If {{{var(INHERIT)}}} is non-~nil~ and the
20261 entry does not have the property, then also check higher levels of the
20262 hierarchy.  If {{{var(INHERIT)}}} is the symbol ~selective~, use
20263 inheritance if and only if the setting of
20264 ~org-use-property-inheritance~ selects {{{var(PROPERTY)}}} for
20265 inheritance.
20266 #+end_defun
20268 #+attr_texinfo: :options org-entry-delete pom property
20269 #+begin_defun
20270 Delete the property {{{var(PROPERTY)}}} from entry at point-or-marker
20271 {{{var(POM)}}}.
20272 #+end_defun
20274 #+attr_texinfo: :options org-entry-put pom property value
20275 #+begin_defun
20276 Set {{{var(PROPERTY)}}} to {{{var(VALUES)}}} for entry at
20277 point-or-marker POM.
20278 #+end_defun
20280 #+attr_texinfo: :options org-buffer-property-keys &optional include-specials
20281 #+begin_defun
20282 Get all property keys in the current buffer.
20283 #+end_defun
20285 #+attr_texinfo: :options org-insert-property-drawer
20286 #+begin_defun
20287 Insert a property drawer for the current entry.  Also
20288 #+end_defun
20290 #+attr_texinfo: :options org-entry-put-multivalued-property pom property &rest values
20291 #+begin_defun
20292 Set {{{var(PROPERTY)}}} at point-or-marker {{{var(POM)}}} to
20293 {{{var(VALUES)}}}.  {{{var(VALUES)}}} should be a list of strings.
20294 They are concatenated, with spaces as separators.
20295 #+end_defun
20297 #+attr_texinfo: :options org-entry-get-multivalued-property pom property
20298 #+begin_defun
20299 Treat the value of the property {{{var(PROPERTY)}}} as
20300 a whitespace-separated list of values and return the values as a list
20301 of strings.
20302 #+end_defun
20304 #+attr_texinfo: :options org-entry-add-to-multivalued-property pom property value
20305 #+begin_defun
20306 Treat the value of the property {{{var(PROPERTY)}}} as
20307 a whitespace-separated list of values and make sure that
20308 {{{var(VALUE)}}} is in this list.
20309 #+end_defun
20311 #+attr_texinfo: :options org-entry-remove-from-multivalued-property pom property value
20312 #+begin_defun
20313 Treat the value of the property {{{var(PROPERTY)}}} as
20314 a whitespace-separated list of values and make sure that
20315 {{{var(VALUE)}}} is /not/ in this list.
20316 #+end_defun
20318 #+attr_texinfo: :options org-entry-member-in-multivalued-property pom property value
20319 #+begin_defun
20320 Treat the value of the property {{{var(PROPERTY)}}} as
20321 a whitespace-separated list of values and check if {{{var(VALUE)}}} is
20322 in this list.
20323 #+end_defun
20325 #+attr_texinfo: :options org-property-allowed-value-functions
20326 #+begin_defopt
20327 Hook for functions supplying allowed values for a specific property.
20328 The functions must take a single argument, the name of the property,
20329 and return a flat list of allowed values.  If =:ETC= is one of the
20330 values, use the values as completion help, but allow also other values
20331 to be entered.  The functions must return ~nil~ if they are not
20332 responsible for this property.
20333 #+end_defopt
20335 ** Using the Mapping API
20336 :PROPERTIES:
20337 :DESCRIPTION: Mapping over all or selected entries.
20338 :END:
20339 #+cindex: API, for mapping
20340 #+cindex: mapping entries, API
20342 Org has sophisticated mapping capabilities to find all entries
20343 satisfying certain criteria.  Internally, this functionality is used
20344 to produce agenda views, but there is also an API that can be used to
20345 execute arbitrary functions for each or selected entries.  The main
20346 entry point for this API is:
20348 #+attr_texinfo: :options org-map-entries func &optional match scope &rest skip
20349 #+begin_defun
20350 Call {{{var(FUNC)}}} at each headline selected by {{{var(MATCH)}}} in
20351 {{{var(SCOPE)}}}.
20353 {{{var(FUNC)}}} is a function or a Lisp form.  With point positioned
20354 at the beginning of the headline, call the function without arguments.
20355 Org returns an alist of return values of calls to the function.
20357 To avoid preserving point, Org wraps the call to {{{var(FUNC)}}} in
20358 ~save-excursion~ form.  After evaluation, Org moves point to the end
20359 of the line that was just processed.  Search continues from that point
20360 forward.  This may not always work as expected under some conditions,
20361 such as if the current sub-tree was removed by a previous archiving
20362 operation.  In such rare circumstances, Org skips the next entry
20363 entirely when it should not.  To stop Org from such skips, make
20364 {{{var(FUNC)}}} set the variable ~org-map-continue-from~ to a specific
20365 buffer position.
20367 {{{var(MATCH)}}} is a tags/property/TODO match.  Org iterates only
20368 matched headlines.  Org iterates over all headlines when
20369 {{{var(MATCH)}}} is ~nil~ or ~t~.
20371 {{{var(SCOPE)}}} determines the scope of this command.  It can be any
20374 - ~nil~ ::
20376   The current buffer, respecting the restriction, if any.
20378 - ~tree~ ::
20380   The subtree started with the entry at point.
20382 - ~region~ ::
20384   The entries within the active region, if any.
20386 - ~file~ ::
20388   The current buffer, without restriction.
20390 - ~file-with-archives~ ::
20392   The current buffer, and any archives associated with it.
20394 - ~agenda~ ::
20396   All agenda files.
20398 - ~agenda-with-archives~ ::
20400   All agenda files with any archive files associated with them.
20402 - list of filenames ::
20404   If this is a list, all files in the list are scanned.
20406 #+texinfo: @noindent
20407 The remaining arguments are treated as settings for the scanner's
20408 skipping facilities.  Valid arguments are:
20410 - ~archive~ ::
20412   Skip trees with the =ARCHIVE= tag.
20414 - ~comment~ ::
20416   Skip trees with the COMMENT keyword.
20418 - function or Lisp form ::
20420   #+vindex: org-agenda-skip-function
20421   Used as value for ~org-agenda-skip-function~, so whenever the
20422   function returns ~t~, {{{var(FUNC)}}} is called for that entry and
20423   search continues from the point where the function leaves it.
20424 #+end_defun
20426 The mapping routine can call any arbitrary function, even functions
20427 that change meta data or query the property API (see [[*Using the
20428 Property API]]).  Here are some handy functions:
20430 #+attr_texinfo: :options org-todo &optional arg
20431 #+begin_defun
20432 Change the TODO state of the entry.  See the docstring of the
20433 functions for the many possible values for the argument
20434 {{{var(ARG)}}}.
20435 #+end_defun
20437 #+attr_texinfo: :options org-priority &optional action
20438 #+begin_defun
20439 Change the priority of the entry.  See the docstring of this function
20440 for the possible values for {{{var(ACTION)}}}.
20441 #+end_defun
20443 #+attr_texinfo: :options org-toggle-tag tag &optional onoff
20444 #+begin_defun
20445 Toggle the tag {{{var(TAG)}}} in the current entry.  Setting
20446 {{{var(ONOFF)}}} to either ~on~ or ~off~ does not toggle tag, but
20447 ensure that it is either on or off.
20448 #+end_defun
20450 #+attr_texinfo: :options org-promote
20451 #+begin_defun
20452 Promote the current entry.
20453 #+end_defun
20455 #+attr_texinfo: :options org-demote
20456 #+begin_defun
20457 Demote the current entry.
20458 #+end_defun
20460 This example turns all entries tagged with =TOMORROW= into TODO
20461 entries with keyword =UPCOMING=.  Org ignores entries in comment trees
20462 and archive trees.
20464 #+begin_src emacs-lisp
20465 (org-map-entries '(org-todo "UPCOMING")
20466                  "+TOMORROW" 'file 'archive 'comment)
20467 #+end_src
20469 The following example counts the number of entries with TODO keyword
20470 =WAITING=, in all agenda files.
20472 #+begin_src emacs-lisp
20473 (length (org-map-entries t "/+WAITING" 'agenda))
20474 #+end_src
20476 * History and Acknowledgments
20477 :PROPERTIES:
20478 :DESCRIPTION: How Org came into being.
20479 :APPENDIX: t
20480 :END:
20482 ** From Carsten
20483 :PROPERTIES:
20484 :UNNUMBERED: notoc
20485 :END:
20487 Org was born in 2003, out of frustration over the user interface of
20488 the Emacs Outline mode.  I was trying to organize my notes and
20489 projects, and using Emacs seemed to be the natural way to go.
20490 However, having to remember eleven different commands with two or
20491 three keys per command, only to hide and show parts of the outline
20492 tree, that seemed entirely unacceptable to me.  Also, when using
20493 outlines to take notes, I constantly wanted to restructure the tree,
20494 organizing it parallel to my thoughts and plans.  /Visibility cycling/
20495 and /structure editing/ were originally implemented in the package
20496 =outline-magic.el=, but quickly moved to the more general =org.el=.
20497 As this environment became comfortable for project planning, the next
20498 step was adding /TODO entries/, basic /timestamps/, and /table
20499 support/.  These areas highlighted the two main goals that Org still
20500 has today: to be a new, outline-based, plain text mode with innovative
20501 and intuitive editing features, and to incorporate project planning
20502 functionality directly into a notes file.
20504 Since the first release, literally thousands of emails to me or to the
20505 [[mailto:emacs-orgmode@gnu.org][mailing list]] have provided a constant stream of bug reports, feedback,
20506 new ideas, and sometimes patches and add-on code.  Many thanks to
20507 everyone who has helped to improve this package.  I am trying to keep
20508 here a list of the people who had significant influence in shaping one
20509 or more aspects of Org.  The list may not be complete, if I have
20510 forgotten someone, please accept my apologies and let me know.
20512 Before I get to this list, a few special mentions are in order:
20514 - Bastien Guerry ::
20516   Bastien has written a large number of extensions to Org (most of
20517   them integrated into the core by now), including the LaTeX exporter
20518   and the plain list parser.  His support during the early days was
20519   central to the success of this project.  Bastien also invented Worg,
20520   helped establishing the Web presence of Org, and sponsored hosting
20521   costs for the orgmode.org website.  Bastien stepped in as maintainer
20522   of Org between 2011 and 2013, at a time when I desperately needed
20523   a break.
20525 - Eric Schulte and Dan Davison ::
20527   Eric and Dan are jointly responsible for the Org Babel system, which
20528   turns Org into a multi-language environment for evaluating code and
20529   doing literate programming and reproducible research.  This has
20530   become one of Org's killer features that define what Org is today.
20532 - John Wiegley ::
20534   John has contributed a number of great ideas and patches directly to
20535   Org, including the attachment system (=org-attach.el=), integration
20536   with Apple Mail (=org-mac-message.el=), hierarchical dependencies of
20537   TODO items, habit tracking (=org-habits.el=), and encryption
20538   (=org-crypt.el=).  Also, the capture system is really an extended
20539   copy of his great =remember.el=.
20541 - Sebastian Rose ::
20543   Without Sebastian, the HTML/XHTML publishing of Org would be the
20544   pitiful work of an ignorant amateur.  Sebastian has pushed this part
20545   of Org onto a much higher level.  He also wrote =org-info.js=,
20546   a Java script for displaying webpages derived from Org using an
20547   Info-like or a folding interface with single-key navigation.
20549 See below for the full list of contributions! Again, please let me
20550 know what I am missing here!
20552 ** From Bastien
20553 :PROPERTIES:
20554 :UNNUMBERED: notoc
20555 :END:
20557 I (Bastien) have been maintaining Org between 2011 and 2013.  This
20558 appendix would not be complete without adding a few more
20559 acknowledgments and thanks.
20561 I am first grateful to Carsten for his trust while handing me over the
20562 maintainership of Org.  His unremitting support is what really helped
20563 me getting more confident over time, with both the community and the
20564 code.
20566 When I took over maintainership, I knew I would have to make Org more
20567 collaborative than ever, as I would have to rely on people that are
20568 more knowledgeable than I am on many parts of the code.  Here is
20569 a list of the persons I could rely on, they should really be
20570 considered co-maintainers, either of the code or the community:
20572 - Eric Schulte ::
20574   Eric is maintaining the Babel parts of Org.  His reactivity here
20575   kept me away from worrying about possible bugs here and let me focus
20576   on other parts.
20578 - Nicolas Goaziou ::
20580   Nicolas is maintaining the consistency of the deepest parts of Org.
20581   His work on =org-element.el= and =ox.el= has been outstanding, and
20582   it opened the doors for many new ideas and features.  He rewrote
20583   many of the old exporters to use the new export engine, and helped
20584   with documenting this major change.  More importantly (if that's
20585   possible), he has been more than reliable during all the work done
20586   for Org 8.0, and always very reactive on the mailing list.
20588 - Achim Gratz ::
20590   Achim rewrote the building process of Org, turning some /ad hoc/
20591   tools into a flexible and conceptually clean process.  He patiently
20592   coped with the many hiccups that such a change can create for users.
20594 - Nick Dokos ::
20596   The Org mode mailing list would not be such a nice place without
20597   Nick, who patiently helped users so many times.  It is impossible to
20598   overestimate such a great help, and the list would not be so active
20599   without him.
20601 I received support from so many users that it is clearly impossible to
20602 be fair when shortlisting a few of them, but Org's history would not
20603 be complete if the ones above were not mentioned in this manual.
20605 ** List of Contributions
20606 :PROPERTIES:
20607 :UNNUMBERED: notoc
20608 :END:
20610 - Russel Adams came up with the idea for drawers.
20612 - Thomas Baumann wrote =ol-bbdb.el= and =ol-mhe.el=.
20614 - Christophe Bataillon created the great unicorn logo that we use on
20615   the Org mode website.
20617 - Alex Bochannek provided a patch for rounding timestamps.
20619 - Jan Böcker wrote =ol-docview.el=.
20621 - Brad Bozarth showed how to pull RSS feed data into Org files.
20623 - Tom Breton wrote =org-choose.el=.
20625 - Charles Cave's suggestion sparked the implementation of templates
20626   for Remember, which are now templates for capture.
20628 - Pavel Chalmoviansky influenced the agenda treatment of items with
20629   specified time.
20631 - Gregory Chernov patched support for Lisp forms into table
20632   calculations and improved XEmacs compatibility, in particular by
20633   porting =nouline.el= to XEmacs.
20635 - Sacha Chua suggested copying some linking code from Planner.
20637 - Baoqiu Cui contributed the DocBook exporter.
20639 - Eddward DeVilla proposed and tested checkbox statistics.  He also
20640   came up with the idea of properties, and that there should be an API
20641   for them.
20643 - Nick Dokos tracked down several nasty bugs.
20645 - Kees Dullemond used to edit projects lists directly in HTML and so
20646   inspired some of the early development, including HTML export.  He
20647   also asked for a way to narrow wide table columns.
20649 - Thomas\nbsp{}S.\nbsp{}Dye contributed documentation on Worg and helped
20650   integrating the Org Babel documentation into the manual.
20652 - Christian Egli converted the documentation into Texinfo format,
20653   inspired the agenda, patched CSS formatting into the HTML exporter,
20654   and wrote =org-taskjuggler.el=.
20656 - David Emery provided a patch for custom CSS support in exported HTML
20657   agendas.
20659 - Nic Ferrier contributed mailcap and XOXO support.
20661 - Miguel\nbsp{}A.\nbsp{}Figueroa-Villanueva implemented hierarchical checkboxes.
20663 - John Foerch figured out how to make incremental search show context
20664   around a match in a hidden outline tree.
20666 - Raimar Finken wrote =org-git-line.el=.
20668 - Mikael Fornius works as a mailing list moderator.
20670 - Austin Frank works as a mailing list moderator.
20672 - Eric Fraga drove the development of Beamer export with ideas and
20673   testing.
20675 - Barry Gidden did proofreading the manual in preparation for the book
20676   publication through Network Theory Ltd.
20678 - Niels Giesen had the idea to automatically archive DONE trees.
20680 - Nicolas Goaziou rewrote much of the plain list code.
20682 - Kai Grossjohann pointed out key-binding conflicts with other
20683   packages.
20685 - Brian Gough of Network Theory Ltd publishes the Org mode manual as
20686   a book.
20688 - Bernt Hansen has driven much of the support for auto-repeating
20689   tasks, task state change logging, and the clocktable.  His clear
20690   explanations have been critical when we started to adopt the Git
20691   version control system.
20693 - Manuel Hermenegildo has contributed various ideas, small fixes and
20694   patches.
20696 - Phil Jackson wrote =ol-irc.el=.
20698 - Scott Jaderholm proposed footnotes, control over whitespace between
20699   folded entries, and column view for properties.
20701 - Matt Jones wrote MobileOrg Android.
20703 - Tokuya Kameshima wrote =org-wl.el= and =org-mew.el=.
20705 - Shidai Liu ("Leo") asked for embedded LaTeX and tested it.  He also
20706   provided frequent feedback and some patches.
20708 - Matt Lundin has proposed last-row references for table formulas and
20709   named invisible anchors.  He has also worked a lot on the FAQ.
20711 - David Maus wrote =org-atom.el=, maintains the issues file for Org,
20712   and is a prolific contributor on the mailing list with competent
20713   replies, small fixes and patches.
20715 - Jason\nbsp{}F.\nbsp{}McBrayer suggested agenda export to CSV format.
20717 - Max Mikhanosha came up with the idea of refiling.
20719 - Dmitri Minaev sent a patch to set priority limits on a per-file
20720   basis.
20722 - Stefan Monnier provided a patch to keep the Emacs Lisp compiler
20723   happy.
20725 - Richard Moreland wrote MobileOrg for the iPhone.
20727 - Rick Moynihan proposed allowing multiple TODO sequences in a file
20728   and being able to quickly restrict the agenda to a subtree.
20730 - Todd Neal provided patches for links to Info files and Elisp forms.
20732 - Greg Newman refreshed the unicorn logo into its current form.
20734 - Tim O'Callaghan suggested in-file links, search options for general
20735   file links, and tags.
20737 - Osamu Okano wrote =orgcard2ref.pl=, a Perl program to create a text
20738   version of the reference card.
20740 - Takeshi Okano translated the manual and David O'Toole's tutorial
20741   into Japanese.
20743 - Oliver Oppitz suggested multi-state TODO items.
20745 - Scott Otterson sparked the introduction of descriptive text for
20746   links, among other things.
20748 - Pete Phillips helped during the development of the TAGS feature,
20749   and provided frequent feedback.
20751 - Martin Pohlack provided the code snippet to bundle character
20752   insertion into bundles of 20 for undo.
20754 - T.\nbsp{}V.\nbsp{}Raman reported bugs and suggested improvements.
20756 - Matthias Rempe (Oelde) provided ideas, Windows support, and quality
20757   control.
20759 - Paul Rivier provided the basic implementation of named footnotes.
20760   He also acted as mailing list moderator for some time.
20762 - Kevin Rogers contributed code to access VM files on remote hosts.
20764 - Frank Ruell solved the mystery of the =keymapp nil= bug, a conflict
20765   with =allout.el=.
20767 - Jason Riedy generalized the send-receive mechanism for Orgtbl
20768   tables with extensive patches.
20770 - Philip Rooke created the Org reference card, provided lots of
20771   feedback, developed and applied standards to the Org documentation.
20773 - Christian Schlauer proposed angular brackets around links, among
20774   other things.
20776 - Paul Sexton wrote =org-ctags.el=.
20778 - Tom Shannon's =organizer-mode.el= inspired linking to VM/BBDB/Gnus.
20780 - Ilya Shlyakhter proposed the Archive Sibling, line numbering in
20781   literal examples, and remote highlighting for referenced code lines.
20783 - Stathis Sideris wrote the =ditaa.jar= ASCII to PNG converter that is
20784   now packaged into Org's =contrib/= directory.
20786 - Daniel Sinder came up with the idea of internal archiving by locking
20787   subtrees.
20789 - Dale Smith proposed link abbreviations.
20791 - James TD Smith has contributed a large number of patches for
20792   useful tweaks and features.
20794 - Adam Spiers asked for global linking commands, inspired the link
20795   extension system, added support for Mairix, and proposed the mapping
20796   API.
20798 - Ulf Stegemann created the table to translate special symbols to
20799   HTML, LaTeX, UTF-8, Latin-1 and ASCII.
20801 - Andy Stewart contributed code to =ol-w3m.el=, to copy
20802   HTML content with links transformation to Org syntax.
20804 - David O'Toole wrote =org-publish.el= and drafted the
20805   manual chapter about publishing.
20807 - Jambunathan\nbsp{}K.\nbsp{}contributed the ODT exporter.
20809 - Sebastien Vauban reported many issues with LaTeX and Beamer export
20810   and enabled source code highlighting in Gnus.
20812 - Stefan Vollmar organized a video-recorded talk at the
20813   Max-Planck-Institute for Neurology.  He also inspired the creation
20814   of a concept index for HTML export.
20816 - Jürgen Vollmer contributed code generating the table of contents in
20817   HTML output.
20819 - Samuel Wales has provided important feedback and bug reports.
20821 - Chris Wallace provided a patch implementing the =QUOTE= block.
20823 - David Wainberg suggested archiving, and improvements to the
20824   linking system.
20826 - Carsten Wimmer suggested some changes and helped fix a bug in
20827   linking to Gnus.
20829 - Roland Winkler requested additional key bindings to make Org work on
20830   a TTY.
20832 - Piotr Zielinski wrote =org-mouse.el=, proposed agenda
20833   blocks and contributed various ideas and code snippets.
20835 - Marco Wahl wrote =ol-eww.el=.
20837 * GNU Free Documentation License
20838 :PROPERTIES:
20839 :APPENDIX: t
20840 :DESCRIPTION: The license for this documentation.
20841 :END:
20843 #+include: fdl.org
20845 * Main Index
20846 :PROPERTIES:
20847 :INDEX:    cp
20848 :DESCRIPTION: An index of Org's concepts and features.
20849 :END:
20851 * Key Index
20852 :PROPERTIES:
20853 :DESCRIPTION: Key bindings and where they are described.
20854 :INDEX:    ky
20855 :END:
20857 * Command and Function Index
20858 :PROPERTIES:
20859 :DESCRIPTION: Command names and some internal functions.
20860 :INDEX:    fn
20861 :END:
20863 * Variable Index
20864 :PROPERTIES:
20865 :DESCRIPTION: Variables mentioned in the manual.
20866 :INDEX:    vr
20867 :END:
20869 This is not a complete index of variables and faces, only the ones
20870 that are mentioned in the manual.  For a more complete list, use
20871 {{{kbd(M-x org-customize)}}} and then click yourself through the tree.
20873 * Copying
20874 :PROPERTIES:
20875 :copying:  t
20876 :END:
20878 This manual is for Org version {{{version}}}.
20880 Copyright \copy 2004--2019  Free Software Foundation, Inc.
20882 #+begin_quote
20883 Permission is granted to copy, distribute and/or modify this document
20884 under the terms of the GNU Free Documentation License, Version 1.3 or
20885 any later version published by the Free Software Foundation; with no
20886 Invariant Sections, with the Front-Cover Texts being "A GNU Manual,"
20887 and with the Back-Cover Texts as in (a) below.  A copy of the license
20888 is included in the section entitled "GNU Free Documentation License."
20890 (a) The FSF's Back-Cover Text is: "You have the freedom to copy and
20891 modify this GNU manual."
20892 #+end_quote
20894 * Export Setup                                                          :noexport:
20896 #+setupfile: doc-setup.org
20898 #+export_file_name: org.texi
20900 #+texinfo_dir_category: Emacs
20901 #+texinfo_dir_title: Org Mode: (org)
20902 #+texinfo_dir_desc: Outline-based notes management and organizer
20904 * Footnotes
20906 [fn:1] If you do not use Font Lock globally turn it on in Org buffer
20907 with =(add-hook 'org-mode-hook 'turn-on-font-lock)=.
20909 [fn:2] Please consider subscribing to the mailing list in order to
20910 minimize the work the mailing list moderators have to do.
20912 [fn:3] See the variables ~org-special-ctrl-a/e~, ~org-special-ctrl-k~,
20913 and ~org-ctrl-k-protect-subtree~ to configure special behavior of
20914 {{{kbd(C-a)}}}, {{{kbd(C-e)}}}, and {{{kbd(C-k)}}} in headlines.  Note
20915 also that clocking only works with headings indented less than 30
20916 stars.
20918 [fn:4] See, however, the option ~org-cycle-emulate-tab~.
20920 [fn:5] The indirect buffer contains the entire buffer, but is narrowed
20921 to the current tree.  Editing the indirect buffer also changes the
20922 original buffer, but without affecting visibility in that buffer.  For
20923 more information about indirect buffers, see [[info:emacs#Indirect Buffers][GNU Emacs Manual]].
20925 [fn:6] When ~org-agenda-inhibit-startup~ is non-~nil~, Org does not
20926 honor the default visibility state when first opening a file for the
20927 agenda (see [[*Speeding Up Your Agendas]]).
20929 [fn:7] See also the variable ~org-show-context-detail~ to decide how
20930 much context is shown around each match.
20932 [fn:8] This depends on the option ~org-remove-highlights-with-change~.
20934 [fn:9] When using =*= as a bullet, lines must be indented so that they
20935 are not interpreted as headlines.  Also, when you are hiding leading
20936 stars to get a clean outline view, plain list items starting with
20937 a star may be hard to distinguish from true headlines.  In short: even
20938 though =*= is supported, it may be better to not use it for plain list
20939 items.
20941 [fn:10] You can filter out any of them by configuring
20942 ~org-plain-list-ordered-item-terminator~.
20944 [fn:11] You can also get =a.=, =A.=, =a)= and =A)= by configuring
20945 ~org-list-allow-alphabetical~.  To minimize confusion with normal
20946 text, those are limited to one character only.  Beyond that limit,
20947 bullets automatically become numbers.
20949 [fn:12] If there's a checkbox in the item, the cookie must be put
20950 /before/ the checkbox.  If you have activated alphabetical lists, you
20951 can also use counters like =[@b]=.
20953 [fn:13] If you do not want the item to be split, customize the
20954 variable ~org-M-RET-may-split-line~.
20956 [fn:14] If you want to cycle around items that way, you may customize
20957 ~org-list-use-circular-motion~.
20959 [fn:15] See ~org-list-use-circular-motion~ for a cyclic behavior.
20961 [fn:16] Many desktops intercept {{{kbd(M-TAB)}}} to switch windows.
20962 Use {{{kbd(C-M-i)}}} or {{{kbd(ESC TAB)}}} instead.
20964 [fn:17] To insert a vertical bar into a table field, use =\vert= or,
20965 inside a word =abc\vert{}def=.
20967 [fn:18] Org understands references typed by the user as =B4=, but it
20968 does not use this syntax when offering a formula for editing.  You can
20969 customize this behavior using the variable
20970 ~org-table-use-standard-references~.
20972 [fn:19] The computation time scales as O(N^2) because table
20973 {{{var(FOO)}}} is parsed for each field to be copied.
20975 [fn:20] The file =constants.el= can supply the values of constants in
20976 two different unit systems, =SI= and =cgs=.  Which one is used depends
20977 on the value of the variable ~constants-unit-system~.  You can use the
20978 =STARTUP= options =constSI= and =constcgs= to set this value for the
20979 current buffer.
20981 [fn:21] The printf reformatting is limited in precision because the
20982 value passed to it is converted into an "integer" or "double".  The
20983 "integer" is limited in size by truncating the signed value to 32
20984 bits.  The "double" is limited in precision to 64 bits overall which
20985 leaves approximately 16 significant decimal digits.
20987 [fn:22] Such names must start with an alphabetic character and use
20988 only alphanumeric/underscore characters.
20990 [fn:23] Plain URIs are recognized only for a well-defined set of
20991 schemes.  See [[*External Links]].  Unlike URI syntax, they cannot contain
20992 parenthesis or white spaces, either.  URIs within angle brackets have
20993 no such limitation.
20995 [fn:24] More accurately, the precise behavior depends on how point
20996 arrived there---see [[info:elisp#Invisible Text][Invisible Text]].
20998 [fn:25] To insert a link targeting a headline, in-buffer completion
20999 can be used.  Just type a star followed by a few optional letters into
21000 the buffer and press {{{kbd(M-TAB)}}}.  All headlines in the current
21001 buffer are offered as completions.
21003 [fn:26] When targeting a =NAME= keyword, the =CAPTION= keyword is
21004 mandatory in order to get proper numbering (see [[*Captions]]).
21006 [fn:27] The actual behavior of the search depends on the value of the
21007 variable ~org-link-search-must-match-exact-headline~.  If its value is
21008 ~nil~, then a fuzzy text search is done.  If it is ~t~, then only the
21009 exact headline is matched, ignoring spaces and statistic cookies.  If
21010 the value is ~query-to-create~, then an exact headline is searched; if
21011 it is not found, then the user is queried to create it.
21013 [fn:28] If the headline contains a timestamp, it is removed from the
21014 link, which results in a wrong link---you should avoid putting
21015 a timestamp in the headline.
21017 [fn:29] The Org Id library must first be loaded, either through
21018 ~org-customize~, by enabling ~id~ in ~org-modules~, or by adding
21019 =(require 'org-id)= in your Emacs init file.
21021 [fn:30] Note that you do not have to use this command to insert
21022 a link.  Links in Org are plain text, and you can type or paste them
21023 straight into the buffer.  By using this command, the links are
21024 automatically enclosed in double brackets, and you will be asked for
21025 the optional descriptive text.
21027 [fn:31] After insertion of a stored link, the link will be removed
21028 from the list of stored links.  To keep it in the list for later use,
21029 use a triple {{{kbd(C-u)}}} prefix argument to {{{kbd(C-c C-l)}}}, or
21030 configure the option ~org-link-keep-stored-after-insertion~.
21032 [fn:32] This works if a function has been defined in the ~:complete~
21033 property of a link in ~org-link-parameters~.
21035 [fn:33] See the variable ~org-link-use-indirect-buffer-for-internals~.
21037 [fn:34] For backward compatibility, line numbers can also follow a
21038 single colon.
21040 [fn:35] Of course, you can make a document that contains only long
21041 lists of TODO items, but this is not required.
21043 [fn:36] Changing the variable ~org-todo-keywords~ only becomes
21044 effective after restarting Org mode in a buffer.
21046 [fn:37] This is also true for the {{{kbd(t)}}} command in the agenda
21047 buffer.
21049 [fn:38] All characters are allowed except =@=, =^= and =!=, which have
21050 a special meaning here.
21052 [fn:39] Check also the variable ~org-fast-tag-selection-include-todo~,
21053 it allows you to change the TODO state through the tags interface (see
21054 [[*Setting Tags]]), in case you like to mingle the two concepts.  Note
21055 that this means you need to come up with unique keys across both sets
21056 of keywords.
21058 [fn:40] Org mode parses these lines only when Org mode is activated
21059 after visiting a file.  {{{kbd(C-c C-c)}}} with point in a line
21060 starting with =#+= is simply restarting Org mode for the current
21061 buffer.
21063 [fn:41] The corresponding in-buffer setting is: =#+STARTUP: logdone=.
21065 [fn:42] The corresponding in-buffer setting is: =#+STARTUP:
21066 lognotedone=.
21068 [fn:43] See the variable ~org-log-states-order-reversed~.
21070 [fn:44] Note that the =LOGBOOK= drawer is unfolded when pressing
21071 {{{kbd(SPC)}}} in the agenda to show an entry---use {{{kbd(C-u
21072 SPC)}}} to keep it folded here.
21074 [fn:45] It is possible that Org mode records two timestamps when you
21075 are using both ~org-log-done~ and state change logging.  However, it
21076 never prompts for two notes: if you have configured both, the state
21077 change recording note takes precedence and cancel the closing note.
21079 [fn:46] See also the option ~org-priority-start-cycle-with-default~.
21081 [fn:47] To keep subtasks out of the global TODO list, see the option
21082 ~org-agenda-todo-list-sublevels~.
21084 [fn:48] With the exception of description lists.  But you can allow it
21085 by modifying ~org-list-automatic-rules~ accordingly.
21087 [fn:49] Set the variable ~org-hierarchical-checkbox-statistics~ if you
21088 want such cookies to count all checkboxes below the cookie, not just
21089 those belonging to direct children.
21091 [fn:50] {{{kbd(C-u C-c C-c)}}} on the /first/ item of a list with no
21092 checkbox adds checkboxes to the rest of the list.
21094 [fn:51] As with all these in-buffer settings, pressing {{{kbd(C-c
21095 C-c)}}} activates any changes in the line.
21097 [fn:52] This is only true if the search does not involve more complex
21098 tests including properties (see [[*Property Searches]]).
21100 [fn:53] To extend this default list to all tags used in all agenda
21101 files (see [[*Agenda Views]]), customize the variable
21102 ~org-complete-tags-always-offer-all-agenda-tags~.
21104 [fn:54] Keys are automatically assigned to tags that have no
21105 configured keys.
21107 [fn:55] If more than one summary type applies to the same property,
21108 the parent values are computed according to the first of them.
21110 [fn:56] An age can be defined as a duration, using units defined in
21111 ~org-duration-units~, e.g., =3d 1h=.  If any value in the column is as
21112 such, the summary is also expressed as a duration.
21114 [fn:57] Please note that the =COLUMNS= definition must be on a single
21115 line; it is wrapped here only because of formatting constraints.
21117 [fn:58] Contributed packages are not part of Emacs, but are
21118 distributed with the main distribution of Org---visit
21119 [[https://orgmode.org]].
21121 [fn:59] The Org date format is inspired by the standard ISO 8601
21122 date/time format.  To use an alternative format, see [[*Custom time
21123 format]].  The day name is optional when you type the date yourself.
21124 However, any date inserted or modified by Org adds that day name, for
21125 reading convenience.
21127 [fn:60] When working with the standard diary expression functions, you
21128 need to be very careful with the order of the arguments.  That order
21129 depends evilly on the variable ~calendar-date-style~.  For example, to
21130 specify a date December 12, 2005, the call might look like
21131 =(diary-date 12 1 2005)= or =(diary-date 1 12 2005)= or =(diary-date
21132 2005 12 1)=, depending on the settings.  This has been the source of
21133 much confusion.  Org mode users can resort to special versions of
21134 these functions like ~org-date~ or ~org-anniversary~.  These work just
21135 like the corresponding ~diary-~ functions, but with stable ISO order
21136 of arguments (year, month, day) wherever applicable, independent of
21137 the value of ~calendar-date-style~.
21139 [fn:61] See the variable ~org-read-date-prefer-future~.  You may set
21140 that variable to the symbol ~time~ to even make a time before now
21141 shift the date to tomorrow.
21143 [fn:62] If you do not need/want the calendar, configure the variable
21144 ~org-popup-calendar-for-date-prompt~.
21146 [fn:63] If you find this distracting, turn off the display with
21147 ~org-read-date-display-live~.
21149 [fn:64] It will still be listed on that date after it has been marked
21150 as done.  If you do not like this, set the variable
21151 ~org-agenda-skip-scheduled-if-done~.
21153 [fn:65] The =SCHEDULED= and =DEADLINE= dates are inserted on the line
21154 right below the headline.  Do not put any text between this line and
21155 the headline.
21157 [fn:66] Note the corresponding =STARTUP= options =logredeadline=,
21158 =lognoteredeadline=, and =nologredeadline=.
21160 [fn:67] Note the corresponding =STARTUP= options =logreschedule=,
21161 =lognotereschedule=, and =nologreschedule=.
21163 [fn:68] Org does not repeat inactive timestamps, however.  See
21164 [[*Timestamps]].
21166 [fn:69] In fact, the target state is taken from, in this sequence, the
21167 =REPEAT_TO_STATE= property, the variable ~org-todo-repeat-to-state~ if
21168 it is a string, the previous TODO state if ~org-todo-repeat-to-state~
21169 is ~t~, or the first state of the TODO state sequence.
21171 [fn:70] You can change this using the option ~org-log-repeat~, or the
21172 =STARTUP= options =logrepeat=, =lognoterepeat=, and =nologrepeat=.
21173 With =lognoterepeat=, you will also be prompted for a note.
21175 [fn:71] Clocking only works if all headings are indented with less
21176 than 30 stars.  This is a hard-coded limitation of ~lmax~ in
21177 ~org-clock-sum~.
21179 [fn:72] To resume the clock under the assumption that you have worked
21180 on this task while outside Emacs, use =(setq org-clock-persist t)=.
21182 [fn:73] To add an effort estimate "on the fly", hook a function doing
21183 this to ~org-clock-in-prepare-hook~.
21185 [fn:74] The last reset of the task is recorded by the =LAST_REPEAT=
21186 property.
21188 [fn:75] See also the variable ~org-clock-mode-line-total~.
21190 [fn:76] The corresponding in-buffer setting is: =#+STARTUP:
21191 lognoteclock-out=.
21193 [fn:77] When using ~:step~, ~untilnow~ starts from the beginning of
21194 2003, not the beginning of time.
21196 [fn:78] Language terms can be set through the variable
21197 ~org-clock-clocktable-language-setup~.
21199 [fn:79] Note that all parameters must be specified in a single
21200 line---the line is broken here only to fit it into the manual.
21202 [fn:80] On computers using macOS, idleness is based on actual user
21203 idleness, not just Emacs' idle time.  For X11, you can install
21204 a utility program =x11idle.c=, available in the =contrib/scripts/=
21205 directory of the Org Git distribution, or install the xprintidle
21206 package and set it to the variable ~org-clock-x11idle-program-name~ if
21207 you are running Debian, to get the same general treatment of idleness.
21208 On other systems, idle time refers to Emacs idle time only.
21210 [fn:81] Please note the pitfalls of summing hierarchical data in
21211 a flat list (see [[*Using Column View in the Agenda]]).
21213 [fn:82] Org used to offer four different targets for date/week tree
21214 capture.  Now, Org automatically translates these to use
21215 ~file+olp+datetree~, applying the ~:time-prompt~ and ~:tree-type~
21216 properties.  Please rewrite your date/week-tree targets using
21217 ~file+olp+datetree~ since the older targets are now deprecated.
21219 [fn:83] A date tree is an outline structure with years on the highest
21220 level, months or ISO weeks as sublevels and then dates on the lowest
21221 level.  Tags are allowed in the tree structure.
21223 [fn:84] If you need one of these sequences literally, escape the =%=
21224 with a backslash.
21226 [fn:85] If you define your own link types (see [[*Adding Hyperlink
21227 Types]]), any property you store with ~org-store-link-props~ can be
21228 accessed in capture templates in a similar way.
21230 [fn:86] This is always the other, not the user.  See the variable
21231 ~org-link-from-user-regexp~.
21233 [fn:87] If you move entries or Org files from one directory to
21234 another, you may want to configure ~org-attach-directory~ to contain
21235 an absolute path.
21237 [fn:88] Note the corresponding =STARTUP= options =logrefile=,
21238 =lognoterefile=, and =nologrefile=.
21240 [fn:89] If the value of that variable is not a list, but a single file
21241 name, then the list of agenda files in maintained in that external
21242 file.
21244 [fn:90] When using the dispatcher, pressing {{{kbd(<)}}} before
21245 selecting a command actually limits the command to the current file,
21246 and ignores ~org-agenda-files~ until the next dispatcher command.
21248 [fn:91] For backward compatibility, you can also press {{{kbd(1)}}} to
21249 restrict to the current buffer.
21251 [fn:92] For backward compatibility, you can also press {{{kbd(0)}}} to
21252 restrict to the current region/subtree.
21254 [fn:93] For backward compatibility, the universal prefix argument
21255 {{{kbd(C-u)}}} causes all TODO entries to be listed before the agenda.
21256 This feature is deprecated, use the dedicated TODO list, or a block
21257 agenda instead (see [[*Block agenda]]).
21259 [fn:94] The variable ~org-anniversary~ used in the example is just
21260 like ~diary-anniversary~, but the argument order is always according
21261 to ISO and therefore independent of the value of
21262 ~calendar-date-style~.
21264 [fn:95] You can, however, disable this by setting
21265 ~org-agenda-search-headline-for-time~ variable to a ~nil~ value.
21267 [fn:96] Custom commands can preset a filter by binding the variable
21268 ~org-agenda-tag-filter-preset~ as an option.  This filter is then
21269 applied to the view and persists as a basic filter through refreshes
21270 and more secondary filtering.  The filter is a global property of the
21271 entire agenda view---in a block agenda, you should only set this in
21272 the global options section, not in the section of an individual block.
21274 [fn:97] Only tags filtering is respected here, effort filtering is
21275 ignored.
21277 [fn:98] You can also create persistent custom functions through
21278 ~org-agenda-bulk-custom-functions~.
21280 [fn:99] This file is parsed for the agenda when
21281 ~org-agenda-include-diary~ is set.
21283 [fn:100] You can provide a description for a prefix key by inserting
21284 a cons cell with the prefix and the description.
21286 [fn:101] /Planned/ means here that these entries have some planning
21287 information attached to them, like a time-stamp, a scheduled or
21288 a deadline string.  See ~org-agenda-entry-types~ on how to set what
21289 planning information is taken into account.
21291 [fn:102] For HTML you need to install Hrvoje Niksic's =htmlize.el=
21292 from [[https://github.com/hniksic/emacs-htmlize][Hrvoje Niksic's repository]].
21294 [fn:103] To create PDF output, the Ghostscript ps2pdf utility must be
21295 installed on the system.  Selecting a PDF file also creates the
21296 postscript file.
21298 [fn:104] If you want to store standard views like the weekly agenda or
21299 the global TODO list as well, you need to define custom commands for
21300 them in order to be able to specify file names.
21302 [fn:105] Quoting depends on the system you use, please check the FAQ
21303 for examples.
21305 [fn:106] You can turn this on by default by setting the variable
21306 ~org-pretty-entities~, or on a per-file base with the =STARTUP= option
21307 =entitiespretty=.
21309 [fn:107] This behavior can be disabled with =-= export setting (see
21310 [[*Export Settings]]).
21312 [fn:108] LaTeX is a macro system based on Donald\nbsp{}E.\nbsp{}Knuth's TeX
21313 system.  Many of the features described here as "LaTeX" are really
21314 from TeX, but for simplicity I am blurring this distinction.
21316 [fn:109] When MathJax is used, only the environments recognized by
21317 MathJax are processed.  When dvipng, dvisvgm, or ImageMagick suite is
21318 used to create images, any LaTeX environment is handled.
21320 [fn:110] These are respectively available at
21321 [[http://sourceforge.net/projects/dvipng/]], [[http://dvisvgm.bplaced.net/]]
21322 and from the ImageMagick suite.  Choose the converter by setting the
21323 variable ~org-preview-latex-default-process~ accordingly.
21325 [fn:111] Org mode has a method to test if point is inside such
21326 a fragment, see the documentation of the function
21327 ~org-inside-LaTeX-fragment-p~.
21329 [fn:112] This works automatically for the HTML backend (it requires
21330 version 1.34 of the =htmlize.el= package, which you need to install).
21331 Fontified code chunks in LaTeX can be achieved using either the
21332 [[https://www.ctan.org/pkg/listings][listings]] package or the [[https://www.ctan.org/pkg/minted][minted]] package.  Refer to
21333 ~org-export-latex-listings~ for details.
21335 [fn:113] Source code in code blocks may also be evaluated either
21336 interactively or on export.  See [[*Working with Source Code]] for more
21337 information on evaluating code blocks.
21339 [fn:114] Adding =-k= to =-n -r= /keeps/ the labels in the source code
21340 while using line numbers for the links, which might be useful to
21341 explain those in an Org mode example code.
21343 [fn:115] Upon exit, lines starting with =*=, =,*=, =#+= and =,#+= get
21344 a comma prepended, to keep them from being interpreted by Org as
21345 outline nodes or special syntax.  These commas are stripped when
21346 editing with {{{kbd(C-c ')}}}, and also before export.
21348 [fn:116] You may select a different-mode with the variable
21349 ~org-edit-fixed-width-region-mode~.
21351 [fn:117] What Emacs considers to be an image depends on
21352 ~image-file-name-extensions~ and ~image-file-name-regexps~.
21354 [fn:118] The variable ~org-startup-with-inline-images~ can be set
21355 within a buffer with the =STARTUP= options =inlineimages= and
21356 =noinlineimages=.
21358 [fn:119] The corresponding in-buffer setting is: =#+STARTUP: fninline=
21359 or =#+STARTUP: nofninline=.
21361 [fn:120] The corresponding in-buffer options are =#+STARTUP: fnadjust=
21362 and =#+STARTUP: nofnadjust=.
21364 [fn:121] The variable ~org-export-date-timestamp-format~ defines how
21365 this timestamp are exported.
21367 [fn:122] For export to LaTeX format---or LaTeX-related formats such as
21368 Beamer---, the =org-latex-package-alist= variable needs further
21369 configuration. See [[LaTeX specific export settings]].
21371 [fn:123] At the moment, some export back-ends do not obey this
21372 specification.  For example, LaTeX export excludes every unnumbered
21373 headline from the table of contents.
21375 [fn:124] Note that ~org-link-search-must-match-exact-headline~ is
21376 locally bound to non-~nil~.  Therefore, ~org-link-search~ only matches
21377 headlines and named elements.
21379 [fn:125] Since commas separate the arguments, commas within arguments
21380 have to be escaped with the backslash character.  So only those
21381 backslash characters before a comma need escaping with another
21382 backslash character.
21384 [fn:126] For a less drastic behavior, consider using a select tag (see
21385 [[*Export Settings]]) instead.
21387 [fn:127] If =BEAMER_ENV= is set, Org export adds =B_environment= tag
21388 to make it visible.  The tag serves as a visual aid and has no
21389 semantic relevance.
21391 [fn:128] By default Org loads MathJax from [[https://cdnjs.com][cdnjs.com]] as recommended by
21392 [[http://www.mathjax.org][MathJax]].
21394 [fn:129] Please note that exported formulas are part of an HTML
21395 document, and that signs such as =<=, =>=, or =&= have special
21396 meanings.  See [[http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents][MathJax TeX and LaTeX support]].
21398 [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
21399 about extensions.
21401 [fn:131] If the classes on TODO keywords and tags lead to conflicts,
21402 use the variables ~org-html-todo-kwd-class-prefix~ and
21403 ~org-html-tag-class-prefix~ to make them unique.
21405 [fn:132] This does not allow setting different bibliography compilers
21406 for different files.  However, "smart" LaTeX compilation systems, such
21407 as latexmk, can select the correct bibliography compiler.
21409 [fn:133] See [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][Open Document Format for Office Applications
21410 (OpenDocument) Version 1.2]].
21412 [fn:134] See [[http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl][MathToWeb]].
21414 [fn:135] See [[http://dlmf.nist.gov/LaTeXML/]].
21416 [fn:136] [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][OpenDocument-v1.2 Specification]]
21418 [fn:137] See the =<table:table-template>= element of the
21419 OpenDocument-v1.2 specification.
21421 [fn:138] See the attributes =table:template-name=,
21422 =table:use-first-row-styles=, =table:use-last-row-styles=,
21423 =table:use-first-column-styles=, =table:use-last-column-styles=,
21424 =table:use-banding-rows-styles=, and =table:use-banding-column-styles=
21425 of the =<table:table>= element in the OpenDocument-v1.2 specification.
21427 [fn:139] If the publishing directory is the same as the source
21428 directory, =file.org= is exported as =file.org.org=, so you probably
21429 do not want to do this.
21431 [fn:140] The option ~org-babel-no-eval-on-ctrl-c-ctrl-c~ can be used
21432 to remove code evaluation from the {{{kbd(C-c C-c)}}} key binding.
21434 [fn:141] Actually, the constructs =call_<name>()= and =src_<lang>{}=
21435 are not evaluated when they appear in a keyword (see [[*Summary of
21436 In-Buffer Settings]]).
21438 [fn:142] Due to the way this header argument is implemented, it
21439 implies ":results file".  Therefore if it is set for multiple blocks
21440 at once (by a subtree or buffer property for example), all blocks are
21441 forced to produce file results.  This is seldom desired behavior, so
21442 it is recommended to set this header only on a per-block basis.  It is
21443 possible that this aspect of the implementation might change in the
21444 future.
21446 [fn:143] C++ language is handled in =ob-C.el=.  Even though the
21447 identifier for such source blocks is =C++=, you activate it by loading
21448 the C language.
21450 [fn:144] D language is handled in =ob-C.el=.  Even though the
21451 identifier for such source blocks is =D=, you activate it by loading
21452 the C language.
21454 [fn:145] For Noweb literate programming details, see
21455 http://www.cs.tufts.edu/~nr/noweb/.
21457 [fn:146] For more information, please refer to the commentary section
21458 in =org-tempo.el=.
21460 [fn:147] Note that ~org-indent-mode~ also sets the ~wrap-prefix~
21461 property, such that ~visual-line-mode~ (or purely setting ~word-wrap~)
21462 wraps long lines (including headlines) correctly indented.
21464 [fn:148] The ~org-indent-mode~ also sets the ~wrap-prefix~ correctly
21465 for indenting and wrapping long lines of headlines or text.  This
21466 minor mode handles ~visual-line-mode~ and directly applied settings
21467 through ~word-wrap~.
21469 [fn:149] Also see the variable ~org-adapt-indentation~.
21471 [fn:150] Because =LEVEL=2= has 3 stars, =LEVEL=3= has 4 stars, and so
21474 [fn:151] For a server to host files, consider using a WebDAV server,
21475 such as [[https://nextcloud.com][Nextcloud]].  Additional help is at this [[https://orgmode.org/worg/org-faq.html#mobileorg_webdav][FAQ entry]].
21477 [fn:152] If Emacs is configured for safe storing of passwords, then
21478 configure the variable ~org-mobile-encryption-password~; please read
21479 the docstring of that variable.
21481 [fn:153] Symbolic links in ~org-directory~ need to have the same name
21482 as their targets.
21484 [fn:154] While creating the agendas, Org mode forces =ID= properties
21485 on all referenced entries, so that these entries can be uniquely
21486 identified if Org Mobile flags them for further action.  To avoid
21487 setting properties configure the variable
21488 ~org-mobile-force-id-on-agenda-items~ to ~nil~.  Org mode then relies
21489 on outline paths, assuming they are unique.
21491 [fn:155] Checksums are stored automatically in the file
21492 =checksums.dat=.
21494 [fn:156] The file will be empty after this operation.
21496 [fn:157] https://www.ctan.org/pkg/comment
21498 [fn:158] By default this works only for LaTeX, HTML, and Texinfo.
21499 Configure the variable ~orgtbl-radio-table-templates~ to install
21500 templates for other modes.
21502 [fn:159] If the =TBLFM= keyword contains an odd number of dollar
21503 characters, this may cause problems with Font Lock in LaTeX mode.  As
21504 shown in the example you can fix this by adding an extra line inside
21505 the =comment= environment that is used to balance the dollar
21506 expressions.  If you are using AUCTeX with the font-latex library,
21507 a much better solution is to add the =comment= environment to the
21508 variable ~LaTeX-verbatim-environments~.
21510 [fn:160] The ~agenda*~ view is the same as ~agenda~ except that it
21511 only considers /appointments/, i.e., scheduled and deadline items that
21512 have a time specification =[h]h:mm= in their time-stamps.
21514 [fn:161] Note that, for ~org-odd-levels-only~, a level number
21515 corresponds to order in the hierarchy, not to the number of stars.