manual.org: Document calls to external blocks
[org-mode/org-tableheadings.git] / contrib / manual.org
blobca5088e53feebe675b1c048c053c85e1104b4d0a
1 #+title: The Org Manual
3 #+texinfo: @insertcopying
5 * Introduction
6 :PROPERTIES:
7 :DESCRIPTION: Getting started.
8 :END:
9 #+cindex: introduction
11 ** Summary
12 :PROPERTIES:
13 :DESCRIPTION: Brief summary of what Org does.
14 :END:
15 #+cindex: summary
17 Org is a mode for keeping notes, maintaining TODO lists, and project
18 planning with a fast and effective plain-text system.  It also is an
19 authoring system with unique support for literate programming and
20 reproducible research.
22 Org is implemented on top of Outline mode, which makes it possible to
23 keep the content of large files well structured.  Visibility cycling
24 and structure editing help to work with the tree.  Tables are easily
25 created with a built-in table editor.  Plain text URL-like links
26 connect to websites, emails, Usenet messages, BBDB entries, and any
27 files related to the projects.
29 Org develops organizational tasks around notes files that contain
30 lists or information about projects as plain text.  Project planning
31 and task management makes use of metadata which is part of an outline
32 node.  Based on this data, specific entries can be extracted in
33 queries and create dynamic /agenda views/ that also integrate the
34 Emacs calendar and diary.  Org can be used to implement many different
35 project planning schemes, such as David Allen's GTD system.
37 Org files can serve as a single source authoring system with export to
38 many different formats such as HTML, LaTeX, Open Document, and
39 Markdown.  New export backends can be derived from existing ones, or
40 defined from scratch.
42 Org files can include source code blocks, which makes Org uniquely
43 suited for authoring technical documents with code examples. Org
44 source code blocks are fully functional; they can be evaluated in
45 place and their results can be captured in the file.  This makes it
46 possible to create a single file reproducible research compendium.
48 Org keeps simple things simple.  When first fired up, it should feel
49 like a straightforward, easy to use outliner.  Complexity is not
50 imposed, but a large amount of functionality is available when needed.
51 Org is a toolbox.  Many users actually run only a---very
52 personal---fraction of Org's capabilities, and know that there is more
53 whenever they need it.
55 All of this is achieved with strictly plain text files, the most
56 portable and future-proof file format.  Org runs in Emacs.  Emacs is
57 one of the most widely ported programs, so that Org mode is available
58 on every major platform.
60 #+cindex: FAQ
61 There is a website for Org which provides links to the newest version
62 of Org, as well as additional information, frequently asked questions
63 (FAQ), links to tutorials, etc.  This page is located at
64 [[https://orgmode.org]].
66 #+cindex: print edition
67 An earlier version (7.3) of this manual is available as a [[http://www.network-theory.co.uk/org/manual/][paperback
68 book from Network Theory Ltd.]].
70 ** Installation
71 :PROPERTIES:
72 :DESCRIPTION: Installing Org.
73 :END:
74 #+cindex: installation
76 Org is part of recent distributions of GNU Emacs, so you normally do
77 not need to install it.  If, for one reason or another, you want to
78 install Org on top of this pre-packaged version, there are three ways
79 to do it:
81 - By using Emacs package system.
82 - By downloading Org as an archive.
83 - By using Org's git repository.
85 We *strongly recommend* to stick to a single installation method.
87 *** Using Emacs packaging system
88 :PROPERTIES:
89 :UNNUMBERED: notoc
90 :END:
92 Recent Emacs distributions include a packaging system which lets you
93 install Elisp libraries.  You can install Org with {{{kbd(M-x
94 package-install RET org)}}}.
96 #+texinfo: @noindent
97 *Important*: you need to do this in a session where no =.org= file has
98 been visited, i.e., where no Org built-in function have been loaded.
99 Otherwise autoload Org functions will mess up the installation.
101 Then, to make sure your Org configuration is taken into account,
102 initialize the package system with ~(package-initialize)~ in your
103 Emacs init file before setting any Org option.  If you want to use
104 Org's package repository, check out the [[https://orgmode.org/elpa.html][Org ELPA page]].
106 *** Downloading Org as an archive
107 :PROPERTIES:
108 :UNNUMBERED: notoc
109 :END:
111 You can download Org latest release from [[https://orgmode.org/][Org's website]].  In this case,
112 make sure you set the load-path correctly in your Emacs init file:
114 #+begin_src emacs-lisp
115   (add-to-list 'load-path "~/path/to/orgdir/lisp")
116 #+end_src
118 The downloaded archive contains contributed libraries that are not
119 included in Emacs.  If you want to use them, add the =contrib/=
120 directory to your load-path:
122 #+begin_src emacs-lisp
123   (add-to-list 'load-path "~/path/to/orgdir/contrib/lisp" t)
124 #+end_src
126 Optionally, you can compile the files and/or install them in your
127 system.  Run =make help= to list compilation and installation options.
129 *** Using Org's git repository
130 :PROPERTIES:
131 :UNNUMBERED: notoc
132 :END:
134 You can clone Org's repository and install Org like this:
136 #+begin_example
137   $ cd ~/src/
138   $ git clone git@code.orgmode.org:bzg/org-mode.git
139   $ make autoloads
140 #+end_example
142 Note that in this case, ~make autoloads~ is mandatory: it defines
143 Org's version in =org-version.el= and Org's autoloads in
144 =org-loaddefs.el=.
146 Remember to add the correct load-path as described in the method
147 above.
149 You can also compile with =make=, generate the documentation with
150 =make doc=, create a local configuration with =make config= and
151 install Org with =make install=.  Please run =make help= to get the
152 list of compilation/installation options.
154 For more detailed explanations on Org's build system, please check the
155 Org Build System page on [[https://orgmode.org/worg/dev/org-build-system.html][Worg]].
157 ** Activation
158 :PROPERTIES:
159 :DESCRIPTION: How to activate Org for certain buffers.
160 :END:
161 #+cindex: activation
162 #+cindex: autoload
163 #+cindex: ELPA
164 #+cindex: global key bindings
165 #+cindex: key bindings, global
167 Org mode buffers need Font Lock to be turned on: this is the default
168 in Emacs[fn:1].
170 There are compatibility issues between Org mode and some other Elisp
171 packages (see [[*Packages that conflict with Org mode]]).  Please take the
172 time to check the list.
174 #+findex: org-agenda
175 #+findex: org-capture
176 #+findex: org-store-link
177 #+findex: org-iswitchb
178 The four Org commands ~org-store-link~, ~org-capture~, ~org-agenda~,
179 and ~org-iswitchb~ be accessible through global keys---i.e., anywhere
180 in Emacs, not just in Org buffers.  Here are suggested bindings for
181 these keys, please modify the keys to your own liking.
183 #+begin_src emacs-lisp
184   (global-set-key "\C-cl" 'org-store-link)
185   (global-set-key "\C-ca" 'org-agenda)
186   (global-set-key "\C-cc" 'org-capture)
187   (global-set-key "\C-cb" 'org-iswitchb)
188 #+end_src
190 #+cindex: Org mode, turning on
191 Files with the =.org= extension use Org mode by default.  To turn on
192 Org mode in a file that does not have the extension =.org=, make the
193 first line of a file look like this:
195 : MY PROJECTS    -*- mode: org; -*-
197 #+vindex: org-insert-mode-line-in-empty-file
198 #+texinfo: @noindent
199 which selects Org mode for this buffer no matter what the file's name
200 is.  See also the variable ~org-insert-mode-line-in-empty-file~.
202 Many commands in Org work on the region if the region is /active/.  To
203 make use of this, you need to have ~transient-mark-mode~ turned on,
204 which is the default.  If you do not like ~transient-mark-mode~, you
205 can create an active region by using the mouse to select a region, or
206 pressing {{{kbd(C-SPC)}}} twice before moving the cursor.
208 ** Feedback
209 :PROPERTIES:
210 :DESCRIPTION: Bug reports, ideas, patches, etc.
211 :END:
212 #+cindex: feedback
213 #+cindex: bug reports
214 #+cindex: reporting a bug
215 #+cindex: maintainer
216 #+cindex: author
218 If you find problems with Org, or if you have questions, remarks, or
219 ideas about it, please mail to the Org mailing list
220 [[mailto:emacs-orgmode@gnu.org]].  You can subscribe to the list [[https://lists.gnu.org/mailman/listinfo/emacs-orgmode][on this
221 web page]].  If you are not a member of the mailing list, your mail will
222 be passed to the list after a moderator has approved it[fn:2].
224 #+findex: org-version
225 #+findex: org-submit-bug-report
226 For bug reports, please first try to reproduce the bug with the latest
227 version of Org available---if you are running an outdated version, it
228 is quite possible that the bug has been fixed already.  If the bug
229 persists, prepare a report and provide as much information as
230 possible, including the version information of Emacs ({{{kbd(M-x
231 emacs-version)}}}) and Org ({{{kbd(M-x org-version)}}}), as well as
232 the Org related setup in the Emacs init file.  The easiest way to do
233 this is to use the command
235 : M-x org-submit-bug-report <RET>
237 #+texinfo: @noindent
238 which puts all this information into an Emacs mail buffer so that you
239 only need to add your description.  If you are not sending the Email
240 from within Emacs, please copy and paste the content into your Email
241 program.
243 Sometimes you might face a problem due to an error in your Emacs or
244 Org mode setup.  Before reporting a bug, it is very helpful to start
245 Emacs with minimal customizations and reproduce the problem.  Doing so
246 often helps you determine if the problem is with your customization or
247 with Org mode itself.  You can start a typical minimal session with
248 a command like the example below.
250 : $ emacs -Q -l /path/to/minimal-org.el
252 However if you are using Org mode as distributed with Emacs, a minimal
253 setup is not necessary.  In that case it is sufficient to start Emacs
254 as =emacs -Q=.  The =minimal-org.el= setup file can have contents as
255 shown below.
257 #+begin_src emacs-lisp
258   ;;; Minimal setup to load latest `org-mode'.
260   ;; Activate debugging.
261   (setq debug-on-error t
262         debug-on-signal nil
263         debug-on-quit nil)
265   ;; Add latest Org mode to load path.
266   (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
267   (add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t))
268 #+end_src
270 If an error occurs, a "backtrace" can be very useful---see below on
271 how to create one.  Often a small example file helps, along with clear
272 information about:
274 1. What exactly did you do?
275 2. What did you expect to happen?
276 3. What happened instead?
278 #+texinfo: @noindent
279 Thank you for helping to improve this program.
281 *** How to create a useful backtrace
282 :PROPERTIES:
283 :UNNUMBERED: notoc
284 :END:
286 #+cindex: backtrace of an error
287 If working with Org produces an error with a message you do not
288 understand, you may have hit a bug.  The best way to report this is by
289 providing, in addition to what was mentioned above, a backtrace.  This
290 is information from the built-in debugger about where and how the
291 error occurred.  Here is how to produce a useful backtrace:
293 1. Reload uncompiled versions of all Org mode Lisp files.  The
294    backtrace contains much more information if it is produced with
295    uncompiled code.  To do this, use
297    : C-u M-x org-reload <RET>
299    #+texinfo: @noindent
300    or, from the menu: Org \rarr Refresh/Reload \rarr Reload Org uncompiled.
302 2. Then, activate the debugger:
304    : M-x toggle-debug-or-errror <RET>
306    #+texinfo: @noindent
307    or, from the menu: Options \rarr Enter Debugger on Error.
309 3. Do whatever you have to do to hit the error.  Do not forget to
310    document the steps you take.
312 4. When you hit the error, a =*Backtrace*= buffer appears on the
313    screen.  Save this buffer to a file---for example using {{{kbd(C-x
314    C-w)}}}---and attach it to your bug report.
316 ** Typesetting Conventions Used in this Manual
317 :PROPERTIES:
318 :DESCRIPTION: Typesetting conventions used in this manual.
319 :ALT_TITLE: Conventions
320 :END:
322 *** TODO keywords, tags, properties, etc.
323 :PROPERTIES:
324 :UNNUMBERED: notoc
325 :END:
327 Org uses various syntactical elements: TODO keywords, tags, property
328 names, keywords, blocks, etc.  In this manual we use the following
329 conventions:
331 #+attr_texinfo: :sep ,
332 - =TODO=, =WAITING= ::
334      TODO keywords are written with all capitals, even if they are
335      user-defined.
337 - =boss=, =ARCHIVE= ::
339      User-defined tags are written in lowercase; built-in tags with
340      special meaning are written with all capitals.
342 - =Release=, =PRIORITY= ::
344      User-defined properties are capitalized; built-in properties with
345      special meaning are written with all capitals.
347 - =TITLE=, =BEGIN= ... =END= ::
349      Keywords and blocks are written in uppercase to enhance their
350      readability, but you can use lowercase in your Org files.
352 *** Key bindings and commands
353 :PROPERTIES:
354 :UNNUMBERED: notoc
355 :END:
357 #+kindex: C-c a
358 #+kindex: C-c c
359 The manual suggests a few global key bindings, in particular
360 {{{kbd(C-c a)}}} for ~org-agenda~ and {{{kbd(C-c c)}}} for
361 ~org-capture~.  These are only suggestions, but the rest of the manual
362 assumes that these key bindings are in place in order to list commands
363 by key access.
365 Also, the manual lists both the keys and the corresponding commands
366 for 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:
379 #+cindex: document structure
380 #+cindex: structure of document
382 Org is based on Outline mode and provides flexible commands to
383 edit the structure of the document.
385 ** Outlines
386 :PROPERTIES:
387 :DESCRIPTION: Org is based on Outline mode.
388 :END:
389 #+cindex: outlines
390 #+cindex: Outline mode
392 Org is implemented on top of Outline mode.  Outlines allow a document
393 to be organized in a hierarchical structure, which, least for me, is
394 the best representation of notes and thoughts.  An overview of this
395 structure is achieved by folding, i.e., hiding large parts of the
396 document to show only the general document structure and the parts
397 currently being worked on.  Org greatly simplifies the use of outlines
398 by compressing the entire show and hide functionalities into a single
399 command, ~org-cycle~, which is bound to the {{{kbd(TAB)}}} key.
401 ** Headlines
402 :PROPERTIES:
403 :DESCRIPTION: How to typeset Org tree headlines.
404 :END:
405 #+cindex: headlines
406 #+cindex: outline tree
407 #+vindex: org-special-ctrl-a/e
408 #+vindex: org-special-ctrl-k
409 #+vindex: org-ctrl-k-protect-subtree
411 Headlines define the structure of an outline tree.  The headlines in
412 Org start with one or more stars, on the left margin[fn:3].  For
413 example:
415 #+begin_example
416   ,* Top level headline
417   ,** Second level
418   ,*** Third level
419       some text
420   ,*** Third level
421       more text
422   ,* Another top level headline
423 #+end_example
425 #+vindex: org-footnote-section
426 #+texinfo: @noindent
427 Note that the name defined in ~org-footnote-section~ is reserved.  Do
428 not use it as a title for your own headings.
430 Some people find the many stars too noisy and would prefer an outline
431 that has whitespace followed by a single star as headline starters.
432 See [[*A Cleaner Outline View]].
434 #+vindex: org-cycle-separator-lines
435 An empty line after the end of a subtree is considered part of it and
436 is hidden when the subtree is folded.  However, if you leave at least
437 two empty lines, one empty line remains visible after folding the
438 subtree, in order to structure the collapsed view.  See the variable
439 ~org-cycle-separator-lines~ to modify this behavior.
441 ** Visibility Cycling
442 :PROPERTIES:
443 :DESCRIPTION: Show and hide, much simplified.
444 :END:
445 #+cindex: cycling, visibility
446 #+cindex: visibility cycling
447 #+cindex: trees, visibility
448 #+cindex: show hidden text
449 #+cindex: hide text
451 *** Global and local cycling
452 :PROPERTIES:
453 :DESCRIPTION: Cycling through various visibility states.
454 :END:
455 #+cindex: subtree visibility states
456 #+cindex: subtree cycling
457 #+cindex: folded, subtree visibility state
458 #+cindex: children, subtree visibility state
459 #+cindex: subtree, subtree visibility state
461 Outlines make it possible to hide parts of the text in the buffer.
462 Org uses just two commands, bound to {{{kbd(TAB)}}} and
463 {{{kbd(S-TAB)}}} to change the visibility in the buffer.
465 #+attr_texinfo: :sep ,
466 - {{{kbd(TAB)}}} (~org-cycle~) ::
468      #+kindex: TAB
469      #+findex: org-cycle
470      /Subtree cycling/: Rotate current subtree among the states
472      #+begin_example
473        ,-> FOLDED -> CHILDREN -> SUBTREE --.
474        '-----------------------------------'
475      #+end_example
477      #+vindex: org-cycle-emulate-tab
478      The cursor must be on a headline for this to work[fn:4].
480 - {{{kbd(S-TAB)}}} (~org-global-cycle~), {{{kbd(C-u TAB)}}} ::
482      #+cindex: global visibility states
483      #+cindex: global cycling
484      #+cindex: overview, global visibility state
485      #+cindex: contents, global visibility state
486      #+cindex: show all, global visibility state
487      #+kindex: C-u TAB
488      #+kindex: S-TAB
489      #+findex: org-global-cycle
490      /Global cycling/: Rotate the entire buffer among the states
492      #+begin_example
493        ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
494        '--------------------------------------'
495      #+end_example
497      When {{{kbd(S-TAB)}}} is called with a numeric prefix argument N,
498      the CONTENTS view up to headlines of level N are shown.  Note
499      that inside tables (see [[*Tables]]), {{{kbd(S-TAB)}}} jumps to the
500      previous field instead.
502      #+vindex: org-cycle-global-at-bob
503      You can run global cycling using {{{kbd(TAB)}}} only if point is
504      at the very beginning of the buffer, but not on a headline, and
505      ~org-cycle-global-at-bob~ is set to a non-~nil~ value.
507 - {{{kbd(C-u C-u TAB)}}} (~org-set-startup-visibility~) ::
509      #+cindex: startup visibility
510      #+kindex: C-u C-u TAB
511      #+findex: org-set-startup-visibility
512      Switch back to the startup visibility of the buffer (see [[*Initial
513      visibility]]).
515 - {{{kbd(C-u C-u C-u TAB)}}} (~outline-show-all~) ::
517      #+cindex: show all, command
518      #+kindex: C-u C-u C-u TAB
519      #+findex: outline-show-all
520      Show all, including drawers.
522 - {{{kbd(C-c C-r)}}} (~org-reveal~) ::
524      #+cindex: revealing context
525      #+kindex: C-c C-r
526      #+findex: org-reveal
527      Reveal context around point, showing the current entry, the
528      following heading and the hierarchy above.  Useful for working
529      near a location that has been exposed by a sparse tree command
530      (see [[*Sparse Trees]]) or an agenda command (see [[*Commands in the
531      Agenda Buffer]]).  With a prefix argument show, on each level, all
532      sibling headings.  With a double prefix argument, also show the
533      entire subtree of the parent.
535 - {{{kbd(C-c C-k)}}} (~outline-show-branches~) ::
537      #+cindex: show branches, command
538      #+kindex: C-c C-k
539      #+findex: outline-show-branches
540      Expose all the headings of the subtree, CONTENTS view for just
541      one subtree.
543 - {{{kbd(C-c TAB)}}} (~outline-show-children~) ::
545      #+cindex: show children, command
546      #+kindex: C-c TAB
547      #+findex: outline-show-children
548      Expose all direct children of the subtree.  With a numeric prefix
549      argument N, expose all children down to level N.
551 - {{{kbd(C-c C-x b)}}} (~org-tree-to-indirect-buffer~) ::
553      #+kindex: C-c C-x b
554      #+findex: org-tree-to-indirect-buffer
555      Show the current subtree in an indirect buffer[fn:5].  With
556      a numeric prefix argument, N, go up to level N and then take that
557      tree.  If N is negative then go up that many levels.  With
558      a {{{kbd(C-u)}}} prefix, do not remove the previously used
559      indirect buffer.
561 - {{{kbd(C-c C-x v)}}} (~org-copy-visible~) ::
563      #+kindex: C-c C-x v
564      #+findex: org-copy-visible
565      Copy the /visible/ text in the region into the kill ring.
567 *** Initial visibility
568 :PROPERTIES:
569 :DESCRIPTION: Setting the initial visibility state.
570 :END:
572 #+vindex: org-startup-folded
573 When Emacs first visits an Org file, the global state is set to
574 OVERVIEW, i.e., only the top level headlines are visible[fn:6].  This
575 can be configured through the variable ~org-startup-folded~, or on
576 a per-file basis by adding one of the following lines anywhere in the
577 buffer:
579 #+cindex: STARTUP, keyword
580 #+begin_example
581   ,#+STARTUP: overview
582   ,#+STARTUP: content
583   ,#+STARTUP: showall
584   ,#+STARTUP: showeverything
585 #+end_example
587 #+cindex: VISIBILITY, property
588 #+texinfo: @noindent
589 Furthermore, any entries with a =VISIBILITY= property (see [[*Properties
590 and Columns]]) get their visibility adapted accordingly.  Allowed values
591 for this property are =folded=, =children=, =content=, and ~all~.
593 - {{{kbd(C-u C-u TAB)}}} (~org-set-startup-visibility~) ::
595      #+kindex: C-u C-u TAB
596      #+findex: org-set-startup-visibility
597      Switch back to the startup visibility of the buffer, i.e.,
598      whatever is requested by startup options and =VISIBILITY=
599      properties in individual entries.
601 *** Catching invisible edits
602 :PROPERTIES:
603 :DESCRIPTION: Preventing mistakes when editing invisible parts.
604 :END:
605 #+cindex: edits, catching invisible
607 #+vindex: org-catch-invisible-edits
608 Sometimes you may inadvertently edit an invisible part of the buffer
609 and be confused on what has been edited and how to undo the mistake.
610 Setting ~org-catch-invisible-edits~ to non-~nil~ helps preventing
611 this.  See the docstring of this option on how Org should catch
612 invisible edits and process them.
614 ** Motion
615 :PROPERTIES:
616 :DESCRIPTION: Jumping to other headlines.
617 :END:
618 #+cindex: motion, between headlines
619 #+cindex: jumping, to headlines
620 #+cindex: headline navigation
622 The following commands jump to other headlines in the buffer.
624 - {{{kbd(C-c C-n)}}} (~outline-next-visible-heading~) ::
626      #+kindex: C-c C-n
627      #+findex: outline-next-visible-heading
628      Next heading.
630 - {{{kbd(C-c C-p)}}} (~outline-previous-visible-heading~) ::
632      #+kindex: C-c C-p
633      #+findex: outline-previous-visible-heading
634      Previous heading.
636 - {{{kbd(C-c C-f)}}} (~org-forward-same-level~) ::
638      #+kindex: C-c C-f
639      #+findex: org-forward-same-level
640      Next heading same level.
642 - {{{kbd(C-c C-b)}}} (~org-backward-same-level~) ::
644      #+kindex: C-c C-b
645      #+findex: org-backward-same-level
646      Previous heading same level.
648 - {{{kbd(C-c C-u)}}} (~outline-up-heading~) ::
650      #+kindex: C-c C-u
651      #+findex: outline-up-heading
652      Backward to higher level heading.
654 - {{{kbd(C-c C-j)}}} (~org-goto~) ::
656      #+kindex: C-c C-j
657      #+findex: org-goto
658      #+vindex: org-goto-auto-isearch
659      Jump to a different place without changing the current outline
660      visibility.  Shows the document structure in a temporary buffer,
661      where you can use the following keys to find your destination:
663      #+attr_texinfo: :columns 0.3 0.7
664      | {{{kbd(TAB)}}}                  | Cycle visibility.               |
665      | {{{kbd(down)}}} / {{{kbd(up)}}} | Next/previous visible headline. |
666      | {{{kbd(RET)}}}                  | Select this location.           |
667      | {{{kbd(/)}}}                    | Do a Sparse-tree search         |
669      #+texinfo: @noindent
670      The following keys work if you turn off ~org-goto-auto-isearch~
672      #+attr_texinfo: :columns 0.3 0.7
673      | {{{kbd(n)}}} / {{{kbd(p)}}}   | Next/previous visible headline.    |
674      | {{{kbd(f)}}} / {{{kbd(b)}}}   | Next/previous headline same level. |
675      | {{{kbd(u)}}}                  | One level up.                      |
676      | {{{kbd(0)}}} ... {{{kbd(9)}}} | Digit argument.                    |
677      | {{{kbd(q)}}}                  | Quit.                              |
679      #+vindex: org-goto-interface
680      #+texinfo: @noindent
681      See also the variable ~org-goto-interface~.
683 ** Structure Editing
684 :PROPERTIES:
685 :DESCRIPTION: Changing sequence and level of headlines.
686 :END:
687 #+cindex: structure editing
688 #+cindex: headline, promotion and demotion
689 #+cindex: promotion, of subtrees
690 #+cindex: demotion, of subtrees
691 #+cindex: subtree, cut and paste
692 #+cindex: pasting, of subtrees
693 #+cindex: cutting, of subtrees
694 #+cindex: copying, of subtrees
695 #+cindex: sorting, of subtrees
696 #+cindex: subtrees, cut and paste
698 - {{{kbd(M-RET)}}} (~org-meta-return~) ::
700      #+kindex: M-RET
701      #+findex: org-meta-return
702      #+vindex: org-M-RET-may-split-line
703      Insert a new heading, item or row.
705      If the command is used at the /beginning/ of a line, and if there
706      is a heading or a plain list item (see [[*Plain Lists]]) at point,
707      the new heading/item is created /before/ the current line.  When
708      used at the beginning of a regular line of text, turn that line
709      into a heading.
711      When this command is used in the middle of a line, the line is
712      split and the rest of the line becomes the new item or headline.
713      If you do not want the line to be split, customize
714      ~org-M-RET-may-split-line~.
716      Calling the command with a {{{kbd(C-u)}}} prefix unconditionally
717      inserts a new heading at the end of the current subtree, thus
718      preserving its contents.  With a double {{{kbd(C-u C-u)}}}
719      prefix, the new heading is created at the end of the parent
720      subtree instead.
722 - {{{kbd(C-RET)}}} (~org-insert-heading-respect-content~) ::
724      #+kindex: C-RET
725      #+findex: org-insert-heading-respect-content
726      Insert a new heading at the end of the current subtree.
728 - {{{kbd(M-S-RET)}}} (~org-insert-todo-heading~) ::
730      #+kindex: M-S-RET
731      #+findex: org-insert-todo-heading
732      #+vindex: org-treat-insert-todo-heading-as-state-change
733      Insert new TODO entry with same level as current heading.  See
734      also the variable
735      ~org-treat-insert-todo-heading-as-state-change~.
737 - {{{kbd(C-S-RET)}}} (~org-insert-todo-heading-respect-content~) ::
739      #+kindex: C-S-RET
740      #+findex: org-insert-todo-heading-respect-content
741      Insert new TODO entry with same level as current heading.  Like
742      {{{kbd(C-RET)}}}, the new headline is inserted after the current
743      subtree.
745 - {{{kbd(TAB)}}} (~org-cycle~) ::
747      #+kindex: TAB
748      #+findex: org-cycle
749      In a new entry with no text yet, the first {{{kbd(TAB)}}} demotes
750      the entry to become a child of the previous one.  The next
751      {{{kbd(TAB)}}} makes it a parent, and so on, all the way to top
752      level.  Yet another {{{kbd(TAB)}}}, and you are back to the
753      initial level.
755 - {{{kbd(M-left)}}} (~org-do-promote~) ::
757      #+kindex: M-left
758      #+findex: org-do-promote
759      Promote current heading by one level.
761 - {{{kbd(M-right)}}} (~org-do-demote~) ::
763      #+kindex: M-right
764      #+findex: org-do-demote
765      Demote current heading by one level.
767 - {{{kbd(M-S-left)}}} (~org-promote-subtree~) ::
769      #+kindex: M-S-left
770      #+findex: org-promote-subtree
771      Promote the current subtree by one level.
773 - {{{kbd(M-S-right)}}} (~org-demote-subtree~) ::
775      #+kindex: M-S-right
776      #+findex: org-demote-subtree
777      Demote the current subtree by one level.
779 - {{{kbd(M-up)}}} (~org-move-subtree-up~) ::
781      #+kindex: M-up
782      #+findex: org-move-subtree-up
783      Move subtree up, i.e., swap with previous subtree of same level.
785 - {{{kbd(M-down)}}} (~org-move-subtree-down~) ::
787      #+kindex: M-down
788      #+findex: org-move-subtree-down
789      Move subtree down, i.e., swap with next subtree of same level.
791 - {{{kbd(C-c @)}}} (~org-mark-subtree~) ::
793      #+kindex: C-c @@
794      #+findex: org-mark-subtree
795      Mark the subtree at point.  Hitting repeatedly marks subsequent
796      subtrees of the same level as the marked subtree.
798 - {{{kbd(C-c C-x C-w)}}} (~org-cut-subtree~) ::
800      #+kindex: C-c C-x C-w
801      #+findex: org-cut-subtree
802      Kill subtree, i.e., remove it from buffer but save in kill ring.
803      With a numeric prefix argument N, kill N sequential subtrees.
805 - {{{kbd(C-c C-x M-w)}}} (~org-copy-subtree~) ::
807      #+kindex: C-c C-x M-w
808      #+findex: org-copy-subtree
809      Copy subtree to kill ring.  With a numeric prefix argument N,
810      copy the N sequential subtrees.
812 - {{{kbd(C-c C-x C-y)}}} (~org-paste-subtree~) ::
814      #+kindex: C-c C-x C-y
815      #+findex: org-paste-subtree
816      Yank subtree from kill ring.  This does modify the level of the
817      subtree to make sure the tree fits in nicely at the yank
818      position.  The yank level can also be specified with a numeric
819      prefix argument, or by yanking after a headline marker like
820      =****=.
822 - {{{kbd(C-y)}}} (~org-yank~) ::
824      #+kindex: C-y
825      #+findex: org-yank
826      #+vindex: org-yank-adjusted-subtrees
827      #+vindex: org-yank-folded-subtrees
828      Depending on the variables ~org-yank-adjusted-subtrees~ and
829      ~org-yank-folded-subtrees~, Org's internal ~yank~ command pastes
830      subtrees folded and in a clever way, using the same command as
831      {{{kbd(C-c C-x C-y)}}}.  With the default settings, no level
832      adjustment takes place, but the yanked tree is folded unless
833      doing so would swallow text previously visible.  Any prefix
834      argument to this command forces a normal ~yank~ to be executed,
835      with the prefix passed along.  A good way to force a normal yank
836      is {{{kbd(C-u C-y)}}}.  If you use ~yank-pop~ after a yank, it
837      yanks previous kill items plainly, without adjustment and
838      folding.
840 - {{{kbd(C-c C-x c)}}} (~org-clone-subtree-with-time-shift~) ::
842      #+kindex: C-c C-x c
843      #+findex: org-clone-subtree-with-time-shift
844      Clone a subtree by making a number of sibling copies of it.  You
845      are prompted for the number of copies to make, and you can also
846      specify if any timestamps in the entry should be shifted.  This
847      can be useful, for example, to create a number of tasks related
848      to a series of lectures to prepare.  For more details, see the
849      docstring of the command ~org-clone-subtree-with-time-shift~.
851 - {{{kbd(C-c C-w)}}} (~org-refile~) ::
853      #+kindex: C-c C-w
854      #+findex: org-refile
855      Refile entry or region to a different location.  See [[Refile and
856      Copy]].
858 - {{{kbd(C-c ^)}}} (~org-sort~) ::
860      #+kindex: C-c ^
861      #+findex: org-sort
862      Sort same-level entries.  When there is an active region, all
863      entries in the region are sorted.  Otherwise the children of the
864      current headline are sorted.  The command prompts for the sorting
865      method, which can be alphabetically, numerically, by time---first
866      timestamp with active preferred, creation time, scheduled time,
867      deadline time---by priority, by TODO keyword---in the sequence
868      the keywords have been defined in the setup---or by the value of
869      a property.  Reverse sorting is possible as well.  You can also
870      supply your own function to extract the sorting key.  With
871      a {{{kbd(C-u)}}} prefix, sorting is case-sensitive.
873 - {{{kbd(C-x n s)}}} (~org-narrow-to-subtree~) ::
875      #+kindex: C-x n s
876      #+findex: org-narrow-to-subtree
877      Narrow buffer to current subtree.
879 - {{{kbd(C-x n b)}}} (~org-narrow-to-block~) ::
881      #+kindex: C-x n b
882      #+findex: org-narrow-to-block
883      Narrow buffer to current block.
885 - {{{kbd(C-x n w)}}} (~widen~) ::
887      #+kindex: C-x n w
888      #+findex: widen
889      Widen buffer to remove narrowing.
891 - {{{kbd(C-c *)}}} (~org-toggle-heading~) ::
893      #+kindex: C-c *
894      #+findex: org-toggle-heading
895      Turn a normal line or plain list item into a headline---so that
896      it becomes a subheading at its location.  Also turn a headline
897      into a normal line by removing the stars.  If there is an active
898      region, turn all lines in the region into headlines.  If the
899      first line in the region was an item, turn only the item lines
900      into headlines.  Finally, if the first line is a headline, remove
901      the stars from all headlines in the region.
903 #+cindex: region, active
904 #+cindex: active region
905 #+cindex: transient mark mode
906 When there is an active region---i.e., when Transient Mark mode is
907 active---promotion and demotion work on all headlines in the region.
908 To select a region of headlines, it is best to place both point and
909 mark at the beginning of a line, mark at the beginning of the first
910 headline, and point at the line just after the last headline to
911 change.  Note that when the cursor is inside a table (see [[*Tables]]),
912 the Meta-Cursor keys have different functionality.
914 ** Sparse Trees
915 :PROPERTIES:
916 :DESCRIPTION: Matches embedded in context.
917 :END:
918 #+cindex: sparse trees
919 #+cindex: trees, sparse
920 #+cindex: folding, sparse trees
921 #+cindex: occur, command
923 #+vindex: org-show-context-detail
924 An important feature of Org mode is the ability to construct /sparse
925 trees/ for selected information in an outline tree, so that the entire
926 document is folded as much as possible, but the selected information
927 is made visible along with the headline structure above it[fn:7].
928 Just try it out and you will see immediately how it works.
930 Org mode contains several commands creating such trees, all these
931 commands can be accessed through a dispatcher:
933 - {{{kbd(C-c /)}}} (~org-sparse-tree~) ::
935      #+kindex: C-c /
936      #+findex: org-sparse-tree
937      This prompts for an extra key to select a sparse-tree creating
938      command.
940 - {{{kbd(C-c / r)}}} or {{{kbd(C-c / /)}}} (~org-occur~) ::
942      #+kindex: C-c / r
943      #+kindex: C-c / /
944      #+findex: org-occur
945      #+vindex: org-remove-highlights-with-change
946      Prompts for a regexp and shows a sparse tree with all matches.
947      If the match is in a headline, the headline is made visible.  If
948      the match is in the body of an entry, headline and body are made
949      visible.  In order to provide minimal context, also the full
950      hierarchy of headlines above the match is shown, as well as the
951      headline following the match.  Each match is also highlighted;
952      the highlights disappear when the buffer is changed by an editing
953      command, or by pressing {{{kbd(C-c C-c)}}}[fn:8].  When called
954      with a {{{kbd(C-u)}}} prefix argument, previous highlights are
955      kept, so several calls to this command can be stacked.
957 - {{{kbd(M-g n)}}} or {{{kbd(M-g M-n)}}} (~next-error~) ::
959      #+kindex: M-g n
960      #+kindex: M-g M-n
961      #+findex: next-error
962      Jump to the next sparse tree match in this buffer.
964 - {{{kbd(M-g p)}}} or {{{kbd(M-g M-p)}}} (~previous-error~) ::
966      #+kindex: M-g p
967      #+kindex: M-g M-p
968      #+findex: previous-error
969      Jump to the previous sparse tree match in this buffer.
971 #+vindex: org-agenda-custom-commands
972 #+texinfo: @noindent
973 For frequently used sparse trees of specific search strings, you can
974 use the variable ~org-agenda-custom-commands~ to define fast keyboard
975 access to specific sparse trees.  These commands will then be
976 accessible through the agenda dispatcher (see [[*The Agenda Dispatcher]]).
977 For example:
979 #+begin_src emacs-lisp
980   (setq org-agenda-custom-commands
981         '(("f" occur-tree "FIXME")))
982 #+end_src
984 #+texinfo: @noindent
985 defines the key {{{kbd(C-c a f)}}} as a shortcut for creating a sparse
986 tree matching the string =FIXME=.
988 The other sparse tree commands select headings based on TODO keywords,
989 tags, or properties and are discussed later in this manual.
991 #+kindex: C-c C-e v
992 #+cindex: printing sparse trees
993 #+cindex: visible text, printing
994 To print a sparse tree, you can use the Emacs command
995 ~ps-print-buffer-with-faces~ which does not print invisible parts of
996 the document.  Or you can use the command {{{kbd(C-c C-e v)}}} to
997 export only the visible part of the document and print the resulting
998 file.
1000 ** Plain Lists
1001 :PROPERTIES:
1002 :DESCRIPTION: Additional structure within an entry.
1003 :END:
1004 #+cindex: plain lists
1005 #+cindex: lists, plain
1006 #+cindex: lists, ordered
1007 #+cindex: ordered lists
1009 Within an entry of the outline tree, hand-formatted lists can provide
1010 additional structure.  They also provide a way to create lists of
1011 checkboxes (see [[*Checkboxes]]).  Org supports editing such lists, and
1012 every exporter (see [[*Exporting]]) can parse and format them.
1014 Org knows ordered lists, unordered lists, and description lists.
1016 #+attr_texinfo: :indic @bullet
1017 - /Unordered/ list items start with =-=, =+=, or =*=[fn:9] as bullets.
1020   #+vindex: org-plain-list-ordered-item-terminator
1021   #+vindex: org-alphabetical-lists
1022   /Ordered/ list items start with a numeral followed by either
1023   a period or a right parenthesis[fn:10], such as =1.= or =1)=[fn:11]
1024   If you want a list to start with a different value---e.g.,
1025   20---start the text of the item with =[@20]=[fn:12].  Those
1026   constructs can be used in any item of the list in order to enforce
1027   a particular numbering.
1029 - /Description/ list items are unordered list items, and contain the
1030   separator =::= to distinguish the description /term/ from the
1031   description.
1033 Items belonging to the same list must have the same indentation on the
1034 first line.  In particular, if an ordered list reaches number =10.=,
1035 then the 2-digit numbers must be written left-aligned with the other
1036 numbers in the list.  An item ends before the next line that is less
1037 or equally indented than its bullet/number.
1039 A list ends whenever every item has ended, which means before any line
1040 less or equally indented than items at top level.  It also ends before
1041 two blank lines.  In that case, all items are closed.  Here is an
1042 example:
1044 #+begin_example
1045   ,* Lord of the Rings
1046   My favorite scenes are (in this order)
1047   1. The attack of the Rohirrim
1048   2. Eowyn's fight with the witch king
1049      + this was already my favorite scene in the book
1050      + I really like Miranda Otto.
1051   3. Peter Jackson being shot by Legolas
1052      - on DVD only
1053      He makes a really funny face when it happens.
1054   But in the end, no individual scenes matter but the film as a whole.
1055   Important actors in this film are:
1056   - Elijah Wood :: He plays Frodo
1057   - Sean Astin :: He plays Sam, Frodo's friend. I still remember him
1058        very well from his role as Mikey Walsh in /The Goonies/.
1059 #+end_example
1061 Org supports these lists by tuning filling and wrapping commands to
1062 deal with them correctly, and by exporting them properly (see
1063 [[Exporting]]).  Since indentation is what governs the structure of these
1064 lists, many structural constructs like =#+BEGIN_= blocks can be
1065 indented to signal that they belong to a particular item.
1067 #+vindex: org-list-demote-modify-bullet
1068 #+vindex: org-list-indent-offset
1069 If you find that using a different bullet for a sub-list---than that
1070 used for the current list-level---improves readability, customize the
1071 variable ~org-list-demote-modify-bullet~.  To get a greater difference
1072 of indentation between items and theirs sub-items, customize
1073 ~org-list-indent-offset~.
1075 #+vindex: org-list-automatic-rules
1076 The following commands act on items when the cursor is in the first
1077 line of an item---the line with the bullet or number.  Some of them
1078 imply the application of automatic rules to keep list structure
1079 intact.  If some of these actions get in your way, configure
1080 ~org-list-automatic-rules~ to disable them individually.
1082 #+attr_texinfo: :sep ,
1083 - {{{kbd(TAB)}}} (~org-cycle~) ::
1085      #+cindex: cycling, in plain lists
1086      #+kindex: TAB
1087      #+findex: org-cycle
1088      #+vindex: org-cycle-include-plain-lists
1089      Items can be folded just like headline levels.  Normally this
1090      works only if the cursor is on a plain list item.  For more
1091      details, see the variable ~org-cycle-include-plain-lists~.  If
1092      this variable is set to ~integrate~, plain list items are treated
1093      like low-level headlines.  The level of an item is then given by
1094      the indentation of the bullet/number.  Items are always
1095      subordinate to real headlines, however; the hierarchies remain
1096      completely separated.  In a new item with no text yet, the first
1097      {{{kbd(TAB)}}} demotes the item to become a child of the previous
1098      one.  Subsequent {{{kbd(TAB)}}}s move the item to meaningful
1099      levels in the list and eventually get it back to its initial
1100      position.
1102 - {{{kbd(M-RET)}}} (~org-insert-heading~) ::
1104      #+kindex: M-RET
1105      #+findex: org-insert-heading
1106      #+vindex: org-M-RET-may-split-line
1107      Insert new item at current level.  With a prefix argument, force
1108      a new heading (see [[*Structure Editing]]).  If this command is used
1109      in the middle of an item, that item is /split/ in two, and the
1110      second part becomes the new item[fn:13].  If this command is
1111      executed /before item's body/, the new item is created /before/
1112      the current one.
1114 - {{{kbd(M-S-RET)}}} ::
1116      #+kindex: M-S-RET
1117      Insert a new item with a checkbox (see [[Checkboxes]]).
1119 - {{{kbd(S-up)}}}, {{{kbd(S-down)}}} ::
1121      #+kindex: S-up
1122      #+kindex: S-down
1123      #+cindex: shift-selection-mode
1124      #+vindex: org-support-shift-select
1125      #+vindex: org-list-use-circular-motion
1126      Jump to the previous/next item in the current list, but only if
1127      ~org-support-shift-select~ is off[fn:14].  If not, you can
1128      still use paragraph jumping commands like {{{kbd(C-up)}}}
1129      and {{{kbd(C-down)}}} to quite similar effect.
1131 - {{{kbd(M-up)}}}, {{{kbd(M-down)}}} ::
1133      #+kindex: M-up
1134      #+kindex: M-down
1135      Move the item including subitems up/down[fn:15], i.e., swap with
1136      previous/next item of same indentation.  If the list is ordered,
1137      renumbering is automatic.
1139 - {{{kbd(M-left)}}}, {{{kbd(M-right)}}} ::
1141      #+kindex: M-left
1142      #+kindex: M-right
1143      Decrease/increase the indentation of an item, leaving children
1144      alone.
1146 - {{{kbd(M-S-left)}}}, {{{kbd(M-S-right)}}} ::
1148      #+kindex: M-S-left
1149      #+kindex: M-S-right
1150      Decrease/increase the indentation of the item, including
1151      subitems.  Initially, the item tree is selected based on current
1152      indentation.  When these commands are executed several times in
1153      direct succession, the initially selected region is used, even if
1154      the new indentation would imply a different hierarchy.  To use
1155      the new hierarchy, break the command chain with a cursor motion
1156      or so.
1158      As a special case, using this command on the very first item of
1159      a list moves the whole list.  This behavior can be disabled by
1160      configuring ~org-list-automatic-rules~.  The global indentation
1161      of a list has no influence on the text /after/ the list.
1163 - {{{kbd(C-c C-c)}}} ::
1165      #+kindex: C-c C-c
1166      If there is a checkbox (see [[Checkboxes]]) in the item line, toggle
1167      the state of the checkbox.  In any case, verify bullets and
1168      indentation consistency in the whole list.
1170 - {{{kbd(C-c -)}}} ::
1172      #+kindex: C-c -
1173      #+vindex: org-plain-list-ordered-item-terminator
1174      Cycle the entire list level through the different
1175      itemize/enumerate bullets (=-=, =+=, =*=, =1.=, =1)=) or a subset
1176      of them, depending on ~org-plain-list-ordered-item-terminator~,
1177      the type of list, and its indentation.  With a numeric prefix
1178      argument N, select the Nth bullet from this list.  If there is an
1179      active region when calling this, selected text is changed into an
1180      item.  With a prefix argument, all lines are converted to list
1181      items.  If the first line already was a list item, any item
1182      marker is removed from the list.  Finally, even without an active
1183      region, a normal line is converted into a list item.
1185 - {{{kbd(C-c *)}}} ::
1187      #+kindex: C-c *
1188      Turn a plain list item into a headline---so that it becomes
1189      a subheading at its location.  See [[*Structure Editing]], for
1190      a detailed explanation.
1192 - {{{kbd(C-c C-*)}}} ::
1194      #+kindex: C-c C-*
1195      Turn the whole plain list into a subtree of the current heading.
1196      Checkboxes (see [[*Checkboxes]]) become TODO, respectively DONE,
1197      keywords when unchecked, respectively checked.
1199 - {{{kbd(S-left)}}}, {{{kbd(S-right)}}} ::
1201      #+vindex: org-support-shift-select
1202      #+kindex: S-left
1203      #+kindex: S-right
1204      This command also cycles bullet styles when the cursor in on the
1205      bullet or anywhere in an item line, details depending on
1206      ~org-support-shift-select~.
1208 - {{{kbd(C-c ^)}}} ::
1210      #+kindex: C-c ^
1211      #+cindex: sorting, of plain list
1212      Sort the plain list.  Prompt for the sorting method: numerically,
1213      alphabetically, by time, or by custom function.
1215 ** Drawers
1216 :PROPERTIES:
1217 :DESCRIPTION: Tucking stuff away.
1218 :END:
1219 #+cindex: drawers
1220 #+cindex: visibility cycling, drawers
1222 Sometimes you want to keep information associated with an entry, but
1223 you normally do not want to see it.  For this, Org mode has /drawers/.
1224 They can contain anything but a headline and another drawer.  Drawers
1225 look like this:
1227 #+begin_example
1228   ,** This is a headline
1229   Still outside the drawer
1230   :DRAWERNAME:
1231   This is inside the drawer.
1232   :END:
1233   After the drawer.
1234 #+end_example
1236 #+kindex: C-c C-x d
1237 #+findex: org-insert-drawer
1238 You can interactively insert a drawer at point by calling
1239 ~org-insert-drawer~, which is bound to {{{kbd(C-c C-x d)}}}.  With an
1240 active region, this command puts the region inside the drawer.  With
1241 a prefix argument, this command calls ~org-insert-property-drawer~,
1242 which creates a =PROPERTIES= drawer right below the current headline.
1243 Org mode uses this special drawer for storing properties (see
1244 [[*Properties and Columns]]).  You cannot use it for anything else.
1246 Completion over drawer keywords is also possible using
1247 {{{kbd(M-TAB)}}}[fn:16].
1249 Visibility cycling (see [[*Visibility Cycling]]) on the headline hides and
1250 shows the entry, but keep the drawer collapsed to a single line.  In
1251 order to look inside the drawer, you need to move the cursor to the
1252 drawer line and press {{{kbd(TAB)}}} there.
1254 You can also arrange for state change notes (see [[Tracking TODO state
1255 changes]]) and clock times (see [[*Clocking Work Time]]) to be stored in
1256 a =LOGBOOK= drawer.  If you want to store a quick note there, in
1257 a similar way to state changes, use
1259 - {{{kbd(C-c C-z)}}} ::
1261      #+kindex: C-c C-z
1262      Add a time-stamped note to the =LOGBOOK= drawer.
1264 ** Blocks
1265 :PROPERTIES:
1266 :DESCRIPTION: Folding blocks.
1267 :END:
1268 #+vindex: org-hide-block-startup
1269 #+cindex: blocks, folding
1271 Org mode uses =#+BEGIN= ... =#+END= blocks for various purposes from
1272 including source code examples (see [[*Literal Examples]]) to capturing
1273 time logging information (see [[*Clocking Work Time]]).  These blocks can
1274 be folded and unfolded by pressing {{{kbd(TAB)}}} in the =#+BEGIN=
1275 line.  You can also get all blocks folded at startup by configuring
1276 the variable ~org-hide-block-startup~ or on a per-file basis by using
1278 #+cindex: STARTUP, keyword
1279 #+begin_example
1280   ,#+STARTUP: hideblocks
1281   ,#+STARTUP: nohideblocks
1282 #+end_example
1284 ** Creating Footnotes
1285 :PROPERTIES:
1286 :DESCRIPTION: How footnotes are defined in Org's syntax.
1287 :END:
1288 #+cindex: footnotes
1290 Org mode supports the creation of footnotes.
1292 A footnote is started by a footnote marker in square brackets in
1293 column 0, no indentation allowed.  It ends at the next footnote
1294 definition, headline, or after two consecutive empty lines.  The
1295 footnote reference is simply the marker in square brackets, inside
1296 text.  Markers always start with =fn:=.  For example:
1298 #+begin_example
1299   The Org homepage[fn:1] now looks a lot better than it used to.
1300   ...
1301   [fn:1] The link is: https://orgmode.org
1302 #+end_example
1304 Org mode extends the number-based syntax to /named/ footnotes and
1305 optional inline definition.  Here are the valid references:
1307 - =[fn:NAME]= ::
1309      A named footnote reference, where {{{var(NAME)}}} is a unique
1310      label word, or, for simplicity of automatic creation, a number.
1312 - =[fn:: This is the inline definition of this footnote]= ::
1314      A LaTeX-like anonymous footnote where the definition is given
1315      directly at the reference point.
1317 - =[fn:NAME: a definition]= ::
1319      An inline definition of a footnote, which also specifies a name
1320      for the note.  Since Org allows multiple references to the same
1321      note, you can then use =[fn:NAME]= to create additional
1322      references.
1324 #+vindex: org-footnote-auto-label
1325 Footnote labels can be created automatically, or you can create names
1326 yourself.  This is handled by the variable ~org-footnote-auto-label~
1327 and its corresponding =STARTUP= keywords.  See the docstring of that
1328 variable for details.
1330 #+texinfo: @noindent
1331 The following command handles footnotes:
1333 - {{{kbd(C-c C-x f)}}} ::
1335      The footnote action command.
1337      #+kindex: C-c C-x f
1338      When the cursor is on a footnote reference, jump to the
1339      definition.  When it is at a definition, jump to
1340      the---first---reference.
1342      #+vindex: org-footnote-define-inline
1343      #+vindex: org-footnote-section
1344      Otherwise, create a new footnote.  Depending on the variable
1345      ~org-footnote-define-inline~[fn:17], the definition is placed
1346      right into the text as part of the reference, or separately into
1347      the location determined by the variable ~org-footnote-section~.
1349      When this command is called with a prefix argument, a menu of
1350      additional options is offered:
1352      #+attr_texinfo: :columns 0.1 0.9
1353      | {{{kbd(s)}}} | Sort the footnote definitions by reference sequence.               |
1354      | {{{kbd(r)}}} | Renumber the simple =fn:N= footnotes.                              |
1355      | {{{kbd(S)}}} | Short for first {{{kbd(r)}}}, then {{{kbd(s)}}} action.            |
1356      | {{{kbd(n)}}} | Rename all footnotes into a =fn:1= ... =fn:n= sequence.            |
1357      | {{{kbd(d)}}} | Delete the footnote at point, including definition and references. |
1359      #+vindex: org-footnote-auto-adjust
1360      Depending on the variable ~org-footnote-auto-adjust~[fn:18],
1361      renumbering and sorting footnotes can be automatic after each
1362      insertion or deletion.
1364 - {{{kbd(C-c C-c)}}} ::
1366      #+kindex: C-c C-c
1367      If the cursor is on a footnote reference, jump to the definition.
1368      If it is at the definition, jump back to the reference.  When
1369      called at a footnote location with a prefix argument, offer the
1370      same menu as {{{kbd(C-c C-x f)}}}.
1372 - {{{kbd(C-c C-o)}}} or {{{kbd(mouse-1/2)}}} ::
1374      #+kindex: C-c C-o
1375      #+kindex: mouse-1
1376      #+kindex: mouse-2
1377      Footnote labels are also links to the corresponding definition or
1378      reference, and you can use the usual commands to follow these
1379      links.
1381 ** Org Syntax
1382 :PROPERTIES:
1383 :DESCRIPTION: Formal description of Org's syntax.
1384 :END:
1386 A reference document providing a formal description of Org's syntax is
1387 available as [[https://orgmode.org/worg/dev/org-syntax.html][a draft on Worg]], written and maintained by Nicolas
1388 Goaziou.  It defines Org's core internal concepts such as =headlines=,
1389 =sections=, =affiliated keywords=, =(greater) elements= and =objects=.
1390 Each part of an Org file falls into one of the categories above.
1392 To explore the abstract structure of an Org buffer, run this in
1393 a buffer:
1395 : M-: (org-element-parse-buffer) <RET>
1397 #+texinfo: @noindent
1398 It outputs a list containing the buffer's content represented as an
1399 abstract structure.  The export engine relies on the information
1400 stored in this list.  Most interactive commands---e.g., for structure
1401 editing---also rely on the syntactic meaning of the surrounding
1402 context.
1404 #+cindex: syntax checker
1405 #+cindex: linter
1406 #+findex: org-lint
1407 You can check syntax in your documents using ~org-lint~ command.
1409 * Tables
1410 :PROPERTIES:
1411 :DESCRIPTION: Pure magic for quick formatting.
1412 :END:
1413 #+cindex: tables
1414 #+cindex: editing tables
1416 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1417 calculations are supported using the Emacs Calc package (see
1418 [[info:calc]]).
1420 ** Built-in Table Editor
1421 :PROPERTIES:
1422 :DESCRIPTION: Simple tables.
1423 :END:
1424 #+cindex: table editor, built-in
1426 Org makes it easy to format tables in plain ASCII.  Any line with =|=
1427 as the first non-whitespace character is considered part of a table.
1428 =|= is also the column separator[fn:19].  A table might look like
1429 this:
1431 #+begin_example
1432   | Name  | Phone | Age |
1433   |-------+-------+-----|
1434   | Peter |  1234 |  17 |
1435   | Anna  |  4321 |  25 |
1436 #+end_example
1438 A table is re-aligned automatically each time you press
1439 {{{kbd(TAB)}}}, {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} inside the table.
1440 {{{kbd(TAB)}}} also moves to the next field---{{{kbd(RET)}}} to the
1441 next row---and creates new table rows at the end of the table or
1442 before horizontal lines.  The indentation of the table is set by the
1443 first line.  Any line starting with =|-= is considered as a horizontal
1444 separator line and will be expanded on the next re-align to span the
1445 whole table width.  So, to create the above table, you would only type
1447 #+begin_example
1448   |Name|Phone|Age|
1449   |-
1450 #+end_example
1452 #+texinfo: @noindent
1453 and then press {{{kbd(TAB)}}} to align the table and start filling in
1454 fields.  Even faster would be to type =|Name|Phone|Age= followed by
1455 {{{kbd(C-c RET)}}}.
1457 When typing text into a field, Org treats {{{kbd(DEL)}}},
1458 {{{kbd(Backspace)}}}, and all character keys in a special way, so that
1459 inserting and deleting avoids shifting other fields.  Also, when
1460 typing /immediately/ after the cursor was moved into a new field with
1461 {{{kbd(TAB)}}}, {{{kbd(S-TAB)}}} or {{{kbd(RET)}}}, the field is
1462 automatically made blank.  If this behavior is too unpredictable for
1463 you, configure the option ~org-table-auto-blank-field~.
1465 *** Creation and conversion
1466 :PROPERTIES:
1467 :UNNUMBERED: notoc
1468 :END:
1470 - {{{kbd(C-c |)}}} (~org-table-create-or-convert-from-region~) ::
1472      #+kindex: C-c |
1473      #+findex: org-table-create-or-convert-from-region
1474      Convert the active region to table.  If every line contains at
1475      least one {{{kbd(TAB)}}} character, the function assumes that the
1476      material is tab separated.  If every line contains a comma,
1477      comma-separated values (CSV) are assumed.  If not, lines are
1478      split at whitespace into fields.  You can use a prefix argument
1479      to force a specific separator: {{{kbd(C-u)}}} forces CSV,
1480      {{{kbd(C-u C-u)}}} forces {{{kbd(TAB)}}}, {{{kbd(C-u C-u C-u)}}}
1481      prompts for a regular expression to match the separator, and
1482      a numeric argument N indicates that at least N consecutive
1483      spaces, or alternatively a {{{kbd(TAB)}}} will be the separator.
1485      If there is no active region, this command creates an empty Org
1486      table.  But it is easier just to start typing, like {{{kbd(|
1487      N a m e | P h o n e | A g e RET | - TAB)}}}.
1489 *** Re-aligning and field motion
1490 :PROPERTIES:
1491 :UNNUMBERED: notoc
1492 :END:
1494 - {{{kbd(C-c C-c)}}} (~org-table-align~) ::
1496      #+kindex: C-c C-c
1497      #+findex: org-table-align
1498      Re-align the table without moving the cursor.
1500 - {{{kbd(TAB)}}} (~org-table-next-field~) ::
1502      #+kindex: TAB
1503      #+findex: org-table-next-field
1504      Re-align the table, move to the next field.  Creates a new row if
1505      necessary.
1507 - {{{kbd(C-c SPC)}}} (~org-table-blank-field~) ::
1509      #+kindex: C-c SPC
1510      #+findex: org-table-blank-field
1511      Blank the field at point.
1513 - {{{kbd(S-TAB)}}} (~org-table-previous-field~) ::
1515      #+kindex: S-TAB
1516      #+findex: org-table-previous-field
1517      Re-align, move to previous field.
1519 - {{{kbd(RET)}}} (~org-table-next-row~) ::
1521      #+kindex: RET
1522      #+findex: org-table-next-row
1523      Re-align the table and move down to next row.  Creates a new row
1524      if necessary.  At the beginning or end of a line, {{{kbd(RET)}}}
1525      still inserts a new line, so it can be used to split a table.
1527 - {{{kbd(M-a)}}} (~org-table-beginning-of-field~) ::
1529      #+kindex: M-a
1530      #+findex: org-table-beginning-of-field
1531      Move to beginning of the current table field, or on to the
1532      previous field.
1534 - {{{kbd(M-e)}}} (~org-table-end-of-field~) ::
1536      #+kindex: M-e
1537      #+findex: org-table-end-of-field
1538      Move to end of the current table field, or on to the next field.
1540 *** Column and row editing
1541 :PROPERTIES:
1542 :UNNUMBERED: notoc
1543 :END:
1545 - {{{kbd(M-left)}}} (~org-table-move-column-left~) ::
1547      #+kindex: M-left
1548      #+findex: org-table-move-column-left
1549      Move the current column left.
1551 - {{{kbd(M-right)}}} (~org-table-move-column-right~) ::
1553      #+kindex: M-right
1554      #+findex: org-table-move-column-right
1555      Move the current column right.
1557 - {{{kbd(M-S-left)}}} (~org-table-delete-column~) ::
1559      #+kindex: M-S-left
1560      #+findex: org-table-delete-column
1561      Kill the current column.
1563 - {{{kbd(M-S-right)}}} (~org-table-insert-column~) ::
1565      #+kindex: M-S-right
1566      #+findex: org-table-insert-column
1567      Insert a new column to the left of the cursor position.
1569 - {{{kbd(M-up)}}} (~org-table-move-row-up~) ::
1571      #+kindex: M-up
1572      #+findex: org-table-move-row-up
1573      Move the current row up.
1575 - {{{kbd(M-down)}}} (~org-table-move-row-down~) ::
1577      #+kindex: M-down
1578      #+findex: org-table-move-row-down
1579      Move the current row down.
1581 - {{{kbd(M-S-up)}}} (~org-table-kill-row~) ::
1583      #+kindex: M-S-up
1584      #+findex: org-table-kill-row
1585      Kill the current row or horizontal line.
1587 - {{{kbd(M-S-down)}}} (~org-table-insert-row~) ::
1589      #+kindex: M-S-down
1590      #+findex: org-table-insert-row
1591      Insert a new row above the current row.  With a prefix argument,
1592      the line is created below the current one.
1594 - {{{kbd(C-c -)}}} (~org-table-insert-hline~) ::
1596      #+kindex: C-c -
1597      #+findex: org-table-insert-hline
1598      Insert a horizontal line below current row.  With a prefix
1599      argument, the line is created above the current line.
1601 - {{{kbd(C-c RET)}}} (~org-table-hline-and-move~) ::
1603      #+kindex: C-c RET
1604      #+findex: org-table-hline-and-move
1605      Insert a horizontal line below current row, and move the cursor
1606      into the row below that line.
1608 - {{{kbd(C-c ^)}}} (~org-table-sort-lines~) ::
1610      #+kindex: C-c ^
1611      #+findex: org-table-sort-lines
1612      Sort the table lines in the region.  The position of point
1613      indicates the column to be used for sorting, and the range of
1614      lines is the range between the nearest horizontal separator
1615      lines, or the entire table.  If point is before the first column,
1616      you are prompted for the sorting column.  If there is an active
1617      region, the mark specifies the first line and the sorting column,
1618      while point should be in the last line to be included into the
1619      sorting.  The command prompts for the sorting type,
1620      alphabetically, numerically, or by time.  You can sort in normal
1621      or reverse order.  You can also supply your own key extraction
1622      and comparison functions.  When called with a prefix argument,
1623      alphabetic sorting is case-sensitive.
1625 *** Regions
1626 :PROPERTIES:
1627 :UNNUMBERED: notoc
1628 :END:
1630 - {{{kbd(C-c C-x M-w)}}} (~org-table-copy-region~) ::
1632      #+kindex: C-c C-x M-w
1633      #+findex: org-table-copy-region
1634      Copy a rectangular region from a table to a special clipboard.
1635      Point and mark determine edge fields of the rectangle.  If there
1636      is no active region, copy just the current field.  The process
1637      ignores horizontal separator lines.
1639 - {{{kbd(C-c C-x C-w)}}} (~org-table-cut-region~) ::
1641      #+kindex: C-c C-x C-w
1642      #+findex: org-table-cut-region
1643      Copy a rectangular region from a table to a special clipboard,
1644      and blank all fields in the rectangle.  So this is the "cut"
1645      operation.
1647 - {{{kbd(C-c C-x C-y)}}} (~org-table-paste-rectangle~) ::
1649      #+kindex: C-c C-x C-y
1650      #+findex: org-table-paste-rectangle
1651      Paste a rectangular region into a table.  The upper left corner
1652      ends up in the current field.  All involved fields are
1653      overwritten.  If the rectangle does not fit into the present
1654      table, the table is enlarged as needed.  The process ignores
1655      horizontal separator lines.
1657 - {{{kbd(M-RET)}}} (~org-table-wrap-region~) ::
1659      #+kindex: M-RET
1660      #+findex: org-table-wrap-region
1661      Split the current field at the cursor position and move the rest
1662      to the line below.  If there is an active region, and both point
1663      and mark are in the same column, the text in the column is
1664      wrapped to minimum width for the given number of lines.
1665      A numeric prefix argument may be used to change the number of
1666      desired lines.  If there is no region, but you specify a prefix
1667      argument, the current field is made blank, and the content is
1668      appended to the field above.
1670 *** Calculations
1671 :PROPERTIES:
1672 :UNNUMBERED: notoc
1673 :END:
1675 #+cindex: formula, in tables
1676 #+cindex: calculations, in tables
1678 - {{{kbd(C-c +)}}} (~org-table-sum~) ::
1680      #+kindex: C-c +
1681      #+findex: org-table-sum
1682      Sum the numbers in the current column, or in the rectangle
1683      defined by the active region.  The result is shown in the echo
1684      area and can be inserted with {{{kbd(C-y)}}}.
1686 - {{{kbd(S-RET)}}} (~org-table-copy-down~) ::
1688      #+kindex: S-RET
1689      #+findex: org-table-copy-down
1690      #+vindex: org-table-copy-increment
1691      When current field is empty, copy from first non-empty field
1692      above.  When not empty, copy current field down to next row and
1693      move cursor along with it.  Depending on the variable
1694      ~org-table-copy-increment~, integer field values can be
1695      incremented during copy.  Integers that are too large are not
1696      incremented, however.  Also, a ~0~ prefix argument temporarily
1697      disables the increment.  This key is also used by shift-selection
1698      and related modes (see [[*Packages that conflict with Org mode]]).
1700 *** Miscellaneous
1701 :PROPERTIES:
1702 :UNNUMBERED: notoc
1703 :END:
1705 - {{{kbd(C-c `)}}} (~org-table-edit-field~) ::
1707      #+kindex: C-c `
1708      #+findex: org-table-edit-field
1709      Edit the current field in a separate window.  This is useful for
1710      fields that are not fully visible (see [[*Column Width and
1711      Alignment]]).  When called with a {{{kbd(C-u)}}} prefix, just make
1712      the full field visible, so that it can be edited in place.  When
1713      called with two {{{kbd(C-u)}}} prefixes, make the editor window
1714      follow the cursor through the table and always show the current
1715      field.  The follow mode exits automatically when the cursor
1716      leaves the table, or when you repeat this command with {{{kbd(C-u
1717      C-u C-c `)}}}.
1719 - {{{kbd(M-x org-table-import)}}} ::
1721      #+findex: org-table-import
1722      Import a file as a table.  The table should be TAB or whitespace
1723      separated.  Use, for example, to import a spreadsheet table or
1724      data from a database, because these programs generally can write
1725      TAB-separated text files.  This command works by inserting the
1726      file into the buffer and then converting the region to a table.
1727      Any prefix argument is passed on to the converter, which uses it
1728      to determine the separator.
1730 - {{{kbd(C-c |)}}} (~org-table-create-or-convert-from-region~) ::
1732      #+kindex: C-c |
1733      #+findex: org-table-create-or-convert-from-region
1734      Tables can also be imported by pasting tabular text into the Org
1735      buffer, selecting the pasted text with {{{kbd(C-x C-x)}}} and
1736      then using the {{{kbd(C-c |)}}} command (see [[*Creation and
1737      conversion]]).
1739 - {{{kbd(M-x org-table-export)}}} ::
1741      #+findex: org-table-export
1742      #+vindex: org-table-export-default-format
1743      Export the table, by default as a TAB-separated file.  Use for
1744      data exchange with, for example, spreadsheet or database
1745      programs.  The format used to export the file can be configured
1746      in the variable ~org-table-export-default-format~.  You may also
1747      use properties =TABLE_EXPORT_FILE= and =TABLE_EXPORT_FORMAT= to
1748      specify the file name and the format for table export in
1749      a subtree.  Org supports quite general formats for exported
1750      tables.  The exporter format is the same as the format used by
1751      Orgtbl radio tables, see [[*Translator functions]], for a detailed
1752      description.
1754 ** Column Width and Alignment
1755 :PROPERTIES:
1756 :DESCRIPTION: Overrule the automatic settings.
1757 :END:
1758 #+cindex: narrow columns in tables
1759 #+cindex: alignment in tables
1761 The width of columns is automatically determined by the table editor.
1762 The alignment of a column is determined automatically from the
1763 fraction of number-like versus non-number fields in the column.
1765 #+vindex: org-table-automatic-realign
1766 Editing a field may modify alignment of the table.  Moving
1767 a contiguous row or column---i.e., using {{{kbd(TAB)}}} or
1768 {{{kbd(RET)}}}---automatically re-aligns it.  If you want to disable
1769 this behavior, set ~org-table-automatic-realign~ to ~nil~.  In any
1770 case, you can always align manually a table:
1772 - {{{kbd(C-c C-c)}}} (~org-table-align~) ::
1774      #+kindex: C-c C-c
1775      #+findex: org-table-align
1776      Align the current table.
1778 #+texinfo: @noindent
1779 #+vindex: org-startup-align-all-tables
1780 Setting the option ~org-startup-align-all-tables~ re-aligns all tables
1781 in a file upon visiting it.  You can also set this option on
1782 a per-file basis with:
1784 #+begin_example
1785   ,#+STARTUP: align
1786   ,#+STARTUP: noalign
1787 #+end_example
1789 Sometimes a single field or a few fields need to carry more text,
1790 leading to inconveniently wide columns.  Maybe you want to hide away
1791 several columns or display them with a fixed width, regardless of
1792 content, as shown in the following example.
1794 #+begin_example
1795   |---+---------------------+--------|           |---+-------…|…|
1796   |   | <6>                 |        |           |   | <6>   â€¦|…|
1797   | 1 | one                 | some   |   ----\   | 1 | one   â€¦|…|
1798   | 2 | two                 | boring |   ----/   | 2 | two   â€¦|…|
1799   | 3 | This is a long text | column |           | 3 | This i…|…|
1800   |---+---------------------+--------|           |---+-------…|…|
1801 #+end_example
1803 To set the width of a column, one field anywhere in the column may
1804 contain just the string =<N>= where {{{var(N)}}} specifies the width
1805 as a number of characters.  You control displayed width of columns
1806 with the following tools:
1808 - {{{kbd(C-c TAB)}}} (~org-table-toggle-column-width~) ::
1810      #+kindex: C-c TAB
1811      #+findex: org-table-toggle-column-width
1812      Shrink or expand current column.
1814      If a width cookie specifies a width W for the column, shrinking
1815      it displays the first W visible characters only.  Otherwise, the
1816      column is shrunk to a single character.
1818      When called before the first column or after the last one, ask
1819      for a list of column ranges to operate on.
1821 - {{{kbd(C-u C-c TAB)}}} (~org-table-shrink~) ::
1823      #+kindex: C-u C-c TAB
1824      #+findex: org-table-shrink
1825      Shrink all columns with a column width.  Expand the others.
1827 - {{{kbd(C-u C-u C-c TAB)}}} (~org-table-expand~) ::
1829      #+kindex: C-u C-u C-c TAB
1830      #+findex: org-table-expand
1831      Expand all columns.
1833 To see the full text of a shrunk field, hold the mouse over it---a
1834 tool-tip window then shows the full content.  Alternatively {{{kbd(C-h
1835 .)}}}  (~display-local-help~) reveals the full content.  For
1836 convenience, any change to a shrunk column expands it.
1838 #+vindex: org-startup-shrink-all-tables
1839 Setting the option ~org-startup-shrink-all-tables~ shrinks all columns
1840 containing a width cookie in a file the moment it is visited.  You can
1841 also set this option on a per-file basis with:
1843 : #+STARTUP: shrink
1845 If you would like to overrule the automatic alignment of number-rich
1846 columns to the right and of string-rich columns to the left, you can
1847 use =<r>=, =<c>= or =<l>= in a similar fashion.  You may also combine
1848 alignment and field width like this: =<r10>=.
1850 Lines which only contain these formatting cookies are removed
1851 automatically upon exporting the document.
1853 ** Column Groups
1854 :PROPERTIES:
1855 :DESCRIPTION: Grouping to trigger vertical lines.
1856 :END:
1857 #+cindex: grouping columns in tables
1859 When Org exports tables, it does so by default without vertical lines
1860 because that is visually more satisfying in general.  Occasionally
1861 however, vertical lines can be useful to structure a table into groups
1862 of columns, much like horizontal lines can do for groups of rows.  In
1863 order to specify column groups, you can use a special row where the
1864 first field contains only =/=.  The further fields can either contain
1865 =<= to indicate that this column should start a group, =>= to indicate
1866 the end of a column, or =<>= (no space between =<= and =>=) to make
1867 a column a group of its own.  Upon export, boundaries between column
1868 groups are marked with vertical lines.  Here is an example:
1870 #+begin_example
1871   | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1872   |---+-----+-----+-----+---------+------------|
1873   | / |  <  |     |  >  |       < |          > |
1874   | 1 |  1  |  1  |  1  |       1 |          1 |
1875   | 2 |  4  |  8  | 16  |  1.4142 |     1.1892 |
1876   | 3 |  9  | 27  | 81  |  1.7321 |     1.3161 |
1877   |---+-----+-----+-----+---------+------------|
1878   ,#+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
1879 #+end_example
1881 It is also sufficient to just insert the column group starters after
1882 every vertical line you would like to have:
1884 #+begin_example
1885   | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1886   |---+-----+-----+-----+---------+------------|
1887   | / | <   |     |     | <       |            |
1888 #+end_example
1890 ** The Orgtbl Minor Mode
1891 :PROPERTIES:
1892 :DESCRIPTION: The table editor as minor mode.
1893 :ALT_TITLE: Orgtbl Mode
1894 :END:
1895 #+cindex: Orgtbl mode
1896 #+cindex: minor mode for tables
1898 #+findex: orgtbl-mode
1899 If you like the intuitive way the Org table editor works, you might
1900 also want to use it in other modes like Text mode or Mail mode.  The
1901 minor mode Orgtbl mode makes this possible.  You can always toggle the
1902 mode with {{{kbd(M-x orgtbl-mode)}}}.  To turn it on by default, for
1903 example in Message mode, use
1905 #+begin_src emacs-lisp
1906   (add-hook 'message-mode-hook 'turn-on-orgtbl)
1907 #+end_src
1909 Furthermore, with some special setup, it is possible to maintain
1910 tables in arbitrary syntax with Orgtbl mode.  For example, it is
1911 possible to construct LaTeX tables with the underlying ease and power
1912 of Orgtbl mode, including spreadsheet capabilities.  For details, see
1913 [[*Tables in Arbitrary Syntax]].
1915 ** The spreadsheet
1916 :PROPERTIES:
1917 :DESCRIPTION: The table editor has spreadsheet capabilities.
1918 :END:
1919 #+cindex: calculations, in tables
1920 #+cindex: spreadsheet capabilities
1921 #+cindex: Calc package
1923 The table editor makes use of the Emacs Calc package to implement
1924 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms
1925 to derive fields from other fields.  While fully featured, Org's
1926 implementation is not identical to other spreadsheets.  For example,
1927 Org knows the concept of a /column formula/ that will be applied to
1928 all non-header fields in a column without having to copy the formula
1929 to each relevant field.  There is also a formula debugger, and
1930 a formula editor with features for highlighting fields in the table
1931 corresponding to the references at the point in the formula, moving
1932 these references by arrow keys.
1934 *** References
1935 :PROPERTIES:
1936 :DESCRIPTION: How to refer to another field or range.
1937 :END:
1938 #+cindex: references
1940 To compute fields in the table from other fields, formulas must
1941 reference other fields or ranges.  In Org, fields can be referenced by
1942 name, by absolute coordinates, and by relative coordinates.  To find
1943 out what the coordinates of a field are, press {{{kbd(C-c ?)}}} in
1944 that field, or press {{{kbd(C-c })}}} to toggle the display of a grid.
1946 **** Field references
1947 :PROPERTIES:
1948 :UNNUMBERED: notoc
1949 :END:
1951 #+cindex: field references
1952 #+cindex: references, to fields
1953 Formulas can reference the value of another field in two ways.  Like
1954 in any other spreadsheet, you may reference fields with
1955 a letter/number combination like =B3=, meaning the second field in the
1956 third row.  However, Org prefers to use another, more general
1957 representation that looks like this:[fn:20]
1959 : @ROW$COLUMN
1961 Column specifications can be absolute like =$1=, =$2=, ..., =$N=, or
1962 relative to the current column, i.e., the column of the field which is
1963 being computed, like =$+1= or =$-2=.  =$<= and =$>= are immutable
1964 references to the first and last column, respectively, and you can use
1965 =$>>>= to indicate the third column from the right.
1967 The row specification only counts data lines and ignores horizontal
1968 separator lines, or "hlines".  Like with columns, you can use absolute
1969 row numbers =@1=, =@2=, ..., =@N=, and row numbers relative to the
1970 current row like =@+3= or =@-1=.  =@<= and =@>= are immutable
1971 references the first and last row in the table, respectively.  You may
1972 also specify the row relative to one of the hlines: =@I= refers to the
1973 first hline, =@II= to the second, etc.  =@-I= refers to the first such
1974 line above the current line, =@+I= to the first such line below the
1975 current line.  You can also write =@III+2= which is the second data
1976 line after the third hline in the table.
1978 =@0= and =$0= refer to the current row and column, respectively, i.e.,
1979 to the row/column for the field being computed.  Also, if you omit
1980 either the column or the row part of the reference, the current
1981 row/column is implied.
1983 Org's references with /unsigned/ numbers are fixed references in the
1984 sense that if you use the same reference in the formula for two
1985 different fields, the same field is referenced each time.  Org's
1986 references with /signed/ numbers are floating references because the
1987 same reference operator can reference different fields depending on
1988 the field being calculated by the formula.
1990 Here are a few examples:
1992 #+attr_texinfo: :columns 0.2 0.8
1993 | =@2$3=   | 2nd row, 3rd column (same as =C2=)                 |
1994 | =$5=     | column 5 in the current row (same as =E&=)         |
1995 | =@2=     | current column, row 2                              |
1996 | =@-1$-3= | field one row up, three columns to the left        |
1997 | =@-I$2=  | field just under hline above current row, column 2 |
1998 | =@>$5=   | field in the last row, in column 5                 |
2000 **** Range references
2001 :PROPERTIES:
2002 :UNNUMBERED: notoc
2003 :END:
2005 #+cindex: range references
2006 #+cindex: references, to ranges
2007 You may reference a rectangular range of fields by specifying two
2008 field references connected by two dots =..=.  If both fields are in
2009 the current row, you may simply use =$2..$7=, but if at least one
2010 field is in a different row, you need to use the general =@ROW$COLUMN=
2011 format at least for the first field, i.e., the reference must start
2012 with =@= in order to be interpreted correctly.  Examples:
2014 #+attr_texinfo: :columns 0.2 0.8
2015 | =$1..$3=      | first three fields in the current row                          |
2016 | =$P..$Q=      | range, using column names (see [[*Advanced features]])             |
2017 | =$<<<..$>>=   | start in third column, continue to the last but one            |
2018 | =@2$1..@4$3=  | six fields between these two fields (same as =A2..C4=)         |
2019 | =@-1$-2..@-1= | 3 fields in the row above, starting from 2 columns on the left |
2020 | =@I..II=      | between first and second hline, short for =@I..@II=            |
2022 #+texinfo: @noindent
2023 Range references return a vector of values that can be fed into Calc
2024 vector functions.  Empty fields in ranges are normally suppressed, so
2025 that the vector contains only the non-empty fields.  For other options
2026 with the mode switches =E=, =N= and examples, see [[*Formula syntax for
2027 Calc]].
2029 **** Field coordinates in formulas
2030 :PROPERTIES:
2031 :UNNUMBERED: notoc
2032 :END:
2034 #+cindex: field coordinates
2035 #+cindex: coordinates, of field
2036 #+cindex: row, of field coordinates
2037 #+cindex: column, of field coordinates
2038 #+vindex: org-table-current-column
2039 #+vindex: org-table-current-dline
2040 One of the very first actions during evaluation of Calc formulas and
2041 Lisp formulas is to substitute =@#= and =$#= in the formula with the
2042 row or column number of the field where the current result will go to.
2043 The traditional Lisp formula equivalents are ~org-table-current-dline~
2044 and ~org-table-current-column~.  Examples:
2046 - =if(@# % 2, $#, string(""))= ::
2048      Insert column number on odd rows, set field to empty on even
2049      rows.
2051 - =$2 = '(identity remote(FOO, @@#$1))= ::
2053      Copy text or values of each row of column 1 of the table named
2054      {{{var(FOO)}}} into column 2 of the current table.
2056 - =@3 = 2 * remote(FOO, @@1$$#)= ::
2058      Insert the doubled value of each column of row 1 of the table
2059      named {{{var(FOO)}}} into row 3 of the current table.
2061 #+texinfo: @noindent
2062 For the second and third examples, table {{{var(FOO)}}} must have at
2063 least as many rows or columns as the current table.  Note that this is
2064 inefficient[fn:21] for large number of rows.
2066 **** Named references
2067 :PROPERTIES:
2068 :UNNUMBERED: notoc
2069 :END:
2070 #+cindex: named references
2071 #+cindex: references, named
2072 #+cindex: name, of column or field
2073 #+cindex: constants, in calculations
2074 #+cindex: CONSTANTS, keyword
2075 #+vindex: org-table-formula-constants
2077 =$name= is interpreted as the name of a column, parameter or constant.
2078 Constants are defined globally through the variable
2079 ~org-table-formula-constants~, and locally---for the file---through
2080 a line like this example:
2082 : #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2084 #+texinfo: @noindent
2085 #+vindex: constants-unit-system
2086 #+pindex: constants.el
2087 Also, properties (see [[*Properties and Columns]]) can be used as
2088 constants in table formulas: for a property =Xyz= use the name
2089 =$PROP_Xyz=, and the property will be searched in the current outline
2090 entry and in the hierarchy above it.  If you have the =constants.el=
2091 package, it will also be used to resolve constants, including natural
2092 constants like =$h= for Planck's constant, and units like =$km= for
2093 kilometers[fn:22].  Column names and parameters can be specified in
2094 special table lines.  These are described below, see [[*Advanced
2095 features]].  All names must start with a letter, and further consist of
2096 letters and numbers.
2098 **** Remote references
2099 :PROPERTIES:
2100 :UNNUMBERED: notoc
2101 :END:
2103 #+cindex: remote references
2104 #+cindex: references, remote
2105 #+cindex: references, to a different table
2106 #+cindex: name, of column or field
2107 #+cindex: constants, in calculations
2108 #+cindex: NAME, keyword
2109 You may also reference constants, fields and ranges from a different
2110 table, either in the current file or even in a different file.  The
2111 syntax is
2113 : remote(NAME,REF)
2115 #+texinfo: @noindent
2116 where {{{var(NAME)}}} can be the name of a table in the current file
2117 as set by a =#+NAME:= line before the table.  It can also be the ID of
2118 an entry, even in a different file, and the reference then refers to
2119 the first table in that entry.  {{{var(REF)}}} is an absolute field or
2120 range reference as described above for example =@3$3= or =$somename=,
2121 valid in the referenced table.
2123 #+cindex: table indirection
2124 When {{{var(NAME)}}} has the format =@ROW$COLUMN=, it is substituted
2125 with the name or ID found in this field of the current table.  For
2126 example =remote($1, @@>$2)= \Rightarrow =remote(year_2013, @@>$1)=.  The format
2127 =B3= is not supported because it can not be distinguished from a plain
2128 table name or ID.
2130 *** Formula syntax for Calc
2131 :PROPERTIES:
2132 :DESCRIPTION: Using Calc to compute stuff.
2133 :END:
2134 #+cindex: formula syntax, Calc
2135 #+cindex: syntax, of formulas
2137 A formula can be any algebraic expression understood by the Emacs
2138 =Calc= package. Note that =calc= has the non-standard convention that
2139 =/= has lower precedence than =*=, so that =a/b*c= is interpreted as
2140 =(a/(b*c))=.  Before evaluation by ~calc-eval~ (see [[info:calc#Calling Calc from Your Programs][Calling Calc from
2141 Your Lisp Programs]]), variable substitution takes place according to
2142 the rules described above.
2144 #+cindex: vectors, in table calculations
2145 The range vectors can be directly fed into the Calc vector functions
2146 like ~vmean~ and ~vsum~.
2148 #+cindex: format specifier, in spreadsheet
2149 #+cindex: mode, for Calc
2150 #+vindex: org-calc-default-modes
2151 A formula can contain an optional mode string after a semicolon.  This
2152 string consists of flags to influence Calc and other modes during
2153 execution.  By default, Org uses the standard Calc modes (precision
2154 12, angular units degrees, fraction and symbolic modes off).  The
2155 display format, however, has been changed to ~(float 8)~ to keep
2156 tables compact.  The default settings can be configured using the
2157 variable ~org-calc-default-modes~.
2159 - =p20= ::
2161      Set the internal Calc calculation precision to 20 digits.
2163 - =n3=, =s3=, =e2=, =f4= ::
2165      Normal, scientific, engineering or fixed format of the result of
2166      Calc passed back to Org.  Calc formatting is unlimited in
2167      precision as long as the Calc calculation precision is greater.
2169 - =D=, =R= ::
2171      Degree and radian angle modes of Calc.
2173 - =F=, =S= ::
2175      Fraction and symbolic modes of Calc.
2177 - =T=, =t=, =U= ::
2179      Duration computations in Calc or Lisp, [[*Durations and time
2180      values]].
2182 - =E= ::
2184      If and how to consider empty fields.  Without =E= empty fields in
2185      range references are suppressed so that the Calc vector or Lisp
2186      list contains only the non-empty fields.  With =E= the empty
2187      fields are kept.  For empty fields in ranges or empty field
2188      references the value =nan= (not a number) is used in Calc
2189      formulas and the empty string is used for Lisp formulas.  Add =N=
2190      to use 0 instead for both formula types.  For the value of
2191      a field the mode =N= has higher precedence than =E=.
2193 - =N= ::
2195      Interpret all fields as numbers, use 0 for non-numbers.  See the
2196      next section to see how this is essential for computations with
2197      Lisp formulas.  In Calc formulas it is used only occasionally
2198      because there number strings are already interpreted as numbers
2199      without =N=.
2201 - =L= ::
2203      Literal, for Lisp formulas only.  See the next section.
2205 #+texinfo: @noindent
2206 Unless you use large integer numbers or high-precision calculation and
2207 display for floating point numbers you may alternatively provide
2208 a ~printf~ format specifier to reformat the Calc result after it has
2209 been passed back to Org instead of letting Calc already do the
2210 formatting[fn:23].  A few examples:
2212 | =$1+$2=            | Sum of first and second field                    |
2213 | =$1+$2;%.2f=       | Same, format result to two decimals              |
2214 | =exp($2)+exp($1)=  | Math functions can be used                       |
2215 | =$0;%.1f=          | Reformat current cell to 1 decimal               |
2216 | =($3-32)*5/9=      | Degrees F \to C conversion                         |
2217 | =$c/$1/$cm=        | Hz \to cm conversion, using =constants.el=         |
2218 | =tan($1);Dp3s1=    | Compute in degrees, precision 3, display SCI 1   |
2219 | =sin($1);Dp3%.1e=  | Same, but use ~printf~ specifier for display     |
2220 | =vmean($2..$7)=    | Compute column range mean, using vector function |
2221 | =vmean($2..$7);EN= | Same, but treat empty fields as 0                |
2222 | =taylor($3,x=7,2)= | Taylor series of $3, at x=7, second degree       |
2224 Calc also contains a complete set of logical operations (see [[info:calc#Logical%20Operations][Logical
2225 Operations]]).  For example
2227 - =if($1 < 20, teen, string(""))= ::
2229      ="teen"= if age =$1= is less than 20, else the Org table result
2230      field is set to empty with the empty string.
2232 - =if("$1" == "nan" || "$2" == "nan", string(""), $1 + $2); E f-1= ::
2234      Sum of the first two columns.  When at least one of the input
2235      fields is empty the Org table result field is set to empty.  =E=
2236      is required to not convert empty fields to 0.  =f-1= is an
2237      optional Calc format string similar to =%.1f= but leaves empty
2238      results empty.
2240 - =if(typeof(vmean($1..$7)) == 12, string(""), vmean($1..$7); E= ::
2242      Mean value of a range unless there is any empty field.  Every
2243      field in the range that is empty is replaced by =nan= which lets
2244      =vmean= result in =nan=.  Then =typeof == 12= detects the =nan=
2245      from ~vmean~ and the Org table result field is set to empty.  Use
2246      this when the sample set is expected to never have missing
2247      values.
2249 - =if("$1..$7" == "[]", string(""), vmean($1..$7))= ::
2251      Mean value of a range with empty fields skipped.  Every field in
2252      the range that is empty is skipped.  When all fields in the range
2253      are empty the mean value is not defined and the Org table result
2254      field is set to empty.  Use this when the sample set can have
2255      a variable size.
2257 - =vmean($1..$7); EN= ::
2259      To complete the example before: Mean value of a range with empty
2260      fields counting as samples with value 0.  Use this only when
2261      incomplete sample sets should be padded with 0 to the full size.
2263 You can add your own Calc functions defined in Emacs Lisp with
2264 ~defmath~ and use them in formula syntax for Calc.
2266 *** Emacs Lisp forms as formulas
2267 :PROPERTIES:
2268 :DESCRIPTION: Writing formulas in Emacs Lisp.
2269 :ALT_TITLE: Formula syntax for Lisp
2270 :END:
2271 #+cindex: Lisp forms, as table formulas
2273 It is also possible to write a formula in Emacs Lisp.  This can be
2274 useful for string manipulation and control structures, if Calc's
2275 functionality is not enough.
2277 If a formula starts with a single-quote followed by an opening
2278 parenthesis, then it is evaluated as a Lisp form.  The evaluation
2279 should return either a string or a number.  Just as with Calc
2280 formulas, you can specify modes and a ~printf~ format after
2281 a semicolon.
2283 With Emacs Lisp forms, you need to be conscious about the way field
2284 references are interpolated into the form.  By default, a reference is
2285 interpolated as a Lisp string (in double-quotes) containing the field.
2286 If you provide the =N= mode switch, all referenced elements are
2287 numbers---non-number fields will be zero---and interpolated as Lisp
2288 numbers, without quotes.  If you provide the =L= flag, all fields are
2289 interpolated literally, without quotes.  I.e., if you want a reference
2290 to be interpreted as a string by the Lisp form, enclose the reference
2291 operator itself in double-quotes, like ="$3"=.  Ranges are inserted as
2292 space-separated fields, so you can embed them in list or vector
2293 syntax.
2295 Here are a few examples---note how the =N= mode is used when we do
2296 computations in Lisp:
2298 - ='(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))= ::
2300      Swap the first two characters of the content of column 1.
2302 - ='(+ $1 $2);N= ::
2304      Add columns 1 and 2, equivalent to Calc's =$1+$2=.
2306 - ='(apply '+ '($1..$4));N= ::
2308      Compute the sum of columns 1 to 4, like Calc's =vsum($1..$4)=.
2310 *** Durations and time values
2311 :PROPERTIES:
2312 :DESCRIPTION: How to compute durations and time values.
2313 :END:
2314 #+cindex: Duration, computing
2315 #+cindex: Time, computing
2316 #+vindex: org-table-duration-custom-format
2318 If you want to compute time values use the =T=, =t=, or =U= flag,
2319 either in Calc formulas or Elisp formulas:
2321 #+begin_example
2322   |  Task 1 |   Task 2 |    Total |
2323   |---------+----------+----------|
2324   |    2:12 |     1:47 | 03:59:00 |
2325   |    2:12 |     1:47 |    03:59 |
2326   | 3:02:20 | -2:07:00 |     0.92 |
2327   ,#+TBLFM: @2$3=$1+$2;T::@3$3=$1+$2;U::@4$3=$1+$2;t
2328 #+end_example
2330 Input duration values must be of the form =HH:MM[:SS]=, where seconds
2331 are optional.  With the =T= flag, computed durations are displayed as
2332 =HH:MM:SS= (see the first formula above).  With the =U= flag, seconds
2333 are omitted so that the result is only =HH:MM= (see second formula
2334 above).  Zero-padding of the hours field depends upon the value of the
2335 variable ~org-table-duration-hour-zero-padding~.
2337 With the =t= flag, computed durations are displayed according to the
2338 value of the option ~org-table-duration-custom-format~, which defaults
2339 to ~hours~ and displays the result as a fraction of hours (see the
2340 third formula in the example above).
2342 Negative duration values can be manipulated as well, and integers are
2343 considered as seconds in addition and subtraction.
2345 *** Field and range formulas
2346 :PROPERTIES:
2347 :DESCRIPTION: Formula for specific (ranges of) fields.
2348 :END:
2349 #+cindex: field formula
2350 #+cindex: range formula
2351 #+cindex: formula, for individual table field
2352 #+cindex: formula, for range of fields
2354 To assign a formula to a particular field, type it directly into the
2355 field, preceded by =:==, for example =vsum(@II..III)=.  When you press
2356 {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} with the cursor
2357 still in the field, the formula is stored as the formula for this
2358 field, evaluated, and the current field is replaced with the result.
2360 #+cindex: TBLFM, keyword
2361 Formulas are stored in a special =TBLFM= keyword located directly
2362 below the table.  If you type the equation in the fourth field of the
2363 third data line in the table, the formula looks like =@3$4=$1+$2=.
2364 When inserting/deleting/swapping column and rows with the appropriate
2365 commands, /absolute references/ (but not relative ones) in stored
2366 formulas are modified in order to still reference the same field.  To
2367 avoid this from happening, in particular in range references, anchor
2368 ranges at the table borders (using =@<=, =@>=, =$<=, =$>=), or at
2369 hlines using the =@I= notation.  Automatic adaptation of field
2370 references does of course not happen if you edit the table structure
2371 with normal editing commands---then you must fix the equations
2372 yourself.
2374 Instead of typing an equation into the field, you may also use the
2375 following command
2377 - {{{kbd(C-u C-c =)}}} (~org-table-eval-formula~) ::
2379      #+kindex: C-u C-c =
2380      #+findex: org-table-eval-formula
2381      Install a new formula for the current field.  The command prompts
2382      for a formula with default taken from the =TBLFM= keyword,
2383      applies it to the current field, and stores it.
2385 The left-hand side of a formula can also be a special expression in
2386 order to assign the formula to a number of different fields.  There is
2387 no keyboard shortcut to enter such range formulas.  To add them, use
2388 the formula editor (see [[*Editing and debugging formulas]]) or edit the
2389 =TBLFM= keyword directly.
2391 - =$2== ::
2393      Column formula, valid for the entire column.  This is so common
2394      that Org treats these formulas in a special way, see [[*Column
2395      formulas]].
2397 - ~@3=~ ::
2399      Row formula, applies to all fields in the specified row.  =@>==
2400      means the last row.
2402 - =@1$2..@4$3== ::
2404      Range formula, applies to all fields in the given rectangular
2405      range.  This can also be used to assign a formula to some but not
2406      all fields in a row.
2408 - =$NAME== ::
2410      Named field, see [[*Advanced features]].
2412 *** Column formulas
2413 :PROPERTIES:
2414 :DESCRIPTION: Formulas valid for an entire column.
2415 :END:
2416 #+cindex: column formula
2417 #+cindex: formula, for table column
2419 When you assign a formula to a simple column reference like =$3==, the
2420 same formula is used in all fields of that column, with the following
2421 very convenient exceptions: (i) If the table contains horizontal
2422 separator hlines with rows above and below, everything before the
2423 first such hline is considered part of the table /header/ and is not
2424 modified by column formulas.  Therefore a header is mandatory when you
2425 use column formulas and want to add hlines to group rows, like for
2426 example to separate a total row at the bottom from the summand rows
2427 above.  (ii) Fields that already get a value from a field/range
2428 formula are left alone by column formulas.  These conditions make
2429 column formulas very easy to use.
2431 To assign a formula to a column, type it directly into any field in
2432 the column, preceded by an equal sign, like ==$1+$2=.  When you press
2433 {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} with the cursor
2434 still in the field, the formula is stored as the formula for the
2435 current column, evaluated and the current field replaced with the
2436 result.  If the field contains only ===, the previously stored formula
2437 for this column is used.  For each column, Org only remembers the most
2438 recently used formula.  In the =TBLFM= keyword, column formulas look
2439 like =$4=$1+$2=.  The left-hand side of a column formula can not be
2440 the name of column, it must be the numeric column reference or =$>=.
2442 Instead of typing an equation into the field, you may also use the
2443 following command:
2445 - {{{kbd(C-c =)}}} (~org-table-eval-formula~) ::
2447      #+kindex: C-c =
2448      #+findex: org-table-eval-formula
2449      Install a new formula for the current column and replace current
2450      field with the result of the formula.  The command prompts for
2451      a formula, with default taken from the =TBLFM= keyword, applies
2452      it to the current field and stores it.  With a numeric prefix
2453      argument, e.g., {{{kbd(C-5 C-c =)}}}, the command applies it to
2454      that many consecutive fields in the current column.
2456 *** Lookup functions
2457 :PROPERTIES:
2458 :DESCRIPTION: Lookup functions for searching tables.
2459 :END:
2460 #+cindex: lookup functions in tables
2461 #+cindex: table lookup functions
2463 Org has three predefined Emacs Lisp functions for lookups in tables.
2465 - ~(org-lookup-first VAL S-LIST R-LIST &optional PREDICATE)~ ::
2467      #+findex: org-lookup-first
2468      Searches for the first element {{{var(S)}}} in list
2469      {{{var(S-LIST)}}} for which
2470      #+begin_src emacs-lisp
2471        (PREDICATE VAL S)
2472      #+end_src
2473      is non-~nil~; returns the value from the corresponding position
2474      in list {{{var(R-LIST)}}}.  The default {{{var(PREDICATE)}}} is
2475      ~equal~.  Note that the parameters {{{var(VAL)}}} and
2476      {{{var(S)}}} are passed to {{{var(PREDICATE)}}} in the same order
2477      as the corresponding parameters are in the call to
2478      ~org-lookup-first~, where {{{var(VAL)}}} precedes
2479      {{{var(S-LIST)}}}.  If {{{var(R-LIST)}}} is ~nil~, the matching
2480      element {{{var(S)}}} of {{{var(S-LIST)}}} is returned.
2482 - ~(org-lookup-last VAL S-LIST R-LIST &optional PREDICATE)~ ::
2484      #+findex: org-lookup-last
2485      Similar to ~org-lookup-first~ above, but searches for the /last/
2486      element for which {{{var(PREDICATE)}}} is non-~nil~.
2488 - ~(org-lookup-all VAL S-LIST R-LIST &optional PREDICATE)~ ::
2490      #+findex: org-lookup-all
2491      Similar to ~org-lookup-first~, but searches for /all/ elements
2492      for which {{{var(PREDICATE)}}} is non-~nil~, and returns /all/
2493      corresponding values.  This function can not be used by itself in
2494      a formula, because it returns a list of values.  However,
2495      powerful lookups can be built when this function is combined with
2496      other Emacs Lisp functions.
2498 If the ranges used in these functions contain empty fields, the =E=
2499 mode for the formula should usually be specified: otherwise empty
2500 fields are not included in {{{var(S-LIST)}}} and/or {{{var(R-LIST)}}}
2501 which can, for example, result in an incorrect mapping from an element
2502 of {{{var(S-LIST)}}} to the corresponding element of
2503 {{{var(R-LIST)}}}.
2505 These three functions can be used to implement associative arrays,
2506 count matching cells, rank results, group data, etc.  For practical
2507 examples see [[https://orgmode.org/worg/org-tutorials/org-lookups.html][this tutorial on Worg]].
2509 *** Editing and debugging formulas
2510 :PROPERTIES:
2511 :DESCRIPTION: Fixing formulas.
2512 :END:
2513 #+cindex: formula editing
2514 #+cindex: editing, of table formulas
2516 #+vindex: org-table-use-standard-references
2517 You can edit individual formulas in the minibuffer or directly in the
2518 field.  Org can also prepare a special buffer with all active formulas
2519 of a table.  When offering a formula for editing, Org converts
2520 references to the standard format (like =B3= or =D&=) if possible.  If
2521 you prefer to only work with the internal format (like =@3$2= or
2522 =$4=), configure the variable ~org-table-use-standard-references~.
2524 - {{{kbd(C-c =)}}} or {{{kbd(C-u C-c =)}}} (~org-table-eval-formula~) ::
2526      #+kindex: C-c =
2527      #+kindex: C-u C-c =
2528      #+findex: org-table-eval-formula
2529      Edit the formula associated with the current column/field in the
2530      minibuffer.  See [[*Column formulas]], and [[*Field and range formulas]].
2532 - {{{kbd(C-u C-u C-c =)}}} (~org-table-eval-formula~) ::
2534      #+kindex: C-u C-u C-c =
2535      #+findex: org-table-eval-formula
2536      Re-insert the active formula (either a field formula, or a column
2537      formula) into the current field, so that you can edit it directly
2538      in the field.  The advantage over editing in the minibuffer is
2539      that you can use the command {{{kbd(C-c ?)}}}.
2541 - {{{kbd(C-c ?)}}} (~org-table-field-info~) ::
2543      #+kindex: C-c ?
2544      #+findex: org-table-field-info
2545      While editing a formula in a table field, highlight the field(s)
2546      referenced by the reference at the cursor position in the
2547      formula.
2549 - {{{kbd(C-c })}}} (~org-table-toggle-coordinate-overlays~) ::
2551      #+kindex: C-c @}
2552      #+findex: org-table-toggle-coordinate-overlays
2553      Toggle the display of row and column numbers for a table, using
2554      overlays.  These are updated each time the table is aligned; you
2555      can force it with {{{kbd(C-c C-c)}}}.
2557 - {{{kbd(C-c {)}}} (~org-table-toggle-formula-debugger~) ::
2559      #+kindex: C-c @{
2560      #+findex: org-table-toggle-formula-debugger
2561      Toggle the formula debugger on and off.  See below.
2563 - {{{kbd(C-c ')}}} (~org-table-edit-formulas~) ::
2565      #+kindex: C-c '
2566      #+findex: org-table-edit-formulas
2567      Edit all formulas for the current table in a special buffer,
2568      where the formulas are displayed one per line.  If the current
2569      field has an active formula, the cursor in the formula editor
2570      marks it.  While inside the special buffer, Org automatically
2571      highlights any field or range reference at the cursor position.
2572      You may edit, remove and add formulas, and use the following
2573      commands:
2575      - {{{kbd(C-c C-c)}}} or {{{kbd(C-x C-s)}}} (~org-table-fedit-finish~) ::
2577           #+kindex: C-x C-s
2578           #+kindex: C-c C-c
2579           #+findex: org-table-fedit-finish
2580           Exit the formula editor and store the modified formulas.  With
2581           {{{kbd(C-u)}}} prefix, also apply the new formulas to the
2582           entire table.
2584      - {{{kbd(C-c C-q)}}} (~org-table-fedit-abort~) ::
2586           #+kindex: C-c C-q
2587           #+findex: org-table-fedit-abort
2588           Exit the formula editor without installing changes.
2590      - {{{kbd(C-c C-r)}}} (~org-table-fedit-toggle-ref-type~) ::
2592           #+kindex: C-c C-r
2593           #+findex: org-table-fedit-toggle-ref-type
2594           Toggle all references in the formula editor between standard
2595           (like =B3=) and internal (like =@3$2=).
2597      - {{{kbd(TAB)}}} (~org-table-fedit-lisp-indent~) ::
2599           #+kindex: TAB
2600           #+findex: org-table-fedit-lisp-indent
2601           Pretty-print or indent Lisp formula at point.  When in a line
2602           containing a Lisp formula, format the formula according to
2603           Emacs Lisp rules.  Another {{{kbd(TAB)}}} collapses the formula
2604           back again.  In the open formula, {{{kbd(TAB)}}} re-indents
2605           just like in Emacs Lisp mode.
2607      - {{{kbd(M-TAB)}}} (~lisp-complete-symbol~) ::
2609           #+kindex: M-TAB
2610           #+findex: lisp-complete-symbol
2611           Complete Lisp symbols, just like in Emacs Lisp mode.
2613      - {{{kbd(S-up)}}}, {{{kbd(S-down)}}}, {{{kbd(S-left)}}}, {{{kbd(S-right)}}} ::
2615           #+kindex: S-up
2616           #+kindex: S-down
2617           #+kindex: S-left
2618           #+kindex: S-right
2619           #+findex: org-table-fedit-ref-up
2620           #+findex: org-table-fedit-ref-down
2621           #+findex: org-table-fedit-ref-left
2622           #+findex: org-table-fedit-ref-right
2623           Shift the reference at point.  For example, if the reference
2624           is =B3= and you press {{{kbd(S-right)}}}, it becomes =C3=.
2625           This also works for relative references and for hline
2626           references.
2628      - {{{kbd(M-S-up)}}} (~org-table-fedit-line-up~) ::
2630           #+kindex: M-S-up
2631           #+findex: org-table-fedit-line-up
2632           Move the test line for column formulas up in the Org buffer.
2634      - {{{kbd(M-S-down)}}} (~org-table-fedit-line-down~) ::
2636           #+kindex: M-S-down
2637           #+findex: org-table-fedit-line-down
2638           Move the test line for column formulas down in the Org buffer.
2640      - {{{kbd(M-up)}}} (~org-table-fedit-scroll-up~) ::
2642           #+kindex: M-up
2643           #+findex: org-table-fedit-scroll-up
2644           Scroll up the window displaying the table.
2646      - {{{kbd(M-down)}}} (~org-table-fedit-scroll-down~) ::
2648           #+kindex: M-down
2649           #+findex: org-table-fedit-scroll-down
2650           Scroll down the window displaying the table.
2652      - {{{kbd(C-c })}}} ::
2654           #+kindex: C-c @}
2655           #+findex: org-table-toggle-coordinate-overlays
2656           Turn the coordinate grid in the table on and off.
2658 Making a table field blank does not remove the formula associated with
2659 the field, because that is stored in a different line---the =TBLFM=
2660 keyword line.  During the next recalculation, the field will be filled
2661 again.  To remove a formula from a field, you have to give an empty
2662 reply when prompted for the formula, or to edit the =TBLFM= keyword.
2664 #+kindex: C-c C-c
2665 You may edit the =TBLFM= keyword directly and re-apply the changed
2666 equations with {{{kbd(C-c C-c)}}} in that line or with the normal
2667 recalculation commands in the table.
2669 **** Using multiple =TBLFM= lines
2670 :PROPERTIES:
2671 :UNNUMBERED: notoc
2672 :END:
2673 #+cindex: multiple formula lines
2674 #+cindex: TBLFM keywords, multiple
2675 #+cindex: TBLFM, switching
2677 #+kindex: C-c C-c
2678 You may apply the formula temporarily.  This is useful when you switch
2679 the formula.  Place multiple =TBLFM= keywords right after the table,
2680 and then press {{{kbd(C-c C-c)}}} on the formula to apply.  Here is an
2681 example:
2683 #+begin_example
2684   | x | y |
2685   |---+---|
2686   | 1 |   |
2687   | 2 |   |
2688   ,#+TBLFM: $2=$1*1
2689   ,#+TBLFM: $2=$1*2
2690 #+end_example
2692 #+texinfo: @noindent
2693 Pressing {{{kbd(C-c C-c)}}} in the line of =#+TBLFM: $2=$1*2= yields:
2695 #+begin_example
2696   | x | y |
2697   |---+---|
2698   | 1 | 2 |
2699   | 2 | 4 |
2700   ,#+TBLFM: $2=$1*1
2701   ,#+TBLFM: $2=$1*2
2702 #+end_example
2704 #+texinfo: @noindent
2705 Note: If you recalculate this table, with {{{kbd(C-u C-c *)}}}, for
2706 example, you get the following result of applying only the first
2707 =TBLFM= keyword.
2709 #+begin_example
2710   | x | y |
2711   |---+---|
2712   | 1 | 1 |
2713   | 2 | 2 |
2714   ,#+TBLFM: $2=$1*1
2715   ,#+TBLFM: $2=$1*2
2716 #+end_example
2718 **** Debugging formulas
2719 :PROPERTIES:
2720 :UNNUMBERED: notoc
2721 :END:
2722 #+cindex: formula debugging
2723 #+cindex: debugging, of table formulas
2725 When the evaluation of a formula leads to an error, the field content
2726 becomes the string =#ERROR=.  If you would like to see what is going
2727 on during variable substitution and calculation in order to find
2728 a bug, turn on formula debugging in the Tbl menu and repeat the
2729 calculation, for example by pressing {{{kbd(C-u C-u C-c = RET)}}} in
2730 a field.  Detailed information are displayed.
2732 *** Updating the table
2733 :PROPERTIES:
2734 :DESCRIPTION: Recomputing all dependent fields.
2735 :END:
2736 #+cindex: recomputing table fields
2737 #+cindex: updating, table
2739 Recalculation of a table is normally not automatic, but needs to be
2740 triggered by a command.  To make recalculation at least
2741 semi-automatic, see [[*Advanced features]].
2743 In order to recalculate a line of a table or the entire table, use the
2744 following commands:
2746 - {{{kbd(C-c *)}}} (~org-table-recalculate~) ::
2748      #+kindex: C-c *
2749      #+findex: org-table-recalculate
2750      Recalculate the current row by first applying the stored column
2751      formulas from left to right, and all field/range formulas in the
2752      current row.
2754 - {{{kbd(C-u C-c *)}}} or {{{kbd(C-u C-c C-c)}}} ::
2756      #+kindex: C-u C-c *
2757      #+kindex: C-u C-c C-c
2758      Recompute the entire table, line by line.  Any lines before the
2759      first hline are left alone, assuming that these are part of the
2760      table header.
2762 - {{{kbd(C-u C-u C-c *)}}} or {{{kbd(C-u C-u C-c C-c)}}} (~org-table-iterate~) ::
2764      #+kindex: C-u C-u C-c *
2765      #+kindex: C-u C-u C-c C-c
2766      #+findex: org-table-iterate
2767      Iterate the table by recomputing it until no further changes
2768      occur.  This may be necessary if some computed fields use the
2769      value of other fields that are computed /later/ in the
2770      calculation sequence.
2772 - {{{kbd(M-x org-table-recalculate-buffer-tables)}}} ::
2774      #+findex: org-table-recalculate-buffer-tables
2775      Recompute all tables in the current buffer.
2777 - {{{kbd(M-x org-table-iterate-buffer-tables)}}} ::
2779      #+findex: org-table-iterate-buffer-tables
2780      Iterate all tables in the current buffer, in order to converge
2781      table-to-table dependencies.
2783 *** Advanced features
2784 :PROPERTIES:
2785 :DESCRIPTION: Field and column names, automatic recalculation...
2786 :END:
2788 If you want the recalculation of fields to happen automatically, or if
2789 you want to be able to assign /names/[fn:24] to fields and columns,
2790 you need to reserve the first column of the table for special marking
2791 characters.
2793 - {{{kbd(C-#)}}} (~org-table-rotate-recalc-marks~) ::
2795      #+kindex: C-#
2796      #+findex: org-table-rotate-recalc-marks
2797      Rotate the calculation mark in first column through the states
2798      =#=, =*=, =!=, =$=.  When there is an active region, change all
2799      marks in the region.
2801 Here is an example of a table that collects exam results of students
2802 and makes use of these features:
2804 #+begin_example
2805   |---+---------+--------+--------+--------+-------+------|
2806   |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2807   |---+---------+--------+--------+--------+-------+------|
2808   | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2809   | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2810   | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2811   |---+---------+--------+--------+--------+-------+------|
2812   | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2813   | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2814   |---+---------+--------+--------+--------+-------+------|
2815   |   | Average |        |        |        |  25.0 |      |
2816   | ^ |         |        |        |        |    at |      |
2817   | $ | max=50  |        |        |        |       |      |
2818   |---+---------+--------+--------+--------+-------+------|
2819   ,#+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@-II..@-I);%.1f
2820 #+end_example
2822 #+texinfo: @noindent
2823 *Important*: please note that for these special tables, recalculating
2824 the table with {{{kbd(C-u C-c *)}}} only affects rows that are marked
2825 =#= or =*=, and fields that have a formula assigned to the field
2826 itself.  The column formulas are not applied in rows with empty first
2827 field.
2829 #+cindex: marking characters, tables
2830 The marking characters have the following meaning:
2832 - =!= ::
2834      The fields in this line define names for the columns, so that you
2835      may refer to a column as =$Tot= instead of =$6=.
2837 - =^= ::
2839      This row defines names for the fields /above/ the row.  With such
2840      a definition, any formula in the table may use =$m1= to refer to
2841      the value =10=.  Also, if you assign a formula to a names field,
2842      it is stored as =$name = ...=.
2844 - =_= ::
2846      Similar to =^=, but defines names for the fields in the row
2847      /below/.
2849 - =$= ::
2851      Fields in this row can define /parameters/ for formulas.  For
2852      example, if a field in a =$= row contains =max=50=, then formulas
2853      in this table can refer to the value 50 using =$max=.  Parameters
2854      work exactly like constants, only that they can be defined on
2855      a per-table basis.
2857 - =#= ::
2859      Fields in this row are automatically recalculated when pressing
2860      {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(S-TAB)}}} in this row.
2861      Also, this row is selected for a global recalculation with
2862      {{{kbd(C-u C-c *)}}}.  Unmarked lines are left alone by this
2863      command.
2865 - =*= ::
2867      Selects this line for global recalculation with {{{kbd(C-u C-c
2868      *)}}}, but not for automatic recalculation.  Use this when
2869      automatic recalculation slows down editing too much.
2871 - =/= ::
2873      Do not export this line.  Useful for lines that contain the
2874      narrowing =<N>= markers or column group markers.
2876 Finally, just to whet your appetite for what can be done with the
2877 fantastic Calc package, here is a table that computes the Taylor
2878 series of degree n at location x for a couple of functions.
2880 #+begin_example
2881   |---+-------------+---+-----+--------------------------------------|
2882   |   | Func        | n | x   | Result                               |
2883   |---+-------------+---+-----+--------------------------------------|
2884   | # | exp(x)      | 1 | x   | 1 + x                                |
2885   | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2886   | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2887   | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2888   | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2889   | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2890   |---+-------------+---+-----+--------------------------------------|
2891   ,#+TBLFM: $5=taylor($2,$4,$3);n3
2892 #+end_example
2894 ** Org Plot
2895 :PROPERTIES:
2896 :DESCRIPTION: Plotting from Org tables.
2897 :END:
2898 #+cindex: graph, in tables
2899 #+cindex: plot tables using Gnuplot
2901 Org Plot can produce graphs of information stored in Org tables,
2902 either graphically or in ASCII art.
2904 *** Graphical plots using Gnuplot
2905 :PROPERTIES:
2906 :UNNUMBERED: notoc
2907 :END:
2909 #+cindex: PLOT, keyword
2910 Org Plot can produce 2D and 3D graphs of information stored in Org
2911 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
2912 that you have both Gnuplot and Gnuplot mode installed on your system,
2913 then call {{{kbd(C-c \quot g)}}} or {{{kbd(M-x org-plot/gnuplot)}}} on the
2914 following table.
2916 #+begin_example
2917   ,#+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2918   | Sede      | Max cites | H-index |
2919   |-----------+-----------+---------|
2920   | Chile     |    257.72 |   21.39 |
2921   | Leeds     |    165.77 |   19.68 |
2922   | Sao Paolo |     71.00 |   11.50 |
2923   | Stockholm |    134.19 |   14.33 |
2924   | Morels    |    257.56 |   17.67 |
2925 #+end_example
2927 Notice that Org Plot is smart enough to apply the table's headers as
2928 labels.  Further control over the labels, type, content, and
2929 appearance of plots can be exercised through the =PLOT= keyword
2930 preceding a table.  See below for a complete list of Org Plot options.
2931 For more information and examples see the [[https://orgmode.org/worg/org-tutorials/org-plot.html][Org Plot tutorial]].
2933 **** Plot options
2934 :PROPERTIES:
2935 :UNNUMBERED: notoc
2936 :END:
2938 - =set= ::
2940      Specify any Gnuplot option to be set when graphing.
2942 - =title= ::
2944      Specify the title of the plot.
2946 - =ind= ::
2948      Specify which column of the table to use as the =x= axis.
2950 - =deps= ::
2952      Specify the columns to graph as a Lisp style list, surrounded by
2953      parentheses and separated by spaces for example =dep:(3 4)= to
2954      graph the third and fourth columns.  Defaults to graphing all
2955      other columns aside from the =ind= column.
2957 - =type= ::
2959      Specify whether the plot is =2d=, =3d=, or =grid=.
2961 - =with= ::
2963      Specify a =with= option to be inserted for every column being
2964      plotted, e.g., =lines=, =points=, =boxes=, =impulses=.  Defaults
2965      to =lines=.
2967 - =file= ::
2969      If you want to plot to a file, specify
2970      ="path/to/desired/output-file"=.
2972 - =labels= ::
2974      List of labels to be used for the =deps=.  Defaults to the column
2975      headers if they exist.
2977 - =line= ::
2979      Specify an entire line to be inserted in the Gnuplot script.
2981 - =map= ::
2983      When plotting =3d= or =grid= types, set this to =t= to graph
2984      a flat mapping rather than a =3d= slope.
2986 - =timefmt= ::
2988      Specify format of Org mode timestamps as they will be parsed by
2989      Gnuplot.  Defaults to =%Y-%m-%d-%H:%M:%S=.
2991 - =script= ::
2993      If you want total control, you can specify a script file---place
2994      the file name between double-quotes---which will be used to plot.
2995      Before plotting, every instance of =$datafile= in the specified
2996      script will be replaced with the path to the generated data file.
2997      Note: even if you set this option, you may still want to specify
2998      the plot type, as that can impact the content of the data file.
3000 *** ASCII bar plots
3001 :PROPERTIES:
3002 :UNNUMBERED: notoc
3003 :END:
3005 While the cursor is on a column, typing {{{kbd(C-c " a)}}} or
3006 {{{kbd(M-x orgtbl-ascii-plot)}}} create a new column containing an
3007 ASCII-art bars plot.  The plot is implemented through a regular column
3008 formula.  When the source column changes, the bar plot may be updated
3009 by refreshing the table, for example typing {{{kbd(C-u C-c *)}}}.
3011 #+begin_example
3012   | Sede          | Max cites |              |
3013   |---------------+-----------+--------------|
3014   | Chile         |    257.72 | WWWWWWWWWWWW |
3015   | Leeds         |    165.77 | WWWWWWWh     |
3016   | Sao Paolo     |     71.00 | WWW;         |
3017   | Stockholm     |    134.19 | WWWWWW:      |
3018   | Morelia       |    257.56 | WWWWWWWWWWWH |
3019   | Rochefourchat |      0.00 |              |
3020   ,#+TBLFM: $3='(orgtbl-ascii-draw $2 0.0 257.72 12)
3021 #+end_example
3023 The formula is an Elisp call.
3025 #+attr_texinfo: :options orgtbl-ascii-draw value min max &optional width
3026 #+begin_defun
3027 Draw an ASCII bar in a table.
3029 {{{var(VALUE)}}} is the value to plot.
3031 {{{var(MIN)}}} is the value displayed as an empty bar.  {{{var(MAX)}}}
3032 is the value filling all the {{{var(WIDTH)}}}.  Sources values outside
3033 this range are displayed as =too small= or =too large=.
3035 {{{var(WIDTH)}}} is the number of characters of the bar plot.  It
3036 defaults to =12=.
3037 #+end_defun
3039 * Hyperlinks
3040 :PROPERTIES:
3041 :DESCRIPTION: Notes in context.
3042 :END:
3043 #+cindex: hyperlinks
3045 Like HTML, Org provides links inside a file, external links to
3046 other files, Usenet articles, emails, and much more.
3048 ** Link Format
3049 :PROPERTIES:
3050 :DESCRIPTION: How links in Org are formatted.
3051 :END:
3052 #+cindex: link format
3053 #+cindex: format, of links
3055 Org recognizes plain URL-like links and activate them as clickable
3056 links.  The general link format, however, looks like this:
3058 : [[LINK][DESCRIPTION]]
3060 #+texinfo: @noindent
3061 or alternatively
3063 : [[LINK]]
3065 #+texinfo: @noindent
3066 Once a link in the buffer is complete (all brackets present), Org
3067 changes the display so that =DESCRIPTION= is displayed instead of
3068 =[[LINK][DESCRIPTION]]= and =LINK= is displayed instead of =[[LINK]]=.  Links are be
3069 highlighted in the face ~org-link~, which by default is an underlined
3070 face.  You can directly edit the visible part of a link.  Note that
3071 this can be either the LINK part, if there is no description, or the
3072 {{{var(DESCRIPTION)}}} part.  To edit also the invisible
3073 {{{var(LINK)}}} part, use {{{kbd(C-c C-l)}}} with the cursor on the
3074 link.
3076 If you place the cursor at the beginning or just behind the end of the
3077 displayed text and press {{{kbd(BS)}}}, you remove
3078 the---invisible---bracket at that location.  This makes the link
3079 incomplete and the internals are again displayed as plain text.
3080 Inserting the missing bracket hides the link internals again.  To show
3081 the internal structure of all links, use the menu: Org \rarr Hyperlinks \rarr
3082 Literal links.
3084 ** Internal Links
3085 :PROPERTIES:
3086 :DESCRIPTION: Links to other places in the current file.
3087 :END:
3088 #+cindex: internal links
3089 #+cindex: links, internal
3090 #+cindex: targets, for links
3092 #+cindex: CUSTOM_ID, property
3093 If the link does not look like a URL, it is considered to be internal
3094 in the current file.  The most important case is a link like
3095 =[[#my-custom-id]]= which links to the entry with the =CUSTOM_ID= property
3096 =my-custom-id=.  You are responsible yourself to make sure these
3097 custom IDs are unique in a file.
3099 Links such as =[[My Target]]= or =[[My Target][Find my target]]= lead to a text search in
3100 the current file.
3102 The link can be followed with {{{kbd(C-c C-o)}}} when the cursor is on
3103 the link, or with a mouse click (see [[*Handling Links]]).  Links to
3104 custom IDs point to the corresponding headline.  The preferred match
3105 for a text link is a /dedicated target/: the same string in double
3106 angular brackets, like =<<My Target>>=.
3108 #+cindex: NAME, keyword
3109 If no dedicated target exists, the link tries to match the exact name
3110 of an element within the buffer.  Naming is done with the =NAME=
3111 keyword, which has to be put in the line before the element it refers
3112 to, as in the following example
3114 #+begin_example
3115   ,#+NAME: My Target
3116   | a  | table      |
3117   |----+------------|
3118   | of | four cells |
3119 #+end_example
3121 If none of the above succeeds, Org searches for a headline that is
3122 exactly the link text but may also include a TODO keyword and
3123 tags[fn:25].
3125 During export, internal links are used to mark objects and assign them
3126 a number.  Marked objects are then referenced by links pointing to
3127 them.  In particular, links without a description appear as the number
3128 assigned to the marked object[fn:26].  In the following excerpt from
3129 an Org buffer
3131 #+begin_example
3132   1. one item
3133   2. <<target>>another item
3134   Here we refer to item [[target]].
3135 #+end_example
3137 #+texinfo: @noindent
3138 The last sentence will appear as =Here we refer to item 2= when
3139 exported.
3141 In non-Org files, the search looks for the words in the link text.  In
3142 the above example the search would be for =target=.
3144 Following a link pushes a mark onto Org's own mark ring.  You can
3145 return to the previous position with {{{kbd(C-c &)}}}.  Using this
3146 command several times in direct succession goes back to positions
3147 recorded earlier.
3149 ** Radio Targets
3150 :PROPERTIES:
3151 :DESCRIPTION: Make targets trigger links in plain text.
3152 :END:
3153 #+cindex: radio targets
3154 #+cindex: targets, radio
3155 #+cindex: links, radio targets
3157 Org can automatically turn any occurrences of certain target names in
3158 normal text into a link.  So without explicitly creating a link, the
3159 text connects to the target radioing its position.  Radio targets are
3160 enclosed by triple angular brackets.  For example, a target =<<<My
3161 Target>>>= causes each occurrence of =my target= in normal text to
3162 become activated as a link.  The Org file is scanned automatically for
3163 radio targets only when the file is first loaded into Emacs.  To
3164 update the target list during editing, press {{{kbd(C-c C-c)}}} with
3165 the cursor on or at a target.
3167 ** External Links
3168 :PROPERTIES:
3169 :DESCRIPTION: URL-like links to the world.
3170 :END:
3171 #+cindex: links, external
3172 #+cindex: external links
3173 #+cindex: Gnus links
3174 #+cindex: BBDB links
3175 #+cindex: irc links
3176 #+cindex: URL links
3177 #+cindex: file links
3178 #+cindex: Rmail links
3179 #+cindex: MH-E links
3180 #+cindex: Usenet links
3181 #+cindex: shell links
3182 #+cindex: Info links
3183 #+cindex: Elisp links
3185 Org supports links to files, websites, Usenet and email messages, BBDB
3186 database entries and links to both IRC conversations and their logs.
3187 External links are URL-like locators.  They start with a short
3188 identifying string followed by a colon.  There can be no space after
3189 the colon.  The following list shows examples for each link type.
3191 | =http://www.astro.uva.nl/=dominik=          | on the web                     |
3192 | =doi:10.1000/182=                           | DOI for an electronic resource |
3193 | =file:/home/dominik/images/jupiter.jpg=     | file, absolute path            |
3194 | =/home/dominik/images/jupiter.jpg=          | same as above                  |
3195 | =file:papers/last.pdf=                      | file, relative path            |
3196 | =./papers/last.pdf=                         | same as above                  |
3197 | =file:/ssh:me@some.where:papers/last.pdf=   | file, path on remote machine   |
3198 | =/ssh:me@some.where:papers/last.pdf=        | same as above                  |
3199 | =file:sometextfile::NNN=                    | file, jump to line number      |
3200 | =file:projects.org=                         | another Org file               |
3201 | =file:projects.org::some words=             | text search in Org file[fn:27] |
3202 | =file:projects.org::*task title=            | heading search in Org file     |
3203 | =file+sys:/path/to/file=                    | open via OS, like double-click |
3204 | =file+emacs:/path/to/file=                  | force opening by Emacs         |
3205 | =docview:papers/last.pdf::NNN=              | open in doc-view mode at page  |
3206 | =id:B7423F4D-2E8A-471B-8810-C40F074717E9=   | Link to heading by ID          |
3207 | =news:comp.emacs=                           | Usenet link                    |
3208 | =mailto:adent@galaxy.net=                   | Mail link                      |
3209 | =mhe:folder=                                | MH-E folder link               |
3210 | =mhe:folder#id=                             | MH-E message link              |
3211 | =rmail:folder=                              | Rmail folder link              |
3212 | =rmail:folder#id=                           | Rmail message link             |
3213 | =gnus:group=                                | Gnus group link                |
3214 | =gnus:group#id=                             | Gnus article link              |
3215 | =bbdb:R.*Stallman=                          | BBDB link (with regexp)        |
3216 | =irc:/irc.com/#emacs/bob=                   | IRC link                       |
3217 | =info:org#External links=                   | Info node link                 |
3218 | =shell:ls *.org=                            | A shell command                |
3219 | =elisp:org-agenda=                          | Interactive Elisp command      |
3220 | =elisp:(find-file-other-frame "Elisp.org")= | Elisp form to evaluate         |
3222 #+cindex: VM links
3223 #+cindex: Wanderlust links
3224 On top of these built-in link types, some are available through the
3225 =contrib/= directory (see [[*Installation]]).  For example, these links to
3226 VM or Wanderlust messages are available when you load the
3227 corresponding libraries from the =contrib/= directory:
3229 | =vm:folder=                            | VM folder link          |
3230 | =vm:folder#id=                         | VM message link         |
3231 | =vm://myself@some.where.org/folder#id= | VM on remote machine    |
3232 | =vm-imap:account:folder=               | VM IMAP folder link     |
3233 | =vm-imap:account:folder#id=            | VM IMAP message link    |
3234 | =wl:folder=                            | Wanderlust folder link  |
3235 | =wl:folder#id=                         | Wanderlust message link |
3237 For customizing Org to add new link types, see [[*Adding Hyperlink
3238 Types]].
3240 A link should be enclosed in double brackets and may contain
3241 a descriptive text to be displayed instead of the URL (see [[*Link
3242 Format]]), for example:
3244 : [[http://www.gnu.org/software/emacs/][GNU Emacs]]
3246 #+texinfo: @noindent
3247 If the description is a file name or URL that points to an image, HTML
3248 export (see [[*HTML Export]]) inlines the image as a clickable button.  If
3249 there is no description at all and the link points to an image, that
3250 image is inlined into the exported HTML file.
3252 #+cindex: square brackets, around links
3253 #+cindex: angular brackets, around links
3254 #+cindex: plain text external links
3255 Org also finds external links in the normal text and activates them as
3256 links.  If spaces must be part of the link (for example in
3257 =bbdb:Richard Stallman=), or if you need to remove ambiguities about
3258 the end of the link, enclose them in square or angular brackets.
3260 ** Handling Links
3261 :PROPERTIES:
3262 :DESCRIPTION: Creating, inserting and following.
3263 :END:
3264 #+cindex: links, handling
3266 Org provides methods to create a link in the correct syntax, to insert
3267 it into an Org file, and to follow the link.
3269 #+attr_texinfo: :sep ,
3270 - {{{kbd(C-c l)}}} (~org-store-link~) ::
3272      #+kindex: C-c l
3273      #+findex: org-store-link
3274      #+cindex: storing links
3275      Store a link to the current location.  This is a /global/
3276      command---you must create the key binding yourself---which can
3277      be used in any buffer to create a link.  The link is stored for
3278      later insertion into an Org buffer---see below.  What kind of
3279      link is created depends on the current buffer:
3281      - /Org mode buffers/ ::
3283           For Org files, if there is a =<<target>>= at the cursor, the
3284           link points to the target.  Otherwise it points to the
3285           current headline, which is also the description[fn:28].
3287           #+vindex: org-link-to-org-use-id
3288           #+cindex: CUSTOM_ID, property
3289           #+cindex: ID, property
3290           If the headline has a =CUSTOM_ID= property, store a link to
3291           this custom ID.  In addition or alternatively, depending on
3292           the value of ~org-link-to-org-use-id~, create and/or use
3293           a globally unique ID property for the link[fn:29].  So using
3294           this command in Org buffers potentially creates two links:
3295           a human-readable link from the custom ID, and one that is
3296           globally unique and works even if the entry is moved from
3297           file to file.  Later, when inserting the link, you need to
3298           decide which one to use.
3300      - /Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus/ ::
3302           Pretty much all Emacs mail clients are supported.  The link
3303           points to the current article, or, in some Gnus buffers, to
3304           the group.  The description is constructed from the author
3305           and the subject.
3307      - /Web browsers: W3 and W3M/ ::
3309           Here the link is the current URL, with the page title as
3310           description.
3312      - /Contacts: BBDB/ ::
3314           Links created in a BBDB buffer point to the current entry.
3316      - /Chat: IRC/ ::
3318           #+vindex: org-irc-links-to-logs
3319           For IRC links, if the variable ~org-irc-link-to-logs~ is
3320           non-~nil~, create a =file= style link to the relevant point
3321           in the logs for the current conversation.  Otherwise store
3322           an =irc= style link to the user/channel/server under the
3323           point.
3325      - /Other files/ ::
3327           For any other files, the link points to the file, with
3328           a search string (see [[*Search Options in File Links]]) pointing
3329           to the contents of the current line.  If there is an active
3330           region, the selected words form the basis of the search
3331           string.  If the automatically created link is not working
3332           correctly or accurately enough, you can write custom
3333           functions to select the search string and to do the search
3334           for particular file types (see [[*Custom Searches]]).  The key
3335           binding {{{kbd(C-c l)}}} is only a suggestion (see
3336           [[*Installation]]).
3338      - /Agenda view/ ::
3340           When the cursor is in an agenda view, the created link
3341           points to the entry referenced by the current line.
3343 - {{{kbd(C-c C-l)}}} (~org-insert-link~) ::
3345      #+kindex: C-c C-l
3346      #+findex: org-insert-link
3347      #+cindex: link completion
3348      #+cindex: completion, of links
3349      #+cindex: inserting links
3350      #+vindex: org-keep-stored-link-after-insertion
3351      Insert a link[fn:30].  This prompts for a link to be inserted
3352      into the buffer.  You can just type a link, using text for an
3353      internal link, or one of the link type prefixes mentioned in the
3354      examples above.  The link is inserted into the buffer, along with
3355      a descriptive text[fn:31].  If some text was selected at this
3356      time, it becomes the default description.
3358      - /Inserting stored links/ ::
3360           All links stored during the current session are part of the
3361           history for this prompt, so you can access them with
3362           {{{kbd(up)}}} and {{{kbd(down)}}} (or {{{kbd(M-p)}}},
3363           {{{kbd(M-n)}}}).
3365      - /Completion support/ ::
3367           Completion with {{{kbd(TAB)}}} helps you to insert valid
3368           link prefixes like =http= or =ftp=, including the prefixes
3369           defined through link abbreviations (see [[*Link
3370           Abbreviations]]).  If you press {{{kbd(RET)}}} after inserting
3371           only the prefix, Org offers specific completion support for
3372           some link types[fn:32].  For example, if you type {{{kbd(f
3373           i l e RET)}}}---alternative access: {{{kbd(C-u C-c C-l)}}},
3374           see below---Org offers file name completion, and after
3375           {{{kbd(b b d b RET)}}} you can complete contact names.
3377 - {{{kbd(C-u C-c C-l)}}} ::
3379      #+cindex: file name completion
3380      #+cindex: completion, of file names
3381      #+kindex: C-u C-c C-l
3382      When {{{kbd(C-c C-l)}}} is called with a {{{kbd(C-u)}}} prefix
3383      argument, insert a link to a file.  You may use file name
3384      completion to select the name of the file.  The path to the file
3385      is inserted relative to the directory of the current Org file, if
3386      the linked file is in the current directory or in a sub-directory
3387      of it, or if the path is written relative to the current
3388      directory using =../=.  Otherwise an absolute path is used, if
3389      possible with =~/= for your home directory.  You can force an
3390      absolute path with two {{{kbd(C-u)}}} prefixes.
3392 - {{{kbd(C-c C-l)}}} (with cursor on existing link) ::
3394      #+cindex: following links
3395      When the cursor is on an existing link, {{{kbd(C-c C-l)}}} allows
3396      you to edit the link and description parts of the link.
3398      - {{{kbd(C-c C-o)}}} (~org-open-at-point~) ::
3400           #+kindex: C-c C-o
3401           #+findex: org-open-at-point
3402           #+vindex: org-file-apps
3403           #+vindex: org-link-frame-setup
3404           Open link at point.  This launches a web browser for URL
3405           (using ~browse-url-at-point~), run
3406           VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for the corresponding
3407           links, and execute the command in a shell link.  When the
3408           cursor is on an internal link, this command runs the
3409           corresponding search.  When the cursor is on a TAG list in
3410           a headline, it creates the corresponding TAGS view.  If the
3411           cursor is on a timestamp, it compiles the agenda for that
3412           date.  Furthermore, it visits text and remote files in
3413           =file= links with Emacs and select a suitable application
3414           for local non-text files.  Classification of files is based
3415           on file extension only.  See option ~org-file-apps~.  If you
3416           want to override the default application and visit the file
3417           with Emacs, use a {{{kbd(C-u)}}} prefix.  If you want to
3418           avoid opening in Emacs, use a {{{kbd(C-u C-u)}}} prefix. \\
3419           If the cursor is on a headline, but not on a link, offer all
3420           links in the headline and entry text.  If you want to setup
3421           the frame configuration for following links, customize
3422           ~org-link-frame-setup~.
3424      - {{{kbd(RET)}}} ::
3426           #+vindex: org-return-follows-link
3427           #+kindex: RET
3428           When ~org-return-follows-link~ is set, {{{kbd(RET)}}} also
3429           follows the link at point.
3431      - {{{kbd(mouse-2)}}} or {{{kbd(mouse-1)}}} ::
3433           #+kindex: mouse-2
3434           #+kindex: mouse-1
3435           On links, {{{kbd(mouse-1)}}} and {{{kbd(mouse-2)}}} opens
3436           the link just as {{{kbd(C-c C-o)}}} does.
3438      - {{{kbd(mouse-3)}}} ::
3440           #+vindex: org-display-internal-link-with-indirect-buffer
3441           #+kindex: mouse-3
3442           Like {{{kbd(mouse-2)}}}, but force file links to be opened
3443           with Emacs, and internal links to be displayed in another
3444           window[fn:33].
3446      - {{{kbd(C-c C-x C-v)}}} (~org-toggle-inline-images~) ::
3448           #+cindex: inlining images
3449           #+cindex: images, inlining
3450           #+vindex: org-startup-with-inline-images
3451           #+kindex: C-c C-x C-v
3452           #+findex: org-toggle-inline-images
3453           Toggle the inline display of linked images.  Normally this
3454           only inlines images that have no description part in the
3455           link, i.e., images that are inlined during export.  When
3456           called with a prefix argument, also display images that do
3457           have a link description.  You can ask for inline images to
3458           be displayed at startup by configuring the variable
3459           ~org-startup-with-inline-images~[fn:34].
3461      - {{{kbd(C-c %)}}} (~org-mark-ring-push~) ::
3463           #+kindex: C-c %
3464           #+findex: org-mark-ring-push
3465           #+cindex: mark ring
3466           Push the current position onto the mark ring, to be able to
3467           return easily.  Commands following an internal link do this
3468           automatically.
3470      - {{{kbd(C-c &)}}} (~org-mark-ring-goto~) ::
3472           #+kindex: C-c &
3473           #+findex: org-mark-ring-goto
3474           #+cindex: links, returning to
3475           Jump back to a recorded position.  A position is recorded by
3476           the commands following internal links, and by {{{kbd(C-c
3477           %)}}}.  Using this command several times in direct
3478           succession moves through a ring of previously recorded
3479           positions.
3481 - {{{kbd(C-c C-x C-n)}}} (~org-next-link~), {{{kbd(C-c C-x C-p)}}} (~org-previous-link~) ::
3483      #+kindex: C-c C-x C-p
3484      #+findex: org-previous-link
3485      #+kindex: C-c C-x C-n
3486      #+findex: org-next-link
3487      #+cindex: links, finding next/previous
3488      Move forward/backward to the next link in the buffer.  At the
3489      limit of the buffer, the search fails once, and then wraps
3490      around.  The key bindings for this are really too long; you might
3491      want to bind this also to {{{kbd(C-n)}}} and {{{kbd(C-p)}}}.
3493      #+begin_src emacs-lisp
3494        (add-hook 'org-load-hook
3495                  (lambda ()
3496                    (define-key org-mode-map "\C-n" 'org-next-link)
3497                    (define-key org-mode-map "\C-p" 'org-previous-link)))
3498      #+end_src
3500 ** Using Links Outside Org
3501 :PROPERTIES:
3502 :DESCRIPTION: Linking from my C source code?
3503 :END:
3505 You can insert and follow links that have Org syntax not only in Org,
3506 but in any Emacs buffer.  For this, you should create two global
3507 commands, like this (please select suitable global keys yourself):
3509 #+begin_src emacs-lisp
3510   (global-set-key "\C-c L" 'org-insert-link-global)
3511   (global-set-key "\C-c o" 'org-open-at-point-global)
3512 #+end_src
3514 ** Link Abbreviations
3515 :PROPERTIES:
3516 :DESCRIPTION: Shortcuts for writing complex links.
3517 :END:
3518 #+cindex: link abbreviations
3519 #+cindex: abbreviation, links
3521 Long URL can be cumbersome to type, and often many similar links are
3522 needed in a document.  For this you can use link abbreviations.  An
3523 abbreviated link looks like this
3525 : [[linkword:tag][description]]
3527 #+texinfo: @noindent
3528 #+vindex: org-link-abbrev-alist
3529 where the tag is optional.  The /linkword/ must be a word, starting
3530 with a letter, followed by letters, numbers, =-=, and =_=.
3531 Abbreviations are resolved according to the information in the
3532 variable ~org-link-abbrev-alist~ that relates the linkwords to
3533 replacement text.  Here is an example:
3535 #+begin_src emacs-lisp
3536   (setq org-link-abbrev-alist
3537         '(("bugzilla"  . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3538           ("url-to-ja" . "http://translate.google.fr/translate?sl=en&tl=ja&u=%h")
3539           ("google"    . "http://www.google.com/search?q=")
3540           ("gmap"      . "http://maps.google.com/maps?q=%s")
3541           ("omap"      . "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")
3542           ("ads"       . "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?author=%s&db_key=AST")))
3543 #+end_src
3545 If the replacement text contains the string =%s=, it is replaced with
3546 the tag.  Using =%h= instead of =%s= percent-encodes the tag (see the
3547 example above, where we need to encode the URL parameter).  Using
3548 =%(my-function)= passes the tag to a custom function, and replace it
3549 by the resulting string.
3551 If the replacement text do not contain any specifier, it is simply
3552 appended to the string in order to create the link.
3554 Instead of a string, you may also specify a function that will be
3555 called with the tag as the only argument to create the link.
3557 With the above setting, you could link to a specific bug with
3558 =[[bugzilla:129]]=, search the web for =OrgMode= with =[[google:OrgMode]]=,
3559 show the map location of the Free Software Foundation =[[gmap:51
3560 Franklin Street, Boston]]= or of Carsten office =[[omap:Science Park 904,
3561 Amsterdam, The Netherlands]]= and find out what the Org author is doing
3562 besides Emacs hacking with =[[ads:Dominik,C]]=.
3564 If you need special abbreviations just for a single Org buffer, you
3565 can define them in the file with
3567 #+cindex: LINK, keyword
3568 #+begin_example
3569   ,#+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3570   ,#+LINK: google    http://www.google.com/search?q=%s
3571 #+end_example
3573 #+texinfo: @noindent
3574 In-buffer completion (see [[*Completion]]) can be used after =[= to
3575 complete link abbreviations.  You may also define a function that
3576 implements special (e.g., completion) support for inserting such
3577 a link with {{{kbd(C-c C-l)}}}.  Such a function should not accept any
3578 arguments, and return the full link with prefix.  You can set the link
3579 completion function like this:
3581 #+BEGIN_SRC emacs-lisp
3582   (org-link-set-parameter "type" :complete #'some-completion-function)
3583 #+END_SRC
3585 ** Search Options in File Links
3586 :PROPERTIES:
3587 :DESCRIPTION: Linking to a specific location.
3588 :ALT_TITLE: Search Options
3589 :END:
3590 #+cindex: search option in file links
3591 #+cindex: file links, searching
3593 File links can contain additional information to make Emacs jump to
3594 a particular location in the file when following a link.  This can be
3595 a line number or a search option after a double colon[fn:35].  For
3596 example, when the command {{{kbd(C-c l)}}} creates a link (see
3597 [[*Handling Links]]) to a file, it encodes the words in the current line
3598 as a search string that can be used to find this line back later when
3599 following the link with {{{kbd(C-c C-o)}}}.
3601 Here is the syntax of the different ways to attach a search to a file
3602 link, together with an explanation:
3604 #+begin_example
3605   [[file:~/code/main.c::255]]
3606   [[file:~/xx.org::My Target]]
3607   [[file:~/xx.org::*My Target]]
3608   [[file:~/xx.org::#my-custom-id]]
3609   [[file:~/xx.org::/regexp/]]
3610 #+end_example
3612 - =255= ::
3614      Jump to line 255.
3616 - =My Target= ::
3618      Search for a link target =<<My Target>>=, or do a text search for
3619      =my target=, similar to the search in internal links, see
3620      [[*Internal Links]].  In HTML export (see [[*HTML Export]]), such a file
3621      link becomes a HTML reference to the corresponding named anchor
3622      in the linked file.
3624 - =*My Target= ::
3626      In an Org file, restrict search to headlines.
3628 - =#my-custom-id= ::
3630      Link to a heading with a =CUSTOM_ID= property
3632 - =/REGEXP/= ::
3634      Do a regular expression search for {{{var(REGEXP)}}}.  This uses
3635      the Emacs command ~occur~ to list all matches in a separate
3636      window.  If the target file is in Org mode, ~org-occur~ is used
3637      to create a sparse tree with the matches.
3639 As a degenerate case, a file link with an empty file name can be used
3640 to search the current file.  For example, =[[file:::find me]]= does
3641 a search for =find me= in the current file, just as =[[find me]]= would.
3643 ** Custom Searches
3644 :PROPERTIES:
3645 :DESCRIPTION: When the default search is not enough.
3646 :END:
3647 #+cindex: custom search strings
3648 #+cindex: search strings, custom
3650 The default mechanism for creating search strings and for doing the
3651 actual search related to a file link may not work correctly in all
3652 cases.  For example, BibTeX database files have many entries like
3653 ~year="1993"~ which would not result in good search strings, because
3654 the only unique identification for a BibTeX entry is the citation key.
3656 #+vindex: org-create-file-search-functions
3657 #+vindex: org-execute-file-search-functions
3658 If you come across such a problem, you can write custom functions to
3659 set the right search string for a particular file type, and to do the
3660 search for the string in the file.  Using ~add-hook~, these functions
3661 need to be added to the hook variables
3662 ~org-create-file-search-functions~ and
3663 ~org-execute-file-search-functions~.  See the docstring for these
3664 variables for more information.  Org actually uses this mechanism for
3665 BibTeX database files, and you can use the corresponding code as an
3666 implementation example.  See the file =org-bibtex.el=.
3668 * TODO Items
3669 :PROPERTIES:
3670 :DESCRIPTION: Every tree branch can be a TODO item.
3671 :END:
3672 #+cindex: TODO items
3674 Org mode does not maintain TODO lists as separate documents[fn:36].
3675 Instead, TODO items are an integral part of the notes file, because
3676 TODO items usually come up while taking notes!  With Org mode, simply
3677 mark any entry in a tree as being a TODO item.  In this way,
3678 information is not duplicated, and the entire context from which the
3679 TODO item emerged is always present.
3681 Of course, this technique for managing TODO items scatters them
3682 throughout your notes file.  Org mode compensates for this by
3683 providing methods to give you an overview of all the things that you
3684 have to do.
3686 ** Basic TODO Functionality
3687 :PROPERTIES:
3688 :DESCRIPTION: Marking and displaying TODO entries.
3689 :ALT_TITLE: TODO Basics
3690 :END:
3692 Any headline becomes a TODO item when it starts with the word =TODO=,
3693 for example:
3695 : *** TODO Write letter to Sam Fortune
3697 #+texinfo: @noindent
3698 The most important commands to work with TODO entries are:
3700 - {{{kbd(C-c C-t)}}} (~org-todo~) ::
3702      #+kindex: C-c C-t
3703      #+cindex: cycling, of TODO states
3704      Rotate the TODO state of the current item among
3706      #+begin_example
3707      ,-> (unmarked) -> TODO -> DONE --.
3708      '--------------------------------'
3709      #+end_example
3711      If TODO keywords have fast access keys (see [[*Fast access to
3712      TODO states]]), prompt for a TODO keyword through the fast
3713      selection interface; this is the default behavior when
3714      ~org-use-fast-todo-selection~ is non-~nil~.
3716      The same rotation can also be done "remotely" from the timeline
3717      and agenda buffers with the {{{kbd(t)}}} command key (see
3718      [[*Commands in the Agenda Buffer]]).
3720 - {{{kbd(C-u C-c C-t)}}} ::
3722      #+kindex: C-u C-c C-t
3723      When TODO keywords have no selection keys, select a specific
3724      keyword using completion; otherwise force cycling through TODO
3725      states with no prompt.  When ~org-use-fast-todo-selection~ is set
3726      to ~prefix~, use the fast selection interface.
3728 - {{{kbd(S-right)}}} {{{kbd(S-left)}}} ::
3730      #+kindex: S-right
3731      #+kindex: S-left
3732      #+vindex: org-treat-S-cursor-todo-selection-as-state-change
3733      Select the following/preceding TODO state, similar to cycling.
3734      Useful mostly if more than two TODO states are possible (see
3735      [[*Extended Use of TODO Keywords]]).  See also [[*Packages that
3736      conflict with Org mode]], for a discussion of the interaction with
3737      ~shift-selection-mode~.  See also the variable
3738      ~org-treat-S-cursor-todo-selection-as-state-change~.
3740 - {{{kbd(C-c / t)}}} (~org-show-todo-tree~) ::
3742      #+kindex: C-c / t
3743      #+cindex: sparse tree, for TODO
3744      #+vindex: org-todo-keywords
3745      #+findex: org-show-todo-tree
3746      View TODO items in a /sparse tree/ (see [[*Sparse Trees]]).  Folds
3747      the entire buffer, but shows all TODO items---with not-DONE
3748      state---and the headings hierarchy above them.  With a prefix
3749      argument, or by using {{{kbd(C-c / T)}}}, search for a specific
3750      TODO.  You are prompted for the keyword, and you can also give
3751      a list of keywords like =KWD1|KWD2|...= to list entries that
3752      match any one of these keywords.  With a numeric prefix argument
3753      N, show the tree for the Nth keyword in the variable
3754      ~org-todo-keywords~.  With two prefix arguments, find all TODO
3755      states, both un-done and done.
3757 - {{{kbd(C-c a t)}}} (~org-todo-list~) ::
3759      #+kindex: C-c a t
3760      Show the global TODO list.  Collects the TODO items (with
3761      not-DONE states) from all agenda files (see [[*Agenda Views]]) into
3762      a single buffer.  The new buffer is in Org Agenda mode, which
3763      provides commands to examine and manipulate the TODO entries from
3764      the new buffer (see [[*Commands in the Agenda Buffer]]).  See [[*The
3765      global TODO list]], for more information.
3767 - {{{kbd(S-M-RET)}}} (~org-insert-todo-heading~) ::
3769      #+kindex: S-M-RET
3770      #+findex: org-insert-todo-heading
3771      Insert a new TODO entry below the current one.
3773 #+vindex: org-todo-state-tags-triggers
3774 #+texinfo: @noindent
3775 Changing a TODO state can also trigger tag changes.  See the docstring
3776 of the option ~org-todo-state-tags-triggers~ for details.
3778 ** Extended Use of TODO Keywords
3779 :PROPERTIES:
3780 :DESCRIPTION: Workflow and assignments.
3781 :ALT_TITLE: TODO Extensions
3782 :END:
3783 #+cindex: extended TODO keywords
3785 #+vindex: org-todo-keywords
3786 By default, marked TODO entries have one of only two states: TODO and
3787 DONE.  Org mode allows you to classify TODO items in more complex ways
3788 with /TODO keywords/ (stored in ~org-todo-keywords~).  With special
3789 setup, the TODO keyword system can work differently in different
3790 files.
3792 Note that /tags/ are another way to classify headlines in general and
3793 TODO items in particular (see [[*Tags]]).
3795 *** TODO keywords as workflow states
3796 :PROPERTIES:
3797 :DESCRIPTION: From TODO to DONE in steps.
3798 :ALT_TITLE: Workflow states
3799 :END:
3800 #+cindex: TODO workflow
3801 #+cindex: workflow states as TODO keywords
3803 You can use TODO keywords to indicate different /sequential/ states in
3804 the process of working on an item, for example[fn:37]:
3806 #+begin_src emacs-lisp
3807   (setq org-todo-keywords
3808         '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3809 #+end_src
3811 The vertical bar separates the TODO keywords (states that /need
3812 action/) from the DONE states (which need /no further action/).  If
3813 you do not provide the separator bar, the last state is used as the
3814 DONE state.
3816 #+cindex: completion, of TODO keywords
3817 With this setup, the command {{{kbd(C-c C-t)}}} cycles an entry from
3818 =TODO= to =FEEDBACK=, then to =VERIFY=, and finally to =DONE= and
3819 =DELEGATED=.  You may also use a numeric prefix argument to quickly
3820 select a specific state.  For example {{{kbd(C-3 C-c C-t)}}} changes
3821 the state immediately to =VERIFY=.  Or you can use {{{kbd(S-left)}}}
3822 to go backward through the sequence.  If you define many keywords, you
3823 can use in-buffer completion (see [[*Completion]]) or even a special
3824 one-key selection scheme (see [[*Fast access to TODO states]]) to insert
3825 these words into the buffer.  Changing a TODO state can be logged with
3826 a timestamp, see [[*Tracking TODO state changes]], for more information.
3828 *** TODO keywords as types
3829 :PROPERTIES:
3830 :DESCRIPTION: I do this, Fred does the rest.
3831 :ALT_TITLE: TODO types
3832 :END:
3833 #+cindex: TODO types
3834 #+cindex: names as TODO keywords
3835 #+cindex: types as TODO keywords
3837 The second possibility is to use TODO keywords to indicate different
3838 /types/ of action items.  For example, you might want to indicate that
3839 items are for "work" or "home".  Or, when you work with several people
3840 on a single project, you might want to assign action items directly to
3841 persons, by using their names as TODO keywords.  This would be set up
3842 like this:
3844 #+begin_src emacs-lisp
3845   (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3846 #+end_src
3848 In this case, different keywords do not indicate a sequence, but
3849 rather different types.  So the normal work flow would be to assign
3850 a task to a person, and later to mark it DONE.  Org mode supports this
3851 style by adapting the workings of the command {{{kbd(C-c
3852 C-t)}}}[fn:38].  When used several times in succession, it still
3853 cycles through all names, in order to first select the right type for
3854 a task.  But when you return to the item after some time and execute
3855 {{{kbd(C-c C-t)}}} again, it will switch from any name directly to
3856 =DONE=.  Use prefix arguments or completion to quickly select
3857 a specific name.  You can also review the items of a specific TODO
3858 type in a sparse tree by using a numeric prefix to {{{kbd(C-c / t)}}}.
3859 For example, to see all things Lucy has to do, you would use
3860 {{{kbd(C-3 C-c / t)}}}.  To collect Lucy's items from all agenda files
3861 into a single buffer, you would use the numeric prefix argument as
3862 well when creating the global TODO list: {{{kbd(C-3 C-c a t)}}}.
3864 *** Multiple keyword sets in one file
3865 :PROPERTIES:
3866 :DESCRIPTION: Mixing it all, still finding your way.
3867 :ALT_TITLE: Multiple sets in one file
3868 :END:
3869 #+cindex: TODO keyword sets
3871 Sometimes you may want to use different sets of TODO keywords in
3872 parallel.  For example, you may want to have the basic TODO/DONE, but
3873 also a workflow for bug fixing, and a separate state indicating that
3874 an item has been canceled---so it is not DONE, but also does not
3875 require action.  Your setup would then look like this:
3877 #+begin_src emacs-lisp
3878   (setq org-todo-keywords
3879         '((sequence "TODO" "|" "DONE")
3880           (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3881           (sequence "|" "CANCELED")))
3882 #+end_src
3884 The keywords should all be different, this helps Org mode to keep
3885 track of which subsequence should be used for a given entry.  In this
3886 setup, {{{kbd(C-c C-t)}}} only operates within a subsequence, so it
3887 switches from =DONE= to (nothing) to =TODO=, and from =FIXED= to
3888 (nothing) to =REPORT=.  Therefore you need a mechanism to initially
3889 select the correct sequence.  Besides the obvious ways like typing
3890 a keyword or using completion, you may also apply the following
3891 commands:
3893 #+attr_texinfo: :sep ,
3894 - {{{kbd(C-u C-u C-c C-t)}}}, {{{kbd(C-S-right)}}}, {{{kbd(C-S-left)}}} ::
3896      #+kindex: C-S-right
3897      #+kindex: C-S-left
3898      #+kindex: C-u C-u C-c C-t
3899      These keys jump from one TODO subset to the next.  In the above
3900      example, {{{kbd(C-u C-u C-c C-t)}}} or {{{kbd(C-S-right)}}} would
3901      jump from =TODO= or =DONE= to =REPORT=, and any of the words in
3902      the second row to =CANCELED=.  Note that the {{{kbd(C-S-)}}} key
3903      binding conflict with ~shift-selection-mode~ (see [[*Packages
3904      that conflict with Org mode]]).
3906 - {{{kbd(S-right)}}}, {{{kbd(S-left)}}} ::
3908      #+kindex: S-right
3909      #+kindex: S-left
3910      {{{kbd(S-left)}}} and {{{kbd(S-right)}}} walk through /all/
3911      keywords from all sets, so for example {{{kbd(S-right)}}} would
3912      switch from =DONE= to =REPORT= in the example above.  For
3913      a discussion of the interaction with ~shift-selection-mode~, see
3914      [[*Packages that conflict with Org mode]].
3916 *** Fast access to TODO states
3917 :PROPERTIES:
3918 :DESCRIPTION: Single letter selection of state.
3919 :END:
3921 If you would like to quickly change an entry to an arbitrary TODO
3922 state instead of cycling through the states, you can set up keys for
3923 single-letter access to the states.  This is done by adding the
3924 selection character after each keyword, in parentheses[fn:39].  For
3925 example:
3927 #+begin_src emacs-lisp
3928   (setq org-todo-keywords
3929         '((sequence "TODO(t)" "|" "DONE(d)")
3930           (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3931           (sequence "|" "CANCELED(c)")))
3932 #+end_src
3934 #+vindex: org-fast-tag-selection-include-todo
3935 If you then press {{{kbd(C-c C-t)}}} followed by the selection key,
3936 the entry is switched to this state.  {{{kbd(SPC)}}} can be used to
3937 remove any TODO keyword from an entry[fn:40].
3939 *** Setting up keywords for individual files
3940 :PROPERTIES:
3941 :DESCRIPTION: Different files, different requirements.
3942 :ALT_TITLE: Per-file keywords
3943 :END:
3944 #+cindex: keyword options
3945 #+cindex: per-file keywords
3946 #+cindex: TODO, keyword
3947 #+cindex: TYP_TODO, keyword
3948 #+cindex: SEQ_TODO, keyword
3950 It can be very useful to use different aspects of the TODO mechanism
3951 in different files.  For file-local settings, you need to add special
3952 lines to the file which set the keywords and interpretation for that
3953 file only.  For example, to set one of the two examples discussed
3954 above, you need one of the following lines, starting in column zero
3955 anywhere in the file:
3957 : #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3959 #+texinfo: @noindent
3960 you may also write =#+SEQ_TODO= to be explicit about the
3961 interpretation, but it means the same as =#+TODO=, or
3963 : #+TYP_TODO: Fred Sara Lucy Mike | DONE
3965 A setup for using several sets in parallel would be:
3967 #+begin_example
3968   ,#+TODO: TODO | DONE
3969   ,#+TODO: REPORT BUG KNOWNCAUSE | FIXED
3970   ,#+TODO: | CANCELED
3971 #+end_example
3973 #+cindex: completion, of option keywords
3974 #+kindex: M-TAB
3975 #+texinfo: @noindent
3976 To make sure you are using the correct keyword, type =#+= into the
3977 buffer and then use {{{kbd(M-TAB)}}} completion.
3979 #+cindex: DONE, final TODO keyword
3980 Remember that the keywords after the vertical bar---or the last
3981 keyword if no bar is there---must always mean that the item is DONE,
3982 although you may use a different word.  After changing one of these
3983 lines, use {{{kbd(C-c C-c)}}} with the cursor still in the line to
3984 make the changes known to Org mode[fn:41].
3986 *** Faces for TODO keywords
3987 :PROPERTIES:
3988 :DESCRIPTION: Highlighting states.
3989 :END:
3990 #+cindex: faces, for TODO keywords
3992 #+vindex: org-todo, face
3993 #+vindex: org-done, face
3994 #+vindex: org-todo-keyword-faces
3995 Org mode highlights TODO keywords with special faces: ~org-todo~ for
3996 keywords indicating that an item still has to be acted upon, and
3997 ~org-done~ for keywords indicating that an item is finished.  If you
3998 are using more than two different states, you might want to use
3999 special faces for some of them.  This can be done using the variable
4000 ~org-todo-keyword-faces~.  For example:
4002 #+begin_src emacs-lisp
4003   (setq org-todo-keyword-faces
4004         '(("TODO" . org-warning) ("STARTED" . "yellow")
4005           ("CANCELED" . (:foreground "blue" :weight bold))))
4006 #+end_src
4008 #+vindex: org-faces-easy-properties
4009 While using a list with face properties as shown for =CANCELED=
4010 /should/ work, this does not always seem to be the case.  If
4011 necessary, define a special face and use that.  A string is
4012 interpreted as a color.  The variable ~org-faces-easy-properties~
4013 determines if that color is interpreted as a foreground or
4014 a background color.
4016 *** TODO dependencies
4017 :PROPERTIES:
4018 :DESCRIPTION: When one task needs to wait for others.
4019 :END:
4020 #+cindex: TODO dependencies
4021 #+cindex: dependencies, of TODO states
4023 #+vindex: org-enforce-todo-dependencies
4024 #+cindex: ORDERED, property
4025 The structure of Org files---hierarchy and lists---makes it easy to
4026 define TODO dependencies.  Usually, a parent TODO task should not be
4027 marked DONE until all subtasks, defined as children tasks, are marked
4028 as DONE.  And sometimes there is a logical sequence to a number of
4029 (sub)tasks, so that one task cannot be acted upon before all siblings
4030 above it are done.  If you customize the variable
4031 ~org-enforce-todo-dependencies~, Org blocks entries from changing
4032 state to DONE while they have children that are not DONE.
4033 Furthermore, if an entry has a property =ORDERED=, each of its
4034 children is blocked until all earlier siblings are marked DONE.  Here
4035 is an example:
4037 #+begin_example
4038   ,* TODO Blocked until (two) is done
4039   ,** DONE one
4040   ,** TODO two
4042   ,* Parent
4043   :PROPERTIES:
4044   :ORDERED:  t
4045   :END:
4046   ,** TODO a
4047   ,** TODO b, needs to wait for (a)
4048   ,** TODO c, needs to wait for (a) and (b)
4049 #+end_example
4051 #+cindex: TODO dependencies, NOBLOCKING
4052 #+cindex: NOBLOCKING, property
4053 You can ensure an entry is never blocked by using the =NOBLOCKING=
4054 property:
4056 #+begin_example
4057   ,* This entry is never blocked
4058   :PROPERTIES:
4059   :NOBLOCKING: t
4060   :END:
4061 #+end_example
4063 - {{{kbd(C-c C-x o)}}} (~org-toggle-ordered-property~) ::
4065      #+kindex: C-c C-x o
4066      #+findex: org-toggle-ordered-property
4067      #+vindex: org-track-ordered-property-with-tag
4068      #+cindex: ORDERED, property
4069      Toggle the =ORDERED= property of the current entry.  A property
4070      is used for this behavior because this should be local to the
4071      current entry, not inherited like a tag.  However, if you would
4072      like to /track/ the value of this property with a tag for better
4073      visibility, customize the variable
4074      ~org-track-ordered-property-with-tag~.
4076 - {{{kbd(C-u C-u C-u C-c C-t)}}} ::
4078      #+kindex: C-u C-u C-u C-c C-t
4079      Change TODO state, circumventing any state blocking.
4081 #+vindex: org-agenda-dim-blocked-tasks
4082 If you set the variable ~org-agenda-dim-blocked-tasks~, TODO entries
4083 that cannot be closed because of such dependencies are shown in
4084 a dimmed font or even made invisible in agenda views (see [[*Agenda
4085 Views]]).
4087 #+cindex: checkboxes and TODO dependencies
4088 #+vindex: org-enforce-todo-dependencies
4089 You can also block changes of TODO states by looking at checkboxes
4090 (see [[*Checkboxes]]).  If you set the variable
4091 ~org-enforce-todo-checkbox-dependencies~, an entry that has unchecked
4092 checkboxes is blocked from switching to DONE.
4094 If you need more complex dependency structures, for example
4095 dependencies between entries in different trees or files, check out
4096 the contributed module =org-depend.el=.
4098 ** Progress Logging
4099 :PROPERTIES:
4100 :DESCRIPTION: Dates and notes for progress.
4101 :END:
4102 #+cindex: progress logging
4103 #+cindex: logging, of progress
4105 Org mode can automatically record a timestamp and possibly a note when
4106 you mark a TODO item as DONE, or even each time you change the state
4107 of a TODO item.  This system is highly configurable, settings can be
4108 on a per-keyword basis and can be localized to a file or even
4109 a subtree.  For information on how to clock working time for a task,
4110 see [[*Clocking Work Time]].
4112 *** Closing items
4113 :PROPERTIES:
4114 :DESCRIPTION: When was this entry marked DONE?
4115 :END:
4117 The most basic logging is to keep track of /when/ a certain TODO item
4118 was finished.  This is achieved with[fn:42]
4120 #+begin_src emacs-lisp
4121   (setq org-log-done 'time)
4122 #+end_src
4124 #+vindex: org-closed-keep-when-no-todo
4125 #+texinfo: @noindent
4126 Then each time you turn an entry from a TODO (not-done) state into any
4127 of the DONE states, a line =CLOSED: [timestamp]= is inserted just
4128 after the headline.  If you turn the entry back into a TODO item
4129 through further state cycling, that line is removed again.  If you
4130 turn the entry back to a non-TODO state (by pressing {{{kbd(C-c C-t
4131 SPC)}}} for example), that line is also removed, unless you set
4132 ~org-closed-keep-when-no-todo~ to non-~nil~.  If you want to record
4133 a note along with the timestamp, use[fn:43]
4135 #+begin_src emacs-lisp
4136   (setq org-log-done 'note)
4137 #+end_src
4139 #+texinfo: @noindent
4140 You are then be prompted for a note, and that note is stored below the
4141 entry with a =Closing Note= heading.
4143 *** Tracking TODO state changes
4144 :PROPERTIES:
4145 :DESCRIPTION: When did the status change?
4146 :END:
4147 #+cindex: drawer, for state change recording
4149 #+vindex: org-log-states-order-reversed
4150 #+vindex: org-log-into-drawer
4151 #+cindex: LOG_INTO_DRAWER, property
4152 When TODO keywords are used as workflow states (see [[*TODO keywords as workflow states][*Workflow states]]),
4153 you might want to keep track of when a state change occurred and maybe
4154 take a note about this change.  You can either record just
4155 a timestamp, or a time-stamped note for a change.  These records are
4156 inserted after the headline as an itemized list, newest first[fn:44].
4157 When taking a lot of notes, you might want to get the notes out of the
4158 way into a drawer (see [[*Drawers]]).  Customize the variable
4159 ~org-log-into-drawer~ to get this behavior---the recommended drawer
4160 for this is called =LOGBOOK=[fn:45].  You can also overrule the
4161 setting of this variable for a subtree by setting a =LOG_INTO_DRAWER=
4162 property.
4164 Since it is normally too much to record a note for every state, Org
4165 mode expects configuration on a per-keyword basis for this.  This is
4166 achieved by adding special markers =!= (for a timestamp) or =@= (for
4167 a note with timestamp) in parentheses after each keyword.  For
4168 example, with the setting
4170 #+begin_src emacs-lisp
4171   (setq org-todo-keywords
4172         '((sequence "TODO(t)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)")))
4173 #+end_src
4175 To record a timestamp without a note for TODO keywords configured with
4176 =@=, just type {{{kbd(C-c C-c)}}} to enter a blank note when prompted.
4178 #+vindex: org-log-done
4179 #+texinfo: noindent
4180 you not only define global TODO keywords and fast access keys, but
4181 also request that a time is recorded when the entry is set to =DONE=,
4182 and that a note is recorded when switching to =WAIT= or
4183 =CANCELED=[fn:46].  The setting for =WAIT= is even more special: the
4184 =!= after the slash means that in addition to the note taken when
4185 entering the state, a timestamp should be recorded when /leaving/ the
4186 =WAIT= state, if and only if the /target/ state does not configure
4187 logging for entering it.  So it has no effect when switching from
4188 =WAIT= to =DONE=, because =DONE= is configured to record a timestamp
4189 only.  But when switching from =WAIT= back to =TODO=, the =/!= in the
4190 =WAIT= setting now triggers a timestamp even though =TODO= has no
4191 logging configured.
4193 You can use the exact same syntax for setting logging preferences local
4194 to a buffer:
4196 : #+TODO: TODO(t) WAIT(w@/!) | DONE(d!) CANCELED(c@)
4198 #+cindex: LOGGING, property
4199 In order to define logging settings that are local to a subtree or
4200 a single item, define a =LOGGING= property in this entry.  Any
4201 non-empty =LOGGING= property resets all logging settings to ~nil~.
4202 You may then turn on logging for this specific tree using =STARTUP=
4203 keywords like =lognotedone= or =logrepeat=, as well as adding state
4204 specific settings like =TODO(!)=.  For example:
4206 #+begin_example
4207   ,* TODO Log each state with only a time
4208     :PROPERTIES:
4209     :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
4210     :END:
4211   ,* TODO Only log when switching to WAIT, and when repeating
4212     :PROPERTIES:
4213     :LOGGING: WAIT(@) logrepeat
4214     :END:
4215   ,* TODO No logging at all
4216     :PROPERTIES:
4217     :LOGGING: nil
4218     :END:
4219 #+end_example
4221 *** Tracking your habits
4222 :PROPERTIES:
4223 :DESCRIPTION: How consistent have you been?
4224 :END:
4225 #+cindex: habits
4226 #+cindex: STYLE, property
4228 Org has the ability to track the consistency of a special category of
4229 TODO, called "habits."  A habit has the following properties:
4231 1. You have enabled the ~habits~ module by customizing the variable
4232    ~org-modules~.
4234 2. The habit is a TODO item, with a TODO keyword representing an open
4235    state.
4237 3. The property =STYLE= is set to the value =habit=.
4239 4. The TODO has a scheduled date, usually with a =.+= style repeat
4240    interval.  A =++= style may be appropriate for habits with time
4241    constraints, e.g., must be done on weekends, or a =+= style for an
4242    unusual habit that can have a backlog, e.g., weekly reports.
4244 5. The TODO may also have minimum and maximum ranges specified by
4245    using the syntax =.+2d/3d=, which says that you want to do the task
4246    at least every three days, but at most every two days.
4248 6. You must also have state logging for the DONE state enabled (see
4249    [[*Tracking TODO state changes]]), in order for historical data to be
4250    represented in the consistency graph.  If it is not enabled it is
4251    not an error, but the consistency graphs are largely meaningless.
4253 To give you an idea of what the above rules look like in action, here's an
4254 actual habit with some history:
4256 #+begin_example
4257   ,** TODO Shave
4258      SCHEDULED: <2009-10-17 Sat .+2d/4d>
4259      :PROPERTIES:
4260      :STYLE:    habit
4261      :LAST_REPEAT: [2009-10-19 Mon 00:36]
4262      :END:
4263      - State "DONE"       from "TODO"       [2009-10-15 Thu]
4264      - State "DONE"       from "TODO"       [2009-10-12 Mon]
4265      - State "DONE"       from "TODO"       [2009-10-10 Sat]
4266      - State "DONE"       from "TODO"       [2009-10-04 Sun]
4267      - State "DONE"       from "TODO"       [2009-10-02 Fri]
4268      - State "DONE"       from "TODO"       [2009-09-29 Tue]
4269      - State "DONE"       from "TODO"       [2009-09-25 Fri]
4270      - State "DONE"       from "TODO"       [2009-09-19 Sat]
4271      - State "DONE"       from "TODO"       [2009-09-16 Wed]
4272      - State "DONE"       from "TODO"       [2009-09-12 Sat]
4273 #+end_example
4275 What this habit says is: I want to shave at most every 2 days---given
4276 by the =SCHEDULED= date and repeat interval---and at least every
4277 4 days.  If today is the 15th, then the habit first appears in the
4278 agenda on Oct 17, after the minimum of 2 days has elapsed, and will
4279 appear overdue on Oct 19, after four days have elapsed.
4281 What's really useful about habits is that they are displayed along
4282 with a consistency graph, to show how consistent you've been at
4283 getting that task done in the past.  This graph shows every day that
4284 the task was done over the past three weeks, with colors for each day.
4285 The colors used are:
4287 - Blue :: If the task was not to be done yet on that day.
4288 - Green :: If the task could have been done on that day.
4289 - Yellow :: If the task was going to be overdue the next day.
4290 - Red :: If the task was overdue on that day.
4292 In addition to coloring each day, the day is also marked with an
4293 asterisk if the task was actually done that day, and an exclamation
4294 mark to show where the current day falls in the graph.
4296 There are several configuration variables that can be used to change
4297 the way habits are displayed in the agenda.
4299 - ~org-habit-graph-column~ ::
4301      #+vindex: org-habit-graph-column
4302      The buffer column at which the consistency graph should be drawn.
4303      This overwrites any text in that column, so it is a good idea to
4304      keep your habits' titles brief and to the point.
4306 - ~org-habit-preceding-days~ ::
4308      #+vindex: org-habit-preceding-days
4309      The amount of history, in days before today, to appear in
4310      consistency graphs.
4312 - ~org-habit-following-days~ ::
4314      #+vindex: org-habit-following-days
4315      The number of days after today that appear in consistency graphs.
4317 - ~org-habit-show-habits-only-for-today~ ::
4319      #+vindex: org-habit-show-habits-only-for-today
4320      If non-~nil~, only show habits in today's agenda view.  This is
4321      set to true by default.
4323 Lastly, pressing {{{kbd(K)}}} in the agenda buffer causes habits to
4324 temporarily be disabled and do not appear at all.  Press {{{kbd(K)}}}
4325 again to bring them back.  They are also subject to tag filtering, if
4326 you have habits which should only be done in certain contexts, for
4327 example.
4329 ** Priorities
4330 :PROPERTIES:
4331 :DESCRIPTION: Some things are more important than others.
4332 :END:
4333 #+cindex: priorities
4334 #+cindex: priority cookie
4336 If you use Org mode extensively, you may end up with enough TODO items
4337 that it starts to make sense to prioritize them.  Prioritizing can be
4338 done by placing a /priority cookie/ into the headline of a TODO item,
4339 like this
4341 : *** TODO [#A] Write letter to Sam Fortune
4343 #+vindex: org-priority-faces
4344 #+texinfo: @noindent
4345 By default, Org mode supports three priorities: =A=, =B=, and =C=.
4346 =A= is the highest priority.  An entry without a cookie is treated
4347 just like priority =B=.  Priorities make a difference only for sorting
4348 in the agenda (see [[*Weekly/daily agenda]]); outside the agenda, they
4349 have no inherent meaning to Org mode.  The cookies can be highlighted
4350 with special faces by customizing the variable ~org-priority-faces~.
4352 Priorities can be attached to any outline node; they do not need to be
4353 TODO items.
4355 #+attr_texinfo: :sep ;
4356 - {{{kbd(C-c \,)}}} (~org-priority~) ::
4358      #+kindex: C-c ,
4359      #+findex: org-priority
4360      Set the priority of the current headline.  The command prompts
4361      for a priority character =A=, =B= or =C=.  When you press
4362      {{{kbd(SPC)}}} instead, the priority cookie is removed from the
4363      headline.  The priorities can also be changed "remotely" from the
4364      timeline and agenda buffer with the {{{kbd(\,)}}} command (see
4365      [[*Commands in the Agenda Buffer]]).
4367 - {{{kbd(S-up)}}} (~org-priority-up~); {{{kbd(S-down)}}} (~org-priority-down~) ::
4369      #+kindex: S-up
4370      #+kindex: S-down
4371      #+findex: org-priority-up
4372      #+findex: org-priority-down
4373      #+vindex: org-priority-start-cycle-with-default
4374      Increase/decrease priority of current headline[fn:47].  Note that
4375      these keys are also used to modify timestamps (see [[*Creating
4376      Timestamps]]).  See also [[*Packages that conflict with Org mode]], for
4377      a discussion of the interaction with ~shift-selection-mode~.
4379 #+vindex: org-highest-priority
4380 #+vindex: org-lowest-priority
4381 #+vindex: org-default-priority
4382 You can change the range of allowed priorities by setting the
4383 variables ~org-highest-priority~, ~org-lowest-priority~, and
4384 ~org-default-priority~.  For an individual buffer, you may set these
4385 values (highest, lowest, default) like this (please make sure that the
4386 highest priority is earlier in the alphabet than the lowest priority):
4388 #+cindex: PRIORITIES, keyword
4389 : #+PRIORITIES: A C B
4391 ** Breaking Down Tasks into Subtasks
4392 :PROPERTIES:
4393 :DESCRIPTION: Splitting a task into manageable pieces.
4394 :ALT_TITLE: Breaking Down Tasks
4395 :END:
4396 #+cindex: tasks, breaking down
4397 #+cindex: statistics, for TODO items
4399 #+vindex: org-agenda-todo-list-sublevels
4400 It is often advisable to break down large tasks into smaller,
4401 manageable subtasks.  You can do this by creating an outline tree
4402 below a TODO item, with detailed subtasks on the tree[fn:48].  To keep
4403 the overview over the fraction of subtasks that are already completed,
4404 insert either =[/]= or =[%]= anywhere in the headline.  These cookies
4405 are updated each time the TODO status of a child changes, or when
4406 pressing {{{kbd(C-c C-c)}}} on the cookie.  For example:
4408 #+begin_example
4409   ,* Organize Party [33%]
4410   ,** TODO Call people [1/2]
4411   ,*** TODO Peter
4412   ,*** DONE Sarah
4413   ,** TODO Buy food
4414   ,** DONE Talk to neighbor
4415 #+end_example
4417 #+cindex: COOKIE_DATA, property
4418 If a heading has both checkboxes and TODO children below it, the
4419 meaning of the statistics cookie become ambiguous.  Set the property
4420 =COOKIE_DATA= to either =checkbox= or =todo= to resolve this issue.
4422 #+vindex: org-hierarchical-todo-statistics
4423 If you would like to have the statistics cookie count any TODO entries
4424 in the subtree (not just direct children), configure the variable
4425 ~org-hierarchical-todo-statistics~.  To do this for a single subtree,
4426 include the word =recursive= into the value of the =COOKIE_DATA=
4427 property.
4429 #+begin_example org
4430   ,* Parent capturing statistics [2/20]
4431     :PROPERTIES:
4432     :COOKIE_DATA: todo recursive
4433     :END:
4434 #+end_example
4436 If you would like a TODO entry to automatically change to DONE when
4437 all children are done, you can use the following setup:
4439 #+begin_src emacs-lisp
4440   (defun org-summary-todo (n-done n-not-done)
4441     "Switch entry to DONE when all subentries are done, to TODO otherwise."
4442     (let (org-log-done org-log-states)   ; turn off logging
4443       (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
4445   (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
4446 #+end_src
4448 Another possibility is the use of checkboxes to identify (a hierarchy
4449 of) a large number of subtasks (see [[*Checkboxes]]).
4451 ** Checkboxes
4452 :PROPERTIES:
4453 :DESCRIPTION: Tick-off lists.
4454 :END:
4455 #+cindex: checkboxes
4457 #+vindex: org-list-automatic-rules
4458 Every item in a plain list[fn:49] (see [[*Plain Lists]]) can be made into
4459 a checkbox by starting it with the string =[ ]=.  This feature is
4460 similar to TODO items (see [[*TODO Items]]), but is more lightweight.
4461 Checkboxes are not included into the global TODO list, so they are
4462 often great to split a task into a number of simple steps.  Or you can
4463 use them in a shopping list.  To toggle a checkbox, use {{{kbd(C-c
4464 C-c)}}}, or use the mouse (thanks to Piotr Zielinski's
4465 =org-mouse.el=).
4467 Here is an example of a checkbox list.
4469 #+begin_example
4470   ,* TODO Organize party [2/4]
4471     - [-] call people [1/3]
4472       - [ ] Peter
4473       - [X] Sarah
4474       - [ ] Sam
4475     - [X] order food
4476     - [ ] think about what music to play
4477     - [X] talk to the neighbors
4478 #+end_example
4480 Checkboxes work hierarchically, so if a checkbox item has children
4481 that are checkboxes, toggling one of the children checkboxes makes the
4482 parent checkbox reflect if none, some, or all of the children are
4483 checked.
4485 #+cindex: statistics, for checkboxes
4486 #+cindex: checkbox statistics
4487 #+cindex: COOKIE_DATA, property
4488 #+vindex: org-hierarchical-checkbox-statistics
4489 The =[2/4]= and =[1/3]= in the first and second line are cookies
4490 indicating how many checkboxes present in this entry have been checked
4491 off, and the total number of checkboxes present.  This can give you an
4492 idea on how many checkboxes remain, even without opening a folded
4493 entry.  The cookies can be placed into a headline or into (the first
4494 line of) a plain list item.  Each cookie covers checkboxes of direct
4495 children structurally below the headline/item on which the cookie
4496 appears[fn:50].  You have to insert the cookie yourself by typing
4497 either =[/]= or =[%]=.  With =[/]= you get an =n out of m= result, as
4498 in the examples above.  With =[%]= you get information about the
4499 percentage of checkboxes checked (in the above example, this would be
4500 =[50%]= and =[33%]=, respectively).  In a headline, a cookie can count
4501 either checkboxes below the heading or TODO states of children, and it
4502 displays whatever was changed last.  Set the property =COOKIE_DATA= to
4503 either =checkbox= or =todo= to resolve this issue.
4505 #+cindex: blocking, of checkboxes
4506 #+cindex: checkbox blocking
4507 #+cindex: ORDERED, property
4508 If the current outline node has an =ORDERED= property, checkboxes must
4509 be checked off in sequence, and an error is thrown if you try to check
4510 off a box while there are unchecked boxes above it.
4512 #+texinfo: @noindent
4513 The following commands work with checkboxes:
4515 - {{{kbd(C-c C-c)}}} (~org-toggle-checkbox~) ::
4517      #+kindex: C-c C-c
4518      #+findex: org-toggle-checkbox
4519      Toggle checkbox status or---with prefix argument---checkbox
4520      presence at point.  With a single prefix argument, add an empty
4521      checkbox or remove the current one[fn:51].  With a double prefix
4522      argument, set it to =[-]=, which is considered to be an
4523      intermediate state.
4525 - {{{kbd(C-c C-x C-b)}}} (~org-toggle-checkbox~) ::
4527      #+kindex: C-c C-x C-b
4528      Toggle checkbox status or---with prefix argument---checkbox
4529      presence at point.  With double prefix argument, set it to =[-]=,
4530      which is considered to be an intermediate state.
4532      - If there is an active region, toggle the first checkbox in the
4533        region and set all remaining boxes to the same status as the
4534        first.  With a prefix argument, add or remove the checkbox for
4535        all items in the region.
4537      - If the cursor is in a headline, toggle checkboxes in the region
4538        between this headline and the next---so /not/ the entire
4539        subtree.
4541      - If there is no active region, just toggle the checkbox at
4542        point.
4544 - {{{kbd(M-S-RET)}}} (~org-insert-todo-heading~) ::
4546      #+kindex: M-S-RET
4547      #+findex: org-insert-todo-heading
4548      Insert a new item with a checkbox.  This works only if the cursor
4549      is already in a plain list item (see [[*Plain Lists]]).
4551 - {{{kbd(C-c C-x o)}}} (~org-toggle-ordered-property~) ::
4553      #+kindex: C-c C-x o
4554      #+findex: org-toggle-ordered-property
4555      #+vindex: org-track-ordered-property-with-tag
4556      Toggle the =ORDERED= property of the entry, to toggle if
4557      checkboxes must be checked off in sequence.  A property is used
4558      for this behavior because this should be local to the current
4559      entry, not inherited like a tag.  However, if you would like to
4560      /track/ the value of this property with a tag for better
4561      visibility, customize ~org-track-ordered-property-with-tag~.
4563 - {{{kbd(C-c #)}}} (~org-update-statistics-cookies~) ::
4565      #+kindex: C-c #
4566      #+findex: org-update-statistics-cookies
4567      Update the statistics cookie in the current outline entry.  When
4568      called with a {{{kbd(C-u)}}} prefix, update the entire file.
4569      Checkbox statistic cookies are updated automatically if you
4570      toggle checkboxes with {{{kbd(C-c C-c)}}} and make new ones with
4571      {{{kbd(M-S-RET)}}}.  TODO statistics cookies update when changing
4572      TODO states.  If you delete boxes/entries or add/change them by
4573      hand, use this command to get things back into sync.
4575 * Tags
4576 :PROPERTIES:
4577 :DESCRIPTION: Tagging headlines and matching sets of tags.
4578 :END:
4579 #+cindex: tags
4580 #+cindex: headline tagging
4581 #+cindex: matching, tags
4582 #+cindex: sparse tree, tag based
4584 An excellent way to implement labels and contexts for
4585 cross-correlating information is to assign /tags/ to headlines.  Org
4586 mode has extensive support for tags.
4588 #+vindex: org-tag-faces
4589 Every headline can contain a list of tags; they occur at the end of
4590 the headline.  Tags are normal words containing letters, numbers, =_=,
4591 and =@=.  Tags must be preceded and followed by a single colon, e.g.,
4592 =:work:=.  Several tags can be specified, as in =:work:urgent:=.  Tags
4593 by default are in bold face with the same color as the headline.  You
4594 may specify special faces for specific tags using the variable
4595 ~org-tag-faces~, in much the same way as you can for TODO keywords
4596 (see [[*Faces for TODO keywords]]).
4598 ** Tag Inheritance
4599 :PROPERTIES:
4600 :DESCRIPTION: Tags use the tree structure of an outline.
4601 :END:
4602 #+cindex: tag inheritance
4603 #+cindex: inheritance, of tags
4604 #+cindex: sublevels, inclusion into tags match
4606 /Tags/ make use of the hierarchical structure of outline trees.  If
4607 a heading has a certain tag, all subheadings inherit the tag as well.
4608 For example, in the list
4610 #+begin_example
4611   ,* Meeting with the French group      :work:
4612   ,** Summary by Frank                  :boss:notes:
4613   ,*** TODO Prepare slides for him      :action:
4614 #+end_example
4616 #+texinfo: @noindent
4617 the final heading has the tags =work=, =boss=, =notes=, and =action=
4618 even though the final heading is not explicitly marked with those
4619 tags.  You can also set tags that all entries in a file should inherit
4620 just as if these tags were defined in a hypothetical level zero that
4621 surrounds the entire file.  Use a line like this[fn:52]
4623 #+cindex: FILETAGS, keyword
4624 : #+FILETAGS: :Peter:Boss:Secret:
4626 #+vindex: org-use-tag-inheritance
4627 #+vindex: org-tags-exclude-from-inheritance
4628 #+texinfo: @noindent
4629 To limit tag inheritance to specific tags, or to turn it off entirely,
4630 use the variables ~org-use-tag-inheritance~ and
4631 ~org-tags-exclude-from-inheritance~.
4633 #+vindex: org-tags-match-list-sublevels
4634 When a headline matches during a tags search while tag inheritance is
4635 turned on, all the sublevels in the same tree---for a simple match
4636 form---match as well[fn:53].  The list of matches may then become
4637 very long.  If you only want to see the first tags match in a subtree,
4638 configure the variable ~org-tags-match-list-sublevels~ (not
4639 recommended).
4641 #+vindex: org-agenda-use-tag-inheritance
4642 Tag inheritance is relevant when the agenda search tries to match
4643 a tag, either in the ~tags~ or ~tags-todo~ agenda types.  In other
4644 agenda types, ~org-use-tag-inheritance~ has no effect.  Still, you may
4645 want to have your tags correctly set in the agenda, so that tag
4646 filtering works fine, with inherited tags.  Set
4647 ~org-agenda-use-tag-inheritance~ to control this: the default value
4648 includes all agenda types, but setting this to ~nil~ can really speed
4649 up agenda generation.
4651 ** Setting Tags
4652 :PROPERTIES:
4653 :DESCRIPTION: How to assign tags to a headline.
4654 :END:
4655 #+cindex: setting tags
4656 #+cindex: tags, setting
4658 #+kindex: M-TAB
4659 Tags can simply be typed into the buffer at the end of a headline.
4660 After a colon, {{{kbd(M-TAB)}}} offers completion on tags.  There is
4661 also a special command for inserting tags:
4663 - {{{kbd(C-c C-q)}}} (~org-set-tags-command~) ::
4665      #+kindex: C-c C-q
4666      #+findex: org-set-tags-command
4667      #+cindex: completion, of tags
4668      #+vindex: org-tags-column
4669      Enter new tags for the current headline.  Org mode either offers
4670      completion or a special single-key interface for setting tags,
4671      see below.  After pressing {{{kbd(RET)}}}, the tags are inserted
4672      and aligned to ~org-tags-column~.  When called with
4673      a {{{kbd(C-u)}}} prefix, all tags in the current buffer are
4674      aligned to that column, just to make things look nice.  Tags are
4675      automatically realigned after promotion, demotion, and TODO state
4676      changes (see [[*Basic TODO Functionality]]).
4678 - {{{kbd(C-c C-c)}}} (~org-set-tags-command~) ::
4680      #+kindex: C-c C-c
4681      When the cursor is in a headline, this does the same as
4682      {{{kbd(C-c C-q)}}}.
4684 #+vindex: org-tag-alist
4685 Org supports tag insertion based on a /list of tags/.  By default this
4686 list is constructed dynamically, containing all tags currently used in
4687 the buffer.  You may also globally specify a hard list of tags with
4688 the variable ~org-tag-alist~.  Finally you can set the default tags
4689 for a given file with lines like
4691 #+cindex: TAGS, keyword
4692 #+begin_example
4693   ,#+TAGS: @work @home @tennisclub
4694   ,#+TAGS: laptop car pc sailboat
4695 #+end_example
4697 If you have globally defined your preferred set of tags using the
4698 variable ~org-tag-alist~, but would like to use a dynamic tag list in
4699 a specific file, add an empty =TAGS= keyword to that file:
4701 : #+TAGS:
4703 #+vindex: org-tag-persistent-alist
4704 If you have a preferred set of tags that you would like to use in
4705 every file, in addition to those defined on a per-file basis by =TAGS=
4706 keyword, then you may specify a list of tags with the variable
4707 ~org-tag-persistent-alist~.  You may turn this off on a per-file basis
4708 by adding a =STARTUP= keyword to that file:
4710 : #+STARTUP: noptag
4712 By default Org mode uses the standard minibuffer completion facilities
4713 for entering tags.  However, it also implements another, quicker, tag
4714 selection method called /fast tag selection/.  This allows you to
4715 select and deselect tags with just a single key press.  For this to
4716 work well you should assign unique letters to most of your commonly
4717 used tags.  You can do this globally by configuring the variable
4718 ~org-tag-alist~ in your Emacs init file.  For example, you may find
4719 the need to tag many items in different files with =@home=.  In this
4720 case you can set something like:
4722 #+begin_src emacs-lisp
4723   (setq org-tag-alist '(("@work" . ?w) ("@home" . ?h) ("laptop" . ?l)))
4724 #+end_src
4726 #+texinfo: @noindent
4727 If the tag is only relevant to the file you are working on, then you
4728 can instead set the =TAGS= keyword as:
4730 : #+TAGS: @work(w)  @home(h)  @tennisclub(t)  laptop(l)  pc(p)
4732 #+texinfo: @noindent
4733 The tags interface shows the available tags in a splash window.  If
4734 you want to start a new line after a specific tag, insert =\n= into
4735 the tag list
4737 : #+TAGS: @work(w) @home(h) @tennisclub(t) \n laptop(l) pc(p)
4739 #+texinfo: @noindent
4740 or write them in two lines:
4742 #+begin_example
4743   ,#+TAGS: @work(w)  @home(h)  @tennisclub(t)
4744   ,#+TAGS: laptop(l)  pc(p)
4745 #+end_example
4747 #+texinfo: @noindent
4748 You can also group together tags that are mutually exclusive by using
4749 braces, as in:
4751 : #+TAGS: { @work(w)  @home(h)  @tennisclub(t) }  laptop(l)  pc(p)
4753 #+texinfo: @noindent
4754 you indicate that at most one of =@work=, =@home=, and =@tennisclub=
4755 should be selected.  Multiple such groups are allowed.
4757 #+texinfo: @noindent
4758 Do not forget to press {{{kbd(C-c C-c)}}} with the cursor in one of
4759 these lines to activate any changes.
4761 #+texinfo: @noindent
4762 To set these mutually exclusive groups in the variable
4763 ~org-tags-alist~, you must use the dummy tags ~:startgroup~ and
4764 ~:endgroup~ instead of the braces.  Similarly, you can use ~:newline~
4765 to indicate a line break.  The previous example would be set globally
4766 by the following configuration:
4768 #+begin_src emacs-lisp
4769   (setq org-tag-alist '((:startgroup . nil)
4770                         ("@work" . ?w) ("@home" . ?h)
4771                         ("@tennisclub" . ?t)
4772                         (:endgroup . nil)
4773                         ("laptop" . ?l) ("pc" . ?p)))
4774 #+end_src
4776 If at least one tag has a selection key then pressing {{{kbd(C-c
4777 C-c)}}} automatically presents you with a special interface, listing
4778 inherited tags, the tags of the current headline, and a list of all
4779 valid tags with corresponding keys[fn:54].
4781 Pressing keys assigned to tags adds or removes them from the list of
4782 tags in the current line.  Selecting a tag in a group of mutually
4783 exclusive tags turns off any other tag from that group.
4785 In this interface, you can also use the following special keys:
4787 - {{{kbd(TAB)}}} ::
4789      #+kindex: TAB
4790      Enter a tag in the minibuffer, even if the tag is not in the
4791      predefined list.  You can complete on all tags present in the
4792      buffer.  You can also add several tags: just separate them with
4793      a comma.
4795 - {{{kbd(SPC)}}} ::
4797      #+kindex: SPC
4798      Clear all tags for this line.
4800 - {{{kbd(RET)}}} ::
4802      #+kindex: RET
4803      Accept the modified set.
4805 - {{{kbd(C-g)}}} ::
4807      #+kindex: C-g
4808      Abort without installing changes.
4810 - {{{kbd(q)}}} ::
4812      #+kindex: q
4813      If {{{kbd(q)}}} is not assigned to a tag, it aborts like
4814      {{{kbd(C-g)}}}.
4816 - {{{kbd(!)}}} ::
4818      #+kindex: !
4819      Turn off groups of mutually exclusive tags.  Use this to (as an
4820      exception) assign several tags from such a group.
4822 - {{{kbd(C-c)}}} ::
4824      #+kindex: C-c C-c
4825      Toggle auto-exit after the next change (see below).  If you are
4826      using expert mode, the first {{{kbd(C-c)}}} displays the
4827      selection window.
4829 #+texinfo: @noindent
4830 This method lets you assign tags to a headline with very few keys.
4831 With the above setup, you could clear the current tags and set
4832 =@home=, =laptop= and =pc= tags with just the following keys:
4833 {{{kbd(C-c C-c SPC h l p RET)}}}.  Switching from =@home= to =@work=
4834 would be done with {{{kbd(C-c C-c w RET)}}} or alternatively with
4835 {{{kbd(C-c C-c C-c w)}}}.  Adding the non-predefined tag =Sarah= could
4836 be done with {{{kbd(C-c C-c TAB S a r a h RET)}}}.
4838 #+vindex: org-fast-tag-selection-single-key
4839 If you find that most of the time you need only a single key press to
4840 modify your list of tags, set the variable
4841 ~org-fast-tag-selection-single-key~.  Then you no longer have to press
4842 {{{kbd(RET)}}} to exit fast tag selection---it exits after the first
4843 change.  If you then occasionally need more keys, press {{{kbd(C-c)}}}
4844 to turn off auto-exit for the current tag selection process (in
4845 effect: start selection with {{{kbd(C-c C-c C-c)}}} instead of
4846 {{{kbd(C-c C-c)}}}).  If you set the variable to the value ~expert~,
4847 the special window is not even shown for single-key tag selection, it
4848 comes up only when you press an extra {{{kbd(C-c)}}}.
4850 ** Tag Hierarchy
4851 :PROPERTIES:
4852 :DESCRIPTION: Create a hierarchy of tags.
4853 :END:
4854 #+cindex: group tags
4855 #+cindex: tags, groups
4856 #+cindex: tags hierarchy
4858 Tags can be defined in hierarchies.  A tag can be defined as a /group
4859 tag/ for a set of other tags.  The group tag can be seen as the
4860 "broader term" for its set of tags.  Defining multiple group tags and
4861 nesting them creates a tag hierarchy.
4863 One use-case is to create a taxonomy of terms (tags) that can be used
4864 to classify nodes in a document or set of documents.
4866 When you search for a group tag, it return matches for all members in
4867 the group and its subgroups.  In an agenda view, filtering by a group
4868 tag displays or hide headlines tagged with at least one of the members
4869 of the group or any of its subgroups.  This makes tag searches and
4870 filters even more flexible.
4872 You can set group tags by using brackets and inserting a colon between
4873 the group tag and its related tags---beware that all whitespaces are
4874 mandatory so that Org can parse this line correctly:
4876 : #+TAGS: [ GTD : Control Persp ]
4878 In this example, =GTD= is the group tag and it is related to two other
4879 tags: =Control=, =Persp=.  Defining =Control= and =Persp= as group
4880 tags creates an hierarchy of tags:
4882 #+begin_example
4883   ,#+TAGS: [ Control : Context Task ]
4884   ,#+TAGS: [ Persp : Vision Goal AOF Project ]
4885 #+end_example
4887 That can conceptually be seen as a hierarchy of tags:
4889 - =GTD=
4890   - =Persp=
4891     - =Vision=
4892     - =Goal=
4893     - =AOF=
4894     - =Project=
4895   - =Control=
4896     - =Context=
4897     - =Task=
4899 You can use the ~:startgrouptag~, ~:grouptags~ and ~:endgrouptag~
4900 keyword directly when setting ~org-tag-alist~ directly:
4902 #+begin_src emacs-lisp
4903   (setq org-tag-alist '((:startgrouptag)
4904                         ("GTD")
4905                         (:grouptags)
4906                         ("Control")
4907                         ("Persp")
4908                         (:endgrouptag)
4909                         (:startgrouptag)
4910                         ("Control")
4911                         (:grouptags)
4912                         ("Context")
4913                         ("Task")
4914                         (:endgrouptag)))
4915 #+end_src
4917 The tags in a group can be mutually exclusive if using the same group
4918 syntax as is used for grouping mutually exclusive tags together; using
4919 curly brackets.
4921 : #+TAGS: { Context : @Home @Work @Call }
4923 When setting ~org-tag-alist~ you can use ~:startgroup~ and ~:endgroup~
4924 instead of ~:startgrouptag~ and ~:endgrouptag~ to make the tags
4925 mutually exclusive.
4927 Furthermore, the members of a group tag can also be regular
4928 expressions, creating the possibility of a more dynamic and rule-based
4929 tag structure.  The regular expressions in the group must be specified
4930 within curly brackets.  Here is an expanded example:
4932 #+begin_example
4933   ,#+TAGS: [ Vision : {V@.+} ]
4934   ,#+TAGS: [ Goal : {G@.+} ]
4935   ,#+TAGS: [ AOF : {AOF@.+} ]
4936   ,#+TAGS: [ Project : {P@.+} ]
4937 #+end_example
4939 Searching for the tag =Project= now lists all tags also including
4940 regular expression matches for =P@.+=, and similarly for tag searches
4941 on =Vision=, =Goal= and =AOF=.  For example, this would work well for
4942 a project tagged with a common project-identifier,
4943 e.g. =P@2014_OrgTags=.
4945 #+kindex: C-c C-x q
4946 #+findex: org-toggle-tags-groups
4947 #+vindex: org-group-tags
4948 If you want to ignore group tags temporarily, toggle group tags
4949 support with ~org-toggle-tags-groups~, bound to {{{kbd(C-c C-x q)}}}.
4950 If you want to disable tag groups completely, set ~org-group-tags~ to
4951 ~nil~.
4953 ** Tag Searches
4954 :PROPERTIES:
4955 :DESCRIPTION: Searching for combinations of tags.
4956 :END:
4957 #+cindex: tag searches
4958 #+cindex: searching for tags
4960 Once a system of tags has been set up, it can be used to collect
4961 related information into special lists.
4963 - {{{kbd(C-c / m)}}} or {{{kbd(C-c \)}}} (~org-match-sparse-tree~) ::
4965      #+kindex: C-c / m
4966      #+kindex: C-c \
4967      #+findex: org-match-sparse-tree
4968      Create a sparse tree with all headlines matching a tags search.
4969      With a {{{kbd(C-u)}}} prefix argument, ignore headlines that are
4970      not a TODO line.
4972 - {{{kbd(C-c a m)}}} (~org-tags-view~) ::
4974      #+kindex: C-c a m
4975      #+findex: org-tags-view
4976      Create a global list of tag matches from all agenda files.  See
4977      [[*Matching tags and properties]].
4979 - {{{kbd(C-c a M)}}} (~org-tags-view~) ::
4981      #+kindex: C-c a M
4982      #+vindex: org-tags-match-list-sublevels
4983      Create a global list of tag matches from all agenda files, but
4984      check only TODO items and force checking subitems (see the option
4985      ~org-tags-match-list-sublevels~).
4987 These commands all prompt for a match string which allows basic
4988 Boolean logic like =+boss+urgent-project1=, to find entries with tags
4989 =boss= and =urgent=, but not =project1=, or =Kathy|Sally= to find
4990 entries which are tagged, like =Kathy= or =Sally=.  The full syntax of
4991 the search string is rich and allows also matching against TODO
4992 keywords, entry levels and properties.  For a complete description
4993 with many examples, see [[*Matching tags and properties]].
4995 * Properties and Columns
4996 :PROPERTIES:
4997 :DESCRIPTION: Storing information about an entry.
4998 :END:
4999 #+cindex: properties
5001 A property is a key-value pair associated with an entry.  Properties
5002 can be set so they are associated with a single entry, with every
5003 entry in a tree, or with every entry in an Org file.
5005 There are two main applications for properties in Org mode.  First,
5006 properties are like tags, but with a value.  Imagine maintaining
5007 a file where you document bugs and plan releases for a piece of
5008 software.  Instead of using tags like =release_1=, =release_2=, you
5009 can use a property, say =Release=, that in different subtrees has
5010 different values, such as =1.0= or =2.0=.  Second, you can use
5011 properties to implement (very basic) database capabilities in an Org
5012 buffer.  Imagine keeping track of your music CDs, where properties
5013 could be things such as the album, artist, date of release, number of
5014 tracks, and so on.
5016 Properties can be conveniently edited and viewed in column view (see
5017 [[*Column View]]).
5019 ** Property Syntax
5020 :PROPERTIES:
5021 :DESCRIPTION: How properties are spelled out.
5022 :END:
5023 #+cindex: property syntax
5024 #+cindex: drawer, for properties
5026 Properties are key--value pairs.  When they are associated with
5027 a single entry or with a tree they need to be inserted into a special
5028 drawer (see [[*Drawers]]) with the name =PROPERTIES=, which has to be
5029 located right below a headline, and its planning line (see [[*Deadlines
5030 and Scheduling]]) when applicable.  Each property is specified on
5031 a single line, with the key---surrounded by colons---first, and the
5032 value after it.  Keys are case-insensitive.  Here is an example:
5034 #+begin_example
5035   ,* CD collection
5036   ,** Classic
5037   ,*** Goldberg Variations
5038       :PROPERTIES:
5039       :Title:     Goldberg Variations
5040       :Composer:  J.S. Bach
5041       :Artist:    Glen Gould
5042       :Publisher: Deutsche Grammophon
5043       :NDisks:    1
5044       :END:
5045 #+end_example
5047 Depending on the value of ~org-use-property-inheritance~, a property
5048 set this way is associated either with a single entry, or with the
5049 sub-tree defined by the entry, see [[*Property Inheritance]].
5051 You may define the allowed values for a particular property =Xyz= by
5052 setting a property =Xyz_ALL=.  This special property is /inherited/,
5053 so if you set it in a level 1 entry, it applies to the entire tree.
5054 When allowed values are defined, setting the corresponding property
5055 becomes easier and is less prone to typing errors.  For the example
5056 with the CD collection, we can pre-define publishers and the number of
5057 disks in a box like this:
5059 #+begin_example
5060   ,* CD collection
5061     :PROPERTIES:
5062     :NDisks_ALL:  1 2 3 4
5063     :Publisher_ALL: "Deutsche Grammophon" Philips EMI
5064     :END:
5065 #+end_example
5067 If you want to set properties that can be inherited by any entry in
5068 a file, use a line like:
5070 #+cindex: @samp{_ALL} suffix, in properties
5071 #+cindex: PROPERTY, keyword
5072 : #+PROPERTY: NDisks_ALL 1 2 3 4
5074 #+cindex: @samp{+} suffix, in properties
5075 If you want to add to the value of an existing property, append a =+=
5076 to the property name.  The following results in the property =var=
5077 having the value =foo=1 bar=2=.
5079 #+begin_example
5080   ,#+PROPERTY: var  foo=1
5081   ,#+PROPERTY: var+ bar=2
5082 #+end_example
5084 It is also possible to add to the values of inherited properties.  The
5085 following results in the =Genres= property having the value =Classic
5086 Baroque= under the =Goldberg Variations= subtree.
5088 #+begin_example
5089   ,* CD collection
5090   ,** Classic
5091       :PROPERTIES:
5092       :Genres: Classic
5093       :END:
5094   ,*** Goldberg Variations
5095       :PROPERTIES:
5096       :Title:     Goldberg Variations
5097       :Composer:  J.S. Bach
5098       :Artist:    Glen Gould
5099       :Publisher: Deutsche Grammophon
5100       :NDisks:    1
5101       :Genres+:   Baroque
5102       :END:
5103 #+end_example
5105 Note that a property can only have one entry per drawer.
5107 #+vindex: org-global-properties
5108 Property values set with the global variable ~org-global-properties~
5109 can be inherited by all entries in all Org files.
5111 #+texinfo: @noindent
5112 The following commands help to work with properties:
5114 #+attr_texinfo: :sep ,
5115 - {{{kbd(M-TAB)}}} (~pcomplete~) ::
5117      #+kindex: M-TAB
5118      #+findex: pcomplete
5119      After an initial colon in a line, complete property keys.  All
5120      keys used in the current file are offered as possible
5121      completions.
5123 - {{{kbd(C-c C-x p)}}} (~org-set-property~) ::
5125      #+kindex: C-c C-x p
5126      #+findex: org-set-property
5127      Set a property.  This prompts for a property name and a value.
5128      If necessary, the property drawer is created as well.
5130 - {{{kbd(C-u M-x org-insert-drawer)}}} ::
5132      #+findex: org-insert-drawer
5133      Insert a property drawer into the current entry.  The drawer is
5134      inserted early in the entry, but after the lines with planning
5135      information like deadlines.
5137 - {{{kbd(C-c C-c)}}} (~org-property-action~) ::
5139      #+kindex: C-c C-c
5140      #+findex: org-property-action
5141      With the cursor in a property drawer, this executes property
5142      commands.
5144 - {{{kbd(C-c C-c s)}}} (~org-set-property~) ::
5146      #+kindex: C-c C-c s
5147      #+findex: org-set-property
5148      Set a property in the current entry.  Both the property and the value
5149      can be inserted using completion.
5151 - {{{kbd(S-right)}}} (~org-property-next-allowed-values~),  {{{kbd(S-left)}}} (~org-property-previous-allowed-value~) ::
5153      #+kindex: S-right
5154      #+kindex: S-left
5155      Switch property at point to the next/previous allowed value.
5157 - {{{kbd(C-c C-c d)}}} (~org-delete-property~) ::
5159      #+kindex: C-c C-c d
5160      #+findex: org-delete-property
5161      Remove a property from the current entry.
5163 - {{{kbd(C-c C-c D)}}} (~org-delete-property-globally~) ::
5165      #+kindex: C-c C-c D
5166      #+findex: org-delete-property-globally
5167      Globally remove a property, from all entries in the current file.
5169 - {{{kbd(C-c C-c c)}}} (~org-compute-property-at-point~) ::
5171      #+kindex: C-c C-c c
5172      #+findex: org-compute-property-at-point
5173      Compute the property at point, using the operator and scope from
5174      the nearest column format definition.
5176 ** Special Properties
5177 :PROPERTIES:
5178 :DESCRIPTION: Access to other Org mode features.
5179 :END:
5180 #+cindex: properties, special
5182 Special properties provide an alternative access method to Org mode
5183 features, like the TODO state or the priority of an entry, discussed
5184 in the previous chapters.  This interface exists so that you can
5185 include these states in a column view (see [[*Column View]]), or to use
5186 them in queries.  The following property names are special and should
5187 not be used as keys in the properties drawer:
5189 #+cindex: ALLTAGS, special property
5190 #+cindex: BLOCKED, special property
5191 #+cindex: CLOCKSUM, special property
5192 #+cindex: CLOCKSUM_T, special property
5193 #+cindex: CLOSED, special property
5194 #+cindex: DEADLINE, special property
5195 #+cindex: FILE, special property
5196 #+cindex: ITEM, special property
5197 #+cindex: PRIORITY, special property
5198 #+cindex: SCHEDULED, special property
5199 #+cindex: TAGS, special property
5200 #+cindex: TIMESTAMP, special property
5201 #+cindex: TIMESTAMP_IA, special property
5202 #+cindex: TODO, special property
5203 | =ALLTAGS=      | All tags, including inherited ones.                            |
5204 | =BLOCKED=      | ~t~ if task is currently blocked by children or siblings.      |
5205 | =CATEGORY=     | The category of an entry.                                      |
5206 | =CLOCKSUM=     | The sum of CLOCK intervals in the subtree.  ~org-clock-sum~    |
5207 |                | must be run first to compute the values in the current buffer. |
5208 | =CLOCKSUM_T=   | The sum of CLOCK intervals in the subtree for today.           |
5209 |                | ~org-clock-sum-today~ must be run first to compute the         |
5210 |                | values in the current buffer.                                  |
5211 | =CLOSED=       | When was this entry closed?                                    |
5212 | =DEADLINE=     | The deadline time string, without the angular brackets.        |
5213 | =FILE=         | The filename the entry is located in.                          |
5214 | =ITEM=         | The headline of the entry.                                     |
5215 | =PRIORITY=     | The priority of the entry, a string with a single letter.      |
5216 | =SCHEDULED=    | The scheduling timestamp, without the angular brackets.        |
5217 | =TAGS=         | The tags defined directly in the headline.                     |
5218 | =TIMESTAMP=    | The first keyword-less timestamp in the entry.                 |
5219 | =TIMESTAMP_IA= | The first inactive timestamp in the entry.                     |
5220 | =TODO=         | The TODO keyword of the entry.                                 |
5222 ** Property Searches
5223 :PROPERTIES:
5224 :DESCRIPTION: Matching property values.
5225 :END:
5226 #+cindex: properties, searching
5227 #+cindex: searching, of properties
5229 To create sparse trees and special lists with selection based on
5230 properties, the same commands are used as for tag searches (see [[*Tag
5231 Searches]]).
5233 - {{{kbd(C-c / m)}}} or {{{kbd(C-c \)}}} (~org-match-sparse-tree~) ::
5235      #+kindex: C-c / m
5236      #+kindex: C-c \
5237      #+findex: org-match-sparse-tree
5238      Create a sparse tree with all matching entries.  With
5239      a {{{kbd(C-u)}}} prefix argument, ignore headlines that are not
5240      a TODO line.
5242 - {{{kbd(C-c a m)}}}, ~org-tags-view~ ::
5244      #+kindex: C-c a m
5245      Create a global list of tag/property matches from all agenda
5246      files.
5248 - {{{kbd(C-c a M)}}} (~org-tags-view~) ::
5250      #+kindex: C-c a M
5251      #+findex: org-tags-view
5252      #+vindex: org-tags-match-list-sublevels
5253      Create a global list of tag matches from all agenda files, but
5254      check only TODO items and force checking of subitems (see the
5255      option ~org-tags-match-list-sublevels~).
5257 The syntax for the search string is described in [[*Matching tags and
5258 properties]].
5260 There is also a special command for creating sparse trees based on a
5261 single property:
5263 - {{{kbd(C-c / p)}}} ::
5265      #+kindex: C-c / p
5266      Create a sparse tree based on the value of a property.  This
5267      first prompts for the name of a property, and then for a value.
5268      A sparse tree is created with all entries that define this
5269      property with the given value.  If you enclose the value in curly
5270      braces, it is interpreted as a regular expression and matched
5271      against the property values.
5273 ** Property Inheritance
5274 :PROPERTIES:
5275 :DESCRIPTION: Passing values down a tree.
5276 :END:
5277 #+cindex: properties, inheritance
5278 #+cindex: inheritance, of properties
5280 #+vindex: org-use-property-inheritance
5281 The outline structure of Org documents lends itself to an inheritance
5282 model of properties: if the parent in a tree has a certain property,
5283 the children can inherit this property.  Org mode does not turn this
5284 on by default, because it can slow down property searches
5285 significantly and is often not needed.  However, if you find
5286 inheritance useful, you can turn it on by setting the variable
5287 ~org-use-property-inheritance~.  It may be set to ~t~ to make all
5288 properties inherited from the parent, to a list of properties that
5289 should be inherited, or to a regular expression that matches inherited
5290 properties.  If a property has the value ~nil~, this is interpreted as
5291 an explicit un-define of the property, so that inheritance search
5292 stops at this value and returns ~nil~.
5294 Org mode has a few properties for which inheritance is hard-coded, at
5295 least for the special applications for which they are used:
5297 - ~COLUMNS~ ::
5299      #+cindex: COLUMNS, property
5300      The =COLUMNS= property defines the format of column view (see
5301      [[*Column View]]).  It is inherited in the sense that the level where
5302      a =COLUMNS= property is defined is used as the starting point for
5303      a column view table, independently of the location in the subtree
5304      from where columns view is turned on.
5306 - ~CATEGORY~ ::
5308      #+cindex: CATEGORY, property
5309      For agenda view, a category set through a =CATEGORY= property
5310      applies to the entire subtree.
5312 - ~ARCHIVE~ ::
5314      #+cindex: ARCHIVE, property
5315      For archiving, the =ARCHIVE= property may define the archive
5316      location for the entire subtree (see [[*Moving a tree to an archive
5317      file]]).
5319 - ~LOGGING~ ::
5321      #+cindex: LOGGING, property
5322      The =LOGGING= property may define logging settings for an entry
5323      or a subtree (see [[*Tracking TODO state changes]]).
5325 ** Column View
5326 :PROPERTIES:
5327 :DESCRIPTION: Tabular viewing and editing.
5328 :END:
5330 A great way to view and edit properties in an outline tree is /column
5331 view/.  In column view, each outline node is turned into a table row.
5332 Columns in this table provide access to properties of the entries.
5333 Org mode implements columns by overlaying a tabular structure over the
5334 headline of each item.  While the headlines have been turned into
5335 a table row, you can still change the visibility of the outline tree.
5336 For example, you get a compact table by switching to "contents"
5337 view---{{{kbd(S-TAB)}}} {{{kbd(S-TAB)}}}, or simply {{{kbd(c)}}}
5338 while column view is active---but you can still open, read, and edit
5339 the entry below each headline.  Or, you can switch to column view
5340 after executing a sparse tree command and in this way get a table only
5341 for the selected items.  Column view also works in agenda buffers (see
5342 [[*Agenda Views]]) where queries have collected selected items, possibly
5343 from a number of files.
5345 *** Defining columns
5346 :PROPERTIES:
5347 :DESCRIPTION: The COLUMNS format property.
5348 :END:
5349 #+cindex: column view, for properties
5350 #+cindex: properties, column view
5352 Setting up a column view first requires defining the columns.  This is
5353 done by defining a column format line.
5355 **** Scope of column definitions
5356 :PROPERTIES:
5357 :DESCRIPTION: Where defined, where valid?
5358 :END:
5360 To define a column format for an entire file, use a line like:
5362 #+cindex: COLUMNS, keyword
5363 : #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5365 To specify a format that only applies to a specific tree, add
5366 a =COLUMNS= property to the top node of that tree, for example:
5368 #+begin_example
5369   ,** Top node for columns view
5370      :PROPERTIES:
5371      :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5372      :END:
5373 #+end_example
5375 If a =COLUMNS= property is present in an entry, it defines columns for
5376 the entry itself, and for the entire subtree below it.  Since the
5377 column definition is part of the hierarchical structure of the
5378 document, you can define columns on level 1 that are general enough
5379 for all sublevels, and more specific columns further down, when you
5380 edit a deeper part of the tree.
5382 **** Column attributes
5383 :PROPERTIES:
5384 :DESCRIPTION: Appearance and content of a column.
5385 :END:
5387 A column definition sets the attributes of a column.  The general
5388 definition looks like this:
5390 : %[WIDTH]PROPERTY[(TITLE)][{SUMMARY-TYPE}]
5392 #+texinfo: @noindent
5393 Except for the percent sign and the property name, all items are
5394 optional.  The individual parts have the following meaning:
5396 - {{{var(WIDTH)}}} ::
5398      An integer specifying the width of the column in characters.  If
5399      omitted, the width is determined automatically.
5401 - {{{var(PROPERTY)}}} ::
5403      The property that should be edited in this column.  Special
5404      properties representing meta data are allowed here as well (see
5405      [[*Special Properties]]).
5407 - {{{var(TITLE)}}} ::
5409      The header text for the column.  If omitted, the property name is
5410      used.
5412 - {{{var(SUMMARY-TYPE)}}} ::
5414      The summary type.  If specified, the column values for parent
5415      nodes are computed from the children[fn:55].
5417      Supported summary types are:
5419      | =+=      | Sum numbers in this column.                           |
5420      | =+;%.1f= | Like =+=, but format result with =%.1f=.              |
5421      | =$=      | Currency, short for =+;%.2f=.                         |
5422      | =min=    | Smallest number in column.                            |
5423      | =max=    | Largest number.                                       |
5424      | =mean=   | Arithmetic mean of numbers.                           |
5425      | =X=      | Checkbox status, =[X]= if all children are =[X]=.     |
5426      | =X/=     | Checkbox status, =[n/m]=.                             |
5427      | =X%=     | Checkbox status, =[n%]=.                              |
5428      | =:=      | Sum times, HH:MM, plain numbers are hours.            |
5429      | =:min=   | Smallest time value in column.                        |
5430      | =:max=   | Largest time value.                                   |
5431      | =:mean=  | Arithmetic mean of time values.                       |
5432      | =@min=   | Minimum age[fn:56] (in days/hours/mins/seconds).      |
5433      | =@max=   | Maximum age (in days/hours/mins/seconds).             |
5434      | =@mean=  | Arithmetic mean of ages (in days/hours/mins/seconds). |
5435      | =est+=   | Add low-high estimates.                               |
5437      #+texinfo: @noindent
5438      #+vindex: org-columns-summary-types
5439      You can also define custom summary types by setting
5440      ~org-columns-summary-types~.
5442 The =est+= summary type requires further explanation.  It is used for
5443 combining estimates, expressed as low-high ranges.  For example,
5444 instead of estimating a particular task will take 5 days, you might
5445 estimate it as 5-6 days if you're fairly confident you know how much
5446 work is required, or 1-10 days if you do not really know what needs to
5447 be done.  Both ranges average at 5.5 days, but the first represents
5448 a more predictable delivery.
5450 When combining a set of such estimates, simply adding the lows and
5451 highs produces an unrealistically wide result.  Instead, =est+= adds
5452 the statistical mean and variance of the sub-tasks, generating a final
5453 estimate from the sum.  For example, suppose you had ten tasks, each
5454 of which was estimated at 0.5 to 2 days of work.  Straight addition
5455 produces an estimate of 5 to 20 days, representing what to expect if
5456 everything goes either extremely well or extremely poorly.  In
5457 contrast, =est+= estimates the full job more realistically, at 10-15
5458 days.
5460 Here is an example for a complete columns definition, along with
5461 allowed values[fn:57].
5463 #+begin_example
5464   :COLUMNS:  %25ITEM %9Approved(Approved?){X} %Owner %11Status \
5465                      %10Time_Estimate{:} %CLOCKSUM %CLOCKSUM_T
5466   :Owner_ALL:    Tammy Mark Karl Lisa Don
5467   :Status_ALL:   "In progress" "Not started yet" "Finished" ""
5468   :Approved_ALL: "[ ]" "[X]"
5469 #+end_example
5471 #+texinfo: @noindent
5472 The first column, =%25ITEM=, means the first 25 characters of the item
5473 itself, i.e., of the headline.  You probably always should start the
5474 column definition with the =ITEM= specifier.  The other specifiers
5475 create columns =Owner= with a list of names as allowed values, for
5476 =Status= with four different possible values, and for a checkbox field
5477 =Approved=.  When no width is given after the =%= character, the
5478 column is exactly as wide as it needs to be in order to fully display
5479 all values.  The =Approved= column does have a modified title
5480 (=Approved?=, with a question mark).  Summaries are created for the
5481 =Time_Estimate= column by adding time duration expressions like HH:MM,
5482 and for the =Approved= column, by providing an =[X]= status if all
5483 children have been checked.  The =CLOCKSUM= and =CLOCKSUM_T= columns
5484 are special, they lists the sums of CLOCK intervals in the subtree,
5485 either for all clocks or just for today.
5487 *** Using column view
5488 :PROPERTIES:
5489 :DESCRIPTION: How to create and use column view.
5490 :END:
5492 **** Turning column view on or off
5493 :PROPERTIES:
5494 :UNNUMBERED: notoc
5495 :END:
5497 - {{{kbd(C-c C-x C-c)}}} (~org-columns~) ::
5499      #+kindex: C-c C-x C-c
5500      #+vindex: org-columns
5501      #+vindex: org-columns-default-format
5502      Turn on column view.  If the cursor is before the first headline
5503      in the file, column view is turned on for the entire file, using
5504      the =#+COLUMNS= definition.  If the cursor is somewhere inside
5505      the outline, this command searches the hierarchy, up from point,
5506      for a =COLUMNS= property that defines a format.  When one is
5507      found, the column view table is established for the tree starting
5508      at the entry that contains the =COLUMNS= property.  If no such
5509      property is found, the format is taken from the =#+COLUMNS= line
5510      or from the variable ~org-columns-default-format~, and column
5511      view is established for the current entry and its subtree.
5513 - {{{kbd(r)}}} or {{{kbd(g)}}} (~org-columns-redo~) ::
5515      #+kindex: r
5516      #+kindex: g
5517      #+findex: org-columns-redo
5518      Recreate the column view, to include recent changes made in the
5519      buffer.
5521 - {{{kbd(q)}}} (~org-columns-quit~) ::
5523      #+kindex: q
5524      #+findex: org-columns-quit
5525      Exit column view.
5527 **** Editing values
5528 :PROPERTIES:
5529 :UNNUMBERED: notoc
5530 :END:
5532 #+attr_texinfo: :sep and
5533 - {{{kbd(left)}}}, {{{kbd(right)}}}, {{{kbd(up)}}}, {{{kbd(down)}}} ::
5535      Move through the column view from field to field.
5537 - {{{kbd(1..9\,0)}}} ::
5539      #+kindex: 1..9,0
5540      Directly select the Nth allowed value, {{{kbd(0)}}} selects the
5541      10th value.
5543 - {{{kbd(n)}}} or {{{kbd(S-right)}}} (~org-columns-next-allowed-value~) and {{{kbd(p)}}} or {{{kbd(S-left)}}} (~org-columns-previous-allowed-value~) ::
5545      #+kindex: n
5546      #+kindex: S-right
5547      #+kindex: p
5548      #+kindex: S-left
5549      #+findex: org-columns-next-allowed-value
5550      #+findex: org-columns-previous-allowed-value
5551      Switch to the next/previous allowed value of the field.  For
5552      this, you have to have specified allowed values for a property.
5554 - {{{kbd(e)}}} (~org-columns-edit-value~) ::
5556      #+kindex: e
5557      #+findex: org-columns-edit-value
5558      Edit the property at point.  For the special properties, this
5559      invokes the same interface that you normally use to change that
5560      property.  For example, the tag completion or fast selection
5561      interface pops up when editing a =TAGS= property.
5563 - {{{kbd(C-c C-c)}}} (~org-columns-set-tags-or-toggle~) ::
5565      #+kindex: C-c C-c
5566      #+findex: org-columns-set-tags-or-toggle
5567      When there is a checkbox at point, toggle it.
5569 - {{{kbd(v)}}} (~org-columns-show-value~) ::
5571      #+kindex: v
5572      #+findex: org-columns-show-value
5573      View the full value of this property.  This is useful if the
5574      width of the column is smaller than that of the value.
5576 - {{{kbd(a)}}} (~org-columns-edit-allowed~) ::
5578      #+kindex: a
5579      #+findex: org-columns-edit-allowed
5580      Edit the list of allowed values for this property.  If the list
5581      is found in the hierarchy, the modified values is stored there.
5582      If no list is found, the new value is stored in the first entry
5583      that is part of the current column view.
5585 **** Modifying column view on-the-fly:
5586 :PROPERTIES:
5587 :UNNUMBERED: notoc
5588 :END:
5590 #+attr_texinfo: :sep and
5591 - {{{kbd(<)}}} (~org-columns-narrow~) and {{{kbd(>)}}} (~org-columns-widen~) ::
5593      #+kindex: <
5594      #+kindex: >
5595      #+findex: org-columns-narrow
5596      #+findex: org-columns-widen
5597      Make the column narrower/wider by one character.
5599 - {{{kbd(S-M-right)}}} (~org-columns-new~) ::
5601      #+kindex: S-M-right
5602      #+findex: org-columns-new
5603      Insert a new column, to the left of the current column.
5605 - {{{kbd(S-M-left)}}} (~org-columns-delete~) ::
5607      #+kindex: S-M-left
5608      #+findex: org-columns-delete
5609      Delete the current column.
5611 *** Capturing column view
5612 :PROPERTIES:
5613 :DESCRIPTION: A dynamic block for column view.
5614 :END:
5616 Since column view is just an overlay over a buffer, it cannot be
5617 exported or printed directly.  If you want to capture a column view,
5618 use a =columnview= dynamic block (see [[*Dynamic Blocks]]).  The frame of
5619 this block looks like this:
5621 #+cindex: BEGIN columnview
5622 #+begin_example
5623   ,* The column view
5624   ,#+BEGIN: columnview :hlines 1 :id "label"
5626   ,#+END:
5627 #+end_example
5629 #+texinfo: @noindent
5630 This dynamic block has the following parameters:
5632 - =:id= ::
5634      This is the most important parameter.  Column view is a feature
5635      that is often localized to a certain (sub)tree, and the capture
5636      block might be at a different location in the file.  To identify
5637      the tree whose view to capture, you can use four values:
5639      - =local= ::
5641           Use the tree in which the capture block is located.
5643      - =global= ::
5645           Make a global view, including all headings in the file.
5647      - =file:FILENAME= ::
5649           Run column view at the top of the {{{var(FILENAME)}}} file
5651      - =LABEL= ::
5653           #+cindex: ID, property
5654           Call column view in the tree that has an =ID= property with
5655           the value {{{var(LABEL)}}}.  You can use {{{kbd(M-x
5656           org-id-copy)}}} to create a globally unique ID for the
5657           current entry and copy it to the kill-ring.
5659 - =:hlines= ::
5661      When ~t~, insert an hline after every line.  When a number N,
5662      insert an hline before each headline with level ~<= N~.
5664 - =:vlines= ::
5666      When non-~nil~, force column groups to get vertical lines.
5668 - =:maxlevel= ::
5670      When set to a number, do not capture entries below this level.
5672 - =:skip-empty-rows= ::
5674      When non-~nil~, skip rows where the only non-empty specifier of
5675      the column view is =ITEM=.
5677 - =:indent= ::
5679      When non-~nil~, indent each =ITEM= field according to its level.
5681 #+texinfo: @noindent
5682 The following commands insert or update the dynamic block:
5684 - {{{kbd(C-c C-x i)}}} (~org-insert-columns-dblock~) ::
5686      #+kindex: C-c C-x i
5687      #+findex: org-insert-columns-dblock
5688      Insert a dynamic block capturing a column view.  Prompt for the
5689      scope or ID of the view.
5691 - {{{kbd(C-c C-c)}}} {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
5693      #+kindex: C-c C-c
5694      #+kindex: C-c C-x C-u
5695      #+findex: org-dblock-update
5696      Update dynamic block at point.  The cursor needs to be in the
5697      =#+BEGIN= line of the dynamic block.
5699 - {{{kbd(C-u C-c C-x C-u)}}} (~org-update-all-dblocks~) ::
5701      #+kindex: C-u C-c C-x C-u
5702      Update all dynamic blocks (see [[*Dynamic Blocks]]).  This is useful
5703      if you have several clock table blocks, column-capturing blocks
5704      or other dynamic blocks in a buffer.
5706 You can add formulas to the column view table and you may add plotting
5707 instructions in front of the table---these survive an update of the
5708 block.  If there is a =TBLFM= keyword after the table, the table is
5709 recalculated automatically after an update.
5711 An alternative way to capture and process property values into a table
5712 is provided by Eric Schulte's =org-collector.el= which is
5713 a contributed package[fn:58].  It provides a general API to collect
5714 properties from entries in a certain scope, and arbitrary Lisp
5715 expressions to process these values before inserting them into a table
5716 or a dynamic block.
5718 * Dates and Times
5719 :PROPERTIES:
5720 :DESCRIPTION: Making items useful for planning.
5721 :END:
5722 #+cindex: dates
5723 #+cindex: times
5724 #+cindex: timestamp
5725 #+cindex: date stamp
5727 To assist project planning, TODO items can be labeled with a date
5728 and/or a time.  The specially formatted string carrying the date and
5729 time information is called a /timestamp/ in Org mode.  This may be
5730 a little confusing because timestamp is often used as indicating when
5731 something was created or last changed.  However, in Org mode this term
5732 is used in a much wider sense.
5734 ** Timestamps, Deadlines and Scheduling
5735 :PROPERTIES:
5736 :DESCRIPTION: Assigning a time to a tree entry.
5737 :ALT_TITLE: Timestamps
5738 :END:
5739 #+cindex: timestamps
5740 #+cindex: ranges, time
5741 #+cindex: date stamps
5742 #+cindex: deadlines
5743 #+cindex: scheduling
5745 A timestamp is a specification of a date (possibly with a time or
5746 a range of times) in a special format, either =<2003-09-16 Tue>= or
5747 =<2003-09-16 Tue 09:39>= or =<2003-09-16 Tue 12:00-12:30>=[fn:59].
5748 A timestamp can appear anywhere in the headline or body of an Org tree
5749 entry.  Its presence causes entries to be shown on specific dates in
5750 the agenda (see [[*Weekly/daily agenda]]).  We distinguish:
5752 - Plain timestamp; Event; Appointment ::
5754      #+cindex: timestamp
5755      #+cindex: appointment
5756      A simple timestamp just assigns a date/time to an item.  This is
5757      just like writing down an appointment or event in a paper agenda.
5758      In the timeline and agenda displays, the headline of an entry
5759      associated with a plain timestamp is shown exactly on that date.
5761      #+begin_example
5762        ,* Meet Peter at the movies
5763          <2006-11-01 Wed 19:15>
5764        ,* Discussion on climate change
5765          <2006-11-02 Thu 20:00-22:00>
5766      #+end_example
5768 - Timestamp with repeater interval ::
5770      #+cindex: timestamp, with repeater interval
5771      A timestamp may contain a /repeater interval/, indicating that it
5772      applies not only on the given date, but again and again after
5773      a certain interval of N days (d), weeks (w), months (m), or years
5774      (y).  The following shows up in the agenda every Wednesday:
5776      #+begin_example
5777        ,* Pick up Sam at school
5778          <2007-05-16 Wed 12:30 +1w>
5779      #+end_example
5781 - Diary-style sexp entries ::
5783      #+cindex: diary style timestamps
5784      #+cindex: sexp timestamps
5785      For more complex date specifications, Org mode supports using the
5786      special sexp diary entries implemented in the Emacs
5787      calendar/diary package[fn:60].  For example, with optional time:
5789      #+begin_example
5790        ,* 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
5791          <%%(org-float t 4 2)>
5792      #+end_example
5794 - Time/Date range ::
5796      #+cindex: timerange
5797      #+cindex: date range
5798      Two timestamps connected by =--= denote a range.  The headline is
5799      shown on the first and last day of the range, and on any dates
5800      that are displayed and fall in the range.  Here is an example:
5802      #+begin_example
5803        ,** Meeting in Amsterdam
5804           <2004-08-23 Mon>--<2004-08-26 Thu>
5805      #+end_example
5807 - Inactive timestamp ::
5809      #+cindex: timestamp, inactive
5810      #+cindex: inactive timestamp
5811      Just like a plain timestamp, but with square brackets instead of
5812      angular ones.  These timestamps are inactive in the sense that
5813      they do /not/ trigger an entry to show up in the agenda.
5815      #+begin_example
5816        ,* Gillian comes late for the fifth time
5817          [2006-11-01 Wed]
5818      #+end_example
5820 ** Creating Timestamps
5821 :PROPERTIES:
5822 :DESCRIPTION: Commands to insert timestamps.
5823 :END:
5825 For Org mode to recognize timestamps, they need to be in the specific
5826 format.  All commands listed below produce timestamps in the correct
5827 format.
5829 #+attr_texinfo: :sep ,
5830 - {{{kbd(C-c .)}}} (~org-time-stamp~) ::
5832      #+kindex: C-c .
5833      #+findex: org-time-stamp
5834      Prompt for a date and insert a corresponding timestamp.  When the
5835      cursor is at an existing timestamp in the buffer, the command is
5836      used to modify this timestamp instead of inserting a new one.
5837      When this command is used twice in succession, a time range is
5838      inserted.
5840 - {{{kbd(C-c !)}}} (~org-time-stamp-inactive~) ::
5842      #+kindex: C-c !
5843      #+findex: org-time-stamp-inactive
5844      Like {{{kbd(C-c .)}}}, but insert an inactive timestamp that does
5845      not cause an agenda entry.
5847 - {{{kbd(C-u C-c .)}}}, {{{kbd(C-u C-c !)}}} ::
5849      #+kindex: C-u C-c .
5850      #+kindex: C-u C-c .
5851      #+kindex: C-u C-c !
5852      #+vindex: org-time-stamp-rounding-minutes
5853      Like {{{kbd(C-c .)}}} and {{{kbd(C-c !)}}}, but use the
5854      alternative format which contains date and time.  The default
5855      time can be rounded to multiples of 5 minutes, see the option
5856      ~org-time-stamp-rounding-minutes~.
5858 - {{{kbd(C-c C-c)}}} ::
5860      #+kindex: C-c C-c
5861      Normalize timestamp, insert/fix day name if missing or wrong.
5863 - {{{kbd(C-c <)}}} (~org-date-from-calendar~) ::
5865      #+kindex: C-c <
5866      #+findex: org-date-from-calendar
5867      Insert a timestamp corresponding to the cursor date in the Calendar.
5869 - {{{kbd(C-c >)}}} (~org-goto-calendar~) ::
5871      #+kindex: C-c >
5872      #+findex: org-goto-calendar
5873      Access the Emacs calendar for the current date.  If there is a
5874      timestamp in the current line, go to the corresponding date instead.
5876 - {{{kbd(C-c C-o)}}} (~org-open-at-point~) ::
5878      #+kindex: C-c C-o
5879      #+findex: org-open-at-point
5880      Access the agenda for the date given by the timestamp or -range
5881      at point (see [[*Weekly/daily agenda]]).
5883 - {{{kbd(S-left)}}} (~org-timestamp-down-day~), {{{kbd(S-right)}}} (~org-timestamp-up-day~) ::
5885      #+kindex: S-left
5886      #+kindex: S-right
5887      #+findex: org-timestamp-down-day
5888      #+findex: org-timestamp-up-day
5889      Change date at cursor by one day.  These key bindings conflict
5890      with shift-selection and related modes (see [[*Packages that
5891      conflict with Org mode]]).
5893 - {{{kbd(S-up)}}} (~org-timestamp-up~), {{{kbd(S-down)}}} (~org-timestamp-down~) ::
5895      #+kindex: S-up
5896      Change the item under the cursor in a timestamp.  The cursor can
5897      be on a year, month, day, hour or minute.  When the timestamp
5898      contains a time range like =15:30-16:30=, modifying the first
5899      time also shifts the second, shifting the time block with
5900      constant length.  To change the length, modify the second time.
5901      Note that if the cursor is in a headline and not at a timestamp,
5902      these same keys modify the priority of an item.  (see
5903      [[*Priorities]]).  The key bindings also conflict with
5904      shift-selection and related modes (see [[*Packages that conflict
5905      with Org mode]]).
5907 - {{{kbd(C-c C-y)}}} (~org-evaluate-time-range~) ::
5909      #+kindex: C-c C-y
5910      #+findex: org-evaluate-time-range
5911      #+cindex: evaluate time range
5912      Evaluate a time range by computing the difference between start
5913      and end.  With a prefix argument, insert result after the time
5914      range (in a table: into the following column).
5916 *** The date/time prompt
5917 :PROPERTIES:
5918 :DESCRIPTION: How Org mode helps you enter dates and times.
5919 :END:
5920 #+cindex: date, reading in minibuffer
5921 #+cindex: time, reading in minibuffer
5923 #+vindex: org-read-date-prefer-future
5924 When Org mode prompts for a date/time, the default is shown in default
5925 date/time format, and the prompt therefore seems to ask for a specific
5926 format.  But it in fact accepts date/time information in a variety of
5927 formats.  Generally, the information should start at the beginning of
5928 the string.  Org mode finds whatever information is in there and
5929 derives anything you have not specified from the /default date and
5930 time/.  The default is usually the current date and time, but when
5931 modifying an existing timestamp, or when entering the second stamp of
5932 a range, it is taken from the stamp in the buffer.  When filling in
5933 information, Org mode assumes that most of the time you want to enter
5934 a date in the future: if you omit the month/year and the given
5935 day/month is /before/ today, it assumes that you mean a future
5936 date[fn:61].  If the date has been automatically shifted into the
5937 future, the time prompt shows this with =(=>F)=.
5939 For example, let's assume that today is *June 13, 2006*.  Here is how
5940 various inputs are interpreted, the items filled in by Org mode are in
5941 *bold*.
5943 | =3-2-5=        | \rArr{} 2003-02-05                              |
5944 | =2/5/3=        | \rArr{} 2003-02-05                              |
5945 | =14=           | \rArr{} *2006*-*06*-14                          |
5946 | =12=           | \rArr{} *2006*-*07*-12                          |
5947 | =2/5=          | \rArr{} *2007*-02-05                            |
5948 | =Fri=          | \rArr{} nearest Friday (default date or later)  |
5949 | =sep 15=       | \rArr{} *2006*-09-15                            |
5950 | =feb 15=       | \rArr{} *2007*-02-15                            |
5951 | =sep 12 9=     | \rArr{} 2009-09-12                              |
5952 | =12:45=        | \rArr{} *2006*-*06*-*13* 12:45                  |
5953 | =22 sept 0:34= | \rArr{} *2006*-09-22 0:34                       |
5954 | =w4=           | \rArr{} ISO week for of the current year *2006* |
5955 | =2012 w4 fri=  | \rArr{} Friday of ISO week 4 in 2012            |
5956 | =2012-w04-5=   | \rArr{} Same as above                           |
5958 Furthermore you can specify a relative date by giving, as the /first/
5959 thing in the input: a plus/minus sign, a number and a letter---=d=,
5960 =w=, =m= or =y=---to indicate change in days, weeks, months, or
5961 years.  With a single plus or minus, the date is always relative to
5962 today.  With a double plus or minus, it is relative to the default
5963 date.  If instead of a single letter, you use the abbreviation of day
5964 name, the date is the Nth such day, e.g.:
5966 | =+0=    | \rArr{} today                       |
5967 | =.=     | \rArr{} today                       |
5968 | =+4d=   | \rArr{} four days from today        |
5969 | =+4=    | \rArr{} same as +4d                 |
5970 | =+2w=   | \rArr{} two weeks from today        |
5971 | =++5=   | \rArr{} five days from default date |
5972 | =+2tue= | \rArr{} second Tuesday from now     |
5974 #+vindex: parse-time-months
5975 #+vindex: parse-time-weekdays
5976 The function understands English month and weekday abbreviations.  If
5977 you want to use un-abbreviated names and/or other languages, configure
5978 the variables ~parse-time-months~ and ~parse-time-weekdays~.
5980 #+vindex: org-read-date-force-compatible-dates
5981 Not all dates can be represented in a given Emacs implementation.  By
5982 default Org mode forces dates into the compatibility range 1970--2037
5983 which works on all Emacs implementations.  If you want to use dates
5984 outside of this range, read the docstring of the variable
5985 ~org-read-date-force-compatible-dates~.
5987 You can specify a time range by giving start and end times or by
5988 giving a start time and a duration (in HH:MM format).  Use one or two
5989 dash(es) as the separator in the former case and use =+= as the
5990 separator in the latter case, e.g.:
5992 | =11am-1:15pm=  | \rArr{} 11:00-13:15   |
5993 | =11am--1:15pm= | \rArr{} same as above |
5994 | =11am+2:15=    | \rArr{} same as above |
5996 #+cindex: calendar, for selecting date
5997 #+vindex: org-popup-calendar-for-date-prompt
5998 Parallel to the minibuffer prompt, a calendar is popped up[fn:62].
5999 When you exit the date prompt, either by clicking on a date in the
6000 calendar, or by pressing {{{kbd(RET)}}}, the date selected in the
6001 calendar is combined with the information entered at the prompt.  You
6002 can control the calendar fully from the minibuffer:
6004 #+kindex: <
6005 #+kindex: >
6006 #+kindex: M-v
6007 #+kindex: C-v
6008 #+kindex: mouse-1
6009 #+kindex: S-right
6010 #+kindex: S-left
6011 #+kindex: S-down
6012 #+kindex: S-up
6013 #+kindex: M-S-right
6014 #+kindex: M-S-left
6015 #+kindex: RET
6016 #+attr_texinfo: :columns 0.25 0.55
6017 | {{{kbd(RET)}}}           | Choose date at cursor in calendar.     |
6018 | {{{kbd(mouse-1)}}}       | Select date by clicking on it.         |
6019 | {{{kbd(S-right)}}}    | One day forward.                       |
6020 | {{{kbd(S-left)}}}     | One day backward.                      |
6021 | {{{kbd(S-down)}}}     | One week forward.                      |
6022 | {{{kbd(S-up)}}}       | One week backward.                     |
6023 | {{{kbd(M-S-right)}}}  | One month forward.                     |
6024 | {{{kbd(M-S-left)}}}   | One month backward.                    |
6025 | {{{kbd(>)}}}             | Scroll calendar forward by one month.  |
6026 | {{{kbd(<)}}}             | Scroll calendar backward by one month. |
6027 | {{{kbd(M-v)}}}           | Scroll calendar forward by 3 months.   |
6028 | {{{kbd(C-v)}}}           | Scroll calendar backward by 3 months.  |
6030 #+vindex: org-read-date-display-live
6031 The actions of the date/time prompt may seem complex, but I assure you
6032 they will grow on you, and you will start getting annoyed by pretty
6033 much any other way of entering a date/time out there.  To help you
6034 understand what is going on, the current interpretation of your input
6035 is displayed live in the minibuffer[fn:63].
6037 *** Custom time format
6038 :PROPERTIES:
6039 :DESCRIPTION: Making dates look different.
6040 :END:
6041 #+cindex: custom date/time format
6042 #+cindex: time format, custom
6043 #+cindex: date format, custom
6045 #+vindex: org-display-custom-times
6046 #+vindex: org-time-stamp-custom-formats
6047 Org mode uses the standard ISO notation for dates and times as it is
6048 defined in ISO 8601.  If you cannot get used to this and require
6049 another representation of date and time to keep you happy, you can get
6050 it by customizing the variables ~org-display-custom-times~ and
6051 ~org-time-stamp-custom-formats~.
6053 - {{{kbd(C-c C-x C-t)}}} (~org-toggle-time-stamp-overlays~) ::
6055      #+kindex: C-c C-x C-t
6056      #+findex: org-toggle-time-stamp-overlays
6057      Toggle the display of custom formats for dates and times.
6059 #+texinfo: @noindent
6060 Org mode needs the default format for scanning, so the custom
6061 date/time format does not /replace/ the default format.  Instead, it
6062 is put /over/ the default format using text properties.  This has the
6063 following consequences:
6065 - You cannot place the cursor onto a timestamp anymore, only before or
6066   after.
6068 - The {{{kbd(S-up)}}} and {{{kbd(S-down)}}} keys can no longer be used
6069   to adjust each component of a timestamp.  If the cursor is at the
6070   beginning of the stamp, {{{kbd(S-up)}}} and {{{kbd(S-down)}}} change
6071   the stamp by one day, just like {{{kbd(S-left)}}}
6072   {{{kbd(S-right)}}}.  At the end of the stamp, change the time by one
6073   minute.
6075 - If the timestamp contains a range of clock times or a repeater,
6076   these are not overlaid, but remain in the buffer as they were.
6078 - When you delete a timestamp character-by-character, it only
6079   disappears from the buffer after /all/ (invisible) characters
6080   belonging to the ISO timestamp have been removed.
6082 - If the custom timestamp format is longer than the default and you
6083   are using dates in tables, table alignment will be messed up.  If
6084   the custom format is shorter, things do work as expected.
6086 ** Deadlines and Scheduling
6087 :PROPERTIES:
6088 :DESCRIPTION: Planning your work.
6089 :END:
6091 A timestamp may be preceded by special keywords to facilitate
6092 planning.  Both the timestamp and the keyword have to be positioned
6093 immediately after the task they refer to.
6095 - =DEADLINE= ::
6097      #+cindex: DEADLINE
6098      Meaning: the task (most likely a TODO item, though not
6099      necessarily) is supposed to be finished on that date.
6101      #+vindex: org-deadline-warning-days
6102      On the deadline date, the task is listed in the agenda.  In
6103      addition, the agenda for /today/ carries a warning about the
6104      approaching or missed deadline, starting
6105      ~org-deadline-warning-days~ before the due date, and continuing
6106      until the entry is marked DONE.  An example:
6108      #+begin_example
6109        ,*** TODO write article about the Earth for the Guide
6110            DEADLINE: <2004-02-29 Sun>
6111            The editor in charge is [[bbdb:Ford Prefect]]
6112      #+end_example
6114      #+vindex: org-agenda-skip-deadline-prewarning-if-scheduled
6115      You can specify a different lead time for warnings for a specific
6116      deadlines using the following syntax.  Here is an example with
6117      a warning period of 5 days =DEADLINE: <2004-02-29 Sun -5d>=.
6118      This warning is deactivated if the task gets scheduled and you
6119      set ~org-agenda-skip-deadline-prewarning-if-scheduled~ to ~t~.
6121 - =SCHEDULED= ::
6123      #+cindex: SCHEDULED
6124      Meaning: you are planning to start working on that task on the
6125      given date.
6127      #+vindex: org-agenda-skip-scheduled-if-done
6128      The headline is listed under the given date[fn:64].  In addition,
6129      a reminder that the scheduled date has passed is present in the
6130      compilation for /today/, until the entry is marked DONE, i.e.,
6131      the task is automatically forwarded until completed.
6133      #+begin_example
6134        ,*** TODO Call Trillian for a date on New Years Eve.
6135            SCHEDULED: <2004-12-25 Sat>
6136      #+end_example
6138      #+vindex: org-scheduled-delay-days
6139      #+vindex: org-agenda-skip-scheduled-delay-if-deadline
6140      If you want to /delay/ the display of this task in the agenda,
6141      use =SCHEDULED: <2004-12-25 Sat -2d>=: the task is still
6142      scheduled on the 25th but will appear two days later.  In case
6143      the task contains a repeater, the delay is considered to affect
6144      all occurrences; if you want the delay to only affect the first
6145      scheduled occurrence of the task, use =--2d= instead.  See
6146      ~org-scheduled-delay-days~ and
6147      ~org-agenda-skip-scheduled-delay-if-deadline~ for details on how
6148      to control this globally or per agenda.
6150      #+texinfo: @noindent
6151      *Important:* Scheduling an item in Org mode should /not/ be
6152      understood in the same way that we understand /scheduling
6153      a meeting/.  Setting a date for a meeting is just a simple
6154      appointment, you should mark this entry with a simple plain
6155      timestamp, to get this item shown on the date where it applies.
6156      This is a frequent misunderstanding by Org users.  In Org mode,
6157      /scheduling/ means setting a date when you want to start working
6158      on an action item.
6160 You may use timestamps with repeaters in scheduling and deadline
6161 entries.  Org mode issues early and late warnings based on the
6162 assumption that the timestamp represents the /nearest instance/ of the
6163 repeater.  However, the use of diary S-exp entries like
6165 : <%%(org-float t 42)>
6167 #+texinfo: @noindent
6168 in scheduling and deadline timestamps is limited.  Org mode does not
6169 know enough about the internals of each S-exp function to issue early
6170 and late warnings.  However, it shows the item on each day where the
6171 S-exp entry matches.
6173 *** Inserting deadlines or schedules
6174 :PROPERTIES:
6175 :DESCRIPTION: Planning items.
6176 :ALT_TITLE: Inserting deadline/schedule
6177 :END:
6179 The following commands allow you to quickly insert a deadline or to
6180 schedule an item:[fn:65]
6182 - {{{kbd(C-c C-d)}}} (~org-deadline~) ::
6184      #+kindex: C-c C-d
6185      #+findex: org-deadline
6186      #+vindex: org-log-redeadline
6187      Insert =DEADLINE= keyword along with a stamp.  The insertion
6188      happens in the line directly following the headline.  Remove any
6189      =CLOSED= timestamp .  When called with a prefix argument, also
6190      remove any existing deadline from the entry.  Depending on the
6191      variable ~org-log-redeadline~, take a note when changing an
6192      existing deadline[fn:66].
6194 - {{{kbd(C-c C-s)}}} (~org-schedule~) ::
6196      #+kindex: C-c C-s
6197      #+findex: org-schedule
6198      #+vindex: org-log-reschedule
6199      Insert =SCHEDULED= keyword along with a stamp.  The insertion
6200      happens in the line directly following the headline.  Remove any
6201      =CLOSED= timestamp.  When called with a prefix argument, also
6202      remove the scheduling date from the entry.  Depending on the
6203      variable ~org-log-reschedule~, take a note when changing an
6204      existing scheduling time[fn:67].
6206 - {{{kbd(C-c C-x C-k)}}} (~org-mark-entry-for-agenda-action~) ::
6208      #+kindex: C-c C-x C-k
6209      #+kindex: k a
6210      #+kindex: k s
6211      #+findex: org-mark-entry-for-agenda-action
6212      Mark the current entry for agenda action.  After you have marked
6213      the entry like this, you can open the agenda or the calendar to
6214      find an appropriate date.  With the cursor on the selected date,
6215      press {{{kbd(k s)}}} or {{{kbd(k d)}}} to schedule the marked
6216      item.
6218 - {{{kbd(C-c / d)}}} (~org-check-deadlines~) ::
6220      #+kindex: C-c / d
6221      #+findex: org-check-deadlines
6222      #+cindex: sparse tree, for deadlines
6223      #+vindex: org-deadline-warning-days
6224      Create a sparse tree with all deadlines that are either past-due,
6225      or which will become due within ~org-deadline-warning-days~.
6226      With {{{kbd(C-u)}}} prefix, show all deadlines in the file.  With
6227      a numeric prefix, check that many days.  For example, {{{kbd(C-1
6228      C-c / d)}}} shows all deadlines due tomorrow.
6230 - {{{kbd(C-c / b)}}}, ~org-check-before-date~ ::
6232      #+kindex: C-c / b
6233      #+findex: org-check-before-date
6234      Sparse tree for deadlines and scheduled items before a given
6235      date.
6237 - {{{kbd(C-c / a)}}}, ~org-check-after-date~ ::
6239      #+kindex: C-c / a
6240      #+findex: org-check-after-date
6241      Sparse tree for deadlines and scheduled items after a given date.
6243 Note that ~org-schedule~ and ~org-deadline~ supports setting the date
6244 by indicating a relative time e.g., =+1d= sets the date to the next
6245 day after today, and =--1w= sets the date to the previous week before
6246 any current timestamp.
6248 *** Repeated tasks
6249 :PROPERTIES:
6250 :DESCRIPTION: Items that show up again and again.
6251 :END:
6252 #+cindex: tasks, repeated
6253 #+cindex: repeated tasks
6255 Some tasks need to be repeated again and again.  Org mode helps to
6256 organize such tasks using a so-called repeater in a =DEADLINE=,
6257 =SCHEDULED=, or plain timestamp.  In the following example:
6259 #+begin_example
6260   ,** TODO Pay the rent
6261      DEADLINE: <2005-10-01 Sat +1m>
6262 #+end_example
6264 #+texinfo: noindent
6265 the =+1m= is a repeater; the intended interpretation is that the task
6266 has a deadline on =<2005-10-01>= and repeats itself every (one) month
6267 starting from that time.  You can use yearly, monthly, weekly, daily
6268 and hourly repeat cookies by using the ~y/w/m/d/h~ letters.  If you
6269 need both a repeater and a special warning period in a deadline entry,
6270 the repeater should come first and the warning period last: =DEADLINE:
6271 <2005-10-01 Sat +1m -3d>=.
6273 #+vindex: org-todo-repeat-to-state
6274 Deadlines and scheduled items produce entries in the agenda when they
6275 are over-due, so it is important to be able to mark such an entry as
6276 completed once you have done so.  When you mark a =DEADLINE= or
6277 a =SCHEDULED= with the TODO keyword =DONE=, it no longer produces
6278 entries in the agenda.  The problem with this is, however, is that
6279 then also the /next/ instance of the repeated entry will not be
6280 active.  Org mode deals with this in the following way: when you try
6281 to mark such an entry DONE, using {{{kbd(C-c C-t)}}}, it shifts the
6282 base date of the repeating timestamp by the repeater interval, and
6283 immediately sets the entry state back to TODO[fn:68].  In the example
6284 above, setting the state to DONE would actually switch the date like
6285 this:
6287 #+begin_example
6288   ,** TODO Pay the rent
6289      DEADLINE: <2005-11-01 Tue +1m>
6290 #+end_example
6292 To mark a task with a repeater as DONE, use {{{kbd(C-- 1 C-c C-t)}}},
6293 i.e., ~org-todo~ with a numeric prefix argument of =-1=.
6295 #+vindex: org-log-repeat
6296 A timestamp[fn:69] is added under the deadline, to keep a record that
6297 you actually acted on the previous instance of this deadline.
6299 As a consequence of shifting the base date, this entry is no longer
6300 visible in the agenda when checking past dates, but all future
6301 instances will be visible.
6303 With the =+1m= cookie, the date shift is always exactly one month.  So
6304 if you have not paid the rent for three months, marking this entry
6305 DONE still keeps it as an overdue deadline.  Depending on the task,
6306 this may not be the best way to handle it.  For example, if you forgot
6307 to call your father for 3 weeks, it does not make sense to call him
6308 3 times in a single day to make up for it.  Finally, there are tasks
6309 like changing batteries which should always repeat a certain time
6310 /after/ the last time you did it.  For these tasks, Org mode has
6311 special repeaters =++= and =.+=.  For example:
6313 #+begin_example
6314   ,** TODO Call Father
6315      DEADLINE: <2008-02-10 Sun ++1w>
6316      Marking this DONE shifts the date by at least one week, but also
6317      by as many weeks as it takes to get this date into the future.
6318      However, it stays on a Sunday, even if you called and marked it
6319      done on Saturday.
6321   ,** TODO Empty kitchen trash
6322      DEADLINE: <2008-02-08 Fri 20:00 ++1d>
6323      Marking this DONE shifts the date by at least one day, and also
6324      by as many days as it takes to get the timestamp into the future.
6325      Since there is a time in the timestamp, the next deadline in the
6326      future will be on today's date if you complete the task before
6327      20:00.
6329   ,** TODO Check the batteries in the smoke detectors
6330      DEADLINE: <2005-11-01 Tue .+1m>
6331      Marking this DONE will shift the date to one month after today.
6332 #+end_example
6334 #+vindex: org-agenda-skip-scheduled-if-deadline-is-shown
6335 You may have both scheduling and deadline information for a specific
6336 task.  If the repeater is set for the scheduling information only, you
6337 probably want the repeater to be ignored after the deadline.  If so,
6338 set the variable ~org-agenda-skip-scheduled-if-deadline-is-shown~ to
6339 ~repeated-after-deadline~.  However, any scheduling information
6340 without a repeater is no longer relevant once the task is done, and
6341 thus, removed upon repeating the task.  If you want both scheduling
6342 and deadline information to repeat after the same interval, set the
6343 same repeater for both timestamps.
6345 An alternative to using a repeater is to create a number of copies of
6346 a task subtree, with dates shifted in each copy.  The command
6347 {{{kbd(C-c C-x c)}}} was created for this purpose; it is described in
6348 [[*Structure Editing]].
6350 ** Clocking Work Time
6351 :PROPERTIES:
6352 :DESCRIPTION: Tracking how long you spend on a task.
6353 :END:
6354 #+cindex: clocking time
6355 #+cindex: time clocking
6357 Org mode allows you to clock the time you spend on specific tasks in
6358 a project.  When you start working on an item, you can start the
6359 clock.  When you stop working on that task, or when you mark the task
6360 done, the clock is stopped and the corresponding time interval is
6361 recorded.  It also computes the total time spent on each
6362 subtree[fn:70] of a project.  And it remembers a history or tasks
6363 recently clocked, to that you can jump quickly between a number of
6364 tasks absorbing your time.
6366 To save the clock history across Emacs sessions, use:
6368 #+begin_src emacs-lisp
6369   (setq org-clock-persist 'history)
6370   (org-clock-persistence-insinuate)
6371 #+end_src
6373 #+vindex: org-clock-persist
6374 When you clock into a new task after resuming Emacs, the incomplete
6375 clock[fn:71] is retrieved (see [[*Resolving idle time]]) and you are
6376 prompted about what to do with it.
6378 *** Clocking commands
6379 :PROPERTIES:
6380 :DESCRIPTION: Starting and stopping a clock.
6381 :END:
6383 #+attr_texinfo: :sep ,
6384 - {{{kbd(C-c C-x C-i)}}} (~org-clock-in~) ::
6386      #+kindex: C-c C-x C-i
6387      #+findex: org-clock-in
6388      #+vindex: org-clock-into-drawer
6389      #+vindex: org-clock-continuously
6390      #+cindex: LOG_INTO_DRAWER, property
6391      Start the clock on the current item (clock-in).  This inserts the
6392      CLOCK keyword together with a timestamp.  If this is not the
6393      first clocking of this item, the multiple CLOCK lines are wrapped
6394      into a =LOGBOOK= drawer (see also the variable
6395      ~org-clock-into-drawer~).  You can also overrule the setting of
6396      this variable for a subtree by setting a =CLOCK_INTO_DRAWER= or
6397      =LOG_INTO_DRAWER= property.  When called with a {{{kbd(C-u)}}}
6398      prefix argument, select the task from a list of recently clocked
6399      tasks.  With two {{{kbd(C-u C-u)}}} prefixes, clock into the task
6400      at point and mark it as the default task; the default task is
6401      always be available with letter {{{kbd(d)}}} when selecting
6402      a clocking task.  With three {{{kbd(C-u C-u C-u)}}} prefixes,
6403      force continuous clocking by starting the clock when the last
6404      clock stopped.
6406      #+cindex: CLOCK_MODELINE_TOTAL, property
6407      #+cindex: LAST_REPEAT, property
6408      #+vindex: org-clock-modeline-total
6409      #+vindex: org-clock-in-prepare-hook
6410      While the clock is running, Org shows the current clocking time
6411      in the mode line, along with the title of the task.  The clock
6412      time shown is all time ever clocked for this task and its
6413      children.  If the task has an effort estimate (see [[*Effort
6414      Estimates]]), the mode line displays the current clocking time
6415      against it[fn:72].  If the task is a repeating one (see [[*Repeated
6416      tasks]]), show only the time since the last reset of the
6417      task[fn:73].  You can exercise more control over show time with
6418      the =CLOCK_MODELINE_TOTAL= property.  It may have the values
6419      =current= to show only the current clocking instance, =today= to
6420      show all time clocked on this tasks today---see also the
6421      variable ~org-extend-today-until~, ~all~ to include all time, or
6422      ~auto~ which is the default[fn:74].  Clicking with
6423      {{{kbd(mouse-1)}}} onto the mode line entry pops up a menu with
6424      clocking options.
6426 - {{{kbd(C-c C-x C-o)}}} (~org-clock-out~) ::
6428      #+kindex: C-c C-x C-o
6429      #+findex: org-clock-out
6430      #+vindex: org-log-note-clock-out
6431      Stop the clock (clock-out).  This inserts another timestamp at
6432      the same location where the clock was last started.  It also
6433      directly computes the resulting time in inserts it after the time
6434      range as ==>HH:MM=.  See the variable ~org-log-note-clock-out~
6435      for the possibility to record an additional note together with
6436      the clock-out timestamp[fn:75].
6438 - {{{kbd(C-c C-x C-x)}}} (~org-clock-in-last~) ::
6440      #+kindex: C-c C-x C-x
6441      #+findex: org-clock-in-last
6442      #+vindex: org-clock-continuously
6443      Re-clock the last clocked task.  With one {{{kbd(C-u)}}} prefix
6444      argument, select the task from the clock history.  With two
6445      {{{kbd(C-u)}}} prefixes, force continuous clocking by starting
6446      the clock when the last clock stopped.
6448 - {{{kbd(C-c C-x C-e)}}} (~org-clock-modify-effort-estimate~) ::
6450      #+kindex: C-c C-x C-e
6451      #+findex: org-clock-modify-effort-estimate
6452      Update the effort estimate for the current clock task.
6454 - {{{kbd(C-c C-c)}}} or {{{kbd(C-c C-y)}}} (~org-evaluate-time-range~) ::
6456      #+kindex: C-c C-c
6457      #+kindex: C-c C-y
6458      #+findex: org-evaluate-time-range
6459      Recompute the time interval after changing one of the timestamps.
6460      This is only necessary if you edit the timestamps directly.  If
6461      you change them with {{{kbd(S-<cursor>)}}} keys, the update is
6462      automatic.
6464 - {{{kbd(C-S-up)}}} (~org-clock-timestamps-up~), {{{kbd(C-S-down)}}} (~org-clock-timestamps-down~) ::
6466      #+kindex: C-S-up
6467      #+findex: org-clock-timestamps-up
6468      #+kindex: C-S-down
6469      #+findex: org-clock-timestamps-down
6470      On CLOCK log lines, increase/decrease both timestamps so that the
6471      clock duration keeps the same value.
6473 - {{{kbd(S-M-up)}}} (~org-timestamp-up~), {{{kbd(S-M-down)}}} (~org-timestamp-down~) ::
6475      #+kindex: S-M-up
6476      #+findex: org-clock-timestamp-up
6477      #+kindex: S-M-down
6478      #+findex: org-clock-timestamp-down
6479      On =CLOCK= log lines, increase/decrease the timestamp at point
6480      and the one of the previous, or the next, clock timestamp by the
6481      same duration.  For example, if you hit {{{kbd(S-M-up)}}} to
6482      increase a clocked-out timestamp by five minutes, then the
6483      clocked-in timestamp of the next clock is increased by five
6484      minutes.
6486 - {{{kbd(C-c C-t)}}} (~org-todo~) ::
6488      #+kindex: C-c C-t
6489      #+findex: org-todo
6490      Changing the TODO state of an item to DONE automatically stops
6491      the clock if it is running in this same item.
6493 - {{{kbd(C-c C-x C-q)}}} (~org-clock-cancel~) ::
6495      #+kindex: C-c C-x C-q
6496      #+findex: org-clock-cancel
6497      Cancel the current clock.  This is useful if a clock was started
6498      by mistake, or if you ended up working on something else.
6500 - {{{kbd(C-c C-x C-j)}}} (~org-clock-goto~) ::
6502      #+kindex: C-c C-x C-j
6503      #+findex: or-clock-goto
6504      Jump to the headline of the currently clocked in task.  With
6505      a {{{kbd(C-u)}}} prefix argument, select the target task from
6506      a list of recently clocked tasks.
6508 - {{{kbd(C-c C-x C-d)}}} (~org-clock-display~) ::
6510      #+kindex: C-c C-x C-d
6511      #+findex: org-clock-display
6512      #+vindex: org-remove-highlights-with-change
6513      Display time summaries for each subtree in the current buffer.
6514      This puts overlays at the end of each headline, showing the total
6515      time recorded under that heading, including the time of any
6516      subheadings.  You can use visibility cycling to study the tree,
6517      but the overlays disappear when you change the buffer (see
6518      variable ~org-remove-highlights-with-change~) or press {{{kbd(C-c
6519      C-c)}}}.
6521 The {{{kbd(l)}}} key may be used in the agenda (see [[*Weekly/daily
6522 agenda]]) to show which tasks have been worked on or closed during
6523 a day.
6525 *Important:* note that both ~org-clock-out~ and ~org-clock-in-last~
6526 can have a global keybinding and do not modify the window disposition.
6528 *** The clock table
6529 :PROPERTIES:
6530 :DESCRIPTION: Detailed reports.
6531 :END:
6532 #+cindex: clocktable, dynamic block
6533 #+cindex: report, of clocked time
6535 Org mode can produce quite complex reports based on the time clocking
6536 information.  Such a report is called a /clock table/, because it is
6537 formatted as one or several Org tables.
6539 #+attr_texinfo: :sep ,
6540 - {{{kbd(C-c C-x C-r)}}} (~org-clock-report~) ::
6542      #+kindex: C-c C-x C-r
6543      #+findex: org-clock-report
6544      Insert a dynamic block (see [[*Dynamic Blocks]]) containing a clock
6545      report as an Org mode table into the current file.  When the
6546      cursor is at an existing clock table, just update it.  When
6547      called with a prefix argument, jump to the first clock report in
6548      the current document and update it.  The clock table always
6549      includes also trees with =ARCHIVE= tag.
6551 - {{{kbd(C-c C-c)}}} or {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
6553      #+kindex: C-c C-c
6554      #+kindex: C-c C-x C-u
6555      #+findex: org-dblock-update
6556      Update dynamic block at point.  The cursor needs to be in the
6557      =BEGIN= line of the dynamic block.
6559 - {{{kbd(C-u C-c C-x C-u)}}} ::
6561      #+kindex: C-u C-c C-x C-u
6562      Update all dynamic blocks (see [[*Dynamic Blocks]]).  This is useful
6563      if you have several clock table blocks in a buffer.
6565 - {{{kbd(S-left)}}}, {{{kbd(S-right)}}} (~org-clocktable-try-shift~) ::
6567      #+kindex: S-left
6568      #+kindex: S-right
6569      #+findex: org-clocktable-try-shift
6570      Shift the current =:block= interval and update the table.  The
6571      cursor needs to be in the =#+BEGIN: clocktable= line for this
6572      command.  If =:block= is =today=, it is shifted to =today-1=,
6573      etc.
6575 Here is an example of the frame for a clock table as it is inserted
6576 into the buffer with the {{{kbd(C-c C-x C-r)}}} command:
6578 #+cindex: BEGIN clocktable
6579 #+begin_example
6580   ,#+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
6581   ,#+END: clocktable
6582 #+end_example
6584 #+texinfo: @noindent
6585 #+vindex: org-clocktable-defaults
6586 The =#+BEGIN= line and specify a number of options to define the
6587 scope, structure, and formatting of the report.  Defaults for all
6588 these options can be configured in the variable
6589 ~org-clocktable-defaults~.
6591 #+texinfo: @noindent
6592 First there are options that determine which clock entries are to
6593 be selected:
6595 - :maxlevel ::
6597      Maximum level depth to which times are listed in the table.
6598      Clocks at deeper levels are summed into the upper level.
6600 - :scope ::
6602      The scope to consider.  This can be any of the following:
6604      | ~nil~                  | the current buffer or narrowed region                    |
6605      | ~file~                 | the full current buffer                                  |
6606      | ~subtree~              | the subtree where the clocktable is located              |
6607      | ~treeN~                | the surrounding level N tree, for example =tree3=        |
6608      | ~tree~                 | the surrounding level 1 tree                             |
6609      | ~agenda~               | all agenda files                                         |
6610      | =("file" ...)=         | scan these files                                         |
6611      | =FUNCTION=             | scan files returned by calling FUNCTION with no argument |
6612      | ~file-with-archives~   | current file and its archives                            |
6613      | ~agenda-with-archives~ | all agenda files, including archives                     |
6615 - :block ::
6617      The time block to consider.  This block is specified either
6618      absolutely, or relative to the current time and may be any of
6619      these formats:
6621      | =2007-12-31=                            | New year eve 2007     |
6622      | =2007-12=                               | December 2007         |
6623      | =2007-W50=                              | ISO-week 50 in 2007   |
6624      | =2007-Q2=                               | 2nd quarter in 2007   |
6625      | =2007=                                  | the year 2007         |
6626      | ~today~, ~yesterday~, ~today-N~         | a relative day        |
6627      | ~thisweek~, ~lastweek~, ~thisweek-N~    | a relative week       |
6628      | ~thismonth~, ~lastmonth~, ~thismonth-N~ | a relative month      |
6629      | ~thisyear~, ~lastyear~, ~thisyear-N~    | a relative year       |
6630      | ~untilnow~                              | all clocked time ever |
6632      #+vindex: org-clock-display-default-range
6633      When this option is not set, Org falls back to the value in
6634      ~org-clock-display-default-range~, which defaults to the current
6635      year.
6637      Use {{{kbd(S-left)}}} or {{{kbd(S-right)}}} to shift the time
6638      interval.
6640 - :tstart ::
6642      A time string specifying when to start considering times.
6643      Relative times like ="<-2w>"= can also be used.  See [[*Matching
6644      tags and properties]] for relative time syntax.
6646 - :tend  ::
6648      A time string specifying when to stop considering times.
6649      Relative times like ="<now>"= can also be used.  See [[*Matching
6650      tags and properties]] for relative time syntax.
6652 - wstart ::
6654      The starting day of the week.  The default is 1 for Monday.
6656 - mstart ::
6658      The starting day of the month.  The default is 1 for the first.
6660 - :step ::
6662      Set to ~week~ or ~day~ to split the table into chunks.  To use
6663      this, ~:block~ or ~:tstart~, ~:tend~ are needed.
6665 - :stepskip0 ::
6667      Do not show steps that have zero time.
6669 - :fileskip0 ::
6671      Do not show table sections from files which did not contribute.
6673 - :tags ::
6675      A tags match to select entries that should contribute.  See
6676      [[*Matching tags and properties]] for the match syntax.
6678 #+findex: org-clocktable-write-default
6679 Then there are options that determine the formatting of the table.
6680 There options are interpreted by the function
6681 ~org-clocktable-write-default~, but you can specify your own function
6682 using the =:formatter= parameter.
6684 - :emphasize ::
6686      When ~t~, emphasize level one and level two items.
6688 - :lang ::
6690      Language[fn:76] to use for descriptive cells like "Task".
6692 - :link ::
6694      Link the item headlines in the table to their origins.
6696 - :narrow ::
6698      An integer to limit the width of the headline column in the Org
6699      table.  If you write it like =50!=, then the headline is also
6700      shortened in export.
6702 - :indent  ::
6704      Indent each headline field according to its level.
6706 - :tcolumns ::
6708      Number of columns to be used for times.  If this is smaller than
6709      =:maxlevel=, lower levels are lumped into one column.
6711 - :level ::
6713      Should a level number column be included?
6715 - :sort ::
6717      A cons cell containing the column to sort and a sorting type.
6718      E.g., =:sort (1 . ?a)= sorts the first column alphabetically.
6720 - :compact ::
6722      Abbreviation for =:level nil :indent t :narrow 40! :tcolumns 1=.
6723      All are overwritten except if there is an explicit =:narrow=.
6725 - :timestamp ::
6727      A timestamp for the entry, when available.  Look for SCHEDULED,
6728      DEADLINE, TIMESTAMP and TIMESTAMP_IA special properties (see
6729      [[*Special Properties]]), in this order.
6731 - :properties ::
6733      List of properties shown in the table.  Each property gets its
6734      own column.
6736 - :inherit-props ::
6738      When this flag is non-~nil~, the values for =:properties= are
6739      inherited.
6741 - :formula  ::
6743      Content of a =TBLFM= keyword to be added and evaluated.  As
6744      a special case, =:formula %= adds a column with % time.  If you
6745      do not specify a formula here, any existing formula below the
6746      clock table survives updates and is evaluated.
6748 - :formatter ::
6750      A function to format clock data and insert it into the buffer.
6752 To get a clock summary of the current level 1 tree, for the current
6753 day, you could write:
6755 #+begin_example
6756   ,#+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
6757   ,#+END: clocktable
6758 #+end_example
6760 #+texinfo: @noindent
6761 To use a specific time range you could write[fn:77]
6763 #+begin_example
6764   ,#+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
6765                       :tend "<2006-08-10 Thu 12:00>"
6766   ,#+END: clocktable
6767 #+end_example
6769 A range starting a week ago and ending right now could be written as
6771 #+begin_example
6772   ,#+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
6773   ,#+END: clocktable
6774 #+end_example
6776 A summary of the current subtree with % times would be:
6778 #+begin_example
6779   ,#+BEGIN: clocktable :scope subtree :link t :formula %
6780   ,#+END: clocktable
6781 #+end_example
6783 A horizontally compact representation of everything clocked during
6784 last week would be:
6786 #+begin_example
6787   ,#+BEGIN: clocktable :scope agenda :block lastweek :compact t
6788   ,#+END: clocktable
6789 #+end_example
6791 *** Resolving idle time and continuous clocking
6792 :PROPERTIES:
6793 :DESCRIPTION: Resolving time when you've been idle.
6794 :ALT_TITLE: Resolving idle time
6795 :END:
6797 **** Resolving idle time
6798 :PROPERTIES:
6799 :UNNUMBERED: notoc
6800 :END:
6802 #+cindex: resolve idle time
6803 #+cindex: idle, resolve, dangling
6805 If you clock in on a work item, and then walk away from your
6806 computer---perhaps to take a phone call---you often need to
6807 "resolve" the time you were away by either subtracting it from the
6808 current clock, or applying it to another one.
6810 #+vindex: org-clock-idle-time
6811 #+vindex: org-clock-x11idle-program-name
6812 By customizing the variable ~org-clock-idle-time~ to some integer,
6813 such as 10 or 15, Emacs can alert you when you get back to your
6814 computer after being idle for that many minutes[fn:78], and ask what
6815 you want to do with the idle time.  There will be a question waiting
6816 for you when you get back, indicating how much idle time has passed
6817 constantly updated with the current amount, as well as a set of
6818 choices to correct the discrepancy:
6820 - {{{kbd(k)}}} ::
6822      #+kindex: k
6823      To keep some or all of the minutes and stay clocked in, press
6824      {{{kbd(k)}}}.  Org asks how many of the minutes to keep.  Press
6825      {{{kbd(RET)}}} to keep them all, effectively changing nothing, or
6826      enter a number to keep that many minutes.
6828 - {{{kbd(K)}}} ::
6830      #+kindex: K
6831      If you use the shift key and press {{{kbd(K)}}}, it keeps however
6832      many minutes you request and then immediately clock out of that
6833      task.  If you keep all of the minutes, this is the same as just
6834      clocking out of the current task.
6836 - {{{kbd(s)}}} ::
6838      #+kindex: s
6839      To keep none of the minutes, use {{{kbd(s)}}} to subtract all the
6840      away time from the clock, and then check back in from the moment
6841      you returned.
6843 - {{{kbd(S)}}} ::
6845      #+kindex: S
6846      To keep none of the minutes and just clock out at the start of
6847      the away time, use the shift key and press {{{kbd(S)}}}.
6848      Remember that using shift always leave you clocked out, no matter
6849      which option you choose.
6851 - {{{kbd(C)}}} ::
6853      #+kindex: C
6854      To cancel the clock altogether, use {{{kbd(C)}}}.  Note that if
6855      instead of canceling you subtract the away time, and the
6856      resulting clock amount is less than a minute, the clock is still
6857      canceled rather than cluttering up the log with an empty entry.
6859 What if you subtracted those away minutes from the current clock, and
6860 now want to apply them to a new clock?  Simply clock in to any task
6861 immediately after the subtraction.  Org will notice that you have
6862 subtracted time "on the books", so to speak, and will ask if you want
6863 to apply those minutes to the next task you clock in on.
6865 There is one other instance when this clock resolution magic occurs.
6866 Say you were clocked in and hacking away, and suddenly your cat chased
6867 a mouse who scared a hamster that crashed into your UPS's power
6868 button!  You suddenly lose all your buffers, but thanks to auto-save
6869 you still have your recent Org mode changes, including your last clock
6872 If you restart Emacs and clock into any task, Org will notice that you
6873 have a dangling clock which was never clocked out from your last
6874 session.  Using that clock's starting time as the beginning of the
6875 unaccounted-for period, Org will ask how you want to resolve that
6876 time.  The logic and behavior is identical to dealing with away time
6877 due to idleness; it is just happening due to a recovery event rather
6878 than a set amount of idle time.
6880 You can also check all the files visited by your Org agenda for
6881 dangling clocks at any time using {{{kbd(M-x org-resolve-clocks
6882 RET)}}} (or {{{kbd(C-c C-x C-z)}}}).
6884 **** Continuous clocking
6885 :PROPERTIES:
6886 :UNNUMBERED: notoc
6887 :END:
6888 #+cindex: continuous clocking
6890 #+vindex: org-clock-continuously
6891 You may want to start clocking from the time when you clocked out the
6892 previous task.  To enable this systematically, set
6893 ~org-clock-continuously~ to non-~nil~.  Each time you clock in, Org
6894 retrieves the clock-out time of the last clocked entry for this
6895 session, and start the new clock from there.
6897 If you only want this from time to time, use three universal prefix
6898 arguments with ~org-clock-in~ and two {{{kbd(C-u C-u)}}} with
6899 ~org-clock-in-last~.
6901 ** Effort Estimates
6902 :PROPERTIES:
6903 :DESCRIPTION: Planning work effort in advance.
6904 :END:
6905 #+cindex: effort estimates
6906 #+cindex: EFFORT, property
6907 #+vindex: org-effort-property
6909 If you want to plan your work in a very detailed way, or if you need
6910 to produce offers with quotations of the estimated work effort, you
6911 may want to assign effort estimates to entries.  If you are also
6912 clocking your work, you may later want to compare the planned effort
6913 with the actual working time, a great way to improve planning
6914 estimates.  Effort estimates are stored in a special property
6915 =EFFORT=.  You can set the effort for an entry with the following
6916 commands:
6918 - {{{kbd(C-c C-x e)}}}  (~org-set-effort~) ::
6920      #+kindex: C-c C-x e
6921      #+findex: org-set-effort
6922      Set the effort estimate for the current entry.  With a prefix
6923      argument, set it to the next allowed value---see below.  This
6924      command is also accessible from the agenda with the {{{kbd(e)}}}
6925      key.
6927 - {{{kbd(C-c C-x C-e)}}} (~org-clock-modify-effort-estimate~) ::
6929      #+kindex: C-c C-x C-e
6930      #+findex: org-clock-modify-effort-estimate
6931      Modify the effort estimate of the item currently being clocked.
6933 Clearly the best way to work with effort estimates is through column
6934 view (see [[*Column View]]).  You should start by setting up discrete
6935 values for effort estimates, and a =COLUMNS= format that displays
6936 these values together with clock sums---if you want to clock your
6937 time.  For a specific buffer you can use:
6939 #+begin_example
6940   ,#+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
6941   ,#+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort){:} %CLOCKSUM
6942 #+end_example
6944 #+texinfo: noindent
6945 #+vindex: org-global-properties
6946 #+vindex: org-columns-default-format
6947 or, even better, you can set up these values globally by customizing
6948 the variables ~org-global-properties~ and
6949 ~org-columns-default-format~.  In particular if you want to use this
6950 setup also in the agenda, a global setup may be advised.
6952 The way to assign estimates to individual items is then to switch to
6953 column mode, and to use {{{kbd(S-right)}}} and {{{kbd(S-left)}}} to
6954 change the value.  The values you enter are immediately summed up in
6955 the hierarchy.  In the column next to it, any clocked time is
6956 displayed.
6958 #+vindex: org-agenda-columns-add-appointments-to-effort-sum
6959 If you switch to column view in the daily/weekly agenda, the effort
6960 column summarizes the estimated work effort for each day[fn:79], and
6961 you can use this to find space in your schedule.  To get an overview
6962 of the entire part of the day that is committed, you can set the
6963 option ~org-agenda-columns-add-appointments-to-effort-sum~.  The
6964 appointments on a day that take place over a specified time interval
6965 are then also added to the load estimate of the day.
6967 Effort estimates can be used in secondary agenda filtering that is
6968 triggered with the {{{kbd(/)}}} key in the agenda (see [[*Commands in
6969 the Agenda Buffer]]).  If you have these estimates defined consistently,
6970 two or three key presses narrow down the list to stuff that fits into
6971 an available time slot.
6973 ** Taking Notes with a Relative Timer
6974 :PROPERTIES:
6975 :DESCRIPTION: Notes with a running timer.
6976 :ALT_TITLE: Timers
6977 :END:
6978 #+cindex: relative timer
6979 #+cindex: countdown timer
6981 Org provides two types of timers.  There is a relative timer that
6982 counts up, which can be useful when taking notes during, for example,
6983 a meeting or a video viewing.  There is also a countdown timer.
6985 The relative and countdown are started with separate commands.
6987 - {{{kbd(C-c C-x 0)}}} (~org-timer-start~) ::
6989      #+kindex: C-c C-x 0
6990      #+findex: org-timer-start
6991      Start or reset the relative timer.  By default, the timer is set
6992      to 0.  When called with a {{{kbd(C-u)}}} prefix, prompt the user
6993      for a starting offset.  If there is a timer string at point, this
6994      is taken as the default, providing a convenient way to restart
6995      taking notes after a break in the process.  When called with
6996      a double prefix argument {{{kbd(C-u C-u)}}}, change all timer
6997      strings in the active region by a certain amount.  This can be
6998      used to fix timer strings if the timer was not started at exactly
6999      the right moment.
7001 - {{{kbd(C-c C-x ;)}}} (~org-timer-set-timer~) ::
7003      #+kindex: C-c C-x ;
7004      #+findex: org-timer-set-timer
7005      #+vindex: org-timer-default-timer
7006      Start a countdown timer.  The user is prompted for a duration.
7007      ~org-timer-default-timer~ sets the default countdown value.
7008      Giving a numeric prefix argument overrides this default value.
7009      This command is available as {{{kbd(;)}}} in agenda buffers.
7011 Once started, relative and countdown timers are controlled with the
7012 same commands.
7014 - {{{kbd(C-c C-x .)}}} (~org-timer~) ::
7016      #+kindex: C-c C-x .
7017      #+findex: org-timer
7018      Insert a relative time into the buffer.  The first time you use
7019      this, the timer starts.  Using a prefix argument restarts it.
7021 - {{{kbd(C-c C-x -)}}} (~org-timer-item~) ::
7023      #+kindex: C-c C-x -
7024      #+findex: org-timer-item
7025      Insert a description list item with the current relative time.
7026      With a prefix argument, first reset the timer to 0.
7028 - {{{kbd(M-RET)}}} (~org-insert-heading~) ::
7030      #+kindex: M-RET
7031      #+findex: org-insert-heading
7032      Once the timer list is started, you can also use
7033      {{{kbd(M-RET)}}} to insert new timer items.
7035 - {{{kbd(C-c C-x \,)}}} (~org-timer-pause-or-continue~) ::
7037      #+kindex: C-c C-x ,
7038      #+findex: org-timer-pause-or-continue
7039      Pause the timer, or continue it if it is already paused.
7041 - {{{kbd(C-c C-x _)}}} (~org-timer-stop~) ::
7043      #+kindex: C-c C-x _
7044      #+findex: org-timer-stop
7045      Stop the timer.  After this, you can only start a new timer, not
7046      continue the old one.  This command also removes the timer from
7047      the mode line.
7049 * Capture, Refile, Archive
7050 :PROPERTIES:
7051 :DESCRIPTION: The ins and outs for projects.
7052 :END:
7053 #+cindex: capture
7055 An important part of any organization system is the ability to quickly
7056 capture new ideas and tasks, and to associate reference material with
7057 them.  Org does this using a process called /capture/.  It also can
7058 store files related to a task (/attachments/) in a special directory.
7059 Once in the system, tasks and projects need to be moved around.
7060 Moving completed project trees to an archive file keeps the system
7061 compact and fast.
7063 ** Capture
7064 :PROPERTIES:
7065 :DESCRIPTION: Capturing new stuff.
7066 :END:
7067 #+cindex: capture
7069 Capture lets you quickly store notes with little interruption of your
7070 work flow.  Org's method for capturing new items is heavily inspired
7071 by John Wiegley's excellent =remember.el= package.
7073 *** Setting up capture
7074 :PROPERTIES:
7075 :DESCRIPTION: Where notes will be stored.
7076 :END:
7078 The following customization sets a default target file for notes, and
7079 defines a global key[fn:80] for capturing new material.
7081 #+vindex: org-default-notes-file
7082 #+begin_src emacs-lisp
7083   (setq org-default-notes-file (concat org-directory "/notes.org"))
7084   (define-key global-map "\C-cc" 'org-capture)
7085 #+end_src
7087 *** Using capture
7088 :PROPERTIES:
7089 :DESCRIPTION: Commands to invoke and terminate capture.
7090 :END:
7092 - {{{kbd(C-c c)}}} (~org-capture~) ::
7094      #+kindex: C-c c
7095      #+findex: org-capture
7096      #+cindex: date tree
7097      Call the command ~org-capture~.  Note that this keybinding is
7098      global and not active by default: you need to install it.  If you
7099      have templates defined (see [[*Capture templates]]), it offers these
7100      templates for selection or use a new Org outline node as the
7101      default template.  It inserts the template into the target file
7102      and switch to an indirect buffer narrowed to this new node.  You
7103      may then insert the information you want.
7105 - {{{kbd(C-c C-c)}}} (~org-capture-finalize~) ::
7107      #+kindex: C-c C-c
7108      #+findex: org-capture-finalize
7109      Once you have finished entering information into the capture
7110      buffer, {{{kbd(C-c C-c)}}} returns you to the window
7111      configuration before the capture process, so that you can resume
7112      your work without further distraction.  When called with a prefix
7113      argument, finalize and then jump to the captured item.
7115 - {{{kbd(C-c C-w)}}} (~org-capture-refile~) ::
7117      #+kindex: C-c C-w
7118      #+findex: org-capture-refile
7119      Finalize the capture process by refiling the note to a different
7120      place (see [[*Refile and Copy]]).  Please realize that this is
7121      a normal refiling command that will be executed---so the cursor
7122      position at the moment you run this command is important.  If you
7123      have inserted a tree with a parent and children, first move the
7124      cursor back to the parent.  Any prefix argument given to this
7125      command is passed on to the ~org-refile~ command.
7127 - {{{kbd(C-c C-k)}}} (~org-capture-kill~) ::
7129      #+kindex: C-c C-k
7130      #+findex: org-capture-kill
7131      Abort the capture process and return to the previous state.
7133 You can also call ~org-capture~ in a special way from the agenda,
7134 using the {{{kbd(k c)}}} key combination.  With this access, any
7135 timestamps inserted by the selected capture template defaults to the
7136 cursor date in the agenda, rather than to the current date.
7138 To find the locations of the last stored capture, use ~org-capture~
7139 with prefix commands:
7141 - {{{kbd(C-u C-c c)}}} ::
7143      #+kindex: C-u C-c c
7144      Visit the target location of a capture template.  You get to
7145      select the template in the usual way.
7147 - {{{kbd(C-u C-u C-c c)}}} ::
7149      #+kindex: C-u C-u C-c c
7150      Visit the last stored capture item in its buffer.
7152 #+vindex: org-capture-bookmark
7153 #+cindex: org-capture-last-stored
7154 You can also jump to the bookmark ~org-capture-last-stored~, which is
7155 automatically created unless you set ~org-capture-bookmark~ to ~nil~.
7157 To insert the capture at point in an Org buffer, call ~org-capture~
7158 with a ~C-0~ prefix argument.
7160 *** Capture templates
7161 :PROPERTIES:
7162 :DESCRIPTION: Define the outline of different note types.
7163 :END:
7164 #+cindex: templates, for Capture
7166 You can use templates for different types of capture items, and for
7167 different target locations.  The easiest way to create such templates
7168 is through the customize interface.
7170 - {{{kbd(C-c c C)}}} ::
7172      #+kindex: C-c c C
7173      #+vindex: org-capture-templates
7174      Customize the variable ~org-capture-templates~.
7176 Before we give the formal description of template definitions, let's
7177 look at an example.  Say you would like to use one template to create
7178 general TODO entries, and you want to put these entries under the
7179 heading =Tasks= in your file =~/org/gtd.org=.  Also, a date tree in
7180 the file =journal.org= should capture journal entries.  A possible
7181 configuration would look like:
7183 #+begin_src emacs-lisp
7184   (setq org-capture-templates
7185         '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
7186            "* TODO %?\n  %i\n  %a")
7187           ("j" "Journal" entry (file+datetree "~/org/journal.org")
7188            "* %?\nEntered on %U\n  %i\n  %a")))
7189 #+end_src
7191 #+texinfo: @noindent
7192 If you then press {{{kbd(C-c c t)}}}, Org will prepare the template
7193 for you like this:
7195 #+begin_example
7196   ,* TODO
7197     [[file:LINK TO WHERE YOU INITIATED CAPTURE]]
7198 #+end_example
7200 #+texinfo: @noindent
7201 During expansion of the template, ~%a~ has been replaced by a link to
7202 the location from where you called the capture command.  This can be
7203 extremely useful for deriving tasks from emails, for example.  You
7204 fill in the task definition, press {{{kbd(C-c C-c)}}} and Org returns
7205 you to the same place where you started the capture process.
7207 To define special keys to capture to a particular template without
7208 going through the interactive template selection, you can create your
7209 key binding like this:
7211 #+begin_src emacs-lisp
7212   (define-key global-map "\C-cx"
7213     (lambda () (interactive) (org-capture nil "x")))
7214 #+end_src
7216 **** Template elements
7217 :PROPERTIES:
7218 :DESCRIPTION: What is needed for a complete template entry.
7219 :END:
7221 Now lets look at the elements of a template definition.  Each entry in
7222 ~org-capture-templates~ is a list with the following items:
7224 - keys ::
7226      The keys that selects the template, as a string, characters only,
7227      for example ="a"=, for a template to be selected with a single
7228      key, or ="bt"= for selection with two keys.  When using several
7229      keys, keys using the same prefix key must be sequential in the
7230      list and preceded by a 2-element entry explaining the prefix key,
7231      for example:
7233      #+begin_src emacs-lisp
7234        ("b" "Templates for marking stuff to buy")
7235      #+end_src
7237      #+texinfo: @noindent
7238      If you do not define a template for the {{{kbd(C)}}} key, this
7239      key opens the Customize buffer for this complex variable.
7241 - description ::
7243      A short string describing the template, shown during selection.
7245 - type ::
7247      The type of entry, a symbol.  Valid values are:
7249      - ~entry~ ::
7251           An Org mode node, with a headline.  Will be filed as the child
7252           of the target entry or as a top-level entry.  The target file
7253           should be an Org file.
7255      - ~item~ ::
7257           A plain list item, placed in the first plain list at the
7258           target location.  Again the target file should be an Org
7259           file.
7261      - ~checkitem~ ::
7263           A checkbox item.  This only differs from the plain list item
7264           by the default template.
7266      - ~table-line~ ::
7268           A new line in the first table at the target location.  Where
7269           exactly the line will be inserted depends on the properties
7270           ~:prepend~ and ~:table-line-pos~ (see below).
7272      - ~plain~ ::
7274           Text to be inserted as it is.
7276 - target ::
7278      #+vindex: org-default-notes-file
7279      #+vindex: org-directory
7280      Specification of where the captured item should be placed.  In
7281      Org files, targets usually define a node.  Entries will become
7282      children of this node.  Other types will be added to the table or
7283      list in the body of this node.  Most target specifications
7284      contain a file name.  If that file name is the empty string, it
7285      defaults to ~org-default-notes-file~.  A file can also be given
7286      as a variable or as a function called with no argument.  When an
7287      absolute path is not specified for a target, it is taken as
7288      relative to ~org-directory~.
7290      Valid values are:
7292      - =(file "path/to/file")= ::
7294           Text will be placed at the beginning or end of that file.
7296      - =(id "id of existing org entry")= ::
7298           Filing as child of this entry, or in the body of the entry.
7300      - =(file+headline "filename" "node headline")= ::
7302           Fast configuration if the target heading is unique in the file.
7304      - =(file+olp "filename" "Level 1 heading" "Level 2" ...)= ::
7306           For non-unique headings, the full path is safer.
7308      - =(file+regexp "filename" "regexp to find location")= ::
7310           Use a regular expression to position the cursor.
7312      - =(file+olp+datetree "filename" [ "Level 1 heading" ...])= ::
7314           This target[fn:81] creates a heading in a date tree[fn:82] for
7315           today's date.  If the optional outline path is given, the tree
7316           will be built under the node it is pointing to, instead of at
7317           top level.  Check out the ~:time-prompt~ and ~:tree-type~
7318           properties below for additional options.
7320      - ~(file+function "filename" function-finding-location)~ ::
7322           A function to find the right location in the file.
7324      - ~(clock)~ ::
7326           File to the entry that is currently being clocked.
7328      - ~(function function-finding-location)~ ::
7330           Most general way: write your own function which both visits the
7331           file and moves point to the right location.
7333 - template ::
7335      The template for creating the capture item.  If you leave this
7336      empty, an appropriate default template will be used.  Otherwise
7337      this is a string with escape codes, which will be replaced
7338      depending on time and context of the capture call.  The string
7339      with escapes may be loaded from a template file, using the
7340      special syntax =(file "template filename")=.  See below for more
7341      details.
7343 - properties ::
7345      The rest of the entry is a property list of additional options.
7346      Recognized properties are:
7348      - ~:prepend~ ::
7350           Normally new captured information will be appended at the
7351           target location (last child, last table line, last list item,
7352           ...).  Setting this property changes that.
7354      - ~:immediate-finish~ ::
7356           When set, do not offer to edit the information, just file it
7357           away immediately.  This makes sense if the template only needs
7358           information that can be added automatically.
7360      - ~:empty-lines~ ::
7362           Set this to the number of lines to insert before and after the
7363           new item.  Default 0, and the only other common value is 1.
7365      - ~:clock-in~ ::
7367           Start the clock in this item.
7369      - ~:clock-keep~ ::
7371           Keep the clock running when filing the captured entry.
7373      - ~:clock-resume~ ::
7375           If starting the capture interrupted a clock, restart that clock
7376           when finished with the capture.  Note that ~:clock-keep~ has
7377           precedence over ~:clock-resume~.  When setting both to
7378           non-~nil~, the current clock will run and the previous one will
7379           not be resumed.
7381      - ~:time-prompt~ ::
7383           Prompt for a date/time to be used for date/week trees and when
7384           filling the template.  Without this property, capture uses the
7385           current date and time.  Even if this property has not been set,
7386           you can force the same behavior by calling ~org-capture~ with
7387           a {{{kbd(C-1)}}} prefix argument.
7389      - ~:tree-type~ ::
7391           When ~week~, make a week tree instead of the month tree, i.e.,
7392           place the headings for each day under a heading with the
7393           current ISO week.
7395      - ~:unnarrowed~ ::
7397           Do not narrow the target buffer, simply show the full buffer.  Default
7398           is to narrow it so that you only see the new material.
7400      - ~:table-line-pos~ ::
7402           Specification of the location in the table where the new line
7403           should be inserted.  It should be a string like =II-3= meaning
7404           that the new line should become the third line before the
7405           second horizontal separator line.
7407      - ~:kill-buffer~ ::
7409           If the target file was not yet visited when capture was invoked, kill
7410           the buffer again after capture is completed.
7412 **** Template expansion
7413 :PROPERTIES:
7414 :DESCRIPTION: Filling in information about time and context.
7415 :END:
7417 In the template itself, special "%-escapes"[fn:83] allow dynamic
7418 insertion of content.  The templates are expanded in the order given
7419 here:
7421 - ~%[FILE]~ ::
7423      Insert the contents of the file given by {{{var(FILE)}}}.
7425 - ~%(SEXP)~ ::
7427      Evaluate Elisp SEXP and replace with the result.  The
7428      {{{var(SEXP)}}} must return a string.
7430 - ~%<FORMAT>~ ::
7432      The result of format-time-string on the {{{var(FORMAT)}}}
7433      specification.
7435 - ~%t~ ::
7437      Timestamp, date only.
7439 - ~%T~ ::
7441      Timestamp, with date and time.
7443 - ~%u~, ~%U~ ::
7445      Like ~%t~, ~%T~ above, but inactive timestamps.
7447 - ~%i~ ::
7449      Initial content, the region when capture is called while the
7450      region is active.  The entire text will be indented like ~%i~
7451      itself.
7453 - ~%a~ ::
7455      Annotation, normally the link created with ~org-store-link~.
7457 - ~%A~ ::
7459      Like ~%a~, but prompt for the description part.
7461 - ~%l~ ::
7463      Like ~%a~, but only insert the literal link.
7465 - ~%c~ ::
7467      Current kill ring head.
7469 - ~%x~ ::
7471      Content of the X clipboard.
7473 - ~%k~ ::
7475      Title of the currently clocked task.
7477 - ~%K~ ::
7479      Link to the currently clocked task.
7481 - ~%n~ ::
7483      User name (taken from ~user-full-name~).
7485 - ~%f~ ::
7487      File visited by current buffer when org-capture was called.
7489 - ~%F~ ::
7491      Full path of the file or directory visited by current buffer.
7493 - ~%:keyword~ ::
7495      Specific information for certain link types, see below.
7497 - ~%^g~  ::
7499      Prompt for tags, with completion on tags in target file.
7501 - ~%^G~  ::
7503      Prompt for tags, with completion all tags in all agenda files.
7505 - ~%^t~  ::
7507      Like ~%t~, but prompt for date.  Similarly ~%^T~, ~%^u~, ~%^U~.  You may
7508      define a prompt like ~%^{Birthday}t~.
7510 - ~%^C~  ::
7512      Interactive selection of which kill or clip to use.
7514 - ~%^L~  ::
7516      Like ~%^C~, but insert as link.
7518 - ~%^{PROP}p~ ::
7520      Prompt the user for a value for property PROP.
7522 - ~%^{PROMPT}~ ::
7524      Prompt the user for a string and replace this sequence with it.
7525      You may specify a default value and a completion table with
7526      ~%^{prompt|default|completion2|completion3...}~.  The arrow keys
7527      access a prompt-specific history.
7529 - ~%\n~ ::
7531      Insert the text entered at the Nth ~%^{PROMPT}~, where N is
7532      a number, starting from 1.
7534 - ~%?~ ::
7536      After completing the template, position cursor here.
7538 #+texinfo: @noindent
7539 #+vindex: org-store-link-props
7540 For specific link types, the following keywords are defined[fn:84]:
7542 #+vindex: org-from-is-user-regexp
7543 | Link type    | Available keywords                                       |
7544 |--------------+----------------------------------------------------------|
7545 | bbdb         | ~%:name~, ~%:company~                                    |
7546 | irc          | ~%:server~, ~%:port~, ~%:nick~                           |
7547 | mh, rmail    | ~%:type~, ~%:subject~, ~%:message-id~                    |
7548 |              | ~%:from~, ~%:fromname~, ~%:fromaddress~                  |
7549 |              | ~%:to~, ~%:toname~, ~%:toaddress~                        |
7550 |              | ~%:date~ (message date header field)                     |
7551 |              | ~%:date-timestamp~ (date as active timestamp)            |
7552 |              | ~%:date-timestamp-inactive~ (date as inactive timestamp) |
7553 |              | ~%:fromto~ (either "to NAME" or "from NAME")[fn:85]      |
7554 | gnus         | ~%:group~, for messages also all email fields            |
7555 | w3, w3m      | ~%:url~                                                  |
7556 | info         | ~%:file~, ~%:node~                                       |
7557 | calendar     | ~%:date~                                                 |
7558 | org-protocol | ~%:link~, ~%:description~, ~%:annotation~                |
7560 **** Templates in contexts
7561 :PROPERTIES:
7562 :DESCRIPTION: Only show a template in a specific context.
7563 :END:
7565 #+vindex: org-capture-templates-contexts
7566 To control whether a capture template should be accessible from
7567 a specific context, you can customize
7568 ~org-capture-templates-contexts~.  Let's say, for example, that you
7569 have a capture template "p" for storing Gnus emails containing
7570 patches.  Then you would configure this option like this:
7572 #+begin_src emacs-lisp
7573   (setq org-capture-templates-contexts
7574         '(("p" (in-mode . "message-mode"))))
7575 #+end_src
7577 You can also tell that the command key {{{kbd(p)}}} should refer to
7578 another template.  In that case, add this command key like this:
7580 #+begin_src emacs-lisp
7581   (setq org-capture-templates-contexts
7582         '(("p" "q" (in-mode . "message-mode"))))
7583 #+end_src
7585 See the docstring of the variable for more information.
7587 ** Attachments
7588 :PROPERTIES:
7589 :DESCRIPTION: Add files to tasks.
7590 :END:
7591 #+cindex: attachments
7592 #+vindex: org-attach-directory
7594 It is often useful to associate reference material with an outline
7595 node/task.  Small chunks of plain text can simply be stored in the
7596 subtree of a project.  Hyperlinks (see [[*Hyperlinks]]) can establish
7597 associations with files that live elsewhere on your computer or in the
7598 cloud, like emails or source code files belonging to a project.
7599 Another method is /attachments/, which are files located in
7600 a directory belonging to an outline node.  Org uses directories named
7601 by the unique ID of each entry.  These directories are located in the
7602 ~data~ directory which lives in the same directory where your Org file
7603 lives[fn:86].  If you initialize this directory with =git init=, Org
7604 automatically commits changes when it sees them.  The attachment
7605 system has been contributed to Org by John Wiegley.
7607 In cases where it seems better to do so, you can attach a directory of
7608 your choice to an entry.  You can also make children inherit the
7609 attachment directory from a parent, so that an entire subtree uses the
7610 same attached directory.
7612 #+texinfo: @noindent
7613 The following commands deal with attachments:
7615 - {{{kbd(C-c C-a)}}} (~org-attach~) ::
7617      #+kindex: C-c C-a
7618      #+findex: org-attach
7619      The dispatcher for commands related to the attachment system.
7620      After these keys, a list of commands is displayed and you must
7621      press an additional key to select a command:
7623      - {{{kbd(a)}}} (~org-attach-attach~) ::
7625           #+kindex: C-c C-a a
7626           #+findex: org-attach-attach
7627           #+vindex: org-attach-method
7628           Select a file and move it into the task's attachment
7629           directory.  The file is copied, moved, or linked, depending
7630           on ~org-attach-method~.  Note that hard links are not
7631           supported on all systems.
7633      - {{{kbd(c)}}}/{{{kbd(m)}}}/{{{kbd(l)}}} ::
7635           #+kindex: C-c C-a c
7636           #+kindex: C-c C-a m
7637           #+kindex: C-c C-a l
7638           Attach a file using the copy/move/link method.  Note that
7639           hard links are not supported on all systems.
7641      - {{{kbd(n)}}} (~org-attach-new~) ::
7643           #+kindex: C-c C-a n
7644           #+findex: org-attach-new
7645           Create a new attachment as an Emacs buffer.
7647      - {{{kbd(z)}}} (~org-attach-sync~) ::
7649           #+kindex: C-c C-a z
7650           #+findex: org-attach-sync
7651           Synchronize the current task with its attachment directory, in case
7652           you added attachments yourself.
7654      - {{{kbd(o)}}} (~org-attach-open~) ::
7656           #+kindex: C-c C-a o
7657           #+findex: org-attach-open
7658           #+vindex: org-file-apps
7659           Open current task's attachment.  If there is more than one,
7660           prompt for a file name first.  Opening follows the rules set
7661           by ~org-file-apps~.  For more details, see the information
7662           on following hyperlinks (see [[*Handling Links]]).
7664      - {{{kbd(O)}}} (~org-attach-open-in-emacs~) ::
7666           #+kindex: C-c C-a O
7667           #+findex: org-attach-open-in-emacs
7668           Also open the attachment, but force opening the file in
7669           Emacs.
7671      - {{{kbd(f)}}} (~org-attach-reveal~) ::
7673           #+kindex: C-c C-a f
7674           #+findex: org-attach-reveal
7675           Open the current task's attachment directory.
7677      - {{{kbd(F)}}} (~org-attach-reveal-in-emacs~) ::
7679           #+kindex: C-c C-a F
7680           #+findex: org-attach-reveal-in-emacs
7681           Also open the directory, but force using Dired in Emacs.
7683      - {{{kbd(d)}}} (~org-attach-delete-one~) ::
7685           #+kindex: C-c C-a d
7686           Select and delete a single attachment.
7688      - {{{kbd(D)}}} (~org-attach-delete-all~) ::
7690           #+kindex: C-c C-a D
7691           Delete all of a task's attachments.  A safer way is to open
7692           the directory in Dired and delete from there.
7694      - {{{kbd(s)}}} (~org-attach-set-directory~) ::
7696           #+kindex: C-c C-a s
7697           #+cindex: ATTACH_DIR, property
7698           Set a specific directory as the entry's attachment
7699           directory.  This works by putting the directory path into
7700           the =ATTACH_DIR= property.
7702      - {{{kbd(i)}}} (~org-attach-set-inherit~) ::
7704           #+kindex: C-c C-a i
7705           #+cindex: ATTACH_DIR_INHERIT, property
7706           Set the =ATTACH_DIR_INHERIT= property, so that children use
7707           the same directory for attachments as the parent does.
7709 #+cindex: attach from Dired
7710 #+findex: org-attach-dired-to-subtree
7711 It is possible to attach files to a subtree from a Dired buffer.  To
7712 use this feature, have one window in Dired mode containing the file(s)
7713 to be attached and another window with point in the subtree that shall
7714 get the attachments.  In the Dired window, with point on a file,
7715 {{{kbd(M-x org-attach-dired-to-subtree)}}} attaches the file to the
7716 subtree using the attachment method set by variable
7717 ~org-attach-method~.  When files are marked in the Dired window then
7718 all marked files get attached.
7720 Add the following lines to the Emacs init file to have {{{kbd(C-c C-x
7721 a)}}} attach files in Dired buffers.
7723 #+begin_src emacs-lisp
7724   (add-hook 'dired-mode-hook
7725             (lambda ()
7726               (define-key dired-mode-map
7727                 (kbd "C-c C-x a")
7728                 #'org-attach-dired-to-subtree))))
7729 #+end_src
7731 The following code shows how to bind the previous command with
7732 a specific attachment method.
7734 #+begin_src emacs-lisp
7735   (add-hook 'dired-mode-hook
7736             (lambda ()
7737               (define-key dired-mode-map (kbd "C-c C-x c")
7738                 (lambda ()
7739                   (interactive)
7740                   (let ((org-attach-method 'cp))
7741                     (call-interactively #'org-attach-dired-to-subtree))))))
7742 #+end_src
7744 ** RSS Feeds
7745 :PROPERTIES:
7746 :DESCRIPTION: Getting input from RSS feeds.
7747 :END:
7748 #+cindex: RSS feeds
7749 #+cindex: Atom feeds
7751 Org can add and change entries based on information found in RSS feeds
7752 and Atom feeds.  You could use this to make a task out of each new
7753 podcast in a podcast feed.  Or you could use a phone-based
7754 note-creating service on the web to import tasks into Org.  To access
7755 feeds, configure the variable ~org-feed-alist~.  The docstring of this
7756 variable has detailed information.  With the following
7758 #+begin_src emacs-lisp
7759   (setq org-feed-alist
7760         '(("Slashdot"
7761            "http://rss.slashdot.org/Slashdot/slashdot"
7762            "~/txt/org/feeds.org" "Slashdot Entries")))
7763 #+end_src
7765 #+texinfo: @noindent
7766 new items from the feed provided by =rss.slashdot.org= result in new
7767 entries in the file =~/org/feeds.org= under the heading =Slashdot
7768 Entries=, whenever the following command is used:
7770 - {{{kbd(C-c C-x g)}}} (~org-feed-update-all~) ::
7772      #+kindex: C-c C-x g
7773      Collect items from the feeds configured in ~org-feed-alist~ and
7774      act upon them.
7776 - {{{kbd(C-c C-x G)}}} (~org-feed-goto-inbox~) ::
7778      #+kindex: C-c C-x G
7779      Prompt for a feed name and go to the inbox configured for this feed.
7781 Under the same headline, Org creates a drawer =FEEDSTATUS= in which it
7782 stores information about the status of items in the feed, to avoid
7783 adding the same item several times.
7785 For more information, including how to read atom feeds, see
7786 =org-feed.el= and the docstring of ~org-feed-alist~.
7788 ** Protocols for External Access
7789 :PROPERTIES:
7790 :DESCRIPTION: External access to Emacs and Org.
7791 :ALT_TITLE: Protocols
7792 :END:
7793 #+cindex: protocols, for external access
7795 Org protocol is a means to trigger custom actions in Emacs from
7796 external applications.  Any application that supports calling external
7797 programs with an URL as argument may be used with this functionality.
7798 For example, you can configure bookmarks in your web browser to send
7799 a link to the current page to Org and create a note from it using
7800 capture (see [[*Capture]]).  You can also create a bookmark that tells
7801 Emacs to open the local source file of a remote website you are
7802 browsing.
7804 #+cindex: Org protocol, set-up
7805 #+cindex: Installing Org protocol
7806 In order to use Org protocol from an application, you need to register
7807 =org-protocol://= as a valid scheme-handler.  External calls are
7808 passed to Emacs through the =emacsclient= command, so you also need to
7809 ensure an Emacs server is running.  More precisely, when the
7810 application calls
7812 : emacsclient org-protocol://PROTOCOL?key1=val1&key2=val2
7814 #+texinfo: @noindent
7815 Emacs calls the handler associated to {{{var(PROTOCOL)}}} with
7816 argument =(:key1 val1 :key2 val2)=.
7818 #+cindex: protocol, new protocol
7819 #+cindex: defining new protocols
7820 Org protocol comes with three predefined protocols, detailed in the
7821 following sections.  Configure ~org-protocol-protocol-alist~ to define
7822 your own.
7824 *** ~store-link~ protocol
7825 :PROPERTIES:
7826 :DESCRIPTION: Store a link, push URL to kill-ring.
7827 :END:
7828 #+cindex: store-link protocol
7829 #+cindex: protocol, store-link
7831 Using ~store-link~ handler, you can copy links, insertable through
7832 {{{kbd(M-x org-insert-link)}}} or yanking thereafter.  More precisely,
7833 the command
7835 : emacsclient org-protocol://store-link?url=URL&title=TITLE
7837 #+texinfo: @noindent
7838 stores the following link:
7840 : [[URL][TITLE]]
7842 In addition, {{{var(URL)}}} is pushed on the kill-ring for yanking.
7843 You need to encode {{{var(URL)}}} and {{{var(TITLE)}}} if they contain
7844 slashes, and probably quote those for the shell.
7846 To use this feature from a browser, add a bookmark with an arbitrary
7847 name, e.g., =Org: store-link= and enter this as /Location/:
7849 #+begin_example
7850 javascript:location.href='org-protocol://store-link?url='+
7851       encodeURIComponent(location.href);
7852 #+end_example
7854 *** ~capture~ protocol
7855 :PROPERTIES:
7856 :DESCRIPTION: Fill a buffer with external information.
7857 :END:
7858 #+cindex: capture protocol
7859 #+cindex: protocol, capture
7861 Activating "capture" handler pops up a =Capture= buffer and fills the
7862 capture template associated to the =X= key with them.
7864 : emacsclient org-protocol://capture?template=X?url=URL?title=TITLE?body=BODY
7866 To use this feature, add a bookmark with an arbitrary name, e.g.
7867 =Org: capture= and enter this as =Location=:
7869 #+begin_example
7870   javascript:location.href='org-protocol://template=x'+
7871         '&url='+encodeURIComponent(window.location.href)+
7872         '&title='+encodeURIComponent(document.title)+
7873         '&body='+encodeURIComponent(window.getSelection());
7874 #+end_example
7876 #+vindex: org-protocol-default-template-key
7877 The result depends on the capture template used, which is set in the
7878 bookmark itself, as in the example above, or in
7879 ~org-protocol-default-template-key~.
7881 The following template placeholders are available:
7883 #+begin_example
7884   %:link          The URL
7885   %:description   The webpage title
7886   %:annotation    Equivalent to [[%:link][%:description]]
7887   %i              The selected text
7888 #+end_example
7890 *** ~open-source~ protocol
7891 :PROPERTIES:
7892 :DESCRIPTION: Edit published contents.
7893 :END:
7894 #+cindex: open-source protocol
7895 #+cindex: protocol, open-source
7897 The ~open-source~ handler is designed to help with editing local
7898 sources when reading a document.  To that effect, you can use
7899 a bookmark with the following location:
7901 #+begin_example
7902   javascript:location.href='org-protocol://open-source?&url='+
7903         encodeURIComponent(location.href)
7904 #+end_example
7906 #+vindex: org-protocol-project-alist
7907 The variable ~org-protocol-project-alist~ maps URLs to local file
7908 names, by stripping URL parameters from the end and replacing the
7909 ~:base-url~ with ~:working-directory~ and ~:online-suffix~ with
7910 ~:working-suffix~.  For example, assuming you own a local copy of
7911 =https://orgmode.org/worg/= contents at =/home/user/worg=, you can set
7912 ~org-protocol-project-alist~ to the following
7914 #+begin_src emacs-lisp
7915   (setq org-protocol-project-alist
7916         '(("Worg"
7917            :base-url "https://orgmode.org/worg/"
7918            :working-directory "/home/user/worg/"
7919            :online-suffix ".html"
7920            :working-suffix ".org")))
7921 #+end_src
7923 #+texinfo: @noindent
7924 If you are now browsing
7925 =https://orgmode.org/worg/org-contrib/org-protocol.html= and find
7926 a typo or have an idea about how to enhance the documentation, simply
7927 click the bookmark and start editing.
7929 #+cindex: rewritten URL in open-source protocol
7930 #+cindex: protocol, open-source rewritten URL
7931 However, such mapping may not yield the desired results.  Suppose you
7932 maintain an online store located at =http://example.com/=.  The local
7933 sources reside in =/home/user/example/=.  It is common practice to
7934 serve all products in such a store through one file and rewrite URLs
7935 that do not match an existing file on the server.  That way, a request
7936 to =http://example.com/print/posters.html= might be rewritten on the
7937 server to something like
7938 =http://example.com/shop/products.php/posters.html.php=.  The
7939 ~open-source~ handler probably cannot find a file named
7940 =/home/user/example/print/posters.html.php= and fails.
7942 Such an entry in ~org-protocol-project-alist~ may hold an additional
7943 property ~:rewrites~.  This property is a list of cons cells, each of
7944 which maps a regular expression to a path relative to the
7945 ~:working-directory~.
7947 Now map the URL to the path =/home/user/example/products.php= by
7948 adding ~:rewrites~ rules like this:
7950 #+begin_src emacs-lisp
7951   (setq org-protocol-project-alist
7952         '(("example.com"
7953            :base-url "http://example.com/"
7954            :working-directory "/home/user/example/"
7955            :online-suffix ".php"
7956            :working-suffix ".php"
7957            :rewrites (("example.com/print/" . "products.php")
7958                       ("example.com/$" . "index.php")))))
7959 #+end_src
7961 #+texinfo: @noindent
7962 Since =example.com/$= is used as a regular expression, it maps
7963 =http://example.com/=, =https://example.com=,
7964 =http://www.example.com/= and similar to
7965 =/home/user/example/index.php=.
7967 The ~:rewrites~ rules are searched as a last resort if and only if no
7968 existing file name is matched.
7970 #+cindex: protocol, open-source, set-up mapping
7971 #+cindex: mappings in open-source protocol
7972 #+findex: org-protocol-create
7973 #+findex: org-protocol-create-for-org
7974 Two functions can help you filling ~org-protocol-project-alist~ with
7975 valid contents: ~org-protocol-create~ and
7976 ~org-protocol-create-for-org~.  The latter is of use if you're editing
7977 an Org file that is part of a publishing project.
7979 ** Refile and Copy
7980 :PROPERTIES:
7981 :DESCRIPTION: Moving/copying a tree from one place to another.
7982 :END:
7983 #+cindex: refiling notes
7984 #+cindex: copying notes
7986 When reviewing the captured data, you may want to refile or to copy
7987 some of the entries into a different list, for example into a project.
7988 Cutting, finding the right location, and then pasting the note is
7989 cumbersome.  To simplify this process, you can use the following
7990 special command:
7992 - {{{kbd(C-c M-w)}}} (~org-copy~) ::
7994      #+kindex: C-c M-w
7995      #+findex: org-copy
7996      Copying works like refiling, except that the original note is not
7997      deleted.
7999 - {{{kbd(C-c C-w)}}} (~org-refile~) ::
8001      #+kindex: C-c C-w
8002      #+findex: org-refile
8003      #+vindex: org-reverse-note-order
8004      #+vindex: org-refile-targets
8005      #+vindex: org-refile-use-outline-path
8006      #+vindex: org-outline-path-complete-in-steps
8007      #+vindex: org-refile-allow-creating-parent-nodes
8008      #+vindex: org-log-refile
8009      Refile the entry or region at point.  This command offers
8010      possible locations for refiling the entry and lets you select one
8011      with completion.  The item (or all items in the region) is filed
8012      below the target heading as a subitem.  Depending on
8013      ~org-reverse-note-order~, it is either the first or last subitem.
8015      By default, all level 1 headlines in the current buffer are
8016      considered to be targets, but you can have more complex
8017      definitions across a number of files.  See the variable
8018      ~org-refile-targets~ for details.  If you would like to select
8019      a location via a file-path-like completion along the outline
8020      path, see the variables ~org-refile-use-outline-path~ and
8021      ~org-outline-path-complete-in-steps~.  If you would like to be
8022      able to create new nodes as new parents for refiling on the fly,
8023      check the variable ~org-refile-allow-creating-parent-nodes~.
8024      When the variable ~org-log-refile~[fn:87] is set, a timestamp or
8025      a note is recorded whenever an entry is refiled.
8027 - {{{kbd(C-u C-c C-w)}}} ::
8029      #+kindex: C-u C-c C-w
8030      Use the refile interface to jump to a heading.
8032 - {{{kbd(C-u C-u C-c C-w)}}} (~org-refile-goto-last-stored~) ::
8034      #+kindex: C-u C-u C-c C-w
8035      #+findex: org-refile-goto-last-stored
8036      Jump to the location where ~org-refile~ last moved a tree to.
8038 - {{{kbd(C-2 C-c C-w)}}} ::
8040      #+kindex: C-2 C-c C-w
8041      Refile as the child of the item currently being clocked.
8043 - {{{kbd(C-3 C-c C-w)}}} ::
8045      #+kindex: C-3 C-c C-w
8046      #+vindex: org-refile-keep
8047      Refile and keep the entry in place.  Also see ~org-refile-keep~
8048      to make this the default behavior, and beware that this may
8049      result in duplicated ~ID~ properties.
8051 - {{{kbd(C-0 C-c C-w)}}} or {{{kbd(C-u C-u C-u C-c C-w)}}} (~org-refile-cache-clear~) ::
8053      #+kindex: C-u C-u C-u C-c C-w
8054      #+kindex: C-0 C-c C-w
8055      #+findex: org-refile-cache-clear
8056      #+vindex: org-refile-use-cache
8057      Clear the target cache.  Caching of refile targets can be turned
8058      on by setting ~org-refile-use-cache~.  To make the command see
8059      new possible targets, you have to clear the cache with this
8060      command.
8062 ** Archiving
8063 :PROPERTIES:
8064 :DESCRIPTION: What to do with finished products.
8065 :END:
8066 #+cindex: archiving
8068 When a project represented by a (sub)tree is finished, you may want to
8069 move the tree out of the way and to stop it from contributing to the
8070 agenda.  Archiving is important to keep your working files compact and
8071 global searches like the construction of agenda views fast.
8073 - {{{kbd(C-c C-x C-a)}}} (~org-archive-subtree-default~) ::
8075      #+kindex: C-c C-x C-a
8076      #+findex: org-archive-subtree-default
8077      #+vindex: org-archive-default-command
8078      Archive the current entry using the command specified in the
8079      variable ~org-archive-default-command~.
8081 *** Moving a tree to an archive file
8082 :PROPERTIES:
8083 :DESCRIPTION: Moving a tree to an archive file.
8084 :ALT_TITLE: Moving subtrees
8085 :END:
8086 #+cindex: external archiving
8088 The most common archiving action is to move a project tree to another
8089 file, the archive file.
8091 - {{{kbd(C-c C-x C-s)}}} or short {{{kbd(C-c $)}}} (~org-archive-subtree~) ::
8093      #+kindex: C-c C-x C-s
8094      #+kindex: C-c $
8095      #+findex: org-archive-subtree
8096      #+vindex: org-archive-location
8097      Archive the subtree starting at the cursor position to the
8098      location given by ~org-archive-location~.
8100 - {{{kbd(C-u C-c C-x C-s)}}} ::
8102      #+kindex: C-u C-c C-x C-s
8103      Check if any direct children of the current headline could be
8104      moved to the archive.  To do this, check each subtree for open
8105      TODO entries.  If none is found, the command offers to move it to
8106      the archive location.  If the cursor is /not/ on a headline when
8107      this command is invoked, check level 1 trees.
8109 - {{{kbd(C-u C-u C-c C-x C-s)}}} ::
8111      #+kindex: C-u C-u C-c C-x C-s
8112      As above, but check subtree for timestamps instead of TODO
8113      entries.  The command offers to archive the subtree if it /does/
8114      contain a timestamp, and that timestamp is in the past.
8116 #+cindex: archive locations
8117 The default archive location is a file in the same directory as the
8118 current file, with the name derived by appending =_archive= to the
8119 current file name.  You can also choose what heading to file archived
8120 items under, with the possibility to add them to a datetree in a file.
8121 For information and examples on how to specify the file and the
8122 heading, see the documentation string of the variable
8123 ~org-archive-location~.
8125 There is also an in-buffer option for setting this variable, for
8126 example:
8128 #+cindex: ARCHIVE, keyword
8129 : #+ARCHIVE: %s_done::
8131 #+texinfo: @noindent
8132 #+cindex: ARCHIVE, property
8133 If you would like to have a special archive location for a single
8134 entry or a (sub)tree, give the entry an =ARCHIVE= property with the
8135 location as the value (see [[*Properties and Columns]]).
8137 #+vindex: org-archive-save-context-info
8138 When a subtree is moved, it receives a number of special properties
8139 that record context information like the file from where the entry
8140 came, its outline path the archiving time etc.  Configure the variable
8141 ~org-archive-save-context-info~ to adjust the amount of information
8142 added.
8144 *** Internal archiving
8145 :PROPERTIES:
8146 :DESCRIPTION: Switch off a tree but keep it in the file.
8147 :END:
8149 If you want to just switch off---for agenda views---certain subtrees
8150 without moving them to a different file, you can use the =ARCHIVE=
8151 tag.
8153 A headline that is marked with the =ARCHIVE= tag (see [[*Tags]]) stays at
8154 its location in the outline tree, but behaves in the following way:
8157   #+vindex: org-cycle-open-archived-trees
8158   It does not open when you attempt to do so with a visibility cycling
8159   command (see [[*Visibility Cycling]]).  You can force cycling archived
8160   subtrees with {{{kbd(C-TAB)}}}, or by setting the option
8161   ~org-cycle-open-archived-trees~.  Also normal outline commands, like
8162   ~outline-show-all~, open archived subtrees.
8165   #+vindex: org-sparse-tree-open-archived-trees
8166   During sparse tree construction (see [[*Sparse Trees]]), matches in
8167   archived subtrees are not exposed, unless you configure the option
8168   ~org-sparse-tree-open-archived-trees~.
8171   #+vindex: org-agenda-skip-archived-trees
8172   During agenda view construction (see [[*Agenda Views]]), the content of
8173   archived trees is ignored unless you configure the option
8174   ~org-agenda-skip-archived-trees~, in which case these trees are
8175   always included.  In the agenda you can press {{{kbd(v a)}}} to get
8176   archives temporarily included.
8179   #+vindex: org-export-with-archived-trees
8180   Archived trees are not exported (see [[*Exporting]]), only the headline
8181   is.  Configure the details using the variable
8182   ~org-export-with-archived-trees~.
8185   #+vindex: org-columns-skip-archived-trees
8186   Archived trees are excluded from column view unless the variable
8187   ~org-columns-skip-archived-trees~ is configured to ~nil~.
8189 The following commands help manage the =ARCHIVE= tag:
8191 - {{{kbd(C-c C-x a)}}} (~org-toggle-archive-tag~) ::
8193      #+kindex: C-c C-x a
8194      #+findex: org-toggle-archive-tag
8195      Toggle the archive tag for the current headline.  When the tag is
8196      set, the headline changes to a shadowed face, and the subtree
8197      below it is hidden.
8199 - {{{kbd(C-u C-c C-x a)}}} ::
8201      #+kindex: C-u C-c C-x a
8202      Check if any direct children of the current headline should be
8203      archived.  To do this, check each subtree for open TODO entries.
8204      If none is found, the command offers to set the =ARCHIVE= tag for
8205      the child.  If the cursor is /not/ on a headline when this
8206      command is invoked, check the level 1 trees.
8208 - {{{kbd(C-TAB)}}}, ~org-force-cycle-archived~ ::
8210      #+kindex: C-TAB
8211      Cycle a tree even if it is tagged with =ARCHIVE=.
8213 - {{{kbd(C-c C-x A)}}} (~org-archive-to-archive-sibling~) ::
8215      #+kindex: C-c C-x A
8216      #+findex: org-archive-to-archive-sibling
8217      Move the current entry to the /Archive Sibling/.  This is
8218      a sibling of the entry with the heading =Archive= and the archive
8219      tag.  The entry becomes a child of that sibling and in this way
8220      retains a lot of its original context, including inherited tags
8221      and approximate position in the outline.
8223 * Agenda Views
8224 :PROPERTIES:
8225 :DESCRIPTION: Collecting information into views.
8226 :END:
8227 #+cindex: agenda views
8229 Due to the way Org works, TODO items, time-stamped items, and tagged
8230 headlines can be scattered throughout a file or even a number of
8231 files.  To get an overview of open action items, or of events that are
8232 important for a particular date, this information must be collected,
8233 sorted and displayed in an organized way.
8235 Org can select items based on various criteria and display them in
8236 a separate buffer.  Seven different view types are provided:
8238 - an /agenda/ that is like a calendar and shows information for
8239   specific dates,
8241 - a /TODO list/ that covers all unfinished action items,
8243 - a /match view/, showings headlines based on the tags, properties,
8244   and TODO state associated with them,
8246 - a /timeline view/ that shows all events in a single Org file, in
8247   time-sorted view,
8249 - a /text search view/ that shows all entries from multiple files that
8250   contain specified keywords,
8252 - a /stuck projects view/ showing projects that currently do not move
8253   along, and
8255 - /custom views/ that are special searches and combinations of
8256   different views.
8258 #+texinfo: @noindent
8259 The extracted information is displayed in a special /agenda buffer/.
8260 This buffer is read-only, but provides commands to visit the
8261 corresponding locations in the original Org files, and even to edit
8262 these files remotely.
8264 #+vindex: org-agenda-skip-comment-trees
8265 #+vindex: org-agenda-skip-archived-trees
8266 #+cindex: commented entries, in agenda views
8267 #+cindex: archived entries, in agenda views
8268 By default, the report ignores commented (see [[*Comment Lines]]) and
8269 archived (see [[*Internal archiving]]) entries.  You can override this by
8270 setting ~org-agenda-skip-comment-trees~ and
8271 ~org-agenda-skip-archived-trees~ to ~nil~.
8273 #+vindex: org-agenda-window-setup
8274 #+vindex: org-agenda-restore-windows-after-quit
8275 Two variables control how the agenda buffer is displayed and whether
8276 the window configuration is restored when the agenda exits:
8277 ~org-agenda-window-setup~ and ~org-agenda-restore-windows-after-quit~.
8279 ** Agenda Files
8280 :PROPERTIES:
8281 :DESCRIPTION: Files being searched for agenda information.
8282 :END:
8283 #+cindex: agenda files
8284 #+cindex: files for agenda
8286 #+vindex: org-agenda-files
8287 The information to be shown is normally collected from all /agenda
8288 files/, the files listed in the variable ~org-agenda-files~[fn:88].
8289 If a directory is part of this list, all files with the extension
8290 =.org= in this directory are part of the list.
8292 Thus, even if you only work with a single Org file, that file should
8293 be put into the list[fn:89].  You can customize ~org-agenda-files~,
8294 but the easiest way to maintain it is through the following commands
8296 #+attr_texinfo: :sep and
8297 - {{{kbd(C-c [)}}} (~org-agenda-file-to-front~) ::
8299      #+kindex: C-c [
8300      #+findex: org-agenda-file-to-front
8301      #+cindex: files, adding to agenda list
8302      Add current file to the list of agenda files.  The file is added
8303      to the front of the list.  If it was already in the list, it is
8304      moved to the front.  With a prefix argument, file is added/moved
8305      to the end.
8307 - {{{kbd(C-c ])}}} (~org-remove-file~) ::
8309      #+kindex: C-c ]
8310      #+findex: org-remove-file
8311      Remove current file from the list of agenda files.
8313 - {{{kbd(C-')}}} and {{{kbd(C-\,)}}} (~org-cycle-agenda-files~) ::
8315      #+kindex: C-'
8316      #+kindex: C-,
8317      #+findex: org-cycle-agenda-files
8318      #+cindex: cycling, of agenda files
8319      Cycle through agenda file list, visiting one file after the other.
8321 - {{{kbd(M-x org-iswitchb)}}} ::
8323      #+findex: org-iswitchb
8324      Command to use an ~iswitchb~-like interface to switch to and
8325      between Org buffers.
8327 #+texinfo: @noindent
8328 The Org menu contains the current list of files and can be used to
8329 visit any of them.
8331 If you would like to focus the agenda temporarily on a file not in
8332 this list, or on just one file in the list, or even on only a subtree
8333 in a file, then this can be done in different ways.  For a single
8334 agenda command, you may press {{{kbd(<)}}} once or several times in
8335 the dispatcher (see [[*The Agenda Dispatcher]]).  To restrict the agenda
8336 scope for an extended period, use the following commands:
8338 - {{{kbd(C-c C-x <)}}} (~org-agenda-set-restriction-lock~) ::
8340      #+kindex: C-c C-x <
8341      #+findex: org-agenda-set-restriction-lock
8342      Permanently restrict the agenda to the current subtree.  When
8343      called with a prefix argument, or with the cursor before the
8344      first headline in a file, set the agenda scope to the entire
8345      file.  This restriction remains in effect until removed with
8346      {{{kbd(C-c C-x >)}}}, or by typing either {{{kbd(<)}}} or
8347      {{{kbd(>)}}} in the agenda dispatcher.  If there is a window
8348      displaying an agenda view, the new restriction takes effect
8349      immediately.
8351 - {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
8353      #+kindex: C-c C-x >
8354      #+findex: org-agenda-remove-restriction-lock
8355      Remove the permanent restriction created by {{{kbd(C-c C-x <)}}}.
8357 #+texinfo: @noindent
8358 When working with =speedbar.el=, you can use the following commands in
8359 the Speedbar frame:
8361 - {{{kbd(<)}}} (~org-speedbar-set-agenda-restriction~) ::
8363      #+findex: org-speedbar-set-agenda-restriction
8364      Permanently restrict the agenda to the item---either an Org file
8365      or a subtree in such a file---at the cursor in the Speedbar
8366      frame.  If there is a window displaying an agenda view, the new
8367      restriction takes effect immediately.
8369 - {{{kbd(>)}}} (~org-agenda-remove-restriction-lock~) ::
8371      #+findex: org-agenda-remove-restriction-lock
8372      Lift the restriction.
8374 ** The Agenda Dispatcher
8375 :PROPERTIES:
8376 :DESCRIPTION: Keyboard access to agenda views.
8377 :ALT_TITLE: Agenda Dispatcher
8378 :END:
8379 #+cindex: agenda dispatcher
8380 #+cindex: dispatching agenda commands
8382 The views are created through a dispatcher, which should be bound to
8383 a global key---for example {{{kbd(C-c a)}}} (see [[*Activation]]).  In
8384 the following we will assume that {{{kbd(C-c a)}}} is indeed how the
8385 dispatcher is accessed and list keyboard access to commands
8386 accordingly.  After pressing {{{kbd(C-c a)}}}, an additional letter is
8387 required to execute a command.  The dispatcher offers the following
8388 default commands:
8390 - {{{kbd(a)}}} ::
8392      #+kindex: C-c a a
8393      Create the calendar-like agenda (see [[*Weekly/daily agenda]]).
8395 - {{{kbd(t)}}} or {{{kbd(T)}}} ::
8397      #+kindex: C-c a t
8398      #+kindex: C-c a T
8399      Create a list of all TODO items (see [[*The global TODO list]]).
8401 - {{{kbd(m)}}} or {{{kbd(M)}}} ::
8403      #+kindex: C-c a m
8404      #+kindex: C-c a M
8405      Create a list of headlines matching a given expression (see
8406      [[*Matching tags and properties]]).
8408 - {{{kbd(s)}}} ::
8410      #+kindex: C-c a s
8411      Create a list of entries selected by a boolean expression of
8412      keywords and/or regular expressions that must or must not occur
8413      in the entry.
8415 - {{{kbd(/)}}} ::
8417      #+kindex: C-c a /
8418      #+vindex: org-agenda-text-search-extra-files
8419      Search for a regular expression in all agenda files and
8420      additionally in the files listed in
8421      ~org-agenda-text-search-extra-files~.  This uses the Emacs
8422      command ~multi-occur~.  A prefix argument can be used to specify
8423      the number of context lines for each match, default is
8424      1.
8426 - {{{kbd(#)}}} or {{{kbd(!)}}} ::
8428      #+kindex: C-c a #
8429      #+kindex: C-c a !
8430      Create a list of stuck projects (see [[*Stuck projects]]).
8432 - {{{kbd(<)}}} ::
8434      #+kindex: C-c a <
8435      Restrict an agenda command to the current buffer[fn:90].  After
8436      pressing {{{kbd(<)}}}, you still need to press the character
8437      selecting the command.
8439 - {{{kbd(< <)}}} ::
8441      #+kindex: C-c a < <
8442      If there is an active region, restrict the following agenda
8443      command to the region.  Otherwise, restrict it to the current
8444      subtree[fn:91].  After pressing {{{kbd(< <)}}}, you still need to
8445      press the character selecting the command.
8447 - {{{kbd(*)}}} ::
8449      #+kindex: C-c a *
8450      #+vindex: org-agenda-sticky
8451      #+findex: org-toggle-sticky-agenda
8452      Toggle sticky agenda views.  By default, Org maintains only
8453      a single agenda buffer and rebuilds it each time you change the
8454      view, to make sure everything is always up to date.  If you
8455      switch between views often and the build time bothers you, you
8456      can turn on sticky agenda buffers (make this the default by
8457      customizing the variable ~org-agenda-sticky~).  With sticky
8458      agendas, the dispatcher only switches to the selected view, you
8459      need to update it by hand with {{{kbd(r)}}} or {{{kbd(g)}}}.  You
8460      can toggle sticky agenda view any time with
8461      ~org-toggle-sticky-agenda~.
8463 You can also define custom commands that are accessible through the
8464 dispatcher, just like the default commands.  This includes the
8465 possibility to create extended agenda buffers that contain several
8466 blocks together, for example the weekly agenda, the global TODO list
8467 and a number of special tags matches.  See [[*Custom Agenda Views]].
8469 ** The Built-in Agenda Views
8470 :PROPERTIES:
8471 :DESCRIPTION: What is available out of the box?
8472 :ALT_TITLE: Built-in Agenda Views
8473 :END:
8475 In this section we describe the built-in views.
8477 *** Weekly/daily agenda
8478 :PROPERTIES:
8479 :DESCRIPTION: The calendar page with current tasks.
8480 :END:
8481 #+cindex: agenda
8482 #+cindex: weekly agenda
8483 #+cindex: daily agenda
8485 The purpose of the weekly/daily /agenda/ is to act like a page of
8486 a paper agenda, showing all the tasks for the current week or day.
8488 - {{{kbd(C-c a a)}}} (~org-agenda-list~) ::
8490      #+kindex: C-c a a
8491      #+findex: org-agenda-list
8492      #+cindex: org-agenda, command
8493      Compile an agenda for the current week from a list of Org files.
8494      The agenda shows the entries for each day.  With a numeric
8495      prefix[fn:92] (like {{{kbd(C-u 2 1 C-c a a)}}}) you may set the
8496      number of days to be displayed.
8498 #+vindex: org-agenda-span
8499 #+vindex: org-agenda-start-day
8500 #+vindex: org-agenda-start-on-weekday
8501 The default number of days displayed in the agenda is set by the
8502 variable ~org-agenda-span~.  This variable can be set to any number of
8503 days you want to see by default in the agenda, or to a span name, such
8504 a ~day~, ~week~, ~month~ or ~year~.  For weekly agendas, the default
8505 is to start on the previous Monday (see
8506 ~org-agenda-start-on-weekday~).  You can also set the start date using
8507 a date shift: ~(setq org-agenda-start-day "+10d")~ starts the agenda
8508 ten days from today in the future.
8510 Remote editing from the agenda buffer means, for example, that you can
8511 change the dates of deadlines and appointments from the agenda buffer.
8512 The commands available in the Agenda buffer are listed in [[*Commands in
8513 the Agenda Buffer]].
8515 **** Calendar/Diary integration
8516 :PROPERTIES:
8517 :UNNUMBERED: notoc
8518 :END:
8519 #+cindex: calendar integration
8520 #+cindex: diary integration
8522 Emacs contains the calendar and diary by Edward M. Reingold.  The
8523 calendar displays a three-month calendar with holidays from different
8524 countries and cultures.  The diary allows you to keep track of
8525 anniversaries, lunar phases, sunrise/set, recurrent appointments
8526 (weekly, monthly) and more.  In this way, it is quite complementary to
8527 Org.  It can be very useful to combine output from Org with the diary.
8529 In order to include entries from the Emacs diary into Org mode's
8530 agenda, you only need to customize the variable
8532 #+begin_src emacs-lisp
8533   (setq org-agenda-include-diary t)
8534 #+end_src
8536 #+texinfo: @noindent
8537 After that, everything happens automatically.  All diary entries
8538 including holidays, anniversaries, etc., are included in the agenda
8539 buffer created by Org mode.  {{{kbd(SPC)}}}, {{{kbd(TAB)}}}, and
8540 {{{kbd(RET)}}} can be used from the agenda buffer to jump to the diary
8541 file in order to edit existing diary entries.  The {{{kbd(i)}}}
8542 command to insert new entries for the current date works in the agenda
8543 buffer, as well as the commands {{{kbd(S)}}}, {{{kbd(M)}}}, and
8544 {{{kbd(C)}}} to display Sunrise/Sunset times, show lunar phases and to
8545 convert to other calendars, respectively.  {{{kbd(c)}}} can be used to
8546 switch back and forth between calendar and agenda.
8548 If you are using the diary only for S-exp entries and holidays, it is
8549 faster to not use the above setting, but instead to copy or even move
8550 the entries into an Org file.  Org mode evaluates diary-style sexp
8551 entries, and does it faster because there is no overhead for first
8552 creating the diary display.  Note that the sexp entries must start at
8553 the left margin, no whitespace is allowed before them, as seen in the
8554 following segment of an Org file:[fn:93]
8556 #+begin_example
8557   ,* Holidays
8558     :PROPERTIES:
8559     :CATEGORY: Holiday
8560     :END:
8561   %%(org-calendar-holiday)   ; special function for holiday names
8563   ,* Birthdays
8564     :PROPERTIES:
8565     :CATEGORY: Ann
8566     :END:
8567   %%(org-anniversary 1956  5 14) Arthur Dent is %d years old
8568   %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
8569 #+end_example
8571 **** Anniversaries from BBDB
8572 :PROPERTIES:
8573 :UNNUMBERED: notoc
8574 :END:
8575 #+cindex: BBDB, anniversaries
8576 #+cindex: anniversaries, from BBDB
8578 #+findex: org-bbdb-anniversaries
8579 If you are using the Insidious Big Brother Database to store your
8580 contacts, you very likely prefer to store anniversaries in BBDB rather
8581 than in a separate Org or diary file.  Org supports this and can show
8582 BBDB anniversaries as part of the agenda.  All you need to do is to
8583 add the following to one of your agenda files:
8585 #+begin_example
8586   ,* Anniversaries
8587     :PROPERTIES:
8588     :CATEGORY: Anniv
8589     :END:
8590   %%(org-bbdb-anniversaries)
8591 #+end_example
8593 You can then go ahead and define anniversaries for a BBDB record.
8594 Basically, you need to press {{{kbd(C-o anniversary RET)}}} with the
8595 cursor in a BBDB record and then add the date in the format
8596 =YYYY-MM-DD= or =MM-DD=, followed by a space and the class of the
8597 anniversary (=birthday=, =wedding=, or a format string).  If you omit
8598 the class, it defaults to =birthday=.  Here are a few examples, the
8599 header for the file =org-bbdb.el= contains more detailed information.
8601 #+begin_example
8602   1973-06-22
8603   06-22
8604   1955-08-02 wedding
8605   2008-04-14 %s released version 6.01 of Org mode, %d years ago
8606 #+end_example
8608 After a change to BBDB, or for the first agenda display during an
8609 Emacs session, the agenda display suffers a short delay as Org updates
8610 its hash with anniversaries.  However, from then on things will be
8611 very fast, much faster in fact than a long list of
8612 =%%(diary-anniversary)= entries in an Org or Diary file.
8614 #+findex: org-bbdb-anniversaries-future
8615 If you would like to see upcoming anniversaries with a bit of
8616 forewarning, you can use the following instead:
8618 #+begin_example
8619   ,* Anniversaries
8620     :PROPERTIES:
8621     :CATEGORY: Anniv
8622     :END:
8623   %%(org-bbdb-anniversaries-future 3)
8624 #+end_example
8626 That will give you three days' warning: on the anniversary date itself
8627 and the two days prior.  The argument is optional: if omitted, it
8628 defaults to 7.
8630 **** Appointment reminders
8631 :PROPERTIES:
8632 :UNNUMBERED: notoc
8633 :END:
8634 #+cindex: @file{appt.el}
8635 #+cindex: appointment reminders
8636 #+cindex: appointment
8637 #+cindex: reminders
8639 #+cindex: APPT_WARNTIME, keyword
8640 Org can interact with Emacs appointments notification facility.  To
8641 add the appointments of your agenda files, use the command
8642 ~org-agenda-to-appt~.  This command lets you filter through the list
8643 of your appointments and add only those belonging to a specific
8644 category or matching a regular expression.  It also reads
8645 a =APPT_WARNTIME= property which overrides the value of
8646 ~appt-message-warning-time~ for this appointment.  See the docstring
8647 for details.
8649 *** The global TODO list
8650 :PROPERTIES:
8651 :DESCRIPTION: All unfinished action items.
8652 :ALT_TITLE: Global TODO list
8653 :END:
8654 #+cindex: global TODO list
8655 #+cindex: TODO list, global
8657 The global TODO list contains all unfinished TODO items formatted and
8658 collected into a single place.
8660 - {{{kbd(C-c a t)}}} (~org-todo-list~) ::
8662      #+kindex: C-c a t
8663      #+findex: org-todo-list
8664      Show the global TODO list.  This collects the TODO items from all
8665      agenda files (see [[*Agenda Views]]) into a single buffer.  By
8666      default, this lists items with a state the is not a DONE state.
8667      The buffer is in ~agenda-mode~, so there are commands to examine
8668      and manipulate the TODO entries directly from that buffer (see
8669      [[*Commands in the Agenda Buffer]]).
8671 - {{{kbd(C-c a T)}}} (~org-todo-list~) ::
8673      #+kindex: C-c a T
8674      #+findex: org-todo-list
8675      #+cindex: TODO keyword matching
8676      #+vindex: org-todo-keywords
8677      Like the above, but allows selection of a specific TODO keyword.
8678      You can also do this by specifying a prefix argument to
8679      {{{kbd(C-c a t)}}}.  You are prompted for a keyword, and you may
8680      also specify several keywords by separating them with =|= as the
8681      boolean OR operator.  With a numeric prefix, the Nth keyword in
8682      ~org-todo-keywords~ is selected.
8684      #+kindex: r
8685      The {{{kbd(r)}}} key in the agenda buffer regenerates it, and you
8686      can give a prefix argument to this command to change the selected
8687      TODO keyword, for example {{{kbd(3 r)}}}.  If you often need
8688      a search for a specific keyword, define a custom command for it
8689      (see [[*The Agenda Dispatcher]]).
8691      Matching specific TODO keywords can also be done as part of
8692      a tags search (see [[*Tag Searches]]).
8694 Remote editing of TODO items means that you can change the state of
8695 a TODO entry with a single key press.  The commands available in the
8696 TODO list are described in [[*Commands in the Agenda Buffer]].
8698 #+cindex: sublevels, inclusion into TODO list
8699 Normally the global TODO list simply shows all headlines with TODO
8700 keywords.  This list can become very long.  There are two ways to keep
8701 it more compact:
8704   #+vindex: org-agenda-todo-ignore-scheduled
8705   #+vindex: org-agenda-todo-ignore-deadlines
8706   #+vindex: org-agenda-todo-ignore-timestamp
8707   #+vindex: org-agenda-todo-ignore-with-date
8708   Some people view a TODO item that has been /scheduled/ for execution
8709   or have a /deadline/ (see [[*Timestamps, Deadlines and Scheduling]]) as
8710   no longer /open/.  Configure the variables
8711   ~org-agenda-todo-ignore-scheduled~,
8712   ~org-agenda-todo-ignore-deadlines~,
8713   ~org-agenda-todo-ignore-timestamp~ and/or
8714   ~org-agenda-todo-ignore-with-date~ to exclude such items from the
8715   global TODO list.
8718   #+vindex: org-agenda-todo-list-sublevels
8719   TODO items may have sublevels to break up the task into subtasks.
8720   In such cases it may be enough to list only the highest level TODO
8721   headline and omit the sublevels from the global list.  Configure the
8722   variable ~org-agenda-todo-list-sublevels~ to get this behavior.
8724 *** Matching tags and properties
8725 :PROPERTIES:
8726 :DESCRIPTION: Structured information with fine-tuned search.
8727 :END:
8728 #+cindex: matching, of tags
8729 #+cindex: matching, of properties
8730 #+cindex: tags view
8731 #+cindex: match view
8733 If headlines in the agenda files are marked with /tags/ (see [[*Tags]]),
8734 or have properties (see [[*Properties and Columns]]), you can select
8735 headlines based on this metadata and collect them into an agenda
8736 buffer.  The match syntax described here also applies when creating
8737 sparse trees with {{{kbd(C-c / m)}}}.
8739 - {{{kbd(C-c a m)}}} (~org-tags-view~) ::
8741      #+kindex: C-c a m
8742      #+findex: org-tags-view
8743      Produce a list of all headlines that match a given set of tags.
8744      The command prompts for a selection criterion, which is a boolean
8745      logic expression with tags, like =+work+urgent-withboss= or
8746      =work|home= (see [[*Tags]]).  If you often need a specific search,
8747      define a custom command for it (see [[*The Agenda Dispatcher]]).
8749 - {{{kbd(C-c a M)}}} (~org-tags-view~) ::
8751      #+kindex: C-c a M
8752      #+findex: org-tags-view
8753      #+vindex: org-tags-match-list-sublevels
8754      #+vindex: org-agenda-tags-todo-honor-ignore-options
8755      Like {{{kbd(C-c a m)}}}, but only select headlines that are also
8756      TODO items and force checking subitems (see the variable
8757      ~org-tags-match-list-sublevels~).  To exclude scheduled/deadline
8758      items, see the variable
8759      ~org-agenda-tags-todo-honor-ignore-options~.  Matching specific
8760      TODO keywords together with a tags match is also possible, see
8761      [[*Tag Searches]].
8763 The commands available in the tags list are described in [[*Commands in
8764 the Agenda Buffer]].
8766 #+cindex: boolean logic, for agenda searches
8767 A search string can use Boolean operators =&= for AND and =|= for OR.
8768 =&= binds more strongly than =|=.  Parentheses are currently not
8769 implemented.  Each element in the search is either a tag, a regular
8770 expression matching tags, or an expression like =PROPERTY OPERATOR
8771 VALUE= with a comparison operator, accessing a property value.  Each
8772 element may be preceded by =-= to select against it, and =+= is
8773 syntactic sugar for positive selection.  The AND operator =&= is
8774 optional when =+= or =-= is present.  Here are some examples, using
8775 only tags.
8777 - ~+work-boss~ ::
8779      Select headlines tagged =work=, but discard those also tagged
8780      =boss=.
8782 - ~work|laptop~ ::
8784      Selects lines tagged =work= or =laptop=.
8786 - ~work|laptop+night~ ::
8788      Like before, but require the =laptop= lines to be tagged
8789      also =night=.
8791 #+cindex: regular expressions, with tags search
8792 Instead of a tag, you may also specify a regular expression enclosed
8793 in curly braces.  For example, =work+{^boss.*}= matches headlines that
8794 contain the tag =:work:= and any tag /starting/ with =boss=.
8796 #+cindex: group tags, as regular expressions
8797 Group tags (see [[*Tag Hierarchy]]) are expanded as regular expressions.
8798 E.g., if =work= is a group tag for the group =:work:lab:conf:=, then
8799 searching for =work= also searches for ={\(?:work\|lab\|conf\)}= and
8800 searching for =-work= searches for all headlines but those with one of
8801 the tags in the group (i.e., =-{\(?:work\|lab\|conf\)}=).
8803 #+cindex: TODO keyword matching, with tags search
8804 #+cindex: level, for tags/property match
8805 #+cindex: category, for tags/property match
8806 #+vindex: org-odd-levels-only
8807 You may also test for properties (see [[*Properties and Columns]]) at the
8808 same time as matching tags.  The properties may be real properties, or
8809 special properties that represent other metadata (see [[*Special
8810 Properties]]).  For example, the property =TODO= represents the TODO
8811 keyword of the entry.  Or, the property =LEVEL= represents the level
8812 of an entry.  So searching =+LEVEL=3+boss-TODO​="DONE"= lists all level
8813 three headlines that have the tag =boss= and are /not/ marked with the
8814 TODO keyword =DONE=.  In buffers with ~org-odd-levels-only~ set,
8815 =LEVEL= does not count the number of stars, but =LEVEL=2= corresponds
8816 to 3 stars etc.
8818 Here are more examples:
8820 - =work+TODO​="WAITING"= ::
8822      Select =work=-tagged TODO lines with the specific TODO keyword
8823      =WAITING=.
8825 - =work+TODO​="WAITING"|home+TODO​="WAITING"= ::
8827      Waiting tasks both at work and at home.
8829 When matching properties, a number of different operators can be used
8830 to test the value of a property.  Here is a complex example:
8832 #+begin_example
8833   +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2
8834            +With={Sarah|Denny}+SCHEDULED>="<2008-10-11>"
8835 #+end_example
8837 #+texinfo: @noindent
8838 The type of comparison depends on how the comparison value is written:
8840 - If the comparison value is a plain number, a numerical comparison is
8841   done, and the allowed operators are =<=, ===, =>=, =<==, =>==, and
8842   =<>=.
8844 - If the comparison value is enclosed in double-quotes, a string
8845   comparison is done, and the same operators are allowed.
8847 - If the comparison value is enclosed in double-quotes /and/ angular
8848   brackets (like =DEADLINE<​="<2008-12-24 18:30>"=), both values are
8849   assumed to be date/time specifications in the standard Org way, and
8850   the comparison is done accordingly.  Valid values also include
8851   ="<now>"= for now (including time), ="<today>"=, and ="<tomorrow>"=
8852   for these days at 0:00 hours, i.e., without a time specification.
8853   You can also use strings like ="<+5d>"= or ="<-2m>"= with units =d=,
8854   =w=, =m=, and =y= for day, week, month, and year, respectively.
8856 - If the comparison value is enclosed in curly braces, a regexp match
8857   is performed, with === meaning that the regexp matches the property
8858   value, and =<>= meaning that it does not match.
8860 So the search string in the example finds entries tagged =work= but
8861 not =boss=, which also have a priority value =A=, a =Coffee= property
8862 with the value =unlimited=, an =EFFORT= property that is numerically
8863 smaller than 2, a =With= property that is matched by the regular
8864 expression =Sarah|Denny=, and that are scheduled on or after October
8865 11, 2008.
8867 You can configure Org mode to use property inheritance during
8868 a search, but beware that this can slow down searches considerably.
8869 See [[*Property Inheritance]], for details.
8871 For backward compatibility, and also for typing speed, there is also
8872 a different way to test TODO states in a search.  For this, terminate
8873 the tags/property part of the search string (which may include several
8874 terms connected with =|=) with a =/= and then specify a Boolean
8875 expression just for TODO keywords.  The syntax is then similar to that
8876 for tags, but should be applied with care: for example, a positive
8877 selection on several TODO keywords cannot meaningfully be combined
8878 with boolean AND.  However, /negative selection/ combined with AND can
8879 be meaningful.  To make sure that only lines are checked that actually
8880 have any TODO keyword (resulting in a speed-up), use {{{kbd(C-c
8881 a M)}}}, or equivalently start the TODO part after the slash with =!=.
8882 Using {{{kbd(C-c a M)}}} or =/!= does not match TODO keywords in
8883 a DONE state.  Examples:
8885 - =work/WAITING= ::
8887      Same as =work+TODO​="WAITING"=.
8889 - =work/!-WAITING-NEXT= ::
8891      Select =work=-tagged TODO lines that are neither =WAITING= nor
8892      =NEXT=.
8894 - =work/!+WAITING|+NEXT= ::
8896      Select =work=-tagged TODO lines that are either =WAITING= or
8897      =NEXT=.
8899 *** Search view
8900 :PROPERTIES:
8901 :DESCRIPTION: Find entries by searching for text.
8902 :END:
8903 #+cindex: search view
8904 #+cindex: text search
8905 #+cindex: searching, for text
8907 This agenda view is a general text search facility for Org mode
8908 entries.  It is particularly useful to find notes.
8910 - {{{kbd(C-c a s)}}} (~org-search-view~) ::
8912      #+kindex: C-c a s
8913      #+findex: org-search-view
8914      This is a special search that lets you select entries by matching
8915      a substring or specific words using a boolean logic.
8917 For example, the search string =computer equipment= matches entries
8918 that contain =computer equipment= as a substring, even if the two
8919 words are separated by more space or a line break.
8921 Search view can also search for specific keywords in the entry, using
8922 Boolean logic.  The search string =+computer
8923 +wifi -ethernet -{8\.11[bg]}= matches note entries that contain the
8924 keywords =computer= and =wifi=, but not the keyword =ethernet=, and
8925 which are also not matched by the regular expression =8\.11[bg]=,
8926 meaning to exclude both =8.11b= and =8.11g=.  The first =+= is
8927 necessary to turn on boolean search, other =+= characters are
8928 optional.  For more details, see the docstring of the command
8929 ~org-search-view~.
8931 You can incrementally adjust a boolean search with the following keys
8933 #+attr_texinfo: :columns 0.1 0.6
8934 | {{{kbd([)}}} | Add a positive search word        |
8935 | {{{kbd(])}}} | Add a negative search word        |
8936 | {{{kbd({)}}} | Add a positive regular expression |
8937 | {{{kbd(})}}} | Add a negative regular expression |
8939 #+vindex: org-agenda-text-search-extra-files
8940 Note that in addition to the agenda files, this command also searches
8941 the files listed in ~org-agenda-text-search-extra-files~.
8943 *** Stuck projects
8944 :PROPERTIES:
8945 :DESCRIPTION: Find projects you need to review.
8946 :END:
8947 #+pindex: GTD, Getting Things Done
8949 If you are following a system like David Allen's GTD to organize your
8950 work, one of the "duties" you have is a regular review to make sure
8951 that all projects move along.  A /stuck/ project is a project that has
8952 no defined next actions, so it never shows up in the TODO lists Org
8953 mode produces.  During the review, you need to identify such projects
8954 and define next actions for them.
8956 - {{{kbd(C-c a #)}}} (~org-agenda-list-stuck-projects~) ::
8958      #+kindex: C-c a #
8959      #+findex: org-agenda-list-stuck-projects
8960      List projects that are stuck.
8962 - {{{kbd(C-c a !)}}} ::
8964      #+kindex: C-c a !
8965      #+vindex: org-stuck-projects
8966      Customize the variable ~org-stuck-projects~ to define what
8967      a stuck project is and how to find it.
8969 You almost certainly need to configure this view before it works for
8970 you.  The built-in default assumes that all your projects are level-2
8971 headlines, and that a project is not stuck if it has at least one
8972 entry marked with a TODO keyword =TODO= or =NEXT= or =NEXTACTION=.
8974 Let's assume that you, in your own way of using Org mode, identify
8975 projects with a tag =:PROJECT:=, and that you use a TODO keyword
8976 =MAYBE= to indicate a project that should not be considered yet.
8977 Let's further assume that the TODO keyword =DONE= marks finished
8978 projects, and that =NEXT= and =TODO= indicate next actions.  The tag
8979 =:@shop:= indicates shopping and is a next action even without the
8980 NEXT tag.  Finally, if the project contains the special word =IGNORE=
8981 anywhere, it should not be listed either.  In this case you would
8982 start by identifying eligible projects with a tags/TODO match (see
8983 [[*Tag Searches]]) =+PROJECT/-MAYBE-DONE=, and then check for =TODO=,
8984 =NEXT=, =@shop=, and =IGNORE= in the subtree to identify projects that
8985 are not stuck.  The correct customization for this is:
8987 #+begin_src emacs-lisp
8988   (setq org-stuck-projects
8989         '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@shop")
8990           "\\<IGNORE\\>"))
8991 #+end_src
8993 Note that if a project is identified as non-stuck, the subtree of this
8994 entry is searched for stuck projects.
8996 ** Presentation and Sorting
8997 :PROPERTIES:
8998 :DESCRIPTION: How agenda items are prepared for display.
8999 :END:
9000 #+cindex: presentation, of agenda items
9002 #+vindex: org-agenda-prefix-format
9003 #+vindex: org-agenda-tags-column
9004 Before displaying items in an agenda view, Org mode visually prepares
9005 the items and sorts them.  Each item occupies a single line.  The line
9006 starts with a /prefix/ that contains the /category/ (see [[*Categories]])
9007 of the item and other important information.  You can customize in
9008 which column tags are displayed through ~org-agenda-tags-column~.  You
9009 can also customize the prefix using the option
9010 ~org-agenda-prefix-format~.  This prefix is followed by a cleaned-up
9011 version of the outline headline associated with the item.
9013 *** Categories
9014 :PROPERTIES:
9015 :DESCRIPTION: Not all tasks are equal.
9016 :END:
9017 #+cindex: category
9018 #+cindex: CATEGORY, keyword
9020 The category is a broad label assigned to each agenda item.  By
9021 default, the category is simply derived from the file name, but you
9022 can also specify it with a special line in the buffer, like
9023 this:
9025 : #+CATEGORY: Thesis
9027 #+texinfo: @noindent
9028 #+cindex: CATEGORY, property
9029 If you would like to have a special category for a single entry or
9030 a (sub)tree, give the entry a =CATEGORY= property with the special
9031 category you want to apply as the value.
9033 #+texinfo: @noindent
9034 The display in the agenda buffer looks best if the category is not
9035 longer than 10 characters.
9037 #+texinfo: @noindent
9038 #+vindex: org-agenda-category-icon-alist
9039 You can set up icons for category by customizing the
9040 ~org-agenda-category-icon-alist~ variable.
9042 *** Time-of-day specifications
9043 :PROPERTIES:
9044 :DESCRIPTION: How the agenda knows the time.
9045 :END:
9046 #+cindex: time-of-day specification
9048 Org mode checks each agenda item for a time-of-day specification.  The
9049 time can be part of the timestamp that triggered inclusion into the
9050 agenda, for example
9052 : <2005-05-10 Tue 19:00>
9054 #+texinfo: @noindent
9055 Time ranges can be specified with two timestamps:
9057 : <2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>
9059 In the headline of the entry itself, a time(range) may also appear as
9060 plain text (like =12:45= or a =8:30-1pm=).  If the agenda integrates
9061 the Emacs diary (see [[*Weekly/daily agenda]]), time specifications in
9062 diary entries are recognized as well.
9064 For agenda display, Org mode extracts the time and displays it in
9065 a standard 24 hour format as part of the prefix.  The example times in
9066 the previous paragraphs would end up in the agenda like this:
9068 #+begin_example
9069    8:30-13:00 Arthur Dent lies in front of the bulldozer
9070   12:45...... Ford Prefect arrives and takes Arthur to the pub
9071   19:00...... The Vogon reads his poem
9072   20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9073 #+end_example
9075 #+cindex: time grid
9076 If the agenda is in single-day mode, or for the display of today, the
9077 timed entries are embedded in a time grid, like
9079 #+begin_example
9080    8:00...... ------------------
9081    8:30-13:00 Arthur Dent lies in front of the bulldozer
9082   10:00...... ------------------
9083   12:00...... ------------------
9084   12:45...... Ford Prefect arrives and takes Arthur to the pub
9085   14:00...... ------------------
9086   16:00...... ------------------
9087   18:00...... ------------------
9088   19:00...... The Vogon reads his poem
9089   20:00...... ------------------
9090   20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9091 #+end_example
9093 #+vindex: org-agenda-use-time-grid
9094 #+vindex: org-agenda-time-grid
9095 The time grid can be turned on and off with the variable
9096 ~org-agenda-use-time-grid~, and can be configured with
9097 ~org-agenda-time-grid~.
9099 *** Sorting of agenda items
9100 :PROPERTIES:
9101 :DESCRIPTION: The order of things.
9102 :END:
9103 #+cindex: sorting, of agenda items
9104 #+cindex: priorities, of agenda items
9106 Before being inserted into a view, the items are sorted.  How this is
9107 done depends on the type of view.
9110   #+vindex: org-agenda-files
9111   For the daily/weekly agenda, the items for each day are sorted.  The
9112   default order is to first collect all items containing an explicit
9113   time-of-day specification.  These entries are shown at the beginning
9114   of the list, as a /schedule/ for the day.  After that, items remain
9115   grouped in categories, in the sequence given by ~org-agenda-files~.
9116   Within each category, items are sorted by priority (see
9117   [[*Priorities]]), which is composed of the base priority (2000 for
9118   priority =A=, 1000 for =B=, and 0 for =C=), plus additional
9119   increments for overdue scheduled or deadline items.
9121 - For the TODO list, items remain in the order of categories, but
9122   within each category, sorting takes place according to priority (see
9123   [[*Priorities]]).  The priority used for sorting derives from the
9124   priority cookie, with additions depending on how close an item is to
9125   its due or scheduled date.
9127 - For tags matches, items are not sorted at all, but just appear in
9128   the sequence in which they are found in the agenda files.
9130 #+vindex: org-agenda-sorting-strategy
9131 Sorting can be customized using the variable
9132 ~org-agenda-sorting-strategy~, and may also include criteria based on
9133 the estimated effort of an entry (see [[*Effort Estimates]]).
9135 *** Filtering/limiting agenda times
9136 :PROPERTIES:
9137 :DESCRIPTION: Dynamically narrow the agenda.
9138 :END:
9140 Agenda built-in or customized commands are statically defined.  Agenda
9141 filters and limits provide two ways of dynamically narrowing down the
9142 list of agenda entries: /filters/ and /limits/.  Filters only act on
9143 the display of the items, while limits take effect before the list of
9144 agenda entries is built.  Filters are more often used interactively,
9145 while limits are mostly useful when defined as local variables within
9146 custom agenda commands.
9148 **** Filtering in the agenda
9149 :PROPERTIES:
9150 :UNNUMBERED: notoc
9151 :END:
9152 #+cindex: agenda filtering
9153 #+cindex: filtering entries, in agenda
9154 #+cindex: tag filtering, in agenda
9155 #+cindex: category filtering, in agenda
9156 #+cindex: top headline filtering, in agenda
9157 #+cindex: effort filtering, in agenda
9158 #+cindex: query editing, in agenda
9160 - {{{kbd(/)}}} (~org-agenda-filter-by-tag~) ::
9162      #+findex: org-agenda-filter-by-tag
9163      #+vindex: org-agenda-tag-filter-preset
9164      Filter the agenda view with respect to a tag and/or effort
9165      estimates.  The difference between this and a custom agenda
9166      command is that filtering is very fast, so that you can switch
9167      quickly between different filters without having to recreate the
9168      agenda.[fn:94]
9170      You are prompted for a tag selection letter; {{{kbd(SPC)}}} means
9171      any tag at all.  Pressing {{{kbd(TAB)}}} at that prompt offers
9172      completion to select a tag, including any tags that do not have
9173      a selection character.  The command then hides all entries that
9174      do not contain or inherit this tag.  When called with prefix
9175      argument, remove the entries that /do/ have the tag.  A second
9176      {{{kbd(/)}}} at the prompt turns off the filter and shows any
9177      hidden entries.  Pressing {{{kbd(+)}}} or {{{kbd(-)}}} switches
9178      between filtering and excluding the next tag.
9180      #+vindex: org-agenda-auto-exclude-function
9181      Org also supports automatic, context-aware tag filtering.  If the
9182      variable ~org-agenda-auto-exclude-function~ is set to
9183      a user-defined function, that function can decide which tags
9184      should be excluded from the agenda automatically.  Once this is
9185      set, the {{{kbd(/)}}} command then accepts {{{kbd(RET)}}} as
9186      a sub-option key and runs the auto exclusion logic.  For example,
9187      let's say you use a =Net= tag to identify tasks which need
9188      network access, an =Errand= tag for errands in town, and a =Call=
9189      tag for making phone calls.  You could auto-exclude these tags
9190      based on the availability of the Internet, and outside of
9191      business hours, with something like this:
9193      #+begin_src emacs-lisp
9194        (defun org-my-auto-exclude-function (tag)
9195          (and (cond
9196                ((string= tag "Net")
9197                 (/= 0 (call-process "/sbin/ping" nil nil nil
9198                                     "-c1" "-q" "-t1" "mail.gnu.org")))
9199                ((or (string= tag "Errand") (string= tag "Call"))
9200                 (let ((hour (nth 2 (decode-time))))
9201                   (or (< hour 8) (> hour 21)))))
9202               (concat "-" tag)))
9204        (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
9205      #+end_src
9207 - {{{kbd(<)}}} (~org-agenda-filter-by-category~) ::
9209      #+findex: org-agenda-filter-by-category
9210      Filter the current agenda view with respect to the category of
9211      the item at point.  Pressing {{{kbd(<)}}} another time removes
9212      this filter.  When called with a prefix argument exclude the
9213      category of the item at point from the agenda.
9215      #+vindex: org-agenda-category-filter-preset
9216      You can add a filter preset in custom agenda commands through the
9217      option ~org-agenda-category-filter-preset~.  See [[*Setting options
9218      for custom commands]].
9220 - {{{kbd(^)}}} (~org-agenda-filter-by-top-headline~) ::
9222      #+findex: org-agenda-filter-by-top-headline
9223      Filter the current agenda view and only display the siblings and
9224      the parent headline of the one at point.
9226 - {{{kbd(=)}}} (~org-agenda-filter-by-regexp~) ::
9228      #+findex: org-agenda-filter-by-regexp
9229      Filter the agenda view by a regular expression: only show agenda
9230      entries matching the regular expression the user entered.  When
9231      called with a prefix argument, it filters /out/ entries matching
9232      the regexp.  With two universal prefix arguments, it removes all
9233      the regexp filters, which can be accumulated.
9235      #+vindex: org-agenda-regexp-filter-preset
9236      You can add a filter preset in custom agenda commands through the
9237      option ~org-agenda-regexp-filter-preset~.  See [[*Setting options
9238      for custom commands]].
9240 - {{{kbd(_)}}} (~org-agenda-filter-by-effort~) ::
9242      #+findex: org-agenda-filter-by-effort
9243      Filter the agenda view with respect to effort estimates.  You
9244      first need to set up allowed efforts globally, for example
9246      #+begin_src emacs-lisp
9247        (setq org-global-properties
9248              '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
9249      #+end_src
9251      #+vindex: org-sort-agenda-noeffort-is-high
9252      You can then filter for an effort by first typing an operator,
9253      one of {{{kbd(<)}}}, {{{kbd(>)}}} and {{{kbd(=)}}}, and then the
9254      one-digit index of an effort estimate in your array of allowed
9255      values, where {{{kbd(0)}}} means the 10th value.  The filter then
9256      restricts to entries with effort smaller-or-equal, equal, or
9257      larger-or-equal than the selected value.  For application of the
9258      operator, entries without a defined effort are treated according
9259      to the value of ~org-sort-agenda-noeffort-is-high~.
9261      When called with a prefix argument, it removes entries matching
9262      the condition.  With two universal prefix arguments, it clears
9263      effort filters, which can be accumulated.
9265      #+vindex: org-agenda-effort-filter-preset
9266      You can add a filter preset in custom agenda commands through the
9267      option ~org-agenda-effort-filter-preset~.  See [[*Setting options
9268      for custom commands]].
9270 - {{{kbd(|)}}} (~org-agenda-filter-remove-all~) ::
9272      Remove all filters in the current agenda view.
9274 **** Setting limits for the agenda
9275 :PROPERTIES:
9276 :UNNUMBERED: notoc
9277 :END:
9278 #+cindex: limits, in agenda
9280 Here is a list of options that you can set, either globally, or
9281 locally in your custom agenda views (see [[*Custom Agenda Views]]).
9283 - ~org-agenda-max-entries~ ::
9285      #+vindex: org-agenda-max-entries
9286      Limit the number of entries.
9288 - ~org-agenda-max-effort~ ::
9290      #+vindex: org-agenda-max-effort
9291      Limit the duration of accumulated efforts (as minutes).
9293 - ~org-agenda-max-todos~ ::
9295      #+vindex: org-agenda-max-todos
9296      Limit the number of entries with TODO keywords.
9298 - ~org-agenda-max-tags~ ::
9300      #+vindex: org-agenda-max-tags
9301      Limit the number of tagged entries.
9303 When set to a positive integer, each option excludes entries from
9304 other categories: for example, ~(setq org-agenda-max-effort 100)~
9305 limits the agenda to 100 minutes of effort and exclude any entry that
9306 has no effort property.  If you want to include entries with no effort
9307 property, use a negative value for ~org-agenda-max-effort~.  One
9308 useful setup is to use ~org-agenda-max-entries~ locally in a custom
9309 command.  For example, this custom command displays the next five
9310 entries with a =NEXT= TODO keyword.
9312 #+begin_src emacs-lisp
9313   (setq org-agenda-custom-commands
9314         '(("n" todo "NEXT"
9315            ((org-agenda-max-entries 5)))))
9316 #+end_src
9318 Once you mark one of these five entry as DONE, rebuilding the agenda
9319 will again the next five entries again, including the first entry that
9320 was excluded so far.
9322 You can also dynamically set temporary limits, which are lost when
9323 rebuilding the agenda:
9325 - {{{kbd(~ )}}} (~org-agenda-limit-interactively~) ::
9327      #+findex: org-agenda-limit-interactively
9328      This prompts for the type of limit to apply and its value.
9330 ** Commands in the Agenda Buffer
9331 :PROPERTIES:
9332 :DESCRIPTION: Remote editing of Org trees.
9333 :ALT_TITLE: Agenda Commands
9334 :END:
9335 #+cindex: commands, in agenda buffer
9337 Entries in the agenda buffer are linked back to the Org file or diary
9338 file where they originate.  You are not allowed to edit the agenda
9339 buffer itself, but commands are provided to show and jump to the
9340 original entry location, and to edit the Org files "remotely" from the
9341 agenda buffer.  In this way, all information is stored only once,
9342 removing the risk that your agenda and note files may diverge.
9344 Some commands can be executed with mouse clicks on agenda lines.  For
9345 the other commands, the cursor needs to be in the desired line.
9347 *** Motion
9348 :PROPERTIES:
9349 :UNNUMBERED: notoc
9350 :END:
9351 #+cindex: motion commands in agenda
9353 - {{{kbd(n)}}} (~org-agenda-next-line~) ::
9355      #+kindex: n
9356      #+findex: org-agenda-next-line
9357      Next line (same as {{{kbd(down)}}} and {{{kbd(C-n)}}}).
9359 - {{{kbd(p)}}} (~org-agenda-previous-line~) ::
9361      #+kindex: p
9362      #+findex: org-agenda-previous-line
9363      Previous line (same as {{{kbd(up)}}} and {{{kbd(C-p)}}}).
9365 *** View/Go to Org file
9366 :PROPERTIES:
9367 :UNNUMBERED: notoc
9368 :END:
9369 #+cindex: view file commands in agenda
9371 - {{{kbd(SPC)}}} or {{{kbd(mouse-3)}}} (~org-agenda-show-and-scroll-up~) ::
9373      #+kindex: SPC
9374      #+kindex: mouse-3
9375      #+findex: org-agenda-show-and-scroll-up
9376      Display the original location of the item in another window.
9377      With a prefix argument, make sure that drawers stay folded.
9379 - {{{kbd(L)}}} (~org-agenda-recenter~) ::
9381      #+findex: org-agenda-recenter
9382      Display original location and recenter that window.
9384 - {{{kbd(TAB)}}} or {{{kbd(mouse-2)}}} (~org-agenda-goto~) ::
9386      #+kindex: TAB
9387      #+kindex: mouse-2
9388      #+findex: org-agenda-goto
9389      Go to the original location of the item in another window.
9391 - {{{kbd(RET)}}} (~org-agenda-switch-to~) ::
9393      #+kindex: RET
9394      #+findex: org-agenda-switch-to
9395      Go to the original location of the item and delete other windows.
9397 - {{{kbd(F)}}} (~org-agenda-follow-mode~) ::
9399      #+kindex: F
9400      #+findex: org-agenda-follow-mode
9401      #+vindex: org-agenda-start-with-follow-mode
9402      Toggle Follow mode.  In Follow mode, as you move the cursor
9403      through the agenda buffer, the other window always shows the
9404      corresponding location in the Org file.  The initial setting for
9405      this mode in new agenda buffers can be set with the variable
9406      ~org-agenda-start-with-follow-mode~.
9408 - {{{kbd(C-c C-x b)}}} (~org-agenda-tree-to-indirect-buffer~) ::
9410      #+kindex: C-c C-x b
9411      #+findex: org-agenda-tree-to-indirect-buffer
9412      Display the entire subtree of the current item in an indirect
9413      buffer.  With a numeric prefix argument N, go up to level N and
9414      then take that tree.  If N is negative, go up that many levels.
9415      With a {{{kbd(C-u)}}} prefix, do not remove the previously used
9416      indirect buffer.
9418 - {{{kbd(C-c C-o)}}} (~org-agenda-open-link~) ::
9420      #+kindex: C-c C-o
9421      #+findex: org-agenda-open-link
9422      Follow a link in the entry.  This offers a selection of any links
9423      in the text belonging to the referenced Org node.  If there is
9424      only one link, follow it without a selection prompt.
9426 *** Change display
9427 :PROPERTIES:
9428 :UNNUMBERED: notoc
9429 :END:
9430 #+cindex: change agenda display
9431 #+cindex: display changing, in agenda
9433 #+attr_texinfo: :sep ,
9434 - {{{kbd(A)}}} ::
9436      #+kindex: A
9437      Interactively select another agenda view and append it to the
9438      current view.
9440 - {{{kbd(o)}}} ::
9442      #+kindex: o
9443      Delete other windows.
9445 - {{{kbd(v d)}}} or short {{{kbd(d)}}} (~org-agenda-day-view~) ::
9447      #+kindex: v d
9448      #+kindex: d
9449      #+findex: org-agenda-day-view
9450      Switch to day view.  When switching to day view, this setting
9451      becomes the default for subsequent agenda refreshes.  A numeric
9452      prefix argument may be used to jump directly to a specific day of
9453      the year.  For example, {{{kbd(32 d)}}} jumps to February 1st.
9454      When setting day view, a year may be encoded in the prefix
9455      argument as well.  For example, {{{kbd(200712 d)}}} jumps to
9456      January 12, 2007.  If such a year specification has only one or
9457      two digits, it is expanded into one of the 30 next years or the
9458      last 69 years.
9460 - {{{kbd(v w)}}} or short {{{kbd(w)}}} (~org-agenda-week-view~) ::
9462      #+kindex: v w
9463      #+kindex: w
9464      #+findex: org-agenda-week-view
9465      Switch to week view.  When switching week view, this setting
9466      becomes the default for subsequent agenda refreshes.  A numeric
9467      prefix argument may be used to jump directly to a specific day of
9468      the ISO week.  For example {{{kbd(9 w)}}} to ISO week number 9.
9469      When setting week view, a year may be encoded in the prefix
9470      argument as well.  For example, {{{kbd(200712 w)}}} jumps to week
9471      12 in 2007.  If such a year specification has only one or two
9472      digits, it is expanded into one of the 30 next years or the last
9473      69 years.
9475 - {{{kbd(v m)}}} (~org-agenda-month-view~) ::
9477      #+kindex: v m
9478      #+findex: org-agenda-month-view
9479      Switch to month view.  Because month views are slow to create,
9480      they do not become the default for subsequent agenda refreshes.
9481      A numeric prefix argument may be used to jump directly to
9482      a specific day of the month.  When setting month view, a year may
9483      be encoded in the prefix argument as well.  For example,
9484      {{{kbd(200712 m)}}} jumps to December, 2007.  If such a year
9485      specification has only one or two digits, it is expanded into one
9486      of the 30 next years or the last 69 years.
9488 - {{{kbd(v y)}}} (~org-agenda-year-view~) ::
9490      #+kindex: v y
9491      #+findex: org-agenda-year-view
9492      Switch to year view.  Because year views are slow to create, they
9493      do not become the default for subsequent agenda refreshes.
9494      A numeric prefix argument may be used to jump directly to
9495      a specific day of the year.
9497 - {{{kbd(v SPC)}}} (~org-agenda-reset-view~) ::
9499      #+kindex: v SPC
9500      #+findex: org-agenda-reset-view
9501      #+vindex: org-agenda-span
9502      Reset the current view to ~org-agenda-span~.
9504 - {{{kbd(f)}}} (~org-agenda-later~) ::
9506      #+kindex: f
9507      #+findex: org-agenda-later
9508      Go forward in time to display the span following the current one.
9509      For example, if the display covers a week, switch to the
9510      following week.  With a prefix argument, repeat that many times.
9512 - {{{kbd(b)}}} (~org-agenda-earlier~) ::
9514      #+kindex: b
9515      #+findex: org-agenda-earlier
9516      Go backward in time to display earlier dates.
9518 - {{{kbd(.)}}} (~org-agenda-goto-today~) ::
9520      #+kindex: .
9521      #+findex: org-agenda-goto-today
9522      Go to today.
9524 - {{{kbd(j)}}} (~org-agenda-goto-date~) ::
9526      #+kindex: j
9527      #+findex: org-agenda-goto-date
9528      Prompt for a date and go there.
9530 - {{{kbd(J)}}} (~org-agenda-clock-goto~) ::
9532      #+kindex: J
9533      #+findex: org-agenda-clock-goto
9534      Go to the currently clocked-in task /in the agenda buffer/.
9536 - {{{kbd(D)}}} (~org-agenda-toggle-diary~) ::
9538      #+kindex: D
9539      #+findex: org-agenda-toggle-diary
9540      Toggle the inclusion of diary entries.  See [[*Weekly/daily agenda]].
9542 - {{{kbd(v l)}}} or {{{kbd(v L)}}} or short {{{kbd(l)}}} (~org-agenda-log-mode~) ::
9544      #+kindex: v l
9545      #+kindex: l
9546      #+kindex: v L
9547      #+findex: org-agenda-log-mode
9548      #+vindex: org-log-done
9549      #+vindex: org-agenda-log-mode-items
9550      Toggle Logbook mode.  In Logbook mode, entries that were marked
9551      DONE while logging was on (see the variable ~org-log-done~) are
9552      shown in the agenda, as are entries that have been clocked on
9553      that day.  You can configure the entry types that should be
9554      included in log mode using the variable
9555      ~org-agenda-log-mode-items~.  When called with a {{{kbd(C-u)}}}
9556      prefix, show all possible logbook entries, including state
9557      changes.  When called with two prefix arguments {{{kbd(C-u
9558      C-u)}}}, show only logging information, nothing else.  {{{kbd(v
9559      L)}}} is equivalent to {{{kbd(C-u v l)}}}.
9561 - {{{kbd(v [)}}} or short {{{kbd([)}}} (~org-agenda-manipulate-query-add~) ::
9563      #+kindex: v [
9564      #+kindex: [
9565      #+findex: org-agenda-manipulate-query-add
9566      Include inactive timestamps into the current view.  Only for
9567      weekly/daily agenda and timeline views.
9569 - {{{kbd(v a)}}} (~org-agenda-archives-mode~) ::
9571      #+kindex: v a
9572      #+findex: org-agenda-archives-mode
9573      Toggle Archives mode.  In Archives mode, trees that are archived
9574      (see [[*Internal archiving]]) are also scanned when producing the
9575      agenda.  To exit archives mode, press {{{kbd(v a)}}} again.
9577 - {{{kbd(v A)}}} ::
9579      #+kindex: v A
9580      Toggle Archives mode.  Include all archive files as well.
9582 - {{{kbd(v R)}}} or short {{{kbd(R)}}} (~org-agenda-clockreport-mode~) ::
9584      #+kindex: v R
9585      #+kindex: R
9586      #+findex: org-agenda-clockreport-mode
9587      #+vindex: org-agenda-start-with-clockreport-mode
9588      #+vindex: org-clock-report-include-clocking-task
9589      Toggle Clockreport mode.  In Clockreport mode, the daily/weekly
9590      agenda always shows a table with the clocked times for the time
9591      span and file scope covered by the current agenda view.  The
9592      initial setting for this mode in new agenda buffers can be set
9593      with the variable ~org-agenda-start-with-clockreport-mode~.  By
9594      using a prefix argument when toggling this mode (i.e., {{{kbd(C-u
9595      R)}}}), the clock table does not show contributions from entries
9596      that are hidden by agenda filtering[fn:95].  See also the
9597      variable ~org-clock-report-include-clocking-task~.
9599 - {{{kbd(v c)}}} ::
9601      #+kindex: v c
9602      #+vindex: org-agenda-clock-consistency-checks
9603      Show overlapping clock entries, clocking gaps, and other clocking
9604      problems in the current agenda range.  You can then visit
9605      clocking lines and fix them manually.  See the variable
9606      ~org-agenda-clock-consistency-checks~ for information on how to
9607      customize the definition of what constituted a clocking problem.
9608      To return to normal agenda display, press {{{kbd(l)}}} to exit
9609      Logbook mode.
9611 - {{{kbd(v E)}}} or short {{{kbd(E)}}} (~org-agenda-entry-text-mode~) ::
9613      #+kindex: v E
9614      #+kindex: E
9615      #+findex: org-agenda-entry-text-mode
9616      #+vindex: org-agenda-start-with-entry-text-mode
9617      #+vindex: org-agenda-entry-text-maxlines
9618      Toggle entry text mode.  In entry text mode, a number of lines
9619      from the Org outline node referenced by an agenda line are
9620      displayed below the line.  The maximum number of lines is given
9621      by the variable ~org-agenda-entry-text-maxlines~.  Calling this
9622      command with a numeric prefix argument temporarily modifies that
9623      number to the prefix value.
9625 - {{{kbd(G)}}} (~org-agenda-toggle-time-grid~) ::
9627      #+kindex: G
9628      #+vindex: org-agenda-use-time-grid
9629      #+vindex: org-agenda-time-grid
9630      Toggle the time grid on and off.  See also the variables
9631      ~org-agenda-use-time-grid~ and ~org-agenda-time-grid~.
9633 - {{{kbd(r)}}} (~org-agenda-redo~), {{{kbd(g)}}} ::
9635      #+kindex: r
9636      #+kindex: g
9637      #+findex: org-agenda-redo
9638      Recreate the agenda buffer, for example to reflect the changes
9639      after modification of the timestamps of items with
9640      {{{kbd(S-left)}}} and {{{kbd(S-right)}}}.  When the
9641      buffer is the global TODO list, a prefix argument is interpreted
9642      to create a selective list for a specific TODO keyword.
9644 - {{{kbd(C-x C-s)}}} or short {{{kbd(s)}}} (~org-save-all-org-buffers~) ::
9646      #+kindex: C-x C-s
9647      #+findex: org-save-all-org-buffers
9648      #+kindex: s
9649      Save all Org buffers in the current Emacs session, and also the
9650      locations of IDs.
9652 - {{{kbd(C-c C-x C-c)}}} (~org-agenda-columns~) ::
9654      #+kindex: C-c C-x C-c
9655      #+findex: org-agenda-columns
9656      #+vindex: org-columns-default-format
9657      Invoke column view (see [[*Column View]]) in the agenda buffer.  The
9658      column view format is taken from the entry at point, or, if there
9659      is no entry at point, from the first entry in the agenda view.
9660      So whatever the format for that entry would be in the original
9661      buffer (taken from a property, from a =COLUMNS= keyword, or from
9662      the default variable ~org-columns-default-format~) is used in the
9663      agenda.
9665 - {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
9667      #+kindex: C-c C-x >
9668      #+findex: org-agenda-remove-restriction-lock
9669      Remove the restriction lock on the agenda, if it is currently
9670      restricted to a file or subtree (see [[*Agenda Files]]).
9672 - {{{kbd(M-up)}}} (~org-agenda-drag-line-backward~) ::
9674      #+kindex: M-up
9675      #+findex: org-agenda-drag-line-backward
9676      Drag the line at point backward one line.  With a numeric prefix
9677      argument, drag backward by that many lines.
9679      Moving agenda lines does not persist after an agenda refresh and
9680      does not modify the contributing Org files.
9682 - {{{kbd(M-down)}}} (~org-agenda-drag-line-forward~) ::
9684      #+kindex: M-down
9685      #+findex: org-agenda-drag-line-forward
9686      Drag the line at point forward one line.  With a numeric prefix
9687      argument, drag forward by that many lines.
9689 *** Remote editing
9690 :PROPERTIES:
9691 :UNNUMBERED: notoc
9692 :END:
9693 #+cindex: remote editing, from agenda
9695 - {{{kbd(0--9)}}} ::
9697      Digit argument.
9699 - {{{kbd(C-_)}}} (~org-agenda-undo~) ::
9701      #+kindex: C-_
9702      #+findex: org-agenda-undo
9703      #+cindex: undoing remote-editing events
9704      #+cindex: remote editing, undo
9705      Undo a change due to a remote editing command.  The change is
9706      undone both in the agenda buffer and in the remote buffer.
9708 - {{{kbd(t)}}} (~org-agenda-todo~) ::
9710      #+kindex: t
9711      #+findex: org-agenda-todo
9712      Change the TODO state of the item, both in the agenda and in the
9713      original Org file.
9715 - {{{kbd(C-S-right)}}} (~org-agenda-todo-nextset~) ::
9717      #+kindex: C-S-right
9718      #+findex: org-agenda-todo-nextset
9719      Switch to the next set of TODO keywords.
9721 - {{{kbd(C-S-left)}}}, ~org-agenda-todo-previousset~ ::
9723      #+kindex: C-S-left
9724      Switch to the previous set of TODO keywords.
9726 - {{{kbd(C-k)}}} (~org-agenda-kill~) ::
9728      #+kindex: C-k
9729      #+findex: org-agenda-kill
9730      #+vindex: org-agenda-confirm-kill
9731      Delete the current agenda item along with the entire subtree
9732      belonging to it in the original Org file.  If the text to be
9733      deleted remotely is longer than one line, the kill needs to be
9734      confirmed by the user.  See variable ~org-agenda-confirm-kill~.
9736 - {{{kbd(C-c C-w)}}} (~org-agenda-refile~) ::
9738      #+kindex: C-c C-w
9739      #+findex: org-agenda-refile
9740      Refile the entry at point.
9742 - {{{kbd(C-c C-x C-a)}}} or short {{{kbd(a)}}} (~org-agenda-archive-default-with-confirmation~) ::
9744      #+kindex: C-c C-x C-a
9745      #+kindex: a
9746      #+findex: org-agenda-archive-default-with-confirmation
9747      #+vindex: org-archive-default-command
9748      Archive the subtree corresponding to the entry at point using the
9749      default archiving command set in ~org-archive-default-command~.
9750      When using the {{{kbd(a)}}} key, confirmation is required.
9752 - {{{kbd(C-c C-x a)}}} (~org-agenda-toggle-archive-tag~) ::
9754      #+kindex: C-c C-x a
9755      #+findex: org-agenda-toggle-archive-tag
9756      Toggle the archive tag (see [[*Internal archiving]]) for the current
9757      headline.
9759 - {{{kbd(C-c C-x A)}}} (~org-agenda-archive-to-archive-sibling~) ::
9761      #+kindex: C-c C-x A
9762      #+findex: org-agenda-archive-to-archive-sibling
9763      Move the subtree corresponding to the current entry to its
9764      /archive sibling/.
9766 - {{{kbd(C-c C-x C-s)}}} or short {{{kbd($)}}} (~org-agenda-archive~) ::
9768      #+kindex: C-c C-x C-s
9769      #+kindex: $
9770      #+findex: org-agenda-archive
9771      Archive the subtree corresponding to the current headline.  This
9772      means the entry is moved to the configured archive location, most
9773      likely a different file.
9775 - {{{kbd(T)}}} (~org-agenda-show-tags~) ::
9777      #+kindex: T
9778      #+findex: org-agenda-show-tags
9779      #+vindex: org-agenda-show-inherited-tags
9780      Show all tags associated with the current item.  This is useful
9781      if you have turned off ~org-agenda-show-inherited-tags~, but
9782      still want to see all tags of a headline occasionally.
9784 - {{{kbd(:)}}} (~org-agenda-set-tags~) ::
9786      #+kindex: :
9787      #+findex: org-agenda-set-tags
9788      Set tags for the current headline.  If there is an active region
9789      in the agenda, change a tag for all headings in the region.
9791 - {{{kbd(\,)}}} (~org-agenda-priority~) ::
9793      #+kindex: ,
9794      #+findex: org-agenda-priority
9795      Set the priority for the current item.  Org mode prompts for the
9796      priority character.  If you reply with {{{kbd(SPC)}}}, the
9797      priority cookie is removed from the entry.
9799 - {{{kbd(P)}}} (~org-agenda-show-priority~) ::
9801      #+kindex: P
9802      #+findex: org-agenda-show-priority
9803      Display weighted priority of current item.
9805 - {{{kbd(+)}}} or {{{kbd(S-up)}}} (~org-agenda-priority-up~) ::
9807      #+kindex: +
9808      #+kindex: C-up
9809      #+findex: org-agenda-priority-up
9810      Increase the priority of the current item.  The priority is
9811      changed in the original buffer, but the agenda is not resorted.
9812      Use the {{{kbd(r)}}} key for this.
9814 - {{{kbd(-)}}} or {{{kbd(S-down)}}} (~org-agenda-priority-down~) ::
9816      #+kindex: -
9817      #+kindex: C-down
9818      #+findex: orga-agenda-priority-down
9819      Decrease the priority of the current item.
9821 - {{{kbd(C-c C-z)}}} or short {{{kbd(z)}}} (~org-agenda-add-note~) ::
9823      #+kindex: z
9824      #+kindex: C-c C-z
9825      #+findex: org-agenda-add-note
9826      #+vindex: org-log-into-drawer
9827      Add a note to the entry.  This note is recorded, and then filed
9828      to the same location where state change notes are put.  Depending
9829      on ~org-log-into-drawer~, this may be inside a drawer.
9831 - {{{kbd(C-c C-a)}}} (~org-attach~) ::
9833      #+kindex: C-c C-a
9834      #+findex: org-attach
9835      Dispatcher for all command related to attachments.
9837 - {{{kbd(C-c C-s)}}} (~org-agenda-schedule~) ::
9839      #+kindex: C-c C-s
9840      #+findex: org-agenda-schedule
9841      Schedule this item.  With a prefix argument, remove the
9842      scheduling timestamp
9844 - {{{kbd(C-c C-d)}}} (~org-agenda-deadline~) ::
9846      #+kindex: C-c C-d
9847      #+findex: org-agenda-deadline
9848      Set a deadline for this item.  With a prefix argument, remove the
9849      deadline.
9851 - {{{kbd(S-right)}}} (~org-agenda-do-date-later~) ::
9853      #+kindex: S-right
9854      #+findex: org-agenda-do-date-later
9855      Change the timestamp associated with the current line by one day
9856      into the future.  If the date is in the past, the first call to
9857      this command moves it to today.  With a numeric prefix argument,
9858      change it by that many days.  For example, {{{kbd(3
9859      6 5 S-right)}}} changes it by a year.  With a {{{kbd(C-u)}}}
9860      prefix, change the time by one hour.  If you immediately repeat
9861      the command, it will continue to change hours even without the
9862      prefix argument.  With a double {{{kbd(C-u C-u)}}} prefix, do the
9863      same for changing minutes.  The stamp is changed in the original
9864      Org file, but the change is not directly reflected in the agenda
9865      buffer.  Use {{{kbd(r)}}} or {{{kbd(g)}}} to update the buffer.
9867 - {{{kbd(S-left)}}} (~org-agenda-do-date-earlier~) ::
9869      #+kindex: S-left
9870      #+findex: org-agenda-do-date-earlier
9871      Change the timestamp associated with the current line by one day
9872      into the past.
9874 - {{{kbd(>)}}} (~org-agenda-date-prompt~) ::
9876      #+kindex: >
9877      #+findex: org-agenda-date-prompt
9878      Change the timestamp associated with the current line.  The key
9879      {{{kbd(>)}}} has been chosen, because it is the same as
9880      {{{kbd(S-.)}}}  on my keyboard.
9882 - {{{kbd(I)}}} (~org-agenda-clock-in~) ::
9884      #+kindex: I
9885      #+findex: org-agenda-clock-in
9886      Start the clock on the current item.  If a clock is running
9887      already, it is stopped first.
9889 - {{{kbd(O)}}} (~org-agenda-clock-out~) ::
9891      #+kindex: O
9892      #+findex: org-agenda-clock-out
9893      Stop the previously started clock.
9895 - {{{kbd(X)}}} (~org-agenda-clock-cancel~) ::
9897      #+kindex: X
9898      #+findex: org-agenda-clock-cancel
9899      Cancel the currently running clock.
9901 - {{{kbd(J)}}} (~org-agenda-clock-goto~) ::
9903      #+kindex: J
9904      #+findex: org-agenda-clock-goto
9905      Jump to the running clock in another window.
9907 - {{{kbd(k)}}} (~org-agenda-capture~) ::
9909      #+kindex: k
9910      #+findex: org-agenda-capture
9911      #+cindex: capturing, from agenda
9912      #+vindex: org-capture-use-agenda-date
9913      Like ~org-capture~, but use the date at point as the default date
9914      for the capture template.  See ~org-capture-use-agenda-date~ to
9915      make this the default behavior of ~org-capture~.
9917 *** Bulk remote editing selected entries
9918 :PROPERTIES:
9919 :UNNUMBERED: notoc
9920 :END:
9921 #+cindex: remote editing, bulk, from agenda
9922 #+vindex: org-agenda-bulk-custom-functions
9924 - {{{kbd(m)}}} (~org-agenda-bulk-mark~) ::
9925      #+kindex: m
9926      #+findex: org-agenda-bulk-mark
9928      Mark the entry at point for bulk action.  If there is an active
9929      region in the agenda, mark the entries in the region.  With
9930      numeric prefix argument, mark that many successive entries.
9932 - {{{kbd(*)}}} (~org-agenda-bulk-mark-all~) ::
9933      #+kindex: *
9934      #+findex: org-agenda-bulk-mark-all
9936      Mark all visible agenda entries for bulk action.
9938 - {{{kbd(u)}}} (~org-agenda-bulk-unmark~) ::
9939      #+kindex: u
9940      #+findex: org-agenda-bulk-unmark
9942      Unmark entry for bulk action.
9944 - {{{kbd(U)}}} (~org-agenda-bulk-remove-all-marks~) ::
9945      #+kindex: U
9946      #+findex: org-agenda-bulk-remove-all-marks
9948      Unmark all marked entries for bulk action.
9950 - {{{kbd(M-m)}}} (~org-agenda-bulk-toggle~) ::
9951      #+kindex: M-m
9952      #+findex: org-agenda-bulk-toggle
9954      Toggle mark of the entry at point for bulk action.
9956 - {{{kbd(M-*)}}} (~org-agenda-bulk-toggle-all~) ::
9957      #+kindex: M-*
9958      #+findex: org-agenda-bulk-toggle-all
9960      Mark entries matching a regular expression for bulk action.
9962 - {{{kbd(%)}}} (~org-agenda-bulk-mark-regexp~) ::
9963      #+kindex: %
9964      #+findex: org-agenda-bulk-mark-regexp
9966      Mark entries matching a regular expression for bulk action.
9968 - {{{kbd(B)}}} (~org-agenda-bulk-action~) ::
9969      #+kindex: B
9970      #+findex: org-agenda-bulk-action
9971      #+vindex: org-agenda-bulk-persistent-marks
9973      Bulk action: act on all marked entries in the agenda.  This
9974      prompts for another key to select the action to be applied.  The
9975      prefix argument to {{{kbd(B)}}} is passed through to the
9976      {{{kbd(s)}}} and {{{kbd(d)}}} commands, to bulk-remove these
9977      special timestamps.  By default, marks are removed after the
9978      bulk.  If you want them to persist, set
9979      ~org-agenda-bulk-persistent-marks~ to ~t~ or hit {{{kbd(p)}}} at
9980      the prompt.
9982      - {{{kbd(*)}}} ::
9984           Toggle persistent marks.
9986      - {{{kbd($)}}} ::
9988           Archive all selected entries.
9990      - {{{kbd(A)}}} ::
9992           Archive entries by moving them to their respective archive
9993           siblings.
9995      - {{{kbd(t)}}} ::
9997           Change TODO state.  This prompts for a single TODO keyword and
9998           changes the state of all selected entries, bypassing blocking
9999           and suppressing logging notes---but not timestamps.
10001      - {{{kbd(+)}}}  ::
10003           Add a tag to all selected entries.
10005      - {{{kbd(-)}}}  ::
10007           Remove a tag from all selected entries.
10009      - {{{kbd(s)}}}  ::
10011           Schedule all items to a new date.  To shift existing schedule
10012           dates by a fixed number of days, use something starting with
10013           double plus at the prompt, for example =++8d= or =++2w=.
10015      - {{{kbd(d)}}}  ::
10017           Set deadline to a specific date.
10019      - {{{kbd(r)}}}  ::
10021           Prompt for a single refile target and move all entries.  The
10022           entries are no longer in the agenda; refresh ({{{kbd(g)}}}) to
10023           bring them back.
10025      - {{{kbd(S)}}}  ::
10027           Reschedule randomly into the coming N days.  N is prompted for.
10028           With a prefix argument ({{{kbd(C-u B S)}}}), scatter only
10029           across weekdays.
10031      - {{{kbd(f)}}}  ::
10033           #+vindex: org-agenda-bulk-custom-functions
10034           Apply a function[fn:96] to marked entries.  For example, the
10035           function below sets the =CATEGORY= property of the entries to
10036           =web=.
10038           #+begin_src emacs-lisp
10039             (defun set-category ()
10040               (interactive "P")
10041               (let ((marker (or (org-get-at-bol 'org-hd-marker)
10042                                 (org-agenda-error))))
10043                 (org-with-point-at marker
10044                   (org-back-to-heading t)
10045                   (org-set-property "CATEGORY" "web"))))
10046           #+end_src
10048 *** Calendar commands
10049 :PROPERTIES:
10050 :UNNUMBERED: notoc
10051 :END:
10052 #+cindex: calendar commands, from agenda
10054 - {{{kbd(c)}}} (~org-agenda-goto-calendar~) ::
10056      #+kindex: c
10057      #+findex: org-agenda-goto-calendar
10058      Open the Emacs calendar and move to the date at the agenda
10059      cursor.
10061 - {{{kbd(c)}}} (~org-calendar-goto-agenda~) ::
10063      #+kindex: c
10064      #+findex: org-calendar-goto-agenda
10065      When in the calendar, compute and show the Org agenda for the
10066      date at the cursor.
10068 - {{{kbd(i)}}} (~org-agenda-diary-entry~) ::
10069      #+kindex: i
10070      #+findex: org-agenda-diary-entry
10072      #+cindex: diary entries, creating from agenda
10073      Insert a new entry into the diary, using the date at the cursor
10074      and (for block entries) the date at the mark.  This adds to the
10075      Emacs diary file[fn:97], in a way similar to the {{{kbd(i)}}}
10076      command in the calendar.  The diary file pops up in another
10077      window, where you can add the entry.
10079      #+vindex: org-agenda-diary-file
10080      If you configure ~org-agenda-diary-file~ to point to an Org file,
10081      Org creates entries in that file instead.  Most entries are
10082      stored in a date-based outline tree that will later make it easy
10083      to archive appointments from previous months/years.  The tree is
10084      built under an entry with a =DATE_TREE= property, or else with
10085      years as top-level entries.  Emacs prompts you for the entry
10086      text---if you specify it, the entry is created in
10087      ~org-agenda-diary-file~ without further interaction.  If you
10088      directly press {{{kbd(RET)}}} at the prompt without typing text,
10089      the target file is shown in another window for you to finish the
10090      entry there.  See also the {{{kbd(k r)}}} command.
10092 - {{{kbd(M)}}} (~org-agenda-phases-of-moon~) ::
10094      #+kindex: M
10095      #+findex: org-agenda-phases-of-moon
10096      Show the phases of the moon for the three months around current
10097      date.
10099 - {{{kbd(S)}}} (~org-agenda-sunrise-sunset~) ::
10101      #+kindex: S
10102      #+findex: org-agenda-sunrise-sunset
10103      Show sunrise and sunset times.  The geographical location must be
10104      set with calendar variables, see the documentation for the Emacs
10105      calendar.
10107 - {{{kbd(C)}}} (~org-agenda-convert-date~) ::
10109      #+kindex: C
10110      #+findex: org-agenda-convert-date
10111      Convert the date at cursor into many other cultural and historic
10112      calendars.
10114 - {{{kbd(H)}}} (~org-agenda-holidays~) ::
10116      #+kindex: H
10117      #+findex: org-agenda-holidays
10118      Show holidays for three months around the cursor date.
10120 *** Quit and exit
10121 :PROPERTIES:
10122 :UNNUMBERED: notoc
10123 :END:
10125 - {{{kbd(q)}}} (~org-agenda-quit~) ::
10126      #+kindex: q
10127      #+findex: org-agenda-quit
10129      Quit agenda, remove the agenda buffer.
10131 - {{{kbd(x)}}} (~org-agenda-exit~) ::
10132      #+kindex: x
10133      #+findex: org-agenda-exit
10135      #+cindex: agenda files, removing buffers
10136      Exit agenda, remove the agenda buffer and all buffers loaded by
10137      Emacs for the compilation of the agenda.  Buffers created by the
10138      user to visit Org files are not removed.
10140 ** Custom Agenda Views
10141 :PROPERTIES:
10142 :DESCRIPTION: Defining special searches and views.
10143 :END:
10144 #+cindex: custom agenda views
10145 #+cindex: agenda views, custom
10147 Custom agenda commands serve two purposes: to store and quickly access
10148 frequently used TODO and tags searches, and to create special
10149 composite agenda buffers.  Custom agenda commands are accessible
10150 through the dispatcher (see [[*The Agenda Dispatcher]]), just like the
10151 default commands.
10153 *** Storing searches
10154 :PROPERTIES:
10155 :DESCRIPTION: Type once, use often.
10156 :END:
10158 The first application of custom searches is the definition of keyboard
10159 shortcuts for frequently used searches, either creating an agenda
10160 buffer, or a sparse tree (the latter covering of course only the
10161 current buffer).
10163 #+kindex: C-c a C
10164 #+vindex: org-agenda-custom-commands
10165 #+cindex: agenda views, main example
10166 #+cindex: agenda, as an agenda views
10167 #+cindex: agenda*, as an agenda views
10168 #+cindex: tags, as an agenda view
10169 #+cindex: todo, as an agenda view
10170 #+cindex: tags-todo
10171 #+cindex: todo-tree
10172 #+cindex: occur-tree
10173 #+cindex: tags-tree
10174 Custom commands are configured in the variable
10175 ~org-agenda-custom-commands~.  You can customize this variable, for
10176 example by pressing {{{kbd(C-c a C)}}}.  You can also directly set it
10177 with Emacs Lisp in the Emacs init file.  The following example
10178 contains all valid agenda views:
10180 #+begin_src emacs-lisp
10181   (setq org-agenda-custom-commands
10182         '(("x" agenda)
10183           ("y" agenda*)
10184           ("w" todo "WAITING")
10185           ("W" todo-tree "WAITING")
10186           ("u" tags "+boss-urgent")
10187           ("v" tags-todo "+boss-urgent")
10188           ("U" tags-tree "+boss-urgent")
10189           ("f" occur-tree "\\<FIXME\\>")
10190           ("h" . "HOME+Name tags searches") ;description for "h" prefix
10191           ("hl" tags "+home+Lisa")
10192           ("hp" tags "+home+Peter")
10193           ("hk" tags "+home+Kim")))
10194 #+end_src
10196 #+texinfo: @noindent
10197 The initial string in each entry defines the keys you have to press
10198 after the dispatcher command {{{kbd(C-c a)}}} in order to access the
10199 command.  Usually this will be just a single character, but if you
10200 have many similar commands, you can also define two-letter
10201 combinations where the first character is the same in several
10202 combinations and serves as a prefix key[fn:98].  The second parameter
10203 is the search type, followed by the string or regular expression to be
10204 used for the matching.  The example above will therefore define:
10206 - {{{kbd(C-c a x)}}} ::
10208      as a global search for agenda entries planned[fn:99] this
10209      week/day.
10211 - {{{kbd(C-c a y)}}} ::
10213      as the same search, but only for entries with an hour
10214      specification like =[h]h:mm=---think of them as appointments.
10216 - {{{kbd(C-c a w)}}} ::
10218      as a global search for TODO entries with =WAITING= as the TODO
10219      keyword.
10221 - {{{kbd(C-c a W)}}} ::
10223      as the same search, but only in the current buffer and displaying
10224      the results as a sparse tree.
10226 - {{{kbd(C-c a u)}}} ::
10228      as a global tags search for headlines tagged =boss= but not
10229      =urgent=.
10231 - {{{kbd(C-c a v)}}} ::
10233      The same search, but limiting it to headlines that are also TODO
10234      items.
10236 - {{{kbd(C-c a U)}}} ::
10238      as the same search, but only in the current buffer and displaying
10239      the result as a sparse tree.
10241 - {{{kbd(C-c a f)}}} ::
10243      to create a sparse tree (again, current buffer only) with all
10244      entries containing the word =FIXME=.
10246 - {{{kbd(C-c a h)}}} ::
10248      as a prefix command for a =HOME= tags search where you have to
10249      press an additional key ({{{kbd(l)}}}, {{{kbd(p)}}} or
10250      {{{kbd(k)}}}) to select a name (Lisa, Peter, or Kim) as
10251      additional tag to match.
10253 Note that ~*-tree~ agenda views need to be called from an Org buffer
10254 as they operate on the current buffer only.
10255 *** Block agenda
10256 :PROPERTIES:
10257 :DESCRIPTION: All the stuff you need in a single buffer.
10258 :END:
10259 #+cindex: block agenda
10260 #+cindex: agenda, with block views
10262 Another possibility is the construction of agenda views that comprise
10263 the results of /several/ commands, each of which creates a block in
10264 the agenda buffer.  The available commands include ~agenda~ for the
10265 daily or weekly agenda (as created with {{{kbd(C-c a a)}}}), ~alltodo~
10266 for the global TODO list (as constructed with {{{kbd(C-c a t)}}}), and
10267 the matching commands discussed above: ~todo~, ~tags~, and
10268 ~tags-todo~.  Here are two examples:
10270 #+begin_src emacs-lisp
10271   (setq org-agenda-custom-commands
10272         '(("h" "Agenda and Home-related tasks"
10273            ((agenda "")
10274             (tags-todo "home")
10275             (tags "garden")))
10276           ("o" "Agenda and Office-related tasks"
10277            ((agenda "")
10278             (tags-todo "work")
10279             (tags "office")))))
10280 #+end_src
10282 #+texinfo: @noindent
10283 This defines {{{kbd(C-c a h)}}} to create a multi-block view for stuff
10284 you need to attend to at home.  The resulting agenda buffer contains
10285 your agenda for the current week, all TODO items that carry the tag
10286 =home=, and also all lines tagged with =garden=.  Finally the command
10287 {{{kbd(C-c a o)}}} provides a similar view for office tasks.
10289 *** Setting options for custom commands
10290 :PROPERTIES:
10291 :DESCRIPTION: Changing the rules.
10292 :ALT_TITLE: Setting options
10293 :END:
10294 #+cindex: options, for custom agenda views
10296 #+vindex: org-agenda-custom-commands
10297 Org mode contains a number of variables regulating agenda construction
10298 and display.  The global variables define the behavior for all agenda
10299 commands, including the custom commands.  However, if you want to
10300 change some settings just for a single custom view, you can do so.
10301 Setting options requires inserting a list of variable names and values
10302 at the right spot in ~org-agenda-custom-commands~.  For example:
10304 #+begin_src emacs-lisp
10305   (setq org-agenda-custom-commands
10306         '(("w" todo "WAITING"
10307            ((org-agenda-sorting-strategy '(priority-down))
10308             (org-agenda-prefix-format "  Mixed: ")))
10309           ("U" tags-tree "+boss-urgent"
10310            ((org-show-context-detail 'minimal)))
10311           ("N" search ""
10312            ((org-agenda-files '("~org/notes.org"))
10313             (org-agenda-text-search-extra-files nil)))))
10314 #+end_src
10316 #+texinfo: @noindent
10317 Now the {{{kbd(C-c a w)}}} command sorts the collected entries only by
10318 priority, and the prefix format is modified to just say =Mixed:=
10319 instead of giving the category of the entry.  The sparse tags tree of
10320 {{{kbd(C-c a U)}}} now turns out ultra-compact, because neither the
10321 headline hierarchy above the match, nor the headline following the
10322 match are shown.  The command {{{kbd(C-c a N)}}} does a text search
10323 limited to only a single file.
10325 For command sets creating a block agenda, ~org-agenda-custom-commands~
10326 has two separate spots for setting options.  You can add options that
10327 should be valid for just a single command in the set, and options that
10328 should be valid for all commands in the set.  The former are just
10329 added to the command entry; the latter must come after the list of
10330 command entries.  Going back to the block agenda example (see [[*Block
10331 agenda]]), let's change the sorting strategy for the {{{kbd(C-c a h)}}}
10332 commands to ~priority-down~, but let's sort the results for GARDEN
10333 tags query in the opposite order, ~priority-up~.  This would look like
10334 this:
10336 #+begin_src emacs-lisp
10337   (setq org-agenda-custom-commands
10338         '(("h" "Agenda and Home-related tasks"
10339            ((agenda)
10340             (tags-todo "home")
10341             (tags "garden"
10342                   ((org-agenda-sorting-strategy '(priority-up)))))
10343            ((org-agenda-sorting-strategy '(priority-down))))
10344           ("o" "Agenda and Office-related tasks"
10345            ((agenda)
10346             (tags-todo "work")
10347             (tags "office")))))
10348 #+end_src
10350 As you see, the values and parentheses setting is a little complex.
10351 When in doubt, use the customize interface to set this variable---it
10352 fully supports its structure.  Just one caveat: when setting options
10353 in this interface, the /values/ are just Lisp expressions.  So if the
10354 value is a string, you need to add the double-quotes around the value
10355 yourself.
10357 #+vindex: org-agenda-custom-commands-contexts
10358 To control whether an agenda command should be accessible from
10359 a specific context, you can customize
10360 ~org-agenda-custom-commands-contexts~.  Let's say for example that you
10361 have an agenda command {{{kbd(o)}}} displaying a view that you only
10362 need when reading emails.  Then you would configure this option like
10363 this:
10365 #+begin_src emacs-lisp
10366   (setq org-agenda-custom-commands-contexts
10367         '(("o" (in-mode . "message-mode"))))
10368 #+end_src
10370 You can also tell that the command key {{{kbd(o)}}} should refer to
10371 another command key {{{kbd(r)}}}.  In that case, add this command key
10372 like this:
10374 #+begin_src emacs-lisp
10375   (setq org-agenda-custom-commands-contexts
10376         '(("o" "r" (in-mode . "message-mode"))))
10377 #+end_src
10379 See the docstring of the variable for more information.
10381 ** Exporting Agenda Views
10382 :PROPERTIES:
10383 :DESCRIPTION: Writing a view to a file.
10384 :END:
10385 #+cindex: agenda views, exporting
10387 If you are away from your computer, it can be very useful to have
10388 a printed version of some agenda views to carry around.  Org mode can
10389 export custom agenda views as plain text, HTML[fn:100], Postscript,
10390 PDF[fn:101], and iCalendar files.  If you want to do this only
10391 occasionally, use the following command:
10393 - {{{kbd(C-x C-w)}}} (~org-agenda-write~) ::
10394      #+kindex: C-x C-w
10395      #+findex: org-agenda-write
10396      #+cindex: exporting agenda views
10397      #+cindex: agenda views, exporting
10399      #+vindex: org-agenda-exporter-settings
10400      Write the agenda view to a file.
10402 If you need to export certain agenda views frequently, you can
10403 associate any custom agenda command with a list of output file
10404 names[fn:102].  Here is an example that first defines custom commands
10405 for the agenda and the global TODO list, together with a number of
10406 files to which to export them.  Then we define two block agenda
10407 commands and specify file names for them as well.  File names can be
10408 relative to the current working directory, or absolute.
10410 #+begin_src emacs-lisp
10411   (setq org-agenda-custom-commands
10412         '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
10413           ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
10414           ("h" "Agenda and Home-related tasks"
10415            ((agenda "")
10416             (tags-todo "home")
10417             (tags "garden"))
10418            nil
10419            ("~/views/home.html"))
10420           ("o" "Agenda and Office-related tasks"
10421            ((agenda)
10422             (tags-todo "work")
10423             (tags "office"))
10424            nil
10425            ("~/views/office.ps" "~/calendars/office.ics"))))
10426 #+end_src
10428 The extension of the file name determines the type of export.  If it
10429 is =.html=, Org mode uses the htmlize package to convert the buffer to
10430 HTML and save it to this file name.  If the extension is =.ps=,
10431 ~ps-print-buffer-with-faces~ is used to produce Postscript output.  If
10432 the extension is =.ics=, iCalendar export is run export over all files
10433 that were used to construct the agenda, and limit the export to
10434 entries listed in the agenda.  Any other extension produces a plain
10435 ASCII file.
10437 The export files are /not/ created when you use one of those
10438 commands interactively because this might use too much overhead.
10439 Instead, there is a special command to produce /all/ specified
10440 files in one step:
10442 #+attr_texinfo: :table-type table :indic @asis
10443 - {{{kbd(C-c a e)}}} (~org-store-agenda-views~) ::
10444      #+kindex: C-c a e
10445      #+findex: org-store-agenda-views
10447      Export all agenda views that have export file names associated
10448      with them.
10450 You can use the options section of the custom agenda commands to also
10451 set options for the export commands.  For example:
10453 #+begin_src emacs-lisp
10454   (setq org-agenda-custom-commands
10455         '(("X" agenda ""
10456            ((ps-number-of-columns 2)
10457             (ps-landscape-mode t)
10458             (org-agenda-prefix-format " [ ] ")
10459             (org-agenda-with-colors nil)
10460             (org-agenda-remove-tags t))
10461            ("theagenda.ps"))))
10462 #+end_src
10464 #+texinfo: @noindent
10465 #+vindex: org-agenda-exporter-settings
10466 This command sets two options for the Postscript exporter, to make it
10467 print in two columns in landscape format---the resulting page can be
10468 cut in two and then used in a paper agenda.  The remaining settings
10469 modify the agenda prefix to omit category and scheduling information,
10470 and instead include a checkbox to check off items.  We also remove the
10471 tags to make the lines compact, and we do not want to use colors for
10472 the black-and-white printer.  Settings specified in
10473 ~org-agenda-exporter-settings~ also apply, e.g.,
10475 #+begin_src emacs-lisp
10476   (setq org-agenda-exporter-settings
10477         '((ps-number-of-columns 2)
10478           (ps-landscape-mode t)
10479           (org-agenda-add-entry-text-maxlines 5)
10480           (htmlize-output-type 'css)))
10481 #+end_src
10483 #+texinfo: @noindent
10484 but the settings in ~org-agenda-custom-commands~ take precedence.
10486 #+texinfo: @noindent
10487 From the command line you may also use:
10489 #+begin_src shell
10490   emacs -eval (org-batch-store-agenda-views) -kill
10491 #+end_src
10493 #+texinfo: @noindent
10494 or, if you need to modify some parameters[fn:103]
10496 #+begin_src shell
10497   emacs -eval '(org-batch-store-agenda-views                      \
10498                 org-agenda-span (quote month)                     \
10499                 org-agenda-start-day "2007-11-01"                 \
10500                 org-agenda-include-diary nil                      \
10501                 org-agenda-files (quote ("~/org/project.org")))'  \
10502         -kill
10503 #+end_src
10505 #+texinfo: @noindent
10506 which creates the agenda views restricted to the file
10507 =~/org/project.org=, without diary entries and with a 30-day extent.
10509 You can also extract agenda information in a way that allows further
10510 processing by other programs.  See [[*Extracting Agenda Information]], for
10511 more information.
10513 ** Using Column View in the Agenda
10514 :PROPERTIES:
10515 :DESCRIPTION: Using column view for collected entries.
10516 :ALT_TITLE: Agenda Column View
10517 :END:
10518 #+cindex: column view, in agenda
10519 #+cindex: agenda, column view
10521 Column view (see [[*Column View]]) is normally used to view and edit
10522 properties embedded in the hierarchical structure of an Org file.  It
10523 can be quite useful to use column view also from the agenda, where
10524 entries are collected by certain criteria.
10526 - {{{kbd(C-c C-x C-c)}}} (~org-agenda-columns~) ::
10527      #+kindex: C-c C-x C-c
10528      #+findex: org-agenda-columns
10530      Turn on column view in the agenda.
10532 To understand how to use this properly, it is important to realize
10533 that the entries in the agenda are no longer in their proper outline
10534 environment.  This causes the following issues:
10537    #+vindex: org-columns-default-format
10538    #+vindex: org-overriding-columns-format
10539    Org needs to make a decision which columns format to use.  Since
10540    the entries in the agenda are collected from different files, and
10541    different files may have different columns formats, this is
10542    a non-trivial problem.  Org first checks if the variable
10543    ~org-agenda-overriding-columns-format~ is currently set, and if so,
10544    takes the format from there.  Otherwise it takes the format
10545    associated with the first item in the agenda, or, if that item does
10546    not have a specific format (defined in a property, or in its file),
10547    it uses ~org-columns-default-format~.
10550    #+cindex: CLOCKSUM, special property
10551    If any of the columns has a summary type defined (see [[*Column
10552    attributes]]), turning on column view in the agenda visits all
10553    relevant agenda files and make sure that the computations of this
10554    property are up to date.  This is also true for the special
10555    =CLOCKSUM= property.  Org then sums the values displayed in the
10556    agenda.  In the daily/weekly agenda, the sums cover a single day;
10557    in all other views they cover the entire block.
10559    It is important to realize that the agenda may show the same entry
10560    /twice/---for example as scheduled and as a deadline---and it may
10561    show two entries from the same hierarchy (for example a /parent/
10562    and its /child/).  In these cases, the summation in the agenda
10563    leads to incorrect results because some values count double.
10565 3. When the column view in the agenda shows the =CLOCKSUM= property,
10566    that is always the entire clocked time for this item.  So even in
10567    the daily/weekly agenda, the clocksum listed in column view may
10568    originate from times outside the current view.  This has the
10569    advantage that you can compare these values with a column listing
10570    the planned total effort for a task---one of the major
10571    applications for column view in the agenda.  If you want
10572    information about clocked time in the displayed period use clock
10573    table mode (press {{{kbd(R)}}} in the agenda).
10576    #+cindex: CLOCKSUM_T, special property
10577    When the column view in the agenda shows the =CLOCKSUM_T= property,
10578    that is always today's clocked time for this item.  So even in the
10579    weekly agenda, the clocksum listed in column view only originates
10580    from today.  This lets you compare the time you spent on a task for
10581    today, with the time already spent---via =CLOCKSUM=---and with
10582    the planned total effort for it.
10584 * Markup for Rich Export
10585 :PROPERTIES:
10586 :DESCRIPTION: Prepare text for rich export.
10587 :ALT_TITLE: Markup
10588 :END:
10590 When exporting Org documents, the exporter tries to reflect the
10591 structure of the document as accurately as possible in the back-end.
10592 Since export targets like HTML and LaTeX allow much richer formatting,
10593 Org mode has rules on how to prepare text for rich export.  This
10594 section summarizes the markup rules used in an Org mode buffer.
10596 ** Paragraphs
10597 :PROPERTIES:
10598 :DESCRIPTION: The basic unit of text.
10599 :END:
10600 #+cindex: paragraphs, markup rules
10602 Paragraphs are separated by at least one empty line.  If you need to
10603 enforce a line break within a paragraph, use ~\\~ at the end of
10604 a line.
10606 To preserve the line breaks, indentation and blank lines in a region,
10607 but otherwise use normal formatting, you can use this construct, which
10608 can also be used to format poetry.
10610 #+cindex: BEGIN_VERSE
10611 #+cindex: verse blocks
10612 #+begin_example
10613   ,#+BEGIN_VERSE
10614    Great clouds overhead
10615    Tiny black birds rise and fall
10616    Snow covers Emacs
10618       ---AlexSchroeder
10619   ,#+END_VERSE
10620 #+end_example
10622 When quoting a passage from another document, it is customary to
10623 format this as a paragraph that is indented on both the left and the
10624 right margin.  You can include quotations in Org documents like this:
10626 #+cindex: BEGIN_QUOTE
10627 #+cindex: quote blocks
10628 #+begin_example
10629   ,#+BEGIN_QUOTE
10630   Everything should be made as simple as possible,
10631   but not any simpler ---Albert Einstein
10632   ,#+END_QUOTE
10633 #+end_example
10635 If you would like to center some text, do it like this:
10637 #+cindex: BEGIN_CENTER
10638 #+cindex: center blocks
10639 #+begin_example
10640   ,#+BEGIN_CENTER
10641   Everything should be made as simple as possible, \\
10642   but not any simpler
10643   ,#+END_CENTER
10644 #+end_example
10646 ** Emphasis and Monospace
10647 :PROPERTIES:
10648 :DESCRIPTION: Bold, italic, etc.
10649 :END:
10650 #+cindex: underlined text, markup rules
10651 #+cindex: bold text, markup rules
10652 #+cindex: italic text, markup rules
10653 #+cindex: verbatim text, markup rules
10654 #+cindex: code text, markup rules
10655 #+cindex: strike-through text, markup rules
10657 You can make words =*bold*=, =/italic/=, =_underlined_=, ==verbatim==
10658 and =~code~=, and, if you must, =+strike-through+=.  Text in the code
10659 and verbatim string is not processed for Org mode specific syntax; it
10660 is exported verbatim.
10662 #+vindex: org-fontify-emphasized-text
10663 To turn off fontification for marked up text, you can set
10664 ~org-fontify-emphasized-text~ to ~nil~.  To narrow down the list of
10665 available markup syntax, you can customize ~org-emphasis-alist~.
10667 ** Horizontal Rules
10668 :PROPERTIES:
10669 :DESCRIPTION: Make a line.
10670 :END:
10671 #+cindex: horizontal rules, markup rules
10673 A line consisting of only dashes, and at least 5 of them, is exported
10674 as a horizontal line.
10676 ** Images and Tables
10677 :PROPERTIES:
10678 :DESCRIPTION: Images, tables and caption mechanism.
10679 :END:
10680 #+cindex: tables, markup rules
10681 #+cindex: CAPTION, keyword
10682 #+cindex: NAME, keyword
10684 Both the native Org mode tables (see [[*Tables]]) and tables formatted
10685 with the =table.el= package are exported properly.  For Org mode
10686 tables, the lines before the first horizontal separator line become
10687 table header lines.  You can use the following lines somewhere before
10688 the table to assign a caption and a label for cross references, and in
10689 the text you can refer to the object with =[[tab:basic-data]]= (see
10690 [[*Internal Links]]):
10692 #+begin_example
10693   ,#+CAPTION: This is the caption for the next table (or link)
10694   ,#+NAME:   tab:basic-data
10695   | ... | ... |
10696   |-----+-----|
10697 #+end_example
10699 Optionally, the caption can take the form:
10701 : #+CAPTION[Caption for list of tables]: Caption for table.
10703 #+cindex: inlined images, markup rules
10704 Some back-ends allow you to directly include images into the exported
10705 document.  Org does this, if a link to an image file does not have
10706 a description part, for example =[[./img/a.jpg]]=.  If you wish to define
10707 a caption for the image and maybe a label for internal cross
10708 references, make sure that the link is on a line by itself and precede
10709 it with =CAPTION= and =NAME= keywords as follows:
10711 #+begin_example
10712   ,#+CAPTION: This is the caption for the next figure link (or table)
10713   ,#+NAME:   fig:SED-HR4049
10714   [[./img/a.jpg]]
10715 #+end_example
10717 #+texinfo: @noindent
10718 Such images can be displayed within the buffer.  See [[*Handling Links][the discussion of
10719 image links]].
10721 Even though images and tables are prominent examples of captioned
10722 structures, the same caption mechanism can apply to many
10723 others---e.g., LaTeX equations, source code blocks.  Depending on the
10724 export back-end, those may or may not be handled.
10726 ** Literal Examples
10727 :PROPERTIES:
10728 :DESCRIPTION: Source code examples with special formatting.
10729 :END:
10730 #+cindex: literal examples, markup
10731 #+cindex: code line references, markup
10733 You can include literal examples that should not be subjected to
10734 markup.  Such examples are typeset in monospace, so this is well
10735 suited for source code and similar examples.
10737 #+cindex: BEGIN_EXAMPLE
10738 #+cindex: example block
10739 #+begin_example
10740   ,#+BEGIN_EXAMPLE
10741     Some example from a text file.
10742   ,#+END_EXAMPLE
10743 #+end_example
10745 Note that such blocks may be /indented/ in order to align nicely with
10746 indented text and in particular with plain list structure (see
10747 [[*Plain Lists]]).  For simplicity when using small examples, you can
10748 also start the example lines with a colon followed by a space.  There
10749 may also be additional whitespace before the colon:
10751 #+begin_example
10752   Here is an example
10753      : Some example from a text file.
10754 #+end_example
10756 #+cindex: formatting source code, markup rules
10757 #+vindex: org-latex-listings
10758 If the example is source code from a programming language, or any
10759 other text that can be marked up by Font Lock in Emacs, you can ask
10760 for the example to look like the fontified Emacs buffer[fn:104].  This
10761 is done with the code block, where you also need to specify the name
10762 of the major mode that should be used to fontify the example[fn:105],
10763 see [[*Structure Templates]] for shortcuts to easily insert code blocks.
10765 #+cindex: BEGIN_SRC
10766 #+cindex: src block
10767 #+begin_example
10768   ,#+BEGIN_SRC emacs-lisp
10769     (defun org-xor (a b)
10770       "Exclusive or."
10771       (if a (not b) b))
10772    ,#+END_SRC
10773 #+end_example
10775 Both in =example= and in =src= snippets, you can add a =-n= switch to
10776 the end of the =#+BEGIN= line, to get the lines of the example
10777 numbered.  The =-n= takes an optional numeric argument specifying the
10778 starting line number of the block.  If you use a =+n= switch, the
10779 numbering from the previous numbered snippet is continued in the
10780 current one.  The =+n= switch can also take a numeric argument.  This
10781 adds the value of the argument to the last line of the previous block
10782 to determine the starting line number.
10784 #+begin_example
10785   ,#+BEGIN_SRC emacs-lisp -n 20
10786     ;; This exports with line number 20.
10787     (message "This is line 21")
10788   ,#+END_SRC
10790   ,#+BEGIN_SRC emacs-lisp +n 10
10791     ;; This is listed as line 31.
10792     (message "This is line 32")
10793   ,#+END_SRC
10794 #+end_example
10796 In literal examples, Org interprets strings like =(ref:name)= as
10797 labels, and use them as targets for special hyperlinks like
10798 =[[(name)]]=---i.e., the reference name enclosed in single parenthesis.
10799 In HTML, hovering the mouse over such a link remote-highlights the
10800 corresponding code line, which is kind of cool.
10802 You can also add a =-r= switch which /removes/ the labels from the
10803 source code[fn:106].  With the =-n= switch, links to these references
10804 are labeled by the line numbers from the code listing.  Otherwise
10805 links use the labels with no parentheses.  Here is an example:
10807 #+begin_example -l "(dumb-reference:%s)"
10808   ,#+BEGIN_SRC emacs-lisp -n -r
10809     (save-excursion                 (ref:sc)
10810        (goto-char (point-min))      (ref:jump)
10811   ,#+END_SRC
10812   In line [[(sc)]] we remember the current position. [[(jump)][Line (jump)]]
10813   jumps to point-min.
10814 #+end_example
10816 #+cindex: indentation, in source blocks
10817 Finally, you can use =-i= to preserve the indentation of a specific
10818 code block (see [[*Editing Source Code]]).
10820 #+vindex: org-coderef-label-format
10821 If the syntax for the label format conflicts with the language syntax,
10822 use a =-l= switch to change the format, for example
10824 : #+BEGIN_SRC pascal -n -r -l "((%s))"
10826 #+texinfo: @noindent
10827 See also the variable ~org-coderef-label-format~.
10829 HTML export also allows examples to be published as text areas (see
10830 [[*Text areas in HTML export]]).
10832 Because the =#+BEGIN= ... =#+END= patterns need to be added so often,
10833 a shortcut is provided (see [[*Structure Templates]]).
10835 - {{{kbd(C-c ')}}} (~org-edit-special~) ::
10837      #+kindex: C-c '
10838      #+findex: org-edit-special
10839      Edit the source code example at point in its native mode.  This
10840      works by switching to a temporary buffer with the source code.
10841      You need to exit by pressing {{{kbd(C-c ')}}} again[fn:107].  The
10842      edited version then replaces the old version in the Org buffer.
10843      Fixed-width regions---where each line starts with a colon
10844      followed by a space---are edited using ~artist-mode~[fn:108] to
10845      allow creating ASCII drawings easily.  Using this command in an
10846      empty line creates a new fixed-width region.
10848 - {{{kbd(C-c l)}}} (~org-store-link~) ::
10850      #+kindex: C-c l
10851      #+findex: org-store-link
10852      Calling ~org-store-link~ while editing a source code example in
10853      a temporary buffer created with {{{kbd(C-c ')}}} prompts for
10854      a label.  Make sure that it is unique in the current buffer, and
10855      insert it with the proper formatting like =(ref:label)= at the
10856      end of the current line.  Then the label is stored as a link
10857      =(label)=, for retrieval with {{{kbd(C-c C-l)}}}.
10859 ** Special Symbols
10860 :PROPERTIES:
10861 :DESCRIPTION: Greek letters and other symbols.
10862 :END:
10863 #+cindex: math symbols
10864 #+cindex: special symbols
10865 #+cindex: @TeX{} macros
10866 #+cindex: @LaTeX{} fragments, markup rules
10867 #+cindex: HTML entities
10868 #+cindex: @LaTeX{} entities
10870 You can use LaTeX-like syntax to insert special symbols---named
10871 entities---like =\alpha= to indicate the Greek letter, or =\to= to indicate
10872 an arrow.  Completion for these symbols is available, just type =\=
10873 and maybe a few letters, and press {{{kbd(M-TAB)}}} to see possible
10874 completions.  If you need such a symbol inside a word, terminate it
10875 with a pair of curly brackets.  For example
10877 #+begin_example
10878   Pro tip: Given a circle \Gamma of diameter d, the length of its
10879   circumference is \pi{}d.
10880 #+end_example
10882 #+findex: org-entities-help
10883 #+vindex: org-entities-user
10884 A large number of entities is provided, with names taken from both
10885 HTML and LaTeX; you can comfortably browse the complete list from
10886 a dedicated buffer using the command ~org-entities-help~.  It is also
10887 possible to provide your own special symbols in the variable
10888 ~org-entities-user~.
10890 During export, these symbols are transformed into the native format of
10891 the exporter back-end.  Strings like =\alpha= are exported as =&alpha;= in
10892 the HTML output, and as =\(\alpha\)= in the LaTeX output.  Similarly, =\nbsp=
10893 becomes =&nbsp;= in HTML and =~= in LaTeX.
10895 #+cindex: escaping characters
10896 Entities may also be used as a way to escape markup in an Org
10897 document, e.g., =\under{}not underlined\under= exports as =_not underlined_=.
10899 #+cindex: special symbols, in-buffer display
10900 If you would like to see entities displayed as UTF-8 characters, use
10901 the following command[fn:109]:
10903 - {{{kbd(C-c C-x \)}}} (~org-toggle-pretty-entities~) ::
10904      #+kindex: C-c C-x \
10905      #+findex: org-toggle-pretty-entities
10907      Toggle display of entities as UTF-8 characters.  This does not
10908      change the buffer content which remains plain ASCII, but it
10909      overlays the UTF-8 character for display purposes only.
10911 #+cindex: shy hyphen, special symbol
10912 #+cindex: dash, special symbol
10913 #+cindex: ellipsis, special symbol
10914 In addition to regular entities defined above, Org exports in
10915 a special way[fn:110] the following commonly used character
10916 combinations: =\-= is treated as a shy hyphen, =--= and =---= are
10917 converted into dashes, and =...= becomes a compact set of dots.
10919 ** Subscripts and Superscripts
10920 :PROPERTIES:
10921 :DESCRIPTION: Simple syntax for raising/lowering text.
10922 :END:
10923 #+cindex: subscript
10924 #+cindex: superscript
10926 =^= and =_= are used to indicate super- and subscripts.  To increase
10927 the readability of ASCII text, it is not necessary, but OK, to
10928 surround multi-character sub- and superscripts with curly braces.  For
10929 example
10931 #+begin_example
10932   The radius of the sun is R_sun = 6.96 x 10^8 m.  On the other hand,
10933   the radius of Alpha Centauri is R_{Alpha Centauri} = 1.28 x R_{sun}.
10934 #+end_example
10936 #+vindex: org-use-sub-superscripts
10937 If you write a text where the underscore is often used in a different
10938 context, Org's convention to always interpret these as subscripts can
10939 get in your way.  Configure the variable ~org-use-sub-superscripts~ to
10940 change this convention.  For example, when setting this variable to
10941 ~{}~, =a_b= is not interpreted as a subscript, but =a_{b}= is.
10943 - {{{kbd(C-c C-x \)}}} (~org-toggle-pretty-entities~~) ::
10944      #+kindex: C-c C-x \
10945      #+findex: org-toggle-pretty-entities
10947      In addition to showing entities as UTF-8 characters, this command
10948      also formats sub- and superscripts in a WYSIWYM way.
10950 ** Embedded LaTeX
10951 :PROPERTIES:
10952 :DESCRIPTION: LaTeX can be freely used inside Org documents.
10953 :END:
10954 #+cindex: @TeX{} interpretation
10955 #+cindex: @LaTeX{} interpretation
10957 Plain ASCII is normally sufficient for almost all note taking.
10958 Exceptions include scientific notes, which often require mathematical
10959 symbols and the occasional formula.  LaTeX[fn:111] is widely used to
10960 typeset scientific documents.  Org mode supports embedding LaTeX code
10961 into its files, because many academics are used to writing and reading
10962 LaTeX source code, and because it can be readily processed to produce
10963 pretty output for a number of export back-ends.
10965 *** LaTeX fragments
10966 :PROPERTIES:
10967 :DESCRIPTION: Complex formulas made easy.
10968 :END:
10969 #+cindex: @LaTeX{} fragments
10971 #+vindex: org-format-latex-header
10972 Org mode can contain LaTeX math fragments, and it supports ways to
10973 process these for several export back-ends.  When exporting to LaTeX,
10974 the code is left as it is.  When exporting to HTML, Org can use either
10975 [[http://www.mathjax.org][MathJax]] (see [[*Math formatting in HTML export]]) or transcode the math
10976 into images (see [[*Previewing LaTeX fragments]]).
10978 LaTeX fragments do not need any special marking at all.  The following
10979 snippets are identified as LaTeX source code:
10981 - Environments of any kind[fn:112].  The only requirement is that the
10982   =\begin= statement appears on a new line, preceded by only
10983   whitespace.
10985 - Text within the usual LaTeX math delimiters.  To avoid conflicts
10986   with currency specifications, single =$= characters are only
10987   recognized as math delimiters if the enclosed text contains at most
10988   two line breaks, is directly attached to the =$= characters with no
10989   whitespace in between, and if the closing =$= is followed by
10990   whitespace, punctuation or a dash.  For the other delimiters, there
10991   is no such restriction, so when in doubt, use =\(...\)= as inline
10992   math delimiters.
10994 #+texinfo: @noindent
10995 For example:
10997 #+begin_example
10998   \begin{equation}                        % arbitrary environments,
10999   x=\sqrt{b}                              % even tables, figures
11000   \end{equation}                          % etc
11002   If $a^2=b$ and \( b=2 \), then the solution must be
11003   either $$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \].
11004 #+end_example
11006 #+vindex: org-export-with-latex
11007 LaTeX processing can be configured with the variable
11008 ~org-export-with-latex~.  The default setting is ~t~ which means
11009 MathJax for HTML, and no processing for ASCII and LaTeX back-ends.
11010 You can also set this variable on a per-file basis using one of these
11011 lines:
11013 | =#+OPTIONS: tex:t=        | Do the right thing automatically (MathJax) |
11014 | =#+OPTIONS: tex:nil=      | Do not process LaTeX fragments at all      |
11015 | =#+OPTIONS: tex:verbatim= | Verbatim export, for jsMath or so          |
11017 *** Previewing LaTeX fragments
11018 :PROPERTIES:
11019 :DESCRIPTION: What will this snippet look like?
11020 :END:
11021 #+cindex: @LaTeX{} fragments, preview
11023 #+vindex: org-preview-latex-default-process
11024 If you have a working LaTeX installation and =dvipng=, =dvisvgm= or
11025 =convert= installed[fn:113], LaTeX fragments can be processed to
11026 produce images of the typeset expressions to be used for inclusion
11027 while exporting to HTML (see [[*LaTeX fragments]]), or for inline
11028 previewing within Org mode.
11030 #+vindex: org-format-latex-options
11031 #+vindex: org-format-latex-header
11032 You can customize the variables ~org-format-latex-options~ and
11033 ~org-format-latex-header~ to influence some aspects of the preview.
11034 In particular, the ~:scale~ (and for HTML export, ~:html-scale~)
11035 property of the former can be used to adjust the size of the preview
11036 images.
11038 - {{{kbd(C-c C-x C-l)}}} (~org-toggle-latex-fragment~) ::
11039      #+kindex: C-c C-x C-l
11040      #+findex: org-toggle-latex-fragment
11042      Produce a preview image of the LaTeX fragment at point and
11043      overlay it over the source code.  If there is no fragment at
11044      point, process all fragments in the current entry (between two
11045      headlines).  When called with a prefix argument, process the
11046      entire subtree.  When called with two prefix arguments, or when
11047      the cursor is before the first headline, process the entire
11048      buffer.
11050 #+vindex: org-startup-with-latex-preview
11051 You can turn on the previewing of all LaTeX fragments in a file with
11053 : #+STARTUP: latexpreview
11055 To disable it, simply use
11057 : #+STARTUP: nolatexpreview
11059 *** Using CDLaTeX to enter math
11060 :PROPERTIES:
11061 :DESCRIPTION: Speed up entering of formulas.
11062 :ALT_TITLE: CDLaTeX mode
11063 :END:
11064 #+cindex: CD@LaTeX{}
11066 CDLaTeX mode is a minor mode that is normally used in combination with
11067 a major LaTeX mode like AUCTeX in order to speed-up insertion of
11068 environments and math templates.  Inside Org mode, you can make use of
11069 some of the features of CDLaTeX mode.  You need to install
11070 =cdlatex.el= and =texmathp.el= (the latter comes also with AUCTeX)
11071 from [[http://www.astro.uva.nl/~dominik/Tools/cdlatex]].  Do not use
11072 CDLaTeX mode itself under Org mode, but use the light version
11073 ~org-cdlatex-mode~ that comes as part of Org mode.  Turn it on for the
11074 current buffer with {{{kbd(M-x org-cdlatex-mode)}}}, or for all Org
11075 files with
11077 #+begin_src emacs-lisp
11078   (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
11079 #+end_src
11081 When this mode is enabled, the following features are present (for
11082 more details see the documentation of CDLaTeX mode):
11084 #+attr_texinfo: :sep ,
11085 - {{{kbd(C-c {)}}} ::
11086      #+kindex: C-c @{
11088      Insert an environment template.
11090 - {{{kbd(TAB)}}} ::
11091      #+kindex: TAB
11093      The {{{kbd(TAB)}}} expands the template if the cursor is inside
11094      a LaTeX fragment[fn:114].  For example, {{{kbd(TAB)}}} expands
11095      =fr= to =\frac{}{}= and position the cursor correctly inside the
11096      first brace.  Another {{{kbd(TAB)}}} gets you into the second
11097      brace.
11099      Even outside fragments, {{{kbd(TAB)}}} expands environment
11100      abbreviations at the beginning of a line.  For example, if you
11101      write =equ= at the beginning of a line and press {{{kbd(TAB)}}},
11102      this abbreviation is expanded to an =equation= environment.  To
11103      get a list of all abbreviations, type {{{kbd(M-x
11104      cdlatex-command-help)}}}.
11106 - {{{kbd(^)}}}, {{{kbd(_)}}} ::
11107      #+kindex: _
11108      #+kindex: ^
11109      #+vindex: cdlatex-simplify-sub-super-scripts
11111      Pressing {{{kbd(_)}}} and {{{kbd(^)}}} inside a LaTeX fragment
11112      inserts these characters together with a pair of braces.  If you
11113      use {{{kbd(TAB)}}} to move out of the braces, and if the braces
11114      surround only a single character or macro, they are removed again
11115      (depending on the variable ~cdlatex-simplify-sub-super-scripts~).
11117 - {{{kbd(`)}}} ::
11118      #+kindex: `
11120      Pressing the backquote followed by a character inserts math
11121      macros, also outside LaTeX fragments.  If you wait more than 1.5
11122      seconds after the backquote, a help window pops up.
11124 - {{{kbd(')}}} ::
11125      #+kindex: '
11127      Pressing the single-quote followed by another character modifies
11128      the symbol before point with an accent or a font.  If you wait
11129      more than 1.5 seconds after the single-quote, a help window pops
11130      up.  Character modification works only inside LaTeX fragments;
11131      outside the quote is normal.
11133 * Exporting
11134 :PROPERTIES:
11135 :DESCRIPTION: Sharing and publishing notes.
11136 :END:
11137 #+cindex: exporting
11139 Sometimes, you may want to pretty print your notes, publish them on
11140 the web or even share them with people not using Org.  In these cases,
11141 the Org export facilities can be used to convert your documents to
11142 a variety of other formats, while retaining as much structure (see
11143 [[*Document Structure]]) and markup (see [[*Markup for Rich Export]]) as
11144 possible.
11146 #+cindex: export back-end
11147 Libraries responsible for such translation are called back-ends.  Org
11148 ships with the following ones
11150 - /ascii/ (ASCII format)
11151 - /beamer/ (LaTeX Beamer format)
11152 - /html/ (HTML format)
11153 - /icalendar/ (iCalendar format)
11154 - /latex/ (LaTeX format)
11155 - /md/ (Markdown format)
11156 - /odt/ (OpenDocument Text format)
11157 - /org/ (Org format)
11158 - /texinfo/ (Texinfo format)
11159 - /man/ (Man page format)
11161 #+texinfo: @noindent
11162 Org also uses additional libraries located in =contrib/= directory
11163 (see [[*Installation]]).  Users can install additional export libraries
11164 for additional formats from the Emacs packaging system.  For easy
11165 discovery, these packages have a common naming scheme: ~ox-NAME~,
11166 where {{{var(NAME)}}} is one of the formats.  For example,
11167 ~ox-koma-letter~ /koma-letter/ back-end.
11169 #+vindex: org-export-backends
11170 Org loads back-ends for the following formats by default: ASCII, HTML,
11171 iCalendar, LaTeX and ODT.  Org can load additional back-ends either of
11172 two ways: through the ~org-export-backends~ variable configuration;
11173 or, by requiring the library in the Emacs init file like this:
11175 #+begin_src emacs-lisp
11176   (require 'ox-md)
11177 #+end_src
11179 ** The Export Dispatcher
11180 :PROPERTIES:
11181 :DESCRIPTION: The main interface.
11182 :END:
11183 #+cindex: dispatcher, for export commands
11184 #+cindex: Export, dispatcher
11186 The export dispatcher is the main interface for Org's exports.
11187 A hierarchical menu presents the currently configured export formats.
11188 Options are shown as easy toggle switches on the same screen.
11190 #+vindex: org-export-dispatch-use-expert-ui
11191 Org also has a minimal prompt interface for the export dispatcher.
11192 When the variable ~org-export-dispatch-use-expert-ui~ is set to
11193 a non-~nil~ value, Org prompts in the minibuffer.  To switch back to
11194 the hierarchical menu, press {{{kbd(?)}}}.
11196 - {{{kbd(C-c C-e)}}} (~org-export~) ::
11197      #+kindex: C-c C-e
11198      #+findex: org-export
11200      Invokes the export dispatcher interface.  The options show
11201      default settings.  The {{{kbd(C-u)}}} prefix argument preserves
11202      options from the previous export, including any sub-tree
11203      selections.
11205 Org exports the entire buffer by default.  If the Org buffer has an
11206 active region, then Org exports just that region.
11208 Within the dispatcher interface, the following key combinations can
11209 further alter what is exported, and how.
11211 - {{{kbd(C-a)}}} ::
11212      #+kindex: C-c C-e C-a
11214      Toggle asynchronous export.  Asynchronous export uses an external
11215      Emacs process with a specially configured initialization file to
11216      complete the exporting process in the background thereby
11217      releasing the current interface.  This is particularly useful
11218      when exporting long documents.
11220      Output from an asynchronous export is saved on the "the export
11221      stack".  To view this stack, call the export dispatcher with
11222      a double {{{kbd(C-u)}}} prefix argument.  If already in the
11223      export dispatcher menu, {{{kbd(&)}}} displays the stack.
11225      #+vindex: org-export-async-init-file
11226      To make the background export process the default, customize the
11227      variable, ~org-export-in-background~.  Additionally, you can set
11228      the initialization file used by the background process with
11229      ~org-export-async-init-file~.
11231      #+vindex: org-export-in-background
11232      You can make asynchronous export the default by setting
11233      ~org-export-in-background~.
11235 - {{{kbd(C-b)}}} ::
11236      #+kindex: C-c C-e C-b
11238      Toggle body-only export.  Useful for excluding headers and
11239      footers in the export.  Affects only those back-end formats that
11240      have such sections---like =<head>...</head>= in HTML.
11242 - {{{kbd(C-s}}} ::
11243      #+kindex: C-c C-e C-s
11245      Toggle sub-tree export.  When turned on, Org exports only the
11246      sub-tree starting from the cursor position at the time the export
11247      dispatcher was invoked.  Org uses the top heading of this
11248      sub-tree as the document's title.  If the cursor is not on
11249      a heading, Org uses the nearest enclosing header.  If the cursor
11250      is in the document preamble, Org signals an error and aborts
11251      export.
11253      #+vindex: org-export-initial-scope
11254      To make the sub-tree export the default, customize the variable
11255      ~org-export-initial-scope~.
11257 - {{{kbd(C-v)}}} ::
11258      #+kindex: C-c C-e C-v
11260      Toggle visible-only export.  Useful for exporting only visible
11261      parts of an Org document by adjusting outline visibility
11262      settings.
11264 ** Export Settings
11265 :PROPERTIES:
11266 :DESCRIPTION: Common export settings.
11267 :END:
11268 #+cindex: options, for export
11269 #+cindex: Export, settings
11271 #+cindex: OPTIONS, keyword
11272 Export options can be set: globally with variables; for an individual
11273 file by making variables buffer-local with in-buffer settings (see
11274 [[*Summary of In-Buffer Settings]]), by setting individual keywords, or by
11275 specifying them in a compact form with the =OPTIONS= keyword; or for
11276 a tree by setting properties (see [[*Properties and Columns]]).  Options
11277 set at a specific level override options set at a more general level.
11279 #+cindex: SETUPFILE, keyword
11280 In-buffer settings may appear anywhere in the file, either directly or
11281 indirectly through a file included using =#+SETUPFILE: filename or
11282 URL= syntax.  Option keyword sets tailored to a particular back-end
11283 can be inserted from the export dispatcher (see [[*The Export
11284 Dispatcher]]) using the =Insert template= command by pressing
11285 {{{kbd(#)}}}.  To insert keywords individually, a good way to make
11286 sure the keyword is correct is to type =#+= and then to use
11287 {{{kbd(M-TAB)}}}[fn:16] for completion.
11289 The export keywords available for every back-end, and their equivalent
11290 global variables, include:
11292 - =AUTHOR= ::
11294      #+cindex: AUTHOR, keyword
11295      #+vindex: user-full-name
11296      The document author (~user-full-name~).
11298 - =CREATOR= ::
11300      #+cindex: CREATOR, keyword
11301      #+vindex: org-expot-creator-string
11302      Entity responsible for output generation
11303      (~org-export-creator-string~).
11305 - =DATE= ::
11307      #+cindex: DATE, keyword
11308      #+vindex: org-export-date-timestamp-format
11309      A date or a time-stamp[fn:115].
11311 - =EMAIL= ::
11313      #+cindex: EMAIL, keyword
11314      #+vindex: user-mail-address
11315      The email address (~user-mail-address~).
11317 - =LANGUAGE= ::
11319      #+cindex: LANGUAGE, keyword
11320      #+vindex: org-export-default-language
11321      Language to use for translating certain strings
11322      (~org-export-default-language~).  With =#+LANGUAGE: fr=, for
11323      example, Org translates =Table of contents= to the French =Table
11324      des matières=.
11326 - =SELECT_TAGS= ::
11328      #+cindex: SELECT_TAGS, keyword
11329      #+vindex: org-export-select-tags
11330      The default value is ~("export")~.  When a tree is tagged with
11331      =export= (~org-export-select-tags~), Org selects that tree and
11332      its sub-trees for export.  Org excludes trees with =noexport=
11333      tags, see below.  When selectively exporting files with =export=
11334      tags set, Org does not export any text that appears before the
11335      first headline.
11337 - =EXCLUDE_TAGS= ::
11339      #+cindex: EXCLUDE_TAGS, keyword
11340      #+vindex: org-export-exclude-tags
11341      The default value is ~("noexport")~.  When a tree is tagged with
11342      =noexport= (~org-export-exclude-tags~), Org excludes that tree
11343      and its sub-trees from export.  Entries tagged with =noexport=
11344      are unconditionally excluded from the export, even if they have
11345      an =export= tag.  Even if a sub-tree is not exported, Org
11346      executes any code blocks contained there.
11348 - =TITLE= ::
11350      #+cindex: TITLE, keyword
11351      #+cindex: document title
11352      Org displays this title.  For long titles, use multiple =#+TITLE=
11353      lines.
11355 - =EXPORT_FILE_NAME= ::
11357      #+cindex: EXPORT_FILE_NAME, keyword
11358      The name of the output file to be generated.  Otherwise, Org
11359      generates the file name based on the buffer name and the
11360      extension based on the back-end format.
11362 The =OPTIONS= keyword is a compact form.  To configure multiple
11363 options, use several =OPTIONS= lines.  =OPTIONS= recognizes the
11364 following arguments.
11366 - ~'~ ::
11368      #+vindex: org-export-with-smart-quotes
11369      Toggle smart quotes (~org-export-with-smart-quotes~).  Depending
11370      on the language used, when activated, Org treats pairs of double
11371      quotes as primary quotes, pairs of single quotes as secondary
11372      quotes, and single quote marks as apostrophes.
11374 - ~*~ ::
11376      #+vindex: org-export-with-emphasize
11377      Toggle emphasized text (~org-export-with-emphasize~).
11379 - ~-~ ::
11381      #+vindex: org-export-with-special-strings
11382      Toggle conversion of special strings
11383      (~org-export-with-special-strings~).
11385 - ~:~ ::
11387      #+vindex: org-export-with-fixed-width
11388      Toggle fixed-width sections (~org-export-with-fixed-width~).
11390 - ~<~ ::
11392      #+vindex: org-export-with-timestamps
11393      Toggle inclusion of time/date active/inactive stamps
11394      (~org-export-with-timestamps~).
11396 - ~\n~ ::
11398      #+vindex: org-export-preserve-breaks
11399      Toggles whether to preserve line breaks
11400      (~org-export-preserve-breaks~).
11402 - ~^~ ::
11404      #+vindex: org-export-with-sub-superscripts
11405      Toggle TeX-like syntax for sub- and superscripts.  If you write
11406      =^:{}=, =a_{b}= is interpreted, but the simple =a_b= is left as
11407      it is (~org-export-with-sub-superscripts~).
11409 - ~arch~ ::
11411      #+vindex: org-export-with-archived-trees
11412      Configure how archived trees are exported.  When set to
11413      ~headline~, the export process skips the contents and processes
11414      only the headlines (~org-export-with-archived-trees~).
11416 - ~author~ ::
11418      #+vindex: org-export-with-author
11419      Toggle inclusion of author name into exported file
11420      (~org-export-with-author~).
11422 - ~broken-links~ ::
11424      #+vindex: org-export-with-broken-links
11425      Toggles if Org should continue exporting upon finding a broken
11426      internal link.  When set to ~mark~, Org clearly marks the problem
11427      link in the output (~org-export-with-broken-links~).
11429 - ~c~ ::
11431      #+vindex: org-export-with-clocks
11432      Toggle inclusion of CLOCK keywords (~org-export-with-clocks~).
11434 - ~creator~ ::
11436      #+vindex: org-export-with-creator
11437      Toggle inclusion of creator information in the exported file
11438      (~org-export-with-creator~).
11440 - ~d~ ::
11442      #+vindex: org-export-with-drawers
11443      Toggles inclusion of drawers, or list of drawers to include, or
11444      list of drawers to exclude (~org-export-with-drawers~).
11446 - ~date~ ::
11448      #+vindex: org-export-with-date
11449      Toggle inclusion of a date into exported file
11450      (~org-export-with-date~).
11452 - ~e~ ::
11454      #+vindex: org-export-with-entities
11455      Toggle inclusion of entities (~org-export-with-entities~).
11457 - ~email~ ::
11459      #+vindex: org-export-with-email
11460      Toggle inclusion of the author's e-mail into exported file
11461      (~org-export-with-email~).
11463 - ~f~ ::
11465      #+vindex: org-export-with-footnotes
11466      Toggle the inclusion of footnotes (~org-export-with-footnotes~).
11468 - ~H~ ::
11470      #+vindex: org-export-headline-levels
11471      Set the number of headline levels for export
11472      (~org-export-headline-levels~).  Below that level, headlines are
11473      treated differently.  In most back-ends, they become list items.
11475 - ~inline~ ::
11477      #+vindex: org-export-with-inlinetasks
11478      Toggle inclusion of inlinetasks (~org-export-with-inlinetasks~).
11480 - ~num~ ::
11482      #+vindex: org-export-with-section-numbers
11483      #+cindex: UNNUMBERED, property
11484      Toggle section-numbers (~org-export-with-section-numbers~).  When
11485      set to number N, Org numbers only those headlines at level N or
11486      above.  Set =UNNUMBERED= property to non-~nil~ to disable
11487      numbering of heading and subheadings entirely.  Moreover, when
11488      the value is =notoc= the headline, and all its children, do not
11489      appear in the table of contents either (see [[*Table of Contents]]).
11491 - ~p~ ::
11493      #+vindex: org-export-with-planning
11494      Toggle export of planning information
11495      (~org-export-with-planning~).  "Planning information" comes from
11496      lines located right after the headline and contain any
11497      combination of these cookies: =SCHEDULED=, =DEADLINE=, or
11498      =CLOSED=.
11500 - ~pri~ ::
11502      #+vindex: org-export-with-priority
11503      Toggle inclusion of priority cookies
11504      (~org-export-with-priority~).
11506 - ~prop~ ::
11508      #+vindex: org-export-with-properties
11509      Toggle inclusion of property drawers, or list the properties to
11510      include (~org-export-with-properties~).
11512 - ~stat~ ::
11514      #+vindex: org-export-with-statistics-cookies
11515      Toggle inclusion of statistics cookies
11516      (~org-export-with-statistics-cookies~).
11518 - ~tags~ ::
11520      #+vindex: org-export-with-tags
11521      Toggle inclusion of tags, may also be ~not-in-toc~
11522      (~org-export-with-tags~).
11524 - ~tasks~ ::
11526      #+vindex: org-export-with-tasks
11527      Toggle inclusion of tasks (TODO items); or ~nil~ to remove all
11528      tasks; or ~todo~ to remove DONE tasks; or list the keywords to
11529      keep (~org-export-with-tasks~).
11531 - ~tex~ ::
11533      #+vindex: org-export-with-latex
11534      ~nil~ does not export; ~t~ exports; ~verbatim~ keeps everything
11535      in verbatim (~org-export-with-latex~).
11537 - ~timestamp~ ::
11539      #+vindex: org-export-time-stamp-file
11540      Toggle inclusion of the creation time in the exported file
11541      (~org-export-time-stamp-file~).
11543 - ~title~ ::
11545      #+vindex: org-export-with-title
11546      Toggle inclusion of title (~org-export-with-title~).
11548 - ~toc~ ::
11550      #+vindex: org-export-with-toc
11551      Toggle inclusion of the table of contents, or set the level limit
11552      (~org-export-with-toc~).
11554 - ~todo~ ::
11556      #+vindex: org-export-with-todo-keywords
11557      Toggle inclusion of TODO keywords into exported text
11558      (~org-export-with-todo-keywords~).
11560 - ~|~ ::
11562      #+vindex: org-export-with-tables
11563      Toggle inclusion of tables (~org-export-with-tables~).
11565 When exporting sub-trees, special node properties in them can override
11566 the above keywords.  They are special because they have an =EXPORT_=
11567 prefix.  For example, =DATE= and =EXPORT_FILE_NAME= keywords become,
11568 respectively, =EXPORT_DATE= and =EXPORT_FILE_NAME=.  Except for
11569 =SETUPFILE=, all other keywords listed above have an =EXPORT_=
11570 equivalent.
11572 #+cindex: BIND, keyword
11573 #+vindex: org-export-allow-bind-keywords
11574 If ~org-export-allow-bind-keywords~ is non-~nil~, Emacs variables can
11575 become buffer-local during export by using the =BIND= keyword.  Its
11576 syntax is =#+BIND: variable value=.  This is particularly useful for
11577 in-buffer settings that cannot be changed using keywords.
11579 ** Table of Contents
11580 :PROPERTIES:
11581 :DESCRIPTION: The if and where of the table of contents.
11582 :END:
11583 #+cindex: table of contents
11584 #+cindex: list of tables
11585 #+cindex: list of listings
11587 #+cindex: @samp{toc}, in OPTIONS keyword
11588 #+vindex: org-export-with-toc
11589 The table of contents includes all headlines in the document.  Its
11590 depth is therefore the same as the headline levels in the file.  If
11591 you need to use a different depth, or turn it off entirely, set the
11592 ~org-export-with-toc~ variable accordingly.  You can achieve the same
11593 on a per file basis, using the following =toc= item in =OPTIONS=
11594 keyword:
11596 #+begin_example
11597   ,#+OPTIONS: toc:2          (only include two levels in TOC)
11598   ,#+OPTIONS: toc:nil        (no default TOC at all)
11599 #+end_example
11601 #+cindex: excluding entries from table of contents
11602 #+cindex: table of contents, exclude entries
11603 Org includes both numbered and unnumbered headlines in the table of
11604 contents[fn:116].  If you need to exclude an unnumbered headline,
11605 along with all its children, set the =UNNUMBERED= property to =notoc=
11606 value.
11608 #+begin_example
11609   ,* Subtree not numbered, not in table of contents either
11610     :PROPERTIES:
11611     :UNNUMBERED: notoc
11612     :END:
11613 #+end_example
11615 #+cindex: TOC, keyword
11616 Org normally inserts the table of contents directly before the first
11617 headline of the file.  To move the table of contents to a different
11618 location, first turn off the default with ~org-export-with-toc~
11619 variable or with =#+OPTIONS: toc:nil=.  Then insert =#+TOC: headlines
11620 N= at the desired location(s).
11622 #+begin_example
11623   ,#+OPTIONS: toc:nil
11624   ...
11625   ,#+TOC: headlines 2
11626 #+end_example
11628 To adjust the table of contents depth for a specific section of the
11629 Org document, append an additional =local= parameter.  This parameter
11630 becomes a relative depth for the current level.  The following example
11631 inserts a local table of contents, with direct children only.
11633 #+begin_example
11634   ,* Section
11635   ,#+TOC: headlines 1 local
11636 #+end_example
11638 Note that for this feature to work properly in LaTeX export, the Org
11639 file requires the inclusion of the titletoc package.  Because of
11640 compatibility issues, titletoc has to be loaded /before/ hyperref.
11641 Customize the ~org-latex-default-packages-alist~ variable.
11643 Use the =TOC= keyword to generate list of tables---respectively, all
11644 listings---with captions.
11646 #+begin_example
11647   ,#+TOC: listings
11648   ,#+TOC: tables
11649 #+end_example
11651 #+cindex: ALT_TITLE, property
11652 Normally Org uses the headline for its entry in the table of contents.
11653 But with =ALT_TITLE= property, a different entry can be specified for
11654 the table of contents.
11656 ** Include Files
11657 :PROPERTIES:
11658 :DESCRIPTION: Include additional files into a document.
11659 :END:
11660 #+cindex: include files, during export
11661 #+cindex: Export, include files
11662 #+cindex: INCLUDE, keyword
11664 During export, you can include the content of another file.  For
11665 example, to include your =.emacs= file, you could use:
11667 : #+INCLUDE: "~/.emacs" src emacs-lisp
11669 #+texinfo: @noindent
11670 The optional second and third parameter are the markup (e.g., =quote=,
11671 =example=, or =src=), and, if the markup is =src=, the language for
11672 formatting the contents.  The markup is optional; if it is not given,
11673 assume text is in Org syntax and process it normally.  The =INCLUDE=
11674 keyword also allows additional parameters =:prefix1= and =:prefix= to
11675 specify prefixes for the first line and for each following line,
11676 =:minlevel= in order to get Org mode content demoted to a specified
11677 level, as well as any options accepted by the selected markup.  For
11678 example, to include a file as an item, use:
11680 : #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
11682 You can also include a portion of a file by specifying a lines range
11683 using the =:lines= parameter.  The line at the upper end of the range
11684 is not included.  The start and/or the end of the range may be omitted
11685 to use the obvious defaults.
11687 - =#+INCLUDE: "~/.emacs" :lines "5-10"= ::
11689      Include lines 5 to 10, 10 excluded.
11691 - =#+INCLUDE: "~/.emacs" :lines "-10"=  ::
11693      Include lines 1 to 10, 10 excluded.
11695 - =#+INCLUDE: "~/.emacs" :lines "10-"=  ::
11697      Include lines from 10 to EOF.
11699 You can visit the file being included with the following command.
11701 - {{{kbd(C-c ')}}} (~org-edit~special~) ::
11702      #+kindex: C-c '
11703      #+findex: org-edit-special
11705      Visit the include file at point.
11707 ** Macro Replacement
11708 :PROPERTIES:
11709 :DESCRIPTION: Use macros to create templates.
11710 :END:
11711 #+cindex: macro replacement, during export
11712 #+cindex: MACRO, keyword
11714 #+vindex: org-export-global-macros
11715 Macros replace text snippets during export.  Macros are defined
11716 globally in ~org-export-global-macros~, or document-wise with the
11717 following syntax:
11719 : #+MACRO: name   replacement text; $1, $2 are arguments
11721 #+texinfo: @noindent
11722 which can be referenced using ={{{name(arg1, arg2)}}}=[fn:117].  For
11723 example
11725 #+begin_example
11726   ,#+MACRO: poem The rose is $1, The violet's $2. Life's ordered: Org assists you.
11727   {{{poem(red,blue)}}}
11728 #+end_example
11730 #+texinfo: @noindent
11731 becomes
11733 : The rose is red, The violet's blue. Life's ordered: Org assists you.
11735 As a special case, Org parses any replacement text starting with
11736 =(eval= as an Emacs Lisp expression and evaluates it accordingly.
11737 Within such templates, arguments become strings.  Thus, the following
11738 macro
11740 : #+MACRO: gnucheck (eval (concat "GNU/" (capitalize $1)))
11742 #+texinfo: @noindent
11743 turns ={{{gnucheck(linux)}}}= into =GNU/Linux= during export.
11745 Org recognizes macro references in following Org markup areas:
11746 paragraphs, headlines, verse blocks, tables cells and lists.  Org also
11747 recognizes macro references in keywords, such as =CAPTION=, =TITLE=,
11748 =AUTHOR=, =DATE=, and for some back-end specific export options.
11750 Org comes with following pre-defined macros:
11752 #+attr_texinfo: :sep ;
11753 - ={{{keyword(NAME)}}}=; ={{{title}}}=; ={{{author}}}=; ={{{email}}}= ::
11755      #+cindex: keyword, macro
11756      #+cindex: title, macro
11757      #+cindex: author, macro
11758      #+cindex: email, macro
11759      The =keyword= macro collects all values from {{{var(NAME)}}}
11760      keywords throughout the buffer, separated with white space.
11761      =title=, =author= and =email= macros are shortcuts for,
11762      respectively, ={{{keyword(TITLE)}}}=, ={{{keyword(AUTHOR)}}}= and
11763      ={{{keyword(EMAIL)}}}=.
11765 - ={{{date}}}=; ={{{date(FORMAT)}}}= ::
11767      #+cindex: date, macro
11768      This macro refers to the =DATE= keyword.  {{{var(FORMAT)}}} is an
11769      optional argument to the =date= macro that is used only if =DATE=
11770      is a single timestamp.  {{{var(FORMAT)}}} should be a format
11771      string understood by ~format-time-string~.
11773 - ={{{time(FORMAT)}}}=; ={{{modification-time(FORMAT, VC)}}}= ::
11775      #+cindex: time, macro
11776      #+cindex: modification time, macro
11777      These macros refer to the document's date and time of export and
11778      date and time of modification.  {{{var(FORMAT)}}} is a string
11779      understood by ~format-time-string~.  If the second argument to
11780      the ~modification-time~ macro is non-~nil~, Org uses =vc.el= to
11781      retrieve the document's modification time from the version
11782      control system.  Otherwise Org reads the file attributes.
11784 - ={{{input-file}}}= ::
11786      #+cindex: input file, macro
11787      This macro refers to the filename of the exported file.
11789 - ={{{property(PROPERTY-NAME)}}}=; ={{{property(PROPERTY-NAME, SEARCH OPTION)}}}= ::
11791      #+cindex: property, macro
11792      This macro returns the value of property {{{var(PROPERTY-NAME)}}}
11793      in the current entry.  If {{{var(SEARCH-OPTION)}}} (see [[*Search
11794      Options in File Links]]) refers to a remote entry, use it instead.
11796 - ={{{n}}}=; ={{{n(NAME)}}}=; ={{{n(NAME, ACTION)}}}= ::
11798      #+cindex: n, macro
11799      #+cindex: counter, macro
11800      This macro implements custom counters by returning the number of
11801      times the macro has been expanded so far while exporting the
11802      buffer.  You can create more than one counter using different
11803      {{{var(NAME)}}} values.  If {{{var(ACTION)}}} is =-=, previous
11804      value of the counter is held, i.e., the specified counter is not
11805      incremented.  If the value is a number, the specified counter is
11806      set to that value.  If it is any other non-empty string, the
11807      specified counter is reset to 1.  You may leave {{{var(NAME)}}}
11808      empty to reset the default counter.
11810 #+vindex: org-hide-macro-markers
11811 The surrounding brackets can be made invisible by setting
11812 ~org-hide-macro-markers~ non-~nil~.
11814 Org expands macros at the very beginning of the export process.
11816 ** Comment Lines
11817 :PROPERTIES:
11818 :DESCRIPTION: What will not be exported.
11819 :END:
11820 #+cindex: exporting, not
11822 #+cindex: comment lines
11823 Lines starting with zero or more whitespace characters followed by one
11824 =#= and a whitespace are treated as comments and, as such, are not
11825 exported.
11827 #+cindex: BEGIN_COMMENT
11828 #+cindex: comment block
11829 Likewise, regions surrounded by =#+BEGIN_COMMENT= ... =#+END_COMMENT=
11830 are not exported.
11832 #+cindex: comment trees
11833 Finally, a =COMMENT= keyword at the beginning of an entry, but after
11834 any other keyword or priority cookie, comments out the entire subtree.
11835 In this case, the subtree is not exported and no code block within it
11836 is executed either[fn:118].  The command below helps changing the
11837 comment status of a headline.
11839 - {{{kbd(C-c ;)}}} (~org-toggle-comment~) ::
11840      #+kindex: C-c ;
11841      #+findex: org-toggle-comment
11843      Toggle the =COMMENT= keyword at the beginning of an entry.
11845 ** ASCII/Latin-1/UTF-8 export
11846 :PROPERTIES:
11847 :DESCRIPTION: Exporting to flat files with encoding.
11848 :END:
11849 #+cindex: ASCII export
11850 #+cindex: Latin-1 export
11851 #+cindex: UTF-8 export
11853 ASCII export produces an output file containing only plain ASCII
11854 characters.  This is the simplest and most direct text output.  It
11855 does not contain any Org markup.  Latin-1 and UTF-8 export use
11856 additional characters and symbols available in these encoding
11857 standards.  All three of these export formats offer the most basic of
11858 text output for maximum portability.
11860 #+vindex: org-ascii-text-width
11861 On export, Org fills and justifies text according to the text width
11862 set in ~org-ascii-text-width~.
11864 #+vindex: org-ascii-links-to-notes
11865 Org exports links using a footnote-like style where the descriptive
11866 part is in the text and the link is in a note before the next heading.
11867 See the variable ~org-ascii-links-to-notes~ for details.
11869 *** ASCII export commands
11870 :PROPERTIES:
11871 :UNNUMBERED: notoc
11872 :END:
11874 #+attr_texinfo: :sep ,
11875 - {{{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)}}} ::
11876      #+kindex: C-c C-e t a
11877      #+kindex: C-c C-e t l
11878      #+kindex: C-c C-e t u
11879      #+findex: org-ascii-export-to-ascii
11881      Export as an ASCII file with a =.txt= extension.  For
11882      =myfile.org=, Org exports to =myfile.txt=, overwriting without
11883      warning.  For =myfile.txt=, Org exports to =myfile.txt.txt= in
11884      order to prevent data loss.
11886 #+attr_texinfo: :sep ,
11887 - {{{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)}}} ::
11888      #+kindex: C-c C-e t A
11889      #+kindex: C-c C-e t L
11890      #+kindex: C-c C-e t U
11891      #+findex: org-ascii-export-to-ascii
11893      Export to a temporary buffer.  Does not create a file.
11895 *** ASCII specific export settings
11896 :PROPERTIES:
11897 :UNNUMBERED: notoc
11898 :END:
11900 The ASCII export back-end has one extra keyword for customizing ASCII
11901 output.  Setting this keyword works similar to the general options
11902 (see [[*Export Settings]]).
11904 - =SUBTITLE= ::
11906      #+cindex: SUBTITLE, keyword
11907      The document subtitle.  For long subtitles, use multiple
11908      =#+SUBTITLE= lines in the Org file.  Org prints them on one
11909      continuous line, wrapping into multiple lines if necessary.
11911 *** Header and sectioning structure
11912 :PROPERTIES:
11913 :UNNUMBERED: notoc
11914 :END:
11916 Org converts the first three outline levels into headlines for ASCII
11917 export.  The remaining levels are turned into lists.  To change this
11918 cut-off point where levels become lists, see [[*Export Settings]].
11920 *** Quoting ASCII text
11921 :PROPERTIES:
11922 :UNNUMBERED: notoc
11923 :END:
11925 To insert text within the Org file by the ASCII back-end, use one the
11926 following constructs, inline, keyword, or export block:
11928 #+cindex: ASCII, keyword
11929 #+cindex: BEGIN_EXPORT ascii
11930 #+begin_example
11931   Inline text @@ascii:and additional text@@ within a paragraph.
11933   ,#+ASCII: Some text
11935   ,#+BEGIN_EXPORT ascii
11936   Org exports text in this block only when using ASCII back-end.
11937   ,#+END_EXPORT
11938 #+end_example
11940 *** ASCII specific attributes
11941 :PROPERTIES:
11942 :UNNUMBERED: notoc
11943 :END:
11944 #+cindex: ATTR_ASCII, keyword
11945 #+cindex: horizontal rules, in ASCII export
11947 ASCII back-end recognizes only one attribute, ~:width~, which
11948 specifies the width of an horizontal rule in number of characters.
11949 The keyword and syntax for specifying widths is:
11951 #+begin_example
11952   ,#+ATTR_ASCII: :width 10
11953   -----
11954 #+end_example
11956 *** ASCII special blocks
11957 :PROPERTIES:
11958 :UNNUMBERED: notoc
11959 :END:
11960 #+cindex: special blocks, in ASCII export
11961 #+cindex: BEGIN_JUSTIFYLEFT
11962 #+cindex: BEGIN_JUSTIFYRIGHT
11964 Besides =#+BEGIN_CENTER= blocks (see [[*Paragraphs]]), ASCII back-end has
11965 these two left and right justification blocks:
11967 #+begin_example
11968   ,#+BEGIN_JUSTIFYLEFT
11969   It's just a jump to the left...
11970   ,#+END_JUSTIFYLEFT
11972   ,#+BEGIN_JUSTIFYRIGHT
11973   ...and then a step to the right.
11974   ,#+END_JUSTIFYRIGHT
11975 #+end_example
11977 ** Beamer Export
11978 #+cindex: Beamer export
11980 Org uses Beamer export to convert an Org file tree structure into
11981 high-quality interactive slides for presentations.  Beamer is a LaTeX
11982 document class for creating presentations in PDF, HTML, and other
11983 popular display formats.
11985 *** Beamer export commands
11986 :PROPERTIES:
11987 :DESCRIPTION: For creating Beamer documents.
11988 :END:
11990 - {{{kbd(C-c C-e l b)}}} (~org-beamer-export-to-latex~) ::
11991      #+kindex: C-c C-e l b
11992      #+findex: org-beamer-export-to-latex
11994      Export as LaTeX file with a =.tex= extension.  For =myfile.org=,
11995      Org exports to =myfile.tex=, overwriting without warning.
11997 - {{{kbd(C-c C-e l B)}}} (~org-beamer-export-as-latex~) ::
11998      #+kindex: C-c C-e l B
11999      #+findex: org-beamer-export-as-latex
12001      Export to a temporary buffer.  Does not create a file.
12003 - {{{kbd(C-c C-e l P)}}} (~org-beamer-export-to-pdf~) ::
12004      #+kindex: C-c C-e l P
12005      #+findex: org-beamer-export-to-pdf
12007      Export as LaTeX file and then convert it to PDF format.
12009 - {{{kbd(C-c C-e l O)}}} ::
12010      #+kindex: C-c C-e l O
12012      Export as LaTeX file, convert it to PDF format, and then open the
12013      PDF file.
12015 *** Beamer specific export settings
12016 :PROPERTIES:
12017 :DESCRIPTION: For customizing Beamer export.
12018 :END:
12020 Beamer export back-end has several additional keywords for customizing
12021 Beamer output.  These keywords work similar to the general options
12022 settings (see [[*Export Settings]]).
12024 - =BEAMER_THEME= ::
12026      #+cindex: BEAMER_THEME, keyword
12027      #+vindex: org-beamer-theme
12028      The Beamer layout theme (~org-beamer-theme~).  Use square
12029      brackets for options.  For example:
12031      : #+BEAMER_THEME: Rochester [height=20pt]
12033 - =BEAMER_FONT_THEME= ::
12035      #+cindex: BEAMER_FONT_THEME, keyword
12036      The Beamer font theme.
12038 - =BEAMER_INNER_THEME= ::
12040      #+cindex: BEAMER_INNER_THEME, keyword
12041      The Beamer inner theme.
12043 - =BEAMER_OUTER_THEME= ::
12045      #+cindex: BEAMER_OUTER_THEME, keyword
12046      The Beamer outer theme.
12048 - =BEAMER_HEADER= ::
12050      #+cindex: BEAMER_HEADER, keyword
12051      Arbitrary lines inserted in the preamble, just before the
12052      =hyperref= settings.
12054 - =DESCRIPTION= ::
12056      #+cindex: DESCRIPTION, keyword
12057      The document description.  For long descriptions, use multiple
12058      =DESCRIPTION= keywords.  By default, =hyperref= inserts
12059      =DESCRIPTION= as metadata.  Use ~org-latex-hyperref-template~ to
12060      configure document metadata.  Use ~org-latex-title-command~ to
12061      configure typesetting of description as part of front matter.
12063 - =KEYWORDS= ::
12065      #+cindex: KEYWORDS, keyword
12066      The keywords for defining the contents of the document.  Use
12067      multiple =KEYWORDS= lines if necessary.  By default, =hyperref=
12068      inserts =KEYWORDS= as metadata.  Use
12069      ~org-latex-hyperref-template~ to configure document metadata.
12070      Use ~org-latex-title-command~ to configure typesetting of
12071      keywords as part of front matter.
12073 - =SUBTITLE= ::
12075      #+cindex: SUBTITLE, keyword
12076      Document's subtitle.  For typesetting, use
12077      ~org-beamer-subtitle-format~ string.  Use
12078      ~org-latex-hyperref-template~ to configure document metadata.
12079      Use ~org-latex-title-command~ to configure typesetting of
12080      subtitle as part of front matter.
12082 *** Frames and Blocks in Beamer
12083 :PROPERTIES:
12084 :DESCRIPTION: For composing Beamer slides.
12085 :END:
12087 Org transforms heading levels into Beamer's sectioning elements,
12088 frames and blocks.  Any Org tree with a not-too-deep-level nesting
12089 should in principle be exportable as a Beamer presentation.
12092   #+vindex: org-beamer-frame-level
12093   Org headlines become Beamer frames when the heading level in Org is
12094   equal to ~org-beamer-frame-level~ or =H= value in a =OPTIONS= line
12095   (see [[*Export Settings]]).
12097   #+cindex: BEAMER_ENV, property
12098   Org overrides headlines to frames conversion for the current tree of
12099   an Org file if it encounters the =BEAMER_ENV= property set to
12100   =frame= or =fullframe=.  Org ignores whatever
12101   ~org-beamer-frame-level~ happens to be for that headline level in
12102   the Org tree.  In Beamer terminology, a full frame is a frame
12103   without its title.
12105 - Org exports a Beamer frame's objects as block environments.  Org can
12106   enforce wrapping in special block types when =BEAMER_ENV= property
12107   is set[fn:119].  For valid values see
12108   ~org-beamer-environments-default~.  To add more values, see
12109   ~org-beamer-environments-extra~.
12110   #+vindex: org-beamer-environments-default
12111   #+vindex: org-beamer-environments-extra
12114   #+cindex: BEAMER_REF, property
12115   If =BEAMER_ENV= is set to =appendix=, Org exports the entry as an
12116   appendix.  When set to =note=, Org exports the entry as a note
12117   within the frame or between frames, depending on the entry's heading
12118   level.  When set to =noteNH=, Org exports the entry as a note
12119   without its title.  When set to =againframe=, Org exports the entry
12120   with =\againframe= command, which makes setting the =BEAMER_REF=
12121   property mandatory because =\againframe= needs frame to resume.
12123   When =ignoreheading= is set, Org export ignores the entry's headline
12124   but not its content.  This is useful for inserting content between
12125   frames.  It is also useful for properly closing a =column=
12126   environment.  @end itemize
12128   #+cindex: BEAMER_ACT, property
12129   #+cindex: BEAMER_OPT, property
12130   When =BEAMER_ACT= is set for a headline, Org export translates that
12131   headline as an overlay or action specification.  When enclosed in
12132   square brackets, Org export makes the overlay specification
12133   a default.  Use =BEAMER_OPT= to set any options applicable to the
12134   current Beamer frame or block.  The Beamer export back-end wraps
12135   with appropriate angular or square brackets.  It also adds the
12136   =fragile= option for any code that may require a verbatim block.
12138   #+cindex: BEAMER_COL, property
12139   To create a column on the Beamer slide, use the =BEAMER_COL=
12140   property for its headline in the Org file.  Set the value of
12141   =BEAMER_COL= to a decimal number representing the fraction of the
12142   total text width.  Beamer export uses this value to set the column's
12143   width and fills the column with the contents of the Org entry.  If
12144   the Org entry has no specific environment defined, Beamer export
12145   ignores the heading.  If the Org entry has a defined environment,
12146   Beamer export uses the heading as title.  Behind the scenes, Beamer
12147   export automatically handles LaTeX column separations for contiguous
12148   headlines.  To manually adjust them for any unique configurations
12149   needs, use the =BEAMER_ENV= property.
12151 *** Beamer specific syntax
12152 :PROPERTIES:
12153 :DESCRIPTION: For using in Org documents.
12154 :END:
12156 Since Org's Beamer export back-end is an extension of the LaTeX
12157 back-end, it recognizes other LaTeX specific syntax---for example,
12158 =#+LATEX:= or =#+ATTR_LATEX:=.  See [[*LaTeX Export]], for details.
12160 Beamer export wraps the table of contents generated with =toc:t=
12161 =OPTION= keyword in a =frame= environment.  Beamer export does not
12162 wrap the table of contents generated with =TOC= keyword (see [[*Table of
12163 Contents]]).  Use square brackets for specifying options.
12165 : #+TOC: headlines [currentsection]
12167 Insert Beamer-specific code using the following constructs:
12169 #+cindex: BEAMER, keyword
12170 #+cindex: BEGIN_EXPORT beamer
12171 #+begin_example
12172   ,#+BEAMER: \pause
12174   ,#+BEGIN_EXPORT beamer
12175     Only Beamer export back-end exports this.
12176   ,#+END_BEAMER
12178   Text @@beamer:some code@@ within a paragraph.
12179 #+end_example
12181 Inline constructs, such as the last one above, are useful for adding
12182 overlay specifications to objects with ~bold~, ~item~, ~link~,
12183 ~radio-target~ and ~target~ types.  Enclose the value in angular
12184 brackets and place the specification at the beginning of the object as
12185 shown in this example:
12187 :  A *@@beamer:<2->@@useful* feature
12189 #+cindex: ATTR_BEAMER, keyword
12190 Beamer export recognizes the =ATTR_BEAMER= keyword with the following
12191 attributes from Beamer configurations: =:environment= for changing
12192 local Beamer environment, =:overlay= for specifying Beamer overlays in
12193 angular or square brackets, and =:options= for inserting optional
12194 arguments.
12196 #+begin_example
12197   ,#+ATTR_BEAMER: :environment nonindentlist
12198   - item 1, not indented
12199   - item 2, not indented
12200   - item 3, not indented
12201 #+end_example
12203 #+begin_example
12204   ,#+ATTR_BEAMER: :overlay <+->
12205   - item 1
12206   - item 2
12207 #+end_example
12209 #+begin_example
12210   ,#+ATTR_BEAMER: :options [Lagrange]
12211   Let $G$ be a finite group, and let $H$ be
12212   a subgroup of $G$.  Then the order of $H$ divides the order of $G$.
12213 #+end_example
12215 *** Editing support
12216 :PROPERTIES:
12217 :DESCRIPTION: Editing support.
12218 :END:
12220 The ~org-beamer-mode~ is a special minor mode for faster editing of
12221 Beamer documents.
12223 : #+STARTUP: beamer
12225 - {{{kbd(C-c C-b)}}} (~org-beamer-select-environment~) ::
12226      #+kindex: C-c C-b
12227      #+findex: org-beamer-select-environment
12229      The ~org-beamer-mode~ provides this key for quicker selections in
12230      Beamer normal environments, and for selecting the =BEAMER_COL=
12231      property.
12233 *** A Beamer example
12234 :PROPERTIES:
12235 :DESCRIPTION: A complete presentation.
12236 :END:
12238 Here is an example of an Org document ready for Beamer export.
12240 #+begin_example
12241   ;#+TITLE: Example Presentation
12242   ;#+AUTHOR: Carsten Dominik
12243   ;#+OPTIONS: H:2 toc:t num:t
12244   ;#+LATEX_CLASS: beamer
12245   ;#+LATEX_CLASS_OPTIONS: [presentation]
12246   ;#+BEAMER_THEME: Madrid
12247   ;#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) %8BEAMER_OPT(Opt)
12249   ,* This is the first structural section
12251   ,** Frame 1
12252   ,*** Thanks to Eric Fraga                                           :B_block:
12253       :PROPERTIES:
12254       :BEAMER_COL: 0.48
12255       :BEAMER_ENV: block
12256       :END:
12257       for the first viable Beamer setup in Org
12258   ,*** Thanks to everyone else                                        :B_block:
12259       :PROPERTIES:
12260       :BEAMER_COL: 0.48
12261       :BEAMER_ACT: <2->
12262       :BEAMER_ENV: block
12263       :END:
12264       for contributing to the discussion
12265   ,**** This will be formatted as a beamer note                       :B_note:
12266        :PROPERTIES:
12267        :BEAMER_env: note
12268        :END:
12269   ,** Frame 2 (where we will not use columns)
12270   ,*** Request
12271       Please test this stuff!
12272 #+end_example
12274 ** HTML Export
12275 :PROPERTIES:
12276 :DESCRIPTION: Exporting to HTML.
12277 :END:
12278 #+cindex: HTML export
12280 Org mode contains an HTML exporter with extensive HTML formatting
12281 compatible with XHTML 1.0 strict standard.
12283 *** HTML export commands
12284 :PROPERTIES:
12285 :DESCRIPTION: Invoking HTML export.
12286 :END:
12288 - {{{kbd(C-c C-e h h)}}} (~org-html-export-to-html~) ::
12289      #+kindex: C-c C-e h h
12290      #+kindex: C-c C-e h o
12291      #+findex: org-html-export-to-html
12293      Export as HTML file with a =.html= extension.  For =myfile.org=,
12294      Org exports to =myfile.html=, overwriting without warning.
12295      {{{kbd{C-c C-e h o)}}} exports to HTML and opens it in a web
12296      browser.
12298 - {{{kbd(C-c C-e h H)}}} (~org-html-export-as-html~) ::
12299      #+kindex: C-c C-e h H
12300      #+findex: org-html-export-as-html
12302      Exports to a temporary buffer.  Does not create a file.
12304 *** HTML specific export settings
12305 :PROPERTIES:
12306 :DESCRIPTION: Settings for HTML export.
12307 :END:
12309 HTML export has a number of keywords, similar to the general options
12310 settings described in [[*Export Settings]].
12312 - =DESCRIPTION= ::
12314      #+cindex: DESCRIPTION, keyword
12315      This is the document's description, which the HTML exporter
12316      inserts it as a HTML meta tag in the HTML file.  For long
12317      descriptions, use multiple =DESCRIPTION= lines.  The exporter
12318      takes care of wrapping the lines properly.
12320 - =HTML_DOCTYPE= ::
12322      #+cindex: HTML_DOCTYPE, keyword
12323      #+vindex: org-html-doctype
12324      Specify the document type, for example: HTML5
12325      (~org-html-doctype~).
12327 - =HTML_CONTAINER= ::
12329      #+cindex: HTML_CONTAINER, keyword
12330      #+vindex: org-html-container-element
12331      Specify the HTML container, such as =div=, for wrapping sections
12332      and elements (~org-html-container-element~).
12334 - =HTML_LINK_HOME= ::
12336      #+cindex: HTML_LINK_HOME, keyword
12337      #+vindex: org-html-link-home
12338      The URL for home link (~org-html-link-home~).
12340 - =HTML_LINK_UP= ::
12342      #+cindex: HTML_LINK_UP, keyword
12343      #+vindex: org-html-link-up
12344      The URL for the up link of exported HTML pages
12345      (~org-html-link-up~).
12347 - =HTML_MATHJAX= ::
12349      #+cindex: HTML_MATHJAX, keyword
12350      #+vindex: org-html-mathjax-options
12351      Options for MathJax (~org-html-mathjax-options~).  MathJax is
12352      used to typeset LaTeX math in HTML documents.  See [[*Math
12353      formatting in HTML export]], for an example.
12355 - =HTML_HEAD= ::
12357      #+cindex: HTML_HEAD, keyword
12358      #+vindex: org-html-head
12359      Arbitrary lines for appending to the HTML document's head
12360      (~org-html-head~).
12362 - =HTML_HEAD_EXTRA= ::
12364      #+cindex: HTML_HEAD_EXTRA, keyword
12365      #+vindex: org-html-head-extra
12366      More arbitrary lines for appending to the HTML document's head
12367      (~org-html-head-extra~).
12369 - =KEYWORDS= ::
12371      #+cindex: KEYWORDS, keyword
12372      Keywords to describe the document's content.  HTML exporter
12373      inserts these keywords as HTML meta tags.  For long keywords, use
12374      multiple =KEYWORDS= lines.
12376 - =LATEX_HEADER= ::
12378      #+cindex: LATEX_HEADER, keyword
12379      Arbitrary lines for appending to the preamble; HTML exporter
12380      appends when transcoding LaTeX fragments to images (see [[*Math
12381      formatting in HTML export]]).
12383 - =SUBTITLE= ::
12385      #+cindex: SUBTITLE, keyword
12386      The document's subtitle.  HTML exporter formats subtitle if
12387      document type is =HTML5= and the CSS has a =subtitle= class.
12389 Some of these keywords are explained in more detail in the following
12390 sections of the manual.
12392 *** HTML doctypes
12393 :PROPERTIES:
12394 :DESCRIPTION: Exporting various (X)HTML flavors.
12395 :END:
12397 Org can export to various (X)HTML flavors.
12399 #+vindex: org-html-doctype
12400 #+vindex: org-html-doctype-alist
12401 Set the ~org-html-doctype~ variable for different (X)HTML variants.
12402 Depending on the variant, the HTML exporter adjusts the syntax of HTML
12403 conversion accordingly.  Org includes the following ready-made
12404 variants:
12406 - ~"html4-strict"~
12407 - ~"html4-transitional"~
12408 - ~"html4-frameset"~
12409 - ~"xhtml-strict"~
12410 - ~"xhtml-transitional"~
12411 - ~"xhtml-frameset"~
12412 - ~"xhtml-11"~
12413 - ~"html5"~
12414 - ~"xhtml5"~
12416 #+texinfo: @noindent
12417 See the variable ~org-html-doctype-alist~ for details.  The default is
12418 ~"xhtml-strict"~.
12420 #+vindex: org-html-html5-fancy
12421 #+cindex: HTML5, export new elements
12422 Org's HTML exporter does not by default enable new block elements
12423 introduced with the HTML5 standard.  To enable them, set
12424 ~org-html-html5-fancy~ to non-~nil~.  Or use an =OPTIONS= line in the
12425 file to set =html5-fancy=.
12427 HTML5 documents can now have arbitrary =#+BEGIN= ... =#+END= blocks.
12428 For example:
12430 #+begin_example
12431   ,#+BEGIN_aside
12432     Lorem ipsum
12433   ,#+END_aside
12434 #+end_example
12436 #+texinfo: @noindent
12437 exports to:
12439 #+begin_src html
12440   <aside>
12441     <p>Lorem ipsum</p>
12442   </aside>
12443 #+end_src
12445 #+texinfo: @noindent
12446 while this:
12448 #+begin_example
12449   ,#+ATTR_HTML: :controls controls :width 350
12450   ,#+BEGIN_video
12451   ,#+HTML: <source src="movie.mp4" type="video/mp4">
12452   ,#+HTML: <source src="movie.ogg" type="video/ogg">
12453   Your browser does not support the video tag.
12454   ,#+END_video
12455 #+end_example
12457 #+texinfo: @noindent
12458 exports to:
12460 #+begin_src html
12461   <video controls="controls" width="350">
12462     <source src="movie.mp4" type="video/mp4">
12463       <source src="movie.ogg" type="video/ogg">
12464         <p>Your browser does not support the video tag.</p>
12465   </video>
12466 #+end_src
12468 #+vindex: org-html-html5-elements
12469 When special blocks do not have a corresponding HTML5 element, the
12470 HTML exporter reverts to standard translation (see
12471 ~org-html-html5-elements~).  For example, =#+BEGIN_lederhosen= exports
12472 to ~<div class="lederhosen">~.
12474 Special blocks cannot have headlines.  For the HTML exporter to wrap
12475 the headline and its contents in ~<section>~ or ~<article>~ tags, set
12476 the =HTML_CONTAINER= property for the headline.
12478 *** HTML preamble and postamble
12479 :PROPERTIES:
12480 :DESCRIPTION: Inserting preamble and postamble.
12481 :END:
12482 #+vindex: org-html-preamble
12483 #+vindex: org-html-postamble
12484 #+vindex: org-html-preamble-format
12485 #+vindex: org-html-postamble-format
12486 #+vindex: org-html-validation-link
12487 #+vindex: org-export-creator-string
12488 #+vindex: org-export-time-stamp-file
12490 The HTML exporter has delineations for preamble and postamble.  The
12491 default value for ~org-html-preamble~ is ~t~, which makes the HTML
12492 exporter insert the preamble.  See the variable
12493 ~org-html-preamble-format~ for the format string.
12495 Set ~org-html-preamble~ to a string to override the default format
12496 string.  If the string is a function, the HTML exporter expects the
12497 function to return a string upon execution.  The HTML exporter inserts
12498 this string in the preamble.  The HTML exporter does not insert
12499 a preamble if ~org-html-preamble~ is set ~nil~.
12501 The default value for ~org-html-postamble~ is ~auto~, which makes the
12502 HTML exporter build a postamble from looking up author's name, email
12503 address, creator's name, and date.  Set ~org-html-postamble~ to ~t~ to
12504 insert the postamble in the format specified in the
12505 ~org-html-postamble-format~ variable.  The HTML exporter does not
12506 insert a postamble if ~org-html-postamble~ is set to ~nil~.
12508 *** Quoting HTML tags
12509 :PROPERTIES:
12510 :DESCRIPTION: Using direct HTML in Org files.
12511 :END:
12513 The HTML export back-end transforms =<= and =>= to =&lt;= and =&gt;=.
12515 To include raw HTML code in the Org file so the HTML export back-end
12516 can insert that HTML code in the output, use this inline syntax:
12517 =@@html:...@@=.  For example:
12519 : @@html:<b>@@bold text@@html:</b>@@
12521 #+cindex: HTML, keyword
12522 #+cindex: BEGIN_EXPORT html
12523 For larger raw HTML code blocks, use these HTML export code blocks:
12525 #+begin_example
12526   ,#+HTML: Literal HTML code for export
12528   ,#+BEGIN_EXPORT html
12529     All lines between these markers are exported literally
12530   ,#+END_EXPORT
12531 #+end_example
12533 *** Links in HTML export
12534 :PROPERTIES:
12535 :DESCRIPTION: Inserting and formatting links.
12536 :END:
12537 #+cindex: links, in HTML export
12538 #+cindex: internal links, in HTML export
12539 #+cindex: external links, in HTML export
12541 The HTML export back-end transforms Org's internal links (see
12542 [[*Internal Links]]) to equivalent HTML links in the output.  The back-end
12543 similarly handles Org's automatic links created by radio targets (see
12544 [[*Radio Targets]]) similarly.  For Org links to external files, the
12545 back-end transforms the links to /relative/ paths.
12547 #+vindex: org-html-link-org-files-as-html
12548 For Org links to other =.org= files, the back-end automatically
12549 changes the file extension to =.html= and makes file paths relative.
12550 If the =.org= files have an equivalent =.html= version at the same
12551 location, then the converted links should work without any further
12552 manual intervention.  However, to disable this automatic path
12553 translation, set ~org-html-link-org-files-as-html~ to ~nil~.  When
12554 disabled, the HTML export back-end substitutes the ID-based links in
12555 the HTML output.  For more about linking files when publishing to
12556 a directory, see [[*Publishing links]].
12558 Org files can also have special directives to the HTML export
12559 back-end.  For example, by using =#+ATTR_HTML= lines to specify new
12560 format attributes to ~<a>~ or ~<img>~ tags.  This example shows
12561 changing the link's title and style:
12563 #+cindex: ATTR_HTML, keyword
12564 #+begin_example
12565   ,#+ATTR_HTML: :title The Org mode homepage :style color:red;
12566   [[https://orgmode.org]]
12567 #+end_example
12569 *** Tables in HTML export
12570 :PROPERTIES:
12571 :DESCRIPTION: How to modify the formatting of tables.
12572 :END:
12573 #+cindex: tables, in HTML
12574 #+vindex: org-export-html-table-tag
12576 The HTML export back-end uses ~org-html-table-default-attributes~ when
12577 exporting Org tables to HTML.  By default, the exporter does not draw
12578 frames and cell borders.  To change for this for a table, use the
12579 following lines before the table in the Org file:
12581 #+cindex: CAPTION, keyword
12582 #+cindex: ATTR_HTML, keyword
12583 #+begin_example
12584    ,#+CAPTION: This is a table with lines around and between cells
12585    ,#+ATTR_HTML: border="2" rules="all" frame="border"
12586 #+end_example
12588 The HTML export back-end preserves column groupings in Org tables (see
12589 [[*Column Groups]]) when exporting to HTML.
12591 Additional options for customizing tables for HTML export.
12593 - ~org-html-table-align-individual-fields~ ::
12595      #+vindex: org-html-table-align-individual-fields
12596      Non-~nil~ attaches style attributes for alignment to each table
12597      field.
12599 - ~org-html-table-caption-above~ ::
12601      #+vindex: org-html-table-caption-above
12602      Non-~nil~ places caption string at the beginning of the table.
12604 - ~org-html-table-data-tags~ ::
12606      #+vindex: org-html-table-data-tags
12607      Opening and ending tags for table data fields.
12609 - ~org-html-table-default-attributes~ ::
12611      #+vindex: org-html-table-default-attributes
12612      Default attributes and values for table tags.
12614 - ~org-html-table-header-tags~ ::
12616      #+vindex: org-html-table-header-tags
12617      Opening and ending tags for table's header fields.
12619 - ~org-html-table-row-tags~ ::
12621      #+vindex: org-html-table-row-tags
12622      Opening and ending tags for table rows.
12624 - ~org-html-table-use-header-tags-for-first-column~ ::
12626      #+vindex: org-html-table-use-header-tags-for-first-column
12627      Non-~nil~ formats column one in tables with header tags.
12629 *** Images in HTML export
12630 :PROPERTIES:
12631 :DESCRIPTION: How to insert figures into HTML output.
12632 :END:
12633 #+cindex: images, inline in HTML
12634 #+cindex: inlining images in HTML
12636 The HTML export back-end has features to convert Org image links to
12637 HTML inline images and HTML clickable image links.
12639 #+vindex: org-html-inline-images
12640 When the link in the Org file has no description, the HTML export
12641 back-end by default in-lines that image.  For example:
12642 =[[file:myimg.jpg]]= is in-lined, while =[[file:myimg.jpg][the image]]= links to the text,
12643 =the image=.  For more details, see the variable
12644 ~org-html-inline-images~.
12646 On the other hand, if the description part of the Org link is itself
12647 another link, such as =file:= or =http:= URL pointing to an image, the
12648 HTML export back-end in-lines this image and links to the main image.
12649 This Org syntax enables the back-end to link low-resolution thumbnail
12650 to the high-resolution version of the image, as shown in this example:
12652 : [[file:highres.jpg][file:thumb.jpg]]
12654 To change attributes of in-lined images, use =#+ATTR_HTML= lines in
12655 the Org file.  This example shows realignment to right, and adds ~alt~
12656 and ~title~ attributes in support of text viewers and modern web
12657 accessibility standards.
12659 #+cindex: CAPTION, keyword
12660 #+cindex: ATTR_HTML, keyword
12661 #+begin_example
12662   ,#+CAPTION: A black cat stalking a spider
12663   ,#+ATTR_HTML: :alt cat/spider image :title Action! :align right
12664   [[./img/a.jpg]]
12665 #+end_example
12667 #+texinfo: @noindent
12668 The HTML export back-end copies the =http= links from the Org file as
12671 *** Math formatting in HTML export
12672 :PROPERTIES:
12673 :DESCRIPTION: Beautiful math also on the web.
12674 :END:
12675 #+cindex: MathJax
12676 #+cindex: dvipng
12677 #+cindex: dvisvgm
12678 #+cindex: ImageMagick
12680 #+vindex: org-html-mathjax-options~
12681 LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
12682 different ways on HTML pages.  The default is to use the [[http://www.mathjax.org][MathJax]],
12683 which should work out of the box with Org[fn:120].  Some MathJax
12684 display options can be configured via ~org-html-mathjax-options~, or
12685 in the buffer.  For example, with the following settings,
12687 #+begin_example
12688   ,#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
12689   ,#+HTML_MATHJAX: cancel.js noErrors.js
12690 #+end_example
12692 #+texinfo: @noindent
12693 equation labels are displayed on the left margin and equations are
12694 five em from the left margin.  In addition, it loads the two MathJax
12695 extensions =cancel.js= and =noErrors.js=[fn:121].
12697 #+vindex: org-html-mathjax-template
12698 See the docstring of ~org-html-mathjax-options~ for all supported
12699 variables.  The MathJax template can be configure via
12700 ~org-html-mathjax-template~.
12702 If you prefer, you can also request that LaTeX fragments are processed
12703 into small images that will be inserted into the browser page.  Before
12704 the availability of MathJax, this was the default method for Org
12705 files.  This method requires that the dvipng program, dvisvgm or
12706 ImageMagick suite is available on your system.  You can still get this
12707 processing with
12709 : #+OPTIONS: tex:dvipng
12711 : #+OPTIONS: tex:dvisvgm
12713 #+texinfo: @noindent
12716 : #+OPTIONS: tex:imagemagick
12718 *** Text areas in HTML export
12719 :PROPERTIES:
12720 :DESCRIPTION: An alternate way to show an example.
12721 :END:
12723 #+cindex: text areas, in HTML
12724 Before Org mode's Babel, one popular approach to publishing code in
12725 HTML was by using =:textarea=.  The advantage of this approach was
12726 that copying and pasting was built into browsers with simple
12727 JavaScript commands.  Even editing before pasting was made simple.
12729 The HTML export back-end can create such text areas.  It requires an
12730 =#+ATTR_HTML= line as shown in the example below with the =:textarea=
12731 option.  This must be followed by either an example or a source code
12732 block.  Other Org block types do not honor the =:textarea= option.
12734 By default, the HTML export back-end creates a text area 80 characters
12735 wide and height just enough to fit the content.  Override these
12736 defaults with =:width= and =:height= options on the =#+ATTR_HTML=
12737 line.
12739 #+begin_example
12740   ,#+ATTR_HTML: :textarea t :width 40
12741   ,#+BEGIN_EXAMPLE
12742     (defun org-xor (a b)
12743        "Exclusive or."
12744        (if a (not b) b))
12745   ,#+END_EXAMPLE
12746 #+end_example
12748 *** CSS support
12749 :PROPERTIES:
12750 :DESCRIPTION: Changing the appearance of the output.
12751 :END:
12752 #+cindex: CSS, for HTML export
12753 #+cindex: HTML export, CSS
12755 #+vindex: org-export-html-todo-kwd-class-prefix
12756 #+vindex: org-export-html-tag-class-prefix
12757 You can modify the CSS style definitions for the exported file.  The
12758 HTML exporter assigns the following special CSS classes[fn:122] to
12759 appropriate parts of the document---your style specifications may
12760 change these, in addition to any of the standard classes like for
12761 headlines, tables, etc.
12763 | ~p.author~           | author information, including email                    |
12764 | ~p.date~             | publishing date                                        |
12765 | ~p.creator~          | creator info, about org mode version                   |
12766 | ~.title~             | document title                                         |
12767 | ~.subtitle~          | document subtitle                                      |
12768 | ~.todo~              | TODO keywords, all not-done states                     |
12769 | ~.done~              | the DONE keywords, all states that count as done       |
12770 | ~.WAITING~           | each TODO keyword also uses a class named after itself |
12771 | ~.timestamp~         | timestamp                                              |
12772 | ~.timestamp-kwd~     | keyword associated with a timestamp, like =SCHEDULED=  |
12773 | ~.timestamp-wrapper~ | span around keyword plus timestamp                     |
12774 | ~.tag~               | tag in a headline                                      |
12775 | ~._HOME~             | each tag uses itself as a class, "@" replaced by "_"   |
12776 | ~.target~            | target for links                                       |
12777 | ~.linenr~            | the line number in a code example                      |
12778 | ~.code-highlighted~  | for highlighting referenced code lines                 |
12779 | ~div.outline-N~      | div for outline level N (headline plus text)           |
12780 | ~div.outline-text-N~ | extra div for text at outline level N                  |
12781 | ~.section-number-N~  | section number in headlines, different for each level  |
12782 | ~.figure-number~     | label like "Figure 1:"                                 |
12783 | ~.table-number~      | label like "Table 1:"                                  |
12784 | ~.listing-number~    | label like "Listing 1:"                                |
12785 | ~div.figure~         | how to format an in-lined image                        |
12786 | ~pre.src~            | formatted source code                                  |
12787 | ~pre.example~        | normal example                                         |
12788 | ~p.verse~            | verse paragraph                                        |
12789 | ~div.footnotes~      | footnote section headline                              |
12790 | ~p.footnote~         | footnote definition paragraph, containing a footnote   |
12791 | ~.footref~           | a footnote reference number (always a <sup>)           |
12792 | ~.footnum~           | footnote number in footnote definition (always <sup>)  |
12793 | ~.org-svg~           | default class for a linked =.svg= image                |
12795 #+vindex: org-html-style-default
12796 #+vindex: org-html-head
12797 #+vindex: org-html-head-extra
12798 #+cindex: HTML_INCLUDE_STYLE, keyword
12799 The HTML export back-end includes a compact default style in each
12800 exported HTML file.  To override the default style with another style,
12801 use these keywords in the Org file.  They will replace the global
12802 defaults the HTML exporter uses.
12804 #+cindex: HTML_HEAD, keyword
12805 #+cindex: HTML_HEAD_EXTRA, keyword
12806 #+begin_example
12807   ,#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
12808   ,#+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
12809 #+end_example
12811 #+vindex: org-html-head-include-default-style
12812 To just turn off the default style, customize
12813 ~org-html-head-include-default-style~ variable, or use this option
12814 line in the Org file.
12816 #+cindex: html-style, OPTIONS item
12817 : #+OPTIONS: html-style:nil
12819 For longer style definitions, either use several =HTML_HEAD= and
12820 =HTML_HEAD_EXTRA= keywords, or use ~<style> ... </style>~ blocks
12821 around them.  Both of these approaches can avoid referring to an
12822 external file.
12824 #+cindex: HTML_CONTAINER_CLASS, property
12825 In order to add styles to a sub-tree, use the =HTML_CONTAINER_CLASS=
12826 property to assign a class to the tree.  In order to specify CSS
12827 styles for a particular headline, you can use the id specified in
12828 a =CUSTOM_ID= property.
12830 Never change the ~org-html-style-default~ constant.  Instead use other
12831 simpler ways of customizing as described above.
12833 *** JavaScript supported display of web pages
12834 :PROPERTIES:
12835 :DESCRIPTION: Info and folding in a web browser.
12836 :ALT_TITLE: JavaScript support
12837 :END:
12839 Sebastian Rose has written a JavaScript program especially designed to
12840 enhance the web viewing experience of HTML files created with Org.
12841 This program enhances large files in two different ways of viewing.
12842 One is an /Info/-like mode where each section is displayed separately
12843 and navigation can be done with the {{{kbd(n)}}} and {{{kbd(p)}}}
12844 keys, and some other keys as well, press {{{kbd(?)}}} for an overview
12845 of the available keys.  The second one has a /folding/ view, much like
12846 Org provides inside Emacs.  The script is available at
12847 https://orgmode.org/org-info.js and the documentation at
12848 https://orgmode.org/worg/code/org-info-js/.  The script is hosted on
12849 https://orgmode.org, but for reliability, prefer installing it on your
12850 own web server.
12852 To use this program, just add this line to the Org file:
12854 #+cindex: INFOJS_OPT, keyword
12855 : #+INFOJS_OPT: view:info toc:nil
12857 #+texinfo: @noindent
12858 The HTML header now has the code needed to automatically invoke the
12859 script.  For setting options, use the syntax from the above line for
12860 options described below:
12862 - =path:= ::
12864      The path to the script.  The default is to grab the script from
12865      [[https://orgmode.org/org-info.js]], but you might want to have
12866      a local copy and use a path like =../scripts/org-info.js=.
12868 - =view:= ::
12870      Initial view when the website is first shown.  Possible values are:
12872      | =info=     | Info-like interface with one section per page          |
12873      | =overview= | Folding interface, initially showing only top-level    |
12874      | =content=  | Folding interface, starting with all headlines visible |
12875      | =showall=  | Folding interface, all headlines and text visible      |
12877 - =sdepth:= ::
12879      Maximum headline level still considered as an independent section
12880      for info and folding modes.  The default is taken from
12881      ~org-export-headline-levels~, i.e., the =H= switch in =OPTIONS=.
12882      If this is smaller than in ~org-export-headline-levels~, each
12883      info/folding section can still contain child headlines.
12885 - =toc:= ::
12887      Should the table of contents /initially/ be visible?  Even when
12888      =nil=, you can always get to the "toc" with {{{kbd(i)}}}.
12890 - =tdepth:= ::
12892      The depth of the table of contents.  The defaults are taken from
12893      the variables ~org-export-headline-levels~ and
12894      ~org-export-with-toc~.
12896 - =ftoc:= ::
12898      Does the CSS of the page specify a fixed position for the "toc"?
12899      If yes, the toc is displayed as a section.
12901 - =ltoc:= ::
12903      Should there be short contents (children) in each section?  Make
12904      this =above= if the section should be above initial text.
12906 - =mouse:= ::
12908      Headings are highlighted when the mouse is over them.  Should be
12909      =underline= (default) or a background color like =#cccccc=.
12911 - =buttons:= ::
12913      Should view-toggle buttons be everywhere?  When =nil= (the
12914      default), only one such button is present.
12916 #+texinfo: @noindent
12917 #+vindex: org-infojs-options
12918 #+vindex: org-export-html-use-infojs
12919 You can choose default values for these options by customizing the
12920 variable ~org-infojs-options~.  If you always want to apply the script
12921 to your pages, configure the variable ~org-export-html-use-infojs~.
12923 ** LaTeX Export
12924 :PROPERTIES:
12925 :DESCRIPTION: Exporting to @LaTeX{} and processing to PDF.
12926 :END:
12927 #+cindex: @LaTeX{} export
12928 #+cindex: PDF export
12930 The LaTeX export back-end can handle complex documents, incorporate
12931 standard or custom LaTeX document classes, generate documents using
12932 alternate LaTeX engines, and produce fully linked PDF files with
12933 indexes, bibliographies, and tables of contents, destined for
12934 interactive online viewing or high-quality print publication.
12936 While the details are covered in-depth in this section, here are some
12937 quick references to variables for the impatient: for engines, see
12938 ~org-latex-compiler~; for build sequences, see
12939 ~org-latex-pdf-process~; for packages, see
12940 ~org-latex-default-packages-alist~ and ~org-latex-packages-alist~.
12942 An important note about the LaTeX export back-end: it is sensitive to
12943 blank lines in the Org document.  That's because LaTeX itself depends
12944 on blank lines to tell apart syntactical elements, such as paragraphs.
12946 *** LaTeX/PDF export commands
12947 :PROPERTIES:
12948 :DESCRIPTION: For producing @LaTeX{} and PDF documents.
12949 :END:
12951 - {{{kbd(C-c C-e l l)}}} (~org-latex-export-to-latex~) ::
12953      #+kindex: C-c C-e l l
12954      #+findex: org-latex-export-to-latex~
12955      Export to a LaTeX file with a =.tex= extension.  For
12956      =myfile.org=, Org exports to =myfile.tex=, overwriting without
12957      warning.
12959 - {{{kbd(C-c C-e l L)}}} (~org-latex-export-as-latex~) ::
12961      #+kindex: C-c C-e l L
12962      #+findex: org-latex-export-as-latex
12963      Export to a temporary buffer.  Do not create a file.
12965 - {{{kbd(C-c C-e l p)}}} (~org-latex-export-to-pdf~) ::
12967      #+kindex: C-c C-e l p
12968      #+findex: org-latex-export-to-pdf
12969      Export as LaTeX file and convert it to PDF file.
12971 - {{{kbd(C-c C-e l o)}}} ::
12973      #+kindex: C-c C-e l o
12974      Export as LaTeX file and convert it to PDF, then open the PDF
12975      using the default viewer.
12977 - {{{kbd(M-x org-export-region-as-latex)}}} ::
12979      Convert the region to LaTeX under the assumption that it was in Org
12980      mode syntax before.  This is a global command that can be invoked in
12981      any buffer.
12983 #+vindex: org-latex-compiler
12984 #+vindex: org-latex-bibtex-compiler
12985 #+vindex: org-latex-default-packages-alist
12986 #+cindex: pdflatex
12987 #+cindex: xelatex
12988 #+cindex: lualatex
12989 #+cindex: LATEX_COMPILER, keyword
12990 The LaTeX export back-end can use any of these LaTeX engines:
12991 =pdflatex=, =xelatex=, and =lualatex=.  These engines compile LaTeX
12992 files with different compilers, packages, and output options.  The
12993 LaTeX export back-end finds the compiler version to use from
12994 ~org-latex-compiler~ variable or the =#+LATEX_COMPILER= keyword in the
12995 Org file.  See the docstring for the
12996 ~org-latex-default-packages-alist~ for loading packages with certain
12997 compilers.  Also see ~org-latex-bibtex-compiler~ to set the
12998 bibliography compiler[fn:123].
13000 *** LaTeX specific export settings
13001 :PROPERTIES:
13002 :DESCRIPTION: Unique to this @LaTeX{} back-end.
13003 :END:
13005 The LaTeX export back-end has several additional keywords for
13006 customizing LaTeX output.  Setting these keywords works similar to the
13007 general options (see [[*Export Settings]]).
13009 #+attr_texinfo: :sep ,
13010 - =DESCRIPTION= ::
13011      #+cindex: DESCRIPTION, keyword
13012      #+vindex: org-latex-hyperref-template
13013      #+vindex: org-latex-title-command
13014      The document's description.  The description along with author
13015      name, keywords, and related file metadata are inserted in the
13016      output file by the hyperref package.  See
13017      ~org-latex-hyperref-template~ for customizing metadata items.
13018      See ~org-latex-title-command~ for typesetting description into
13019      the document's front matter.  Use multiple =DESCRIPTION= keywords
13020      for long descriptions.
13022 - =LATEX_CLASS= ::
13024      #+cindex: LATEX_CLASS, keyword
13025      #+vindex: org-latex-default-class
13026      #+vindex: org-latex-classes
13027      This is LaTeX document class, such as /article/, /report/,
13028      /book/, and so on, which contain predefined preamble and headline
13029      level mapping that the LaTeX export back-end needs.  The back-end
13030      reads the default class name from the ~org-latex-default-class~
13031      variable.  Org has /article/ as the default class.  A valid
13032      default class must be an element of ~org-latex-classes~.
13034 - =LATEX_CLASS_OPTIONS= ::
13036      #+cindex: LATEX_CLASS_OPTIONS, keyword
13037      Options the LaTeX export back-end uses when calling the LaTeX
13038      document class.
13040 - =LATEX_COMPILER= ::
13042      #+cindex: LATEX_COMPILER, keyword
13043      #+vindex: org-latex-compiler
13044      The compiler, such as =pdflatex=, =xelatex=, =lualatex=, for
13045      producing the PDF.  See ~org-latex-compiler~.
13047 - =LATEX_HEADER=, =LATEX_HEADER_EXTRA= ::
13049      #+cindex: LATEX_HEADER, keyword
13050      #+cindex: LATEX_HEADER_EXTRA, keyword
13051      #+vindex: org-latex-classes
13052      Arbitrary lines to add to the document's preamble, before the
13053      hyperref settings.  See ~org-latex-classes~ for adjusting the
13054      structure and order of the LaTeX headers.
13056 - =KEYWORDS= ::
13058      #+cindex: KEYWORDS, keyword
13059      #+vindex: org-latex-hyperref-template
13060      #+vindex: org-latex-title-command
13061      The keywords for the document.  The description along with author
13062      name, keywords, and related file metadata are inserted in the
13063      output file by the hyperref package.  See
13064      ~org-latex-hyperref-template~ for customizing metadata items.
13065      See ~org-latex-title-command~ for typesetting description into
13066      the document's front matter.  Use multiple =KEYWORDS= lines if
13067      necessary.
13069 - =SUBTITLE= ::
13071      #+cindex: SUBTITLE, keyword
13072      #+vindex: org-latex-subtitle-separate
13073      #+vindex: org-latex-subtitle-format
13074      The document's subtitle.  It is typeset as per
13075      ~org-latex-subtitle-format~.  If ~org-latex-subtitle-separate~ is
13076      non-~nil~, it is typed as part of the ~\title~ macro.  See
13077      ~org-latex-hyperref-template~ for customizing metadata items.
13078      See ~org-latex-title-command~ for typesetting description
13079      into the document's front matter.
13081 The following sections have further details.
13083 *** LaTeX header and sectioning structure
13084 :PROPERTIES:
13085 :DESCRIPTION: Setting up the export file structure.
13086 :ALT_TITLE: LaTeX header and sectioning
13087 :END:
13088 #+cindex: @LaTeX{} class
13089 #+cindex: @LaTeX{} sectioning structure
13090 #+cindex: @LaTeX{} header
13091 #+cindex: header, for @LaTeX{} files
13092 #+cindex: sectioning structure, for @LaTeX{} export
13094 The LaTeX export back-end converts the first three of Org's outline
13095 levels into LaTeX headlines.  The remaining Org levels are exported as
13096 lists.  To change this globally for the cut-off point between levels
13097 and lists, (see [[*Export Settings]]).
13099 By default, the LaTeX export back-end uses the /article/ class.
13101 #+vindex: org-latex-default-class
13102 #+vindex: org-latex-classes
13103 #+vindex: org-latex-default-packages-alist
13104 #+vindex: org-latex-packages-alist
13105 To change the default class globally, edit ~org-latex-default-class~.
13106 To change the default class locally in an Org file, add option lines
13107 =#+LATEX_CLASS: myclass=.  To change the default class for just a part
13108 of the Org file, set a sub-tree property, =EXPORT_LATEX_CLASS=.  The
13109 class name entered here must be valid member of ~org-latex-classes~.
13110 This variable defines a header template for each class into which the
13111 exporter splices the values of ~org-latex-default-packages-alist~ and
13112 ~org-latex-packages-alist~.  Use the same three variables to define
13113 custom sectioning or custom classes.
13115 #+cindex: LATEX_CLASS, keyword
13116 #+cindex: LATEX_CLASS_OPTIONS, keyword
13117 #+cindex: EXPORT_LATEX_CLASS, property
13118 #+cindex: EXPORT_LATEX_CLASS_OPTIONS, property
13119 The LaTeX export back-end sends the =LATEX_CLASS_OPTIONS= keyword and
13120 =EXPORT_LATEX_CLASS_OPTIONS= property as options to the LaTeX
13121 ~\documentclass~ macro.  The options and the syntax for specifying
13122 them, including enclosing them in square brackets, follow LaTeX
13123 conventions.
13125 : #+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside,twocolumn]
13127 #+cindex: LATEX_HEADER, keyword
13128 #+cindex: LATEX_HEADER_EXTRA, keyword
13129 The LaTeX export back-end appends values from =LATEX_HEADER= and
13130 =LATEX_HEADER_EXTRA= keywords to the LaTeX header.  The docstring for
13131 ~org-latex-classes~ explains in more detail.  Also note that LaTeX
13132 export back-end does not append =LATEX_HEADER_EXTRA= to the header
13133 when previewing LaTeX snippets (see [[*Previewing LaTeX fragments]]).
13135 A sample Org file with the above headers:
13137 #+begin_example
13138   ,#+LATEX_CLASS: article
13139   ,#+LATEX_CLASS_OPTIONS: [a4paper]
13140   ,#+LATEX_HEADER: \usepackage{xyz}
13142   ,* Headline 1
13143     some text
13144   ,* Headline 2
13145     some more text
13146 #+end_example
13148 *** Quoting LaTeX code
13149 :PROPERTIES:
13150 :DESCRIPTION: Incorporating literal @LaTeX{} code.
13151 :END:
13153 The LaTeX export back-end can insert any arbitrary LaTeX code, see
13154 [[*Embedded LaTeX]].  There are three ways to embed such code in the Org
13155 file and they all use different quoting syntax.
13157 #+cindex: inline, in @LaTeX{} export
13158 Inserting in-line quoted with @ symbols:
13160 : Code embedded in-line @@latex:any arbitrary LaTeX code@@ in a paragraph.
13162 #+cindex: LATEX, keyword
13163 Inserting as one or more keyword lines in the Org file:
13165 : #+LATEX: any arbitrary LaTeX code
13167 #+cindex: BEGIN_EXPORT latex
13168 Inserting as an export block in the Org file, where the back-end
13169 exports any code between begin and end markers:
13171 #+begin_example
13172   ,#+BEGIN_EXPORT latex
13173     any arbitrary LaTeX code
13174   ,#+END_EXPORT
13175 #+end_example
13177 *** Tables in LaTeX export
13178 :PROPERTIES:
13179 :DESCRIPTION: Options for exporting tables to @LaTeX{}.
13180 :END:
13181 #+cindex: tables, in @LaTeX{} export
13183 The LaTeX export back-end can pass several LaTeX attributes for table
13184 contents and layout.  Besides specifying label and caption (see
13185 [[*Images and Tables]]), the other valid LaTeX attributes include:
13187 #+attr_texinfo: :sep ,
13188 - =:mode= ::
13190      #+vindex: org-latex-default-table-mode
13191      The LaTeX export back-end wraps the table differently depending
13192      on the mode for accurate rendering of math symbols.  Mode is
13193      either =table=, =math=, =inline-math= or =verbatim=.
13195      For =math= or =inline-math= mode, LaTeX export back-end wraps the
13196      table in a math environment, but every cell in it is exported
13197      as-is.  The LaTeX export back-end determines the default mode
13198      from ~org-latex-default-table-mode~.  The LaTeX export back-end
13199      merges contiguous tables in the same mode into a single
13200      environment.
13202 - =:environment= ::
13204      #+vindex: org-latex-default-table-environment
13205      Set the default LaTeX table environment for the LaTeX export
13206      back-end to use when exporting Org tables.  Common LaTeX table
13207      environments are provided by these packages: tabularx, longtable,
13208      array, tabu, and bmatrix.  For packages, such as tabularx and
13209      tabu, or any newer replacements, include them in the
13210      ~org-latex-packages-alist~ variable so the LaTeX export back-end
13211      can insert the appropriate load package headers in the converted
13212      LaTeX file.  Look in the docstring for the
13213      ~org-latex-packages-alist~ variable for configuring these
13214      packages for LaTeX snippet previews, if any.
13216 - =:caption= ::
13218      Use =CAPTION= keyword to set a simple caption for a table (see
13219      [[*Images and Tables]]).  For custom captions, use =:caption=
13220      attribute, which accepts raw LaTeX code.  =:caption= value
13221      overrides =CAPTION= value.
13223 - =:float=, =:placement= ::
13225      The table environments by default are not floats in LaTeX.  To
13226      make them floating objects use =:float= with one of the following
13227      options: =sideways=, =multicolumn=, =t=, and =nil=.
13229      LaTeX floats can also have additional layout =:placement=
13230      attributes.  These are the usual =[h t b p ! H]= permissions
13231      specified in square brackets.  Note that for =:float sideways=
13232      tables, the LaTeX export back-end ignores =:placement=
13233      attributes.
13235 - =:align=, =:font=, =:width= ::
13237      The LaTeX export back-end uses these attributes for regular
13238      tables to set their alignments, fonts, and widths.
13240 - =:spread= ::
13242      When =:spread= is non-~nil~, the LaTeX export back-end spreads or
13243      shrinks the table by the =:width= for tabu and longtabu
13244      environments.  =:spread= has no effect if =:width= is not set.
13246 - =:booktabs=, =:center=, =:rmlines= ::
13248      #+vindex: org-latex-tables-booktabs
13249      #+vindex: org-latex-tables-centered
13250      All three commands are toggles.  =:booktabs= brings in modern
13251      typesetting enhancements to regular tables.  The booktabs package
13252      has to be loaded through ~org-latex-packages-alist~.  =:center=
13253      is for centering the table.  =:rmlines= removes all but the very
13254      first horizontal line made of ASCII characters from "table.el"
13255      tables only.
13257 - =:math-prefix=, =:math-suffix=, =:math-arguments= ::
13259      The LaTeX export back-end inserts =:math-prefix= string value in
13260      a math environment before the table.  The LaTeX export back-end
13261      inserts =:math-suffix= string value in a math environment after
13262      the table.  The LaTeX export back-end inserts =:math-arguments=
13263      string value between the macro name and the table's contents.
13264      =:math-arguments= comes in use for matrix macros that require
13265      more than one argument, such as =qbordermatrix=.
13267 LaTeX table attributes help formatting tables for a wide range of
13268 situations, such as matrix product or spanning multiple pages:
13270 #+begin_example
13271   ,#+ATTR_LATEX: :environment longtable :align l|lp{3cm}r|l
13272   | ... | ... |
13273   | ... | ... |
13275   ,#+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
13276   | a | b |
13277   | c | d |
13278   ,#+ATTR_LATEX: :mode math :environment bmatrix
13279   | 1 | 2 |
13280   | 3 | 4 |
13281 #+end_example
13283 Set the caption with the LaTeX command
13284 =\bicaption{HeadingA}{HeadingB}=:
13286 #+begin_example
13287   ,#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
13288   | ... | ... |
13289   | ... | ... |
13290 #+end_example
13292 *** Images in LaTeX export
13293 :PROPERTIES:
13294 :DESCRIPTION: How to insert figures into @LaTeX{} output.
13295 :END:
13296 #+cindex: images, inline in LaTeX
13297 #+cindex: inlining images in LaTeX
13298 #+cindex: ATTR_LATEX, keyword
13300 The LaTeX export back-end processes image links in Org files that do
13301 not have descriptions, such as these links =[[file:img.jpg]]= or
13302 =[[./img.jpg]]=, as direct image insertions in the final PDF output.  In
13303 the PDF, they are no longer links but actual images embedded on the
13304 page.  The LaTeX export back-end uses =\includegraphics= macro to
13305 insert the image.  But for TikZ (http://sourceforge.net/projects/pgf/)
13306 images, the back-end uses an ~\input~ macro wrapped within
13307 a ~tikzpicture~ environment.
13309 For specifying image =:width=, =:height=, and other =:options=, use
13310 this syntax:
13312 #+begin_example
13313   ,#+ATTR_LATEX: :width 5cm :options angle=90
13314   [[./img/sed-hr4049.pdf]]
13315 #+end_example
13317 For custom commands for captions, use the =:caption= attribute.  It
13318 overrides the default =#+CAPTION= value:
13320 #+begin_example
13321   ,#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
13322   [[./img/sed-hr4049.pdf]]
13323 #+end_example
13325 When captions follow the method as described in [[*Images and Tables]],
13326 the LaTeX export back-end wraps the picture in a floating =figure=
13327 environment.  To float an image without specifying a caption, set the
13328 =:float= attribute to one of the following:
13330 - =t= ::
13332      For a standard =figure= environment; used by default whenever an
13333      image has a caption.
13335 - =multicolumn= ::
13337      To span the image across multiple columns of a page; the back-end
13338      wraps the image in a =figure*= environment.
13340 - =wrap= ::
13342      For text to flow around the image on the right; the figure
13343      occupies the left half of the page.
13345 - =sideways= ::
13347      For a new page with the image sideways, rotated ninety degrees,
13348      in a =sidewaysfigure= environment; overrides =:placement=
13349      setting.
13351 - =nil= ::
13353      To avoid a =:float= even if using a caption.
13355 #+texinfo: @noindent
13356 Use the =placement= attribute to modify a floating environment's
13357 placement.
13359 #+begin_example
13360   ,#+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement {r}{0.4\textwidth}
13361   [[./img/hst.png]]
13362 #+end_example
13364 #+vindex: org-latex-images-centered
13365 #+cindex: center image in LaTeX export
13366 #+cindex: image, centering in LaTeX export
13367 The LaTeX export back-end centers all images by default.  Setting
13368 =:center= to =nil= disables centering.  To disable centering globally,
13369 set ~org-latex-images-centered~ to =t=.
13371 Set the =:comment-include= attribute to non-~nil~ value for the LaTeX
13372 export back-end to comment out the =\includegraphics= macro.
13374 *** Plain lists in LaTeX export
13375 :PROPERTIES:
13376 :DESCRIPTION: Attributes specific to lists.
13377 :END:
13379 #+cindex: plain lists, in @LaTeX{} export
13380 #+cindex: ATTR_LATEX, keyword
13381 The LaTeX export back-end accepts the =environment= and =options=
13382 attributes for plain lists.  Both attributes work together for
13383 customizing lists, as shown in the examples:
13385 #+begin_example
13386   ,#+LATEX_HEADER: \usepackage[inline]{enumitem}
13387   Some ways to say "Hello":
13388   ,#+ATTR_LATEX: :environment itemize*
13389   ,#+ATTR_LATEX: :options [label={}, itemjoin={,}, itemjoin*={, and}]
13390   - Hola
13391   - Bonjour
13392   - Guten Tag.
13393 #+end_example
13395 Since LaTeX supports only four levels of nesting for lists, use an
13396 external package, such as =enumitem= in LaTeX, for levels deeper than
13397 four:
13399 #+begin_example
13400   ,#+LATEX_HEADER: \usepackage{enumitem}
13401   ,#+LATEX_HEADER: \renewlist{itemize}{itemize}{9}
13402   ,#+LATEX_HEADER: \setlist[itemize]{label=$\circ$}
13403   - One
13404     - Two
13405       - Three
13406         - Four
13407           - Five
13408 #+end_example
13410 *** Source blocks in LaTeX export
13411 :PROPERTIES:
13412 :DESCRIPTION: Attributes specific to source code blocks.
13413 :END:
13414 #+cindex: source blocks, in @LaTeX{} export
13415 #+cindex: ATTR_LATEX, keyword
13417 The LaTeX export back-end can make source code blocks into floating
13418 objects through the attributes =:float= and =:options=.  For =:float=:
13420 - =t= ::
13422      Makes a source block float; by default floats any source block
13423      with a caption.
13425 - =multicolumn= ::
13427      Spans the source block across multiple columns of a page.
13429 - =nil= ::
13431      Avoids a =:float= even if using a caption; useful for source code
13432      blocks that may not fit on a page.
13434 #+begin_example
13435   ,#+ATTR_LATEX: :float nil
13436   ,#+BEGIN_SRC emacs-lisp
13437     Lisp code that may not fit in a single page.
13438   ,#+END_SRC
13439 #+end_example
13441 #+vindex: org-latex-listings-options
13442 #+vindex: org-latex-minted-options
13443 The LaTeX export back-end passes string values in =:options= to LaTeX
13444 packages for customization of that specific source block.  In the
13445 example below, the =:options= are set for Minted.  Minted is a source
13446 code highlighting LaTeX package with many configurable options.
13448 #+begin_example
13449   ,#+ATTR_LATEX: :options commentstyle=\bfseries
13450   ,#+BEGIN_SRC emacs-lisp
13451     (defun Fib (n)
13452       (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
13453   ,#+END_SRC
13454 #+end_example
13456 To apply similar configuration options for all source blocks in
13457 a file, use the ~org-latex-listings-options~ and
13458 ~org-latex-minted-options~ variables.
13460 *** Example blocks in LaTeX export
13461 :PROPERTIES:
13462 :DESCRIPTION: Attributes specific to example blocks.
13463 :END:
13464 #+cindex: example blocks, in @LaTeX{} export
13465 #+cindex: verbatim blocks, in @LaTeX{} export
13466 #+cindex: ATTR_LATEX, keyword
13468 The LaTeX export back-end wraps the contents of example blocks in
13469 a =verbatim= environment.  To change this behavior to use another
13470 environment globally, specify an appropriate export filter (see
13471 [[*Advanced Configuration]]).  To change this behavior to use another
13472 environment for each block, use the =:environment= parameter to
13473 specify a custom environment.
13475 #+begin_example
13476   ,#+ATTR_LATEX: :environment myverbatim
13477   ,#+BEGIN_EXAMPLE
13478     This sentence is false.
13479   ,#+END_EXAMPLE
13480 #+end_example
13482 *** Special blocks in LaTeX export
13483 :PROPERTIES:
13484 :DESCRIPTION: Attributes specific to special blocks.
13485 :END:
13487 #+cindex: special blocks, in @LaTeX{} export
13488 #+cindex: abstract, in @LaTeX{} export
13489 #+cindex: proof, in @LaTeX{} export
13490 #+cindex: ATTR_LATEX, keyword
13492 For other special blocks in the Org file, the LaTeX export back-end
13493 makes a special environment of the same name.  The back-end also takes
13494 =:options=, if any, and appends as-is to that environment's opening
13495 string.  For example:
13497 #+begin_example
13498   ,#+BEGIN_abstract
13499     We demonstrate how to solve the Syracuse problem.
13500   ,#+END_abstract
13502   ,#+ATTR_LATEX: :options [Proof of important theorem]
13503   ,#+BEGIN_proof
13504     ...
13505     Therefore, any even number greater than 2 is the sum of two primes.
13506   ,#+END_proof
13507 #+end_example
13509 #+texinfo: @noindent
13510 exports to
13512 #+begin_example
13513   \begin{abstract}
13514     We demonstrate how to solve the Syracuse problem.
13515   \end{abstract}
13517   \begin{proof}[Proof of important theorem]
13518     ...
13519     Therefore, any even number greater than 2 is the sum of two primes.
13520   \end{proof}
13521 #+end_example
13523 If you need to insert a specific caption command, use =:caption=
13524 attribute.  It overrides standard =CAPTION= value, if any.  For
13525 example:
13527 #+begin_example
13528   ,#+ATTR_LATEX: :caption \MyCaption{HeadingA}
13529   ,#+BEGIN_proof
13530     ...
13531   ,#+END_proof
13532 #+end_example
13534 *** Horizontal rules in LaTeX export
13535 :PROPERTIES:
13536 :DESCRIPTION: Attributes specific to horizontal rules.
13537 :END:
13538 #+cindex: horizontal rules, in @LaTeX{} export
13539 #+cindex: ATTR_LATEX, keyword
13541 The LaTeX export back-end converts horizontal rules by the specified
13542 =:width= and =:thickness= attributes.  For example:
13544 #+begin_example
13545   ,#+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt
13546   -----
13547 #+end_example
13549 ** Markdown Export
13550 :PROPERTIES:
13551 :DESCRIPTION: Exporting to Markdown.
13552 :END:
13553 #+cindex: Markdown export
13555 The Markdown export back-end, "md", converts an Org file to a Markdown
13556 format, as defined at http://daringfireball.net/projects/markdown/.
13558 Since "md" is built on top of the HTML back-end, any Org constructs
13559 not supported by Markdown, such as tables, the underlying "html"
13560 back-end (see [[*HTML Export]]) converts them.
13562 *** Markdown export commands
13563 :PROPERTIES:
13564 :UNNUMBERED: notoc
13565 :END:
13567 - {{{kbd(C-c C-e m m)}}} (~org-md-export-to-markdown~) ::
13569      #+kindex: C-c C-c m m
13570      #+findex: org-md-export-to-markdown
13571      Export to a text file with Markdown syntax.  For =myfile.org=,
13572      Org exports to =myfile.md=, overwritten without warning.
13574 - {{{kbd(C-c C-e m M)}}} (~org-md-export-as-markdown~) ::
13576      #+kindex: C-c C-c m M
13577      #+findex: org-md-export-as-markdown
13578      Export to a temporary buffer.  Does not create a file.
13580 - {{{kbd(C-c C-e m o)}}} ::
13582      #+kindex: C-c C-e m o
13583      Export as a text file with Markdown syntax, then open it.
13585 *** Header and sectioning structure
13586 :PROPERTIES:
13587 :UNNUMBERED: notoc
13588 :END:
13590 #+vindex: org-md-headline-style
13591 Based on ~org-md-headline-style~, Markdown export can generate
13592 headlines of both /atx/ and /setext/ types.  /atx/ limits headline
13593 levels to two whereas /setext/ limits headline levels to six.  Beyond
13594 these limits, the export back-end converts headlines to lists.  To set
13595 a limit to a level before the absolute limit (see [[*Export Settings]]).
13597 ** OpenDocument Text Export
13598 :PROPERTIES:
13599 :DESCRIPTION: Exporting to OpenDocument Text.
13600 :END:
13601 #+cindex: ODT
13602 #+cindex: OpenDocument
13603 #+cindex: export, OpenDocument
13604 #+cindex: LibreOffice
13606 The ODT export back-end handles creating of OpenDocument Text (ODT)
13607 format.  Documents created by this exporter use the
13608 {{{cite(OpenDocument-v1.2 specification)}}}[fn:124] and are compatible
13609 with LibreOffice 3.4.
13611 *** Pre-requisites for ODT export
13612 :PROPERTIES:
13613 :DESCRIPTION: Required packages.
13614 :END:
13615 #+cindex: zip
13617 The ODT export back-end relies on the zip program to create the final
13618 compressed ODT output.  Check if =zip= is locally available and
13619 executable.  Without it, export cannot finish.
13621 *** ODT export commands
13622 :PROPERTIES:
13623 :DESCRIPTION: Invoking export.
13624 :END:
13626 - {{{kbd(C-c C-e o o)}}} (~org-export-to-odt~) ::
13628      #+kindex: C-c C-e o o
13629      #+findex: org-export-to-odt
13630      Export as OpenDocument Text file.
13632      #+cindex: EXPORT_FILE_NAME, property
13633      #+vindex: org-odt-preferred-output-format
13635      If ~org-odt-preferred-output-format~ is specified, the ODT export
13636      back-end automatically converts the exported file to that format.
13638      For =myfile.org=, Org exports to =myfile.odt=, overwriting
13639      without warning.  The ODT export back-end exports a region only
13640      if a region was active.
13642      If the selected region is a single tree, the ODT export back-end
13643      makes the tree head the document title.  Incidentally, {{{kbd(C-c
13644      @)}}} selects the current sub-tree.  If the tree head entry has,
13645      or inherits, an =EXPORT_FILE_NAME= property, the ODT export
13646      back-end uses that for file name.
13648 - {{{kbd(C-c C-e o O)}}} ::
13650      #+kindex: C-c C-e o O
13651      Export as an OpenDocument Text file and open the resulting file.
13653      #+vindex: org-export-odt-preferred-output-format
13654      If ~org-export-odt-preferred-output-format~ is specified, open
13655      the converted file instead.  See [[*Automatically exporting to
13656      other formats]].
13658 *** ODT specific export settings
13659 :PROPERTIES:
13660 :DESCRIPTION: Configuration options.
13661 :END:
13663 The ODT export back-end has several additional keywords for
13664 customizing ODT output.  Setting these keywords works similar to the
13665 general options (see [[*Export Settings]]).
13667 - =DESCRIPTION= ::
13669      #+cindex: DESCRIPTION, keyword
13670      This is the document's description, which the ODT export back-end
13671      inserts as document metadata.  For long descriptions, use
13672      multiple lines, prefixed with =DESCRIPTION=.
13674 - =KEYWORDS= ::
13676      #+cindex: KEYWORDS, keyword
13677      The keywords for the document.  The ODT export back-end inserts
13678      the description along with author name, keywords, and related
13679      file metadata as metadata in the output file.  Use multiple
13680      =KEYWORDS= if necessary.
13682 - =ODT_STYLES_FILE= ::
13684      #+cindex: ODT_STYLES_FILE, keyword
13685      #+vindex: org-odt-styles-file
13686      The ODT export back-end uses the ~org-odt-styles-file~ by
13687      default.  See [[*Applying custom styles]] for details.
13689 - =SUBTITLE= ::
13691      #+cindex: SUBTITLE, keyword
13692      The document subtitle.
13694 *** Extending ODT export
13695 :PROPERTIES:
13696 :DESCRIPTION: Producing DOC, PDF files.
13697 :END:
13699 The ODT export back-end can produce documents in other formats besides
13700 ODT using a specialized ODT converter process.  Its common interface
13701 works with popular converters to produce formats such as =doc=, or
13702 convert a document from one format, say =csv=, to another format, say
13703 =xls=.
13705 #+cindex: @file{unoconv}
13706 #+vindex: org-odt-convert-process
13707 Customize ~org-odt-convert-process~ variable to point to =unoconv=,
13708 which is the ODT's preferred converter.  Working installations of
13709 LibreOffice would already have =unoconv= installed.  Alternatively,
13710 other converters may be substituted here.  See [[*Configuring
13711 a document converter]].
13713 **** Automatically exporting to other formats
13714 :PROPERTIES:
13715 :UNNUMBERED: notoc
13716 :END:
13718 #+vindex: org-odt-preferred-output-format
13719 If ODT format is just an intermediate step to get to other formats,
13720 such as =doc=, =docx=, =rtf=, or =pdf=, etc., then extend the ODT
13721 export back-end to directly produce that format.  Specify the final
13722 format in the ~org-odt-preferred-output-format~ variable.  This is one
13723 way to extend (see [[*ODT export commands]]).
13725 **** Converting between document formats
13726 :PROPERTIES:
13727 :UNNUMBERED: notoc
13728 :END:
13730 The Org export back-end is made to be inter-operable with a wide range
13731 of text document format converters.  Newer generation converters, such
13732 as LibreOffice and Pandoc, can handle hundreds of formats at once.
13733 Org provides a consistent interaction with whatever converter is
13734 installed.  Here are some generic commands:
13736 - {{{kbd(M-x org-odt-convert)}}} ::
13738      #+findex: org-odt-convert
13739      Convert an existing document from one format to another.  With
13740      a prefix argument, opens the newly produced file.
13742 *** Applying custom styles
13743 :PROPERTIES:
13744 :DESCRIPTION: Styling the output.
13745 :END:
13746 #+cindex: styles, custom
13747 #+cindex: template, custom
13749 The ODT export back-end comes with many OpenDocument styles (see
13750 [[*Working with OpenDocument style files]]).  To expand or further
13751 customize these built-in style sheets, either edit the style sheets
13752 directly or generate them using an application such as LibreOffice.
13753 The example here shows creating a style using LibreOffice.
13755 **** Applying custom styles: the easy way
13756 :PROPERTIES:
13757 :UNNUMBERED: notoc
13758 :END:
13760 1. Create a sample =example.org= file with settings as shown below,
13761    and export it to ODT format.
13763    : #+OPTIONS: H:10 num:t
13765 2. Open the above =example.odt= using LibreOffice.  Use the /Stylist/
13766    to locate the target styles, which typically have the "Org" prefix.
13767    Open one, modify, and save as either OpenDocument Text (ODT) or
13768    OpenDocument Template (OTT) file.
13771    #+vindex: org-odt-styles-file
13772    Customize the variable ~org-odt-styles-file~ and point it to the
13773    newly created file.  For additional configuration options, see
13774    [[x-overriding-factory-styles][Overriding factory styles]].
13776    #+cindex: ODT_STYLES_FILE, keyword
13777    To apply an ODT style to a particular file, use the
13778    =ODT_STYLES_FILE= keyword as shown in the example below:
13780    : #+ODT_STYLES_FILE: "/path/to/example.ott"
13782    #+texinfo: @noindent
13783    or
13785    : #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
13787 **** Using third-party styles and templates
13788 :PROPERTIES:
13789 :UNNUMBERED: notoc
13790 :END:
13792 The ODT export back-end relies on many templates and style names.
13793 Using third-party styles and templates can lead to mismatches.
13794 Templates derived from built in ODT templates and styles seem to have
13795 fewer problems.
13797 *** Links in ODT export
13798 :PROPERTIES:
13799 :DESCRIPTION: Handling and formatting links.
13800 :END:
13801 #+cindex: links, in ODT export
13803 ODT exporter creates native cross-references for internal links.  It
13804 creates Internet-style links for all other links.
13806 A link with no description and pointing to a regular, un-itemized,
13807 outline heading is replaced with a cross-reference and section number
13808 of the heading.
13810 A =\ref{label}=-style reference to an image, table etc., is replaced
13811 with a cross-reference and sequence number of the labeled entity.  See
13812 [[*Labels and captions in ODT export]].
13814 *** Tables in ODT export
13815 :PROPERTIES:
13816 :DESCRIPTION: Org tables conversions.
13817 :END:
13819 #+cindex: tables, in ODT export
13821 The ODT export back-end handles native Org mode tables (see [[*Tables]])
13822 and simple =table.el= tables.  Complex =table.el= tables having column
13823 or row spans are not supported.  Such tables are stripped from the
13824 exported document.
13826 By default, the ODT export back-end exports a table with top and
13827 bottom frames and with ruled lines separating row and column groups
13828 (see [[*Column Groups]]).  All tables are typeset to occupy the same
13829 width.  The ODT export back-end honors any table alignments and
13830 relative widths for columns (see [[*Column Width and Alignment]]).
13832 Note that the ODT export back-end interprets column widths as weighted
13833 ratios, the default weight being 1.
13835 #+cindex: ATTR_ODT, keyword
13836 Specifying =:rel-width= property on an =ATTR_ODT= line controls the
13837 width of the table.  For example:
13839 #+begin_example
13840   ,#+ATTR_ODT: :rel-width 50
13841   | Area/Month    |   Jan |   Feb |   Mar |   Sum |
13842   |---------------+-------+-------+-------+-------|
13843   | /             |     < |       |       |     < |
13844   | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
13845   | North America |     1 |    21 |   926 |   948 |
13846   | Middle East   |     6 |    75 |   844 |   925 |
13847   | Asia Pacific  |     9 |    27 |   790 |   826 |
13848   |---------------+-------+-------+-------+-------|
13849   | Sum           |    16 |   123 |  2560 |  2699 |
13850 #+end_example
13852 On export, the above table takes 50% of text width area.  The exporter
13853 sizes the columns in the ratio: 13:5:5:5:6.  The first column is
13854 left-aligned and rest of the columns, right-aligned.  Vertical rules
13855 separate the header and the last column.  Horizontal rules separate
13856 the header and the last row.
13858 For even more customization, create custom table styles and associate
13859 them with a table using the =ATTR_ODT= keyword.  See [[*Customizing
13860 tables in ODT export]].
13862 *** Images in ODT export
13863 :PROPERTIES:
13864 :DESCRIPTION: Inserting images.
13865 :END:
13866 #+cindex: images, embedding in ODT
13867 #+cindex: embedding images in ODT
13869 **** Embedding images
13870 :PROPERTIES:
13871 :UNNUMBERED: notoc
13872 :END:
13874 The ODT export back-end processes image links in Org files that do not
13875 have descriptions, such as these links =[[file:img.jpg]]= or =[[./img.jpg]]=,
13876 as direct image insertions in the final output.  Either of these
13877 examples works:
13879 : [[file:img.png]]
13881 : [[./img.png]]
13883 **** Embedding clickable images
13884 :PROPERTIES:
13885 :UNNUMBERED: notoc
13886 :END:
13888 For clickable images, provide a link whose description is another link
13889 to an image file.  For example, to embed a image
13890 =org-mode-unicorn.png= which when clicked jumps to https://orgmode.org
13891 website, do the following
13893 : [[https://orgmode.org][./org-mode-unicorn.png]]
13895 **** Sizing and scaling of embedded images
13896 :PROPERTIES:
13897 :UNNUMBERED: notoc
13898 :END:
13900 #+cindex: ATTR_ODT, keyword
13902 Control the size and scale of the embedded images with the =ATTR_ODT=
13903 attribute.
13905 #+cindex: identify, ImageMagick
13906 #+vindex: org-odt-pixels-per-inch
13907 The ODT export back-end starts with establishing the size of the image
13908 in the final document.  The dimensions of this size are measured in
13909 centimeters.  The back-end then queries the image file for its
13910 dimensions measured in pixels.  For this measurement, the back-end
13911 relies on ImageMagick's identify program or Emacs ~create-image~ and
13912 ~image-size~ API.  ImageMagick is the preferred choice for large file
13913 sizes or frequent batch operations.  The back-end then converts the
13914 pixel dimensions using ~org-odt-pixels-per-inch~ into the familiar 72
13915 dpi or 96 dpi.  The default value for this is in
13916 ~display-pixels-per-inch~, which can be tweaked for better results
13917 based on the capabilities of the output device.  Here are some common
13918 image scaling operations:
13920 - Explicitly size the image ::
13922      To embed =img.png= as a 10 cm x 10 cm image, do the following:
13924      #+begin_example
13925        ,#+ATTR_ODT: :width 10 :height 10
13926        [[./img.png]]
13927      #+end_example
13929 - Scale the image ::
13931      To embed =img.png= at half its size, do the following:
13933      #+begin_example
13934        ,#+ATTR_ODT: :scale 0.5
13935        [[./img.png]]
13936      #+end_example
13938 - Scale the image to a specific width ::
13940      To embed =img.png= with a width of 10 cm while retaining the
13941      original height:width ratio, do the following:
13943      #+begin_example
13944        ,#+ATTR_ODT: :width 10
13945        [[./img.png]]
13946      #+end_example
13948 - Scale the image to a specific height ::
13950      To embed =img.png= with a height of 10 cm while retaining the
13951      original height:width ratio, do the following:
13953      #+begin_example
13954        ,#+ATTR_ODT: :height 10
13955        [[./img.png]]
13956      #+end_example
13958 **** Anchoring of images
13959 :PROPERTIES:
13960 :UNNUMBERED: notoc
13961 :END:
13963 #+cindex: ATTR_ODT, keyword
13964 The ODT export back-end can anchor images to ="as-char"=,
13965 ="paragraph"=, or ="page"=.  Set the preferred anchor using the
13966 =:anchor= property of the =ATTR_ODT= line.
13968 To create an image that is anchored to a page:
13970 #+begin_example
13971   ,#+ATTR_ODT: :anchor "page"
13972   [[./img.png]]
13973 #+end_example
13975 *** Math formatting in ODT export
13976 :PROPERTIES:
13977 :DESCRIPTION: Formatting @LaTeX{} fragments.
13978 :END:
13980 The ODT exporter has special support for handling math.
13982 **** LaTeX math snippets
13983 :PROPERTIES:
13984 :DESCRIPTION: Embedding in @LaTeX{} format.
13985 :END:
13987 LaTeX math snippets (see [[*LaTeX fragments]]) can be embedded in the ODT
13988 document in one of the following ways:
13990 - MathML ::
13992      #+cindex: MathML
13993      Add this line to the Org file.  This option is activated on
13994      a per-file basis.
13996      : #+OPTIONS: tex:t
13998      With this option, LaTeX fragments are first converted into MathML
13999      fragments using an external LaTeX-to-MathML converter program.
14000      The resulting MathML fragments are then embedded as an
14001      OpenDocument Formula in the exported document.
14003      #+vindex: org-latex-to-mathml-convert-command
14004      #+vindex: org-latex-to-mathml-jar-file
14005      You can specify the LaTeX-to-MathML converter by customizing the
14006      variables ~org-latex-to-mathml-convert-command~ and
14007      ~org-latex-to-mathml-jar-file~.
14009      If you prefer to use MathToWeb[fn:125] as your converter, you can
14010      configure the above variables as shown below.
14012      #+begin_src emacs-lisp
14013        (setq org-latex-to-mathml-convert-command
14014              "java -jar %j -unicode -force -df %o %I"
14015              org-latex-to-mathml-jar-file
14016              "/path/to/mathtoweb.jar")
14017      #+end_src
14019      To use LaTeX​ML[fn:126] use
14021      #+begin_src emacs-lisp
14022        (setq org-latex-to-mathml-convert-command
14023              "latexmlmath \"%i\" --presentationmathml=%o")
14024      #+end_src
14026      To quickly verify the reliability of the LaTeX-to-MathML
14027      converter, use the following commands:
14029      - {{{kbd(M-x org-export-as-odf)}}} ::
14031           Convert a LaTeX math snippet to an OpenDocument formula
14032           (=.odf=) file.
14034      - {{{kbd(M-x org-export-as-odf-and-open)}}} ::
14036           Convert a LaTeX math snippet to an OpenDocument formula
14037           (=.odf=) file and open the formula file with the
14038           system-registered application.
14040 - PNG images ::
14042      #+cindex: dvipng
14043      #+cindex: dvisvgm
14044      #+cindex: ImageMagick
14045      Add this line to the Org file.  This option is activated on
14046      a per-file basis.
14048      : #+OPTIONS: tex:dvipng
14050      : #+OPTIONS: tex:dvisvgm
14052      #+texinfo: @noindent
14053      or
14055      : #+OPTIONS: tex:imagemagick
14057      Under this option, LaTeX fragments are processed into PNG or SVG
14058      images and the resulting images are embedded in the exported
14059      document.  This method requires dvipng program, dvisvgm or
14060      ImageMagick programs.
14062 **** MathML and OpenDocument formula files
14063 :PROPERTIES:
14064 :DESCRIPTION: Embedding in native format.
14065 :END:
14067 When embedding LaTeX math snippets in ODT documents is not reliable,
14068 there is one more option to try.  Embed an equation by linking to its
14069 MathML (=.mml=) source or its OpenDocument formula (=.odf=) file as
14070 shown below:
14072 : [[./equation.mml]]
14074 #+texinfo: @noindent
14077 : [[./equation.odf]]
14079 *** Labels and captions in ODT export
14080 :PROPERTIES:
14081 :DESCRIPTION: Rendering objects.
14082 :END:
14084 ODT format handles labeling and captioning of objects based on their
14085 types.  Inline images, tables, LaTeX fragments, and Math formulas are
14086 numbered and captioned separately.  Each object also gets a unique
14087 sequence number based on its order of first appearance in the Org
14088 file.  Each category has its own sequence.  A caption is just a label
14089 applied to these objects.
14091 #+begin_example
14092   ,#+CAPTION: Bell curve
14093   ,#+NAME:   fig:SED-HR4049
14094   [[./img/a.png]]
14095 #+end_example
14097 When rendered, it may show as follows in the exported document:
14099 : Figure 2: Bell curve
14101 #+vindex: org-odt-category-map-alist
14102 To modify the category component of the caption, customize the option
14103 ~org-odt-category-map-alist~.  For example, to tag embedded images
14104 with the string "Illustration" instead of the default string "Figure",
14105 use the following setting:
14107 #+begin_src emacs-lisp
14108   (setq org-odt-category-map-alist
14109         '(("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))
14110 #+end_src
14112 With the above modification, the previous example changes to:
14114 : Illustration 2: Bell curve
14116 *** Literal examples in ODT export
14117 :PROPERTIES:
14118 :DESCRIPTION: For source code and example blocks.
14119 :END:
14121 The ODT export back-end supports literal examples (see [[*Literal
14122 Examples]]) with full fontification.  Internally, the ODT export
14123 back-end relies on =htmlfontify.el= to generate the style definitions
14124 needed for fancy listings.  The auto-generated styles get =OrgSrc=
14125 prefix and inherit colors from the faces used by Emacs Font Lock
14126 library for that source language.
14128 #+vindex: org-odt-fontify-srcblocks
14129 For custom fontification styles, customize the
14130 ~org-odt-create-custom-styles-for-srcblocks~ option.
14132 #+vindex: org-odt-create-custom-styles-for-srcblocks
14133 To turn off fontification of literal examples, customize the
14134 ~org-odt-fontify-srcblocks~ option.
14136 *** Advanced topics in ODT export
14137 :PROPERTIES:
14138 :DESCRIPTION: For power users.
14139 :END:
14141 The ODT export back-end has extensive features useful for power users
14142 and frequent uses of ODT formats.
14144 **** Configuring a document converter
14145 :PROPERTIES:
14146 :DESCRIPTION: Registering a document converter.
14147 :UNNUMBERED: notoc
14148 :END:
14149 #+cindex: convert
14150 #+cindex: doc, docx, rtf
14151 #+cindex: converter
14153 The ODT export back-end works with popular converters with little or
14154 no extra configuration.  See [[*Extending ODT export]].  The following is
14155 for unsupported converters or tweaking existing defaults.
14157 - Register the converter ::
14159      #+vindex: org-export-odt-convert-processes
14160      Add the name of the converter to the ~org-odt-convert-processes~
14161      variable.  Note that it also requires how the converter is
14162      invoked on the command line.  See the variable's docstring for
14163      details.
14165 - Configure its capabilities ::
14167      #+vindex: org-export-odt-convert-capabilities
14168      Specify which formats the converter can handle by customizing the
14169      variable ~org-odt-convert-capabilities~.  Use the entry for the
14170      default values in this variable for configuring the new
14171      converter.  Also see its docstring for details.
14173 - Choose the converter ::
14175      #+vindex: org-export-odt-convert-process
14176      Select the newly added converter as the preferred one by
14177      customizing the option ~org-odt-convert-process~.
14179 **** Working with OpenDocument style files
14180 :PROPERTIES:
14181 :DESCRIPTION: Exploring internals.
14182 :UNNUMBERED: notoc
14183 :END:
14184 #+cindex: styles, custom
14185 #+cindex: template, custom
14187 This section explores the internals of the ODT exporter; the means by which
14188 it produces styled documents; the use of automatic and custom OpenDocument
14189 styles.
14191 The ODT exporter relies on two files for generating its output.  These
14192 files are bundled with the distribution under the directory pointed to
14193 by the variable ~org-odt-styles-dir~.  The two files are:
14195 - =OrgOdtStyles.xml= <<x-orgodtstyles-xml>> ::
14197      This file contributes to the =styles.xml= file of the final ODT
14198      document.  This file gets modified for the following purposes:
14200      1. To control outline numbering based on user settings;
14202      2. To add styles generated by =htmlfontify.el= for fontification of
14203         code blocks.
14205 - =OrgOdtContentTemplate.xml= <<x-orgodtcontenttemplate-xml>> ::
14207      This file contributes to the =content.xml= file of the final ODT
14208      document.  The contents of the Org outline are inserted between the
14209      =<office:text>= ... =</office:text>= elements of this file.
14211      Apart from serving as a template file for the final =content.xml=,
14212      the file serves the following purposes:
14214      1. It contains automatic styles for formatting of tables which are
14215         referenced by the exporter;
14217      2. It contains =<text:sequence-decl>= ... =</text:sequence-decl>=
14218         elements that control numbering of tables, images, equations, and
14219         similar entities.
14221 <<x-overriding-factory-styles>> The following two variables control
14222 the location from where the ODT exporter picks up the custom styles
14223 and content template files.  Customize these variables to override the
14224 factory styles used by the exporter.
14226 - ~org-odt-styles-file~ ::
14228      The ODT export back-end uses the file pointed to by this
14229      variable, such as =styles.xml=, for the final output.  It can
14230      take one of the following values:
14232      - =FILE.xml= ::
14234           Use this file instead of the default =styles.xml=
14236      - =FILE.odt= or =FILE.ott= ::
14238           Use the =styles.xml= contained in the specified OpenDocument
14239           Text or Template file
14241      - =FILE.odt= or =FILE.ott= and a subset of included files ::
14243           Use the =styles.xml= contained in the specified OpenDocument
14244           Text or Template file.  Additionally extract the specified
14245           member files and embed those within the final ODT document.
14247           Use this option if the =styles.xml= file references additional
14248           files like header and footer images.
14250      - ~nil~ ::
14252           Use the default =styles.xml=.
14254 - ~org-odt-content-template-file~ ::
14256      Use this variable to specify the blank =content.xml= used in the
14257      final output.
14259 **** Creating one-off styles
14260 :PROPERTIES:
14261 :DESCRIPTION: Customizing styles, highlighting...
14262 :UNNUMBERED: notoc
14263 :END:
14265 The ODT export back-end can read embedded raw OpenDocument XML from
14266 the Org file.  Such direct formatting is useful for one-off instances.
14268 - Embedding ODT tags as part of regular text ::
14270      Enclose OpenDocument syntax in =@@odt:...@@= for inline markup.
14271      For example, to highlight a region of text do the following:
14273      #+begin_example
14274        @@odt:<text:span text:style-name="Highlight">This is highlighted
14275        text</text:span>@@.  But this is regular text.
14276      #+end_example
14278      *Hint:* To see the above example in action, edit the =styles.xml=
14279      (see [[x-orgodtstyles-xml][Factory styles]]) and add a custom /Highlight/ style as shown
14280      below:
14282      #+begin_example
14283        <style:style style:name="Highlight" style:family="text">
14284          <style:text-properties fo:background-color="#ff0000"/>
14285        </style:style>
14286      #+end_example
14288 - Embedding a one-line OpenDocument XML ::
14290      #+cindex: ODT, keyword
14291      The ODT export back-end can read one-liner options with =#+ODT:=
14292      in the Org file.  For example, to force a page break:
14294      #+begin_example
14295        ,#+ODT: <text:p text:style-name="PageBreak"/>
14296      #+end_example
14298      *Hint:* To see the above example in action, edit your
14299      =styles.xml= (see [[x-orgodtstyles-xml][Factory styles]]) and add a custom =PageBreak=
14300      style as shown below.
14302      #+begin_example
14303        <style:style style:name="PageBreak" style:family="paragraph"
14304                     style:parent-style-name="Text_20_body">
14305          <style:paragraph-properties fo:break-before="page"/>
14306        </style:style>
14307      #+end_example
14309 - Embedding a block of OpenDocument XML ::
14311      The ODT export back-end can also read ODT export blocks for
14312      OpenDocument XML.  Such blocks use the =#+BEGIN_EXPORT odt=
14313      ... =#+END_EXPORT= constructs.
14315      For example, to create a one-off paragraph that uses bold text,
14316      do the following:
14318      #+begin_example
14319        ,#+BEGIN_EXPORT odt
14320          <text:p text:style-name="Text_20_body_20_bold">
14321          This paragraph is specially formatted and uses bold text.
14322          </text:p>
14323        ,#+END_EXPORT
14324      #+end_example
14326 **** Customizing tables in ODT export
14327 :PROPERTIES:
14328 :DESCRIPTION: Defining table templates.
14329 :UNNUMBERED: notoc
14330 :END:
14331 #+cindex: tables, in ODT export
14332 #+cindex: ATTR_ODT, keyword
14334 Override the default table format by specifying a custom table style
14335 with the =#+ATTR_ODT= line.  For a discussion on default formatting of
14336 tables, see [[*Tables in ODT export]].
14338 This feature closely mimics the way table templates are defined in the
14339 OpenDocument-v1.2 specification.[fn:127]
14341 #+vindex: org-odt-table-styles
14342 For quick preview of this feature, install the settings below and export the
14343 table that follows:
14345 #+begin_src emacs-lisp
14346   (setq org-export-odt-table-styles
14347         (append org-export-odt-table-styles
14348                 '(("TableWithHeaderRowAndColumn" "Custom"
14349                    ((use-first-row-styles . t)
14350                     (use-first-column-styles . t)))
14351                   ("TableWithFirstRowandLastRow" "Custom"
14352                    ((use-first-row-styles . t)
14353                     (use-last-row-styles . t))))))
14354 #+end_src
14356 #+begin_example
14357   ,#+ATTR_ODT: :style TableWithHeaderRowAndColumn
14358   | Name  | Phone | Age |
14359   | Peter |  1234 |  17 |
14360   | Anna  |  4321 |  25 |
14361 #+end_example
14363 The example above used =Custom= template and installed two table
14364 styles =TableWithHeaderRowAndColumn= and
14365 =TableWithFirstRowandLastRow=.  *Important:* The OpenDocument styles
14366 needed for producing the above template were pre-defined.  They are
14367 available in the section marked =Custom Table Template= in
14368 =OrgOdtContentTemplate.xml= (see [[x-orgodtcontenttemplate-xml][Factory styles]]).  For adding new
14369 templates, define new styles there.
14371 To use this feature proceed as follows:
14373 1. Create a table template[fn:128].
14375    A table template is set of =table-cell= and =paragraph= styles for
14376    each of the following table cell categories:
14378    - Body
14379    - First column
14380    - Last column
14381    - First row
14382    - Last row
14383    - Even row
14384    - Odd row
14385    - Even column
14386    - Odd Column
14388    The names for the above styles must be chosen based on the name of
14389    the table template using a well-defined convention.
14391    The naming convention is better illustrated with an example.  For
14392    a table template with the name =Custom=, the needed style names are
14393    listed in the following table.
14395    | Cell type    | Cell style                   | Paragraph style                   |
14396    |--------------+------------------------------+-----------------------------------|
14397    | Body         | =CustomTableCell=            | =CustomTableParagraph=            |
14398    | First column | =CustomFirstColumnTableCell= | =CustomFirstColumnTableParagraph= |
14399    | Last column  | =CustomLastColumnTableCell=  | =CustomLastColumnTableParagraph=  |
14400    | First row    | =CustomFirstRowTableCell=    | =CustomFirstRowTableParagraph=    |
14401    | Last row     | =CustomLastRowTableCell=     | =CustomLastRowTableParagraph=     |
14402    | Even row     | =CustomEvenRowTableCell=     | =CustomEvenRowTableParagraph=     |
14403    | Odd row      | =CustomOddRowTableCell=      | =CustomOddRowTableParagraph=      |
14404    | Even column  | =CustomEvenColumnTableCell=  | =CustomEvenColumnTableParagraph=  |
14405    | Odd column   | =CustomOddColumnTableCell=   | =CustomOddColumnTableParagraph=   |
14407    To create a table template with the name =Custom=, define the above
14408    styles in the =<office:automatic-styles>= ...
14409    =</office:automatic-styles>= element of the content template file
14410    (see [[x-orgodtcontenttemplate-xml][Factory styles]]).
14412 2. Define a table style[fn:129].
14414    #+vindex: org-odt-table-styles
14415    To define a table style, create an entry for the style in the
14416    variable ~org-odt-table-styles~ and specify the following:
14418    - the name of the table template created in step (1),
14419    - the set of cell styles in that template that are to be activated.
14421    For example, the entry below defines two different table styles
14422    =TableWithHeaderRowAndColumn= and =TableWithFirstRowandLastRow=
14423    based on the same template =Custom=.  The styles achieve their
14424    intended effect by selectively activating the individual cell
14425    styles in that template.
14427    #+begin_src emacs-lisp
14428      (setq org-export-odt-table-styles
14429            (append org-export-odt-table-styles
14430                    '(("TableWithHeaderRowAndColumn" "Custom"
14431                       ((use-first-row-styles . t)
14432                        (use-first-column-styles . t)))
14433                      ("TableWithFirstRowandLastRow" "Custom"
14434                       ((use-first-row-styles . t)
14435                        (use-last-row-styles . t))))))
14436    #+end_src
14438 3. Associate a table with the table style.
14440    To do this, specify the table style created in step (2) as part of
14441    the =ATTR_ODT= line as shown below.
14443    #+begin_example
14444      ,#+ATTR_ODT: :style TableWithHeaderRowAndColumn
14445      | Name  | Phone | Age |
14446      | Peter |  1234 |  17 |
14447      | Anna  |  4321 |  25 |
14448    #+end_example
14450 **** Validating OpenDocument XML
14451 :PROPERTIES:
14452 :DESCRIPTION: Debugging corrupted OpenDocument files.
14453 :UNNUMBERED: notoc
14454 :END:
14456 Sometimes ODT format files may not open due to =.odt= file corruption.
14457 To verify if such a file is corrupt, validate it against the
14458 OpenDocument Relax NG Compact (RNC) syntax schema.  But first the
14459 =.odt= files have to be decompressed using =zip=.  Note that =.odt=
14460 files are ZIP archives: [[info:emacs::File Archives]].  The contents of
14461 ODT files are in XML.  For general help with validation---and
14462 schema-sensitive editing---of XML files:
14463 [[info:nxml-mode::Introduction]].
14465 #+vindex: org-export-odt-schema-dir
14466 Customize ~org-odt-schema-dir~ to point to a directory with
14467 OpenDocument RNC files and the needed schema-locating rules.  The ODT
14468 export back-end takes care of updating the
14469 ~rng-schema-locating-files~.
14471 ** Org Export
14472 :PROPERTIES:
14473 :DESCRIPTION: Exporting to Org.
14474 :END:
14476 #+cindex: Org export
14477 /org/ export back-end creates a normalized version of the Org document
14478 in current buffer.  The exporter evaluates Babel code (see [[*Evaluating
14479 Code Blocks]]) and removes content specific to other back-ends.
14481 *** Org export commands
14482 :PROPERTIES:
14483 :UNNUMBERED: notoc
14484 :END:
14486 - {{{kbd(C-c C-e O o)}}} (~org-org-export-to-org~) ::
14488      #+kindex: C-c C-e O o
14489      #+findex: org-org-export-to-org
14490      Export as an Org file with a =.org= extension.  For =myfile.org=,
14491      Org exports to =myfile.org.org=, overwriting without warning.
14493 - {{{kbd(C-c C-e O v)}}} (~~) ::
14495      #+kindex: C-c C-e O v
14496      Export to an Org file, then open it.
14498 ** Texinfo Export
14499 :PROPERTIES:
14500 :DESCRIPTION: Exporting to Texinfo.
14501 :END:
14503 *** Texinfo export commands
14504 :PROPERTIES:
14505 :DESCRIPTION: Invoking commands.
14506 :END:
14508 - {{{kbd(C-c C-e i t)}}} (~org-texinfo-export-to-texinfo~) ::
14510      #+kindex: C-c C-e i t
14511      #+findex: org-texinfo-export-to-texinfo
14512      Export as a Texinfo file with =.texi= extension.  For
14513      =myfile.org=, Org exports to =myfile.texi=, overwriting without
14514      warning.
14516 - {{{kbd(C-c C-e i i)}}} (~org-texinfo-export-to-info~) ::
14518      #+kindex: C-c C-e i i
14519      #+findex: org-texinfo-export-to-info
14520      #+vindex: org-texinfo-info-process
14521      Export to Texinfo format first and then process it to make an
14522      Info file.  To generate other formats, such as DocBook, customize
14523      the ~org-texinfo-info-process~ variable.
14525 *** Texinfo specific export settings
14526 :PROPERTIES:
14527 :DESCRIPTION: Setting the environment.
14528 :END:
14530 The Texinfo export back-end has several additional keywords for
14531 customizing Texinfo output.  Setting these keywords works similar to
14532 the general options (see [[*Export Settings]]).
14534 - =SUBTITLE= ::
14536      #+cindex: SUBTITLE, keyword
14537      The document subtitle.
14539 - =SUBAUTHOR= ::
14541      #+cindex: SUBAUTHOR, keyword
14542      Additional authors for the document.
14544 - =TEXINFO_FILENAME= ::
14546      #+cindex: TEXINFO_FILENAME, keyword
14547      The Texinfo filename.
14549 - =TEXINFO_CLASS= ::
14551      #+cindex: TEXINFO_CLASS, keyword
14552      #+vindex: org-texinfo-default-class
14553      The default document class (~org-texinfo-default-class~), which
14554      must be a member of ~org-texinfo-classes~.
14556 - =TEXINFO_HEADER= ::
14558      #+cindex: TEXINFO_HEADER, keyword
14559      Arbitrary lines inserted at the end of the header.
14561 - =TEXINFO_POST_HEADER= ::
14563      #+cindex: TEXINFO_POST_HEADER, keyword
14564      Arbitrary lines inserted after the end of the header.
14566 - =TEXINFO_DIR_CATEGORY= ::
14568      #+cindex: TEXINFO_DIR_CATEGORY, keyword
14569      The directory category of the document.
14571 - =TEXINFO_DIR_TITLE= ::
14573      #+cindex: TEXINFO_DIR_TITLE, keyword
14574      The directory title of the document.
14576 - =TEXINFO_DIR_DESC= ::
14578      #+cindex: TEXINFO_DIR_DESC, keyword
14579      The directory description of the document.
14581 - =TEXINFO_PRINTED_TITLE= ::
14583      #+cindex: TEXINFO_PRINTED_TITLE, keyword
14584      The printed title of the document.
14586 *** Texinfo file header
14587 :PROPERTIES:
14588 :DESCRIPTION: Generating the header.
14589 :END:
14591 #+cindex: TEXINFO_FILENAME, keyword
14592 After creating the header for a Texinfo file, the Texinfo back-end
14593 automatically generates a name and destination path for the Info file.
14594 To override this default with a more sensible path and name, specify
14595 the =TEXINFO_FILENAME= keyword.
14597 #+vindex: org-texinfo-coding-system
14598 #+cindex: TEXINFO_HEADER, keyword
14599 Along with the output's file name, the Texinfo header also contains
14600 language details (see [[*Export Settings]]) and encoding system as set in
14601 the ~org-texinfo-coding-system~ variable.  Insert =TEXINFO_HEADER=
14602 keywords for each additional command in the header, for example:
14604 : #+TEXINFO_HEADER: @synindex
14606 #+cindex: TEXINFO_CLASS, keyword
14607 #+vindex: org-texinfo-classes
14608 Instead of repeatedly installing the same set of commands, define
14609 a class in ~org-texinfo-classes~ once, and then activate it in the
14610 document by setting the =TEXINFO_CLASS= keyword to that class.
14612 *** Texinfo title and copyright page
14613 :PROPERTIES:
14614 :DESCRIPTION: Creating preamble pages.
14615 :END:
14617 #+cindex: TEXINFO_PRINTED_TITLE, keyword
14618 The default template for hard copy output has a title page with
14619 =TITLE= and =AUTHOR= keywords (see [[*Export Settings]]).  To replace the
14620 regular title with something different for the printed version, use
14621 the =TEXINFO_PRINTED_TITLE= and =SUBTITLE= keywords.  Both expect raw
14622 Texinfo code for setting their values.
14624 #+cindex: SUBAUTHOR, keyword
14625 If one =AUTHOR= line is not sufficient, add multiple =SUBAUTHOR=
14626 keywords.  They have to be set in raw Texinfo code.
14628 #+begin_example
14629   ,#+AUTHOR: Jane Smith
14630   ,#+SUBAUTHOR: John Doe
14631   ,#+TEXINFO_PRINTED_TITLE: This Long Title@@inlinefmt{tex,@*} Is Broken in @TeX{}
14632 #+end_example
14634 #+cindex: COPYING, property
14635 Copying material is defined in a dedicated headline with a non-~nil~
14636 =COPYING= property.  The back-end inserts the contents within
14637 a =@copying= command at the beginning of the document.  The heading
14638 itself does not appear in the structure of the document.
14640 Copyright information is printed on the back of the title page.
14642 #+begin_example
14643   ,* Legalese
14644     :PROPERTIES:
14645     :COPYING: t
14646     :END:
14648     This is a short example of a complete Texinfo file, version 1.0.
14650     Copyright \copy 2016 Free Software Foundation, Inc.
14651 #+end_example
14653 *** Info directory file
14654 :PROPERTIES:
14655 :DESCRIPTION: Installing a manual in Info file hierarchy.
14656 :END:
14658 #+cindex: @samp{dir} file, in Texinfo export
14659 #+cindex: Info directory file, in Texinfo export
14660 #+cindex: @code{install-info}, in Texinfo export
14662 #+cindex: TEXINFO_DIR_CATEGORY, keyword
14663 #+cindex: TEXINFO_DIR_TITLE, keyword
14664 #+cindex: TEXINFO_DIR_DESC, keyword
14665 The end result of the Texinfo export process is the creation of an
14666 Info file.  This Info file's metadata has variables for category,
14667 title, and description: =TEXINFO_DIR_CATEGORY=, =TEXINFO_DIR_TITLE=,
14668 and =TEXINFO_DIR_DESC= keywords that establish where in the Info
14669 hierarchy the file fits.
14671 Here is an example that writes to the Info directory file:
14673 #+begin_example
14674   ,#+TEXINFO_DIR_CATEGORY: Emacs
14675   ,#+TEXINFO_DIR_TITLE: Org Mode: (org)
14676   ,#+TEXINFO_DIR_DESC: Outline-based notes management and organizer
14677 #+end_example
14679 *** Headings and sectioning structure
14680 :PROPERTIES:
14681 :DESCRIPTION: Building document structure.
14682 :END:
14684 #+vindex: org-texinfo-classes
14685 #+vindex: org-texinfo-default-class
14686 #+cindex: TEXINFO_CLASS, keyword
14687 The Texinfo export back-end uses a pre-defined scheme to convert Org
14688 headlines to equivalent Texinfo structuring commands.  A scheme like
14689 this maps top-level headlines to numbered chapters tagged as
14690 ~@chapter~ and lower-level headlines to unnumbered chapters tagged as
14691 ~@unnumbered~.  To override such mappings to introduce ~@part~ or
14692 other Texinfo structuring commands, define a new class in
14693 ~org-texinfo-classes~.  Activate the new class with the
14694 =TEXINFO_CLASS= keyword.  When no new class is defined and activated,
14695 the Texinfo export back-end defaults to the
14696 ~org-texinfo-default-class~.
14698 If an Org headline's level has no associated Texinfo structuring
14699 command, or is below a certain threshold (see [[*Export Settings]]), then
14700 the Texinfo export back-end makes it into a list item.
14702 #+cindex: APPENDIX, property
14703 The Texinfo export back-end makes any headline with a non-~nil~
14704 =APPENDIX= property into an appendix.  This happens independent of the
14705 Org headline level or the =TEXINFO_CLASS= keyword.
14707 #+cindex: ALT_TITLE, property
14708 #+cindex: DESCRIPTION, property
14709 The Texinfo export back-end creates a menu entry after the Org
14710 headline for each regular sectioning structure.  To override this with
14711 a shorter menu entry, use the =ALT_TITLE= property (see [[*Table of
14712 Contents]]).  Texinfo menu entries also have an option for a longer
14713 =DESCRIPTION= property.  Here's an example that uses both to override
14714 the default menu entry:
14716 #+begin_example
14717 ,* Controlling Screen Display
14718   :PROPERTIES:
14719   :ALT_TITLE: Display
14720   :DESCRIPTION: Controlling Screen Display
14721   :END:
14722 #+end_example
14724 #+cindex: Top node, in Texinfo export
14725 The text before the first headline belongs to the /Top/ node, i.e.,
14726 the node in which a reader enters an Info manual.  As such, it is
14727 expected not to appear in printed output generated from the =.texi=
14728 file.  See [[info:texinfo::The%20Top%20Node]], for more information.
14730 *** Indices
14731 :PROPERTIES:
14732 :DESCRIPTION: Creating indices.
14733 :END:
14735 #+cindex: CINDEX, keyword
14736 #+cindex: concept index, in Texinfo export
14737 #+cindex: FINDEX, keyword
14738 #+cindex: function index, in Texinfo export
14739 #+cindex: KINDEX, keyword
14740 #+cindex: keystroke index, in Texinfo export
14741 #+cindex: PINDEX, keyword
14742 #+cindex: program index, in Texinfo export
14743 #+cindex: TINDEX, keyword
14744 #+cindex: data type index, in Texinfo export
14745 #+cindex: VINDEX, keyword
14746 #+cindex: variable index, in Texinfo export
14747 The Texinfo export back-end recognizes these indexing keywords if used
14748 in the Org file: =CINDEX=, =FINDEX=, =KINDEX=, =PINDEX=, =TINDEX= and
14749 =VINDEX=.  Write their value as verbatim Texinfo code; in particular,
14750 ={=, =}= and =@= characters need to be escaped with =@= if they do not
14751 belong to a Texinfo command.
14753 : #+CINDEX: Defining indexing entries
14755 #+cindex: INDEX, property
14756 For the back-end to generate an index entry for a headline, set the
14757 =INDEX= property to =cp= or =vr=.  These abbreviations come from
14758 Texinfo that stand for concept index and variable index.  The Texinfo
14759 manual has abbreviations for all other kinds of indexes.  The back-end
14760 exports the headline as an unnumbered chapter or section command, and
14761 then inserts the index after its contents.
14763 #+begin_example
14764   ,* Concept Index
14765     :PROPERTIES:
14766     :INDEX: cp
14767     :END:
14768 #+end_example
14770 *** Quoting Texinfo code
14771 :PROPERTIES:
14772 :DESCRIPTION: Incorporating literal Texinfo code.
14773 :END:
14775 Use any of the following three methods to insert or escape raw Texinfo
14776 code:
14778 #+cindex: TEXINFO, keyword
14779 #+cindex: BEGIN_EXPORT texinfo
14780 #+begin_example
14781   Richard @@texinfo:@sc{@@Stallman@@texinfo:}@@ commence' GNU.
14783   ,#+TEXINFO: @need800
14784   This paragraph is preceded by...
14786   ,#+BEGIN_EXPORT texinfo
14787     @auindex Johnson, Mark
14788     @auindex Lakoff, George
14789   ,#+END_EXPORT
14790 #+end_example
14792 *** Plain lists in Texinfo export
14793 :PROPERTIES:
14794 :DESCRIPTION: List attributes.
14795 :END:
14797 #+cindex: ATTR_TEXINFO, keyword
14798 #+cindex: two-column tables, in Texinfo export
14800 #+cindex: table types, in Texinfo export
14801 The Texinfo export back-end by default converts description lists in
14802 the Org file using the default command =@table=, which results in
14803 a table with two columns.  To change this behavior, specify
14804 =:table-type= with =ftable= or =vtable= attributes.  For more
14805 information, see [[info:texinfo::Two-column Tables]].
14807 #+vindex: org-texinfo-table-default-markup
14808 The Texinfo export back-end by default also applies a text highlight
14809 based on the defaults stored in ~org-texinfo-table-default-markup~.
14810 To override the default highlight command, specify another one with
14811 the =:indic= attribute.
14813 #+cindex: multiple items in Texinfo lists
14814 Org syntax is limited to one entry per list item.  Nevertheless, the
14815 Texinfo export back-end can split that entry according to any text
14816 provided through the =:sep= attribute.  Each part then becomes a new
14817 entry in the first column of the table.
14819 The following example illustrates all the attributes above:
14821 #+begin_example
14822   ,#+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
14823   - foo, bar :: This is the common text for variables foo and bar.
14824 #+end_example
14826 #+texinfo: @noindent
14827 becomes
14829 #+begin_example
14830   @vtable @asis
14831   @item foo
14832   @itemx bar
14833   This is the common text for variables foo and bar.
14834   @end table
14835 #+end_example
14837 *** Tables in Texinfo export
14838 :PROPERTIES:
14839 :DESCRIPTION: Table attributes.
14840 :END:
14842 #+cindex: ATTR_TEXINFO, keyword
14843 When exporting tables, the Texinfo export back-end uses the widest
14844 cell width in each column.  To override this and instead specify as
14845 fractions of line length, use the =:columns= attribute.  See example
14846 below.
14848 #+begin_example
14849 #+ATTR_TEXINFO: :columns .5 .5
14850 | a cell | another cell |
14851 #+end_example
14853 *** Images in Texinfo export
14854 :PROPERTIES:
14855 :DESCRIPTION: Image attributes.
14856 :END:
14858 #+cindex: ATTR_TEXINFO, keyword
14859 Insert a file link to the image in the Org file, and the Texinfo
14860 export back-end inserts the image.  These links must have the usual
14861 supported image extensions and no descriptions.  To scale the image,
14862 use =:width= and =:height= attributes.  For alternate text, use =:alt=
14863 and specify the text using Texinfo code, as shown in the example:
14865 #+begin_example
14866   ,#+ATTR_TEXINFO: :width 1in :alt Alternate @i{text}
14867   [[ridt.pdf]]
14868 #+end_example
14870 *** Special blocks in Texinfo export
14871 :PROPERTIES:
14872 :DESCRIPTION: Special block attributes.
14873 :END:
14875 #+cindex: ATTR_TEXINFO, keyword
14877 The Texinfo export back-end converts special blocks to commands with
14878 the same name.  It also adds any =:options= attributes to the end of
14879 the command, as shown in this example:
14881 #+begin_example
14882   ,#+ATTR_TEXINFO: :options org-org-export-to-org ...
14883   ,#+BEGIN_defun
14884     A somewhat obsessive function name.
14885   ,#+END_defun
14886 #+end_example
14888 #+texinfo: @noindent
14889 becomes
14891 #+begin_example
14892   @defun org-org-export-to-org ...
14893     A somewhat obsessive function name.
14894   @end defun
14895 #+end_example
14897 *** A Texinfo example
14898 :PROPERTIES:
14899 :DESCRIPTION: Processing Org to Texinfo.
14900 :END:
14902 Here is a more detailed example Org file.  See
14903 [[info:texinfo::GNU%20Sample%20Texts]] for an equivalent example using
14904 Texinfo code.
14906 #+begin_example
14907   ,#+TITLE: GNU Sample {{{version}}}
14908   ,#+SUBTITLE: for version {{{version}}}, {{{updated}}}
14909   ,#+AUTHOR: A.U. Thor
14910   ,#+EMAIL: bug-sample@gnu.org
14912   ,#+OPTIONS: ':t toc:t author:t email:t
14913   ,#+LANGUAGE: en
14915   ,#+MACRO: version 2.0
14916   ,#+MACRO: updated last updated 4 March 2014
14918   ,#+TEXINFO_FILENAME: sample.info
14919   ,#+TEXINFO_HEADER: @syncodeindex pg cp
14921   ,#+TEXINFO_DIR_CATEGORY: Texinfo documentation system
14922   ,#+TEXINFO_DIR_TITLE: sample: (sample)
14923   ,#+TEXINFO_DIR_DESC: Invoking sample
14925   ,#+TEXINFO_PRINTED_TITLE: GNU Sample
14927   This manual is for GNU Sample (version {{{version}}},
14928   {{{updated}}}).
14930   ,* Copying
14931     :PROPERTIES:
14932     :COPYING:  t
14933     :END:
14935     This manual is for GNU Sample (version {{{version}}},
14936     {{{updated}}}), which is an example in the Texinfo documentation.
14938     Copyright \copy 2016 Free Software Foundation, Inc.
14940     ,#+BEGIN_QUOTE
14941     Permission is granted to copy, distribute and/or modify this
14942     document under the terms of the GNU Free Documentation License,
14943     Version 1.3 or any later version published by the Free Software
14944     Foundation; with no Invariant Sections, with no Front-Cover Texts,
14945     and with no Back-Cover Texts.  A copy of the license is included in
14946     the section entitled "GNU Free Documentation License".
14947     ,#+END_QUOTE
14949   ,* Invoking sample
14951     ,#+PINDEX: sample
14952     ,#+CINDEX: invoking @command{sample}
14954     This is a sample manual.  There is no sample program to invoke, but
14955     if there were, you could see its basic usage and command line
14956     options here.
14958   ,* GNU Free Documentation License
14959     :PROPERTIES:
14960     :APPENDIX: t
14961     :END:
14963     ,#+TEXINFO: @include fdl.texi
14965   ,* Index
14966     :PROPERTIES:
14967     :INDEX:    cp
14968     :END:
14969 #+end_example
14971 ** iCalendar Export
14972 :PROPERTIES:
14973 :DESCRIPTION: Exporting to iCalendar.
14974 :END:
14975 #+cindex: iCalendar export
14977 A large part of Org mode's interoperability success is its ability to
14978 easily export to or import from external applications.  The iCalendar
14979 export back-end takes calendar data from Org files and exports to the
14980 standard iCalendar format.
14982 #+vindex: org-icalendar-include-todo
14983 #+vindex: org-icalendar-use-deadline
14984 #+vindex: org-icalendar-use-scheduled
14985 The iCalendar export back-end can also incorporate TODO entries based
14986 on the configuration of the ~org-icalendar-include-todo~ variable.
14987 The back-end exports plain timestamps as =VEVENT=, TODO items as
14988 =VTODO=, and also create events from deadlines that are in non-TODO
14989 items.  The back-end uses the deadlines and scheduling dates in Org
14990 TODO items for setting the start and due dates for the iCalendar TODO
14991 entry.  Consult the ~org-icalendar-use-deadline~ and
14992 ~org-icalendar-use-scheduled~ variables for more details.
14994 #+vindex: org-icalendar-categories
14995 #+vindex: org-icalendar-alarm-time
14996 For tags on the headline, the iCalendar export back-end makes them
14997 into iCalendar categories.  To tweak the inheritance of tags and TODO
14998 states, configure the variable ~org-icalendar-categories~.  To assign
14999 clock alarms based on time, configure the ~org-icalendar-alarm-time~
15000 variable.
15002 #+vindex: org-icalendar-store-UID
15003 #+cindex: ID, property
15004 The iCalendar format standard requires globally unique identifier---or
15005 UID---for each entry.  The iCalendar export back-end creates UIDs
15006 during export.  To save a copy of the UID in the Org file set the
15007 variable ~org-icalendar-store-UID~.  The back-end looks for the =ID=
15008 property of the entry for re-using the same UID for subsequent
15009 exports.
15011 Since a single Org entry can result in multiple iCalendar
15012 entries---timestamp, deadline, scheduled item, or TODO item---Org adds
15013 prefixes to the UID, depending on which part of the Org entry
15014 triggered the creation of the iCalendar entry.  Prefixing ensures UIDs
15015 remains unique, yet enable synchronization programs trace the
15016 connections.
15018 - {{{kbd(C-c C-e c f)}}} (~org-icalendar-export-to-ics~) ::
15020      #+kindex: C-c C-e c f
15021      #+findex: org-icalendar-export-to-ics
15022      Create iCalendar entries from the current Org buffer and store
15023      them in the same directory, using a file extension =.ics=.
15025 - {{{kbd(C-c C-e c a)}}} (~org-icalendar-export-agenda-files~) ::
15027      #+kindex: C-c C-e c a
15028      #+findex: org-icalendar-export-agenda-files
15029      Create iCalendar entries from Org files in ~org-agenda-files~ and
15030      store in a separate iCalendar file for each Org file.
15032 - {{{kbd(C-c C-e c c)}}} (~org-icalendar-combine-agenda-files~) ::
15034      #+kindex: C-c C-e c c
15035      #+findex: org-icalendar-combine-agenda-files
15036      #+vindex: org-icalendar-combined-agenda-file
15037      Create a combined iCalendar file from Org files in
15038      ~org-agenda-files~ and write it to
15039      ~org-icalendar-combined-agenda-file~ file name.
15041 #+cindex: SUMMARY, property
15042 #+cindex: DESCRIPTION, property
15043 #+cindex: LOCATION, property
15044 #+cindex: TIMEZONE, property
15045 The iCalendar export back-end includes =SUMMARY=, =DESCRIPTION=,
15046 =LOCATION= and =TIMEZONE= properties from the Org entries when
15047 exporting.  To force the back-end to inherit the =LOCATION= and
15048 =TIMEZONE= properties, configure the ~org-use-property-inheritance~
15049 variable.
15051 #+vindex: org-icalendar-include-body
15052 When Org entries do not have =SUMMARY=, =DESCRIPTION= and =LOCATION=
15053 properties, the iCalendar export back-end derives the summary from the
15054 headline, and derives the description from the body of the Org item.
15055 The ~org-icalendar-include-body~ variable limits the maximum number of
15056 characters of the content are turned into its description.
15058 The =TIMEZONE= property can be used to specify a per-entry time zone,
15059 and is applied to any entry with timestamp information.  Time zones
15060 should be specified as per the IANA time zone database format, e.g.,
15061 =Asia/Almaty=.  Alternately, the property value can be =UTC=, to force
15062 UTC time for this entry only.
15064 Exporting to iCalendar format depends in large part on the
15065 capabilities of the destination application.  Some are more lenient
15066 than others.  Consult the Org mode FAQ for advice on specific
15067 applications.
15069 ** Other Built-in Back-ends
15070 :PROPERTIES:
15071 :DESCRIPTION: Exporting to a man page.
15072 :END:
15074 Other export back-ends included with Org are:
15076 - =ox-man.el=: Export to a man page.
15078 To activate such back-ends, either customize ~org-export-backends~ or
15079 load directly with ~(require 'ox-man)~.  On successful load, the
15080 back-end adds new keys in the export dispatcher (see [[*The Export
15081 Dispatcher]]).
15083 Follow the comment section of such files, for example, =ox-man.el=,
15084 for usage and configuration details.
15086 ** Advanced Configuration
15087 :PROPERTIES:
15088 :DESCRIPTION: Fine-tuning the export output.
15089 :END:
15091 *** Hooks
15092 :PROPERTIES:
15093 :UNNUMBERED: notoc
15094 :END:
15096 #+vindex: org-export-before-processing-hook
15097 #+vindex: org-export-before-parsing-hook
15098 The export process executes two hooks before the actual exporting
15099 begins.  The first hook, ~org-export-before-processing-hook~, runs
15100 before any expansions of macros, Babel code, and include keywords in
15101 the buffer.  The second hook, ~org-export-before-parsing-hook~, runs
15102 before the buffer is parsed.
15104 Functions added to these hooks are called with a single argument: the
15105 export back-end actually used, as a symbol.  You may use them for
15106 heavy duty structural modifications of the document.  For example, you
15107 can remove every headline in the buffer during export like this:
15109 #+begin_src emacs-lisp
15110   (defun my-headline-removal (backend)
15111     "Remove all headlines in the current buffer.
15112   BACKEND is the export back-end being used, as a symbol."
15113     (org-map-entries
15114      (lambda () (delete-region (point) (line-beginning-position 2)))))
15116   (add-hook 'org-export-before-parsing-hook 'my-headline-removal)
15117 #+end_src
15119 *** Filters
15120 :PROPERTIES:
15121 :UNNUMBERED: notoc
15122 :END:
15124 #+cindex: Filters, exporting
15125 Filters are lists of functions to be applied to certain parts for
15126 a given back-end.  The output from the first function in the filter is
15127 passed on to the next function in the filter.  The final output is the
15128 output from the final function in the filter.
15130 The Org export process has many filter sets applicable to different
15131 types of objects, plain text, parse trees, export options, and final
15132 output formats.  The filters are named after the element type or
15133 object type: ~org-export-filter-TYPE-functions~, where {{{var(TYPE)}}}
15134 is the type targeted by the filter.  Valid types are:
15136 #+attr_texinfo: :columns 0.33 0.33 0.33
15137 | body                | bold               | babel-call       |
15138 | center-block        | clock              | code             |
15139 | diary-sexp          | drawer             | dynamic-block    |
15140 | entity              | example-block      | export-block     |
15141 | export-snippet      | final-output       | fixed-width      |
15142 | footnote-definition | footnote-reference | headline         |
15143 | horizontal-rule     | inline-babel-call  | inline-src-block |
15144 | inlinetask          | italic             | item             |
15145 | keyword             | latex-environment  | latex-fragment   |
15146 | line-break          | link               | node-property    |
15147 | options             | paragraph          | parse-tree       |
15148 | plain-list          | plain-text         | planning         |
15149 | property-drawer     | quote-block        | radio-target     |
15150 | section             | special-block      | src-block        |
15151 | statistics-cookie   | strike-through     | subscript        |
15152 | superscript         | table              | table-cell       |
15153 | table-row           | target             | timestamp        |
15154 | underline           | verbatim           | verse-block      |
15156 Here is an example filter that replaces non-breaking spaces ~ ~ in the
15157 Org buffer with =~= for the LaTeX back-end.
15159 #+begin_src emacs-lisp
15160   (defun my-latex-filter-nobreaks (text backend info)
15161     "Ensure \" \" are properly handled in LaTeX export."
15162     (when (org-export-derived-backend-p backend 'latex)
15163       (replace-regexp-in-string " " "~" text)))
15165   (add-to-list 'org-export-filter-plain-text-functions
15166                'my-latex-filter-nobreaks)
15167 #+end_src
15169 A filter requires three arguments: the code to be transformed, the
15170 name of the back-end, and some optional information about the export
15171 process.  The third argument can be safely ignored.  Note the use of
15172 ~org-export-derived-backend-p~ predicate that tests for /latex/
15173 back-end or any other back-end, such as /beamer/, derived from
15174 /latex/.
15176 *** Defining filters for individual files
15177 :PROPERTIES:
15178 :UNNUMBERED: notoc
15179 :END:
15181 The Org export can filter not just for back-ends, but also for
15182 specific files through the =BIND= keyword.  Here is an example with
15183 two filters; one removes brackets from time stamps, and the other
15184 removes strike-through text.  The filter functions are defined in
15185 a code block in the same Org file, which is a handy location for
15186 debugging.
15188 #+begin_example
15189   ,#+BIND: org-export-filter-timestamp-functions (tmp-f-timestamp)
15190   ,#+BIND: org-export-filter-strike-through-functions (tmp-f-strike-through)
15191   ,#+BEGIN_SRC emacs-lisp :exports results :results none
15192     (defun tmp-f-timestamp (s backend info)
15193       (replace-regexp-in-string "&[lg]t;\\|[][]" "" s))
15194     (defun tmp-f-strike-through (s backend info) "")
15195   ,#+END_SRC
15196 #+end_example
15198 *** Extending an existing back-end
15199 :PROPERTIES:
15200 :UNNUMBERED: notoc
15201 :END:
15203 Some parts of the conversion process can be extended for certain
15204 elements so as to introduce a new or revised translation.  That is how
15205 the HTML export back-end was extended to handle Markdown format.  The
15206 extensions work seamlessly so any aspect of filtering not done by the
15207 extended back-end is handled by the original back-end.  Of all the
15208 export customization in Org, extending is very powerful as it operates
15209 at the parser level.
15211 For this example, make the /ascii/ back-end display the language used
15212 in a source code block.  Also make it display only when some attribute
15213 is non-~nil~, like the following:
15215 : #+ATTR_ASCII: :language t
15217 Then extend /ascii/ back-end with a custom "my-ascii" back-end.
15219 #+begin_src emacs-lisp
15220   (defun my-ascii-src-block (src-block contents info)
15221     "Transcode a SRC-BLOCK element from Org to ASCII.
15222   CONTENTS is nil.  INFO is a plist used as a communication
15223   channel."
15224     (if (not (org-export-read-attribute :attr_ascii src-block :language))
15225         (org-export-with-backend 'ascii src-block contents info)
15226       (concat
15227        (format ",--[ %s ]--\n%s`----"
15228                (org-element-property :language src-block)
15229                (replace-regexp-in-string
15230                 "^" "| "
15231                 (org-element-normalize-string
15232                  (org-export-format-code-default src-block info)))))))
15234   (org-export-define-derived-backend 'my-ascii 'ascii
15235     :translate-alist '((src-block . my-ascii-src-block)))
15236 #+end_src
15238 The ~my-ascii-src-block~ function looks at the attribute above the
15239 current element.  If not true, hands over to /ascii/ back-end.  If
15240 true, which it is in this example, it creates a box around the code
15241 and leaves room for the inserting a string for language.  The last
15242 form creates the new back-end that springs to action only when
15243 translating ~src-block~ type elements.
15245 To use the newly defined back-end, evaluate the following from an Org
15246 buffer:
15248 #+begin_src emacs-lisp
15249   (org-export-to-buffer 'my-ascii "*Org MY-ASCII Export*")
15250 #+end_src
15252 Further steps to consider would be an interactive function,
15253 self-installing an item in the export dispatcher menu, and other
15254 user-friendly improvements.
15256 ** Export in Foreign Buffers
15257 :PROPERTIES:
15258 :DESCRIPTION: Author tables and lists in Org syntax.
15259 :END:
15261 The export back-ends in Org often include commands to convert selected
15262 regions.  A convenient feature of this in-place conversion is that the
15263 exported output replaces the original source.  Here are such
15264 functions:
15266 - ~org-html-convert-region-to-html~ ::
15268      #+findex: org-html-convert-region-to-html
15269      Convert the selected region into HTML.
15271 - ~org-latex-convert-region-to-latex~ ::
15273      #+findex: org-latex-convert-region-to-latex
15274      Convert the selected region into LaTeX.
15276 - ~org-texinfo-convert-region-to-texinfo~ ::
15278      #+findex: org-texinfo-convert-region-to-texinfo
15279      Convert the selected region into Texinfo.
15281 - ~org-md-convert-region-to-md~ ::
15283      #+findex: org-md-convert-region-to-md
15284      Convert the selected region into Markdown.
15286 In-place conversions are particularly handy for quick conversion of
15287 tables and lists in foreign buffers.  For example, turn on the minor
15288 mode {{{kbd(M-x orgstruct-mode)}}} in an HTML buffer, then use the
15289 convenient Org keyboard commands to create a list, select it, and
15290 covert it to HTML with {{{kbd(M-x org-html-convert-region-to-html)}}}.
15292 * Publishing
15293 :PROPERTIES:
15294 :DESCRIPTION: Create a web site of linked Org files.
15295 :END:
15296 #+cindex: publishing
15298 Org includes a publishing management system that allows you to
15299 configure automatic HTML conversion of /projects/ composed of
15300 interlinked Org files.  You can also configure Org to automatically
15301 upload your exported HTML pages and related attachments, such as
15302 images and source code files, to a web server.
15304 You can also use Org to convert files into PDF, or even combine HTML
15305 and PDF conversion so that files are available in both formats on the
15306 server.
15308 Publishing has been contributed to Org by David O'Toole.
15310 ** Configuration
15311 :PROPERTIES:
15312 :DESCRIPTION: Defining projects.
15313 :END:
15314 Publishing needs significant configuration to specify files,
15315 destination and many other properties of a project.
15317 *** The variable ~org-publish-project-alist~
15318 :PROPERTIES:
15319 :DESCRIPTION: The central configuration variable.
15320 :ALT_TITLE: Project alist
15321 :END:
15322 #+cindex: projects, for publishing
15324 #+cindex: org-publish-project-alist
15325 Publishing is configured almost entirely through setting the value of
15326 one variable, called ~org-publish-project-alist~.  Each element of the
15327 list configures one project, and may be in one of the two following
15328 forms:
15330 #+begin_src emacs-lisp
15331   ("project-name" :property value :property value ...)
15332 #+end_src
15334 #+texinfo: @noindent
15335 i.e., a well-formed property list with alternating keys and values,
15338 #+begin_src emacs-lisp
15339   ("project-name" :components ("project-name" "project-name" ...))
15340 #+end_src
15342 In both cases, projects are configured by specifying property values.
15343 A project defines the set of files that are to be published, as well
15344 as the publishing configuration to use when publishing those files.
15345 When a project takes the second form listed above, the individual
15346 members of the ~:components~ property are taken to be sub-projects,
15347 which group together files requiring different publishing options.
15348 When you publish such a "meta-project", all the components are also
15349 published, in the sequence given.
15351 *** Sources and destinations for files
15352 :PROPERTIES:
15353 :DESCRIPTION: From here to there.
15354 :ALT_TITLE: Sources and destinations
15355 :END:
15356 #+cindex: directories, for publishing
15358 Most properties are optional, but some should always be set.  In
15359 particular, Org needs to know where to look for source files, and
15360 where to put published files.
15362 - ~:base-directory~ ::
15364      Directory containing publishing source files.
15366 - ~:publishing-directory~ ::
15368      Directory where output files are published.  You can directly
15369      publish to a webserver using a file name syntax appropriate for
15370      the Emacs tramp package.  Or you can publish to a local directory
15371      and use external tools to upload your website (see [[*Uploading
15372      Files]]).
15374 - ~:preparation-function~ ::
15376      Function or list of functions to be called before starting the
15377      publishing process, for example, to run =make= for updating files
15378      to be published.  Each preparation function is called with
15379      a single argument, the project property list.
15381 - ~:completion-function~ ::
15383      Function or list of functions called after finishing the
15384      publishing process, for example, to change permissions of the
15385      resulting files.  Each completion function is called with
15386      a single argument, the project property list.
15388 *** Selecting files
15389 :PROPERTIES:
15390 :DESCRIPTION: What files are part of the project?
15391 :END:
15392 #+cindex: files, selecting for publishing
15394 By default, all files with extension =.org= in the base directory are
15395 considered part of the project.  This can be modified by setting the
15396 following properties
15398 - ~:base-extension~ ::
15400      Extension---without the dot---of source files.  This actually
15401      is a regular expression.  Set this to the symbol ~any~ if you
15402      want to get all files in ~:base-directory~, even without
15403      extension.
15405 - ~:exclude~ ::
15407      Regular expression to match file names that should not be published,
15408      even though they have been selected on the basis of their extension.
15410 - ~:include~ ::
15412      List of files to be included regardless of ~:base-extension~ and
15413      ~:exclude~.
15415 - ~:recursive~ ::
15417      Non-~nil~ means, check base-directory recursively for files to
15418      publish.
15420 *** Publishing action
15421 :PROPERTIES:
15422 :DESCRIPTION: Setting the function doing the publishing.
15423 :END:
15424 #+cindex: action, for publishing
15426 Publishing means that a file is copied to the destination directory
15427 and possibly transformed in the process.  The default transformation
15428 is to export Org files as HTML files, and this is done by the function
15429 ~org-publish-org-to-html~ which calls the HTML exporter (see [[*HTML
15430 Export]]).  But you can also publish your content as PDF files using
15431 ~org-publish-org-to-pdf~, or as ASCII, Texinfo, etc., using the
15432 corresponding functions.
15434 If you want to publish the Org file as an =.org= file but with
15435 /archived/, /commented/, and /tag-excluded/ trees removed, use
15436 ~org-publish-org-to-org~.  This produces =file.org= and put it in the
15437 publishing directory.  If you want a htmlized version of this file,
15438 set the parameter ~:htmlized-source~ to ~t~.  It produces
15439 =file.org.html= in the publishing directory[fn:130].
15441 Other files like images only need to be copied to the publishing
15442 destination; for this you can use ~org-publish-attachment~.  For
15443 non-Org files, you always need to specify the publishing function:
15445 - ~:publishing-function~ ::
15447      Function executing the publication of a file.  This may also be
15448      a list of functions, which are all called in turn.
15450 - ~:plain-source~ ::
15452      Non-~nil~ means, publish plain source.
15454 - ~:htmlized-source~ ::
15456      Non-~nil~ means, publish htmlized source.
15458 The function must accept three arguments: a property list containing
15459 at least a ~:publishing-directory~ property, the name of the file to
15460 be published, and the path to the publishing directory of the output
15461 file.  It should take the specified file, make the necessary
15462 transformation, if any, and place the result into the destination
15463 folder.
15465 *** Options for the exporters
15466 :PROPERTIES:
15467 :DESCRIPTION: Tweaking HTML/@LaTeX{} export.
15468 :ALT_TITLE: Publishing options
15469 :END:
15470 #+cindex: options, for publishing
15471 #+cindex: publishing options
15473 The property list can be used to set many export options for the HTML
15474 and LaTeX exporters.  In most cases, these properties correspond to
15475 user variables in Org.  The table below lists these properties along
15476 with the variable they belong to.  See the documentation string for
15477 the respective variable for details.
15479 #+vindex: org-publish-project-alist
15480 When a property is given a value in ~org-publish-project-alist~, its
15481 setting overrides the value of the corresponding user variable, if
15482 any, during publishing.  Options set within a file (see [[*Export
15483 Settings]]), however, override everything.
15485 **** Generic properties
15486 :PROPERTIES:
15487 :UNNUMBERED: notoc
15488 :END:
15490 | ~:archived-trees~       | ~org-export-with-archived-trees~   |
15491 | ~:exclude-tags~         | ~org-export-exclude-tags~          |
15492 | ~:headline-levels~      | ~org-export-headline-levels~       |
15493 | ~:language~             | ~org-export-default-language~      |
15494 | ~:preserve-breaks~      | ~org-export-preserve-breaks~       |
15495 | ~:section-numbers~      | ~org-export-with-section-numbers~  |
15496 | ~:select-tags~          | ~org-export-select-tags~           |
15497 | ~:with-author~          | ~org-export-with-author~           |
15498 | ~:with-broken-links~    | ~org-export-with-broken-links~     |
15499 | ~:with-clocks~          | ~org-export-with-clocks~           |
15500 | ~:with-creator~         | ~org-export-with-creator~          |
15501 | ~:with-date~            | ~org-export-with-date~             |
15502 | ~:with-drawers~         | ~org-export-with-drawers~          |
15503 | ~:with-email~           | ~org-export-with-email~            |
15504 | ~:with-emphasize~       | ~org-export-with-emphasize~        |
15505 | ~:with-fixed-width~     | ~org-export-with-fixed-width~      |
15506 | ~:with-footnotes~       | ~org-export-with-footnotes~        |
15507 | ~:with-latex~           | ~org-export-with-latex~            |
15508 | ~:with-planning~        | ~org-export-with-planning~         |
15509 | ~:with-priority~        | ~org-export-with-priority~         |
15510 | ~:with-properties~      | ~org-export-with-properties~       |
15511 | ~:with-special-strings~ | ~org-export-with-special-strings~  |
15512 | ~:with-sub-superscript~ | ~org-export-with-sub-superscripts~ |
15513 | ~:with-tables~          | ~org-export-with-tables~           |
15514 | ~:with-tags~            | ~org-export-with-tags~             |
15515 | ~:with-tasks~           | ~org-export-with-tasks~            |
15516 | ~:with-timestamps~      | ~org-export-with-timestamps~       |
15517 | ~:with-title~           | ~org-export-with-title~            |
15518 | ~:with-toc~             | ~org-export-with-toc~              |
15519 | ~:with-todo-keywords~   | ~org-export-with-todo-keywords~    |
15521 **** ASCII specific properties
15522 :PROPERTIES:
15523 :UNNUMBERED: notoc
15524 :END:
15526 | ~:ascii-bullets~                       | ~org-ascii-bullets~                       |
15527 | ~:ascii-caption-above~                 | ~org-ascii-caption-above~                 |
15528 | ~:ascii-charset~                       | ~org-ascii-charset~                       |
15529 | ~:ascii-global-margin~                 | ~org-ascii-global-margin~                 |
15530 | ~:ascii-format-drawer-function~        | ~org-ascii-format-drawer-function~        |
15531 | ~:ascii-format-inlinetask-function~    | ~org-ascii-format-inlinetask-function~    |
15532 | ~:ascii-headline-spacing~              | ~org-ascii-headline-spacing~              |
15533 | ~:ascii-indented-line-width~           | ~org-ascii-indented-line-width~           |
15534 | ~:ascii-inlinetask-width~              | ~org-ascii-inlinetask-width~              |
15535 | ~:ascii-inner-margin~                  | ~org-ascii-inner-margin~                  |
15536 | ~:ascii-links-to-notes~                | ~org-ascii-links-to-notes~                |
15537 | ~:ascii-list-margin~                   | ~org-ascii-list-margin~                   |
15538 | ~:ascii-paragraph-spacing~             | ~org-ascii-paragraph-spacing~             |
15539 | ~:ascii-quote-margin~                  | ~org-ascii-quote-margin~                  |
15540 | ~:ascii-table-keep-all-vertical-lines~ | ~org-ascii-table-keep-all-vertical-lines~ |
15541 | ~:ascii-table-use-ascii-art~           | ~org-ascii-table-use-ascii-art~           |
15542 | ~:ascii-table-widen-columns~           | ~org-ascii-table-widen-columns~           |
15543 | ~:ascii-text-width~                    | ~org-ascii-text-width~                    |
15544 | ~:ascii-underline~                     | ~org-ascii-underline~                     |
15545 | ~:ascii-verbatim-format~               | ~org-ascii-verbatim-format~               |
15547 **** Beamer specific properties
15548 :PROPERTIES:
15549 :UNNUMBERED: notoc
15550 :END:
15552 | ~:beamer-theme~                 | ~org-beamer-theme~                 |
15553 | ~:beamer-column-view-format~    | ~org-beamer-column-view-format~    |
15554 | ~:beamer-environments-extra~    | ~org-beamer-environments-extra~    |
15555 | ~:beamer-frame-default-options~ | ~org-beamer-frame-default-options~ |
15556 | ~:beamer-outline-frame-options~ | ~org-beamer-outline-frame-options~ |
15557 | ~:beamer-outline-frame-title~   | ~org-beamer-outline-frame-title~   |
15558 | ~:beamer-subtitle-format~       | ~org-beamer-subtitle-format~       |
15560 **** HTML specific properties
15561 :PROPERTIES:
15562 :UNNUMBERED: notoc
15563 :END:
15565 | ~:html-allow-name-attribute-in-anchors~        | ~org-html-allow-name-attribute-in-anchors~        |
15566 | ~:html-checkbox-type~                          | ~org-html-checkbox-type~                          |
15567 | ~:html-container~                              | ~org-html-container-element~                      |
15568 | ~:html-divs~                                   | ~org-html-divs~                                   |
15569 | ~:html-doctype~                                | ~org-html-doctype~                                |
15570 | ~:html-extension~                              | ~org-html-extension~                              |
15571 | ~:html-footnote-format~                        | ~org-html-footnote-format~                        |
15572 | ~:html-footnote-separator~                     | ~org-html-footnote-separator~                     |
15573 | ~:html-footnotes-section~                      | ~org-html-footnotes-section~                      |
15574 | ~:html-format-drawer-function~                 | ~org-html-format-drawer-function~                 |
15575 | ~:html-format-headline-function~               | ~org-html-format-headline-function~               |
15576 | ~:html-format-inlinetask-function~             | ~org-html-format-inlinetask-function~             |
15577 | ~:html-head-extra~                             | ~org-html-head-extra~                             |
15578 | ~:html-head-include-default-style~             | ~org-html-head-include-default-style~             |
15579 | ~:html-head-include-scripts~                   | ~org-html-head-include-scripts~                   |
15580 | ~:html-head~                                   | ~org-html-head~                                   |
15581 | ~:html-home/up-format~                         | ~org-html-home/up-format~                         |
15582 | ~:html-html5-fancy~                            | ~org-html-html5-fancy~                            |
15583 | ~:html-indent~                                 | ~org-html-indent~                                 |
15584 | ~:html-infojs-options~                         | ~org-html-infojs-options~                         |
15585 | ~:html-infojs-template~                        | ~org-html-infojs-template~                        |
15586 | ~:html-inline-image-rules~                     | ~org-html-inline-image-rules~                     |
15587 | ~:html-inline-images~                          | ~org-html-inline-images~                          |
15588 | ~:html-link-home~                              | ~org-html-link-home~                              |
15589 | ~:html-link-org-files-as-html~                 | ~org-html-link-org-files-as-html~                 |
15590 | ~:html-link-up~                                | ~org-html-link-up~                                |
15591 | ~:html-link-use-abs-url~                       | ~org-html-link-use-abs-url~                       |
15592 | ~:html-mathjax-options~                        | ~org-html-mathjax-options~                        |
15593 | ~:html-mathjax-template~                       | ~org-html-mathjax-template~                       |
15594 | ~:html-metadata-timestamp-format~              | ~org-html-metadata-timestamp-format~              |
15595 | ~:html-postamble-format~                       | ~org-html-postamble-format~                       |
15596 | ~:html-postamble~                              | ~org-html-postamble~                              |
15597 | ~:html-preamble-format~                        | ~org-html-preamble-format~                        |
15598 | ~:html-preamble~                               | ~org-html-preamble~                               |
15599 | ~:html-table-align-individual-field~           | ~de{org-html-table-align-individual-fields~       |
15600 | ~:html-table-attributes~                       | ~org-html-table-default-attributes~               |
15601 | ~:html-table-caption-above~                    | ~org-html-table-caption-above~                    |
15602 | ~:html-table-data-tags~                        | ~org-html-table-data-tags~                        |
15603 | ~:html-table-header-tags~                      | ~org-html-table-header-tags~                      |
15604 | ~:html-table-row-tags~                         | ~org-html-table-row-tags~                         |
15605 | ~:html-table-use-header-tags-for-first-column~ | ~org-html-table-use-header-tags-for-first-column~ |
15606 | ~:html-tag-class-prefix~                       | ~org-html-tag-class-prefix~                       |
15607 | ~:html-text-markup-alist~                      | ~org-html-text-markup-alist~                      |
15608 | ~:html-todo-kwd-class-prefix~                  | ~org-html-todo-kwd-class-prefix~                  |
15609 | ~:html-toplevel-hlevel~                        | ~org-html-toplevel-hlevel~                        |
15610 | ~:html-use-infojs~                             | ~org-html-use-infojs~                             |
15611 | ~:html-validation-link~                        | ~org-html-validation-link~                        |
15612 | ~:html-viewport~                               | ~org-html-viewport~                               |
15613 | ~:html-xml-declaration~                        | ~org-html-xml-declaration~                        |
15615 **** LaTeX specific properties
15616 :PROPERTIES:
15617 :UNNUMBERED: notoc
15618 :END:
15620 | ~:latex-active-timestamp-format~       | ~org-latex-active-timestamp-format~       |
15621 | ~:latex-caption-above~                 | ~org-latex-caption-above~                 |
15622 | ~:latex-classes~                       | ~org-latex-classes~                       |
15623 | ~:latex-class~                         | ~org-latex-default-class~                 |
15624 | ~:latex-compiler~                      | ~org-latex-compiler~                      |
15625 | ~:latex-default-figure-position~       | ~org-latex-default-figure-position~       |
15626 | ~:latex-default-table-environment~     | ~org-latex-default-table-environment~     |
15627 | ~:latex-default-table-mode~            | ~org-latex-default-table-mode~            |
15628 | ~:latex-diary-timestamp-format~        | ~org-latex-diary-timestamp-format~        |
15629 | ~:latex-footnote-defined-format~       | ~org-latex-footnote-defined-format~       |
15630 | ~:latex-footnote-separator~            | ~org-latex-footnote-separator~            |
15631 | ~:latex-format-drawer-function~        | ~org-latex-format-drawer-function~        |
15632 | ~:latex-format-headline-function~      | ~org-latex-format-headline-function~      |
15633 | ~:latex-format-inlinetask-function~    | ~org-latex-format-inlinetask-function~    |
15634 | ~:latex-hyperref-template~             | ~org-latex-hyperref-template~             |
15635 | ~:latex-image-default-height~          | ~org-latex-image-default-height~          |
15636 | ~:latex-image-default-option~          | ~org-latex-image-default-option~          |
15637 | ~:latex-image-default-width~           | ~org-latex-image-default-width~           |
15638 | ~:latex-images-centered~               | ~org-latex-images-centered~               |
15639 | ~:latex-inactive-timestamp-format~     | ~org-latex-inactive-timestamp-format~     |
15640 | ~:latex-inline-image-rules~            | ~org-latex-inline-image-rules~            |
15641 | ~:latex-link-with-unknown-path-format~ | ~org-latex-link-with-unknown-path-format~ |
15642 | ~:latex-listings-langs~                | ~org-latex-listings-langs~                |
15643 | ~:latex-listings-options~              | ~org-latex-listings-options~              |
15644 | ~:latex-listings~                      | ~org-latex-listings~                      |
15645 | ~:latex-minted-langs~                  | ~org-latex-minted-langs~                  |
15646 | ~:latex-minted-options~                | ~org-latex-minted-options~                |
15647 | ~:latex-prefer-user-labels~            | ~org-latex-prefer-user-labels~            |
15648 | ~:latex-subtitle-format~               | ~org-latex-subtitle-format~               |
15649 | ~:latex-subtitle-separate~             | ~org-latex-subtitle-separate~             |
15650 | ~:latex-table-scientific-notation~     | ~org-latex-table-scientific-notation~     |
15651 | ~:latex-tables-booktabs~               | ~org-latex-tables-booktabs~               |
15652 | ~:latex-tables-centered~               | ~org-latex-tables-centered~               |
15653 | ~:latex-text-markup-alist~             | ~org-latex-text-markup-alist~             |
15654 | ~:latex-title-command~                 | ~org-latex-title-command~                 |
15655 | ~:latex-toc-command~                   | ~org-latex-toc-command~                   |
15657 **** Markdown specific properties
15658 :PROPERTIES:
15659 :UNNUMBERED: notoc
15660 :END:
15662 | ~:md-footnote-format~   | ~org-md-footnote-format~   |
15663 | ~:md-footnotes-section~ | ~org-md-footnotes-section~ |
15664 | ~:md-headline-style~    | ~org-md-headline-style~    |
15666 **** ODT specific properties
15667 :PROPERTIES:
15668 :UNNUMBERED: notoc
15669 :END:
15671 | ~:odt-content-template-file~      | ~org-odt-content-template-file~      |
15672 | ~:odt-display-outline-level~      | ~org-odt-display-outline-level~      |
15673 | ~:odt-fontify-srcblocks~          | ~org-odt-fontify-srcblocks~          |
15674 | ~:odt-format-drawer-function~     | ~org-odt-format-drawer-function~     |
15675 | ~:odt-format-headline-function~   | ~org-odt-format-headline-function~   |
15676 | ~:odt-format-inlinetask-function~ | ~org-odt-format-inlinetask-function~ |
15677 | ~:odt-inline-formula-rules~       | ~org-odt-inline-formula-rules~       |
15678 | ~:odt-inline-image-rules~         | ~org-odt-inline-image-rules~         |
15679 | ~:odt-pixels-per-inch~            | ~org-odt-pixels-per-inch~            |
15680 | ~:odt-styles-file~                | ~org-odt-styles-file~                |
15681 | ~:odt-table-styles~               | ~org-odt-table-styles~               |
15682 | ~:odt-use-date-fields~            | ~org-odt-use-date-fields~            |
15684 **** Texinfo specific properties
15685 :PROPERTIES:
15686 :UNNUMBERED: notoc
15687 :END:
15689 | ~:texinfo-active-timestamp-format~       | ~org-texinfo-active-timestamp-format~       |
15690 | ~:texinfo-classes~                       | ~org-texinfo-classes~                       |
15691 | ~:texinfo-class~                         | ~org-texinfo-default-class~                 |
15692 | ~:texinfo-table-default-markup~          | ~org-texinfo-table-default-markup~          |
15693 | ~:texinfo-diary-timestamp-format~        | ~org-texinfo-diary-timestamp-format~        |
15694 | ~:texinfo-filename~                      | ~org-texinfo-filename~                      |
15695 | ~:texinfo-format-drawer-function~        | ~org-texinfo-format-drawer-function~        |
15696 | ~:texinfo-format-headline-function~      | ~org-texinfo-format-headline-function~      |
15697 | ~:texinfo-format-inlinetask-function~    | ~org-texinfo-format-inlinetask-function~    |
15698 | ~:texinfo-inactive-timestamp-format~     | ~org-texinfo-inactive-timestamp-format~     |
15699 | ~:texinfo-link-with-unknown-path-format~ | ~org-texinfo-link-with-unknown-path-format~ |
15700 | ~:texinfo-node-description-column~       | ~org-texinfo-node-description-column~       |
15701 | ~:texinfo-table-scientific-notation~     | ~org-texinfo-table-scientific-notation~     |
15702 | ~:texinfo-tables-verbatim~               | ~org-texinfo-tables-verbatim~               |
15703 | ~:texinfo-text-markup-alist~             | ~org-texinfo-text-markup-alist~             |
15705 *** Publishing links
15706 :PROPERTIES:
15707 :DESCRIPTION: Which links keep working after publishing?
15708 :END:
15709 #+cindex: links, publishing
15711 To create a link from one Org file to another, you would use something
15712 like =[[file:foo.org][The foo]]= or simply =[[file:foo.org]]= (see [[*External Links]]).  When
15713 published, this link becomes a link to =foo.html=.  You can thus
15714 interlink the pages of your "Org web" project and the links will work
15715 as expected when you publish them to HTML.  If you also publish the
15716 Org source file and want to link to it, use an =http= link instead of
15717 a =file:= link, because =file= links are converted to link to the
15718 corresponding =.html= file.
15720 You may also link to related files, such as images.  Provided you are
15721 careful with relative file names, and provided you have also
15722 configured Org to upload the related files, these links will work too.
15723 See [[*Example: complex publishing configuration]], for an example of this
15724 usage.
15726 Eventually, links between published documents can contain some search
15727 options (see [[*Search Options in File Links]]), which will be resolved to
15728 the appropriate location in the linked file.  For example, once
15729 published to HTML, the following links all point to a dedicated anchor
15730 in =foo.html=.
15732 #+begin_example
15733   [[file:foo.org::*heading]]
15734   [[file:foo.org::#custom-id]]
15735   [[file:foo.org::target]]
15736 #+end_example
15738 *** Generating a sitemap
15739 :PROPERTIES:
15740 :DESCRIPTION: Generating a list of all pages.
15741 :ALT_TITLE: Site map
15742 :END:
15743 #+cindex: sitemap, of published pages
15745 The following properties may be used to control publishing of
15746 a map of files for a given project.
15748 - ~:auto-sitemap~ ::
15750      When non-~nil~, publish a sitemap during
15751      ~org-publish-current-project~ or ~org-publish-all~.
15753 - ~:sitemap-filename~ ::
15755      Filename for output of sitemap.  Defaults to =sitemap.org=, which
15756      becomes =sitemap.html=.
15758 - ~:sitemap-title~ ::
15760      Title of sitemap page.  Defaults to name of file.
15762 - ~:sitemap-format-entry~ ::
15764      #+findex: org-publish-find-date
15765      #+findex: org-publish-find-property
15766      #+findex: org-publish-find-title
15767      With this option one can tell how a site-map entry is formatted
15768      in the site-map.  It is a function called with three arguments:
15769      the file or directory name relative to base directory of the
15770      project, the site-map style and the current project.  It is
15771      expected to return a string.  Default value turns file names into
15772      links and use document titles as descriptions.  For specific
15773      formatting needs, one can use ~org-publish-find-date~,
15774      ~org-publish-find-title~ and ~org-publish-find-property~, to
15775      retrieve additional information about published documents.
15777 - ~:sitemap-function~ ::
15779      Plug-in function to use for generation of the sitemap.  It is
15780      called with two arguments: the title of the site-map and
15781      a representation of the files and directories involved in the
15782      project as a nested list, which can further be transformed using
15783      ~org-list-to-generic~, ~org-list-to-subtree~ and alike.  Default
15784      value generates a plain list of links to all files in the
15785      project.
15787 - ~:sitemap-sort-folders~ ::
15789      Where folders should appear in the sitemap.  Set this to ~first~
15790      (default) or ~last~ to display folders first or last,
15791      respectively.  When set to ~ignore~, folders are ignored
15792      altogether.  Any other value mixes files and folders.  This
15793      variable has no effect when site-map style is ~tree~.
15795 - ~:sitemap-sort-files~ ::
15797      How the files are sorted in the site map.  Set this to
15798      ~alphabetically~ (default), ~chronologically~ or
15799      ~anti-chronologically~.  ~chronologically~ sorts the files with
15800      older date first while ~anti-chronologically~ sorts the files
15801      with newer date first.  ~alphabetically~ sorts the files
15802      alphabetically.  The date of a file is retrieved with
15803      ~org-publish-find-date~.
15805 - ~:sitemap-ignore-case~ ::
15807      Should sorting be case-sensitive?  Default ~nil~.
15809 - ~:sitemap-file-entry-format~ ::
15811      With this option one can tell how a sitemap's entry is formatted
15812      in the sitemap.  This is a format string with some escape
15813      sequences: ~%t~ stands for the title of the file, ~%a~ stands for
15814      the author of the file and ~%d~ stands for the date of the file.
15815      The date is retrieved with the ~org-publish-find-date~ function
15816      and formatted with ~org-publish-sitemap-date-format~.  Default
15817      ~%t~.
15819 - ~:sitemap-date-format~ ::
15821      Format string for the ~format-time-string~ function that tells
15822      how a sitemap entry's date is to be formatted.  This property
15823      bypasses ~org-publish-sitemap-date-format~ which defaults to
15824      ~%Y-%m-%d~.
15826 *** Generating an index
15827 :PROPERTIES:
15828 :DESCRIPTION: An index that reaches across pages.
15829 :END:
15830 #+cindex: index, in a publishing project
15832 Org mode can generate an index across the files of a publishing project.
15834 - ~:makeindex~ ::
15836      When non-~nil~, generate in index in the file =theindex.org= and
15837      publish it as =theindex.html=.
15839 The file is created when first publishing a project with the
15840 ~:makeindex~ set.  The file only contains a statement =#+INCLUDE:
15841 "theindex.inc"=.  You can then build around this include statement by
15842 adding a title, style information, etc.
15844 #+cindex: INDEX, keyword
15845 Index entries are specified with =INDEX= keyword.  An entry that
15846 contains an exclamation mark creates a sub item.
15848 #+begin_example
15849   ,*** Curriculum Vitae
15850   ,#+INDEX: CV
15851   ,#+INDEX: Application!CV
15852 #+end_example
15854 ** Uploading Files
15855 :PROPERTIES:
15856 :DESCRIPTION: How to get files up on the server.
15857 :END:
15858 #+cindex: rsync
15859 #+cindex: unison
15861 For those people already utilizing third party sync tools such as
15862 Rsync or Unison, it might be preferable not to use the built-in remote
15863 publishing facilities of Org mode which rely heavily on Tramp.  Tramp,
15864 while very useful and powerful, tends not to be so efficient for
15865 multiple file transfer and has been known to cause problems under
15866 heavy usage.
15868 Specialized synchronization utilities offer several advantages.  In
15869 addition to timestamp comparison, they also do content and
15870 permissions/attribute checks.  For this reason you might prefer to
15871 publish your web to a local directory---possibly even /in place/ with
15872 your Org files---and then use Unison or Rsync to do the
15873 synchronization with the remote host.
15875 Since Unison, for example, can be configured as to which files to
15876 transfer to a certain remote destination, it can greatly simplify the
15877 project publishing definition.  Simply keep all files in the correct
15878 location, process your Org files with ~org-publish~ and let the
15879 synchronization tool do the rest.  You do not need, in this scenario,
15880 to include attachments such as JPG, CSS or PNG files in the project
15881 definition since the third-party tool syncs them.
15883 Publishing to a local directory is also much faster than to a remote
15884 one, so that you can afford more easily to republish entire projects.
15885 If you set ~org-publish-use-timestamps-flag~ to ~nil~, you gain the
15886 main benefit of re-including any changed external files such as source
15887 example files you might include with =INCLUDE= keyword.  The timestamp
15888 mechanism in Org is not smart enough to detect if included files have
15889 been modified.
15891 ** Sample Configuration
15892 :PROPERTIES:
15893 :DESCRIPTION: Example projects.
15894 :END:
15896 Below we provide two example configurations.  The first one is
15897 a simple project publishing only a set of Org files.  The second
15898 example is more complex, with a multi-component project.
15900 *** Example: simple publishing configuration
15901 :PROPERTIES:
15902 :DESCRIPTION: One-component publishing.
15903 :ALT_TITLE: Simple example
15904 :END:
15906 This example publishes a set of Org files to the =public_html=
15907 directory on the local machine.
15909 #+begin_src emacs-lisp
15910   (setq org-publish-project-alist
15911         '(("org"
15912            :base-directory "~/org/"
15913            :publishing-directory "~/public_html"
15914            :section-numbers nil
15915            :table-of-contents nil
15916            :style "<link rel=\"stylesheet\"
15917                   href=\"../other/mystyle.css\"
15918                   type=\"text/css\"/>")))
15919 #+end_src
15921 *** Example: complex publishing configuration
15922 :PROPERTIES:
15923 :DESCRIPTION: A multi-component publishing example.
15924 :ALT_TITLE: Complex example
15925 :END:
15927 This more complicated example publishes an entire website, including
15928 Org files converted to HTML, image files, Emacs Lisp source code, and
15929 style sheets.  The publishing directory is remote and private files
15930 are excluded.
15932 To ensure that links are preserved, care should be taken to replicate
15933 your directory structure on the web server, and to use relative file
15934 paths.  For example, if your Org files are kept in =~/org/= and your
15935 publishable images in =~/images/=, you would link to an image with
15937 : file:../images/myimage.png
15939 On the web server, the relative path to the image should be the same.
15940 You can accomplish this by setting up an =images/= folder in the right
15941 place on the web server, and publishing images to it.
15943 #+begin_src emacs-lisp
15944   (setq org-publish-project-alist
15945         '(("orgfiles"
15946            :base-directory "~/org/"
15947            :base-extension "org"
15948            :publishing-directory "/ssh:user@host:~/html/notebook/"
15949            :publishing-function org-html-publish-to-html
15950            :exclude "PrivatePage.org" ;; regexp
15951            :headline-levels 3
15952            :section-numbers nil
15953            :with-toc nil
15954            :html-head "<link rel=\"stylesheet\"
15955                     href=\"../other/mystyle.css\" type=\"text/css\"/>"
15956            :html-preamble t)
15958           ("images"
15959            :base-directory "~/images/"
15960            :base-extension "jpg\\|gif\\|png"
15961            :publishing-directory "/ssh:user@host:~/html/images/"
15962            :publishing-function org-publish-attachment)
15964           ("other"
15965            :base-directory "~/other/"
15966            :base-extension "css\\|el"
15967            :publishing-directory "/ssh:user@host:~/html/other/"
15968            :publishing-function org-publish-attachment)
15969           ("website" :components ("orgfiles" "images" "other"))))
15970 #+end_src
15972 ** Triggering Publication
15973 :PROPERTIES:
15974 :DESCRIPTION: Publication commands.
15975 :END:
15977 Once properly configured, Org can publish with the following commands:
15979 - {{{kbd(C-c C-e X)}}} (~org-publish~) ::
15981      #+kindex: C-c C-e X
15982      #+findex: org-publish
15983      Prompt for a specific project and publish all files that belong
15984      to it.
15986 - {{{kbd(C-c C-e P)}}} (~org-publish-current-project~) ::
15988      #+kindex: C-c C-e P
15989      #+findex: org-publish-current-project
15990      Publish the project containing the current file.
15992 - {{{kbd(C-c C-e F)}}} (~org-publish-current-file~) ::
15994      #+kindex: C-c C-e F
15995      #+findex: org-publish-current-file
15996      Publish only the current file.
15998 - {{{kbd(C-c C-e E)}}} (~org-publish-all~) ::
16000      #+kindex: C-c C-e E
16001      #+findex: org-publish-all
16002      Publish every project.
16004 #+vindex: org-publish-use-timestamps-flag
16005 Org uses timestamps to track when a file has changed.  The above
16006 functions normally only publish changed files.  You can override this
16007 and force publishing of all files by giving a prefix argument to any
16008 of the commands above, or by customizing the variable
16009 ~org-publish-use-timestamps-flag~.  This may be necessary in
16010 particular if files include other files via =SETUPFILE= or =INCLUDE=
16011 keywords.
16013 * Working with Source Code
16014 :PROPERTIES:
16015 :DESCRIPTION: Export, evaluate, and tangle code blocks.
16016 :END:
16017 #+cindex: source code, working with
16019 Source code here refers to any plain text collection of computer
16020 instructions, possibly with comments, written using a human-readable
16021 programming language.  Org can manage source code in an Org document
16022 when the source code is identified with begin and end markers.
16023 Working with source code begins with identifying source code blocks.
16024 A source code block can be placed almost anywhere in an Org document;
16025 it is not restricted to the preamble or the end of the document.
16026 However, Org cannot manage a source code block if it is placed inside
16027 an Org comment or within a fixed width section.
16029 Here is an example source code block in the Emacs Lisp language:
16031 #+begin_example
16032   ,#+BEGIN_SRC emacs-lisp
16033     (defun org-xor (a b)
16034        "Exclusive or."
16035        (if a (not b) b))
16036   ,#+END_SRC
16037 #+end_example
16039 Org can manage the source code in the block delimited by =#+BEGIN_SRC=
16040 ... =#+END_SRC= in several ways that can simplify housekeeping tasks
16041 essential to modern source code maintenance.  Org can edit, format,
16042 extract, export, and publish source code blocks.  Org can also compile
16043 and execute a source code block, then capture the results.  The Org
16044 mode literature sometimes refers to source code blocks as /live code/
16045 blocks because they can alter the content of the Org document or the
16046 material that it exports.  Users can control how live they want each
16047 source code block by tweaking the header arguments (see [[*Using
16048 Header Arguments]]) for compiling, execution, extraction, and
16049 exporting.
16051 Source code blocks are one of many Org block types, which also include
16052 =quote=, =export=, =verse=, =latex=, =example=, and =verbatim=.  This
16053 section pertains to blocks between =#+BEGIN_SRC= and =#+END_SRC=.
16055 For editing and formatting a source code block, Org uses an
16056 appropriate Emacs major mode that includes features specifically
16057 designed for source code in that language.
16059 Org can extract one or more source code blocks and write them to one
16060 or more source files---a process known as /tangling/ in literate
16061 programming terminology.
16063 For exporting and publishing, Org's back-ends can format a source code
16064 block appropriately, often with native syntax highlighting.
16066 For executing and compiling a source code block, the user can
16067 configure Org to select the appropriate compiler.  Org provides
16068 facilities to collect the result of the execution or compiler output,
16069 insert it into the Org document, and/or export it.  In addition to
16070 text results, Org can insert links to other data types, including
16071 audio, video, and graphics.  Org can also link a compiler error
16072 message to the appropriate line in the source code block.
16074 An important feature of Org's management of source code blocks is the
16075 ability to pass variables, functions, and results to one another using
16076 a common syntax for source code blocks in any language.  Although most
16077 literate programming facilities are restricted to one language or
16078 another, Org's language-agnostic approach lets the literate programmer
16079 match each programming task with the appropriate computer language and
16080 to mix them all together in a single Org document.  This
16081 interoperability among languages explains why Org's source code
16082 management facility was named /Org Babel/ by its originators, Eric
16083 Schulte and Dan Davison.
16085 Org mode fulfills the promise of easy verification and maintenance of
16086 publishing reproducible research by keeping text, data, code,
16087 configuration settings of the execution environment, the results of
16088 the execution, and associated narratives, claims, references, and
16089 internal and external links in a single Org document.
16091 Details of Org's facilities for working with source code are described
16092 in the following sections.
16094 ** Structure of Code Blocks
16095 :PROPERTIES:
16096 :DESCRIPTION: Code block syntax described.
16097 :END:
16098 #+cindex: code block, structure
16099 #+cindex: source code, block structure
16100 #+cindex: NAME keyword, in source blocks
16101 #+cindex: BEGIN_SRC
16103 Org offers two ways to structure source code in Org documents: in
16104 a source code block, and directly inline.  Both specifications are
16105 shown below.
16107 A source code block conforms to this structure:
16109 #+begin_example
16110   ,#+NAME: <name>
16111   ,#+BEGIN_SRC <language> <switches> <header arguments>
16112     <body>
16113   ,#+END_SRC
16114 #+end_example
16116 Do not be put-off by having to remember the source block syntax.  Org
16117 mode offers a command for wrapping existing text in a block (see
16118 [[*Structure Templates]]).  Org also works with other completion systems
16119 in Emacs, some of which predate Org and have custom domain-specific
16120 languages for defining templates.  Regular use of templates reduces
16121 errors, increases accuracy, and maintains consistency.
16123 #+cindex: source code, inline
16124 An inline code block conforms to this structure:
16126 : src_<language>{<body>}
16128 #+texinfo: @noindent
16131 : src_<language>[<header arguments>]{<body>}
16133 - =#+NAME: <name>= ::
16135      Optional.  Names the source block so it can be called, like
16136      a function, from other source blocks or inline code to evaluate
16137      or to capture the results.  Code from other blocks, other files,
16138      and from table formulas (see [[*The spreadsheet]]) can use the name
16139      to reference a source block.  This naming serves the same purpose
16140      as naming Org tables.  Org mode requires unique names.  For
16141      duplicate names, Org mode's behavior is undefined.
16143 - =#+BEGIN_SRC= ... =#+END_SRC= ::
16145      Mandatory.  They mark the start and end of a block that Org
16146      requires.  The =#+BEGIN_SRC= line takes additional arguments, as
16147      described next.
16149 - =<language>= ::
16151      #+cindex: language, in code blocks
16152      Mandatory.  It is the identifier of the source code language in
16153      the block.  See [[*Languages]], for identifiers of supported
16154      languages.
16156 - =<switches>= ::
16158      #+cindex: switches, in code blocks
16159      Optional.  Switches provide finer control of the code execution,
16160      export, and format (see the discussion of switches in [[*Literal
16161      Examples]]).
16163 - =<header arguments>= ::
16165      #+cindex: header arguments, in code blocks
16166      Optional.  Heading arguments control many aspects of evaluation,
16167      export and tangling of code blocks (see [[*Using Header Arguments]]).
16168      Using Org's properties feature, header arguments can be
16169      selectively applied to the entire buffer or specific sub-trees of
16170      the Org document.
16172 - =<body>= ::
16174      Source code in the dialect of the specified language identifier.
16176 ** Using Header Arguments
16177 :PROPERTIES:
16178 :DESCRIPTION: Different ways to set header arguments.
16179 :END:
16181 Org comes with many header arguments common to all languages.  New
16182 header arguments are added for specific languages as they become
16183 available for use in source code blocks.  A header argument is
16184 specified with an initial colon followed by the argument's name in
16185 lowercase.
16187 Since header arguments can be set in several ways, Org prioritizes
16188 them in case of overlaps or conflicts by giving local settings
16189 a higher priority.  Header values in function calls, for example,
16190 override header values from global defaults.
16192 *** System-wide header arguments
16193 :PROPERTIES:
16194 :UNNUMBERED: notoc
16195 :END:
16196 #+vindex: org-babel-default-header-args
16198 #+vindex: org-babel-default-header-args
16199 System-wide values of header arguments can be specified by customizing
16200 the ~org-babel-default-header-args~ variable, which defaults to the
16201 following values:
16203 #+begin_example
16204   :session    => "none"
16205   :results    => "replace"
16206   :exports    => "code"
16207   :cache      => "no"
16208   :noweb      => "no"
16209 #+end_example
16211 The example below sets =:noweb= header arguments to =yes=, which makes
16212 Org expand =:noweb= references by default.
16214 #+begin_src emacs-lisp
16215   (setq org-babel-default-header-args
16216         (cons '(:noweb . "yes")
16217               (assq-delete-all :noweb org-babel-default-header-args)))
16218 #+end_src
16220 #+cindex: language specific default header arguments
16221 #+cindex: default header arguments per language
16222 Each language can have separate default header arguments by
16223 customizing the variable ~org-babel-default-header-args:<LANG>~, where
16224 {{{var(<LANG>)}}} is the name of the language.  For details, see the
16225 language-specific online documentation at
16226 https://orgmode.org/worg/org-contrib/babel/.
16228 *** Header arguments in Org mode properties
16229 :PROPERTIES:
16230 :UNNUMBERED: notoc
16231 :END:
16233 For header arguments applicable to the buffer, use =PROPERTY= keyword
16234 anywhere in the Org file (see [[*Property Syntax]]).
16236 The following example makes all the R code blocks execute in the same
16237 session.  Setting =:results= to =silent= ignores the results of
16238 executions for all blocks, not just R code blocks; no results inserted
16239 for any block.
16241 #+begin_example
16242   ,#+PROPERTY: header-args:R  :session *R*
16243   ,#+PROPERTY: header-args    :results silent
16244 #+end_example
16246 #+vindex: org-use-property-inheritance
16247 Header arguments set through Org's property drawers (see [[*Property
16248 Syntax]]) apply at the sub-tree level on down.  Since these property
16249 drawers can appear anywhere in the file hierarchy, Org uses outermost
16250 call or source block to resolve the values.  Org ignores
16251 ~org-use-property-inheritance~ setting.
16253 In this example, =:cache= defaults to =yes= for all code blocks in the
16254 sub-tree.
16256 #+begin_example
16257   ,* sample header
16258     :PROPERTIES:
16259     :header-args:    :cache yes
16260     :END:
16261 #+end_example
16263 #+kindex: C-c C-x p
16264 #+findex: org-set-property
16265 Properties defined through ~org-set-property~ function, bound to
16266 {{{kbd(C-c C-x p)}}}, apply to all active languages.  They override
16267 properties set in ~org-babel-default-header-args~.
16269 #+cindex: language specific header arguments properties
16270 #+cindex: header arguments per language
16271 Language-specific header arguments are also read from properties
16272 =header-args:<LANG>= where {{{var(<LANG>)}}} is the language
16273 identifier.  For example,
16275 #+begin_example
16276   ,* Heading
16277     :PROPERTIES:
16278     :header-args:clojure:    :session *clojure-1*
16279     :header-args:R:          :session *R*
16280     :END:
16281   ,** Subheading
16282     :PROPERTIES:
16283     :header-args:clojure:    :session *clojure-2*
16284     :END:
16285 #+end_example
16287 #+texinfo: @noindent
16288 would force separate sessions for Clojure blocks in =Heading= and
16289 =Subheading=, but use the same session for all R blocks.  Blocks in
16290 =Subheading= inherit settings from =Heading=.
16292 *** Code block specific header arguments
16293 :PROPERTIES:
16294 :UNNUMBERED: notoc
16295 :END:
16297 Header arguments are most commonly set at the source code block level,
16298 on the =#+BEGIN_SRC= line.  Arguments set at this level take
16299 precedence over those set in the ~org-babel-default-header-args~
16300 variable, and also those set as header properties.
16302 In the following example, setting =:results= to =silent= makes it
16303 ignore results of the code execution.  Setting =:exports= to =code=
16304 exports only the body of the code block to HTML or LaTeX.
16306 #+begin_example
16307   ,#+NAME: factorial
16308   ,#+BEGIN_SRC haskell :results silent :exports code :var n=0
16309     fac 0 = 1
16310     fac n = n * fac (n-1)
16311   ,#+END_SRC
16312 #+end_example
16314 The same header arguments in an inline code block:
16316 : src_haskell[:exports both]{fac 5}
16318 #+cindex: HEADER, keyword
16319 Code block header arguments can span multiple lines using =#+HEADER:=
16320 on each line.  Note that Org currently accepts the plural spelling of
16321 =#+HEADER:= only as a convenience for backward-compatibility.  It may
16322 be removed at some point.
16324 Multi-line header arguments on an unnamed code block:
16326 #+begin_example
16327   ,#+HEADER: :var data1=1
16328   ,#+BEGIN_SRC emacs-lisp :var data2=2
16329      (message "data1:%S, data2:%S" data1 data2)
16330   ,#+END_SRC
16332   ,#+RESULTS:
16333   : data1:1, data2:2
16334 #+end_example
16336 Multi-line header arguments on a named code block:
16338 #+begin_example
16339   ,#+NAME: named-block
16340   ,#+HEADER: :var data=2
16341   ,#+BEGIN_SRC emacs-lisp
16342     (message "data:%S" data)
16343   ,#+END_SRC
16345   ,#+RESULTS: named-block
16346     : data:2
16347 #+end_example
16349 *** Header arguments in function calls
16350 :PROPERTIES:
16351 :UNNUMBERED: notoc
16352 :END:
16354 Header arguments in function calls are the most specific and override
16355 all other settings in case of an overlap.  They get the highest
16356 priority.  Two =#+CALL:= examples are shown below.  For the complete
16357 syntax of =CALL= keyword, see [[*Evaluating Code Blocks]].
16359 In this example, =:exports results= header argument is applied to the
16360 evaluation of the =#+CALL:= line.
16362 : #+CALL: factorial(n=5) :exports results
16364 In this example, =:session special= header argument is applied to the
16365 evaluation of =factorial= code block.
16367 : #+CALL: factorial[:session special](n=5)
16369 ** Environment of a Code Block
16370 :PROPERTIES:
16371 :DESCRIPTION: Arguments, sessions, working directory...
16372 :END:
16374 *** Passing arguments
16375 :PROPERTIES:
16376 :UNNUMBERED: notoc
16377 :END:
16379 #+cindex: passing arguments to code blocks
16380 #+cindex: arguments, in code blocks
16381 #+cindex: @samp{var}, header argument
16382 Use =var= for passing arguments to source code blocks.  The specifics
16383 of variables in code blocks vary by the source language and are
16384 covered in the language-specific documentation.  The syntax for =var=,
16385 however, is the same for all languages.  This includes declaring
16386 a variable, and assigning a default value.
16388 The following syntax is used to pass arguments to code blocks using
16389 the =var= header argument.
16391 : :var NAME=ASSIGN
16393 #+texinfo: @noindent
16394 {{{var(NAME)}}} is the name of the variable bound in the code block
16395 body.  {{{var(ASSIGN)}}} is a literal value, such as a string,
16396 a number, a reference to a table, a list, a literal example, another
16397 code block---with or without arguments---or the results of evaluating
16398 a code block.
16400 Here are examples of passing values by reference:
16402 - table ::
16404      A table named with a =NAME= keyword.
16406      #+begin_example
16407        ,#+NAME: example-table
16408        | 1 |
16409        | 2 |
16410        | 3 |
16411        | 4 |
16413        ,#+NAME: table-length
16414        ,#+BEGIN_SRC emacs-lisp :var table=example-table
16415          (length table)
16416        ,#+END_SRC
16418        ,#+RESULTS: table-length
16419        : 4
16420      #+end_example
16422      When passing a table, you can treat specially the row, or the
16423      column, containing labels for the columns, or the rows, in the
16424      table.
16426      #+cindex: @samp{colnames}, header argument
16427      The =colnames= header argument accepts =yes=, =no=, or =nil=
16428      values.  The default value is =nil=: if an input table has column
16429      names---because the second row is a horizontal rule---then Org
16430      removes the column names, processes the table, puts back the
16431      column names, and then writes the table to the results block.
16432      Using =yes=, Org does the same to the first row, even if the
16433      initial table does not contain any horizontal rule.  When set to
16434      =no=, Org does not pre-process column names at all.
16436      #+begin_example
16437        ,#+NAME: less-cols
16438        | a |
16439        |---|
16440        | b |
16441        | c |
16443        ,#+BEGIN_SRC python :var tab=less-cols :colnames nil
16444          return [[val + '*' for val in row] for row in tab]
16445        ,#+END_SRC
16447        ,#+RESULTS:
16448        | a  |
16449        |----|
16450        | b* |
16451        | c* |
16452      #+end_example
16454      #+cindex: @samp{rownames}, header argument
16455      Similarly, the =rownames= header argument can take two values:
16456      =yes= or =no=.  When set to =yes=, Org removes the first column,
16457      processes the table, puts back the first column, and then writes
16458      the table to the results block.  The default is =no=, which means
16459      Org does not pre-process the first column.  Note that Emacs Lisp
16460      code blocks ignore =rownames= header argument because of the ease
16461      of table-handling in Emacs.
16463      #+begin_example
16464        ,#+NAME: with-rownames
16465        | one | 1 | 2 | 3 | 4 |  5 |
16466        | two | 6 | 7 | 8 | 9 | 10 |
16468        ,#+BEGIN_SRC python :var tab=with-rownames :rownames yes
16469          return [[val + 10 for val in row] for row in tab]
16470        ,#+END_SRC
16472        ,#+RESULTS:
16473        | one | 11 | 12 | 13 | 14 | 15 |
16474        | two | 16 | 17 | 18 | 19 | 20 |
16475      #+end_example
16477 - list ::
16479      A simple named list.
16481      #+begin_example
16482        ,#+NAME: example-list
16483        - simple
16484          - not
16485          - nested
16486        - list
16488        ,#+BEGIN_SRC emacs-lisp :var x=example-list
16489          (print x)
16490        ,#+END_SRC
16492        ,#+RESULTS:
16493        | simple | list |
16494      #+end_example
16496      Note that only the top level list items are passed along.  Nested
16497      list items are ignored.
16499 - code block without arguments ::
16501      A code block name, as assigned by =NAME= keyword from the example
16502      above, optionally followed by parentheses.
16504      #+begin_example
16505        ,#+BEGIN_SRC emacs-lisp :var length=table-length()
16506          (* 2 length)
16507        ,#+END_SRC
16509        ,#+RESULTS:
16510        : 8
16511      #+end_example
16513 - code block with arguments ::
16515      A code block name, as assigned by =NAME= keyword, followed by
16516      parentheses and optional arguments passed within the parentheses.
16518      #+begin_example
16519        ,#+NAME: double
16520        ,#+BEGIN_SRC emacs-lisp :var input=8
16521          (* 2 input)
16522        ,#+END_SRC
16524        ,#+RESULTS: double
16525        : 16
16527        ,#+NAME: squared
16528        ,#+BEGIN_SRC emacs-lisp :var input=double(input=1)
16529          (* input input)
16530        ,#+END_SRC
16532        ,#+RESULTS: squared
16533        : 4
16534      #+end_example
16536 - literal example ::
16538      A literal example block named with a =NAME= keyword.
16540      #+begin_example
16541        ,#+NAME: literal-example
16542        ,#+BEGIN_EXAMPLE
16543          A literal example
16544          on two lines
16545        ,#+END_EXAMPLE
16547        ,#+NAME: read-literal-example
16548        ,#+BEGIN_SRC emacs-lisp :var x=literal-example
16549          (concatenate #'string x " for you.")
16550        ,#+END_SRC
16552        ,#+RESULTS: read-literal-example
16553        : A literal example
16554        : on two lines for you.
16555      #+end_example
16557 Indexing variable values enables referencing portions of a variable.
16558 Indexes are 0 based with negative values counting backwards from the
16559 end.  If an index is separated by commas then each subsequent section
16560 indexes as the next dimension.  Note that this indexing occurs
16561 /before/ other table-related header arguments are applied, such as
16562 =hlines=, =colnames= and =rownames=.  The following example assigns
16563 the last cell of the first row the table =example-table= to the
16564 variable =data=:
16566 #+begin_example
16567   ,#+NAME: example-table
16568   | 1 | a |
16569   | 2 | b |
16570   | 3 | c |
16571   | 4 | d |
16573   ,#+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
16574     data
16575   ,#+END_SRC
16577   ,#+RESULTS:
16578   : a
16579 #+end_example
16581 Two integers separated by a colon reference a range of variable
16582 values.  In that case the entire inclusive range is referenced.  For
16583 example the following assigns the middle three rows of =example-table=
16584 to =data=.
16586 #+begin_example
16587   ,#+NAME: example-table
16588   | 1 | a |
16589   | 2 | b |
16590   | 3 | c |
16591   | 4 | d |
16592   | 5 | 3 |
16594   ,#+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
16595     data
16596   ,#+END_SRC
16598   ,#+RESULTS:
16599   | 2 | b |
16600   | 3 | c |
16601   | 4 | d |
16602 #+end_example
16604 To pick the entire range, use an empty index, or the single character
16605 =*=.  =0:-1= does the same thing.  Example below shows how to
16606 reference the first column only.
16608 #+begin_example
16609   ,#+NAME: example-table
16610   | 1 | a |
16611   | 2 | b |
16612   | 3 | c |
16613   | 4 | d |
16615   ,#+BEGIN_SRC emacs-lisp :var data=example-table[,0]
16616     data
16617   ,#+END_SRC
16619   ,#+RESULTS:
16620   | 1 | 2 | 3 | 4 |
16621 #+end_example
16623 Index referencing can be used for tables and code blocks.  Index
16624 referencing can handle any number of dimensions.  Commas delimit
16625 multiple dimensions, as shown below.
16627 #+begin_example
16628   ,#+NAME: 3D
16629   ,#+BEGIN_SRC emacs-lisp
16630     '(((1  2  3)  (4  5  6)  (7  8  9))
16631       ((10 11 12) (13 14 15) (16 17 18))
16632       ((19 20 21) (22 23 24) (25 26 27)))
16633   ,#+END_SRC
16635   ,#+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
16636     data
16637   ,#+END_SRC
16639   ,#+RESULTS:
16640   | 11 | 14 | 17 |
16641 #+end_example
16643 Note that row names and column names are not removed prior to variable
16644 indexing.  You need to take them into account, even when =colnames= or
16645 =rownames= header arguments remove them.
16647 Emacs lisp code can also set the values for variables.  To
16648 differentiate a value from Lisp code, Org interprets any value
16649 starting with =(=, =[=, ='= or =`= as Emacs Lisp code.  The result of
16650 evaluating that code is then assigned to the value of that variable.
16651 The following example shows how to reliably query and pass the file
16652 name of the Org mode buffer to a code block using headers.  We need
16653 reliability here because the file's name could change once the code in
16654 the block starts executing.
16656 #+begin_example
16657   ,#+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
16658     wc -w $filename
16659   ,#+END_SRC
16660 #+end_example
16662 Note that values read from tables and lists are not mistakenly
16663 evaluated as Emacs Lisp code, as illustrated in the following example.
16665 #+begin_example
16666   ,#+NAME: table
16667   | (a b c) |
16669   ,#+HEADERS: :var data=table[0,0]
16670   ,#+BEGIN_SRC perl
16671     $data
16672   ,#+END_SRC
16674   ,#+RESULTS:
16675   : (a b c)
16676 #+end_example
16678 *** Using sessions
16679 :PROPERTIES:
16680 :UNNUMBERED: notoc
16681 :END:
16683 #+cindex: using sessions in code blocks
16684 #+cindex: @samp{session}, header argument
16685 Two code blocks can share the same environment.  The =session= header
16686 argument is for running multiple source code blocks under one session.
16687 Org runs code blocks with the same session name in the same
16688 interpreter process.
16690 - =none= ::
16692      Default.  Each code block gets a new interpreter process to
16693      execute.  The process terminates once the block is evaluated.
16695 - {{{var(STRING)}}} ::
16697      Any string besides =none= turns that string into the name of that
16698      session.  For example, =:session STRING= names it =STRING=.  If
16699      =session= has no value, then the session name is derived from the
16700      source language identifier.  Subsequent blocks with the same
16701      source code language use the same session.  Depending on the
16702      language, state variables, code from other blocks, and the
16703      overall interpreted environment may be shared.  Some interpreted
16704      languages support concurrent sessions when subsequent source code
16705      language blocks change session names.
16707 Only languages that provide interactive evaluation can have session
16708 support.  Not all languages provide this support, such as C and ditaa.
16709 Even languages, such as Python and Haskell, that do support
16710 interactive evaluation impose limitations on allowable language
16711 constructs that can run interactively.  Org inherits those limitations
16712 for those code blocks running in a session.
16714 *** Choosing a working directory
16715 :PROPERTIES:
16716 :UNNUMBERED: notoc
16717 :END:
16719 #+cindex: working directory, in a code block
16720 #+cindex: @samp{dir}, header argument
16721 The =dir= header argument specifies the default directory during code
16722 block execution.  If it is absent, then the directory associated with
16723 the current buffer is used.  In other words, supplying =:dir PATH=
16724 temporarily has the same effect as changing the current directory with
16725 {{{kbd(M-x cd PATH)}}}, and then not setting =dir=.  Under the
16726 surface, =dir= simply sets the value of the Emacs variable
16727 ~default-directory~.
16729 For example, to save the plot file in the =Work/= folder of the home
16730 directory---notice tilde is expanded:
16732 #+begin_example
16733   ,#+BEGIN_SRC R :file myplot.png :dir ~/Work
16734     matplot(matrix(rnorm(100), 10), type="l")
16735   ,#+END_SRC
16736 #+end_example
16738 To evaluate the code block on a remote machine, supply a remote
16739 directory name using Tramp syntax.  For example:
16741 #+begin_example
16742   ,#+BEGIN_SRC R :file plot.png :dir /scp:dand@yakuba.princeton.edu:
16743     plot(1:10, main=system("hostname", intern=TRUE))
16744   ,#+END_SRC
16745 #+end_example
16747 Org first captures the text results as usual for insertion in the Org
16748 file.  Then Org also inserts a link to the remote file, thanks to
16749 Emacs Tramp.  Org constructs the remote path to the file name from
16750 =dir= and ~default-directory~, as illustrated here:
16752 : [[file:/scp:dand@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
16754 When =dir= is used with =session=, Org sets the starting directory for
16755 a new session.  But Org does not alter the directory of an already
16756 existing session.
16758 Do not use =dir= with =:exports results= or with =:exports both= to
16759 avoid Org inserting incorrect links to remote files.  That is because
16760 Org does not expand ~default directory~ to avoid some underlying
16761 portability issues.
16763 *** Inserting headers and footers
16764 :PROPERTIES:
16765 :UNNUMBERED: notoc
16766 :END:
16768 #+cindex: headers, in code blocks
16769 #+cindex: footers, in code blocks
16770 #+cindex: @samp{prologue}, header argument
16771 The =prologue= header argument is for appending to the top of the code
16772 block for execution, like a reset instruction.  For example, you may
16773 use =:prologue "reset"= in a Gnuplot code block or, for every such
16774 block:
16776 #+begin_src emacs-lisp
16777   (add-to-list 'org-babel-default-header-args:gnuplot
16778                '((:prologue . "reset")))
16780 #+end_src
16782 #+cindex: @samp{epilogue}, header argument
16783 Likewise, the value of the =epilogue= header argument is for appending
16784 to the end of the code block for execution.
16786 ** Evaluating Code Blocks
16787 :PROPERTIES:
16788 :DESCRIPTION: Place results of evaluation in the Org buffer.
16789 :END:
16790 #+cindex: code block, evaluating
16791 #+cindex: source code, evaluating
16792 #+cindex: RESULTS, keyword
16794 A note about security: With code evaluation comes the risk of harm.
16795 Org safeguards by prompting for user's permission before executing any
16796 code in the source block.  To customize this safeguard, or disable it,
16797 see [[*Code Evaluation and Security Issues]].
16799 *** How to evaluate source code
16800 :PROPERTIES:
16801 :UNNUMBERED: notoc
16802 :END:
16804 Org captures the results of the code block evaluation and inserts them
16805 in the Org file, right after the code block.  The insertion point is
16806 after a newline and the =RESULTS= keyword.  Org creates the =RESULTS=
16807 keyword if one is not already there.
16809 By default, Org enables only Emacs Lisp code blocks for execution.
16810 See [[*Languages]] to enable other languages.
16812 #+kindex: C-c C-c
16813 #+kindex: C-c C-v e
16814 #+findex: org-babel-execute-src-block
16815 Org provides many ways to execute code blocks.  {{{kbd(C-c C-c)}}} or
16816 {{{kbd(C-c C-v e)}}} with the point on a code block[fn:131] calls the
16817 ~org-babel-execute-src-block~ function, which executes the code in the
16818 block, collects the results, and inserts them in the buffer.
16820 #+cindex: CALL, keyword
16821 #+vindex: org-babel-inline-result-wrap
16822 By calling a named code block[fn:132] from an Org mode buffer or
16823 a table.  Org can call the named code blocks from the current Org mode
16824 buffer or from the "Library of Babel" (see [[*Library of Babel]]).
16826 The syntax for =CALL= keyword is:
16828 #+begin_example
16829   ,#+CALL: <name>(<arguments>)
16830   ,#+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
16831 #+end_example
16833 The syntax for inline named code blocks is:
16835 #+begin_example
16836   ... call_<name>(<arguments>) ...
16837   ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
16838 #+end_example
16840 When inline syntax is used, the result is wrapped based on the
16841 variable ~org-babel-inline-result-wrap~, which by default is set to
16842 ~"=%s="~ to produce verbatim text suitable for markup.
16844 - =<name>= ::
16846      This is the name of the code block (see [[*Structure of Code
16847      Blocks]]) to be evaluated in the current document.  If the block is
16848      located in another file, start =<name>= with the file name
16849      followed by a colon. For example, in order to execute a block
16850      named =clear-data= in =file.org=, you can write the following:
16852      #+begin_src org
16853        ,#+CALL: file.org:clear-data()
16854      #+end_src
16856 - =<arguments>= ::
16858      Org passes arguments to the code block using standard function
16859      call syntax.  For example, a =#+CALL:= line that passes =4= to
16860      a code block named =double=, which declares the header argument
16861      =:var n=2=, would be written as:
16863      : #+CALL: double(n=4)
16865      #+texinfo: @noindent
16866      Note how this function call syntax is different from the header
16867      argument syntax.
16869 - =<inside header arguments>= ::
16871      Org passes inside header arguments to the named code block using
16872      the header argument syntax.  Inside header arguments apply to
16873      code block evaluation.  For example, =[:results output]= collects
16874      results printed to stdout during code execution of that block.
16875      Note how this header argument syntax is different from the
16876      function call syntax.
16878 - =<end header arguments>= ::
16880      End header arguments affect the results returned by the code
16881      block.  For example, =:results html= wraps the results in
16882      a =#+BEGIN_EXPORT html= block before inserting the results in the
16883      Org buffer.
16885 *** Limit code block evaluation
16886 :PROPERTIES:
16887 :UNNUMBERED: notoc
16888 :END:
16890 #+cindex: @samp{eval}, header argument
16891 #+cindex: control code block evaluation
16892 The =eval= header argument can limit evaluation of specific code
16893 blocks and =CALL= keyword.  It is useful for protection against
16894 evaluating untrusted code blocks by prompting for a confirmation.
16896 - =never= or =no= ::
16898      Org never evaluates the source code.
16900 - =query= ::
16902      Org prompts the user for permission to evaluate the source code.
16904 - =never-export= or =no-export= ::
16906      Org does not evaluate the source code when exporting, yet the
16907      user can evaluate it interactively.
16909 - =query-export= ::
16911      Org prompts the user for permission to evaluate the source code
16912      during export.
16914 If =eval= header argument is not set, then Org determines whether to
16915 evaluate the source code from the ~org-confirm-babel-evaluate~
16916 variable (see [[*Code Evaluation and Security Issues]]).
16918 *** Cache results of evaluation
16919 :PROPERTIES:
16920 :UNNUMBERED: notoc
16921 :END:
16923 #+cindex: @samp{cache}, header argument
16924 #+cindex: cache results of code evaluation
16925 The =cache= header argument is for caching results of evaluating code
16926 blocks.  Caching results can avoid re-evaluating a code block that
16927 have not changed since the previous run.  To benefit from the cache
16928 and avoid redundant evaluations, the source block must have a result
16929 already present in the buffer, and neither the header
16930 arguments---including the value of =var= references---nor the text of
16931 the block itself has changed since the result was last computed.  This
16932 feature greatly helps avoid long-running calculations.  For some edge
16933 cases, however, the cached results may not be reliable.
16935 The caching feature is best for when code blocks are pure functions,
16936 that is functions that return the same value for the same input
16937 arguments (see [[*Environment of a Code Block]]), and that do not have
16938 side effects, and do not rely on external variables other than the
16939 input arguments.  Functions that depend on a timer, file system
16940 objects, and random number generators are clearly unsuitable for
16941 caching.
16943 A note of warning: when =cache= is used in a session, caching may
16944 cause unexpected results.
16946 When the caching mechanism tests for any source code changes, it does
16947 not expand Noweb style references (see [[*Noweb Reference Syntax]]).  For
16948 reasons why, see http://thread.gmane.org/gmane.emacs.orgmode/79046.
16950 The =cache= header argument can have one of two values: =yes= or =no=.
16952 - =no= ::
16954      Default.  No caching of results; code block evaluated every
16955      time.
16957 - =yes= ::
16959      Whether to run the code or return the cached results is
16960      determined by comparing the SHA1 hash value of the combined code
16961      block and arguments passed to it.  This hash value is packed on
16962      the =#+RESULTS:= line from previous evaluation.  When hash values
16963      match, Org does not evaluate the code block.  When hash values
16964      mismatch, Org evaluates the code block, inserts the results,
16965      recalculates the hash value, and updates =#+RESULTS:= line.
16967 In this example, both functions are cached.  But =caller= runs only if
16968 the result from =random= has changed since the last run.
16970 #+begin_example
16971   ,#+NAME: random
16972   ,#+BEGIN_SRC R :cache yes
16973     runif(1)
16974   ,#+END_SRC
16976   ,#+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
16977   0.4659510825295
16979   ,#+NAME: caller
16980   ,#+BEGIN_SRC emacs-lisp :var x=random :cache yes
16981     x
16982   ,#+END_SRC
16984   ,#+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
16985   0.254227238707244
16986 #+end_example
16988 ** Results of Evaluation
16989 :PROPERTIES:
16990 :DESCRIPTION: Choosing a results type, post-processing...
16991 :END:
16992 #+cindex: code block, results of evaluation
16993 #+cindex: source code, results of evaluation
16995 #+cindex: @samp{results}, header argument
16996 How Org handles results of a code block execution depends on many
16997 header arguments working together.  The primary determinant, however,
16998 is the =results= header argument.  It accepts four classes of options.
16999 Each code block can take only one option per class:
17001 - collection ::
17003      For how the results should be collected from the code block;
17005 - type ::
17007      For which type of result the code block will return; affects how
17008      Org processes and inserts results in the Org buffer;
17010 - format ::
17012      For the result; affects how Org processes and inserts results in
17013      the Org buffer;
17015 - handling ::
17017      For processing results after evaluation of the code block;
17019 *** Collection
17020 :PROPERTIES:
17021 :UNNUMBERED: notoc
17022 :END:
17024 Collection options specify the results.  Choose one of the options;
17025 they are mutually exclusive.
17027 - =value= ::
17029      Default.  Functional mode.  Org gets the value by wrapping the
17030      code in a function definition in the language of the source
17031      block.  That is why when using =:results value=, code should
17032      execute like a function and return a value.  For languages like
17033      Python, an explicit ~return~ statement is mandatory when using
17034      =:results value=.  Result is the value returned by the last
17035      statement in the code block.
17037      When evaluating the code block in a session (see [[*Environment of
17038      a Code Block]]), Org passes the code to an interpreter running as
17039      an interactive Emacs inferior process. Org gets the value from
17040      the source code interpreter's last statement output.  Org has to
17041      use language-specific methods to obtain the value.  For example,
17042      from the variable ~_~ in Python and Ruby, and the value of
17043      ~.Last.value~ in R.
17045 - =output= ::
17047      Scripting mode.  Org passes the code to an external process
17048      running the interpreter.  Org returns the contents of the
17049      standard output stream as text results.
17051      When using a session, Org passes the code to the interpreter
17052      running as an interactive Emacs inferior process.  Org
17053      concatenates any text output from the interpreter and returns the
17054      collection as a result.
17056      Note that this collection is not the same as that would be
17057      collected from stdout of a non-interactive interpreter running as
17058      an external process.  Compare for example these two blocks:
17060      #+begin_example
17061        ,#+BEGIN_SRC python :results output
17062          print "hello"
17063          2
17064          print "bye"
17065        ,#+END_SRC
17067        ,#+RESULTS:
17068        : hello
17069        : bye
17070      #+end_example
17072      In the above non-session mode, the "2" is not printed; so it does
17073      not appear in results.
17075      #+begin_example
17076        ,#+BEGIN_SRC python :results output :session
17077          print "hello"
17078          2
17079          print "bye"
17080        ,#+END_SRC
17082        ,#+RESULTS:
17083        : hello
17084        : 2
17085        : bye
17086      #+end_example
17088      In the above session, the interactive interpreter receives and
17089      prints "2".  Results show that.
17091 *** Type
17092 :PROPERTIES:
17093 :UNNUMBERED: notoc
17094 :END:
17096 Type tells what result types to expect from the execution of the code
17097 block.  Choose one of the options; they are mutually exclusive.  The
17098 default behavior is to automatically determine the result type.
17100 #+attr_texinfo: :sep ,
17101 - =table=, =vector= ::
17103      Interpret the results as an Org table.  If the result is a single
17104      value, create a table with one row and one column.  Usage
17105      example: =:results value table=.
17107      #+cindex: @samp{hlines}, header argument
17108      In-between each table row or below the table headings, sometimes
17109      results have horizontal lines, which are also known as "hlines".
17110      The =hlines= argument with the default =no= value strips such
17111      lines from the input table.  For most code, this is desirable, or
17112      else those =hline= symbols raise unbound variable errors.
17113      A =yes= accepts such lines, as demonstrated in the following
17114      example.
17116      #+begin_example
17117        ,#+NAME: many-cols
17118        | a | b | c |
17119        |---+---+---|
17120        | d | e | f |
17121        |---+---+---|
17122        | g | h | i |
17124        ,#+NAME: no-hline
17125        ,#+BEGIN_SRC python :var tab=many-cols :hlines no
17126          return tab
17127        ,#+END_SRC
17129        ,#+RESULTS: no-hline
17130        | a | b | c |
17131        | d | e | f |
17132        | g | h | i |
17134        ,#+NAME: hlines
17135        ,#+BEGIN_SRC python :var tab=many-cols :hlines yes
17136          return tab
17137        ,#+END_SRC
17139        ,#+RESULTS: hlines
17140        | a | b | c |
17141        |---+---+---|
17142        | d | e | f |
17143        |---+---+---|
17144        | g | h | i |
17145      #+end_example
17147 - =list= ::
17149      Interpret the results as an Org list.  If the result is a single
17150      value, create a list of one element.
17152 - =scalar=, =verbatim= ::
17154      Interpret literally and insert as quoted text.  Do not create
17155      a table.  Usage example: =:results value verbatim=.
17157 - =file= ::
17159      Interpret as a filename.  Save the results of execution of the
17160      code block to that file, then insert a link to it.  You can
17161      control both the filename and the description associated to the
17162      link.
17164      #+cindex: @samp{file}, header argument
17165      #+cindex: @samp{output-dir}, header argument
17166      Org first tries to generate the filename from the value of the
17167      =file= header argument and the directory specified using the
17168      =output-dir= header arguments.  If =output-dir= is not specified,
17169      Org assumes it is the current directory.
17171      #+begin_example
17172        ,#+BEGIN_SRC asymptote :results value file :file circle.pdf :output-dir img/
17173          size(2cm);
17174          draw(unitcircle);
17175        ,#+END_SRC
17176      #+end_example
17178      #+cindex: @samp{file-ext}, header argument
17179      If =file= is missing, Org generates the base name of the output
17180      file from the name of the code block, and its extension from the
17181      =file-ext= header argument.  In that case, both the name and the
17182      extension are mandatory.
17184      #+begin_example
17185        ,#+name: circle
17186        ,#+BEGIN_SRC asymptote :results value file :file-ext pdf
17187          size(2cm);
17188          draw(unitcircle);
17189        ,#+END_SRC
17190      #+end_example
17192      #+cindex: @samp{file-desc}, header argument
17193      The =file-desc= header argument defines the description (see
17194      [[*Link Format]]) for the link.  If =file-desc= has no value, Org
17195      uses the generated file name for both the "link" and
17196      "description" parts of the link.
17198 *** Format
17199 :PROPERTIES:
17200 :UNNUMBERED: notoc
17201 :END:
17203 Format pertains to the type of the result returned by the code block.
17204 Choose one of the options; they are mutually exclusive.  The default
17205 follows from the type specified above.
17207 - =raw= ::
17209      Interpreted as raw Org mode.  Inserted directly into the buffer.
17210      Aligned if it is a table.  Usage example: =:results value raw=.
17212 - =org= ::
17214      Results enclosed in a =BEGIN_SRC org= block.  For comma-escape,
17215      either {{{kbd(TAB)}}} in the block, or export the file.  Usage
17216      example: =:results value org=.
17218 - =html= ::
17220      Results enclosed in a =BEGIN_EXPORT html= block.  Usage example:
17221      =:results value html=.
17223 - =latex= ::
17225      Results enclosed in a =BEGIN_EXPORT latex= block.  Usage example:
17226      =:results value latex=.
17228 - =code= ::
17230      Result enclosed in a code block.  Useful for parsing.  Usage
17231      example: =:results value code=.
17233 - =pp= ::
17235      Result converted to pretty-print source code.  Enclosed in a code
17236      block.  Languages supported: Emacs Lisp, Python, and Ruby.  Usage
17237      example: =:results value pp=.
17239 - =drawer= ::
17241      Result wrapped in a =RESULTS= drawer.  Useful for containing
17242      =raw= or =org= results for later scripting and automated
17243      processing.  Usage example: =:results value drawer=.
17245 *** Handling
17246 :PROPERTIES:
17247 :UNNUMBERED: notoc
17248 :END:
17250 Handling options after collecting the results.
17252 - =silent= ::
17254      Do not insert results in the Org mode buffer, but echo them in
17255      the minibuffer.  Usage example: =:results output silent=.
17257 - =replace= ::
17259      Default.  Insert results in the Org buffer.  Remove previous
17260      results.  Usage example: =:results output replace=.
17262 - =append= ::
17264      Append results to the Org buffer.  Latest results are at the
17265      bottom.  Does not remove previous results.  Usage example:
17266      =:results output append=.
17268 - =prepend= ::
17270      Prepend results to the Org buffer.  Latest results are at the
17271      top.  Does not remove previous results.  Usage example: =:results
17272      output prepend=.
17274 *** Post-processing
17275 :PROPERTIES:
17276 :UNNUMBERED: notoc
17277 :END:
17279 #+cindex: @samp{post}, header argument
17280 #+cindex: @samp{*this*}, in @samp{post} header argument
17281 The =post= header argument is for post-processing results from block
17282 evaluation.  When =post= has any value, Org binds the results to
17283 ~*this*~ variable for easy passing to =var= header argument
17284 specifications (see [[*Environment of a Code Block]]).  That makes results
17285 available to other code blocks, or even for direct Emacs Lisp code
17286 execution.
17288 The following two examples illustrate =post= header argument in
17289 action.  The first one shows how to attach an =ATTR_LATEX= keyword
17290 using =post=.
17292 #+begin_example
17293   ,#+NAME: attr_wrap
17294   ,#+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output
17295     echo "#+ATTR_LATEX: :width $width"
17296     echo "$data"
17297   ,#+END_SRC
17299   ,#+HEADER: :file /tmp/it.png
17300   ,#+BEGIN_SRC dot :post attr_wrap(width="5cm", data=*this*) :results drawer
17301     digraph{
17302             a -> b;
17303             b -> c;
17304             c -> a;
17305     }
17306   ,#+end_src
17308   ,#+RESULTS:
17309   :RESULTS:
17310   ,#+ATTR_LATEX :width 5cm
17311   [[file:/tmp/it.png]]
17312   :END:
17313 #+end_example
17315 The second example shows use of =colnames= header argument in =post=
17316 to pass data between code blocks.
17318 #+begin_example
17319   ,#+NAME: round-tbl
17320   ,#+BEGIN_SRC emacs-lisp :var tbl="" fmt="%.3f"
17321     (mapcar (lambda (row)
17322               (mapcar (lambda (cell)
17323                         (if (numberp cell)
17324                             (format fmt cell)
17325                           cell))
17326                       row))
17327             tbl)
17328   ,#+end_src
17330   ,#+BEGIN_SRC R :colnames yes :post round-tbl[:colnames yes](*this*)
17331     set.seed(42)
17332     data.frame(foo=rnorm(1))
17333   ,#+END_SRC
17335   ,#+RESULTS:
17336   |   foo |
17337   |-------|
17338   | 1.371 |
17339 #+end_example
17341 ** Exporting Code Blocks
17342 :PROPERTIES:
17343 :DESCRIPTION: Export contents and/or results.
17344 :END:
17345 #+cindex: code block, exporting
17346 #+cindex: source code, exporting
17348 It is possible to export the /code/ of code blocks, the /results/ of
17349 code block evaluation, /both/ the code and the results of code block
17350 evaluation, or /none/.  Org defaults to exporting /code/ for most
17351 languages.  For some languages, such as ditaa, Org defaults to
17352 /results/.  To export just the body of code blocks, see [[*Literal
17353 Examples]].  To selectively export sub-trees of an Org document, see
17354 [[*Exporting]].
17356 #+cindex: @samp{export}, header argument
17357 The =exports= header argument is to specify if that part of the Org
17358 file is exported to, say, HTML or LaTeX formats.
17360 - =code= ::
17362      The default.  The body of code is included into the exported
17363      file.  Example: =:exports code=.
17365 - =results= ::
17367      The results of evaluation of the code is included in the exported
17368      file.  Example: =:exports results=.
17370 - =both= ::
17372      Both the code and results of evaluation are included in the
17373      exported file.  Example: =:exports both=.
17375 - =none= ::
17377      Neither the code nor the results of evaluation is included in the
17378      exported file.  Whether the code is evaluated at all depends on
17379      other options.  Example: =:exports none=.
17381 #+vindex: org-export-use-babel
17382 To stop Org from evaluating code blocks to speed exports, use the
17383 header argument =:eval never-export= (see [[*Evaluating Code Blocks]]).
17384 To stop Org from evaluating code blocks for greater security, set the
17385 ~org-export-use-babel~ variable to ~nil~, but understand that header
17386 arguments will have no effect.
17388 Turning off evaluation comes in handy when batch processing.  For
17389 example, markup languages for wikis, which have a high risk of
17390 untrusted code.  Stopping code block evaluation also stops evaluation
17391 of all header arguments of the code block.  This may not be desirable
17392 in some circumstances.  So during export, to allow evaluation of just
17393 the header arguments but not any code evaluation in the source block,
17394 set =:eval never-export= (see [[*Evaluating Code Blocks]]).
17396 Org never evaluates code blocks in commented sub-trees when exporting
17397 (see [[*Comment Lines]]).  On the other hand, Org does evaluate code
17398 blocks in sub-trees excluded from export (see [[*Export Settings]]).
17400 ** Extracting Source Code
17401 :PROPERTIES:
17402 :DESCRIPTION: Create pure source code files.
17403 :END:
17404 #+cindex: tangling
17405 #+cindex: source code, extracting
17406 #+cindex: code block, extracting source code
17408 Extracting source code from code blocks is a basic task in literate
17409 programming.  Org has features to make this easy.  In literate
17410 programming parlance, documents on creation are /woven/ with code and
17411 documentation, and on export, the code is tangled for execution by
17412 a computer.  Org facilitates weaving and tangling for producing,
17413 maintaining, sharing, and exporting literate programming documents.
17414 Org provides extensive customization options for extracting source
17415 code.
17417 When Org tangles code blocks, it expands, merges, and transforms them.
17418 Then Org recomposes them into one or more separate files, as
17419 configured through the options.  During this tangling process, Org
17420 expands variables in the source code, and resolves any Noweb style
17421 references (see [[*Noweb Reference Syntax]]).
17423 *** Header arguments
17424 :PROPERTIES:
17425 :UNNUMBERED: notoc
17426 :END:
17428 #+cindex: @samp{tangle}, header argument
17429 The =tangle= header argument specifies if the code block is exported
17430 to source file(s).
17432 - =yes= ::
17434      Export the code block to source file.  The file name for the
17435      source file is derived from the name of the Org file, and the
17436      file extension is derived from the source code language
17437      identifier.  Example: =:tangle yes=.
17439 - =no= ::
17441      The default.  Do not extract the code in a source code file.
17442      Example: =:tangle no=.
17444 - {{{var(FILENAME)}}} ::
17446      Export the code block to source file whose file name is derived
17447      from any string passed to the =tangle= header argument.  Org
17448      derives the file name as being relative to the directory of the
17449      Org file's location.  Example: =:tangle FILENAME=.
17451 #+cindex: @samp{mkdirp}, header argument
17452 The =mkdirp= header argument creates parent directories for tangled
17453 files if the directory does not exist.  =yes= enables directory
17454 creation and =no= inhibits directory creation.
17456 #+cindex: @samp{comments}, header argument
17457 The =comments= header argument controls inserting comments into
17458 tangled files.  These are above and beyond whatever comments may
17459 already exist in the code block.
17461 - =no= ::
17463      The default.  Do not insert any extra comments during tangling.
17465 - =link= ::
17467      Wrap the code block in comments.  Include links pointing back to
17468      the place in the Org file from where the code was tangled.
17470 - =yes= ::
17472      Kept for backward compatibility; same as =link=.
17474 - =org= ::
17476      Nearest headline text from Org file is inserted as comment.  The
17477      exact text that is inserted is picked from the leading context of
17478      the source block.
17480 - =both= ::
17482      Includes both =link= and =org= options.
17484 - =noweb= ::
17486      Includes =link= option, expands Noweb references (see [[*Noweb
17487      Reference Syntax]]), and wraps them in link comments inside the
17488      body of the code block.
17490 #+cindex: @samp{padline}, header argument
17491 The =padline= header argument controls insertion of newlines to pad
17492 source code in the tangled file.
17494 - =yes= ::
17496      Default.  Insert a newline before and after each code block in
17497      the tangled file.
17499 - =no= ::
17501      Do not insert newlines to pad the tangled code blocks.
17503 #+cindex: @samp{shebang}, header argument
17504 The =shebang= header argument can turn results into executable script
17505 files.  By setting it to a string value---for example, =:shebang
17506 "#!/bin/bash"=---Org inserts that string as the first line of the
17507 tangled file that the code block is extracted to.  Org then turns on
17508 the tangled file's executable permission.
17510 #+cindex: @samp{no-expand}, header argument
17511 By default Org expands code blocks during tangling.  The =no-expand=
17512 header argument turns off such expansions.  Note that one side-effect
17513 of expansion by ~org-babel-expand-src-block~ also assigns values (see
17514 [[*Environment of a Code Block]]) to variables.  Expansions also replace
17515 Noweb references with their targets (see [[*Noweb Reference Syntax]]).
17516 Some of these expansions may cause premature assignment, hence this
17517 option.  This option makes a difference only for tangling.  It has no
17518 effect when exporting since code blocks for execution have to be
17519 expanded anyway.
17521 *** Functions
17522 :PROPERTIES:
17523 :UNNUMBERED: notoc
17524 :END:
17526 - ~org-babel-tangle~ ::
17528      #+findex: org-babel-tangle
17529      #+kindex: C-c C-v t
17530      Tangle the current file.  Bound to {{{kbd(C-c C-v t)}}}.
17532      With prefix argument only tangle the current code block.
17534 - ~org-babel-tangle-file~ ::
17536      #+findex: org-babel-tangle-file
17537      #+kindex: C-c C-v f
17538      Choose a file to tangle.  Bound to {{{kbd(C-c C-v f)}}}.
17540 *** Hooks
17541 :PROPERTIES:
17542 :UNNUMBERED: notoc
17543 :END:
17545 - ~org-babel-post-tangle-hook~ ::
17547      #+vindex: org-babel-post-tangle-hook
17548      This hook is run from within code files tangled by
17549      ~org-babel-tangle~, making it suitable for post-processing,
17550      compilation, and evaluation of code in the tangled files.
17552 *** Jumping between code and Org
17553 :PROPERTIES:
17554 :UNNUMBERED: notoc
17555 :END:
17557 #+findex: org-babel-tangle-jump-to-org
17558 Debuggers normally link errors and messages back to the source code.
17559 But for tangled files, we want to link back to the Org file, not to
17560 the tangled source file.  To make this extra jump, Org uses
17561 ~org-babel-tangle-jump-to-org~ function with two additional source
17562 code block header arguments:
17564 1. Set =padline= to true---this is the default setting.
17565 2. Set =comments= to =link=, which makes Org insert links to the Org
17566    file.
17568 ** Languages
17569 :PROPERTIES:
17570 :DESCRIPTION: List of supported code block languages.
17571 :END:
17572 #+cindex: babel, languages
17573 #+cindex: source code, languages
17574 #+cindex: code block, languages
17576 Code blocks in the following languages are supported.
17578 | Language   | Identifier | Language       | Identifier |
17579 |------------+------------+----------------+------------|
17580 | Asymptote  | asymptote  | Awk            | awk        |
17581 | C          | C          | C++            | C++        |
17582 | Clojure    | clojure    | CSS            | css        |
17583 | D          | d          | ditaa          | ditaa      |
17584 | Graphviz   | dot        | Emacs Calc     | calc       |
17585 | Emacs Lisp | emacs-lisp | Fortran        | fortran    |
17586 | Gnuplot    | gnuplot    | Haskell        | haskell    |
17587 | Java       | java       | Javascript     | js         |
17588 | LaTeX      | latex      | Ledger         | ledger     |
17589 | Lisp       | lisp       | Lilypond       | lilypond   |
17590 | Lua        | lua        | MATLAB         | matlab     |
17591 | Mscgen     | mscgen     | Objective Caml | ocaml      |
17592 | Octave     | octave     | Org mode       | org        |
17593 | Oz         | oz         | Perl           | perl       |
17594 | Plantuml   | plantuml   | Processing.js  | processing |
17595 | Python     | python     | R              | R          |
17596 | Ruby       | ruby       | Sass           | sass       |
17597 | Scheme     | scheme     | GNU Screen     | screen     |
17598 | Sed        | sed        | shell          | sh         |
17599 | SQL        | sql        | SQLite         | sqlite     |
17600 | Vala       | vala       |                |            |
17602 Additional documentation for some languages is at
17603 https://orgmode.org/worg/org-contrib/babel/languages.html.
17605 #+vindex: org-babel-load-languages
17606 By default, only Emacs Lisp is enabled for evaluation.  To enable or
17607 disable other languages, customize the ~org-babel-load-languages~
17608 variable either through the Emacs customization interface, or by
17609 adding code to the init file as shown next.
17611 In this example, evaluation is disabled for Emacs Lisp, and enabled
17612 for R.
17614 #+begin_src emacs-lisp
17615   (org-babel-do-load-languages
17616    'org-babel-load-languages
17617    '((emacs-lisp . nil)
17618      (R . t)))
17619 #+end_src
17621 Note that this is not the only way to enable a language.  Org also
17622 enables languages when loaded with ~require~ statement.  For example,
17623 the following enables execution of Clojure code blocks:
17625 #+begin_src emacs-lisp
17626   (require 'ob-clojure)
17627 #+end_src
17629 ** Editing Source Code
17630 :PROPERTIES:
17631 :DESCRIPTION: Language major-mode editing.
17632 :END:
17633 #+cindex: code block, editing
17634 #+cindex: source code, editing
17636 #+kindex: C-c '
17637 Use {{{kbd(C-c ')}}} to edit the current code block.  It opens a new
17638 major-mode edit buffer containing the body of the source code block,
17639 ready for any edits.  Use {{{kbd(C-c ')}}} again to close the buffer
17640 and return to the Org buffer.
17642 #+kindex: C-x C-s
17643 #+vindex: org-edit-src-auto-save-idle-delay
17644 #+cindex: auto-save, in code block editing
17645 {{{kbd(C-x C-s)}}} saves the buffer and updates the contents of the
17646 Org buffer.  Set ~org-edit-src-auto-save-idle-delay~ to save the base
17647 buffer after a certain idle delay time.  Set
17648 ~org-edit-src-turn-on-auto-save~ to auto-save this buffer into
17649 a separate file using Auto-save mode.
17651 While editing the source code in the major mode, the Org Src minor
17652 mode remains active.  It provides these customization variables as
17653 described below.  For even more variables, look in the customization
17654 group ~org-edit-structure~.
17656 - ~org-src-lang-modes~ ::
17658      #+vindex: org-src-lang-modes
17659      If an Emacs major-mode named ~<LANG>-mode~ exists, where
17660      {{{var(<LANG>)}}} is the language identifier from code block's
17661      header line, then the edit buffer uses that major mode.  Use this
17662      variable to arbitrarily map language identifiers to major modes.
17664 - ~org-src-window-setup~ ::
17666      #+vindex: org-src-window-setup
17667      For specifying Emacs window arrangement when the new edit buffer
17668      is created.
17670 - ~org-src-preserve-indentation~ ::
17672      #+cindex: indentation, in code blocks
17673      #+vindex: org-src-preserve-indentation
17674      Default is ~nil~.  Source code is indented.  This indentation
17675      applies during export or tangling, and depending on the context,
17676      may alter leading spaces and tabs.  When non-~nil~, source code
17677      is aligned with the leftmost column.  No lines are modified
17678      during export or tangling, which is very useful for white-space
17679      sensitive languages, such as Python.
17681 - ~org-src-ask-before-returning-to-edit-buffer~ ::
17683      #+vindex: org-src-ask-before-returning-to-edit-buffer
17684      When ~nil~, Org returns to the edit buffer without further
17685      prompts.  The default prompts for a confirmation.
17687 #+vindex: org-src-fontify-natively
17688 #+vindex: org-src-block-faces
17689 Set ~org-src-fontify-natively~ to non-~nil~ to turn on native code
17690 fontification in the /Org/ buffer.  Fontification of code blocks can
17691 give visual separation of text and code on the display page.  To
17692 further customize the appearance of ~org-block~ for specific
17693 languages, customize ~org-src-block-faces~.  The following example
17694 shades the background of regular blocks, and colors source blocks only
17695 for Python and Emacs Lisp languages.
17697 #+begin_src emacs-lisp
17698   (require 'color)
17699   (set-face-attribute 'org-block nil :background
17700                       (color-darken-name
17701                        (face-attribute 'default :background) 3))
17703   (setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF"))
17704                               ("python" (:background "#E5FFB8"))))
17705 #+end_src
17707 ** Noweb Reference Syntax
17708 :PROPERTIES:
17709 :DESCRIPTION: Literate programming in Org mode.
17710 :END:
17711 #+cindex: code block, Noweb reference
17712 #+cindex: syntax, Noweb
17713 #+cindex: source code, Noweb reference
17715 Org supports named blocks in Noweb[fn:133] style syntax:
17717 : <<CODE-BLOCK-ID>>
17719 Org can replace the construct with the source code, or the results of
17720 evaluation, of the code block identified as {{{var(CODE-BLOCK-ID)}}}.
17722 #+cindex: @samp{noweb}, header argument
17723 The =noweb= header argument controls expansion of Noweb syntax
17724 references.  Expansions occur when source code blocks are evaluated,
17725 tangled, or exported.
17727 - =no= ::
17729      Default.  No expansion of Noweb syntax references in the body of
17730      the code when evaluating, tangling, or exporting.
17732 - =yes= ::
17734      Expansion of Noweb syntax references in the body of the code
17735      block when evaluating, tangling, or exporting.
17737 - =tangle= ::
17739      Expansion of Noweb syntax references in the body of the code
17740      block when tangling.  No expansion when evaluating or exporting.
17742 - =no-export= ::
17744      Expansion of Noweb syntax references in the body of the code
17745      block when evaluating or tangling.  No expansion when exporting.
17747 - =strip-export= ::
17749      Expansion of Noweb syntax references in the body of the code
17750      block when expanding prior to evaluating or tangling.  Removes
17751      Noweb syntax references when exporting.
17753 - =eval= ::
17755      Expansion of Noweb syntax references in the body of the code
17756      block only before evaluating.
17758 In the following example,
17760 #+begin_example
17761   ,#+NAME: initialization
17762   ,#+BEGIN_SRC emacs-lisp
17763     (setq sentence "Never a foot too far, even.")
17764   ,#+END_SRC
17766   ,#+BEGIN_SRC emacs-lisp :noweb yes
17767     <<initialization>>
17768     (reverse sentence)
17769   ,#+END_SRC
17770 #+end_example
17772 #+texinfo: @noindent
17773 the second code block is expanded as
17775 #+begin_example
17776   ,#+BEGIN_SRC emacs-lisp :noweb yes
17777     (setq sentence "Never a foot too far, even.")
17778     (reverse sentence)
17779   ,#+END_SRC
17780 #+end_example
17782 Noweb insertions honor prefix characters that appear before the Noweb
17783 syntax reference.  This behavior is illustrated in the following
17784 example.  Because the =<<example>>= Noweb reference appears behind the
17785 SQL comment syntax, each line of the expanded Noweb reference is
17786 commented.  With:
17788 #+begin_example
17789   ,#+NAME: example
17790   ,#+BEGIN_SRC text
17791     this is the
17792     multi-line body of example
17793   ,#+END_SRC
17794 #+end_example
17796 #+texinfo: @noindent
17797 this code block:
17799 #+begin_example
17800   ,#+BEGIN_SRC sql :noweb yes
17801    ---<<example>>
17802   ,#+END_SRC
17803 #+end_example
17805 #+texinfo: @noindent
17806 expands to:
17808 #+begin_example
17809   ,#+BEGIN_SRC sql :noweb yes
17810    ---this is the
17811    ---multi-line body of example
17812   ,#+END_SRC
17813 #+end_example
17815 Since this change does not affect Noweb replacement text without
17816 newlines in them, inline Noweb references are acceptable.
17818 This feature can also be used for management of indentation in
17819 exported code snippets.  With:
17821 #+begin_example
17822   ,#+NAME: if-true
17823   ,#+BEGIN_SRC python :exports none
17824     print('do things when true')
17825   ,#+end_src
17827   ,#+name: if-false
17828   ,#+begin_src python :exports none
17829     print('do things when false')
17830   ,#+end_src
17831 #+end_example
17833 #+texinfo: @noindent
17834 this code block:
17836 #+begin_example
17837   ,#+begin_src python :noweb yes :results output
17838     if true:
17839         <<if-true>>
17840     else:
17841         <<if-false>>
17842   ,#+end_src
17843 #+end_example
17845 #+texinfo: @noindent
17846 expands to:
17848 #+begin_example
17849   if true:
17850       print('do things when true')
17851   else:
17852       print('do things when false')
17853 #+end_example
17855 #+cindex: @samp{noweb-ref}, header argument
17856 When expanding Noweb style references, Org concatenates code blocks by
17857 matching the reference name to either the code block name or, if none
17858 is found, to the =noweb-ref= header argument.
17860 For simple concatenation, set this =noweb-ref= header argument at the
17861 sub-tree or file level.  In the example Org file shown next, the body
17862 of the source code in each block is extracted for concatenation to
17863 a pure code file when tangled.
17865 #+begin_example
17866   ,#+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
17867     <<fullest-disk>>
17868   ,#+END_SRC
17869   ,* the mount point of the fullest disk
17870     :PROPERTIES:
17871     :header-args: :noweb-ref fullest-disk
17872     :END:
17874   ,** query all mounted disks
17875   ,#+BEGIN_SRC sh
17876     df \
17877   ,#+END_SRC
17879   ,** strip the header row
17880   ,#+BEGIN_SRC sh
17881     |sed '1d' \
17882   ,#+END_SRC
17884   ,** output mount point of fullest disk
17885   ,#+BEGIN_SRC sh
17886     |awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}'
17887   ,#+END_SRC
17888 #+end_example
17890 #+cindex: @samp{noweb-sep}, header argument
17891 By default a newline separates each noweb reference concatenation.  To
17892 change this newline separator, edit the =noweb-sep= header argument.
17894 Eventually, Org can include the results of a code block rather than
17895 its body.  To that effect, append parentheses, possibly including
17896 arguments, to the code block name, as shown below.
17898 : <<code-block-name(optional arguments)>>
17900 Note that when using the above approach to a code block's results, the
17901 code block name set by =NAME= keyword is required; the reference set
17902 by =noweb-ref= does not work in that case.
17904 Here is an example that demonstrates how the exported content changes
17905 when Noweb style references are used with parentheses versus without.
17906 With:
17908 #+begin_example
17909   ,#+NAME: some-code
17910   ,#+BEGIN_SRC python :var num=0 :results output :exports none
17911     print(num*10)
17912   ,#+END_SRC
17913 #+end_example
17915 #+texinfo: @noindent
17916 this code block:
17918 #+begin_example
17919   ,#+BEGIN_SRC text :noweb yes
17920     <<some-code>>
17921   ,#+END_SRC
17922 #+end_example
17924 #+texinfo: @noindent
17925 expands to:
17927 : print(num*10)
17929 Below, a similar Noweb style reference is used, but with parentheses,
17930 while setting a variable =num= to 10:
17932 #+begin_example
17933   ,#+BEGIN_SRC text :noweb yes
17934     <<some-code(num=10)>>
17935   ,#+END_SRC
17936 #+end_example
17938 #+texinfo: @noindent
17939 Note that now the expansion contains the results of the code block
17940 =some-code=, not the code block itself:
17942 : 100
17944 ** Library of Babel
17945 :PROPERTIES:
17946 :DESCRIPTION: Use and contribute to a library of useful code blocks.
17947 :END:
17948 #+cindex: babel, library of
17949 #+cindex: source code, library
17950 #+cindex: code block, library
17952 The "Library of Babel" is a collection of code blocks.  Like
17953 a function library, these code blocks can be called from other Org
17954 files.  A collection of useful code blocks is available on [[https://orgmode.org/worg/library-of-babel.html][Worg]].  For
17955 remote code block evaluation syntax, see [[*Evaluating Code Blocks]].
17957 #+kindex: C-c C-v i
17958 #+findex: org-babel-lob-ingest
17959 For any user to add code to the library, first save the code in
17960 regular code blocks of an Org file, and then load the Org file with
17961 ~org-babel-lob-ingest~, which is bound to {{{kbd(C-c C-v i)}}}.
17963 ** Key bindings and Useful Functions
17964 :PROPERTIES:
17965 :DESCRIPTION: Work quickly with code blocks.
17966 :END:
17967 #+cindex: code block, key bindings
17969 Many common Org mode key sequences are re-bound depending on
17970 the context.
17972 Active key bindings in code blocks:
17974 #+kindex: C-c C-c
17975 #+findex: org-babel-execute-src-block
17976 #+kindex: C-c C-o
17977 #+findex: org-babel-open-src-block-result
17978 #+kindex: M-up
17979 #+findex: org-babel-load-in-session
17980 #+kindex: M-down
17981 #+findex: org-babel-pop-to-session
17982 #+attr_texinfo: :columns 0.2 0.55
17983 | Key binding        | Function                          |
17984 |--------------------+-----------------------------------|
17985 | {{{kbd(C-c C-c)}}} | ~org-babel-execute-src-block~     |
17986 | {{{kbd(C-c C-o)}}} | ~org-babel-open-src-block-result~ |
17987 | {{{kbd(M-up)}}}    | ~org-babel-load-in-session~       |
17988 | {{{kbd(M-down)}}}  | ~org-babel-pop-to-session~        |
17990 Active key bindings in Org mode buffer:
17992 #+kindex: C-c C-v p
17993 #+kindex: C-c C-v C-p
17994 #+kindex: C-c C-v n
17995 #+kindex: C-c C-v C-n
17996 #+kindex: C-c C-v e
17997 #+kindex: C-c C-v C-e
17998 #+kindex: C-c C-v o
17999 #+kindex: C-c C-v C-o
18000 #+kindex: C-c C-v v
18001 #+kindex: C-c C-v C-v
18002 #+kindex: C-c C-v u
18003 #+kindex: C-c C-v C-u
18004 #+kindex: C-c C-v g
18005 #+kindex: C-c C-v C-g
18006 #+kindex: C-c C-v r
18007 #+kindex: C-c C-v C-r
18008 #+kindex: C-c C-v b
18009 #+kindex: C-c C-v C-b
18010 #+kindex: C-c C-v s
18011 #+kindex: C-c C-v C-s
18012 #+kindex: C-c C-v d
18013 #+kindex: C-c C-v C-d
18014 #+kindex: C-c C-v t
18015 #+kindex: C-c C-v C-t
18016 #+kindex: C-c C-v f
18017 #+kindex: C-c C-v C-f
18018 #+kindex: C-c C-v c
18019 #+kindex: C-c C-v C-c
18020 #+kindex: C-c C-v j
18021 #+kindex: C-c C-v C-j
18022 #+kindex: C-c C-v l
18023 #+kindex: C-c C-v C-l
18024 #+kindex: C-c C-v i
18025 #+kindex: C-c C-v C-i
18026 #+kindex: C-c C-v I
18027 #+kindex: C-c C-v C-I
18028 #+kindex: C-c C-v z
18029 #+kindex: C-c C-v C-z
18030 #+kindex: C-c C-v a
18031 #+kindex: C-c C-v C-a
18032 #+kindex: C-c C-v h
18033 #+kindex: C-c C-v C-h
18034 #+kindex: C-c C-v x
18035 #+kindex: C-c C-v C-x
18036 #+findex: org-babel-previous-src-block
18037 #+findex: org-babel-next-src-block
18038 #+findex: org-babel-execute-maybe
18039 #+findex: org-babel-open-src-block-result
18040 #+findex: org-babel-expand-src-block
18041 #+findex: org-babel-goto-src-block-head
18042 #+findex: org-babel-goto-named-src-block
18043 #+findex: org-babel-goto-named-result
18044 #+findex: org-babel-execute-buffer
18045 #+findex: org-babel-execute-subtree
18046 #+findex: org-babel-demarcate-block
18047 #+findex: org-babel-tangle
18048 #+findex: org-babel-tangle-file
18049 #+findex: org-babel-check-src-block
18050 #+findex: org-babel-insert-header-arg
18051 #+findex: org-babel-load-in-session
18052 #+findex: org-babel-lob-ingest
18053 #+findex: org-babel-view-src-block-info
18054 #+findex: org-babel-switch-to-session-with-code
18055 #+findex: org-babel-sha1-hash
18056 #+findex: org-babel-describe-bindings
18057 #+findex: org-babel-do-key-sequence-in-edit-buffer
18058 #+attr_texinfo: :columns 0.45 0.55
18059 | Key binding                                    | Function                                   |
18060 |------------------------------------------------+--------------------------------------------|
18061 | {{{kbd(C-c C-v p)}}} or {{{kbd(C-c C-v C-p)}}} | ~org-babel-previous-src-block~             |
18062 | {{{kbd(C-c C-v n)}}} or {{{kbd(C-c C-v C-n)}}} | ~org-babel-next-src-block~                 |
18063 | {{{kbd(C-c C-v e)}}} or {{{kbd(C-c C-v C-e)}}} | ~org-babel-execute-maybe~                  |
18064 | {{{kbd(C-c C-v o)}}} or {{{kbd(C-c C-v C-o)}}} | ~org-babel-open-src-block-result~          |
18065 | {{{kbd(C-c C-v v)}}} or {{{kbd(C-c C-v C-v)}}} | ~org-babel-expand-src-block~               |
18066 | {{{kbd(C-c C-v u)}}} or {{{kbd(C-c C-v C-u)}}} | ~org-babel-goto-src-block-head~            |
18067 | {{{kbd(C-c C-v g)}}} or {{{kbd(C-c C-v C-g)}}} | ~org-babel-goto-named-src-block~           |
18068 | {{{kbd(C-c C-v r)}}} or {{{kbd(C-c C-v C-r)}}} | ~org-babel-goto-named-result~              |
18069 | {{{kbd(C-c C-v b)}}} or {{{kbd(C-c C-v C-b)}}} | ~org-babel-execute-buffer~                 |
18070 | {{{kbd(C-c C-v s)}}} or {{{kbd(C-c C-v C-s)}}} | ~org-babel-execute-subtree~                |
18071 | {{{kbd(C-c C-v d)}}} or {{{kbd(C-c C-v C-d)}}} | ~org-babel-demarcate-block~                |
18072 | {{{kbd(C-c C-v t)}}} or {{{kbd(C-c C-v C-t)}}} | ~org-babel-tangle~                         |
18073 | {{{kbd(C-c C-v f)}}} or {{{kbd(C-c C-v C-f)}}} | ~org-babel-tangle-file~                    |
18074 | {{{kbd(C-c C-v c)}}} or {{{kbd(C-c C-v C-c)}}} | ~org-babel-check-src-block~                |
18075 | {{{kbd(C-c C-v j)}}} or {{{kbd(C-c C-v C-j)}}} | ~org-babel-insert-header-arg~              |
18076 | {{{kbd(C-c C-v l)}}} or {{{kbd(C-c C-v C-l)}}} | ~org-babel-load-in-session~                |
18077 | {{{kbd(C-c C-v i)}}} or {{{kbd(C-c C-v C-i)}}} | ~org-babel-lob-ingest~                     |
18078 | {{{kbd(C-c C-v I)}}} or {{{kbd(C-c C-v C-I)}}} | ~org-babel-view-src-block-info~            |
18079 | {{{kbd(C-c C-v z)}}} or {{{kbd(C-c C-v C-z)}}} | ~org-babel-switch-to-session-with-code~    |
18080 | {{{kbd(C-c C-v a)}}} or {{{kbd(C-c C-v C-a)}}} | ~org-babel-sha1-hash~                      |
18081 | {{{kbd(C-c C-v h)}}} or {{{kbd(C-c C-v C-h)}}} | ~org-babel-describe-bindings~              |
18082 | {{{kbd(C-c C-v x)}}} or {{{kbd(C-c C-v C-x)}}} | ~org-babel-do-key-sequence-in-edit-buffer~ |
18084 ** Batch Execution
18085 :PROPERTIES:
18086 :DESCRIPTION: Call functions from the command line.
18087 :END:
18088 #+cindex: code block, batch execution
18089 #+cindex: source code, batch execution
18091 Org mode features, including working with source code facilities can
18092 be invoked from the command line.  This enables building shell scripts
18093 for batch processing, running automated system tasks, and expanding
18094 Org mode's usefulness.
18096 The sample script shows batch processing of multiple files using
18097 ~org-babel-tangle~.
18099 #+begin_example
18100   #!/bin/sh
18101   # Tangle files with Org mode
18102   #
18103   emacs -Q --batch --eval "
18104       (progn
18105         (require 'ob-tangle)
18106         (dolist (file command-line-args-left)
18107           (with-current-buffer (find-file-noselect file)
18108             (org-babel-tangle))))
18109     " "$@"
18110 #+end_example
18112 * Miscellaneous
18113 :PROPERTIES:
18114 :DESCRIPTION: All the rest which did not fit elsewhere.
18115 :END:
18117 ** Completion
18118 :PROPERTIES:
18119 :DESCRIPTION: M-TAB guesses completions.
18120 :END:
18121 #+cindex: completion, of @TeX{} symbols
18122 #+cindex: completion, of TODO keywords
18123 #+cindex: completion, of dictionary words
18124 #+cindex: completion, of option keywords
18125 #+cindex: completion, of tags
18126 #+cindex: completion, of property keys
18127 #+cindex: completion, of link abbreviations
18128 #+cindex: @TeX{} symbol completion
18129 #+cindex: TODO keywords completion
18130 #+cindex: dictionary word completion
18131 #+cindex: option keyword completion
18132 #+cindex: tag completion
18133 #+cindex: link abbreviations, completion of
18135 Org has in-buffer completions.  Unlike minibuffer completions, which
18136 are useful for quick command interactions, Org's in-buffer completions
18137 are more suitable for content creation in Org documents.  Type one or
18138 more letters and invoke the hot key to complete the text in-place.
18139 Depending on the context and the keys, Org offers different types of
18140 completions.  No minibuffer is involved.  Such mode-specific hot keys
18141 have become an integral part of Emacs and Org provides several
18142 shortcuts.
18144 - {{{kbd(M-TAB)}}} ::
18145      #+kindex: M-TAB
18147      Complete word at point.
18149      - At the beginning of a headline, complete TODO keywords.
18151      - After =\=, complete TeX symbols supported by the exporter.
18153      - After =*=, complete headlines in the current buffer so that
18154        they can be used in search links like:
18156        : [[*find this headline]]
18158      - After =:= in a headline, complete tags.  Org deduces the list
18159        of tags from the =TAGS= in-buffer option (see [[*Setting Tags]]),
18160        the variable ~org-tag-alist~, or from all tags used in the
18161        current buffer.
18163      - After =:= and not in a headline, complete property keys.  The
18164        list of keys is constructed dynamically from all keys used in
18165        the current buffer.
18167      - After =[=, complete link abbreviations (see [[*Link
18168        Abbreviations]]).
18170      - After =#+=, complete the special keywords like =TYP_TODO= or
18171        file-specific =OPTIONS=.  After option keyword is complete,
18172        pressing {{{kbd(M-TAB)}}} again inserts example settings for
18173        this keyword.
18175      - After =STARTUP= keyword, complete startup items.
18177      - When point is anywhere else, complete dictionary words using
18178        Ispell.
18180 ** Structure Templates
18181 :PROPERTIES:
18182 :DESCRIPTION: Quick insertion of structural elements.
18183 :END:
18184 #+cindex: template insertion
18185 #+cindex: insertion, of templates
18187 With just a few keystrokes, it is possible to insert empty structural
18188 blocks, such as =#+BEGIN_SRC= ... =#+END_SRC=, or to wrap existing
18189 text in such a block.
18191 - {{{kbd(C-c C-x w)}}} (~org-insert-structure-template~) ::
18193      Prompt for a type of block structure, and insert the block at
18194      point.  If the region is active, it is wrapped in the block.
18195      First prompts the user for a key, which is used to look up
18196      a structure type from the values below.  If the key is
18197      {{{kbd(TAB)}}}, the user is prompted to enter a type.
18199 #+vindex: org-structure-template-alist
18200 Available structure types are defined in
18201 ~org-structure-template-alist~, see the docstring for adding or
18202 changing values.
18204 #+cindex: Tempo
18205 #+cindex: template expansion
18206 #+cindex: insertion, of templates
18207 #+vindex: org-tempo-keywords-alist
18208 #+vindex: org-structure-template-alist
18209 Org Tempo expands snippets to structures defined in
18210 ~org-structure-template-alist~ and ~org-tempo-keywords-alist~.  For
18211 example, {{{kbd(< s TAB)}}} creates a code block.  Enable it by
18212 customizing ~org-modules~ or add ~(require 'org-tempo)~ to your Emacs
18213 init file[fn:134].
18216 #+attr_texinfo: :columns 0.1 0.9
18217 | {{{kbd(a)}}} | =#+BEGIN_EXPORT ascii= ... =#+END_EXPORT= |
18218 | {{{kbd(c)}}} | =#+BEGIN_CENTER= ... =#+END_CENTER=       |
18219 | {{{kbd(C)}}} | =#+BEGIN_COMMENT= ... =#+END_COMMENT=     |
18220 | {{{kbd(e)}}} | =#+BEGIN_EXAMPLE= ... =#+END_EXAMPLE=     |
18221 | {{{kbd(h)}}} | =#+BEGIN_EXPORT html= ... =#+END_EXPORT=  |
18222 | {{{kbd(l)}}} | =#+BEGIN_EXPORT latex= ... =#+END_EXPORT= |
18223 | {{{kbd(q)}}} | =#+BEGIN_QUOTE= ... =#+END_QUOTE=         |
18224 | {{{kbd(s)}}} | =#+BEGIN_SRC= ... =#+END_SRC=             |
18225 | {{{kbd(v)}}} | =#+BEGIN_VERSE= ... =#+END_VERSE=         |
18227 ** Speed Keys
18228 :PROPERTIES:
18229 :DESCRIPTION: Electric commands at the beginning of a headline.
18230 :END:
18231 #+cindex: speed keys
18233 Single keystrokes can execute custom commands in an Org file when the
18234 cursor is on a headline.  Without the extra burden of a meta or
18235 modifier key, Speed Keys can speed navigation or execute custom
18236 commands.  Besides faster navigation, Speed Keys may come in handy on
18237 small mobile devices that do not have full keyboards.  Speed Keys may
18238 also work on TTY devices known for their problems when entering Emacs
18239 key chords.
18241 #+vindex: org-use-speed-commands
18242 By default, Org has Speed Keys disabled.  To activate Speed Keys, set
18243 the variable ~org-use-speed-commands~ to a non-~nil~ value.  To
18244 trigger a Speed Key, the cursor must be at the beginning of an Org
18245 headline, before any of the stars.
18247 #+vindex: org-speed-commands-user
18248 #+findex: org-speed-command-help
18249 Org comes with a pre-defined list of Speed Keys.  To add or modify
18250 Speed Keys, customize the variable, ~org-speed-commands-user~.  For
18251 more details, see the variable's docstring.  With Speed Keys
18252 activated, {{{kbd(M-x org-speed-command-help)}}}, or {{{kbd(?)}}} when
18253 cursor is at the beginning of an Org headline, shows currently active
18254 Speed Keys, including the user-defined ones.
18256 ** Code Evaluation and Security Issues
18257 :PROPERTIES:
18258 :DESCRIPTION: Org files evaluate in-line code.
18259 :ALT_TITLE: Code Evaluation Security
18260 :END:
18262 Unlike plain text, running code comes with risk.  Each =src= code
18263 block, in terms of risk, is equivalent to an executable file.  Org
18264 therefore puts a few confirmation prompts by default.  This is to
18265 alert the casual user from accidentally running untrusted code.
18267 For users who do not run code blocks or write code regularly, Org's
18268 default settings should suffice.  However, some users may want to
18269 tweak the prompts for fewer interruptions.  To weigh the risks of
18270 automatic execution of code blocks, here are some details about code
18271 evaluation.
18273 Org evaluates code in the following circumstances:
18275 - /Source code blocks/ ::
18277      Org evaluates =src= code blocks in an Org file during export.
18278      Org also evaluates a =src= code block with the {{{kbd(C-c C-c)}}}
18279      key chord.  Users exporting or running code blocks must load
18280      files only from trusted sources.  Be wary of customizing
18281      variables that remove or alter default security measures.
18283      #+attr_texinfo: :options org-confirm-babel-evaluate
18284      #+begin_defopt
18285      When ~t~, Org prompts the user for confirmation before executing
18286      each code block.  When ~nil~, Org executes code blocks without
18287      prompting the user for confirmation.  When this option is set to
18288      a custom function, Org invokes the function with these two
18289      arguments: the source code language and the body of the code
18290      block.  The custom function must return either a ~t~ or ~nil~,
18291      which determines if the user is prompted.  Each source code
18292      language can be handled separately through this function
18293      argument.
18294      #+end_defopt
18296      For example, here is how to execute ditaa code blocks without
18297      prompting:
18299      #+begin_src emacs-lisp
18300        (defun my-org-confirm-babel-evaluate (lang body)
18301          (not (string= lang "ditaa")))  ;don't ask for ditaa
18302        (setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
18303      #+end_src
18305 - /Following =shell= and =elisp= links/ ::
18307      Org has two link types that can directly evaluate code (see
18308      [[*External Links]]).  Because such code is not visible, these links
18309      have a potential risk.  Org therefore prompts the user when it
18310      encounters such links.  The customization variables are:
18312      #+attr_texinfo: :options org-confirm-shell-link-function
18313      #+begin_defopt
18314      Function that prompts the user before executing a shell link.
18315      #+end_defopt
18317      #+attr_texinfo: :options org-confirm-elisp-link-function
18318      #+begin_defopt
18319      Function that prompts the user before executing an Emacs Lisp link.
18320      #+end_defopt
18322 - /Formulas in tables/ ::
18324      Formulas in tables (see [[*The spreadsheet]]) are code that is
18325      evaluated either by the Calc interpreter, or by the Emacs Lisp
18326      interpreter.
18328 ** Customization
18329 :PROPERTIES:
18330 :DESCRIPTION: Adapting Org to your taste.
18331 :END:
18332 #+cindex: customization
18333 #+cindex: options, for customization
18334 #+cindex: variables, for customization
18336 Org has more than 500 variables for customization.  They can be
18337 accessed through the usual {{{kbd(M-x org-customize)}}} command.  Or
18338 through the Org menu: Org \rarr Customization \rarr Browse Org Group.
18340 Org also has per-file settings for some variables (see [[*Summary of
18341 In-Buffer Settings]]).
18343 ** Summary of In-Buffer Settings
18344 :PROPERTIES:
18345 :DESCRIPTION: Overview of the #+KEYWORDS.
18346 :ALT_TITLE: In-buffer Settings
18347 :END:
18348 #+cindex: in-buffer settings
18349 #+cindex: special keywords
18351 In-buffer settings start with =#+=, followed by a keyword, a colon,
18352 and then a word for each setting.  Org accepts multiple settings on
18353 the same line.  Org also accepts multiple lines for a keyword.  This
18354 manual describes these settings throughout.  A summary follows here.
18356 #+cindex: refresh set-up
18357 {{{kbd(C-c C-c)}}} activates any changes to the in-buffer settings.
18358 Closing and reopening the Org file in Emacs also activates the
18359 changes.
18361 #+attr_texinfo: :sep ,
18362 - =#+ARCHIVE: %s_done= ::
18364      #+cindex: ARCHIVE, keyword
18365      #+vindex: org-archive-location
18366      Sets the archive location of the agenda file.  The corresponding
18367      variable is ~org-archive-location~.
18369 - =#+CATEGORY= ::
18371      #+cindex: CATEGORY, keyword
18372      Sets the category of the agenda file, which applies to the entire
18373      document.
18375 - =#+COLUMNS: %25ITEM ...= ::
18377      #+cindex: COLUMNS, property
18378      Set the default format for columns view.  This format applies
18379      when columns view is invoked in locations where no =COLUMNS=
18380      property applies.
18382 - =#+CONSTANTS: name1=value1 ...= ::
18384      #+cindex: CONSTANTS, keyword
18385      #+vindex: org-table-formula-constants
18386      #+vindex: org-table-formula
18387      Set file-local values for constants that table formulas can use.
18388      This line sets the local variable
18389      ~org-table-formula-constants-local~.  The global version of this
18390      variable is ~org-table-formula-constants~.
18392 - =#+FILETAGS: :tag1:tag2:tag3:= ::
18394      #+cindex: FILETAGS, keyword
18395      Set tags that all entries in the file inherit from, including the
18396      top-level entries.
18398 - =#+LINK: linkword replace= ::
18400      #+cindex: LINK, keyword
18401      #+vindex: org-link-abbrev-alist
18402      Each line specifies one abbreviation for one link.  Use multiple
18403      =LINK= keywords for more, see [[*Link Abbreviations]].  The
18404      corresponding variable is ~org-link-abbrev-alist~.
18406 - =#+PRIORITIES: highest lowest default= ::
18408      #+cindex: PRIORITIES, keyword
18409      #+vindex: org-highest-priority
18410      #+vindex: org-lowest-priority
18411      #+vindex: org-default-priority
18412      This line sets the limits and the default for the priorities.
18413      All three must be either letters A--Z or numbers 0--9.  The
18414      highest priority must have a lower ASCII number than the lowest
18415      priority.
18417 - =#+PROPERTY: Property_Name Value= ::
18419      #+cindex: PROPERTY, keyword
18420      This line sets a default inheritance value for entries in the
18421      current buffer, most useful for specifying the allowed values of
18422      a property.
18424 - =#+SETUPFILE: file= ::
18426      #+cindex: SETUPFILE, keyword
18427      The setup file or a URL pointing to such file is for additional
18428      in-buffer settings.  Org loads this file and parses it for any
18429      settings in it only when Org opens the main file.  If URL is
18430      specified, the contents are downloaded and stored in a temporary
18431      file cache.  {{{kbd(C-c C-c)}}} on the settings line parses and
18432      loads the file, and also resets the temporary file cache.  Org
18433      also parses and loads the document during normal exporting
18434      process.  Org parses the contents of this document as if it was
18435      included in the buffer.  It can be another Org file.  To visit
18436      the file---not a URL---use {{{kbd(C-c ')}}} while the cursor is
18437      on the line with the file name.
18439 - =#+STARTUP:= ::
18441      #+cindex: STARTUP, keyword
18442      Startup options Org uses when first visiting a file.
18444      #+vindex: org-startup-folded
18445      The first set of options deals with the initial visibility of the
18446      outline tree.  The corresponding variable for global default
18447      settings is ~org-startup-folded~ with a default value of ~t~,
18448      which is the same as ~overview~.
18450      - =overview= ::
18452           Top-level headlines only.
18454      - =content= ::
18456           All headlines.
18458      - =showall= ::
18460           No folding on any entry.
18462      - =showeverything= ::
18464           Show even drawer contents.
18466      #+vindex: org-startup-indented
18467      Dynamic virtual indentation is controlled by the variable
18468      ~org-startup-indented~.[fn:135]
18470      - =indent= ::
18472           Start with ~org-indent-mode~ turned on.
18474      - =noindent= ::
18476           Start with ~org-indent-mode~ turned off.
18478      #+vindex: org-startup-align-all-tables
18479      Aligns tables consistently upon visiting a file.  The corresponding
18480      variable is ~org-startup-align-all-tables~ with ~nil~ as default
18481      value.
18483      - =align= ::
18485           Align all tables.
18487      - =noalign= ::
18489           Do not align tables on startup.
18491      #+vindex: org-startup-shrink-all-tables
18492      Shrink table columns with a width cookie.  The corresponding
18493      variable is ~org-startup-shrink-all-tables~ with ~nil~ as default
18494      value.
18496      #+vindex: org-startup-with-inline-images
18497      When visiting a file, inline images can be automatically displayed.
18498      The corresponding variable is ~org-startup-with-inline-images~,
18499      with a default value ~nil~ to avoid delays when visiting a file.
18501      - =inlineimages= ::
18503           Show inline images.
18505      - =noinlineimages= ::
18507           Do not show inline images on startup.
18509      #+vindex: org-log-done
18510      #+vindex: org-log-note-clock-out
18511      #+vindex: org-log-repeat
18512      Logging the closing and reopening of TODO items and clock
18513      intervals can be configured using these options (see variables
18514      ~org-log-done~, ~org-log-note-clock-out~, and ~org-log-repeat~).
18516      - =logdone= ::
18518           Record a timestamp when an item is marked DONE.
18520      - =lognotedone= ::
18522           Record timestamp and a note when DONE.
18524      - =nologdone= ::
18526           Do not record when items are marked DONE.
18528      - =logrepeat= ::
18530           Record a time when reinstating a repeating item.
18532      - =lognoterepeat= ::
18534           Record a note when reinstating a repeating item.
18536      - =nologrepeat= ::
18538           Do not record when reinstating repeating item.
18540      - =lognoteclock-out= ::
18542           Record a note when clocking out.
18544      - =nolognoteclock-out= ::
18546           Do not record a note when clocking out.
18548      - =logreschedule= ::
18550           Record a timestamp when scheduling time changes.
18552      - =lognotereschedule= ::
18554           Record a note when scheduling time changes.
18556      - =nologreschedule= ::
18558           Do not record when a scheduling date changes.
18560      - =logredeadline= ::
18562           Record a timestamp when deadline changes.
18564      - =lognoteredeadline= ::
18566           Record a note when deadline changes.
18568      - =nologredeadline= ::
18570           Do not record when a deadline date changes.
18572      - =logrefile= ::
18574           Record a timestamp when refiling.
18576      - =lognoterefile= ::
18578           Record a note when refiling.
18580      - =nologrefile= ::
18582           Do not record when refiling.
18584      #+vindex: org-hide-leading-stars
18585      #+vindex: org-odd-levels-only
18586      Here are the options for hiding leading stars in outline headings,
18587      and for indenting outlines.  The corresponding variables are
18588      ~org-hide-leading-stars~ and ~org-odd-levels-only~, both with
18589      a default setting ~nil~ (meaning =showstars= and =oddeven=).
18591      - =hidestars= ::
18593           Make all but one of the stars starting a headline invisible.
18595      - =showstars= ::
18597           Show all stars starting a headline.
18599      - =indent= ::
18601           Virtual indentation according to outline level.
18603      - =noindent= ::
18605           No virtual indentation according to outline level.
18607      - =odd= ::
18609           Allow only odd outline levels (1, 3, ...).
18611      - =oddeven= ::
18613           Allow all outline levels.
18615      #+vindex: org-put-time-stamp-overlays
18616      #+vindex: org-time-stamp-overlay-formats
18617      To turn on custom format overlays over timestamps (variables
18618      ~org-put-time-stamp-overlays~ and ~org-time-stamp-overlay-formats~),
18619      use:
18621      - =customtime= ::
18623           Overlay custom time format.
18625      #+vindex: constants-unit-system
18626      The following options influence the table spreadsheet (variable
18627      ~constants-unit-system~).
18629      - =constcgs= ::
18631           =constants.el= should use the c-g-s unit system.
18633      - =constSI= ::
18635           =constants.el= should use the SI unit system.
18637      #+vindex: org-footnote-define-inline
18638      #+vindex: org-footnote-auto-label
18639      #+vindex: org-footnote-auto-adjust
18640      To influence footnote settings, use the following keywords.  The
18641      corresponding variables are ~org-footnote-define-inline~,
18642      ~org-footnote-auto-label~, and ~org-footnote-auto-adjust~.
18644      - =fninline= ::
18646           Define footnotes inline.
18648      - =fnnoinline= ::
18650           Define footnotes in separate section.
18652      - =fnlocal= ::
18654           Define footnotes near first reference, but not inline.
18656      - =fnprompt= ::
18658           Prompt for footnote labels.
18660      - =fnauto= ::
18662           Create =[fn:1]=-like labels automatically (default).
18664      - =fnconfirm= ::
18666           Offer automatic label for editing or confirmation.
18668      - =fnadjust= ::
18670           Automatically renumber and sort footnotes.
18672      - =nofnadjust= ::
18674           Do not renumber and sort automatically.
18676      #+cindex: org-hide-block-startup
18677      To hide blocks on startup, use these keywords.  The corresponding
18678      variable is ~org-hide-block-startup~.
18680      - =hideblocks= ::
18682           Hide all begin/end blocks on startup.
18684      - =nohideblocks= ::
18686           Do not hide blocks on startup.
18688      #+cindex: org-pretty-entities
18689      The display of entities as UTF-8 characters is governed by the
18690      variable ~org-pretty-entities~ and the keywords
18692      - =entitiespretty= ::
18694           Show entities as UTF-8 characters where possible.
18696      - =entitiesplain= ::
18698           Leave entities plain.
18700 - =#+TAGS: TAG1(c1) TAG2(c2)= ::
18702      #+cindex: TAGS, keyword
18703      #+vindex: org-tag-alist
18704      These lines (several such lines are allowed) specify the valid
18705      tags in this file, and (potentially) the corresponding /fast tag
18706      selection/ keys.  The corresponding variable is ~org-tag-alist~.
18708 - =#+TODO:=, =#+SEQ_TODO:=, =#+TYP_TODO:= ::
18710      #+cindex: SEQ_TODO, keyword
18711      #+cindex: TODO, keyword
18712      #+cindex: TYP_TODO, keyword
18713      #+vindex: org-todo-keywords
18714      These lines set the TODO keywords and their interpretation in the
18715      current file.  The corresponding variable is ~org-todo-keywords~.
18717 ** The Very Busy {{{kbd(C-c C-c)}}} Key
18718 :PROPERTIES:
18719 :DESCRIPTION: When in doubt, press @kbd{C-c C-c}.
18720 :END:
18721 #+kindex: C-c C-c
18722 #+cindex: C-c C-c, overview
18724 The {{{kbd(C-c C-c)}}} key in Org serves many purposes depending on
18725 the context.  It is probably the most over-worked, multi-purpose key
18726 combination in Org.  Its uses are well documented throughout this
18727 manual, but here is a consolidated list for easy reference.
18729 - If any highlights shown in the buffer from the creation of a sparse
18730   tree, or from clock display, remove such highlights.
18732 - If the cursor is in one of the special =KEYWORD= lines, scan the
18733   buffer for these lines and update the information.  Also reset the
18734   Org file cache used to temporary store the contents of URLs used as
18735   values for keywords like =SETUPFILE=.
18737 - If the cursor is inside a table, realign the table.  The table
18738   realigns even if automatic table editor is turned off.
18740 - If the cursor is on a =TBLFM= keyword, re-apply the formulas to the
18741   entire table.
18743 - If the current buffer is a capture buffer, close the note and file
18744   it.  With a prefix argument, also jump to the target location after
18745   saving the note.
18747 - If the cursor is on a =<<<target>>>=, update radio targets and
18748   corresponding links in this buffer.
18750 - If the cursor is on a property line or at the start or end of
18751   a property drawer, offer property commands.
18753 - If the cursor is at a footnote reference, go to the corresponding
18754   definition, and /vice versa/.
18756 - If the cursor is on a statistics cookie, update it.
18758 - If the cursor is in a plain list item with a checkbox, toggle the
18759   status of the checkbox.
18761 - If the cursor is on a numbered item in a plain list, renumber the
18762   ordered list.
18764 - If the cursor is on the =#+BEGIN= line of a dynamic block, the block
18765   is updated.
18767 - If the cursor is at a timestamp, fix the day name in the timestamp.
18769 ** A Cleaner Outline View
18770 :PROPERTIES:
18771 :DESCRIPTION: Getting rid of leading stars in the outline.
18772 :ALT_TITLE: Clean View
18773 :END:
18774 #+cindex: hiding leading stars
18775 #+cindex: dynamic indentation
18776 #+cindex: odd-levels-only outlines
18777 #+cindex: clean outline view
18779 Org's default outline with stars and no indents can become too
18780 cluttered for short documents.  For /book-like/ long documents, the
18781 effect is not as noticeable.  Org provides an alternate stars and
18782 indentation scheme, as shown on the right in the following table.  It
18783 uses only one star and indents text to line with the heading:
18785 #+begin_example
18786   ,* Top level headline             |    * Top level headline
18787   ,** Second level                  |      * Second level
18788   ,*** Third level                  |        * Third level
18789       some text                    |          some text
18790   ,*** Third level                  |        * Third level
18791       more text                    |          more text
18792   ,* Another top level headline     |    * Another top level headline
18793 #+end_example
18795 #+texinfo: @noindent
18796 #+cindex: Indent mode
18797 #+findex: org-indent-mode
18798 To turn this mode on, use the minor mode, ~org-indent-mode~.  Text
18799 lines that are not headlines are prefixed with spaces to vertically
18800 align with the headline text[fn:136].
18802 #+vindex: org-indent-indentation-per-level
18803 To make more horizontal space, the headlines are shifted by two stars.
18804 This can be configured by the ~org-indent-indentation-per-level~
18805 variable.  Only one star on each headline is visible, the rest are
18806 masked with the same font color as the background.
18808 Note that turning on ~org-indent-mode~ sets ~org-hide-leading-stars~
18809 to ~t~ and ~org-adapt-indentation~ to ~nil~.
18811 #+vindex: org-startup-indented
18812 To globally turn on ~org-indent-mode~ for all files, customize the
18813 variable ~org-startup-indented~.
18815 To turn on indenting for individual files, use =STARTUP= keyword as
18816 follows:
18818 : #+STARTUP: indent
18820 Indent on startup makes Org use hard spaces to align text with
18821 headings as shown in examples below.
18823 - /Indentation of text below headlines/ ::
18825      Indent text to align with the headline.
18827      #+begin_example
18828        ,*** Third level
18829            more text, now indented
18830      #+end_example
18832      #+vindex: org-adapt-indentation
18833      Org supports this with paragraph filling, line wrapping, and
18834      structure editing, preserving or adapting the indentation as
18835      appropriate[fn:137].
18837 - /Hiding leading stars/ ::
18839      #+vindex: org-hide-leading-stars
18840      Org can make leading stars invisible.  For global preference,
18841      configure the variable ~org-hide-leading-stars~.  For per-file
18842      preference, use these file =STARTUP= options:
18844      #+begin_example
18845        ,#+STARTUP: hidestars
18846        ,#+STARTUP: showstars
18847      #+end_example
18849      With stars hidden, the tree is shown as:
18851      #+begin_example
18852        ,* Top level headline
18853         ,* Second level
18854          ,* Third level
18855          ...
18856      #+end_example
18858      #+texinfo: @noindent
18859      #+vindex: org-hide, face
18860      Because Org makes the font color the same as the background color
18861      to hide to stars, sometimes ~org-hide~ face may need tweaking to
18862      get the effect right.  For some black and white combinations,
18863      ~grey90~ on a white background might mask the stars better.
18865 - /Odd levels/ ::
18867      #+vindex: org-odd-levels-only
18868      Using stars for only odd levels, 1, 3, 5, ..., can also clean up
18869      the clutter.  This removes two stars from each level[fn:138].
18870      For Org to properly handle this cleaner structure during edits
18871      and exports, configure the variable ~org-odd-levels-only~.  To
18872      set this per-file, use either one of the following lines:
18874      #+begin_example
18875        ,#+STARTUP: odd
18876        ,#+STARTUP: oddeven
18877      #+end_example
18879      To switch between single and double stars layouts, use {{{kbd(M-x
18880      org-convert-to-odd-levels)}}} and {{{kbd(M-x
18881      org-convert-to-oddeven-levels)}}}.
18883 ** Using Org on a TTY
18884 :PROPERTIES:
18885 :DESCRIPTION: Using Org on a tty.
18886 :ALT_TITLE: TTY Keys
18887 :END:
18888 #+cindex: tty key bindings
18890 Org provides alternative key bindings for TTY and modern mobile
18891 devices that cannot handle cursor keys and complex modifier key
18892 chords.  Some of these workarounds may be more cumbersome than
18893 necessary.  Users should look into customizing these further based on
18894 their usage needs.  For example, the normal {{{kbd(S-cursor)}}} for
18895 editing timestamp might be better with {{{kbd(C-c .)}}} chord.
18897 #+attr_texinfo: :columns 0.2 0.25 0.1 0.25
18898 | Default              | Alternative 1            | Speed key    | Alternative 2        |
18899 |----------------------+--------------------------+--------------+----------------------|
18900 | {{{kbd(S-TAB)}}}     | {{{kbd(C-u TAB)}}}       | {{{kbd(C)}}} |                      |
18901 | {{{kbd(M-left)}}}    | {{{kbd(C-c C-x l)}}}     | {{{kbd(l)}}} | {{{kbd(Esc left)}}}  |
18902 | {{{kbd(M-S-left)}}}  | {{{kbd(C-c C-x L)}}}     | {{{kbd(L)}}} |                      |
18903 | {{{kbd(M-right)}}}   | {{{kbd(C-c C-x r)}}}     | {{{kbd(r)}}} | {{{kbd(Esc right)}}} |
18904 | {{{kbd(M-S-right)}}} | {{{kbd(C-c C-x R)}}}     | {{{kbd(R)}}} |                      |
18905 | {{{kbd(M-up)}}}      | {{{kbd(C-c C-x u)}}}     |              | {{{kbd(Esc up)}}}    |
18906 | {{{kbd(M-S-up)}}}    | {{{kbd(C-c C-x U)}}}     | {{{kbd(U)}}} |                      |
18907 | {{{kbd(M-down)}}}    | {{{kbd(C-c C-x d)}}}     |              | {{{kbd(Esc down)}}}  |
18908 | {{{kbd(M-S-down)}}}  | {{{kbd(C-c C-x D)}}}     | {{{kbd(D)}}} |                      |
18909 | {{{kbd(S-RET)}}}     | {{{kbd(C-c C-x c)}}}     |              |                      |
18910 | {{{kbd(M-RET)}}}     | {{{kbd(C-c C-x m)}}}     |              | {{{kbd(Esc RET)}}}   |
18911 | {{{kbd(M-S-RET)}}}   | {{{kbd(C-c C-x M)}}}     |              |                      |
18912 | {{{kbd(S-left)}}}    | {{{kbd(C-c left)}}}      |              |                      |
18913 | {{{kbd(S-right)}}}   | {{{kbd(C-c right)}}}     |              |                      |
18914 | {{{kbd(S-up)}}}      | {{{kbd(C-c up)}}}        |              |                      |
18915 | {{{kbd(S-down)}}}    | {{{kbd(C-c down)}}}      |              |                      |
18916 | {{{kbd(C-S-left)}}}  | {{{kbd(C-c C-x left)}}}  |              |                      |
18917 | {{{kbd(C-S-right)}}} | {{{kbd(C-c C-x right)}}} |              |                      |
18919 ** Interaction with Other Packages
18920 :PROPERTIES:
18921 :DESCRIPTION: With other Emacs packages.
18922 :ALT_TITLE: Interaction
18923 :END:
18924 #+cindex: packages, interaction with other
18926 Org's compatibility and the level of interaction with other Emacs
18927 packages are documented here.
18929 *** Packages that Org cooperates with
18930 :PROPERTIES:
18931 :DESCRIPTION: Packages Org cooperates with.
18932 :ALT_TITLE: Cooperation
18933 :END:
18935 - =calc.el= by Dave Gillespie ::
18936      #+cindex: @file{calc.el}
18938      Org uses the Calc package for implementing spreadsheet
18939      functionality in its tables (see [[*The spreadsheet]]).  Org also
18940      uses Calc for embedded calculations.  See [[info:calc:Embedded%20Mode][GNU Emacs Calc Manual]].
18942 - =constants.el= by Carsten Dominik ::
18943      #+cindex: @file{constants.el}
18944      #+vindex: org-table-formula-constants
18946      Org can use names for constants in formulas in tables.  Org can
18947      also use calculation suffixes for units, such as =M= for =Mega=.
18948      For a standard collection of such constants, install the
18949      =constants= package.  Install version 2.0 of this package,
18950      available at [[http://www.astro.uva.nl/~dominik/Tools]].  Org checks
18951      if the function ~constants-get~ has been autoloaded.
18952      Installation instructions are in the file =constants.el=.
18954 - =cdlatex.el= by Carsten Dominik ::
18955      #+cindex: @file{cdlatex.el}
18957      Org mode can make use of the CDLaTeX package to efficiently enter
18958      LaTeX fragments into Org files.  See [[*Using CDLaTeX to enter
18959      math]].
18961 - =imenu.el= by Ake Stenhoff and Lars Lindberg ::
18962      #+cindex: @file{imenu.el}
18964      Imenu creates dynamic menus based on an index of items in a file.
18965      Org mode supports Imenu menus.  Enable it with a mode hook as
18966      follows:
18968      #+begin_src emacs-lisp
18969        (add-hook 'org-mode-hook
18970                  (lambda () (imenu-add-to-menubar "Imenu")))
18971      #+end_src
18973      #+vindex: org-imenu-depth
18974      By default the index is two levels deep---you can modify the
18975      depth using the option ~org-imenu-depth~.
18977 - =speedbar.el= by Eric M. Ludlam ::
18978      #+cindex: @file{speedbar.el}
18980      Speedbar package creates a special Emacs frame for displaying
18981      files and index items in files.  Org mode supports Speedbar;
18982      users can drill into Org files directly from the Speedbar.  The
18983      {{{kbd(<)}}} in the Speedbar frame tweaks the agenda commands to
18984      that file or to a subtree.
18986 - =table.el= by Takaaki Ota ::
18987      #+cindex: table editor, @file{table.el}
18988      #+cindex: @file{table.el}
18990      Complex ASCII tables with automatic line wrapping, column- and
18991      row-spanning, and alignment can be created using the Emacs table
18992      package by Takaaki Ota.  Org mode recognizes such tables and
18993      exports them properly.  {{{kbd(C-c ')}}} to edit these tables in
18994      a special buffer, much like Org's code blocks.  Because of
18995      interference with other Org mode functionality, Takaaki Ota
18996      tables cannot be edited directly in the Org buffer.
18998      - {{{kbd(C-c ')}}} (~org-edit-special~) ::
19000           #+kindex: C-c '
19001           #+findex: org-edit-special
19002           Edit a =table.el= table.  Works when the cursor is in
19003           a =table.el= table.
19005      - {{{kbd(C-c ~ )}}} (~org-table-create-with-table.el~) ::
19007           #+kindex: C-c ~
19008           #+findex: org-table-create-with-table.el
19009           Insert a =table.el= table.  If there is already a table at
19010           point, this command converts it between the =table.el=
19011           format and the Org mode format.  See the documentation
19012           string of the command ~org-convert-table~ for the
19013           restrictions under which this is possible.
19015 *** Packages that conflict with Org mode
19016 :PROPERTIES:
19017 :DESCRIPTION: Packages that lead to conflicts.
19018 :ALT_TITLE: Conflicts
19019 :END:
19021 #+cindex: shift-selection-mode
19022 #+vindex: org-support-shift-select
19023 In Emacs, ~shift-selection-mode~ combines cursor motions with shift
19024 key to enlarge regions.  Emacs sets this mode by default.  This
19025 conflicts with Org's use of {{{kbd(S-<cursor>)}}} commands to change
19026 timestamps, TODO keywords, priorities, and item bullet types, etc.
19027 Since {{{kbd(S-<cursor>)}}} commands outside of specific contexts do
19028 not do anything, Org offers the variable ~org-support-shift-select~
19029 for customization.  Org mode accommodates shift selection by (i)
19030 making it available outside of the special contexts where special
19031 commands apply, and (ii) extending an existing active region even if
19032 the cursor moves across a special context.
19034 - =cua.el= by Kim. F. Storm ::
19036      #+cindex: @file{cua.el}
19037      #+vindex: org-replace-disputed-keys
19038      Org key bindings conflict with {{{kbd(S-cursor)}}} keys used by
19039      CUA mode.  For Org to relinquish these bindings to CUA mode,
19040      configure the variable ~org-replace-disputed-keys~.  When set,
19041      Org moves the following key bindings in Org files, and in the
19042      agenda buffer---but not during date selection.
19044      | S-UP      \rArr{}  M-p   | S-DOWN     \rArr{}  M-n   |
19045      | S-LEFT    \rArr{}  M--   | S-RIGHT    \rArr{}  M-+   |
19046      | C-S-LEFT  \rArr{}  M-S-- | C-S-RIGHT  \rArr{}  M-S-+ |
19048      #+vindex: org-disputed-keys
19049      Yes, these are unfortunately more difficult to remember.  If you
19050      want to have other replacement keys, look at the variable
19051      ~org-disputed-keys~.
19053 - =ecomplete.el= by Lars Magne Ingebrigtsen ::
19055      #+cindex: @file{ecomplete.el}
19056      Ecomplete provides "electric" address completion in address
19057      header lines in message buffers.  Sadly Orgtbl mode cuts
19058      Ecomplete's power supply: no completion happens when Orgtbl mode
19059      is enabled in message buffers while entering text in address
19060      header lines.  If one wants to use ecomplete one should /not/
19061      follow the advice to automagically turn on Orgtbl mode in message
19062      buffers (see [[*The Orgtbl Minor Mode]]), but instead---after
19063      filling in the message headers---turn on Orgtbl mode manually
19064      when needed in the messages body.
19066 - =filladapt.el= by Kyle Jones ::
19068      #+cindex: @file{filladapt.el}
19069      Org mode tries to do the right thing when filling paragraphs,
19070      list items and other elements.  Many users reported problems
19071      using both =filladapt.el= and Org mode, so a safe thing to do is
19072      to disable filladapt like this:
19074      #+begin_src emacs-lisp
19075        (add-hook 'org-mode-hook 'turn-off-filladapt-mode)
19076      #+end_src
19078 - =viper.el= by Michael Kifer ::
19079      #+cindex: @file{viper.el}
19080      #+kindex: C-c /
19082      Viper uses {{{kbd(C-c /)}}} and therefore makes this key not
19083      access the corresponding Org mode command ~org-sparse-tree~.  You
19084      need to find another key for this command, or override the key in
19085      ~viper-vi-global-user-map~ with
19087      #+begin_src emacs-lisp
19088        (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
19089      #+end_src
19091 - =windmove.el= by Hovav Shacham ::
19092      #+cindex: @file{windmove.el}
19094      This package also uses the {{{kbd(S-<cursor>)}}} keys, so
19095      everything written in the paragraph above about CUA mode also
19096      applies here.  If you want to make the windmove function active
19097      in locations where Org mode does not have special functionality
19098      on {{{kbd(S-<cursor>)}}}, add this to your configuration:
19100      #+begin_src emacs-lisp
19101        ;; Make windmove work in Org mode:
19102        (add-hook 'org-shiftup-final-hook 'windmove-up)
19103        (add-hook 'org-shiftleft-final-hook 'windmove-left)
19104        (add-hook 'org-shiftdown-final-hook 'windmove-down)
19105        (add-hook 'org-shiftright-final-hook 'windmove-right)
19106      #+end_src
19108 - =yasnippet.el= ::
19110      #+cindex: @file{yasnippet.el}
19111      The way Org mode binds the {{{kbd(TAB)}}} key (binding to ~[tab]~
19112      instead of ~"\t"~) overrules YASnippet's access to this key.  The
19113      following code fixed this problem:
19115      #+begin_src emacs-lisp
19116        (add-hook 'org-mode-hook
19117                  (lambda ()
19118                    (setq-local yas/trigger-key [tab])
19119                    (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
19120      #+end_src
19122      The latest version of YASnippet does not play well with Org mode.
19123      If the above code does not fix the conflict, start by defining
19124      the following function:
19126      #+begin_src emacs-lisp
19127        (defun yas/org-very-safe-expand ()
19128          (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
19129      #+end_src
19131      Then, tell Org mode to use that function:
19133      #+begin_src emacs-lisp
19134        (add-hook 'org-mode-hook
19135                  (lambda ()
19136                    (make-variable-buffer-local 'yas/trigger-key)
19137                    (setq yas/trigger-key [tab])
19138                    (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
19139                    (define-key yas/keymap [tab] 'yas/next-field)))
19140      #+end_src
19142 ** Org Crypt
19143 :PROPERTIES:
19144 :DESCRIPTION: Encrypting Org files.
19145 :END:
19147 Org Crypt encrypts the text of an entry, but not the headline, or
19148 properties.  Behind the scene, it uses the Emacs EasyPG library to
19149 encrypt and decrypt files.
19151 #+vindex: org-crypt-tag-matcher
19152 Any text below a headline that has a =crypt= tag is automatically
19153 encrypted when the file is saved.  To use a different tag, customize
19154 the ~org-crypt-tag-matcher~ setting.
19156 Here is a suggestion for Org Crypt settings in Emacs init file:
19158 #+begin_src emacs-lisp
19159   (require 'org-crypt)
19160   (org-crypt-use-before-save-magic)
19161   (setq org-tags-exclude-from-inheritance '("crypt"))
19163   (setq org-crypt-key nil)
19164   ;; GPG key to use for encryption
19165   ;; Either the Key ID or set to nil to use symmetric encryption.
19167   (setq auto-save-default nil)
19168   ;; Auto-saving does not cooperate with org-crypt.el: so you need to
19169   ;; turn it off if you plan to use org-crypt.el quite often.  Otherwise,
19170   ;; you'll get an (annoying) message each time you start Org.
19172   ;; To turn it off only locally, you can insert this:
19173   ;;
19174   ;; # -*- buffer-auto-save-file-name: nil; -*-
19175 #+end_src
19177 Excluding the =crypt= tag from inheritance prevents already encrypted
19178 text from being encrypted again.
19180 * Hacking
19181 :PROPERTIES:
19182 :DESCRIPTION: How to hack your way around.
19183 :APPENDIX: Appendix
19184 :END:
19185 #+cindex: hacking
19187 This appendix describes some ways a user can extend the functionality
19188 of Org.
19190 ** Hooks
19191 :PROPERTIES:
19192 :DESCRIPTION: How to reach into Org's internals.
19193 :END:
19194 #+cindex: hooks
19196 Org has a large number of hook variables for adding functionality.
19197 This appendix illustrates using a few.  A complete list of hooks with
19198 documentation is maintained by the Worg project at
19199 https://orgmode.org/worg/doc.html#hooks.
19201 ** Add-on Packages
19202 :PROPERTIES:
19203 :DESCRIPTION: Available extensions.
19204 :END:
19205 #+cindex: add-on packages
19207 Various authors wrote a large number of add-on packages for Org.
19209 These packages are not part of Emacs, but they are distributed as
19210 contributed packages with the separate release available at
19211 https://orgmode.org.  See the =contrib/README= file in the source code
19212 directory for a list of contributed files.  Worg page with more
19213 information is at: https://orgmode.org/worg/org-contrib/.
19215 ** Adding Hyperlink Types
19216 :PROPERTIES:
19217 :DESCRIPTION: New custom link types.
19218 :END:
19219 #+cindex: hyperlinks, adding new types
19221 Org has many built-in hyperlink types (see [[*Hyperlinks]]), and an
19222 interface for adding new link types.  The example file, =org-man.el=,
19223 shows the process of adding Org links to Unix man pages, which look
19224 like this
19226 : [[man:printf][The printf manual]]
19228 #+begin_src emacs-lisp
19229   ;;; org-man.el - Support for links to manpages in Org
19231   (require 'org)
19233   (org-add-link-type "man" 'org-man-open)
19234   (add-hook 'org-store-link-functions 'org-man-store-link)
19236   (defcustom org-man-command 'man
19237     "The Emacs command to be used to display a man page."
19238     :group 'org-link
19239     :type '(choice (const man) (const woman)))
19241   (defun org-man-open (path)
19242     "Visit the manpage on PATH.
19243   PATH should be a topic that can be thrown at the man command."
19244     (funcall org-man-command path))
19246   (defun org-man-store-link ()
19247     "Store a link to a manpage."
19248     (when (memq major-mode '(Man-mode woman-mode))
19249       ;; This is a man page, we do make this link
19250       (let* ((page (org-man-get-page-name))
19251              (link (concat "man:" page))
19252              (description (format "Manpage for %s" page)))
19253         (org-store-link-props
19254          :type "man"
19255          :link link
19256          :description description))))
19258   (defun org-man-get-page-name ()
19259     "Extract the page name from the buffer name."
19260     ;; This works for both `Man-mode' and `woman-mode'.
19261     (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
19262         (match-string 1 (buffer-name))
19263       (error "Cannot create link to this man page")))
19265   (provide 'org-man)
19267   ;;; org-man.el ends here
19268 #+end_src
19270 #+texinfo: @noindent
19271 To activate links to man pages in Org, enter this in the init file:
19273 #+begin_src emacs-lisp
19274   (require 'org-man)
19275 #+end_src
19277 #+texinfo: @noindent
19278 A review of =org-man.el=:
19280 1. First, ~(require 'org)~ ensures =org.el= is loaded.
19282 2. Then ~org-add-link-type~ defines a new link type with =man= prefix.
19283    The call contains the function to call that follows the link type.
19286    #+vindex: org-store-link-functions
19287    The next line adds a function to ~org-store-link-functions~ that
19288    records a useful link with the command {{{kbd(C-c l)}}} in a buffer
19289    displaying a man page.
19291 The rest of the file defines necessary variables and functions.  First
19292 is the customization variable ~org-man-command~.  It has two options,
19293 ~man~ and ~woman~.  Next is a function whose argument is the link
19294 path, which for man pages is the topic of the man command.  To follow
19295 the link, the function calls the ~org-man-command~ to display the man
19296 page.
19298 {{{kbd(C-c l)}}} constructs and stores the link.
19300 {{{kbd(C-c l)}}} calls the function ~org-man-store-link~, which first
19301 checks if the ~major-mode~ is appropriate.  If check fails, the
19302 function returns ~nil~.  Otherwise the function makes a link string by
19303 combining the =man:= prefix with the man topic.  The function then
19304 calls ~org-store-link-props~ with ~:type~ and ~:link~ properties.
19305 A ~:description~ property is an optional string that is displayed when
19306 the function inserts the link in the Org buffer.
19308 {{{kbd(C-c C-l)}}} inserts the stored link.
19310 To define new link types, define a function that implements completion
19311 support with {{{kbd(C-c C-l)}}}.  This function should not accept any
19312 arguments but return the appropriate prefix and complete link string.
19314 ** Adding Export Back-ends
19315 :PROPERTIES:
19316 :DESCRIPTION: How to write new export back-ends.
19317 :END:
19318 #+cindex: Export, writing back-ends
19320 Org's export engine makes it easy for writing new back-ends.  The
19321 framework on which the engine was built makes it easy to derive new
19322 back-ends from existing ones.
19324 #+findex: org-export-define-backend
19325 #+findex: org-export-define-derived-backend
19326 The two main entry points to the export engine are:
19327 ~org-export-define-backend~ and ~org-export-define-derived-backend~.
19328 To grok these functions, see =ox-latex.el= for an example of defining
19329 a new back-end from scratch, and =ox-beamer.el= for an example of
19330 deriving from an existing engine.
19332 For creating a new back-end from scratch, first set its name as
19333 a symbol in an alist consisting of elements and export functions.  To
19334 make the back-end visible to the export dispatcher, set ~:menu-entry~
19335 keyword.  For export options specific to this back-end, set the
19336 ~:options-alist~.
19338 For creating a new back-end from an existing one, set
19339 ~:translate-alist~ to an alist of export functions.  This alist
19340 replaces the parent back-end functions.
19342 For complete documentation, see [[https://orgmode.org/worg/dev/org-export-reference.html][the Org Export Reference on Worg]].
19344 ** Tables in Arbitrary Syntax
19345 :PROPERTIES:
19346 :DESCRIPTION: Orgtbl for LaTeX and other programs.
19347 :END:
19348 #+cindex: tables, in other modes
19349 #+cindex: lists, in other modes
19350 #+cindex: Orgtbl mode
19352 Due to Org's success in handling tables with Orgtbl, a frequently
19353 requested feature is the use of Org's table functions in other modes,
19354 e.g., LaTeX.  This would be hard to do in a general way without
19355 complicated customization nightmares.  Moreover, that would take Org
19356 away from its simplicity roots that Orgtbl has proven.  There is,
19357 however, an alternate approach to accomplishing the same.
19359 This approach involves implementing a custom /translate/ function that
19360 operates on a native Org /source table/ to produce a table in another
19361 format.  This strategy would keep the excellently working Orgtbl
19362 simple and isolate complications, if any, confined to the translate
19363 function.  To add more alien table formats, we just add more translate
19364 functions.  Also the burden of developing custom translate functions
19365 for new table formats is in the hands of those who know those formats
19366 best.
19368 *** Radio tables
19369 :PROPERTIES:
19370 :DESCRIPTION: Sending and receiving radio tables.
19371 :END:
19372 #+cindex: radio tables
19374 Radio tables are target locations for translated tables that are not near
19375 their source.  Org finds the target location and inserts the translated
19376 table.
19378 The key to finding the target location is the magic words =BEGIN/END
19379 RECEIVE ORGTBL=.  They have to appear as comments in the current mode.
19380 If the mode is C, then:
19382 #+begin_example
19383    /* BEGIN RECEIVE ORGTBL table_name */
19384    /* END RECEIVE ORGTBL table_name */
19385 #+end_example
19387 #+texinfo: @noindent
19388 At the location of source, Org needs a special line to direct Orgtbl
19389 to translate and to find the target for inserting the translated
19390 table.  For example:
19392 #+cindex: ORGTBL, keyword
19393 : #+ORGTBL: SEND table_name translation_function arguments ...
19395 #+texinfo: @noindent
19396 =table_name= is the table's reference name, which is also used in the
19397 receiver lines, and the =translation_function= is the Lisp function
19398 that translates.  This line, in addition, may also contain alternating
19399 key and value arguments at the end.  The translation function gets
19400 these values as a property list.  A few standard parameters are
19401 already recognized and acted upon before the translation function is
19402 called:
19404 - =:skip N= ::
19406      Skip the first N lines of the table.  Hlines do count; include
19407      them if they are to be skipped.
19409 - =:skipcols (n1 n2 ...)= ::
19411      List of columns to be skipped.  First Org automatically discards
19412      columns with calculation marks and then sends the table to the
19413      translator function, which then skips columns as specified in
19414      =skipcols=.
19416 #+texinfo: @noindent
19417 To keep the source table intact in the buffer without being disturbed
19418 when the source file is compiled or otherwise being worked on, use one
19419 of these strategies:
19421 - Place the table in a block comment.  For example, in C mode you
19422   could wrap the table between =/*= and =*/= lines.
19424 - Put the table after an "end" statement.  For example ~\bye~ in TeX
19425   and ~\end{document}~ in LaTeX.
19427 - Comment and un-comment each line of the table during edits.  The
19428   {{{kbd(M-x orgtbl-toggle-comment)}}} command makes toggling easy.
19430 *** A LaTeX example of radio tables
19431 :PROPERTIES:
19432 :DESCRIPTION: Step by step, almost a tutorial.
19433 :ALT_TITLE: A LaTeX example
19434 :END:
19435 #+cindex: @LaTeX{}, and Orgtbl mode
19437 To wrap a source table in LaTeX, use the =comment= environment
19438 provided by =comment.sty=[fn:139].  To activate it, put
19439 ~\usepackage{comment}~ in the document header.  Orgtbl mode inserts
19440 a radio table skeleton[fn:138] with the command {{{kbd(M-x
19441 orgtbl-insert-radio-table)}}}, which prompts for a table name.  For
19442 example, if =salesfigures= is the name, the template inserts:
19444 #+begin_example
19445   % BEGIN RECEIVE ORGTBL salesfigures
19446   % END RECEIVE ORGTBL salesfigures
19447   \begin{comment}
19448   ,#+ORGTBL: SEND salesfigures orgtbl-to-latex
19449   | | |
19450   \end{comment}
19451 #+end_example
19453 #+vindex: @LaTeX{}-verbatim-environments
19454 #+texinfo: @noindent
19455 The line =#+ORGTBL: SEND= tells Orgtbl mode to use the function
19456 ~orgtbl-to-latex~ to convert the table to LaTeX format, then insert
19457 the table at the target (receive) location named =salesfigures=.  Now
19458 the table is ready for data entry.  It can even use spreadsheet
19459 features[fn:140]:
19461 #+begin_example
19462   % BEGIN RECEIVE ORGTBL salesfigures
19463   % END RECEIVE ORGTBL salesfigures
19464   \begin{comment}
19465   ,#+ORGTBL: SEND salesfigures orgtbl-to-latex
19466   | Month | Days | Nr sold | per day |
19467   |-------+------+---------+---------|
19468   | Jan   |   23 |      55 |     2.4 |
19469   | Feb   |   21 |      16 |     0.8 |
19470   | March |   22 |     278 |    12.6 |
19471   ,#+TBLFM: $4=$3/$2;%.1f
19472   % $ (optional extra dollar to keep Font Lock happy, see footnote)
19473   \end{comment}
19474 #+end_example
19476 #+texinfo: @noindent
19477 After editing, {{{kbd(C-c C-c)}}} inserts the translated table at the
19478 target location, between the two marker lines.
19480 For hand-made custom tables, note that the translator needs to skip
19481 the first two lines of the source table.  Also the command has to
19482 /splice/ out the target table without the header and footer.
19484 #+begin_example
19485   \begin{tabular}{lrrr}
19486   Month & \multicolumn{1}{c}{Days} & Nr.\ sold & per day\\
19487   % BEGIN RECEIVE ORGTBL salesfigures
19488   % END RECEIVE ORGTBL salesfigures
19489   \end{tabular}
19490   %
19491   \begin{comment}
19492   ,#+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
19493   | Month | Days | Nr sold | per day |
19494   |-------+------+---------+---------|
19495   | Jan   |   23 |      55 |     2.4 |
19496   | Feb   |   21 |      16 |     0.8 |
19497   | March |   22 |     278 |    12.6 |
19498   ,#+TBLFM: $4=$3/$2;%.1f
19499   \end{comment}
19500 #+end_example
19502 The LaTeX translator function ~orgtbl-to-latex~ is already part of
19503 Orgtbl mode and uses a =tabular= environment to typeset the table and
19504 marks horizontal lines with ~\hline~.  For additional parameters to
19505 control output, see [[*Translator functions]]:
19507 - ~:splice nil/t~ ::
19509      When non-~nil~, return only table body lines; not wrapped in
19510      tabular environment.  Default is ~nil~.
19512 - ~:fmt FMT~ ::
19514      Format to warp each field.  It should contain =%s= for the
19515      original field value.  For example, to wrap each field value in
19516      dollar symbol, you could use =:fmt "$%s$"=.  Format can also wrap
19517      a property list with column numbers and formats, for example
19518      =:fmt (2 "$%s$" 4 "%s\\%%")=.  In place of a string, a function
19519      of one argument can be used; the function must return a formatted
19520      string.
19522 - ~:efmt EFMT~ ::
19524      Format numbers as exponentials.  The spec should have =%s= twice
19525      for inserting mantissa and exponent, for example
19526      ="%s\\times10^{%s}"=.  This may also be a property list with
19527      column numbers and formats, for example =:efmt (2
19528      "$%s\\times10^{%s}$" 4 "$%s\\cdot10^{%s}$")=.  After
19529      {{{var(EFMT)}}} has been applied to a value, {{{var(FMT)}}}---see
19530      above---is also be applied.  Functions with two arguments can be
19531      supplied instead of strings.  By default, no special formatting
19532      is applied.
19534 *** Translator functions
19535 :PROPERTIES:
19536 :DESCRIPTION: Copy and modify.
19537 :END:
19538 #+cindex: HTML, and Orgtbl mode
19539 #+cindex: translator function
19541 #+findex: orgtbl-to-csv
19542 #+findex: orgtbl-to-tsv
19543 #+findex: orgtbl-to-latex
19544 #+findex: orgtbl-to-html
19545 #+findex: orgtbl-to-texinfo
19546 #+findex: orgtbl-to-unicode
19547 #+findex: orgtbl-to-orgtbl
19548 #+findex: orgtbl-to-generic
19549 Orgtbl mode has built-in translator functions: ~orgtbl-to-csv~
19550 (comma-separated values), ~orgtbl-to-tsv~ (TAB-separated values),
19551 ~orgtbl-to-latex~, ~orgtbl-to-html~, ~orgtbl-to-texinfo~,
19552 ~orgtbl-to-unicode~ and ~orgtbl-to-orgtbl~.  They use the generic
19553 translator, ~orgtbl-to-generic~, which delegates translations to
19554 various export back-ends.
19556 Properties passed to the function through the =ORGTBL SEND= line take
19557 precedence over properties defined inside the function.  For example,
19558 this overrides the default LaTeX line endings, ~\\~, with ~\\[2mm]~:
19560 : #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
19562 For a new language translator, define a converter function.  It can be
19563 a generic function, such as shown in this example.  It marks
19564 a beginning and ending of a table with =!BTBL!= and =!ETBL!=;
19565 a beginning and ending of lines with =!BL!= and =!EL!=; and uses a TAB
19566 for a field separator:
19568 #+begin_src emacs-lisp
19569   (defun orgtbl-to-language (table params)
19570     "Convert the orgtbl-mode TABLE to language."
19571     (orgtbl-to-generic
19572      table
19573      (org-combine-plists
19574       '(:tstart "!BTBL!" :tend "!ETBL!" :lstart "!BL!" :lend "!EL!" :sep "\t")
19575       params)))
19576 #+end_src
19578 #+texinfo: @noindent
19579 The documentation for the ~orgtbl-to-generic~ function shows
19580 a complete list of parameters, each of which can be passed through to
19581 ~orgtbl-to-latex~, ~orgtbl-to-texinfo~, and any other function using
19582 that generic function.
19584 For complicated translations the generic translator function could be
19585 replaced by a custom translator function.  Such a custom function must
19586 take two arguments and return a single string containing the formatted
19587 table.  The first argument is the table whose lines are a list of
19588 fields or the symbol ~hline~.  The second argument is the property
19589 list consisting of parameters specified in the =#+ORGTBL: SEND= line.
19590 Please share your translator functions by posting them to the Org
19591 users mailing list, at mailto:emacs-orgmode@gnu.org.
19593 ** Dynamic Blocks
19594 :PROPERTIES:
19595 :DESCRIPTION: Automatically filled blocks.
19596 :END:
19597 #+cindex: dynamic blocks
19599 Org supports /dynamic blocks/ in Org documents.  They are inserted
19600 with begin and end markers like any other code block, but the contents
19601 are updated automatically by a user function.  For example, {{{kbd(C-c
19602 C-x C-r)}}} inserts a dynamic table that updates the work time (see
19603 [[*Clocking Work Time]]).
19605 Dynamic blocks can have names and function parameters.  The syntax is
19606 similar to source code block specifications:
19608 #+begin_example
19609   ,#+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
19610     ...
19611   ,#+END:
19612 #+end_example
19614 These commands update dynamic blocks:
19616 - {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
19618      #+kindex: C-c C-x C-u
19619      #+findex: org-dblock-update
19620      Update dynamic block at point.
19622 - {{{kbd(C-u C-c C-x C-u)}}} ::
19624      #+kindex: C-u C-c C-x C-u
19625      Update all dynamic blocks in the current file.
19627 Before updating a dynamic block, Org removes content between the
19628 =BEGIN= and =END= markers.  Org then reads the parameters on the
19629 =BEGIN= line for passing to the writer function.  If the function
19630 expects to access the removed content, then Org expects an extra
19631 parameter, =:content=, on the =BEGIN= line.
19633 The syntax for naming a writer function with a dynamic block labelled
19634 =myblock= is: ~org-dblock-write:myblock~.  Parameters come from the
19635 =BEGIN= line.
19637 The following is an example of a dynamic block and a block writer function
19638 that updates the time when the function was last run:
19640 #+begin_example
19641   ,#+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
19642     ...
19643   ,#+END:
19644 #+end_example
19646 #+texinfo: @noindent
19647 The dynamic block's writer function:
19649 #+begin_src emacs-lisp
19650   (defun org-dblock-write:block-update-time (params)
19651     (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
19652       (insert "Last block update at: "
19653               (format-time-string fmt))))
19654 #+end_src
19656 To keep dynamic blocks up-to-date in an Org file, use the function,
19657 ~org-update-all-dblocks~ in hook, such as ~before-save-hook~.  The
19658 ~org-update-all-dblocks~ function does not run if the file is not in
19659 Org mode.
19661 #+findex: org-narrow-to-block
19662 Dynamic blocks, like any other block, can be narrowed with
19663 ~org-narrow-to-block~.
19665 ** Special Agenda Views
19666 :PROPERTIES:
19667 :DESCRIPTION: Customized views.
19668 :END:
19669 #+cindex: agenda views, user-defined
19671 #+vindex: org-agenda-skip-function
19672 #+vindex: org-agenda-skip-function-global
19673 Org provides a special hook to further limit items in agenda views:
19674 ~agenda~, ~agenda*~[fn:141], ~todo~, ~alltodo~, ~tags~, ~tags-todo~,
19675 ~tags-tree~.  Specify a custom function that tests inclusion of every
19676 matched item in the view.  This function can also skip as much as is
19677 needed.
19679 For a global condition applicable to agenda views, use the
19680 ~org-agenda-skip-function-global~ variable.  Org uses a global
19681 condition with ~org-agenda-skip-function~ for custom searching.
19683 This example defines a function for a custom view showing TODO items
19684 with =waiting= status.  Manually this is a multi-step search process,
19685 but with a custom view, this can be automated as follows:
19687 The custom function searches the subtree for the =waiting= tag and
19688 returns ~nil~ on match.  Otherwise it gives the location from where
19689 the search continues.
19691 #+begin_src emacs-lisp
19692   (defun my-skip-unless-waiting ()
19693     "Skip trees that are not waiting"
19694     (let ((subtree-end (save-excursion (org-end-of-subtree t))))
19695       (if (re-search-forward ":waiting:" subtree-end t)
19696           nil          ; tag found, do not skip
19697         subtree-end))) ; tag not found, continue after end of subtree
19698 #+end_src
19700 To use this custom function in a custom agenda command:
19702 #+begin_src emacs-lisp
19703   (org-add-agenda-custom-command
19704    '("b" todo "PROJECT"
19705      ((org-agenda-skip-function 'my-skip-unless-waiting)
19706       (org-agenda-overriding-header "Projects waiting for something: "))))
19707 #+end_src
19709 #+vindex: org-agenda-overriding-header
19710 Note that this also binds ~org-agenda-overriding-header~ to a more
19711 meaningful string suitable for the agenda view.
19713 #+vindex: org-odd-levels-only
19714 #+vindex: org-agenda-skip-function
19715 Search for entries with a limit set on levels for the custom search.
19716 This is a general approach to creating custom searches in Org.  To
19717 include all levels, use =LEVEL>0=[fn:142].  Then to selectively pick
19718 the matched entries, use ~org-agenda-skip-function~, which also
19719 accepts Lisp forms, such as ~org-agenda-skip-entry-if~ and
19720 ~org-agenda-skip-subtree-if~.  For example:
19722 - ~(org-agenda-skip-entry-if 'scheduled)~ ::
19724      Skip current entry if it has been scheduled.
19726 - ~(org-agenda-skip-entry-if 'notscheduled)~ ::
19728      Skip current entry if it has not been scheduled.
19730 - ~(org-agenda-skip-entry-if 'deadline)~ ::
19732      Skip current entry if it has a deadline.
19734 - ~(org-agenda-skip-entry-if 'scheduled 'deadline)~ ::
19736      Skip current entry if it has a deadline, or if it is scheduled.
19738 - ~(org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))~ ::
19740      Skip current entry if the TODO keyword is TODO or WAITING.
19742 - ~(org-agenda-skip-entry-if 'todo 'done)~ ::
19744      Skip current entry if the TODO keyword marks a DONE state.
19746 - ~(org-agenda-skip-entry-if 'timestamp)~ ::
19748      Skip current entry if it has any timestamp, may also be deadline
19749      or scheduled.
19751 - ~(org-agenda-skip-entry-if 'regexp "regular expression")~ ::
19753      Skip current entry if the regular expression matches in the
19754      entry.
19756 - ~(org-agenda-skip-entry-if 'notregexp "regular expression")~ ::
19758      Skip current entry unless the regular expression matches.
19760 - ~(org-agenda-skip-subtree-if 'regexp "regular expression")~ ::
19762      Same as above, but check and skip the entire subtree.
19764 The following is an example of a search for =waiting= without the
19765 special function:
19767 #+begin_src emacs-lisp
19768   (org-add-agenda-custom-command
19769    '("b" todo "PROJECT"
19770      ((org-agenda-skip-function '(org-agenda-skip-subtree-if
19771                                   'regexp ":waiting:"))
19772       (org-agenda-overriding-header "Projects waiting for something: "))))
19773 #+end_src
19775 ** Speeding Up Your Agendas
19776 :PROPERTIES:
19777 :DESCRIPTION: Tips on how to speed up your agendas.
19778 :END:
19779 #+cindex: agenda views, optimization
19781 Some agenda commands slow down when the Org files grow in size or
19782 number.  Here are tips to speed up:
19784 - Reduce the number of Org agenda files to avoid slowdowns due to hard drive
19785   accesses.
19787 - Reduce the number of DONE and archived headlines so agenda
19788   operations that skip over these can finish faster.
19790 - Do not dim blocked tasks:
19791   #+vindex: org-agenda-dim-blocked-tasks
19793   #+begin_src emacs-lisp
19794     (setq org-agenda-dim-blocked-tasks nil)
19795   #+end_src
19797 - Stop preparing agenda buffers on startup:
19798   #+vindex: org-startup-folded
19799   #+vindex: org-agenda-inhibit-startup
19801   #+begin_src emacs-lisp
19802     (setq org-agenda-inhibit-startup nil)
19803   #+end_src
19805 - Disable tag inheritance for agendas:
19806   #+vindex: org-agenda-show-inherited-tags
19807   #+vindex: org-agenda-use-tag-inheritance
19809   #+begin_src emacs-lisp
19810     (setq org-agenda-use-tag-inheritance nil)
19811   #+end_src
19813 These options can be applied to selected agenda views.  For more
19814 details about generation of agenda views, see the docstrings for the
19815 relevant variables, and this [[https://orgmode.org/worg/agenda-optimization.html][dedicated Worg page]] for agenda
19816 optimization.
19818 ** Extracting Agenda Information
19819 :PROPERTIES:
19820 :DESCRIPTION: Post-processing agenda information.
19821 :END:
19822 #+cindex: agenda, pipe
19823 #+cindex: scripts, for agenda processing
19825 Org provides commands to access agendas through Emacs batch mode.
19826 Through this command-line interface, agendas are automated for further
19827 processing or printing.
19829 #+vindex: org-agenda-custom-commands
19830 #+findex: org-batch-agenda
19831 ~org-batch-agenda~ creates an agenda view in ASCII and outputs to
19832 standard output.  This command takes one string parameter.  When
19833 string consists of a single character, Org uses it as a key to
19834 ~org-agenda-custom-commands~.  These are the same ones available
19835 through {{{kbd(C-c a)}}}.
19837 This example command line directly prints the TODO list to the printer:
19839 : emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
19841 When the string parameter length is two or more characters, Org
19842 matches it with tags/TODO strings.  For example, this example command
19843 line prints items tagged with =shop=, but excludes items tagged with
19844 =NewYork=:
19846 #+begin_example
19847   emacs -batch -l ~/.emacs                                      \
19848         -eval '(org-batch-agenda "+shop-NewYork")' | lpr
19849 #+end_example
19851 #+texinfo: @noindent
19852 An example showing on-the-fly parameter modifications:
19854 #+begin_example
19855   emacs -batch -l ~/.emacs                                      \
19856      -eval '(org-batch-agenda "a"                               \
19857              org-agenda-span (quote month)                      \
19858              org-agenda-include-diary nil                       \
19859              org-agenda-files (quote ("~/org/project.org")))'   \
19860      | lpr
19861 #+end_example
19863 #+texinfo: @noindent
19864 which produces an agenda for the next 30 days from just the
19865 =~/org/projects.org= file.
19867 #+findex: org-batch-agenda-csv
19868 For structured processing of agenda output, use ~org-batch-agenda-csv~
19869 with the following fields:
19871 - category :: The category of the item
19872 - head :: The headline, without TODO keyword, TAGS and PRIORITY
19873 - type :: The type of the agenda entry, can be
19875      | ~todo~              | selected in TODO match              |
19876      | ~tagsmatch~         | selected in tags match              |
19877      | ~diary~             | imported from diary                 |
19878      | ~deadline~          | a deadline                          |
19879      | ~scheduled~         | scheduled                           |
19880      | ~timestamp~         | appointment, selected by timestamp  |
19881      | ~closed~            | entry was closed on date            |
19882      | ~upcoming-deadline~ | warning about nearing deadline      |
19883      | ~past-scheduled~    | forwarded scheduled item            |
19884      | ~block~             | entry has date block including date |
19886 - todo :: The TODO keyword, if any
19887 - tags :: All tags including inherited ones, separated by colons
19888 - date :: The relevant date, like =2007-2-14=
19889 - time :: The time, like =15:00-16:50=
19890 - extra :: String with extra planning info
19891 - priority-l :: The priority letter if any was given
19892 - priority-n :: The computed numerical priority
19894 #+texinfo: @noindent
19895 If the selection of the agenda item was based on a timestamp,
19896 including those items with =DEADLINE= and =SCHEDULED= keywords, then
19897 Org includes date and time in the output.
19899 If the selection of the agenda item was based on a timestamp  (or
19900 deadline/scheduled), then Org includes date and time in the output.
19902 Here is an example of a post-processing script in Perl.  It takes the
19903 CSV output from Emacs and prints with a checkbox:
19905 #+begin_src perl
19906   #!/usr/bin/perl
19908   # define the Emacs command to run
19909   $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
19911   # run it and capture the output
19912   $agenda = qx{$cmd 2>/dev/null};
19914   # loop over all lines
19915   foreach $line (split(/\n/,$agenda)) {
19916       # get the individual values
19917       ($category,$head,$type,$todo,$tags,$date,$time,$extra,
19918        $priority_l,$priority_n) = split(/,/,$line);
19919       # process and print
19920       print "[ ] $head\n";
19921   }
19922 #+end_src
19924 ** Using the Property API
19925 :PROPERTIES:
19926 :DESCRIPTION: Writing programs that use entry properties.
19927 :END:
19928 #+cindex: API, for properties
19929 #+cindex: properties, API
19931 Here is a description of the functions that can be used to work with
19932 properties.
19934 #+attr_texinfo: :options org-entry-properties &optional pom which
19935 #+begin_defun
19936 Get all properties of the entry at point-or-marker {{{var(POM)}}}.
19937 This includes the TODO keyword, the tags, time strings for deadline,
19938 scheduled, and clocking, and any additional properties defined in the
19939 entry.  The return value is an alist.  Keys may occur multiple times
19940 if the property key was used several times.  {{{var(POM)}}} may also
19941 be ~nil~, in which case the current entry is used.  If
19942 {{{var(WHICH)}}} is ~nil~ or ~all~, get all properties.  If
19943 {{{var(WHICH)}}} is ~special~ or ~standard~, only get that subclass.
19944 #+end_defun
19946 #+vindex: org-use-property-inheritance
19947 #+findex: org-insert-property-drawer
19948 #+attr_texinfo: :options org-entry-get pom property &optional inherit
19949 #+begin_defun
19950 Get value of {{{var(PROPERTY)}}} for entry at point-or-marker
19951 {{{var(POM)}}}.  By default, this only looks at properties defined
19952 locally in the entry.  If {{{var(INHERIT)}}} is non-~nil~ and the
19953 entry does not have the property, then also check higher levels of the
19954 hierarchy.  If {{{var(INHERIT)}}} is the symbol ~selective~, use
19955 inheritance if and only if the setting of
19956 ~org-use-property-inheritance~ selects {{{var(PROPERTY)}}} for
19957 inheritance.
19958 #+end_defun
19960 #+attr_texinfo: :options org-entry-delete pom property
19961 #+begin_defun
19962 Delete the property {{{var(PROPERTY)}}} from entry at point-or-marker
19963 {{{var(POM)}}}.
19964 #+end_defun
19966 #+attr_texinfo: :options org-entry-put pom property value
19967 #+begin_defun
19968 Set {{{var(PROPERTY)}}} to {{{var(VALUES)}}} for entry at
19969 point-or-marker POM.
19970 #+end_defun
19972 #+attr_texinfo: :options org-buffer-property-keys &optional include-specials
19973 #+begin_defun
19974 Get all property keys in the current buffer.
19975 #+end_defun
19977 #+attr_texinfo: :options org-insert-property-drawer
19978 #+begin_defun
19979 Insert a property drawer for the current entry.  Also
19980 #+end_defun
19982 #+attr_texinfo: :options org-entry-put-multivalued-property pom property &rest values
19983 #+begin_defun
19984 Set {{{var(PROPERTY)}}} at point-or-marker {{{var(POM)}}} to
19985 {{{var(VALUES)}}}.  {{{var(VALUES)}}} should be a list of strings.
19986 They are concatenated, with spaces as separators.
19987 #+end_defun
19989 #+attr_texinfo: :options org-entry-get-multivalued-property pom property
19990 #+begin_defun
19991 Treat the value of the property {{{var(PROPERTY)}}} as
19992 a whitespace-separated list of values and return the values as a list
19993 of strings.
19994 #+end_defun
19996 #+attr_texinfo: :options org-entry-add-to-multivalued-property pom property value
19997 #+begin_defun
19998 Treat the value of the property {{{var(PROPERTY)}}} as
19999 a whitespace-separated list of values and make sure that
20000 {{{var(VALUE)}}} is in this list.
20001 #+end_defun
20003 #+attr_texinfo: :options org-entry-remove-from-multivalued-property pom property value
20004 #+begin_defun
20005 Treat the value of the property {{{var(PROPERTY)}}} as
20006 a whitespace-separated list of values and make sure that
20007 {{{var(VALUE)}}} is /not/ in this list.
20008 #+end_defun
20010 #+attr_texinfo: :options org-entry-member-in-multivalued-property pom property value
20011 #+begin_defun
20012 Treat the value of the property {{{var(PROPERTY)}}} as
20013 a whitespace-separated list of values and check if {{{var(VALUE)}}} is
20014 in this list.
20015 #+end_defun
20017 #+attr_texinfo: :options org-property-allowed-value-functions
20018 #+begin_defopt
20019 Hook for functions supplying allowed values for a specific property.
20020 The functions must take a single argument, the name of the property,
20021 and return a flat list of allowed values.  If =:ETC= is one of the
20022 values, use the values as completion help, but allow also other values
20023 to be entered.  The functions must return ~nil~ if they are not
20024 responsible for this property.
20025 #+end_defopt
20027 ** Using the Mapping API
20028 :PROPERTIES:
20029 :DESCRIPTION: Mapping over all or selected entries.
20030 :END:
20031 #+cindex: API, for mapping
20032 #+cindex: mapping entries, API
20034 Org has sophisticated mapping capabilities to find all entries
20035 satisfying certain criteria.  Internally, this functionality is used
20036 to produce agenda views, but there is also an API that can be used to
20037 execute arbitrary functions for each or selected entries.  The main
20038 entry point for this API is:
20040 #+attr_texinfo: :options org-map-entries func &optional match scope &rest skip
20041 #+begin_defun
20042 Call {{{(var(FUNC))}}} at each headline selected by {{{var(MATCH)}}}
20043 in {{{var(SCOPE)}}}.
20045 {{{var(FUNC)}}} is a function or a Lisp form.  With the cursor
20046 positioned at the beginning of the headline, call the function without
20047 arguments.  Org returns an alist of return values of calls to the
20048 function.
20050 To avoid preserving point, Org wraps the call to {{{var(FUNC)}}} in
20051 save-excursion form.  After evaluation, Org moves the cursor to the
20052 end of the line that was just processed.  Search continues from that
20053 point forward.  This may not always work as expected under some
20054 conditions, such as if the current sub-tree was removed by a previous
20055 archiving operation.  In such rare circumstances, Org skips the next
20056 entry entirely when it should not.  To stop Org from such skips, make
20057 {{{var(FUNC)}}} set the variable ~org-map-continue-from~ to a specific
20058 buffer position.
20060 {{{var(MATCH)}}} is a tags/property/TODO match.  Org iterates only
20061 matched headlines.  Org iterates over all headlines when
20062 {{{var(MATCH)}}} is ~nil~ or ~t~.
20064 {{{var(SCOPE)}}} determines the scope of this command.  It can be any
20067 - ~nil~ ::
20069      The current buffer, respecting the restriction, if any.
20071 - ~tree~ ::
20073      The subtree started with the entry at point.
20075 - ~region~ ::
20077      The entries within the active region, if any.
20079 - ~file~ ::
20081      The current buffer, without restriction.
20083 - ~file-with-archives~ ::
20085      The current buffer, and any archives associated with it.
20087 - ~agenda~ ::
20089      All agenda files.
20091 - ~agenda-with-archives~ ::
20093      All agenda files with any archive files associated with them.
20095 - ~(file1 file2 ...)~ ::
20097      If this is a list, all files in the list are scanned.
20099 #+texinfo: @noindent
20100 The remaining arguments are treated as settings for the scanner's
20101 skipping facilities.  Valid arguments are:
20103 - ~archive~ ::
20105      Skip trees with the archive tag.
20107 - ~comment~ ::
20109      Skip trees with the COMMENT keyword.
20111 - function or Lisp form ::
20113      #+vindex: org-agenda-skip-function
20114      Used as value for ~org-agenda-skip-function~, so whenever the
20115      function returns ~t~, {{{var(FUNC)}}} is called for that entry
20116      and search continues from the point where the function leaves it.
20117 #+end_defun
20119 The mapping routine can call any arbitrary function, even functions
20120 that change meta data or query the property API (see [[*Using the
20121 Property API]]).  Here are some handy functions:
20123 #+attr_texinfo: :options org-todo &optional arg
20124 #+begin_defun
20125 Change the TODO state of the entry.  See the docstring of the
20126 functions for the many possible values for the argument
20127 {{{var(ARG)}}}.
20128 #+end_defun
20130 #+attr_texinfo: :options org-priority &optional action
20131 #+begin_defun
20132 Change the priority of the entry.  See the docstring of this function
20133 for the possible values for {{{var(ACTION)}}}.
20134 #+end_defun
20136 #+attr_texinfo: :options org-toggle-tag tag &optional onoff
20137 #+begin_defun
20138 Toggle the tag {{{var(TAG)}}} in the current entry.  Setting
20139 {{{var(ONOFF)}}} to either ~on~ or ~off~ does not toggle tag, but
20140 ensure that it is either on or off.
20141 #+end_defun
20143 #+attr_texinfo: :options org-promote
20144 #+begin_defun
20145 Promote the current entry.
20146 #+end_defun
20148 #+attr_texinfo: :options org-demote
20149 #+begin_defun
20150 Demote the current entry.
20151 #+end_defun
20153 This example turns all entries tagged with =TOMORROW= into TODO
20154 entries with keyword =UPCOMING=.  Org ignores entries in comment trees
20155 and archive trees.
20157 #+begin_src emacs-lisp
20158   (org-map-entries '(org-todo "UPCOMING")
20159                    "+TOMORROW" 'file 'archive 'comment)
20160 #+end_src
20162 The following example counts the number of entries with TODO keyword
20163 =WAITING=, in all agenda files.
20165 #+begin_src emacs-lisp
20166   (length (org-map-entries t "/+WAITING" 'agenda))
20167 #+end_src
20169 * MobileOrg
20170 :PROPERTIES:
20171 :DESCRIPTION: Viewing and capture on a mobile device.
20172 :APPENDIX: Appendix
20173 :END:
20174 #+cindex: iPhone
20175 #+cindex: smartphone
20176 #+cindex: android
20177 #+cindex: MobileOrg
20179 MobileOrg is a companion mobile app that runs on iOS and Android
20180 devices.  MobileOrg enables offline-views and capture support for an
20181 Org mode system that is rooted on a "real" computer.  MobileOrg can
20182 record changes to existing entries.
20184 The [[https://github.com/MobileOrg/][iOS implementation]] for the /iPhone/iPod Touch/iPad/ series of
20185 devices, was started by Richard Moreland and is now in the hands of
20186 Sean Escriva.  Android users should check out [[http://wiki.github.com/matburt/mobileorg-android/][MobileOrg Android]] by
20187 Matt Jones.  Though the two implementations are not identical, they
20188 offer similar features.
20190 This appendix describes Org's support for agenda view formats
20191 compatible with MobileOrg.  It also describes synchronizing changes,
20192 such as to notes, between MobileOrg and the computer.
20194 To change tags and TODO states in MobileOrg, first customize the
20195 variables ~org-todo-keywords~ and ~org-tag-alist~.  These should cover
20196 all the important tags and TODO keywords, even if Org files use only
20197 some of them.  Though MobileOrg has in-buffer settings, it understands
20198 TODO states /sets/ (see [[*Setting up keywords for individual files]]) and
20199 /mutually exclusive/ tags (see [[*Setting Tags]]) only for those set in
20200 these variables.
20202 ** Setting Up the Staging Area
20203 :PROPERTIES:
20204 :DESCRIPTION: For the mobile device.
20205 :END:
20207 MobileOrg needs access to a file directory on a server to interact
20208 with Emacs.  With a public server, consider encrypting the files.
20209 MobileOrg version 1.5 supports encryption for the iPhone.  Org also
20210 requires =openssl= installed on the local computer.  To turn on
20211 encryption, set the same password in MobileOrg and in Emacs.  Set the
20212 password in the variable ~org-mobile-use-encryption~[fn:143].  Note
20213 that even after MobileOrg encrypts the file contents, the file name
20214 remains visible on the file systems of the local computer, the server,
20215 and the mobile device.
20217 For a server to host files, consider options like [[http://dropbox.com][Dropbox.com]]
20218 account[fn:144].  On first connection, MobileOrg creates a directory
20219 =MobileOrg= on Dropbox.  Pass its location to Emacs through an
20220 initialisation file variable as follows:
20222 #+begin_src emacs-lisp
20223   (setq org-mobile-directory "~/Dropbox/MobileOrg")
20224 #+end_src
20226 Org copies files to the above directory for MobileOrg.  Org also uses
20227 the same directory for sharing notes between Org and MobileOrg.
20229 ** Pushing to MobileOrg
20230 :PROPERTIES:
20231 :DESCRIPTION: Uploading Org files and agendas.
20232 :END:
20234 #+vindex: org-mobile-files
20235 #+vindex: org-directory
20236 Org pushes files listed in ~org-mobile-files~ to
20237 ~org-mobile-directory~.  Files include agenda files (as listed in
20238 ~org-agenda-files~).  Customize ~org-mobile-files~ to add other files.
20239 File names are staged with paths relative to ~org-directory~, so all
20240 files should be inside this directory[fn:145].
20242 Push creates a special Org file =agendas.org= with custom agenda views
20243 defined by the user[fn:146].
20245 Finally, Org writes the file =index.org=, containing links to other
20246 files.  MobileOrg reads this file first from the server to determine
20247 what other files to download for agendas.  For faster downloads,
20248 MobileOrg only reads files whose checksums[fn:147] have changed.
20250 ** Pulling from MobileOrg
20251 :PROPERTIES:
20252 :DESCRIPTION: Integrating captured and flagged items.
20253 :END:
20255 When MobileOrg synchronizes with the server, it pulls the Org files
20256 for viewing.  It then appends to the file =mobileorg.org= on the
20257 server the captured entries, pointers to flagged and changed entries.
20258 Org integrates its data in an inbox file format.
20261    #+vindex: org-mobile-inbox-for-pull
20262    Org moves all entries found in =mobileorg.org=[fn:148] and appends
20263    them to the file pointed to by the variable
20264    ~org-mobile-inbox-for-pull~.  Each captured entry and each editing
20265    event is a top-level entry in the inbox file.
20267 2. After moving the entries, Org attempts changes to MobileOrg.  Some
20268    changes are applied directly and without user interaction.
20269    Examples include changes to tags, TODO state, headline and body
20270    text.  Entries for further action are tagged as =FLAGGED=.  Org
20271    marks entries with problems with an error message in the inbox.
20272    They have to be resolved manually.
20274 3. Org generates an agenda view for flagged entries for user
20275    intervention to clean up.  For notes stored in flagged entries,
20276    MobileOrg displays them in the echo area when the cursor is on the
20277    corresponding agenda item.
20279    - {{{kbd(?)}}} ::
20280         #+kindex: ?
20282         Pressing {{{kbd(?)}}} displays the entire flagged note in
20283         another window.  Org also pushes it to the kill ring.  To
20284         store flagged note as a normal note, use {{{kbd(? z C-y C-c
20285         C-c)}}}.  Pressing{{{kbd(?)}}} twice does these things: first
20286         it removes the =FLAGGED= tag; second, it removes the flagged
20287         note from the property drawer; third, it signals that manual
20288         editing of the flagged entry is now finished.
20290 #+kindex: C-c a ?
20291 {{{kbd(C-c a ?)}}} returns to the agenda view to finish processing
20292 flagged entries.  Note that these entries may not be the most recent
20293 since MobileOrg searches files that were last pulled.  To get an
20294 updated agenda view with changes since the last pull, pull again.
20296 * History and Acknowledgments
20297 :PROPERTIES:
20298 :DESCRIPTION: How Org came into being.
20299 :APPENDIX: t
20300 :END:
20302 ** From Carsten
20303 :PROPERTIES:
20304 :UNNUMBERED: notoc
20305 :END:
20307 Org was born in 2003, out of frustration over the user interface of
20308 the Emacs Outline mode.  I was trying to organize my notes and
20309 projects, and using Emacs seemed to be the natural way to go.
20310 However, having to remember eleven different commands with two or
20311 three keys per command, only to hide and show parts of the outline
20312 tree, that seemed entirely unacceptable to me.  Also, when using
20313 outlines to take notes, I constantly wanted to restructure the tree,
20314 organizing it parallel to my thoughts and plans.  /Visibility cycling/
20315 and /structure editing/ were originally implemented in the package
20316 =outline-magic.el=, but quickly moved to the more general =org.el=.
20317 As this environment became comfortable for project planning, the next
20318 step was adding /TODO entries/, basic /timestamps/, and /table
20319 support/.  These areas highlighted the two main goals that Org still
20320 has today: to be a new, outline-based, plain text mode with innovative
20321 and intuitive editing features, and to incorporate project planning
20322 functionality directly into a notes file.
20324 Since the first release, literally thousands of emails to me or to the
20325 [[mailto:emacs-orgmode@gnu.org][mailing list]] have provided a constant stream of bug reports, feedback,
20326 new ideas, and sometimes patches and add-on code.  Many thanks to
20327 everyone who has helped to improve this package.  I am trying to keep
20328 here a list of the people who had significant influence in shaping one
20329 or more aspects of Org.  The list may not be complete, if I have
20330 forgotten someone, please accept my apologies and let me know.
20332 Before I get to this list, a few special mentions are in order:
20334 - Bastien Guerry ::
20336      Bastien has written a large number of extensions to Org (most of
20337      them integrated into the core by now), including the LaTeX
20338      exporter and the plain list parser.  His support during the early
20339      days was central to the success of this project.  Bastien also
20340      invented Worg, helped establishing the Web presence of Org, and
20341      sponsored hosting costs for the orgmode.org website.  Bastien
20342      stepped in as maintainer of Org between 2011 and 2013, at a time
20343      when I desperately needed a break.
20345 - Eric Schulte and Dan Davison ::
20347      Eric and Dan are jointly responsible for the Org-babel system,
20348      which turns Org into a multi-language environment for evaluating
20349      code and doing literate programming and reproducible research.
20350      This has become one of Org's killer features that define what Org
20351      is today.
20353 - John Wiegley ::
20355      John has contributed a number of great ideas and patches directly
20356      to Org, including the attachment system (=org-attach.el=),
20357      integration with Apple Mail (=org-mac-message.el=), hierarchical
20358      dependencies of TODO items, habit tracking (=org-habits.el=), and
20359      encryption (=org-crypt.el=).  Also, the capture system is really
20360      an extended copy of his great =remember.el=.
20362 - Sebastian Rose ::
20364      Without Sebastian, the HTML/XHTML publishing of Org would be the
20365      pitiful work of an ignorant amateur.  Sebastian has pushed this
20366      part of Org onto a much higher level.  He also wrote
20367      =org-info.js=, a Java script for displaying webpages derived from
20368      Org using an Info-like or a folding interface with single-key
20369      navigation.
20371 #+texinfo: @noindent
20372 See below for the full list of contributions! Again, please let me
20373 know what I am missing here!
20375 ** From Bastien
20376 :PROPERTIES:
20377 :UNNUMBERED: notoc
20378 :END:
20380 I (Bastien) have been maintaining Org between 2011 and 2013.  This
20381 appendix would not be complete without adding a few more
20382 acknowledgments and thanks.
20384 I am first grateful to Carsten for his trust while handing me over the
20385 maintainership of Org.  His unremitting support is what really helped
20386 me getting more confident over time, with both the community and the
20387 code.
20389 When I took over maintainership, I knew I would have to make Org more
20390 collaborative than ever, as I would have to rely on people that are
20391 more knowledgeable than I am on many parts of the code.  Here is
20392 a list of the persons I could rely on, they should really be
20393 considered co-maintainers, either of the code or the community:
20395 - Eric Schulte ::
20397      Eric is maintaining the Babel parts of Org.  His reactivity here
20398      kept me away from worrying about possible bugs here and let me
20399      focus on other parts.
20401 - Nicolas Goaziou ::
20403      Nicolas is maintaining the consistency of the deepest parts of
20404      Org.  His work on =org-element.el= and =ox.el= has been
20405      outstanding, and it opened the doors for many new ideas and
20406      features.  He rewrote many of the old exporters to use the new
20407      export engine, and helped with documenting this major change.
20408      More importantly (if that's possible), he has been more than
20409      reliable during all the work done for Org 8.0, and always very
20410      reactive on the mailing list.
20412 - Achim Gratz ::
20414      Achim rewrote the building process of Org, turning some /ad hoc/
20415      tools into a flexible and conceptually clean process.  He
20416      patiently coped with the many hiccups that such a change can
20417      create for users.
20419 - Nick Dokos ::
20421      The Org mode mailing list would not be such a nice place without
20422      Nick, who patiently helped users so many times.  It is impossible
20423      to overestimate such a great help, and the list would not be so
20424      active without him.
20426 I received support from so many users that it is clearly impossible to
20427 be fair when shortlisting a few of them, but Org's history would not
20428 be complete if the ones above were not mentioned in this manual.
20430 ** List of Contributions
20431 :PROPERTIES:
20432 :UNNUMBERED: notoc
20433 :END:
20435 - Russel Adams came up with the idea for drawers.
20437 - Thomas Baumann wrote =org-bbdb.el= and =org-mhe.el=.
20439 - Christophe Bataillon created the great unicorn logo that we use on
20440   the Org mode website.
20442 - Alex Bochannek provided a patch for rounding timestamps.
20444 - Jan Böcker wrote =org-docview.el=.
20446 - Brad Bozarth showed how to pull RSS feed data into Org files.
20448 - Tom Breton wrote =org-choose.el=.
20450 - Charles Cave's suggestion sparked the implementation of templates
20451   for Remember, which are now templates for capture.
20453 - Pavel Chalmoviansky influenced the agenda treatment of items with
20454   specified time.
20456 - Gregory Chernov patched support for Lisp forms into table
20457   calculations and improved XEmacs compatibility, in particular by
20458   porting =nouline.el= to XEmacs.
20460 - Sacha Chua suggested copying some linking code from Planner.
20462 - Baoqiu Cui contributed the DocBook exporter.
20464 - Eddward DeVilla proposed and tested checkbox statistics.  He also
20465   came up with the idea of properties, and that there should be an API
20466   for them.
20468 - Nick Dokos tracked down several nasty bugs.
20470 - Kees Dullemond used to edit projects lists directly in HTML and so
20471   inspired some of the early development, including HTML export.  He
20472   also asked for a way to narrow wide table columns.
20474 - Thomas S. Dye contributed documentation on Worg and helped
20475   integrating the Org Babel documentation into the manual.
20477 - Christian Egli converted the documentation into Texinfo format,
20478   inspired the agenda, patched CSS formatting into the HTML exporter,
20479   and wrote =org-taskjuggler.el=.
20481 - David Emery provided a patch for custom CSS support in exported HTML
20482   agendas.
20484 - Nic Ferrier contributed mailcap and XOXO support.
20486 - Miguel A.  Figueroa-Villanueva implemented hierarchical checkboxes.
20488 - John Foerch figured out how to make incremental search show context
20489   around a match in a hidden outline tree.
20491 - Raimar Finken wrote =org-git-line.el=.
20493 - Mikael Fornius works as a mailing list moderator.
20495 - Austin Frank works as a mailing list moderator.
20497 - Eric Fraga drove the development of Beamer export with ideas and
20498   testing.
20500 - Barry Gidden did proofreading the manual in preparation for the book
20501   publication through Network Theory Ltd.
20503 - Niels Giesen had the idea to automatically archive DONE trees.
20505 - Nicolas Goaziou rewrote much of the plain list code.
20507 - Kai Grossjohann pointed out key-binding conflicts with other
20508   packages.
20510 - Brian Gough of Network Theory Ltd publishes the Org mode manual as
20511   a book.
20513 - Bernt Hansen has driven much of the support for auto-repeating
20514   tasks, task state change logging, and the clocktable.  His clear
20515   explanations have been critical when we started to adopt the Git
20516   version control system.
20518 - Manuel Hermenegildo has contributed various ideas, small fixes and
20519   patches.
20521 - Phil Jackson wrote =org-irc.el=.
20523 - Scott Jaderholm proposed footnotes, control over whitespace between
20524   folded entries, and column view for properties.
20526 - Matt Jones wrote MobileOrg Android.
20528 - Tokuya Kameshima wrote =org-wl.el= and =org-mew.el=.
20530 - Shidai Liu ("Leo") asked for embedded LaTeX and tested it.  He also
20531   provided frequent feedback and some patches.
20533 - Matt Lundin has proposed last-row references for table formulas and
20534   named invisible anchors.  He has also worked a lot on the FAQ.
20536 - David Maus wrote =org-atom.el=, maintains the issues file for Org,
20537   and is a prolific contributor on the mailing list with competent
20538   replies, small fixes and patches.
20540 - Jason F. McBrayer suggested agenda export to CSV format.
20542 - Max Mikhanosha came up with the idea of refiling.
20544 - Dmitri Minaev sent a patch to set priority limits on a per-file
20545   basis.
20547 - Stefan Monnier provided a patch to keep the Emacs Lisp compiler
20548   happy.
20550 - Richard Moreland wrote MobileOrg for the iPhone.
20552 - Rick Moynihan proposed allowing multiple TODO sequences in a file
20553   and being able to quickly restrict the agenda to a subtree.
20555 - Todd Neal provided patches for links to Info files and Elisp forms.
20557 - Greg Newman refreshed the unicorn logo into its current form.
20559 - Tim O'Callaghan suggested in-file links, search options for general
20560   file links, and tags.
20562 - Osamu Okano wrote =orgcard2ref.pl=, a Perl program to create a text
20563   version of the reference card.
20565 - Takeshi Okano translated the manual and David O'Toole's tutorial
20566   into Japanese.
20568 - Oliver Oppitz suggested multi-state TODO items.
20570 - Scott Otterson sparked the introduction of descriptive text for
20571   links, among other things.
20573 - Pete Phillips helped during the development of the TAGS feature,
20574   and provided frequent feedback.
20576 - Martin Pohlack provided the code snippet to bundle character
20577   insertion into bundles of 20 for undo.
20579 - T.V. Raman reported bugs and suggested improvements.
20581 - Matthias Rempe (Oelde) provided ideas, Windows support, and quality
20582   control.
20584 - Paul Rivier provided the basic implementation of named footnotes.
20585   He also acted as mailing list moderator for some time.
20587 - Kevin Rogers contributed code to access VM files on remote hosts.
20589 - Frank Ruell solved the mystery of the =keymapp nil= bug, a conflict
20590   with =allout.el=.
20592 - Jason Riedy generalized the send-receive mechanism for Orgtbl
20593   tables with extensive patches.
20595 - Philip Rooke created the Org reference card, provided lots of
20596   feedback, developed and applied standards to the Org documentation.
20598 - Christian Schlauer proposed angular brackets around links, among
20599   other things.
20601 - Paul Sexton wrote =org-ctags.el=.
20603 - Tom Shannon's =organizer-mode.el= inspired linking to VM/BBDB/Gnus.
20605 - Ilya Shlyakhter proposed the Archive Sibling, line numbering in
20606   literal examples, and remote highlighting for referenced code lines.
20608 - Stathis Sideris wrote the =ditaa.jar= ASCII to PNG converter that is
20609   now packaged into Org's =contrib/= directory.
20611 - Daniel Sinder came up with the idea of internal archiving by locking
20612   subtrees.
20614 - Dale Smith proposed link abbreviations.
20616 - James TD Smith has contributed a large number of patches for
20617   useful tweaks and features.
20619 - Adam Spiers asked for global linking commands, inspired the link
20620   extension system, added support for Mairix, and proposed the mapping
20621   API.
20623 - Ulf Stegemann created the table to translate special symbols to
20624   HTML, LaTeX, UTF-8, Latin-1 and ASCII.
20626 - Andy Stewart contributed code to =org-w3m.el=, to copy
20627   HTML content with links transformation to Org syntax.
20629 - David O'Toole wrote =org-publish.el= and drafted the
20630   manual chapter about publishing.
20632 - Jambunathan K. contributed the ODT exporter.
20634 - Sebastien Vauban reported many issues with LaTeX and Beamer export
20635   and enabled source code highlighting in Gnus.
20637 - Stefan Vollmar organized a video-recorded talk at the
20638   Max-Planck-Institute for Neurology.  He also inspired the creation
20639   of a concept index for HTML export.
20641 - Jürgen Vollmer contributed code generating the table of contents in
20642   HTML output.
20644 - Samuel Wales has provided important feedback and bug reports.
20646 - Chris Wallace provided a patch implementing the =QUOTE= block.
20648 - David Wainberg suggested archiving, and improvements to the
20649   linking system.
20651 - Carsten Wimmer suggested some changes and helped fix a bug in
20652   linking to Gnus.
20654 - Roland Winkler requested additional key bindings to make Org work on
20655   a TTY.
20657 - Piotr Zielinski wrote =org-mouse.el=, proposed agenda
20658   blocks and contributed various ideas and code snippets.
20660 * GNU Free Documentation License
20661 :PROPERTIES:
20662 :APPENDIX: t
20663 :DESCRIPTION: The license for this documentation.
20664 :END:
20666 #+TEXINFO: @include ../doc/doclicense.texi
20668 * Main Index
20669 :PROPERTIES:
20670 :INDEX:    cp
20671 :DESCRIPTION: An index of Org's concepts and features.
20672 :END:
20674 * Key Index
20675 :PROPERTIES:
20676 :DESCRIPTION: Key bindings and where they are described.
20677 :INDEX:    ky
20678 :END:
20680 * Command and Function Index
20681 :PROPERTIES:
20682 :DESCRIPTION: Command names and some internal functions.
20683 :INDEX:    fn
20684 :END:
20686 * Variable Index
20687 :PROPERTIES:
20688 :DESCRIPTION: Variables mentioned in the manual.
20689 :INDEX:    vr
20690 :END:
20692 This is not a complete index of variables and faces, only the ones
20693 that are mentioned in the manual.  For a more complete list, use
20694 {{{kbd(M-x org-customize)}}} and then click yourself through the tree.
20696 * Copying
20697 :PROPERTIES:
20698 :copying:  t
20699 :END:
20701 This manual is for Org version {{{version}}}.
20703 Copyright \copy 2004--2018  Free Software Foundation, Inc.
20705 #+begin_quote
20706 Permission is granted to copy, distribute and/or modify this document
20707 under the terms of the GNU Free Documentation License, Version 1.3 or
20708 any later version published by the Free Software Foundation; with no
20709 Invariant Sections, with the Front-Cover texts being "A GNU Manual",
20710 and with the Back-Cover Texts as in (a) below.  A copy of the license
20711 is included in the section entitled "GNU Free Documentation License".
20713 (a) The FSF's Back-Cover Text is: "You have the freedom to copy and
20714 modify this GNU manual."
20715 #+end_quote
20717 * Export Setup                                                          :noexport:
20719 #+subtitle:  Release {{{version}}}
20720 #+author:    by Carsten Dominik
20721 #+subauthor: with contributions by Bastien Guerry, Nicolas Goaziou, Eric Schulte, Jambunathan K, Dan Davison, Thomas Dye, David O'Toole, and Philip Rooke.
20722 #+date:      {{{modification-time}}}
20723 #+email:     tsd@tsdye.com
20724 #+language:  en
20726 # XXX: We cannot use TODO keyword as a node starts with "TODO".
20727 #+todo: REVIEW FIXME | DONE
20728 #+property: header-args :eval no
20729 #+startup: overview nologdone
20731 #+export_file_name: org.texi
20733 #+texinfo_dir_category: Emacs editing modes
20734 #+texinfo_dir_title: Org Mode: (org)
20735 #+texinfo_dir_desc: Outline-based notes management and organizer
20737 # Use proper quote and backtick for code sections in PDF output
20738 # Cf. Texinfo manual 14.2
20739 #+texinfo_header: @set txicodequoteundirected
20740 #+texinfo_header: @set txicodequotebacktick
20742 # Contact Info
20743 #+texinfo_header: @set MAINTAINERSITE @uref{https://orgmode.org,maintainers webpage}
20744 #+texinfo_header: @set MAINTAINER Carsten Dominik
20745 #+texinfo_header: @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
20746 #+texinfo_header: @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
20748 #+options: H:4 num:t toc:t author:t \n:nil ::t |:t ^:nil -:t f:t *:t <:t e:t ':t
20749 #+options: d:nil todo:nil pri:nil tags:not-in-toc stat:nil broken-links:mark
20750 #+select_tags: export
20751 #+exclude_tags: noexport
20753 #+macro: cite @@texinfo:@cite{@@$1@@texinfo:}@@
20754 #+macro: var @@texinfo:@var{@@$1@@texinfo:}@@
20756 # The "version" macro returns major.minor version number.  This is
20757 # sufficient since bugfix releases are not expected to add features
20758 # and therefore imply manual modifications.
20759 #+macro: version (eval (mapconcat #'identity (cl-subseq (split-string (org-version) "\\.") 0 -1) "."))
20761 # The "kbd" macro turns KBD into @kbd{KBD}.  Additionnally, it
20762 # encloses case-sensitive special keys (SPC, RET...) within @key{...}.
20763 #+macro: kbd (eval (let ((case-fold-search nil) (regexp (regexp-opt '("SPC" "RET" "LFD" "TAB" "BS" "ESC" "DELETE" "SHIFT" "CTRL" "META" "up" "left" "right" "down") 'words))) (format "@@texinfo:@kbd{@@%s@@texinfo:}@@" (replace-regexp-in-string regexp "@@texinfo:@key{@@\\&@@texinfo:}@@" $1 t))))
20765 * Footnotes
20767 [fn:1] If you do not use Font Lock globally turn it on in Org buffer
20768 with ~(add-hook 'org-mode-hook 'turn-on-font-lock)~.
20770 [fn:2] Please consider subscribing to the mailing list in order to
20771 minimize the work the mailing list moderators have to do.
20773 [fn:3] See the variables ~org-special-ctrl-a/e~, ~org-special-ctrl-k~,
20774 and ~org-ctrl-k-protect-subtree~ to configure special behavior of
20775 {{{kbd(C-a)}}}, {{{kbd(C-e)}}}, and {{{kbd(C-k)}}} in headlines.  Note
20776 also that clocking only works with headings indented less than 30
20777 stars.
20779 [fn:4] See, however, the option ~org-cycle-emulate-tab~.
20781 [fn:5] The indirect buffer contains the entire buffer, but is narrowed
20782 to the current tree.  Editing the indirect buffer also changes the
20783 original buffer, but without affecting visibility in that buffer.  For
20784 more information about indirect buffers, see [[info:emacs:Indirect%20Buffers][GNU Emacs Manual]].
20786 [fn:6] When ~org-agenda-inhibit-startup~ is non-~nil~, Org does not
20787 honor the default visibility state when first opening a file for the
20788 agenda (see [[*Speeding Up Your Agendas]]).
20790 [fn:7] See also the variable ~org-show-context-detail~ to decide how
20791 much context is shown around each match.
20793 [fn:8] This depends on the option ~org-remove-highlights-with-change~.
20795 [fn:9] When using =*= as a bullet, lines must be indented so that they
20796 are not interpreted as headlines.  Also, when you are hiding leading
20797 stars to get a clean outline view, plain list items starting with
20798 a star may be hard to distinguish from true headlines.  In short: even
20799 though =*= is supported, it may be better to not use it for plain list
20800 items.
20802 [fn:10] You can filter out any of them by configuring
20803 ~org-plain-list-ordered-item-terminator~.
20805 [fn:11] You can also get =a.=, =A.=, =a)= and =A)= by configuring
20806 ~org-list-allow-alphabetical~.  To minimize confusion with normal
20807 text, those are limited to one character only.  Beyond that limit,
20808 bullets automatically become numbers.
20810 [fn:12] If there's a checkbox in the item, the cookie must be put
20811 /before/ the checkbox.  If you have activated alphabetical lists, you
20812 can also use counters like =[@b]=.
20814 [fn:13] If you do not want the item to be split, customize the
20815 variable ~org-M-RET-may-split-line~.
20817 [fn:14] If you want to cycle around items that way, you may customize
20818 ~org-list-use-circular-motion~.
20820 [fn:15] See ~org-list-use-circular-motion~ for a cyclic behavior.
20822 [fn:16] Many desktops intercept {{{kbd(M-TAB)}}} to switch windows.
20823 Use {{{kbd(C-M-i)}}} or {{{kbd(ESC TAB)}}} instead.
20825 [fn:17] The corresponding in-buffer setting is: =#+STARTUP: fninline=
20826 or =#+STARTUP: nofninline=.
20828 [fn:18] The corresponding in-buffer options are =#+STARTUP: fnadjust=
20829 and =#+STARTUP: nofnadjust=.
20831 [fn:19] To insert a vertical bar into a table field, use =\vert= or,
20832 inside a word =abc\vert{}def=.
20834 [fn:20] Org understands references typed by the user as =B4=, but it
20835 does not use this syntax when offering a formula for editing.  You can
20836 customize this behavior using the variable
20837 ~org-table-use-standard-references~.
20839 [fn:21] The computation time scales as O(N^2) because table
20840 {{{var(FOO)}}} is parsed for each field to be copied.
20842 [fn:22] The file =constants.el= can supply the values of constants in
20843 two different unit systems, =SI= and =cgs=.  Which one is used depends
20844 on the value of the variable ~constants-unit-system~.  You can use the
20845 =STARTUP= options =constSI= and =constcgs= to set this value for the
20846 current buffer.
20848 [fn:23] The printf reformatting is limited in precision because the
20849 value passed to it is converted into an "integer" or "double".  The
20850 "integer" is limited in size by truncating the signed value to 32
20851 bits.  The "double" is limited in precision to 64 bits overall which
20852 leaves approximately 16 significant decimal digits.
20854 [fn:24] Such names must start with an alphabetic character and use
20855 only alphanumeric/underscore characters.
20857 [fn:25] To insert a link targeting a headline, in-buffer completion
20858 can be used.  Just type a star followed by a few optional letters into
20859 the buffer and press {{{kbd(M-TAB)}}}.  All headlines in the current
20860 buffer are offered as completions.
20862 [fn:26] When targeting a =NAME= keyword, =CAPTION= keyword is
20863 mandatory in order to get proper numbering (see [[*Images and Tables]]).
20865 [fn:27] The actual behavior of the search depends on the value of the
20866 variable ~org-link-search-must-match-exact-headline~.  If its value is
20867 ~nil~, then a fuzzy text search is done.  If it is ~t~, then only the
20868 exact headline is matched, ignoring spaces and statistic cookies.  If
20869 the value is ~query-to-create~, then an exact headline is searched; if
20870 it is not found, then the user is queried to create it.
20872 [fn:28] If the headline contains a timestamp, it is removed from the
20873 link, which results in a wrong link---you should avoid putting
20874 a timestamp in the headline.
20876 [fn:29] The Org Id library must first be loaded, either through
20877 ~org-customize~, by enabling ~id~ in ~org-modules~, or by adding
20878 ~(require 'org-id)~ in your Emacs init file.
20880 [fn:30] Note that you do not have to use this command to insert
20881 a link.  Links in Org are plain text, and you can type or paste them
20882 straight into the buffer.  By using this command, the links are
20883 automatically enclosed in double brackets, and you will be asked for
20884 the optional descriptive text.
20886 [fn:31] After insertion of a stored link, the link will be removed
20887 from the list of stored links.  To keep it in the list later use, use
20888 a triple {{{kbd(C-u)}}} prefix argument to {{{kbd(C-c C-l)}}}, or
20889 configure the option ~org-keep-stored-link-after-insertion~.
20891 [fn:32] This works if a function has been defined in the ~:complete~
20892 property of a link in ~org-link-parameters~.
20894 [fn:33] See the variable ~org-display-internal-link-with-indirect-buffer~.
20896 [fn:34] The variable ~org-startup-with-inline-images~ can be set
20897 within a buffer with the =STARTUP= options =inlineimages= and
20898 =noinlineimages=.
20900 [fn:35] For backward compatibility, line numbers can also follow a
20901 single colon.
20903 [fn:36] Of course, you can make a document that contains only long
20904 lists of TODO items, but this is not required.
20906 [fn:37] Changing the variable ~org-todo-keywords~ only becomes
20907 effective after restarting Org mode in a buffer.
20909 [fn:38] This is also true for the {{{kbd(t)}}} command in the timeline
20910 and agenda buffers.
20912 [fn:39] All characters are allowed except =@=, =^= and =!=, which have
20913 a special meaning here.
20915 [fn:40] Check also the variable ~org-fast-tag-selection-include-todo~,
20916 it allows you to change the TODO state through the tags interface
20917 ([[*Setting Tags]]), in case you like to mingle the two concepts.  Note
20918 that this means you need to come up with unique keys across both sets
20919 of keywords.
20921 [fn:41] Org mode parses these lines only when Org mode is activated
20922 after visiting a file.  {{{kbd(C-c C-c)}}} with the cursor in a line
20923 starting with =#+= is simply restarting Org mode for the current
20924 buffer.
20926 [fn:42] The corresponding in-buffer setting is: =#+STARTUP: logdone=.
20928 [fn:43] The corresponding in-buffer setting is: =#+STARTUP:
20929 lognotedone=.
20931 [fn:44] See the variable ~org-log-states-order-reversed~.
20933 [fn:45] Note that the =LOGBOOK= drawer is unfolded when pressing
20934 {{{kbd(SPC)}}} in the agenda to show an entry---use {{{kbd(C-u
20935 SPC)}}} to keep it folded here.
20937 [fn:46] It is possible that Org mode records two timestamps when you
20938 are using both ~org-log-done~ and state change logging.  However, it
20939 never prompts for two notes: if you have configured both, the state
20940 change recording note takes precedence and cancel the closing note.
20942 [fn:47] See also the option ~org-priority-start-cycle-with-default~.
20944 [fn:48] To keep subtasks out of the global TODO list, see the
20945 ~org-agenda-todo-list-sublevels~.
20947 [fn:49] With the exception of description lists.  But you can allow it
20948 by modifying ~org-list-automatic-rules~ accordingly.
20950 [fn:50] Set the variable ~org-hierarchical-checkbox-statistics~ if you
20951 want such cookies to count all checkboxes below the cookie, not just
20952 those belonging to direct children.
20954 [fn:51] {{{kbd(C-u C-c C-c)}}} on the /first/ item of a list with no
20955 checkbox adds checkboxes to the rest of the list.
20957 [fn:52] As with all these in-buffer settings, pressing {{{kbd(C-c
20958 C-c)}}} activates any changes in the line.
20960 [fn:53] This is only true if the search does not involve more complex
20961 tests including properties (see [[*Property Searches]]).
20963 [fn:54] Keys are automatically assigned to tags that have no
20964 configured keys.
20966 [fn:55] If more than one summary type applies to the same property,
20967 the parent values are computed according to the first of them.
20969 [fn:56] An age is defined as a duration, using effort modifiers
20970 defined in ~org-effort-durations~, e.g., =3d 1h=.  If any value in the
20971 column is as such, the summary is also an effort duration.
20973 [fn:57] Please note that the =COLUMNS= definition must be on a single
20974 line; it is wrapped here only because of formatting constraints.
20976 [fn:58] Contributed packages are not part of Emacs, but are
20977 distributed with the main distribution of Org---visit
20978 [[https://orgmode.org]].
20980 [fn:59] The Org date format is inspired by the standard ISO 8601
20981 date/time format.  To use an alternative format, see [[*Custom time
20982 format]].  The day name is optional when you type the date yourself.
20983 However, any date inserted or modified by Org adds that day name, for
20984 reading convenience.
20986 [fn:60] When working with the standard diary sexp functions, you need
20987 to be very careful with the order of the arguments.  That order
20988 depends evilly on the variable ~calendar-date-style~.  For example, to
20989 specify a date December 12, 2005, the call might look like
20990 =(diary-date 12 1 2005)= or =(diary-date 1 12 2005)= or =(diary-date
20991 2005 12 1)=, depending on the settings.  This has been the source of
20992 much confusion.  Org mode users can resort to special versions of
20993 these functions like ~org-date~ or ~org-anniversary~.  These work just
20994 like the corresponding ~diary-~ functions, but with stable ISO order
20995 of arguments (year, month, day) wherever applicable, independent of
20996 the value of ~calendar-date-style~.
20998 [fn:61] See the variable ~org-read-date-prefer-future~.  You may set
20999 that variable to the symbol ~time~ to even make a time before now
21000 shift the date to tomorrow.
21002 [fn:62] If you do not need/want the calendar, configure the variable
21003 ~org-popup-calendar-for-date-prompt~.
21005 [fn:63] If you find this distracting, turn off the display with
21006 ~org-read-date-display-live~.
21008 [fn:64] It will still be listed on that date after it has been marked
21009 DONE.  If you do not like this, set the variable
21010 ~org-agenda-skip-scheduled-if-done~.
21012 [fn:65] The =SCHEDULED= and =DEADLINE= dates are inserted on the line
21013 right below the headline.  Do not put any text between this line and
21014 the headline.
21016 [fn:66] Note the corresponding =STARTUP= options =logredeadline=,
21017 =lognoteredeadline=, and =nologredeadline=.
21019 [fn:67] Note the corresponding =STARTUP= options =logreschedule=,
21020 =lognotereschedule=, and =nologreschedule=.
21022 [fn:68] In fact, the target state is taken from, in this sequence, the
21023 =REPEAT_TO_STATE= property, the variable ~org-todo-repeat-to-state~ if
21024 it is a string, the previous TODO state if ~org-todo-repeat-to-state~
21025 is ~t~, or the first state of the TODO state sequence.
21027 [fn:69] You can change this using the option ~org-log-repeat~, or the
21028 =STARTUP= options =logrepeat=, =lognoterepeat=, and =nologrepeat=.
21029 With =lognoterepeat=, you will also be prompted for a note.
21031 [fn:70] Clocking only works if all headings are indented with less
21032 than 30 stars.  This is a hard-coded limitation of ~lmax~ in
21033 ~org-clock-sum~.
21035 [fn:71] To resume the clock under the assumption that you have worked
21036 on this task while outside Emacs, use ~(setq org-clock-persist t)~.
21038 [fn:72] To add an effort estimate "on the fly", hook a function doing
21039 this to ~org-clock-in-prepare-hook~.
21041 [fn:73] The last reset of the task is recorded by the =LAST_REPEAT=
21042 property.
21044 [fn:74] See also the variable ~org-clock-modeline-total~.
21046 [fn:75] The corresponding in-buffer setting is: =#+STARTUP:
21047 lognoteclock-out=.
21049 [fn:76] Language terms can be set through the variable
21050 ~org-clock-clocktable-language-setup~.
21052 [fn:77] Note that all parameters must be specified in a single
21053 line---the line is broken here only to fit it into the manual.
21055 [fn:78] On computers using Mac OS X, idleness is based on actual user
21056 idleness, not just Emacs' idle time.  For X11, you can install
21057 a utility program =x11idle.c=, available in the =contrib/scripts/=
21058 directory of the Org Git distribution, or install the xprintidle
21059 package and set it to the variable ~org-clock-x11idle-program-name~ if
21060 you are running Debian, to get the same general treatment of idleness.
21061 On other systems, idle time refers to Emacs idle time only.
21063 [fn:79] Please note the pitfalls of summing hierarchical data in
21064 a flat list ([[*Using Column View in the Agenda]]).
21066 [fn:80] Please select your own key, {{{kbd(C-c c)}}} is only
21067 a suggestion.
21069 [fn:81] Org used to offer four different targets for date/week tree
21070 capture.  Now, Org automatically translates these to use
21071 ~file+olp+datetree~, applying the ~:time-prompt~ and ~:tree-type~
21072 properties.  Please rewrite your date/week-tree targets using
21073 ~file+olp+datetree~ since the older targets are now deprecated.
21075 [fn:82] A date tree is an outline structure with years on the highest
21076 level, months or ISO weeks as sublevels and then dates on the lowest
21077 level.  Tags are allowed in the tree structure.
21079 [fn:83] If you need one of these sequences literally, escape the =%=
21080 with a backslash.
21082 [fn:84] If you define your own link types (see [[*Adding Hyperlink
21083 Types]]), any property you store with ~org-store-link-props~ can be
21084 accessed in capture templates in a similar way.
21086 [fn:85] This is always the other, not the user.  See the variable
21087 ~org-from-is-user-regexp~.
21089 [fn:86] If you move entries or Org files from one directory to
21090 another, you may want to configure ~org-attach-directory~ to contain
21091 an absolute path.
21093 [fn:87] Note the corresponding =STARTUP= options =logrefile=,
21094 =lognoterefile=, and =nologrefile=.
21096 [fn:88] If the value of that variable is not a list, but a single file
21097 name, then the list of agenda files in maintained in that external
21098 file.
21100 [fn:89] When using the dispatcher, pressing {{{kbd(<)}}} before
21101 selecting a command actually limits the command to the current file,
21102 and ignores ~org-agenda-files~ until the next dispatcher command.
21104 [fn:90] For backward compatibility, you can also press {{{kbd(1)}}} to
21105 restrict to the current buffer.
21107 [fn:91] For backward compatibility, you can also press {{{kbd(0)}}} to
21108 restrict to the current region/subtree.
21110 [fn:92] For backward compatibility, the universal prefix
21111 {{{kbd(C-u)}}} causes all TODO entries to be listed before the agenda.
21112 This feature is deprecated, use the dedicated TODO list, or a block
21113 agenda instead (see [[*Block agenda]]).
21115 [fn:93] The variable ~org-anniversary~ used in the example is just
21116 like ~diary-anniversary~, but the argument order is always according
21117 to ISO and therefore independent of the value of
21118 ~calendar-date-style~.
21120 [fn:94] Custom commands can preset a filter by binding the variable
21121 ~org-agenda-tag-filter-preset~ as an option.  This filter is then
21122 applied to the view and persists as a basic filter through refreshes
21123 and more secondary filtering.  The filter is a global property of the
21124 entire agenda view---in a block agenda, you should only set this in
21125 the global options section, not in the section of an individual block.
21127 [fn:95] Only tags filtering is respected here, effort filtering is
21128 ignored.
21130 [fn:96] You can also create persistent custom functions through
21131 ~org-agenda-bulk-custom-functions~.
21133 [fn:97] This file is parsed for the agenda when
21134 ~org-agenda-include-diary~ is set.
21136 [fn:98] You can provide a description for a prefix key by inserting
21137 a cons cell with the prefix and the description.
21139 [fn:99] /Planned/ means here that these entries have some planning
21140 information attached to them, like a time-stamp, a scheduled or
21141 a deadline string.  See ~org-agenda-entry-types~ on how to set what
21142 planning information is taken into account.
21144 [fn:100] For HTML you need to install Hrvoje Niksic's =htmlize.el=
21145 from [[https://github.com/hniksic/emacs-htmlize][Hrvoje Niksic's repository]].
21147 [fn:101] To create PDF output, the Ghostscript ps2pdf utility must be
21148 installed on the system.  Selecting a PDF file also creates the
21149 postscript file.
21151 [fn:102] If you want to store standard views like the weekly agenda or
21152 the global TODO list as well, you need to define custom commands for
21153 them in order to be able to specify file names.
21155 [fn:103] Quoting depends on the system you use, please check the FAQ
21156 for examples.
21158 [fn:104] This works automatically for the HTML backend (it requires
21159 version 1.34 of the =htmlize.el= package, which you need to install).
21160 Fontified code chunks in LaTeX can be achieved using either the
21161 listings package or the [[https://github.com/gpoore/minted][minted]] package.  Refer to
21162 ~org-export-latex-listings~ for details.
21164 [fn:105] Source code in code blocks may also be evaluated either
21165 interactively or on export.  See [[*Working with Source Code]] for more
21166 information on evaluating code blocks.
21168 [fn:106] Adding =-k= to =-n -r= /keeps/ the labels in the source code
21169 while using line numbers for the links, which might be useful to
21170 explain those in an Org mode example code.
21172 [fn:107] Upon exit, lines starting with =*=, =,*=, =#+= and =,#+= get
21173 a comma prepended, to keep them from being interpreted by Org as
21174 outline nodes or special syntax.  These commas are stripped when
21175 editing with {{{kbd(C-c ')}}}, and also before export.
21177 [fn:108] You may select a different-mode with the variable
21178 ~org-edit-fixed-width-region-mode~.
21180 [fn:109] You can turn this on by default by setting the variable
21181 ~org-pretty-entities~, or on a per-file base with the =STARTUP= option
21182 =entitiespretty=.
21184 [fn:110] This behaviour can be disabled with =-= export setting (see
21185 [[*Export Settings]]).
21187 [fn:111] LaTeX is a macro system based on Donald\nbsp{}E.\nbsp{}Knuth's TeX
21188 system.  Many of the features described here as "LaTeX" are really
21189 from TeX, but for simplicity I am blurring this distinction.
21191 [fn:112] When MathJax is used, only the environments recognized by
21192 MathJax are processed.  When dvipng, dvisvgm, or ImageMagick suite is
21193 used to create images, any LaTeX environment is handled.
21195 [fn:113] These are respectively available at
21196 [[http://sourceforge.net/projects/dvipng/]], [[http://dvisvgm.bplaced.net/]]
21197 and from the ImageMagick suite.  Choose the converter by setting the
21198 variable ~org-preview-latex-default-process~ accordingly.
21200 [fn:114] Org mode has a method to test if the cursor is inside such
21201 a fragment, see the documentation of the function
21202 ~org-inside-LaTeX-fragment-p~.
21204 [fn:115] The variable ~org-export-date-timestamp-format~ defines how
21205 this timestamp are exported.
21207 [fn:116] At the moment, some export back-ends do not obey this
21208 specification.  For example, LaTeX export excludes every unnumbered
21209 headline from the table of contents.
21211 [fn:117] Since commas separate the arguments, commas within arguments
21212 have to be escaped with the backslash character.  So only those
21213 backslash characters before a comma need escaping with another
21214 backslash character.
21216 [fn:118] For a less drastic behavior, consider using a select tag (see
21217 [[*Export Settings]]) instead.
21219 [fn:119] If =BEAMER_ENV= is set, Org export adds =B_environment= tag
21220 to make it visible.  The tag serves as a visual aid and has no
21221 semantic relevance.
21223 [fn:120] By default Org loads MathJax from [[https://cdnjs.com][cdnjs.com]] as recommended by
21224 [[http://www.mathjax.org][MathJax]].
21226 [fn:121] 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
21227 about extensions.
21229 [fn:122] If the classes on TODO keywords and tags lead to conflicts,
21230 use the variables ~org-html-todo-kwd-class-prefix~ and
21231 ~org-html-tag-class-prefix~ to make them unique.
21233 [fn:123] This does not allow setting different bibliography compilers
21234 for different files.  However, "smart" LaTeX compilation systems, such
21235 as latexmk, can select the correct bibliography compiler.
21237 [fn:124] See [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][Open Document Format for Office Applications
21238 (OpenDocument) Version 1.2]].
21240 [fn:125] See [[http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl][MathToWeb]].
21242 [fn:126] See [[http://dlmf.nist.gov/LaTeXML/]].
21244 [fn:127] [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][OpenDocument-v1.2 Specification]]
21246 [fn:128] See the =<table:table-template>= element of the
21247 OpenDocument-v1.2 specification.
21249 [fn:129] See the attributes =table:template-name=,
21250 =table:use-first-row-styles=, =table:use-last-row-styles=,
21251 =table:use-first-column-styles=, =table:use-last-column-styles=,
21252 =table:use-banding-rows-styles=, and =table:use-banding-column-styles=
21253 of the =<table:table>= element in the OpenDocument-v1.2 specification.
21255 [fn:130] If the publishing directory is the same as the source
21256 directory, =file.org= is exported as =file.org.org=, so you probably
21257 do not want to do this.
21259 [fn:131] The option ~org-babel-no-eval-on-ctrl-c-ctrl-c~ can be used
21260 to remove code evaluation from the {{{kbd(C-c C-c)}}} key binding.
21262 [fn:132] Actually, the constructs =call_<name>()= and =src_<lang>{}=
21263 are not evaluated when they appear in a keyword line---i.e. lines
21264 starting with =#+KEYWORD:=, see [[*Summary of In-Buffer Settings]].
21266 [fn:133] For Noweb literate programming details, see
21267 http://www.cs.tufts.edu/~nr/noweb/.
21269 [fn:134] For more information, please refer to the commentary section
21270 in =org-tempo.el=.
21272 [fn:135] Note that ~org-indent-mode~ also sets the ~wrap-prefix~
21273 property, such that ~visual-line-mode~ (or purely setting ~word-wrap~)
21274 wraps long lines (including headlines) correctly indented.
21276 [fn:136] The ~org-indent-mode~ also sets the ~wrap-prefix~ correctly
21277 for indenting and wrapping long lines of headlines or text.  This
21278 minor mode handles ~visual-line-mode~ and directly applied settings
21279 through ~word-wrap~.
21281 [fn:137] Also see the variable ~org-adapt-indentation~.
21283 [fn:138] Because =LEVEL=2= has 3 stars, =LEVEL=3= has 4 stars, and so
21286 [fn:139] https://ctan.org/tex-archive/macros/latex/contrib/comment?lang=en
21288 [fn:140] If the =TBLFM= keyword contains an odd number of dollar
21289 characters, this may cause problems with Font Lock in LaTeX mode.  As
21290 shown in the example you can fix this by adding an extra line inside
21291 the =comment= environment that is used to balance the dollar
21292 expressions.  If you are using AUCTeX with the font-latex library,
21293 a much better solution is to add the =comment= environment to the
21294 variable ~LaTeX-verbatim-environments~.
21296 [fn:141] The ~agenda*~ view is the same as ~agenda~ except that it
21297 only considers /appointments/, i.e., scheduled and deadline items that
21298 have a time specification =[h]h:mm= in their time-stamps.
21300 [fn:142] Note that, for ~org-odd-levels-only~, a level number
21301 corresponds to order in the hierarchy, not to the number of stars.
21303 [fn:143] If Emacs is configured for safe storing of passwords, then
21304 configure the variable, ~org-mobile-encryption-password~; please read
21305 the docstring of that variable.
21307 [fn:144] An alternative is to use a WebDAV server.  MobileOrg
21308 documentation has details of WebDAV server configuration.  Additional
21309 help is at this [[https://orgmode.org/worg/org-faq.html#mobileorg_webdav][FAQ entry]].
21311 [fn:145] Symbolic links in ~org-directory~ need to have the same name
21312 as their targets.
21314 [fn:146] While creating the agendas, Org mode forces ID properties on
21315 all referenced entries, so that these entries can be uniquely
21316 identified if MobileOrg flags them for further action.  To avoid
21317 setting properties configure the variable
21318 ~org-mobile-force-id-on-agenda-items~ to ~nil~.  Org mode then relies
21319 on outline paths, assuming they are unique.
21321 [fn:147] Checksums are stored automatically in the file
21322 =checksums.dat=.
21324 [fn:148] The file will be empty after this operation.